1 | function isArray(x) {
|
2 | return Array.isArray(x);
|
3 | }
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | const MATHEMATICA_COLORS = {
|
15 | m0: '#3F3D99',
|
16 | m1: '#993D71',
|
17 | m2: '#998B3D',
|
18 | m3: '#3D9956',
|
19 | m4: '#3D5A99',
|
20 | m5: '#993D90',
|
21 | m6: '#996D3D',
|
22 | m7: '#43993D',
|
23 | m8: '#3D7999',
|
24 | m9: '#843D99',
|
25 | };
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 | const MATLAB_COLORS = {
|
46 | blue: '#0072BD',
|
47 | orange: '#D95319',
|
48 | yellow: '#EDB120',
|
49 | purple: '#7E2F8E',
|
50 | green: '#77AC30',
|
51 | cyan: '#4DBEEE',
|
52 | red: '#A2142F',
|
53 | };
|
54 |
|
55 | const BACKGROUND_COLORS = {
|
56 | 'red': '#fbbbb6',
|
57 | 'orange': '#ffe0c2',
|
58 | 'yellow': '#fff1c2',
|
59 | 'lime': '#d0e8b9',
|
60 | 'green': '#bceac4',
|
61 | 'teal': '#b9f1f1',
|
62 | 'blue': '#b6d9fb',
|
63 | 'indigo': '#d1c2f0',
|
64 | 'purple': '#e3baf8',
|
65 | 'magenta': '#f9c8e0',
|
66 | 'black': '#353535',
|
67 | 'dark-grey': '#8C8C8C',
|
68 | 'grey': '#D0D0D0',
|
69 | 'light-grey': '#F0F0F0',
|
70 | 'white': '#ffffff',
|
71 | };
|
72 |
|
73 | const FOREGROUND_COLORS = {
|
74 | 'red': '#d7170b',
|
75 | 'orange': '#fe8a2b',
|
76 | 'yellow': '#ffc02b',
|
77 | 'lime': '#63b215',
|
78 | 'green': '#21ba3a',
|
79 | 'teal': '#17cfcf',
|
80 | 'blue': '#0d80f2',
|
81 | 'indigo': '#63c',
|
82 | 'purple': '#a219e6',
|
83 | 'magenta': '#eb4799',
|
84 | 'black': '#000',
|
85 | 'dark-grey': '#666',
|
86 | 'grey': '#A6A6A6',
|
87 | 'light-grey': '#d4d5d2',
|
88 | 'white': '#ffffff',
|
89 | };
|
90 |
|
91 | const DVIPS_TO_CHROMATIC = {
|
92 | Red: 'red',
|
93 | Orange: 'orange',
|
94 | Yellow: 'yellow',
|
95 | LimeGreen: 'lime',
|
96 | Green: 'green',
|
97 | TealBlue: 'teal',
|
98 | Blue: 'blue',
|
99 | Violet: 'indigo',
|
100 | Purple: 'purple',
|
101 | Magenta: 'magenta',
|
102 | Black: 'black',
|
103 | Gray: 'grey',
|
104 | White: 'white',
|
105 | };
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 | const DVIPS_COLORS = {
|
120 | Apricot: '#FBB982',
|
121 | Aquamarine: '#00B5BE',
|
122 | Bittersweet: '#C04F17',
|
123 | Black: '#221E1F',
|
124 | Blue: '#2D2F92',
|
125 | BlueGreen: '#00B3B8',
|
126 | BlueViolet: '#473992',
|
127 | BrickRed: '#B6321C',
|
128 | Brown: '#792500',
|
129 | BurntOrange: '#F7921D',
|
130 | CadetBlue: '#74729A',
|
131 | CarnationPink: '#F282B4',
|
132 | Cerulean: '#00A2E3',
|
133 | CornflowerBlue: '#41B0E4',
|
134 | Cyan: '#00AEEF',
|
135 | Dandelion: '#FDBC42',
|
136 | DarkOrchid: '#A4538A',
|
137 | Emerald: '#00A99D',
|
138 | ForestGreen: '#009B55',
|
139 | Fuchsia: '#8C368C',
|
140 | Goldenrod: '#FFDF42',
|
141 | Gray: '#949698',
|
142 | Green: '#00A64F',
|
143 | GreenYellow: '#DFE674',
|
144 | JungleGreen: '#00A99A',
|
145 | Lavender: '#F49EC4',
|
146 | Limegreen: '#8DC73E',
|
147 | Magenta: '#EC008C',
|
148 | Mahogany: '#A9341F',
|
149 | Maroon: '#AF3235',
|
150 | Melon: '#F89E7B',
|
151 | MidnightBlue: '#006795',
|
152 | Mulberry: '#A93C93',
|
153 | NavyBlue: '#006EB8',
|
154 | OliveGreen: '#3C8031',
|
155 | Orange: '#F58137',
|
156 | OrangeRed: '#ED135A',
|
157 | Orchid: '#AF72B0',
|
158 | Peach: '#F7965A',
|
159 | Periwinkle: '#7977B8',
|
160 | PineGreen: '#008B72',
|
161 | Plum: '#92268F',
|
162 | ProcessBlue: '#00B0F0',
|
163 | Purple: '#99479B',
|
164 | RawSienna: '#974006',
|
165 | Red: '#ED1B23',
|
166 | RedOrange: '#F26035',
|
167 | RedViolet: '#A1246B',
|
168 | Rhodamine: '#EF559F',
|
169 | RoyalBlue: '#0071BC',
|
170 | RoyalPurple: '#613F99',
|
171 | RubineRed: '#ED017D',
|
172 | Salmon: '#F69289',
|
173 | SeaGreen: '#3FBC9D',
|
174 | Sepia: '#671800',
|
175 | SkyBlue: '#46C5DD',
|
176 | SpringGreen: '#C6DC67',
|
177 | Tan: '#DA9D76',
|
178 | TealBlue: '#00AEB3',
|
179 | Thistle: '#D883B7',
|
180 | Turquoise: '#00B4CE',
|
181 | Violet: '#58429B',
|
182 | VioletRed: '#EF58A0',
|
183 | White: '#FFFFFF',
|
184 | WildStrawberry: '#EE2967',
|
185 | Yellow: '#FFF200',
|
186 | YellowGreen: '#98CC70',
|
187 | YellowOrange: '#FAA21A',
|
188 | };
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 | function defaultColorMap(s) {
|
366 | var _a, _b, _c, _d, _e, _f;
|
367 | const colorSpec = s.split('!');
|
368 | let baseRed;
|
369 | let baseGreen;
|
370 | let baseBlue;
|
371 | let red = 255;
|
372 | let green = 255;
|
373 | let blue = 255;
|
374 | let mix = -1;
|
375 |
|
376 | const complementary = colorSpec.length > 0 && colorSpec[0].startsWith('-');
|
377 | if (complementary)
|
378 | colorSpec[0] = colorSpec[0].slice(1);
|
379 | for (let i = 0; i < colorSpec.length; i++) {
|
380 | baseRed = red;
|
381 | baseGreen = green;
|
382 | baseBlue = blue;
|
383 | const colorName = (_a = colorSpec[i].trim().match(/^([A-Za-z\d]+)/)) === null || _a === void 0 ? void 0 : _a[1];
|
384 | const lcColorName = colorName === null || colorName === void 0 ? void 0 : colorName.toLowerCase();
|
385 | const color = !colorName
|
386 | ? colorSpec[i].trim()
|
387 | : (_f = (_e = (_d = (_c = (_b = FOREGROUND_COLORS[lcColorName]) !== null && _b !== void 0 ? _b : FOREGROUND_COLORS[DVIPS_TO_CHROMATIC[colorName]]) !== null && _c !== void 0 ? _c : MATLAB_COLORS[colorName]) !== null && _d !== void 0 ? _d : DVIPS_COLORS[colorName]) !== null && _e !== void 0 ? _e : MATHEMATICA_COLORS[colorName]) !== null && _f !== void 0 ? _f : colorSpec[i].trim();
|
388 | let m = color.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i);
|
389 | if ((m === null || m === void 0 ? void 0 : m[1]) && m[2] && m[3]) {
|
390 |
|
391 | red = Math.max(0, Math.min(255, Number.parseInt(m[1], 16)));
|
392 | green = Math.max(0, Math.min(255, Number.parseInt(m[2], 16)));
|
393 | blue = Math.max(0, Math.min(255, Number.parseInt(m[3], 16)));
|
394 | }
|
395 | else {
|
396 | m = color.match(/^#([\da-f]{3})$/i);
|
397 | if (m === null || m === void 0 ? void 0 : m[1]) {
|
398 |
|
399 | const r1 = Number.parseInt(m[1][0], 16);
|
400 | const g1 = Number.parseInt(m[1][1], 16);
|
401 | const b1 = Number.parseInt(m[1][2], 16);
|
402 | red = Math.max(0, Math.min(255, r1 * 16 + r1));
|
403 | green = Math.max(0, Math.min(255, g1 * 16 + g1));
|
404 | blue = Math.max(0, Math.min(255, b1 * 16 + b1));
|
405 | }
|
406 | else {
|
407 |
|
408 | m = color.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i);
|
409 | if ((m === null || m === void 0 ? void 0 : m[1]) && m[2] && m[3]) {
|
410 | red = Math.max(0, Math.min(255, Number.parseInt(m[1])));
|
411 | green = Math.max(0, Math.min(255, Number.parseInt(m[2])));
|
412 | blue = Math.max(0, Math.min(255, Number.parseInt(m[3])));
|
413 | }
|
414 | else {
|
415 | return undefined;
|
416 | }
|
417 | }
|
418 | }
|
419 | if (mix >= 0) {
|
420 | red = (1 - mix) * red + mix * baseRed;
|
421 | green = (1 - mix) * green + mix * baseGreen;
|
422 | blue = (1 - mix) * blue + mix * baseBlue;
|
423 | mix = -1;
|
424 | }
|
425 | if (i + 1 < colorSpec.length) {
|
426 | mix = Math.max(0, Math.min(100, Number.parseInt(colorSpec[++i]))) / 100;
|
427 | }
|
428 | }
|
429 | if (mix >= 0) {
|
430 | red = mix * red + (1 - mix) * baseRed;
|
431 | green = mix * green + (1 - mix) * baseGreen;
|
432 | blue = mix * blue + (1 - mix) * baseBlue;
|
433 | }
|
434 | if (complementary) {
|
435 | red = 255 - red;
|
436 | green = 255 - green;
|
437 | blue = 255 - blue;
|
438 | }
|
439 | return ('#' +
|
440 | ('00' + Math.round(red).toString(16)).slice(-2) +
|
441 | ('00' + Math.round(green).toString(16)).slice(-2) +
|
442 | ('00' + Math.round(blue).toString(16)).slice(-2));
|
443 | }
|
444 | function defaultBackgroundColorMap(s) {
|
445 | var _a, _b;
|
446 | s = s.trim();
|
447 | return ((_b = (_a = BACKGROUND_COLORS[s.toLowerCase()]) !== null && _a !== void 0 ? _a : BACKGROUND_COLORS[DVIPS_TO_CHROMATIC[s]]) !== null && _b !== void 0 ? _b : defaultColorMap(s));
|
448 | }
|
449 | function parseHex(hex) {
|
450 | if (!hex)
|
451 | return undefined;
|
452 | if (hex[0] !== '#')
|
453 | return undefined;
|
454 | hex = hex.slice(1);
|
455 | let result;
|
456 | if (hex.length <= 4) {
|
457 | result = {
|
458 | r: parseInt(hex[0] + hex[0], 16),
|
459 | g: parseInt(hex[1] + hex[1], 16),
|
460 | b: parseInt(hex[2] + hex[2], 16),
|
461 | };
|
462 | if (hex.length === 4) {
|
463 | result.a = parseInt(hex[3] + hex[3], 16) / 255;
|
464 | }
|
465 | }
|
466 | else {
|
467 | result = {
|
468 | r: parseInt(hex[0] + hex[1], 16),
|
469 | g: parseInt(hex[2] + hex[3], 16),
|
470 | b: parseInt(hex[4] + hex[5], 16),
|
471 | };
|
472 | if (hex.length === 8) {
|
473 | result.a = parseInt(hex[6] + hex[7], 16) / 255;
|
474 | }
|
475 | }
|
476 | if (result && result.a === undefined)
|
477 | result.a = 1.0;
|
478 | return result;
|
479 | }
|
480 | function hueToRgbChannel(t1, t2, hue) {
|
481 | if (hue < 0)
|
482 | hue += 6;
|
483 | if (hue >= 6)
|
484 | hue -= 6;
|
485 | if (hue < 1)
|
486 | return (t2 - t1) * hue + t1;
|
487 | else if (hue < 3)
|
488 | return t2;
|
489 | else if (hue < 4)
|
490 | return (t2 - t1) * (4 - hue) + t1;
|
491 | return t1;
|
492 | }
|
493 | function hslToRgb(hsl) {
|
494 | let [hue, sat, light] = [hsl.h, hsl.s, hsl.l];
|
495 | hue = ((hue + 360) % 360) / 60.0;
|
496 | light = Math.max(0, Math.min(light, 1.0));
|
497 | sat = Math.max(0, Math.min(sat, 1.0));
|
498 | const t2 = light <= 0.5 ? light * (sat + 1) : light + sat - light * sat;
|
499 | const t1 = light * 2 - t2;
|
500 | return {
|
501 | r: Math.round(255 * hueToRgbChannel(t1, t2, hue + 2)),
|
502 | g: Math.round(255 * hueToRgbChannel(t1, t2, hue)),
|
503 | b: Math.round(255 * hueToRgbChannel(t1, t2, hue - 2)),
|
504 | };
|
505 | }
|
506 | function clampByte(v) {
|
507 | if (v < 0)
|
508 | return 0;
|
509 | if (v > 255)
|
510 | return 255;
|
511 | return Math.round(v);
|
512 | }
|
513 | function rgbToHexstring(rgb) {
|
514 | const { r, g, b } = rgb;
|
515 | let hexString = ((1 << 24) +
|
516 | (clampByte(r) << 16) +
|
517 | (clampByte(g) << 8) +
|
518 | clampByte(b))
|
519 | .toString(16)
|
520 | .slice(1);
|
521 | if (hexString[0] === hexString[1] &&
|
522 | hexString[2] === hexString[3] &&
|
523 | hexString[4] === hexString[5] &&
|
524 | hexString[6] === hexString[7]) {
|
525 | hexString = hexString[0] + hexString[2] + hexString[4];
|
526 | }
|
527 | return '#' + hexString;
|
528 | }
|
529 | function rgbToHsl(rgb) {
|
530 | let { r, g, b } = rgb;
|
531 | r = r / 255;
|
532 | g = g / 255;
|
533 | b = b / 255;
|
534 | const min = Math.min(r, g, b);
|
535 | const max = Math.max(r, g, b);
|
536 | const delta = max - min;
|
537 | let h;
|
538 | let s;
|
539 | if (max === min) {
|
540 | h = 0;
|
541 | }
|
542 | else if (r === max) {
|
543 | h = (g - b) / delta;
|
544 | }
|
545 | else if (g === max) {
|
546 | h = 2 + (b - r) / delta;
|
547 | }
|
548 | else if (b === max) {
|
549 | h = 4 + (r - g) / delta;
|
550 | }
|
551 | h = Math.min(h * 60, 360);
|
552 | if (h < 0) {
|
553 | h += 360;
|
554 | }
|
555 | const l = (min + max) / 2;
|
556 | if (max === min) {
|
557 | s = 0;
|
558 | }
|
559 | else if (l <= 0.5) {
|
560 | s = delta / (max + min);
|
561 | }
|
562 | else {
|
563 | s = delta / (2 - max - min);
|
564 | }
|
565 | return { h: h, s: s, l: l };
|
566 | }
|
567 | function highlight(color) {
|
568 |
|
569 | let rgb = parseHex(color);
|
570 | if (!rgb)
|
571 | return color;
|
572 |
|
573 | let { h, s, l } = rgbToHsl(rgb);
|
574 | s += 0.1;
|
575 | l -= 0.1;
|
576 | return rgbToHexstring(hslToRgb({ h, s, l }));
|
577 | }
|
578 |
|
579 |
|
580 | const M6 = [0, 0.69444, 0, 0];
|
581 | const M11 = [0, 0.61111, 0, 0];
|
582 | const M15 = [0.25, 0.75, 0, 0];
|
583 | const M7 = [0, 0.44444, 0, 0];
|
584 | const M4 = [0, 0.68611, 0, 0];
|
585 | const M16 = [0.19444, 0.69444, 0, 0];
|
586 | const M9 = [0, 0.68333, 0, 0];
|
587 | const M1 = [0, 0.68889, 0, 0];
|
588 | const M21 = [0, 0.69141, 0, 0];
|
589 | const M0 = [0, 0, 0, 0];
|
590 | const M5 = [0, 0.64444, 0, 0];
|
591 | const M3 = [0, 0.69224, 0, 0];
|
592 | const M8 = [0.19444, 0.44444, 0, 0];
|
593 | const M19 = [0.65002, 1.15, 0, 0];
|
594 | const M20 = [0, 0.55556, 0, 0];
|
595 | const M10 = [0.35001, 0.85, 0, 0];
|
596 | const M12 = [1.25003, 1.75, 0, 0];
|
597 | const M13 = [0.95003, 1.45, 0, 0];
|
598 | const M14 = [0, 0.75, 0, 0];
|
599 | const M22 = [0, 0.47534, 0, 0];
|
600 | const M17 = [0.25001, 0.75, 0, 0];
|
601 | const M18 = [0.55001, 1.05, 0, 0];
|
602 | const M2 = [0.16667, 0.68889, 0, 0];
|
603 | const M23 = [0.08167, 0.58167, 0, 0];
|
604 | var CHARACTER_METRICS_MAP = {
|
605 | 'AMS-Regular': {
|
606 | '32': M0,
|
607 | '65': M1,
|
608 | '66': M1,
|
609 | '67': M1,
|
610 | '68': M1,
|
611 | '69': M1,
|
612 | '70': M1,
|
613 | '71': M1,
|
614 | '72': M1,
|
615 | '73': M1,
|
616 | '74': M2,
|
617 | '75': M1,
|
618 | '76': M1,
|
619 | '77': M1,
|
620 | '78': M1,
|
621 | '79': M2,
|
622 | '80': M1,
|
623 | '81': M2,
|
624 | '82': M1,
|
625 | '83': M1,
|
626 | '84': M1,
|
627 | '85': M1,
|
628 | '86': M1,
|
629 | '87': M1,
|
630 | '88': M1,
|
631 | '89': M1,
|
632 | '90': M1,
|
633 | '107': M1,
|
634 | '160': M0,
|
635 | '165': [0, 0.675, 0.025, 0],
|
636 | '174': [0.15559, 0.69224, 0, 0],
|
637 | '240': M1,
|
638 | '295': M1,
|
639 | '710': [0, 0.825, 0, 0],
|
640 | '732': [0, 0.9, 0, 0],
|
641 | '770': [0, 0.825, 0, 0],
|
642 | '771': [0, 0.9, 0, 0],
|
643 | '989': M23,
|
644 | '1008': [0, 0.43056, 0.04028, 0],
|
645 | '8245': [0, 0.54986, 0, 0],
|
646 | '8463': M1,
|
647 | '8487': M1,
|
648 | '8498': M1,
|
649 | '8502': M1,
|
650 | '8503': M1,
|
651 | '8504': M1,
|
652 | '8513': M1,
|
653 | '8592': [-0.03598, 0.46402, 0, 0],
|
654 | '8594': [-0.03598, 0.46402, 0, 0],
|
655 | '8602': [-0.13313, 0.36687, 0, 0],
|
656 | '8603': [-0.13313, 0.36687, 0, 0],
|
657 | '8606': [0.01354, 0.52239, 0, 0],
|
658 | '8608': [0.01354, 0.52239, 0, 0],
|
659 | '8610': [0.01354, 0.52239, 0, 0],
|
660 | '8611': [0.01354, 0.52239, 0, 0],
|
661 | '8619': [0, 0.54986, 0, 0],
|
662 | '8620': [0, 0.54986, 0, 0],
|
663 | '8621': [-0.13313, 0.37788, 0, 0],
|
664 | '8622': [-0.13313, 0.36687, 0, 0],
|
665 | '8624': M3,
|
666 | '8625': M3,
|
667 | '8630': [0, 0.43056, 0, 0],
|
668 | '8631': [0, 0.43056, 0, 0],
|
669 | '8634': [0.08198, 0.58198, 0, 0],
|
670 | '8635': [0.08198, 0.58198, 0, 0],
|
671 | '8638': [0.19444, 0.69224, 0, 0],
|
672 | '8639': [0.19444, 0.69224, 0, 0],
|
673 | '8642': [0.19444, 0.69224, 0, 0],
|
674 | '8643': [0.19444, 0.69224, 0, 0],
|
675 | '8644': [0.1808, 0.675, 0, 0],
|
676 | '8646': [0.1808, 0.675, 0, 0],
|
677 | '8647': [0.1808, 0.675, 0, 0],
|
678 | '8648': [0.19444, 0.69224, 0, 0],
|
679 | '8649': [0.1808, 0.675, 0, 0],
|
680 | '8650': [0.19444, 0.69224, 0, 0],
|
681 | '8651': [0.01354, 0.52239, 0, 0],
|
682 | '8652': [0.01354, 0.52239, 0, 0],
|
683 | '8653': [-0.13313, 0.36687, 0, 0],
|
684 | '8654': [-0.13313, 0.36687, 0, 0],
|
685 | '8655': [-0.13313, 0.36687, 0, 0],
|
686 | '8666': [0.13667, 0.63667, 0, 0],
|
687 | '8667': [0.13667, 0.63667, 0, 0],
|
688 | '8669': [-0.13313, 0.37788, 0, 0],
|
689 | '8672': [-0.064, 0.437, 0, 0],
|
690 | '8674': [-0.064, 0.437, 0, 0],
|
691 | '8705': [0, 0.825, 0, 0],
|
692 | '8708': M1,
|
693 | '8709': M23,
|
694 | '8717': [0, 0.43056, 0, 0],
|
695 | '8722': [-0.03598, 0.46402, 0, 0],
|
696 | '8724': [0.08198, 0.69224, 0, 0],
|
697 | '8726': M23,
|
698 | '8733': M3,
|
699 | '8736': M3,
|
700 | '8737': M3,
|
701 | '8738': [0.03517, 0.52239, 0, 0],
|
702 | '8739': M23,
|
703 | '8740': [0.25142, 0.74111, 0, 0],
|
704 | '8741': M23,
|
705 | '8742': [0.25142, 0.74111, 0, 0],
|
706 | '8756': M3,
|
707 | '8757': M3,
|
708 | '8764': [-0.13313, 0.36687, 0, 0],
|
709 | '8765': [-0.13313, 0.37788, 0, 0],
|
710 | '8769': [-0.13313, 0.36687, 0, 0],
|
711 | '8770': [-0.03625, 0.46375, 0, 0],
|
712 | '8774': [0.30274, 0.79383, 0, 0],
|
713 | '8776': [-0.01688, 0.48312, 0, 0],
|
714 | '8778': M23,
|
715 | '8782': [0.06062, 0.54986, 0, 0],
|
716 | '8783': [0.06062, 0.54986, 0, 0],
|
717 | '8785': [0.08198, 0.58198, 0, 0],
|
718 | '8786': [0.08198, 0.58198, 0, 0],
|
719 | '8787': [0.08198, 0.58198, 0, 0],
|
720 | '8790': M3,
|
721 | '8791': [0.22958, 0.72958, 0, 0],
|
722 | '8796': [0.08198, 0.91667, 0, 0],
|
723 | '8806': [0.25583, 0.75583, 0, 0],
|
724 | '8807': [0.25583, 0.75583, 0, 0],
|
725 | '8808': [0.25142, 0.75726, 0, 0],
|
726 | '8809': [0.25142, 0.75726, 0, 0],
|
727 | '8812': [0.25583, 0.75583, 0, 0],
|
728 | '8814': [0.20576, 0.70576, 0, 0],
|
729 | '8815': [0.20576, 0.70576, 0, 0],
|
730 | '8816': [0.30274, 0.79383, 0, 0],
|
731 | '8817': [0.30274, 0.79383, 0, 0],
|
732 | '8818': [0.22958, 0.72958, 0, 0],
|
733 | '8819': [0.22958, 0.72958, 0, 0],
|
734 | '8822': [0.1808, 0.675, 0, 0],
|
735 | '8823': [0.1808, 0.675, 0, 0],
|
736 | '8828': [0.13667, 0.63667, 0, 0],
|
737 | '8829': [0.13667, 0.63667, 0, 0],
|
738 | '8830': [0.22958, 0.72958, 0, 0],
|
739 | '8831': [0.22958, 0.72958, 0, 0],
|
740 | '8832': [0.20576, 0.70576, 0, 0],
|
741 | '8833': [0.20576, 0.70576, 0, 0],
|
742 | '8840': [0.30274, 0.79383, 0, 0],
|
743 | '8841': [0.30274, 0.79383, 0, 0],
|
744 | '8842': [0.13597, 0.63597, 0, 0],
|
745 | '8843': [0.13597, 0.63597, 0, 0],
|
746 | '8847': [0.03517, 0.54986, 0, 0],
|
747 | '8848': [0.03517, 0.54986, 0, 0],
|
748 | '8858': [0.08198, 0.58198, 0, 0],
|
749 | '8859': [0.08198, 0.58198, 0, 0],
|
750 | '8861': [0.08198, 0.58198, 0, 0],
|
751 | '8862': [0, 0.675, 0, 0],
|
752 | '8863': [0, 0.675, 0, 0],
|
753 | '8864': [0, 0.675, 0, 0],
|
754 | '8865': [0, 0.675, 0, 0],
|
755 | '8872': M3,
|
756 | '8873': M3,
|
757 | '8874': M3,
|
758 | '8876': M1,
|
759 | '8877': M1,
|
760 | '8878': M1,
|
761 | '8879': M1,
|
762 | '8882': [0.03517, 0.54986, 0, 0],
|
763 | '8883': [0.03517, 0.54986, 0, 0],
|
764 | '8884': [0.13667, 0.63667, 0, 0],
|
765 | '8885': [0.13667, 0.63667, 0, 0],
|
766 | '8888': [0, 0.54986, 0, 0],
|
767 | '8890': [0.19444, 0.43056, 0, 0],
|
768 | '8891': [0.19444, 0.69224, 0, 0],
|
769 | '8892': [0.19444, 0.69224, 0, 0],
|
770 | '8901': [0, 0.54986, 0, 0],
|
771 | '8903': M23,
|
772 | '8905': M23,
|
773 | '8906': M23,
|
774 | '8907': M3,
|
775 | '8908': M3,
|
776 | '8909': [-0.03598, 0.46402, 0, 0],
|
777 | '8910': [0, 0.54986, 0, 0],
|
778 | '8911': [0, 0.54986, 0, 0],
|
779 | '8912': [0.03517, 0.54986, 0, 0],
|
780 | '8913': [0.03517, 0.54986, 0, 0],
|
781 | '8914': [0, 0.54986, 0, 0],
|
782 | '8915': [0, 0.54986, 0, 0],
|
783 | '8916': M3,
|
784 | '8918': [0.0391, 0.5391, 0, 0],
|
785 | '8919': [0.0391, 0.5391, 0, 0],
|
786 | '8920': [0.03517, 0.54986, 0, 0],
|
787 | '8921': [0.03517, 0.54986, 0, 0],
|
788 | '8922': [0.38569, 0.88569, 0, 0],
|
789 | '8923': [0.38569, 0.88569, 0, 0],
|
790 | '8926': [0.13667, 0.63667, 0, 0],
|
791 | '8927': [0.13667, 0.63667, 0, 0],
|
792 | '8928': [0.30274, 0.79383, 0, 0],
|
793 | '8929': [0.30274, 0.79383, 0, 0],
|
794 | '8934': [0.23222, 0.74111, 0, 0],
|
795 | '8935': [0.23222, 0.74111, 0, 0],
|
796 | '8936': [0.23222, 0.74111, 0, 0],
|
797 | '8937': [0.23222, 0.74111, 0, 0],
|
798 | '8938': [0.20576, 0.70576, 0, 0],
|
799 | '8939': [0.20576, 0.70576, 0, 0],
|
800 | '8940': [0.30274, 0.79383, 0, 0],
|
801 | '8941': [0.30274, 0.79383, 0, 0],
|
802 | '8994': [0.19444, 0.69224, 0, 0],
|
803 | '8995': [0.19444, 0.69224, 0, 0],
|
804 | '9416': [0.15559, 0.69224, 0, 0],
|
805 | '9484': M3,
|
806 | '9488': M3,
|
807 | '9492': [0, 0.37788, 0, 0],
|
808 | '9496': [0, 0.37788, 0, 0],
|
809 | '9585': [0.19444, 0.68889, 0, 0],
|
810 | '9586': [0.19444, 0.74111, 0, 0],
|
811 | '9632': [0, 0.675, 0, 0],
|
812 | '9633': [0, 0.675, 0, 0],
|
813 | '9650': [0, 0.54986, 0, 0],
|
814 | '9651': [0, 0.54986, 0, 0],
|
815 | '9654': [0.03517, 0.54986, 0, 0],
|
816 | '9660': [0, 0.54986, 0, 0],
|
817 | '9661': [0, 0.54986, 0, 0],
|
818 | '9664': [0.03517, 0.54986, 0, 0],
|
819 | '9674': [0.11111, 0.69224, 0, 0],
|
820 | '9733': [0.19444, 0.69224, 0, 0],
|
821 | '10003': M3,
|
822 | '10016': M3,
|
823 | '10731': [0.11111, 0.69224, 0, 0],
|
824 | '10846': [0.19444, 0.75583, 0, 0],
|
825 | '10877': [0.13667, 0.63667, 0, 0],
|
826 | '10878': [0.13667, 0.63667, 0, 0],
|
827 | '10885': [0.25583, 0.75583, 0, 0],
|
828 | '10886': [0.25583, 0.75583, 0, 0],
|
829 | '10887': [0.13597, 0.63597, 0, 0],
|
830 | '10888': [0.13597, 0.63597, 0, 0],
|
831 | '10889': [0.26167, 0.75726, 0, 0],
|
832 | '10890': [0.26167, 0.75726, 0, 0],
|
833 | '10891': [0.48256, 0.98256, 0, 0],
|
834 | '10892': [0.48256, 0.98256, 0, 0],
|
835 | '10901': [0.13667, 0.63667, 0, 0],
|
836 | '10902': [0.13667, 0.63667, 0, 0],
|
837 | '10933': [0.25142, 0.75726, 0, 0],
|
838 | '10934': [0.25142, 0.75726, 0, 0],
|
839 | '10935': [0.26167, 0.75726, 0, 0],
|
840 | '10936': [0.26167, 0.75726, 0, 0],
|
841 | '10937': [0.26167, 0.75726, 0, 0],
|
842 | '10938': [0.26167, 0.75726, 0, 0],
|
843 | '10949': [0.25583, 0.75583, 0, 0],
|
844 | '10950': [0.25583, 0.75583, 0, 0],
|
845 | '10955': [0.28481, 0.79383, 0, 0],
|
846 | '10956': [0.28481, 0.79383, 0, 0],
|
847 | '57350': M23,
|
848 | '57351': M23,
|
849 | '57352': M23,
|
850 | '57353': [0, 0.43056, 0.04028, 0],
|
851 | '57356': [0.25142, 0.75726, 0, 0],
|
852 | '57357': [0.25142, 0.75726, 0, 0],
|
853 | '57358': [0.41951, 0.91951, 0, 0],
|
854 | '57359': [0.30274, 0.79383, 0, 0],
|
855 | '57360': [0.30274, 0.79383, 0, 0],
|
856 | '57361': [0.41951, 0.91951, 0, 0],
|
857 | '57366': [0.25142, 0.75726, 0, 0],
|
858 | '57367': [0.25142, 0.75726, 0, 0],
|
859 | '57368': [0.25142, 0.75726, 0, 0],
|
860 | '57369': [0.25142, 0.75726, 0, 0],
|
861 | '57370': [0.13597, 0.63597, 0, 0],
|
862 | '57371': [0.13597, 0.63597, 0, 0],
|
863 | },
|
864 | 'Caligraphic-Regular': {
|
865 | '32': M0,
|
866 | '65': [0, 0.68333, 0, 0.19445],
|
867 | '66': [0, 0.68333, 0.03041, 0.13889],
|
868 | '67': [0, 0.68333, 0.05834, 0.13889],
|
869 | '68': [0, 0.68333, 0.02778, 0.08334],
|
870 | '69': [0, 0.68333, 0.08944, 0.11111],
|
871 | '70': [0, 0.68333, 0.09931, 0.11111],
|
872 | '71': [0.09722, 0.68333, 0.0593, 0.11111],
|
873 | '72': [0, 0.68333, 0.00965, 0.11111],
|
874 | '73': [0, 0.68333, 0.07382, 0],
|
875 | '74': [0.09722, 0.68333, 0.18472, 0.16667],
|
876 | '75': [0, 0.68333, 0.01445, 0.05556],
|
877 | '76': [0, 0.68333, 0, 0.13889],
|
878 | '77': [0, 0.68333, 0, 0.13889],
|
879 | '78': [0, 0.68333, 0.14736, 0.08334],
|
880 | '79': [0, 0.68333, 0.02778, 0.11111],
|
881 | '80': [0, 0.68333, 0.08222, 0.08334],
|
882 | '81': [0.09722, 0.68333, 0, 0.11111],
|
883 | '82': [0, 0.68333, 0, 0.08334],
|
884 | '83': [0, 0.68333, 0.075, 0.13889],
|
885 | '84': [0, 0.68333, 0.25417, 0],
|
886 | '85': [0, 0.68333, 0.09931, 0.08334],
|
887 | '86': [0, 0.68333, 0.08222, 0],
|
888 | '87': [0, 0.68333, 0.08222, 0.08334],
|
889 | '88': [0, 0.68333, 0.14643, 0.13889],
|
890 | '89': [0.09722, 0.68333, 0.08222, 0.08334],
|
891 | '90': [0, 0.68333, 0.07944, 0.13889],
|
892 | '160': M0,
|
893 | },
|
894 | 'Fraktur-Regular': {
|
895 | '32': M0,
|
896 | '33': M21,
|
897 | '34': M21,
|
898 | '38': M21,
|
899 | '39': M21,
|
900 | '40': [0.24982, 0.74947, 0, 0],
|
901 | '41': [0.24982, 0.74947, 0, 0],
|
902 | '42': [0, 0.62119, 0, 0],
|
903 | '43': [0.08319, 0.58283, 0, 0],
|
904 | '44': [0, 0.10803, 0, 0],
|
905 | '45': [0.08319, 0.58283, 0, 0],
|
906 | '46': [0, 0.10803, 0, 0],
|
907 | '47': [0.24982, 0.74947, 0, 0],
|
908 | '48': M22,
|
909 | '49': M22,
|
910 | '50': M22,
|
911 | '51': [0.18906, 0.47534, 0, 0],
|
912 | '52': [0.18906, 0.47534, 0, 0],
|
913 | '53': [0.18906, 0.47534, 0, 0],
|
914 | '54': M21,
|
915 | '55': [0.18906, 0.47534, 0, 0],
|
916 | '56': M21,
|
917 | '57': [0.18906, 0.47534, 0, 0],
|
918 | '58': M22,
|
919 | '59': [0.12604, 0.47534, 0, 0],
|
920 | '61': [-0.13099, 0.36866, 0, 0],
|
921 | '63': M21,
|
922 | '65': M21,
|
923 | '66': M21,
|
924 | '67': M21,
|
925 | '68': M21,
|
926 | '69': M21,
|
927 | '70': [0.12604, 0.69141, 0, 0],
|
928 | '71': M21,
|
929 | '72': [0.06302, 0.69141, 0, 0],
|
930 | '73': M21,
|
931 | '74': [0.12604, 0.69141, 0, 0],
|
932 | '75': M21,
|
933 | '76': M21,
|
934 | '77': M21,
|
935 | '78': M21,
|
936 | '79': M21,
|
937 | '80': [0.18906, 0.69141, 0, 0],
|
938 | '81': [0.03781, 0.69141, 0, 0],
|
939 | '82': M21,
|
940 | '83': M21,
|
941 | '84': M21,
|
942 | '85': M21,
|
943 | '86': M21,
|
944 | '87': M21,
|
945 | '88': M21,
|
946 | '89': [0.18906, 0.69141, 0, 0],
|
947 | '90': [0.12604, 0.69141, 0, 0],
|
948 | '91': [0.24982, 0.74947, 0, 0],
|
949 | '93': [0.24982, 0.74947, 0, 0],
|
950 | '94': M21,
|
951 | '97': M22,
|
952 | '98': M21,
|
953 | '99': M22,
|
954 | '100': [0, 0.62119, 0, 0],
|
955 | '101': M22,
|
956 | '102': [0.18906, 0.69141, 0, 0],
|
957 | '103': [0.18906, 0.47534, 0, 0],
|
958 | '104': [0.18906, 0.69141, 0, 0],
|
959 | '105': M21,
|
960 | '106': M21,
|
961 | '107': M21,
|
962 | '108': M21,
|
963 | '109': M22,
|
964 | '110': M22,
|
965 | '111': M22,
|
966 | '112': [0.18906, 0.52396, 0, 0],
|
967 | '113': [0.18906, 0.47534, 0, 0],
|
968 | '114': M22,
|
969 | '115': M22,
|
970 | '116': [0, 0.62119, 0, 0],
|
971 | '117': M22,
|
972 | '118': [0, 0.52396, 0, 0],
|
973 | '119': [0, 0.52396, 0, 0],
|
974 | '120': [0.18906, 0.47534, 0, 0],
|
975 | '121': [0.18906, 0.47534, 0, 0],
|
976 | '122': [0.18906, 0.47534, 0, 0],
|
977 | '160': M0,
|
978 | '8216': M21,
|
979 | '8217': M21,
|
980 | '58112': [0, 0.62119, 0, 0],
|
981 | '58113': [0, 0.62119, 0, 0],
|
982 | '58114': [0.18906, 0.69141, 0, 0],
|
983 | '58115': [0.18906, 0.69141, 0, 0],
|
984 | '58116': [0.18906, 0.47534, 0, 0],
|
985 | '58117': M21,
|
986 | '58118': [0, 0.62119, 0, 0],
|
987 | '58119': M22,
|
988 | },
|
989 | 'Main-Bold': {
|
990 | '32': M0,
|
991 | '33': M6,
|
992 | '34': M6,
|
993 | '35': M16,
|
994 | '36': [0.05556, 0.75, 0, 0],
|
995 | '37': [0.05556, 0.75, 0, 0],
|
996 | '38': M6,
|
997 | '39': M6,
|
998 | '40': M15,
|
999 | '41': M15,
|
1000 | '42': M14,
|
1001 | '43': [0.13333, 0.63333, 0, 0],
|
1002 | '44': [0.19444, 0.15556, 0, 0],
|
1003 | '45': M7,
|
1004 | '46': [0, 0.15556, 0, 0],
|
1005 | '47': M15,
|
1006 | '48': M5,
|
1007 | '49': M5,
|
1008 | '50': M5,
|
1009 | '51': M5,
|
1010 | '52': M5,
|
1011 | '53': M5,
|
1012 | '54': M5,
|
1013 | '55': M5,
|
1014 | '56': M5,
|
1015 | '57': M5,
|
1016 | '58': M7,
|
1017 | '59': M8,
|
1018 | '60': [0.08556, 0.58556, 0, 0],
|
1019 | '61': [-0.10889, 0.39111, 0, 0],
|
1020 | '62': [0.08556, 0.58556, 0, 0],
|
1021 | '63': M6,
|
1022 | '64': M6,
|
1023 | '65': M4,
|
1024 | '66': M4,
|
1025 | '67': M4,
|
1026 | '68': M4,
|
1027 | '69': M4,
|
1028 | '70': M4,
|
1029 | '71': M4,
|
1030 | '72': M4,
|
1031 | '73': M4,
|
1032 | '74': M4,
|
1033 | '75': M4,
|
1034 | '76': M4,
|
1035 | '77': M4,
|
1036 | '78': M4,
|
1037 | '79': M4,
|
1038 | '80': M4,
|
1039 | '81': [0.19444, 0.68611, 0, 0],
|
1040 | '82': M4,
|
1041 | '83': M4,
|
1042 | '84': M4,
|
1043 | '85': M4,
|
1044 | '86': [0, 0.68611, 0.01597, 0],
|
1045 | '87': [0, 0.68611, 0.01597, 0],
|
1046 | '88': M4,
|
1047 | '89': [0, 0.68611, 0.02875, 0],
|
1048 | '90': M4,
|
1049 | '91': M15,
|
1050 | '92': M15,
|
1051 | '93': M15,
|
1052 | '94': M6,
|
1053 | '95': [0.31, 0.13444, 0.03194, 0],
|
1054 | '97': M7,
|
1055 | '98': M6,
|
1056 | '99': M7,
|
1057 | '100': M6,
|
1058 | '101': M7,
|
1059 | '102': [0, 0.69444, 0.10903, 0],
|
1060 | '103': [0.19444, 0.44444, 0.01597, 0],
|
1061 | '104': M6,
|
1062 | '105': M6,
|
1063 | '106': M16,
|
1064 | '107': M6,
|
1065 | '108': M6,
|
1066 | '109': M7,
|
1067 | '110': M7,
|
1068 | '111': M7,
|
1069 | '112': M8,
|
1070 | '113': M8,
|
1071 | '114': M7,
|
1072 | '115': M7,
|
1073 | '116': [0, 0.63492, 0, 0],
|
1074 | '117': M7,
|
1075 | '118': [0, 0.44444, 0.01597, 0],
|
1076 | '119': [0, 0.44444, 0.01597, 0],
|
1077 | '120': M7,
|
1078 | '121': [0.19444, 0.44444, 0.01597, 0],
|
1079 | '122': M7,
|
1080 | '123': M15,
|
1081 | '124': M15,
|
1082 | '125': M15,
|
1083 | '126': [0.35, 0.34444, 0, 0],
|
1084 | '160': M0,
|
1085 | '163': M6,
|
1086 | '168': M6,
|
1087 | '172': M7,
|
1088 | '176': M6,
|
1089 | '177': [0.13333, 0.63333, 0, 0],
|
1090 | '184': [0.17014, 0, 0, 0],
|
1091 | '198': M4,
|
1092 | '215': [0.13333, 0.63333, 0, 0],
|
1093 | '216': [0.04861, 0.73472, 0, 0],
|
1094 | '223': M6,
|
1095 | '230': M7,
|
1096 | '247': [0.13333, 0.63333, 0, 0],
|
1097 | '248': [0.09722, 0.54167, 0, 0],
|
1098 | '305': M7,
|
1099 | '338': M4,
|
1100 | '339': M7,
|
1101 | '567': M8,
|
1102 | '710': M6,
|
1103 | '711': [0, 0.63194, 0, 0],
|
1104 | '713': [0, 0.59611, 0, 0],
|
1105 | '714': M6,
|
1106 | '715': M6,
|
1107 | '728': M6,
|
1108 | '729': M6,
|
1109 | '730': M6,
|
1110 | '732': M6,
|
1111 | '733': M6,
|
1112 | '915': M4,
|
1113 | '916': M4,
|
1114 | '920': M4,
|
1115 | '923': M4,
|
1116 | '926': M4,
|
1117 | '928': M4,
|
1118 | '931': M4,
|
1119 | '933': M4,
|
1120 | '934': M4,
|
1121 | '936': M4,
|
1122 | '937': M4,
|
1123 | '8211': [0, 0.44444, 0.03194, 0],
|
1124 | '8212': [0, 0.44444, 0.03194, 0],
|
1125 | '8216': M6,
|
1126 | '8217': M6,
|
1127 | '8220': M6,
|
1128 | '8221': M6,
|
1129 | '8224': M16,
|
1130 | '8225': M16,
|
1131 | '8242': M20,
|
1132 | '8407': [0, 0.72444, 0.15486, 0],
|
1133 | '8463': M6,
|
1134 | '8465': M6,
|
1135 | '8467': M6,
|
1136 | '8472': M8,
|
1137 | '8476': M6,
|
1138 | '8501': M6,
|
1139 | '8592': [-0.10889, 0.39111, 0, 0],
|
1140 | '8593': M16,
|
1141 | '8594': [-0.10889, 0.39111, 0, 0],
|
1142 | '8595': M16,
|
1143 | '8596': [-0.10889, 0.39111, 0, 0],
|
1144 | '8597': M15,
|
1145 | '8598': M16,
|
1146 | '8599': M16,
|
1147 | '8600': M16,
|
1148 | '8601': M16,
|
1149 | '8636': [-0.10889, 0.39111, 0, 0],
|
1150 | '8637': [-0.10889, 0.39111, 0, 0],
|
1151 | '8640': [-0.10889, 0.39111, 0, 0],
|
1152 | '8641': [-0.10889, 0.39111, 0, 0],
|
1153 | '8656': [-0.10889, 0.39111, 0, 0],
|
1154 | '8657': M16,
|
1155 | '8658': [-0.10889, 0.39111, 0, 0],
|
1156 | '8659': M16,
|
1157 | '8660': [-0.10889, 0.39111, 0, 0],
|
1158 | '8661': M15,
|
1159 | '8704': M6,
|
1160 | '8706': [0, 0.69444, 0.06389, 0],
|
1161 | '8707': M6,
|
1162 | '8709': [0.05556, 0.75, 0, 0],
|
1163 | '8711': M4,
|
1164 | '8712': [0.08556, 0.58556, 0, 0],
|
1165 | '8715': [0.08556, 0.58556, 0, 0],
|
1166 | '8722': [0.13333, 0.63333, 0, 0],
|
1167 | '8723': [0.13333, 0.63333, 0, 0],
|
1168 | '8725': M15,
|
1169 | '8726': M15,
|
1170 | '8727': [-0.02778, 0.47222, 0, 0],
|
1171 | '8728': [-0.02639, 0.47361, 0, 0],
|
1172 | '8729': [-0.02639, 0.47361, 0, 0],
|
1173 | '8730': [0.18, 0.82, 0, 0],
|
1174 | '8733': M7,
|
1175 | '8734': M7,
|
1176 | '8736': M3,
|
1177 | '8739': M15,
|
1178 | '8741': M15,
|
1179 | '8743': M20,
|
1180 | '8744': M20,
|
1181 | '8745': M20,
|
1182 | '8746': M20,
|
1183 | '8747': [0.19444, 0.69444, 0.12778, 0],
|
1184 | '8764': [-0.10889, 0.39111, 0, 0],
|
1185 | '8768': M16,
|
1186 | '8771': [0.00222, 0.50222, 0, 0],
|
1187 | '8776': [0.02444, 0.52444, 0, 0],
|
1188 | '8781': [0.00222, 0.50222, 0, 0],
|
1189 | '8801': [0.00222, 0.50222, 0, 0],
|
1190 | '8804': [0.19667, 0.69667, 0, 0],
|
1191 | '8805': [0.19667, 0.69667, 0, 0],
|
1192 | '8810': [0.08556, 0.58556, 0, 0],
|
1193 | '8811': [0.08556, 0.58556, 0, 0],
|
1194 | '8826': [0.08556, 0.58556, 0, 0],
|
1195 | '8827': [0.08556, 0.58556, 0, 0],
|
1196 | '8834': [0.08556, 0.58556, 0, 0],
|
1197 | '8835': [0.08556, 0.58556, 0, 0],
|
1198 | '8838': [0.19667, 0.69667, 0, 0],
|
1199 | '8839': [0.19667, 0.69667, 0, 0],
|
1200 | '8846': M20,
|
1201 | '8849': [0.19667, 0.69667, 0, 0],
|
1202 | '8850': [0.19667, 0.69667, 0, 0],
|
1203 | '8851': M20,
|
1204 | '8852': M20,
|
1205 | '8853': [0.13333, 0.63333, 0, 0],
|
1206 | '8854': [0.13333, 0.63333, 0, 0],
|
1207 | '8855': [0.13333, 0.63333, 0, 0],
|
1208 | '8856': [0.13333, 0.63333, 0, 0],
|
1209 | '8857': [0.13333, 0.63333, 0, 0],
|
1210 | '8866': M6,
|
1211 | '8867': M6,
|
1212 | '8868': M6,
|
1213 | '8869': M6,
|
1214 | '8900': [-0.02639, 0.47361, 0, 0],
|
1215 | '8901': [-0.02639, 0.47361, 0, 0],
|
1216 | '8902': [-0.02778, 0.47222, 0, 0],
|
1217 | '8968': M15,
|
1218 | '8969': M15,
|
1219 | '8970': M15,
|
1220 | '8971': M15,
|
1221 | '8994': [-0.13889, 0.36111, 0, 0],
|
1222 | '8995': [-0.13889, 0.36111, 0, 0],
|
1223 | '9651': M16,
|
1224 | '9657': [-0.02778, 0.47222, 0, 0],
|
1225 | '9661': M16,
|
1226 | '9667': [-0.02778, 0.47222, 0, 0],
|
1227 | '9711': M16,
|
1228 | '9824': [0.12963, 0.69444, 0, 0],
|
1229 | '9825': [0.12963, 0.69444, 0, 0],
|
1230 | '9826': [0.12963, 0.69444, 0, 0],
|
1231 | '9827': [0.12963, 0.69444, 0, 0],
|
1232 | '9837': M14,
|
1233 | '9838': M16,
|
1234 | '9839': M16,
|
1235 | '10216': M15,
|
1236 | '10217': M15,
|
1237 | '10815': M4,
|
1238 | '10927': [0.19667, 0.69667, 0, 0],
|
1239 | '10928': [0.19667, 0.69667, 0, 0],
|
1240 | '57376': M16,
|
1241 | },
|
1242 | 'Main-BoldItalic': {
|
1243 | '32': M0,
|
1244 | '33': [0, 0.69444, 0.11417, 0],
|
1245 | '34': [0, 0.69444, 0.07939, 0],
|
1246 | '35': [0.19444, 0.69444, 0.06833, 0],
|
1247 | '37': [0.05556, 0.75, 0.12861, 0],
|
1248 | '38': [0, 0.69444, 0.08528, 0],
|
1249 | '39': [0, 0.69444, 0.12945, 0],
|
1250 | '40': [0.25, 0.75, 0.15806, 0],
|
1251 | '41': [0.25, 0.75, 0.03306, 0],
|
1252 | '42': [0, 0.75, 0.14333, 0],
|
1253 | '43': [0.10333, 0.60333, 0.03306, 0],
|
1254 | '44': [0.19444, 0.14722, 0, 0],
|
1255 | '45': [0, 0.44444, 0.02611, 0],
|
1256 | '46': [0, 0.14722, 0, 0],
|
1257 | '47': [0.25, 0.75, 0.15806, 0],
|
1258 | '48': [0, 0.64444, 0.13167, 0],
|
1259 | '49': [0, 0.64444, 0.13167, 0],
|
1260 | '50': [0, 0.64444, 0.13167, 0],
|
1261 | '51': [0, 0.64444, 0.13167, 0],
|
1262 | '52': [0.19444, 0.64444, 0.13167, 0],
|
1263 | '53': [0, 0.64444, 0.13167, 0],
|
1264 | '54': [0, 0.64444, 0.13167, 0],
|
1265 | '55': [0.19444, 0.64444, 0.13167, 0],
|
1266 | '56': [0, 0.64444, 0.13167, 0],
|
1267 | '57': [0, 0.64444, 0.13167, 0],
|
1268 | '58': [0, 0.44444, 0.06695, 0],
|
1269 | '59': [0.19444, 0.44444, 0.06695, 0],
|
1270 | '61': [-0.10889, 0.39111, 0.06833, 0],
|
1271 | '63': [0, 0.69444, 0.11472, 0],
|
1272 | '64': [0, 0.69444, 0.09208, 0],
|
1273 | '65': M4,
|
1274 | '66': [0, 0.68611, 0.0992, 0],
|
1275 | '67': [0, 0.68611, 0.14208, 0],
|
1276 | '68': [0, 0.68611, 0.09062, 0],
|
1277 | '69': [0, 0.68611, 0.11431, 0],
|
1278 | '70': [0, 0.68611, 0.12903, 0],
|
1279 | '71': [0, 0.68611, 0.07347, 0],
|
1280 | '72': [0, 0.68611, 0.17208, 0],
|
1281 | '73': [0, 0.68611, 0.15681, 0],
|
1282 | '74': [0, 0.68611, 0.145, 0],
|
1283 | '75': [0, 0.68611, 0.14208, 0],
|
1284 | '76': M4,
|
1285 | '77': [0, 0.68611, 0.17208, 0],
|
1286 | '78': [0, 0.68611, 0.17208, 0],
|
1287 | '79': [0, 0.68611, 0.09062, 0],
|
1288 | '80': [0, 0.68611, 0.0992, 0],
|
1289 | '81': [0.19444, 0.68611, 0.09062, 0],
|
1290 | '82': [0, 0.68611, 0.02559, 0],
|
1291 | '83': [0, 0.68611, 0.11264, 0],
|
1292 | '84': [0, 0.68611, 0.12903, 0],
|
1293 | '85': [0, 0.68611, 0.17208, 0],
|
1294 | '86': [0, 0.68611, 0.18625, 0],
|
1295 | '87': [0, 0.68611, 0.18625, 0],
|
1296 | '88': [0, 0.68611, 0.15681, 0],
|
1297 | '89': [0, 0.68611, 0.19803, 0],
|
1298 | '90': [0, 0.68611, 0.14208, 0],
|
1299 | '91': [0.25, 0.75, 0.1875, 0],
|
1300 | '93': [0.25, 0.75, 0.09972, 0],
|
1301 | '94': [0, 0.69444, 0.06709, 0],
|
1302 | '95': [0.31, 0.13444, 0.09811, 0],
|
1303 | '97': [0, 0.44444, 0.09426, 0],
|
1304 | '98': [0, 0.69444, 0.07861, 0],
|
1305 | '99': [0, 0.44444, 0.05222, 0],
|
1306 | '100': [0, 0.69444, 0.10861, 0],
|
1307 | '101': [0, 0.44444, 0.085, 0],
|
1308 | '102': [0.19444, 0.69444, 0.21778, 0],
|
1309 | '103': [0.19444, 0.44444, 0.105, 0],
|
1310 | '104': [0, 0.69444, 0.09426, 0],
|
1311 | '105': [0, 0.69326, 0.11387, 0],
|
1312 | '106': [0.19444, 0.69326, 0.1672, 0],
|
1313 | '107': [0, 0.69444, 0.11111, 0],
|
1314 | '108': [0, 0.69444, 0.10861, 0],
|
1315 | '109': [0, 0.44444, 0.09426, 0],
|
1316 | '110': [0, 0.44444, 0.09426, 0],
|
1317 | '111': [0, 0.44444, 0.07861, 0],
|
1318 | '112': [0.19444, 0.44444, 0.07861, 0],
|
1319 | '113': [0.19444, 0.44444, 0.105, 0],
|
1320 | '114': [0, 0.44444, 0.11111, 0],
|
1321 | '115': [0, 0.44444, 0.08167, 0],
|
1322 | '116': [0, 0.63492, 0.09639, 0],
|
1323 | '117': [0, 0.44444, 0.09426, 0],
|
1324 | '118': [0, 0.44444, 0.11111, 0],
|
1325 | '119': [0, 0.44444, 0.11111, 0],
|
1326 | '120': [0, 0.44444, 0.12583, 0],
|
1327 | '121': [0.19444, 0.44444, 0.105, 0],
|
1328 | '122': [0, 0.44444, 0.13889, 0],
|
1329 | '126': [0.35, 0.34444, 0.11472, 0],
|
1330 | '160': M0,
|
1331 | '168': [0, 0.69444, 0.11473, 0],
|
1332 | '176': M6,
|
1333 | '184': [0.17014, 0, 0, 0],
|
1334 | '198': [0, 0.68611, 0.11431, 0],
|
1335 | '216': [0.04861, 0.73472, 0.09062, 0],
|
1336 | '223': [0.19444, 0.69444, 0.09736, 0],
|
1337 | '230': [0, 0.44444, 0.085, 0],
|
1338 | '248': [0.09722, 0.54167, 0.09458, 0],
|
1339 | '305': [0, 0.44444, 0.09426, 0],
|
1340 | '338': [0, 0.68611, 0.11431, 0],
|
1341 | '339': [0, 0.44444, 0.085, 0],
|
1342 | '567': [0.19444, 0.44444, 0.04611, 0],
|
1343 | '710': [0, 0.69444, 0.06709, 0],
|
1344 | '711': [0, 0.63194, 0.08271, 0],
|
1345 | '713': [0, 0.59444, 0.10444, 0],
|
1346 | '714': [0, 0.69444, 0.08528, 0],
|
1347 | '715': M6,
|
1348 | '728': [0, 0.69444, 0.10333, 0],
|
1349 | '729': [0, 0.69444, 0.12945, 0],
|
1350 | '730': M6,
|
1351 | '732': [0, 0.69444, 0.11472, 0],
|
1352 | '733': [0, 0.69444, 0.11472, 0],
|
1353 | '915': [0, 0.68611, 0.12903, 0],
|
1354 | '916': M4,
|
1355 | '920': [0, 0.68611, 0.09062, 0],
|
1356 | '923': M4,
|
1357 | '926': [0, 0.68611, 0.15092, 0],
|
1358 | '928': [0, 0.68611, 0.17208, 0],
|
1359 | '931': [0, 0.68611, 0.11431, 0],
|
1360 | '933': [0, 0.68611, 0.10778, 0],
|
1361 | '934': [0, 0.68611, 0.05632, 0],
|
1362 | '936': [0, 0.68611, 0.10778, 0],
|
1363 | '937': [0, 0.68611, 0.0992, 0],
|
1364 | '8211': [0, 0.44444, 0.09811, 0],
|
1365 | '8212': [0, 0.44444, 0.09811, 0],
|
1366 | '8216': [0, 0.69444, 0.12945, 0],
|
1367 | '8217': [0, 0.69444, 0.12945, 0],
|
1368 | '8220': [0, 0.69444, 0.16772, 0],
|
1369 | '8221': [0, 0.69444, 0.07939, 0],
|
1370 | },
|
1371 | 'Main-Italic': {
|
1372 | '32': M0,
|
1373 | '33': [0, 0.69444, 0.12417, 0],
|
1374 | '34': [0, 0.69444, 0.06961, 0],
|
1375 | '35': [0.19444, 0.69444, 0.06616, 0],
|
1376 | '37': [0.05556, 0.75, 0.13639, 0],
|
1377 | '38': [0, 0.69444, 0.09694, 0],
|
1378 | '39': [0, 0.69444, 0.12417, 0],
|
1379 | '40': [0.25, 0.75, 0.16194, 0],
|
1380 | '41': [0.25, 0.75, 0.03694, 0],
|
1381 | '42': [0, 0.75, 0.14917, 0],
|
1382 | '43': [0.05667, 0.56167, 0.03694, 0],
|
1383 | '44': [0.19444, 0.10556, 0, 0],
|
1384 | '45': [0, 0.43056, 0.02826, 0],
|
1385 | '46': [0, 0.10556, 0, 0],
|
1386 | '47': [0.25, 0.75, 0.16194, 0],
|
1387 | '48': [0, 0.64444, 0.13556, 0],
|
1388 | '49': [0, 0.64444, 0.13556, 0],
|
1389 | '50': [0, 0.64444, 0.13556, 0],
|
1390 | '51': [0, 0.64444, 0.13556, 0],
|
1391 | '52': [0.19444, 0.64444, 0.13556, 0],
|
1392 | '53': [0, 0.64444, 0.13556, 0],
|
1393 | '54': [0, 0.64444, 0.13556, 0],
|
1394 | '55': [0.19444, 0.64444, 0.13556, 0],
|
1395 | '56': [0, 0.64444, 0.13556, 0],
|
1396 | '57': [0, 0.64444, 0.13556, 0],
|
1397 | '58': [0, 0.43056, 0.0582, 0],
|
1398 | '59': [0.19444, 0.43056, 0.0582, 0],
|
1399 | '61': [-0.13313, 0.36687, 0.06616, 0],
|
1400 | '63': [0, 0.69444, 0.1225, 0],
|
1401 | '64': [0, 0.69444, 0.09597, 0],
|
1402 | '65': M9,
|
1403 | '66': [0, 0.68333, 0.10257, 0],
|
1404 | '67': [0, 0.68333, 0.14528, 0],
|
1405 | '68': [0, 0.68333, 0.09403, 0],
|
1406 | '69': [0, 0.68333, 0.12028, 0],
|
1407 | '70': [0, 0.68333, 0.13305, 0],
|
1408 | '71': [0, 0.68333, 0.08722, 0],
|
1409 | '72': [0, 0.68333, 0.16389, 0],
|
1410 | '73': [0, 0.68333, 0.15806, 0],
|
1411 | '74': [0, 0.68333, 0.14028, 0],
|
1412 | '75': [0, 0.68333, 0.14528, 0],
|
1413 | '76': M9,
|
1414 | '77': [0, 0.68333, 0.16389, 0],
|
1415 | '78': [0, 0.68333, 0.16389, 0],
|
1416 | '79': [0, 0.68333, 0.09403, 0],
|
1417 | '80': [0, 0.68333, 0.10257, 0],
|
1418 | '81': [0.19444, 0.68333, 0.09403, 0],
|
1419 | '82': [0, 0.68333, 0.03868, 0],
|
1420 | '83': [0, 0.68333, 0.11972, 0],
|
1421 | '84': [0, 0.68333, 0.13305, 0],
|
1422 | '85': [0, 0.68333, 0.16389, 0],
|
1423 | '86': [0, 0.68333, 0.18361, 0],
|
1424 | '87': [0, 0.68333, 0.18361, 0],
|
1425 | '88': [0, 0.68333, 0.15806, 0],
|
1426 | '89': [0, 0.68333, 0.19383, 0],
|
1427 | '90': [0, 0.68333, 0.14528, 0],
|
1428 | '91': [0.25, 0.75, 0.1875, 0],
|
1429 | '93': [0.25, 0.75, 0.10528, 0],
|
1430 | '94': [0, 0.69444, 0.06646, 0],
|
1431 | '95': [0.31, 0.12056, 0.09208, 0],
|
1432 | '97': [0, 0.43056, 0.07671, 0],
|
1433 | '98': [0, 0.69444, 0.06312, 0],
|
1434 | '99': [0, 0.43056, 0.05653, 0],
|
1435 | '100': [0, 0.69444, 0.10333, 0],
|
1436 | '101': [0, 0.43056, 0.07514, 0],
|
1437 | '102': [0.19444, 0.69444, 0.21194, 0],
|
1438 | '103': [0.19444, 0.43056, 0.08847, 0],
|
1439 | '104': [0, 0.69444, 0.07671, 0],
|
1440 | '105': [0, 0.65536, 0.1019, 0],
|
1441 | '106': [0.19444, 0.65536, 0.14467, 0],
|
1442 | '107': [0, 0.69444, 0.10764, 0],
|
1443 | '108': [0, 0.69444, 0.10333, 0],
|
1444 | '109': [0, 0.43056, 0.07671, 0],
|
1445 | '110': [0, 0.43056, 0.07671, 0],
|
1446 | '111': [0, 0.43056, 0.06312, 0],
|
1447 | '112': [0.19444, 0.43056, 0.06312, 0],
|
1448 | '113': [0.19444, 0.43056, 0.08847, 0],
|
1449 | '114': [0, 0.43056, 0.10764, 0],
|
1450 | '115': [0, 0.43056, 0.08208, 0],
|
1451 | '116': [0, 0.61508, 0.09486, 0],
|
1452 | '117': [0, 0.43056, 0.07671, 0],
|
1453 | '118': [0, 0.43056, 0.10764, 0],
|
1454 | '119': [0, 0.43056, 0.10764, 0],
|
1455 | '120': [0, 0.43056, 0.12042, 0],
|
1456 | '121': [0.19444, 0.43056, 0.08847, 0],
|
1457 | '122': [0, 0.43056, 0.12292, 0],
|
1458 | '126': [0.35, 0.31786, 0.11585, 0],
|
1459 | '160': M0,
|
1460 | '168': [0, 0.66786, 0.10474, 0],
|
1461 | '176': M6,
|
1462 | '184': [0.17014, 0, 0, 0],
|
1463 | '198': [0, 0.68333, 0.12028, 0],
|
1464 | '216': [0.04861, 0.73194, 0.09403, 0],
|
1465 | '223': [0.19444, 0.69444, 0.10514, 0],
|
1466 | '230': [0, 0.43056, 0.07514, 0],
|
1467 | '248': [0.09722, 0.52778, 0.09194, 0],
|
1468 | '338': [0, 0.68333, 0.12028, 0],
|
1469 | '339': [0, 0.43056, 0.07514, 0],
|
1470 | '710': [0, 0.69444, 0.06646, 0],
|
1471 | '711': [0, 0.62847, 0.08295, 0],
|
1472 | '713': [0, 0.56167, 0.10333, 0],
|
1473 | '714': [0, 0.69444, 0.09694, 0],
|
1474 | '715': M6,
|
1475 | '728': [0, 0.69444, 0.10806, 0],
|
1476 | '729': [0, 0.66786, 0.11752, 0],
|
1477 | '730': M6,
|
1478 | '732': [0, 0.66786, 0.11585, 0],
|
1479 | '733': [0, 0.69444, 0.1225, 0],
|
1480 | '915': [0, 0.68333, 0.13305, 0],
|
1481 | '916': M9,
|
1482 | '920': [0, 0.68333, 0.09403, 0],
|
1483 | '923': M9,
|
1484 | '926': [0, 0.68333, 0.15294, 0],
|
1485 | '928': [0, 0.68333, 0.16389, 0],
|
1486 | '931': [0, 0.68333, 0.12028, 0],
|
1487 | '933': [0, 0.68333, 0.11111, 0],
|
1488 | '934': [0, 0.68333, 0.05986, 0],
|
1489 | '936': [0, 0.68333, 0.11111, 0],
|
1490 | '937': [0, 0.68333, 0.10257, 0],
|
1491 | '8211': [0, 0.43056, 0.09208, 0],
|
1492 | '8212': [0, 0.43056, 0.09208, 0],
|
1493 | '8216': [0, 0.69444, 0.12417, 0],
|
1494 | '8217': [0, 0.69444, 0.12417, 0],
|
1495 | '8220': [0, 0.69444, 0.1685, 0],
|
1496 | '8221': [0, 0.69444, 0.06961, 0],
|
1497 | '8463': M1,
|
1498 | },
|
1499 | 'Main-Regular': {
|
1500 | '32': M0,
|
1501 | '33': M6,
|
1502 | '34': M6,
|
1503 | '35': M16,
|
1504 | '36': [0.05556, 0.75, 0, 0],
|
1505 | '37': [0.05556, 0.75, 0, 0],
|
1506 | '38': M6,
|
1507 | '39': M6,
|
1508 | '40': M15,
|
1509 | '41': M15,
|
1510 | '42': M14,
|
1511 | '43': [0.08333, 0.58333, 0, 0],
|
1512 | '44': [0.19444, 0.10556, 0, 0],
|
1513 | '45': [0, 0.43056, 0, 0],
|
1514 | '46': [0, 0.10556, 0, 0],
|
1515 | '47': M15,
|
1516 | '48': M5,
|
1517 | '49': M5,
|
1518 | '50': M5,
|
1519 | '51': M5,
|
1520 | '52': M5,
|
1521 | '53': M5,
|
1522 | '54': M5,
|
1523 | '55': M5,
|
1524 | '56': M5,
|
1525 | '57': M5,
|
1526 | '58': [0, 0.43056, 0, 0],
|
1527 | '59': [0.19444, 0.43056, 0, 0],
|
1528 | '60': [0.0391, 0.5391, 0, 0],
|
1529 | '61': [-0.13313, 0.36687, 0, 0],
|
1530 | '62': [0.0391, 0.5391, 0, 0],
|
1531 | '63': M6,
|
1532 | '64': M6,
|
1533 | '65': M9,
|
1534 | '66': M9,
|
1535 | '67': M9,
|
1536 | '68': M9,
|
1537 | '69': M9,
|
1538 | '70': M9,
|
1539 | '71': M9,
|
1540 | '72': M9,
|
1541 | '73': M9,
|
1542 | '74': M9,
|
1543 | '75': M9,
|
1544 | '76': M9,
|
1545 | '77': M9,
|
1546 | '78': M9,
|
1547 | '79': M9,
|
1548 | '80': M9,
|
1549 | '81': [0.19444, 0.68333, 0, 0],
|
1550 | '82': M9,
|
1551 | '83': M9,
|
1552 | '84': M9,
|
1553 | '85': M9,
|
1554 | '86': [0, 0.68333, 0.01389, 0],
|
1555 | '87': [0, 0.68333, 0.01389, 0],
|
1556 | '88': M9,
|
1557 | '89': [0, 0.68333, 0.025, 0],
|
1558 | '90': M9,
|
1559 | '91': M15,
|
1560 | '92': M15,
|
1561 | '93': M15,
|
1562 | '94': M6,
|
1563 | '95': [0.31, 0.12056, 0.02778, 0],
|
1564 | '97': [0, 0.43056, 0, 0],
|
1565 | '98': M6,
|
1566 | '99': [0, 0.43056, 0, 0],
|
1567 | '100': M6,
|
1568 | '101': [0, 0.43056, 0, 0],
|
1569 | '102': [0, 0.69444, 0.07778, 0],
|
1570 | '103': [0.19444, 0.43056, 0.01389, 0],
|
1571 | '104': M6,
|
1572 | '105': [0, 0.66786, 0, 0],
|
1573 | '106': [0.19444, 0.66786, 0, 0],
|
1574 | '107': M6,
|
1575 | '108': M6,
|
1576 | '109': [0, 0.43056, 0, 0],
|
1577 | '110': [0, 0.43056, 0, 0],
|
1578 | '111': [0, 0.43056, 0, 0],
|
1579 | '112': [0.19444, 0.43056, 0, 0],
|
1580 | '113': [0.19444, 0.43056, 0, 0],
|
1581 | '114': [0, 0.43056, 0, 0],
|
1582 | '115': [0, 0.43056, 0, 0],
|
1583 | '116': [0, 0.61508, 0, 0],
|
1584 | '117': [0, 0.43056, 0, 0],
|
1585 | '118': [0, 0.43056, 0.01389, 0],
|
1586 | '119': [0, 0.43056, 0.01389, 0],
|
1587 | '120': [0, 0.43056, 0, 0],
|
1588 | '121': [0.19444, 0.43056, 0.01389, 0],
|
1589 | '122': [0, 0.43056, 0, 0],
|
1590 | '123': M15,
|
1591 | '124': M15,
|
1592 | '125': M15,
|
1593 | '126': [0.35, 0.31786, 0, 0],
|
1594 | '160': M0,
|
1595 | '163': M6,
|
1596 | '167': M16,
|
1597 | '168': [0, 0.66786, 0, 0],
|
1598 | '172': [0, 0.43056, 0, 0],
|
1599 | '176': M6,
|
1600 | '177': [0.08333, 0.58333, 0, 0],
|
1601 | '182': M16,
|
1602 | '184': [0.17014, 0, 0, 0],
|
1603 | '198': M9,
|
1604 | '215': [0.08333, 0.58333, 0, 0],
|
1605 | '216': [0.04861, 0.73194, 0, 0],
|
1606 | '223': M6,
|
1607 | '230': [0, 0.43056, 0, 0],
|
1608 | '247': [0.08333, 0.58333, 0, 0],
|
1609 | '248': [0.09722, 0.52778, 0, 0],
|
1610 | '305': [0, 0.43056, 0, 0],
|
1611 | '338': M9,
|
1612 | '339': [0, 0.43056, 0, 0],
|
1613 | '567': [0.19444, 0.43056, 0, 0],
|
1614 | '710': M6,
|
1615 | '711': [0, 0.62847, 0, 0],
|
1616 | '713': [0, 0.56778, 0, 0],
|
1617 | '714': M6,
|
1618 | '715': M6,
|
1619 | '728': M6,
|
1620 | '729': [0, 0.66786, 0, 0],
|
1621 | '730': M6,
|
1622 | '732': [0, 0.66786, 0, 0],
|
1623 | '733': M6,
|
1624 | '915': M9,
|
1625 | '916': M9,
|
1626 | '920': M9,
|
1627 | '923': M9,
|
1628 | '926': M9,
|
1629 | '928': M9,
|
1630 | '931': M9,
|
1631 | '933': M9,
|
1632 | '934': M9,
|
1633 | '936': M9,
|
1634 | '937': M9,
|
1635 | '8211': [0, 0.43056, 0.02778, 0],
|
1636 | '8212': [0, 0.43056, 0.02778, 0],
|
1637 | '8216': M6,
|
1638 | '8217': M6,
|
1639 | '8220': M6,
|
1640 | '8221': M6,
|
1641 | '8224': M16,
|
1642 | '8225': M16,
|
1643 | '8230': [0, 0.12, 0, 0],
|
1644 | '8242': M20,
|
1645 | '8407': [0, 0.71444, 0.15382, 0],
|
1646 | '8463': M1,
|
1647 | '8465': M6,
|
1648 | '8467': [0, 0.69444, 0, 0.11111],
|
1649 | '8472': [0.19444, 0.43056, 0, 0.11111],
|
1650 | '8476': M6,
|
1651 | '8501': M6,
|
1652 | '8592': [-0.13313, 0.36687, 0, 0],
|
1653 | '8593': M16,
|
1654 | '8594': [-0.13313, 0.36687, 0, 0],
|
1655 | '8595': M16,
|
1656 | '8596': [-0.13313, 0.36687, 0, 0],
|
1657 | '8597': M15,
|
1658 | '8598': M16,
|
1659 | '8599': M16,
|
1660 | '8600': M16,
|
1661 | '8601': M16,
|
1662 | '8614': [0.011, 0.511, 0, 0],
|
1663 | '8617': [0.011, 0.511, 0, 0],
|
1664 | '8618': [0.011, 0.511, 0, 0],
|
1665 | '8636': [-0.13313, 0.36687, 0, 0],
|
1666 | '8637': [-0.13313, 0.36687, 0, 0],
|
1667 | '8640': [-0.13313, 0.36687, 0, 0],
|
1668 | '8641': [-0.13313, 0.36687, 0, 0],
|
1669 | '8652': [0.011, 0.671, 0, 0],
|
1670 | '8656': [-0.13313, 0.36687, 0, 0],
|
1671 | '8657': M16,
|
1672 | '8658': [-0.13313, 0.36687, 0, 0],
|
1673 | '8659': M16,
|
1674 | '8660': [-0.13313, 0.36687, 0, 0],
|
1675 | '8661': M15,
|
1676 | '8704': M6,
|
1677 | '8706': [0, 0.69444, 0.05556, 0.08334],
|
1678 | '8707': M6,
|
1679 | '8709': [0.05556, 0.75, 0, 0],
|
1680 | '8711': M9,
|
1681 | '8712': [0.0391, 0.5391, 0, 0],
|
1682 | '8715': [0.0391, 0.5391, 0, 0],
|
1683 | '8722': [0.08333, 0.58333, 0, 0],
|
1684 | '8723': [0.08333, 0.58333, 0, 0],
|
1685 | '8725': M15,
|
1686 | '8726': M15,
|
1687 | '8727': [-0.03472, 0.46528, 0, 0],
|
1688 | '8728': [-0.05555, 0.44445, 0, 0],
|
1689 | '8729': [-0.05555, 0.44445, 0, 0],
|
1690 | '8730': [0.2, 0.8, 0, 0],
|
1691 | '8733': [0, 0.43056, 0, 0],
|
1692 | '8734': [0, 0.43056, 0, 0],
|
1693 | '8736': M3,
|
1694 | '8739': M15,
|
1695 | '8741': M15,
|
1696 | '8743': M20,
|
1697 | '8744': M20,
|
1698 | '8745': M20,
|
1699 | '8746': M20,
|
1700 | '8747': [0.19444, 0.69444, 0.11111, 0],
|
1701 | '8764': [-0.13313, 0.36687, 0, 0],
|
1702 | '8768': M16,
|
1703 | '8771': [-0.03625, 0.46375, 0, 0],
|
1704 | '8773': [-0.022, 0.589, 0, 0],
|
1705 | '8776': [-0.01688, 0.48312, 0, 0],
|
1706 | '8781': [-0.03625, 0.46375, 0, 0],
|
1707 | '8784': [-0.133, 0.67, 0, 0],
|
1708 | '8801': [-0.03625, 0.46375, 0, 0],
|
1709 | '8804': [0.13597, 0.63597, 0, 0],
|
1710 | '8805': [0.13597, 0.63597, 0, 0],
|
1711 | '8810': [0.0391, 0.5391, 0, 0],
|
1712 | '8811': [0.0391, 0.5391, 0, 0],
|
1713 | '8826': [0.0391, 0.5391, 0, 0],
|
1714 | '8827': [0.0391, 0.5391, 0, 0],
|
1715 | '8834': [0.0391, 0.5391, 0, 0],
|
1716 | '8835': [0.0391, 0.5391, 0, 0],
|
1717 | '8838': [0.13597, 0.63597, 0, 0],
|
1718 | '8839': [0.13597, 0.63597, 0, 0],
|
1719 | '8846': M20,
|
1720 | '8849': [0.13597, 0.63597, 0, 0],
|
1721 | '8850': [0.13597, 0.63597, 0, 0],
|
1722 | '8851': M20,
|
1723 | '8852': M20,
|
1724 | '8853': [0.08333, 0.58333, 0, 0],
|
1725 | '8854': [0.08333, 0.58333, 0, 0],
|
1726 | '8855': [0.08333, 0.58333, 0, 0],
|
1727 | '8856': [0.08333, 0.58333, 0, 0],
|
1728 | '8857': [0.08333, 0.58333, 0, 0],
|
1729 | '8866': M6,
|
1730 | '8867': M6,
|
1731 | '8868': M6,
|
1732 | '8869': M6,
|
1733 | '8872': [0.249, 0.75, 0, 0],
|
1734 | '8900': [-0.05555, 0.44445, 0, 0],
|
1735 | '8901': [-0.05555, 0.44445, 0, 0],
|
1736 | '8902': [-0.03472, 0.46528, 0, 0],
|
1737 | '8904': [0.005, 0.505, 0, 0],
|
1738 | '8942': [0.03, 0.9, 0, 0],
|
1739 | '8943': [-0.19, 0.31, 0, 0],
|
1740 | '8945': [-0.1, 0.82, 0, 0],
|
1741 | '8968': M15,
|
1742 | '8969': M15,
|
1743 | '8970': M15,
|
1744 | '8971': M15,
|
1745 | '8994': [-0.14236, 0.35764, 0, 0],
|
1746 | '8995': [-0.14236, 0.35764, 0, 0],
|
1747 | '9136': [0.244, 0.744, 0, 0],
|
1748 | '9137': [0.244, 0.744, 0, 0],
|
1749 | '9651': M16,
|
1750 | '9657': [-0.03472, 0.46528, 0, 0],
|
1751 | '9661': M16,
|
1752 | '9667': [-0.03472, 0.46528, 0, 0],
|
1753 | '9711': M16,
|
1754 | '9824': [0.12963, 0.69444, 0, 0],
|
1755 | '9825': [0.12963, 0.69444, 0, 0],
|
1756 | '9826': [0.12963, 0.69444, 0, 0],
|
1757 | '9827': [0.12963, 0.69444, 0, 0],
|
1758 | '9837': M14,
|
1759 | '9838': M16,
|
1760 | '9839': M16,
|
1761 | '10216': M15,
|
1762 | '10217': M15,
|
1763 | '10222': [0.244, 0.744, 0, 0],
|
1764 | '10223': [0.244, 0.744, 0, 0],
|
1765 | '10229': [0.011, 0.511, 0, 0],
|
1766 | '10230': [0.011, 0.511, 0, 0],
|
1767 | '10231': [0.011, 0.511, 0, 0],
|
1768 | '10232': [0.024, 0.525, 0, 0],
|
1769 | '10233': [0.024, 0.525, 0, 0],
|
1770 | '10234': [0.024, 0.525, 0, 0],
|
1771 | '10236': [0.011, 0.511, 0, 0],
|
1772 | '10815': M9,
|
1773 | '10927': [0.13597, 0.63597, 0, 0],
|
1774 | '10928': [0.13597, 0.63597, 0, 0],
|
1775 | '57376': M16,
|
1776 | },
|
1777 | 'Math-BoldItalic': {
|
1778 | '32': M0,
|
1779 | '48': M7,
|
1780 | '49': M7,
|
1781 | '50': M7,
|
1782 | '51': M8,
|
1783 | '52': M8,
|
1784 | '53': M8,
|
1785 | '54': M5,
|
1786 | '55': M8,
|
1787 | '56': M5,
|
1788 | '57': M8,
|
1789 | '65': M4,
|
1790 | '66': [0, 0.68611, 0.04835, 0],
|
1791 | '67': [0, 0.68611, 0.06979, 0],
|
1792 | '68': [0, 0.68611, 0.03194, 0],
|
1793 | '69': [0, 0.68611, 0.05451, 0],
|
1794 | '70': [0, 0.68611, 0.15972, 0],
|
1795 | '71': M4,
|
1796 | '72': [0, 0.68611, 0.08229, 0],
|
1797 | '73': [0, 0.68611, 0.07778, 0],
|
1798 | '74': [0, 0.68611, 0.10069, 0],
|
1799 | '75': [0, 0.68611, 0.06979, 0],
|
1800 | '76': M4,
|
1801 | '77': [0, 0.68611, 0.11424, 0],
|
1802 | '78': [0, 0.68611, 0.11424, 0],
|
1803 | '79': [0, 0.68611, 0.03194, 0],
|
1804 | '80': [0, 0.68611, 0.15972, 0],
|
1805 | '81': [0.19444, 0.68611, 0, 0],
|
1806 | '82': [0, 0.68611, 0.00421, 0],
|
1807 | '83': [0, 0.68611, 0.05382, 0],
|
1808 | '84': [0, 0.68611, 0.15972, 0],
|
1809 | '85': [0, 0.68611, 0.11424, 0],
|
1810 | '86': [0, 0.68611, 0.25555, 0],
|
1811 | '87': [0, 0.68611, 0.15972, 0],
|
1812 | '88': [0, 0.68611, 0.07778, 0],
|
1813 | '89': [0, 0.68611, 0.25555, 0],
|
1814 | '90': [0, 0.68611, 0.06979, 0],
|
1815 | '97': M7,
|
1816 | '98': M6,
|
1817 | '99': M7,
|
1818 | '100': M6,
|
1819 | '101': M7,
|
1820 | '102': [0.19444, 0.69444, 0.11042, 0],
|
1821 | '103': [0.19444, 0.44444, 0.03704, 0],
|
1822 | '104': M6,
|
1823 | '105': [0, 0.69326, 0, 0],
|
1824 | '106': [0.19444, 0.69326, 0.0622, 0],
|
1825 | '107': [0, 0.69444, 0.01852, 0],
|
1826 | '108': [0, 0.69444, 0.0088, 0],
|
1827 | '109': M7,
|
1828 | '110': M7,
|
1829 | '111': M7,
|
1830 | '112': M8,
|
1831 | '113': [0.19444, 0.44444, 0.03704, 0],
|
1832 | '114': [0, 0.44444, 0.03194, 0],
|
1833 | '115': M7,
|
1834 | '116': [0, 0.63492, 0, 0],
|
1835 | '117': M7,
|
1836 | '118': [0, 0.44444, 0.03704, 0],
|
1837 | '119': [0, 0.44444, 0.02778, 0],
|
1838 | '120': M7,
|
1839 | '121': [0.19444, 0.44444, 0.03704, 0],
|
1840 | '122': [0, 0.44444, 0.04213, 0],
|
1841 | '160': M0,
|
1842 | '915': [0, 0.68611, 0.15972, 0],
|
1843 | '916': M4,
|
1844 | '920': [0, 0.68611, 0.03194, 0],
|
1845 | '923': M4,
|
1846 | '926': [0, 0.68611, 0.07458, 0],
|
1847 | '928': [0, 0.68611, 0.08229, 0],
|
1848 | '931': [0, 0.68611, 0.05451, 0],
|
1849 | '933': [0, 0.68611, 0.15972, 0],
|
1850 | '934': M4,
|
1851 | '936': [0, 0.68611, 0.11653, 0],
|
1852 | '937': [0, 0.68611, 0.04835, 0],
|
1853 | '945': M7,
|
1854 | '946': [0.19444, 0.69444, 0.03403, 0],
|
1855 | '947': [0.19444, 0.44444, 0.06389, 0],
|
1856 | '948': [0, 0.69444, 0.03819, 0],
|
1857 | '949': M7,
|
1858 | '950': [0.19444, 0.69444, 0.06215, 0],
|
1859 | '951': [0.19444, 0.44444, 0.03704, 0],
|
1860 | '952': [0, 0.69444, 0.03194, 0],
|
1861 | '953': M7,
|
1862 | '954': M7,
|
1863 | '955': M6,
|
1864 | '956': M8,
|
1865 | '957': [0, 0.44444, 0.06898, 0],
|
1866 | '958': [0.19444, 0.69444, 0.03021, 0],
|
1867 | '959': M7,
|
1868 | '960': [0, 0.44444, 0.03704, 0],
|
1869 | '961': M8,
|
1870 | '962': [0.09722, 0.44444, 0.07917, 0],
|
1871 | '963': [0, 0.44444, 0.03704, 0],
|
1872 | '964': [0, 0.44444, 0.13472, 0],
|
1873 | '965': [0, 0.44444, 0.03704, 0],
|
1874 | '966': M8,
|
1875 | '967': M8,
|
1876 | '968': [0.19444, 0.69444, 0.03704, 0],
|
1877 | '969': [0, 0.44444, 0.03704, 0],
|
1878 | '977': M6,
|
1879 | '981': M16,
|
1880 | '982': [0, 0.44444, 0.03194, 0],
|
1881 | '1009': M8,
|
1882 | '1013': M7,
|
1883 | '57649': M7,
|
1884 | '57911': M8,
|
1885 | },
|
1886 | 'Math-Italic': {
|
1887 | '32': M0,
|
1888 | '48': [0, 0.43056, 0, 0],
|
1889 | '49': [0, 0.43056, 0, 0],
|
1890 | '50': [0, 0.43056, 0, 0],
|
1891 | '51': [0.19444, 0.43056, 0, 0],
|
1892 | '52': [0.19444, 0.43056, 0, 0],
|
1893 | '53': [0.19444, 0.43056, 0, 0],
|
1894 | '54': M5,
|
1895 | '55': [0.19444, 0.43056, 0, 0],
|
1896 | '56': M5,
|
1897 | '57': [0.19444, 0.43056, 0, 0],
|
1898 | '65': [0, 0.68333, 0, 0.13889],
|
1899 | '66': [0, 0.68333, 0.05017, 0.08334],
|
1900 | '67': [0, 0.68333, 0.07153, 0.08334],
|
1901 | '68': [0, 0.68333, 0.02778, 0.05556],
|
1902 | '69': [0, 0.68333, 0.05764, 0.08334],
|
1903 | '70': [0, 0.68333, 0.13889, 0.08334],
|
1904 | '71': [0, 0.68333, 0, 0.08334],
|
1905 | '72': [0, 0.68333, 0.08125, 0.05556],
|
1906 | '73': [0, 0.68333, 0.07847, 0.11111],
|
1907 | '74': [0, 0.68333, 0.09618, 0.16667],
|
1908 | '75': [0, 0.68333, 0.07153, 0.05556],
|
1909 | '76': [0, 0.68333, 0, 0.02778],
|
1910 | '77': [0, 0.68333, 0.10903, 0.08334],
|
1911 | '78': [0, 0.68333, 0.10903, 0.08334],
|
1912 | '79': [0, 0.68333, 0.02778, 0.08334],
|
1913 | '80': [0, 0.68333, 0.13889, 0.08334],
|
1914 | '81': [0.19444, 0.68333, 0, 0.08334],
|
1915 | '82': [0, 0.68333, 0.00773, 0.08334],
|
1916 | '83': [0, 0.68333, 0.05764, 0.08334],
|
1917 | '84': [0, 0.68333, 0.13889, 0.08334],
|
1918 | '85': [0, 0.68333, 0.10903, 0.02778],
|
1919 | '86': [0, 0.68333, 0.22222, 0],
|
1920 | '87': [0, 0.68333, 0.13889, 0],
|
1921 | '88': [0, 0.68333, 0.07847, 0.08334],
|
1922 | '89': [0, 0.68333, 0.22222, 0],
|
1923 | '90': [0, 0.68333, 0.07153, 0.08334],
|
1924 | '97': [0, 0.43056, 0, 0],
|
1925 | '98': M6,
|
1926 | '99': [0, 0.43056, 0, 0.05556],
|
1927 | '100': [0, 0.69444, 0, 0.16667],
|
1928 | '101': [0, 0.43056, 0, 0.05556],
|
1929 | '102': [0.19444, 0.69444, 0.10764, 0.16667],
|
1930 | '103': [0.19444, 0.43056, 0.03588, 0.02778],
|
1931 | '104': M6,
|
1932 | '105': [0, 0.65952, 0, 0],
|
1933 | '106': [0.19444, 0.65952, 0.05724, 0],
|
1934 | '107': [0, 0.69444, 0.03148, 0],
|
1935 | '108': [0, 0.69444, 0.01968, 0.08334],
|
1936 | '109': [0, 0.43056, 0, 0],
|
1937 | '110': [0, 0.43056, 0, 0],
|
1938 | '111': [0, 0.43056, 0, 0.05556],
|
1939 | '112': [0.19444, 0.43056, 0, 0.08334],
|
1940 | '113': [0.19444, 0.43056, 0.03588, 0.08334],
|
1941 | '114': [0, 0.43056, 0.02778, 0.05556],
|
1942 | '115': [0, 0.43056, 0, 0.05556],
|
1943 | '116': [0, 0.61508, 0, 0.08334],
|
1944 | '117': [0, 0.43056, 0, 0.02778],
|
1945 | '118': [0, 0.43056, 0.03588, 0.02778],
|
1946 | '119': [0, 0.43056, 0.02691, 0.08334],
|
1947 | '120': [0, 0.43056, 0, 0.02778],
|
1948 | '121': [0.19444, 0.43056, 0.03588, 0.05556],
|
1949 | '122': [0, 0.43056, 0.04398, 0.05556],
|
1950 | '160': M0,
|
1951 | '915': [0, 0.68333, 0.13889, 0.08334],
|
1952 | '916': [0, 0.68333, 0, 0.16667],
|
1953 | '920': [0, 0.68333, 0.02778, 0.08334],
|
1954 | '923': [0, 0.68333, 0, 0.16667],
|
1955 | '926': [0, 0.68333, 0.07569, 0.08334],
|
1956 | '928': [0, 0.68333, 0.08125, 0.05556],
|
1957 | '931': [0, 0.68333, 0.05764, 0.08334],
|
1958 | '933': [0, 0.68333, 0.13889, 0.05556],
|
1959 | '934': [0, 0.68333, 0, 0.08334],
|
1960 | '936': [0, 0.68333, 0.11, 0.05556],
|
1961 | '937': [0, 0.68333, 0.05017, 0.08334],
|
1962 | '945': [0, 0.43056, 0.0037, 0.02778],
|
1963 | '946': [0.19444, 0.69444, 0.05278, 0.08334],
|
1964 | '947': [0.19444, 0.43056, 0.05556, 0],
|
1965 | '948': [0, 0.69444, 0.03785, 0.05556],
|
1966 | '949': [0, 0.43056, 0, 0.08334],
|
1967 | '950': [0.19444, 0.69444, 0.07378, 0.08334],
|
1968 | '951': [0.19444, 0.43056, 0.03588, 0.05556],
|
1969 | '952': [0, 0.69444, 0.02778, 0.08334],
|
1970 | '953': [0, 0.43056, 0, 0.05556],
|
1971 | '954': [0, 0.43056, 0, 0],
|
1972 | '955': M6,
|
1973 | '956': [0.19444, 0.43056, 0, 0.02778],
|
1974 | '957': [0, 0.43056, 0.06366, 0.02778],
|
1975 | '958': [0.19444, 0.69444, 0.04601, 0.11111],
|
1976 | '959': [0, 0.43056, 0, 0.05556],
|
1977 | '960': [0, 0.43056, 0.03588, 0],
|
1978 | '961': [0.19444, 0.43056, 0, 0.08334],
|
1979 | '962': [0.09722, 0.43056, 0.07986, 0.08334],
|
1980 | '963': [0, 0.43056, 0.03588, 0],
|
1981 | '964': [0, 0.43056, 0.1132, 0.02778],
|
1982 | '965': [0, 0.43056, 0.03588, 0.02778],
|
1983 | '966': [0.19444, 0.43056, 0, 0.08334],
|
1984 | '967': [0.19444, 0.43056, 0, 0.05556],
|
1985 | '968': [0.19444, 0.69444, 0.03588, 0.11111],
|
1986 | '969': [0, 0.43056, 0.03588, 0],
|
1987 | '977': [0, 0.69444, 0, 0.08334],
|
1988 | '981': [0.19444, 0.69444, 0, 0.08334],
|
1989 | '982': [0, 0.43056, 0.02778, 0],
|
1990 | '1009': [0.19444, 0.43056, 0, 0.08334],
|
1991 | '1013': [0, 0.43056, 0, 0.05556],
|
1992 | '57649': [0, 0.43056, 0, 0.02778],
|
1993 | '57911': [0.19444, 0.43056, 0, 0.08334],
|
1994 | },
|
1995 | 'SansSerif-Bold': {
|
1996 | '32': M0,
|
1997 | '33': M6,
|
1998 | '34': M6,
|
1999 | '35': M16,
|
2000 | '36': [0.05556, 0.75, 0, 0],
|
2001 | '37': [0.05556, 0.75, 0, 0],
|
2002 | '38': M6,
|
2003 | '39': M6,
|
2004 | '40': M15,
|
2005 | '41': M15,
|
2006 | '42': M14,
|
2007 | '43': [0.11667, 0.61667, 0, 0],
|
2008 | '44': [0.10556, 0.13056, 0, 0],
|
2009 | '45': [0, 0.45833, 0, 0],
|
2010 | '46': [0, 0.13056, 0, 0],
|
2011 | '47': M15,
|
2012 | '48': M6,
|
2013 | '49': M6,
|
2014 | '50': M6,
|
2015 | '51': M6,
|
2016 | '52': M6,
|
2017 | '53': M6,
|
2018 | '54': M6,
|
2019 | '55': M6,
|
2020 | '56': M6,
|
2021 | '57': M6,
|
2022 | '58': [0, 0.45833, 0, 0],
|
2023 | '59': [0.10556, 0.45833, 0, 0],
|
2024 | '61': [-0.09375, 0.40625, 0, 0],
|
2025 | '63': M6,
|
2026 | '64': M6,
|
2027 | '65': M6,
|
2028 | '66': M6,
|
2029 | '67': M6,
|
2030 | '68': M6,
|
2031 | '69': M6,
|
2032 | '70': M6,
|
2033 | '71': M6,
|
2034 | '72': M6,
|
2035 | '73': M6,
|
2036 | '74': M6,
|
2037 | '75': M6,
|
2038 | '76': M6,
|
2039 | '77': M6,
|
2040 | '78': M6,
|
2041 | '79': M6,
|
2042 | '80': M6,
|
2043 | '81': [0.10556, 0.69444, 0, 0],
|
2044 | '82': M6,
|
2045 | '83': M6,
|
2046 | '84': M6,
|
2047 | '85': M6,
|
2048 | '86': [0, 0.69444, 0.01528, 0],
|
2049 | '87': [0, 0.69444, 0.01528, 0],
|
2050 | '88': M6,
|
2051 | '89': [0, 0.69444, 0.0275, 0],
|
2052 | '90': M6,
|
2053 | '91': M15,
|
2054 | '93': M15,
|
2055 | '94': M6,
|
2056 | '95': [0.35, 0.10833, 0.03056, 0],
|
2057 | '97': [0, 0.45833, 0, 0],
|
2058 | '98': M6,
|
2059 | '99': [0, 0.45833, 0, 0],
|
2060 | '100': M6,
|
2061 | '101': [0, 0.45833, 0, 0],
|
2062 | '102': [0, 0.69444, 0.07639, 0],
|
2063 | '103': [0.19444, 0.45833, 0.01528, 0],
|
2064 | '104': M6,
|
2065 | '105': M6,
|
2066 | '106': M16,
|
2067 | '107': M6,
|
2068 | '108': M6,
|
2069 | '109': [0, 0.45833, 0, 0],
|
2070 | '110': [0, 0.45833, 0, 0],
|
2071 | '111': [0, 0.45833, 0, 0],
|
2072 | '112': [0.19444, 0.45833, 0, 0],
|
2073 | '113': [0.19444, 0.45833, 0, 0],
|
2074 | '114': [0, 0.45833, 0.01528, 0],
|
2075 | '115': [0, 0.45833, 0, 0],
|
2076 | '116': [0, 0.58929, 0, 0],
|
2077 | '117': [0, 0.45833, 0, 0],
|
2078 | '118': [0, 0.45833, 0.01528, 0],
|
2079 | '119': [0, 0.45833, 0.01528, 0],
|
2080 | '120': [0, 0.45833, 0, 0],
|
2081 | '121': [0.19444, 0.45833, 0.01528, 0],
|
2082 | '122': [0, 0.45833, 0, 0],
|
2083 | '126': [0.35, 0.34444, 0, 0],
|
2084 | '160': M0,
|
2085 | '168': M6,
|
2086 | '176': M6,
|
2087 | '180': M6,
|
2088 | '184': [0.17014, 0, 0, 0],
|
2089 | '305': [0, 0.45833, 0, 0],
|
2090 | '567': [0.19444, 0.45833, 0, 0],
|
2091 | '710': M6,
|
2092 | '711': [0, 0.63542, 0, 0],
|
2093 | '713': [0, 0.63778, 0, 0],
|
2094 | '728': M6,
|
2095 | '729': M6,
|
2096 | '730': M6,
|
2097 | '732': M6,
|
2098 | '733': M6,
|
2099 | '915': M6,
|
2100 | '916': M6,
|
2101 | '920': M6,
|
2102 | '923': M6,
|
2103 | '926': M6,
|
2104 | '928': M6,
|
2105 | '931': M6,
|
2106 | '933': M6,
|
2107 | '934': M6,
|
2108 | '936': M6,
|
2109 | '937': M6,
|
2110 | '8211': [0, 0.45833, 0.03056, 0],
|
2111 | '8212': [0, 0.45833, 0.03056, 0],
|
2112 | '8216': M6,
|
2113 | '8217': M6,
|
2114 | '8220': M6,
|
2115 | '8221': M6,
|
2116 | },
|
2117 | 'SansSerif-Italic': {
|
2118 | '32': M0,
|
2119 | '33': [0, 0.69444, 0.05733, 0],
|
2120 | '34': [0, 0.69444, 0.00316, 0],
|
2121 | '35': [0.19444, 0.69444, 0.05087, 0],
|
2122 | '36': [0.05556, 0.75, 0.11156, 0],
|
2123 | '37': [0.05556, 0.75, 0.03126, 0],
|
2124 | '38': [0, 0.69444, 0.03058, 0],
|
2125 | '39': [0, 0.69444, 0.07816, 0],
|
2126 | '40': [0.25, 0.75, 0.13164, 0],
|
2127 | '41': [0.25, 0.75, 0.02536, 0],
|
2128 | '42': [0, 0.75, 0.11775, 0],
|
2129 | '43': [0.08333, 0.58333, 0.02536, 0],
|
2130 | '44': [0.125, 0.08333, 0, 0],
|
2131 | '45': [0, 0.44444, 0.01946, 0],
|
2132 | '46': [0, 0.08333, 0, 0],
|
2133 | '47': [0.25, 0.75, 0.13164, 0],
|
2134 | '48': [0, 0.65556, 0.11156, 0],
|
2135 | '49': [0, 0.65556, 0.11156, 0],
|
2136 | '50': [0, 0.65556, 0.11156, 0],
|
2137 | '51': [0, 0.65556, 0.11156, 0],
|
2138 | '52': [0, 0.65556, 0.11156, 0],
|
2139 | '53': [0, 0.65556, 0.11156, 0],
|
2140 | '54': [0, 0.65556, 0.11156, 0],
|
2141 | '55': [0, 0.65556, 0.11156, 0],
|
2142 | '56': [0, 0.65556, 0.11156, 0],
|
2143 | '57': [0, 0.65556, 0.11156, 0],
|
2144 | '58': [0, 0.44444, 0.02502, 0],
|
2145 | '59': [0.125, 0.44444, 0.02502, 0],
|
2146 | '61': [-0.13, 0.37, 0.05087, 0],
|
2147 | '63': [0, 0.69444, 0.11809, 0],
|
2148 | '64': [0, 0.69444, 0.07555, 0],
|
2149 | '65': M6,
|
2150 | '66': [0, 0.69444, 0.08293, 0],
|
2151 | '67': [0, 0.69444, 0.11983, 0],
|
2152 | '68': [0, 0.69444, 0.07555, 0],
|
2153 | '69': [0, 0.69444, 0.11983, 0],
|
2154 | '70': [0, 0.69444, 0.13372, 0],
|
2155 | '71': [0, 0.69444, 0.11983, 0],
|
2156 | '72': [0, 0.69444, 0.08094, 0],
|
2157 | '73': [0, 0.69444, 0.13372, 0],
|
2158 | '74': [0, 0.69444, 0.08094, 0],
|
2159 | '75': [0, 0.69444, 0.11983, 0],
|
2160 | '76': M6,
|
2161 | '77': [0, 0.69444, 0.08094, 0],
|
2162 | '78': [0, 0.69444, 0.08094, 0],
|
2163 | '79': [0, 0.69444, 0.07555, 0],
|
2164 | '80': [0, 0.69444, 0.08293, 0],
|
2165 | '81': [0.125, 0.69444, 0.07555, 0],
|
2166 | '82': [0, 0.69444, 0.08293, 0],
|
2167 | '83': [0, 0.69444, 0.09205, 0],
|
2168 | '84': [0, 0.69444, 0.13372, 0],
|
2169 | '85': [0, 0.69444, 0.08094, 0],
|
2170 | '86': [0, 0.69444, 0.1615, 0],
|
2171 | '87': [0, 0.69444, 0.1615, 0],
|
2172 | '88': [0, 0.69444, 0.13372, 0],
|
2173 | '89': [0, 0.69444, 0.17261, 0],
|
2174 | '90': [0, 0.69444, 0.11983, 0],
|
2175 | '91': [0.25, 0.75, 0.15942, 0],
|
2176 | '93': [0.25, 0.75, 0.08719, 0],
|
2177 | '94': [0, 0.69444, 0.0799, 0],
|
2178 | '95': [0.35, 0.09444, 0.08616, 0],
|
2179 | '97': [0, 0.44444, 0.00981, 0],
|
2180 | '98': [0, 0.69444, 0.03057, 0],
|
2181 | '99': [0, 0.44444, 0.08336, 0],
|
2182 | '100': [0, 0.69444, 0.09483, 0],
|
2183 | '101': [0, 0.44444, 0.06778, 0],
|
2184 | '102': [0, 0.69444, 0.21705, 0],
|
2185 | '103': [0.19444, 0.44444, 0.10836, 0],
|
2186 | '104': [0, 0.69444, 0.01778, 0],
|
2187 | '105': [0, 0.67937, 0.09718, 0],
|
2188 | '106': [0.19444, 0.67937, 0.09162, 0],
|
2189 | '107': [0, 0.69444, 0.08336, 0],
|
2190 | '108': [0, 0.69444, 0.09483, 0],
|
2191 | '109': [0, 0.44444, 0.01778, 0],
|
2192 | '110': [0, 0.44444, 0.01778, 0],
|
2193 | '111': [0, 0.44444, 0.06613, 0],
|
2194 | '112': [0.19444, 0.44444, 0.0389, 0],
|
2195 | '113': [0.19444, 0.44444, 0.04169, 0],
|
2196 | '114': [0, 0.44444, 0.10836, 0],
|
2197 | '115': [0, 0.44444, 0.0778, 0],
|
2198 | '116': [0, 0.57143, 0.07225, 0],
|
2199 | '117': [0, 0.44444, 0.04169, 0],
|
2200 | '118': [0, 0.44444, 0.10836, 0],
|
2201 | '119': [0, 0.44444, 0.10836, 0],
|
2202 | '120': [0, 0.44444, 0.09169, 0],
|
2203 | '121': [0.19444, 0.44444, 0.10836, 0],
|
2204 | '122': [0, 0.44444, 0.08752, 0],
|
2205 | '126': [0.35, 0.32659, 0.08826, 0],
|
2206 | '160': M0,
|
2207 | '168': [0, 0.67937, 0.06385, 0],
|
2208 | '176': M6,
|
2209 | '184': [0.17014, 0, 0, 0],
|
2210 | '305': [0, 0.44444, 0.04169, 0],
|
2211 | '567': [0.19444, 0.44444, 0.04169, 0],
|
2212 | '710': [0, 0.69444, 0.0799, 0],
|
2213 | '711': [0, 0.63194, 0.08432, 0],
|
2214 | '713': [0, 0.60889, 0.08776, 0],
|
2215 | '714': [0, 0.69444, 0.09205, 0],
|
2216 | '715': M6,
|
2217 | '728': [0, 0.69444, 0.09483, 0],
|
2218 | '729': [0, 0.67937, 0.07774, 0],
|
2219 | '730': M6,
|
2220 | '732': [0, 0.67659, 0.08826, 0],
|
2221 | '733': [0, 0.69444, 0.09205, 0],
|
2222 | '915': [0, 0.69444, 0.13372, 0],
|
2223 | '916': M6,
|
2224 | '920': [0, 0.69444, 0.07555, 0],
|
2225 | '923': M6,
|
2226 | '926': [0, 0.69444, 0.12816, 0],
|
2227 | '928': [0, 0.69444, 0.08094, 0],
|
2228 | '931': [0, 0.69444, 0.11983, 0],
|
2229 | '933': [0, 0.69444, 0.09031, 0],
|
2230 | '934': [0, 0.69444, 0.04603, 0],
|
2231 | '936': [0, 0.69444, 0.09031, 0],
|
2232 | '937': [0, 0.69444, 0.08293, 0],
|
2233 | '8211': [0, 0.44444, 0.08616, 0],
|
2234 | '8212': [0, 0.44444, 0.08616, 0],
|
2235 | '8216': [0, 0.69444, 0.07816, 0],
|
2236 | '8217': [0, 0.69444, 0.07816, 0],
|
2237 | '8220': [0, 0.69444, 0.14205, 0],
|
2238 | '8221': [0, 0.69444, 0.00316, 0],
|
2239 | },
|
2240 | 'SansSerif-Regular': {
|
2241 | '32': M0,
|
2242 | '33': M6,
|
2243 | '34': M6,
|
2244 | '35': M16,
|
2245 | '36': [0.05556, 0.75, 0, 0],
|
2246 | '37': [0.05556, 0.75, 0, 0],
|
2247 | '38': M6,
|
2248 | '39': M6,
|
2249 | '40': M15,
|
2250 | '41': M15,
|
2251 | '42': M14,
|
2252 | '43': [0.08333, 0.58333, 0, 0],
|
2253 | '44': [0.125, 0.08333, 0, 0],
|
2254 | '45': M7,
|
2255 | '46': [0, 0.08333, 0, 0],
|
2256 | '47': M15,
|
2257 | '48': [0, 0.65556, 0, 0],
|
2258 | '49': [0, 0.65556, 0, 0],
|
2259 | '50': [0, 0.65556, 0, 0],
|
2260 | '51': [0, 0.65556, 0, 0],
|
2261 | '52': [0, 0.65556, 0, 0],
|
2262 | '53': [0, 0.65556, 0, 0],
|
2263 | '54': [0, 0.65556, 0, 0],
|
2264 | '55': [0, 0.65556, 0, 0],
|
2265 | '56': [0, 0.65556, 0, 0],
|
2266 | '57': [0, 0.65556, 0, 0],
|
2267 | '58': M7,
|
2268 | '59': [0.125, 0.44444, 0, 0],
|
2269 | '61': [-0.13, 0.37, 0, 0],
|
2270 | '63': M6,
|
2271 | '64': M6,
|
2272 | '65': M6,
|
2273 | '66': M6,
|
2274 | '67': M6,
|
2275 | '68': M6,
|
2276 | '69': M6,
|
2277 | '70': M6,
|
2278 | '71': M6,
|
2279 | '72': M6,
|
2280 | '73': M6,
|
2281 | '74': M6,
|
2282 | '75': M6,
|
2283 | '76': M6,
|
2284 | '77': M6,
|
2285 | '78': M6,
|
2286 | '79': M6,
|
2287 | '80': M6,
|
2288 | '81': [0.125, 0.69444, 0, 0],
|
2289 | '82': M6,
|
2290 | '83': M6,
|
2291 | '84': M6,
|
2292 | '85': M6,
|
2293 | '86': [0, 0.69444, 0.01389, 0],
|
2294 | '87': [0, 0.69444, 0.01389, 0],
|
2295 | '88': M6,
|
2296 | '89': [0, 0.69444, 0.025, 0],
|
2297 | '90': M6,
|
2298 | '91': M15,
|
2299 | '93': M15,
|
2300 | '94': M6,
|
2301 | '95': [0.35, 0.09444, 0.02778, 0],
|
2302 | '97': M7,
|
2303 | '98': M6,
|
2304 | '99': M7,
|
2305 | '100': M6,
|
2306 | '101': M7,
|
2307 | '102': [0, 0.69444, 0.06944, 0],
|
2308 | '103': [0.19444, 0.44444, 0.01389, 0],
|
2309 | '104': M6,
|
2310 | '105': [0, 0.67937, 0, 0],
|
2311 | '106': [0.19444, 0.67937, 0, 0],
|
2312 | '107': M6,
|
2313 | '108': M6,
|
2314 | '109': M7,
|
2315 | '110': M7,
|
2316 | '111': M7,
|
2317 | '112': M8,
|
2318 | '113': M8,
|
2319 | '114': [0, 0.44444, 0.01389, 0],
|
2320 | '115': M7,
|
2321 | '116': [0, 0.57143, 0, 0],
|
2322 | '117': M7,
|
2323 | '118': [0, 0.44444, 0.01389, 0],
|
2324 | '119': [0, 0.44444, 0.01389, 0],
|
2325 | '120': M7,
|
2326 | '121': [0.19444, 0.44444, 0.01389, 0],
|
2327 | '122': M7,
|
2328 | '126': [0.35, 0.32659, 0, 0],
|
2329 | '160': M0,
|
2330 | '168': [0, 0.67937, 0, 0],
|
2331 | '176': M6,
|
2332 | '184': [0.17014, 0, 0, 0],
|
2333 | '305': M7,
|
2334 | '567': M8,
|
2335 | '710': M6,
|
2336 | '711': [0, 0.63194, 0, 0],
|
2337 | '713': [0, 0.60889, 0, 0],
|
2338 | '714': M6,
|
2339 | '715': M6,
|
2340 | '728': M6,
|
2341 | '729': [0, 0.67937, 0, 0],
|
2342 | '730': M6,
|
2343 | '732': [0, 0.67659, 0, 0],
|
2344 | '733': M6,
|
2345 | '915': M6,
|
2346 | '916': M6,
|
2347 | '920': M6,
|
2348 | '923': M6,
|
2349 | '926': M6,
|
2350 | '928': M6,
|
2351 | '931': M6,
|
2352 | '933': M6,
|
2353 | '934': M6,
|
2354 | '936': M6,
|
2355 | '937': M6,
|
2356 | '8211': [0, 0.44444, 0.02778, 0],
|
2357 | '8212': [0, 0.44444, 0.02778, 0],
|
2358 | '8216': M6,
|
2359 | '8217': M6,
|
2360 | '8220': M6,
|
2361 | '8221': M6,
|
2362 | },
|
2363 | 'Script-Regular': {
|
2364 | '32': M0,
|
2365 | '65': [0, 0.7, 0.22925, 0],
|
2366 | '66': [0, 0.7, 0.04087, 0],
|
2367 | '67': [0, 0.7, 0.1689, 0],
|
2368 | '68': [0, 0.7, 0.09371, 0],
|
2369 | '69': [0, 0.7, 0.18583, 0],
|
2370 | '70': [0, 0.7, 0.13634, 0],
|
2371 | '71': [0, 0.7, 0.17322, 0],
|
2372 | '72': [0, 0.7, 0.29694, 0],
|
2373 | '73': [0, 0.7, 0.19189, 0],
|
2374 | '74': [0.27778, 0.7, 0.19189, 0],
|
2375 | '75': [0, 0.7, 0.31259, 0],
|
2376 | '76': [0, 0.7, 0.19189, 0],
|
2377 | '77': [0, 0.7, 0.15981, 0],
|
2378 | '78': [0, 0.7, 0.3525, 0],
|
2379 | '79': [0, 0.7, 0.08078, 0],
|
2380 | '80': [0, 0.7, 0.08078, 0],
|
2381 | '81': [0, 0.7, 0.03305, 0],
|
2382 | '82': [0, 0.7, 0.06259, 0],
|
2383 | '83': [0, 0.7, 0.19189, 0],
|
2384 | '84': [0, 0.7, 0.29087, 0],
|
2385 | '85': [0, 0.7, 0.25815, 0],
|
2386 | '86': [0, 0.7, 0.27523, 0],
|
2387 | '87': [0, 0.7, 0.27523, 0],
|
2388 | '88': [0, 0.7, 0.26006, 0],
|
2389 | '89': [0, 0.7, 0.2939, 0],
|
2390 | '90': [0, 0.7, 0.24037, 0],
|
2391 | '160': M0,
|
2392 | },
|
2393 | 'Size1-Regular': {
|
2394 | '32': M0,
|
2395 | '40': M10,
|
2396 | '41': M10,
|
2397 | '47': M10,
|
2398 | '91': M10,
|
2399 | '92': M10,
|
2400 | '93': M10,
|
2401 | '123': M10,
|
2402 | '125': M10,
|
2403 | '160': M0,
|
2404 | '710': [0, 0.72222, 0, 0],
|
2405 | '732': [0, 0.72222, 0, 0],
|
2406 | '770': [0, 0.72222, 0, 0],
|
2407 | '771': [0, 0.72222, 0, 0],
|
2408 | '8214': [-0.00099, 0.601, 0, 0],
|
2409 | '8593': [1e-5, 0.6, 0, 0],
|
2410 | '8595': [1e-5, 0.6, 0, 0],
|
2411 | '8657': [1e-5, 0.6, 0, 0],
|
2412 | '8659': [1e-5, 0.6, 0, 0],
|
2413 | '8719': M17,
|
2414 | '8720': M17,
|
2415 | '8721': M17,
|
2416 | '8730': M10,
|
2417 | '8739': [-0.00599, 0.606, 0, 0],
|
2418 | '8741': [-0.00599, 0.606, 0, 0],
|
2419 | '8747': [0.30612, 0.805, 0.19445, 0],
|
2420 | '8748': [0.306, 0.805, 0.19445, 0],
|
2421 | '8749': [0.306, 0.805, 0.19445, 0],
|
2422 | '8750': [0.30612, 0.805, 0.19445, 0],
|
2423 | '8896': M17,
|
2424 | '8897': M17,
|
2425 | '8898': M17,
|
2426 | '8899': M17,
|
2427 | '8968': M10,
|
2428 | '8969': M10,
|
2429 | '8970': M10,
|
2430 | '8971': M10,
|
2431 | '9168': [-0.00099, 0.601, 0, 0],
|
2432 | '10216': M10,
|
2433 | '10217': M10,
|
2434 | '10752': M17,
|
2435 | '10753': M17,
|
2436 | '10754': M17,
|
2437 | '10756': M17,
|
2438 | '10758': M17,
|
2439 | },
|
2440 | 'Size2-Regular': {
|
2441 | '32': M0,
|
2442 | '40': M19,
|
2443 | '41': M19,
|
2444 | '47': M19,
|
2445 | '91': M19,
|
2446 | '92': M19,
|
2447 | '93': M19,
|
2448 | '123': M19,
|
2449 | '125': M19,
|
2450 | '160': M0,
|
2451 | '710': M14,
|
2452 | '732': M14,
|
2453 | '770': M14,
|
2454 | '771': M14,
|
2455 | '8719': M18,
|
2456 | '8720': M18,
|
2457 | '8721': M18,
|
2458 | '8730': M19,
|
2459 | '8747': [0.86225, 1.36, 0.44445, 0],
|
2460 | '8748': [0.862, 1.36, 0.44445, 0],
|
2461 | '8749': [0.862, 1.36, 0.44445, 0],
|
2462 | '8750': [0.86225, 1.36, 0.44445, 0],
|
2463 | '8896': M18,
|
2464 | '8897': M18,
|
2465 | '8898': M18,
|
2466 | '8899': M18,
|
2467 | '8968': M19,
|
2468 | '8969': M19,
|
2469 | '8970': M19,
|
2470 | '8971': M19,
|
2471 | '10216': M19,
|
2472 | '10217': M19,
|
2473 | '10752': M18,
|
2474 | '10753': M18,
|
2475 | '10754': M18,
|
2476 | '10756': M18,
|
2477 | '10758': M18,
|
2478 | },
|
2479 | 'Size3-Regular': {
|
2480 | '32': M0,
|
2481 | '40': M13,
|
2482 | '41': M13,
|
2483 | '47': M13,
|
2484 | '91': M13,
|
2485 | '92': M13,
|
2486 | '93': M13,
|
2487 | '123': M13,
|
2488 | '125': M13,
|
2489 | '160': M0,
|
2490 | '710': M14,
|
2491 | '732': M14,
|
2492 | '770': M14,
|
2493 | '771': M14,
|
2494 | '8730': M13,
|
2495 | '8968': M13,
|
2496 | '8969': M13,
|
2497 | '8970': M13,
|
2498 | '8971': M13,
|
2499 | '10216': M13,
|
2500 | '10217': M13,
|
2501 | },
|
2502 | 'Size4-Regular': {
|
2503 | '32': M0,
|
2504 | '40': M12,
|
2505 | '41': M12,
|
2506 | '47': M12,
|
2507 | '91': M12,
|
2508 | '92': M12,
|
2509 | '93': M12,
|
2510 | '123': M12,
|
2511 | '125': M12,
|
2512 | '160': M0,
|
2513 | '710': [0, 0.825, 0, 0],
|
2514 | '732': [0, 0.825, 0, 0],
|
2515 | '770': [0, 0.825, 0, 0],
|
2516 | '771': [0, 0.825, 0, 0],
|
2517 | '8730': M12,
|
2518 | '8968': M12,
|
2519 | '8969': M12,
|
2520 | '8970': M12,
|
2521 | '8971': M12,
|
2522 | '9115': [0.64502, 1.155, 0, 0],
|
2523 | '9116': [1e-5, 0.6, 0, 0],
|
2524 | '9117': [0.64502, 1.155, 0, 0],
|
2525 | '9118': [0.64502, 1.155, 0, 0],
|
2526 | '9119': [1e-5, 0.6, 0, 0],
|
2527 | '9120': [0.64502, 1.155, 0, 0],
|
2528 | '9121': [0.64502, 1.155, 0, 0],
|
2529 | '9122': [-0.00099, 0.601, 0, 0],
|
2530 | '9123': [0.64502, 1.155, 0, 0],
|
2531 | '9124': [0.64502, 1.155, 0, 0],
|
2532 | '9125': [-0.00099, 0.601, 0, 0],
|
2533 | '9126': [0.64502, 1.155, 0, 0],
|
2534 | '9127': [1e-5, 0.9, 0, 0],
|
2535 | '9128': M19,
|
2536 | '9129': [0.90001, 0, 0, 0],
|
2537 | '9130': [0, 0.3, 0, 0],
|
2538 | '9131': [1e-5, 0.9, 0, 0],
|
2539 | '9132': M19,
|
2540 | '9133': [0.90001, 0, 0, 0],
|
2541 | '9143': [0.88502, 0.915, 0, 0],
|
2542 | '10216': M12,
|
2543 | '10217': M12,
|
2544 | '57344': [-0.00499, 0.605, 0, 0],
|
2545 | '57345': [-0.00499, 0.605, 0, 0],
|
2546 | '57680': [0, 0.12, 0, 0],
|
2547 | '57681': [0, 0.12, 0, 0],
|
2548 | '57682': [0, 0.12, 0, 0],
|
2549 | '57683': [0, 0.12, 0, 0],
|
2550 | },
|
2551 | 'Typewriter-Regular': {
|
2552 | '32': M0,
|
2553 | '33': M11,
|
2554 | '34': M11,
|
2555 | '35': M11,
|
2556 | '36': [0.08333, 0.69444, 0, 0],
|
2557 | '37': [0.08333, 0.69444, 0, 0],
|
2558 | '38': M11,
|
2559 | '39': M11,
|
2560 | '40': [0.08333, 0.69444, 0, 0],
|
2561 | '41': [0.08333, 0.69444, 0, 0],
|
2562 | '42': [0, 0.52083, 0, 0],
|
2563 | '43': [-0.08056, 0.53055, 0, 0],
|
2564 | '44': [0.13889, 0.125, 0, 0],
|
2565 | '45': [-0.08056, 0.53055, 0, 0],
|
2566 | '46': [0, 0.125, 0, 0],
|
2567 | '47': [0.08333, 0.69444, 0, 0],
|
2568 | '48': M11,
|
2569 | '49': M11,
|
2570 | '50': M11,
|
2571 | '51': M11,
|
2572 | '52': M11,
|
2573 | '53': M11,
|
2574 | '54': M11,
|
2575 | '55': M11,
|
2576 | '56': M11,
|
2577 | '57': M11,
|
2578 | '58': [0, 0.43056, 0, 0],
|
2579 | '59': [0.13889, 0.43056, 0, 0],
|
2580 | '60': [-0.05556, 0.55556, 0, 0],
|
2581 | '61': [-0.19549, 0.41562, 0, 0],
|
2582 | '62': [-0.05556, 0.55556, 0, 0],
|
2583 | '63': M11,
|
2584 | '64': M11,
|
2585 | '65': M11,
|
2586 | '66': M11,
|
2587 | '67': M11,
|
2588 | '68': M11,
|
2589 | '69': M11,
|
2590 | '70': M11,
|
2591 | '71': M11,
|
2592 | '72': M11,
|
2593 | '73': M11,
|
2594 | '74': M11,
|
2595 | '75': M11,
|
2596 | '76': M11,
|
2597 | '77': M11,
|
2598 | '78': M11,
|
2599 | '79': M11,
|
2600 | '80': M11,
|
2601 | '81': [0.13889, 0.61111, 0, 0],
|
2602 | '82': M11,
|
2603 | '83': M11,
|
2604 | '84': M11,
|
2605 | '85': M11,
|
2606 | '86': M11,
|
2607 | '87': M11,
|
2608 | '88': M11,
|
2609 | '89': M11,
|
2610 | '90': M11,
|
2611 | '91': [0.08333, 0.69444, 0, 0],
|
2612 | '92': [0.08333, 0.69444, 0, 0],
|
2613 | '93': [0.08333, 0.69444, 0, 0],
|
2614 | '94': M11,
|
2615 | '95': [0.09514, 0, 0, 0],
|
2616 | '96': M11,
|
2617 | '97': [0, 0.43056, 0, 0],
|
2618 | '98': M11,
|
2619 | '99': [0, 0.43056, 0, 0],
|
2620 | '100': M11,
|
2621 | '101': [0, 0.43056, 0, 0],
|
2622 | '102': M11,
|
2623 | '103': [0.22222, 0.43056, 0, 0],
|
2624 | '104': M11,
|
2625 | '105': M11,
|
2626 | '106': [0.22222, 0.61111, 0, 0],
|
2627 | '107': M11,
|
2628 | '108': M11,
|
2629 | '109': [0, 0.43056, 0, 0],
|
2630 | '110': [0, 0.43056, 0, 0],
|
2631 | '111': [0, 0.43056, 0, 0],
|
2632 | '112': [0.22222, 0.43056, 0, 0],
|
2633 | '113': [0.22222, 0.43056, 0, 0],
|
2634 | '114': [0, 0.43056, 0, 0],
|
2635 | '115': [0, 0.43056, 0, 0],
|
2636 | '116': [0, 0.55358, 0, 0],
|
2637 | '117': [0, 0.43056, 0, 0],
|
2638 | '118': [0, 0.43056, 0, 0],
|
2639 | '119': [0, 0.43056, 0, 0],
|
2640 | '120': [0, 0.43056, 0, 0],
|
2641 | '121': [0.22222, 0.43056, 0, 0],
|
2642 | '122': [0, 0.43056, 0, 0],
|
2643 | '123': [0.08333, 0.69444, 0, 0],
|
2644 | '124': [0.08333, 0.69444, 0, 0],
|
2645 | '125': [0.08333, 0.69444, 0, 0],
|
2646 | '126': M11,
|
2647 | '127': M11,
|
2648 | '160': M0,
|
2649 | '176': M11,
|
2650 | '184': [0.19445, 0, 0, 0],
|
2651 | '305': [0, 0.43056, 0, 0],
|
2652 | '567': [0.22222, 0.43056, 0, 0],
|
2653 | '711': [0, 0.56597, 0, 0],
|
2654 | '713': [0, 0.56555, 0, 0],
|
2655 | '714': M11,
|
2656 | '715': M11,
|
2657 | '728': M11,
|
2658 | '730': M11,
|
2659 | '770': M11,
|
2660 | '771': M11,
|
2661 | '776': M11,
|
2662 | '915': M11,
|
2663 | '916': M11,
|
2664 | '920': M11,
|
2665 | '923': M11,
|
2666 | '926': M11,
|
2667 | '928': M11,
|
2668 | '931': M11,
|
2669 | '933': M11,
|
2670 | '934': M11,
|
2671 | '936': M11,
|
2672 | '937': M11,
|
2673 | '8216': M11,
|
2674 | '8217': M11,
|
2675 | '8242': M11,
|
2676 | '9251': [0.11111, 0.21944, 0, 0],
|
2677 | },
|
2678 | };
|
2679 |
|
2680 |
|
2681 |
|
2682 |
|
2683 |
|
2684 |
|
2685 |
|
2686 |
|
2687 |
|
2688 |
|
2689 |
|
2690 |
|
2691 |
|
2692 | const CJK_REGEX = /[\u3040-\u309F]|[\u30A0-\u30FF]|[\u4E00-\u9FAF]|[\uAC00-\uD7AF]/;
|
2693 |
|
2694 |
|
2695 |
|
2696 |
|
2697 | const PT_PER_EM = 10.0;
|
2698 |
|
2699 |
|
2700 |
|
2701 |
|
2702 |
|
2703 |
|
2704 |
|
2705 | const AXIS_HEIGHT = 0.25;
|
2706 |
|
2707 | const BASELINE_SKIP = 1.2;
|
2708 | const X_HEIGHT = 0.431;
|
2709 |
|
2710 |
|
2711 |
|
2712 |
|
2713 |
|
2714 |
|
2715 |
|
2716 |
|
2717 |
|
2718 |
|
2719 |
|
2720 |
|
2721 |
|
2722 |
|
2723 |
|
2724 |
|
2725 |
|
2726 |
|
2727 |
|
2728 |
|
2729 |
|
2730 |
|
2731 |
|
2732 |
|
2733 |
|
2734 |
|
2735 |
|
2736 | const FONT_METRICS = {
|
2737 | slant: [0.25, 0.25, 0.25],
|
2738 | space: [0.0, 0.0, 0.0],
|
2739 | stretch: [0.0, 0.0, 0.0],
|
2740 | shrink: [0.0, 0.0, 0.0],
|
2741 | xHeight: [X_HEIGHT, X_HEIGHT, X_HEIGHT],
|
2742 | quad: [1.0, 1.171, 1.472],
|
2743 | extraSpace: [0.0, 0.0, 0.0],
|
2744 | num1: [0.677, 0.732, 0.925],
|
2745 | num2: [0.394, 0.384, 0.387],
|
2746 | num3: [0.444, 0.471, 0.504],
|
2747 | denom1: [0.686, 0.752, 1.025],
|
2748 | denom2: [0.345, 0.344, 0.532],
|
2749 | sup1: [0.413, 0.503, 0.504],
|
2750 | sup2: [0.363, 0.431, 0.404],
|
2751 | sup3: [0.289, 0.286, 0.294],
|
2752 | sub1: [0.15, 0.143, 0.2],
|
2753 | sub2: [0.247, 0.286, 0.4],
|
2754 | supDrop: [0.386, 0.353, 0.494],
|
2755 | subDrop: [0.05, 0.071, 0.1],
|
2756 | delim1: [2.39, 1.7, 1.98],
|
2757 | delim2: [1.01, 1.157, 1.42],
|
2758 | axisHeight: [AXIS_HEIGHT, AXIS_HEIGHT, AXIS_HEIGHT],
|
2759 | defaultRuleThickness: [0.04, 0.049, 0.049],
|
2760 | bigOpSpacing1: [0.111, 0.111, 0.111],
|
2761 | bigOpSpacing2: [0.166, 0.166, 0.166],
|
2762 | bigOpSpacing3: [0.2, 0.2, 0.2],
|
2763 | bigOpSpacing4: [0.6, 0.611, 0.611],
|
2764 | bigOpSpacing5: [0.1, 0.143, 0.143],
|
2765 | sqrtRuleThickness: [0.04, 0.04, 0.04],
|
2766 | };
|
2767 |
|
2768 |
|
2769 | const FONT_SCALE = [
|
2770 | 0,
|
2771 | 0.5,
|
2772 | 0.7,
|
2773 | 0.8,
|
2774 | 0.9,
|
2775 | 1.0,
|
2776 | 1.2,
|
2777 | 1.44,
|
2778 | 1.728,
|
2779 | 2.074,
|
2780 | 2.488,
|
2781 | ];
|
2782 | const DEFAULT_FONT_SIZE = 5;
|
2783 |
|
2784 |
|
2785 |
|
2786 |
|
2787 |
|
2788 |
|
2789 |
|
2790 | const extraCharacterMap = {
|
2791 | '\u00A0': '\u0020',
|
2792 | '\u200B': '\u0020',
|
2793 |
|
2794 | 'Å': 'A',
|
2795 | 'Ç': 'C',
|
2796 | 'Ð': 'D',
|
2797 | 'Þ': 'o',
|
2798 | 'å': 'a',
|
2799 | 'ç': 'c',
|
2800 | 'ð': 'd',
|
2801 | 'þ': 'o',
|
2802 |
|
2803 | 'А': 'A',
|
2804 | 'Б': 'B',
|
2805 | 'В': 'B',
|
2806 | 'Г': 'F',
|
2807 | 'Д': 'A',
|
2808 | 'Е': 'E',
|
2809 | 'Ж': 'K',
|
2810 | 'З': '3',
|
2811 | 'И': 'N',
|
2812 | 'Й': 'N',
|
2813 | 'К': 'K',
|
2814 | 'Л': 'N',
|
2815 | 'М': 'M',
|
2816 | 'Н': 'H',
|
2817 | 'О': 'O',
|
2818 | 'П': 'N',
|
2819 | 'Р': 'P',
|
2820 | 'С': 'C',
|
2821 | 'Т': 'T',
|
2822 | 'У': 'y',
|
2823 | 'Ф': 'O',
|
2824 | 'Х': 'X',
|
2825 | 'Ц': 'U',
|
2826 | 'Ч': 'h',
|
2827 | 'Ш': 'W',
|
2828 | 'Щ': 'W',
|
2829 | 'Ъ': 'B',
|
2830 | 'Ы': 'X',
|
2831 | 'Ь': 'B',
|
2832 | 'Э': '3',
|
2833 | 'Ю': 'X',
|
2834 | 'Я': 'R',
|
2835 | 'а': 'a',
|
2836 | 'б': 'b',
|
2837 | 'в': 'a',
|
2838 | 'г': 'r',
|
2839 | 'д': 'y',
|
2840 | 'е': 'e',
|
2841 | 'ж': 'm',
|
2842 | 'з': 'e',
|
2843 | 'и': 'n',
|
2844 | 'й': 'n',
|
2845 | 'к': 'n',
|
2846 | 'л': 'n',
|
2847 | 'м': 'm',
|
2848 | 'н': 'n',
|
2849 | 'о': 'o',
|
2850 | 'п': 'n',
|
2851 | 'р': 'p',
|
2852 | 'с': 'c',
|
2853 | 'т': 'o',
|
2854 | 'у': 'y',
|
2855 | 'ф': 'b',
|
2856 | 'х': 'x',
|
2857 | 'ц': 'n',
|
2858 | 'ч': 'n',
|
2859 | 'ш': 'w',
|
2860 | 'щ': 'w',
|
2861 | 'ъ': 'a',
|
2862 | 'ы': 'm',
|
2863 | 'ь': 'a',
|
2864 | 'э': 'e',
|
2865 | 'ю': 'm',
|
2866 | 'я': 'r',
|
2867 | };
|
2868 |
|
2869 |
|
2870 |
|
2871 |
|
2872 |
|
2873 |
|
2874 | function getCharacterMetrics(codepoint, fontName) {
|
2875 | if (codepoint === undefined)
|
2876 | codepoint = 77;
|
2877 | const metrics = CHARACTER_METRICS_MAP[fontName][codepoint];
|
2878 | if (metrics) {
|
2879 | return {
|
2880 | defaultMetrics: false,
|
2881 | depth: metrics[0],
|
2882 | height: metrics[1],
|
2883 | italic: metrics[2],
|
2884 | skew: metrics[3],
|
2885 | };
|
2886 | }
|
2887 | if (codepoint === 11034) {
|
2888 |
|
2889 | return {
|
2890 | defaultMetrics: true,
|
2891 | depth: 0.2,
|
2892 | height: 0.8,
|
2893 | italic: 0,
|
2894 | skew: 0,
|
2895 | };
|
2896 | }
|
2897 | const char = String.fromCodePoint(codepoint);
|
2898 | if (char in extraCharacterMap) {
|
2899 | codepoint = extraCharacterMap[char].codePointAt(0);
|
2900 | }
|
2901 | else if (CJK_REGEX.test(char)) {
|
2902 | codepoint = 77;
|
2903 | return {
|
2904 | defaultMetrics: true,
|
2905 | depth: 0.2,
|
2906 | height: 0.9,
|
2907 | italic: 0,
|
2908 | skew: 0,
|
2909 | };
|
2910 | }
|
2911 | return {
|
2912 | defaultMetrics: true,
|
2913 | depth: 0.2,
|
2914 | height: 0.7,
|
2915 | italic: 0,
|
2916 | skew: 0,
|
2917 | };
|
2918 | }
|
2919 |
|
2920 |
|
2921 |
|
2922 |
|
2923 |
|
2924 |
|
2925 |
|
2926 |
|
2927 |
|
2928 |
|
2929 |
|
2930 |
|
2931 |
|
2932 |
|
2933 |
|
2934 |
|
2935 |
|
2936 |
|
2937 |
|
2938 |
|
2939 |
|
2940 |
|
2941 |
|
2942 |
|
2943 |
|
2944 |
|
2945 |
|
2946 |
|
2947 |
|
2948 |
|
2949 |
|
2950 |
|
2951 |
|
2952 |
|
2953 |
|
2954 |
|
2955 |
|
2956 |
|
2957 |
|
2958 |
|
2959 |
|
2960 |
|
2961 |
|
2962 |
|
2963 | const D$1 = 7;
|
2964 | const Dc = 6;
|
2965 | const T$2 = 5;
|
2966 | const Tc = 4;
|
2967 | const S$2 = 3;
|
2968 | const Sc = 2;
|
2969 | const SS = 1;
|
2970 | const SSc = 0;
|
2971 |
|
2972 |
|
2973 |
|
2974 |
|
2975 |
|
2976 |
|
2977 | class Mathstyle {
|
2978 | constructor(id, sizeDelta, cramped) {
|
2979 | this.id = id;
|
2980 | this.sizeDelta = sizeDelta;
|
2981 | this.cramped = cramped;
|
2982 | const metricsIndex = { '-4': 2, '-3': 1, 0: 0 }[sizeDelta];
|
2983 | this.metrics = Object.keys(FONT_METRICS).reduce((acc, x) => {
|
2984 | return { ...acc, [x]: FONT_METRICS[x][metricsIndex] };
|
2985 | }, {});
|
2986 | }
|
2987 | getFontSize(size) {
|
2988 | return Math.max(1, size + this.sizeDelta);
|
2989 | }
|
2990 | |
2991 |
|
2992 |
|
2993 | get sup() {
|
2994 | return MATHSTYLES[[SSc, SS, SSc, SS, Sc, S$2, Sc, S$2][this.id]];
|
2995 | }
|
2996 | |
2997 |
|
2998 |
|
2999 | get sub() {
|
3000 | return MATHSTYLES[[SSc, SSc, SSc, SSc, Sc, Sc, Sc, Sc][this.id]];
|
3001 | }
|
3002 | |
3003 |
|
3004 |
|
3005 |
|
3006 |
|
3007 | get fracNum() {
|
3008 | return MATHSTYLES[[SSc, SS, SSc, SS, Sc, S$2, Tc, T$2][this.id]];
|
3009 | }
|
3010 | |
3011 |
|
3012 |
|
3013 |
|
3014 |
|
3015 | get fracDen() {
|
3016 | return MATHSTYLES[[SSc, SSc, SSc, SSc, Sc, Sc, Tc, Tc][this.id]];
|
3017 | }
|
3018 | |
3019 |
|
3020 |
|
3021 |
|
3022 | get cramp() {
|
3023 | return MATHSTYLES[[SSc, SSc, Sc, Sc, Tc, Tc, Dc, Dc][this.id]];
|
3024 | }
|
3025 | |
3026 |
|
3027 |
|
3028 | get isTight() {
|
3029 | return this.sizeDelta < 0;
|
3030 | }
|
3031 | }
|
3032 | const MATHSTYLES = {
|
3033 | 7: new Mathstyle(D$1, 0, false),
|
3034 | 6: new Mathstyle(Dc, 0, true),
|
3035 | 5: new Mathstyle(T$2, 0, false),
|
3036 | 4: new Mathstyle(Tc, 0, true),
|
3037 | 3: new Mathstyle(S$2, -3, false),
|
3038 | 2: new Mathstyle(Sc, -3, true),
|
3039 | 1: new Mathstyle(SS, -4, false),
|
3040 | 0: new Mathstyle(SSc, -4, true),
|
3041 | };
|
3042 |
|
3043 | MATHSTYLES.displaystyle = MATHSTYLES[D$1];
|
3044 | MATHSTYLES.textstyle = MATHSTYLES[T$2];
|
3045 | MATHSTYLES.scriptstyle = MATHSTYLES[S$2];
|
3046 | MATHSTYLES.scriptscriptstyle = MATHSTYLES[SS];
|
3047 |
|
3048 | function convertDimensionToPt(value, precision) {
|
3049 | var _a;
|
3050 | if (!value)
|
3051 | return 0;
|
3052 |
|
3053 | const f = {
|
3054 | pt: 1,
|
3055 | mm: 7227 / 2540,
|
3056 | cm: 7227 / 254,
|
3057 | ex: 35271 / 8192,
|
3058 | px: 3 / 4,
|
3059 | em: PT_PER_EM,
|
3060 | bp: 803 / 800,
|
3061 | dd: 1238 / 1157,
|
3062 | pc: 12,
|
3063 | in: 72.27,
|
3064 | mu: 10 / 18,
|
3065 | }[(_a = value.unit) !== null && _a !== void 0 ? _a : 'pt'];
|
3066 | if (Number.isFinite(precision)) {
|
3067 | const factor = 10 ** precision;
|
3068 | return Math.round((value.dimension / PT_PER_EM) * f * factor) / factor;
|
3069 | }
|
3070 | return value.dimension * f;
|
3071 | }
|
3072 | function convertDimensionToEm(value, precision) {
|
3073 | if (value === null)
|
3074 | return 0;
|
3075 | return convertDimensionToPt(value, precision) / PT_PER_EM;
|
3076 | }
|
3077 | function convertGlueToEm(value) {
|
3078 | return convertDimensionToEm(value.glue);
|
3079 | }
|
3080 | function serializeDimension(value) {
|
3081 | var _a;
|
3082 | return `${value.dimension}${(_a = value.unit) !== null && _a !== void 0 ? _a : 'pt'}`;
|
3083 | }
|
3084 |
|
3085 |
|
3086 |
|
3087 |
|
3088 |
|
3089 |
|
3090 |
|
3091 |
|
3092 |
|
3093 |
|
3094 |
|
3095 |
|
3096 |
|
3097 |
|
3098 |
|
3099 |
|
3100 |
|
3101 |
|
3102 |
|
3103 |
|
3104 |
|
3105 |
|
3106 |
|
3107 |
|
3108 |
|
3109 |
|
3110 |
|
3111 |
|
3112 |
|
3113 | class Context {
|
3114 | constructor(parent, style, inMathstyle) {
|
3115 | var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
3116 |
|
3117 |
|
3118 | console.assert(parent instanceof Context || (style === null || style === void 0 ? void 0 : style.fontSize) !== undefined);
|
3119 | console.assert(parent instanceof Context || inMathstyle !== undefined);
|
3120 | if (parent instanceof Context)
|
3121 | this.parent = parent;
|
3122 | if (!(parent instanceof Context))
|
3123 | this.registers = (_a = parent.registers) !== null && _a !== void 0 ? _a : {};
|
3124 | this.isSelected = (_c = (_b = style === null || style === void 0 ? void 0 : style.isSelected) !== null && _b !== void 0 ? _b : parent === null || parent === void 0 ? void 0 : parent.isSelected) !== null && _c !== void 0 ? _c : false;
|
3125 | this.isPhantom = (_f = (_d = style === null || style === void 0 ? void 0 : style.isPhantom) !== null && _d !== void 0 ? _d : (_e = this.parent) === null || _e === void 0 ? void 0 : _e.isPhantom) !== null && _f !== void 0 ? _f : false;
|
3126 | const from = {
|
3127 | ...parent,
|
3128 | };
|
3129 | if (style) {
|
3130 | let size = undefined;
|
3131 | if (style.fontSize &&
|
3132 | style.fontSize !== 'auto' &&
|
3133 | style.fontSize !== ((_g = this.parent) === null || _g === void 0 ? void 0 : _g._size)) {
|
3134 | size = style.fontSize;
|
3135 | }
|
3136 | if (style.letterShapeStyle && style.letterShapeStyle !== 'auto') {
|
3137 | from.letterShapeStyle = style.letterShapeStyle;
|
3138 | }
|
3139 | if (style.color && style.color !== 'none')
|
3140 | from.color = style.color;
|
3141 | if (style.backgroundColor && style.backgroundColor !== 'none') {
|
3142 | from.backgroundColor = this.isSelected
|
3143 | ? highlight(style.backgroundColor)
|
3144 | : style.backgroundColor;
|
3145 | }
|
3146 | this._size = size;
|
3147 | }
|
3148 | this.letterShapeStyle = (_h = from.letterShapeStyle) !== null && _h !== void 0 ? _h : 'tex';
|
3149 | this.color = from.color;
|
3150 | this.backgroundColor = from.backgroundColor;
|
3151 | let mathstyle;
|
3152 | if (typeof inMathstyle === 'string') {
|
3153 | if (parent instanceof Context) {
|
3154 | switch (inMathstyle) {
|
3155 | case 'cramp':
|
3156 | mathstyle = parent.mathstyle.cramp;
|
3157 | break;
|
3158 | case 'superscript':
|
3159 | mathstyle = parent.mathstyle.sup;
|
3160 | break;
|
3161 | case 'subscript':
|
3162 | mathstyle = parent.mathstyle.sub;
|
3163 | break;
|
3164 | case 'numerator':
|
3165 | mathstyle = parent.mathstyle.fracNum;
|
3166 | break;
|
3167 | case 'denominator':
|
3168 | mathstyle = parent.mathstyle.fracDen;
|
3169 | break;
|
3170 | }
|
3171 | }
|
3172 | switch (inMathstyle) {
|
3173 | case 'textstyle':
|
3174 | mathstyle = MATHSTYLES.textstyle;
|
3175 | break;
|
3176 | case 'displaystyle':
|
3177 | mathstyle = MATHSTYLES.displaystyle;
|
3178 | break;
|
3179 | case 'scriptstyle':
|
3180 | mathstyle = MATHSTYLES.scriptstyle;
|
3181 | break;
|
3182 | case 'scriptscriptstyle':
|
3183 | mathstyle = MATHSTYLES.scriptscriptstyle;
|
3184 | break;
|
3185 | }
|
3186 | }
|
3187 | this._mathstyle = mathstyle;
|
3188 | this.atomIdsSettings = parent.atomIdsSettings;
|
3189 | this.macros = (_j = from.macros) !== null && _j !== void 0 ? _j : {};
|
3190 | this.smartFence = (_k = from.smartFence) !== null && _k !== void 0 ? _k : false;
|
3191 | this.renderPlaceholder = from.renderPlaceholder;
|
3192 | console.assert(!(parent instanceof Context) ||
|
3193 | this.atomIdsSettings === parent.atomIdsSettings);
|
3194 | }
|
3195 | get mathstyle() {
|
3196 | let result = this._mathstyle;
|
3197 | let parent = this.parent;
|
3198 | while (!result) {
|
3199 | result = parent._mathstyle;
|
3200 | parent = parent.parent;
|
3201 | }
|
3202 | return result;
|
3203 | }
|
3204 | getRegister(name) {
|
3205 | var _a;
|
3206 | if ((_a = this.registers) === null || _a === void 0 ? void 0 : _a[name])
|
3207 | return this.registers[name];
|
3208 | if (this.parent)
|
3209 | return this.parent.getRegister(name);
|
3210 | return undefined;
|
3211 | }
|
3212 | getRegisterAsGlue(name) {
|
3213 | var _a;
|
3214 | if ((_a = this.registers) === null || _a === void 0 ? void 0 : _a[name]) {
|
3215 | const value = this.registers[name];
|
3216 | if (typeof value === 'object' && 'glue' in value) {
|
3217 | return value;
|
3218 | }
|
3219 | else if (typeof value === 'object' && 'dimension' in value) {
|
3220 | return { glue: { dimension: value.dimension } };
|
3221 | }
|
3222 | else if (typeof value === 'number') {
|
3223 | return { glue: { dimension: value } };
|
3224 | }
|
3225 | return undefined;
|
3226 | }
|
3227 | if (this.parent)
|
3228 | return this.parent.getRegisterAsGlue(name);
|
3229 | return undefined;
|
3230 | }
|
3231 | getRegisterAsEm(name) {
|
3232 | return convertDimensionToEm(this.getRegisterAsDimension(name));
|
3233 | }
|
3234 | getRegisterAsDimension(name) {
|
3235 | var _a;
|
3236 | if ((_a = this.registers) === null || _a === void 0 ? void 0 : _a[name]) {
|
3237 | const value = this.registers[name];
|
3238 | if (typeof value === 'object' && 'glue' in value) {
|
3239 | return value.glue;
|
3240 | }
|
3241 | else if (typeof value === 'object' && 'dimension' in value) {
|
3242 | return value;
|
3243 | }
|
3244 | else if (typeof value === 'number') {
|
3245 | return { dimension: value };
|
3246 | }
|
3247 | return undefined;
|
3248 | }
|
3249 | if (this.parent)
|
3250 | return this.parent.getRegisterAsDimension(name);
|
3251 | return undefined;
|
3252 | }
|
3253 | setRegister(name, value) {
|
3254 | if (value === undefined) {
|
3255 | delete this.registers[name];
|
3256 | return;
|
3257 | }
|
3258 | this.registers[name] = value;
|
3259 | }
|
3260 | setGlobalRegister(name, value) {
|
3261 |
|
3262 | let root = this;
|
3263 | while (root.parent) {
|
3264 | root.setRegister(name, undefined);
|
3265 | root = root.parent;
|
3266 | }
|
3267 | root.setRegister(name, value);
|
3268 | }
|
3269 | get size() {
|
3270 | let result = this._size;
|
3271 | let parent = this.parent;
|
3272 | while (!result) {
|
3273 | result = parent._size;
|
3274 | parent = parent.parent;
|
3275 | }
|
3276 | return result;
|
3277 | }
|
3278 | makeID() {
|
3279 | if (!this.atomIdsSettings)
|
3280 | return undefined;
|
3281 | if (typeof this.atomIdsSettings.seed !== 'number') {
|
3282 | return (Date.now().toString(36).slice(-2) +
|
3283 | Math.floor(Math.random() * 0x186a0).toString(36));
|
3284 | }
|
3285 | const result = this.atomIdsSettings.overrideID
|
3286 | ? this.atomIdsSettings.overrideID
|
3287 | : this.atomIdsSettings.seed.toString(36);
|
3288 | this.atomIdsSettings.seed += 1;
|
3289 | return result;
|
3290 | }
|
3291 |
|
3292 |
|
3293 | scale(value) {
|
3294 | return value * this.effectiveFontSize;
|
3295 | }
|
3296 | get scalingFactor() {
|
3297 | if (!this.parent)
|
3298 | return 1.0;
|
3299 | return this.effectiveFontSize / this.parent.effectiveFontSize;
|
3300 | }
|
3301 | get isDisplayStyle() {
|
3302 | return this.mathstyle.id === D$1 || this.mathstyle.id === Dc;
|
3303 | }
|
3304 | get isCramped() {
|
3305 | return this.mathstyle.cramped;
|
3306 | }
|
3307 | get isTight() {
|
3308 | return this.mathstyle.isTight;
|
3309 | }
|
3310 |
|
3311 |
|
3312 | get effectiveFontSize() {
|
3313 | return FONT_SCALE[Math.max(1, this.size + this.mathstyle.sizeDelta)];
|
3314 | }
|
3315 | get computedColor() {
|
3316 | let result = this.color;
|
3317 | let parent = this.parent;
|
3318 | if (!result && parent) {
|
3319 | result = parent.color;
|
3320 | parent = parent.parent;
|
3321 | }
|
3322 | return result !== null && result !== void 0 ? result : '';
|
3323 | }
|
3324 | get computedBackgroundColor() {
|
3325 | let result = this.backgroundColor;
|
3326 | let parent = this.parent;
|
3327 | if (!result && parent) {
|
3328 | result = parent.backgroundColor;
|
3329 | parent = parent.parent;
|
3330 | }
|
3331 | return result !== null && result !== void 0 ? result : '';
|
3332 | }
|
3333 | get metrics() {
|
3334 | return this.mathstyle.metrics;
|
3335 | }
|
3336 | }
|
3337 |
|
3338 | const SVG_BODY = {
|
3339 |
|
3340 | overrightarrow: [['rightarrow'], 0.888, 522, 'xMaxYMin'],
|
3341 | overleftarrow: [['leftarrow'], 0.888, 522, 'xMinYMin'],
|
3342 | underrightarrow: [['rightarrow'], 0.888, 522, 'xMaxYMin'],
|
3343 | underleftarrow: [['leftarrow'], 0.888, 522, 'xMinYMin'],
|
3344 | xrightarrow: [['rightarrow'], 1.469, 522, 'xMaxYMin'],
|
3345 | xleftarrow: [['leftarrow'], 1.469, 522, 'xMinYMin'],
|
3346 | Overrightarrow: [['doublerightarrow'], 0.888, 560, 'xMaxYMin'],
|
3347 | xRightarrow: [['doublerightarrow'], 1.526, 560, 'xMaxYMin'],
|
3348 | xLeftarrow: [['doubleleftarrow'], 1.526, 560, 'xMinYMin'],
|
3349 | overleftharpoon: [['leftharpoon'], 0.888, 522, 'xMinYMin'],
|
3350 | xleftharpoonup: [['leftharpoon'], 0.888, 522, 'xMinYMin'],
|
3351 | xleftharpoondown: [['leftharpoondown'], 0.888, 522, 'xMinYMin'],
|
3352 | overrightharpoon: [['rightharpoon'], 0.888, 522, 'xMaxYMin'],
|
3353 | xrightharpoonup: [['rightharpoon'], 0.888, 522, 'xMaxYMin'],
|
3354 | xrightharpoondown: [['rightharpoondown'], 0.888, 522, 'xMaxYMin'],
|
3355 | xlongequal: [['longequal'], 0.888, 334, 'xMinYMin'],
|
3356 | xtwoheadleftarrow: [['twoheadleftarrow'], 0.888, 334, 'xMinYMin'],
|
3357 | xtwoheadrightarrow: [['twoheadrightarrow'], 0.888, 334, 'xMaxYMin'],
|
3358 | overleftrightarrow: [['leftarrow', 'rightarrow'], 0.888, 522],
|
3359 | overbrace: [['leftbrace', 'midbrace', 'rightbrace'], 1.6, 548],
|
3360 | underbrace: [
|
3361 | ['leftbraceunder', 'midbraceunder', 'rightbraceunder'],
|
3362 | 1.6,
|
3363 | 548,
|
3364 | ],
|
3365 | underleftrightarrow: [['leftarrow', 'rightarrow'], 0.888, 522],
|
3366 | xleftrightarrow: [['leftarrow', 'rightarrow'], 1.75, 522],
|
3367 | xLeftrightarrow: [['doubleleftarrow', 'doublerightarrow'], 1.75, 560],
|
3368 | xrightleftharpoons: [['leftharpoondownplus', 'rightharpoonplus'], 1.75, 716],
|
3369 | xleftrightharpoons: [['leftharpoonplus', 'rightharpoondownplus'], 1.75, 716],
|
3370 | xhookleftarrow: [['leftarrow', 'righthook'], 1.08, 522],
|
3371 | xhookrightarrow: [['lefthook', 'rightarrow'], 1.08, 522],
|
3372 | overlinesegment: [['leftlinesegment', 'rightlinesegment'], 0.888, 522],
|
3373 | underlinesegment: [['leftlinesegment', 'rightlinesegment'], 0.888, 522],
|
3374 | overgroup: [['leftgroup', 'rightgroup'], 0.888, 342],
|
3375 | undergroup: [['leftgroupunder', 'rightgroupunder'], 0.888, 342],
|
3376 | xmapsto: [['leftmapsto', 'rightarrow'], 1.5, 522],
|
3377 | xtofrom: [['leftToFrom', 'rightToFrom'], 1.75, 528],
|
3378 |
|
3379 |
|
3380 |
|
3381 |
|
3382 | xrightleftarrows: [['baraboveleftarrow', 'rightarrowabovebar'], 1.75, 901],
|
3383 | xrightequilibrium: [
|
3384 | ['baraboveshortleftharpoon', 'rightharpoonaboveshortbar'],
|
3385 | 1.75,
|
3386 | 716,
|
3387 | ],
|
3388 | xleftequilibrium: [
|
3389 | ['shortbaraboveleftharpoon', 'shortrightharpoonabovebar'],
|
3390 | 1.75,
|
3391 | 716,
|
3392 | ],
|
3393 | };
|
3394 |
|
3395 |
|
3396 |
|
3397 | const SVG_ACCENTS = {
|
3398 |
|
3399 | widehat1: [1062, 239, 0.24],
|
3400 | widehat2: [2364, 300, 0.3],
|
3401 | widehat3: [2364, 360, 0.36],
|
3402 | widehat4: [2364, 420, 0.42],
|
3403 | widecheck1: [1062, 239, 0.24],
|
3404 | widecheck2: [2364, 300, 0.3],
|
3405 | widecheck3: [2364, 360, 0.36],
|
3406 | widecheck4: [2364, 420, 0.42],
|
3407 | widetilde1: [600, 260, 0.26],
|
3408 | widetilde2: [1033, 286, 0.286],
|
3409 | widetilde3: [2339, 306, 0.306],
|
3410 | widetilde4: [2340, 312, 0.34],
|
3411 | overarc: [1061, 159, 0.3],
|
3412 | underarc: [1061, 159, 0.3],
|
3413 | };
|
3414 |
|
3415 | const PATHS = {
|
3416 |
|
3417 | doubleleftarrow: `M262 157
|
3418 | l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3
|
3419 | 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28
|
3420 | 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5
|
3421 | c2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5
|
3422 | 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87
|
3423 | -86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7
|
3424 | -2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z
|
3425 | m8 0v40h399730v-40zm0 194v40h399730v-40z`,
|
3426 |
|
3427 | doublerightarrow: `M399738 392l
|
3428 | -10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5
|
3429 | 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88
|
3430 | -33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68
|
3431 | -17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18
|
3432 | -13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782
|
3433 | c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3
|
3434 | -107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z`,
|
3435 |
|
3436 | leftarrow: `M400000 241H110l3-3c68.7-52.7 113.7-120
|
3437 | 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
|
3438 | -5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
|
3439 | c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
|
3440 | 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
|
3441 | 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
|
3442 | l-3-3h399890zM100 241v40h399900v-40z`,
|
3443 |
|
3444 | leftbrace: `M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117
|
3445 | -45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7
|
3446 | 5-6 9-10 13-.7 1-7.3 1-20 1H6z`,
|
3447 | leftbraceunder: `M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13
|
3448 | 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688
|
3449 | 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7
|
3450 | -331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z`,
|
3451 | overarc: `M529 0c179 0 524 115 524 115 5 1 9 5 9 10 0 1-1 2-1 3l-4 22c-1 5-5 9-11 9h-2s-338-93-512-92c-174 0-513 92-513 92h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13 0 0 342-115 520-115z`,
|
3452 | underarc: `m 529 160
|
3453 | c -179 0 -524 -115 -524 -115
|
3454 | c -5 -1 -9 -5 -9 -10
|
3455 | c 0 -1 1 -2 1 -3
|
3456 | l 4 -22
|
3457 | c 1 -5 5 -9 11 -9
|
3458 | h 2
|
3459 | s 338 93 512 92
|
3460 | c 174 0 513 -92 513 -92
|
3461 | h 2
|
3462 | c 5 0 9 4 11 9
|
3463 | l 5 22
|
3464 | c 1 6 -2 12 -8 13
|
3465 | c 0 0 -342 115 -520 115
|
3466 | z
|
3467 | `,
|
3468 |
|
3469 | leftgroup: `M400000 80
|
3470 | H435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0
|
3471 | 435 0h399565z`,
|
3472 | leftgroupunder: `M400000 262
|
3473 | H435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219
|
3474 | 435 219h399565z`,
|
3475 |
|
3476 | leftharpoon: `M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3
|
3477 | -3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5
|
3478 | -18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7
|
3479 | -196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z`,
|
3480 | leftharpoonplus: `M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5
|
3481 | 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3
|
3482 | -4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7
|
3483 | -10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z
|
3484 | m0 0v40h400000v-40z`,
|
3485 | leftharpoondown: `M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333
|
3486 | 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5
|
3487 | 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667
|
3488 | -152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z`,
|
3489 | leftharpoondownplus: `M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12
|
3490 | 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7
|
3491 | -2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0
|
3492 | v40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z`,
|
3493 |
|
3494 | lefthook: `M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5
|
3495 | -83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3
|
3496 | -68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21
|
3497 | 71.5 23h399859zM103 281v-40h399897v40z`,
|
3498 | leftlinesegment: `M40 281 V428 H0 V94 H40 V241 H400000 v40z
|
3499 | M40 281 V428 H0 V94 H40 V241 H400000 v40z`,
|
3500 | leftmapsto: `M40 281 V448H0V74H40V241H400000v40z
|
3501 | M40 281 V448H0V74H40V241H400000v40z`,
|
3502 |
|
3503 | leftToFrom: `M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23
|
3504 | -.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8
|
3505 | c28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3
|
3506 | 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z`,
|
3507 | longequal: `M0 50 h400000 v40H0z m0 194h40000v40H0z
|
3508 | M0 50 h400000 v40H0z m0 194h40000v40H0z`,
|
3509 | midbrace: `M200428 334
|
3510 | c-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14
|
3511 | -53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7
|
3512 | 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11
|
3513 | 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z`,
|
3514 | midbraceunder: `M199572 214
|
3515 | c100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14
|
3516 | 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3
|
3517 | 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0
|
3518 | -5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z`,
|
3519 | oiintSize1: `M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6
|
3520 | -320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z
|
3521 | m368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8
|
3522 | 60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z`,
|
3523 | oiintSize2: `M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8
|
3524 | -451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z
|
3525 | m502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2
|
3526 | c0 110 84 276 504 276s502.4-166 502.4-276z`,
|
3527 | oiiintSize1: `M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6
|
3528 | -480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z
|
3529 | m525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0
|
3530 | 85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z`,
|
3531 | oiiintSize2: `M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8
|
3532 | -707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z
|
3533 | m770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1
|
3534 | c0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z`,
|
3535 | rightarrow: `M0 241v40h399891c-47.3 35.3-84 78-110 128
|
3536 | -16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
|
3537 | 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
|
3538 | 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
|
3539 | -40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
|
3540 | -12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
|
3541 | 151.7 139 205zm0 0v40h399900v-40z`,
|
3542 | rightbrace: `M400000 542l
|
3543 | -6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5
|
3544 | s-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1
|
3545 | c124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z`,
|
3546 | rightbraceunder: `M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3
|
3547 | 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237
|
3548 | -174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z`,
|
3549 | rightgroup: `M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0
|
3550 | 3-1 3-3v-38c-76-158-257-219-435-219H0z`,
|
3551 | rightgroupunder: `M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18
|
3552 | 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z`,
|
3553 | rightharpoon: `M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3
|
3554 | -3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2
|
3555 | -10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58
|
3556 | 69.2 92 94.5zm0 0v40h399900v-40z`,
|
3557 | rightharpoonplus: `M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11
|
3558 | -18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7
|
3559 | 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z
|
3560 | m0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z`,
|
3561 | rightharpoondown: `M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8
|
3562 | 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5
|
3563 | -7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95
|
3564 | -27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z`,
|
3565 | rightharpoondownplus: `M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8
|
3566 | 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3
|
3567 | 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3
|
3568 | -64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z
|
3569 | m0-194v40h400000v-40zm0 0v40h400000v-40z`,
|
3570 | righthook: `M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3
|
3571 | 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0
|
3572 | -13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21
|
3573 | 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z`,
|
3574 | rightlinesegment: `M399960 241 V94 h40 V428 h-40 V281 H0 v-40z
|
3575 | M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`,
|
3576 | rightToFrom: `M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23
|
3577 | 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32
|
3578 | -52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142
|
3579 | -167z M100 147v40h399900v-40zM0 341v40h399900v-40z`,
|
3580 |
|
3581 | twoheadleftarrow: `M0 167c68 40
|
3582 | 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69
|
3583 | -70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3
|
3584 | -40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19
|
3585 | -37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101
|
3586 | 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z`,
|
3587 | twoheadrightarrow: `M400000 167
|
3588 | c-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3
|
3589 | 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42
|
3590 | 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333
|
3591 | -19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70
|
3592 | 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z`,
|
3593 |
|
3594 | widetilde1: `M200 55.538c-77 0-168 73.953-177 73.953-3 0-7
|
3595 | -2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0
|
3596 | 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0
|
3597 | 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128
|
3598 | -68.267.847-113-73.952-191-73.952z`,
|
3599 |
|
3600 | widetilde2: `M344 55.266c-142 0-300.638 81.316-311.5 86.418
|
3601 | -8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9
|
3602 | 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114
|
3603 | c1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751
|
3604 | 181.476 676 181.476c-149 0-189-126.21-332-126.21z`,
|
3605 | widetilde3: `M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457
|
3606 | -11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0
|
3607 | 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697
|
3608 | 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696
|
3609 | -338 0-409-156.573-744-156.573z`,
|
3610 | widetilde4: `M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345
|
3611 | -11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409
|
3612 | 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9
|
3613 | 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409
|
3614 | -175.236-744-175.236z`,
|
3615 |
|
3616 | vec: `M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5
|
3617 | 3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11
|
3618 | 10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63
|
3619 | -1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1
|
3620 | -7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59
|
3621 | H213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359
|
3622 | c-16-25.333-24-45-24-59z`,
|
3623 |
|
3624 | widehat1: `M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22
|
3625 | c-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z`,
|
3626 |
|
3627 | widehat2: `M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10
|
3628 | -11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`,
|
3629 | widehat3: `M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10
|
3630 | -11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`,
|
3631 | widehat4: `M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10
|
3632 | -11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`,
|
3633 |
|
3634 | widecheck1: `M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,
|
3635 | -5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z`,
|
3636 | widecheck2: `M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
|
3637 | -11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,
|
3638 | widecheck3: `M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
|
3639 | -11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,
|
3640 | widecheck4: `M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
|
3641 | -11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,
|
3642 |
|
3643 |
|
3644 |
|
3645 | baraboveleftarrow: `M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202
|
3646 | c4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5
|
3647 | c-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130
|
3648 | s-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47
|
3649 | 121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6
|
3650 | s2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11
|
3651 | c0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z
|
3652 | M100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z`,
|
3653 |
|
3654 | rightarrowabovebar: `M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32
|
3655 | -27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0
|
3656 | 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39
|
3657 | -84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5
|
3658 | -119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
|
3659 | -12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
|
3660 | 151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z`,
|
3661 |
|
3662 |
|
3663 | baraboveshortleftharpoon: `M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11
|
3664 | c1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17
|
3665 | c2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21
|
3666 | c-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40
|
3667 | c-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z
|
3668 | M0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z`,
|
3669 | rightharpoonaboveshortbar: `M0,241 l0,40c399126,0,399993,0,399993,0
|
3670 | c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,
|
3671 | -231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6
|
3672 | c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z
|
3673 | M0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z`,
|
3674 | shortbaraboveleftharpoon: `M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11
|
3675 | c1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,
|
3676 | 1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,
|
3677 | -152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z
|
3678 | M93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z`,
|
3679 | shortrightharpoonabovebar: `M53,241l0,40c398570,0,399437,0,399437,0
|
3680 | c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,
|
3681 | -231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6
|
3682 | c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z
|
3683 | M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`,
|
3684 | };
|
3685 |
|
3686 |
|
3687 |
|
3688 |
|
3689 | function svgBodyToMarkup(svgBodyName) {
|
3690 | if (SVG_ACCENTS[svgBodyName]) {
|
3691 | const [vbWidth, vbHeight, height] = SVG_ACCENTS[svgBodyName];
|
3692 | const result = `<span class="stretchy" style="height:${height}em">` +
|
3693 | `<svg width="100%" height="${height}em" ` +
|
3694 | `viewBox="0 0 ${vbWidth} ${vbHeight}" ` +
|
3695 | `preserveAspectRatio="none" >` +
|
3696 | `<path d="${PATHS[svgBodyName]}"></path>` +
|
3697 | `</svg></span>`;
|
3698 | return `<span style="display:inline-block;height:${height / 2}em;min-width:0">${result}</span>`;
|
3699 | }
|
3700 | const [paths, minWidth, viewBoxHeight, align] = SVG_BODY[svgBodyName];
|
3701 | let widthClasses;
|
3702 | let aligns;
|
3703 | const height = viewBoxHeight / 1000;
|
3704 | if (paths.length === 3) {
|
3705 | widthClasses = ['slice-1-of-3', 'slice-2-of-3', 'slice-3-of-3'];
|
3706 | aligns = ['xMinYMin', 'xMidYMin', 'xMaxYMin'];
|
3707 | }
|
3708 | else if (paths.length === 2) {
|
3709 | widthClasses = ['slice-1-of-2', 'slice-2-of-2'];
|
3710 | aligns = ['xMinYMin', 'xMaxYMin'];
|
3711 | }
|
3712 | else {
|
3713 | widthClasses = ['slice-1-of-1'];
|
3714 | aligns = [align];
|
3715 | }
|
3716 | const body = paths
|
3717 | .map((path, i) => `<span class="${widthClasses[i]}" style=height:${height}em>` +
|
3718 | `<svg width=400em height=${height}em ` +
|
3719 | `viewBox="0 0 400000 ${viewBoxHeight}" ` +
|
3720 | `preserveAspectRatio="${aligns[i]} slice">` +
|
3721 | `<path d="${PATHS[path]}"></path>` +
|
3722 | `</svg></span>`)
|
3723 | .join('');
|
3724 | return `<span style="display:inline-block;height:${height}em;min-width:${minWidth}em;">${body}</span>`;
|
3725 | }
|
3726 | function svgBodyHeight(svgBodyName) {
|
3727 | if (SVG_BODY[svgBodyName]) {
|
3728 | return SVG_BODY[svgBodyName][2] / 1000;
|
3729 | }
|
3730 | return SVG_ACCENTS[svgBodyName][2];
|
3731 | }
|
3732 |
|
3733 | class Mode {
|
3734 | constructor(name) {
|
3735 | Mode._registry[name] = this;
|
3736 | }
|
3737 | static createAtom(mode, command, style) {
|
3738 | return Mode._registry[mode].createAtom(command, style);
|
3739 | }
|
3740 | static parseTokens(mode, tokens, onError, options) {
|
3741 | return Mode._registry[mode].parseTokens(tokens, onError, options);
|
3742 | }
|
3743 |
|
3744 |
|
3745 | static serialize(run, options) {
|
3746 | console.assert(run.length > 0);
|
3747 | const mode = Mode._registry[run[0].mode];
|
3748 | return mode.serialize(run, options);
|
3749 | }
|
3750 | static applyStyle(mode, box, style) {
|
3751 | return Mode._registry[mode].applyStyle(box, style);
|
3752 | }
|
3753 | createAtom(_command, _style) {
|
3754 | return null;
|
3755 | }
|
3756 | parseTokens(_tokens, _onError, _options) {
|
3757 | return null;
|
3758 | }
|
3759 | serialize(_run, _options) {
|
3760 | return '';
|
3761 | }
|
3762 | |
3763 |
|
3764 |
|
3765 |
|
3766 |
|
3767 | applyStyle(_box, _style) {
|
3768 | return '';
|
3769 | }
|
3770 | }
|
3771 | Mode._registry = {};
|
3772 |
|
3773 |
|
3774 |
|
3775 | function getModeRuns(atoms) {
|
3776 | const result = [];
|
3777 | let run = [];
|
3778 | let currentMode = 'NONE';
|
3779 | for (const atom of atoms) {
|
3780 | if (atom.type !== 'first') {
|
3781 | if (atom.mode !== currentMode) {
|
3782 | if (run.length > 0)
|
3783 | result.push(run);
|
3784 | run = [atom];
|
3785 | currentMode = atom.mode;
|
3786 | }
|
3787 | else {
|
3788 | run.push(atom);
|
3789 | }
|
3790 | }
|
3791 | }
|
3792 |
|
3793 | if (run.length > 0)
|
3794 | result.push(run);
|
3795 | return result;
|
3796 | }
|
3797 |
|
3798 |
|
3799 |
|
3800 |
|
3801 | function getPropertyRuns(atoms, property) {
|
3802 | const result = [];
|
3803 | let run = [];
|
3804 | let currentValue = undefined;
|
3805 | for (const atom of atoms) {
|
3806 | if (atom.type !== 'first') {
|
3807 | let value;
|
3808 | if (property === 'variant') {
|
3809 | value = atom.style.variant;
|
3810 | if (atom.style.variantStyle && atom.style.variantStyle !== 'up') {
|
3811 | value += '-' + atom.style.variantStyle;
|
3812 | }
|
3813 | }
|
3814 | else if (property === 'cssClass') {
|
3815 | if (atom.type === 'group') {
|
3816 | value = atom.customClass;
|
3817 | }
|
3818 | }
|
3819 | else {
|
3820 | value = atom.style[property];
|
3821 | }
|
3822 | if (value === currentValue) {
|
3823 |
|
3824 | run.push(atom);
|
3825 | }
|
3826 | else {
|
3827 |
|
3828 |
|
3829 | if (run.length > 0)
|
3830 | result.push(run);
|
3831 | run = [atom];
|
3832 | currentValue = value;
|
3833 | }
|
3834 | }
|
3835 | }
|
3836 |
|
3837 | if (run.length > 0)
|
3838 | result.push(run);
|
3839 | return result;
|
3840 | }
|
3841 |
|
3842 |
|
3843 |
|
3844 |
|
3845 |
|
3846 |
|
3847 |
|
3848 |
|
3849 |
|
3850 |
|
3851 | const BOX_TYPE = [
|
3852 | '',
|
3853 | 'chem',
|
3854 | 'mord',
|
3855 | 'mbin',
|
3856 | 'mop',
|
3857 | 'mrel',
|
3858 | 'mopen',
|
3859 | 'mclose',
|
3860 | 'mpunct',
|
3861 | 'minner',
|
3862 | 'spacing',
|
3863 | 'first',
|
3864 | 'latex',
|
3865 | 'composition',
|
3866 | 'error',
|
3867 | 'placeholder',
|
3868 | 'supsub',
|
3869 | 'none',
|
3870 | 'mathfield',
|
3871 | ];
|
3872 | function isBoxType(type) {
|
3873 | return BOX_TYPE.includes(type);
|
3874 | }
|
3875 |
|
3876 |
|
3877 |
|
3878 |
|
3879 |
|
3880 |
|
3881 |
|
3882 |
|
3883 |
|
3884 |
|
3885 |
|
3886 |
|
3887 |
|
3888 |
|
3889 |
|
3890 |
|
3891 |
|
3892 |
|
3893 |
|
3894 |
|
3895 |
|
3896 |
|
3897 |
|
3898 |
|
3899 |
|
3900 | const INTER_ATOM_SPACING = {
|
3901 | mord: { mop: 3, mbin: 4, mrel: 5, minner: 3 },
|
3902 | mop: { mord: 3, mop: 3, rel: 5, minner: 3 },
|
3903 | mbin: { mord: 4, mop: 4, mopen: 4, minner: 4 },
|
3904 | mrel: { mord: 5, mop: 5, mopen: 5, minner: 5 },
|
3905 | mclose: { mop: 3, mbin: 4, mrel: 5, minner: 3 },
|
3906 | mpunct: { mord: 3, mop: 3, mrel: 3, mopen: 3, mpunct: 3, minner: 3 },
|
3907 | minner: { mord: 3, mop: 3, mbin: 4, mrel: 5, mopen: 3, mpunct: 3, minner: 3 },
|
3908 | };
|
3909 |
|
3910 |
|
3911 |
|
3912 |
|
3913 | const INTER_ATOM_TIGHT_SPACING = {
|
3914 | mord: { mop: 3 },
|
3915 | mop: { mord: 3, mop: 3 },
|
3916 | mclose: { mop: 3 },
|
3917 | minner: { mop: 3 },
|
3918 | };
|
3919 | function toString$1(arg1, arg2) {
|
3920 | if (typeof arg1 === 'string') {
|
3921 | return arg1;
|
3922 | }
|
3923 | if (typeof arg1 === 'number') {
|
3924 | console.assert(Number.isFinite(arg1));
|
3925 | const numValue = Math.ceil(1e2 * arg1) / 1e2;
|
3926 | if (numValue === 0)
|
3927 | return '0';
|
3928 | return numValue.toString() + (arg2 !== null && arg2 !== void 0 ? arg2 : '');
|
3929 | }
|
3930 | return '';
|
3931 | }
|
3932 |
|
3933 |
|
3934 |
|
3935 |
|
3936 |
|
3937 |
|
3938 |
|
3939 |
|
3940 |
|
3941 |
|
3942 |
|
3943 |
|
3944 |
|
3945 |
|
3946 |
|
3947 |
|
3948 |
|
3949 |
|
3950 |
|
3951 |
|
3952 |
|
3953 |
|
3954 |
|
3955 |
|
3956 |
|
3957 | class Box {
|
3958 | constructor(content, options) {
|
3959 | var _a, _b, _c, _d, _e, _f, _g, _h;
|
3960 | if (typeof content === 'number') {
|
3961 | this.value = String.fromCodePoint(content);
|
3962 | }
|
3963 | else if (typeof content === 'string') {
|
3964 | this.value = content;
|
3965 | }
|
3966 | else if (isArray(content)) {
|
3967 | this.children = content.filter((x) => x !== null);
|
3968 | }
|
3969 | else if (content && content instanceof Box) {
|
3970 | this.children = [content];
|
3971 | }
|
3972 | this.type = (_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : '';
|
3973 | this.isSelected = false;
|
3974 | this.isTight = (_b = options === null || options === void 0 ? void 0 : options.isTight) !== null && _b !== void 0 ? _b : false;
|
3975 | this.newList = (_c = options === null || options === void 0 ? void 0 : options.newList) !== null && _c !== void 0 ? _c : false;
|
3976 |
|
3977 |
|
3978 | if (options === null || options === void 0 ? void 0 : options.properties) {
|
3979 | for (const prop of Object.keys(options.properties)) {
|
3980 | this.setStyle(prop, options.properties[prop]);
|
3981 | }
|
3982 | }
|
3983 | if (options === null || options === void 0 ? void 0 : options.attributes)
|
3984 | this.attributes = options.attributes;
|
3985 |
|
3986 | this.classes = (_d = options === null || options === void 0 ? void 0 : options.classes) !== null && _d !== void 0 ? _d : '';
|
3987 | let fontName = (_e = options === null || options === void 0 ? void 0 : options.fontFamily) !== null && _e !== void 0 ? _e : 'Main-Regular';
|
3988 | if ((options === null || options === void 0 ? void 0 : options.style) && this.value) {
|
3989 | fontName =
|
3990 | (_g = Mode.applyStyle((_f = options.mode) !== null && _f !== void 0 ? _f : 'math', this, options.style)) !== null && _g !== void 0 ? _g : 'Main-Regular';
|
3991 | }
|
3992 | this.height = 0;
|
3993 | this.depth = 0;
|
3994 | this.skew = 0;
|
3995 | this.italic = 0;
|
3996 | this.maxFontSize = 0;
|
3997 |
|
3998 |
|
3999 |
|
4000 | if (typeof content === 'number') {
|
4001 |
|
4002 |
|
4003 |
|
4004 | const metrics = getCharacterMetrics(content, fontName);
|
4005 | this.height = metrics.height;
|
4006 | this.depth = metrics.depth;
|
4007 | this.skew = metrics.skew;
|
4008 | this.italic = metrics.italic;
|
4009 |
|
4010 |
|
4011 | this.right = metrics.italic;
|
4012 | }
|
4013 | else if (this.value) {
|
4014 |
|
4015 |
|
4016 |
|
4017 |
|
4018 | this.height = -Infinity;
|
4019 | this.depth = -Infinity;
|
4020 | this.skew = -Infinity;
|
4021 | this.italic = -Infinity;
|
4022 |
|
4023 |
|
4024 | for (let i = 0; i < this.value.length; i++) {
|
4025 | const metrics = getCharacterMetrics(this.value.codePointAt(i), fontName !== null && fontName !== void 0 ? fontName : 'Main-Regular');
|
4026 | this.height = Math.max(this.height, metrics.height);
|
4027 | this.depth = Math.max(this.depth, metrics.depth);
|
4028 | this.skew = metrics.skew;
|
4029 | this.italic = metrics.italic;
|
4030 | }
|
4031 | this.right = this.italic;
|
4032 | }
|
4033 | else if (this.type === 'latex') {
|
4034 |
|
4035 |
|
4036 |
|
4037 | this.height = 0.8;
|
4038 | this.depth = 0.2;
|
4039 | }
|
4040 | else if (this.children && this.children.length > 0) {
|
4041 |
|
4042 |
|
4043 |
|
4044 | if (this.children.length === 1) {
|
4045 |
|
4046 |
|
4047 |
|
4048 | const child = this.children[0];
|
4049 | this.height = child.height;
|
4050 | this.depth = child.depth;
|
4051 | this.maxFontSize = child.maxFontSize;
|
4052 | this.skew = child.skew;
|
4053 | this.italic = child.italic;
|
4054 | }
|
4055 | else {
|
4056 |
|
4057 |
|
4058 |
|
4059 |
|
4060 | let height = -Infinity;
|
4061 | let depth = -Infinity;
|
4062 | let maxFontSize = 0;
|
4063 | for (const child of this.children) {
|
4064 | if (child.height > height)
|
4065 | height = child.height;
|
4066 | if (child.depth > depth)
|
4067 | depth = child.depth;
|
4068 | maxFontSize = Math.max(maxFontSize, (_h = child.maxFontSize) !== null && _h !== void 0 ? _h : 0);
|
4069 | }
|
4070 | this.height = height;
|
4071 | this.depth = depth;
|
4072 | this.maxFontSize = maxFontSize;
|
4073 | }
|
4074 | }
|
4075 |
|
4076 |
|
4077 |
|
4078 | if ((options === null || options === void 0 ? void 0 : options.height) !== undefined)
|
4079 | this.height = options.height;
|
4080 | if ((options === null || options === void 0 ? void 0 : options.depth) !== undefined)
|
4081 | this.depth = options.depth;
|
4082 | if ((options === null || options === void 0 ? void 0 : options.maxFontSize) !== undefined) {
|
4083 | this.maxFontSize = options.maxFontSize;
|
4084 | }
|
4085 | }
|
4086 | set atomID(id) {
|
4087 | if (id === undefined)
|
4088 | return;
|
4089 | if (!this.attributes)
|
4090 | this.attributes = {};
|
4091 | this.attributes['data-atom-id'] = id;
|
4092 | }
|
4093 | selected(isSelected) {
|
4094 | this.isSelected = isSelected;
|
4095 | if (this.children) {
|
4096 | for (const child of this.children) {
|
4097 | child.selected(isSelected);
|
4098 | }
|
4099 | }
|
4100 | }
|
4101 | setStyle(prop, value, unit) {
|
4102 |
|
4103 |
|
4104 |
|
4105 | const v = toString$1(value, unit);
|
4106 | if (v.length > 0) {
|
4107 | if (!this.cssProperties)
|
4108 | this.cssProperties = {};
|
4109 | this.cssProperties[prop] = v;
|
4110 | }
|
4111 | }
|
4112 | setTop(top) {
|
4113 | if (Number.isFinite(top) && Math.abs(top) > 1e-2) {
|
4114 | if (!this.cssProperties)
|
4115 | this.cssProperties = {};
|
4116 | this.cssProperties.top = toString$1(top, 'em');
|
4117 | this.height -= top;
|
4118 | this.depth += top;
|
4119 | }
|
4120 | }
|
4121 | get left() {
|
4122 | var _a;
|
4123 | if ((_a = this.cssProperties) === null || _a === void 0 ? void 0 : _a['margin-left']) {
|
4124 | return Number.parseFloat(this.cssProperties['margin-left']);
|
4125 | }
|
4126 | return 0;
|
4127 | }
|
4128 | set left(value) {
|
4129 | if (!Number.isFinite(value))
|
4130 | return;
|
4131 | if (!this.cssProperties)
|
4132 | this.cssProperties = {};
|
4133 | if (value === 0) {
|
4134 | delete this.cssProperties['margin-left'];
|
4135 | }
|
4136 | else {
|
4137 | this.cssProperties['margin-left'] = toString$1(value, 'em');
|
4138 | }
|
4139 | }
|
4140 | set right(value) {
|
4141 | if (!Number.isFinite(value))
|
4142 | return;
|
4143 | if (!this.cssProperties)
|
4144 | this.cssProperties = {};
|
4145 | if (value === 0) {
|
4146 | delete this.cssProperties['margin-right'];
|
4147 | }
|
4148 | else {
|
4149 | this.cssProperties['margin-right'] = toString$1(value, 'em');
|
4150 | }
|
4151 | }
|
4152 | set width(value) {
|
4153 | if (!this.cssProperties)
|
4154 | this.cssProperties = {};
|
4155 | this.cssProperties.width = toString$1(value, 'em');
|
4156 | }
|
4157 | |
4158 |
|
4159 |
|
4160 |
|
4161 |
|
4162 | wrap(context, options) {
|
4163 | const parent = context.parent;
|
4164 |
|
4165 | if (!parent)
|
4166 | return this;
|
4167 | if (context.isPhantom) {
|
4168 | this.setStyle('opacity', 0);
|
4169 | }
|
4170 | const newColor = context.computedColor === parent.computedColor
|
4171 | ? undefined
|
4172 | : context.color;
|
4173 |
|
4174 |
|
4175 |
|
4176 | this.setStyle('color', newColor);
|
4177 | const newSize = context.effectiveFontSize === parent.effectiveFontSize
|
4178 | ? undefined
|
4179 | : context.effectiveFontSize;
|
4180 | const newBackgroundColor = context.computedBackgroundColor === parent.computedBackgroundColor
|
4181 | ? undefined
|
4182 | : context.backgroundColor;
|
4183 |
|
4184 |
|
4185 |
|
4186 |
|
4187 |
|
4188 |
|
4189 |
|
4190 | if (!newSize &&
|
4191 | !newBackgroundColor &&
|
4192 | !(options && (options.classes || options.type))) {
|
4193 | return this;
|
4194 | }
|
4195 | let result;
|
4196 | if (newBackgroundColor) {
|
4197 | result = makeStruts(this, options);
|
4198 | result.selected(this.isSelected);
|
4199 | result.setStyle('background-color', newBackgroundColor);
|
4200 | result.setStyle('display', 'inline-block');
|
4201 | }
|
4202 | else {
|
4203 | result = new Box(this, options);
|
4204 | }
|
4205 |
|
4206 |
|
4207 |
|
4208 | const factor = context.scalingFactor;
|
4209 | if (factor !== 1.0) {
|
4210 | result.setStyle('font-size', factor * 100, '%');
|
4211 | result.height *= factor;
|
4212 | result.depth *= factor;
|
4213 | result.italic *= factor;
|
4214 | result.skew *= factor;
|
4215 | }
|
4216 | return result;
|
4217 | }
|
4218 | |
4219 |
|
4220 |
|
4221 | toMarkup() {
|
4222 | var _a, _b, _c;
|
4223 | let body = (_a = this.value) !== null && _a !== void 0 ? _a : '';
|
4224 |
|
4225 |
|
4226 |
|
4227 | if (this.children) {
|
4228 | for (const box of this.children) {
|
4229 | body += box.toMarkup();
|
4230 | }
|
4231 | }
|
4232 |
|
4233 |
|
4234 |
|
4235 | const classes = this.classes.split(' ');
|
4236 | classes.push((_b = {
|
4237 | latex: 'ML__latex',
|
4238 | placeholder: 'ML__placeholder',
|
4239 | error: 'ML__error',
|
4240 | }[this.type]) !== null && _b !== void 0 ? _b : '');
|
4241 | if (this.caret === 'latex') {
|
4242 | classes.push('ML__latex-caret');
|
4243 | }
|
4244 |
|
4245 | const classList = classes.length === 1
|
4246 | ? classes[0]
|
4247 | : classes
|
4248 | .filter((x, e, a) => x.length > 0 && a.indexOf(x) === e)
|
4249 | .join(' ');
|
4250 |
|
4251 |
|
4252 |
|
4253 | let result = '';
|
4254 | if ((body.length > 0 && body !== '\u200B') ||
|
4255 | classList.length > 0 ||
|
4256 | this.cssId ||
|
4257 | this.htmlData ||
|
4258 | this.attributes ||
|
4259 | this.cssProperties ||
|
4260 | this.svgBody ||
|
4261 | this.svgOverlay) {
|
4262 | let props = '';
|
4263 | if (this.cssId) {
|
4264 |
|
4265 | props += ` id=${this.cssId.replace(/ /g, '-')} `;
|
4266 | }
|
4267 | if (this.htmlData) {
|
4268 | const entries = this.htmlData.split(',');
|
4269 | for (const entry of entries) {
|
4270 | const matched = entry.match(/([^=]+)=(.+$)/);
|
4271 | if (matched) {
|
4272 | const key = matched[1].trim().replace(/ /g, '-');
|
4273 | if (key) {
|
4274 | props += ` data-${key}=${matched[2]} `;
|
4275 | }
|
4276 | }
|
4277 | else {
|
4278 | const key = entry.trim().replace(/ /g, '-');
|
4279 | if (key) {
|
4280 | props += ` data-${key} `;
|
4281 | }
|
4282 | }
|
4283 | }
|
4284 | }
|
4285 | if (this.attributes) {
|
4286 | props +=
|
4287 | ' ' +
|
4288 | Object.keys(this.attributes)
|
4289 | .map((x) => `${x}="${this.attributes[x]}"`)
|
4290 | .join(' ');
|
4291 | }
|
4292 | if (classList.length > 0) {
|
4293 | props += ` class="${classList}"`;
|
4294 | }
|
4295 | if (this.cssProperties) {
|
4296 | const styleString = Object.keys(this.cssProperties)
|
4297 | .map((x) => `${x}:${this.cssProperties[x]}`)
|
4298 | .join(';');
|
4299 | if (styleString.length > 0) {
|
4300 | props += ` style="${styleString}"`;
|
4301 | }
|
4302 | }
|
4303 |
|
4304 |
|
4305 |
|
4306 |
|
4307 | let svgMarkup = '';
|
4308 | if (this.svgBody) {
|
4309 | svgMarkup = svgBodyToMarkup(this.svgBody);
|
4310 | }
|
4311 | else if (this.svgOverlay) {
|
4312 | svgMarkup = '<span style="';
|
4313 | svgMarkup += 'display: inline-block;';
|
4314 | svgMarkup += `height:${this.height + this.depth}em;`;
|
4315 | svgMarkup += `vertical-align:${this.depth}em;`;
|
4316 | svgMarkup += '">';
|
4317 | svgMarkup += body;
|
4318 | svgMarkup += '</span>';
|
4319 | svgMarkup += '<svg style="position:absolute;overflow:overlay;';
|
4320 | svgMarkup += `height:${this.height + this.depth}em;`;
|
4321 | if ((_c = this.cssProperties) === null || _c === void 0 ? void 0 : _c.padding) {
|
4322 | svgMarkup += `top:${this.cssProperties.padding}em;`;
|
4323 | svgMarkup += `left:${this.cssProperties.padding}em;`;
|
4324 | svgMarkup += `width:calc(100% - 2 * ${this.cssProperties.padding}em );`;
|
4325 | }
|
4326 | else {
|
4327 | svgMarkup += 'top:0;left:0;width:100%;';
|
4328 | }
|
4329 | svgMarkup += 'z-index:2;';
|
4330 | svgMarkup += '"';
|
4331 | if (this.svgStyle) {
|
4332 | svgMarkup += ` style="${this.svgStyle}"`;
|
4333 | }
|
4334 | svgMarkup += `>${this.svgOverlay}</svg>`;
|
4335 | }
|
4336 |
|
4337 |
|
4338 | result = `<span${props}>${body}${svgMarkup}</span>`;
|
4339 | }
|
4340 |
|
4341 |
|
4342 |
|
4343 | if (this.caret === 'text') {
|
4344 | result += '<span class="ML__text-caret"></span>';
|
4345 | }
|
4346 | else if (this.caret === 'math') {
|
4347 | result += '<span class="ML__caret"></span>';
|
4348 | }
|
4349 | return result;
|
4350 | }
|
4351 | |
4352 |
|
4353 |
|
4354 |
|
4355 |
|
4356 |
|
4357 |
|
4358 |
|
4359 |
|
4360 | tryCoalesceWith(box) {
|
4361 |
|
4362 | if (this.type !== box.type)
|
4363 | return false;
|
4364 |
|
4365 | if (!/ML__text/.test(this.classes) &&
|
4366 | !['mord', 'mbin', 'mrel'].includes(this.type)) {
|
4367 | return false;
|
4368 | }
|
4369 |
|
4370 | if (this.svgBody || !this.value)
|
4371 | return false;
|
4372 | if (box.svgBody || !box.value)
|
4373 | return false;
|
4374 |
|
4375 |
|
4376 | const hasChildren = this.children && this.children.length > 0;
|
4377 | const boxHasChildren = box.children && box.children.length > 0;
|
4378 | if (hasChildren || boxHasChildren)
|
4379 | return false;
|
4380 |
|
4381 | const thisStyleCount = this.cssProperties
|
4382 | ? Object.keys(this.cssProperties).length
|
4383 | : 0;
|
4384 | const boxStyleCount = box.cssProperties
|
4385 | ? Object.keys(box.cssProperties).length
|
4386 | : 0;
|
4387 | if (thisStyleCount !== boxStyleCount)
|
4388 | return false;
|
4389 |
|
4390 | if (thisStyleCount > 0) {
|
4391 | for (const prop of Object.keys(this.cssProperties)) {
|
4392 | if (this.cssProperties[prop] !== box.cssProperties[prop]) {
|
4393 | return false;
|
4394 | }
|
4395 | }
|
4396 | }
|
4397 |
|
4398 |
|
4399 | const classes = this.classes.trim().replace(/\s+/g, ' ').split(' ');
|
4400 | const boxClasses = box.classes.trim().replace(/\s+/g, ' ').split(' ');
|
4401 |
|
4402 | if (classes.length !== boxClasses.length)
|
4403 | return false;
|
4404 |
|
4405 |
|
4406 | classes.sort();
|
4407 | boxClasses.sort();
|
4408 | for (const [i, class_] of classes.entries()) {
|
4409 |
|
4410 |
|
4411 | if (class_ === 'vertical-separator')
|
4412 | return false;
|
4413 | if (class_ !== boxClasses[i])
|
4414 | return false;
|
4415 | }
|
4416 |
|
4417 |
|
4418 | this.value += box.value;
|
4419 | this.height = Math.max(this.height, box.height);
|
4420 | this.depth = Math.max(this.depth, box.depth);
|
4421 | this.maxFontSize = Math.max(this.maxFontSize, box.maxFontSize);
|
4422 |
|
4423 |
|
4424 | this.italic = box.italic;
|
4425 | return true;
|
4426 | }
|
4427 | }
|
4428 |
|
4429 |
|
4430 |
|
4431 |
|
4432 |
|
4433 | function coalesceRecursive(boxes) {
|
4434 | if (!boxes || boxes.length === 0)
|
4435 | return [];
|
4436 | boxes[0].children = coalesceRecursive(boxes[0].children);
|
4437 | const result = [boxes[0]];
|
4438 | for (let i = 1; i < boxes.length; i++) {
|
4439 | if (!result[result.length - 1].tryCoalesceWith(boxes[i])) {
|
4440 | boxes[i].children = coalesceRecursive(boxes[i].children);
|
4441 | result.push(boxes[i]);
|
4442 | }
|
4443 | }
|
4444 | return result;
|
4445 | }
|
4446 | function coalesce(box) {
|
4447 | if (box.children)
|
4448 | box.children = coalesceRecursive(box.children);
|
4449 | return box;
|
4450 | }
|
4451 |
|
4452 |
|
4453 |
|
4454 | function adjustType(root) {
|
4455 | forEachBox(root, (prevBox, box) => {
|
4456 |
|
4457 |
|
4458 |
|
4459 |
|
4460 |
|
4461 | if (box.type === 'mbin' &&
|
4462 | (!prevBox || /first|none|mbin|mop|mrel|mopen|mpunct/.test(prevBox.type))) {
|
4463 | box.type = 'mord';
|
4464 | }
|
4465 |
|
4466 |
|
4467 |
|
4468 | if (prevBox &&
|
4469 | prevBox.type === 'mbin' &&
|
4470 | /mrel|mclose|mpunct|placeholder/.test(box.type)) {
|
4471 | prevBox.type = 'mord';
|
4472 | }
|
4473 | });
|
4474 | }
|
4475 |
|
4476 |
|
4477 |
|
4478 | function applyInterAtomSpacing(root, scale) {
|
4479 | forEachBox(root, (prevBox, box) => {
|
4480 | var _a, _b, _c, _d;
|
4481 | const prevType = (_a = prevBox === null || prevBox === void 0 ? void 0 : prevBox.type) !== null && _a !== void 0 ? _a : 'none';
|
4482 | const table = box.isTight
|
4483 | ? (_b = INTER_ATOM_TIGHT_SPACING[prevType]) !== null && _b !== void 0 ? _b : null
|
4484 | : (_c = INTER_ATOM_SPACING[prevType]) !== null && _c !== void 0 ? _c : null;
|
4485 | const hskip = table ? (_d = table[box.type]) !== null && _d !== void 0 ? _d : 0 : 0;
|
4486 | if (hskip)
|
4487 | box.left += scale * (hskip / 18);
|
4488 | });
|
4489 | }
|
4490 |
|
4491 |
|
4492 |
|
4493 |
|
4494 |
|
4495 |
|
4496 |
|
4497 |
|
4498 |
|
4499 | function forEachBoxRecursive(prevBox, box, f) {
|
4500 |
|
4501 |
|
4502 |
|
4503 |
|
4504 | if (box.newList)
|
4505 | prevBox = null;
|
4506 | const type = box.type;
|
4507 | if (type === 'first') {
|
4508 | console.assert(box.newList === true);
|
4509 | return null;
|
4510 | }
|
4511 |
|
4512 | if (type === 'spacing') {
|
4513 | return prevBox;
|
4514 | }
|
4515 | f(prevBox, box);
|
4516 | if (box.children) {
|
4517 | let childPrev = null;
|
4518 | if (type === undefined || type.length === 0) {
|
4519 | childPrev = prevBox;
|
4520 | }
|
4521 | for (const child of box.children) {
|
4522 | childPrev = forEachBoxRecursive(childPrev, child, f);
|
4523 | }
|
4524 | if (type === undefined || type.length === 0) {
|
4525 | prevBox = childPrev;
|
4526 | }
|
4527 | }
|
4528 | if (type !== 'supsub' && type !== undefined && type.length > 0) {
|
4529 | prevBox = box;
|
4530 | }
|
4531 | return prevBox;
|
4532 | }
|
4533 | function forEachBox(box, f) {
|
4534 | if (!box)
|
4535 | return;
|
4536 | forEachBoxRecursive(null, box, f);
|
4537 | }
|
4538 | function adjustInterAtomSpacing(root, scale = 1.0) {
|
4539 | adjustType(root);
|
4540 | applyInterAtomSpacing(root, scale);
|
4541 | return root;
|
4542 | }
|
4543 |
|
4544 |
|
4545 |
|
4546 |
|
4547 |
|
4548 |
|
4549 |
|
4550 |
|
4551 |
|
4552 |
|
4553 |
|
4554 |
|
4555 |
|
4556 |
|
4557 |
|
4558 |
|
4559 |
|
4560 |
|
4561 | function makeStruts(content, options) {
|
4562 | if (!content)
|
4563 | return new Box(null, options);
|
4564 | const topStrut = new Box(null, { classes: 'ML__strut' });
|
4565 | topStrut.setStyle('height', Math.max(0, content.height), 'em');
|
4566 | const struts = [topStrut];
|
4567 | if (content.depth !== 0) {
|
4568 | const bottomStrut = new Box(null, { classes: 'ML__strut--bottom' });
|
4569 | bottomStrut.setStyle('height', content.height + content.depth, 'em');
|
4570 | bottomStrut.setStyle('vertical-align', -content.depth, 'em');
|
4571 | struts.push(bottomStrut);
|
4572 | }
|
4573 | struts.push(content);
|
4574 | return new Box(struts, options);
|
4575 | }
|
4576 |
|
4577 |
|
4578 |
|
4579 | function addSVGOverlay(body, svgMarkup, svgStyle) {
|
4580 | body.svgOverlay = svgMarkup;
|
4581 | body.svgStyle = svgStyle;
|
4582 | return body;
|
4583 | }
|
4584 |
|
4585 |
|
4586 |
|
4587 | function makeSVGBox(svgBodyName) {
|
4588 | const height = svgBodyHeight(svgBodyName) / 2;
|
4589 | const box = new Box(null, {
|
4590 | height: height + 0.166,
|
4591 | depth: height - 0.166,
|
4592 | maxFontSize: 0,
|
4593 | });
|
4594 | box.svgBody = svgBodyName;
|
4595 | return box;
|
4596 | }
|
4597 |
|
4598 |
|
4599 | function getVListChildrenAndDepth(params) {
|
4600 | if ('individualShift' in params) {
|
4601 | const oldChildren = params.individualShift;
|
4602 | let prevChild = oldChildren[0];
|
4603 | const children = [prevChild];
|
4604 |
|
4605 |
|
4606 | const depth = -prevChild.shift - prevChild.box.depth;
|
4607 | let currPos = depth;
|
4608 | for (let i = 1; i < oldChildren.length; i++) {
|
4609 | const child = oldChildren[i];
|
4610 | const diff = -child.shift - currPos - child.box.depth;
|
4611 | const size = diff - (prevChild.box.height + prevChild.box.depth);
|
4612 | currPos = currPos + diff;
|
4613 | children.push(size);
|
4614 | children.push(child);
|
4615 | prevChild = child;
|
4616 | }
|
4617 | return [children, depth];
|
4618 | }
|
4619 | if ('top' in params) {
|
4620 |
|
4621 |
|
4622 | let bottom = params.top;
|
4623 | for (const child of params.children) {
|
4624 | bottom -=
|
4625 | typeof child === 'number' ? child : child.box.height + child.box.depth;
|
4626 | }
|
4627 | return [params.children, bottom];
|
4628 | }
|
4629 | else if ('bottom' in params) {
|
4630 | return [params.children, -params.bottom];
|
4631 | }
|
4632 | else if ('firstBaseline' in params) {
|
4633 | const firstChild = params.firstBaseline[0];
|
4634 | if (typeof firstChild === 'number') {
|
4635 | throw new Error('First child must be an element.');
|
4636 | }
|
4637 | return [params.firstBaseline, -firstChild.box.depth];
|
4638 | }
|
4639 | else if ('shift' in params) {
|
4640 | const firstChild = params.children[0];
|
4641 | if (typeof firstChild === 'number') {
|
4642 | throw new Error('First child must be an element.');
|
4643 | }
|
4644 | return [params.children, -firstChild.box.depth - params.shift];
|
4645 | }
|
4646 | return [null, 0];
|
4647 | }
|
4648 |
|
4649 |
|
4650 |
|
4651 |
|
4652 |
|
4653 |
|
4654 |
|
4655 |
|
4656 |
|
4657 |
|
4658 | function makeRows(params) {
|
4659 | var _a;
|
4660 | const [children, depth] = getVListChildrenAndDepth(params);
|
4661 | if (!children)
|
4662 | return [[], 0, 0];
|
4663 |
|
4664 |
|
4665 |
|
4666 |
|
4667 |
|
4668 |
|
4669 |
|
4670 | let pstrutSize = 0;
|
4671 | for (const child of children) {
|
4672 | if (typeof child !== 'number') {
|
4673 | const box = child.box;
|
4674 | pstrutSize = Math.max(pstrutSize, box.maxFontSize, box.height);
|
4675 | }
|
4676 | }
|
4677 | pstrutSize += 2;
|
4678 | const pstrut = new Box(null, { classes: 'pstrut' });
|
4679 | pstrut.setStyle('height', pstrutSize, 'em');
|
4680 |
|
4681 | const realChildren = [];
|
4682 | let minPos = depth;
|
4683 | let maxPos = depth;
|
4684 | let currPos = depth;
|
4685 | for (const child of children) {
|
4686 | if (typeof child === 'number') {
|
4687 | currPos += child;
|
4688 | }
|
4689 | else {
|
4690 | const box = child.box;
|
4691 | const classes = (_a = child.classes) !== null && _a !== void 0 ? _a : [];
|
4692 | const childWrap = new Box([pstrut, box], {
|
4693 | classes: classes.join(' '),
|
4694 | style: child.style,
|
4695 | });
|
4696 | childWrap.setStyle('top', -pstrutSize - currPos - box.depth, 'em');
|
4697 | if (child.marginLeft) {
|
4698 | childWrap.setStyle('margin-left', child.marginLeft, 'em');
|
4699 | }
|
4700 | if (child.marginRight) {
|
4701 | childWrap.setStyle('margin-right', child.marginRight, 'em');
|
4702 | }
|
4703 | realChildren.push(childWrap);
|
4704 | currPos += box.height + box.depth;
|
4705 | }
|
4706 | minPos = Math.min(minPos, currPos);
|
4707 | maxPos = Math.max(maxPos, currPos);
|
4708 | }
|
4709 |
|
4710 |
|
4711 |
|
4712 | const vlist = new Box(realChildren, { classes: 'vlist' });
|
4713 | vlist.setStyle('height', maxPos, 'em');
|
4714 |
|
4715 | let rows;
|
4716 | if (minPos < 0) {
|
4717 |
|
4718 |
|
4719 |
|
4720 |
|
4721 |
|
4722 | const depthStrut = new Box(new Box(null), { classes: 'vlist' });
|
4723 | depthStrut.setStyle('height', -minPos, 'em');
|
4724 |
|
4725 |
|
4726 | const topStrut = new Box(0x200b, {
|
4727 | classes: 'vlist-s',
|
4728 | maxFontSize: 0,
|
4729 | height: 0,
|
4730 | depth: 0,
|
4731 | });
|
4732 | rows = [
|
4733 | new Box([vlist, topStrut], { classes: 'vlist-r' }),
|
4734 | new Box(depthStrut, { classes: 'vlist-r' }),
|
4735 | ];
|
4736 | }
|
4737 | else {
|
4738 | rows = [new Box(vlist, { classes: 'vlist-r' })];
|
4739 | }
|
4740 | return [rows, maxPos, -minPos];
|
4741 | }
|
4742 | class VBox extends Box {
|
4743 | constructor(content, options) {
|
4744 | var _a;
|
4745 | const [rows, height, depth] = makeRows(content);
|
4746 | super(rows.length === 1 ? rows[0] : rows, {
|
4747 | classes: ((_a = options === null || options === void 0 ? void 0 : options.classes) !== null && _a !== void 0 ? _a : '') +
|
4748 | ' vlist-t' +
|
4749 | (rows.length === 2 ? ' vlist-t2' : ''),
|
4750 | height,
|
4751 | depth,
|
4752 | type: options === null || options === void 0 ? void 0 : options.type,
|
4753 | });
|
4754 | }
|
4755 | }
|
4756 |
|
4757 |
|
4758 |
|
4759 |
|
4760 |
|
4761 |
|
4762 |
|
4763 |
|
4764 |
|
4765 |
|
4766 |
|
4767 | function makeLimitsStack(context, options) {
|
4768 | var _a, _b, _c, _d, _e;
|
4769 |
|
4770 |
|
4771 |
|
4772 |
|
4773 |
|
4774 |
|
4775 |
|
4776 | const metrics = context.metrics;
|
4777 |
|
4778 |
|
4779 |
|
4780 | const base = new Box(options.base);
|
4781 | const baseShift = (_a = options.baseShift) !== null && _a !== void 0 ? _a : 0;
|
4782 | const slant = (_b = options.slant) !== null && _b !== void 0 ? _b : 0;
|
4783 | let aboveShift = 0;
|
4784 | let belowShift = 0;
|
4785 | if (options.above) {
|
4786 | aboveShift =
|
4787 | (_c = options.aboveShift) !== null && _c !== void 0 ? _c : Math.max(metrics.bigOpSpacing1, metrics.bigOpSpacing3 - options.above.depth);
|
4788 | }
|
4789 | if (options.below) {
|
4790 | belowShift =
|
4791 | (_d = options.belowShift) !== null && _d !== void 0 ? _d : Math.max(metrics.bigOpSpacing2, metrics.bigOpSpacing4 - options.below.height);
|
4792 | }
|
4793 | let result = null;
|
4794 | if (options.below && options.above) {
|
4795 | const bottom = metrics.bigOpSpacing5 +
|
4796 | options.below.height +
|
4797 | options.below.depth +
|
4798 | belowShift +
|
4799 | base.depth +
|
4800 | baseShift;
|
4801 |
|
4802 |
|
4803 |
|
4804 |
|
4805 | result = new VBox({
|
4806 | bottom,
|
4807 | children: [
|
4808 | metrics.bigOpSpacing5,
|
4809 | {
|
4810 | box: options.below,
|
4811 | marginLeft: -slant,
|
4812 | classes: ['ML__center'],
|
4813 | },
|
4814 | belowShift,
|
4815 |
|
4816 |
|
4817 | { box: base, classes: ['ML__center'] },
|
4818 | aboveShift,
|
4819 | {
|
4820 | box: options.above,
|
4821 | marginLeft: slant,
|
4822 | classes: ['ML__center'],
|
4823 | },
|
4824 | metrics.bigOpSpacing5,
|
4825 | ],
|
4826 | }).wrap(context);
|
4827 | }
|
4828 | else if (options.below && !options.above) {
|
4829 | result = new VBox({
|
4830 | top: base.height - baseShift,
|
4831 | children: [
|
4832 | metrics.bigOpSpacing5,
|
4833 | {
|
4834 | box: options.below,
|
4835 | marginLeft: -slant,
|
4836 | classes: ['ML__center'],
|
4837 | },
|
4838 | belowShift,
|
4839 | { box: base, classes: ['ML__center'] },
|
4840 | ],
|
4841 | }).wrap(context);
|
4842 | }
|
4843 | else if (!options.below && options.above) {
|
4844 | const bottom = base.depth + baseShift;
|
4845 | result = new VBox({
|
4846 | bottom,
|
4847 | children: [
|
4848 | { box: base, classes: ['ML__center'] },
|
4849 | aboveShift,
|
4850 | {
|
4851 | box: options.above,
|
4852 | marginLeft: slant,
|
4853 | classes: ['ML__center'],
|
4854 | },
|
4855 | metrics.bigOpSpacing5,
|
4856 | ],
|
4857 | }).wrap(context);
|
4858 | }
|
4859 | else {
|
4860 | const bottom = base.depth + baseShift;
|
4861 | result = new VBox({
|
4862 | bottom,
|
4863 | children: [{ box: base }, metrics.bigOpSpacing5],
|
4864 | }).wrap(context);
|
4865 | }
|
4866 | console.assert(options.type !== undefined);
|
4867 | return new Box(result, { type: (_e = options.type) !== null && _e !== void 0 ? _e : 'mop' });
|
4868 | }
|
4869 |
|
4870 | function stringToCodepoints(string) {
|
4871 | const result = [];
|
4872 | for (let i = 0; i < string.length; i++) {
|
4873 | let code = string.charCodeAt(i);
|
4874 | if (code === 0x0d && string.charCodeAt(i + 1) === 0x0a) {
|
4875 | code = 0x0a;
|
4876 | i++;
|
4877 | }
|
4878 | if (code === 0x0d || code === 0x0c)
|
4879 | code = 0x0a;
|
4880 | if (code === 0x00)
|
4881 | code = 0xfffd;
|
4882 |
|
4883 | if (code >= 0xd800 && code <= 0xdbff) {
|
4884 | const nextCode = string.charCodeAt(i + 1);
|
4885 | if (nextCode >= 0xdc00 && nextCode <= 0xdfff) {
|
4886 | const lead = code - 0xd800;
|
4887 | const trail = nextCode - 0xdc00;
|
4888 | code = 2 ** 16 + lead * 2 ** 10 + trail;
|
4889 |
|
4890 | i++;
|
4891 | }
|
4892 | }
|
4893 | result.push(code);
|
4894 | }
|
4895 | return result;
|
4896 | }
|
4897 | const ZWJ = 0x200d;
|
4898 |
|
4899 |
|
4900 | const EMOJI_COMBINATOR = [
|
4901 | [ZWJ, 1],
|
4902 | [0xfe0e, 2],
|
4903 | [0x1f3fb, 5],
|
4904 | [0x1f9b0, 4],
|
4905 | [0xe0020, 96],
|
4906 | ];
|
4907 | let emojiCombinator;
|
4908 |
|
4909 | const REGIONAL_INDICATOR = [0x1f1e6, 0x1f1ff];
|
4910 | function isEmojiCombinator(code) {
|
4911 | var _a;
|
4912 | if (emojiCombinator === undefined) {
|
4913 | emojiCombinator = {};
|
4914 | for (const x of EMOJI_COMBINATOR) {
|
4915 | for (let i = x[0]; i <= x[0] + x[1] - 1; i++) {
|
4916 | emojiCombinator[i] = true;
|
4917 | }
|
4918 | }
|
4919 | }
|
4920 | return (_a = emojiCombinator[code]) !== null && _a !== void 0 ? _a : false;
|
4921 | }
|
4922 | function isRegionalIndicator(code) {
|
4923 | return code >= REGIONAL_INDICATOR[0] && code <= REGIONAL_INDICATOR[1];
|
4924 | }
|
4925 |
|
4926 |
|
4927 |
|
4928 |
|
4929 |
|
4930 |
|
4931 |
|
4932 |
|
4933 |
|
4934 |
|
4935 |
|
4936 |
|
4937 | function splitGraphemes(string) {
|
4938 |
|
4939 | if (/^[\u0020-\u00FF]*$/.test(string))
|
4940 | return string;
|
4941 | const result = [];
|
4942 | const codePoints = stringToCodepoints(string);
|
4943 | let index = 0;
|
4944 | while (index < codePoints.length) {
|
4945 | const code = codePoints[index++];
|
4946 | const next = codePoints[index];
|
4947 |
|
4948 | if (next === ZWJ) {
|
4949 |
|
4950 |
|
4951 | const baseIndex = index - 1;
|
4952 | index += 2;
|
4953 | while (codePoints[index] === ZWJ) {
|
4954 | index += 2;
|
4955 | }
|
4956 | result.push(String.fromCodePoint(...codePoints.slice(baseIndex, index - baseIndex + 1)));
|
4957 | }
|
4958 | else if (isEmojiCombinator(next)) {
|
4959 |
|
4960 |
|
4961 | const baseIndex = index - 1;
|
4962 | while (isEmojiCombinator(codePoints[index])) {
|
4963 | index += codePoints[index] === ZWJ ? 2 : 1;
|
4964 | }
|
4965 | result.push(String.fromCodePoint(...codePoints.slice(baseIndex, 2 * index - baseIndex - 1)));
|
4966 | }
|
4967 | else if (isRegionalIndicator(code)) {
|
4968 |
|
4969 |
|
4970 | index += 1;
|
4971 | result.push(String.fromCodePoint(...codePoints.slice(index - 2, 2)));
|
4972 | }
|
4973 | else {
|
4974 | result.push(String.fromCodePoint(code));
|
4975 | }
|
4976 | }
|
4977 | return result;
|
4978 | }
|
4979 |
|
4980 |
|
4981 |
|
4982 |
|
4983 |
|
4984 |
|
4985 |
|
4986 |
|
4987 |
|
4988 |
|
4989 |
|
4990 |
|
4991 |
|
4992 |
|
4993 | class Tokenizer {
|
4994 | constructor(s) {
|
4995 | this.s = splitGraphemes(s);
|
4996 | this.pos = 0;
|
4997 | this.obeyspaces = false;
|
4998 | }
|
4999 | |
5000 |
|
5001 |
|
5002 | end() {
|
5003 | return this.pos >= this.s.length;
|
5004 | }
|
5005 | |
5006 |
|
5007 |
|
5008 | get() {
|
5009 | return this.pos < this.s.length ? this.s[this.pos++] : '';
|
5010 | }
|
5011 | |
5012 |
|
5013 |
|
5014 | peek() {
|
5015 | return this.s[this.pos];
|
5016 | }
|
5017 | |
5018 |
|
5019 |
|
5020 | match(regEx) {
|
5021 |
|
5022 |
|
5023 | const execResult = typeof this.s === 'string'
|
5024 | ? regEx.exec(this.s.slice(this.pos))
|
5025 | : regEx.exec(this.s.slice(this.pos).join(''));
|
5026 | if (execResult === null || execResult === void 0 ? void 0 : execResult[0]) {
|
5027 | this.pos += execResult[0].length;
|
5028 | return execResult[0];
|
5029 | }
|
5030 | return '';
|
5031 | }
|
5032 | |
5033 |
|
5034 |
|
5035 | next() {
|
5036 |
|
5037 | if (this.end())
|
5038 | return null;
|
5039 |
|
5040 |
|
5041 |
|
5042 | if (!this.obeyspaces && this.match(/^[ \f\n\r\t\v\u00A0\u2028\u2029]+/)) {
|
5043 |
|
5044 |
|
5045 |
|
5046 |
|
5047 |
|
5048 |
|
5049 |
|
5050 |
|
5051 |
|
5052 |
|
5053 |
|
5054 |
|
5055 |
|
5056 | return '<space>';
|
5057 | }
|
5058 | if (this.obeyspaces && this.match(/^[ \f\n\r\t\v\u00A0\u2028\u2029]/)) {
|
5059 |
|
5060 | return '<space>';
|
5061 | }
|
5062 | const next = this.get();
|
5063 |
|
5064 | if (next === '\\') {
|
5065 | if (!this.end()) {
|
5066 |
|
5067 | let command = this.match(/^[a-zA-Z*]+/);
|
5068 | if (command) {
|
5069 |
|
5070 |
|
5071 | this.match(/^[ \f\n\r\t\v\u00A0\u2028\u2029]*/);
|
5072 | }
|
5073 | else {
|
5074 |
|
5075 | command = this.get();
|
5076 | if (command === ' ') {
|
5077 |
|
5078 | return '<space>';
|
5079 | }
|
5080 | }
|
5081 | return '\\' + command;
|
5082 | }
|
5083 | }
|
5084 | else if (next === '{') {
|
5085 |
|
5086 | return '<{>';
|
5087 | }
|
5088 | else if (next === '}') {
|
5089 |
|
5090 | return '<}>';
|
5091 | }
|
5092 | else if (next === '^') {
|
5093 | if (this.peek() === '^') {
|
5094 |
|
5095 | this.get();
|
5096 |
|
5097 | const hex = this.match(/^(\^(\^(\^(\^[\da-f])?[\da-f])?[\da-f])?[\da-f])?[\da-f]{2}/);
|
5098 | if (hex) {
|
5099 | return String.fromCodePoint(Number.parseInt(hex.slice(hex.lastIndexOf('^') + 1), 16));
|
5100 | }
|
5101 | }
|
5102 | return next;
|
5103 | }
|
5104 | else if (next === '#') {
|
5105 |
|
5106 |
|
5107 |
|
5108 |
|
5109 |
|
5110 |
|
5111 | if (!this.end()) {
|
5112 | let isParameter = false;
|
5113 | if (/[\d?@]/.test(this.peek())) {
|
5114 |
|
5115 | isParameter = true;
|
5116 |
|
5117 |
|
5118 | if (this.pos + 1 < this.s.length) {
|
5119 | const after = this.s[this.pos + 1];
|
5120 | isParameter = /[^\dA-Za-z]/.test(after);
|
5121 | }
|
5122 | }
|
5123 | if (isParameter) {
|
5124 | return '#' + this.get();
|
5125 | }
|
5126 | return '#';
|
5127 | }
|
5128 | }
|
5129 | else if (next === '$') {
|
5130 |
|
5131 | if (this.peek() === '$') {
|
5132 |
|
5133 | this.get();
|
5134 | return '<$$>';
|
5135 | }
|
5136 |
|
5137 | return '<$>';
|
5138 | }
|
5139 | return next;
|
5140 | }
|
5141 | }
|
5142 |
|
5143 |
|
5144 | function expand(lex, args) {
|
5145 | var _a, _b, _c, _d;
|
5146 | let result = [];
|
5147 | let token = lex.next();
|
5148 | if (token) {
|
5149 | if (token === '\\relax') ;
|
5150 | else if (token === '\\noexpand') {
|
5151 |
|
5152 | token = lex.next();
|
5153 | if (token) {
|
5154 | result.push(token);
|
5155 | }
|
5156 | }
|
5157 | else if (token === '\\obeyspaces') {
|
5158 | lex.obeyspaces = true;
|
5159 | }
|
5160 | else if (token === '\\space' || token === '~') {
|
5161 |
|
5162 |
|
5163 |
|
5164 | result.push('<space>');
|
5165 | }
|
5166 | else if (token === '\\bgroup') {
|
5167 |
|
5168 | result.push('<{>');
|
5169 | }
|
5170 | else if (token === '\\egroup') {
|
5171 |
|
5172 | result.push('<}>');
|
5173 | }
|
5174 | else if (token === '\\string') {
|
5175 |
|
5176 | token = lex.next();
|
5177 | if (token) {
|
5178 | if (token.startsWith('\\')) {
|
5179 | for (const x of token) {
|
5180 | result.push(x === '\\' ? '\\backslash' : x);
|
5181 | }
|
5182 | }
|
5183 | else if (token === '<{>') {
|
5184 | result.push('\\{');
|
5185 | }
|
5186 | else if (token === '<space>') {
|
5187 | result.push('~');
|
5188 | }
|
5189 | else if (token === '<}>') {
|
5190 | result.push('\\}');
|
5191 | }
|
5192 | }
|
5193 | }
|
5194 | else if (token === '\\csname') {
|
5195 |
|
5196 | while (lex.peek() === '<space>') {
|
5197 | lex.next();
|
5198 | }
|
5199 | let command = '';
|
5200 | let done = false;
|
5201 | let tokens = [];
|
5202 | do {
|
5203 | if (tokens.length === 0) {
|
5204 |
|
5205 | if (/^#[\d?@]$/.test(lex.peek())) {
|
5206 |
|
5207 | const parameter = lex.get().slice(1);
|
5208 | tokens = tokenize((_b = (_a = args === null || args === void 0 ? void 0 : args(parameter)) !== null && _a !== void 0 ? _a : args === null || args === void 0 ? void 0 : args('?')) !== null && _b !== void 0 ? _b : '\\placeholder{}', args);
|
5209 | token = tokens[0];
|
5210 | }
|
5211 | else {
|
5212 | token = lex.next();
|
5213 | tokens = token ? [token] : [];
|
5214 | }
|
5215 | }
|
5216 | done = tokens.length === 0;
|
5217 | if (!done && token === '\\endcsname') {
|
5218 | done = true;
|
5219 | tokens.shift();
|
5220 | }
|
5221 | if (!done) {
|
5222 | done =
|
5223 | token === '<$>' ||
|
5224 | token === '<$$>' ||
|
5225 | token === '<{>' ||
|
5226 | token === '<}>' ||
|
5227 | (typeof token === 'string' &&
|
5228 | token.length > 1 &&
|
5229 | token.startsWith('\\'));
|
5230 | }
|
5231 | if (!done) {
|
5232 | command += tokens.shift();
|
5233 | }
|
5234 | } while (!done);
|
5235 | if (command) {
|
5236 | result.push('\\' + command);
|
5237 | }
|
5238 | result = result.concat(tokens);
|
5239 | }
|
5240 | else if (token === '\\endcsname') ;
|
5241 | else if (token.length > 1 && token.startsWith('#')) {
|
5242 |
|
5243 | const parameter = token.slice(1);
|
5244 | result = result.concat(tokenize((_d = (_c = args === null || args === void 0 ? void 0 : args(parameter)) !== null && _c !== void 0 ? _c : args === null || args === void 0 ? void 0 : args('?')) !== null && _d !== void 0 ? _d : '\\placeholder{}', args));
|
5245 | }
|
5246 | else {
|
5247 | result.push(token);
|
5248 | }
|
5249 | }
|
5250 | return result;
|
5251 | }
|
5252 |
|
5253 |
|
5254 |
|
5255 |
|
5256 |
|
5257 |
|
5258 | function tokenize(s, args = null) {
|
5259 |
|
5260 | const lines = s.toString().split(/\r?\n/);
|
5261 | let stream = '';
|
5262 | let sep = '';
|
5263 | for (const line of lines) {
|
5264 | stream += sep;
|
5265 | sep = ' ';
|
5266 |
|
5267 |
|
5268 | const m = line.match(/((?:\\%)|[^%])*/);
|
5269 | if (m !== null)
|
5270 | stream += m[0];
|
5271 | }
|
5272 | const tokenizer = new Tokenizer(stream);
|
5273 | let result = [];
|
5274 | do {
|
5275 | result = result.concat(expand(tokenizer, args));
|
5276 | } while (!tokenizer.end());
|
5277 | return result;
|
5278 | }
|
5279 | function joinLatex(segments) {
|
5280 | let sep = '';
|
5281 | let result = '';
|
5282 | for (const segment of segments) {
|
5283 | if (segment) {
|
5284 | if (/[a-zA-Z*]/.test(segment[0])) {
|
5285 |
|
5286 |
|
5287 | result += sep;
|
5288 | }
|
5289 |
|
5290 | sep = /\\[a-zA-Z]+\*?$/.test(segment) ? ' ' : '';
|
5291 | result += segment;
|
5292 | }
|
5293 | }
|
5294 | return result;
|
5295 | }
|
5296 | function tokensToString(tokens) {
|
5297 | const result = joinLatex(tokens.map((token) => {
|
5298 | var _a;
|
5299 | return ((_a = {
|
5300 | '<space>': ' ',
|
5301 | '<$$>': '$$',
|
5302 | '<$>': '$',
|
5303 | '<{>': '{',
|
5304 | '<}>': '}',
|
5305 | }[token]) !== null && _a !== void 0 ? _a : token);
|
5306 | }));
|
5307 | return result;
|
5308 | }
|
5309 |
|
5310 |
|
5311 |
|
5312 | function isBrowser() {
|
5313 | return 'window' in globalThis && 'document' in globalThis;
|
5314 | }
|
5315 | function throwIfNotInBrowser() {
|
5316 | if (!isBrowser()) {
|
5317 | throw new Error('<math-field> is an interactive component that needs to run in a browser environment\n' +
|
5318 | 'If you are using nextjs, see https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr');
|
5319 | }
|
5320 | }
|
5321 | function isTouchCapable() {
|
5322 | var _a, _b;
|
5323 | return ((_b = (isBrowser() && ((_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, '(any-pointer: coarse)').matches))) !== null && _b !== void 0 ? _b : false);
|
5324 | }
|
5325 | function canVibrate() {
|
5326 | return isBrowser() && typeof navigator.vibrate === 'function';
|
5327 | }
|
5328 | function osPlatform() {
|
5329 | if (!isBrowser()) {
|
5330 | return 'other';
|
5331 | }
|
5332 | const platform = navigator.platform;
|
5333 | if (/^(mac)/i.test(platform)) {
|
5334 |
|
5335 |
|
5336 | if (navigator.maxTouchPoints === 5)
|
5337 | return 'ios';
|
5338 | return 'macos';
|
5339 | }
|
5340 | if (/^(win)/i.test(platform))
|
5341 | return 'windows';
|
5342 | if (/(android)/i.test(navigator.userAgent))
|
5343 | return 'android';
|
5344 | if (/(iphone|ipod|ipad)/i.test(navigator.userAgent))
|
5345 | return 'ios';
|
5346 | if (/\bcros\b/i.test(navigator.userAgent))
|
5347 | return 'chromeos';
|
5348 | return 'other';
|
5349 | }
|
5350 | function supportRegexPropertyEscape() {
|
5351 | if (!isBrowser())
|
5352 | return true;
|
5353 | if (/firefox/i.test(navigator.userAgent)) {
|
5354 | const m = navigator.userAgent.match(/firefox\/(\d+)/i);
|
5355 | if (!m)
|
5356 | return false;
|
5357 | const version = parseInt(m[1]);
|
5358 | return version >= 78;
|
5359 | }
|
5360 | if (/trident/i.test(navigator.userAgent))
|
5361 | return false;
|
5362 | if (/edge/i.test(navigator.userAgent)) {
|
5363 | const m = navigator.userAgent.match(/edg\/(\d+)/i);
|
5364 | if (!m)
|
5365 | return false;
|
5366 | const version = parseInt(m[1]);
|
5367 | return version >= 79;
|
5368 | }
|
5369 | return true;
|
5370 | }
|
5371 | function supportLocalFontEnumeration() {
|
5372 |
|
5373 |
|
5374 |
|
5375 | return isBrowser() && !/firefox|safari/i.test(navigator.userAgent);
|
5376 | }
|
5377 |
|
5378 | const MATH_SYMBOLS = {};
|
5379 |
|
5380 |
|
5381 |
|
5382 |
|
5383 |
|
5384 |
|
5385 |
|
5386 |
|
5387 |
|
5388 |
|
5389 | const REVERSE_MATH_SYMBOLS = {
|
5390 | 0x003C: '<',
|
5391 | 0x003E: '>',
|
5392 | 0x006F: 'o',
|
5393 | 0x0026: '\\&',
|
5394 | 0x007B: '\\lbrace',
|
5395 | 0x007D: '\\rbrace',
|
5396 | 0x005B: '\\lbrack',
|
5397 | 0x005D: '\\rbrack',
|
5398 | 0x003A: '\\colon',
|
5399 | 0x00A0: '~',
|
5400 | 0x00AC: '\\neg',
|
5401 | 0x00B7: '\\cdot',
|
5402 | 0x00BC: '\\frac{1}{4}',
|
5403 | 0x00BD: '\\frac{1}{2}',
|
5404 | 0x00BE: '\\frac{3}{4}',
|
5405 | 0x2070: '^{0}',
|
5406 | 0x2071: '^{i}',
|
5407 | 0x00B9: '^{1}',
|
5408 | 0x00B2: '^{2}',
|
5409 | 0x00B3: '^{3}',
|
5410 | 0x2020: '\\dagger',
|
5411 | 0x2021: '\\ddagger',
|
5412 | 0x2026: '\\ldots',
|
5413 | 0x2074: '^{4}',
|
5414 | 0x2075: '^{5}',
|
5415 | 0x2076: '^{6}',
|
5416 | 0x2077: '^{7}',
|
5417 | 0x2078: '^{8}',
|
5418 | 0x2079: '^{9}',
|
5419 | 0x207A: '^{+}',
|
5420 | 0x207B: '^{-}',
|
5421 | 0x207C: '^{=}',
|
5422 | 0x207F: '^{n}',
|
5423 | 0x2080: '_{0}',
|
5424 | 0x2081: '_{1}',
|
5425 | 0x2082: '_{2}',
|
5426 | 0x2083: '_{3}',
|
5427 | 0x2084: '_{4}',
|
5428 | 0x2085: '_{5}',
|
5429 | 0x2086: '_{6}',
|
5430 | 0x2087: '_{7}',
|
5431 | 0x2088: '_{8}',
|
5432 | 0x2089: '_{9}',
|
5433 | 0x208A: '_{+}',
|
5434 | 0x208B: '_{-}',
|
5435 | 0x208C: '_{=}',
|
5436 | 0x2090: '_{a}',
|
5437 | 0x2091: '_{e}',
|
5438 | 0x2092: '_{o}',
|
5439 | 0x2093: '_{x}',
|
5440 | 0x2032: '\\prime',
|
5441 | 0x0027: '\\prime',
|
5442 | 0x2190: '\\gets',
|
5443 | 0x2192: '\\to',
|
5444 | 0x25B3: '\\triangle',
|
5445 | 0x25BD: '\\triangledown',
|
5446 | 0x220B: '\\owns',
|
5447 | 0x2217: '\\ast',
|
5448 | 0x2223: '\\vert',
|
5449 | 0x2225: '\\Vert',
|
5450 | 0x2227: '\\land',
|
5451 | 0x2228: '\\lor',
|
5452 | 0x22C5: '\\cdot',
|
5453 | 0x22C8: '\\bowtie',
|
5454 | 0x2260: '\\ne',
|
5455 | 0x2264: '\\le',
|
5456 | 0x2265: '\\ge',
|
5457 | 0x22A5: '\\bot',
|
5458 | 0x27F7: '\\biconditional',
|
5459 | 0x27F8: '\\impliedby',
|
5460 | 0x27F9: '\\implies',
|
5461 | 0x27fa: '\\iff',
|
5462 | 0x2102: '\\C',
|
5463 | 0x2115: '\\N',
|
5464 | 0x2119: '\\P',
|
5465 | 0x211A: '\\Q',
|
5466 | 0x211D: '\\R',
|
5467 | 0x2124: '\\Z',
|
5468 | };
|
5469 | const LEGACY_COMMANDS = {};
|
5470 | const ENVIRONMENTS = {};
|
5471 | const TEXVC_MACROS = {
|
5472 |
|
5473 |
|
5474 |
|
5475 |
|
5476 |
|
5477 |
|
5478 | darr: '\\downarrow',
|
5479 | dArr: '\\Downarrow',
|
5480 | Darr: '\\Downarrow',
|
5481 | lang: '\\langle',
|
5482 | rang: '\\rangle',
|
5483 | uarr: '\\uparrow',
|
5484 | uArr: '\\Uparrow',
|
5485 | Uarr: '\\Uparrow',
|
5486 | N: '\\mathbb{N}',
|
5487 | R: '\\mathbb{R}',
|
5488 | Z: '\\mathbb{Z}',
|
5489 | alef: '\\aleph',
|
5490 | alefsym: '\\aleph',
|
5491 | Alpha: '\\mathrm{A}',
|
5492 | Beta: '\\mathrm{B}',
|
5493 | bull: '\\bullet',
|
5494 | Chi: '\\mathrm{X}',
|
5495 | clubs: '\\clubsuit',
|
5496 | cnums: '\\mathbb{C}',
|
5497 | Complex: '\\mathbb{C}',
|
5498 | Dagger: '\\ddagger',
|
5499 | diamonds: '\\diamondsuit',
|
5500 | empty: '\\emptyset',
|
5501 | Epsilon: '\\mathrm{E}',
|
5502 | Eta: '\\mathrm{H}',
|
5503 | exist: '\\exists',
|
5504 | harr: '\\leftrightarrow',
|
5505 | hArr: '\\Leftrightarrow',
|
5506 | Harr: '\\Leftrightarrow',
|
5507 | hearts: '\\heartsuit',
|
5508 | image: '\\Im',
|
5509 | infin: '\\infty',
|
5510 | Iota: '\\mathrm{I}',
|
5511 | isin: '\\in',
|
5512 | Kappa: '\\mathrm{K}',
|
5513 | larr: '\\leftarrow',
|
5514 | lArr: '\\Leftarrow',
|
5515 | Larr: '\\Leftarrow',
|
5516 | lrarr: '\\leftrightarrow',
|
5517 | lrArr: '\\Leftrightarrow',
|
5518 | Lrarr: '\\Leftrightarrow',
|
5519 | Mu: '\\mathrm{M}',
|
5520 | natnums: '\\mathbb{N}',
|
5521 | Nu: '\\mathrm{N}',
|
5522 | Omicron: '\\mathrm{O}',
|
5523 | plusmn: '\\pm',
|
5524 | rarr: '\\rightarrow',
|
5525 | rArr: '\\Rightarrow',
|
5526 | Rarr: '\\Rightarrow',
|
5527 | real: '\\Re',
|
5528 | reals: '\\mathbb{R}',
|
5529 | Reals: '\\mathbb{R}',
|
5530 | Rho: '\\mathrm{P}',
|
5531 | sdot: '\\cdot',
|
5532 | sect: '\\S',
|
5533 | spades: '\\spadesuit',
|
5534 | sub: '\\subset',
|
5535 | sube: '\\subseteq',
|
5536 | supe: '\\supseteq',
|
5537 | Tau: '\\mathrm{T}',
|
5538 | thetasym: '\\vartheta',
|
5539 |
|
5540 | weierp: '\\wp',
|
5541 | Zeta: '\\mathrm{Z}',
|
5542 | };
|
5543 | const AMSMATH_MACROS = {
|
5544 |
|
5545 |
|
5546 |
|
5547 |
|
5548 | varGamma: '\\mathit{\\Gamma}',
|
5549 | varDelta: '\\mathit{\\Delta}',
|
5550 | varTheta: '\\mathit{\\Theta}',
|
5551 | varLambda: '\\mathit{\\Lambda}',
|
5552 | varXi: '\\mathit{\\Xi}',
|
5553 | varPi: '\\mathit{\\Pi}',
|
5554 | varSigma: '\\mathit{\\Sigma}',
|
5555 | varUpsilon: '\\mathit{\\Upsilon}',
|
5556 | varPhi: '\\mathit{\\Phi}',
|
5557 | varPsi: '\\mathit{\\Psi}',
|
5558 | varOmega: '\\mathit{\\Omega}',
|
5559 |
|
5560 |
|
5561 |
|
5562 |
|
5563 |
|
5564 |
|
5565 |
|
5566 |
|
5567 |
|
5568 |
|
5569 |
|
5570 |
|
5571 |
|
5572 |
|
5573 | pmod: {
|
5574 | def: '\\quad(\\operatorname{mod}\\ #1)',
|
5575 | args: 1,
|
5576 | expand: false,
|
5577 | captureSelection: false,
|
5578 | },
|
5579 |
|
5580 |
|
5581 |
|
5582 |
|
5583 |
|
5584 |
|
5585 |
|
5586 |
|
5587 | mod: {
|
5588 | def: '\\quad\\operatorname{mod}\\,\\,#1',
|
5589 | args: 1,
|
5590 | expand: false,
|
5591 | captureSelection: false,
|
5592 | },
|
5593 |
|
5594 |
|
5595 |
|
5596 |
|
5597 |
|
5598 |
|
5599 |
|
5600 | bmod: {
|
5601 | def: '\\;\\mathbin{\\operatorname{mod }}',
|
5602 | expand: false,
|
5603 | },
|
5604 | };
|
5605 |
|
5606 | const BRAKET_MACROS = {
|
5607 | bra: '\\mathinner{\\langle{#1}|}',
|
5608 | ket: '\\mathinner{|{#1}\\rangle}',
|
5609 | braket: '\\mathinner{\\langle{#1}\\rangle}',
|
5610 | set: '\\mathinner{\\lbrace #1 \\rbrace}',
|
5611 | Bra: '\\left\\langle #1\\right|',
|
5612 | Ket: '\\left|#1\\right\\rangle',
|
5613 | Braket: '\\left\\langle{#1}\\right\\rangle',
|
5614 | Set: '\\left\\lbrace #1 \\right\\rbrace',
|
5615 | };
|
5616 | const DEFAULT_MACROS = {
|
5617 | 'iff': '\\;\u27FA\\;',
|
5618 | 'nicefrac': '^{#1}\\!\\!/\\!_{#2}',
|
5619 |
|
5620 | 'rd': '\\mathrm{d}',
|
5621 | 'rD': '\\mathrm{D}',
|
5622 |
|
5623 | 'doubleStruckCapitalN': '\\mathbb{N}',
|
5624 | 'doubleStruckCapitalR': '\\mathbb{R}',
|
5625 | 'doubleStruckCapitalQ': '\\mathbb{Q}',
|
5626 | 'doubleStruckCapitalZ': '\\mathbb{Z}',
|
5627 | 'doubleStruckCapitalP': '\\mathbb{P}',
|
5628 | 'scriptCapitalE': '\\mathscr{E}',
|
5629 | 'scriptCapitalH': '\\mathscr{H}',
|
5630 | 'scriptCapitalL': '\\mathscr{L}',
|
5631 | 'gothicCapitalC': '\\mathfrak{C}',
|
5632 | 'gothicCapitalH': '\\mathfrak{H}',
|
5633 | 'gothicCapitalI': '\\mathfrak{I}',
|
5634 | 'gothicCapitalR': '\\mathfrak{R}',
|
5635 | 'imaginaryI': '\\mathrm{i}',
|
5636 | 'imaginaryJ': '\\mathrm{j}',
|
5637 | 'exponentialE': '\\mathrm{e}',
|
5638 | 'differentialD': '\\mathrm{d}',
|
5639 | 'capitalDifferentialD': '\\mathrm{D}',
|
5640 | 'braket.sty': { package: BRAKET_MACROS },
|
5641 | 'amsmath.sty': {
|
5642 | package: AMSMATH_MACROS,
|
5643 | expand: false,
|
5644 | },
|
5645 | 'texvc.sty': {
|
5646 | package: TEXVC_MACROS,
|
5647 | expand: false,
|
5648 | },
|
5649 | };
|
5650 |
|
5651 |
|
5652 | const TEXT_SYMBOLS = {
|
5653 | ' ': 0x0020,
|
5654 | '\\#': 0x0023,
|
5655 | '\\&': 0x0026,
|
5656 | '\\$': 0x0024,
|
5657 | '\\%': 0x0025,
|
5658 | '\\_': 0x005f,
|
5659 | '\\euro': 0x20ac,
|
5660 | '\\maltese': 0x2720,
|
5661 | '\\{': 0x007b,
|
5662 | '\\}': 0x007d,
|
5663 | '\\nobreakspace': 0x00a0,
|
5664 | '\\ldots': 0x2026,
|
5665 | '\\textellipsis': 0x2026,
|
5666 | '\\backslash': 0x005c,
|
5667 | '`': 0x2018,
|
5668 | "'": 0x2019,
|
5669 | '``': 0x201c,
|
5670 | "''": 0x201d,
|
5671 | '\\degree': 0x00b0,
|
5672 | '\\textasciicircum': 0x005e,
|
5673 | '\\textasciitilde': 0x007e,
|
5674 | '\\textasteriskcentered': 0x002a,
|
5675 | '\\textbackslash': 0x005c,
|
5676 | '\\textbraceleft': 0x007b,
|
5677 | '\\textbraceright': 0x007d,
|
5678 | '\\textbullet': 0x2022,
|
5679 | '\\textdollar': 0x0024,
|
5680 | '\\textsterling': 0x00a3,
|
5681 | '\\textdagger': 0x2020,
|
5682 | '\\textdaggerdbl': 0x2021,
|
5683 | '–': 0x2013,
|
5684 | '—': 0x2014,
|
5685 | '‘': 0x2018,
|
5686 | '’': 0x2019,
|
5687 | '“': 0x201c,
|
5688 | '”': 0x201d,
|
5689 | '"': 0x201d,
|
5690 | '\\ss': 0x00df,
|
5691 | '\\ae': 0x00e6,
|
5692 | '\\oe': 0x0153,
|
5693 | '\\AE': 0x00c6,
|
5694 | '\\OE': 0x0152,
|
5695 | '\\O': 0x00d8,
|
5696 | '\\i': 0x0131,
|
5697 | '\\j': 0x0237,
|
5698 | '\\aa': 0x00e5,
|
5699 | '\\AA': 0x00c5,
|
5700 | };
|
5701 | const COMMAND_MODE_CHARACTERS = /[\w!@*()-=+{}[\]\\';:?/.,~<>`|$%#&^" ]/;
|
5702 | const LETTER = supportRegexPropertyEscape()
|
5703 | ?
|
5704 | new RegExp('\\p{Letter}', 'u')
|
5705 | : /[a-zA-ZаАбБвВгГдДеЕёЁжЖзЗиИйЙкКлЛмМнНоОпПрРсСтТуУфФхХцЦчЧшШщЩъЪыЫьЬэЭюЮяĄąĆćĘꣳŃńÓ󌜏źŻżàâäôéèëêïîçùûüÿæœÀÂÄÔÉÈËÊÏΟÇÙÛÜÆŒößÖẞìíòúÌÍÒÚáñÁÑ]/;
|
5706 | const LETTER_AND_DIGITS = supportRegexPropertyEscape()
|
5707 | ?
|
5708 | new RegExp('[0-9\\p{Letter}]', 'u')
|
5709 | : /[\da-zA-ZаАбБвВгГдДеЕёЁжЖзЗиИйЙкКлЛмМнНоОпПрРсСтТуУфФхХцЦчЧшШщЩъЪыЫьЬэЭюЮяĄąĆćĘꣳŃńÓ󌜏źŻżàâäôéèëêïîçùûüÿæœÀÂÄÔÉÈËÊÏΟÇÙÛÜÆŒößÖẞìíòúÌÍÒÚáñÁÑ]/;
|
5710 |
|
5711 |
|
5712 |
|
5713 |
|
5714 | function newSymbol(symbol, value, type = 'mord', variant) {
|
5715 | if (value === undefined)
|
5716 | return;
|
5717 | MATH_SYMBOLS[symbol] = {
|
5718 | type,
|
5719 | variant,
|
5720 | codepoint: value,
|
5721 | };
|
5722 | if (!REVERSE_MATH_SYMBOLS[value] && !variant) {
|
5723 | REVERSE_MATH_SYMBOLS[value] = symbol;
|
5724 | }
|
5725 |
|
5726 |
|
5727 | if (!TEXT_SYMBOLS[symbol]) {
|
5728 | TEXT_SYMBOLS[symbol] = value;
|
5729 | }
|
5730 | }
|
5731 |
|
5732 |
|
5733 |
|
5734 | function newSymbols(value, inType, inVariant) {
|
5735 | if (typeof value === 'string') {
|
5736 | for (let i = 0; i < value.length; i++) {
|
5737 | const ch = value.charAt(i);
|
5738 | newSymbol(ch, ch.codePointAt(0));
|
5739 | }
|
5740 | return;
|
5741 | }
|
5742 | for (const [symbol, val, type, variant] of value) {
|
5743 | newSymbol(symbol, val, type !== null && type !== void 0 ? type : inType, variant !== null && variant !== void 0 ? variant : inVariant);
|
5744 | }
|
5745 | }
|
5746 |
|
5747 |
|
5748 |
|
5749 |
|
5750 |
|
5751 | function newSymbolRange(from, to) {
|
5752 | for (let i = from; i <= to; i++) {
|
5753 | newSymbol(String.fromCodePoint(i), i);
|
5754 | }
|
5755 | }
|
5756 |
|
5757 |
|
5758 |
|
5759 |
|
5760 | function charToLatex(parseMode, codepoint) {
|
5761 | if (codepoint === undefined)
|
5762 | return '';
|
5763 | if (parseMode === 'math' && REVERSE_MATH_SYMBOLS[codepoint]) {
|
5764 | return REVERSE_MATH_SYMBOLS[codepoint];
|
5765 | }
|
5766 | if (parseMode === 'text') {
|
5767 | let textSymbol = Object.keys(TEXT_SYMBOLS).find((x) => TEXT_SYMBOLS[x] === codepoint);
|
5768 | if (!textSymbol) {
|
5769 | const hex = codepoint.toString(16);
|
5770 | textSymbol = '^'.repeat(hex.length) + hex;
|
5771 | }
|
5772 | return textSymbol;
|
5773 | }
|
5774 | return String.fromCodePoint(codepoint);
|
5775 | }
|
5776 |
|
5777 |
|
5778 | const MATH_LETTER_EXCEPTIONS = {
|
5779 | 0x1d455: 0x0210e,
|
5780 | 0x1d49d: 0x0212c,
|
5781 | 0x1d4a0: 0x02130,
|
5782 | 0x1d4a1: 0x02131,
|
5783 | 0x1d4a3: 0x0210b,
|
5784 | 0x1d4a4: 0x02110,
|
5785 | 0x1d4a7: 0x02112,
|
5786 | 0x1d4a8: 0x02133,
|
5787 | 0x1d4ad: 0x0211b,
|
5788 | 0x1d4ba: 0x0212f,
|
5789 | 0x1d4bc: 0x0210a,
|
5790 | 0x1d4c4: 0x02134,
|
5791 | 0x1d506: 0x0212d,
|
5792 | 0x1d50b: 0x0210c,
|
5793 | 0x1d50c: 0x02111,
|
5794 | 0x1d515: 0x0211c,
|
5795 | 0x1d51d: 0x02128,
|
5796 | 0x1d53a: 0x02102,
|
5797 | 0x1d53f: 0x0210d,
|
5798 | 0x1d545: 0x02115,
|
5799 | 0x1d547: 0x02119,
|
5800 | 0x1d548: 0x0211a,
|
5801 | 0x1d549: 0x0211d,
|
5802 | 0x1d551: 0x02124,
|
5803 | };
|
5804 | const MATH_UNICODE_BLOCKS = [
|
5805 | { start: 0x1d400, len: 26, offset: 65, style: 'bold' },
|
5806 | { start: 0x1d41a, len: 26, offset: 97, style: 'bold' },
|
5807 | { start: 0x1d434, len: 26, offset: 65, style: 'italic' },
|
5808 | { start: 0x1d44e, len: 26, offset: 97, style: 'italic' },
|
5809 | { start: 0x1d468, len: 26, offset: 65, style: 'bolditalic' },
|
5810 | { start: 0x1d482, len: 26, offset: 97, style: 'bolditalic' },
|
5811 | { start: 0x1d49c, len: 26, offset: 65, variant: 'script' },
|
5812 | { start: 0x1d4b6, len: 26, offset: 97, variant: 'script' },
|
5813 | { start: 0x1d4d0, len: 26, offset: 65, variant: 'script', style: 'bold' },
|
5814 | { start: 0x1d4ea, len: 26, offset: 97, variant: 'script', style: 'bold' },
|
5815 | { start: 0x1d504, len: 26, offset: 65, variant: 'fraktur' },
|
5816 | { start: 0x1d51e, len: 26, offset: 97, variant: 'fraktur' },
|
5817 | { start: 0x1d56c, len: 26, offset: 65, variant: 'fraktur', style: 'bold' },
|
5818 | { start: 0x1d586, len: 26, offset: 97, variant: 'fraktur', style: 'bold' },
|
5819 | { start: 0x1d538, len: 26, offset: 65, variant: 'double-struck' },
|
5820 | { start: 0x1d552, len: 26, offset: 97, variant: 'double-struck' },
|
5821 | { start: 0x1d5a0, len: 26, offset: 65, variant: 'sans-serif' },
|
5822 | { start: 0x1d5ba, len: 26, offset: 97, variant: 'sans-serif' },
|
5823 | {
|
5824 | start: 0x1d5d4,
|
5825 | len: 26,
|
5826 | offset: 65,
|
5827 | variant: 'sans-serif',
|
5828 | style: 'bold',
|
5829 | },
|
5830 | {
|
5831 | start: 0x1d5ee,
|
5832 | len: 26,
|
5833 | offset: 97,
|
5834 | variant: 'sans-serif',
|
5835 | style: 'bold',
|
5836 | },
|
5837 | {
|
5838 | start: 0x1d608,
|
5839 | len: 26,
|
5840 | offset: 65,
|
5841 | variant: 'sans-serif',
|
5842 | style: 'italic',
|
5843 | },
|
5844 | {
|
5845 | start: 0x1d622,
|
5846 | len: 26,
|
5847 | offset: 97,
|
5848 | variant: 'sans-serif',
|
5849 | style: 'italic',
|
5850 | },
|
5851 | {
|
5852 | start: 0x1d63c,
|
5853 | len: 26,
|
5854 | offset: 65,
|
5855 | variant: 'sans-serif',
|
5856 | style: 'bolditalic',
|
5857 | },
|
5858 | {
|
5859 | start: 0x1d656,
|
5860 | len: 26,
|
5861 | offset: 97,
|
5862 | variant: 'sans-serif',
|
5863 | style: 'bolditalic',
|
5864 | },
|
5865 | { start: 0x1d670, len: 26, offset: 65, variant: 'monospace' },
|
5866 | { start: 0x1d68a, len: 26, offset: 97, variant: 'monospace' },
|
5867 | { start: 0x1d6a8, len: 25, offset: 0x391, style: 'bold' },
|
5868 | { start: 0x1d6c2, len: 25, offset: 0x3b1, style: 'bold' },
|
5869 | { start: 0x1d6e2, len: 25, offset: 0x391, style: 'italic' },
|
5870 | { start: 0x1d6fc, len: 25, offset: 0x3b1, style: 'italic' },
|
5871 | { start: 0x1d71c, len: 25, offset: 0x391, style: 'bolditalic' },
|
5872 | { start: 0x1d736, len: 25, offset: 0x3b1, style: 'bolditalic' },
|
5873 | {
|
5874 | start: 0x1d756,
|
5875 | len: 25,
|
5876 | offset: 0x391,
|
5877 | variant: 'sans-serif',
|
5878 | style: 'bold',
|
5879 | },
|
5880 | {
|
5881 | start: 0x1d770,
|
5882 | len: 25,
|
5883 | offset: 0x3b1,
|
5884 | variant: 'sans-serif',
|
5885 | style: 'bold',
|
5886 | },
|
5887 | {
|
5888 | start: 0x1d790,
|
5889 | len: 25,
|
5890 | offset: 0x391,
|
5891 | variant: 'sans-serif',
|
5892 | style: 'bolditalic',
|
5893 | },
|
5894 | {
|
5895 | start: 0x1d7aa,
|
5896 | len: 25,
|
5897 | offset: 0x3b1,
|
5898 | variant: 'sans-serif',
|
5899 | style: 'bolditalic',
|
5900 | },
|
5901 | { start: 0x1d7ce, len: 10, offset: 48, variant: 'main', style: 'bold' },
|
5902 | { start: 0x1d7d8, len: 10, offset: 48, variant: 'double-struck' },
|
5903 | { start: 0x1d7e3, len: 10, offset: 48, variant: 'sans-serif' },
|
5904 | {
|
5905 | start: 0x1d7ec,
|
5906 | len: 10,
|
5907 | offset: 48,
|
5908 | variant: 'sans-serif',
|
5909 | style: 'bold',
|
5910 | },
|
5911 | { start: 0x1d7f6, len: 10, offset: 48, variant: 'monospace' },
|
5912 | ];
|
5913 | function unicodeToMathVariant(codepoint) {
|
5914 | var _a;
|
5915 | if ((codepoint < 0x1d400 || codepoint > 0x1d7ff) &&
|
5916 | (codepoint < 0x2100 || codepoint > 0x214f)) {
|
5917 | return { char: String.fromCodePoint(codepoint) };
|
5918 | }
|
5919 |
|
5920 | for (const c in MATH_LETTER_EXCEPTIONS) {
|
5921 | if (MATH_LETTER_EXCEPTIONS[c] === codepoint) {
|
5922 | codepoint = (_a = c.codePointAt(0)) !== null && _a !== void 0 ? _a : 0;
|
5923 | break;
|
5924 | }
|
5925 | }
|
5926 | for (const MATH_UNICODE_BLOCK of MATH_UNICODE_BLOCKS) {
|
5927 | if (codepoint >= MATH_UNICODE_BLOCK.start &&
|
5928 | codepoint < MATH_UNICODE_BLOCK.start + MATH_UNICODE_BLOCK.len) {
|
5929 | return {
|
5930 | char: String.fromCodePoint(codepoint - MATH_UNICODE_BLOCK.start + MATH_UNICODE_BLOCK.offset),
|
5931 | variant: MATH_UNICODE_BLOCK.variant,
|
5932 | style: MATH_UNICODE_BLOCK.style,
|
5933 | };
|
5934 | }
|
5935 | }
|
5936 | return { char: String.fromCodePoint(codepoint) };
|
5937 | }
|
5938 |
|
5939 |
|
5940 |
|
5941 |
|
5942 | function mathVariantToUnicode(char, variant, style) {
|
5943 | if (!/[A-Za-z\d]/.test(char))
|
5944 | return char;
|
5945 | if (!variant && !style)
|
5946 | return char;
|
5947 | const codepoint = char.codePointAt(0);
|
5948 | if (codepoint === undefined)
|
5949 | return char;
|
5950 | for (const MATH_UNICODE_BLOCK of MATH_UNICODE_BLOCKS) {
|
5951 | if (!variant || MATH_UNICODE_BLOCK.variant === variant) {
|
5952 | if (!style || MATH_UNICODE_BLOCK.style === style) {
|
5953 | if (codepoint >= MATH_UNICODE_BLOCK.offset &&
|
5954 | codepoint < MATH_UNICODE_BLOCK.offset + MATH_UNICODE_BLOCK.len) {
|
5955 | const result = MATH_UNICODE_BLOCK.start + codepoint - MATH_UNICODE_BLOCK.offset;
|
5956 | return String.fromCodePoint(MATH_LETTER_EXCEPTIONS[result] || result);
|
5957 | }
|
5958 | }
|
5959 | }
|
5960 | }
|
5961 | return char;
|
5962 | }
|
5963 | function unicodeCharToLatex(parseMode, char) {
|
5964 | var _a;
|
5965 | if (parseMode === 'text') {
|
5966 | return (_a = charToLatex(parseMode, char.codePointAt(0))) !== null && _a !== void 0 ? _a : char;
|
5967 | }
|
5968 | let result;
|
5969 |
|
5970 |
|
5971 |
|
5972 | result = charToLatex(parseMode, char.codePointAt(0));
|
5973 | if (result)
|
5974 | return result;
|
5975 | const cp = char.codePointAt(0);
|
5976 | const v = unicodeToMathVariant(cp);
|
5977 | if (!v.style && !v.variant)
|
5978 | return '';
|
5979 | result = v.char;
|
5980 | if (v.variant) {
|
5981 | result = '\\' + v.variant + '{' + result + '}';
|
5982 | }
|
5983 | if (v.style === 'bold') {
|
5984 | result = '\\mathbf{' + result + '}';
|
5985 | }
|
5986 | else if (v.style === 'italic') {
|
5987 | result = '\\mathit{' + result + '}';
|
5988 | }
|
5989 | else if (v.style === 'bolditalic') {
|
5990 | result = '\\mathbfit{' + result + '}';
|
5991 | }
|
5992 | return '\\mathord{' + result + '}';
|
5993 | }
|
5994 |
|
5995 |
|
5996 |
|
5997 |
|
5998 |
|
5999 |
|
6000 | function getEnvironmentDefinition(name) {
|
6001 | var _a;
|
6002 | return (_a = ENVIRONMENTS[name]) !== null && _a !== void 0 ? _a : null;
|
6003 | }
|
6004 |
|
6005 |
|
6006 |
|
6007 |
|
6008 |
|
6009 |
|
6010 | function getInfo(symbol, parseMode, macros) {
|
6011 | var _a, _b;
|
6012 | if (!symbol || symbol.length === 0)
|
6013 | return null;
|
6014 | let info = null;
|
6015 | if (symbol.startsWith('\\')) {
|
6016 |
|
6017 | info = (_a = LEGACY_COMMANDS[symbol]) !== null && _a !== void 0 ? _a : null;
|
6018 | if (info) {
|
6019 |
|
6020 | return info;
|
6021 | }
|
6022 |
|
6023 | if (parseMode === 'math') {
|
6024 | info = MATH_SYMBOLS[symbol];
|
6025 | }
|
6026 | else if (TEXT_SYMBOLS[symbol]) {
|
6027 | info = { type: 'mord', codepoint: TEXT_SYMBOLS[symbol] };
|
6028 | }
|
6029 | if (!info) {
|
6030 |
|
6031 | const command = symbol.slice(1);
|
6032 | if (macros === null || macros === void 0 ? void 0 : macros[command]) {
|
6033 | let argCount = (_b = macros[command].args) !== null && _b !== void 0 ? _b : 0;
|
6034 | info = {
|
6035 | type: 'group',
|
6036 | params: [],
|
6037 | infix: false,
|
6038 | };
|
6039 | while (argCount >= 1) {
|
6040 | info.params.push({
|
6041 | isOptional: false,
|
6042 | type: 'math',
|
6043 | });
|
6044 | argCount -= 1;
|
6045 | }
|
6046 | }
|
6047 | }
|
6048 | }
|
6049 | else if (parseMode === 'math') {
|
6050 | info = MATH_SYMBOLS[symbol];
|
6051 | }
|
6052 | else if (TEXT_SYMBOLS[symbol]) {
|
6053 | info = { codepoint: TEXT_SYMBOLS[symbol], type: 'mord' };
|
6054 | }
|
6055 | else if (parseMode === 'text') {
|
6056 | info = { codepoint: symbol.codePointAt(0), type: 'mord' };
|
6057 | }
|
6058 |
|
6059 | if (info &&
|
6060 | info.type === 'mord' &&
|
6061 | (info.codepoint === 0x66 ||
|
6062 | info.codepoint === 0x67 ||
|
6063 | info.codepoint === 0x68)) {
|
6064 |
|
6065 | info.isFunction = true;
|
6066 | }
|
6067 | return info;
|
6068 | }
|
6069 |
|
6070 |
|
6071 |
|
6072 |
|
6073 |
|
6074 | function suggest(s) {
|
6075 | var _a, _b;
|
6076 | if (s === '\\')
|
6077 | return [];
|
6078 | const result = [];
|
6079 |
|
6080 | for (const p in LEGACY_COMMANDS) {
|
6081 |
|
6082 | if (p.startsWith(s) && !LEGACY_COMMANDS[p].infix) {
|
6083 | result.push({ match: p, frequency: (_a = LEGACY_COMMANDS[p].frequency) !== null && _a !== void 0 ? _a : 0 });
|
6084 | }
|
6085 | }
|
6086 | for (const p in MATH_SYMBOLS) {
|
6087 | if (p.startsWith(s)) {
|
6088 | result.push({ match: p, frequency: (_b = MATH_SYMBOLS[p].frequency) !== null && _b !== void 0 ? _b : 0 });
|
6089 | }
|
6090 | }
|
6091 | result.sort((a, b) => {
|
6092 | var _a, _b;
|
6093 | if (a.frequency === b.frequency) {
|
6094 | if (a.match.length === b.match.length) {
|
6095 | return a.match.localeCompare(b.match);
|
6096 | }
|
6097 | return a.match.length - b.match.length;
|
6098 | }
|
6099 | return ((_a = b.frequency) !== null && _a !== void 0 ? _a : 0) - ((_b = a.frequency) !== null && _b !== void 0 ? _b : 0);
|
6100 | });
|
6101 | return result;
|
6102 | }
|
6103 |
|
6104 |
|
6105 |
|
6106 |
|
6107 |
|
6108 |
|
6109 |
|
6110 |
|
6111 |
|
6112 |
|
6113 |
|
6114 | function parseParameterTemplateArgument(argTemplate) {
|
6115 | let type = 'auto';
|
6116 |
|
6117 | const r = argTemplate.match(/:([^=]+)/);
|
6118 | if (r)
|
6119 | type = r[1].trim();
|
6120 | return type;
|
6121 | }
|
6122 | function parseParameterTemplate(parameterTemplate) {
|
6123 | if (!parameterTemplate)
|
6124 | return [];
|
6125 | let result = [];
|
6126 | let parameters = parameterTemplate.split(']');
|
6127 | if (parameters[0].startsWith('[')) {
|
6128 |
|
6129 | result.push({
|
6130 | isOptional: true,
|
6131 | type: parseParameterTemplateArgument(parameters[0].slice(1)),
|
6132 | });
|
6133 |
|
6134 | for (let i = 1; i <= parameters.length; i++) {
|
6135 | result = result.concat(parseParameterTemplate(parameters[i]));
|
6136 | }
|
6137 | }
|
6138 | else {
|
6139 | parameters = parameterTemplate.split('}');
|
6140 | if (parameters[0].startsWith('{')) {
|
6141 |
|
6142 | result.push({
|
6143 | isOptional: false,
|
6144 | type: parseParameterTemplateArgument(parameters[0].slice(1)),
|
6145 | });
|
6146 |
|
6147 | for (let i = 1; i <= parameters.length; i++) {
|
6148 | result = result.concat(parseParameterTemplate(parameters[i]));
|
6149 | }
|
6150 | }
|
6151 | }
|
6152 | return result;
|
6153 | }
|
6154 |
|
6155 |
|
6156 |
|
6157 |
|
6158 | function parseArgAsString(atoms) {
|
6159 | if (!atoms)
|
6160 | return '';
|
6161 | let result = '';
|
6162 | let success = true;
|
6163 | for (const atom of atoms) {
|
6164 | if (typeof atom.value === 'string') {
|
6165 | result += atom.value;
|
6166 | }
|
6167 | else {
|
6168 | success = false;
|
6169 | }
|
6170 | }
|
6171 | return success ? result : '';
|
6172 | }
|
6173 |
|
6174 |
|
6175 |
|
6176 |
|
6177 |
|
6178 |
|
6179 | function defineEnvironment(names, parameters, parser, isTabular = false) {
|
6180 | if (typeof names === 'string') {
|
6181 | names = [names];
|
6182 | }
|
6183 | const parsedParameters = parseParameterTemplate(parameters);
|
6184 |
|
6185 | const data = {
|
6186 | tabular: isTabular,
|
6187 |
|
6188 |
|
6189 | params: parsedParameters,
|
6190 |
|
6191 | createAtom: parser,
|
6192 | };
|
6193 | for (const name of names) {
|
6194 | ENVIRONMENTS[name] = data;
|
6195 | }
|
6196 | }
|
6197 |
|
6198 |
|
6199 |
|
6200 |
|
6201 |
|
6202 | function defineTabularEnvironment(names, parameters, parser) {
|
6203 | defineEnvironment(names, parameters, parser, true);
|
6204 | }
|
6205 |
|
6206 |
|
6207 |
|
6208 |
|
6209 |
|
6210 |
|
6211 |
|
6212 |
|
6213 | function defineFunction(names, parameters, options) {
|
6214 | var _a, _b;
|
6215 | if (!options)
|
6216 | options = {};
|
6217 |
|
6218 | const data = {
|
6219 |
|
6220 |
|
6221 | params: parseParameterTemplate(parameters),
|
6222 | ifMode: options.ifMode,
|
6223 | isFunction: (_a = options.isFunction) !== null && _a !== void 0 ? _a : false,
|
6224 | applyMode: options.applyMode,
|
6225 | infix: (_b = options.infix) !== null && _b !== void 0 ? _b : false,
|
6226 | createAtom: options.createAtom,
|
6227 | applyStyle: options.applyStyle,
|
6228 | };
|
6229 | if (typeof names === 'string') {
|
6230 | LEGACY_COMMANDS['\\' + names] = data;
|
6231 | }
|
6232 | else {
|
6233 | for (const name of names)
|
6234 | LEGACY_COMMANDS['\\' + name] = data;
|
6235 | }
|
6236 | }
|
6237 | let _DEFAULT_MACROS;
|
6238 | function getMacros(otherMacros) {
|
6239 | if (!_DEFAULT_MACROS) {
|
6240 | _DEFAULT_MACROS = normalizeMacroDictionary(DEFAULT_MACROS);
|
6241 | }
|
6242 | if (!otherMacros)
|
6243 | return _DEFAULT_MACROS;
|
6244 | return { ..._DEFAULT_MACROS, ...normalizeMacroDictionary(otherMacros) };
|
6245 | }
|
6246 | function normalizeMacroDefinition(def, options) {
|
6247 | var _a, _b, _c, _d;
|
6248 | if (typeof def === 'string') {
|
6249 |
|
6250 | let argCount = 0;
|
6251 | const defString = def;
|
6252 |
|
6253 | if (/(^|[^\\])#1/.test(defString))
|
6254 | argCount = 1;
|
6255 | if (/(^|[^\\])#2/.test(defString))
|
6256 | argCount = 2;
|
6257 | if (/(^|[^\\])#3/.test(defString))
|
6258 | argCount = 3;
|
6259 | if (/(^|[^\\])#4/.test(defString))
|
6260 | argCount = 4;
|
6261 | if (/(^|[^\\])#5/.test(defString))
|
6262 | argCount = 5;
|
6263 | if (/(^|[^\\])#6/.test(defString))
|
6264 | argCount = 6;
|
6265 | if (/(^|[^\\])#7/.test(defString))
|
6266 | argCount = 7;
|
6267 | if (/(^|[^\\])#8/.test(defString))
|
6268 | argCount = 8;
|
6269 | if (/(^|[^\\])#9/.test(defString))
|
6270 | argCount = 9;
|
6271 | return {
|
6272 | expand: (_a = options === null || options === void 0 ? void 0 : options.expand) !== null && _a !== void 0 ? _a : true,
|
6273 | captureSelection: (_b = options === null || options === void 0 ? void 0 : options.captureSelection) !== null && _b !== void 0 ? _b : true,
|
6274 | args: argCount,
|
6275 | def: defString,
|
6276 | };
|
6277 | }
|
6278 | return {
|
6279 | expand: (_c = options === null || options === void 0 ? void 0 : options.expand) !== null && _c !== void 0 ? _c : true,
|
6280 | captureSelection: (_d = options === null || options === void 0 ? void 0 : options.captureSelection) !== null && _d !== void 0 ? _d : true,
|
6281 | args: 0,
|
6282 | ...def,
|
6283 | };
|
6284 | }
|
6285 | function normalizeMacroDictionary(macros) {
|
6286 | if (!macros)
|
6287 | return {};
|
6288 | const result = {};
|
6289 | for (const macro of Object.keys(macros)) {
|
6290 | const macroDef = macros[macro];
|
6291 | if (macroDef === undefined || macroDef === null) {
|
6292 | delete result[macro];
|
6293 | }
|
6294 | else if (typeof macroDef === 'object' && 'package' in macroDef) {
|
6295 | for (const packageMacro of Object.keys(macroDef.package)) {
|
6296 | result[packageMacro] = normalizeMacroDefinition(macroDef.package[packageMacro], {
|
6297 | expand: macroDef.expand,
|
6298 | captureSelection: macroDef.captureSelection,
|
6299 | });
|
6300 | }
|
6301 | }
|
6302 | else {
|
6303 | result[macro] = normalizeMacroDefinition(macroDef);
|
6304 | }
|
6305 | }
|
6306 | return result;
|
6307 | }
|
6308 |
|
6309 | class MathfieldBox extends Box {
|
6310 | constructor(placeholderId, element, options) {
|
6311 | super(null, options);
|
6312 | this.placeholderId = placeholderId;
|
6313 | this.element = element;
|
6314 | this.htmlData = `placeholder-id=${placeholderId}`;
|
6315 | this.height =
|
6316 | element.style.fontSize === ''
|
6317 | ? 1
|
6318 | : (element.clientHeight / parseInt(element.style.fontSize)) * 0.6;
|
6319 | }
|
6320 | toMarkup() {
|
6321 | let props = '';
|
6322 | const classes = this.classes.split(' ');
|
6323 | const classList = classes.length === 1
|
6324 | ? classes[0]
|
6325 | : classes
|
6326 | .filter((x, e, a) => x.length > 0 && a.indexOf(x) === e)
|
6327 | .join(' ');
|
6328 | if (this.cssId) {
|
6329 |
|
6330 | props += ` id=${this.cssId.replace(/ /g, '-')} `;
|
6331 | }
|
6332 | if (this.htmlData) {
|
6333 | const entries = this.htmlData.split(',');
|
6334 | for (const entry of entries) {
|
6335 | const matched = entry.match(/([^=]+)=(.+$)/);
|
6336 | if (matched) {
|
6337 | const key = matched[1].trim().replace(/ /g, '-');
|
6338 | if (key) {
|
6339 | props += ` data-${key}=${matched[2]} `;
|
6340 | }
|
6341 | }
|
6342 | else {
|
6343 | const key = entry.trim().replace(/ /g, '-');
|
6344 | if (key) {
|
6345 | props += ` data-${key} `;
|
6346 | }
|
6347 | }
|
6348 | }
|
6349 | }
|
6350 | if (this.attributes) {
|
6351 | props +=
|
6352 | ' ' +
|
6353 | Object.keys(this.attributes)
|
6354 | .map((x) => `${x}="${this.attributes[x]}"`)
|
6355 | .join(' ');
|
6356 | }
|
6357 | if (classList.length > 0) {
|
6358 | props += ` class="${classList}"`;
|
6359 | }
|
6360 | props += ` style="display: inline-block; width:${this.element.clientWidth}px; height:${this.element.clientHeight}px; "`;
|
6361 | return `<span ${props}></span>`;
|
6362 | }
|
6363 | }
|
6364 |
|
6365 |
|
6366 |
|
6367 |
|
6368 | const NAMED_BRANCHES = [
|
6369 | 'above',
|
6370 | 'body',
|
6371 | 'below',
|
6372 | 'superscript',
|
6373 | 'subscript',
|
6374 | ];
|
6375 |
|
6376 |
|
6377 |
|
6378 |
|
6379 |
|
6380 |
|
6381 |
|
6382 |
|
6383 |
|
6384 | function isNamedBranch(branch) {
|
6385 | return typeof branch === 'string' && NAMED_BRANCHES.includes(branch);
|
6386 | }
|
6387 | function isColRowBranch(branch) {
|
6388 | return branch !== undefined && Array.isArray(branch) && branch.length === 2;
|
6389 | }
|
6390 |
|
6391 |
|
6392 |
|
6393 |
|
6394 |
|
6395 |
|
6396 |
|
6397 | class Atom {
|
6398 | constructor(type, options) {
|
6399 | var _a, _b, _c, _d;
|
6400 | this.command = options === null || options === void 0 ? void 0 : options.command;
|
6401 | this.type = type;
|
6402 | if (typeof (options === null || options === void 0 ? void 0 : options.value) === 'string') {
|
6403 | this.value = options.value;
|
6404 | }
|
6405 | this._isDirty = false;
|
6406 | this._changeCounter = 0;
|
6407 | this.mode = (_a = options === null || options === void 0 ? void 0 : options.mode) !== null && _a !== void 0 ? _a : 'math';
|
6408 | this.isFunction = (_b = options === null || options === void 0 ? void 0 : options.isFunction) !== null && _b !== void 0 ? _b : false;
|
6409 | this.subsupPlacement = options === null || options === void 0 ? void 0 : options.limits;
|
6410 | this.style = (_c = options === null || options === void 0 ? void 0 : options.style) !== null && _c !== void 0 ? _c : {};
|
6411 | this.serializeOverride = options === null || options === void 0 ? void 0 : options.serialize;
|
6412 | this.displayContainsHighlight = (_d = options === null || options === void 0 ? void 0 : options.displayContainsHighlight) !== null && _d !== void 0 ? _d : false;
|
6413 | }
|
6414 | get changeCounter() {
|
6415 | return this._changeCounter;
|
6416 | }
|
6417 | get isDirty() {
|
6418 | return this._isDirty;
|
6419 | }
|
6420 | set isDirty(dirty) {
|
6421 | this._isDirty = dirty;
|
6422 | if (dirty) {
|
6423 | this._changeCounter++;
|
6424 | this.verbatimLatex = undefined;
|
6425 | this._children = undefined;
|
6426 | let { parent } = this;
|
6427 | while (parent) {
|
6428 | parent._isDirty = true;
|
6429 | parent._changeCounter++;
|
6430 | parent.verbatimLatex = undefined;
|
6431 | parent._children = undefined;
|
6432 | parent = parent.parent;
|
6433 | }
|
6434 | }
|
6435 | }
|
6436 | |
6437 |
|
6438 |
|
6439 |
|
6440 |
|
6441 |
|
6442 |
|
6443 |
|
6444 |
|
6445 |
|
6446 |
|
6447 |
|
6448 |
|
6449 |
|
6450 | static createBox(parentContext, atoms, options) {
|
6451 | var _a, _b, _c;
|
6452 | if (!atoms)
|
6453 | return null;
|
6454 | const runs = getStyleRuns(atoms);
|
6455 |
|
6456 |
|
6457 |
|
6458 | if (runs.length === 1) {
|
6459 | const run = runs[0];
|
6460 | if (run[0].style) {
|
6461 | return renderStyleRun(parentContext, run, {
|
6462 | ...options,
|
6463 | style: {
|
6464 | color: run[0].style.color,
|
6465 | backgroundColor: run[0].style.backgroundColor,
|
6466 | fontSize: run[0].style.fontSize,
|
6467 | },
|
6468 | });
|
6469 | }
|
6470 | return renderStyleRun(parentContext, run, options);
|
6471 | }
|
6472 |
|
6473 |
|
6474 |
|
6475 | const boxes = [];
|
6476 | let newList = options === null || options === void 0 ? void 0 : options.newList;
|
6477 | for (const run of runs) {
|
6478 | const context = new Context(parentContext, {
|
6479 | color: (_a = run[0].style) === null || _a === void 0 ? void 0 : _a.color,
|
6480 | backgroundColor: (_b = run[0].style) === null || _b === void 0 ? void 0 : _b.backgroundColor,
|
6481 | fontSize: (_c = run[0].style) === null || _c === void 0 ? void 0 : _c.fontSize,
|
6482 | isSelected: run[0].isSelected,
|
6483 | });
|
6484 | const box = renderStyleRun(context, run, { newList });
|
6485 | if (box) {
|
6486 | newList = false;
|
6487 | boxes.push(box);
|
6488 | }
|
6489 | }
|
6490 | if (boxes.length === 0)
|
6491 | return null;
|
6492 | if (boxes.length === 1 && !(options === null || options === void 0 ? void 0 : options.classes) && !(options === null || options === void 0 ? void 0 : options.type)) {
|
6493 | return boxes[0].wrap(parentContext);
|
6494 | }
|
6495 | return new Box(boxes, {
|
6496 | classes: options === null || options === void 0 ? void 0 : options.classes,
|
6497 | type: options === null || options === void 0 ? void 0 : options.type,
|
6498 | newList: options === null || options === void 0 ? void 0 : options.newList,
|
6499 | }).wrap(parentContext);
|
6500 | }
|
6501 | |
6502 |
|
6503 |
|
6504 | static serialize(value, options) {
|
6505 | let result = '';
|
6506 | if (isArray(value)) {
|
6507 | result = atomsToLatex(value, options);
|
6508 | }
|
6509 | else if (typeof value === 'number' || typeof value === 'boolean') {
|
6510 | result = value.toString();
|
6511 | }
|
6512 | else if (typeof value === 'string') {
|
6513 | result = value.replace(/\s/g, '~');
|
6514 | }
|
6515 | else if (value !== undefined) {
|
6516 |
|
6517 |
|
6518 | if (!options.expandMacro && typeof value.verbatimLatex === 'string') {
|
6519 | return value.verbatimLatex;
|
6520 | }
|
6521 | if (value.serializeOverride) {
|
6522 | return value.serializeOverride(value, options);
|
6523 | }
|
6524 | result = value.serialize(options);
|
6525 | }
|
6526 | return result;
|
6527 | }
|
6528 | |
6529 |
|
6530 |
|
6531 | static commonAncestor(a, b) {
|
6532 | if (a === b)
|
6533 | return a.parent;
|
6534 |
|
6535 | if (a.parent === b.parent)
|
6536 | return a.parent;
|
6537 |
|
6538 | const parents = new WeakSet();
|
6539 | let { parent } = a;
|
6540 | while (parent) {
|
6541 | parents.add(parent);
|
6542 | parent = parent.parent;
|
6543 | }
|
6544 |
|
6545 |
|
6546 | parent = b.parent;
|
6547 | while (parent) {
|
6548 | if (parents.has(parent))
|
6549 | return parent;
|
6550 | parent = parent.parent;
|
6551 | }
|
6552 | console.assert(Boolean(parent));
|
6553 | return undefined;
|
6554 | }
|
6555 | |
6556 |
|
6557 |
|
6558 |
|
6559 |
|
6560 |
|
6561 | serialize(options) {
|
6562 | var _a;
|
6563 | if (this.body && this.command) {
|
6564 |
|
6565 | return joinLatex([
|
6566 | this.command,
|
6567 | '{',
|
6568 | this.bodyToLatex(options),
|
6569 | '}',
|
6570 | this.supsubToLatex(options),
|
6571 | ]);
|
6572 | }
|
6573 | if (this.body) {
|
6574 |
|
6575 | return joinLatex([
|
6576 | this.bodyToLatex(options),
|
6577 | this.supsubToLatex(options),
|
6578 | ]);
|
6579 | }
|
6580 | if (this.value && this.value !== '\u200B') {
|
6581 |
|
6582 | return (_a = this.command) !== null && _a !== void 0 ? _a : unicodeCharToLatex(this.mode, this.value);
|
6583 | }
|
6584 | return '';
|
6585 | }
|
6586 | bodyToLatex(options) {
|
6587 | return atomsToLatex(this.body, options);
|
6588 | }
|
6589 | aboveToLatex(options) {
|
6590 | return atomsToLatex(this.above, options);
|
6591 | }
|
6592 | belowToLatex(options) {
|
6593 | return atomsToLatex(this.below, options);
|
6594 | }
|
6595 | supsubToLatex(options) {
|
6596 | let result = '';
|
6597 |
|
6598 |
|
6599 |
|
6600 |
|
6601 |
|
6602 | if (this.branch('subscript') !== undefined) {
|
6603 | const sub = atomsToLatex(this.subscript, options);
|
6604 | if (sub.length === 0) {
|
6605 | result += '_';
|
6606 | }
|
6607 | else if (sub.length === 1) {
|
6608 | result += '_' + sub;
|
6609 | }
|
6610 | else {
|
6611 | result += `_{${sub}}`;
|
6612 | }
|
6613 | }
|
6614 | if (this.branch('superscript') !== undefined) {
|
6615 | const sup = atomsToLatex(this.superscript, options);
|
6616 | if (sup.length === 0) {
|
6617 | result += '^';
|
6618 | }
|
6619 | else if (sup.length === 1) {
|
6620 | if (sup === '\u2032') {
|
6621 | result += '^\\prime ';
|
6622 | }
|
6623 | else if (sup === '\u2033') {
|
6624 | result += '^\\doubleprime ';
|
6625 | }
|
6626 | else {
|
6627 | result += '^' + sup;
|
6628 | }
|
6629 | }
|
6630 | else {
|
6631 | result += `^{${sup}}`;
|
6632 | }
|
6633 | }
|
6634 | return result;
|
6635 | }
|
6636 | get treeDepth() {
|
6637 | let result = 1;
|
6638 | let atom = this.parent;
|
6639 | while (atom) {
|
6640 | atom = atom.parent;
|
6641 | result += 1;
|
6642 | }
|
6643 | return result;
|
6644 | }
|
6645 | get inCaptureSelection() {
|
6646 | let result = false;
|
6647 |
|
6648 | let atom = this;
|
6649 | while (atom) {
|
6650 | if (atom.captureSelection) {
|
6651 | result = true;
|
6652 | break;
|
6653 | }
|
6654 | atom = atom.parent;
|
6655 | }
|
6656 | return result;
|
6657 | }
|
6658 | |
6659 |
|
6660 |
|
6661 | branch(name) {
|
6662 | if (!isNamedBranch(name))
|
6663 | return undefined;
|
6664 | if (!this._branches)
|
6665 | return undefined;
|
6666 | return this._branches[name];
|
6667 | }
|
6668 | |
6669 |
|
6670 |
|
6671 |
|
6672 | get branches() {
|
6673 | if (!this._branches)
|
6674 | return [];
|
6675 | const result = [];
|
6676 | for (const branch of NAMED_BRANCHES) {
|
6677 | if (this._branches[branch]) {
|
6678 | result.push(branch);
|
6679 | }
|
6680 | }
|
6681 | return result;
|
6682 | }
|
6683 | |
6684 |
|
6685 |
|
6686 | createBranch(name) {
|
6687 | console.assert(isNamedBranch(name));
|
6688 | if (!isNamedBranch(name))
|
6689 | return [];
|
6690 | if (!this._branches) {
|
6691 | this._branches = {
|
6692 | [name]: [this.makeFirstAtom(name)],
|
6693 | };
|
6694 | }
|
6695 | else if (!this._branches[name]) {
|
6696 | this._branches[name] = [this.makeFirstAtom(name)];
|
6697 | }
|
6698 | this.isDirty = true;
|
6699 | return this._branches[name];
|
6700 | }
|
6701 | get row() {
|
6702 | if (!isColRowBranch(this.treeBranch))
|
6703 | return -1;
|
6704 | return this.treeBranch[0];
|
6705 | }
|
6706 | get col() {
|
6707 | if (!isColRowBranch(this.treeBranch))
|
6708 | return -1;
|
6709 | return this.treeBranch[1];
|
6710 | }
|
6711 | get body() {
|
6712 | var _a;
|
6713 | return (_a = this._branches) === null || _a === void 0 ? void 0 : _a.body;
|
6714 | }
|
6715 | set body(atoms) {
|
6716 | this.setChildren(atoms, 'body');
|
6717 | }
|
6718 | get superscript() {
|
6719 | var _a;
|
6720 | return (_a = this._branches) === null || _a === void 0 ? void 0 : _a.superscript;
|
6721 | }
|
6722 | set superscript(atoms) {
|
6723 | this.setChildren(atoms, 'superscript');
|
6724 | }
|
6725 | get subscript() {
|
6726 | var _a;
|
6727 | return (_a = this._branches) === null || _a === void 0 ? void 0 : _a.subscript;
|
6728 | }
|
6729 | set subscript(atoms) {
|
6730 | this.setChildren(atoms, 'subscript');
|
6731 | }
|
6732 | get above() {
|
6733 | var _a;
|
6734 | return (_a = this._branches) === null || _a === void 0 ? void 0 : _a.above;
|
6735 | }
|
6736 | set above(atoms) {
|
6737 | this.setChildren(atoms, 'above');
|
6738 | }
|
6739 | get below() {
|
6740 | var _a;
|
6741 | return (_a = this._branches) === null || _a === void 0 ? void 0 : _a.below;
|
6742 | }
|
6743 | set below(atoms) {
|
6744 | this.setChildren(atoms, 'below');
|
6745 | }
|
6746 | get computedStyle() {
|
6747 | const style = { ...this.style };
|
6748 | const hadVerbatimColor = this.style.verbatimColor !== undefined;
|
6749 | const hadVerbatimBackgroundColor = this.style.verbatimBackgroundColor !== undefined;
|
6750 | if (style) {
|
6751 |
|
6752 | delete style.variant;
|
6753 | delete style.variantStyle;
|
6754 | }
|
6755 | if (!this.parent)
|
6756 | return style !== null && style !== void 0 ? style : {};
|
6757 | const result = { ...this.parent.computedStyle, ...style };
|
6758 | if (!hadVerbatimBackgroundColor)
|
6759 | delete result.verbatimBackgroundColor;
|
6760 | if (!hadVerbatimColor)
|
6761 | delete result.verbatimColor;
|
6762 | return result;
|
6763 | }
|
6764 | applyStyle(style) {
|
6765 | this.isDirty = true;
|
6766 | this.style = { ...this.style, ...style };
|
6767 | if (this.style.fontFamily === 'none') {
|
6768 | delete this.style.fontFamily;
|
6769 | }
|
6770 | if (this.style.fontShape === 'auto') {
|
6771 | delete this.style.fontShape;
|
6772 | }
|
6773 | if (this.style.fontSeries === 'auto') {
|
6774 | delete this.style.fontSeries;
|
6775 | }
|
6776 | if (this.style.color === 'none') {
|
6777 | delete this.style.color;
|
6778 | delete this.style.verbatimColor;
|
6779 | }
|
6780 | if (this.style.backgroundColor === 'none') {
|
6781 | delete this.style.backgroundColor;
|
6782 | delete this.style.verbatimBackgroundColor;
|
6783 | }
|
6784 | if (this.style.fontSize === 'auto') {
|
6785 | delete this.style.fontSize;
|
6786 | }
|
6787 | }
|
6788 | getInitialBaseElement() {
|
6789 | var _a;
|
6790 | let result = undefined;
|
6791 | if (!this.hasEmptyBranch('body')) {
|
6792 | console.assert(((_a = this.body) === null || _a === void 0 ? void 0 : _a[0].type) === 'first');
|
6793 | result = this.body[1].getInitialBaseElement();
|
6794 | }
|
6795 | return result !== null && result !== void 0 ? result : this;
|
6796 | }
|
6797 | getFinalBaseElement() {
|
6798 | if (!this.hasEmptyBranch('body')) {
|
6799 | return this.body[this.body.length - 1].getFinalBaseElement();
|
6800 | }
|
6801 | return this;
|
6802 | }
|
6803 | isCharacterBox() {
|
6804 | const base = this.getInitialBaseElement();
|
6805 | return /mord/.test(base.type);
|
6806 | }
|
6807 | hasEmptyBranch(branch) {
|
6808 | const atoms = this.branch(branch);
|
6809 | if (!atoms)
|
6810 | return true;
|
6811 | console.assert(atoms.length > 0);
|
6812 | console.assert(atoms[0].type === 'first');
|
6813 | return atoms.length === 1;
|
6814 | }
|
6815 | |
6816 |
|
6817 |
|
6818 |
|
6819 |
|
6820 |
|
6821 | setChildren(children, branch) {
|
6822 | var _a;
|
6823 | if (!children)
|
6824 | return;
|
6825 | console.assert(isNamedBranch(branch));
|
6826 | if (!isNamedBranch(branch))
|
6827 | return;
|
6828 | console.assert(((_a = children[0]) === null || _a === void 0 ? void 0 : _a.type) !== 'first');
|
6829 |
|
6830 | if (this._branches) {
|
6831 | this._branches[branch] = [this.makeFirstAtom(branch), ...children];
|
6832 | }
|
6833 | else {
|
6834 | this._branches = {
|
6835 | [branch]: [this.makeFirstAtom(branch), ...children],
|
6836 | };
|
6837 | }
|
6838 | this.isDirty = true;
|
6839 |
|
6840 | for (const child of children) {
|
6841 | child.parent = this;
|
6842 | child.treeBranch = branch;
|
6843 | }
|
6844 | }
|
6845 | makeFirstAtom(branch) {
|
6846 | const result = new Atom('first', { mode: this.mode });
|
6847 | result.parent = this;
|
6848 | result.treeBranch = branch;
|
6849 | return result;
|
6850 | }
|
6851 | addChild(child, branch) {
|
6852 | console.assert(child.type !== 'first');
|
6853 | this.createBranch(branch).push(child);
|
6854 | this.isDirty = true;
|
6855 |
|
6856 | child.parent = this;
|
6857 | child.treeBranch = branch;
|
6858 | }
|
6859 | addChildBefore(child, before) {
|
6860 | console.assert(before.treeBranch !== undefined);
|
6861 | const branch = this.createBranch(before.treeBranch);
|
6862 | branch.splice(branch.indexOf(before), 0, child);
|
6863 | this.isDirty = true;
|
6864 |
|
6865 | child.parent = this;
|
6866 | child.treeBranch = before.treeBranch;
|
6867 | }
|
6868 | addChildAfter(child, after) {
|
6869 | console.assert(after.treeBranch !== undefined);
|
6870 | const branch = this.createBranch(after.treeBranch);
|
6871 | branch.splice(branch.indexOf(after) + 1, 0, child);
|
6872 | this.isDirty = true;
|
6873 |
|
6874 | child.parent = this;
|
6875 | child.treeBranch = after.treeBranch;
|
6876 | }
|
6877 | addChildren(children, branch) {
|
6878 | for (const child of children)
|
6879 | this.addChild(child, branch);
|
6880 | }
|
6881 | |
6882 |
|
6883 |
|
6884 | addChildrenAfter(children, after) {
|
6885 | console.assert(children.length === 0 || children[0].type !== 'first');
|
6886 | console.assert(after.treeBranch !== undefined);
|
6887 | const branch = this.createBranch(after.treeBranch);
|
6888 | branch.splice(branch.indexOf(after) + 1, 0, ...children);
|
6889 | this.isDirty = true;
|
6890 |
|
6891 | for (const child of children) {
|
6892 | child.parent = this;
|
6893 | child.treeBranch = after.treeBranch;
|
6894 | }
|
6895 | return children[children.length - 1];
|
6896 | }
|
6897 | removeBranch(name) {
|
6898 | const children = this.branch(name);
|
6899 | if (isNamedBranch(name)) {
|
6900 | this._branches[name] = undefined;
|
6901 | }
|
6902 | if (!children)
|
6903 | return [];
|
6904 | for (const child of children) {
|
6905 | child.parent = undefined;
|
6906 | child.treeBranch = undefined;
|
6907 | }
|
6908 |
|
6909 | console.assert(children[0].type === 'first');
|
6910 | children.shift();
|
6911 | this.isDirty = true;
|
6912 | return children;
|
6913 | }
|
6914 | removeChild(child) {
|
6915 | console.assert(child.parent === this);
|
6916 |
|
6917 | if (child.type === 'first')
|
6918 | return;
|
6919 |
|
6920 | const branch = this.branch(child.treeBranch);
|
6921 | const index = branch.indexOf(child);
|
6922 | console.assert(index >= 0);
|
6923 | branch.splice(index, 1);
|
6924 | this.isDirty = true;
|
6925 |
|
6926 | child.parent = undefined;
|
6927 | child.treeBranch = undefined;
|
6928 | }
|
6929 | get siblings() {
|
6930 | if (this.type === 'root')
|
6931 | return [];
|
6932 | return this.parent.branch(this.treeBranch);
|
6933 | }
|
6934 | get firstSibling() {
|
6935 | return this.siblings[0];
|
6936 | }
|
6937 | get lastSibling() {
|
6938 | const { siblings } = this;
|
6939 | return siblings[siblings.length - 1];
|
6940 | }
|
6941 | get isFirstSibling() {
|
6942 | return this === this.firstSibling;
|
6943 | }
|
6944 | get isLastSibling() {
|
6945 | return this === this.lastSibling;
|
6946 | }
|
6947 | get hasNoSiblings() {
|
6948 |
|
6949 |
|
6950 | return this.siblings.length === 1;
|
6951 | }
|
6952 | get leftSibling() {
|
6953 | console.assert(this.parent !== undefined);
|
6954 | const siblings = this.parent.branch(this.treeBranch);
|
6955 | return siblings[siblings.indexOf(this) - 1];
|
6956 | }
|
6957 | get rightSibling() {
|
6958 | console.assert(this.parent !== undefined);
|
6959 | const siblings = this.parent.branch(this.treeBranch);
|
6960 | return siblings[siblings.indexOf(this) + 1];
|
6961 | }
|
6962 | get hasChildren() {
|
6963 | return this._branches && this.children.length > 0;
|
6964 | }
|
6965 | get firstChild() {
|
6966 | console.assert(this.hasChildren);
|
6967 | return this.children[0];
|
6968 | }
|
6969 | get lastChild() {
|
6970 | console.assert(this.hasChildren);
|
6971 | const { children } = this;
|
6972 | return children[children.length - 1];
|
6973 | }
|
6974 | |
6975 |
|
6976 |
|
6977 |
|
6978 |
|
6979 |
|
6980 | get children() {
|
6981 | if (this._children)
|
6982 | return this._children;
|
6983 | if (!this._branches)
|
6984 | return [];
|
6985 | const result = [];
|
6986 | for (const branchName of NAMED_BRANCHES) {
|
6987 | if (this._branches[branchName]) {
|
6988 | for (const x of this._branches[branchName]) {
|
6989 | result.push(...x.children);
|
6990 | result.push(x);
|
6991 | }
|
6992 | }
|
6993 | }
|
6994 | this._children = result;
|
6995 | return result;
|
6996 | }
|
6997 | |
6998 |
|
6999 |
|
7000 |
|
7001 |
|
7002 |
|
7003 |
|
7004 | render(parentContext, options) {
|
7005 | if (this.type === 'first' && !parentContext.atomIdsSettings)
|
7006 | return null;
|
7007 |
|
7008 |
|
7009 |
|
7010 | const context = new Context(parentContext, this.style);
|
7011 | let result = this.createBox(context, {
|
7012 | classes: this.type === 'root' ? ' ML__base' : '',
|
7013 | newList: (options === null || options === void 0 ? void 0 : options.newList) === true || this.type === 'first',
|
7014 | });
|
7015 | if (!result)
|
7016 | return null;
|
7017 |
|
7018 |
|
7019 |
|
7020 | if (!this.subsupPlacement && (this.superscript || this.subscript)) {
|
7021 |
|
7022 |
|
7023 | result = this.attachSupsub(context, { base: result });
|
7024 | }
|
7025 | return result.wrap(context);
|
7026 | }
|
7027 | attachSupsub(parentContext, options) {
|
7028 | var _a, _b;
|
7029 | const base = options.base;
|
7030 | const superscript = this.superscript;
|
7031 | const subscript = this.subscript;
|
7032 |
|
7033 | if (!superscript && !subscript) {
|
7034 | return base;
|
7035 | }
|
7036 |
|
7037 |
|
7038 |
|
7039 | let supBox = null;
|
7040 | let subBox = null;
|
7041 | const isCharacterBox = (_a = options.isCharacterBox) !== null && _a !== void 0 ? _a : this.isCharacterBox();
|
7042 |
|
7043 | let supShift = 0;
|
7044 | if (superscript) {
|
7045 | const context = new Context(parentContext, undefined, 'superscript');
|
7046 | supBox = Atom.createBox(context, superscript, { newList: true });
|
7047 | if (!isCharacterBox) {
|
7048 | supShift =
|
7049 | base.height - parentContext.metrics.supDrop * context.scalingFactor;
|
7050 | }
|
7051 | }
|
7052 | let subShift = 0;
|
7053 | if (subscript) {
|
7054 | const context = new Context(parentContext, undefined, 'subscript');
|
7055 | subBox = Atom.createBox(context, subscript, { newList: true });
|
7056 | if (!isCharacterBox) {
|
7057 | subShift =
|
7058 | base.depth + parentContext.metrics.subDrop * context.scalingFactor;
|
7059 | }
|
7060 | }
|
7061 |
|
7062 | let minSupShift;
|
7063 | if (parentContext.isDisplayStyle) {
|
7064 | minSupShift = parentContext.metrics.sup1;
|
7065 | }
|
7066 | else if (parentContext.isCramped) {
|
7067 | minSupShift = parentContext.metrics.sup3;
|
7068 | }
|
7069 | else {
|
7070 | minSupShift = parentContext.metrics.sup2;
|
7071 | }
|
7072 |
|
7073 |
|
7074 | const scriptspace = 0.5 / PT_PER_EM / parentContext.scalingFactor;
|
7075 | let supsub = null;
|
7076 | if (subBox && supBox) {
|
7077 |
|
7078 | supShift = Math.max(supShift, minSupShift, supBox.depth + 0.25 * parentContext.metrics.xHeight);
|
7079 | subShift = Math.max(subShift, parentContext.metrics.sub2);
|
7080 | const ruleWidth = parentContext.metrics.defaultRuleThickness;
|
7081 | if (supShift - supBox.depth - (subBox.height - subShift) <
|
7082 | 4 * ruleWidth) {
|
7083 | subShift = 4 * ruleWidth - (supShift - supBox.depth) + subBox.height;
|
7084 | const psi = 0.8 * parentContext.metrics.xHeight - (supShift - supBox.depth);
|
7085 | if (psi > 0) {
|
7086 | supShift += psi;
|
7087 | subShift -= psi;
|
7088 | }
|
7089 | }
|
7090 |
|
7091 |
|
7092 |
|
7093 | const slant = this.isExtensibleSymbol && base.italic ? -base.italic : 0;
|
7094 | supsub = new VBox({
|
7095 | individualShift: [
|
7096 | { box: subBox, shift: subShift, marginLeft: slant },
|
7097 | { box: supBox, shift: -supShift },
|
7098 | ],
|
7099 | }).wrap(parentContext);
|
7100 | }
|
7101 | else if (subBox && !supBox) {
|
7102 |
|
7103 | subShift = Math.max(subShift, parentContext.metrics.sub1, subBox.height - 0.8 * X_HEIGHT);
|
7104 | supsub = new VBox({
|
7105 | shift: subShift,
|
7106 | children: [
|
7107 | {
|
7108 | box: subBox,
|
7109 | marginRight: scriptspace,
|
7110 | marginLeft: this.isCharacterBox() ? -((_b = base.italic) !== null && _b !== void 0 ? _b : 0) : 0,
|
7111 | },
|
7112 | ],
|
7113 | });
|
7114 | }
|
7115 | else if (!subBox && supBox) {
|
7116 |
|
7117 | supShift = Math.max(supShift, minSupShift, supBox.depth + 0.25 * X_HEIGHT);
|
7118 | supsub = new VBox({
|
7119 | shift: -supShift,
|
7120 | children: [{ box: supBox, marginRight: scriptspace }],
|
7121 | });
|
7122 | supsub.wrap(parentContext);
|
7123 | }
|
7124 |
|
7125 |
|
7126 | const supsubContainer = new Box(supsub, { classes: 'msubsup' });
|
7127 | if (this.caret) {
|
7128 | supsubContainer.caret = this.caret;
|
7129 | }
|
7130 | return new Box([base, supsubContainer], { type: options.type });
|
7131 | }
|
7132 | attachLimits(parentContext, options) {
|
7133 | var _a;
|
7134 | const above = this.superscript
|
7135 | ? Atom.createBox(new Context(parentContext, this.style, 'superscript'), this.superscript, { newList: true })
|
7136 | : null;
|
7137 | const below = this.subscript
|
7138 | ? Atom.createBox(new Context(parentContext, this.style, 'subscript'), this.subscript, { newList: true })
|
7139 | : null;
|
7140 | if (!above && !below)
|
7141 | return options.base.wrap(parentContext);
|
7142 | return makeLimitsStack(parentContext, {
|
7143 | ...options,
|
7144 | above,
|
7145 | below,
|
7146 | type: (_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : 'mop',
|
7147 | });
|
7148 | }
|
7149 | |
7150 |
|
7151 |
|
7152 |
|
7153 | bind(context, box) {
|
7154 | if (!box)
|
7155 | return null;
|
7156 |
|
7157 | if (context.isPhantom)
|
7158 | return box;
|
7159 | if (!box || this.value === '\u200B')
|
7160 | return box;
|
7161 | if (!this.id)
|
7162 | this.id = context.makeID();
|
7163 | box.atomID = this.id;
|
7164 | return box;
|
7165 | }
|
7166 | |
7167 |
|
7168 |
|
7169 | createMathfieldBox(context, options) {
|
7170 | var _a;
|
7171 |
|
7172 | const type = 'mathfield';
|
7173 |
|
7174 |
|
7175 |
|
7176 |
|
7177 |
|
7178 |
|
7179 |
|
7180 |
|
7181 |
|
7182 | const classes = (_a = options === null || options === void 0 ? void 0 : options.classes) !== null && _a !== void 0 ? _a : '';
|
7183 | const result = new MathfieldBox(options.placeholderId, options.element, {
|
7184 | type,
|
7185 | mode: this.mode,
|
7186 | maxFontSize: context.scalingFactor,
|
7187 | style: {
|
7188 | variant: 'normal',
|
7189 | ...this.style,
|
7190 | letterShapeStyle: context.letterShapeStyle,
|
7191 | fontSize: Math.max(1, context.size + context.mathstyle.sizeDelta),
|
7192 | },
|
7193 | classes,
|
7194 | newList: options === null || options === void 0 ? void 0 : options.newList,
|
7195 | });
|
7196 |
|
7197 | if (context.isTight)
|
7198 | result.isTight = true;
|
7199 |
|
7200 | if (this.mode !== 'math')
|
7201 | result.italic = 0;
|
7202 | result.right = result.italic;
|
7203 |
|
7204 |
|
7205 | this.bind(context, result);
|
7206 | return result;
|
7207 | }
|
7208 | |
7209 |
|
7210 |
|
7211 | createBox(context, options) {
|
7212 | var _a, _b, _c, _d;
|
7213 | const value = (_a = this.value) !== null && _a !== void 0 ? _a : this.body;
|
7214 |
|
7215 | const type = isBoxType(this.type)
|
7216 | ? this.type
|
7217 | : undefined;
|
7218 |
|
7219 |
|
7220 |
|
7221 |
|
7222 |
|
7223 |
|
7224 |
|
7225 |
|
7226 |
|
7227 | let classes = (_b = options === null || options === void 0 ? void 0 : options.classes) !== null && _b !== void 0 ? _b : '';
|
7228 | if (this.mode === 'text')
|
7229 | classes += ' ML__text';
|
7230 | const result = typeof value === 'string' || value === undefined
|
7231 | ? new Box((_c = value) !== null && _c !== void 0 ? _c : null, {
|
7232 | type,
|
7233 | mode: this.mode,
|
7234 | maxFontSize: context.scalingFactor,
|
7235 | style: {
|
7236 | variant: 'normal',
|
7237 | ...this.style,
|
7238 | letterShapeStyle: context.letterShapeStyle,
|
7239 | fontSize: Math.max(1, context.size + context.mathstyle.sizeDelta),
|
7240 | },
|
7241 | classes,
|
7242 | newList: options === null || options === void 0 ? void 0 : options.newList,
|
7243 | })
|
7244 | : (_d = Atom.createBox(context, value, {
|
7245 | type,
|
7246 | mode: this.mode,
|
7247 | style: this.style,
|
7248 | classes,
|
7249 | newList: options === null || options === void 0 ? void 0 : options.newList,
|
7250 | })) !== null && _d !== void 0 ? _d : new Box(null);
|
7251 |
|
7252 | if (context.isTight)
|
7253 | result.isTight = true;
|
7254 |
|
7255 | if (this.mode !== 'math')
|
7256 | result.italic = 0;
|
7257 | result.right = result.italic;
|
7258 |
|
7259 |
|
7260 | this.bind(context, result);
|
7261 | if (this.caret) {
|
7262 |
|
7263 |
|
7264 | if (!this.superscript && !this.subscript) {
|
7265 | result.caret = this.caret;
|
7266 | }
|
7267 | }
|
7268 | return result;
|
7269 | }
|
7270 | }
|
7271 |
|
7272 |
|
7273 |
|
7274 |
|
7275 |
|
7276 |
|
7277 | function atomsToLatex(atoms, options) {
|
7278 | if (!atoms || atoms.length === 0)
|
7279 | return '';
|
7280 | if (atoms[0].type === 'first') {
|
7281 | if (atoms.length === 1)
|
7282 | return '';
|
7283 |
|
7284 | atoms = atoms.slice(1);
|
7285 | }
|
7286 | if (atoms.length === 0)
|
7287 | return '';
|
7288 | return joinLatex(getPropertyRuns(atoms, 'cssClass').map((x) => joinLatex(getPropertyRuns(x, 'color').map((x) => joinLatex(getModeRuns(x).map((x) => Mode.serialize(x, options)))))));
|
7289 | }
|
7290 | function getStyleRuns(atoms) {
|
7291 | let style = undefined;
|
7292 | let selected;
|
7293 | const runs = [];
|
7294 | let run = [];
|
7295 | for (const atom of atoms) {
|
7296 | const atomStyle = atom.computedStyle;
|
7297 | if (!style && !atom.style) {
|
7298 | run.push(atom);
|
7299 | }
|
7300 | else if (style &&
|
7301 | selected === atom.isSelected &&
|
7302 | atomStyle.color === style.color &&
|
7303 | atomStyle.backgroundColor === style.backgroundColor &&
|
7304 | atomStyle.fontSize === style.fontSize) {
|
7305 |
|
7306 | run.push(atom);
|
7307 | }
|
7308 | else {
|
7309 |
|
7310 | if (run.length > 0)
|
7311 | runs.push(run);
|
7312 | run = [atom];
|
7313 | style = atom.computedStyle;
|
7314 | selected = atom.isSelected;
|
7315 | }
|
7316 | }
|
7317 | if (run.length > 0)
|
7318 | runs.push(run);
|
7319 | return runs;
|
7320 | }
|
7321 |
|
7322 |
|
7323 |
|
7324 | function renderStyleRun(parentContext, atoms, options) {
|
7325 | var _a, _b, _c, _d, _e;
|
7326 | function isDigit(atom) {
|
7327 | return (atom.type === 'mord' && Boolean(atom.value) && /^[\d,.]$/.test(atom.value));
|
7328 | }
|
7329 | function isText(atom) {
|
7330 | return atom.mode === 'text';
|
7331 | }
|
7332 | if (!atoms || atoms.length === 0)
|
7333 | return null;
|
7334 | const context = new Context(parentContext, options === null || options === void 0 ? void 0 : options.style);
|
7335 |
|
7336 |
|
7337 |
|
7338 | const displaySelection = !context.atomIdsSettings || !context.atomIdsSettings.groupNumbers;
|
7339 | let boxes = [];
|
7340 | if (atoms.length === 1) {
|
7341 | const box = atoms[0].render(context, {
|
7342 | newList: (_a = options === null || options === void 0 ? void 0 : options.newList) !== null && _a !== void 0 ? _a : false,
|
7343 | });
|
7344 | if (box && displaySelection && atoms[0].isSelected) {
|
7345 | box.selected(true);
|
7346 | }
|
7347 | if (box)
|
7348 | boxes = [box];
|
7349 | }
|
7350 | else {
|
7351 | let selection = [];
|
7352 | let digitOrTextStringID = '';
|
7353 | let lastWasDigit = true;
|
7354 | let isNewList = (_b = options === null || options === void 0 ? void 0 : options.newList) !== null && _b !== void 0 ? _b : false;
|
7355 | for (const atom of atoms) {
|
7356 | if (((_c = context.atomIdsSettings) === null || _c === void 0 ? void 0 : _c.groupNumbers) &&
|
7357 | digitOrTextStringID &&
|
7358 | ((lastWasDigit && isDigit(atom)) || (!lastWasDigit && isText(atom)))) {
|
7359 | context.atomIdsSettings.overrideID = digitOrTextStringID;
|
7360 | }
|
7361 | const box = atom.render(context, { newList: isNewList });
|
7362 | if (context.atomIdsSettings) {
|
7363 | context.atomIdsSettings.overrideID = undefined;
|
7364 | }
|
7365 | if (box) {
|
7366 | isNewList = false;
|
7367 |
|
7368 | if ((_d = context.atomIdsSettings) === null || _d === void 0 ? void 0 : _d.groupNumbers) {
|
7369 | if (isDigit(atom) || isText(atom)) {
|
7370 | if (!digitOrTextStringID || lastWasDigit !== isDigit(atom)) {
|
7371 |
|
7372 | lastWasDigit = isDigit(atom);
|
7373 | digitOrTextStringID = (_e = atom.id) !== null && _e !== void 0 ? _e : '';
|
7374 | }
|
7375 | }
|
7376 | if ((!(isDigit(atom) || isText(atom)) ||
|
7377 | !atom.hasEmptyBranch('superscript') ||
|
7378 | !atom.hasEmptyBranch('subscript')) &&
|
7379 | digitOrTextStringID) {
|
7380 |
|
7381 | digitOrTextStringID = '';
|
7382 | }
|
7383 | }
|
7384 | if (displaySelection && atom.isSelected) {
|
7385 | selection.push(box);
|
7386 | for (const box of selection)
|
7387 | box.selected(true);
|
7388 | }
|
7389 | else {
|
7390 | if (selection.length > 0) {
|
7391 |
|
7392 |
|
7393 | boxes = [...boxes, ...selection];
|
7394 | selection = [];
|
7395 | }
|
7396 | boxes.push(box);
|
7397 | }
|
7398 | }
|
7399 | }
|
7400 |
|
7401 | if (selection.length > 0) {
|
7402 | boxes = [...boxes, ...selection];
|
7403 | selection = [];
|
7404 | }
|
7405 | }
|
7406 | if (!boxes || boxes.length === 0)
|
7407 | return null;
|
7408 | let result = boxes[0];
|
7409 | if (options || boxes.length > 1) {
|
7410 | result = new Box(boxes, {
|
7411 | isTight: context.isTight,
|
7412 | ...options,
|
7413 | });
|
7414 | result.selected(boxes[0].isSelected);
|
7415 | }
|
7416 |
|
7417 | return result.wrap(context).wrap(parentContext);
|
7418 | }
|
7419 |
|
7420 | class GroupAtom extends Atom {
|
7421 | constructor(arg, options) {
|
7422 | var _a, _b;
|
7423 | super('group', {
|
7424 | mode: (_a = options === null || options === void 0 ? void 0 : options.mode) !== null && _a !== void 0 ? _a : 'math',
|
7425 | serialize: options === null || options === void 0 ? void 0 : options.serialize,
|
7426 | style: options === null || options === void 0 ? void 0 : options.style,
|
7427 | displayContainsHighlight: true,
|
7428 | });
|
7429 | this.body = arg;
|
7430 | this.mathstyleName = options === null || options === void 0 ? void 0 : options.mathstyleName;
|
7431 | this.latexOpen = options === null || options === void 0 ? void 0 : options.latexOpen;
|
7432 | this.latexClose = options === null || options === void 0 ? void 0 : options.latexClose;
|
7433 | this.cssId = options === null || options === void 0 ? void 0 : options.cssId;
|
7434 | this.htmlData = options === null || options === void 0 ? void 0 : options.htmlData;
|
7435 | this.customClass = options === null || options === void 0 ? void 0 : options.customClass;
|
7436 | this.boxType = options === null || options === void 0 ? void 0 : options.boxType;
|
7437 | this.skipBoundary = true;
|
7438 | this.captureSelection = options === null || options === void 0 ? void 0 : options.captureSelection;
|
7439 | this.changeMode = (_b = options === null || options === void 0 ? void 0 : options.changeMode) !== null && _b !== void 0 ? _b : false;
|
7440 | this.displayContainsHighlight = false;
|
7441 | }
|
7442 | render(context) {
|
7443 |
|
7444 |
|
7445 |
|
7446 |
|
7447 |
|
7448 |
|
7449 | const localContext = new Context(context, this.style, this.mathstyleName);
|
7450 | const box = Atom.createBox(localContext, this.body, {
|
7451 | type: this.boxType,
|
7452 | classes: this.customClass,
|
7453 | mode: this.mode,
|
7454 | style: {
|
7455 | backgroundColor: this.style.backgroundColor,
|
7456 | },
|
7457 | });
|
7458 | if (!box)
|
7459 | return box;
|
7460 | if (this.cssId)
|
7461 | box.cssId = this.cssId;
|
7462 | if (this.htmlData)
|
7463 | box.htmlData = this.htmlData;
|
7464 | if (this.caret)
|
7465 | box.caret = this.caret;
|
7466 |
|
7467 |
|
7468 |
|
7469 | return this.bind(context, box);
|
7470 | }
|
7471 | serialize(options) {
|
7472 | let result = this.bodyToLatex(options);
|
7473 | if (typeof this.latexOpen === 'string') {
|
7474 | result = this.latexOpen + result + this.latexClose;
|
7475 | }
|
7476 | if (this.htmlData) {
|
7477 | result = `\\htmlData{${this.htmlData}}{${result}}`;
|
7478 | }
|
7479 | if (this.customClass) {
|
7480 | result = `\\class{${this.customClass}}{${result}}`;
|
7481 | }
|
7482 | if (this.cssId) {
|
7483 | result = `\\cssId{${this.cssId}}{${result}}`;
|
7484 | }
|
7485 | return result;
|
7486 | }
|
7487 | }
|
7488 |
|
7489 | class SpacingAtom extends Atom {
|
7490 | constructor(command, style, width) {
|
7491 | super('spacing', { command, style });
|
7492 | this.width = width;
|
7493 | }
|
7494 | render(_context) {
|
7495 | var _a;
|
7496 | let result;
|
7497 | if (this.width) {
|
7498 | result = new Box(null, { classes: 'mspace' });
|
7499 | result.left = convertGlueToEm(this.width);
|
7500 | }
|
7501 | else {
|
7502 | const spacingCls = (_a = {
|
7503 | '\\qquad': 'qquad',
|
7504 | '\\quad': 'quad',
|
7505 | '\\enspace': 'enspace',
|
7506 | '\\;': 'thickspace',
|
7507 | '\\:': 'mediumspace',
|
7508 | '\\,': 'thinspace',
|
7509 | '\\!': 'negativethinspace',
|
7510 | }[this.command]) !== null && _a !== void 0 ? _a : 'mediumspace';
|
7511 | result = new Box(null, { classes: spacingCls });
|
7512 | }
|
7513 | if (this.caret)
|
7514 | result.caret = this.caret;
|
7515 | return result;
|
7516 | }
|
7517 | serialize(_options) {
|
7518 | var _a;
|
7519 |
|
7520 |
|
7521 |
|
7522 |
|
7523 | let result = (_a = this.command) !== null && _a !== void 0 ? _a : '';
|
7524 | if (this.command === '\\hspace' || this.command === '\\hspace*') {
|
7525 | if (Number.isFinite(this.width)) {
|
7526 | result += `{${this.width}em'}`;
|
7527 | }
|
7528 | else {
|
7529 | result += `{0pt}`;
|
7530 | }
|
7531 | }
|
7532 | else {
|
7533 | if (Number.isFinite(this.width)) {
|
7534 | result += ` ${this.width}em`;
|
7535 | }
|
7536 | }
|
7537 | return result;
|
7538 | }
|
7539 | }
|
7540 |
|
7541 |
|
7542 |
|
7543 |
|
7544 |
|
7545 |
|
7546 |
|
7547 |
|
7548 |
|
7549 |
|
7550 |
|
7551 |
|
7552 |
|
7553 |
|
7554 |
|
7555 |
|
7556 |
|
7557 |
|
7558 |
|
7559 |
|
7560 |
|
7561 |
|
7562 |
|
7563 | const RIGHT_DELIM = {
|
7564 | '(': ')',
|
7565 | '{': '}',
|
7566 | '[': ']',
|
7567 | '|': '|',
|
7568 | '\\lbrace': '\\rbrace',
|
7569 | '\\lparen': '\\rparen',
|
7570 | '\\{': '\\}',
|
7571 | '\\langle': '\\rangle',
|
7572 | '\\lfloor': '\\rfloor',
|
7573 | '\\lceil': '\\rceil',
|
7574 | '\\vert': '\\vert',
|
7575 | '\\lvert': '\\rvert',
|
7576 | '\\Vert': '\\Vert',
|
7577 | '\\lVert': '\\rVert',
|
7578 | '\\lbrack': '\\rbrack',
|
7579 | '\\ulcorner': '\\urcorner',
|
7580 | '\\llcorner': '\\lrcorner',
|
7581 | '\\lgroup': '\\rgroup',
|
7582 | '\\lmoustache': '\\rmoustache',
|
7583 | };
|
7584 | function getSymbolValue(symbol) {
|
7585 | var _a;
|
7586 | return ((_a = {
|
7587 | '[': 0x5b,
|
7588 | ']': 0x5d,
|
7589 | '(': 0x28,
|
7590 | ')': 0x29,
|
7591 | '\\mid': 0x2223,
|
7592 | '|': 0x2223,
|
7593 | '\u2223': 0x2223,
|
7594 | '\u2225': 0x2225,
|
7595 | '\\|': 0x2223,
|
7596 | '\\{': 0x7b,
|
7597 | '\\}': 0x7d,
|
7598 | '\\lbrace': 0x7b,
|
7599 | '\\rbrace': 0x7d,
|
7600 | '\\lparen': 0x28,
|
7601 | '\\rparen': 0x29,
|
7602 | '\\lbrack': 0x5b,
|
7603 | '\\rbrack': 0x5d,
|
7604 | '\\vert': 0x2223,
|
7605 | '\\lvert': 0x2223,
|
7606 | '\\mvert': 0x2223,
|
7607 | '\\rvert': 0x2223,
|
7608 | '\\Vert': 0x2225,
|
7609 | '\\lVert': 0x2225,
|
7610 | '\\mVert': 0x2225,
|
7611 | '\\rVert': 0x2225,
|
7612 | '\\parallel': 0x2225,
|
7613 | '\\shortparallel': 0x2225,
|
7614 | '\\langle': 0x27e8,
|
7615 | '\\rangle': 0x27e9,
|
7616 | '\\lfloor': 0x230a,
|
7617 | '\\rfloor': 0x230b,
|
7618 | '\\lceil': 0x2308,
|
7619 | '\\rceil': 0x2309,
|
7620 | '\\ulcorner': 0x250c,
|
7621 | '\\urcorner': 0x2510,
|
7622 | '\\llcorner': 0x2514,
|
7623 | '\\lrcorner': 0x2518,
|
7624 | '\\lgroup': 0x27ee,
|
7625 | '\\rgroup': 0x27ef,
|
7626 | '\\lmoustache': 0x23b0,
|
7627 | '\\rmoustache': 0x23b1,
|
7628 | '\\surd': 0x221a,
|
7629 | }[symbol]) !== null && _a !== void 0 ? _a : symbol.codePointAt(0));
|
7630 | }
|
7631 |
|
7632 |
|
7633 |
|
7634 |
|
7635 |
|
7636 | function makeSmallDelim(delim, context, center, options) {
|
7637 | const text = new Box(getSymbolValue(delim), { fontFamily: 'Main-Regular' });
|
7638 | const box = text.wrap(context, options);
|
7639 | if (center) {
|
7640 | box.setTop((1 - context.scalingFactor) * AXIS_HEIGHT);
|
7641 | }
|
7642 | return box;
|
7643 | }
|
7644 |
|
7645 |
|
7646 |
|
7647 |
|
7648 | function makeLargeDelim(delim, size, center, parentContext, options) {
|
7649 |
|
7650 | const context = new Context(parentContext, options === null || options === void 0 ? void 0 : options.style, 'textstyle');
|
7651 | const result = new Box(getSymbolValue(delim), {
|
7652 | fontFamily: 'Size' + size + '-Regular',
|
7653 | classes: 'ML__delim-size' + size,
|
7654 | }).wrap(context);
|
7655 | if (center) {
|
7656 | result.setTop((1 - context.scalingFactor) * AXIS_HEIGHT);
|
7657 | }
|
7658 | return result;
|
7659 | }
|
7660 |
|
7661 |
|
7662 |
|
7663 |
|
7664 | function makeStackedDelim(delim, heightTotal, center, context, options) {
|
7665 | var _a;
|
7666 |
|
7667 |
|
7668 | let top;
|
7669 | let middle;
|
7670 | let repeat;
|
7671 | let bottom;
|
7672 | top = repeat = bottom = getSymbolValue(delim);
|
7673 | middle = null;
|
7674 |
|
7675 | let fontFamily = 'Size1-Regular';
|
7676 |
|
7677 |
|
7678 |
|
7679 | if (delim === '\\vert' ||
|
7680 | delim === '\\lvert' ||
|
7681 | delim === '\\rvert' ||
|
7682 | delim === '\\mvert' ||
|
7683 | delim === '\\mid') {
|
7684 | repeat = top = bottom = 0x2223;
|
7685 | }
|
7686 | else if (delim === '\\Vert' ||
|
7687 | delim === '\\lVert' ||
|
7688 | delim === '\\rVert' ||
|
7689 | delim === '\\mVert' ||
|
7690 | delim === '\\|') {
|
7691 | repeat = top = bottom = 0x2225;
|
7692 | }
|
7693 | else if (delim === '\\uparrow') {
|
7694 | repeat = bottom = 0x23d0;
|
7695 | }
|
7696 | else if (delim === '\\Uparrow') {
|
7697 | repeat = bottom = 0x2016;
|
7698 | }
|
7699 | else if (delim === '\\downarrow') {
|
7700 | top = repeat = 0x23d0;
|
7701 | }
|
7702 | else if (delim === '\\Downarrow') {
|
7703 | top = repeat = 0x2016;
|
7704 | }
|
7705 | else if (delim === '\\updownarrow') {
|
7706 | top = 0x2191;
|
7707 | repeat = 0x23d0;
|
7708 | bottom = 0x2193;
|
7709 | }
|
7710 | else if (delim === '\\Updownarrow') {
|
7711 | top = 0x21d1;
|
7712 | repeat = 0x2016;
|
7713 | bottom = 0x21d3;
|
7714 | }
|
7715 | else if (delim === '[' || delim === '\\lbrack') {
|
7716 | top = 0x23a1;
|
7717 | repeat = 0x23a2;
|
7718 | bottom = 0x23a3;
|
7719 | fontFamily = 'Size4-Regular';
|
7720 | }
|
7721 | else if (delim === ']' || delim === '\\rbrack') {
|
7722 | top = 0x23a4;
|
7723 | repeat = 0x23a5;
|
7724 | bottom = 0x23a6;
|
7725 | fontFamily = 'Size4-Regular';
|
7726 | }
|
7727 | else if (delim === '\\lfloor' || delim === '\u230a') {
|
7728 | repeat = top = 0x23a2;
|
7729 | bottom = 0x23a3;
|
7730 | fontFamily = 'Size4-Regular';
|
7731 | }
|
7732 | else if (delim === '\\lceil' || delim === '\u2308') {
|
7733 | top = 0x23a1;
|
7734 | repeat = bottom = 0x23a2;
|
7735 | fontFamily = 'Size4-Regular';
|
7736 | }
|
7737 | else if (delim === '\\rfloor' || delim === '\u230b') {
|
7738 | repeat = top = 0x23a5;
|
7739 | bottom = 0x23a6;
|
7740 | fontFamily = 'Size4-Regular';
|
7741 | }
|
7742 | else if (delim === '\\rceil' || delim === '\u2309') {
|
7743 | top = 0x23a4;
|
7744 | repeat = bottom = 0x23a5;
|
7745 | fontFamily = 'Size4-Regular';
|
7746 | }
|
7747 | else if (delim === '(' || delim === '\\lparen') {
|
7748 | top = 0x239b;
|
7749 | repeat = 0x239c;
|
7750 | bottom = 0x239d;
|
7751 | fontFamily = 'Size4-Regular';
|
7752 | }
|
7753 | else if (delim === ')' || delim === '\\rparen') {
|
7754 | top = 0x239e;
|
7755 | repeat = 0x239f;
|
7756 | bottom = 0x23a0;
|
7757 | fontFamily = 'Size4-Regular';
|
7758 | }
|
7759 | else if (delim === '\\{' || delim === '\\lbrace') {
|
7760 | top = 0x23a7;
|
7761 | middle = 0x23a8;
|
7762 | bottom = 0x23a9;
|
7763 | repeat = 0x23aa;
|
7764 | fontFamily = 'Size4-Regular';
|
7765 | }
|
7766 | else if (delim === '\\}' || delim === '\\rbrace') {
|
7767 | top = 0x23ab;
|
7768 | middle = 0x23ac;
|
7769 | bottom = 0x23ad;
|
7770 | repeat = 0x23aa;
|
7771 | fontFamily = 'Size4-Regular';
|
7772 | }
|
7773 | else if (delim === '\\lgroup' || delim === '\u27ee') {
|
7774 | top = 0x23a7;
|
7775 | bottom = 0x23a9;
|
7776 | repeat = 0x23aa;
|
7777 | fontFamily = 'Size4-Regular';
|
7778 | }
|
7779 | else if (delim === '\\rgroup' || delim === '\u27ef') {
|
7780 | top = 0x23ab;
|
7781 | bottom = 0x23ad;
|
7782 | repeat = 0x23aa;
|
7783 | fontFamily = 'Size4-Regular';
|
7784 | }
|
7785 | else if (delim === '\\lmoustache' || delim === '\u23b0') {
|
7786 | top = 0x23a7;
|
7787 | bottom = 0x23ad;
|
7788 | repeat = 0x23aa;
|
7789 | fontFamily = 'Size4-Regular';
|
7790 | }
|
7791 | else if (delim === '\\rmoustache' || delim === '\u23b1') {
|
7792 | top = 0x23ab;
|
7793 | bottom = 0x23a9;
|
7794 | repeat = 0x23aa;
|
7795 | fontFamily = 'Size4-Regular';
|
7796 | }
|
7797 | else if (delim === '\\surd') {
|
7798 | top = 0xe001;
|
7799 | bottom = 0x23b7;
|
7800 | repeat = 0xe000;
|
7801 | fontFamily = 'Size4-Regular';
|
7802 | }
|
7803 | else if (delim === '\\ulcorner') {
|
7804 | top = 0x250c;
|
7805 | repeat = bottom = 0x20;
|
7806 | }
|
7807 | else if (delim === '\\urcorner') {
|
7808 | top = 0x2510;
|
7809 | repeat = bottom = 0x20;
|
7810 | }
|
7811 | else if (delim === '\\llcorner') {
|
7812 | bottom = 0x2514;
|
7813 | repeat = top = 0x20;
|
7814 | }
|
7815 | else if (delim === '\\lrcorner') {
|
7816 | top = 0x2518;
|
7817 | repeat = top = 0x20;
|
7818 | }
|
7819 |
|
7820 | const topMetrics = getCharacterMetrics(top, fontFamily);
|
7821 | const topHeightTotal = topMetrics.height + topMetrics.depth;
|
7822 | const repeatMetrics = getCharacterMetrics(repeat, fontFamily);
|
7823 | const repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth;
|
7824 | const bottomMetrics = getCharacterMetrics(bottom, fontFamily);
|
7825 | const bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth;
|
7826 | let middleHeightTotal = 0;
|
7827 | let middleFactor = 1;
|
7828 | if (middle !== null) {
|
7829 | const middleMetrics = getCharacterMetrics(middle, fontFamily);
|
7830 | middleHeightTotal = middleMetrics.height + middleMetrics.depth;
|
7831 | middleFactor = 2;
|
7832 | }
|
7833 |
|
7834 |
|
7835 | const minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal;
|
7836 |
|
7837 | const repeatCount = Math.max(0, Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal)));
|
7838 |
|
7839 | const realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal;
|
7840 |
|
7841 |
|
7842 |
|
7843 |
|
7844 | let axisHeight = AXIS_HEIGHT;
|
7845 | if (center) {
|
7846 | axisHeight = axisHeight * context.scalingFactor;
|
7847 | }
|
7848 |
|
7849 | const depth = realHeightTotal / 2 - axisHeight;
|
7850 |
|
7851 | const OVERLAP = 0.008;
|
7852 |
|
7853 | const stack = [];
|
7854 |
|
7855 | stack.push({ box: new Box(bottom, { fontFamily }) });
|
7856 | stack.push(-OVERLAP);
|
7857 | const repeatBox = new Box(repeat, { fontFamily });
|
7858 | if (middle === null) {
|
7859 |
|
7860 | for (let i = 0; i < repeatCount; i++) {
|
7861 | stack.push({ box: repeatBox });
|
7862 | }
|
7863 | }
|
7864 | else {
|
7865 |
|
7866 |
|
7867 | for (let i = 0; i < repeatCount; i++) {
|
7868 | stack.push({ box: repeatBox });
|
7869 | }
|
7870 | stack.push(-OVERLAP);
|
7871 | stack.push({ box: new Box(middle, { fontFamily }) });
|
7872 | stack.push(-OVERLAP);
|
7873 | for (let i = 0; i < repeatCount; i++) {
|
7874 | stack.push({ box: repeatBox });
|
7875 | }
|
7876 | }
|
7877 |
|
7878 | stack.push(-OVERLAP);
|
7879 | stack.push({ box: new Box(top, { fontFamily }) });
|
7880 |
|
7881 | let sizeClass = '';
|
7882 |
|
7883 | if (fontFamily === 'Size1-Regular') {
|
7884 | sizeClass = ' delim-size1';
|
7885 | }
|
7886 | else if (fontFamily === 'Size4-Regular') {
|
7887 | sizeClass = ' delim-size4';
|
7888 | }
|
7889 | const inner = new VBox({
|
7890 | bottom: depth,
|
7891 | children: stack,
|
7892 | }, { classes: sizeClass });
|
7893 | const result = new Box(inner, {
|
7894 | ...(options !== null && options !== void 0 ? options : {}),
|
7895 | classes: ((_a = options === null || options === void 0 ? void 0 : options.classes) !== null && _a !== void 0 ? _a : '') + ' ML__delim-mult',
|
7896 | });
|
7897 |
|
7898 | return result;
|
7899 | }
|
7900 |
|
7901 |
|
7902 | const stackLargeDelimiters = new Set([
|
7903 | '(',
|
7904 | ')',
|
7905 | '\\lparen',
|
7906 | '\\rparen',
|
7907 | '[',
|
7908 | ']',
|
7909 | '\\lbrack',
|
7910 | '\\rbrack',
|
7911 | '\\{',
|
7912 | '\\}',
|
7913 | '\\lbrace',
|
7914 | '\\rbrace',
|
7915 | '\\lfloor',
|
7916 | '\\rfloor',
|
7917 | '\\lceil',
|
7918 | '\\rceil',
|
7919 | '\\surd',
|
7920 | '\u230a',
|
7921 | '\u230b',
|
7922 | '\u2308',
|
7923 | '\u2309',
|
7924 | ]);
|
7925 |
|
7926 | const stackAlwaysDelimiters = new Set([
|
7927 | '\\uparrow',
|
7928 | '\\downarrow',
|
7929 | '\\updownarrow',
|
7930 | '\\Uparrow',
|
7931 | '\\Downarrow',
|
7932 | '\\Updownarrow',
|
7933 | '|',
|
7934 | '\\|',
|
7935 | '\\vert',
|
7936 | '\\Vert',
|
7937 | '\\lvert',
|
7938 | '\\rvert',
|
7939 | '\\lVert',
|
7940 | '\\rVert',
|
7941 | '\\mvert',
|
7942 | '\\mid',
|
7943 | '\\lgroup',
|
7944 | '\\rgroup',
|
7945 | '\\lmoustache',
|
7946 | '\\rmoustache',
|
7947 | '\u27ee',
|
7948 | '\u27ef',
|
7949 | '\u23b0',
|
7950 | '\u23b1',
|
7951 | ]);
|
7952 |
|
7953 | const stackNeverDelimiters = new Set([
|
7954 | '<',
|
7955 | '>',
|
7956 | '\\langle',
|
7957 | '\\rangle',
|
7958 | '/',
|
7959 | '\\backslash',
|
7960 | '\\lt',
|
7961 | '\\gt',
|
7962 | ]);
|
7963 |
|
7964 |
|
7965 |
|
7966 | const sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3];
|
7967 |
|
7968 |
|
7969 |
|
7970 | function makeSizedDelim(delim, size, context, options) {
|
7971 | var _a;
|
7972 | if (delim === undefined || delim === '.') {
|
7973 |
|
7974 |
|
7975 | return makeNullDelimiter(context, (_a = options.type) !== null && _a !== void 0 ? _a : 'minner', options.classes);
|
7976 | }
|
7977 |
|
7978 | if (delim === '<' || delim === '\\lt' || delim === '\u27e8') {
|
7979 | delim = '\\langle';
|
7980 | }
|
7981 | else if (delim === '>' || delim === '\\gt' || delim === '\u27e9') {
|
7982 | delim = '\\rangle';
|
7983 | }
|
7984 |
|
7985 | if (stackLargeDelimiters.has(delim) || stackNeverDelimiters.has(delim)) {
|
7986 | return makeLargeDelim(delim, size, false, context, options);
|
7987 | }
|
7988 | if (stackAlwaysDelimiters.has(delim)) {
|
7989 | return makeStackedDelim(delim, sizeToMaxHeight[size], false, context, options);
|
7990 | }
|
7991 | console.assert(false, "Unknown delimiter '" + delim + "'");
|
7992 | return null;
|
7993 | }
|
7994 |
|
7995 | const stackNeverDelimiterSequence = [
|
7996 | { type: 'small', mathstyle: 'scriptscriptstyle' },
|
7997 | { type: 'small', mathstyle: 'scriptstyle' },
|
7998 | { type: 'small', mathstyle: 'textstyle' },
|
7999 | { type: 'large', size: 1 },
|
8000 | { type: 'large', size: 2 },
|
8001 | { type: 'large', size: 3 },
|
8002 | { type: 'large', size: 4 },
|
8003 | ];
|
8004 |
|
8005 | const stackAlwaysDelimiterSequence = [
|
8006 | { type: 'small', mathstyle: 'scriptscriptstyle' },
|
8007 | { type: 'small', mathstyle: 'scriptscriptstyle' },
|
8008 | { type: 'small', mathstyle: 'textstyle' },
|
8009 | { type: 'stack' },
|
8010 | ];
|
8011 |
|
8012 |
|
8013 | const stackLargeDelimiterSequence = [
|
8014 | { type: 'small', mathstyle: 'scriptscriptstyle' },
|
8015 | { type: 'small', mathstyle: 'scriptstyle' },
|
8016 | { type: 'small', mathstyle: 'textstyle' },
|
8017 | { type: 'large', size: 1 },
|
8018 | { type: 'large', size: 2 },
|
8019 | { type: 'large', size: 3 },
|
8020 | { type: 'large', size: 4 },
|
8021 | { type: 'stack' },
|
8022 | ];
|
8023 |
|
8024 |
|
8025 |
|
8026 | function delimTypeToFont(info) {
|
8027 | if (info.type === 'small') {
|
8028 | return 'Main-Regular';
|
8029 | }
|
8030 | if (info.type === 'large') {
|
8031 | return 'Size' + info.size + '-Regular';
|
8032 | }
|
8033 | console.assert(info.type === 'stack');
|
8034 | return 'Size4-Regular';
|
8035 | }
|
8036 |
|
8037 |
|
8038 |
|
8039 |
|
8040 |
|
8041 | function traverseSequence(delim, height, sequence, context) {
|
8042 |
|
8043 |
|
8044 |
|
8045 |
|
8046 |
|
8047 |
|
8048 | const start = { '-4': 0, '-3': 1, '0': 2 }[context.mathstyle.sizeDelta];
|
8049 | for (let i = start; i < sequence.length; i++) {
|
8050 | if (sequence[i].type === 'stack') {
|
8051 |
|
8052 | break;
|
8053 | }
|
8054 | const metrics = getCharacterMetrics(delim, delimTypeToFont(sequence[i]));
|
8055 | if (metrics.defaultMetrics) {
|
8056 |
|
8057 |
|
8058 | return { type: 'small', mathstyle: 'scriptstyle' };
|
8059 | }
|
8060 | let heightDepth = metrics.height + metrics.depth;
|
8061 |
|
8062 |
|
8063 | if (sequence[i].type === 'small') {
|
8064 | if (sequence[i].mathstyle === 'scriptscriptstyle') {
|
8065 | heightDepth *= FONT_SCALE[Math.max(1, context.size - 2)];
|
8066 | }
|
8067 | else if (sequence[i].mathstyle === 'scriptstyle') {
|
8068 | heightDepth *= FONT_SCALE[Math.max(1, context.size - 1)];
|
8069 | }
|
8070 | }
|
8071 |
|
8072 | if (heightDepth > height) {
|
8073 | return sequence[i];
|
8074 | }
|
8075 | }
|
8076 |
|
8077 | return sequence[sequence.length - 1];
|
8078 | }
|
8079 |
|
8080 |
|
8081 |
|
8082 |
|
8083 | function makeCustomSizedDelim(type, delim, height, center, context, options) {
|
8084 | var _a;
|
8085 | if (!delim || delim.length === 0 || delim === '.') {
|
8086 | return makeNullDelimiter(context, type, type);
|
8087 | }
|
8088 | if (delim === '<' || delim === '\\lt') {
|
8089 | delim = '\\langle';
|
8090 | }
|
8091 | else if (delim === '>' || delim === '\\gt') {
|
8092 | delim = '\\rangle';
|
8093 | }
|
8094 |
|
8095 | let sequence;
|
8096 | if (stackNeverDelimiters.has(delim)) {
|
8097 | sequence = stackNeverDelimiterSequence;
|
8098 | }
|
8099 | else if (stackLargeDelimiters.has(delim)) {
|
8100 | sequence = stackLargeDelimiterSequence;
|
8101 | }
|
8102 | else {
|
8103 | sequence = stackAlwaysDelimiterSequence;
|
8104 | }
|
8105 |
|
8106 | const delimType = traverseSequence(getSymbolValue(delim), height, sequence, context);
|
8107 | const delimContext = new Context(context, options === null || options === void 0 ? void 0 : options.style, delimType.mathstyle);
|
8108 |
|
8109 |
|
8110 | if (delimType.type === 'small') {
|
8111 | return makeSmallDelim(delim, delimContext, center, {
|
8112 | type,
|
8113 | classes: 'ML__small-delim ' + ((_a = options === null || options === void 0 ? void 0 : options.classes) !== null && _a !== void 0 ? _a : ''),
|
8114 | });
|
8115 | }
|
8116 | if (delimType.type === 'large') {
|
8117 | return makeLargeDelim(delim, delimType.size, center, delimContext, {
|
8118 | ...options,
|
8119 | type,
|
8120 | });
|
8121 | }
|
8122 | console.assert(delimType.type === 'stack');
|
8123 | return makeStackedDelim(delim, height, center, delimContext, {
|
8124 | ...options,
|
8125 | type,
|
8126 | });
|
8127 | }
|
8128 |
|
8129 |
|
8130 |
|
8131 |
|
8132 |
|
8133 | function makeLeftRightDelim(type, delim, height, depth, context, options) {
|
8134 |
|
8135 | if (delim === '.') {
|
8136 | return makeNullDelimiter(context, type, options === null || options === void 0 ? void 0 : options.classes);
|
8137 | }
|
8138 |
|
8139 | const axisHeight = AXIS_HEIGHT * context.scalingFactor;
|
8140 |
|
8141 | const delimiterFactor = 901;
|
8142 |
|
8143 | const delimiterExtend = 5 / PT_PER_EM;
|
8144 | const maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight);
|
8145 | const totalHeight = Math.max((maxDistFromAxis / 500) * delimiterFactor, 2 * maxDistFromAxis - delimiterExtend);
|
8146 |
|
8147 |
|
8148 | return makeCustomSizedDelim(type, delim, totalHeight, true, context, options);
|
8149 | }
|
8150 | function makeNullDelimiter(parentContext, type, classes) {
|
8151 |
|
8152 |
|
8153 | const context = new Context(parentContext, undefined, 'textstyle');
|
8154 | return new Box(null, {
|
8155 | classes: ' nulldelimiter ' + (classes !== null && classes !== void 0 ? classes : ''),
|
8156 | type,
|
8157 | }).wrap(context);
|
8158 | }
|
8159 |
|
8160 |
|
8161 |
|
8162 |
|
8163 |
|
8164 |
|
8165 |
|
8166 |
|
8167 |
|
8168 |
|
8169 | class LeftRightAtom extends Atom {
|
8170 | constructor(body, options) {
|
8171 | var _a;
|
8172 | super('leftright', {
|
8173 | style: options.style,
|
8174 | displayContainsHighlight: true,
|
8175 | });
|
8176 | this.body = body;
|
8177 | this.inner = (_a = options.inner) !== null && _a !== void 0 ? _a : false;
|
8178 | this.leftDelim = options.leftDelim;
|
8179 | this.rightDelim = options.rightDelim;
|
8180 | }
|
8181 | serialize(options) {
|
8182 | var _a, _b, _c, _d;
|
8183 | let segments = [];
|
8184 | if (this.inner) {
|
8185 | segments = [
|
8186 | '\\left' + ((_a = this.leftDelim) !== null && _a !== void 0 ? _a : '.'),
|
8187 | this.bodyToLatex(options),
|
8188 | '\\right' + ((_b = this.rightDelim) !== null && _b !== void 0 ? _b : '.'),
|
8189 | ];
|
8190 | }
|
8191 | else if (options.expandMacro) {
|
8192 |
|
8193 |
|
8194 |
|
8195 |
|
8196 | segments = [
|
8197 | !this.leftDelim || this.leftDelim === '.' ? '' : this.leftDelim,
|
8198 | this.bodyToLatex(options),
|
8199 | !this.rightDelim || this.rightDelim === '.' ? '' : this.rightDelim,
|
8200 | ];
|
8201 | }
|
8202 | else {
|
8203 | segments = [
|
8204 | '\\mleft' + ((_c = this.leftDelim) !== null && _c !== void 0 ? _c : '.'),
|
8205 | this.bodyToLatex(options),
|
8206 | '\\mright' + ((_d = this.rightDelim) !== null && _d !== void 0 ? _d : '.'),
|
8207 | ];
|
8208 | }
|
8209 | return joinLatex(segments);
|
8210 | }
|
8211 | render(parentContext) {
|
8212 | var _a, _b, _c, _d;
|
8213 | const context = new Context(parentContext, this.style);
|
8214 | if (!this.body) {
|
8215 |
|
8216 | const boxes = [];
|
8217 | if (this.leftDelim) {
|
8218 | boxes.push(new Atom('mopen', { value: this.leftDelim }).render(context));
|
8219 | }
|
8220 | if (this.rightDelim) {
|
8221 | boxes.push(new Atom('mclose', { value: this.rightDelim }).render(context));
|
8222 | }
|
8223 | if (boxes.length === 0)
|
8224 | return null;
|
8225 | return new Box(boxes, { type: 'minner' });
|
8226 | }
|
8227 |
|
8228 |
|
8229 |
|
8230 |
|
8231 | const delimContext = new Context(parentContext, this.style, 'textstyle');
|
8232 | const inner = (_a = Atom.createBox(context, this.body, { newList: true })) !== null && _a !== void 0 ? _a : new Box(null, { newList: true });
|
8233 | const innerHeight = inner.height / delimContext.scalingFactor;
|
8234 | const innerDepth = inner.depth / delimContext.scalingFactor;
|
8235 | const boxes = [];
|
8236 |
|
8237 |
|
8238 |
|
8239 |
|
8240 | if (this.leftDelim) {
|
8241 | boxes.push(this.bind(delimContext, makeLeftRightDelim('mopen', this.leftDelim, innerHeight, innerDepth, delimContext, {
|
8242 | classes: 'ML__open' + (this.containsCaret ? ' ML__contains-caret' : ''),
|
8243 | mode: this.mode,
|
8244 | style: this.style,
|
8245 | })));
|
8246 | }
|
8247 | if (inner) {
|
8248 |
|
8249 |
|
8250 | if (inner.children) {
|
8251 | for (let i = 0; i < inner.children.length; i++) {
|
8252 | const child = inner.children[i];
|
8253 | if (child.delim) {
|
8254 | const savedCaret = child.caret;
|
8255 | inner.children[i] = this.bind(context, makeLeftRightDelim('minner', child.delim, innerHeight, innerDepth, context));
|
8256 | inner.children[i].caret = savedCaret;
|
8257 | }
|
8258 | }
|
8259 | }
|
8260 | boxes.push(inner);
|
8261 | }
|
8262 |
|
8263 | if (this.rightDelim) {
|
8264 | let delim = this.rightDelim;
|
8265 | let classes = this.containsCaret ? ' ML__contains-caret' : '';
|
8266 | if (delim === '?') {
|
8267 | if (context.smartFence) {
|
8268 |
|
8269 | delim =
|
8270 | (_d = (_c = {
|
8271 | '(': ')',
|
8272 | '[': '\\rbrack',
|
8273 | '\\{': '\\}',
|
8274 | '\\lbrace': '\\rbrace',
|
8275 | '\\lparen': '\\rparen',
|
8276 | '\\langle': '\\rangle',
|
8277 | '\\lfloor': '\\rfloor',
|
8278 | '\\lceil': '\\rceil',
|
8279 | '\\vert': '\\vert',
|
8280 | '\\lvert': '\\rvert',
|
8281 | '\\Vert': '\\Vert',
|
8282 | '\\lVert': '\\rVert',
|
8283 | '\\lbrack': '\\rbrack',
|
8284 | '\\ulcorner': '\\urcorner',
|
8285 | '\\llcorner': '\\lrcorner',
|
8286 | '\\lgroup': '\\rgroup',
|
8287 | '\\lmoustache': '\\rmoustache',
|
8288 | }[(_b = this.leftDelim) !== null && _b !== void 0 ? _b : '.']) !== null && _c !== void 0 ? _c : this.leftDelim) !== null && _d !== void 0 ? _d : '.';
|
8289 | classes += ' ML__smart-fence__close';
|
8290 | }
|
8291 | else {
|
8292 | delim = '.';
|
8293 | }
|
8294 | }
|
8295 | boxes.push(this.bind(delimContext, makeLeftRightDelim('mclose', delim, innerHeight, innerDepth, delimContext, {
|
8296 | classes: classes + ' ML__close',
|
8297 | mode: this.mode,
|
8298 | style: this.style,
|
8299 | })));
|
8300 | }
|
8301 |
|
8302 |
|
8303 |
|
8304 |
|
8305 |
|
8306 | const result = new Box(boxes, {
|
8307 | type: this.inner ? 'minner' : 'mclose',
|
8308 | classes: 'left-right',
|
8309 | });
|
8310 | if (this.caret)
|
8311 | result.caret = this.caret;
|
8312 | return this.bind(context, result.wrap(context));
|
8313 | }
|
8314 | }
|
8315 |
|
8316 | class SubsupAtom extends Atom {
|
8317 | constructor(options) {
|
8318 | super('msubsup', { style: options === null || options === void 0 ? void 0 : options.style });
|
8319 | }
|
8320 | render(context) {
|
8321 | var _a;
|
8322 |
|
8323 | console.assert(!this.subsupPlacement);
|
8324 |
|
8325 |
|
8326 | const phantomContex = new Context(context, { isPhantom: true });
|
8327 | const base = (_a = this.leftSibling.render(phantomContex)) !== null && _a !== void 0 ? _a : new Box(null);
|
8328 | const phantom = new Box(null, { height: base.height, depth: base.depth });
|
8329 | return this.attachSupsub(context, {
|
8330 | base: phantom,
|
8331 | isCharacterBox: this.leftSibling.isCharacterBox(),
|
8332 |
|
8333 |
|
8334 | type: 'supsub',
|
8335 | });
|
8336 | }
|
8337 | serialize(options) {
|
8338 | return this.supsubToLatex(options);
|
8339 | }
|
8340 | }
|
8341 |
|
8342 | class PlaceholderAtom extends Atom {
|
8343 | constructor(options) {
|
8344 | super('placeholder', {
|
8345 | mode: options === null || options === void 0 ? void 0 : options.mode,
|
8346 | style: options === null || options === void 0 ? void 0 : options.style,
|
8347 | value: options === null || options === void 0 ? void 0 : options.value,
|
8348 | });
|
8349 | this.captureSelection = true;
|
8350 | this.value = '⬚';
|
8351 | this.placeholderId = options === null || options === void 0 ? void 0 : options.placeholderId;
|
8352 | this.defaultValue = options === null || options === void 0 ? void 0 : options.default;
|
8353 | }
|
8354 | render(context) {
|
8355 | if (typeof context.renderPlaceholder === 'function') {
|
8356 | return context.renderPlaceholder(context, this);
|
8357 | }
|
8358 | return this.createBox(context, {
|
8359 | classes: this.caret ? 'ML__placeholder-selected' : '',
|
8360 | });
|
8361 | }
|
8362 | serialize(_options) {
|
8363 | var _a;
|
8364 | const id = this.placeholderId ? `[${this.placeholderId}]` : '';
|
8365 | const defaultValue = this.defaultValue
|
8366 | ? `[${Atom.serialize(this.defaultValue, _options)}]`
|
8367 | : '';
|
8368 | return `\\placeholder${id}${defaultValue}{${(_a = this.value) !== null && _a !== void 0 ? _a : ''}}`;
|
8369 | }
|
8370 | }
|
8371 |
|
8372 |
|
8373 |
|
8374 |
|
8375 | class ErrorAtom extends Atom {
|
8376 | constructor(value) {
|
8377 | super('error', { value, command: value, mode: 'math' });
|
8378 | this.verbatimLatex = value;
|
8379 | }
|
8380 | render(context) {
|
8381 | const result = this.createBox(context, { classes: 'ML__error' });
|
8382 | if (this.caret)
|
8383 | result.caret = this.caret;
|
8384 | return result;
|
8385 | }
|
8386 | }
|
8387 |
|
8388 | class MacroAtom extends Atom {
|
8389 | constructor(macro, options) {
|
8390 | var _a, _b;
|
8391 | super('macro', { command: macro });
|
8392 | this.body = options.body;
|
8393 |
|
8394 |
|
8395 | this.captureSelection = (_a = options.captureSelection) !== null && _a !== void 0 ? _a : true;
|
8396 |
|
8397 |
|
8398 | this.macroLatex = macro + options.args;
|
8399 | this.expand = (_b = options.expand) !== null && _b !== void 0 ? _b : false;
|
8400 | }
|
8401 | serialize(options) {
|
8402 | return options.expandMacro && this.expand
|
8403 | ? this.bodyToLatex(options)
|
8404 | : this.macroLatex;
|
8405 | }
|
8406 | render(context) {
|
8407 | const result = Atom.createBox(context, this.body);
|
8408 | if (!result)
|
8409 | return null;
|
8410 | if (this.caret)
|
8411 | result.caret = this.caret;
|
8412 | return this.bind(context, result);
|
8413 | }
|
8414 | }
|
8415 |
|
8416 | class TextAtom extends Atom {
|
8417 | constructor(command, value, style) {
|
8418 | super('text', { command, mode: 'text', displayContainsHighlight: true });
|
8419 | this.value = value;
|
8420 | this.verbatimLatex = value;
|
8421 | this.applyStyle(style);
|
8422 | }
|
8423 | render(context) {
|
8424 | const result = this.createBox(context);
|
8425 | if (this.caret)
|
8426 | result.caret = this.caret;
|
8427 | return result;
|
8428 | }
|
8429 | serialize(_options) {
|
8430 | var _a;
|
8431 | return (_a = this.verbatimLatex) !== null && _a !== void 0 ? _a : charToLatex('text', this.value.codePointAt(0));
|
8432 | }
|
8433 | }
|
8434 |
|
8435 |
|
8436 | function isLiteral(token) {
|
8437 | return !/^<({|}|\$|\$\$|space)>$/.test(token);
|
8438 | }
|
8439 |
|
8440 |
|
8441 |
|
8442 |
|
8443 | class Parser {
|
8444 | |
8445 |
|
8446 |
|
8447 | constructor(tokens, options) {
|
8448 | var _a, _b, _c, _d, _e, _f;
|
8449 |
|
8450 | this.index = 0;
|
8451 | this.smartFence = false;
|
8452 |
|
8453 |
|
8454 | this.endCount = 0;
|
8455 | this.tokens = tokens;
|
8456 | this.args = (_a = options.args) !== null && _a !== void 0 ? _a : null;
|
8457 | this.macros = options.macros;
|
8458 | this.colorMap = options.colorMap;
|
8459 | this.backgroundColorMap = (_b = options.backgroundColorMap) !== null && _b !== void 0 ? _b : this.colorMap;
|
8460 | this.smartFence = (_c = options.smartFence) !== null && _c !== void 0 ? _c : false;
|
8461 | this.onError = options.onError
|
8462 | ? (err) => options.onError({
|
8463 | before: tokensToString(this.tokens.slice(this.index, this.index + 10)),
|
8464 | after: tokensToString(this.tokens.slice(Math.max(0, this.index - 10), this.index)),
|
8465 | ...err,
|
8466 | })
|
8467 | : () => { };
|
8468 | this._parsingContexts = [
|
8469 | {
|
8470 | parseMode: (_d = options.parseMode) !== null && _d !== void 0 ? _d : 'math',
|
8471 | mathstyle: (_e = options.mathstyle) !== null && _e !== void 0 ? _e : 'displaystyle',
|
8472 | registers: options.registers,
|
8473 | tabular: false,
|
8474 | style: (_f = options.style) !== null && _f !== void 0 ? _f : {},
|
8475 | mathlist: [],
|
8476 | },
|
8477 | ];
|
8478 | }
|
8479 |
|
8480 |
|
8481 |
|
8482 |
|
8483 |
|
8484 |
|
8485 |
|
8486 |
|
8487 |
|
8488 |
|
8489 | get currentContext() {
|
8490 | return this._parsingContexts[this._parsingContexts.length - 1];
|
8491 | }
|
8492 | beginContext(options) {
|
8493 | var _a, _b, _c;
|
8494 | this._parsingContexts.push({
|
8495 | parseMode: (_a = options === null || options === void 0 ? void 0 : options.mode) !== null && _a !== void 0 ? _a : this.currentContext.parseMode,
|
8496 | mathstyle: (_b = options === null || options === void 0 ? void 0 : options.mathstyle) !== null && _b !== void 0 ? _b : this.currentContext.mathstyle,
|
8497 | registers: null,
|
8498 | style: { ...this.currentContext.style },
|
8499 | tabular: (_c = options === null || options === void 0 ? void 0 : options.tabular) !== null && _c !== void 0 ? _c : false,
|
8500 | mathlist: [],
|
8501 | });
|
8502 | }
|
8503 | endContext() {
|
8504 | this._parsingContexts.pop();
|
8505 | }
|
8506 | get mathlist() {
|
8507 | return this._parsingContexts[this._parsingContexts.length - 1].mathlist;
|
8508 | }
|
8509 | set mathlist(value) {
|
8510 | this._parsingContexts[this._parsingContexts.length - 1].mathlist = value;
|
8511 | }
|
8512 | get parseMode() {
|
8513 | return this._parsingContexts[this._parsingContexts.length - 1].parseMode;
|
8514 | }
|
8515 |
|
8516 | set parseMode(value) {
|
8517 | this._parsingContexts[this._parsingContexts.length - 1].parseMode = value;
|
8518 | }
|
8519 | get tabularMode() {
|
8520 | return this._parsingContexts[this._parsingContexts.length - 1].tabular;
|
8521 | }
|
8522 | get style() {
|
8523 |
|
8524 | let i = this._parsingContexts.length - 1;
|
8525 | let result = this._parsingContexts[i].style;
|
8526 | while (result === undefined && i > 0) {
|
8527 | i -= 1;
|
8528 | result = this._parsingContexts[i].style;
|
8529 | }
|
8530 | return result !== null && result !== void 0 ? result : {};
|
8531 | }
|
8532 |
|
8533 | set style(value) {
|
8534 | this._parsingContexts[this._parsingContexts.length - 1].style = value;
|
8535 | }
|
8536 | getRegister(name) {
|
8537 | var _a, _b, _c, _d;
|
8538 | console.assert(name[0] !== '\\');
|
8539 | if (name.startsWith('global ')) {
|
8540 | return (_b = (_a = this._parsingContexts[0].registers) === null || _a === void 0 ? void 0 : _a[name.slice(7)]) !== null && _b !== void 0 ? _b : 0;
|
8541 | }
|
8542 | let i = this._parsingContexts.length - 1;
|
8543 | let registers = this._parsingContexts[i].registers;
|
8544 | while (i >= 0 && registers && registers[name] === undefined) {
|
8545 | i -= 1;
|
8546 | registers = (_c = this._parsingContexts[i]) === null || _c === void 0 ? void 0 : _c.registers;
|
8547 | }
|
8548 | return (_d = registers === null || registers === void 0 ? void 0 : registers[name]) !== null && _d !== void 0 ? _d : 0;
|
8549 | }
|
8550 | setRegister(name, value) {
|
8551 | if (name.startsWith('global ')) {
|
8552 |
|
8553 | name = name.slice(7);
|
8554 | let i = this._parsingContexts.length - 1;
|
8555 | while (i > 0) {
|
8556 | if (this._parsingContexts[i].registers) {
|
8557 | delete this._parsingContexts[i].registers[name];
|
8558 | }
|
8559 | i -= 1;
|
8560 | }
|
8561 | this._parsingContexts[0].registers[name] = value;
|
8562 | return;
|
8563 | }
|
8564 |
|
8565 | if (!this._parsingContexts[this._parsingContexts.length - 1].registers) {
|
8566 | this._parsingContexts[this._parsingContexts.length - 1].registers = {};
|
8567 | }
|
8568 | this._parsingContexts[this._parsingContexts.length - 1].registers[name] =
|
8569 | value;
|
8570 | }
|
8571 | |
8572 |
|
8573 |
|
8574 | end() {
|
8575 |
|
8576 |
|
8577 |
|
8578 | this.endCount++;
|
8579 | return this.index >= this.tokens.length || this.endCount > 1000;
|
8580 | }
|
8581 | get() {
|
8582 | this.endCount = 0;
|
8583 | return this.index < this.tokens.length ? this.tokens[this.index++] : '';
|
8584 | }
|
8585 | peek() {
|
8586 | return this.tokens[this.index];
|
8587 | }
|
8588 | |
8589 |
|
8590 |
|
8591 | match(input) {
|
8592 | if (this.tokens[this.index] === input) {
|
8593 | this.index++;
|
8594 | return true;
|
8595 | }
|
8596 | return false;
|
8597 | }
|
8598 | |
8599 |
|
8600 |
|
8601 |
|
8602 | lastSubsupAtom() {
|
8603 | let atom;
|
8604 | if (this.mathlist.length > 0) {
|
8605 | atom = this.mathlist[this.mathlist.length - 1];
|
8606 |
|
8607 | if (atom.type === 'msubsup')
|
8608 | return atom;
|
8609 |
|
8610 |
|
8611 |
|
8612 | if (atom.subsupPlacement !== undefined)
|
8613 | return atom;
|
8614 | }
|
8615 |
|
8616 | atom = new SubsupAtom({ style: this.style });
|
8617 | this.mathlist.push(atom);
|
8618 | return atom;
|
8619 | }
|
8620 | |
8621 |
|
8622 |
|
8623 | hasPattern(pattern) {
|
8624 | return pattern.test(this.tokens[this.index]);
|
8625 | }
|
8626 | hasInfixCommand() {
|
8627 | var _a;
|
8628 | const { index } = this;
|
8629 | if (index < this.tokens.length && this.tokens[index].startsWith('\\')) {
|
8630 | const info = getInfo(this.tokens[index], this.parseMode, this.macros);
|
8631 | if (!info)
|
8632 | return false;
|
8633 | if (info.ifMode && !info.ifMode.includes(this.parseMode)) {
|
8634 | return false;
|
8635 | }
|
8636 | return (_a = info.infix) !== null && _a !== void 0 ? _a : false;
|
8637 | }
|
8638 | return false;
|
8639 | }
|
8640 | matchColumnSeparator() {
|
8641 | const { index } = this;
|
8642 | if (this.tabularMode && this.tokens[index] === '&') {
|
8643 | this.index++;
|
8644 | return true;
|
8645 | }
|
8646 | return false;
|
8647 | }
|
8648 | matchRowSeparator() {
|
8649 | const { index } = this;
|
8650 | if (this.tabularMode &&
|
8651 | (this.tokens[index] === '\\\\' || this.tokens[index] === '\\cr')) {
|
8652 | this.index++;
|
8653 | return true;
|
8654 | }
|
8655 | return false;
|
8656 | }
|
8657 | |
8658 |
|
8659 |
|
8660 |
|
8661 | placeholder() {
|
8662 | var _a;
|
8663 | const placeHolderArg = (_a = this.args) === null || _a === void 0 ? void 0 : _a.call(this, '?');
|
8664 | if (!placeHolderArg) {
|
8665 | return [
|
8666 | new PlaceholderAtom({
|
8667 | mode: this.parseMode,
|
8668 | style: this.style,
|
8669 | }),
|
8670 | ];
|
8671 | }
|
8672 |
|
8673 |
|
8674 | return parseLatex(placeHolderArg, {
|
8675 | parseMode: this.parseMode,
|
8676 | onError: this.onError,
|
8677 | registers: this.currentContext.registers,
|
8678 | mathstyle: 'textstyle',
|
8679 | colorMap: this.colorMap,
|
8680 | backgroundColorMap: this.backgroundColorMap,
|
8681 | });
|
8682 | }
|
8683 | matchWhitespace() {
|
8684 | let found = false;
|
8685 | while (this.match('<space>')) {
|
8686 | found = true;
|
8687 | }
|
8688 | return found;
|
8689 | }
|
8690 | skipUntilToken(input) {
|
8691 | let token = this.tokens[this.index];
|
8692 | while (token && token !== input) {
|
8693 | token = this.tokens[++this.index];
|
8694 | }
|
8695 | if (token === input) {
|
8696 | this.index++;
|
8697 | }
|
8698 | }
|
8699 | skipFiller() {
|
8700 | let done = false;
|
8701 | do {
|
8702 | const skippedSpace = this.matchWhitespace();
|
8703 | const skippedRelax = this.match('\\relax');
|
8704 | done = !skippedSpace && !skippedRelax;
|
8705 | } while (!done);
|
8706 | }
|
8707 | |
8708 |
|
8709 |
|
8710 |
|
8711 |
|
8712 |
|
8713 |
|
8714 |
|
8715 |
|
8716 |
|
8717 |
|
8718 |
|
8719 |
|
8720 |
|
8721 | matchKeyword(keyword) {
|
8722 | const savedIndex = this.index;
|
8723 | let done = this.end();
|
8724 | let value = '';
|
8725 | while (!done) {
|
8726 | const token = this.get();
|
8727 | if (isLiteral(token)) {
|
8728 | value += token;
|
8729 | done = this.end() || value.length >= keyword.length;
|
8730 | }
|
8731 | else {
|
8732 | done = true;
|
8733 | }
|
8734 | }
|
8735 | const hasKeyword = keyword.toUpperCase() === value.toUpperCase();
|
8736 | if (!hasKeyword) {
|
8737 | this.index = savedIndex;
|
8738 | }
|
8739 | return hasKeyword;
|
8740 | }
|
8741 | |
8742 |
|
8743 |
|
8744 |
|
8745 |
|
8746 |
|
8747 |
|
8748 | scanString() {
|
8749 | let result = '';
|
8750 | while (!this.end()) {
|
8751 | if (this.match('<space>')) {
|
8752 | result += ' ';
|
8753 | }
|
8754 | else {
|
8755 | const token = this.peek();
|
8756 | if (token === ']')
|
8757 | break;
|
8758 | if (isLiteral(token)) {
|
8759 | result += this.get();
|
8760 | }
|
8761 | else if (token.startsWith('\\')) {
|
8762 |
|
8763 |
|
8764 |
|
8765 | this.onError({ code: 'unbalanced-braces' });
|
8766 | result += this.get();
|
8767 | }
|
8768 | else {
|
8769 |
|
8770 | break;
|
8771 | }
|
8772 | }
|
8773 | }
|
8774 | return result;
|
8775 | }
|
8776 | |
8777 |
|
8778 |
|
8779 |
|
8780 |
|
8781 | scanBalancedString() {
|
8782 | let result = '';
|
8783 | let done = this.end();
|
8784 | let level = 1;
|
8785 | while (!done) {
|
8786 | if (this.match('<space>')) {
|
8787 | result += ' ';
|
8788 | }
|
8789 | else {
|
8790 | const token = this.get();
|
8791 | if (token === '<{>') {
|
8792 | result += '{';
|
8793 | level += 1;
|
8794 | }
|
8795 | else if (token === '<}>') {
|
8796 | level -= 1;
|
8797 | if (level > 0) {
|
8798 | result += '}';
|
8799 | }
|
8800 | else {
|
8801 | this.index -= 1;
|
8802 | }
|
8803 | }
|
8804 | else if (token === '<$>') {
|
8805 | result += '$';
|
8806 | }
|
8807 | else if (token === '<$$>') {
|
8808 | result += '$$';
|
8809 | }
|
8810 | else {
|
8811 | result += token;
|
8812 | }
|
8813 | }
|
8814 | done = level === 0 || this.end();
|
8815 | }
|
8816 | return result;
|
8817 | }
|
8818 | |
8819 |
|
8820 |
|
8821 | matchLiteralArg() {
|
8822 | var _a;
|
8823 | let result = '';
|
8824 | if (this.match('<{>')) {
|
8825 | let depth = 1;
|
8826 | while (depth > 0 && !this.end()) {
|
8827 | const token = this.get();
|
8828 | if (token === '<}>') {
|
8829 | depth -= 1;
|
8830 | if (depth > 0) {
|
8831 |
|
8832 | result += '}';
|
8833 | }
|
8834 | }
|
8835 | else if (token === '<{>') {
|
8836 | depth += 1;
|
8837 | result += '{';
|
8838 | }
|
8839 | else {
|
8840 | result +=
|
8841 | (_a = {
|
8842 | '<space>': ' ',
|
8843 | '<$$>': '$$',
|
8844 | '<$>': '$',
|
8845 | }[token]) !== null && _a !== void 0 ? _a : token;
|
8846 | }
|
8847 | }
|
8848 | }
|
8849 | return result;
|
8850 | }
|
8851 | |
8852 |
|
8853 |
|
8854 |
|
8855 |
|
8856 |
|
8857 |
|
8858 |
|
8859 |
|
8860 |
|
8861 |
|
8862 | scanNumber(isInteger = true) {
|
8863 | var _a, _b;
|
8864 | let negative = false;
|
8865 | let token = this.peek();
|
8866 | while (token === '<space>' || token === '+' || token === '-') {
|
8867 | this.get();
|
8868 | if (token === '-')
|
8869 | negative = !negative;
|
8870 | token = this.peek();
|
8871 | }
|
8872 | isInteger = Boolean(isInteger);
|
8873 | let radix = 10;
|
8874 | let digits = /\d/;
|
8875 | if (this.match("'")) {
|
8876 |
|
8877 | radix = 8;
|
8878 | digits = /[0-7]/;
|
8879 | isInteger = true;
|
8880 | }
|
8881 | else if (this.match('"') || this.match('x')) {
|
8882 |
|
8883 |
|
8884 |
|
8885 | radix = 16;
|
8886 |
|
8887 | digits = /[\dA-F]/;
|
8888 | isInteger = true;
|
8889 | }
|
8890 | else if (this.match('`')) {
|
8891 |
|
8892 | token = this.get();
|
8893 | if (token) {
|
8894 | if (token.startsWith('\\') && token.length === 2) {
|
8895 | return (negative ? -1 : 1) * ((_a = token.codePointAt(1)) !== null && _a !== void 0 ? _a : 0);
|
8896 | }
|
8897 | return (negative ? -1 : 1) * ((_b = token.codePointAt(0)) !== null && _b !== void 0 ? _b : 0);
|
8898 | }
|
8899 | return null;
|
8900 | }
|
8901 | let value = '';
|
8902 | while (this.hasPattern(digits)) {
|
8903 | value += this.get();
|
8904 | }
|
8905 |
|
8906 | if (!isInteger && (this.match('.') || this.match(','))) {
|
8907 | value += '.';
|
8908 | while (this.hasPattern(digits)) {
|
8909 | value += this.get();
|
8910 | }
|
8911 | }
|
8912 | const result = isInteger
|
8913 | ? Number.parseInt(value, radix)
|
8914 | : Number.parseFloat(value);
|
8915 | if (Number.isNaN(result))
|
8916 | return null;
|
8917 | return negative ? -result : result;
|
8918 | }
|
8919 | |
8920 |
|
8921 |
|
8922 |
|
8923 |
|
8924 | scanDimen() {
|
8925 | var _a, _b, _c;
|
8926 | let value = this.scanNumber(false);
|
8927 | if (value === null) {
|
8928 |
|
8929 | if ((_a = this.peek()) === null || _a === void 0 ? void 0 : _a.startsWith('\\')) {
|
8930 | value = 1;
|
8931 | }
|
8932 | else {
|
8933 | return null;
|
8934 | }
|
8935 | }
|
8936 | this.matchWhitespace();
|
8937 | let result;
|
8938 | if (this.matchKeyword('pt')) {
|
8939 | result = { dimension: value, unit: 'pt' };
|
8940 | }
|
8941 | else if (this.matchKeyword('mm')) {
|
8942 | result = { dimension: value, unit: 'mm' };
|
8943 | }
|
8944 | else if (this.matchKeyword('cm')) {
|
8945 | result = { dimension: value, unit: 'cm' };
|
8946 | }
|
8947 | else if (this.matchKeyword('ex')) {
|
8948 | result = { dimension: value, unit: 'ex' };
|
8949 | }
|
8950 | else if (this.matchKeyword('px')) {
|
8951 | result = { dimension: value, unit: 'px' };
|
8952 | }
|
8953 | else if (this.matchKeyword('em')) {
|
8954 | result = { dimension: value, unit: 'em' };
|
8955 | }
|
8956 | else if (this.matchKeyword('bp')) {
|
8957 | result = { dimension: value, unit: 'bp' };
|
8958 | }
|
8959 | else if (this.matchKeyword('dd')) {
|
8960 | result = { dimension: value, unit: 'dd' };
|
8961 | }
|
8962 | else if (this.matchKeyword('pc')) {
|
8963 | result = { dimension: value, unit: 'pc' };
|
8964 | }
|
8965 | else if (this.matchKeyword('in')) {
|
8966 | result = { dimension: value, unit: 'in' };
|
8967 | }
|
8968 | else if (this.matchKeyword('mu')) {
|
8969 | result = { dimension: value, unit: 'mu' };
|
8970 | }
|
8971 | else {
|
8972 | if ((_b = this.peek()) === null || _b === void 0 ? void 0 : _b.startsWith('\\')) {
|
8973 | result = (_c = convertToDimension(this.getRegister(this.get().slice(1)), this.currentContext.registers)) !== null && _c !== void 0 ? _c : { dimension: 0 };
|
8974 | result.dimension *= value;
|
8975 | }
|
8976 | else {
|
8977 | if (!this.match('\\relax')) {
|
8978 |
|
8979 | this.onError({ code: 'missing-unit' });
|
8980 | }
|
8981 | result = { dimension: value, unit: 'pt' };
|
8982 | }
|
8983 | }
|
8984 | return result;
|
8985 | }
|
8986 | scanGlue() {
|
8987 | const dimen = this.scanDimen();
|
8988 | if (dimen === null)
|
8989 | return null;
|
8990 | const result = { glue: dimen };
|
8991 |
|
8992 |
|
8993 | this.matchWhitespace();
|
8994 | if (this.match('\\relax'))
|
8995 | return result;
|
8996 |
|
8997 |
|
8998 |
|
8999 | if (this.matchKeyword('plus')) {
|
9000 |
|
9001 | this.scanDimen();
|
9002 | }
|
9003 | this.matchWhitespace();
|
9004 | if (this.match('\\relax'))
|
9005 | return result;
|
9006 | this.matchWhitespace();
|
9007 | if (this.matchKeyword('minus')) {
|
9008 |
|
9009 | this.scanDimen();
|
9010 | }
|
9011 | return result;
|
9012 | }
|
9013 | scanColspec() {
|
9014 | this.matchWhitespace();
|
9015 | const result = [];
|
9016 | while (!this.end() && !(this.peek() === '<}>' || this.peek() === ']')) {
|
9017 | const literal = this.get();
|
9018 | if (literal === 'c' || literal === 'r' || literal === 'l') {
|
9019 | result.push({ align: literal });
|
9020 | }
|
9021 | else if (literal === '|') {
|
9022 | result.push({ separator: 'solid' });
|
9023 | }
|
9024 | else if (literal === ':') {
|
9025 | result.push({ separator: 'dashed' });
|
9026 | }
|
9027 | else if (literal === '@') {
|
9028 | if (this.match('<{>')) {
|
9029 | this.beginContext({ mode: 'math' });
|
9030 | result.push({
|
9031 | gap: this.parse((token) => token === '<}>'),
|
9032 | });
|
9033 | this.endContext();
|
9034 | }
|
9035 | if (!this.match('<}>')) {
|
9036 | this.onError({ code: 'unbalanced-braces' });
|
9037 | }
|
9038 | }
|
9039 | }
|
9040 | return result;
|
9041 | }
|
9042 | |
9043 |
|
9044 |
|
9045 |
|
9046 | parseModeSet() {
|
9047 | let final = '';
|
9048 | if (this.match('\\('))
|
9049 | final = '\\)';
|
9050 | if (!final && this.match('\\['))
|
9051 | final = '\\]';
|
9052 | if (!final)
|
9053 | return null;
|
9054 | this.beginContext({
|
9055 | mode: 'math',
|
9056 | mathstyle: final === '\\)' ? 'textstyle' : 'displaystyle',
|
9057 | });
|
9058 | const result = new GroupAtom(this.parse((token) => token === final), {
|
9059 | mathstyleName: final === '\\)' ? 'textstyle' : 'displaystyle',
|
9060 | latexOpen: final === '\\]' ? '\\[' : '\\(',
|
9061 | latexClose: final,
|
9062 | boxType: 'mord',
|
9063 | });
|
9064 | if (!this.match(final)) {
|
9065 | this.onError({ code: 'unbalanced-mode-shift' });
|
9066 | }
|
9067 | this.endContext();
|
9068 | if (result.hasEmptyBranch('body'))
|
9069 | return null;
|
9070 | return result;
|
9071 | }
|
9072 | |
9073 |
|
9074 |
|
9075 | parseModeShift() {
|
9076 | let final = '';
|
9077 | if (this.match('<$>'))
|
9078 | final = '<$>';
|
9079 | if (!final && this.match('<$$>'))
|
9080 | final = '<$$>';
|
9081 | if (!final)
|
9082 | return null;
|
9083 | this.beginContext({
|
9084 | mode: 'math',
|
9085 | mathstyle: 'textstyle' ,
|
9086 | });
|
9087 | const result = new GroupAtom(this.parse((token) => token === final), {
|
9088 | mathstyleName: final === '<$>' ? 'textstyle' : 'displaystyle',
|
9089 | latexOpen: final === '<$>' ? '$ ' : '$$ ',
|
9090 | latexClose: final === '<$>' ? ' $' : ' $$',
|
9091 | });
|
9092 | if (!this.match(final)) {
|
9093 | this.onError({ code: 'unbalanced-mode-shift' });
|
9094 | }
|
9095 | this.endContext();
|
9096 | if (result.hasEmptyBranch('body'))
|
9097 | return null;
|
9098 | return result;
|
9099 | }
|
9100 | |
9101 |
|
9102 |
|
9103 | parseEnvironment() {
|
9104 |
|
9105 | if (!this.match('\\begin'))
|
9106 | return null;
|
9107 |
|
9108 |
|
9109 | const envName = this.parseArgument('string');
|
9110 | if (!envName)
|
9111 | return null;
|
9112 | const def = getEnvironmentDefinition(envName);
|
9113 | if (!def) {
|
9114 | this.onError({
|
9115 | code: 'unknown-environment',
|
9116 | arg: envName,
|
9117 | });
|
9118 | return null;
|
9119 | }
|
9120 |
|
9121 | const args = [];
|
9122 | if (def.params) {
|
9123 | for (const parameter of def.params) {
|
9124 |
|
9125 | if (parameter.isOptional) {
|
9126 |
|
9127 |
|
9128 |
|
9129 |
|
9130 | args.push(this.parseOptionalArgument(parameter.type));
|
9131 | }
|
9132 | else {
|
9133 | const arg = this.parseArgument(parameter.type);
|
9134 | if (!arg) {
|
9135 | this.onError({
|
9136 | code: 'missing-argument',
|
9137 | arg: envName,
|
9138 | });
|
9139 | }
|
9140 | args.push(arg);
|
9141 | }
|
9142 | }
|
9143 | }
|
9144 | this.beginContext({ tabular: def.tabular });
|
9145 | const array = [];
|
9146 | const rowGaps = [];
|
9147 | let row = [];
|
9148 | let done = false;
|
9149 | do {
|
9150 | if (this.end()) {
|
9151 | this.onError({ code: 'unbalanced-environment', arg: envName });
|
9152 | done = true;
|
9153 | }
|
9154 | if (!done && this.match('\\end')) {
|
9155 | if (this.parseArgument('string') !== envName) {
|
9156 | this.onError({
|
9157 | code: 'unbalanced-environment',
|
9158 | arg: envName,
|
9159 | });
|
9160 | }
|
9161 | done = true;
|
9162 | }
|
9163 | if (!done) {
|
9164 | if (this.matchColumnSeparator()) {
|
9165 | row.push(this.mathlist);
|
9166 | this.mathlist = [];
|
9167 | }
|
9168 | else if (this.matchRowSeparator()) {
|
9169 | row.push(this.mathlist);
|
9170 | this.mathlist = [];
|
9171 | let gap = null;
|
9172 | this.matchWhitespace();
|
9173 | if (this.match('[')) {
|
9174 | gap = this.scanDimen();
|
9175 | this.matchWhitespace();
|
9176 | this.match(']');
|
9177 | }
|
9178 | rowGaps.push(gap !== null && gap !== void 0 ? gap : { dimension: 0 });
|
9179 | array.push(row);
|
9180 | row = [];
|
9181 | }
|
9182 | else {
|
9183 | this.mathlist = this.mathlist.concat(this.parse((token) => token === '<}>' ||
|
9184 | token === '&' ||
|
9185 | token === '\\end' ||
|
9186 | token === '\\cr' ||
|
9187 | token === '\\\\'));
|
9188 | }
|
9189 | }
|
9190 | } while (!done);
|
9191 | row.push(this.mathlist);
|
9192 | if (row.length > 0)
|
9193 | array.push(row);
|
9194 | this.endContext();
|
9195 | return def.createAtom(envName, array, rowGaps, args);
|
9196 | }
|
9197 | |
9198 |
|
9199 |
|
9200 |
|
9201 |
|
9202 |
|
9203 |
|
9204 |
|
9205 |
|
9206 |
|
9207 | parse(done) {
|
9208 | this.beginContext();
|
9209 | if (!done) {
|
9210 |
|
9211 | done = (token) => token === '<}>';
|
9212 | }
|
9213 |
|
9214 |
|
9215 | let infix = '';
|
9216 | let infixInfo = null;
|
9217 | let infixArgs = [];
|
9218 | let prefix = null;
|
9219 | const saveAtoms = this.mathlist;
|
9220 | this.mathlist = [];
|
9221 | while (!this.end() && !done(this.peek())) {
|
9222 | if (this.hasInfixCommand() && !infix) {
|
9223 |
|
9224 |
|
9225 | infix = this.get();
|
9226 |
|
9227 |
|
9228 |
|
9229 |
|
9230 | infixInfo = getInfo(infix, 'math', this.macros);
|
9231 | if (infixInfo) {
|
9232 | infixArgs = this.parseArguments(infixInfo)[1];
|
9233 | }
|
9234 |
|
9235 | prefix = this.mathlist;
|
9236 | this.mathlist = [];
|
9237 | }
|
9238 | else {
|
9239 | this.parseToken();
|
9240 | }
|
9241 | }
|
9242 | let result;
|
9243 | if (infix) {
|
9244 | console.assert(Boolean(infixInfo));
|
9245 | infixArgs.unshift(this.mathlist);
|
9246 | this.mathlist = saveAtoms;
|
9247 | if (prefix)
|
9248 | infixArgs.unshift(prefix);
|
9249 | result = [
|
9250 | infixInfo.createAtom(infix, infixArgs, this.style, {
|
9251 | colorMap: this.colorMap,
|
9252 | backgroundColorMap: this.backgroundColorMap,
|
9253 | }),
|
9254 | ];
|
9255 | }
|
9256 | else {
|
9257 | result = this.mathlist;
|
9258 | this.mathlist = saveAtoms;
|
9259 | }
|
9260 | this.endContext();
|
9261 | return result;
|
9262 | }
|
9263 | |
9264 |
|
9265 |
|
9266 |
|
9267 |
|
9268 |
|
9269 |
|
9270 |
|
9271 | parseGroup() {
|
9272 | if (!this.match('<{>'))
|
9273 | return null;
|
9274 | const result = new GroupAtom(this.parse((token) => token === '<}>'), {
|
9275 | mode: this.parseMode,
|
9276 | latexOpen: '{',
|
9277 | latexClose: '}',
|
9278 | });
|
9279 | if (!this.match('<}>')) {
|
9280 | this.onError({ code: 'unbalanced-braces' });
|
9281 | }
|
9282 | return result;
|
9283 | }
|
9284 | scanSmartFence() {
|
9285 | this.matchWhitespace();
|
9286 | if (!this.match('('))
|
9287 | return null;
|
9288 |
|
9289 | this.beginContext();
|
9290 | let nestLevel = 1;
|
9291 | while (!this.end() && nestLevel !== 0) {
|
9292 | if (this.match('('))
|
9293 | nestLevel += 1;
|
9294 | if (this.match(')'))
|
9295 | nestLevel -= 1;
|
9296 | if (nestLevel !== 0)
|
9297 | this.parseToken();
|
9298 | }
|
9299 | if (nestLevel === 0)
|
9300 | this.match(')');
|
9301 | const result = new LeftRightAtom(this.mathlist, {
|
9302 | inner: false,
|
9303 | leftDelim: '(',
|
9304 | rightDelim: nestLevel === 0 ? ')' : '?',
|
9305 | });
|
9306 | this.endContext();
|
9307 | return result;
|
9308 | }
|
9309 | |
9310 |
|
9311 |
|
9312 |
|
9313 |
|
9314 | scanDelim() {
|
9315 | this.matchWhitespace();
|
9316 | const token = this.get();
|
9317 | if (!token) {
|
9318 | this.onError({ code: 'unexpected-end-of-string' });
|
9319 | return null;
|
9320 | }
|
9321 | let delim = '.';
|
9322 | if (token.startsWith('\\') || isLiteral(token)) {
|
9323 | delim = token;
|
9324 | }
|
9325 | const info = getInfo(delim, 'math', this.macros);
|
9326 | if (!info) {
|
9327 | this.onError({ code: 'unknown-command', arg: delim });
|
9328 | return null;
|
9329 | }
|
9330 | if (info.ifMode && !info.ifMode.includes(this.parseMode)) {
|
9331 | this.onError({ code: 'unexpected-delimiter', arg: delim });
|
9332 | return null;
|
9333 | }
|
9334 | if (info.type === 'mopen' || info.type === 'mclose') {
|
9335 | return delim;
|
9336 | }
|
9337 |
|
9338 |
|
9339 |
|
9340 |
|
9341 | if (/^(\.|\?|\||<|>|\\vert|\\Vert|\\\||\\surd|\\uparrow|\\downarrow|\\Uparrow|\\Downarrow|\\updownarrow|\\Updownarrow|\\mid|\\mvert|\\mVert)$/.test(delim)) {
|
9342 | return delim;
|
9343 | }
|
9344 | this.onError({ code: 'unexpected-delimiter', arg: delim });
|
9345 | return null;
|
9346 | }
|
9347 | |
9348 |
|
9349 |
|
9350 |
|
9351 |
|
9352 |
|
9353 |
|
9354 |
|
9355 | parseLeftRight() {
|
9356 | var _a;
|
9357 | if (this.match('\\right') || this.match('\\mright')) {
|
9358 |
|
9359 | this.onError({ code: 'unbalanced-braces' });
|
9360 | return null;
|
9361 | }
|
9362 | let close = '\\right';
|
9363 | if (!this.match('\\left')) {
|
9364 | if (!this.match('\\mleft'))
|
9365 | return null;
|
9366 | close = '\\mright';
|
9367 | }
|
9368 | const leftDelim = this.scanDelim();
|
9369 | if (!leftDelim)
|
9370 | return null;
|
9371 | this.beginContext();
|
9372 | while (!this.end() && !this.match(close)) {
|
9373 | this.parseToken();
|
9374 | }
|
9375 | const body = this.mathlist;
|
9376 | this.endContext();
|
9377 |
|
9378 |
|
9379 |
|
9380 | const rightDelim = (_a = this.scanDelim()) !== null && _a !== void 0 ? _a : '.';
|
9381 | return new LeftRightAtom(body, {
|
9382 | leftDelim,
|
9383 | rightDelim,
|
9384 | inner: close === '\\right',
|
9385 | style: this.style,
|
9386 | });
|
9387 | }
|
9388 | |
9389 |
|
9390 |
|
9391 |
|
9392 |
|
9393 |
|
9394 | parseSupSub() {
|
9395 |
|
9396 | if (this.parseMode !== 'math')
|
9397 | return false;
|
9398 |
|
9399 |
|
9400 |
|
9401 | let token = this.peek();
|
9402 | if (token !== '^' && token !== '_' && token !== "'")
|
9403 | return false;
|
9404 | while (token === '^' || token === '_' || token === "'") {
|
9405 | if (this.match("'")) {
|
9406 | if (this.match("'")) {
|
9407 |
|
9408 | this.lastSubsupAtom().addChild(new Atom('mord', {
|
9409 | command: '\\doubleprime',
|
9410 | mode: 'math',
|
9411 | value: '\u2032\u2032',
|
9412 | }), 'superscript');
|
9413 | }
|
9414 | else {
|
9415 |
|
9416 | this.lastSubsupAtom().addChild(new Atom('mord', {
|
9417 | command: '\\prime',
|
9418 | mode: 'math',
|
9419 | value: '\u2032',
|
9420 | }), 'superscript');
|
9421 | }
|
9422 | }
|
9423 | else if (this.match('^') || this.match('_')) {
|
9424 | const arg = this.parseArgument('math');
|
9425 | if (arg) {
|
9426 | this.lastSubsupAtom().addChildren(arg, token === '_' ? 'subscript' : 'superscript');
|
9427 | }
|
9428 | else {
|
9429 | this.lastSubsupAtom().createBranch(token === '_' ? 'subscript' : 'superscript');
|
9430 | }
|
9431 | }
|
9432 | token = this.peek();
|
9433 | }
|
9434 | return true;
|
9435 | }
|
9436 | |
9437 |
|
9438 |
|
9439 |
|
9440 |
|
9441 |
|
9442 |
|
9443 |
|
9444 |
|
9445 |
|
9446 | parseLimits() {
|
9447 |
|
9448 |
|
9449 |
|
9450 |
|
9451 | const isLimits = this.match('\\limits');
|
9452 | const isNoLimits = !isLimits && this.match('\\nolimits');
|
9453 | const isDisplayLimits = !isNoLimits && !isLimits && this.match('\\displaylimits');
|
9454 | if (!isLimits && !isNoLimits && !isDisplayLimits)
|
9455 | return false;
|
9456 | const opAtom = this.mathlist.length > 0 ? this.mathlist[this.mathlist.length - 1] : null;
|
9457 | if (opAtom === null || opAtom.type !== 'mop')
|
9458 | return false;
|
9459 | if (isLimits) {
|
9460 | opAtom.subsupPlacement = 'over-under';
|
9461 |
|
9462 |
|
9463 | opAtom.explicitSubsupPlacement = true;
|
9464 | return true;
|
9465 | }
|
9466 | if (isNoLimits) {
|
9467 | opAtom.subsupPlacement = 'adjacent';
|
9468 | opAtom.explicitSubsupPlacement = true;
|
9469 | return true;
|
9470 | }
|
9471 | if (isDisplayLimits) {
|
9472 | opAtom.subsupPlacement = 'auto';
|
9473 | opAtom.explicitSubsupPlacement = true;
|
9474 | return true;
|
9475 | }
|
9476 | return false;
|
9477 | }
|
9478 | parseArguments(info) {
|
9479 | if (!info || !info.params)
|
9480 | return [undefined, []];
|
9481 | let explicitGroup = undefined;
|
9482 | const args = [];
|
9483 | let i = info.infix ? 2 : 0;
|
9484 | while (i < info.params.length) {
|
9485 | const parameter = info.params[i];
|
9486 |
|
9487 | if (parameter.type === 'rest') {
|
9488 | args.push(this.parse((token) => token === '<}>' ||
|
9489 | token === '&' ||
|
9490 | token === '\\end' ||
|
9491 | token === '\\cr' ||
|
9492 | token === '\\\\'));
|
9493 | }
|
9494 | else if (parameter.isOptional) {
|
9495 | args.push(this.parseOptionalArgument(parameter.type));
|
9496 | }
|
9497 | else if (parameter.type.endsWith('*')) {
|
9498 |
|
9499 |
|
9500 |
|
9501 | explicitGroup = parameter.type.slice(0, -1);
|
9502 | }
|
9503 | else {
|
9504 | const arg = this.parseArgument(parameter.type);
|
9505 | if (arg !== null) {
|
9506 | args.push(arg);
|
9507 | }
|
9508 | else {
|
9509 |
|
9510 | this.onError({ code: 'missing-argument' });
|
9511 | switch (parameter.type) {
|
9512 | case 'number':
|
9513 |
|
9514 |
|
9515 | args.push(0);
|
9516 | break;
|
9517 | case 'dimen':
|
9518 | args.push({ dimension: 0, unit: 'pt' });
|
9519 | break;
|
9520 | case 'glue':
|
9521 | args.push({ glue: { dimension: 0, unit: 'pt' } });
|
9522 | break;
|
9523 | case 'string':
|
9524 | case 'balanced-string':
|
9525 | args.push('');
|
9526 | break;
|
9527 | case 'delim':
|
9528 | args.push('.');
|
9529 | break;
|
9530 | case 'colspec':
|
9531 | args.push('llllllllll');
|
9532 | break;
|
9533 | case 'auto':
|
9534 | default:
|
9535 | args.push(this.placeholder());
|
9536 | break;
|
9537 | }
|
9538 | }
|
9539 | }
|
9540 | i += 1;
|
9541 | }
|
9542 | return [explicitGroup, args];
|
9543 | }
|
9544 | parseArgument(argType) {
|
9545 | var _a, _b, _c, _d;
|
9546 | this.skipFiller();
|
9547 | argType = argType === 'auto' ? this.parseMode : argType;
|
9548 | let result = null;
|
9549 |
|
9550 |
|
9551 |
|
9552 |
|
9553 | if (!this.match('<{>')) {
|
9554 | if (argType === 'delim') {
|
9555 | return (_a = this.scanDelim()) !== null && _a !== void 0 ? _a : '.';
|
9556 | }
|
9557 | if (argType === 'text' || argType === 'math') {
|
9558 |
|
9559 | this.beginContext();
|
9560 | const atom = this.parseSimpleToken();
|
9561 | this.endContext();
|
9562 | return atom;
|
9563 | }
|
9564 | }
|
9565 | if (argType === 'text' || argType === 'math') {
|
9566 | this.beginContext({ mode: argType });
|
9567 |
|
9568 | const initialIndex = this.index;
|
9569 | let depth = 1;
|
9570 | do {
|
9571 | const token = this.get();
|
9572 | if (token === '<}>')
|
9573 | depth -= 1;
|
9574 | if (token === '<{>')
|
9575 | depth += 1;
|
9576 | } while (depth > 0 && !this.end());
|
9577 | result = Mode.parseTokens(argType, this.tokens.slice(initialIndex, this.index - 1), this.onError, {
|
9578 | args: (_b = this.args) !== null && _b !== void 0 ? _b : (() => ''),
|
9579 | macros: (_c = this.macros) !== null && _c !== void 0 ? _c : {},
|
9580 | smartFence: this.smartFence,
|
9581 | style: this.style,
|
9582 | parse: (mode, tokens, options) => {
|
9583 | const parser = new Parser(tokens, {
|
9584 | args: options.args,
|
9585 | parseMode: mode,
|
9586 | smartFence: this.smartFence,
|
9587 | macros: options.macros,
|
9588 | registers: this.currentContext.registers,
|
9589 | mathstyle: this.currentContext.mathstyle,
|
9590 | colorMap: this.colorMap,
|
9591 | backgroundColorMap: this.backgroundColorMap,
|
9592 | style: options.style,
|
9593 | onError: this.onError,
|
9594 | });
|
9595 | result = parser.parse();
|
9596 | return [result, tokens.slice(parser.index)];
|
9597 | },
|
9598 | });
|
9599 | if (!result) {
|
9600 |
|
9601 | this.index = initialIndex;
|
9602 | do {
|
9603 | this.mathlist = this.mathlist.concat(this.parse());
|
9604 | } while (!this.match('<}>') && !this.end());
|
9605 | }
|
9606 | }
|
9607 | else {
|
9608 | this.beginContext();
|
9609 | if (argType === 'string') {
|
9610 | result = this.scanString();
|
9611 | }
|
9612 | else if (argType === 'balanced-string') {
|
9613 | result = this.scanBalancedString();
|
9614 | }
|
9615 | else if (argType === 'number') {
|
9616 | result = this.scanNumber();
|
9617 | }
|
9618 | else if (argType === 'colspec') {
|
9619 | result = this.scanColspec();
|
9620 | }
|
9621 | else if (argType === 'dimen') {
|
9622 | result = this.scanDimen();
|
9623 | }
|
9624 | else if (argType === 'glue') {
|
9625 | result = this.scanGlue();
|
9626 | }
|
9627 | else if (argType === 'delim') {
|
9628 | result = (_d = this.scanDelim()) !== null && _d !== void 0 ? _d : '.';
|
9629 | }
|
9630 | if (result === null) {
|
9631 | this.endContext();
|
9632 | return null;
|
9633 | }
|
9634 | this.skipUntilToken('<}>');
|
9635 | }
|
9636 | const atoms = this.mathlist;
|
9637 | this.endContext();
|
9638 | return result !== null && result !== void 0 ? result : atoms;
|
9639 | }
|
9640 | parseOptionalArgument(argType) {
|
9641 | var _a;
|
9642 | argType = argType === 'auto' ? this.parseMode : argType;
|
9643 | this.matchWhitespace();
|
9644 | if (!this.match('['))
|
9645 | return null;
|
9646 | let result = null;
|
9647 | while (!this.end() && !this.match(']')) {
|
9648 | if (argType === 'string') {
|
9649 | result = this.scanString();
|
9650 | }
|
9651 | else if (argType === 'number') {
|
9652 | result = this.scanNumber();
|
9653 | }
|
9654 | else if (argType === 'dimen') {
|
9655 | result = this.scanDimen();
|
9656 | }
|
9657 | else if (argType === 'glue') {
|
9658 | result = this.scanGlue();
|
9659 | }
|
9660 | else if (argType === 'colspec') {
|
9661 | result = this.scanColspec();
|
9662 | }
|
9663 | else if (argType === 'bbox') {
|
9664 |
|
9665 |
|
9666 |
|
9667 |
|
9668 |
|
9669 |
|
9670 | const list = this.scanString()
|
9671 | .toLowerCase()
|
9672 | .trim()
|
9673 | .split(/,(?![^(]*\)(?:(?:[^(]*\)){2})*[^"]*$)/);
|
9674 | const bboxParameter = {};
|
9675 | for (const element of list) {
|
9676 | const color = (_a = this.backgroundColorMap) === null || _a === void 0 ? void 0 : _a.call(this, element);
|
9677 | if (color) {
|
9678 | bboxParameter.backgroundcolor = color;
|
9679 | }
|
9680 | else {
|
9681 | const m = element.match(/^\s*([\d.]+)\s*([a-z]{2})/);
|
9682 | if (m) {
|
9683 | bboxParameter.padding = m[0];
|
9684 | }
|
9685 | else {
|
9686 | const m = element.match(/^\s*border\s*:\s*(.*)/);
|
9687 | if (m) {
|
9688 | bboxParameter.border = m[1];
|
9689 | }
|
9690 | }
|
9691 | }
|
9692 | }
|
9693 | result = bboxParameter;
|
9694 | }
|
9695 | else if (argType === 'math') {
|
9696 | this.beginContext({ mode: 'math' });
|
9697 | result = this.mathlist.concat(this.parse((token) => token === ']'));
|
9698 | this.endContext();
|
9699 | }
|
9700 | }
|
9701 | return result;
|
9702 | }
|
9703 | parseCommand(command) {
|
9704 | var _a, _b, _c, _d, _e, _f;
|
9705 | let result = null;
|
9706 | if (command === '\\placeholder') {
|
9707 | const placeholder = new PlaceholderAtom({
|
9708 | mode: this.parseMode,
|
9709 | placeholderId: this.parseOptionalArgument('string'),
|
9710 | default: this.parseOptionalArgument('math'),
|
9711 | value: (_a = this.parseArgument('string')) !== null && _a !== void 0 ? _a : undefined,
|
9712 | style: this.style,
|
9713 | });
|
9714 | return [placeholder];
|
9715 | }
|
9716 | if (command === '\\char') {
|
9717 |
|
9718 |
|
9719 | const initialIndex = this.index;
|
9720 | let codepoint = Math.floor((_b = this.scanNumber(true)) !== null && _b !== void 0 ? _b : Number.NaN);
|
9721 | if (!Number.isFinite(codepoint) ||
|
9722 | codepoint < 0 ||
|
9723 | codepoint > 0x10ffff) {
|
9724 | codepoint = 0x2753;
|
9725 | }
|
9726 | const verbatimLatex = '\\char' + tokensToString(this.tokens.slice(initialIndex, this.index));
|
9727 | result = new Atom(this.parseMode === 'math' ? 'mord' : 'text', {
|
9728 | command: '\\char',
|
9729 | mode: this.parseMode,
|
9730 | value: String.fromCodePoint(codepoint),
|
9731 | serialize: () => verbatimLatex,
|
9732 | });
|
9733 | result.verbatimLatex = verbatimLatex;
|
9734 | return [result];
|
9735 | }
|
9736 | if (command === '\\hskip' || command === '\\kern') {
|
9737 |
|
9738 |
|
9739 | const width = this.scanGlue();
|
9740 | if (!width)
|
9741 | return null;
|
9742 | return [new SpacingAtom(command, this.style, width)];
|
9743 | }
|
9744 |
|
9745 | result = this.scanMacro(command);
|
9746 | if (result)
|
9747 | return [result];
|
9748 |
|
9749 | const info = getInfo(command, this.parseMode, {});
|
9750 | if (!info) {
|
9751 |
|
9752 | this.onError({
|
9753 | code: 'unknown-command',
|
9754 | arg: command,
|
9755 | });
|
9756 | return [new ErrorAtom(command)];
|
9757 | }
|
9758 | if (info.ifMode && !info.ifMode.includes(this.parseMode)) {
|
9759 |
|
9760 |
|
9761 | return [];
|
9762 | }
|
9763 |
|
9764 |
|
9765 |
|
9766 |
|
9767 |
|
9768 |
|
9769 |
|
9770 |
|
9771 |
|
9772 |
|
9773 |
|
9774 |
|
9775 | const savedMode = this.parseMode;
|
9776 | if (info.applyMode) {
|
9777 | this.parseMode = info.applyMode;
|
9778 | }
|
9779 | const initialIndex = this.index;
|
9780 | const [deferredArg, args] = this.parseArguments(info);
|
9781 | this.parseMode = savedMode;
|
9782 | if (!args)
|
9783 | return null;
|
9784 | if (info.applyMode && !info.applyStyle && !info.createAtom) {
|
9785 | return args[0];
|
9786 | }
|
9787 | if (info.infix) {
|
9788 |
|
9789 |
|
9790 |
|
9791 | this.onError({
|
9792 | code: 'too-many-infix-commands',
|
9793 | arg: command,
|
9794 | });
|
9795 | return null;
|
9796 | }
|
9797 |
|
9798 | if (typeof info.createAtom === 'function') {
|
9799 | result = info.createAtom(command, args, this.style, {
|
9800 | colorMap: this.colorMap,
|
9801 | backgroundColorMap: this.backgroundColorMap,
|
9802 | });
|
9803 | if (deferredArg) {
|
9804 | result.body = (_c = this.parseArgument(deferredArg)) !== null && _c !== void 0 ? _c : undefined;
|
9805 | }
|
9806 | }
|
9807 | else if (typeof info.applyStyle === 'function') {
|
9808 | const style = info.applyStyle(command, args, {
|
9809 | colorMap: this.colorMap,
|
9810 | backgroundColorMap: this.backgroundColorMap,
|
9811 | });
|
9812 |
|
9813 |
|
9814 | const savedMode = this.parseMode;
|
9815 | if (info.applyMode) {
|
9816 |
|
9817 | this.parseMode = info.applyMode;
|
9818 | }
|
9819 |
|
9820 | if (deferredArg) {
|
9821 |
|
9822 | const saveStyle = this.style;
|
9823 | this.style = { ...this.style, ...style };
|
9824 | const atoms = this.parseArgument(deferredArg);
|
9825 | this.style = saveStyle;
|
9826 | this.parseMode = savedMode;
|
9827 | return atoms;
|
9828 | }
|
9829 |
|
9830 | this.style = { ...this.style, ...style };
|
9831 | this.parseMode = savedMode;
|
9832 | }
|
9833 | else {
|
9834 |
|
9835 | const style = { ...this.style };
|
9836 |
|
9837 | if (info.variant) {
|
9838 | style.variant = info.variant;
|
9839 | }
|
9840 | result = new Atom((_d = info.type) !== null && _d !== void 0 ? _d : 'mop', {
|
9841 | command,
|
9842 | style,
|
9843 | value: info.codepoint ? String.fromCodePoint(info.codepoint) : command,
|
9844 | mode: (_e = info.applyMode) !== null && _e !== void 0 ? _e : this.parseMode,
|
9845 | });
|
9846 | }
|
9847 | if (result instanceof Atom &&
|
9848 | !result.verbatimLatex &&
|
9849 | !/^\\(llap|rlap|class|cssId|htmlData)$/.test(command)) {
|
9850 | result.verbatimLatex =
|
9851 | ((_f = result.command) !== null && _f !== void 0 ? _f : '') +
|
9852 | tokensToString(this.tokens.slice(initialIndex, this.index));
|
9853 | if (result.isFunction && this.smartFence) {
|
9854 |
|
9855 |
|
9856 | const smartFence = this.scanSmartFence();
|
9857 | if (smartFence)
|
9858 | return [result, smartFence];
|
9859 | }
|
9860 | }
|
9861 | if (!result)
|
9862 | return null;
|
9863 | return [result];
|
9864 | }
|
9865 | parseLiteral(literal) {
|
9866 | const result = Mode.createAtom(this.parseMode, literal, {
|
9867 | ...this.style,
|
9868 | });
|
9869 | if (!result)
|
9870 | return null;
|
9871 | if (result.isFunction && this.smartFence) {
|
9872 |
|
9873 |
|
9874 | const smartFence = this.scanSmartFence();
|
9875 | if (smartFence)
|
9876 | return [result, smartFence];
|
9877 | }
|
9878 | return [result];
|
9879 | }
|
9880 | parseSimpleToken() {
|
9881 | const token = this.get();
|
9882 | if (!token)
|
9883 | return null;
|
9884 | if (token === '<space>') {
|
9885 | if (this.parseMode === 'text') {
|
9886 | return [new TextAtom(' ', ' ', this.style)];
|
9887 | }
|
9888 | return null;
|
9889 | }
|
9890 | if (token.startsWith('\\'))
|
9891 | return this.parseCommand(token);
|
9892 | if (isLiteral(token))
|
9893 | return this.parseLiteral(token);
|
9894 | if (token === '<}>') {
|
9895 | this.onError({ latex: '', code: 'unbalanced-braces' });
|
9896 | }
|
9897 | else {
|
9898 | this.onError({
|
9899 | latex: '',
|
9900 | code: 'unexpected-token',
|
9901 | arg: token,
|
9902 | });
|
9903 | }
|
9904 | return null;
|
9905 | }
|
9906 | |
9907 |
|
9908 |
|
9909 |
|
9910 | scanMacro(macro) {
|
9911 | var _a, _b;
|
9912 | const macroName = macro.slice(1);
|
9913 | if (!this.macros || !this.macros[macroName])
|
9914 | return null;
|
9915 | const initialIndex = this.index;
|
9916 | const def = this.macros[macroName].def;
|
9917 | const argCount = this.macros[macroName].args;
|
9918 | const args = {};
|
9919 | for (let i = 1; i <= argCount; i++) {
|
9920 |
|
9921 |
|
9922 |
|
9923 | args[i] = this.matchLiteralArg();
|
9924 | }
|
9925 |
|
9926 | args['?'] = (_a = this.args) === null || _a === void 0 ? void 0 : _a.call(this, '?');
|
9927 |
|
9928 | return new MacroAtom(macro, {
|
9929 | expand: this.macros[macroName].expand,
|
9930 | captureSelection: this.macros[macroName].captureSelection,
|
9931 | args: tokensToString(this.tokens.slice(initialIndex, this.index)),
|
9932 | body: parseLatex(def, {
|
9933 | parseMode: this.parseMode,
|
9934 | args: (arg) => args[arg],
|
9935 | macros: this.macros,
|
9936 | registers: (_b = this.currentContext.registers) !== null && _b !== void 0 ? _b : null,
|
9937 | mathstyle: this.currentContext.mathstyle,
|
9938 | colorMap: this.colorMap,
|
9939 | backgroundColorMap: this.backgroundColorMap,
|
9940 | onError: this.onError,
|
9941 | }),
|
9942 | });
|
9943 | }
|
9944 | |
9945 |
|
9946 |
|
9947 |
|
9948 | parseToken() {
|
9949 | var _a, _b, _c, _d;
|
9950 | let result = (_d = (_c = (_b = (_a = this.parseEnvironment()) !== null && _a !== void 0 ? _a : this.parseModeShift()) !== null && _b !== void 0 ? _b : this.parseModeSet()) !== null && _c !== void 0 ? _c : this.parseGroup()) !== null && _d !== void 0 ? _d : this.parseLeftRight();
|
9951 | if (result === null) {
|
9952 | if (this.parseSupSub())
|
9953 | return true;
|
9954 | if (this.parseLimits())
|
9955 | return true;
|
9956 | result = this.parseSimpleToken();
|
9957 | }
|
9958 |
|
9959 |
|
9960 |
|
9961 | if (isArray(result)) {
|
9962 | this.mathlist = this.mathlist.concat(result);
|
9963 | }
|
9964 | else if (result) {
|
9965 | this.mathlist.push(result);
|
9966 | }
|
9967 | return result !== null;
|
9968 | }
|
9969 | }
|
9970 |
|
9971 |
|
9972 |
|
9973 |
|
9974 |
|
9975 |
|
9976 |
|
9977 | function parseLatex(s, options) {
|
9978 | var _a, _b, _c, _d, _e, _f, _g, _h;
|
9979 | const parser = new Parser(tokenize(s, (_a = options === null || options === void 0 ? void 0 : options.args) !== null && _a !== void 0 ? _a : null), {
|
9980 | args: (_b = options === null || options === void 0 ? void 0 : options.args) !== null && _b !== void 0 ? _b : null,
|
9981 | macros: getMacros(options === null || options === void 0 ? void 0 : options.macros),
|
9982 | registers: (_c = options === null || options === void 0 ? void 0 : options.registers) !== null && _c !== void 0 ? _c : null,
|
9983 | mathstyle: (_d = options === null || options === void 0 ? void 0 : options.mathstyle) !== null && _d !== void 0 ? _d : 'displaystyle',
|
9984 | colorMap: (_e = options === null || options === void 0 ? void 0 : options.colorMap) !== null && _e !== void 0 ? _e : defaultColorMap,
|
9985 | parseMode: (_f = options === null || options === void 0 ? void 0 : options.parseMode) !== null && _f !== void 0 ? _f : 'math',
|
9986 | smartFence: options === null || options === void 0 ? void 0 : options.smartFence,
|
9987 | backgroundColorMap: (_h = (_g = options === null || options === void 0 ? void 0 : options.backgroundColorMap) !== null && _g !== void 0 ? _g : options === null || options === void 0 ? void 0 : options.colorMap) !== null && _h !== void 0 ? _h : defaultBackgroundColorMap,
|
9988 | onError: (err) => {
|
9989 | if (typeof (options === null || options === void 0 ? void 0 : options.onError) === 'function') {
|
9990 | options.onError({ ...err, latex: s });
|
9991 | }
|
9992 | },
|
9993 | });
|
9994 | let atoms = [];
|
9995 | while (!parser.end()) {
|
9996 | const more = parser.parse();
|
9997 | if (!more)
|
9998 | break;
|
9999 | atoms = atoms.concat(more);
|
10000 | }
|
10001 | return atoms;
|
10002 | }
|
10003 | function convertToGlue(value, registers) {
|
10004 |
|
10005 | if (typeof value === 'object' && 'glue' in value)
|
10006 | return value;
|
10007 | if (typeof value === 'object' && 'dimension' in value) {
|
10008 | return { glue: value };
|
10009 | }
|
10010 | if (typeof value === 'number')
|
10011 | return { glue: { dimension: value } };
|
10012 |
|
10013 | const parser = new Parser(tokenize(value), { registers });
|
10014 | return parser.scanGlue();
|
10015 | }
|
10016 |
|
10017 | function convertToDimension(value, registers) {
|
10018 | if (typeof value === 'number')
|
10019 | return { dimension: value, unit: 'pt' };
|
10020 | if (typeof value === 'object' && 'glue' in value) {
|
10021 | value = value.glue;
|
10022 | }
|
10023 | if (typeof value === 'object' && 'dimension' in value) {
|
10024 | return value;
|
10025 | }
|
10026 |
|
10027 | const parser = new Parser(tokenize(value), { registers });
|
10028 | return parser.scanDimen();
|
10029 | }
|
10030 |
|
10031 | class AccentAtom extends Atom {
|
10032 | constructor(command, body, options) {
|
10033 | super('accent', { command, style: options.style });
|
10034 | if (options.accentChar) {
|
10035 | this.accent = options.accentChar;
|
10036 | }
|
10037 | else {
|
10038 | this.svgAccent = options === null || options === void 0 ? void 0 : options.svgAccent;
|
10039 | }
|
10040 | this.body = body;
|
10041 | this.skipBoundary = true;
|
10042 |
|
10043 |
|
10044 |
|
10045 |
|
10046 | }
|
10047 | render(parentContext) {
|
10048 | var _a;
|
10049 | const context = new Context(parentContext, this.style, 'cramp');
|
10050 |
|
10051 |
|
10052 |
|
10053 |
|
10054 | const base = (_a = Atom.createBox(context, this.body)) !== null && _a !== void 0 ? _a : new Box(null);
|
10055 |
|
10056 |
|
10057 |
|
10058 |
|
10059 |
|
10060 |
|
10061 |
|
10062 |
|
10063 |
|
10064 | let skew = 0;
|
10065 | if (!this.hasEmptyBranch('body') &&
|
10066 | this.body.length === 2 &&
|
10067 | this.body[1].isCharacterBox()) {
|
10068 | skew = base.skew;
|
10069 | }
|
10070 |
|
10071 |
|
10072 |
|
10073 | let clearance = Math.min(base.height, X_HEIGHT);
|
10074 |
|
10075 |
|
10076 |
|
10077 | let accentBox;
|
10078 | if (this.svgAccent) {
|
10079 | accentBox = makeSVGBox(this.svgAccent);
|
10080 | clearance = context.metrics.bigOpSpacing1 - clearance;
|
10081 | }
|
10082 | else if (this.accent) {
|
10083 |
|
10084 | const accent = new Box(this.accent, { fontFamily: 'Main-Regular' });
|
10085 |
|
10086 |
|
10087 | accent.italic = 0;
|
10088 |
|
10089 |
|
10090 |
|
10091 | const vecClass = this.accent === 0x20d7 ? ' ML__accent-vec' : '';
|
10092 | accentBox = new Box(new Box(accent), {
|
10093 | classes: 'ML__accent-body' + vecClass,
|
10094 | });
|
10095 | }
|
10096 |
|
10097 |
|
10098 |
|
10099 |
|
10100 |
|
10101 |
|
10102 | accentBox = new VBox({
|
10103 | shift: 0,
|
10104 | children: [
|
10105 | { box: new Box(base) },
|
10106 | -clearance,
|
10107 | {
|
10108 | box: accentBox,
|
10109 | marginLeft: base.left + 2 * skew,
|
10110 | classes: ['ML__center'],
|
10111 | },
|
10112 | ],
|
10113 | });
|
10114 | const result = new Box(accentBox, { newList: true, type: 'mord' });
|
10115 | if (this.caret)
|
10116 | result.caret = this.caret;
|
10117 | this.bind(context, result.wrap(context));
|
10118 | return this.attachSupsub(context, { base: result });
|
10119 | }
|
10120 | }
|
10121 |
|
10122 |
|
10123 |
|
10124 |
|
10125 |
|
10126 |
|
10127 |
|
10128 |
|
10129 | class OverunderAtom extends Atom {
|
10130 | constructor(command, options) {
|
10131 | var _a, _b, _c;
|
10132 | super('overunder', {
|
10133 | command,
|
10134 | serialize: options.serialize,
|
10135 | style: options.style,
|
10136 | });
|
10137 | this.skipBoundary = (_a = options.skipBoundary) !== null && _a !== void 0 ? _a : true;
|
10138 | this.subsupPlacement = options.supsubPlacement;
|
10139 | this.body = options.body;
|
10140 | this.svgAbove = options.svgAbove;
|
10141 | this.svgBelow = options.svgBelow;
|
10142 | this.svgBody = options.svgBody;
|
10143 | this.above = options.above;
|
10144 | this.below = options.below;
|
10145 | this.boxType = (_b = options.boxType) !== null && _b !== void 0 ? _b : 'mord';
|
10146 | this.padded = (_c = options.padded) !== null && _c !== void 0 ? _c : false;
|
10147 | }
|
10148 | |
10149 |
|
10150 |
|
10151 |
|
10152 |
|
10153 |
|
10154 |
|
10155 |
|
10156 |
|
10157 | render(parentContext) {
|
10158 | let body = this.svgBody
|
10159 | ? makeSVGBox(this.svgBody)
|
10160 | : Atom.createBox(parentContext, this.body, { newList: true });
|
10161 | const annotationContext = new Context(parentContext, this.style, 'scriptstyle');
|
10162 | let above = null;
|
10163 |
|
10164 | if (this.svgAbove) {
|
10165 | above = makeSVGBox(this.svgAbove);
|
10166 |
|
10167 |
|
10168 | }
|
10169 | else if (this.above) {
|
10170 | above = Atom.createBox(annotationContext, this.above, { newList: true });
|
10171 | }
|
10172 | let below = null;
|
10173 |
|
10174 | if (this.svgBelow) {
|
10175 | below = makeSVGBox(this.svgBelow);
|
10176 |
|
10177 |
|
10178 | }
|
10179 | else if (this.below) {
|
10180 | below = Atom.createBox(annotationContext, this.below, { newList: true });
|
10181 | }
|
10182 | if (this.padded) {
|
10183 |
|
10184 | body = new Box([
|
10185 | makeNullDelimiter(parentContext, 'mopen'),
|
10186 | body,
|
10187 | makeNullDelimiter(parentContext, 'mclose'),
|
10188 | ], { newList: true });
|
10189 | }
|
10190 |
|
10191 | let base = makeOverunderStack(parentContext, {
|
10192 | base: body,
|
10193 | above,
|
10194 |
|
10195 | below,
|
10196 |
|
10197 | type: this.boxType === 'mbin' || this.boxType === 'mrel'
|
10198 | ? this.boxType
|
10199 | : 'mord',
|
10200 | });
|
10201 | if (!base)
|
10202 | return null;
|
10203 | if (this.subsupPlacement === 'over-under') {
|
10204 | base = this.attachLimits(parentContext, { base, type: base.type });
|
10205 | }
|
10206 | else {
|
10207 | base = this.attachSupsub(parentContext, { base });
|
10208 | }
|
10209 | if (this.caret)
|
10210 | base.caret = this.caret;
|
10211 |
|
10212 | return this.bind(parentContext, base);
|
10213 | }
|
10214 | }
|
10215 |
|
10216 |
|
10217 |
|
10218 |
|
10219 |
|
10220 |
|
10221 |
|
10222 |
|
10223 | function makeOverunderStack(context, options) {
|
10224 |
|
10225 | if (!options.base)
|
10226 | return null;
|
10227 |
|
10228 | if (!options.above && !options.below) {
|
10229 | const box = new Box(options.base, { type: options.type });
|
10230 | box.setStyle('position', 'relative');
|
10231 | return box;
|
10232 | }
|
10233 | let aboveShift = 0;
|
10234 | if (options.above) {
|
10235 | aboveShift = -options.above.depth + context.metrics.bigOpSpacing2;
|
10236 | }
|
10237 | let result = null;
|
10238 | const base = options.base;
|
10239 | const baseShift = 0;
|
10240 |
|
10241 |
|
10242 | if (options.below && options.above) {
|
10243 | const bottom = context.metrics.bigOpSpacing5 +
|
10244 | options.below.height +
|
10245 | options.below.depth +
|
10246 | base.depth +
|
10247 | baseShift;
|
10248 | result = new VBox({
|
10249 | bottom,
|
10250 | children: [
|
10251 | context.metrics.bigOpSpacing5,
|
10252 | { box: options.below, classes: ['ML__center'] },
|
10253 | { box: base, classes: ['ML__center'] },
|
10254 | aboveShift,
|
10255 | { box: options.above, classes: ['ML__center'] },
|
10256 | context.metrics.bigOpSpacing5,
|
10257 | ],
|
10258 | });
|
10259 | }
|
10260 | else if (options.below) {
|
10261 | result = new VBox({
|
10262 | top: base.height - baseShift,
|
10263 | children: [
|
10264 | context.metrics.bigOpSpacing5,
|
10265 | { box: options.below, classes: ['ML__center'] },
|
10266 | { box: base, classes: ['ML__center'] },
|
10267 | ],
|
10268 | });
|
10269 | }
|
10270 | else if (options.above) {
|
10271 | result = new VBox({
|
10272 | bottom: base.depth + baseShift,
|
10273 | children: [
|
10274 |
|
10275 | { box: base, classes: ['ML__center'] },
|
10276 | aboveShift,
|
10277 | { box: options.above, classes: ['ML__center'] },
|
10278 | context.metrics.bigOpSpacing5,
|
10279 | ],
|
10280 | });
|
10281 | }
|
10282 | return new Box(result, { type: options.type });
|
10283 | }
|
10284 |
|
10285 | class BoxAtom extends Atom {
|
10286 | constructor(command, body, options) {
|
10287 | super('box', {
|
10288 | command,
|
10289 | serialize: options.serialize,
|
10290 | style: options.style,
|
10291 | });
|
10292 | this.body = body;
|
10293 | this.framecolor = options.framecolor;
|
10294 | this.verbatimFramecolor = options.verbatimBackgroundcolor;
|
10295 | this.backgroundcolor = options.backgroundcolor;
|
10296 | this.verbatimBackgroundcolor = options.verbatimBackgroundcolor;
|
10297 | this.padding = options.padding;
|
10298 | this.border = options.border;
|
10299 | }
|
10300 | render(parentContext) {
|
10301 | const context = new Context(parentContext, this.style);
|
10302 | const fboxsep = convertDimensionToEm(context.getRegisterAsDimension('fboxsep'));
|
10303 |
|
10304 | const padding = this.padding === undefined
|
10305 | ? fboxsep
|
10306 | : convertDimensionToEm(convertToDimension(this.padding, parentContext.registers));
|
10307 |
|
10308 | const content = Atom.createBox(parentContext, this.body);
|
10309 | if (!content)
|
10310 | return null;
|
10311 | content.setStyle('vertical-align', -content.height, 'em');
|
10312 | const base = new Box(content, { type: 'mord' });
|
10313 |
|
10314 |
|
10315 |
|
10316 |
|
10317 | const box = new Box(null, { classes: 'ML__box' });
|
10318 | box.height = base.height + padding;
|
10319 | box.depth = base.depth + padding;
|
10320 | box.setStyle('box-sizing', 'border-box');
|
10321 | box.setStyle('position', 'absolute');
|
10322 | box.setStyle('height', base.height + base.depth + 2 * padding, 'em');
|
10323 | if (padding === 0) {
|
10324 | box.setStyle('width', '100%');
|
10325 | }
|
10326 | else {
|
10327 | box.setStyle('width', `calc(100% + ${2 * padding}em)`);
|
10328 | box.setStyle('top', fboxsep, 'em');
|
10329 | box.setStyle('left', -padding, 'em');
|
10330 | }
|
10331 | box.setStyle('z-index', '-1');
|
10332 | if (this.backgroundcolor) {
|
10333 | box.setStyle('background-color', this.backgroundcolor);
|
10334 | }
|
10335 | if (this.framecolor) {
|
10336 | box.setStyle('border', `${convertDimensionToEm(context.getRegisterAsDimension('fboxrule'))}em solid ${this.framecolor}`);
|
10337 | }
|
10338 | if (this.border)
|
10339 | box.setStyle('border', this.border);
|
10340 |
|
10341 | base.setStyle('display', 'inline-block');
|
10342 | base.setStyle('height', content.height + content.depth, 'em');
|
10343 | base.setStyle('vertical-align', -padding, 'em');
|
10344 |
|
10345 | const result = new Box([box, base]);
|
10346 |
|
10347 |
|
10348 | result.setStyle('position', 'relative');
|
10349 | result.setStyle('display', 'inline-block');
|
10350 | result.setStyle('line-height', 0);
|
10351 |
|
10352 | result.height = base.height + padding;
|
10353 | result.depth = base.depth + padding;
|
10354 | result.left = padding;
|
10355 | result.right = padding;
|
10356 | result.setStyle('height', base.height + padding, 'em');
|
10357 | result.setStyle('top', base.depth - base.height, 'em');
|
10358 | result.setStyle('vertical-align', base.depth + padding, 'em');
|
10359 | if (this.caret)
|
10360 | result.caret = this.caret;
|
10361 | return this.attachSupsub(parentContext, { base: result });
|
10362 | }
|
10363 | }
|
10364 |
|
10365 | class PhantomAtom extends Atom {
|
10366 | constructor(command, body, options) {
|
10367 | var _a, _b, _c, _d;
|
10368 | super('phantom', { command, style: options.style });
|
10369 | this.captureSelection = true;
|
10370 | this.body = body;
|
10371 | this.isInvisible = (_a = options.isInvisible) !== null && _a !== void 0 ? _a : false;
|
10372 | this.smashDepth = (_b = options.smashDepth) !== null && _b !== void 0 ? _b : false;
|
10373 | this.smashHeight = (_c = options.smashHeight) !== null && _c !== void 0 ? _c : false;
|
10374 | this.smashWidth = (_d = options.smashWidth) !== null && _d !== void 0 ? _d : false;
|
10375 | }
|
10376 | render(context) {
|
10377 | const phantom = new Context(context, { isPhantom: true });
|
10378 | if (!this.smashDepth && !this.smashHeight && !this.smashWidth) {
|
10379 | console.assert(this.isInvisible);
|
10380 | return Atom.createBox(phantom, this.body, { classes: 'inner' });
|
10381 | }
|
10382 | const content = Atom.createBox(this.isInvisible ? phantom : context, this.body);
|
10383 | if (!content)
|
10384 | return null;
|
10385 | if (this.smashWidth) {
|
10386 | const fix = new Box(null, { classes: 'fix' });
|
10387 | return new Box([content, fix], { classes: 'rlap' }).wrap(context);
|
10388 | }
|
10389 | if (!this.smashHeight && !this.smashDepth)
|
10390 | return content;
|
10391 | if (this.smashHeight)
|
10392 | content.height = 0;
|
10393 | if (this.smashDepth)
|
10394 | content.depth = 0;
|
10395 | if (content.children) {
|
10396 | for (const box of content.children) {
|
10397 | if (this.smashHeight)
|
10398 | box.height = 0;
|
10399 | if (this.smashDepth)
|
10400 | box.depth = 0;
|
10401 | }
|
10402 | }
|
10403 |
|
10404 |
|
10405 |
|
10406 | return new VBox({ firstBaseline: [{ box: content }] }, { type: 'mord' }).wrap(context);
|
10407 | }
|
10408 | }
|
10409 |
|
10410 | class DelimAtom extends Atom {
|
10411 | constructor(command, delim, options) {
|
10412 | super('delim', { command, style: options === null || options === void 0 ? void 0 : options.style });
|
10413 | this.value = delim;
|
10414 | this.size = options === null || options === void 0 ? void 0 : options.size;
|
10415 | }
|
10416 | render(_context) {
|
10417 | const box = new Box(null);
|
10418 | box.delim = this.value;
|
10419 | return box;
|
10420 | }
|
10421 | serialize(_options) {
|
10422 | if (this.value.length === 1) {
|
10423 | return this.command + this.value;
|
10424 | }
|
10425 | return this.command + '{' + this.value + '}';
|
10426 | }
|
10427 | }
|
10428 | class SizedDelimAtom extends Atom {
|
10429 | constructor(command, delim, options) {
|
10430 | super('sizeddelim', { command, style: options.style });
|
10431 | this.value = delim;
|
10432 | this.delimClass = options.delimClass;
|
10433 | this.size = options.size;
|
10434 | }
|
10435 | render(context) {
|
10436 | const result = this.bind(context, makeSizedDelim(this.value, this.size, context, {
|
10437 | classes: this.delimClass,
|
10438 | }));
|
10439 | if (!result)
|
10440 | return null;
|
10441 | if (this.caret)
|
10442 | result.caret = this.caret;
|
10443 | return result;
|
10444 | }
|
10445 | serialize(_options) {
|
10446 | if (this.value.length === 1) {
|
10447 | return this.command + this.value;
|
10448 | }
|
10449 | return this.command + '{' + this.value + '}';
|
10450 | }
|
10451 | }
|
10452 |
|
10453 | class LineAtom extends Atom {
|
10454 | constructor(command, body, options) {
|
10455 | super('line', { command, style: options.style });
|
10456 | this.skipBoundary = true;
|
10457 | this.body = body;
|
10458 | this.position = options.position;
|
10459 | }
|
10460 | render(parentContext) {
|
10461 |
|
10462 | const context = new Context(parentContext, this.style, 'cramp');
|
10463 | const inner = Atom.createBox(context, this.body);
|
10464 | if (!inner)
|
10465 | return null;
|
10466 | const ruleWidth = context.metrics.defaultRuleThickness / context.scalingFactor;
|
10467 | const line = new Box(null, { classes: this.position + '-line' });
|
10468 | line.height = ruleWidth;
|
10469 | line.maxFontSize = ruleWidth * 1.125 * context.scalingFactor;
|
10470 | let stack;
|
10471 | if (this.position === 'overline') {
|
10472 | stack = new VBox({
|
10473 | shift: 0,
|
10474 | children: [{ box: inner }, 3 * ruleWidth, { box: line }, ruleWidth],
|
10475 | });
|
10476 | }
|
10477 | else {
|
10478 | stack = new VBox({
|
10479 | top: inner.height,
|
10480 | children: [ruleWidth, { box: line }, 3 * ruleWidth, { box: inner }],
|
10481 | });
|
10482 | }
|
10483 | if (this.caret)
|
10484 | stack.caret = this.caret;
|
10485 | return new Box(stack, {
|
10486 | classes: this.position,
|
10487 | type: 'mord',
|
10488 | });
|
10489 | }
|
10490 | }
|
10491 |
|
10492 | class OverlapAtom extends Atom {
|
10493 | constructor(command, body, options) {
|
10494 | var _a, _b;
|
10495 | super('overlap', { command, style: options === null || options === void 0 ? void 0 : options.style });
|
10496 | this.skipBoundary = true;
|
10497 | if (typeof body === 'string') {
|
10498 | this.body = [new Atom('mord', { value: body })];
|
10499 | }
|
10500 | else {
|
10501 | this.body = body;
|
10502 | }
|
10503 | this.align = (_a = options === null || options === void 0 ? void 0 : options.align) !== null && _a !== void 0 ? _a : 'left';
|
10504 | this.boxType = (_b = options === null || options === void 0 ? void 0 : options.boxType) !== null && _b !== void 0 ? _b : 'mord';
|
10505 | }
|
10506 | render(context) {
|
10507 |
|
10508 |
|
10509 |
|
10510 |
|
10511 | const inner = Atom.createBox(context, this.body, { classes: 'inner' });
|
10512 | if (!inner)
|
10513 | return null;
|
10514 | if (this.caret)
|
10515 | inner.caret = this.caret;
|
10516 | return this.bind(context, new Box([inner, new Box(null, { classes: 'fix' })], {
|
10517 | classes: this.align === 'left' ? 'llap' : 'rlap',
|
10518 | type: this.boxType,
|
10519 | }));
|
10520 | }
|
10521 | }
|
10522 |
|
10523 |
|
10524 |
|
10525 |
|
10526 |
|
10527 |
|
10528 |
|
10529 |
|
10530 |
|
10531 |
|
10532 |
|
10533 |
|
10534 | class GenfracAtom extends Atom {
|
10535 | constructor(command, above, below, options) {
|
10536 | var _a, _b;
|
10537 | super('genfrac', {
|
10538 | style: options.style,
|
10539 | command,
|
10540 | serialize: options.serialize,
|
10541 | displayContainsHighlight: true,
|
10542 | });
|
10543 | this.above = above;
|
10544 | this.below = below;
|
10545 | this.hasBarLine = (_a = options === null || options === void 0 ? void 0 : options.hasBarLine) !== null && _a !== void 0 ? _a : true;
|
10546 | this.continuousFraction = (_b = options === null || options === void 0 ? void 0 : options.continuousFraction) !== null && _b !== void 0 ? _b : false;
|
10547 | this.numerPrefix = options === null || options === void 0 ? void 0 : options.numerPrefix;
|
10548 | this.denomPrefix = options === null || options === void 0 ? void 0 : options.denomPrefix;
|
10549 | this.mathstyleName = options === null || options === void 0 ? void 0 : options.mathstyleName;
|
10550 | this.leftDelim = options === null || options === void 0 ? void 0 : options.leftDelim;
|
10551 | this.rightDelim = options === null || options === void 0 ? void 0 : options.rightDelim;
|
10552 | }
|
10553 | serialize(options) {
|
10554 | return (this.command +
|
10555 | `{${this.aboveToLatex(options)}}` +
|
10556 | `{${this.belowToLatex(options)}}`);
|
10557 | }
|
10558 | render(context) {
|
10559 | var _a, _b;
|
10560 | const fracContext = new Context(context, this.style, this.mathstyleName);
|
10561 | const metrics = fracContext.metrics;
|
10562 | const numContext = new Context(fracContext, this.style, this.continuousFraction ? '' : 'numerator');
|
10563 | const numerBox = this.numerPrefix
|
10564 | ? new Box([new Box(this.numerPrefix), Atom.createBox(numContext, this.above)], { isTight: numContext.isTight, newList: true })
|
10565 | : (_a = Atom.createBox(numContext, this.above, { newList: true })) !== null && _a !== void 0 ? _a : new Box(null, { newList: true });
|
10566 | const denomContext = new Context(fracContext, this.style, this.continuousFraction ? '' : 'denominator');
|
10567 | const denomBox = this.denomPrefix
|
10568 | ? new Box([
|
10569 | new Box(this.denomPrefix),
|
10570 | Atom.createBox(denomContext, this.below, { newList: true }),
|
10571 | ])
|
10572 | : (_b = Atom.createBox(denomContext, this.below, { newList: true })) !== null && _b !== void 0 ? _b : new Box(null, { newList: true });
|
10573 | const ruleWidth = this.hasBarLine ? metrics.defaultRuleThickness : 0;
|
10574 |
|
10575 |
|
10576 |
|
10577 |
|
10578 |
|
10579 |
|
10580 |
|
10581 | let numerShift;
|
10582 | let clearance = 0;
|
10583 | let denomShift;
|
10584 | if (fracContext.isDisplayStyle) {
|
10585 | numerShift = metrics.num1;
|
10586 | clearance = ruleWidth > 0 ? 3 * ruleWidth : 7 * ruleWidth;
|
10587 | denomShift = metrics.denom1;
|
10588 | }
|
10589 | else {
|
10590 | if (ruleWidth > 0) {
|
10591 | numerShift = metrics.num2;
|
10592 | clearance = ruleWidth;
|
10593 | }
|
10594 | else {
|
10595 | numerShift = metrics.num3;
|
10596 | clearance = 3 * ruleWidth;
|
10597 | }
|
10598 | denomShift = metrics.denom2;
|
10599 | }
|
10600 | const numerDepth = numerBox.depth;
|
10601 | const denomHeight = denomBox.height;
|
10602 | let frac;
|
10603 | if (ruleWidth <= 0) {
|
10604 |
|
10605 |
|
10606 | const candidateClearance = numerShift - numerDepth - (denomHeight - denomShift);
|
10607 | if (candidateClearance < clearance) {
|
10608 | numerShift += (clearance - candidateClearance) / 2;
|
10609 | denomShift += (clearance - candidateClearance) / 2;
|
10610 | }
|
10611 | frac = new VBox({
|
10612 | individualShift: [
|
10613 | {
|
10614 | box: numerBox,
|
10615 | shift: -numerShift,
|
10616 | classes: ['ML__center'],
|
10617 | },
|
10618 | {
|
10619 | box: denomBox,
|
10620 | shift: denomShift,
|
10621 | classes: ['ML__center'],
|
10622 | },
|
10623 | ],
|
10624 | }).wrap(fracContext);
|
10625 | }
|
10626 | else {
|
10627 |
|
10628 |
|
10629 | const numerLine = AXIS_HEIGHT + ruleWidth / 2;
|
10630 | const denomLine = AXIS_HEIGHT - ruleWidth / 2;
|
10631 | if (numerShift < clearance + numerDepth + numerLine) {
|
10632 | numerShift = clearance + numerDepth + numerLine;
|
10633 | }
|
10634 | if (denomShift < clearance + denomHeight - denomLine) {
|
10635 | denomShift = clearance + denomHeight - denomLine;
|
10636 | }
|
10637 | const fracLine = new Box(null, {
|
10638 | classes: 'ML__frac-line',
|
10639 | mode: this.mode,
|
10640 | style: this.style,
|
10641 | });
|
10642 |
|
10643 |
|
10644 | fracLine.height = ruleWidth / 2;
|
10645 | fracLine.depth = ruleWidth / 2;
|
10646 | frac = new VBox({
|
10647 | individualShift: [
|
10648 | {
|
10649 | box: denomBox,
|
10650 | shift: denomShift,
|
10651 | classes: ['ML__center'],
|
10652 | },
|
10653 | { box: fracLine, shift: -denomLine },
|
10654 | {
|
10655 | box: numerBox,
|
10656 | shift: -numerShift,
|
10657 | classes: ['ML__center'],
|
10658 | },
|
10659 | ],
|
10660 | }).wrap(fracContext);
|
10661 | }
|
10662 |
|
10663 | const delimSize = fracContext.isDisplayStyle
|
10664 | ? metrics.delim1
|
10665 | : metrics.delim2;
|
10666 |
|
10667 | const leftDelim = this.leftDelim
|
10668 | ? this.bind(context, makeCustomSizedDelim('mopen', this.leftDelim, delimSize, true, context, { style: this.style, mode: this.mode }))
|
10669 | : makeNullDelimiter(fracContext, 'mopen');
|
10670 | let rightDelim = null;
|
10671 | if (this.continuousFraction) {
|
10672 |
|
10673 | rightDelim = new Box(null, { type: 'mclose' });
|
10674 | }
|
10675 | else if (!this.rightDelim) {
|
10676 | rightDelim = makeNullDelimiter(fracContext, 'mclose');
|
10677 | }
|
10678 | else {
|
10679 | rightDelim = this.bind(context, makeCustomSizedDelim('mclose', this.rightDelim, delimSize, true, context, { style: this.style, mode: this.mode }));
|
10680 | }
|
10681 |
|
10682 |
|
10683 | const result = this.bind(context, new Box([leftDelim, frac, rightDelim], {
|
10684 | isTight: fracContext.isTight,
|
10685 | type: 'mord',
|
10686 | classes: 'mfrac',
|
10687 | }));
|
10688 | if (!result)
|
10689 | return null;
|
10690 | if (this.caret)
|
10691 | result.caret = this.caret;
|
10692 | return this.attachSupsub(context, { base: result });
|
10693 | }
|
10694 | }
|
10695 |
|
10696 | class RuleAtom extends Atom {
|
10697 | constructor(command, options) {
|
10698 | var _a;
|
10699 | super('rule', { command, style: options.style });
|
10700 | this.shift = (_a = options.shift) !== null && _a !== void 0 ? _a : { dimension: 0 };
|
10701 | this.height = options.height;
|
10702 | this.width = options.width;
|
10703 | }
|
10704 | render(parentContext) {
|
10705 |
|
10706 |
|
10707 |
|
10708 | const context = new Context(parentContext, this.style, 'textstyle');
|
10709 | const shift = convertDimensionToEm(this.shift);
|
10710 | const width = convertDimensionToEm(this.width);
|
10711 | const height = convertDimensionToEm(this.height);
|
10712 | const result = new Box(null, { classes: 'rule', type: 'mord' });
|
10713 | result.setStyle('border-right-width', width, 'em');
|
10714 | result.setStyle('border-top-width', height, 'em');
|
10715 | result.setStyle('border-color', this.style.color);
|
10716 | result.setStyle('vertical-align', shift, 'em');
|
10717 | if (context.isSelected)
|
10718 | result.setStyle('opacity', '50%');
|
10719 | result.width = width;
|
10720 | result.height = height + shift;
|
10721 | result.depth = -shift;
|
10722 | this.bind(parentContext, result);
|
10723 | if (this.caret)
|
10724 | result.caret = this.caret;
|
10725 | return result.wrap(context);
|
10726 | }
|
10727 | serialize(_options) {
|
10728 | var _a;
|
10729 | let result = (_a = this.command) !== null && _a !== void 0 ? _a : '';
|
10730 | if (this.shift) {
|
10731 | result += `[${serializeDimension(this.shift)}]`;
|
10732 | }
|
10733 | result += `{${serializeDimension(this.width)}}{${serializeDimension(this.height)}}`;
|
10734 | return result;
|
10735 | }
|
10736 | }
|
10737 |
|
10738 |
|
10739 |
|
10740 |
|
10741 | class OperatorAtom extends Atom {
|
10742 | constructor(command, symbol, options) {
|
10743 | var _a, _b;
|
10744 | super((_a = options.type) !== null && _a !== void 0 ? _a : 'mop', {
|
10745 | command,
|
10746 | style: options.style,
|
10747 | isFunction: options === null || options === void 0 ? void 0 : options.isFunction,
|
10748 | });
|
10749 | if (typeof symbol === 'string') {
|
10750 | this.value = symbol;
|
10751 | }
|
10752 | else {
|
10753 | this.body = symbol;
|
10754 | }
|
10755 | this.captureSelection = options.captureSelection;
|
10756 | this.variant = options === null || options === void 0 ? void 0 : options.variant;
|
10757 | this.variantStyle = options === null || options === void 0 ? void 0 : options.variantStyle;
|
10758 | this.subsupPlacement = options === null || options === void 0 ? void 0 : options.limits;
|
10759 | this.isExtensibleSymbol = (_b = options === null || options === void 0 ? void 0 : options.isExtensibleSymbol) !== null && _b !== void 0 ? _b : false;
|
10760 | }
|
10761 | render(context) {
|
10762 | var _a;
|
10763 | let base;
|
10764 | let baseShift = 0;
|
10765 | let slant = 0;
|
10766 | if (this.isExtensibleSymbol) {
|
10767 |
|
10768 |
|
10769 | const large = context.isDisplayStyle && this.value !== '\\smallint';
|
10770 | base = new Box(this.value, {
|
10771 | fontFamily: large ? 'Size2-Regular' : 'Size1-Regular',
|
10772 | classes: 'op-symbol ' + (large ? 'large-op' : 'small-op'),
|
10773 | type: 'mop',
|
10774 | maxFontSize: context.scalingFactor,
|
10775 | });
|
10776 | if (!base)
|
10777 | return null;
|
10778 |
|
10779 |
|
10780 |
|
10781 |
|
10782 |
|
10783 | baseShift =
|
10784 | (base.height - base.depth) / 2 - AXIS_HEIGHT * context.scalingFactor;
|
10785 |
|
10786 | slant = base.italic;
|
10787 | base.setStyle('color', this.style.color);
|
10788 | base.setStyle('background-color', this.style.backgroundColor);
|
10789 | }
|
10790 | else if (this.body) {
|
10791 |
|
10792 | base = Atom.createBox(context, this.body, { newList: true });
|
10793 | if (!base)
|
10794 | return null;
|
10795 | base.setStyle('color', this.style.color);
|
10796 | base.setStyle('background-color', this.style.backgroundColor);
|
10797 | }
|
10798 | else {
|
10799 |
|
10800 |
|
10801 | console.assert(this.type === 'mop');
|
10802 |
|
10803 |
|
10804 | base = new Box(this.value, {
|
10805 | type: 'mop',
|
10806 | mode: 'math',
|
10807 | maxFontSize: context.scalingFactor,
|
10808 | style: {
|
10809 | color: this.style.color,
|
10810 | backgroundColor: this.style.backgroundColor,
|
10811 | letterShapeStyle: context.letterShapeStyle,
|
10812 | variant: this.variant,
|
10813 | variantStyle: this.variantStyle,
|
10814 | },
|
10815 | });
|
10816 | }
|
10817 | if (this.isExtensibleSymbol)
|
10818 | base.setTop(baseShift);
|
10819 | let result = base;
|
10820 | if (this.superscript || this.subscript) {
|
10821 | const limits = (_a = this.subsupPlacement) !== null && _a !== void 0 ? _a : 'auto';
|
10822 | result =
|
10823 | limits === 'over-under' || (limits === 'auto' && context.isDisplayStyle)
|
10824 | ? this.attachLimits(context, { base, baseShift, slant })
|
10825 | : this.attachSupsub(context, { base });
|
10826 | }
|
10827 | if (this.caret)
|
10828 | result.caret = this.caret;
|
10829 |
|
10830 |
|
10831 | return new Box(this.bind(context, result), {
|
10832 | type: 'mop',
|
10833 | classes: 'op-group',
|
10834 | });
|
10835 | }
|
10836 | serialize(options) {
|
10837 | var _a;
|
10838 | const result = [];
|
10839 | if (this.value !== '\u200B') {
|
10840 |
|
10841 | result.push(this.command === '\\mathop' || this.command === '\\operatorname'
|
10842 | ? this.command + `{${this.bodyToLatex(options)}}`
|
10843 | : (_a = this.command) !== null && _a !== void 0 ? _a : '');
|
10844 | if (this.explicitSubsupPlacement) {
|
10845 | if (this.subsupPlacement === 'over-under')
|
10846 | result.push('\\limits');
|
10847 | if (this.subsupPlacement === 'adjacent')
|
10848 | result.push('\\nolimits');
|
10849 | if (this.subsupPlacement === 'auto')
|
10850 | result.push('\\displaylimits');
|
10851 | }
|
10852 | }
|
10853 | result.push(this.supsubToLatex(options));
|
10854 | return joinLatex(result);
|
10855 | }
|
10856 | }
|
10857 |
|
10858 | defineFunction('ensuremath', '{:math}', {
|
10859 | createAtom: (_name, args, style) => new GroupAtom(args[0], {
|
10860 | mode: 'math',
|
10861 | latexOpen: '\\ensuremath{',
|
10862 | latexClose: '}',
|
10863 | style,
|
10864 |
|
10865 | }),
|
10866 | });
|
10867 | defineFunction('color', '{:string}', {
|
10868 | applyStyle: (_name, args, options) => {
|
10869 | var _a, _b;
|
10870 | const color = args[0];
|
10871 | return {
|
10872 | verbatimColor: args[0],
|
10873 | color: (_b = (_a = options.colorMap) === null || _a === void 0 ? void 0 : _a.call(options, color)) !== null && _b !== void 0 ? _b : color,
|
10874 | };
|
10875 | },
|
10876 | });
|
10877 |
|
10878 |
|
10879 |
|
10880 | defineFunction('textcolor', '{:string}{content:auto*}', {
|
10881 | applyStyle: (_name, args, options) => {
|
10882 | var _a, _b;
|
10883 | const color = args[0];
|
10884 | return {
|
10885 | verbatimColor: color,
|
10886 | color: (_b = (_a = options.colorMap) === null || _a === void 0 ? void 0 : _a.call(options, color)) !== null && _b !== void 0 ? _b : color,
|
10887 | };
|
10888 | },
|
10889 | });
|
10890 |
|
10891 |
|
10892 |
|
10893 |
|
10894 |
|
10895 |
|
10896 |
|
10897 | defineFunction('boxed', '{content:math}', {
|
10898 | createAtom: (name, args, style) => new BoxAtom(name, args[0], {
|
10899 | framecolor: 'black',
|
10900 | style,
|
10901 | }),
|
10902 | });
|
10903 |
|
10904 |
|
10905 | defineFunction('colorbox', '{:string}{content:auto*}', {
|
10906 | applyMode: 'text',
|
10907 | applyStyle: (_name, args, options) => {
|
10908 | var _a, _b;
|
10909 | const color = args[0];
|
10910 | return {
|
10911 | verbatimBackgroundColor: args[0],
|
10912 | backgroundColor: (_b = (_a = options.backgroundColorMap) === null || _a === void 0 ? void 0 : _a.call(options, color)) !== null && _b !== void 0 ? _b : color,
|
10913 | };
|
10914 | },
|
10915 | });
|
10916 | defineFunction('fcolorbox', '{frame-color:string}{background-color:string}{content:auto}', {
|
10917 | applyMode: 'text',
|
10918 | createAtom: (name, args, style, options) => {
|
10919 | var _a, _b, _c, _d;
|
10920 | const color = args[0];
|
10921 | const bgColor = args[1];
|
10922 | return new BoxAtom(name, args[2], {
|
10923 | verbatimFramecolor: color,
|
10924 | framecolor: (_b = (_a = options.colorMap) === null || _a === void 0 ? void 0 : _a.call(options, color)) !== null && _b !== void 0 ? _b : color,
|
10925 | verbatimBackgroundcolor: args[1],
|
10926 | backgroundcolor: (_d = (_c = options.backgroundColorMap) === null || _c === void 0 ? void 0 : _c.call(options, bgColor)) !== null && _d !== void 0 ? _d : bgColor,
|
10927 | style,
|
10928 | serialize: (atom, options) => {
|
10929 | var _a, _b;
|
10930 | return `${atom.command}{${(_a = atom.verbatimFramecolor) !== null && _a !== void 0 ? _a : atom.framecolor}{${(_b = atom.verbatimBackgroundcolor) !== null && _b !== void 0 ? _b : atom.backgroundcolor}}{${atom.bodyToLatex(options)}}`;
|
10931 | },
|
10932 | });
|
10933 | },
|
10934 | });
|
10935 |
|
10936 |
|
10937 |
|
10938 |
|
10939 |
|
10940 |
|
10941 |
|
10942 | defineFunction('bbox', '[:bbox]{body:auto}', {
|
10943 | createAtom: (name, args, style) => {
|
10944 | if (args[0]) {
|
10945 | const arg = args[0];
|
10946 | return new BoxAtom(name, args[1], {
|
10947 | padding: arg.padding,
|
10948 | border: arg.border,
|
10949 | backgroundcolor: arg.backgroundcolor,
|
10950 | style,
|
10951 | serialize: (atom, options) => {
|
10952 | var _a;
|
10953 | let result = name;
|
10954 | if (Number.isFinite(atom.padding) ||
|
10955 | atom.border !== undefined ||
|
10956 | atom.backgroundcolor !== undefined) {
|
10957 | const bboxParameters = [];
|
10958 | if (atom.padding) {
|
10959 | bboxParameters.push(atom.padding);
|
10960 | }
|
10961 | if (atom.border) {
|
10962 | bboxParameters.push(`border: ${atom.border}`);
|
10963 | }
|
10964 | if (atom.verbatimBackgroundcolor || atom.backgroundcolor) {
|
10965 | bboxParameters.push((_a = atom.verbatimBackgroundcolor) !== null && _a !== void 0 ? _a : atom.backgroundcolor);
|
10966 | }
|
10967 | result += `[${bboxParameters.join(',')}]`;
|
10968 | }
|
10969 | return result + `{${atom.bodyToLatex(options)}}`;
|
10970 | },
|
10971 | });
|
10972 | }
|
10973 | return new BoxAtom(name, args[1], { style });
|
10974 | },
|
10975 | });
|
10976 |
|
10977 |
|
10978 |
|
10979 |
|
10980 | defineFunction(['displaystyle', 'textstyle', 'scriptstyle', 'scriptscriptstyle'], '{:rest}', {
|
10981 | createAtom: (name, args, style) => new GroupAtom(args[0], {
|
10982 | latexOpen: `{${name} `,
|
10983 | latexClose: '}',
|
10984 | style,
|
10985 | mathstyleName: name.slice(1),
|
10986 | }),
|
10987 | });
|
10988 |
|
10989 |
|
10990 |
|
10991 |
|
10992 |
|
10993 |
|
10994 |
|
10995 |
|
10996 | defineFunction([
|
10997 | 'tiny',
|
10998 | 'scriptsize',
|
10999 | 'footnotesize',
|
11000 | 'small',
|
11001 | 'normalsize',
|
11002 | 'large',
|
11003 | 'Large',
|
11004 | 'LARGE',
|
11005 | 'huge',
|
11006 | 'Huge',
|
11007 | ], '', {
|
11008 |
|
11009 |
|
11010 |
|
11011 | applyStyle: (name, _args) => {
|
11012 | return {
|
11013 | fontSize: {
|
11014 | '\\tiny': 1,
|
11015 | '\\scriptsize': 2,
|
11016 | '\\footnotesize': 3,
|
11017 | '\\small': 4,
|
11018 | '\\normalsize': 5,
|
11019 | '\\large': 6,
|
11020 | '\\Large': 7,
|
11021 | '\\LARGE': 8,
|
11022 | '\\huge': 9,
|
11023 | '\\Huge': 10,
|
11024 | }[name],
|
11025 | };
|
11026 | },
|
11027 | });
|
11028 |
|
11029 | defineFunction('fontseries', '{:string}', {
|
11030 | ifMode: 'text',
|
11031 | applyStyle: (_name, args) => {
|
11032 | return { fontSeries: args[0] };
|
11033 | },
|
11034 | });
|
11035 |
|
11036 | defineFunction('fontshape', '{:string}', {
|
11037 | ifMode: 'text',
|
11038 | applyStyle: (_name, args) => {
|
11039 | return { fontShape: args[0] };
|
11040 | },
|
11041 | });
|
11042 |
|
11043 | defineFunction('fontfamily', '{:string}', {
|
11044 | ifMode: 'text',
|
11045 | applyStyle: (_name, args) => {
|
11046 | return { fontFamily: args[0] };
|
11047 | },
|
11048 | });
|
11049 |
|
11050 |
|
11051 |
|
11052 | defineFunction('selectfont', '', {
|
11053 | ifMode: 'text',
|
11054 | applyStyle: (_name, _args) => {
|
11055 | return {};
|
11056 | },
|
11057 | });
|
11058 |
|
11059 |
|
11060 | defineFunction('bf', '', {
|
11061 | applyStyle: (_name, _args) => {
|
11062 | return { fontSeries: 'b', fontShape: 'n', fontFamily: 'cmr' };
|
11063 | },
|
11064 | });
|
11065 |
|
11066 |
|
11067 |
|
11068 |
|
11069 | defineFunction(['boldsymbol', 'bm'], '{:math*}', {
|
11070 | applyMode: 'math',
|
11071 | createAtom: (name, args, style) => new GroupAtom(args[0], {
|
11072 | latexOpen: `${name}{`,
|
11073 | latexClose: '}',
|
11074 | style,
|
11075 | customClass: 'ML__boldsymbol',
|
11076 | }),
|
11077 | });
|
11078 |
|
11079 | defineFunction('bold', '{:math*}', {
|
11080 | applyMode: 'math',
|
11081 | applyStyle: (_name, _args) => {
|
11082 | return { variantStyle: 'bold' };
|
11083 | },
|
11084 | });
|
11085 | defineFunction('bfseries', '', {
|
11086 | applyMode: 'text',
|
11087 | applyStyle: (_name, _args) => {
|
11088 | return { fontSeries: 'b' };
|
11089 | },
|
11090 | });
|
11091 | defineFunction('mdseries', '', {
|
11092 | applyMode: 'text',
|
11093 | applyStyle: (_name, _args) => {
|
11094 | return { fontSeries: 'm' };
|
11095 | },
|
11096 | });
|
11097 | defineFunction('upshape', '', {
|
11098 | applyMode: 'text',
|
11099 | applyStyle: (_name, _args) => {
|
11100 | return { fontShape: 'n' };
|
11101 | },
|
11102 | });
|
11103 | defineFunction('slshape', '', {
|
11104 | applyMode: 'text',
|
11105 | applyStyle: (_name, _args) => {
|
11106 | return { fontShape: 'sl' };
|
11107 | },
|
11108 | });
|
11109 |
|
11110 | defineFunction('scshape', '', {
|
11111 | applyMode: 'text',
|
11112 | applyStyle: (_name, _args) => {
|
11113 | return { fontShape: 'sc' };
|
11114 | },
|
11115 | });
|
11116 | defineFunction('textbf', '{:text*}', {
|
11117 | applyMode: 'text',
|
11118 | applyStyle: (_name, _args) => {
|
11119 | return { fontSeries: 'b' };
|
11120 | },
|
11121 | });
|
11122 | defineFunction('textmd', '{:text*}', {
|
11123 | applyMode: 'text',
|
11124 | applyStyle: (_name, _args) => {
|
11125 | return { fontSeries: 'm' };
|
11126 | },
|
11127 | });
|
11128 | defineFunction('textup', '{:text*}', {
|
11129 | applyMode: 'text',
|
11130 | applyStyle: (_name, _args) => {
|
11131 | return { fontShape: 'n' };
|
11132 | },
|
11133 | });
|
11134 |
|
11135 |
|
11136 | defineFunction('textnormal', '{:text*}', {
|
11137 | applyMode: 'text',
|
11138 | applyStyle: (_name, _args) => {
|
11139 | return { fontShape: 'n', fontSeries: 'm' };
|
11140 | },
|
11141 | });
|
11142 | defineFunction('textsl', '{:text*}', {
|
11143 | applyMode: 'text',
|
11144 | applyStyle: (_name, _args) => {
|
11145 | return { fontShape: 'sl' };
|
11146 | },
|
11147 | });
|
11148 | defineFunction('textit', '{:text*}', {
|
11149 | applyMode: 'text',
|
11150 | applyStyle: (_name, _args) => {
|
11151 | return { fontShape: 'it' };
|
11152 | },
|
11153 | });
|
11154 | defineFunction('textsc', '{:text*}', {
|
11155 | applyMode: 'text',
|
11156 | applyStyle: (_name, _args) => {
|
11157 | return { fontShape: 'sc' };
|
11158 | },
|
11159 | });
|
11160 | defineFunction('textrm', '{:text*}', {
|
11161 | applyMode: 'text',
|
11162 | applyStyle: (_name, _args) => {
|
11163 | return { fontFamily: 'roman' };
|
11164 | },
|
11165 | });
|
11166 | defineFunction('textsf', '{:text*}', {
|
11167 | applyMode: 'text',
|
11168 | applyStyle: (_name, _args) => {
|
11169 | return { fontFamily: 'sans-serif' };
|
11170 | },
|
11171 | });
|
11172 | defineFunction('texttt', '{:text*}', {
|
11173 | applyMode: 'text',
|
11174 | applyStyle: (_name, _args) => {
|
11175 | return { fontFamily: 'monospace' };
|
11176 | },
|
11177 | });
|
11178 |
|
11179 | defineFunction('mathbf', '{:math*}', {
|
11180 | applyMode: 'math',
|
11181 | applyStyle: (_name, _args) => {
|
11182 | return { variant: 'normal', variantStyle: 'bold' };
|
11183 | },
|
11184 | });
|
11185 | defineFunction('mathit', '{:math*}', {
|
11186 | applyMode: 'math',
|
11187 | applyStyle: (_name, _args) => {
|
11188 | return { variant: 'normal', variantStyle: 'italic' };
|
11189 | },
|
11190 | });
|
11191 |
|
11192 | defineFunction('mathbfit', '{:math*}', {
|
11193 | applyMode: 'math',
|
11194 | applyStyle: (_name, _args) => {
|
11195 | return { variant: 'normal', variantStyle: 'bolditalic' };
|
11196 | },
|
11197 | });
|
11198 | defineFunction('mathrm', '{:math*}', {
|
11199 | applyMode: 'math',
|
11200 | applyStyle: (_name, _args) => {
|
11201 | return { variant: 'normal', variantStyle: 'up' };
|
11202 | },
|
11203 | });
|
11204 | defineFunction('mathsf', '{:math*}', {
|
11205 | applyMode: 'math',
|
11206 | applyStyle: (_name, _args) => {
|
11207 | return { variant: 'sans-serif', variantStyle: 'up' };
|
11208 | },
|
11209 | });
|
11210 | defineFunction('mathtt', '{:math*}', {
|
11211 | applyMode: 'math',
|
11212 | applyStyle: (_name, _args) => {
|
11213 | return { variant: 'monospace', variantStyle: 'up' };
|
11214 | },
|
11215 | });
|
11216 | defineFunction('it', '', {
|
11217 | applyStyle: (_name, _args) => {
|
11218 | return {
|
11219 | fontSeries: 'm',
|
11220 | fontShape: 'it',
|
11221 | fontFamily: 'cmr',
|
11222 | variantStyle: 'italic',
|
11223 | };
|
11224 | },
|
11225 | });
|
11226 |
|
11227 | defineFunction('rmfamily', '', {
|
11228 | applyStyle: (_name, _args) => {
|
11229 | return { fontFamily: 'roman' };
|
11230 | },
|
11231 | });
|
11232 | defineFunction('sffamily', '', {
|
11233 | applyStyle: (_name, _args) => {
|
11234 | return { fontFamily: 'sans-serif' };
|
11235 | },
|
11236 | });
|
11237 | defineFunction('ttfamily', '', {
|
11238 | applyStyle: (_name, _args) => {
|
11239 | return { fontFamily: 'monospace' };
|
11240 | },
|
11241 | });
|
11242 |
|
11243 |
|
11244 |
|
11245 | defineFunction(['Bbb', 'mathbb'], '{:math*}', {
|
11246 | applyStyle: (_name, _args) => {
|
11247 | return { variant: 'double-struck', variantStyle: 'up' };
|
11248 | },
|
11249 | });
|
11250 | defineFunction(['frak', 'mathfrak'], '{:math*}', {
|
11251 | applyStyle: (_name, _args) => {
|
11252 | return { variant: 'fraktur', variantStyle: 'up' };
|
11253 | },
|
11254 | });
|
11255 | defineFunction('mathcal', '{:math*}', {
|
11256 | applyStyle: (_name, _args) => {
|
11257 | return { variant: 'calligraphic', variantStyle: 'up' };
|
11258 | },
|
11259 | });
|
11260 | defineFunction('mathscr', '{:math*}', {
|
11261 | applyStyle: (_name, _args) => {
|
11262 | return { variant: 'script', variantStyle: 'up' };
|
11263 | },
|
11264 | });
|
11265 |
|
11266 |
|
11267 |
|
11268 |
|
11269 |
|
11270 | defineFunction('mbox', '{:text}', {
|
11271 | ifMode: 'math',
|
11272 | createAtom: (_name, args, style) => new GroupAtom(args[0], {
|
11273 | changeMode: true,
|
11274 | style,
|
11275 | mode: 'text',
|
11276 | serialize: (atom, options) => `\\mbox{${atom.bodyToLatex({
|
11277 | ...options,
|
11278 | skipModeCommand: true,
|
11279 | })}}`,
|
11280 | }),
|
11281 | });
|
11282 | defineFunction('text', '{:text}', {
|
11283 | ifMode: 'math',
|
11284 | applyMode: 'text',
|
11285 | });
|
11286 |
|
11287 | defineFunction('class', '{name:string}{content:auto*}', {
|
11288 | createAtom: (_command, args, style) => new GroupAtom(args[1], {
|
11289 | customClass: args[0],
|
11290 | style,
|
11291 | }),
|
11292 | });
|
11293 |
|
11294 | defineFunction('cssId', '{id:string}{content:auto}', {
|
11295 | createAtom: (command, args, style) => new GroupAtom(args[1], {
|
11296 | cssId: args[0],
|
11297 | style,
|
11298 | }),
|
11299 | });
|
11300 |
|
11301 | defineFunction('htmlData', '{data:string}{content:auto}', {
|
11302 | createAtom: (command, args, style) => new GroupAtom(args[1], {
|
11303 | htmlData: args[0],
|
11304 | style,
|
11305 | }),
|
11306 | });
|
11307 |
|
11308 |
|
11309 |
|
11310 |
|
11311 |
|
11312 | defineFunction('em', '{:auto*}', {
|
11313 | createAtom: (command, args, style) => new GroupAtom(args[0], {
|
11314 | latexOpen: '\\em',
|
11315 | latexClose: '',
|
11316 | customClass: 'ML__emph',
|
11317 | style,
|
11318 | }),
|
11319 | });
|
11320 |
|
11321 | defineFunction('emph', '{:auto}', {
|
11322 | createAtom: (command, args, style) => new GroupAtom(args[0], {
|
11323 | latexOpen: '\\emph{',
|
11324 | latexClose: '}',
|
11325 | customClass: 'ML__emph',
|
11326 | style,
|
11327 | }),
|
11328 | });
|
11329 |
|
11330 | const DELIMITER_SIZES = {
|
11331 | '\\bigl': { mclass: 'mopen', size: 1 },
|
11332 | '\\Bigl': { mclass: 'mopen', size: 2 },
|
11333 | '\\biggl': { mclass: 'mopen', size: 3 },
|
11334 | '\\Biggl': { mclass: 'mopen', size: 4 },
|
11335 | '\\bigr': { mclass: 'mclose', size: 1 },
|
11336 | '\\Bigr': { mclass: 'mclose', size: 2 },
|
11337 | '\\biggr': { mclass: 'mclose', size: 3 },
|
11338 | '\\Biggr': { mclass: 'mclose', size: 4 },
|
11339 | '\\bigm': { mclass: 'mrel', size: 1 },
|
11340 | '\\Bigm': { mclass: 'mrel', size: 2 },
|
11341 | '\\biggm': { mclass: 'mrel', size: 3 },
|
11342 | '\\Biggm': { mclass: 'mrel', size: 4 },
|
11343 | '\\big': { mclass: 'mord', size: 1 },
|
11344 | '\\Big': { mclass: 'mord', size: 2 },
|
11345 | '\\bigg': { mclass: 'mord', size: 3 },
|
11346 | '\\Bigg': { mclass: 'mord', size: 4 },
|
11347 | };
|
11348 | defineFunction([
|
11349 | 'bigl',
|
11350 | 'Bigl',
|
11351 | 'biggl',
|
11352 | 'Biggl',
|
11353 | 'bigr',
|
11354 | 'Bigr',
|
11355 | 'biggr',
|
11356 | 'Biggr',
|
11357 | 'bigm',
|
11358 | 'Bigm',
|
11359 | 'biggm',
|
11360 | 'Biggm',
|
11361 | 'big',
|
11362 | 'Big',
|
11363 | 'bigg',
|
11364 | 'Bigg',
|
11365 | ], '{:delim}', {
|
11366 | createAtom: (name, args, style) => new SizedDelimAtom(name, args[0], {
|
11367 | size: DELIMITER_SIZES[name].size,
|
11368 | delimClass: DELIMITER_SIZES[name].mclass,
|
11369 | style,
|
11370 | }),
|
11371 | });
|
11372 | defineFunction([
|
11373 | 'hspace',
|
11374 | 'hspace*',
|
11375 |
|
11376 |
|
11377 | ], '{width:glue}', {
|
11378 | createAtom: (name, args, style) => {
|
11379 | var _a;
|
11380 | return new SpacingAtom(name, style, (_a = args[0]) !== null && _a !== void 0 ? _a : { glue: { dimension: 0 } });
|
11381 | },
|
11382 | });
|
11383 | defineFunction('mathop', '{:auto}', {
|
11384 | createAtom: (command, args, style) => new OperatorAtom(command, args[0], {
|
11385 | type: 'mop',
|
11386 | captureSelection: true,
|
11387 | limits: 'over-under',
|
11388 | isFunction: true,
|
11389 | style,
|
11390 | }),
|
11391 | });
|
11392 | defineFunction([
|
11393 | 'mathbin',
|
11394 | 'mathrel',
|
11395 | 'mathopen',
|
11396 | 'mathclose',
|
11397 | 'mathpunct',
|
11398 | 'mathord',
|
11399 | 'mathinner',
|
11400 | ], '{:auto}', {
|
11401 | createAtom: (command, args, style) => new OperatorAtom(command, args[0], {
|
11402 | type: {
|
11403 | '\\mathbin': 'mbin',
|
11404 | '\\mathrel': 'mrel',
|
11405 | '\\mathopen': 'mopen',
|
11406 | '\\mathclose': 'mclose',
|
11407 | '\\mathpunct': 'mpunct',
|
11408 | '\\mathord': 'mord',
|
11409 | '\\mathinner': 'minner',
|
11410 | }[command],
|
11411 | captureSelection: true,
|
11412 | style,
|
11413 | }),
|
11414 | });
|
11415 |
|
11416 |
|
11417 | defineFunction(['operatorname', 'operatorname*'], '{operator:math}', {
|
11418 | createAtom: (name, args, style) => {
|
11419 | const result = new OperatorAtom(name, args[0], {
|
11420 | isFunction: true,
|
11421 | limits: name === '\\operatorname' ? 'adjacent' : 'over-under',
|
11422 | style,
|
11423 | });
|
11424 | result.captureSelection = true;
|
11425 | |
11426 |
|
11427 |
|
11428 |
|
11429 |
|
11430 |
|
11431 |
|
11432 |
|
11433 |
|
11434 |
|
11435 |
|
11436 |
|
11437 |
|
11438 |
|
11439 |
|
11440 |
|
11441 |
|
11442 | if (result.body) {
|
11443 | result.body.forEach((x) => {
|
11444 | var _a;
|
11445 | if (x.type !== 'first') {
|
11446 | x.type = 'mord';
|
11447 | x.value = (_a = { '\u2217': '*', '\u2212': '-' }[x.value]) !== null && _a !== void 0 ? _a : x.value;
|
11448 | x.isFunction = false;
|
11449 | if (!x.style.variant && !x.style.variantStyle) {
|
11450 |
|
11451 |
|
11452 |
|
11453 | x.style.variant = 'main';
|
11454 | x.style.variantStyle = 'up';
|
11455 | }
|
11456 | }
|
11457 | });
|
11458 | }
|
11459 | return result;
|
11460 | },
|
11461 | });
|
11462 | class UnicodeAtom extends Atom {
|
11463 | constructor(arg, style) {
|
11464 | let codepoint = Number.parseInt(arg);
|
11465 | if (!Number.isFinite(codepoint))
|
11466 | codepoint = 0x2753;
|
11467 | super('mord', {
|
11468 | value: String.fromCodePoint(codepoint),
|
11469 | style,
|
11470 | });
|
11471 | this.codepoint = codepoint;
|
11472 | }
|
11473 | serialize(_options) {
|
11474 | return ('\\unicode"' +
|
11475 | ('000000' + this.codepoint.toString(16)).toUpperCase().slice(-6));
|
11476 | }
|
11477 | }
|
11478 | defineFunction('unicode', '{charcode:number}', {
|
11479 | createAtom: (name, args, style) => new UnicodeAtom(args[0], style),
|
11480 | });
|
11481 |
|
11482 | defineFunction('rule', '[raise:dimen]{width:dimen}{thickness:dimen}', {
|
11483 | createAtom: (name, args, style) => new RuleAtom(name, {
|
11484 | shift: args[0],
|
11485 | width: args[1],
|
11486 | height: args[2],
|
11487 | style,
|
11488 | }),
|
11489 | });
|
11490 |
|
11491 | defineFunction('overline', '{:auto}', {
|
11492 | createAtom: (name, args, style) => new LineAtom(name, args[0], {
|
11493 | position: 'overline',
|
11494 | style,
|
11495 | }),
|
11496 | });
|
11497 | defineFunction('underline', '{:auto}', {
|
11498 | createAtom: (name, args, style) => new LineAtom(name, args[0], {
|
11499 | position: 'underline',
|
11500 | style,
|
11501 | }),
|
11502 | });
|
11503 | function binRelType(atoms) {
|
11504 | if (atoms.length === 1) {
|
11505 | const atom = atoms[0];
|
11506 | if (atom.type === 'mbin')
|
11507 | return 'mbin';
|
11508 | if (atom.type === 'mrel')
|
11509 | return 'mrel';
|
11510 | }
|
11511 | return 'mord';
|
11512 | }
|
11513 | defineFunction('overset', '{above:auto}{base:auto}', {
|
11514 | createAtom: (name, args, style) => new OverunderAtom(name, {
|
11515 | above: args[0],
|
11516 | body: args[1],
|
11517 | skipBoundary: false,
|
11518 | style,
|
11519 | boxType: binRelType(args[1]),
|
11520 | serialize: (atom, options) => `${atom.command}{${atom.aboveToLatex(options)}}` +
|
11521 | `{${atom.bodyToLatex(options)}}`,
|
11522 | }),
|
11523 | });
|
11524 | defineFunction('underset', '{below:auto}{base:auto}', {
|
11525 | createAtom: (name, args, style) => new OverunderAtom(name, {
|
11526 | below: args[0],
|
11527 | body: args[1],
|
11528 | skipBoundary: false,
|
11529 | style,
|
11530 | boxType: binRelType(args[1]),
|
11531 | serialize: (atom, options) => `${name}{${atom.belowToLatex(options)}}` +
|
11532 | `{${atom.bodyToLatex(options)}}`,
|
11533 | }),
|
11534 | });
|
11535 | defineFunction('overunderset', '{above:auto}{below:auto}{base:auto}', {
|
11536 | createAtom: (name, args, style) => new OverunderAtom(name, {
|
11537 | above: args[0],
|
11538 | below: args[1],
|
11539 | body: args[2],
|
11540 | skipBoundary: false,
|
11541 | style,
|
11542 | boxType: binRelType(args[2]),
|
11543 | serialize: (atom, options) => `${atom.command}{${atom.aboveToLatex(options)}}` +
|
11544 | `{${atom.bodyToLatex(options)}}`,
|
11545 | }),
|
11546 | });
|
11547 |
|
11548 |
|
11549 |
|
11550 |
|
11551 | defineFunction(['stackrel', 'stackbin'], '[below:auto]{above:auto}{base:auto}', {
|
11552 | createAtom: (name, args, style) => new OverunderAtom(name, {
|
11553 | body: args[2],
|
11554 | above: args[1],
|
11555 | below: args[0],
|
11556 | skipBoundary: false,
|
11557 | style,
|
11558 | boxType: name === '\\stackrel' ? 'mrel' : 'mbin',
|
11559 | serialize: (atom, options) => `${atom.command}{${atom.aboveToLatex(options)}}` +
|
11560 | `{${atom.bodyToLatex(options)}}`,
|
11561 | }),
|
11562 | });
|
11563 | defineFunction(['overwithdelims', 'atopwithdelims'], '{numer:auto}{denom:auto}{left-delim:delim}{right-delim:delim}', {
|
11564 | infix: true,
|
11565 | createAtom: (name, args, style) => new GenfracAtom(name, args[0], args[1], {
|
11566 | leftDelim: args[2],
|
11567 | rightDelim: args[3],
|
11568 | hasBarLine: false,
|
11569 | style,
|
11570 | serialize: (atom, options) => `${atom.aboveToLatex(options)} ${atom.command}${atom.leftDelim}${atom.rightDelim}${atom.belowToLatex(options)}`,
|
11571 | }),
|
11572 | });
|
11573 | defineFunction('smash', '[:string]{:auto}', {
|
11574 | createAtom: (name, args, style) => {
|
11575 | if (!args[0]) {
|
11576 | return new PhantomAtom(name, args[1], {
|
11577 | smashHeight: true,
|
11578 | smashDepth: true,
|
11579 | style,
|
11580 | });
|
11581 | }
|
11582 | return new PhantomAtom(name, args[1], {
|
11583 | smashHeight: args[0].includes('t'),
|
11584 | smashDepth: args[0].includes('b'),
|
11585 | style,
|
11586 | });
|
11587 | },
|
11588 | });
|
11589 | defineFunction(['vphantom'], '{:auto*}', {
|
11590 | createAtom: (name, args, style) => new PhantomAtom(name, args[1], {
|
11591 | isInvisible: true,
|
11592 | smashWidth: true,
|
11593 | style,
|
11594 | }),
|
11595 | });
|
11596 | defineFunction(['hphantom'], '{:auto*}', {
|
11597 | createAtom: (name, args, style) => new PhantomAtom(name, args[1], {
|
11598 | isInvisible: true,
|
11599 | smashHeight: true,
|
11600 | smashDepth: true,
|
11601 | style,
|
11602 | }),
|
11603 | });
|
11604 | defineFunction(['phantom'], '{:auto*}', {
|
11605 | createAtom: (name, args, style) => new PhantomAtom(name, args[1], {
|
11606 | isInvisible: true,
|
11607 | style,
|
11608 | }),
|
11609 | });
|
11610 | defineFunction('not', '{:math}', {
|
11611 | createAtom: (name, args, style) => {
|
11612 | if (args.length < 1 || args[0] === null) {
|
11613 | return new Atom('mrel', { command: name, style, value: '\ue020' });
|
11614 | }
|
11615 | const arg = args[0];
|
11616 | return new GroupAtom([
|
11617 | new OverlapAtom(name, '\ue020', {
|
11618 | align: 'right',
|
11619 | style,
|
11620 | boxType: 'mrel',
|
11621 | }),
|
11622 | ...arg,
|
11623 | ], {
|
11624 | boxType: 'mrel',
|
11625 | captureSelection: true,
|
11626 | serialize: (atom, options) => {
|
11627 | const argLatex = Atom.serialize(arg, options);
|
11628 | if (argLatex.length === 1 && !/[a-zA-Z]/.test(argLatex)) {
|
11629 | return '\\not' + argLatex;
|
11630 | }
|
11631 | return `\\not{${argLatex}}`;
|
11632 | },
|
11633 | });
|
11634 | },
|
11635 | });
|
11636 | defineFunction(['ne', 'neq'], '', {
|
11637 | createAtom: (name, _args, style) => new GroupAtom([
|
11638 | new OverlapAtom(name, '\ue020', {
|
11639 | align: 'right',
|
11640 | style,
|
11641 | boxType: 'mrel',
|
11642 | }),
|
11643 | new Atom('mrel', { style, value: '=' }),
|
11644 | ], { boxType: 'mrel', captureSelection: true, serialize: () => name }),
|
11645 | });
|
11646 | defineFunction('rlap', '{:auto}', {
|
11647 | createAtom: (name, args, style) => new OverlapAtom(name, args[0], { align: 'right', style }),
|
11648 | });
|
11649 | defineFunction('llap', '{:auto}', {
|
11650 | createAtom: (name, args, style) => new OverlapAtom(name, args[0], { style }),
|
11651 | });
|
11652 | defineFunction('mathllap', '{:auto}', {
|
11653 | createAtom: (name, args, style) => new OverlapAtom(name, args[0], { style }),
|
11654 | });
|
11655 | defineFunction('mathrlap', '{:auto}', {
|
11656 | createAtom: (name, args, style) => new OverlapAtom(name, args[0], { align: 'right', style }),
|
11657 | });
|
11658 |
|
11659 | const ACCENTS = {
|
11660 | acute: 0x02ca,
|
11661 | grave: 0x02cb,
|
11662 | dot: 0x02d9,
|
11663 | ddot: 0x00a8,
|
11664 | mathring: 0x02da,
|
11665 | tilde: 0x007e,
|
11666 | bar: 0x02c9,
|
11667 | breve: 0x02d8,
|
11668 | check: 0x02c7,
|
11669 | hat: 0x005e,
|
11670 | vec: 0x20d7,
|
11671 | };
|
11672 | defineFunction(Object.keys(ACCENTS), '{body:auto}', {
|
11673 | createAtom: (command, args, style) => new AccentAtom(command, args[0], {
|
11674 | accentChar: ACCENTS[command.slice(1)],
|
11675 | style,
|
11676 | }),
|
11677 | });
|
11678 | defineFunction(['widehat', 'widecheck', 'widetilde'], '{body:auto}', {
|
11679 | createAtom: (command, args, style) => {
|
11680 |
|
11681 | const baseString = parseArgAsString(args[0]);
|
11682 | return new AccentAtom(command, args[0], {
|
11683 | style,
|
11684 | svgAccent: command.slice(1) +
|
11685 | (baseString.length > 5
|
11686 | ? '4'
|
11687 | : ['1', '1', '2', '2', '3', '3'][baseString.length]),
|
11688 | });
|
11689 | },
|
11690 | });
|
11691 | defineFunction(['overarc', 'overparen', 'wideparen'], '{body:auto}', {
|
11692 | createAtom: (command, args, style) => {
|
11693 | return new AccentAtom(command, args[0], {
|
11694 | style,
|
11695 | svgAccent: 'overarc',
|
11696 | });
|
11697 | },
|
11698 | });
|
11699 | defineFunction(['underarc', 'underparen'], '{body:auto}', {
|
11700 | createAtom: (command, args, style) => {
|
11701 | return new OverunderAtom(command, {
|
11702 | body: args[0],
|
11703 | style,
|
11704 | svgBelow: 'underarc',
|
11705 | });
|
11706 | },
|
11707 | });
|
11708 | defineFunction('utilde', '{body:auto}', {
|
11709 | createAtom: (command, args, style) => {
|
11710 | const baseString = parseArgAsString(args[0]);
|
11711 | const accent = 'widetilde' +
|
11712 | (baseString.length > 5
|
11713 | ? '4'
|
11714 | : ['1', '1', '2', '2', '3', '3'][baseString.length]);
|
11715 | return new OverunderAtom(command, {
|
11716 | body: args[0],
|
11717 | svgBelow: accent,
|
11718 | style,
|
11719 | boxType: binRelType(args[0]),
|
11720 | });
|
11721 | },
|
11722 | });
|
11723 |
|
11724 |
|
11725 |
|
11726 |
|
11727 | defineFunction('^', '{:string}', {
|
11728 | createAtom: (command, args, style) => {
|
11729 | var _a;
|
11730 | return new Atom('mord', {
|
11731 | command,
|
11732 | isFunction: false,
|
11733 | limits: 'adjacent',
|
11734 | style,
|
11735 | value: args[0]
|
11736 | ? (_a = {
|
11737 | a: 'â',
|
11738 | e: 'ê',
|
11739 | i: 'î',
|
11740 | o: 'ô',
|
11741 | u: 'û',
|
11742 | A: 'Â',
|
11743 | E: 'Ê',
|
11744 | I: 'Î',
|
11745 | O: 'Ô',
|
11746 | U: 'Û',
|
11747 | }[args[0]]) !== null && _a !== void 0 ? _a : '^'
|
11748 | : '^',
|
11749 | });
|
11750 | },
|
11751 | });
|
11752 | defineFunction('`', '{:string}', {
|
11753 | createAtom: (command, args, style) => {
|
11754 | var _a;
|
11755 | return new Atom('mord', {
|
11756 | command,
|
11757 | isFunction: false,
|
11758 | limits: 'adjacent',
|
11759 | style,
|
11760 | value: args[0]
|
11761 | ? (_a = {
|
11762 | a: 'à',
|
11763 | e: 'è',
|
11764 | i: 'ì',
|
11765 | o: 'ò',
|
11766 | u: 'ù',
|
11767 | A: 'À',
|
11768 | E: 'È',
|
11769 | I: 'Ì',
|
11770 | O: 'Ò',
|
11771 | U: 'Ù',
|
11772 | }[args[0]]) !== null && _a !== void 0 ? _a : '`'
|
11773 | : '`',
|
11774 | });
|
11775 | },
|
11776 | });
|
11777 | defineFunction("'", '{:string}', {
|
11778 | createAtom: (command, args, style) => {
|
11779 | var _a;
|
11780 | return new Atom('mord', {
|
11781 | command,
|
11782 | isFunction: false,
|
11783 | limits: 'adjacent',
|
11784 | style,
|
11785 | value: args[0]
|
11786 | ? (_a = {
|
11787 | a: 'á',
|
11788 | e: 'é',
|
11789 | i: 'í',
|
11790 | o: 'ó',
|
11791 | u: 'ú',
|
11792 | A: 'Á',
|
11793 | E: 'É',
|
11794 | I: 'Í',
|
11795 | O: 'Ó',
|
11796 | U: 'Ú',
|
11797 | }[args[0]]) !== null && _a !== void 0 ? _a : '\u005E'
|
11798 | : '\u005E',
|
11799 | });
|
11800 | },
|
11801 | });
|
11802 | defineFunction('~', '{:string}', {
|
11803 | createAtom: (command, args, style) => {
|
11804 | var _a;
|
11805 | return new Atom('mord', {
|
11806 | command,
|
11807 | isFunction: false,
|
11808 | limits: 'adjacent',
|
11809 | style,
|
11810 | value: args[0]
|
11811 | ? (_a = { n: 'ñ', N: 'Ñ', a: 'ã', o: 'õ', A: 'Ã', O: 'Õ' }[args[0]]) !== null && _a !== void 0 ? _a : '\u00B4'
|
11812 | : '\u00B4',
|
11813 | });
|
11814 | },
|
11815 | });
|
11816 | defineFunction('c', '{:string}', {
|
11817 | createAtom: (command, args, style) => {
|
11818 | var _a;
|
11819 | return new Atom('mord', {
|
11820 | command,
|
11821 | isFunction: false,
|
11822 | limits: 'adjacent',
|
11823 | style,
|
11824 | value: args[0] ? (_a = { c: 'ç', C: 'Ç' }[args[0]]) !== null && _a !== void 0 ? _a : '' : '',
|
11825 | });
|
11826 | },
|
11827 | });
|
11828 |
|
11829 | class EncloseAtom extends Atom {
|
11830 | constructor(command, body, notation, options) {
|
11831 | super('enclose', { command, style: options.style });
|
11832 | this.body = body;
|
11833 | this.backgroundcolor = options.backgroundcolor;
|
11834 | if (notation.updiagonalarrow) {
|
11835 | notation.updiagonalstrike = false;
|
11836 | }
|
11837 | if (notation.box) {
|
11838 | notation.left = false;
|
11839 | notation.right = false;
|
11840 | notation.bottom = false;
|
11841 | notation.top = false;
|
11842 | }
|
11843 | this.notation = notation;
|
11844 | this.shadow = options.shadow;
|
11845 | this.strokeWidth = options.strokeWidth;
|
11846 | this.strokeStyle = options.strokeStyle;
|
11847 | this.svgStrokeStyle = options.svgStrokeStyle;
|
11848 | this.strokeColor = options.strokeColor;
|
11849 | this.borderStyle = options.borderStyle;
|
11850 | this.padding = options.padding;
|
11851 | this.captureSelection = true;
|
11852 | }
|
11853 | serialize(options) {
|
11854 | var _a;
|
11855 | let result = (_a = this.command) !== null && _a !== void 0 ? _a : '';
|
11856 | if (this.command === '\\enclose') {
|
11857 | result += '{' + Object.keys(this.notation).join(' ') + '}';
|
11858 |
|
11859 | let style = '';
|
11860 | let sep = '';
|
11861 | if (this.backgroundcolor && this.backgroundcolor !== 'transparent') {
|
11862 | style += sep + 'mathbackground="' + this.backgroundcolor + '"';
|
11863 | sep = ',';
|
11864 | }
|
11865 | if (this.shadow && this.shadow !== 'auto') {
|
11866 | style += sep + 'shadow="' + this.shadow + '"';
|
11867 | sep = ',';
|
11868 | }
|
11869 | if (this.strokeWidth || this.strokeStyle !== 'solid') {
|
11870 | style += sep + this.borderStyle;
|
11871 | sep = ',';
|
11872 | }
|
11873 | else if (this.strokeColor && this.strokeColor !== 'currentColor') {
|
11874 | style += sep + 'mathcolor="' + this.strokeColor + '"';
|
11875 | sep = ',';
|
11876 | }
|
11877 | if (style) {
|
11878 | result += `[${style}]`;
|
11879 | }
|
11880 | }
|
11881 | result += `{${this.bodyToLatex(options)}}`;
|
11882 | return result;
|
11883 | }
|
11884 | render(parentContext) {
|
11885 | var _a;
|
11886 | const context = new Context(parentContext, this.style);
|
11887 | const base = Atom.createBox(context, this.body);
|
11888 | if (!base)
|
11889 | return null;
|
11890 |
|
11891 | const padding = (_a = convertDimensionToEm(this.padding && this.padding !== 'auto'
|
11892 | ? convertToDimension(this.padding, parentContext.registers)
|
11893 | : context.getRegisterAsDimension('fboxsep'))) !== null && _a !== void 0 ? _a : 0;
|
11894 |
|
11895 |
|
11896 | const notation = new Box(null, { classes: 'ML__notation' });
|
11897 | notation.setStyle('position', 'absolute');
|
11898 | notation.setStyle('height', base.height + base.depth + 2 * padding, 'em');
|
11899 | notation.height = base.height + padding;
|
11900 | notation.depth = base.depth + padding;
|
11901 | if (padding !== 0) {
|
11902 | notation.setStyle('width', `calc(100% + ${2 * padding}em)`);
|
11903 | }
|
11904 | else {
|
11905 | notation.setStyle('width', '100%');
|
11906 | }
|
11907 | notation.setStyle('top', -base.height + 2 * padding, 'em');
|
11908 | notation.setStyle('left', -padding, 'em');
|
11909 | notation.setStyle('z-index', '-1');
|
11910 | notation.setStyle('box-sizing', 'border-box');
|
11911 | if (this.backgroundcolor) {
|
11912 | notation.setStyle('background-color', this.backgroundcolor);
|
11913 | }
|
11914 | if (this.notation.box)
|
11915 | notation.setStyle('border', this.borderStyle);
|
11916 | if (this.notation.actuarial) {
|
11917 | notation.setStyle('border-top', this.borderStyle);
|
11918 | notation.setStyle('border-right', this.borderStyle);
|
11919 | }
|
11920 | if (this.notation.madruwb) {
|
11921 | notation.setStyle('border-bottom', this.borderStyle);
|
11922 | notation.setStyle('border-right', this.borderStyle);
|
11923 | }
|
11924 | if (this.notation.roundedbox) {
|
11925 | notation.setStyle('border-radius', (base.height + base.depth) / 2, 'em');
|
11926 | notation.setStyle('border', this.borderStyle);
|
11927 | }
|
11928 | if (this.notation.circle) {
|
11929 | notation.setStyle('border-radius', '50%');
|
11930 | notation.setStyle('border', this.borderStyle);
|
11931 | }
|
11932 | if (this.notation.top) {
|
11933 | notation.setStyle('border-top', this.borderStyle);
|
11934 | }
|
11935 | if (this.notation.left) {
|
11936 | notation.setStyle('border-left', this.borderStyle);
|
11937 | }
|
11938 | if (this.notation.right) {
|
11939 | notation.setStyle('border-right', this.borderStyle);
|
11940 | }
|
11941 | if (this.notation.bottom) {
|
11942 | notation.setStyle('border-bottom', this.borderStyle);
|
11943 | }
|
11944 | let svg = '';
|
11945 | if (this.notation.horizontalstrike) {
|
11946 | svg += '<line x1="3%" y1="50%" x2="97%" y2="50%"';
|
11947 | svg += ` stroke-width="${this.strokeWidth}" stroke="${this.strokeColor}"`;
|
11948 | svg += ' stroke-linecap="round"';
|
11949 | if (this.svgStrokeStyle) {
|
11950 | svg += ` stroke-dasharray="${this.svgStrokeStyle}"`;
|
11951 | }
|
11952 | svg += '/>';
|
11953 | }
|
11954 | if (this.notation.verticalstrike) {
|
11955 | svg += '<line x1="50%" y1="3%" x2="50%" y2="97%"';
|
11956 | svg += ` stroke-width="${this.strokeWidth}" stroke="${this.strokeColor}"`;
|
11957 | svg += ' stroke-linecap="round"';
|
11958 | if (this.svgStrokeStyle) {
|
11959 | svg += ` stroke-dasharray="${this.svgStrokeStyle}"`;
|
11960 | }
|
11961 | svg += '/>';
|
11962 | }
|
11963 | if (this.notation.updiagonalstrike) {
|
11964 | svg += '<line x1="3%" y1="97%" x2="97%" y2="3%"';
|
11965 | svg += ` stroke-width="${this.strokeWidth}" stroke="${this.strokeColor}"`;
|
11966 | svg += ' stroke-linecap="round"';
|
11967 | if (this.svgStrokeStyle) {
|
11968 | svg += ` stroke-dasharray="${this.svgStrokeStyle}"`;
|
11969 | }
|
11970 | svg += '/>';
|
11971 | }
|
11972 | if (this.notation.downdiagonalstrike) {
|
11973 | svg += '<line x1="3%" y1="3%" x2="97%" y2="97%"';
|
11974 | svg += ` stroke-width="${this.strokeWidth}" stroke="${this.strokeColor}"`;
|
11975 | svg += ' stroke-linecap="round"';
|
11976 | if (this.svgStrokeStyle) {
|
11977 | svg += ` stroke-dasharray="${this.svgStrokeStyle}"`;
|
11978 | }
|
11979 | svg += '/>';
|
11980 | }
|
11981 |
|
11982 |
|
11983 |
|
11984 |
|
11985 |
|
11986 |
|
11987 |
|
11988 |
|
11989 |
|
11990 |
|
11991 |
|
11992 |
|
11993 |
|
11994 |
|
11995 |
|
11996 |
|
11997 |
|
11998 |
|
11999 |
|
12000 |
|
12001 |
|
12002 |
|
12003 |
|
12004 |
|
12005 |
|
12006 |
|
12007 |
|
12008 |
|
12009 |
|
12010 |
|
12011 |
|
12012 |
|
12013 |
|
12014 |
|
12015 |
|
12016 |
|
12017 |
|
12018 |
|
12019 |
|
12020 |
|
12021 |
|
12022 |
|
12023 |
|
12024 |
|
12025 |
|
12026 |
|
12027 |
|
12028 |
|
12029 |
|
12030 |
|
12031 |
|
12032 |
|
12033 |
|
12034 |
|
12035 |
|
12036 |
|
12037 |
|
12038 |
|
12039 |
|
12040 |
|
12041 |
|
12042 |
|
12043 | if (svg) {
|
12044 | let svgStyle;
|
12045 | if (this.shadow !== 'none') {
|
12046 | svgStyle =
|
12047 | this.shadow === 'auto'
|
12048 | ? 'filter: drop-shadow(0 0 .5px rgba(255, 255, 255, .7)) drop-shadow(1px 1px 2px #333)'
|
12049 | : 'filter: drop-shadow(' + this.shadow + ')';
|
12050 | }
|
12051 | addSVGOverlay(notation, svg, svgStyle);
|
12052 | }
|
12053 | const result = new Box([notation, base]);
|
12054 |
|
12055 |
|
12056 | result.setStyle('position', 'relative');
|
12057 | result.setStyle('display', 'inline');
|
12058 |
|
12059 | result.height = base.height + padding;
|
12060 | result.depth = base.depth + padding;
|
12061 | result.left = padding;
|
12062 | result.right = padding;
|
12063 | if (this.caret)
|
12064 | result.caret = this.caret;
|
12065 | return result.wrap(context);
|
12066 | }
|
12067 | }
|
12068 |
|
12069 |
|
12070 |
|
12071 |
|
12072 |
|
12073 | defineFunction('enclose', '{notation:string}[style:string]{body:auto}', {
|
12074 | createAtom: (command, args, style) => {
|
12075 | var _a;
|
12076 | const options = {
|
12077 | strokeColor: 'currentColor',
|
12078 | strokeWidth: '',
|
12079 | strokeStyle: 'solid',
|
12080 | backgroundcolor: 'transparent',
|
12081 | padding: 'auto',
|
12082 | shadow: 'auto',
|
12083 | svgStrokeStyle: undefined,
|
12084 | borderStyle: undefined,
|
12085 | style,
|
12086 | };
|
12087 |
|
12088 | if (args[1]) {
|
12089 |
|
12090 |
|
12091 |
|
12092 | const styles = args[1].split(/,(?![^(]*\)(?:(?:[^(]*\)){2})*[^"]*$)/);
|
12093 | for (const s of styles) {
|
12094 | const shorthand = s.match(/\s*(\S+)\s+(\S+)\s+(.*)/);
|
12095 | if (shorthand) {
|
12096 | options.strokeWidth = shorthand[1];
|
12097 | options.strokeStyle = shorthand[2];
|
12098 | options.strokeColor = shorthand[3];
|
12099 | }
|
12100 | else {
|
12101 | const attribute = s.match(/\s*([a-z]*)\s*=\s*"(.*)"/);
|
12102 | if (attribute) {
|
12103 | if (attribute[1] === 'mathbackground') {
|
12104 | options.backgroundcolor = attribute[2];
|
12105 | }
|
12106 | else if (attribute[1] === 'mathcolor') {
|
12107 | options.strokeColor = attribute[2];
|
12108 | }
|
12109 | else if (attribute[1] === 'padding') {
|
12110 | options.padding = attribute[2];
|
12111 | }
|
12112 | else if (attribute[1] === 'shadow') {
|
12113 | options.shadow = attribute[2];
|
12114 | }
|
12115 | }
|
12116 | }
|
12117 | }
|
12118 | if (options.strokeStyle === 'dashed') {
|
12119 | options.svgStrokeStyle = '5,5';
|
12120 | }
|
12121 | else if (options.strokeStyle === 'dotted') {
|
12122 | options.svgStrokeStyle = '1,5';
|
12123 | }
|
12124 | }
|
12125 | options.borderStyle = `${options.strokeWidth}px ${options.strokeStyle} ${options.strokeColor}`;
|
12126 |
|
12127 | const notation = {};
|
12128 | ((_a = args[0]) !== null && _a !== void 0 ? _a : '')
|
12129 | .split(/[, ]/)
|
12130 | .filter((v) => v.length > 0)
|
12131 | .forEach((x) => {
|
12132 | notation[x.toLowerCase()] = true;
|
12133 | });
|
12134 | return new EncloseAtom(command, args[2], notation, options);
|
12135 | },
|
12136 | });
|
12137 | defineFunction('cancel', '{body:auto}', {
|
12138 | createAtom: (name, args, style) => new EncloseAtom(name, args[0], { updiagonalstrike: true }, {
|
12139 | strokeColor: 'currentColor',
|
12140 | strokeWidth: '',
|
12141 | strokeStyle: 'solid',
|
12142 | borderStyle: '1px solid currentColor',
|
12143 | backgroundcolor: 'transparent',
|
12144 | padding: 'auto',
|
12145 | shadow: 'auto',
|
12146 | style,
|
12147 | }),
|
12148 | });
|
12149 | defineFunction('bcancel', '{body:auto}', {
|
12150 | createAtom: (name, args, style) => new EncloseAtom(name, args[0], { downdiagonalstrike: true }, {
|
12151 | strokeColor: 'currentColor',
|
12152 | strokeWidth: '',
|
12153 | strokeStyle: 'solid',
|
12154 | borderStyle: '1px solid currentColor',
|
12155 | backgroundcolor: 'transparent',
|
12156 | padding: 'auto',
|
12157 | shadow: 'auto',
|
12158 | style,
|
12159 | }),
|
12160 | });
|
12161 | defineFunction('xcancel', '{body:auto}', {
|
12162 | createAtom: (name, args, style) => new EncloseAtom(name, args[0], { updiagonalstrike: true, downdiagonalstrike: true }, {
|
12163 | strokeColor: 'currentColor',
|
12164 | strokeWidth: '',
|
12165 | strokeStyle: 'solid',
|
12166 | borderStyle: '1px solid currentColor',
|
12167 | backgroundcolor: 'transparent',
|
12168 | padding: 'auto',
|
12169 | shadow: 'auto',
|
12170 | style,
|
12171 | }),
|
12172 | });
|
12173 |
|
12174 |
|
12175 |
|
12176 |
|
12177 |
|
12178 |
|
12179 |
|
12180 |
|
12181 |
|
12182 |
|
12183 |
|
12184 |
|
12185 |
|
12186 |
|
12187 |
|
12188 |
|
12189 |
|
12190 |
|
12191 |
|
12192 |
|
12193 |
|
12194 |
|
12195 |
|
12196 |
|
12197 |
|
12198 |
|
12199 |
|
12200 |
|
12201 |
|
12202 |
|
12203 |
|
12204 | function normalizeArray(atom, array, colFormat) {
|
12205 |
|
12206 |
|
12207 |
|
12208 |
|
12209 |
|
12210 |
|
12211 |
|
12212 |
|
12213 | let maxColCount = 0;
|
12214 | for (const colSpec of colFormat) {
|
12215 | if ('align' in colSpec)
|
12216 | maxColCount += 1;
|
12217 | }
|
12218 |
|
12219 | let colCount = 0;
|
12220 | const rows = [];
|
12221 | for (const row of array) {
|
12222 | let colIndex = 0;
|
12223 | colCount = Math.max(colCount, Math.min(row.length, maxColCount));
|
12224 | while (colIndex < row.length) {
|
12225 | const newRow = [];
|
12226 | const lastCol = Math.min(row.length, colIndex + maxColCount);
|
12227 | while (colIndex < lastCol) {
|
12228 | if (row[colIndex].length > 0 && row[colIndex][0].type !== 'first') {
|
12229 | newRow.push([
|
12230 | new Atom('first', { mode: atom.mode }),
|
12231 | ...row[colIndex],
|
12232 | ]);
|
12233 | }
|
12234 | else {
|
12235 | newRow.push(row[colIndex]);
|
12236 | }
|
12237 | colIndex += 1;
|
12238 | }
|
12239 | rows.push(newRow);
|
12240 | }
|
12241 | }
|
12242 |
|
12243 |
|
12244 |
|
12245 | if (rows[rows.length - 1].length === 1 &&
|
12246 | rows[rows.length - 1][0].length === 0) {
|
12247 | rows.pop();
|
12248 | }
|
12249 |
|
12250 |
|
12251 |
|
12252 | const result = [];
|
12253 | for (const row of rows) {
|
12254 | if (row.length !== colCount) {
|
12255 | for (let i = row.length; i < colCount; i++) {
|
12256 | row.push([
|
12257 | new Atom('first', { mode: atom.mode }),
|
12258 | new PlaceholderAtom(),
|
12259 | ]);
|
12260 | }
|
12261 | }
|
12262 | result.push(row);
|
12263 | }
|
12264 |
|
12265 |
|
12266 |
|
12267 | let rowIndex = 0;
|
12268 | let colIndex = 0;
|
12269 | for (const row of result) {
|
12270 | colIndex = 0;
|
12271 | for (const cell of row) {
|
12272 | for (const element of cell) {
|
12273 | element.parent = atom;
|
12274 | element.treeBranch = [rowIndex, colIndex];
|
12275 | }
|
12276 | colIndex += 1;
|
12277 | }
|
12278 | rowIndex += 1;
|
12279 | }
|
12280 | atom.isDirty = true;
|
12281 | return result;
|
12282 | }
|
12283 |
|
12284 | class ArrayAtom extends Atom {
|
12285 | constructor(envName, array, rowGaps, options = {}) {
|
12286 | var _a;
|
12287 | super('array');
|
12288 | this.environmentName = envName;
|
12289 | this.rowGaps = rowGaps;
|
12290 | if (options.mathstyleName)
|
12291 | this.mathstyleName = options.mathstyleName;
|
12292 | if (options.columns) {
|
12293 | if (options.columns.length === 0) {
|
12294 | this.colFormat = [{ align: 'l' }];
|
12295 | }
|
12296 | else {
|
12297 | this.colFormat = options.columns;
|
12298 | }
|
12299 | }
|
12300 |
|
12301 |
|
12302 | if (!this.colFormat) {
|
12303 | this.colFormat = [
|
12304 | { align: 'l' },
|
12305 | { align: 'l' },
|
12306 | { align: 'l' },
|
12307 | { align: 'l' },
|
12308 | { align: 'l' },
|
12309 | { align: 'l' },
|
12310 | { align: 'l' },
|
12311 | { align: 'l' },
|
12312 | { align: 'l' },
|
12313 | { align: 'l' },
|
12314 | ];
|
12315 | }
|
12316 | this.array = normalizeArray(this, array, this.colFormat);
|
12317 |
|
12318 | if (options.leftDelim)
|
12319 | this.leftDelim = options.leftDelim;
|
12320 | if (options.rightDelim)
|
12321 | this.rightDelim = options.rightDelim;
|
12322 | if (options.jot !== undefined)
|
12323 | this.jot = options.jot;
|
12324 | if (options.arraycolsep)
|
12325 | this.arraycolsep = options.arraycolsep;
|
12326 | this.colSeparationType = options.colSeparationType;
|
12327 |
|
12328 | this.arraystretch = (_a = options.arraystretch) !== null && _a !== void 0 ? _a : 1.0;
|
12329 | }
|
12330 | branch(cell) {
|
12331 | var _a;
|
12332 | if (!isColRowBranch(cell))
|
12333 | return undefined;
|
12334 | return (_a = this.array[cell[0]][cell[1]]) !== null && _a !== void 0 ? _a : undefined;
|
12335 | }
|
12336 | get branches() {
|
12337 | const result = super.branches;
|
12338 | this.array.forEach((_, col) => {
|
12339 | this.array[col].forEach((_, row) => {
|
12340 | if (this.array[col][row]) {
|
12341 | result.push([col, row]);
|
12342 | }
|
12343 | });
|
12344 | });
|
12345 | return result;
|
12346 | }
|
12347 | createBranch(cell) {
|
12348 | if (!isColRowBranch(cell))
|
12349 | return [];
|
12350 | return [];
|
12351 | }
|
12352 | get rowCount() {
|
12353 | return this.array.length;
|
12354 | }
|
12355 | get colCount() {
|
12356 | return this.array[0].length;
|
12357 | }
|
12358 | removeBranch(name) {
|
12359 | if (isNamedBranch(name)) {
|
12360 | return super.removeBranch(name);
|
12361 | }
|
12362 | const children = this.branch(name);
|
12363 | this.array[name[0]][name[1]] = undefined;
|
12364 | children.forEach((x) => {
|
12365 | x.parent = undefined;
|
12366 | x.treeBranch = undefined;
|
12367 | });
|
12368 |
|
12369 | console.assert(children[0].type === 'first');
|
12370 | children.shift();
|
12371 | this.isDirty = true;
|
12372 | return children;
|
12373 | }
|
12374 | get hasChildren() {
|
12375 | return this.children.length > 0;
|
12376 | }
|
12377 | get children() {
|
12378 | const result = [];
|
12379 | for (const row of this.array) {
|
12380 | for (const cell of row) {
|
12381 | if (cell) {
|
12382 | for (const atom of cell) {
|
12383 | result.push(...atom.children);
|
12384 | result.push(atom);
|
12385 | }
|
12386 | }
|
12387 | }
|
12388 | }
|
12389 | return [...result, ...super.children];
|
12390 | }
|
12391 | render(context) {
|
12392 |
|
12393 |
|
12394 | var _a, _b, _c, _d, _e;
|
12395 | const innerContext = new Context(context, this.style, this.mathstyleName);
|
12396 | const arrayRuleWidth = innerContext.getRegisterAsEm('arrayrulewidth');
|
12397 | const arrayColSep = innerContext.getRegisterAsEm('arraycolsep');
|
12398 | const doubleRuleSep = innerContext.getRegisterAsEm('doublerulesep');
|
12399 |
|
12400 | const arraystretch = (_a = this.arraystretch) !== null && _a !== void 0 ? _a : 1.0;
|
12401 | let arraycolsep = typeof this.arraycolsep === 'number' ? this.arraycolsep : arrayColSep;
|
12402 | if (this.colSeparationType === 'small') {
|
12403 |
|
12404 |
|
12405 |
|
12406 |
|
12407 |
|
12408 | const localMultiplier = new Context(context, undefined, 'scriptstyle')
|
12409 | .scalingFactor;
|
12410 | arraycolsep = 0.2778 * (localMultiplier / context.scalingFactor);
|
12411 | }
|
12412 | const arrayskip = arraystretch * BASELINE_SKIP;
|
12413 | const arstrutHeight = 0.7 * arrayskip;
|
12414 | const arstrutDepth = 0.3 * arrayskip;
|
12415 | let totalHeight = 0;
|
12416 | const body = [];
|
12417 | let nc = 0;
|
12418 | const nr = this.array.length;
|
12419 | for (let r = 0; r < nr; ++r) {
|
12420 | const inrow = this.array[r];
|
12421 | nc = Math.max(nc, inrow.length);
|
12422 |
|
12423 |
|
12424 |
|
12425 | const cellContext = new Context(innerContext, this.style, this.mathstyleName);
|
12426 | let height = arstrutHeight / cellContext.scalingFactor;
|
12427 | let depth = arstrutDepth / cellContext.scalingFactor;
|
12428 | const outrow = { cells: [], height: 0, depth: 0, pos: 0 };
|
12429 | for (const element of inrow) {
|
12430 | const elt = (_b = Atom.createBox(cellContext, element, { newList: true })) !== null && _b !== void 0 ? _b : new Box(null, { newList: true });
|
12431 | depth = Math.max(depth, elt.depth);
|
12432 | height = Math.max(height, elt.height);
|
12433 | outrow.cells.push(elt);
|
12434 | }
|
12435 | let gap = (_c = convertDimensionToEm(this.rowGaps[r])) !== null && _c !== void 0 ? _c : 0;
|
12436 | if (gap > 0) {
|
12437 |
|
12438 | gap += arstrutDepth;
|
12439 | depth = Math.max(depth, gap);
|
12440 | gap = 0;
|
12441 | }
|
12442 | if (this.jot !== undefined) {
|
12443 | depth += this.jot;
|
12444 | }
|
12445 | outrow.height = height;
|
12446 | outrow.depth = depth;
|
12447 | totalHeight += height;
|
12448 | outrow.pos = totalHeight;
|
12449 | totalHeight += depth + gap;
|
12450 | body.push(outrow);
|
12451 | }
|
12452 | const offset = totalHeight / 2 + AXIS_HEIGHT;
|
12453 | const contentCols = [];
|
12454 | for (let colIndex = 0; colIndex < nc; colIndex++) {
|
12455 | const stack = [];
|
12456 | for (const row of body) {
|
12457 | const element = row.cells[colIndex];
|
12458 | element.depth = row.depth;
|
12459 | element.height = row.height;
|
12460 | stack.push({ box: element, shift: row.pos - offset });
|
12461 | }
|
12462 | if (stack.length > 0) {
|
12463 | contentCols.push(new VBox({ individualShift: stack }));
|
12464 | }
|
12465 | }
|
12466 |
|
12467 |
|
12468 |
|
12469 | const cols = [];
|
12470 | let previousColContent = false;
|
12471 | let previousColRule = false;
|
12472 | let currentContentCol = 0;
|
12473 | let firstColumn = !this.leftDelim;
|
12474 | const { colFormat } = this;
|
12475 | for (const colDesc of colFormat) {
|
12476 | if ('align' in colDesc && currentContentCol >= contentCols.length) {
|
12477 |
|
12478 | break;
|
12479 | }
|
12480 | if ('align' in colDesc) {
|
12481 |
|
12482 | if (previousColContent) {
|
12483 |
|
12484 |
|
12485 | cols.push(makeColGap(2 * arraycolsep));
|
12486 | }
|
12487 | else if (previousColRule || firstColumn) {
|
12488 |
|
12489 |
|
12490 | cols.push(makeColGap(arraycolsep));
|
12491 | }
|
12492 | cols.push(new Box(contentCols[currentContentCol], {
|
12493 | classes: 'col-align-' + colDesc.align,
|
12494 | }));
|
12495 | currentContentCol++;
|
12496 | previousColContent = true;
|
12497 | previousColRule = false;
|
12498 | firstColumn = false;
|
12499 | }
|
12500 | else if ('gap' in colDesc) {
|
12501 |
|
12502 |
|
12503 |
|
12504 | if (typeof colDesc.gap === 'number') {
|
12505 |
|
12506 |
|
12507 | cols.push(makeColGap(colDesc.gap));
|
12508 | }
|
12509 | else {
|
12510 |
|
12511 |
|
12512 |
|
12513 | const col = makeColOfRepeatingElements(context, body, offset, colDesc.gap);
|
12514 | if (col)
|
12515 | cols.push(col);
|
12516 | }
|
12517 | previousColContent = false;
|
12518 | previousColRule = false;
|
12519 | firstColumn = false;
|
12520 | }
|
12521 | else if ('separator' in colDesc) {
|
12522 |
|
12523 |
|
12524 |
|
12525 | const separator = new Box(null, { classes: 'vertical-separator' });
|
12526 | separator.setStyle('height', totalHeight, 'em');
|
12527 | separator.setStyle('border-right', `${arrayRuleWidth}em ${colDesc.separator} currentColor`);
|
12528 |
|
12529 |
|
12530 |
|
12531 |
|
12532 |
|
12533 | separator.setStyle('vertical-align', -(totalHeight - offset), 'em');
|
12534 | let gap = 0;
|
12535 | if (previousColRule) {
|
12536 | gap = doubleRuleSep - arrayRuleWidth;
|
12537 | }
|
12538 | else if (previousColContent) {
|
12539 | gap = arraycolsep - arrayRuleWidth;
|
12540 | }
|
12541 | separator.left = gap;
|
12542 | cols.push(separator);
|
12543 | previousColContent = false;
|
12544 | previousColRule = true;
|
12545 | firstColumn = false;
|
12546 | }
|
12547 | }
|
12548 | if (previousColContent && !this.rightDelim) {
|
12549 |
|
12550 | cols.push(makeColGap(arraycolsep));
|
12551 | }
|
12552 | const inner = new Box(cols, { classes: 'mtable' });
|
12553 | if ((!this.leftDelim || this.leftDelim === '.') &&
|
12554 | (!this.rightDelim || this.rightDelim === '.')) {
|
12555 |
|
12556 |
|
12557 | return inner;
|
12558 | }
|
12559 |
|
12560 |
|
12561 | const innerHeight = inner.height;
|
12562 | const innerDepth = inner.depth;
|
12563 | const result = this.bind(context, new Box([
|
12564 | this.bind(context, makeLeftRightDelim('mopen', (_d = this.leftDelim) !== null && _d !== void 0 ? _d : '.', innerHeight, innerDepth, innerContext)),
|
12565 | inner,
|
12566 | this.bind(context, makeLeftRightDelim('mclose', (_e = this.rightDelim) !== null && _e !== void 0 ? _e : '.', innerHeight, innerDepth, innerContext)),
|
12567 | ], { type: 'mord' }));
|
12568 | if (!result)
|
12569 | return null;
|
12570 | if (this.caret)
|
12571 | result.caret = this.caret;
|
12572 | return this.attachSupsub(context, { base: result });
|
12573 | }
|
12574 | serialize(options) {
|
12575 | let result = '\\begin{' + this.environmentName + '}';
|
12576 | if (this.environmentName === 'array') {
|
12577 | result += '{';
|
12578 | if (this.colFormat !== undefined) {
|
12579 | for (const format of this.colFormat) {
|
12580 | if ('align' in format) {
|
12581 | result += format.align;
|
12582 | }
|
12583 | else if ('separator' in format && format.separator === 'solid') {
|
12584 | result += '|';
|
12585 | }
|
12586 | else if ('separator' in format && format.separator === 'dashed') {
|
12587 | result += ':';
|
12588 | }
|
12589 | }
|
12590 | }
|
12591 | result += '}';
|
12592 | }
|
12593 | for (let row = 0; row < this.array.length; row++) {
|
12594 | for (let col = 0; col < this.array[row].length; col++) {
|
12595 | if (col > 0)
|
12596 | result += ' & ';
|
12597 | result = joinLatex([
|
12598 | result,
|
12599 | Atom.serialize(this.array[row][col], options),
|
12600 | ]);
|
12601 | }
|
12602 |
|
12603 | if (row < this.array.length - 1) {
|
12604 | result += ' \\\\ ';
|
12605 | }
|
12606 | }
|
12607 | result += '\\end{' + this.environmentName + '}';
|
12608 | return result;
|
12609 | }
|
12610 | getCell(row, col) {
|
12611 | return this.array[row][col];
|
12612 | }
|
12613 | setCell(_row, _column, _value) {
|
12614 |
|
12615 | console.assert(this.type === 'array' && Array.isArray(this.array));
|
12616 | this.isDirty = true;
|
12617 | }
|
12618 | addRowBefore(_row) {
|
12619 | console.assert(this.type === 'array' && Array.isArray(this.array));
|
12620 |
|
12621 | this.isDirty = true;
|
12622 | }
|
12623 | addRowAfter(_row) {
|
12624 | console.assert(this.type === 'array' && Array.isArray(this.array));
|
12625 |
|
12626 | this.isDirty = true;
|
12627 | }
|
12628 | addColumnBefore(_col) {
|
12629 | console.assert(this.type === 'array' && Array.isArray(this.array));
|
12630 | this.isDirty = true;
|
12631 | }
|
12632 | addColumnAfter(_col) {
|
12633 | console.assert(this.type === 'array' && Array.isArray(this.array));
|
12634 |
|
12635 | this.isDirty = true;
|
12636 | }
|
12637 | get cells() {
|
12638 | const result = [];
|
12639 | for (const row of this.array) {
|
12640 | for (const cell of row) {
|
12641 | if (cell)
|
12642 | result.push(cell);
|
12643 | }
|
12644 | }
|
12645 | return result;
|
12646 | }
|
12647 | }
|
12648 |
|
12649 |
|
12650 |
|
12651 |
|
12652 | function makeColGap(width) {
|
12653 | const separator = new Box(null, { classes: 'arraycolsep' });
|
12654 | separator.width = width;
|
12655 | return separator;
|
12656 | }
|
12657 |
|
12658 |
|
12659 |
|
12660 | function makeColOfRepeatingElements(context, rows, offset, element) {
|
12661 | if (!element)
|
12662 | return null;
|
12663 | const col = [];
|
12664 | for (const row of rows) {
|
12665 | const cell = Atom.createBox(context, element, { newList: true });
|
12666 | if (cell) {
|
12667 | cell.depth = row.depth;
|
12668 | cell.height = row.height;
|
12669 | col.push({ box: cell, shift: row.pos - offset });
|
12670 | }
|
12671 | }
|
12672 | return new VBox({ individualShift: col }).wrap(context);
|
12673 | }
|
12674 |
|
12675 |
|
12676 |
|
12677 |
|
12678 |
|
12679 |
|
12680 |
|
12681 |
|
12682 |
|
12683 |
|
12684 |
|
12685 |
|
12686 |
|
12687 |
|
12688 |
|
12689 |
|
12690 |
|
12691 |
|
12692 |
|
12693 |
|
12694 |
|
12695 |
|
12696 |
|
12697 |
|
12698 |
|
12699 |
|
12700 |
|
12701 |
|
12702 |
|
12703 |
|
12704 |
|
12705 |
|
12706 |
|
12707 |
|
12708 |
|
12709 |
|
12710 |
|
12711 |
|
12712 |
|
12713 |
|
12714 |
|
12715 |
|
12716 |
|
12717 |
|
12718 |
|
12719 |
|
12720 |
|
12721 |
|
12722 |
|
12723 |
|
12724 |
|
12725 |
|
12726 |
|
12727 |
|
12728 |
|
12729 |
|
12730 |
|
12731 |
|
12732 |
|
12733 |
|
12734 |
|
12735 |
|
12736 |
|
12737 |
|
12738 |
|
12739 |
|
12740 |
|
12741 |
|
12742 |
|
12743 |
|
12744 |
|
12745 |
|
12746 |
|
12747 |
|
12748 |
|
12749 |
|
12750 |
|
12751 |
|
12752 |
|
12753 |
|
12754 |
|
12755 |
|
12756 |
|
12757 |
|
12758 |
|
12759 |
|
12760 |
|
12761 |
|
12762 |
|
12763 |
|
12764 |
|
12765 |
|
12766 |
|
12767 |
|
12768 |
|
12769 |
|
12770 |
|
12771 |
|
12772 |
|
12773 |
|
12774 |
|
12775 |
|
12776 |
|
12777 |
|
12778 |
|
12779 |
|
12780 |
|
12781 |
|
12782 |
|
12783 |
|
12784 |
|
12785 |
|
12786 |
|
12787 |
|
12788 |
|
12789 |
|
12790 |
|
12791 |
|
12792 |
|
12793 |
|
12794 |
|
12795 |
|
12796 |
|
12797 |
|
12798 |
|
12799 |
|
12800 |
|
12801 |
|
12802 |
|
12803 |
|
12804 |
|
12805 |
|
12806 |
|
12807 |
|
12808 |
|
12809 |
|
12810 |
|
12811 |
|
12812 |
|
12813 |
|
12814 |
|
12815 |
|
12816 |
|
12817 |
|
12818 | defineEnvironment('math', '', (name, array, rowGaps) => new ArrayAtom(name, array, rowGaps, { mathstyleName: 'textstyle' }));
|
12819 | defineEnvironment('displaymath', '', (name, array, rowGaps) => new ArrayAtom(name, array, rowGaps, { mathstyleName: 'textstyle' }));
|
12820 | defineTabularEnvironment('array', '{columns:colspec}', (name, array, rowGaps, args) => new ArrayAtom(name, array, rowGaps, {
|
12821 | columns: args[0],
|
12822 | mathstyleName: 'textstyle',
|
12823 | }));
|
12824 | defineTabularEnvironment(['equation', 'equation*', 'subequations'], '', (name, array, rowGaps) => new ArrayAtom(name, array, rowGaps, {
|
12825 | columns: [{ align: 'c' }],
|
12826 | }));
|
12827 |
|
12828 | defineTabularEnvironment('multline', '', (name, array, rowGaps) => new ArrayAtom(name, array, rowGaps, {
|
12829 | columns: [{ align: 'm' }],
|
12830 | }));
|
12831 |
|
12832 |
|
12833 |
|
12834 |
|
12835 |
|
12836 |
|
12837 |
|
12838 |
|
12839 | defineTabularEnvironment(['align', 'align*', 'aligned', 'eqnarray'], '', (name, array, rowGaps) => {
|
12840 | let colCount = 0;
|
12841 | for (const row of array) {
|
12842 | colCount = Math.max(colCount, row.length);
|
12843 | }
|
12844 | const colFormat = [
|
12845 | { gap: 0 },
|
12846 | { align: 'r' },
|
12847 | { gap: 0 },
|
12848 | { align: 'l' },
|
12849 | ];
|
12850 | let i = 2;
|
12851 | while (i < colCount) {
|
12852 | colFormat.push({ gap: 1 });
|
12853 | colFormat.push({ align: 'r' });
|
12854 | colFormat.push({ gap: 0 });
|
12855 | colFormat.push({ align: 'l' });
|
12856 | i += 2;
|
12857 | }
|
12858 | colFormat.push({ gap: 0 });
|
12859 | return new ArrayAtom(name, array, rowGaps, {
|
12860 | arraycolsep: 0,
|
12861 | columns: colFormat,
|
12862 | colSeparationType: 'align',
|
12863 | jot: 0.3,
|
12864 | });
|
12865 | });
|
12866 |
|
12867 |
|
12868 |
|
12869 |
|
12870 |
|
12871 |
|
12872 |
|
12873 |
|
12874 | defineTabularEnvironment('split', '', (name, array, rowGaps) => new ArrayAtom(name, array, rowGaps, {
|
12875 | columns: [{ align: 'r' }, { align: 'l' }],
|
12876 | }));
|
12877 | defineTabularEnvironment(['gather', 'gathered'], '', (name, array, rowGaps) =>
|
12878 |
|
12879 |
|
12880 |
|
12881 |
|
12882 |
|
12883 |
|
12884 |
|
12885 |
|
12886 |
|
12887 |
|
12888 |
|
12889 | new ArrayAtom(name, array, rowGaps, {
|
12890 | columns: [{ gap: 0.25 }, { align: 'c' }, { gap: 0 }],
|
12891 | colSeparationType: 'gather',
|
12892 | }));
|
12893 |
|
12894 |
|
12895 |
|
12896 |
|
12897 |
|
12898 |
|
12899 |
|
12900 | defineTabularEnvironment([
|
12901 | 'matrix',
|
12902 | 'pmatrix',
|
12903 | 'bmatrix',
|
12904 | 'Bmatrix',
|
12905 | 'vmatrix',
|
12906 | 'Vmatrix',
|
12907 | 'matrix*',
|
12908 | 'pmatrix*',
|
12909 | 'bmatrix*',
|
12910 | 'Bmatrix*',
|
12911 | 'vmatrix*',
|
12912 | 'Vmatrix*',
|
12913 | ], '[columns:colspec]', (name, array, rowGaps, args) => {
|
12914 | var _a;
|
12915 |
|
12916 |
|
12917 |
|
12918 | let leftDelim = '.';
|
12919 | let rightDelim = '.';
|
12920 | switch (name) {
|
12921 | case 'pmatrix':
|
12922 | case 'pmatrix*':
|
12923 | leftDelim = '(';
|
12924 | rightDelim = ')';
|
12925 | break;
|
12926 | case 'bmatrix':
|
12927 | case 'bmatrix*':
|
12928 | leftDelim = '[';
|
12929 | rightDelim = ']';
|
12930 | break;
|
12931 | case 'Bmatrix':
|
12932 | case 'Bmatrix*':
|
12933 | leftDelim = '\\lbrace';
|
12934 | rightDelim = '\\rbrace';
|
12935 | break;
|
12936 | case 'vmatrix':
|
12937 | case 'vmatrix*':
|
12938 | leftDelim = '\\vert';
|
12939 | rightDelim = '\\vert';
|
12940 | break;
|
12941 | case 'Vmatrix':
|
12942 | case 'Vmatrix*':
|
12943 | leftDelim = '\\Vert';
|
12944 | rightDelim = '\\Vert';
|
12945 | break;
|
12946 | case 'matrix':
|
12947 | case 'matrix*':
|
12948 |
|
12949 |
|
12950 | leftDelim = '.';
|
12951 | rightDelim = '.';
|
12952 | break;
|
12953 | }
|
12954 | return new ArrayAtom(name, array, rowGaps, {
|
12955 | mathstyleName: 'textstyle',
|
12956 | leftDelim,
|
12957 | rightDelim,
|
12958 | columns: (_a = args[0]) !== null && _a !== void 0 ? _a : [
|
12959 | { align: 'c' },
|
12960 | { align: 'c' },
|
12961 | { align: 'c' },
|
12962 | { align: 'c' },
|
12963 | { align: 'c' },
|
12964 | { align: 'c' },
|
12965 | { align: 'c' },
|
12966 | { align: 'c' },
|
12967 | { align: 'c' },
|
12968 | { align: 'c' },
|
12969 | ],
|
12970 | });
|
12971 | });
|
12972 | defineTabularEnvironment(['smallmatrix', 'smallmatrix*'], '[columns:colspec]', (name, array, rowGaps, args) => {
|
12973 | var _a;
|
12974 | return new ArrayAtom(name, array, rowGaps, {
|
12975 | mathstyleName: 'scriptstyle',
|
12976 | columns: (_a = args[0]) !== null && _a !== void 0 ? _a : [
|
12977 | { align: 'c' },
|
12978 | { align: 'c' },
|
12979 | { align: 'c' },
|
12980 | { align: 'c' },
|
12981 | { align: 'c' },
|
12982 | { align: 'c' },
|
12983 | { align: 'c' },
|
12984 | { align: 'c' },
|
12985 | { align: 'c' },
|
12986 | { align: 'c' },
|
12987 | ],
|
12988 | colSeparationType: 'small',
|
12989 | arraystretch: 0.5,
|
12990 | });
|
12991 | });
|
12992 |
|
12993 |
|
12994 | defineTabularEnvironment(['cases', 'dcases'], '', (name, array, rowGaps) => {
|
12995 |
|
12996 |
|
12997 |
|
12998 |
|
12999 |
|
13000 |
|
13001 |
|
13002 |
|
13003 |
|
13004 |
|
13005 | return new ArrayAtom(name, array, rowGaps, {
|
13006 | mathstyleName: name === 'dcases' ? 'displaystyle' : 'textstyle',
|
13007 | arraystretch: 1.2,
|
13008 | leftDelim: '\\lbrace',
|
13009 | rightDelim: '.',
|
13010 | columns: [{ align: 'l' }, { gap: 1 }, { align: 'l' }],
|
13011 | });
|
13012 | });
|
13013 |
|
13014 | defineTabularEnvironment('rcases', '', (name, array, rowGaps) => {
|
13015 | return new ArrayAtom(name, array, rowGaps, {
|
13016 | arraystretch: 1.2,
|
13017 | leftDelim: '.',
|
13018 | rightDelim: '\\rbrace',
|
13019 | columns: [{ align: 'l' }, { gap: 1 }, { align: 'l' }],
|
13020 | });
|
13021 | });
|
13022 |
|
13023 |
|
13024 |
|
13025 |
|
13026 |
|
13027 |
|
13028 |
|
13029 |
|
13030 |
|
13031 |
|
13032 | defineEnvironment('center', '', (name, array, rowGaps) => new ArrayAtom(name, array, rowGaps, { columns: [{ align: 'c' }] }));
|
13033 |
|
13034 |
|
13035 | defineFunction([
|
13036 | 'overrightarrow',
|
13037 | 'overleftarrow',
|
13038 | 'Overrightarrow',
|
13039 | 'overleftharpoon',
|
13040 | 'overrightharpoon',
|
13041 | 'overleftrightarrow',
|
13042 | 'overlinesegment',
|
13043 | 'overgroup',
|
13044 | ], '{:auto}', {
|
13045 | createAtom: (command, args, style) => new OverunderAtom(command, {
|
13046 | body: args[0],
|
13047 | skipBoundary: false,
|
13048 | supsubPlacement: 'over-under',
|
13049 | padded: true,
|
13050 | boxType: 'mrel',
|
13051 | style,
|
13052 |
|
13053 |
|
13054 | svgAbove: command.slice(1),
|
13055 | }),
|
13056 | });
|
13057 | defineFunction('overbrace', '{:auto}', {
|
13058 | createAtom: (command, args, style) => new OverunderAtom(command, {
|
13059 | body: args[0],
|
13060 | skipBoundary: false,
|
13061 | supsubPlacement: 'over-under',
|
13062 | padded: true,
|
13063 | boxType: 'mord',
|
13064 | style,
|
13065 | svgAbove: command.slice(1),
|
13066 | }),
|
13067 | });
|
13068 | defineFunction([
|
13069 | 'underrightarrow',
|
13070 | 'underleftarrow',
|
13071 | 'underleftrightarrow',
|
13072 | 'underlinesegment',
|
13073 | 'undergroup',
|
13074 | ], '{:auto}', {
|
13075 | createAtom: (command, args, style) => new OverunderAtom(command, {
|
13076 | body: args[0],
|
13077 | skipBoundary: false,
|
13078 | supsubPlacement: 'over-under',
|
13079 | padded: true,
|
13080 | boxType: 'mrel',
|
13081 | style,
|
13082 |
|
13083 |
|
13084 | svgBelow: command.slice(1),
|
13085 | }),
|
13086 | });
|
13087 | defineFunction(['underbrace'], '{:auto}', {
|
13088 | createAtom: (command, args, style) => new OverunderAtom(command, {
|
13089 | body: args[0],
|
13090 | skipBoundary: false,
|
13091 | supsubPlacement: 'over-under',
|
13092 | padded: true,
|
13093 | boxType: 'mord',
|
13094 | style,
|
13095 | svgBelow: command.slice(1),
|
13096 | }),
|
13097 | });
|
13098 | defineFunction([
|
13099 | 'xrightarrow',
|
13100 | 'xleftarrow',
|
13101 | 'xRightarrow',
|
13102 | 'xLeftarrow',
|
13103 | 'xleftharpoonup',
|
13104 | 'xleftharpoondown',
|
13105 | 'xrightharpoonup',
|
13106 | 'xrightharpoondown',
|
13107 | 'xlongequal',
|
13108 | 'xtwoheadleftarrow',
|
13109 | 'xtwoheadrightarrow',
|
13110 | 'xleftrightarrow',
|
13111 | 'xLeftrightarrow',
|
13112 | 'xrightleftharpoons',
|
13113 | 'xleftrightharpoons',
|
13114 | 'xhookleftarrow',
|
13115 | 'xhookrightarrow',
|
13116 | 'xmapsto',
|
13117 | 'xtofrom',
|
13118 | 'xrightleftarrows',
|
13119 | 'xrightequilibrium',
|
13120 | 'xleftequilibrium',
|
13121 | ], '[:auto]{:auto}', {
|
13122 | createAtom: (command, args, style) => {
|
13123 | var _a, _b;
|
13124 | return new OverunderAtom(command, {
|
13125 | style,
|
13126 |
|
13127 |
|
13128 | svgBody: command.slice(1),
|
13129 |
|
13130 | above: ((_a = args[1]) === null || _a === void 0 ? void 0 : _a.length) === 0 ? undefined : args[1],
|
13131 | below: (_b = args[0]) !== null && _b !== void 0 ? _b : null,
|
13132 | skipBoundary: false,
|
13133 | supsubPlacement: 'over-under',
|
13134 | padded: true,
|
13135 | boxType: 'mrel',
|
13136 | serialize: (atom, options) => command +
|
13137 | (!atom.hasEmptyBranch('below')
|
13138 | ? `[${atom.belowToLatex(options)}]`
|
13139 | : '') +
|
13140 | `{${atom.aboveToLatex(options)}}`,
|
13141 | });
|
13142 | },
|
13143 | });
|
13144 |
|
13145 | class SurdAtom extends Atom {
|
13146 | constructor(command, options) {
|
13147 | var _a;
|
13148 | super('surd', {
|
13149 | command,
|
13150 | mode: (_a = options.mode) !== null && _a !== void 0 ? _a : 'math',
|
13151 | style: options.style,
|
13152 | displayContainsHighlight: true,
|
13153 | });
|
13154 | this.body = options.body;
|
13155 | this.above = options.index;
|
13156 | }
|
13157 | serialize(options) {
|
13158 | let args = '';
|
13159 | if (this.above) {
|
13160 | args += `[${this.aboveToLatex(options)}]`;
|
13161 | }
|
13162 | args += `{${this.bodyToLatex(options)}}`;
|
13163 | return this.command + args;
|
13164 | }
|
13165 | render(parentContext) {
|
13166 |
|
13167 |
|
13168 | var _a;
|
13169 |
|
13170 |
|
13171 |
|
13172 |
|
13173 |
|
13174 |
|
13175 | const innerContext = new Context(parentContext, this.style, 'cramp');
|
13176 | const innerBox = (_a = Atom.createBox(innerContext, this.body, {
|
13177 | style: this.style,
|
13178 | newList: true,
|
13179 | })) !== null && _a !== void 0 ? _a : new Box(null);
|
13180 |
|
13181 |
|
13182 |
|
13183 | const factor = innerContext.scalingFactor;
|
13184 | const ruleWidth = innerContext.metrics.defaultRuleThickness / factor;
|
13185 |
|
13186 | const phi = parentContext.isDisplayStyle ? X_HEIGHT : ruleWidth;
|
13187 | const line = new Box(null, {
|
13188 | classes: 'ML__sqrt-line',
|
13189 | style: this.style,
|
13190 | height: ruleWidth,
|
13191 | });
|
13192 |
|
13193 |
|
13194 |
|
13195 |
|
13196 |
|
13197 | let lineClearance = factor * (ruleWidth + phi / 4);
|
13198 | const innerTotalHeight = Math.max(factor * 2 * phi, innerBox.height + innerBox.depth);
|
13199 | const minDelimiterHeight = innerTotalHeight + lineClearance + ruleWidth;
|
13200 | const delimContext = new Context(parentContext, this.style);
|
13201 | const delimBox = this.bind(delimContext, new Box(makeCustomSizedDelim('', '\\surd', minDelimiterHeight, false, delimContext), { classes: 'ML__sqrt-sign', style: this.style }));
|
13202 | if (!delimBox)
|
13203 | return null;
|
13204 | const delimDepth = delimBox.height + delimBox.depth - ruleWidth;
|
13205 |
|
13206 | if (delimDepth > innerBox.height + innerBox.depth + lineClearance) {
|
13207 | lineClearance =
|
13208 | (lineClearance + delimDepth - (innerBox.height + innerBox.depth)) / 2;
|
13209 | }
|
13210 |
|
13211 | delimBox.setTop(delimBox.height - innerBox.height - (lineClearance + ruleWidth));
|
13212 |
|
13213 |
|
13214 |
|
13215 | const bodyBox = new VBox({
|
13216 | firstBaseline: [
|
13217 | { box: new Box(innerBox) },
|
13218 | lineClearance - 2 * ruleWidth,
|
13219 | { box: line },
|
13220 | ruleWidth,
|
13221 | ],
|
13222 | }).wrap(parentContext);
|
13223 |
|
13224 |
|
13225 |
|
13226 |
|
13227 |
|
13228 |
|
13229 |
|
13230 |
|
13231 |
|
13232 |
|
13233 | const indexBox = Atom.createBox(new Context(parentContext, this.style, 'scriptscriptstyle'), this.above, {
|
13234 | style: this.style,
|
13235 | newList: true,
|
13236 | });
|
13237 | if (!indexBox) {
|
13238 |
|
13239 |
|
13240 |
|
13241 | const result = new Box([delimBox, bodyBox], {
|
13242 | classes: this.containsCaret ? 'ML__contains-caret' : '',
|
13243 | type: 'mord',
|
13244 | });
|
13245 | if (this.caret)
|
13246 | result.caret = this.caret;
|
13247 | return this.bind(parentContext, result.wrap(parentContext));
|
13248 | }
|
13249 |
|
13250 |
|
13251 |
|
13252 | const indexStack = new VBox({
|
13253 | shift: -0.6 *
|
13254 | (Math.max(delimBox.height, bodyBox.height) -
|
13255 | Math.max(delimBox.depth, bodyBox.depth)),
|
13256 | children: [{ box: indexBox }],
|
13257 | });
|
13258 |
|
13259 |
|
13260 | const result = new Box([new Box(indexStack, { classes: 'ML__sqrt-index' }), delimBox, bodyBox], { type: 'mord', classes: this.containsCaret ? 'ML__contains-caret' : '' });
|
13261 | result.height = delimBox.height;
|
13262 | result.depth = delimBox.depth;
|
13263 | if (this.caret)
|
13264 | result.caret = this.caret;
|
13265 | return this.bind(parentContext, result.wrap(parentContext));
|
13266 | }
|
13267 | }
|
13268 |
|
13269 | defineFunction([
|
13270 | 'arccos',
|
13271 | 'arcsin',
|
13272 | 'arctan',
|
13273 | 'arctg',
|
13274 | 'arcctg',
|
13275 | 'arg',
|
13276 | 'ch',
|
13277 | 'cos',
|
13278 | 'cosh',
|
13279 | 'cot',
|
13280 | 'coth',
|
13281 | 'ctg',
|
13282 | 'cth',
|
13283 | 'cotg',
|
13284 | 'csc',
|
13285 | 'cosec',
|
13286 | 'deg',
|
13287 | 'dim',
|
13288 | 'exp',
|
13289 | 'hom',
|
13290 | 'inf',
|
13291 | 'ker',
|
13292 | 'lg',
|
13293 | 'lb',
|
13294 | 'lg',
|
13295 |
|
13296 | 'ln',
|
13297 | 'log',
|
13298 | 'Pr',
|
13299 | 'sec',
|
13300 | 'sh',
|
13301 | 'sin',
|
13302 | 'sinh',
|
13303 | 'sup',
|
13304 | 'tan',
|
13305 | 'tanh',
|
13306 | 'tg',
|
13307 | 'th',
|
13308 | ], '', {
|
13309 | isFunction: true,
|
13310 | createAtom: (command, _args, style) => new OperatorAtom(command, command.slice(1), {
|
13311 | limits: 'adjacent',
|
13312 | isFunction: true,
|
13313 | variant: 'main',
|
13314 | variantStyle: 'up',
|
13315 | style,
|
13316 | }),
|
13317 | });
|
13318 | defineFunction(['liminf', 'limsup'], '', {
|
13319 | createAtom: (command, _args, style) => new OperatorAtom(command, { '\\liminf': 'lim inf', '\\limsup': 'lim sup' }[command], {
|
13320 | limits: 'over-under',
|
13321 | variant: 'main',
|
13322 | style,
|
13323 | }),
|
13324 | });
|
13325 | defineFunction(['lim', 'mod'], '', {
|
13326 | createAtom: (command, _args, style) => new OperatorAtom(command, command.slice(1), {
|
13327 | limits: 'over-under',
|
13328 | variant: 'main',
|
13329 | style,
|
13330 | }),
|
13331 | });
|
13332 |
|
13333 | defineFunction(['det', 'max', 'min'], '', {
|
13334 | isFunction: true,
|
13335 | createAtom: (command, _args, style) => new OperatorAtom(command, command.slice(1), {
|
13336 | limits: 'over-under',
|
13337 | isFunction: true,
|
13338 | variant: 'main',
|
13339 | style,
|
13340 | }),
|
13341 | });
|
13342 |
|
13343 | defineFunction('sqrt', '[index:auto]{radicand:auto}', {
|
13344 | createAtom: (command, args, style) => new SurdAtom(command, {
|
13345 | body: args[1],
|
13346 | index: args[0],
|
13347 | style,
|
13348 | }),
|
13349 | });
|
13350 |
|
13351 | defineFunction(['frac', 'dfrac', 'tfrac', 'cfrac', 'binom', 'dbinom', 'tbinom'], '{numerator}{denominator}', {
|
13352 | createAtom: (command, args, style) => {
|
13353 | const options = {
|
13354 | style,
|
13355 | };
|
13356 | switch (command) {
|
13357 | case '\\dfrac':
|
13358 | case '\\frac':
|
13359 | case '\\tfrac':
|
13360 | options.hasBarLine = true;
|
13361 | break;
|
13362 | case '\\atopfrac':
|
13363 | options.hasBarLine = false;
|
13364 | break;
|
13365 | case '\\dbinom':
|
13366 | case '\\binom':
|
13367 | case '\\tbinom':
|
13368 | options.hasBarLine = false;
|
13369 | options.leftDelim = '(';
|
13370 | options.rightDelim = ')';
|
13371 | break;
|
13372 | }
|
13373 | switch (command) {
|
13374 | case '\\dfrac':
|
13375 | case '\\dbinom':
|
13376 | options.mathstyleName = 'displaystyle';
|
13377 | break;
|
13378 | case '\\tfrac':
|
13379 | case '\\tbinom':
|
13380 | options.mathstyleName = 'textstyle';
|
13381 | break;
|
13382 | case '\\cfrac':
|
13383 | options.hasBarLine = true;
|
13384 | options.continuousFraction = true;
|
13385 | break;
|
13386 | }
|
13387 | return new GenfracAtom(command, args[0], args[1], options);
|
13388 | },
|
13389 | });
|
13390 | defineFunction(['over', 'atop', 'choose'], '', {
|
13391 | infix: true,
|
13392 | createAtom: (command, args, style) => {
|
13393 | let leftDelim = undefined;
|
13394 | let rightDelim = undefined;
|
13395 | if (command === '\\choose') {
|
13396 | leftDelim = '(';
|
13397 | rightDelim = ')';
|
13398 | }
|
13399 | return new GenfracAtom(command, args[0], args[1], {
|
13400 | hasBarLine: command === '\\over',
|
13401 | leftDelim,
|
13402 | rightDelim,
|
13403 | style,
|
13404 | serialize: (atom, options) => `{${atom.aboveToLatex(options)}${atom.command} ${atom.belowToLatex(options)}}`,
|
13405 | });
|
13406 | },
|
13407 | });
|
13408 |
|
13409 |
|
13410 |
|
13411 |
|
13412 | defineFunction('pdiff', '{numerator}{denominator}', {
|
13413 | createAtom: (command, args, style) => new GenfracAtom(command, args[0], args[1], {
|
13414 | hasBarLine: true,
|
13415 | numerPrefix: '\u2202',
|
13416 | denomPrefix: '\u2202',
|
13417 | style,
|
13418 | }),
|
13419 | });
|
13420 |
|
13421 | defineFunction([
|
13422 | 'sum',
|
13423 | 'prod',
|
13424 | 'bigcup',
|
13425 | 'bigcap',
|
13426 | 'coprod',
|
13427 | 'bigvee',
|
13428 | 'bigwedge',
|
13429 | 'biguplus',
|
13430 | 'bigotimes',
|
13431 | 'bigoplus',
|
13432 | 'bigodot',
|
13433 | 'bigsqcup',
|
13434 | 'smallint',
|
13435 | 'intop',
|
13436 | ], '', {
|
13437 | createAtom: (command, args, style) => new OperatorAtom(command, {
|
13438 | coprod: '\u2210',
|
13439 | bigvee: '\u22C1',
|
13440 | bigwedge: '\u22C0',
|
13441 | biguplus: '\u2A04',
|
13442 | bigcap: '\u22C2',
|
13443 | bigcup: '\u22C3',
|
13444 | intop: '\u222B',
|
13445 | prod: '\u220F',
|
13446 | sum: '\u2211',
|
13447 | bigotimes: '\u2A02',
|
13448 | bigoplus: '\u2A01',
|
13449 | bigodot: '\u2A00',
|
13450 | bigsqcup: '\u2A06',
|
13451 | smallint: '\u222B',
|
13452 | }[command.slice(1)], {
|
13453 | isExtensibleSymbol: true,
|
13454 | limits: 'auto',
|
13455 | variant: 'main',
|
13456 | style,
|
13457 | }),
|
13458 | });
|
13459 |
|
13460 |
|
13461 | const EXTENSIBLE_SYMBOLS = {
|
13462 | int: '\u222B',
|
13463 | iint: '\u222C',
|
13464 | iiint: '\u222D',
|
13465 | oint: '\u222E',
|
13466 | oiint: '\u222F',
|
13467 | oiiint: '\u2230',
|
13468 | intclockwise: '\u2231',
|
13469 | varointclockwise: '\u2232',
|
13470 | ointctrclockwise: '\u2233',
|
13471 | intctrclockwise: '\u2A11',
|
13472 | sqcup: '\u2294',
|
13473 | sqcap: '\u2293',
|
13474 | uplus: '\u228E',
|
13475 | wr: '\u2240',
|
13476 | amalg: '\u2A3F',
|
13477 | Cap: '\u22D2',
|
13478 | Cup: '\u22D3',
|
13479 | doublecap: '\u22D2',
|
13480 | doublecup: '\u22D3',
|
13481 | };
|
13482 | defineFunction(Object.keys(EXTENSIBLE_SYMBOLS), '', {
|
13483 | createAtom: (command, _args, style) => new OperatorAtom(command, EXTENSIBLE_SYMBOLS[command.slice(1)], {
|
13484 | limits: 'adjacent',
|
13485 | isExtensibleSymbol: true,
|
13486 | style,
|
13487 | variant: { '\u22D2': 'ams', '\u22D3': 'ams' }[EXTENSIBLE_SYMBOLS[command.slice(1)]],
|
13488 | }),
|
13489 | });
|
13490 | defineFunction(['Re', 'Im'], '', {
|
13491 | createAtom: (command, _args, style) => new OperatorAtom(command, { '\\Re': '\u211C', '\\Im': '\u2111' }[command], {
|
13492 | limits: 'adjacent',
|
13493 | style,
|
13494 | isFunction: true,
|
13495 | variant: 'fraktur',
|
13496 | }),
|
13497 | });
|
13498 | defineFunction('middle', '{:delim}', {
|
13499 | createAtom: (command, args, style) => new DelimAtom(command, args[0], { size: 1, style }),
|
13500 | });
|
13501 |
|
13502 |
|
13503 |
|
13504 |
|
13505 |
|
13506 |
|
13507 |
|
13508 |
|
13509 |
|
13510 |
|
13511 |
|
13512 |
|
13513 |
|
13514 |
|
13515 |
|
13516 |
|
13517 |
|
13518 |
|
13519 |
|
13520 |
|
13521 |
|
13522 |
|
13523 |
|
13524 |
|
13525 |
|
13526 |
|
13527 |
|
13528 |
|
13529 |
|
13530 |
|
13531 |
|
13532 |
|
13533 |
|
13534 | class ChemAtom extends Atom {
|
13535 | constructor(command, arg) {
|
13536 | super('chem', { command, mode: 'math' });
|
13537 | const tex = texify.go(mhchemParser.go(arg, command === '\\pu' ? 'pu' : 'ce'), false);
|
13538 | this.body = parseLatex(tex);
|
13539 | this.verbatimLatex = command + '{' + arg + '}';
|
13540 | this.captureSelection = true;
|
13541 | }
|
13542 | render(context) {
|
13543 | const box = Atom.createBox(context, this.body, {
|
13544 | type: 'chem',
|
13545 | newList: true,
|
13546 | });
|
13547 | if (this.caret)
|
13548 | box.caret = this.caret;
|
13549 |
|
13550 |
|
13551 |
|
13552 | return this.bind(context, box);
|
13553 | }
|
13554 | serialize(_options) {
|
13555 | return this.verbatimLatex;
|
13556 | }
|
13557 | }
|
13558 | defineFunction(['ce', 'pu'], '{chemformula:balanced-string}', {
|
13559 | createAtom: (command, args, _style) => new ChemAtom(command, args[0]),
|
13560 | });
|
13561 |
|
13562 |
|
13563 |
|
13564 |
|
13565 |
|
13566 |
|
13567 |
|
13568 |
|
13569 |
|
13570 |
|
13571 |
|
13572 |
|
13573 |
|
13574 |
|
13575 |
|
13576 |
|
13577 |
|
13578 |
|
13579 |
|
13580 |
|
13581 |
|
13582 |
|
13583 |
|
13584 |
|
13585 |
|
13586 |
|
13587 |
|
13588 |
|
13589 | var mhchemParser = {
|
13590 |
|
13591 |
|
13592 |
|
13593 |
|
13594 |
|
13595 |
|
13596 | go: function (input, stateMachine) {
|
13597 | if (!input) {
|
13598 | return [];
|
13599 | }
|
13600 | if (stateMachine === undefined) {
|
13601 | stateMachine = 'ce';
|
13602 | }
|
13603 | var state = '0';
|
13604 |
|
13605 |
|
13606 |
|
13607 |
|
13608 |
|
13609 |
|
13610 |
|
13611 |
|
13612 |
|
13613 |
|
13614 |
|
13615 |
|
13616 |
|
13617 |
|
13618 |
|
13619 |
|
13620 |
|
13621 |
|
13622 |
|
13623 |
|
13624 |
|
13625 |
|
13626 |
|
13627 |
|
13628 |
|
13629 |
|
13630 |
|
13631 |
|
13632 |
|
13633 |
|
13634 |
|
13635 |
|
13636 |
|
13637 |
|
13638 | var buffer = {};
|
13639 | buffer['parenthesisLevel'] = 0;
|
13640 | input = input.replace(/\n/g, ' ');
|
13641 | input = input.replace(/[\u2212\u2013\u2014\u2010]/g, '-');
|
13642 | input = input.replace(/[\u2026]/g, '...');
|
13643 |
|
13644 |
|
13645 |
|
13646 |
|
13647 | var lastInput;
|
13648 | var watchdog = 10;
|
13649 |
|
13650 | var output = [];
|
13651 | while (true) {
|
13652 | if (lastInput !== input) {
|
13653 | watchdog = 10;
|
13654 | lastInput = input;
|
13655 | }
|
13656 | else {
|
13657 | watchdog--;
|
13658 | }
|
13659 |
|
13660 |
|
13661 |
|
13662 | var machine = mhchemParser.stateMachines[stateMachine];
|
13663 | var t = machine.transitions[state] || machine.transitions['*'];
|
13664 | iterateTransitions: for (var i = 0; i < t.length; i++) {
|
13665 | var matches = mhchemParser.patterns.match_(t[i].pattern, input);
|
13666 | if (matches) {
|
13667 |
|
13668 |
|
13669 |
|
13670 | var task = t[i].task;
|
13671 | for (var iA = 0; iA < task.action_.length; iA++) {
|
13672 | var o;
|
13673 |
|
13674 |
|
13675 |
|
13676 | if (machine.actions[task.action_[iA].type_]) {
|
13677 | o = machine.actions[task.action_[iA].type_](buffer, matches.match_, task.action_[iA].option);
|
13678 | }
|
13679 | else if (mhchemParser.actions[task.action_[iA].type_]) {
|
13680 | o = mhchemParser.actions[task.action_[iA].type_](buffer, matches.match_, task.action_[iA].option);
|
13681 | }
|
13682 | else {
|
13683 | throw [
|
13684 | 'MhchemBugA',
|
13685 | 'mhchem bug A. Please report. (' + task.action_[iA].type_ + ')',
|
13686 | ];
|
13687 | }
|
13688 |
|
13689 |
|
13690 |
|
13691 | mhchemParser.concatArray(output, o);
|
13692 | }
|
13693 |
|
13694 |
|
13695 |
|
13696 |
|
13697 |
|
13698 |
|
13699 | state = task.nextState || state;
|
13700 | if (input.length > 0) {
|
13701 | if (!task.revisit) {
|
13702 | input = matches.remainder;
|
13703 | }
|
13704 | if (!task.toContinue) {
|
13705 | break iterateTransitions;
|
13706 | }
|
13707 | }
|
13708 | else {
|
13709 | return output;
|
13710 | }
|
13711 | }
|
13712 | }
|
13713 |
|
13714 |
|
13715 |
|
13716 | if (watchdog <= 0) {
|
13717 | throw ['MhchemBugU', 'mhchem bug U. Please report.'];
|
13718 | }
|
13719 | }
|
13720 | },
|
13721 | concatArray: function (a, b) {
|
13722 | if (b) {
|
13723 | if (Array.isArray(b)) {
|
13724 | for (var iB = 0; iB < b.length; iB++) {
|
13725 | a.push(b[iB]);
|
13726 | }
|
13727 | }
|
13728 | else {
|
13729 | a.push(b);
|
13730 | }
|
13731 | }
|
13732 | },
|
13733 | patterns: {
|
13734 |
|
13735 |
|
13736 |
|
13737 |
|
13738 | patterns: {
|
13739 |
|
13740 | 'empty': /^$/,
|
13741 | 'else': /^./,
|
13742 | 'else2': /^./,
|
13743 | 'space': /^\s/,
|
13744 | 'space A': /^\s(?=[A-Z\\$])/,
|
13745 | 'space$': /^\s$/,
|
13746 | 'a-z': /^[a-z]/,
|
13747 | 'x': /^x/,
|
13748 | 'x$': /^x$/,
|
13749 | 'i$': /^i$/,
|
13750 | 'letters': /^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/,
|
13751 | '\\greek': /^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/,
|
13752 | 'one lowercase latin letter $': /^(?:([a-z])(?:$|[^a-zA-Z]))$/,
|
13753 | '$one lowercase latin letter$ $': /^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/,
|
13754 | 'one lowercase greek letter $': /^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/,
|
13755 | 'digits': /^[0-9]+/,
|
13756 | '-9.,9': /^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/,
|
13757 | '-9.,9 no missing 0': /^[+\-]?[0-9]+(?:[.,][0-9]+)?/,
|
13758 | '(-)(9.,9)(e)(99)': function (input) {
|
13759 | var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:([eE]|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/);
|
13760 | if (m && m[0]) {
|
13761 | return {
|
13762 | match_: m.splice(1),
|
13763 | remainder: input.substr(m[0].length),
|
13764 | };
|
13765 | }
|
13766 | return null;
|
13767 | },
|
13768 | '(-)(9)^(-9)': function (input) {
|
13769 | var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/);
|
13770 | if (m && m[0]) {
|
13771 | return {
|
13772 | match_: m.splice(1),
|
13773 | remainder: input.substr(m[0].length),
|
13774 | };
|
13775 | }
|
13776 | return null;
|
13777 | },
|
13778 | 'state of aggregation $': function (input) {
|
13779 |
|
13780 | var a = mhchemParser.patterns.findObserveGroups(input, '', /^\([a-z]{1,3}(?=[\),])/, ')', '');
|
13781 | if (a && a.remainder.match(/^($|[\s,;\)\]\}])/)) {
|
13782 | return a;
|
13783 | }
|
13784 | var m = input.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/);
|
13785 | if (m) {
|
13786 | return {
|
13787 | match_: m[0],
|
13788 | remainder: input.substr(m[0].length),
|
13789 | };
|
13790 | }
|
13791 | return null;
|
13792 | },
|
13793 | '_{(state of aggregation)}$': /^_\{(\([a-z]{1,3}\))\}/,
|
13794 | '{[(': /^(?:\\\{|\[|\()/,
|
13795 | ')]}': /^(?:\)|\]|\\\})/,
|
13796 | ', ': /^[,;]\s*/,
|
13797 | ',': /^[,;]/,
|
13798 | '.': /^[.]/,
|
13799 | '. ': /^([.\u22C5\u00B7\u2022])\s*/,
|
13800 | '...': /^\.\.\.(?=$|[^.])/,
|
13801 | '* ': /^([*])\s*/,
|
13802 | '^{(...)}': function (input) {
|
13803 | return mhchemParser.patterns.findObserveGroups(input, '^{', '', '', '}');
|
13804 | },
|
13805 | '^($...$)': function (input) {
|
13806 | return mhchemParser.patterns.findObserveGroups(input, '^', '$', '$', '');
|
13807 | },
|
13808 | '^a': /^\^([0-9]+|[^\\_])/,
|
13809 | '^\\x{}{}': function (input) {
|
13810 | return mhchemParser.patterns.findObserveGroups(input, '^', /^\\[a-zA-Z]+\{/, '}', '', '', '{', '}', '', true);
|
13811 | },
|
13812 | '^\\x{}': function (input) {
|
13813 | return mhchemParser.patterns.findObserveGroups(input, '^', /^\\[a-zA-Z]+\{/, '}', '');
|
13814 | },
|
13815 | '^\\x': /^\^(\\[a-zA-Z]+)\s*/,
|
13816 | '^(-1)': /^\^(-?\d+)/,
|
13817 | "'": /^'/,
|
13818 | '_{(...)}': function (input) {
|
13819 | return mhchemParser.patterns.findObserveGroups(input, '_{', '', '', '}');
|
13820 | },
|
13821 | '_($...$)': function (input) {
|
13822 | return mhchemParser.patterns.findObserveGroups(input, '_', '$', '$', '');
|
13823 | },
|
13824 | '_9': /^_([+\-]?[0-9]+|[^\\])/,
|
13825 | '_\\x{}{}': function (input) {
|
13826 | return mhchemParser.patterns.findObserveGroups(input, '_', /^\\[a-zA-Z]+\{/, '}', '', '', '{', '}', '', true);
|
13827 | },
|
13828 | '_\\x{}': function (input) {
|
13829 | return mhchemParser.patterns.findObserveGroups(input, '_', /^\\[a-zA-Z]+\{/, '}', '');
|
13830 | },
|
13831 | '_\\x': /^_(\\[a-zA-Z]+)\s*/,
|
13832 | '^_': /^(?:\^(?=_)|\_(?=\^)|[\^_]$)/,
|
13833 | '{}': /^\{\}/,
|
13834 | '{...}': function (input) {
|
13835 | return mhchemParser.patterns.findObserveGroups(input, '', '{', '}', '');
|
13836 | },
|
13837 | '{(...)}': function (input) {
|
13838 | return mhchemParser.patterns.findObserveGroups(input, '{', '', '', '}');
|
13839 | },
|
13840 | '$...$': function (input) {
|
13841 | return mhchemParser.patterns.findObserveGroups(input, '', '$', '$', '');
|
13842 | },
|
13843 | '${(...)}$': function (input) {
|
13844 | return mhchemParser.patterns.findObserveGroups(input, '${', '', '', '}$');
|
13845 | },
|
13846 | '$(...)$': function (input) {
|
13847 | return mhchemParser.patterns.findObserveGroups(input, '$', '', '', '$');
|
13848 | },
|
13849 | '=<>': /^[=<>]/,
|
13850 | '#': /^[#\u2261]/,
|
13851 | '+': /^\+/,
|
13852 | '-$': /^-(?=[\s_},;\]/]|$|\([a-z]+\))/,
|
13853 | '-9': /^-(?=[0-9])/,
|
13854 | '- orbital overlap': /^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/,
|
13855 | '-': /^-/,
|
13856 | 'pm-operator': /^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,
|
13857 | 'operator': /^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,
|
13858 | 'arrowUpDown': /^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,
|
13859 | '\\bond{(...)}': function (input) {
|
13860 | return mhchemParser.patterns.findObserveGroups(input, '\\bond{', '', '', '}');
|
13861 | },
|
13862 | '->': /^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,
|
13863 | 'CMT': /^[CMT](?=\[)/,
|
13864 | '[(...)]': function (input) {
|
13865 | return mhchemParser.patterns.findObserveGroups(input, '[', '', '', ']');
|
13866 | },
|
13867 | '1st-level escape': /^(&|\\\\|\\hline)\s*/,
|
13868 | '\\,': /^(?:\\[,\ ;:])/,
|
13869 | '\\x{}{}': function (input) {
|
13870 | return mhchemParser.patterns.findObserveGroups(input, '', /^\\[a-zA-Z]+\{/, '}', '', '', '{', '}', '', true);
|
13871 | },
|
13872 | '\\x{}': function (input) {
|
13873 | return mhchemParser.patterns.findObserveGroups(input, '', /^\\[a-zA-Z]+\{/, '}', '');
|
13874 | },
|
13875 | '\\ca': /^\\ca(?:\s+|(?![a-zA-Z]))/,
|
13876 | '\\x': /^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/,
|
13877 | 'orbital': /^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,
|
13878 | 'others': /^[\/~|]/,
|
13879 | '\\frac{(...)}': function (input) {
|
13880 | return mhchemParser.patterns.findObserveGroups(input, '\\frac{', '', '', '}', '{', '', '', '}');
|
13881 | },
|
13882 | '\\overset{(...)}': function (input) {
|
13883 | return mhchemParser.patterns.findObserveGroups(input, '\\overset{', '', '', '}', '{', '', '', '}');
|
13884 | },
|
13885 | '\\underset{(...)}': function (input) {
|
13886 | return mhchemParser.patterns.findObserveGroups(input, '\\underset{', '', '', '}', '{', '', '', '}');
|
13887 | },
|
13888 | '\\underbrace{(...)}': function (input) {
|
13889 | return mhchemParser.patterns.findObserveGroups(input, '\\underbrace{', '', '', '}_', '{', '', '', '}');
|
13890 | },
|
13891 | '\\color{(...)}0': function (input) {
|
13892 | return mhchemParser.patterns.findObserveGroups(input, '\\color{', '', '', '}');
|
13893 | },
|
13894 | '\\color{(...)}{(...)}1': function (input) {
|
13895 | return mhchemParser.patterns.findObserveGroups(input, '\\color{', '', '', '}', '{', '', '', '}');
|
13896 | },
|
13897 | '\\color(...){(...)}2': function (input) {
|
13898 | return mhchemParser.patterns.findObserveGroups(input, '\\color', '\\', '', /^(?=\{)/, '{', '', '', '}');
|
13899 | },
|
13900 | '\\ce{(...)}': function (input) {
|
13901 | return mhchemParser.patterns.findObserveGroups(input, '\\ce{', '', '', '}');
|
13902 | },
|
13903 | 'oxidation$': /^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,
|
13904 | 'd-oxidation$': /^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,
|
13905 | 'roman numeral': /^[IVX]+/,
|
13906 | '1/2$': /^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,
|
13907 | 'amount': function (input) {
|
13908 | var match;
|
13909 |
|
13910 | match = input.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/);
|
13911 | if (match) {
|
13912 | return {
|
13913 | match_: match[0],
|
13914 | remainder: input.substr(match[0].length),
|
13915 | };
|
13916 | }
|
13917 | var a = mhchemParser.patterns.findObserveGroups(input, '', '$', '$', '');
|
13918 | if (a) {
|
13919 |
|
13920 | match = a.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/);
|
13921 | if (match) {
|
13922 | return {
|
13923 | match_: match[0],
|
13924 | remainder: input.substr(match[0].length),
|
13925 | };
|
13926 | }
|
13927 | }
|
13928 | return null;
|
13929 | },
|
13930 | 'amount2': function (input) {
|
13931 | return this['amount'](input);
|
13932 | },
|
13933 | '(KV letters),': /^(?:[A-Z][a-z]{0,2}|i)(?=,)/,
|
13934 | 'formula$': function (input) {
|
13935 | if (input.match(/^\([a-z]+\)$/)) {
|
13936 | return null;
|
13937 | }
|
13938 | var match = input.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/);
|
13939 | if (match) {
|
13940 | return {
|
13941 | match_: match[0],
|
13942 | remainder: input.substr(match[0].length),
|
13943 | };
|
13944 | }
|
13945 | return null;
|
13946 | },
|
13947 | 'uprightEntities': /^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/,
|
13948 | '/': /^\s*(\/)\s*/,
|
13949 | '//': /^\s*(\/\/)\s*/,
|
13950 | '*': /^\s*[*.]\s*/,
|
13951 | },
|
13952 | findObserveGroups: function (input, begExcl, begIncl, endIncl, endExcl, beg2Excl, beg2Incl, end2Incl, end2Excl, combine) {
|
13953 |
|
13954 | var _match = function (input, pattern) {
|
13955 | if (typeof pattern === 'string') {
|
13956 | if (input.indexOf(pattern) !== 0) {
|
13957 | return null;
|
13958 | }
|
13959 | return pattern;
|
13960 | }
|
13961 | else {
|
13962 | var match = input.match(pattern);
|
13963 | if (!match) {
|
13964 | return null;
|
13965 | }
|
13966 | return match[0];
|
13967 | }
|
13968 | };
|
13969 |
|
13970 | var _findObserveGroups = function (input, i, endChars) {
|
13971 | var braces = 0;
|
13972 | while (i < input.length) {
|
13973 | var a = input.charAt(i);
|
13974 | var match = _match(input.substr(i), endChars);
|
13975 | if (match !== null && braces === 0) {
|
13976 | return {
|
13977 | endMatchBegin: i,
|
13978 | endMatchEnd: i + match.length,
|
13979 | };
|
13980 | }
|
13981 | else if (a === '{') {
|
13982 | braces++;
|
13983 | }
|
13984 | else if (a === '}') {
|
13985 | if (braces === 0) {
|
13986 | throw [
|
13987 | 'ExtraCloseMissingOpen',
|
13988 | 'Extra close brace or missing open brace',
|
13989 | ];
|
13990 | }
|
13991 | else {
|
13992 | braces--;
|
13993 | }
|
13994 | }
|
13995 | i++;
|
13996 | }
|
13997 | if (braces > 0) {
|
13998 | return null;
|
13999 | }
|
14000 | return null;
|
14001 | };
|
14002 | var match = _match(input, begExcl);
|
14003 | if (match === null) {
|
14004 | return null;
|
14005 | }
|
14006 | input = input.substr(match.length);
|
14007 | match = _match(input, begIncl);
|
14008 | if (match === null) {
|
14009 | return null;
|
14010 | }
|
14011 | var e = _findObserveGroups(input, match.length, endIncl || endExcl);
|
14012 | if (e === null) {
|
14013 | return null;
|
14014 | }
|
14015 | var match1 = input.substring(0, endIncl ? e.endMatchEnd : e.endMatchBegin);
|
14016 | if (!(beg2Excl || beg2Incl)) {
|
14017 | return {
|
14018 | match_: match1,
|
14019 | remainder: input.substr(e.endMatchEnd),
|
14020 | };
|
14021 | }
|
14022 | else {
|
14023 | var group2 = this.findObserveGroups(input.substr(e.endMatchEnd), beg2Excl, beg2Incl, end2Incl, end2Excl);
|
14024 | if (group2 === null) {
|
14025 | return null;
|
14026 | }
|
14027 |
|
14028 | var matchRet = [match1, group2.match_];
|
14029 | return {
|
14030 | match_: combine ? matchRet.join('') : matchRet,
|
14031 | remainder: group2.remainder,
|
14032 | };
|
14033 | }
|
14034 | },
|
14035 |
|
14036 |
|
14037 |
|
14038 |
|
14039 |
|
14040 | match_: function (m, input) {
|
14041 | var pattern = mhchemParser.patterns.patterns[m];
|
14042 | if (pattern === undefined) {
|
14043 | throw ['MhchemBugP', 'mhchem bug P. Please report. (' + m + ')'];
|
14044 | }
|
14045 | else if (typeof pattern === 'function') {
|
14046 | return mhchemParser.patterns.patterns[m](input);
|
14047 | }
|
14048 | else {
|
14049 |
|
14050 | var match = input.match(pattern);
|
14051 | if (match) {
|
14052 | var mm;
|
14053 | if (match[2]) {
|
14054 | mm = [match[1], match[2]];
|
14055 | }
|
14056 | else if (match[1]) {
|
14057 | mm = match[1];
|
14058 | }
|
14059 | else {
|
14060 | mm = match[0];
|
14061 | }
|
14062 | return {
|
14063 | match_: mm,
|
14064 | remainder: input.substr(match[0].length),
|
14065 | };
|
14066 | }
|
14067 | return null;
|
14068 | }
|
14069 | },
|
14070 | },
|
14071 |
|
14072 |
|
14073 |
|
14074 | actions: {
|
14075 | 'a=': function (buffer, m) {
|
14076 | buffer.a = (buffer.a || '') + m;
|
14077 | },
|
14078 | 'b=': function (buffer, m) {
|
14079 | buffer.b = (buffer.b || '') + m;
|
14080 | },
|
14081 | 'p=': function (buffer, m) {
|
14082 | buffer.p = (buffer.p || '') + m;
|
14083 | },
|
14084 | 'o=': function (buffer, m) {
|
14085 | buffer.o = (buffer.o || '') + m;
|
14086 | },
|
14087 | 'q=': function (buffer, m) {
|
14088 | buffer.q = (buffer.q || '') + m;
|
14089 | },
|
14090 | 'd=': function (buffer, m) {
|
14091 | buffer.d = (buffer.d || '') + m;
|
14092 | },
|
14093 | 'rm=': function (buffer, m) {
|
14094 | buffer.rm = (buffer.rm || '') + m;
|
14095 | },
|
14096 | 'text=': function (buffer, m) {
|
14097 | buffer.text_ = (buffer.text_ || '') + m;
|
14098 | },
|
14099 | 'insert': function (buffer, m, a) {
|
14100 | return { type_: a };
|
14101 | },
|
14102 | 'insert+p1': function (buffer, m, a) {
|
14103 | return { type_: a, p1: m };
|
14104 | },
|
14105 | 'insert+p1+p2': function (buffer, m, a) {
|
14106 | return { type_: a, p1: m[0], p2: m[1] };
|
14107 | },
|
14108 | 'copy': function (buffer, m) {
|
14109 | return m;
|
14110 | },
|
14111 | 'rm': function (buffer, m) {
|
14112 | return { type_: 'rm', p1: m || '' };
|
14113 | },
|
14114 | 'text': function (buffer, m) {
|
14115 | return mhchemParser.go(m, 'text');
|
14116 | },
|
14117 | '{text}': function (buffer, m) {
|
14118 | var ret = ['{'];
|
14119 | mhchemParser.concatArray(ret, mhchemParser.go(m, 'text'));
|
14120 | ret.push('}');
|
14121 | return ret;
|
14122 | },
|
14123 | 'tex-math': function (buffer, m) {
|
14124 | return mhchemParser.go(m, 'tex-math');
|
14125 | },
|
14126 | 'tex-math tight': function (buffer, m) {
|
14127 | return mhchemParser.go(m, 'tex-math tight');
|
14128 | },
|
14129 | 'bond': function (buffer, m, k) {
|
14130 | return { type_: 'bond', kind_: k || m };
|
14131 | },
|
14132 | 'color0-output': function (buffer, m) {
|
14133 | return { type_: 'color0', color: m[0] };
|
14134 | },
|
14135 | 'ce': function (buffer, m) {
|
14136 | return mhchemParser.go(m);
|
14137 | },
|
14138 | '1/2': function (buffer, m) {
|
14139 |
|
14140 | var ret = [];
|
14141 | if (m.match(/^[+\-]/)) {
|
14142 | ret.push(m.substr(0, 1));
|
14143 | m = m.substr(1);
|
14144 | }
|
14145 | var n = m.match(/^([0-9]+|\$[a-z]\$|[a-z])\/([0-9]+)(\$[a-z]\$|[a-z])?$/);
|
14146 | n[1] = n[1].replace(/\$/g, '');
|
14147 | ret.push({ type_: 'frac', p1: n[1], p2: n[2] });
|
14148 | if (n[3]) {
|
14149 | n[3] = n[3].replace(/\$/g, '');
|
14150 | ret.push({ type_: 'tex-math', p1: n[3] });
|
14151 | }
|
14152 | return ret;
|
14153 | },
|
14154 | '9,9': function (buffer, m) {
|
14155 | return mhchemParser.go(m, '9,9');
|
14156 | },
|
14157 | },
|
14158 |
|
14159 |
|
14160 |
|
14161 |
|
14162 |
|
14163 | createTransitions: function (o) {
|
14164 | var pattern, state;
|
14165 |
|
14166 | var stateArray;
|
14167 | var i;
|
14168 |
|
14169 |
|
14170 |
|
14171 |
|
14172 | var transitions = {};
|
14173 | for (pattern in o) {
|
14174 | for (state in o[pattern]) {
|
14175 | stateArray = state.split('|');
|
14176 | o[pattern][state].stateArray = stateArray;
|
14177 | for (i = 0; i < stateArray.length; i++) {
|
14178 | transitions[stateArray[i]] = [];
|
14179 | }
|
14180 | }
|
14181 | }
|
14182 |
|
14183 |
|
14184 |
|
14185 | for (pattern in o) {
|
14186 | for (state in o[pattern]) {
|
14187 | stateArray = o[pattern][state].stateArray || [];
|
14188 | for (i = 0; i < stateArray.length; i++) {
|
14189 |
|
14190 |
|
14191 |
|
14192 |
|
14193 |
|
14194 | var p = o[pattern][state];
|
14195 | if (p.action_) {
|
14196 | p.action_ = [].concat(p.action_);
|
14197 | for (var k = 0; k < p.action_.length; k++) {
|
14198 | if (typeof p.action_[k] === 'string') {
|
14199 | p.action_[k] = { type_: p.action_[k] };
|
14200 | }
|
14201 | }
|
14202 | }
|
14203 | else {
|
14204 | p.action_ = [];
|
14205 | }
|
14206 |
|
14207 |
|
14208 |
|
14209 | var patternArray = pattern.split('|');
|
14210 | for (var j = 0; j < patternArray.length; j++) {
|
14211 | if (stateArray[i] === '*') {
|
14212 |
|
14213 | for (var t in transitions) {
|
14214 | transitions[t].push({
|
14215 | pattern: patternArray[j],
|
14216 | task: p,
|
14217 | });
|
14218 | }
|
14219 | }
|
14220 | else {
|
14221 | transitions[stateArray[i]].push({
|
14222 | pattern: patternArray[j],
|
14223 | task: p,
|
14224 | });
|
14225 | }
|
14226 | }
|
14227 | }
|
14228 | }
|
14229 | }
|
14230 | return transitions;
|
14231 | },
|
14232 | stateMachines: {},
|
14233 | };
|
14234 |
|
14235 |
|
14236 |
|
14237 | mhchemParser.stateMachines = {
|
14238 |
|
14239 |
|
14240 |
|
14241 |
|
14242 | 'ce': {
|
14243 |
|
14244 | transitions: mhchemParser.createTransitions({
|
14245 | 'empty': {
|
14246 | '*': { action_: 'output' },
|
14247 | },
|
14248 | 'else': {
|
14249 | '0|1|2': {
|
14250 | action_: 'beginsWithBond=false',
|
14251 | revisit: true,
|
14252 | toContinue: true,
|
14253 | },
|
14254 | },
|
14255 | 'oxidation$': {
|
14256 | '0': { action_: 'oxidation-output' },
|
14257 | },
|
14258 | 'CMT': {
|
14259 | r: { action_: 'rdt=', nextState: 'rt' },
|
14260 | rd: { action_: 'rqt=', nextState: 'rdt' },
|
14261 | },
|
14262 | 'arrowUpDown': {
|
14263 | '0|1|2|as': {
|
14264 | action_: ['sb=false', 'output', 'operator'],
|
14265 | nextState: '1',
|
14266 | },
|
14267 | },
|
14268 | 'uprightEntities': {
|
14269 | '0|1|2': { action_: ['o=', 'output'], nextState: '1' },
|
14270 | },
|
14271 | 'orbital': {
|
14272 | '0|1|2|3': { action_: 'o=', nextState: 'o' },
|
14273 | },
|
14274 | '->': {
|
14275 | '0|1|2|3': { action_: 'r=', nextState: 'r' },
|
14276 | 'a|as': { action_: ['output', 'r='], nextState: 'r' },
|
14277 | '*': { action_: ['output', 'r='], nextState: 'r' },
|
14278 | },
|
14279 | '+': {
|
14280 | 'o': { action_: 'd= kv', nextState: 'd' },
|
14281 | 'd|D': { action_: 'd=', nextState: 'd' },
|
14282 | 'q': { action_: 'd=', nextState: 'qd' },
|
14283 | 'qd|qD': { action_: 'd=', nextState: 'qd' },
|
14284 | 'dq': { action_: ['output', 'd='], nextState: 'd' },
|
14285 | '3': {
|
14286 | action_: ['sb=false', 'output', 'operator'],
|
14287 | nextState: '0',
|
14288 | },
|
14289 | },
|
14290 | 'amount': {
|
14291 | '0|2': { action_: 'a=', nextState: 'a' },
|
14292 | },
|
14293 | 'pm-operator': {
|
14294 | '0|1|2|a|as': {
|
14295 | action_: [
|
14296 | 'sb=false',
|
14297 | 'output',
|
14298 | { type_: 'operator', option: '\\pm' },
|
14299 | ],
|
14300 | nextState: '0',
|
14301 | },
|
14302 | },
|
14303 | 'operator': {
|
14304 | '0|1|2|a|as': {
|
14305 | action_: ['sb=false', 'output', 'operator'],
|
14306 | nextState: '0',
|
14307 | },
|
14308 | },
|
14309 | '-$': {
|
14310 | 'o|q': {
|
14311 | action_: ['charge or bond', 'output'],
|
14312 | nextState: 'qd',
|
14313 | },
|
14314 | 'd': { action_: 'd=', nextState: 'd' },
|
14315 | 'D': {
|
14316 | action_: ['output', { type_: 'bond', option: '-' }],
|
14317 | nextState: '3',
|
14318 | },
|
14319 | 'q': { action_: 'd=', nextState: 'qd' },
|
14320 | 'qd': { action_: 'd=', nextState: 'qd' },
|
14321 | 'qD|dq': {
|
14322 | action_: ['output', { type_: 'bond', option: '-' }],
|
14323 | nextState: '3',
|
14324 | },
|
14325 | },
|
14326 | '-9': {
|
14327 | '3|o': {
|
14328 | action_: ['output', { type_: 'insert', option: 'hyphen' }],
|
14329 | nextState: '3',
|
14330 | },
|
14331 | },
|
14332 | '- orbital overlap': {
|
14333 | o: {
|
14334 | action_: ['output', { type_: 'insert', option: 'hyphen' }],
|
14335 | nextState: '2',
|
14336 | },
|
14337 | d: {
|
14338 | action_: ['output', { type_: 'insert', option: 'hyphen' }],
|
14339 | nextState: '2',
|
14340 | },
|
14341 | },
|
14342 | '-': {
|
14343 | '0|1|2': {
|
14344 | action_: [
|
14345 | { type_: 'output', option: 1 },
|
14346 | 'beginsWithBond=true',
|
14347 | { type_: 'bond', option: '-' },
|
14348 | ],
|
14349 | nextState: '3',
|
14350 | },
|
14351 | '3': { action_: { type_: 'bond', option: '-' } },
|
14352 | 'a': {
|
14353 | action_: ['output', { type_: 'insert', option: 'hyphen' }],
|
14354 | nextState: '2',
|
14355 | },
|
14356 | 'as': {
|
14357 | action_: [
|
14358 | { type_: 'output', option: 2 },
|
14359 | { type_: 'bond', option: '-' },
|
14360 | ],
|
14361 | nextState: '3',
|
14362 | },
|
14363 | 'b': { action_: 'b=' },
|
14364 | 'o': {
|
14365 | action_: { type_: '- after o/d', option: false },
|
14366 | nextState: '2',
|
14367 | },
|
14368 | 'q': {
|
14369 | action_: { type_: '- after o/d', option: false },
|
14370 | nextState: '2',
|
14371 | },
|
14372 | 'd|qd|dq': {
|
14373 | action_: { type_: '- after o/d', option: true },
|
14374 | nextState: '2',
|
14375 | },
|
14376 | 'D|qD|p': {
|
14377 | action_: ['output', { type_: 'bond', option: '-' }],
|
14378 | nextState: '3',
|
14379 | },
|
14380 | },
|
14381 | 'amount2': {
|
14382 | '1|3': { action_: 'a=', nextState: 'a' },
|
14383 | },
|
14384 | 'letters': {
|
14385 | '0|1|2|3|a|as|b|p|bp|o': { action_: 'o=', nextState: 'o' },
|
14386 | 'q|dq': { action_: ['output', 'o='], nextState: 'o' },
|
14387 | 'd|D|qd|qD': { action_: 'o after d', nextState: 'o' },
|
14388 | },
|
14389 | 'digits': {
|
14390 | 'o': { action_: 'q=', nextState: 'q' },
|
14391 | 'd|D': { action_: 'q=', nextState: 'dq' },
|
14392 | 'q': { action_: ['output', 'o='], nextState: 'o' },
|
14393 | 'a': { action_: 'o=', nextState: 'o' },
|
14394 | },
|
14395 | 'space A': {
|
14396 | 'b|p|bp': {},
|
14397 | },
|
14398 | 'space': {
|
14399 | 'a': { nextState: 'as' },
|
14400 | '0': { action_: 'sb=false' },
|
14401 | '1|2': { action_: 'sb=true' },
|
14402 | 'r|rt|rd|rdt|rdq': { action_: 'output', nextState: '0' },
|
14403 | '*': { action_: ['output', 'sb=true'], nextState: '1' },
|
14404 | },
|
14405 | '1st-level escape': {
|
14406 | '1|2': {
|
14407 | action_: [
|
14408 | 'output',
|
14409 | { type_: 'insert+p1', option: '1st-level escape' },
|
14410 | ],
|
14411 | },
|
14412 | '*': {
|
14413 | action_: [
|
14414 | 'output',
|
14415 | { type_: 'insert+p1', option: '1st-level escape' },
|
14416 | ],
|
14417 | nextState: '0',
|
14418 | },
|
14419 | },
|
14420 | '[(...)]': {
|
14421 | 'r|rt': { action_: 'rd=', nextState: 'rd' },
|
14422 | 'rd|rdt': { action_: 'rq=', nextState: 'rdq' },
|
14423 | },
|
14424 | '...': {
|
14425 | 'o|d|D|dq|qd|qD': {
|
14426 | action_: ['output', { type_: 'bond', option: '...' }],
|
14427 | nextState: '3',
|
14428 | },
|
14429 | '*': {
|
14430 | action_: [
|
14431 | { type_: 'output', option: 1 },
|
14432 | { type_: 'insert', option: 'ellipsis' },
|
14433 | ],
|
14434 | nextState: '1',
|
14435 | },
|
14436 | },
|
14437 | '. |* ': {
|
14438 | '*': {
|
14439 | action_: ['output', { type_: 'insert', option: 'addition compound' }],
|
14440 | nextState: '1',
|
14441 | },
|
14442 | },
|
14443 | 'state of aggregation $': {
|
14444 | '*': {
|
14445 | action_: ['output', 'state of aggregation'],
|
14446 | nextState: '1',
|
14447 | },
|
14448 | },
|
14449 | '{[(': {
|
14450 | 'a|as|o': {
|
14451 | action_: ['o=', 'output', 'parenthesisLevel++'],
|
14452 | nextState: '2',
|
14453 | },
|
14454 | '0|1|2|3': {
|
14455 | action_: ['o=', 'output', 'parenthesisLevel++'],
|
14456 | nextState: '2',
|
14457 | },
|
14458 | '*': {
|
14459 | action_: ['output', 'o=', 'output', 'parenthesisLevel++'],
|
14460 | nextState: '2',
|
14461 | },
|
14462 | },
|
14463 | ')]}': {
|
14464 | '0|1|2|3|b|p|bp|o': {
|
14465 | action_: ['o=', 'parenthesisLevel--'],
|
14466 | nextState: 'o',
|
14467 | },
|
14468 | 'a|as|d|D|q|qd|qD|dq': {
|
14469 | action_: ['output', 'o=', 'parenthesisLevel--'],
|
14470 | nextState: 'o',
|
14471 | },
|
14472 | },
|
14473 | ', ': {
|
14474 | '*': { action_: ['output', 'comma'], nextState: '0' },
|
14475 | },
|
14476 | '^_': {
|
14477 |
|
14478 | '*': {},
|
14479 | },
|
14480 | '^{(...)}|^($...$)': {
|
14481 | '0|1|2|as': { action_: 'b=', nextState: 'b' },
|
14482 | 'p': { action_: 'b=', nextState: 'bp' },
|
14483 | '3|o': { action_: 'd= kv', nextState: 'D' },
|
14484 | 'q': { action_: 'd=', nextState: 'qD' },
|
14485 | 'd|D|qd|qD|dq': { action_: ['output', 'd='], nextState: 'D' },
|
14486 | },
|
14487 | "^a|^\\x{}{}|^\\x{}|^\\x|'": {
|
14488 | '0|1|2|as': { action_: 'b=', nextState: 'b' },
|
14489 | 'p': { action_: 'b=', nextState: 'bp' },
|
14490 | '3|o': { action_: 'd= kv', nextState: 'd' },
|
14491 | 'q': { action_: 'd=', nextState: 'qd' },
|
14492 | 'd|qd|D|qD': { action_: 'd=' },
|
14493 | 'dq': { action_: ['output', 'd='], nextState: 'd' },
|
14494 | },
|
14495 | '_{(state of aggregation)}$': {
|
14496 | 'd|D|q|qd|qD|dq': { action_: ['output', 'q='], nextState: 'q' },
|
14497 | },
|
14498 | '_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x': {
|
14499 | '0|1|2|as': { action_: 'p=', nextState: 'p' },
|
14500 | 'b': { action_: 'p=', nextState: 'bp' },
|
14501 | '3|o': { action_: 'q=', nextState: 'q' },
|
14502 | 'd|D': { action_: 'q=', nextState: 'dq' },
|
14503 | 'q|qd|qD|dq': { action_: ['output', 'q='], nextState: 'q' },
|
14504 | },
|
14505 | '=<>': {
|
14506 | '0|1|2|3|a|as|o|q|d|D|qd|qD|dq': {
|
14507 | action_: [{ type_: 'output', option: 2 }, 'bond'],
|
14508 | nextState: '3',
|
14509 | },
|
14510 | },
|
14511 | '#': {
|
14512 | '0|1|2|3|a|as|o': {
|
14513 | action_: [
|
14514 | { type_: 'output', option: 2 },
|
14515 | { type_: 'bond', option: '#' },
|
14516 | ],
|
14517 | nextState: '3',
|
14518 | },
|
14519 | },
|
14520 | '{}': {
|
14521 | '*': {
|
14522 | action_: { type_: 'output', option: 1 },
|
14523 | nextState: '1',
|
14524 | },
|
14525 | },
|
14526 | '{...}': {
|
14527 | '0|1|2|3|a|as|b|p|bp': { action_: 'o=', nextState: 'o' },
|
14528 | 'o|d|D|q|qd|qD|dq': {
|
14529 | action_: ['output', 'o='],
|
14530 | nextState: 'o',
|
14531 | },
|
14532 | },
|
14533 | '$...$': {
|
14534 | 'a': { action_: 'a=' },
|
14535 | '0|1|2|3|as|b|p|bp|o': { action_: 'o=', nextState: 'o' },
|
14536 | 'as|o': { action_: 'o=' },
|
14537 | 'q|d|D|qd|qD|dq': { action_: ['output', 'o='], nextState: 'o' },
|
14538 | },
|
14539 | '\\bond{(...)}': {
|
14540 | '*': {
|
14541 | action_: [{ type_: 'output', option: 2 }, 'bond'],
|
14542 | nextState: '3',
|
14543 | },
|
14544 | },
|
14545 | '\\frac{(...)}': {
|
14546 | '*': {
|
14547 | action_: [{ type_: 'output', option: 1 }, 'frac-output'],
|
14548 | nextState: '3',
|
14549 | },
|
14550 | },
|
14551 | '\\overset{(...)}': {
|
14552 | '*': {
|
14553 | action_: [{ type_: 'output', option: 2 }, 'overset-output'],
|
14554 | nextState: '3',
|
14555 | },
|
14556 | },
|
14557 | '\\underset{(...)}': {
|
14558 | '*': {
|
14559 | action_: [{ type_: 'output', option: 2 }, 'underset-output'],
|
14560 | nextState: '3',
|
14561 | },
|
14562 | },
|
14563 | '\\underbrace{(...)}': {
|
14564 | '*': {
|
14565 | action_: [{ type_: 'output', option: 2 }, 'underbrace-output'],
|
14566 | nextState: '3',
|
14567 | },
|
14568 | },
|
14569 | '\\color{(...)}{(...)}1|\\color(...){(...)}2': {
|
14570 | '*': {
|
14571 | action_: [{ type_: 'output', option: 2 }, 'color-output'],
|
14572 | nextState: '3',
|
14573 | },
|
14574 | },
|
14575 | '\\color{(...)}0': {
|
14576 | '*': {
|
14577 | action_: [{ type_: 'output', option: 2 }, 'color0-output'],
|
14578 | },
|
14579 | },
|
14580 | '\\ce{(...)}': {
|
14581 | '*': {
|
14582 | action_: [{ type_: 'output', option: 2 }, 'ce'],
|
14583 | nextState: '3',
|
14584 | },
|
14585 | },
|
14586 | '\\,': {
|
14587 | '*': {
|
14588 | action_: [{ type_: 'output', option: 1 }, 'copy'],
|
14589 | nextState: '1',
|
14590 | },
|
14591 | },
|
14592 | '\\x{}{}|\\x{}|\\x': {
|
14593 | '0|1|2|3|a|as|b|p|bp|o|c0': {
|
14594 | action_: ['o=', 'output'],
|
14595 | nextState: '3',
|
14596 | },
|
14597 | '*': { action_: ['output', 'o=', 'output'], nextState: '3' },
|
14598 | },
|
14599 | 'others': {
|
14600 | '*': {
|
14601 | action_: [{ type_: 'output', option: 1 }, 'copy'],
|
14602 | nextState: '3',
|
14603 | },
|
14604 | },
|
14605 | 'else2': {
|
14606 | 'a': { action_: 'a to o', nextState: 'o', revisit: true },
|
14607 | 'as': {
|
14608 | action_: ['output', 'sb=true'],
|
14609 | nextState: '1',
|
14610 | revisit: true,
|
14611 | },
|
14612 | 'r|rt|rd|rdt|rdq': {
|
14613 | action_: ['output'],
|
14614 | nextState: '0',
|
14615 | revisit: true,
|
14616 | },
|
14617 | '*': { action_: ['output', 'copy'], nextState: '3' },
|
14618 | },
|
14619 | }),
|
14620 | actions: {
|
14621 | 'o after d': function (buffer, m) {
|
14622 | var ret;
|
14623 | if ((buffer.d || '').match(/^[0-9]+$/)) {
|
14624 | var tmp = buffer.d;
|
14625 | buffer.d = undefined;
|
14626 | ret = this['output'](buffer);
|
14627 | buffer.b = tmp;
|
14628 | }
|
14629 | else {
|
14630 | ret = this['output'](buffer);
|
14631 | }
|
14632 | mhchemParser.actions['o='](buffer, m);
|
14633 | return ret;
|
14634 | },
|
14635 | 'd= kv': function (buffer, m) {
|
14636 | buffer.d = m;
|
14637 | buffer.dType = 'kv';
|
14638 | },
|
14639 | 'charge or bond': function (buffer, m) {
|
14640 | if (buffer['beginsWithBond']) {
|
14641 |
|
14642 | var ret = [];
|
14643 | mhchemParser.concatArray(ret, this['output'](buffer));
|
14644 | mhchemParser.concatArray(ret, mhchemParser.actions['bond'](buffer, m, '-'));
|
14645 | return ret;
|
14646 | }
|
14647 | else {
|
14648 | buffer.d = m;
|
14649 | }
|
14650 | },
|
14651 | '- after o/d': function (buffer, m, isAfterD) {
|
14652 | var c1 = mhchemParser.patterns.match_('orbital', buffer.o || '');
|
14653 | var c2 = mhchemParser.patterns.match_('one lowercase greek letter $', buffer.o || '');
|
14654 | var c3 = mhchemParser.patterns.match_('one lowercase latin letter $', buffer.o || '');
|
14655 | var c4 = mhchemParser.patterns.match_('$one lowercase latin letter$ $', buffer.o || '');
|
14656 | var hyphenFollows = m === '-' && ((c1 && c1.remainder === '') || c2 || c3 || c4);
|
14657 | if (hyphenFollows &&
|
14658 | !buffer.a &&
|
14659 | !buffer.b &&
|
14660 | !buffer.p &&
|
14661 | !buffer.d &&
|
14662 | !buffer.q &&
|
14663 | !c1 &&
|
14664 | c3) {
|
14665 | buffer.o = '$' + buffer.o + '$';
|
14666 | }
|
14667 |
|
14668 | var ret = [];
|
14669 | if (hyphenFollows) {
|
14670 | mhchemParser.concatArray(ret, this['output'](buffer));
|
14671 | ret.push({ type_: 'hyphen' });
|
14672 | }
|
14673 | else {
|
14674 | c1 = mhchemParser.patterns.match_('digits', buffer.d || '');
|
14675 | if (isAfterD && c1 && c1.remainder === '') {
|
14676 | mhchemParser.concatArray(ret, mhchemParser.actions['d='](buffer, m));
|
14677 | mhchemParser.concatArray(ret, this['output'](buffer));
|
14678 | }
|
14679 | else {
|
14680 | mhchemParser.concatArray(ret, this['output'](buffer));
|
14681 | mhchemParser.concatArray(ret, mhchemParser.actions['bond'](buffer, m, '-'));
|
14682 | }
|
14683 | }
|
14684 | return ret;
|
14685 | },
|
14686 | 'a to o': function (buffer) {
|
14687 | buffer.o = buffer.a;
|
14688 | buffer.a = undefined;
|
14689 | },
|
14690 | 'sb=true': function (buffer) {
|
14691 | buffer.sb = true;
|
14692 | },
|
14693 | 'sb=false': function (buffer) {
|
14694 | buffer.sb = false;
|
14695 | },
|
14696 | 'beginsWithBond=true': function (buffer) {
|
14697 | buffer['beginsWithBond'] = true;
|
14698 | },
|
14699 | 'beginsWithBond=false': function (buffer) {
|
14700 | buffer['beginsWithBond'] = false;
|
14701 | },
|
14702 | 'parenthesisLevel++': function (buffer) {
|
14703 | buffer['parenthesisLevel']++;
|
14704 | },
|
14705 | 'parenthesisLevel--': function (buffer) {
|
14706 | buffer['parenthesisLevel']--;
|
14707 | },
|
14708 | 'state of aggregation': function (buffer, m) {
|
14709 | return {
|
14710 | type_: 'state of aggregation',
|
14711 | p1: mhchemParser.go(m, 'o'),
|
14712 | };
|
14713 | },
|
14714 | 'comma': function (buffer, m) {
|
14715 | var a = m.replace(/\s*$/, '');
|
14716 | var withSpace = a !== m;
|
14717 | if (withSpace && buffer['parenthesisLevel'] === 0) {
|
14718 | return { type_: 'comma enumeration L', p1: a };
|
14719 | }
|
14720 | else {
|
14721 | return { type_: 'comma enumeration M', p1: a };
|
14722 | }
|
14723 | },
|
14724 | 'output': function (buffer, m, entityFollows) {
|
14725 |
|
14726 |
|
14727 |
|
14728 |
|
14729 |
|
14730 | var ret;
|
14731 | if (!buffer.r) {
|
14732 | ret = [];
|
14733 | if (!buffer.a &&
|
14734 | !buffer.b &&
|
14735 | !buffer.p &&
|
14736 | !buffer.o &&
|
14737 | !buffer.q &&
|
14738 | !buffer.d &&
|
14739 | !entityFollows) ;
|
14740 | else {
|
14741 | if (buffer.sb) {
|
14742 | ret.push({ type_: 'entitySkip' });
|
14743 | }
|
14744 | if (!buffer.o &&
|
14745 | !buffer.q &&
|
14746 | !buffer.d &&
|
14747 | !buffer.b &&
|
14748 | !buffer.p &&
|
14749 | entityFollows !== 2) {
|
14750 | buffer.o = buffer.a;
|
14751 | buffer.a = undefined;
|
14752 | }
|
14753 | else if (!buffer.o &&
|
14754 | !buffer.q &&
|
14755 | !buffer.d &&
|
14756 | (buffer.b || buffer.p)) {
|
14757 | buffer.o = buffer.a;
|
14758 | buffer.d = buffer.b;
|
14759 | buffer.q = buffer.p;
|
14760 | buffer.a = buffer.b = buffer.p = undefined;
|
14761 | }
|
14762 | else {
|
14763 | if (buffer.o &&
|
14764 | buffer.dType === 'kv' &&
|
14765 | mhchemParser.patterns.match_('d-oxidation$', buffer.d || '')) {
|
14766 | buffer.dType = 'oxidation';
|
14767 | }
|
14768 | else if (buffer.o && buffer.dType === 'kv' && !buffer.q) {
|
14769 | buffer.dType = undefined;
|
14770 | }
|
14771 | }
|
14772 | ret.push({
|
14773 | type_: 'chemfive',
|
14774 | a: mhchemParser.go(buffer.a, 'a'),
|
14775 | b: mhchemParser.go(buffer.b, 'bd'),
|
14776 | p: mhchemParser.go(buffer.p, 'pq'),
|
14777 | o: mhchemParser.go(buffer.o, 'o'),
|
14778 | q: mhchemParser.go(buffer.q, 'pq'),
|
14779 | d: mhchemParser.go(buffer.d, buffer.dType === 'oxidation' ? 'oxidation' : 'bd'),
|
14780 | dType: buffer.dType,
|
14781 | });
|
14782 | }
|
14783 | }
|
14784 | else {
|
14785 |
|
14786 |
|
14787 | var rd;
|
14788 | if (buffer.rdt === 'M') {
|
14789 | rd = mhchemParser.go(buffer.rd, 'tex-math');
|
14790 | }
|
14791 | else if (buffer.rdt === 'T') {
|
14792 | rd = [{ type_: 'text', p1: buffer.rd || '' }];
|
14793 | }
|
14794 | else {
|
14795 | rd = mhchemParser.go(buffer.rd);
|
14796 | }
|
14797 |
|
14798 | var rq;
|
14799 | if (buffer.rqt === 'M') {
|
14800 | rq = mhchemParser.go(buffer.rq, 'tex-math');
|
14801 | }
|
14802 | else if (buffer.rqt === 'T') {
|
14803 | rq = [{ type_: 'text', p1: buffer.rq || '' }];
|
14804 | }
|
14805 | else {
|
14806 | rq = mhchemParser.go(buffer.rq);
|
14807 | }
|
14808 | ret = {
|
14809 | type_: 'arrow',
|
14810 | r: buffer.r,
|
14811 | rd: rd,
|
14812 | rq: rq,
|
14813 | };
|
14814 | }
|
14815 | for (var p in buffer) {
|
14816 | if (p !== 'parenthesisLevel' && p !== 'beginsWithBond') {
|
14817 | delete buffer[p];
|
14818 | }
|
14819 | }
|
14820 | return ret;
|
14821 | },
|
14822 | 'oxidation-output': function (buffer, m) {
|
14823 | var ret = ['{'];
|
14824 | mhchemParser.concatArray(ret, mhchemParser.go(m, 'oxidation'));
|
14825 | ret.push('}');
|
14826 | return ret;
|
14827 | },
|
14828 | 'frac-output': function (buffer, m) {
|
14829 | return {
|
14830 | type_: 'frac-ce',
|
14831 | p1: mhchemParser.go(m[0]),
|
14832 | p2: mhchemParser.go(m[1]),
|
14833 | };
|
14834 | },
|
14835 | 'overset-output': function (buffer, m) {
|
14836 | return {
|
14837 | type_: 'overset',
|
14838 | p1: mhchemParser.go(m[0]),
|
14839 | p2: mhchemParser.go(m[1]),
|
14840 | };
|
14841 | },
|
14842 | 'underset-output': function (buffer, m) {
|
14843 | return {
|
14844 | type_: 'underset',
|
14845 | p1: mhchemParser.go(m[0]),
|
14846 | p2: mhchemParser.go(m[1]),
|
14847 | };
|
14848 | },
|
14849 | 'underbrace-output': function (buffer, m) {
|
14850 | return {
|
14851 | type_: 'underbrace',
|
14852 | p1: mhchemParser.go(m[0]),
|
14853 | p2: mhchemParser.go(m[1]),
|
14854 | };
|
14855 | },
|
14856 | 'color-output': function (buffer, m) {
|
14857 | return {
|
14858 | type_: 'color',
|
14859 | color1: m[0],
|
14860 | color2: mhchemParser.go(m[1]),
|
14861 | };
|
14862 | },
|
14863 | 'r=': function (buffer, m) {
|
14864 | buffer.r = m;
|
14865 | },
|
14866 | 'rdt=': function (buffer, m) {
|
14867 | buffer.rdt = m;
|
14868 | },
|
14869 | 'rd=': function (buffer, m) {
|
14870 | buffer.rd = m;
|
14871 | },
|
14872 | 'rqt=': function (buffer, m) {
|
14873 | buffer.rqt = m;
|
14874 | },
|
14875 | 'rq=': function (buffer, m) {
|
14876 | buffer.rq = m;
|
14877 | },
|
14878 | 'operator': function (buffer, m, p1) {
|
14879 | return { type_: 'operator', kind_: p1 || m };
|
14880 | },
|
14881 | },
|
14882 | },
|
14883 | 'a': {
|
14884 | transitions: mhchemParser.createTransitions({
|
14885 | 'empty': {
|
14886 | '*': {},
|
14887 | },
|
14888 | '1/2$': {
|
14889 | '0': { action_: '1/2' },
|
14890 | },
|
14891 | 'else': {
|
14892 | '0': { nextState: '1', revisit: true },
|
14893 | },
|
14894 | '$(...)$': {
|
14895 | '*': { action_: 'tex-math tight', nextState: '1' },
|
14896 | },
|
14897 | ',': {
|
14898 | '*': { action_: { type_: 'insert', option: 'commaDecimal' } },
|
14899 | },
|
14900 | 'else2': {
|
14901 | '*': { action_: 'copy' },
|
14902 | },
|
14903 | }),
|
14904 | actions: {},
|
14905 | },
|
14906 | 'o': {
|
14907 | transitions: mhchemParser.createTransitions({
|
14908 | 'empty': {
|
14909 | '*': {},
|
14910 | },
|
14911 | '1/2$': {
|
14912 | '0': { action_: '1/2' },
|
14913 | },
|
14914 | 'else': {
|
14915 | '0': { nextState: '1', revisit: true },
|
14916 | },
|
14917 | 'letters': {
|
14918 | '*': { action_: 'rm' },
|
14919 | },
|
14920 | '\\ca': {
|
14921 | '*': { action_: { type_: 'insert', option: 'circa' } },
|
14922 | },
|
14923 | '\\x{}{}|\\x{}|\\x': {
|
14924 | '*': { action_: 'copy' },
|
14925 | },
|
14926 | '${(...)}$|$(...)$': {
|
14927 | '*': { action_: 'tex-math' },
|
14928 | },
|
14929 | '{(...)}': {
|
14930 | '*': { action_: '{text}' },
|
14931 | },
|
14932 | 'else2': {
|
14933 | '*': { action_: 'copy' },
|
14934 | },
|
14935 | }),
|
14936 | actions: {},
|
14937 | },
|
14938 | 'text': {
|
14939 | transitions: mhchemParser.createTransitions({
|
14940 | 'empty': {
|
14941 | '*': { action_: 'output' },
|
14942 | },
|
14943 | '{...}': {
|
14944 | '*': { action_: 'text=' },
|
14945 | },
|
14946 | '${(...)}$|$(...)$': {
|
14947 | '*': { action_: 'tex-math' },
|
14948 | },
|
14949 | '\\greek': {
|
14950 | '*': { action_: ['output', 'rm'] },
|
14951 | },
|
14952 | '\\,|\\x{}{}|\\x{}|\\x': {
|
14953 | '*': { action_: ['output', 'copy'] },
|
14954 | },
|
14955 | 'else': {
|
14956 | '*': { action_: 'text=' },
|
14957 | },
|
14958 | }),
|
14959 | actions: {
|
14960 | output: function (buffer) {
|
14961 | if (buffer.text_) {
|
14962 |
|
14963 | var ret = { type_: 'text', p1: buffer.text_ };
|
14964 | for (var p in buffer) {
|
14965 | delete buffer[p];
|
14966 | }
|
14967 | return ret;
|
14968 | }
|
14969 | },
|
14970 | },
|
14971 | },
|
14972 | 'pq': {
|
14973 | transitions: mhchemParser.createTransitions({
|
14974 | 'empty': {
|
14975 | '*': {},
|
14976 | },
|
14977 | 'state of aggregation $': {
|
14978 | '*': { action_: 'state of aggregation' },
|
14979 | },
|
14980 | 'i$': {
|
14981 | '0': { nextState: '!f', revisit: true },
|
14982 | },
|
14983 | '(KV letters),': {
|
14984 | '0': { action_: 'rm', nextState: '0' },
|
14985 | },
|
14986 | 'formula$': {
|
14987 | '0': { nextState: 'f', revisit: true },
|
14988 | },
|
14989 | '1/2$': {
|
14990 | '0': { action_: '1/2' },
|
14991 | },
|
14992 | 'else': {
|
14993 | '0': { nextState: '!f', revisit: true },
|
14994 | },
|
14995 | '${(...)}$|$(...)$': {
|
14996 | '*': { action_: 'tex-math' },
|
14997 | },
|
14998 | '{(...)}': {
|
14999 | '*': { action_: 'text' },
|
15000 | },
|
15001 | 'a-z': {
|
15002 | f: { action_: 'tex-math' },
|
15003 | },
|
15004 | 'letters': {
|
15005 | '*': { action_: 'rm' },
|
15006 | },
|
15007 | '-9.,9': {
|
15008 | '*': { action_: '9,9' },
|
15009 | },
|
15010 | ',': {
|
15011 | '*': {
|
15012 | action_: {
|
15013 | type_: 'insert+p1',
|
15014 | option: 'comma enumeration S',
|
15015 | },
|
15016 | },
|
15017 | },
|
15018 | '\\color{(...)}{(...)}1|\\color(...){(...)}2': {
|
15019 | '*': { action_: 'color-output' },
|
15020 | },
|
15021 | '\\color{(...)}0': {
|
15022 | '*': { action_: 'color0-output' },
|
15023 | },
|
15024 | '\\ce{(...)}': {
|
15025 | '*': { action_: 'ce' },
|
15026 | },
|
15027 | '\\,|\\x{}{}|\\x{}|\\x': {
|
15028 | '*': { action_: 'copy' },
|
15029 | },
|
15030 | 'else2': {
|
15031 | '*': { action_: 'copy' },
|
15032 | },
|
15033 | }),
|
15034 | actions: {
|
15035 | 'state of aggregation': function (buffer, m) {
|
15036 | return {
|
15037 | type_: 'state of aggregation subscript',
|
15038 | p1: mhchemParser.go(m, 'o'),
|
15039 | };
|
15040 | },
|
15041 | 'color-output': function (buffer, m) {
|
15042 | return {
|
15043 | type_: 'color',
|
15044 | color1: m[0],
|
15045 | color2: mhchemParser.go(m[1], 'pq'),
|
15046 | };
|
15047 | },
|
15048 | },
|
15049 | },
|
15050 | 'bd': {
|
15051 | transitions: mhchemParser.createTransitions({
|
15052 | 'empty': {
|
15053 | '*': {},
|
15054 | },
|
15055 | 'x$': {
|
15056 | '0': { nextState: '!f', revisit: true },
|
15057 | },
|
15058 | 'formula$': {
|
15059 | '0': { nextState: 'f', revisit: true },
|
15060 | },
|
15061 | 'else': {
|
15062 | '0': { nextState: '!f', revisit: true },
|
15063 | },
|
15064 | '-9.,9 no missing 0': {
|
15065 | '*': { action_: '9,9' },
|
15066 | },
|
15067 | '.': {
|
15068 | '*': { action_: { type_: 'insert', option: 'electron dot' } },
|
15069 | },
|
15070 | 'a-z': {
|
15071 | f: { action_: 'tex-math' },
|
15072 | },
|
15073 | 'x': {
|
15074 | '*': { action_: { type_: 'insert', option: 'KV x' } },
|
15075 | },
|
15076 | 'letters': {
|
15077 | '*': { action_: 'rm' },
|
15078 | },
|
15079 | "'": {
|
15080 | '*': { action_: { type_: 'insert', option: 'prime' } },
|
15081 | },
|
15082 | '${(...)}$|$(...)$': {
|
15083 | '*': { action_: 'tex-math' },
|
15084 | },
|
15085 | '{(...)}': {
|
15086 | '*': { action_: 'text' },
|
15087 | },
|
15088 | '\\color{(...)}{(...)}1|\\color(...){(...)}2': {
|
15089 | '*': { action_: 'color-output' },
|
15090 | },
|
15091 | '\\color{(...)}0': {
|
15092 | '*': { action_: 'color0-output' },
|
15093 | },
|
15094 | '\\ce{(...)}': {
|
15095 | '*': { action_: 'ce' },
|
15096 | },
|
15097 | '\\,|\\x{}{}|\\x{}|\\x': {
|
15098 | '*': { action_: 'copy' },
|
15099 | },
|
15100 | 'else2': {
|
15101 | '*': { action_: 'copy' },
|
15102 | },
|
15103 | }),
|
15104 | actions: {
|
15105 | 'color-output': function (buffer, m) {
|
15106 | return {
|
15107 | type_: 'color',
|
15108 | color1: m[0],
|
15109 | color2: mhchemParser.go(m[1], 'bd'),
|
15110 | };
|
15111 | },
|
15112 | },
|
15113 | },
|
15114 | 'oxidation': {
|
15115 | transitions: mhchemParser.createTransitions({
|
15116 | 'empty': {
|
15117 | '*': {},
|
15118 | },
|
15119 | 'roman numeral': {
|
15120 | '*': { action_: 'roman-numeral' },
|
15121 | },
|
15122 | '${(...)}$|$(...)$': {
|
15123 | '*': { action_: 'tex-math' },
|
15124 | },
|
15125 | 'else': {
|
15126 | '*': { action_: 'copy' },
|
15127 | },
|
15128 | }),
|
15129 | actions: {
|
15130 | 'roman-numeral': function (buffer, m) {
|
15131 | return { type_: 'roman numeral', p1: m || '' };
|
15132 | },
|
15133 | },
|
15134 | },
|
15135 | 'tex-math': {
|
15136 | transitions: mhchemParser.createTransitions({
|
15137 | 'empty': {
|
15138 | '*': { action_: 'output' },
|
15139 | },
|
15140 | '\\ce{(...)}': {
|
15141 | '*': { action_: ['output', 'ce'] },
|
15142 | },
|
15143 | '{...}|\\,|\\x{}{}|\\x{}|\\x': {
|
15144 | '*': { action_: 'o=' },
|
15145 | },
|
15146 | 'else': {
|
15147 | '*': { action_: 'o=' },
|
15148 | },
|
15149 | }),
|
15150 | actions: {
|
15151 | output: function (buffer) {
|
15152 | if (buffer.o) {
|
15153 |
|
15154 | var ret = { type_: 'tex-math', p1: buffer.o };
|
15155 | for (var p in buffer) {
|
15156 | delete buffer[p];
|
15157 | }
|
15158 | return ret;
|
15159 | }
|
15160 | },
|
15161 | },
|
15162 | },
|
15163 | 'tex-math tight': {
|
15164 | transitions: mhchemParser.createTransitions({
|
15165 | 'empty': {
|
15166 | '*': { action_: 'output' },
|
15167 | },
|
15168 | '\\ce{(...)}': {
|
15169 | '*': { action_: ['output', 'ce'] },
|
15170 | },
|
15171 | '{...}|\\,|\\x{}{}|\\x{}|\\x': {
|
15172 | '*': { action_: 'o=' },
|
15173 | },
|
15174 | '-|+': {
|
15175 | '*': { action_: 'tight operator' },
|
15176 | },
|
15177 | 'else': {
|
15178 | '*': { action_: 'o=' },
|
15179 | },
|
15180 | }),
|
15181 | actions: {
|
15182 | 'tight operator': function (buffer, m) {
|
15183 | buffer.o = (buffer.o || '') + '{' + m + '}';
|
15184 | },
|
15185 | 'output': function (buffer) {
|
15186 | if (buffer.o) {
|
15187 |
|
15188 | var ret = { type_: 'tex-math', p1: buffer.o };
|
15189 | for (var p in buffer) {
|
15190 | delete buffer[p];
|
15191 | }
|
15192 | return ret;
|
15193 | }
|
15194 | },
|
15195 | },
|
15196 | },
|
15197 | '9,9': {
|
15198 | transitions: mhchemParser.createTransitions({
|
15199 | 'empty': {
|
15200 | '*': {},
|
15201 | },
|
15202 | ',': {
|
15203 | '*': { action_: 'comma' },
|
15204 | },
|
15205 | 'else': {
|
15206 | '*': { action_: 'copy' },
|
15207 | },
|
15208 | }),
|
15209 | actions: {
|
15210 | comma: function () {
|
15211 | return { type_: 'commaDecimal' };
|
15212 | },
|
15213 | },
|
15214 | },
|
15215 |
|
15216 |
|
15217 |
|
15218 |
|
15219 |
|
15220 | 'pu': {
|
15221 | transitions: mhchemParser.createTransitions({
|
15222 | 'empty': {
|
15223 | '*': { action_: 'output' },
|
15224 | },
|
15225 | 'space$': {
|
15226 | '*': { action_: ['output', 'space'] },
|
15227 | },
|
15228 | '{[(|)]}': {
|
15229 | '0|a': { action_: 'copy' },
|
15230 | },
|
15231 | '(-)(9)^(-9)': {
|
15232 | '0': { action_: 'number^', nextState: 'a' },
|
15233 | },
|
15234 | '(-)(9.,9)(e)(99)': {
|
15235 | '0': { action_: 'enumber', nextState: 'a' },
|
15236 | },
|
15237 | 'space': {
|
15238 | '0|a': {},
|
15239 | },
|
15240 | 'pm-operator': {
|
15241 | '0|a': {
|
15242 | action_: { type_: 'operator', option: '\\pm' },
|
15243 | nextState: '0',
|
15244 | },
|
15245 | },
|
15246 | 'operator': {
|
15247 | '0|a': { action_: 'copy', nextState: '0' },
|
15248 | },
|
15249 | '//': {
|
15250 | d: { action_: 'o=', nextState: '/' },
|
15251 | },
|
15252 | '/': {
|
15253 | d: { action_: 'o=', nextState: '/' },
|
15254 | },
|
15255 | '{...}|else': {
|
15256 | '0|d': { action_: 'd=', nextState: 'd' },
|
15257 | 'a': { action_: ['space', 'd='], nextState: 'd' },
|
15258 | '/|q': { action_: 'q=', nextState: 'q' },
|
15259 | },
|
15260 | }),
|
15261 | actions: {
|
15262 | 'enumber': function (buffer, m) {
|
15263 |
|
15264 | var ret = [];
|
15265 | if (m[0] === '+-' || m[0] === '+/-') {
|
15266 | ret.push('\\pm ');
|
15267 | }
|
15268 | else if (m[0]) {
|
15269 | ret.push(m[0]);
|
15270 | }
|
15271 | if (m[1]) {
|
15272 | mhchemParser.concatArray(ret, mhchemParser.go(m[1], 'pu-9,9'));
|
15273 | if (m[2]) {
|
15274 | if (m[2].match(/[,.]/)) {
|
15275 | mhchemParser.concatArray(ret, mhchemParser.go(m[2], 'pu-9,9'));
|
15276 | }
|
15277 | else {
|
15278 | ret.push(m[2]);
|
15279 | }
|
15280 | }
|
15281 | m[3] = m[4] || m[3];
|
15282 | if (m[3]) {
|
15283 | m[3] = m[3].trim();
|
15284 | if (m[3] === 'e' || m[3].substr(0, 1) === '*') {
|
15285 | ret.push({ type_: 'cdot' });
|
15286 | }
|
15287 | else {
|
15288 | ret.push({ type_: 'times' });
|
15289 | }
|
15290 | }
|
15291 | }
|
15292 | if (m[3]) {
|
15293 | ret.push('10^{' + m[5] + '}');
|
15294 | }
|
15295 | return ret;
|
15296 | },
|
15297 | 'number^': function (buffer, m) {
|
15298 |
|
15299 | var ret = [];
|
15300 | if (m[0] === '+-' || m[0] === '+/-') {
|
15301 | ret.push('\\pm ');
|
15302 | }
|
15303 | else if (m[0]) {
|
15304 | ret.push(m[0]);
|
15305 | }
|
15306 | mhchemParser.concatArray(ret, mhchemParser.go(m[1], 'pu-9,9'));
|
15307 | ret.push('^{' + m[2] + '}');
|
15308 | return ret;
|
15309 | },
|
15310 | 'operator': function (buffer, m, p1) {
|
15311 | return { type_: 'operator', kind_: p1 || m };
|
15312 | },
|
15313 | 'space': function () {
|
15314 | return { type_: 'pu-space-1' };
|
15315 | },
|
15316 | 'output': function (buffer) {
|
15317 |
|
15318 | var ret;
|
15319 | var md = mhchemParser.patterns.match_('{(...)}', buffer.d || '');
|
15320 | if (md && md.remainder === '') {
|
15321 | buffer.d = md.match_;
|
15322 | }
|
15323 | var mq = mhchemParser.patterns.match_('{(...)}', buffer.q || '');
|
15324 | if (mq && mq.remainder === '') {
|
15325 | buffer.q = mq.match_;
|
15326 | }
|
15327 | if (buffer.d) {
|
15328 | buffer.d = buffer.d.replace(/\u00B0C|\^oC|\^{o}C/g, '{}^{\\circ}C');
|
15329 | buffer.d = buffer.d.replace(/\u00B0F|\^oF|\^{o}F/g, '{}^{\\circ}F');
|
15330 | }
|
15331 | if (buffer.q) {
|
15332 |
|
15333 | buffer.q = buffer.q.replace(/\u00B0C|\^oC|\^{o}C/g, '{}^{\\circ}C');
|
15334 | buffer.q = buffer.q.replace(/\u00B0F|\^oF|\^{o}F/g, '{}^{\\circ}F');
|
15335 | var b5 = {
|
15336 | d: mhchemParser.go(buffer.d, 'pu'),
|
15337 | q: mhchemParser.go(buffer.q, 'pu'),
|
15338 | };
|
15339 | if (buffer.o === '//') {
|
15340 | ret = { type_: 'pu-frac', p1: b5.d, p2: b5.q };
|
15341 | }
|
15342 | else {
|
15343 | ret = b5.d;
|
15344 | if (b5.d.length > 1 || b5.q.length > 1) {
|
15345 | ret.push({ type_: ' / ' });
|
15346 | }
|
15347 | else {
|
15348 | ret.push({ type_: '/' });
|
15349 | }
|
15350 | mhchemParser.concatArray(ret, b5.q);
|
15351 | }
|
15352 | }
|
15353 | else {
|
15354 |
|
15355 | ret = mhchemParser.go(buffer.d, 'pu-2');
|
15356 | }
|
15357 | for (var p in buffer) {
|
15358 | delete buffer[p];
|
15359 | }
|
15360 | return ret;
|
15361 | },
|
15362 | },
|
15363 | },
|
15364 | 'pu-2': {
|
15365 | transitions: mhchemParser.createTransitions({
|
15366 | 'empty': {
|
15367 | '*': { action_: 'output' },
|
15368 | },
|
15369 | '*': {
|
15370 | '*': { action_: ['output', 'cdot'], nextState: '0' },
|
15371 | },
|
15372 | '\\x': {
|
15373 | '*': { action_: 'rm=' },
|
15374 | },
|
15375 | 'space': {
|
15376 | '*': { action_: ['output', 'space'], nextState: '0' },
|
15377 | },
|
15378 | '^{(...)}|^(-1)': {
|
15379 | '1': { action_: '^(-1)' },
|
15380 | },
|
15381 | '-9.,9': {
|
15382 | '0': { action_: 'rm=', nextState: '0' },
|
15383 | '1': { action_: '^(-1)', nextState: '0' },
|
15384 | },
|
15385 | '{...}|else': {
|
15386 | '*': { action_: 'rm=', nextState: '1' },
|
15387 | },
|
15388 | }),
|
15389 | actions: {
|
15390 | 'cdot': function () {
|
15391 | return { type_: 'tight cdot' };
|
15392 | },
|
15393 | '^(-1)': function (buffer, m) {
|
15394 | buffer.rm += '^{' + m + '}';
|
15395 | },
|
15396 | 'space': function () {
|
15397 | return { type_: 'pu-space-2' };
|
15398 | },
|
15399 | 'output': function (buffer) {
|
15400 |
|
15401 | var ret = [];
|
15402 | if (buffer.rm) {
|
15403 | var mrm = mhchemParser.patterns.match_('{(...)}', buffer.rm || '');
|
15404 | if (mrm && mrm.remainder === '') {
|
15405 | ret = mhchemParser.go(mrm.match_, 'pu');
|
15406 | }
|
15407 | else {
|
15408 | ret = { type_: 'rm', p1: buffer.rm };
|
15409 | }
|
15410 | }
|
15411 | for (var p in buffer) {
|
15412 | delete buffer[p];
|
15413 | }
|
15414 | return ret;
|
15415 | },
|
15416 | },
|
15417 | },
|
15418 | 'pu-9,9': {
|
15419 | transitions: mhchemParser.createTransitions({
|
15420 | 'empty': {
|
15421 | '0': { action_: 'output-0' },
|
15422 | 'o': { action_: 'output-o' },
|
15423 | },
|
15424 | ',': {
|
15425 | '0': { action_: ['output-0', 'comma'], nextState: 'o' },
|
15426 | },
|
15427 | '.': {
|
15428 | '0': { action_: ['output-0', 'copy'], nextState: 'o' },
|
15429 | },
|
15430 | 'else': {
|
15431 | '*': { action_: 'text=' },
|
15432 | },
|
15433 | }),
|
15434 | actions: {
|
15435 | 'comma': function () {
|
15436 | return { type_: 'commaDecimal' };
|
15437 | },
|
15438 | 'output-0': function (buffer) {
|
15439 |
|
15440 | var ret = [];
|
15441 | buffer.text_ = buffer.text_ || '';
|
15442 | if (buffer.text_.length > 4) {
|
15443 | var a = buffer.text_.length % 3;
|
15444 | if (a === 0) {
|
15445 | a = 3;
|
15446 | }
|
15447 | for (var i = buffer.text_.length - 3; i > 0; i -= 3) {
|
15448 | ret.push(buffer.text_.substr(i, 3));
|
15449 | ret.push({ type_: '1000 separator' });
|
15450 | }
|
15451 | ret.push(buffer.text_.substr(0, a));
|
15452 | ret.reverse();
|
15453 | }
|
15454 | else {
|
15455 | ret.push(buffer.text_);
|
15456 | }
|
15457 | for (var p in buffer) {
|
15458 | delete buffer[p];
|
15459 | }
|
15460 | return ret;
|
15461 | },
|
15462 | 'output-o': function (buffer) {
|
15463 |
|
15464 | var ret = [];
|
15465 | buffer.text_ = buffer.text_ || '';
|
15466 | if (buffer.text_.length > 4) {
|
15467 | var a = buffer.text_.length - 3;
|
15468 | for (var i = 0; i < a; i += 3) {
|
15469 | ret.push(buffer.text_.substr(i, 3));
|
15470 | ret.push({ type_: '1000 separator' });
|
15471 | }
|
15472 | ret.push(buffer.text_.substr(i));
|
15473 | }
|
15474 | else {
|
15475 | ret.push(buffer.text_);
|
15476 | }
|
15477 | for (var p in buffer) {
|
15478 | delete buffer[p];
|
15479 | }
|
15480 | return ret;
|
15481 | },
|
15482 | },
|
15483 | },
|
15484 |
|
15485 | };
|
15486 |
|
15487 |
|
15488 |
|
15489 |
|
15490 | var texify = {
|
15491 | go: function (input, isInner) {
|
15492 |
|
15493 | if (!input) {
|
15494 | return '';
|
15495 | }
|
15496 | var res = '';
|
15497 | var cee = false;
|
15498 | for (var i = 0; i < input.length; i++) {
|
15499 | var inputi = input[i];
|
15500 | if (typeof inputi === 'string') {
|
15501 | res += inputi;
|
15502 | }
|
15503 | else {
|
15504 | res += texify._go2(inputi);
|
15505 | if (inputi.type_ === '1st-level escape') {
|
15506 | cee = true;
|
15507 | }
|
15508 | }
|
15509 | }
|
15510 | if (!isInner && !cee && res) {
|
15511 | res = '{' + res + '}';
|
15512 | }
|
15513 | return res;
|
15514 | },
|
15515 | _goInner: function (input) {
|
15516 | if (!input) {
|
15517 | return input;
|
15518 | }
|
15519 | return texify.go(input, true);
|
15520 | },
|
15521 | _go2: function (buf) {
|
15522 |
|
15523 | var res;
|
15524 | switch (buf.type_) {
|
15525 | case 'chemfive':
|
15526 | res = '';
|
15527 | var b5 = {
|
15528 | a: texify._goInner(buf.a),
|
15529 | b: texify._goInner(buf.b),
|
15530 | p: texify._goInner(buf.p),
|
15531 | o: texify._goInner(buf.o),
|
15532 | q: texify._goInner(buf.q),
|
15533 | d: texify._goInner(buf.d),
|
15534 | };
|
15535 |
|
15536 |
|
15537 |
|
15538 | if (b5.a) {
|
15539 | if (b5.a.match(/^[+\-]/)) {
|
15540 | b5.a = '{' + b5.a + '}';
|
15541 | }
|
15542 | res += b5.a + '\\,';
|
15543 | }
|
15544 |
|
15545 |
|
15546 |
|
15547 | if (b5.b || b5.p) {
|
15548 | res += '{\\vphantom{X}}';
|
15549 | res +=
|
15550 | '^{\\hphantom{' +
|
15551 | (b5.b || '') +
|
15552 | '}}_{\\hphantom{' +
|
15553 | (b5.p || '') +
|
15554 | '}}';
|
15555 | res += '{\\vphantom{X}}';
|
15556 | res += '^{\\smash[t]{\\vphantom{2}}\\mathllap{' + (b5.b || '') + '}}';
|
15557 | res += '_{\\vphantom{2}\\mathllap{\\smash[t]{' + (b5.p || '') + '}}}';
|
15558 | }
|
15559 |
|
15560 |
|
15561 |
|
15562 | if (b5.o) {
|
15563 | if (b5.o.match(/^[+\-]/)) {
|
15564 | b5.o = '{' + b5.o + '}';
|
15565 | }
|
15566 | res += b5.o;
|
15567 | }
|
15568 |
|
15569 |
|
15570 |
|
15571 | if (buf.dType === 'kv') {
|
15572 | if (b5.d || b5.q) {
|
15573 | res += '{\\vphantom{X}}';
|
15574 | }
|
15575 | if (b5.d) {
|
15576 | res += '^{' + b5.d + '}';
|
15577 | }
|
15578 | if (b5.q) {
|
15579 | res += '_{\\smash[t]{' + b5.q + '}}';
|
15580 | }
|
15581 | }
|
15582 | else if (buf.dType === 'oxidation') {
|
15583 | if (b5.d) {
|
15584 | res += '{\\vphantom{X}}';
|
15585 | res += '^{' + b5.d + '}';
|
15586 | }
|
15587 | if (b5.q) {
|
15588 | res += '{\\vphantom{X}}';
|
15589 | res += '_{\\smash[t]{' + b5.q + '}}';
|
15590 | }
|
15591 | }
|
15592 | else {
|
15593 | if (b5.q) {
|
15594 | res += '{\\vphantom{X}}';
|
15595 | res += '_{\\smash[t]{' + b5.q + '}}';
|
15596 | }
|
15597 | if (b5.d) {
|
15598 | res += '{\\vphantom{X}}';
|
15599 | res += '^{' + b5.d + '}';
|
15600 | }
|
15601 | }
|
15602 | break;
|
15603 | case 'rm':
|
15604 | res = '\\mathrm{' + buf.p1 + '}';
|
15605 | break;
|
15606 | case 'text':
|
15607 | if (buf.p1.match(/[\^_]/)) {
|
15608 | buf.p1 = buf.p1.replace(' ', '~').replace('-', '\\text{-}');
|
15609 | res = '\\mathrm{' + buf.p1 + '}';
|
15610 | }
|
15611 | else {
|
15612 | res = '\\text{' + buf.p1 + '}';
|
15613 | }
|
15614 | break;
|
15615 | case 'roman numeral':
|
15616 | res = '\\mathrm{' + buf.p1 + '}';
|
15617 | break;
|
15618 | case 'state of aggregation':
|
15619 | res = '\\mskip2mu ' + texify._goInner(buf.p1);
|
15620 | break;
|
15621 | case 'state of aggregation subscript':
|
15622 | res = '\\mskip1mu ' + texify._goInner(buf.p1);
|
15623 | break;
|
15624 | case 'bond':
|
15625 | res = texify._getBond(buf.kind_);
|
15626 | if (!res) {
|
15627 | throw [
|
15628 | 'MhchemErrorBond',
|
15629 | 'mhchem Error. Unknown bond type (' + buf.kind_ + ')',
|
15630 | ];
|
15631 | }
|
15632 | break;
|
15633 | case 'frac':
|
15634 | var c = '\\frac{' + buf.p1 + '}{' + buf.p2 + '}';
|
15635 | res =
|
15636 | '\\mathchoice{\\textstyle' + c + '}{' + c + '}{' + c + '}{' + c + '}';
|
15637 | break;
|
15638 | case 'pu-frac':
|
15639 | var d = '\\frac{' +
|
15640 | texify._goInner(buf.p1) +
|
15641 | '}{' +
|
15642 | texify._goInner(buf.p2) +
|
15643 | '}';
|
15644 | res =
|
15645 | '\\mathchoice{\\textstyle' + d + '}{' + d + '}{' + d + '}{' + d + '}';
|
15646 | break;
|
15647 | case 'tex-math':
|
15648 | res = buf.p1 + ' ';
|
15649 | break;
|
15650 | case 'frac-ce':
|
15651 | res =
|
15652 | '\\frac{' +
|
15653 | texify._goInner(buf.p1) +
|
15654 | '}{' +
|
15655 | texify._goInner(buf.p2) +
|
15656 | '}';
|
15657 | break;
|
15658 | case 'overset':
|
15659 | res =
|
15660 | '\\overset{' +
|
15661 | texify._goInner(buf.p1) +
|
15662 | '}{' +
|
15663 | texify._goInner(buf.p2) +
|
15664 | '}';
|
15665 | break;
|
15666 | case 'underset':
|
15667 | res =
|
15668 | '\\underset{' +
|
15669 | texify._goInner(buf.p1) +
|
15670 | '}{' +
|
15671 | texify._goInner(buf.p2) +
|
15672 | '}';
|
15673 | break;
|
15674 | case 'underbrace':
|
15675 | res =
|
15676 | '\\underbrace{' +
|
15677 | texify._goInner(buf.p1) +
|
15678 | '}_{' +
|
15679 | texify._goInner(buf.p2) +
|
15680 | '}';
|
15681 | break;
|
15682 | case 'color':
|
15683 | res =
|
15684 | '{\\color{' + buf.color1 + '}{' + texify._goInner(buf.color2) + '}}';
|
15685 | break;
|
15686 | case 'color0':
|
15687 | res = '\\color{' + buf.color + '}';
|
15688 | break;
|
15689 | case 'arrow':
|
15690 | var b6 = {
|
15691 | rd: texify._goInner(buf.rd),
|
15692 | rq: texify._goInner(buf.rq),
|
15693 | };
|
15694 | var arrow = '\\x' + texify._getArrow(buf.r);
|
15695 | if (b6.rq) {
|
15696 | arrow += '[{' + b6.rq + '}]';
|
15697 | }
|
15698 | if (b6.rd) {
|
15699 | arrow += '{' + b6.rd + '}';
|
15700 | }
|
15701 | else {
|
15702 | arrow += '{}';
|
15703 | }
|
15704 | res = arrow;
|
15705 | break;
|
15706 | case 'operator':
|
15707 | res = texify._getOperator(buf.kind_);
|
15708 | break;
|
15709 | case '1st-level escape':
|
15710 | res = buf.p1 + ' ';
|
15711 | break;
|
15712 | case 'space':
|
15713 | res = ' ';
|
15714 | break;
|
15715 | case 'entitySkip':
|
15716 | res = '~';
|
15717 | break;
|
15718 | case 'pu-space-1':
|
15719 | res = '~';
|
15720 | break;
|
15721 | case 'pu-space-2':
|
15722 | res = '\\mkern3mu ';
|
15723 | break;
|
15724 | case '1000 separator':
|
15725 | res = '\\mkern2mu ';
|
15726 | break;
|
15727 | case 'commaDecimal':
|
15728 | res = '{,}';
|
15729 | break;
|
15730 | case 'comma enumeration L':
|
15731 | res = '{' + buf.p1 + '}\\mkern6mu ';
|
15732 | break;
|
15733 | case 'comma enumeration M':
|
15734 | res = '{' + buf.p1 + '}\\mkern3mu ';
|
15735 | break;
|
15736 | case 'comma enumeration S':
|
15737 | res = '{' + buf.p1 + '}\\mkern1mu ';
|
15738 | break;
|
15739 | case 'hyphen':
|
15740 | res = '\\text{-}';
|
15741 | break;
|
15742 | case 'addition compound':
|
15743 | res = '\\,{\\cdot}\\,';
|
15744 | break;
|
15745 | case 'electron dot':
|
15746 | res = '\\mkern1mu \\bullet\\mkern1mu ';
|
15747 | break;
|
15748 | case 'KV x':
|
15749 | res = '{\\times}';
|
15750 | break;
|
15751 | case 'prime':
|
15752 | res = '\\prime ';
|
15753 | break;
|
15754 | case 'cdot':
|
15755 | res = '\\cdot ';
|
15756 | break;
|
15757 | case 'tight cdot':
|
15758 | res = '\\mkern1mu{\\cdot}\\mkern1mu ';
|
15759 | break;
|
15760 | case 'times':
|
15761 | res = '\\times ';
|
15762 | break;
|
15763 | case 'circa':
|
15764 | res = '{\\sim}';
|
15765 | break;
|
15766 | case '^':
|
15767 | res = 'uparrow';
|
15768 | break;
|
15769 | case 'v':
|
15770 | res = 'downarrow';
|
15771 | break;
|
15772 | case 'ellipsis':
|
15773 | res = '\\ldots ';
|
15774 | break;
|
15775 | case '/':
|
15776 | res = '/';
|
15777 | break;
|
15778 | case ' / ':
|
15779 | res = '\\,/\\,';
|
15780 | break;
|
15781 | default:
|
15782 | throw ['MhchemBugT', 'mhchem bug T. Please report.'];
|
15783 | }
|
15784 | return res;
|
15785 | },
|
15786 | _getArrow: function (a) {
|
15787 | switch (a) {
|
15788 | case '->':
|
15789 | return 'rightarrow';
|
15790 | case '\u2192':
|
15791 | return 'rightarrow';
|
15792 | case '\u27F6':
|
15793 | return 'rightarrow';
|
15794 | case '<-':
|
15795 | return 'leftarrow';
|
15796 | case '<->':
|
15797 | return 'leftrightarrow';
|
15798 | case '<-->':
|
15799 | return 'rightleftarrows';
|
15800 | case '<=>':
|
15801 | return 'rightleftharpoons';
|
15802 | case '\u21CC':
|
15803 | return 'rightleftharpoons';
|
15804 | case '<=>>':
|
15805 | return 'rightequilibrium';
|
15806 | case '<<=>':
|
15807 | return 'leftequilibrium';
|
15808 | default:
|
15809 | throw ['MhchemBugT', 'mhchem bug T. Please report.'];
|
15810 | }
|
15811 | },
|
15812 | _getBond: function (a) {
|
15813 | switch (a) {
|
15814 | case '-':
|
15815 | return '{-}';
|
15816 | case '1':
|
15817 | return '{-}';
|
15818 | case '=':
|
15819 | return '{=}';
|
15820 | case '2':
|
15821 | return '{=}';
|
15822 | case '#':
|
15823 | return '{\\equiv}';
|
15824 | case '3':
|
15825 | return '{\\equiv}';
|
15826 | case '~':
|
15827 | return '{\\tripledash}';
|
15828 | case '~-':
|
15829 | return '{\\mathrlap{\\raisebox{-.1em}{$-$}}\\raisebox{.1em}{$\\tripledash$}}';
|
15830 | case '~=':
|
15831 | return '{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}';
|
15832 | case '~--':
|
15833 | return '{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}';
|
15834 | case '-~-':
|
15835 | return '{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$-$}}\\tripledash}';
|
15836 | case '...':
|
15837 | return '{{\\cdot}{\\cdot}{\\cdot}}';
|
15838 | case '....':
|
15839 | return '{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}';
|
15840 | case '->':
|
15841 | return '{\\rightarrow}';
|
15842 | case '<-':
|
15843 | return '{\\leftarrow}';
|
15844 | case '<':
|
15845 | return '{<}';
|
15846 | case '>':
|
15847 | return '{>}';
|
15848 | default:
|
15849 | throw ['MhchemBugT', 'mhchem bug T. Please report.'];
|
15850 | }
|
15851 | },
|
15852 | _getOperator: function (a) {
|
15853 | switch (a) {
|
15854 | case '+':
|
15855 | return ' {}+{} ';
|
15856 | case '-':
|
15857 | return ' {}-{} ';
|
15858 | case '=':
|
15859 | return ' {}={} ';
|
15860 | case '<':
|
15861 | return ' {}<{} ';
|
15862 | case '>':
|
15863 | return ' {}>{} ';
|
15864 | case '<<':
|
15865 | return ' {}\\ll{} ';
|
15866 | case '>>':
|
15867 | return ' {}\\gg{} ';
|
15868 | case '\\pm':
|
15869 | return ' {}\\pm{} ';
|
15870 | case '\\approx':
|
15871 | return ' {}\\approx{} ';
|
15872 | case '$\\approx$':
|
15873 | return ' {}\\approx{} ';
|
15874 | case 'v':
|
15875 | return ' \\downarrow{} ';
|
15876 | case '(v)':
|
15877 | return ' \\downarrow{} ';
|
15878 | case '^':
|
15879 | return ' \\uparrow{} ';
|
15880 | case '(^)':
|
15881 | return ' \\uparrow{} ';
|
15882 | default:
|
15883 | throw ['MhchemBugT', 'mhchem bug T. Please report.'];
|
15884 | }
|
15885 | },
|
15886 | };
|
15887 |
|
15888 |
|
15889 | newSymbols('0123456789/@.?!');
|
15890 | newSymbolRange(0x0041, 0x005a);
|
15891 | newSymbolRange(0x0061, 0x007a);
|
15892 |
|
15893 | newSymbols([
|
15894 | ['\\forall', 0x2200],
|
15895 | ['\\exists', 0x2203],
|
15896 | ['\\nexists', 0x2204, 'mord', 'ams'],
|
15897 | ['\\mid', 0x2223, 'mrel'],
|
15898 | ['\\top', 0x22a4],
|
15899 | ['\\bot', 0x22a5],
|
15900 | ]);
|
15901 |
|
15902 | newSymbols([
|
15903 | ['\\sharp', 0x266f],
|
15904 | ['\\flat', 0x266d],
|
15905 | ['\\natural', 0x266e],
|
15906 | ['\\#', 0x0023],
|
15907 | ['\\&', 0x0026],
|
15908 | ['\\clubsuit', 0x2663],
|
15909 | ['\\heartsuit', 0x2661],
|
15910 | ['\\spadesuit', 0x2660],
|
15911 | ['\\diamondsuit', 0x2662],
|
15912 | ]);
|
15913 |
|
15914 |
|
15915 |
|
15916 |
|
15917 |
|
15918 | newSymbols([
|
15919 | ['\\backslash', 0x005c],
|
15920 | ['\\nabla', 0x2207],
|
15921 | ['\\partial', 0x2202],
|
15922 | ['\\ell', 0x2113],
|
15923 | ['\\hbar', 0x210f],
|
15924 | ['\\Q', 0x0051, 'mord', 'double-struck'],
|
15925 | ['\\C', 0x0043, 'mord', 'double-struck'],
|
15926 | ['\\P', 0x0050, 'mord', 'double-struck'],
|
15927 | ['\\pounds', 0x00a3],
|
15928 | ['\\euro', 0x20ac],
|
15929 |
|
15930 | ]);
|
15931 |
|
15932 | newSymbols([
|
15933 | ['\\rightarrow', 0x2192],
|
15934 | ['\\to', 0x2192],
|
15935 | ['\\leftarrow', 0x2190],
|
15936 | ['\\gets', 0x2190],
|
15937 | ['\\Rightarrow', 0x21d2],
|
15938 | ['\\Leftarrow', 0x21d0],
|
15939 | ['\\longrightarrow', 0x27f6],
|
15940 | ['\\longleftarrow', 0x27f5],
|
15941 | ['\\Longrightarrow', 0x27f9],
|
15942 | ['\\implies', 0x27f9],
|
15943 | ['\\Longleftarrow', 0x27f8],
|
15944 | ['\\impliedby', 0x27f8],
|
15945 | ['\\longleftrightarrow', 0x27f7],
|
15946 | ['\\biconditional', 0x27f7],
|
15947 | ['\\Longleftrightarrow', 0x27fa],
|
15948 | ['\\mapsto', 0x21a6],
|
15949 | ['\\longmapsto', 0x27fc],
|
15950 | ['\\uparrow', 0x2191],
|
15951 | ['\\downarrow', 0x2193],
|
15952 | ['\\Uparrow', 0x21d1],
|
15953 | ['\\Downarrow', 0x21d3],
|
15954 | ['\\updownarrow', 0x2195],
|
15955 | ['\\Updownarrow', 0x21d5],
|
15956 | ['\\hookrightarrow', 0x21aa],
|
15957 | ['\\hookleftarrow', 0x21a9],
|
15958 | ['\\rightharpoonup', 0x21c0],
|
15959 | ['\\leftharpoonup', 0x21bc],
|
15960 | ['\\rightharpoondown', 0x21c1],
|
15961 | ['\\leftharpoondown', 0x21bd],
|
15962 | ['\\searrow', 0x2198],
|
15963 | ['\\nearrow', 0x2197],
|
15964 | ['\\swarrow', 0x2199],
|
15965 | ['\\nwarrow', 0x2196],
|
15966 | ['\\originalof', 0x22b6],
|
15967 | ['\\laplace', 0x22b6],
|
15968 | ['\\imageof', 0x22b7],
|
15969 | ['\\Laplace', 0x22b7],
|
15970 | ], 'mrel');
|
15971 |
|
15972 | newSymbols([
|
15973 |
|
15974 | ['\\lbrace', 0x007b, 'mopen'],
|
15975 | ['\\rbrace', 0x007d, 'mclose'],
|
15976 | ['\\lparen', 0x0028, 'mopen'],
|
15977 | ['\\rparen', 0x0029, 'mclose'],
|
15978 | ['\\langle', 0x27e8, 'mopen'],
|
15979 | ['\\rangle', 0x27e9, 'mclose'],
|
15980 | ['\\lfloor', 0x230a, 'mopen'],
|
15981 | ['\\rfloor', 0x230b, 'mclose'],
|
15982 | ['\\lceil', 0x2308, 'mopen'],
|
15983 | ['\\rceil', 0x2309, 'mclose'],
|
15984 | ['\\vert', 0x2223],
|
15985 | ['\\lvert', 0x2223, 'mopen'],
|
15986 | ['\\rvert', 0x2223, 'mclose'],
|
15987 | ['\\|', 0x2225],
|
15988 | ['\\Vert', 0x2225],
|
15989 | ['\\mVert', 0x2225],
|
15990 | ['\\lVert', 0x2225, 'mopen'],
|
15991 | ['\\rVert', 0x2225, 'mclose'],
|
15992 | ['\\lbrack', 0x005b, 'mopen'],
|
15993 | ['\\rbrack', 0x005d, 'mclose'],
|
15994 | ['\\{', 0x007b, 'mopen'],
|
15995 | ['\\}', 0x007d, 'mclose'],
|
15996 | ['(', 0x0028, 'mopen'],
|
15997 | [')', 0x029, 'mclose'],
|
15998 | ['[', 0x005b, 'mopen'],
|
15999 | [']', 0x005d, 'mclose'],
|
16000 | ['\\ulcorner', 0x250c, 'mopen', 'ams'],
|
16001 | ['\\urcorner', 0x2510, 'mclose', 'ams'],
|
16002 | ['\\llcorner', 0x2514, 'mopen', 'ams'],
|
16003 | ['\\lrcorner', 0x2518, 'mclose', 'ams'],
|
16004 |
|
16005 | ['\\lgroup', 0x27ee, 'mopen'],
|
16006 | ['\\rgroup', 0x27ef, 'mclose'],
|
16007 | ['\\lmoustache', 0x23b0, 'mopen'],
|
16008 | ['\\rmoustache', 0x23b1, 'mclose'],
|
16009 |
|
16010 |
|
16011 |
|
16012 | ]);
|
16013 | newSymbols([
|
16014 |
|
16015 | ['\\dashrightarrow', 0x21e2],
|
16016 | ['\\dashleftarrow', 0x21e0],
|
16017 | ['\\Rrightarrow', 0x21db],
|
16018 | ['\\Lleftarrow', 0x21da],
|
16019 | ['\\leftrightarrows', 0x21c6],
|
16020 | ['\\rightleftarrows', 0x21c4],
|
16021 | ['\\curvearrowright', 0x21b7],
|
16022 | ['\\curvearrowleft', 0x21b6],
|
16023 | ['\\rightrightarrows', 0x21c9],
|
16024 | ['\\leftleftarrows', 0x21c7],
|
16025 | ['\\upuparrows', 0x21c8],
|
16026 | ['\\downdownarrows', 0x21ca],
|
16027 | ['\\vartriangle', 0x25b3],
|
16028 | ['\\triangleq', 0x225c],
|
16029 | ['\\vartriangleleft', 0x22b2],
|
16030 | ['\\trianglelefteq', 0x22b4],
|
16031 | ['\\ntriangleleft', 0x22ea],
|
16032 | ['\\ntrianglelefteq', 0x22ec],
|
16033 | ['\\vartriangleright', 0x22b3],
|
16034 | ['\\trianglerighteq', 0x22b5],
|
16035 | ['\\ntriangleright', 0x22eb],
|
16036 | ['\\ntrianglerighteq', 0x22ed],
|
16037 | ['\\blacktriangleleft', 0x25c0],
|
16038 | ['\\blacktriangleright', 0x25b6],
|
16039 | ['\\leftarrowtail', 0x21a2],
|
16040 | ['\\rightarrowtail', 0x21a3],
|
16041 | ['\\looparrowright', 0x21ac],
|
16042 | ['\\looparrowleft', 0x21ab],
|
16043 | ['\\twoheadleftarrow', 0x219e],
|
16044 | ['\\twoheadrightarrow', 0x21a0],
|
16045 | ['\\rightleftharpoons', 0x21cc],
|
16046 | ['\\leftrightharpoons', 0x21cb],
|
16047 | ['\\Rsh', 0x21b1],
|
16048 | ['\\Lsh', 0x21b0],
|
16049 |
|
16050 | ['\\circlearrowright', 0x21bb],
|
16051 | ['\\circlearrowleft', 0x21ba],
|
16052 | ['\\restriction', 0x21be],
|
16053 | ['\\upharpoonright', 0x21be],
|
16054 | ['\\upharpoonleft', 0x21bf],
|
16055 | ['\\downharpoonright', 0x21c2],
|
16056 | ['\\downharpoonleft', 0x21c3],
|
16057 | ['\\rightsquigarrow', 0x21dd],
|
16058 | ['\\leadsto', 0x21dd],
|
16059 | ['\\leftrightsquigarrow', 0x21ad],
|
16060 | ['\\multimap', 0x22b8],
|
16061 |
|
16062 | ['\\nrightarrow', 0x219b],
|
16063 | ['\\nleftarrow', 0x219a],
|
16064 | ['\\nRightarrow', 0x21cf],
|
16065 | ['\\nLeftarrow', 0x21cd],
|
16066 | ['\\nleftrightarrow', 0x21ae],
|
16067 | ['\\nLeftrightarrow', 0x21ce],
|
16068 |
|
16069 | ['\\shortparallel', 0x2225],
|
16070 | ['\\nless', 0x226e],
|
16071 | ['\\nleqslant', 0xe010],
|
16072 | ['\\lneq', 0x2a87],
|
16073 | ['\\lneqq', 0x2268],
|
16074 | ['\\nleqq', 0xe011],
|
16075 | ['\\lvertneqq', 0xe00c],
|
16076 | ['\\lnsim', 0x22e6],
|
16077 | ['\\lnapprox', 0x2a89],
|
16078 | ['\\nprec', 0x2280],
|
16079 | ['\\npreceq', 0x22e0],
|
16080 | ['\\precnsim', 0x22e8],
|
16081 | ['\\precnapprox', 0x2ab9],
|
16082 | ['\\nsim', 0x2241],
|
16083 | ['\\nshortmid', 0xe006],
|
16084 | ['\\nmid', 0x2224],
|
16085 | ['\\nvdash', 0x22ac],
|
16086 | ['\\nvDash', 0x22ad],
|
16087 | ['\\ngtr', 0x226f],
|
16088 | ['\\ngeqslant', 0xe00f],
|
16089 | ['\\ngeqq', 0xe00e],
|
16090 | ['\\gneq', 0x2a88],
|
16091 | ['\\gneqq', 0x2269],
|
16092 | ['\\gvertneqq', 0xe00d],
|
16093 | ['\\gnsim', 0x22e7],
|
16094 | ['\\gnapprox', 0x2a8a],
|
16095 | ['\\nsucc', 0x2281],
|
16096 | ['\\nsucceq', 0x22e1],
|
16097 | ['\\succnsim', 0x22e9],
|
16098 | ['\\succnapprox', 0x2aba],
|
16099 | ['\\ncong', 0x2246],
|
16100 | ['\\nshortparallel', 0xe007],
|
16101 | ['\\nparallel', 0x2226],
|
16102 | ['\\nVDash', 0x22af],
|
16103 | ['\\nsupseteqq', 0xe018],
|
16104 | ['\\supsetneq', 0x228b],
|
16105 | ['\\varsupsetneq', 0xe01b],
|
16106 | ['\\supsetneqq', 0x2acc],
|
16107 | ['\\varsupsetneqq', 0xe019],
|
16108 | ['\\nVdash', 0x22ae],
|
16109 | ['\\precneqq', 0x2ab5],
|
16110 | ['\\succneqq', 0x2ab6],
|
16111 | ['\\nsubseteqq', 0xe016],
|
16112 | ['\\leqslant', 0x2a7d],
|
16113 | ['\\geqslant', 0x2a7e],
|
16114 | ['\\gtrsim', 0x2273],
|
16115 | ['\\approxeq', 0x224a],
|
16116 | ['\\thickapprox', 0x2248],
|
16117 | ['\\lessapprox', 0x2a85],
|
16118 | ['\\gtrapprox', 0x2a86],
|
16119 | ['\\precapprox', 0x2ab7],
|
16120 | ['\\succapprox', 0x2ab8],
|
16121 | ['\\thicksim', 0x223c],
|
16122 | ['\\succsim', 0x227f],
|
16123 | ['\\precsim', 0x227e],
|
16124 | ['\\backsim', 0x223d],
|
16125 | ['\\eqsim', 0x2242],
|
16126 | ['\\backsimeq', 0x22cd],
|
16127 | ['\\lesssim', 0x2272],
|
16128 | ['\\nleq', 0x2270],
|
16129 | ['\\ngeq', 0x2271],
|
16130 | ['\\smallsmile', 0x2323],
|
16131 | ['\\smallfrown', 0x2322],
|
16132 | ['\\leqq', 0x2266],
|
16133 | ['\\eqslantless', 0x2a95],
|
16134 | ['\\lll', 0x22d8],
|
16135 | ['\\lessgtr', 0x2276],
|
16136 | ['\\lesseqgtr', 0x22da],
|
16137 | ['\\lesseqqgtr', 0x2a8b],
|
16138 | ['\\risingdotseq', 0x2253],
|
16139 | ['\\fallingdotseq', 0x2252],
|
16140 | ['\\subseteqq', 0x2ac5],
|
16141 | ['\\Subset', 0x22d0],
|
16142 | ['\\sqsubset', 0x228f],
|
16143 | ['\\preccurlyeq', 0x227c],
|
16144 | ['\\curlyeqprec', 0x22de],
|
16145 | ['\\vDash', 0x22a8],
|
16146 | ['\\Vvdash', 0x22aa],
|
16147 | ['\\bumpeq', 0x224f],
|
16148 | ['\\Bumpeq', 0x224e],
|
16149 | ['\\geqq', 0x2267],
|
16150 | ['\\eqslantgtr', 0x2a96],
|
16151 | ['\\ggg', 0x22d9],
|
16152 | ['\\gtrless', 0x2277],
|
16153 | ['\\gtreqless', 0x22db],
|
16154 | ['\\gtreqqless', 0x2a8c],
|
16155 | ['\\supseteqq', 0x2ac6],
|
16156 | ['\\Supset', 0x22d1],
|
16157 | ['\\sqsupset', 0x2290],
|
16158 | ['\\succcurlyeq', 0x227d],
|
16159 | ['\\curlyeqsucc', 0x22df],
|
16160 | ['\\Vdash', 0x22a9],
|
16161 | ['\\shortmid', 0x2223],
|
16162 | ['\\between', 0x226c],
|
16163 | ['\\pitchfork', 0x22d4],
|
16164 | ['\\varpropto', 0x221d],
|
16165 | ['\\backepsilon', 0x220d],
|
16166 | ['\\llless', 0x22d8],
|
16167 | ['\\gggtr', 0x22d9],
|
16168 | ['\\doteqdot', 0x2251],
|
16169 | ['\\Doteq', 0x2251],
|
16170 | ['\\eqcirc', 0x2256],
|
16171 | ['\\circeq', 0x2257],
|
16172 | ['\\therefore', 0x2234],
|
16173 | ['\\because', 0x2235],
|
16174 | ], 'mrel', 'ams');
|
16175 |
|
16176 | newSymbols([
|
16177 | ['+', 0x002b],
|
16178 | ['-', 0x2212],
|
16179 | ['\u2212', 0x2212],
|
16180 | ['\\pm', 0x00b1],
|
16181 | ['\\mp', 0x2213],
|
16182 | ['*', 0x2217],
|
16183 | ['\\times', 0x00d7],
|
16184 | ['\\div', 0x00f7],
|
16185 | ['\\divides', 0x2223],
|
16186 | ['\\cdot', 0x22c5],
|
16187 | ['\\cap', 0x2229],
|
16188 | ['\\cup', 0x222a],
|
16189 | ['\\setminus', 0x2216],
|
16190 | ['\\land', 0x2227],
|
16191 | ['\\wedge', 0x2227],
|
16192 | ['\\lor', 0x2228],
|
16193 | ['\\vee', 0x2228],
|
16194 | ['\\circ', 0x2218],
|
16195 | ['\\bigcirc', 0x25ef],
|
16196 | ['\\bullet', 0x2219],
|
16197 | ['\\oplus', 0x2295],
|
16198 | ['\\ominus', 0x2296],
|
16199 | ['\\otimes', 0x2297],
|
16200 | ['\\odot', 0x2299],
|
16201 | ['\\oslash', 0x2298],
|
16202 | ['\\bigtriangleup', 0x25b3],
|
16203 | ['\\bigtriangledown', 0x25bd],
|
16204 | ['\\triangleleft', 0x25c3],
|
16205 | ['\\triangleright', 0x25b9],
|
16206 | ['\\And', 0x0026],
|
16207 | ['\\dagger', 0x2020],
|
16208 | ['\\dag', 0x2020],
|
16209 | ['\\ddag', 0x2021],
|
16210 | ['\\ddagger', 0x2021],
|
16211 | ['\\ast', 0x2217],
|
16212 | ['\\star', 0x22c6],
|
16213 | ['\\bigstar', 0x2605],
|
16214 | ['\\diamond', 0x22c4],
|
16215 | ], 'mbin');
|
16216 |
|
16217 | newSymbols([
|
16218 | ['\\lhd', 0x22b2],
|
16219 | ['\\rhd', 0x22b3],
|
16220 | ['\\lessdot', 0x22d6],
|
16221 | ['\\gtrdot', 0x22d7],
|
16222 | ['\\ltimes', 0x22c9],
|
16223 | ['\\rtimes', 0x22ca],
|
16224 | ['\\leftthreetimes', 0x22cb],
|
16225 | ['\\rightthreetimes', 0x22cc],
|
16226 | ['\\intercal', 0x22ba],
|
16227 | ['\\dotplus', 0x2214],
|
16228 | ['\\doublebarwedge', 0x2a5e],
|
16229 | ['\\divideontimes', 0x22c7],
|
16230 | ['\\centerdot', 0x22c5],
|
16231 | ['\\smallsetminus', 0x2216],
|
16232 | ['\\barwedge', 0x22bc],
|
16233 | ['\\veebar', 0x22bb],
|
16234 | ['\\nor', 0x22bb],
|
16235 | ['\\curlywedge', 0x22cf],
|
16236 | ['\\curlyvee', 0x22ce],
|
16237 | ['\\boxminus', 0x229f],
|
16238 | ['\\boxplus', 0x229e],
|
16239 | ['\\boxtimes', 0x22a0],
|
16240 | ['\\boxdot', 0x22a1],
|
16241 | ['\\circleddash', 0x229d],
|
16242 | ['\\circledast', 0x229b],
|
16243 | ['\\circledcirc', 0x229a],
|
16244 | ['\\unlhd', 0x22b4],
|
16245 | ['\\unrhd', 0x22b5],
|
16246 | ], 'mbin', 'ams');
|
16247 |
|
16248 | newSymbols([
|
16249 | ['\\surd', 0x221a],
|
16250 |
|
16251 | ['\\infty', 0x221e],
|
16252 | ['\\prime', 0x2032],
|
16253 | ['\\doubleprime', 0x2033],
|
16254 | ['\\angle', 0x2220],
|
16255 | ['`', 0x2018],
|
16256 | ['\\$', 0x0024],
|
16257 | ['\\%', 0x0025],
|
16258 | ['\\_', 0x005f],
|
16259 |
|
16260 | ['\\alpha', 0x03b1],
|
16261 | ['\\beta', 0x03b2],
|
16262 | ['\\gamma', 0x03b3],
|
16263 | ['\\delta', 0x03b4],
|
16264 | ['\\epsilon', 0x03f5],
|
16265 | ['\\varepsilon', 0x03b5],
|
16266 | ['\\zeta', 0x03b6],
|
16267 | ['\\eta', 0x03b7],
|
16268 | ['\\theta', 0x03b8],
|
16269 | ['\\vartheta', 0x03d1],
|
16270 | ['\\iota', 0x03b9],
|
16271 | ['\\kappa', 0x03ba],
|
16272 | ['\\varkappa', 0x03f0, 'mord', 'ams'],
|
16273 | ['\\lambda', 0x03bb],
|
16274 | ['\\mu', 0x03bc],
|
16275 | ['\\nu', 0x03bd],
|
16276 | ['\\xi', 0x03be],
|
16277 | ['\\omicron', 0x006f],
|
16278 | ['\\pi', 0x03c0],
|
16279 | ['\\varpi', 0x03d6],
|
16280 | ['\\rho', 0x03c1],
|
16281 | ['\\varrho', 0x03f1],
|
16282 | ['\\sigma', 0x03c3],
|
16283 | ['\\varsigma', 0x03c2],
|
16284 | ['\\tau', 0x03c4],
|
16285 | ['\\phi', 0x03d5],
|
16286 | ['\\varphi', 0x03c6],
|
16287 | ['\\upsilon', 0x03c5],
|
16288 | ['\\chi', 0x03c7],
|
16289 | ['\\psi', 0x03c8],
|
16290 | ['\\omega', 0x03c9],
|
16291 | ['\\Gamma', 0x0393],
|
16292 | ['\\Delta', 0x0394],
|
16293 | ['\\Theta', 0x0398],
|
16294 | ['\\Lambda', 0x039b],
|
16295 | ['\\Xi', 0x039e],
|
16296 | ['\\Pi', 0x03a0],
|
16297 | ['\\Sigma', 0x03a3],
|
16298 | ['\\Upsilon', 0x03a5],
|
16299 | ['\\Phi', 0x03a6],
|
16300 | ['\\Psi', 0x03a8],
|
16301 | ['\\Omega', 0x03a9],
|
16302 |
|
16303 | ['\\digamma', 0x03dd, 'mord', 'ams'],
|
16304 | ['\\emptyset', 0x2205],
|
16305 | ]);
|
16306 |
|
16307 | newSymbols([
|
16308 | ['=', 0x003d],
|
16309 | ['<', 0x003c],
|
16310 | ['\\lt', 0x003c],
|
16311 | ['>', 0x003e],
|
16312 | ['\\gt', 0x003e],
|
16313 | ['\\le', 0x2264],
|
16314 | ['\\leq', 0x2264],
|
16315 | ['\\ge', 0x2265],
|
16316 | ['\\geq', 0x2265],
|
16317 | ['\\ll', 0x226a],
|
16318 | ['\\gg', 0x226b],
|
16319 | ['\\coloneq', 0x2254],
|
16320 | ['\\measeq', 0x225d],
|
16321 | ['\\eqdef', 0x225e],
|
16322 | ['\\questeq', 0x225f],
|
16323 | [':', 0x003a],
|
16324 | ['\\cong', 0x2245],
|
16325 | ['\\equiv', 0x2261],
|
16326 | ['\\prec', 0x227a],
|
16327 | ['\\preceq', 0x2aaf],
|
16328 | ['\\succ', 0x227b],
|
16329 | ['\\succeq', 0x2ab0],
|
16330 | ['\\perp', 0x22a5],
|
16331 | ['\\propto', 0x221d],
|
16332 | ['\\Colon', 0x2237],
|
16333 | ['\\smile', 0x2323],
|
16334 | ['\\frown', 0x2322],
|
16335 | ['\\sim', 0x223c],
|
16336 | ['\\doteq', 0x2250],
|
16337 | ['\\bowtie', 0x22c8],
|
16338 | ['\\Join', 0x22c8],
|
16339 | ['\\asymp', 0x224d],
|
16340 | ['\\sqsubseteq', 0x2291],
|
16341 | ['\\sqsupseteq', 0x2292],
|
16342 | ['\\approx', 0x2248],
|
16343 |
|
16344 |
|
16345 | ['\\~', 0x007e],
|
16346 | ['\\leftrightarrow', 0x2194],
|
16347 | ['\\Leftrightarrow', 0x21d4],
|
16348 | ['\\models', 0x22a8],
|
16349 | ['\\vdash', 0x22a2],
|
16350 | ['\\dashv', 0x22a3],
|
16351 | ['\\roundimplies', 0x2970],
|
16352 | ['\\in', 0x2208],
|
16353 | ['\\notin', 0x2209],
|
16354 |
|
16355 |
|
16356 | ['\\ni', 0x220b],
|
16357 | ['\\owns', 0x220b],
|
16358 | ['\\subset', 0x2282],
|
16359 | ['\\supset', 0x2283],
|
16360 | ['\\subseteq', 0x2286],
|
16361 | ['\\supseteq', 0x2287],
|
16362 | ['\\differencedelta', 0x2206],
|
16363 | ['\\mvert', 0x2223],
|
16364 | ['\\parallel', 0x2225],
|
16365 | ['\\simeq', 0x2243],
|
16366 | ], 'mrel');
|
16367 |
|
16368 | newSymbols([
|
16369 | ['\\lnot', 0x00ac],
|
16370 | ['\\neg', 0x00ac],
|
16371 | ['\\triangle', 0x25b3],
|
16372 | ['\\subsetneq', 0x228a],
|
16373 | ['\\varsubsetneq', 0xe01a],
|
16374 | ['\\subsetneqq', 0x2acb],
|
16375 | ['\\varsubsetneqq', 0xe017],
|
16376 | ['\\nsubset', 0x2284],
|
16377 | ['\\nsupset', 0x2285],
|
16378 | ['\\nsubseteq', 0x2288],
|
16379 | ['\\nsupseteq', 0x2289],
|
16380 | ], 'mrel', 'ams');
|
16381 | newSymbols([
|
16382 | ['\\wp', 0x2118],
|
16383 | ['\\aleph', 0x2135],
|
16384 | ]);
|
16385 |
|
16386 | newSymbols([
|
16387 | ['\\blacktriangle', 0x25b2],
|
16388 | ['\\hslash', 0x210f],
|
16389 | ['\\Finv', 0x2132],
|
16390 | ['\\Game', 0x2141],
|
16391 | ['\\eth', 0x00f0],
|
16392 | ['\\mho', 0x2127],
|
16393 | ['\\Bbbk', 0x006b],
|
16394 | ['\\yen', 0x00a5],
|
16395 | ['\\square', 0x25a1],
|
16396 | ['\\Box', 0x25a1],
|
16397 | ['\\blacksquare', 0x25a0],
|
16398 | ['\\circledS', 0x24c8],
|
16399 | ['\\circledR', 0x00ae],
|
16400 | ['\\triangledown', 0x25bd],
|
16401 | ['\\blacktriangledown', 0x25bc],
|
16402 | ['\\checkmark', 0x2713],
|
16403 | ['\\diagup', 0x2571],
|
16404 | ['\\measuredangle', 0x2221],
|
16405 | ['\\sphericalangle', 0x2222],
|
16406 | ['\\backprime', 0x2035],
|
16407 | ['\\backdoubleprime', 0x2036],
|
16408 | ['\\Diamond', 0x25ca],
|
16409 | ['\\lozenge', 0x25ca],
|
16410 | ['\\blacklozenge', 0x29eb],
|
16411 | ['\\varnothing', 0x2205],
|
16412 | ['\\complement', 0x2201],
|
16413 | ['\\maltese', 0x2720],
|
16414 |
|
16415 | ['\\beth', 0x2136],
|
16416 | ['\\daleth', 0x2138],
|
16417 | ['\\gimel', 0x2137],
|
16418 | ], 'mord', 'ams');
|
16419 | newSymbols([
|
16420 |
|
16421 | ['\\ ', 0x00a0],
|
16422 | ['~', 0x00a0],
|
16423 | ['\\space', 0x00a0],
|
16424 | ], 'space');
|
16425 |
|
16426 | defineFunction(['!', ',', ':', ';', 'enskip', 'enspace', 'quad', 'qquad'], '', {
|
16427 | createAtom: (command, _args, style) => new SpacingAtom(command, style),
|
16428 | });
|
16429 |
|
16430 | newSymbols([
|
16431 | ['\\colon', 0x003a],
|
16432 | ['\\cdotp', 0x22c5],
|
16433 | ['\\vdots', 0x22ee, 'mord'],
|
16434 | ['\\ldotp', 0x002e],
|
16435 | [',', 0x002c],
|
16436 | [';', 0x003b],
|
16437 | ], 'mpunct');
|
16438 | newSymbols([
|
16439 | ['\\cdots', 0x22ef],
|
16440 | ['\\ddots', 0x22f1],
|
16441 | ['\\ldots', 0x2026],
|
16442 | ['\\mathellipsis', 0x2026],
|
16443 | ], 'minner');
|
16444 | newSymbols([
|
16445 | ['\\/', 0x002f],
|
16446 | ['|', 0x2223, 'mord'],
|
16447 | ['\\imath', 0x0131],
|
16448 | ['\\jmath', 0x0237],
|
16449 | ['\\degree', 0x00b0],
|
16450 | ["'", 0x2032],
|
16451 | ['"', 0x201d],
|
16452 |
|
16453 | ]);
|
16454 |
|
16455 | var _a$1, _b$1;
|
16456 |
|
16457 | function getFileUrl() {
|
16458 | const stackTraceFrames = String(new Error().stack)
|
16459 | .replace(/^Error.*\n/, '')
|
16460 | .split('\n');
|
16461 | if (stackTraceFrames.length === 0) {
|
16462 | console.error("Can't use relative paths to specify assets location because the source" +
|
16463 | 'file location could not be determined (unexpected stack trace format' +
|
16464 | ` "${new Error().stack}").`);
|
16465 | return '';
|
16466 | }
|
16467 |
|
16468 |
|
16469 | let callerFrame = stackTraceFrames[1];
|
16470 |
|
16471 | let m = callerFrame.match(/http.*\.ts[\?:]/);
|
16472 | if (m) {
|
16473 |
|
16474 |
|
16475 | callerFrame = stackTraceFrames[2];
|
16476 | }
|
16477 | m = callerFrame.match(/(http.*(\.mjs|\.js))[\?:]/);
|
16478 | if (!m) {
|
16479 |
|
16480 | m = callerFrame.match(/at (.*(\.ts))[\?:]/);
|
16481 | if (!m) {
|
16482 | m = callerFrame.match(/at (.*(\.mjs|\.js))[\?:]/);
|
16483 | }
|
16484 | }
|
16485 | if (!m) {
|
16486 | console.error(stackTraceFrames);
|
16487 | console.error("Can't use relative paths to specify assets location because the source " +
|
16488 | 'file location could not be determined ' +
|
16489 | `(unexpected location "${callerFrame}").`);
|
16490 | return '';
|
16491 | }
|
16492 | return m[1];
|
16493 | }
|
16494 | function resolveRelativeUrl(url) {
|
16495 | let result = '';
|
16496 | try {
|
16497 | result = new URL(url, gScriptUrl).toString();
|
16498 | }
|
16499 | catch (e) {
|
16500 | console.error(`Invalid URL "${url}" (relative to "${gScriptUrl}")`);
|
16501 | }
|
16502 | return result;
|
16503 | }
|
16504 |
|
16505 |
|
16506 |
|
16507 |
|
16508 |
|
16509 |
|
16510 |
|
16511 |
|
16512 |
|
16513 |
|
16514 | const gScriptUrl = ((_b$1 = (_a$1 = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) === null || _a$1 === void 0 ? void 0 : _a$1.currentScript) === null || _b$1 === void 0 ? void 0 : _b$1.src) ||
|
16515 | getFileUrl();
|
16516 |
|
16517 | function makeFontFace(name, source, descriptors = {}) {
|
16518 | return new FontFace(name, `url(${source}.woff2) format('woff2')`, descriptors);
|
16519 | }
|
16520 | async function loadFonts(fontsDirectory, onError) {
|
16521 | var _a;
|
16522 |
|
16523 | if (!isBrowser() || document.body.classList.contains('ML__fonts-loading')) {
|
16524 | return;
|
16525 | }
|
16526 |
|
16527 |
|
16528 |
|
16529 | const useStaticFonts = (_a = getComputedStyle(document.documentElement).getPropertyValue('--ML__static-fonts')) !== null && _a !== void 0 ? _a : false;
|
16530 | if (useStaticFonts)
|
16531 | return;
|
16532 | if ('fonts' in document) {
|
16533 | const fontFamilies = [
|
16534 | 'KaTeX_Main',
|
16535 | 'KaTeX_Math',
|
16536 | 'KaTeX_AMS',
|
16537 | 'KaTeX_Caligraphic',
|
16538 | 'KaTeX_Fraktur',
|
16539 | 'KaTeX_SansSerif',
|
16540 | 'KaTeX_Script',
|
16541 | 'KaTeX_Size1',
|
16542 | 'KaTeX_Size2',
|
16543 | 'KaTeX_Size3',
|
16544 | 'KaTeX_Size4',
|
16545 | ];
|
16546 | let fontsLoaded = false;
|
16547 | if (supportLocalFontEnumeration()) {
|
16548 | try {
|
16549 | fontsLoaded = fontFamilies.every((x) => document.fonts.check('16px ' + x));
|
16550 | }
|
16551 | catch {
|
16552 | fontsLoaded = false;
|
16553 | }
|
16554 | }
|
16555 | if (fontsLoaded)
|
16556 | return;
|
16557 |
|
16558 | const fontsFolder = resolveRelativeUrl(fontsDirectory !== null && fontsDirectory !== void 0 ? fontsDirectory : './fonts');
|
16559 | if (!fontsFolder)
|
16560 | return;
|
16561 | document.body.classList.add('ML__fonts-loading');
|
16562 | const fonts = [
|
16563 | ['KaTeX_Main-Regular'],
|
16564 | ['KaTeX_Main-BoldItalic', { style: 'italic', weight: 'bold' }],
|
16565 | ['KaTeX_Main-Bold', { weight: 'bold' }],
|
16566 | ['KaTeX_Main-Italic', { style: 'italic' }],
|
16567 | ['KaTeX_Math-Italic', { style: 'italic' }],
|
16568 | ['KaTeX_Math-BoldItalic', { style: 'italic', weight: 'bold' }],
|
16569 | ['KaTeX_AMS-Regular'],
|
16570 | ['KaTeX_Caligraphic-Regular'],
|
16571 | ['KaTeX_Caligraphic-Bold', { weight: 'bold' }],
|
16572 | ['KaTeX_Fraktur-Regular'],
|
16573 | ['KaTeX_Fraktur-Bold', { weight: 'bold' }],
|
16574 | ['KaTeX_SansSerif-Regular', { style: 'italic' }],
|
16575 | ['KaTeX_SansSerif-Bold', { weight: 'bold' }],
|
16576 | ['KaTeX_SansSerif-Italic', { style: 'italic' }],
|
16577 | ['KaTeX_Script-Regular'],
|
16578 | ['KaTeX_Typewriter-Regular'],
|
16579 | ['KaTeX_Size1-Regular'],
|
16580 | ['KaTeX_Size2-Regular'],
|
16581 | ['KaTeX_Size3-Regular'],
|
16582 | ['KaTeX_Size4-Regular'],
|
16583 | ].map((x) => makeFontFace(x[0].replace(/-[a-zA-Z]+$/, ''), fontsFolder + '/' + x[0], x[1]));
|
16584 | try {
|
16585 | const loadedFonts = (await Promise.all(fonts.map((x) => {
|
16586 | try {
|
16587 | return x.load();
|
16588 | }
|
16589 | catch { }
|
16590 | return undefined;
|
16591 | })));
|
16592 |
|
16593 | loadedFonts.forEach((font) => document.fonts.add(font));
|
16594 | }
|
16595 | catch (error) {
|
16596 | console.error(`The mathlive fonts could not be loaded from "${fontsFolder}" (${error})`);
|
16597 | if (typeof onError === 'function') {
|
16598 | onError({
|
16599 | code: 'font-not-found',
|
16600 | arg: error,
|
16601 | });
|
16602 | }
|
16603 | }
|
16604 |
|
16605 |
|
16606 | document.body.classList.remove('ML__fonts-loading');
|
16607 | }
|
16608 | }
|
16609 |
|
16610 | function inject(element, css, id) {
|
16611 | var _a, _b;
|
16612 | throwIfNotInBrowser();
|
16613 | if (!css)
|
16614 | return null;
|
16615 | let root = (_a = element === null || element === void 0 ? void 0 : element.getRootNode()) !== null && _a !== void 0 ? _a : document === null || document === void 0 ? void 0 : document.head;
|
16616 | if (!root)
|
16617 | return null;
|
16618 | if (root === document)
|
16619 | root = document.head;
|
16620 | const element_ = root.querySelector(`style[data-id="${id}"]`);
|
16621 | if (element_) {
|
16622 | const refCount = Number.parseFloat((_b = element_.getAttribute('data-refcount')) !== null && _b !== void 0 ? _b : '0');
|
16623 | element_.dataset.refcount = Number(refCount + 1).toString();
|
16624 | }
|
16625 | else {
|
16626 |
|
16627 | const styleNode = document.createElement('style');
|
16628 |
|
16629 |
|
16630 | styleNode.dataset.id = id;
|
16631 | styleNode.dataset.refcount = '1';
|
16632 | styleNode.append(document.createTextNode(css));
|
16633 | root.appendChild(styleNode);
|
16634 | }
|
16635 | return {
|
16636 | release: () => {
|
16637 | var _a;
|
16638 | const element_ = document.head.querySelector(`style[data-id="${id}"]`);
|
16639 | if (element_) {
|
16640 | const refCount = Number.parseFloat((_a = element_.getAttribute('data-refcount')) !== null && _a !== void 0 ? _a : '0');
|
16641 | if (refCount === 1) {
|
16642 | element_.remove();
|
16643 | }
|
16644 | else {
|
16645 | element_.dataset.refcount = Number(refCount - 1).toString();
|
16646 | }
|
16647 | }
|
16648 | },
|
16649 | };
|
16650 | }
|
16651 |
|
16652 | var css_248z$4 = ".ML__sr-only{clip:rect(0,0,0,0);border:0;height:1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.ML__base,.ML__isInline{display:inline-block}.ML__base{border:0;box-sizing:content-box;cursor:text;font-family:inherit;font-style:inherit;font-weight:inherit;margin:0;outline:0;padding:0;position:relative;text-decoration:none;vertical-align:baseline;visibility:inherit;width:min-content}body.ML__fonts-loading .ML__base{visibility:hidden}.ML__strut,.ML__strut--bottom{display:inline-block;min-height:.5em}.ML__small-delim{font-family:KaTeX_Main}.ML__text{font-family:var(--text-font-family,system-ui,-apple-system,BlinkMacSystemFont,\"Segoe UI\",\"Roboto\",\"Oxygen\",\"Ubuntu\",\"Cantarell\",\"Fira Sans\",\"Droid Sans\",\"Helvetica Neue\",sans-serif);white-space:pre}.ML__cmr{font-family:KaTeX_Main;font-style:normal}.ML__mathit{font-family:KaTeX_Math;font-style:italic}.ML__mathbf{font-family:KaTeX_Main;font-weight:700}.lcGreek.ML__mathbf{font-family:KaTeX_Math;font-weight:400}.ML__mathbfit{font-family:KaTeX_Math;font-style:italic;font-weight:700}.ML__ams,.ML__bb{font-family:KaTeX_AMS}.ML__cal{font-family:KaTeX_Caligraphic}.ML__frak{font-family:KaTeX_Fraktur}.ML__tt{font-family:KaTeX_Typewriter}.ML__script{font-family:KaTeX_Script}.ML__sans{font-family:KaTeX_SansSerif}.ML__series_el,.ML__series_ul{font-weight:100}.ML__series_l{font-weight:200}.ML__series_sl{font-weight:300}.ML__series_sb{font-weight:500}.ML__bold,.ML__boldsymbol{font-weight:700}.ML__series_eb{font-weight:800}.ML__series_ub{font-weight:900}.ML__series_uc{font-stretch:ultra-condensed}.ML__series_ec{font-stretch:extra-condensed}.ML__series_c{font-stretch:condensed}.ML__series_sc{font-stretch:semi-condensed}.ML__series_sx{font-stretch:semi-expanded}.ML__series_x{font-stretch:expanded}.ML__series_ex{font-stretch:extra-expanded}.ML__series_ux{font-stretch:ultra-expanded}.ML__it{font-style:italic}.ML__shape_ol{-webkit-text-stroke:1px #000;text-stroke:1px #000;color:transparent}.ML__shape_sc{font-variant:small-caps}.ML__shape_sl{font-style:oblique}.ML__emph{color:#bc2612}.ML__emph .ML__emph{color:#0c7f99}.ML__highlight{background:#edd1b0;color:#007cb2}.ML__center{text-align:center}.ML__frac-line{min-height:1px;width:100%}.ML__frac-line:after{background:currentColor;box-sizing:content-box;content:\"\";display:block;margin-top:-.04em;min-height:.04em;transform:translate(0)}.ML__sqrt,.ML__sqrt-sign{display:inline-block}.ML__sqrt-sign{font-family:KaTeX_Main;position:relative}.ML__sqrt-line{display:inline-block;height:.04em;width:100%}.ML__sqrt-line:before{background:currentColor;content:\"\";display:block;margin-top:-.04em;min-height:.04em}.ML__sqrt-line:after{border-bottom-width:1px;content:\" \";display:block;margin-top:-.1em;transform:translate(0)}.ML__sqrt-index{margin-left:.27777778em;margin-right:-.55555556em}.ML__delim-size1{font-family:KaTeX_Size1}.ML__delim-size2{font-family:KaTeX_Size2}.ML__delim-size3{font-family:KaTeX_Size3}.ML__delim-size4{font-family:KaTeX_Size4}.ML__delim-mult .delim-size1>span{font-family:KaTeX_Size1}.ML__delim-mult .delim-size4>span{font-family:KaTeX_Size4}.ML__accent-body>span{font-family:KaTeX_Main;width:0}.ML__accent-vec>span{left:.38em;position:relative}.ML__mathlive{text-rendering:auto;word-wrap:normal;direction:ltr;display:inline-block;font-family:KaTeX_Main;font-size-adjust:none;font-stretch:normal;font-style:normal;font-variant-caps:normal;letter-spacing:normal;text-align:left;text-indent:0;text-shadow:none;transform:translateZ(0);-webkit-user-select:none;user-select:none;white-space:nowrap;width:min-content;word-spacing:normal}.ML__mathlive .style-wrap{position:relative}.ML__mathlive .left-right,.ML__mathlive .mfrac{display:inline-block}.ML__mathlive .vlist-t{border-collapse:collapse;display:inline-table;table-layout:fixed}.ML__mathlive .vlist-r{display:table-row}.ML__mathlive .vlist{display:table-cell;position:relative;vertical-align:bottom}.ML__mathlive .vlist>span{display:block;height:0;position:relative}.ML__mathlive .vlist>span>span{display:inline-block}.ML__mathlive .vlist>span>.pstrut{overflow:hidden;width:0}.ML__mathlive .vlist-t2{margin-right:-2px}.ML__mathlive .vlist-s{display:table-cell;font-size:1px;min-width:2px;vertical-align:bottom;width:2px}.ML__mathlive .msubsup{text-align:left}.ML__mathlive .negativethinspace{display:inline-block;margin-left:-.16667em}.ML__mathlive .thinspace{display:inline-block;width:.16667em}.ML__mathlive .mediumspace{display:inline-block;width:.22222em}.ML__mathlive .thickspace{display:inline-block;width:.27778em}.ML__mathlive .enspace{display:inline-block;width:.5em}.ML__mathlive .quad{display:inline-block;width:1em}.ML__mathlive .qquad{display:inline-block;width:2em}.ML__mathlive .llap,.ML__mathlive .rlap{display:inline-block;position:relative;width:0}.ML__mathlive .llap>.inner,.ML__mathlive .rlap>.inner{position:absolute}.ML__mathlive .llap>.fix,.ML__mathlive .rlap>.fix{display:inline-block}.ML__mathlive .llap>.inner{right:0}.ML__mathlive .rlap>.inner{left:0}.ML__mathlive .rule{border:0 solid;box-sizing:border-box;display:inline-block;position:relative}.ML__mathlive .overline .overline-line,.ML__mathlive .underline .underline-line{width:100%}.ML__mathlive .overline .overline-line:before,.ML__mathlive .underline .underline-line:before{border-bottom-style:solid;border-bottom-width:.04em;content:\"\";display:block}.ML__mathlive .overline .overline-line:after,.ML__mathlive .underline .underline-line:after{border-bottom-style:solid;border-bottom-width:.04em;content:\"\";display:block;margin-top:-1px;min-height:thin}.ML__mathlive .stretchy{display:block;left:0;overflow:hidden;position:absolute;width:100%}.ML__mathlive .stretchy:after,.ML__mathlive .stretchy:before{content:\"\"}.ML__mathlive .stretchy svg{fill:currentColor;stroke:currentColor;fill-rule:nonzero;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:block;height:inherit;position:absolute;width:100%}.ML__mathlive .slice-1-of-2{left:0}.ML__mathlive .slice-1-of-2,.ML__mathlive .slice-2-of-2{display:inline-flex;overflow:hidden;position:absolute;width:50.2%}.ML__mathlive .slice-2-of-2{right:0}.ML__mathlive .slice-1-of-3{display:inline-flex;left:0;overflow:hidden;position:absolute;width:25.1%}.ML__mathlive .slice-2-of-3{display:inline-flex;left:25%;overflow:hidden;position:absolute;width:50%}.ML__mathlive .slice-3-of-3{display:inline-flex;overflow:hidden;position:absolute;right:0;width:25.1%}.ML__mathlive .slice-1-of-1{display:inline-flex;left:0;overflow:hidden;position:absolute;width:100%}.ML__mathlive .nulldelimiter{display:inline-block;width:.12em}.ML__mathlive .op-group{display:inline-block}.ML__mathlive .op-symbol{position:relative}.ML__mathlive .op-symbol.small-op{font-family:KaTeX_Size1}.ML__mathlive .op-symbol.large-op{font-family:KaTeX_Size2}.ML__mathlive .accent>.vlist>span{text-align:center}.ML__mathlive .mtable .vertical-separator{box-sizing:border-box;display:inline-block;min-width:1px}.ML__mathlive .mtable .arraycolsep{display:inline-block}.ML__mathlive .mtable .col-align-m>.vlist-t{text-align:center}.ML__mathlive .mtable .col-align-c>.vlist-t{text-align:center}.ML__mathlive .mtable .col-align-l>.vlist-t{text-align:left}.ML__mathlive .mtable .col-align-r>.vlist-t{text-align:right}.ML__error{background-image:radial-gradient(ellipse at center,#cc0041,transparent 70%);background-position:0 98%;background-repeat:repeat-x;background-size:3px 3px}.ML__composition{background:#fff1c2;color:#000;-webkit-text-decoration:underline var(--caret,hsl(var(--hue,212),40%,49%));text-decoration:underline var(--caret,hsl(var(--hue,212),40%,49%))}@media (prefers-color-scheme:dark){.ML__composition{background:#69571c;color:#fff}}.ML__placeholder{color:var(--caret,hsl(var(--hue,212),40%,49%));font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;padding-left:.4ex;padding-right:.4ex}.ML__placeholdercontainer{display:none}.ML__isReadOnly .ML__placeholdercontainer{display:block}";
|
16653 |
|
16654 |
|
16655 |
|
16656 |
|
16657 | function getInlineShortcutsStartingWith(s, config) {
|
16658 | const result = [];
|
16659 | for (let i = 0; i <= s.length - 1; i++) {
|
16660 | const s2 = s.slice(Math.max(0, i));
|
16661 | for (const key of Object.keys(config.inlineShortcuts)) {
|
16662 | if (key.startsWith(s2) && !result.includes(key)) {
|
16663 | result.push(key);
|
16664 | }
|
16665 | }
|
16666 | }
|
16667 | return result;
|
16668 | }
|
16669 |
|
16670 |
|
16671 |
|
16672 |
|
16673 | function validateShortcut(siblings, shortcut) {
|
16674 | if (!shortcut)
|
16675 | return '';
|
16676 |
|
16677 | if (typeof shortcut === 'string')
|
16678 | return shortcut;
|
16679 |
|
16680 | if (!siblings)
|
16681 | return shortcut.value;
|
16682 | let nothing = false;
|
16683 | let letter = false;
|
16684 | let digit = false;
|
16685 | let isFunction = false;
|
16686 | let frac = false;
|
16687 | let surd = false;
|
16688 | let binop = false;
|
16689 | let relop = false;
|
16690 | let operator = false;
|
16691 | let punct = false;
|
16692 | let array = false;
|
16693 | let openfence = false;
|
16694 | let closefence = false;
|
16695 | let text = false;
|
16696 | let space = false;
|
16697 | let sibling = siblings[siblings.length - 1];
|
16698 | let index = siblings.length - 1;
|
16699 | while (sibling && /msubsup|placeholder/.test(sibling.type)) {
|
16700 | index -= 1;
|
16701 | sibling = siblings[index];
|
16702 | }
|
16703 | nothing = !sibling || sibling.type === 'first';
|
16704 | if (sibling) {
|
16705 | if (shortcut.mode !== undefined && sibling.mode !== shortcut.mode) {
|
16706 | return '';
|
16707 | }
|
16708 | text = sibling.mode === 'text';
|
16709 | letter = !text && sibling.type === 'mord' && LETTER.test(sibling.value);
|
16710 | digit = !text && sibling.type === 'mord' && /\d+$/.test(sibling.value);
|
16711 | isFunction = !text && sibling.isFunction;
|
16712 | frac = sibling.type === 'genfrac';
|
16713 | surd = sibling.type === 'surd';
|
16714 | binop = sibling.type === 'mbin';
|
16715 | relop = sibling.type === 'mrel';
|
16716 | operator = sibling.type === 'mop';
|
16717 | punct = sibling.type === 'mpunct' || sibling.type === 'minner';
|
16718 | array = sibling.type === 'array';
|
16719 | openfence = sibling.type === 'mopen';
|
16720 | closefence = sibling.type === 'mclose' || sibling.type === 'leftright';
|
16721 | space = sibling.type === 'space';
|
16722 | }
|
16723 | if (shortcut.after !== undefined) {
|
16724 |
|
16725 | if ((shortcut.after.includes('nothing') && nothing) ||
|
16726 | (shortcut.after.includes('letter') && letter) ||
|
16727 | (shortcut.after.includes('digit') && digit) ||
|
16728 | (shortcut.after.includes('function') && isFunction) ||
|
16729 | (shortcut.after.includes('frac') && frac) ||
|
16730 | (shortcut.after.includes('surd') && surd) ||
|
16731 | (shortcut.after.includes('binop') && binop) ||
|
16732 | (shortcut.after.includes('relop') && relop) ||
|
16733 | (shortcut.after.includes('operator') && operator) ||
|
16734 | (shortcut.after.includes('punct') && punct) ||
|
16735 | (shortcut.after.includes('array') && array) ||
|
16736 | (shortcut.after.includes('openfence') && openfence) ||
|
16737 | (shortcut.after.includes('closefence') && closefence) ||
|
16738 | (shortcut.after.includes('text') && text) ||
|
16739 | (shortcut.after.includes('space') && space)) {
|
16740 | return shortcut.value;
|
16741 | }
|
16742 | return '';
|
16743 | }
|
16744 | return shortcut.value;
|
16745 | }
|
16746 |
|
16747 |
|
16748 |
|
16749 |
|
16750 |
|
16751 |
|
16752 |
|
16753 |
|
16754 | function getInlineShortcut(context, s, shortcuts) {
|
16755 | if (!shortcuts)
|
16756 | return '';
|
16757 | return validateShortcut(context, shortcuts[s]);
|
16758 | }
|
16759 |
|
16760 |
|
16761 |
|
16762 |
|
16763 |
|
16764 | const INLINE_SHORTCUTS = {
|
16765 | '%': '\\%',
|
16766 |
|
16767 | "''": { mode: 'math', value: '^{\\doubleprime}' },
|
16768 |
|
16769 | 'alpha': '\\alpha',
|
16770 | 'delta': '\\delta',
|
16771 | 'Delta': '\\Delta',
|
16772 | 'pi': { mode: 'math', value: '\\pi' },
|
16773 | 'pi ': { mode: 'text', value: '\\pi ' },
|
16774 | 'Pi': { mode: 'math', value: '\\Pi' },
|
16775 | 'theta': '\\theta',
|
16776 | 'Theta': '\\Theta',
|
16777 |
|
16778 | 'ii': {
|
16779 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16780 | value: '\\imaginaryI',
|
16781 | },
|
16782 | 'jj': {
|
16783 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16784 | value: '\\imaginaryJ',
|
16785 | },
|
16786 | 'ee': {
|
16787 | mode: 'math',
|
16788 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16789 | value: '\\exponentialE',
|
16790 | },
|
16791 | 'nabla': { mode: 'math', value: '\\nabla' },
|
16792 | 'grad': { mode: 'math', value: '\\nabla' },
|
16793 | 'del': { mode: 'math', value: '\\partial' },
|
16794 | 'infty': { mode: 'math', value: '\\infty' },
|
16795 | '\u221E': '\\infty',
|
16796 |
|
16797 |
|
16798 | 'oo': {
|
16799 | mode: 'math',
|
16800 | after: 'nothing+digit+frac+surd+binop+relop+punct+array+openfence+closefence+space',
|
16801 | value: '\\infty',
|
16802 | },
|
16803 |
|
16804 | '∑': { mode: 'math', value: '\\sum' },
|
16805 | 'sum': { mode: 'math', value: '\\sum_{#?}^{#?}' },
|
16806 | 'int': { mode: 'math', value: '\\int_{#?}^{#?}' },
|
16807 | 'prod': { mode: 'math', value: '\\prod_{#?}^{#?}' },
|
16808 | 'sqrt': { mode: 'math', value: '\\sqrt{#?}' },
|
16809 |
|
16810 | '∆': { mode: 'math', value: '\\differentialD' },
|
16811 | '∂': { mode: 'math', value: '\\differentialD' },
|
16812 |
|
16813 | 'arcsin': { mode: 'math', value: '\\arcsin' },
|
16814 | 'arccos': { mode: 'math', value: '\\arccos' },
|
16815 | 'arctan': { mode: 'math', value: '\\arctan' },
|
16816 | 'sin': { mode: 'math', value: '\\sin' },
|
16817 | 'sinh': { mode: 'math', value: '\\sinh' },
|
16818 | 'cos': { mode: 'math', value: '\\cos' },
|
16819 | 'cosh': { mode: 'math', value: '\\cosh' },
|
16820 | 'tan': { mode: 'math', value: '\\tan' },
|
16821 | 'tanh': { mode: 'math', value: '\\tanh' },
|
16822 | 'sec': { mode: 'math', value: '\\sec' },
|
16823 | 'csc': { mode: 'math', value: '\\csc' },
|
16824 | 'cot': { mode: 'math', value: '\\cot' },
|
16825 | 'log': { mode: 'math', value: '\\log' },
|
16826 | 'ln': { mode: 'math', value: '\\ln' },
|
16827 | 'exp': { mode: 'math', value: '\\exp' },
|
16828 | 'lim': { mode: 'math', value: '\\lim_{#?}' },
|
16829 |
|
16830 |
|
16831 | 'dx': {
|
16832 | mode: 'math',
|
16833 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16834 | value: '\\differentialD x',
|
16835 | },
|
16836 | 'dy': {
|
16837 | mode: 'math',
|
16838 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16839 | value: '\\differentialD y',
|
16840 | },
|
16841 | 'dt': {
|
16842 | mode: 'math',
|
16843 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16844 | value: '\\differentialD t',
|
16845 | },
|
16846 |
|
16847 | 'AA': { mode: 'math', value: '\\forall' },
|
16848 | 'EE': { mode: 'math', value: '\\exists' },
|
16849 | '!EE': { mode: 'math', value: '\\nexists' },
|
16850 | '&&': { mode: 'math', value: '\\land' },
|
16851 |
|
16852 | 'xin': {
|
16853 | mode: 'math',
|
16854 | after: 'nothing+text+relop+punct+openfence+space',
|
16855 | value: 'x \\in',
|
16856 | },
|
16857 | 'in': {
|
16858 | mode: 'math',
|
16859 | after: 'nothing+letter+closefence',
|
16860 | value: '\\in',
|
16861 | },
|
16862 | '!in': { mode: 'math', value: '\\notin' },
|
16863 |
|
16864 | 'NN': '\\N',
|
16865 | 'ZZ': '\\Z',
|
16866 | 'QQ': '\\Q',
|
16867 | 'RR': '\\R',
|
16868 | 'CC': '\\C',
|
16869 | 'PP': '\\P',
|
16870 |
|
16871 | 'xx': { mode: 'math', value: '\\times' },
|
16872 | '+-': { mode: 'math', value: '\\pm' },
|
16873 |
|
16874 | '!=': { mode: 'math', value: '\\ne' },
|
16875 | '>=': { mode: 'math', value: '\\ge' },
|
16876 | '<=': { mode: 'math', value: '\\le' },
|
16877 | '<<': { mode: 'math', value: '\\ll' },
|
16878 | '>>': { mode: 'math', value: '\\gg' },
|
16879 | '~~': { mode: 'math', value: '\\approx' },
|
16880 |
|
16881 | '≈': { mode: 'math', value: '\\approx' },
|
16882 | '?=': { mode: 'math', value: '\\questeq' },
|
16883 | '÷': { mode: 'math', value: '\\div' },
|
16884 | '¬': { mode: 'math', value: '\\neg' },
|
16885 | ':=': { mode: 'math', value: '\\coloneq' },
|
16886 | '::': { mode: 'math', value: '\\Colon' },
|
16887 |
|
16888 | '(:': { mode: 'math', value: '\\langle' },
|
16889 | ':)': { mode: 'math', value: '\\rangle' },
|
16890 |
|
16891 | 'beta': '\\beta',
|
16892 | 'chi': '\\chi',
|
16893 | 'epsilon': '\\epsilon',
|
16894 | 'varepsilon': '\\varepsilon',
|
16895 | 'eta': {
|
16896 | mode: 'math',
|
16897 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16898 | value: '\\eta',
|
16899 | },
|
16900 | 'eta ': {
|
16901 | mode: 'text',
|
16902 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16903 | value: '\\eta ',
|
16904 | },
|
16905 | 'gamma': '\\gamma',
|
16906 | 'Gamma': '\\Gamma',
|
16907 | 'iota': '\\iota',
|
16908 | 'kappa': '\\kappa',
|
16909 | 'lambda': '\\lambda',
|
16910 | 'Lambda': '\\Lambda',
|
16911 | 'mu': {
|
16912 | mode: 'math',
|
16913 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16914 | value: '\\mu',
|
16915 | },
|
16916 | 'mu ': {
|
16917 | mode: 'text',
|
16918 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16919 | value: '\\mu ',
|
16920 | },
|
16921 | 'nu': {
|
16922 | mode: 'math',
|
16923 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16924 | value: '\\nu',
|
16925 | },
|
16926 | 'nu ': {
|
16927 | mode: 'text',
|
16928 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16929 | value: '\\nu ',
|
16930 | },
|
16931 | 'µ': '\\mu',
|
16932 | 'phi': {
|
16933 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16934 | value: '\\phi',
|
16935 | },
|
16936 | 'Phi': {
|
16937 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16938 | value: '\\Phi',
|
16939 | },
|
16940 | 'varphi': '\\varphi',
|
16941 | 'psi': {
|
16942 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16943 | value: '\\psi',
|
16944 | },
|
16945 | 'Psi': {
|
16946 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16947 | value: '\\Psi',
|
16948 | },
|
16949 | 'rho': {
|
16950 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16951 | value: '\\rho',
|
16952 | },
|
16953 | 'sigma': '\\sigma',
|
16954 | 'Sigma': '\\Sigma',
|
16955 | 'tau': {
|
16956 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16957 | value: '\\tau',
|
16958 | },
|
16959 | 'vartheta': '\\vartheta',
|
16960 | 'upsilon': '\\upsilon',
|
16961 | 'xi': {
|
16962 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16963 | value: '\\xi',
|
16964 | },
|
16965 | 'Xi': {
|
16966 | after: 'nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text',
|
16967 | value: '\\Xi',
|
16968 | },
|
16969 | 'zeta': '\\zeta',
|
16970 | 'omega': '\\omega',
|
16971 | 'Omega': '\\Omega',
|
16972 | 'Ω': '\\omega',
|
16973 |
|
16974 | 'forall': { mode: 'math', value: '\\forall' },
|
16975 | 'exists': {
|
16976 | mode: 'math',
|
16977 | value: '\\exists',
|
16978 | },
|
16979 | '!exists': {
|
16980 | mode: 'math',
|
16981 | value: '\\nexists',
|
16982 | },
|
16983 | ':.': {
|
16984 | mode: 'math',
|
16985 | value: '\\therefore',
|
16986 | },
|
16987 |
|
16988 |
|
16989 | 'liminf': '\\operatorname*{lim~inf}_{#?}',
|
16990 | 'limsup': '\\operatorname*{lim~sup}_{#?}',
|
16991 | 'argmin': '\\operatorname*{arg~min}_{#?}',
|
16992 | 'argmax': '\\operatorname*{arg~max}_{#?}',
|
16993 | 'det': '\\det',
|
16994 | 'mod': {
|
16995 | mode: 'math',
|
16996 | value: '\\mod',
|
16997 | },
|
16998 | 'max': {
|
16999 | mode: 'math',
|
17000 | value: '\\max',
|
17001 | },
|
17002 | 'min': {
|
17003 | mode: 'math',
|
17004 | value: '\\min',
|
17005 | },
|
17006 | 'erf': '\\operatorname{erf}',
|
17007 | 'erfc': '\\operatorname{erfc}',
|
17008 | 'bessel': {
|
17009 | mode: 'math',
|
17010 | value: '\\operatorname{bessel}',
|
17011 | },
|
17012 | 'mean': {
|
17013 | mode: 'math',
|
17014 | value: '\\operatorname{mean}',
|
17015 | },
|
17016 | 'median': {
|
17017 | mode: 'math',
|
17018 | value: '\\operatorname{median}',
|
17019 | },
|
17020 | 'fft': {
|
17021 | mode: 'math',
|
17022 | value: '\\operatorname{fft}',
|
17023 | },
|
17024 | 'lcm': {
|
17025 | mode: 'math',
|
17026 | value: '\\operatorname{lcm}',
|
17027 | },
|
17028 | 'gcd': {
|
17029 | mode: 'math',
|
17030 | value: '\\operatorname{gcd}',
|
17031 | },
|
17032 | 'randomReal': '\\operatorname{randomReal}',
|
17033 | 'randomInteger': '\\operatorname{randomInteger}',
|
17034 | 'Re': {
|
17035 | mode: 'math',
|
17036 | value: '\\operatorname{Re}',
|
17037 | },
|
17038 | 'Im': {
|
17039 | mode: 'math',
|
17040 | value: '\\operatorname{Im}',
|
17041 | },
|
17042 |
|
17043 | 'mm': {
|
17044 | mode: 'math',
|
17045 | after: 'nothing+digit+operator',
|
17046 | value: '\\operatorname{mm}',
|
17047 | },
|
17048 | 'cm': {
|
17049 | mode: 'math',
|
17050 | after: 'nothing+digit+operator',
|
17051 | value: '\\operatorname{cm}',
|
17052 | },
|
17053 | 'km': {
|
17054 | mode: 'math',
|
17055 | after: 'nothing+digit+operator',
|
17056 | value: '\\operatorname{km}',
|
17057 | },
|
17058 | 'kg': {
|
17059 | mode: 'math',
|
17060 | after: 'nothing+digit+operator',
|
17061 | value: '\\operatorname{kg}',
|
17062 | },
|
17063 |
|
17064 | '...': '\\ldots',
|
17065 | '+...': '+\\cdots',
|
17066 | '-...': '-\\cdots',
|
17067 | '->...': '\\to\\cdots',
|
17068 | '->': '\\to',
|
17069 | '|->': '\\mapsto',
|
17070 | '-->': '\\longrightarrow',
|
17071 |
|
17072 | '<--': '\\longleftarrow',
|
17073 | '=>': '\\Rightarrow',
|
17074 | '==>': '\\Longrightarrow',
|
17075 |
|
17076 | '<=>': '\\Leftrightarrow',
|
17077 | '<->': '\\leftrightarrow',
|
17078 | '(.)': '\\odot',
|
17079 | '(+)': '\\oplus',
|
17080 | '(/)': '\\oslash',
|
17081 | '(*)': '\\otimes',
|
17082 | '(-)': '\\ominus',
|
17083 |
|
17084 | '||': '\\Vert',
|
17085 | '{': '\\{',
|
17086 | '}': '\\}',
|
17087 | '*': '\\cdot',
|
17088 | |
17089 |
|
17090 |
|
17091 |
|
17092 |
|
17093 |
|
17094 |
|
17095 |
|
17096 |
|
17097 |
|
17098 |
|
17099 |
|
17100 |
|
17101 |
|
17102 |
|
17103 |
|
17104 |
|
17105 |
|
17106 |
|
17107 |
|
17108 |
|
17109 |
|
17110 |
|
17111 |
|
17112 |
|
17113 |
|
17114 |
|
17115 |
|
17116 |
|
17117 |
|
17118 |
|
17119 |
|
17120 |
|
17121 |
|
17122 |
|
17123 |
|
17124 |
|
17125 |
|
17126 |
|
17127 |
|
17128 |
|
17129 |
|
17130 |
|
17131 |
|
17132 |
|
17133 |
|
17134 |
|
17135 |
|
17136 |
|
17137 |
|
17138 |
|
17139 |
|
17140 |
|
17141 |
|
17142 |
|
17143 |
|
17144 |
|
17145 |
|
17146 |
|
17147 |
|
17148 |
|
17149 |
|
17150 |
|
17151 |
|
17152 |
|
17153 |
|
17154 |
|
17155 |
|
17156 |
|
17157 |
|
17158 |
|
17159 |
|
17160 |
|
17161 |
|
17162 |
|
17163 |
|
17164 |
|
17165 |
|
17166 |
|
17167 |
|
17168 | };
|
17169 |
|
17170 |
|
17171 |
|
17172 |
|
17173 |
|
17174 |
|
17175 |
|
17176 |
|
17177 |
|
17178 |
|
17179 |
|
17180 |
|
17181 |
|
17182 |
|
17183 |
|
17184 |
|
17185 |
|
17186 |
|
17187 |
|
17188 |
|
17189 |
|
17190 |
|
17191 |
|
17192 |
|
17193 |
|
17194 |
|
17195 |
|
17196 |
|
17197 |
|
17198 |
|
17199 |
|
17200 |
|
17201 |
|
17202 | function parseMathString(s, options) {
|
17203 | let format;
|
17204 | [format, s] = inferFormat(s);
|
17205 | if (format === 'latex')
|
17206 | return ['latex', s];
|
17207 |
|
17208 | format = 'ascii-math';
|
17209 | s = s.replace(/\u2061/gu, '');
|
17210 | s = s.replace(/\u3016/gu, '{');
|
17211 | s = s.replace(/\u3017/gu, '}');
|
17212 | s = s.replace(/([^\\])sinx/g, '$1\\sin x');
|
17213 | s = s.replace(/([^\\])cosx/g, '$1\\cos x ');
|
17214 | s = s.replace(/\u2013/g, '-');
|
17215 | return [
|
17216 | format,
|
17217 | parseMathExpression(s, { inlineShortcuts: options === null || options === void 0 ? void 0 : options.inlineShortcuts }),
|
17218 | ];
|
17219 | }
|
17220 | function parseMathExpression(s, options) {
|
17221 | var _a, _b, _c;
|
17222 | if (!s)
|
17223 | return '';
|
17224 | let done = false;
|
17225 | let m;
|
17226 | const inlineShortcuts = (_a = options.inlineShortcuts) !== null && _a !== void 0 ? _a : INLINE_SHORTCUTS;
|
17227 | if (!done && (s.startsWith('^') || s.startsWith('_'))) {
|
17228 |
|
17229 | m = parseMathArgument(s.slice(1), { inlineShortcuts, noWrap: true });
|
17230 | s = s[0] + '{' + m.match + '}';
|
17231 | s += parseMathExpression(m.rest, options);
|
17232 | done = true;
|
17233 | }
|
17234 | if (!done) {
|
17235 | m = s.match(/^(sqrt|\u221A)(.*)/);
|
17236 | if (m) {
|
17237 |
|
17238 | m = parseMathArgument(m[2], { inlineShortcuts, noWrap: true });
|
17239 | const sqrtArgument = (_b = m.match) !== null && _b !== void 0 ? _b : '\\placeholder{}';
|
17240 | s = '\\sqrt{' + sqrtArgument + '}';
|
17241 | s += parseMathExpression(m.rest, options);
|
17242 | done = true;
|
17243 | }
|
17244 | }
|
17245 | if (!done) {
|
17246 | m = s.match(/^(\\cbrt|\u221B)(.*)/);
|
17247 | if (m) {
|
17248 |
|
17249 | m = parseMathArgument(m[2], { inlineShortcuts, noWrap: true });
|
17250 | const sqrtArgument = (_c = m.match) !== null && _c !== void 0 ? _c : '\\placeholder{}';
|
17251 | s = '\\sqrt[3]{' + sqrtArgument + '}';
|
17252 | s += parseMathExpression(m.rest, options);
|
17253 | done = true;
|
17254 | }
|
17255 | }
|
17256 | if (!done) {
|
17257 | m = s.match(/^abs(.*)/);
|
17258 | if (m) {
|
17259 |
|
17260 | m = parseMathArgument(m[1], { inlineShortcuts, noWrap: true });
|
17261 | s = '\\left|' + m.match + '\\right|';
|
17262 | s += parseMathExpression(m.rest, options);
|
17263 | done = true;
|
17264 | }
|
17265 | }
|
17266 | if (!done) {
|
17267 | m = s.match(/^["”“](.*?)["”“](.*)/);
|
17268 | if (m) {
|
17269 |
|
17270 | s = '\\text{' + m[1] + '}';
|
17271 | s += parseMathExpression(m[2], options);
|
17272 | done = true;
|
17273 | }
|
17274 | }
|
17275 | if (!done) {
|
17276 | m = s.match(/^([^a-zA-Z({[_^\\\s"]+)(.*)/);
|
17277 |
|
17278 |
|
17279 | if (m) {
|
17280 | s = paddedShortcut(m[1], inlineShortcuts);
|
17281 | s += parseMathExpression(m[2], options);
|
17282 | done = true;
|
17283 | }
|
17284 | }
|
17285 | if (!done && /^([fgh])[^a-zA-Z]/.test(s)) {
|
17286 |
|
17287 | m = parseMathArgument(s.slice(1), { inlineShortcuts, noWrap: true });
|
17288 | s =
|
17289 | s[1] === '(' ? s[0] + '\\mleft(' + m.match + '\\mright)' : s[0] + m.match;
|
17290 | s += parseMathExpression(m.rest, options);
|
17291 | done = true;
|
17292 | }
|
17293 | if (!done) {
|
17294 | m = s.match(/^([a-zA-Z]+)(.*)/);
|
17295 | if (m) {
|
17296 |
|
17297 |
|
17298 | s = paddedShortcut(m[1], inlineShortcuts);
|
17299 | s += parseMathExpression(m[2], options);
|
17300 | done = true;
|
17301 | }
|
17302 | }
|
17303 | if (!done) {
|
17304 | m = parseMathArgument(s, { inlineShortcuts, noWrap: true });
|
17305 | if (m.match && m.rest[0] === '/') {
|
17306 |
|
17307 | const m2 = parseMathArgument(m.rest.slice(1), {
|
17308 | inlineShortcuts,
|
17309 | noWrap: true,
|
17310 | });
|
17311 | if (m2.match) {
|
17312 | s =
|
17313 | '\\frac{' +
|
17314 | m.match +
|
17315 | '}{' +
|
17316 | m2.match +
|
17317 | '}' +
|
17318 | parseMathExpression(m2.rest, options);
|
17319 | }
|
17320 | done = true;
|
17321 | }
|
17322 | else if (m.match) {
|
17323 | s = s.startsWith('(')
|
17324 | ? '\\left(' +
|
17325 | m.match +
|
17326 | '\\right)' +
|
17327 | parseMathExpression(m.rest, options)
|
17328 | : m.match + parseMathExpression(m.rest, options);
|
17329 | done = true;
|
17330 | }
|
17331 | }
|
17332 | if (!done) {
|
17333 | m = s.match(/^(\s+)(.*)$/);
|
17334 |
|
17335 | if (m) {
|
17336 | s = ' ' + parseMathExpression(m[2], options);
|
17337 | done = true;
|
17338 | }
|
17339 | }
|
17340 | return s;
|
17341 | }
|
17342 |
|
17343 |
|
17344 |
|
17345 |
|
17346 |
|
17347 |
|
17348 |
|
17349 |
|
17350 |
|
17351 |
|
17352 |
|
17353 | function parseMathArgument(s, options) {
|
17354 | let match = '';
|
17355 | s = s.trim();
|
17356 | let rest = s;
|
17357 | let lFence = s.charAt(0);
|
17358 | let rFence = { '(': ')', '{': '}', '[': ']' }[lFence];
|
17359 | if (rFence) {
|
17360 |
|
17361 | let level = 1;
|
17362 | let i = 1;
|
17363 | while (i < s.length && level > 0) {
|
17364 | if (s[i] === lFence)
|
17365 | level++;
|
17366 | if (s[i] === rFence)
|
17367 | level--;
|
17368 | i++;
|
17369 | }
|
17370 | if (level === 0) {
|
17371 |
|
17372 | if (options.noWrap && lFence === '(') {
|
17373 | match = parseMathExpression(s.substring(1, i - 1), options);
|
17374 | }
|
17375 | else {
|
17376 | if (lFence === '{' && rFence === '}') {
|
17377 | lFence = '\\{';
|
17378 | rFence = '\\}';
|
17379 | }
|
17380 | match =
|
17381 | '\\left' +
|
17382 | lFence +
|
17383 | parseMathExpression(s.substring(1, i - 1), options) +
|
17384 | '\\right' +
|
17385 | rFence;
|
17386 | }
|
17387 | rest = s.slice(Math.max(0, i));
|
17388 | }
|
17389 | else {
|
17390 |
|
17391 | match = s.substring(1, i);
|
17392 | rest = '';
|
17393 | }
|
17394 | }
|
17395 | else {
|
17396 | let m = s.match(/^([a-zA-Z]+)/);
|
17397 | if (m) {
|
17398 |
|
17399 | let shortcut = getInlineShortcut(null, s, options.inlineShortcuts);
|
17400 | if (shortcut) {
|
17401 | shortcut = shortcut.replace('_{#?}', '');
|
17402 | shortcut = shortcut.replace('^{#?}', '');
|
17403 | return { match: shortcut, rest: s.slice(shortcut.length) };
|
17404 | }
|
17405 | }
|
17406 | m = s.match(/^([a-zA-Z])/);
|
17407 | if (m) {
|
17408 |
|
17409 | return { match: m[1], rest: s.slice(1) };
|
17410 | }
|
17411 | m = s.match(/^(-)?\d+(\.\d*)?/);
|
17412 | if (m) {
|
17413 |
|
17414 | return { match: m[0], rest: s.slice(m[0].length) };
|
17415 | }
|
17416 | if (!/^\\(left|right)/.test(s)) {
|
17417 |
|
17418 | m = s.match(/^(\\[a-zA-Z]+)/);
|
17419 | if (m) {
|
17420 | rest = s.slice(m[1].length);
|
17421 | match = m[1];
|
17422 | }
|
17423 | }
|
17424 | }
|
17425 | return { match, rest };
|
17426 | }
|
17427 | function paddedShortcut(s, shortcuts) {
|
17428 | let result = getInlineShortcut(null, s, shortcuts);
|
17429 | if (result) {
|
17430 | result = result.replace('_{#?}', '');
|
17431 | result = result.replace('^{#?}', '');
|
17432 | result += ' ';
|
17433 | }
|
17434 | else {
|
17435 | result = s;
|
17436 | }
|
17437 | return result;
|
17438 | }
|
17439 | const MODE_SHIFT_COMMANDS = [
|
17440 | ['\\[', '\\]'],
|
17441 | ['\\(', '\\)'],
|
17442 | ['$$', '$$'],
|
17443 | ['$', '$'],
|
17444 | ['\\begin{math}', '\\end{math}'],
|
17445 | ['\\begin{displaymath}', '\\end{displaymath}'],
|
17446 | ['\\begin{equation}', '\\end{equation}'],
|
17447 | ['\\begin{equation*}', '\\end{equation*}'],
|
17448 | ];
|
17449 | function trimModeShiftCommand(s) {
|
17450 | const trimedString = s.trim();
|
17451 | for (const mode of MODE_SHIFT_COMMANDS) {
|
17452 | if (trimedString.startsWith(mode[0]) && trimedString.endsWith(mode[1])) {
|
17453 | return [
|
17454 | true,
|
17455 | trimedString.substring(mode[0].length, trimedString.length - mode[1].length),
|
17456 | ];
|
17457 | }
|
17458 | }
|
17459 | return [false, s];
|
17460 | }
|
17461 | function inferFormat(s) {
|
17462 | s = s.trim();
|
17463 | if (!s)
|
17464 | return ['latex', ''];
|
17465 |
|
17466 | if (s.length <= 1)
|
17467 | return ['latex', s];
|
17468 |
|
17469 | s = s.replace(/\\\\([^\s\n])/g, '\\$1');
|
17470 |
|
17471 | let hasLatexModeShiftCommand;
|
17472 | [hasLatexModeShiftCommand, s] = trimModeShiftCommand(s);
|
17473 | if (hasLatexModeShiftCommand)
|
17474 | return ['latex', s];
|
17475 |
|
17476 |
|
17477 | if (s.startsWith('`') && s.endsWith('`')) {
|
17478 | s = s.substring(1, s.length - 1);
|
17479 | return ['ascii-math', s];
|
17480 | }
|
17481 | if (s.includes('\\')) {
|
17482 |
|
17483 |
|
17484 |
|
17485 |
|
17486 |
|
17487 | return ['latex', s];
|
17488 | }
|
17489 | if (/\$(.+)\$/.test(s)) {
|
17490 |
|
17491 |
|
17492 |
|
17493 | return ['latex', `\\text{${s}}`];
|
17494 | }
|
17495 | return [undefined, s];
|
17496 | }
|
17497 |
|
17498 | function hashCode(s) {
|
17499 | let hash = 0;
|
17500 | if (s.length === 0) {
|
17501 | return hash;
|
17502 | }
|
17503 | for (let i = 0; i < s.length; i++) {
|
17504 | const char = s.charCodeAt(i);
|
17505 | hash = (hash << 5) - hash + char;
|
17506 | hash &= hash;
|
17507 | }
|
17508 | return Math.abs(hash);
|
17509 | }
|
17510 |
|
17511 |
|
17512 | function findEndOfMath(delimiter, text, startIndex) {
|
17513 |
|
17514 |
|
17515 | let index = startIndex;
|
17516 | let braceLevel = 0;
|
17517 | const delimLength = delimiter.length;
|
17518 | while (index < text.length) {
|
17519 | const character = text[index];
|
17520 | if (braceLevel <= 0 &&
|
17521 | text.slice(index, index + delimLength) === delimiter) {
|
17522 | return index;
|
17523 | }
|
17524 | if (character === '\\') {
|
17525 | index++;
|
17526 | }
|
17527 | else if (character === '{') {
|
17528 | braceLevel++;
|
17529 | }
|
17530 | else if (character === '}') {
|
17531 | braceLevel--;
|
17532 | }
|
17533 | index++;
|
17534 | }
|
17535 | return -1;
|
17536 | }
|
17537 | function splitAtDelimiters(startData, leftDelim, rightDelim, mathstyle, format = 'latex') {
|
17538 | const finalData = [];
|
17539 | for (const startDatum of startData) {
|
17540 | if (startDatum.type === 'text') {
|
17541 | const text = startDatum.data;
|
17542 | let lookingForLeft = true;
|
17543 | let currIndex = 0;
|
17544 | let nextIndex;
|
17545 | nextIndex = text.indexOf(leftDelim);
|
17546 | if (nextIndex !== -1) {
|
17547 | currIndex = nextIndex;
|
17548 | if (currIndex > 0) {
|
17549 | finalData.push({
|
17550 | type: 'text',
|
17551 | data: text.slice(0, currIndex),
|
17552 | });
|
17553 | }
|
17554 | lookingForLeft = false;
|
17555 | }
|
17556 | let done = false;
|
17557 | while (!done) {
|
17558 | if (lookingForLeft) {
|
17559 | nextIndex = text.indexOf(leftDelim, currIndex);
|
17560 | if (nextIndex === -1) {
|
17561 | done = true;
|
17562 | break;
|
17563 | }
|
17564 | if (currIndex !== nextIndex) {
|
17565 | finalData.push({
|
17566 | type: 'text',
|
17567 | data: text.slice(currIndex, nextIndex),
|
17568 | });
|
17569 | }
|
17570 | currIndex = nextIndex;
|
17571 | }
|
17572 | else {
|
17573 | nextIndex = findEndOfMath(rightDelim, text, currIndex + leftDelim.length);
|
17574 | if (nextIndex === -1) {
|
17575 | done = true;
|
17576 | break;
|
17577 | }
|
17578 | let formula = text.slice(currIndex + leftDelim.length, nextIndex);
|
17579 | if (format === 'ascii-math') {
|
17580 | [, formula] = parseMathString(formula, { format: 'ascii-math' });
|
17581 | }
|
17582 | finalData.push({
|
17583 | type: 'math',
|
17584 | data: formula,
|
17585 | rawData: text.slice(currIndex, nextIndex + rightDelim.length),
|
17586 | mathstyle,
|
17587 | });
|
17588 | currIndex = nextIndex + rightDelim.length;
|
17589 | }
|
17590 | lookingForLeft = !lookingForLeft;
|
17591 | }
|
17592 | if (currIndex < text.length) {
|
17593 | finalData.push({
|
17594 | type: 'text',
|
17595 | data: text.slice(currIndex),
|
17596 | });
|
17597 | }
|
17598 | }
|
17599 | else {
|
17600 | finalData.push(startDatum);
|
17601 | }
|
17602 | }
|
17603 | return finalData;
|
17604 | }
|
17605 | function splitWithDelimiters(text, texDelimiters, mathAsciiDelimiters) {
|
17606 | let data = [{ type: 'text', data: text }];
|
17607 | if (texDelimiters === null || texDelimiters === void 0 ? void 0 : texDelimiters.inline) {
|
17608 | texDelimiters.inline.forEach(([openDelim, closeDelim]) => {
|
17609 | data = splitAtDelimiters(data, openDelim, closeDelim, 'textstyle');
|
17610 | });
|
17611 | }
|
17612 | if (texDelimiters === null || texDelimiters === void 0 ? void 0 : texDelimiters.display) {
|
17613 | texDelimiters.display.forEach(([openDelim, closeDelim]) => {
|
17614 | data = splitAtDelimiters(data, openDelim, closeDelim, 'displaystyle');
|
17615 | });
|
17616 | }
|
17617 | if (mathAsciiDelimiters === null || mathAsciiDelimiters === void 0 ? void 0 : mathAsciiDelimiters.inline) {
|
17618 | mathAsciiDelimiters.inline.forEach(([openDelim, closeDelim]) => {
|
17619 | data = splitAtDelimiters(data, openDelim, closeDelim, 'textstyle', 'ascii-math');
|
17620 | });
|
17621 | }
|
17622 | if (mathAsciiDelimiters === null || mathAsciiDelimiters === void 0 ? void 0 : mathAsciiDelimiters.display) {
|
17623 | mathAsciiDelimiters.display.forEach(([openDelim, closeDelim]) => {
|
17624 | data = splitAtDelimiters(data, openDelim, closeDelim, 'displaystyle', 'ascii-math');
|
17625 | });
|
17626 | }
|
17627 | return data;
|
17628 | }
|
17629 | function createMathMLNode(latex, options) {
|
17630 | throwIfNotInBrowser();
|
17631 |
|
17632 |
|
17633 | const span = document.createElement('span');
|
17634 | try {
|
17635 | const html = "<math xmlns='http://www.w3.org/1998/Math/MathML'>" +
|
17636 | options.renderToMathML(latex, options) +
|
17637 | '</math>';
|
17638 | span.innerHTML = options.createHTML ? options.createHTML(html) : html;
|
17639 | }
|
17640 | catch (error) {
|
17641 | console.error("Could not convert '" + latex + "' to MathML with ", error);
|
17642 | span.textContent = latex;
|
17643 | }
|
17644 | span.className = 'ML__sr-only';
|
17645 | return span;
|
17646 | }
|
17647 | function createMarkupNode(text, options, mathstyle, createNodeOnFailure) {
|
17648 | throwIfNotInBrowser();
|
17649 |
|
17650 |
|
17651 |
|
17652 |
|
17653 |
|
17654 | const element = document.createElement(mathstyle === 'displaystyle' ? 'div' : 'span');
|
17655 | element.setAttribute('aria-hidden', 'true');
|
17656 | try {
|
17657 | const html = options.renderToMarkup(text, {
|
17658 | mathstyle: mathstyle !== null && mathstyle !== void 0 ? mathstyle : 'displaystyle',
|
17659 | format: 'html',
|
17660 | macros: options.macros,
|
17661 | });
|
17662 | element.innerHTML = options.createHTML ? options.createHTML(html) : html;
|
17663 | }
|
17664 | catch (error) {
|
17665 | console.error("Could not parse'" + text + "' with ", error);
|
17666 | if (createNodeOnFailure) {
|
17667 | return document.createTextNode(text);
|
17668 | }
|
17669 | return null;
|
17670 | }
|
17671 | return element;
|
17672 | }
|
17673 | function createAccessibleMarkupPair(latex, mathstyle, options, createNodeOnFailure) {
|
17674 | var _a;
|
17675 |
|
17676 |
|
17677 |
|
17678 | const markupNode = createMarkupNode(latex, options, mathstyle, createNodeOnFailure);
|
17679 | const accessibleContent = (_a = options.renderAccessibleContent) !== null && _a !== void 0 ? _a : '';
|
17680 | if (markupNode && /\b(mathml|speakable-text)\b/i.test(accessibleContent)) {
|
17681 | throwIfNotInBrowser();
|
17682 | const fragment = document.createElement('span');
|
17683 | if (/\bmathml\b/i.test(accessibleContent) && options.renderToMathML) {
|
17684 | fragment.append(createMathMLNode(latex, options));
|
17685 | }
|
17686 | if (/\bspeakable-text\b/i.test(accessibleContent) &&
|
17687 | options.renderToSpeakableText) {
|
17688 | const span = document.createElement('span');
|
17689 | const html = options.renderToSpeakableText(latex, options);
|
17690 | span.innerHTML = options.createHTML ? options.createHTML(html) : html;
|
17691 | span.className = 'ML__sr-only';
|
17692 | fragment.append(span);
|
17693 | }
|
17694 | fragment.append(markupNode);
|
17695 | return fragment;
|
17696 | }
|
17697 | return markupNode;
|
17698 | }
|
17699 | function scanText$1(text, options) {
|
17700 | var _a, _b, _c, _d;
|
17701 | throwIfNotInBrowser();
|
17702 |
|
17703 | let fragment = null;
|
17704 | if (((_a = options.TeX) === null || _a === void 0 ? void 0 : _a.processEnvironments) && /^\s*\\begin/.test(text)) {
|
17705 | fragment = document.createDocumentFragment();
|
17706 | const node = createAccessibleMarkupPair(text, '', options, true);
|
17707 | if (node)
|
17708 | fragment.appendChild(node);
|
17709 | }
|
17710 | else {
|
17711 | if (!text.trim())
|
17712 | return null;
|
17713 | const data = splitWithDelimiters(text, (_b = options.TeX) === null || _b === void 0 ? void 0 : _b.delimiters, (_c = options.asciiMath) === null || _c === void 0 ? void 0 : _c.delimiters);
|
17714 | if (data.length === 1 && data[0].type === 'text') {
|
17715 |
|
17716 | return null;
|
17717 | }
|
17718 | fragment = document.createDocumentFragment();
|
17719 | for (const datum of data) {
|
17720 | if (datum.type === 'text') {
|
17721 | fragment.appendChild(document.createTextNode(datum.data));
|
17722 | }
|
17723 | else {
|
17724 | const node = createAccessibleMarkupPair(datum.data, (_d = datum.mathstyle) !== null && _d !== void 0 ? _d : '', options, true);
|
17725 | if (node)
|
17726 | fragment.appendChild(node);
|
17727 | }
|
17728 | }
|
17729 | }
|
17730 | return fragment;
|
17731 | }
|
17732 | function scanElement(element, options) {
|
17733 | var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
17734 | const originalContent = element.getAttribute('data-' + options.namespace + 'original-content');
|
17735 | if (originalContent) {
|
17736 | const mathstyle = element.getAttribute('data-' + options.namespace + 'mathstyle');
|
17737 | const span = createAccessibleMarkupPair(originalContent, mathstyle, options, false);
|
17738 | if (span !== null) {
|
17739 | element.textContent = '';
|
17740 | element.append(span);
|
17741 | }
|
17742 | return;
|
17743 | }
|
17744 | if (element.childNodes.length === 1 && element.childNodes[0].nodeType === 3) {
|
17745 |
|
17746 |
|
17747 | const text = element.childNodes[0].textContent;
|
17748 | if (((_a = options.TeX) === null || _a === void 0 ? void 0 : _a.processEnvironments) && /^\s*\\begin/.test(text)) {
|
17749 | element.textContent = '';
|
17750 | element.append(createAccessibleMarkupPair(text, '', options, true));
|
17751 | return;
|
17752 | }
|
17753 | const data = splitWithDelimiters(text, (_b = options.TeX) === null || _b === void 0 ? void 0 : _b.delimiters, (_c = options.asciiMath) === null || _c === void 0 ? void 0 : _c.delimiters);
|
17754 | if (data.length === 1 && data[0].type === 'math') {
|
17755 |
|
17756 |
|
17757 | element.textContent = '';
|
17758 | element.append(createAccessibleMarkupPair(data[0].data, (_d = data[0].mathstyle) !== null && _d !== void 0 ? _d : '', options, true));
|
17759 | return;
|
17760 | }
|
17761 | if (data.length === 1 && data[0].type === 'text') {
|
17762 |
|
17763 |
|
17764 | return;
|
17765 | }
|
17766 | }
|
17767 |
|
17768 |
|
17769 |
|
17770 | for (let i = element.childNodes.length - 1; i >= 0; i--) {
|
17771 | const childNode = element.childNodes[i];
|
17772 | if (childNode.nodeType === 3) {
|
17773 |
|
17774 |
|
17775 | const frag = scanText$1(childNode.textContent, options);
|
17776 | if (frag) {
|
17777 | i += frag.childNodes.length - 1;
|
17778 | childNode.replaceWith(frag);
|
17779 | }
|
17780 | }
|
17781 | else if (childNode.nodeType === 1) {
|
17782 |
|
17783 | const tag = childNode.nodeName.toLowerCase();
|
17784 | if (tag === 'script' &&
|
17785 | ((_e = options.processScriptTypePattern) === null || _e === void 0 ? void 0 : _e.test(childNode.type))) {
|
17786 | let style = 'displaystyle';
|
17787 | for (const l of childNode.type.split(';')) {
|
17788 | const v = l.split('=');
|
17789 | if (v[0].toLowerCase() === 'mode') {
|
17790 | style =
|
17791 | v[1].toLoweCase() === 'display' ? 'displaystyle' : 'textstyle';
|
17792 | }
|
17793 | }
|
17794 | const span = createAccessibleMarkupPair(childNode.textContent, style, options, true);
|
17795 | childNode.parentNode.replaceChild(span, childNode);
|
17796 | }
|
17797 | else if (tag !== 'script') {
|
17798 |
|
17799 |
|
17800 | const shouldRender = ((_g = (_f = options.processClassPattern) === null || _f === void 0 ? void 0 : _f.test(childNode.className)) !== null && _g !== void 0 ? _g : false) ||
|
17801 | !(((_j = (_h = options.skipTags) === null || _h === void 0 ? void 0 : _h.includes(tag)) !== null && _j !== void 0 ? _j : false) ||
|
17802 | ((_l = (_k = options.ignoreClassPattern) === null || _k === void 0 ? void 0 : _k.test(childNode.className)) !== null && _l !== void 0 ? _l : false));
|
17803 | if (shouldRender) {
|
17804 | if (element.childNodes.length === 1 &&
|
17805 | element.childNodes[0].nodeType === 3) {
|
17806 | const formula = element.textContent;
|
17807 | element.textContent = '';
|
17808 | element.append(createAccessibleMarkupPair(formula, 'displaystyle', options, true));
|
17809 | }
|
17810 | else {
|
17811 | scanElement(childNode, options);
|
17812 | }
|
17813 | }
|
17814 | }
|
17815 | }
|
17816 |
|
17817 | }
|
17818 | }
|
17819 | const DEFAULT_AUTO_RENDER_OPTIONS = {
|
17820 |
|
17821 | namespace: '',
|
17822 |
|
17823 | skipTags: [
|
17824 | 'math-field',
|
17825 | 'noscript',
|
17826 | 'style',
|
17827 | 'textarea',
|
17828 | 'pre',
|
17829 | 'code',
|
17830 | 'annotation',
|
17831 | 'annotation-xml',
|
17832 | ],
|
17833 |
|
17834 | processScriptType: 'math/tex',
|
17835 |
|
17836 |
|
17837 | ignoreClass: 'tex2jax_ignore',
|
17838 |
|
17839 |
|
17840 | processClass: 'tex2jax_process',
|
17841 |
|
17842 | renderAccessibleContent: 'mathml',
|
17843 | asciiMath: {
|
17844 | delimiters: {
|
17845 | display: [
|
17846 | ['`', '`'],
|
17847 | ],
|
17848 | },
|
17849 | },
|
17850 | TeX: {
|
17851 | processEnvironments: true,
|
17852 | delimiters: {
|
17853 | inline: [['\\(', '\\)']],
|
17854 | display: [
|
17855 | ['$$', '$$'],
|
17856 | ['\\[', '\\]'],
|
17857 | ],
|
17858 | },
|
17859 | },
|
17860 | };
|
17861 | function autoRenderMathInElement(element, options) {
|
17862 | var _a, _b, _c;
|
17863 | try {
|
17864 | options = { ...DEFAULT_AUTO_RENDER_OPTIONS, ...options };
|
17865 | options.ignoreClassPattern = new RegExp((_a = options.ignoreClass) !== null && _a !== void 0 ? _a : '');
|
17866 | options.processClassPattern = new RegExp((_b = options.processClass) !== null && _b !== void 0 ? _b : '');
|
17867 | options.processScriptTypePattern = new RegExp((_c = options.processScriptType) !== null && _c !== void 0 ? _c : '');
|
17868 | options.macros = getMacros(options.macros);
|
17869 |
|
17870 | if (options.namespace) {
|
17871 | if (!/^[a-z]+-?$/.test(options.namespace)) {
|
17872 | throw new Error('options.namespace must be a string of lowercase characters only');
|
17873 | }
|
17874 | if (!options.namespace.endsWith('-')) {
|
17875 | options.namespace += '-';
|
17876 | }
|
17877 | }
|
17878 |
|
17879 |
|
17880 |
|
17881 | void loadFonts(options.fontsDirectory);
|
17882 | inject(null, css_248z$4, hashCode(css_248z$4).toString(36));
|
17883 | scanElement(element, options);
|
17884 | }
|
17885 | catch (error) {
|
17886 | if (error instanceof Error) {
|
17887 | console.error('renderMathInElement(): ' + error.message);
|
17888 | }
|
17889 | else {
|
17890 | console.error('renderMathInElement(): Could not render math for element', element);
|
17891 | }
|
17892 | }
|
17893 | }
|
17894 |
|
17895 | const DEFAULT_KEYBINDINGS = [
|
17896 | { key: 'left', command: 'moveToPreviousChar' },
|
17897 | { key: 'right', command: 'moveToNextChar' },
|
17898 | { key: 'up', command: 'moveUp' },
|
17899 | { key: 'down', command: 'moveDown' },
|
17900 | { key: 'shift+[ArrowLeft]', command: 'extendSelectionBackward' },
|
17901 | { key: 'shift+[ArrowRight]', command: 'extendSelectionForward' },
|
17902 | { key: 'shift+[ArrowUp]', command: 'extendSelectionUpward' },
|
17903 | { key: 'shift+[ArrowDown]', command: 'extendSelectionDownward' },
|
17904 | { key: '[Backspace]', command: 'deleteBackward' },
|
17905 | { key: 'alt+[Delete]', command: 'deleteBackward' },
|
17906 | { key: '[Delete]', command: 'deleteForward' },
|
17907 | { key: 'alt+[Backspace]', command: 'deleteForward' },
|
17908 | { key: 'alt+[ArrowLeft]', command: 'moveToPreviousWord' },
|
17909 | { key: 'alt+[ArrowRight]', command: 'moveToNextWord' },
|
17910 | { key: 'shift+alt+[ArrowLeft]', command: 'extendToPreviousWord' },
|
17911 | { key: 'shift+alt+[ArrowRight]', command: 'extendToNextWord' },
|
17912 | { key: 'ctrl+[ArrowLeft]', command: 'moveToGroupStart' },
|
17913 | { key: 'ctrl+[ArrowRight]', command: 'moveToGroupEnd' },
|
17914 | { key: 'shift+ctrl+[ArrowLeft]', command: 'extendToGroupStart' },
|
17915 | { key: 'shift+ctrl+[ArrowRight]', command: 'extendToGroupEnd' },
|
17916 | { key: '[Space]', ifMode: 'math', command: 'moveAfterParent' },
|
17917 | { key: 'shift+[Space]', ifMode: 'math', command: 'moveBeforeParent' },
|
17918 | { key: '[Home]', command: 'moveToMathFieldStart' },
|
17919 | { key: 'cmd+[ArrowLeft]', command: 'moveToMathFieldStart' },
|
17920 | { key: 'shift+[Home]', command: 'extendToMathFieldStart' },
|
17921 | { key: 'shift+cmd+[ArrowLeft]', command: 'extendToMathFieldStart' },
|
17922 | { key: '[End]', command: 'moveToMathFieldEnd' },
|
17923 | { key: 'cmd+[ArrowRight]', command: 'moveToMathFieldEnd' },
|
17924 | { key: 'shift+[End]', command: 'extendToMathFieldEnd' },
|
17925 | { key: 'shift+cmd+[ArrowRight]', command: 'extendToMathFieldEnd' },
|
17926 | { key: '[Pageup]', command: 'moveToGroupStart' },
|
17927 | { key: '[Pagedown]', command: 'moveToGroupEnd' },
|
17928 | { key: '[Tab]', ifMode: 'math', command: 'moveToNextPlaceholder' },
|
17929 | {
|
17930 | key: 'shift+[Tab]',
|
17931 | ifMode: 'math',
|
17932 | command: 'moveToPreviousPlaceholder',
|
17933 | },
|
17934 | { key: '[Tab]', ifMode: 'text', command: 'moveToNextPlaceholder' },
|
17935 | {
|
17936 | key: 'shift+[Tab]',
|
17937 | ifMode: 'text',
|
17938 | command: 'moveToPreviousPlaceholder',
|
17939 | },
|
17940 | { key: '[Escape]', ifMode: 'math', command: ['switchMode', 'latex'] },
|
17941 | { key: '[Escape]', ifMode: 'text', command: ['switchMode', 'latex'] },
|
17942 | {
|
17943 | key: '\\',
|
17944 | ifMode: 'math',
|
17945 | command: ['switchMode', 'latex', '\\'],
|
17946 | },
|
17947 |
|
17948 | {
|
17949 | key: '[IntlBackslash]',
|
17950 | ifMode: 'math',
|
17951 | command: ['switchMode', 'latex', '\\'],
|
17952 | },
|
17953 | {
|
17954 | key: '[Escape]',
|
17955 | ifMode: 'latex',
|
17956 | command: ['complete', 'complete', { selectItem: 'true' }],
|
17957 | },
|
17958 | {
|
17959 | key: '[Tab]',
|
17960 | ifMode: 'latex',
|
17961 | command: ['complete', 'accept-suggestion'],
|
17962 | },
|
17963 | { key: '[Return]', ifMode: 'latex', command: 'complete' },
|
17964 | { key: '[Enter]', ifMode: 'latex', command: 'complete' },
|
17965 | {
|
17966 | key: 'shift+[Escape]',
|
17967 | ifMode: 'latex',
|
17968 | command: ['complete', 'reject'],
|
17969 | },
|
17970 |
|
17971 | { key: '[ArrowDown]', ifMode: 'latex', command: 'nextSuggestion' },
|
17972 |
|
17973 | { key: '[ArrowUp]', ifMode: 'latex', command: 'previousSuggestion' },
|
17974 | { key: 'ctrl+a', ifPlatform: '!macos', command: 'selectAll' },
|
17975 | { key: 'cmd+a', command: 'selectAll' },
|
17976 |
|
17977 | { key: '[Cut]', command: 'cutToClipboard' },
|
17978 | { key: '[Copy]', command: 'copyToClipboard' },
|
17979 | { key: '[Paste]', command: 'pasteFromClipboard' },
|
17980 | { key: '[Clear]', command: 'deleteBackward' },
|
17981 | { key: 'ctrl+z', ifPlatform: '!macos', command: 'undo' },
|
17982 | { key: 'cmd+z', command: 'undo' },
|
17983 | { key: '[Undo]', command: 'undo' },
|
17984 | { key: 'ctrl+y', ifPlatform: '!macos', command: 'redo' },
|
17985 | { key: 'shift+cmd+y', command: 'redo' },
|
17986 | { key: 'shift+ctrl+z', ifPlatform: '!macos', command: 'redo' },
|
17987 | { key: 'shift+cmd+z', command: 'redo' },
|
17988 | { key: '[Redo]', command: 'redo' },
|
17989 | { key: '[EraseEof]', command: 'deleteToGroupEnd' },
|
17990 |
|
17991 | { key: 'ctrl+b', ifPlatform: 'macos', command: 'moveToPreviousChar' },
|
17992 | { key: 'ctrl+f', ifPlatform: 'macos', command: 'moveToNextChar' },
|
17993 | { key: 'ctrl+p', ifPlatform: 'macos', command: 'moveUp' },
|
17994 | { key: 'ctrl+n', ifPlatform: 'macos', command: 'moveDown' },
|
17995 | { key: 'ctrl+a', ifPlatform: 'macos', command: 'moveToMathFieldStart' },
|
17996 | { key: 'ctrl+e', ifPlatform: 'macos', command: 'moveToMathFieldEnd' },
|
17997 | {
|
17998 | key: 'shift+ctrl+b',
|
17999 | ifPlatform: 'macos',
|
18000 | command: 'extendSelectionBackward',
|
18001 | },
|
18002 | {
|
18003 | key: 'shift+ctrl+f',
|
18004 | ifPlatform: 'macos',
|
18005 | command: 'extendSelectionForward',
|
18006 | },
|
18007 | {
|
18008 | key: 'shift+ctrl+p',
|
18009 | ifPlatform: 'macos',
|
18010 | command: 'extendSelectionUpward',
|
18011 | },
|
18012 | {
|
18013 | key: 'shift+ctrl+n',
|
18014 | ifPlatform: 'macos',
|
18015 | command: 'extendSelectionDownward',
|
18016 | },
|
18017 | {
|
18018 | key: 'shift+ctrl+a',
|
18019 | ifPlatform: 'macos',
|
18020 | command: 'extendToMathFieldStart',
|
18021 | },
|
18022 | {
|
18023 | key: 'shift+ctrl+e',
|
18024 | ifPlatform: 'macos',
|
18025 | command: 'extendToMathFieldEnd',
|
18026 | },
|
18027 | { key: 'alt+ctrl+b', ifPlatform: 'macos', command: 'moveToPreviousWord' },
|
18028 | { key: 'alt+ctrl+f', ifPlatform: 'macos', command: 'moveToNextWord' },
|
18029 | {
|
18030 | key: 'shift+alt+ctrl+b',
|
18031 | ifPlatform: 'macos',
|
18032 | command: 'extendToPreviousWord',
|
18033 | },
|
18034 | {
|
18035 | key: 'shift+alt+ctrl+f',
|
18036 | ifPlatform: 'macos',
|
18037 | command: 'extendToNextWord',
|
18038 | },
|
18039 | { key: 'ctrl+h', ifPlatform: 'macos', command: 'deleteBackward' },
|
18040 | { key: 'ctrl+d', ifPlatform: 'macos', command: 'deleteForward' },
|
18041 | { key: 'ctrl+l', ifPlatform: 'macos', command: 'scrollIntoView' },
|
18042 |
|
18043 |
|
18044 | {
|
18045 | key: 'ctrl+[Digit2]',
|
18046 | ifMode: 'math',
|
18047 | command: ['insert', '\\sqrt{#0}'],
|
18048 | },
|
18049 | { key: 'ctrl+[Digit5]', ifMode: 'math', command: 'moveToOpposite' },
|
18050 | { key: 'ctrl+[Digit6]', ifMode: 'math', command: 'moveToSuperscript' },
|
18051 | { key: 'ctrl+[Return]', ifMode: 'math', command: 'addRowAfter' },
|
18052 | { key: 'ctrl+[Enter]', ifMode: 'math', command: 'addRowAfter' },
|
18053 | { key: 'cmd+[Return]', ifMode: 'math', command: 'addRowAfter' },
|
18054 | { key: 'cmd+[Enter]', ifMode: 'math', command: 'addRowAfter' },
|
18055 |
|
18056 |
|
18057 |
|
18058 |
|
18059 |
|
18060 |
|
18061 | { key: 'alt+p', ifMode: 'math', command: ['insert', '\\pi'] },
|
18062 | { key: 'alt+v', ifMode: 'math', command: ['insert', '\\sqrt{#0}'] },
|
18063 | {
|
18064 | key: 'alt+w',
|
18065 | ifMode: 'math',
|
18066 | command: ['insert', '\\sum_{i=#?}^{#?}'],
|
18067 | },
|
18068 | { key: 'alt+b', command: ['insert', '\\int_{#?}^{#?}'] },
|
18069 | { key: 'alt+u', ifMode: 'math', command: ['insert', '\\cup'] },
|
18070 | { key: 'alt+n', ifMode: 'math', command: ['insert', '\\cap'] },
|
18071 | { key: 'alt+o', ifMode: 'math', command: ['insert', '\\emptyset'] },
|
18072 | {
|
18073 | key: 'alt+d',
|
18074 | ifMode: 'math',
|
18075 | command: ['insert', '\\differentialD'],
|
18076 | },
|
18077 | {
|
18078 | key: 'shift+alt+o',
|
18079 | ifMode: 'math',
|
18080 | command: ['insert', '\\varnothing'],
|
18081 | },
|
18082 | {
|
18083 | key: 'shift+alt+d',
|
18084 | ifMode: 'math',
|
18085 | command: ['insert', '\\partial'],
|
18086 | },
|
18087 | {
|
18088 | key: 'shift+alt+p',
|
18089 | ifMode: 'math',
|
18090 | command: ['insert', '\\prod_{i=#?}^{#?}'],
|
18091 | },
|
18092 | { key: 'shift+alt+u', ifMode: 'math', command: ['insert', '\\bigcup'] },
|
18093 | { key: 'shift+alt+n', ifMode: 'math', command: ['insert', '\\bigcap'] },
|
18094 | { key: 'shift+alt+a', ifMode: 'math', command: ['insert', '\\forall'] },
|
18095 | { key: 'shift+alt+e', ifMode: 'math', command: ['insert', '\\exists'] },
|
18096 | {
|
18097 | key: 'alt+[Backslash]',
|
18098 | ifMode: 'math',
|
18099 | command: ['insert', '\\backslash'],
|
18100 | },
|
18101 | {
|
18102 | key: '[NumpadDivide]',
|
18103 | ifMode: 'math',
|
18104 | command: ['insert', '\\frac{#@}{#?}'],
|
18105 | },
|
18106 | {
|
18107 | key: 'alt+[NumpadDivide]',
|
18108 | ifMode: 'math',
|
18109 | command: ['insert', '\\frac{#?}{#@}'],
|
18110 | },
|
18111 |
|
18112 | { key: 'shift+alt+k', command: 'toggleKeystrokeCaption' },
|
18113 | { key: 'alt+[Space]', command: 'toggleVirtualKeyboard' },
|
18114 |
|
18115 |
|
18116 |
|
18117 |
|
18118 |
|
18119 |
|
18120 |
|
18121 |
|
18122 |
|
18123 |
|
18124 | {
|
18125 | key: 'alt+ctrl+[ArrowUp]',
|
18126 | command: ['speak', 'all', { withHighlighting: false }],
|
18127 | },
|
18128 | {
|
18129 | key: 'alt+ctrl+[ArrowDown]',
|
18130 | command: ['speak', 'selection', { withHighlighting: false }],
|
18131 | },
|
18132 |
|
18133 |
|
18134 |
|
18135 |
|
18136 | {
|
18137 | key: 'alt+[Equal]',
|
18138 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18139 | ifMode: 'math',
|
18140 | command: ['applyStyle', { mode: 'text' }],
|
18141 | },
|
18142 | {
|
18143 | key: 'alt+[Equal]',
|
18144 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18145 | ifMode: 'text',
|
18146 | command: ['applyStyle', { mode: 'math' }],
|
18147 | },
|
18148 | {
|
18149 | key: 'shift+[Quote]',
|
18150 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18151 | ifMode: 'math',
|
18152 | command: ['switchMode', 'text', '', '“'],
|
18153 | },
|
18154 | {
|
18155 | key: 'shift+[Quote]',
|
18156 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18157 | ifMode: 'text',
|
18158 | command: ['switchMode', 'math', '”', ''],
|
18159 | },
|
18160 | {
|
18161 | key: '/',
|
18162 | ifMode: 'math',
|
18163 | command: ['insert', '\\frac{#@}{#?}'],
|
18164 | },
|
18165 | {
|
18166 | key: 'alt+/',
|
18167 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18168 | ifMode: 'math',
|
18169 | command: ['insert', '\\/'],
|
18170 | },
|
18171 | {
|
18172 | key: 'alt+[BracketLeft]',
|
18173 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18174 | ifMode: 'math',
|
18175 | command: ['insert', '\\left\\lbrack #0 \\right\\rbrack'],
|
18176 | },
|
18177 | {
|
18178 | key: 'ctrl+[Minus]',
|
18179 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18180 | ifMode: 'math',
|
18181 | command: 'moveToSubscript',
|
18182 | },
|
18183 | {
|
18184 | key: 'shift+alt+[BracketLeft]',
|
18185 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18186 | ifMode: 'math',
|
18187 | command: ['insert', '\\left\\lbrace #0 \\right\\rbrace'],
|
18188 | },
|
18189 | {
|
18190 | key: 'ctrl+;',
|
18191 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18192 | ifMode: 'math',
|
18193 | command: 'addRowAfter',
|
18194 | },
|
18195 | {
|
18196 | key: 'cmd+;',
|
18197 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18198 | ifMode: 'math',
|
18199 | command: 'addRowAfter',
|
18200 | },
|
18201 | {
|
18202 | key: 'shift+ctrl+;',
|
18203 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18204 | ifMode: 'math',
|
18205 | command: 'addRowBefore',
|
18206 | },
|
18207 | {
|
18208 | key: 'shift+cmd+;',
|
18209 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18210 | ifMode: 'math',
|
18211 | command: 'addRowBefore',
|
18212 | },
|
18213 | {
|
18214 | key: 'ctrl+[Comma]',
|
18215 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18216 | ifMode: 'math',
|
18217 | command: 'addColumnAfter',
|
18218 | },
|
18219 | {
|
18220 | key: 'cmd+[Comma]',
|
18221 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18222 | ifMode: 'math',
|
18223 | command: 'addColumnAfter',
|
18224 | },
|
18225 | {
|
18226 | key: 'shift+ctrl+[Comma]',
|
18227 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18228 | ifMode: 'math',
|
18229 | command: 'addColumnAfter',
|
18230 | },
|
18231 | {
|
18232 | key: 'shift+cmd+[Comma]',
|
18233 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18234 | ifMode: 'math',
|
18235 | command: 'addColumnAfter',
|
18236 | },
|
18237 | {
|
18238 | key: 'alt+[Digit5]',
|
18239 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18240 | ifMode: 'math',
|
18241 | command: ['insert', '$\\infty'],
|
18242 | },
|
18243 | {
|
18244 | key: 'alt+[Digit6]',
|
18245 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18246 | ifMode: 'math',
|
18247 | command: ['insert', '\\wedge'],
|
18248 | },
|
18249 | {
|
18250 | key: 'shift+alt+[Digit6]',
|
18251 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18252 | ifMode: 'math',
|
18253 | command: ['insert', '\\vee'],
|
18254 | },
|
18255 | {
|
18256 | key: 'alt+[Digit9]',
|
18257 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18258 | ifMode: 'math',
|
18259 | command: ['insert', '('],
|
18260 | },
|
18261 | {
|
18262 | key: 'alt+[Digit0]',
|
18263 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18264 | ifMode: 'math',
|
18265 | command: ['insert', ')'],
|
18266 | },
|
18267 | {
|
18268 | key: 'alt+|',
|
18269 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18270 | ifMode: 'math',
|
18271 | command: ['insert', '|'],
|
18272 | },
|
18273 | {
|
18274 | key: 'shift+[Backquote]',
|
18275 | ifLayout: ['apple.en-intl', 'windows.en-intl', 'linux.en'],
|
18276 | ifMode: 'math',
|
18277 | command: ['insert', '\\~'],
|
18278 | },
|
18279 | ];
|
18280 |
|
18281 |
|
18282 |
|
18283 |
|
18284 |
|
18285 |
|
18286 |
|
18287 |
|
18288 | const REVERSE_KEYBINDINGS = {
|
18289 | '\\theta': 'alt+q',
|
18290 | '\\sqrt': ['alt+v', 'ctrl+[Digit2]'],
|
18291 | '\\pi': 'alt+p',
|
18292 | '\\prod': 'shift+alt+p',
|
18293 | '\\sum': 'alt+w',
|
18294 | '\\int': 'alt+b',
|
18295 | '\\cup': 'alt+u',
|
18296 | '\\cap': 'alt+n',
|
18297 | '\\bigcup': 'shift+alt+u',
|
18298 | '\\bigcap': 'shift+alt+n',
|
18299 | '\\forall': 'shift+alt+a',
|
18300 | '\\exists': 'shift+alt+e',
|
18301 | '\\infty': 'alt+[Digit5]',
|
18302 | '\\wedge': 'alt+[Digit5]',
|
18303 | '\\vee': 'shift+alt+[Digit6]',
|
18304 | '\\differentialD': 'alt+d',
|
18305 | '\\partial': 'shift+alt+d',
|
18306 | '\\frac': 'Slash',
|
18307 | '\\emptyset': 'alt+o',
|
18308 | '\\varnothing': 'shift+alt+o',
|
18309 | '\\~': '~',
|
18310 | };
|
18311 |
|
18312 | function keystrokeModifiersFromString(key) {
|
18313 | const segments = key.split('+');
|
18314 | const result = {
|
18315 | shift: false,
|
18316 | alt: false,
|
18317 | cmd: false,
|
18318 | win: false,
|
18319 | meta: false,
|
18320 | ctrl: false,
|
18321 | key: segments.pop(),
|
18322 | };
|
18323 | if (segments.includes('shift'))
|
18324 | result.shift = true;
|
18325 | if (segments.includes('alt'))
|
18326 | result.alt = true;
|
18327 | if (segments.includes('ctrl'))
|
18328 | result.ctrl = true;
|
18329 | if (segments.includes('cmd'))
|
18330 | result.cmd = true;
|
18331 | if (segments.includes('win'))
|
18332 | result.win = true;
|
18333 | if (segments.includes('meta'))
|
18334 | result.meta = true;
|
18335 | return result;
|
18336 | }
|
18337 | function keystrokeModifiersToString(key) {
|
18338 | let result = '';
|
18339 | if (key.shift)
|
18340 | result += 'shift+';
|
18341 | if (key.alt)
|
18342 | result += 'alt+';
|
18343 | if (key.ctrl)
|
18344 | result += 'ctrl+';
|
18345 | if (key.cmd)
|
18346 | result += 'cmd+';
|
18347 | if (key.win)
|
18348 | result += 'win+';
|
18349 | if (key.meta)
|
18350 | result += 'meta+';
|
18351 | return result + key.key;
|
18352 | }
|
18353 | const DEFAULT_KEYBOARD_LAYOUT = platform() === 'apple'
|
18354 | ? {
|
18355 | id: 'apple.en-intl',
|
18356 | displayName: 'English (international)',
|
18357 | virtualLayout: 'qwerty',
|
18358 | platform: 'apple',
|
18359 | locale: 'en',
|
18360 | score: 0,
|
18361 | mapping: {
|
18362 | KeyA: ['a', 'A', 'å', 'Å'],
|
18363 | KeyB: ['b', 'B', '∫', 'ı'],
|
18364 | KeyC: ['c', 'C', 'ç', 'Ç'],
|
18365 | KeyD: ['d', 'D', '∂', 'Î'],
|
18366 | KeyE: ['e', 'E', '´', '´'],
|
18367 | KeyF: ['f', 'F', 'ƒ', 'Ï'],
|
18368 | KeyG: ['g', 'G', '©', '˝'],
|
18369 | KeyH: ['h', 'H', '˙', 'Ó'],
|
18370 | KeyI: ['i', 'I', 'ˆ', 'ˆ'],
|
18371 | KeyJ: ['j', 'J', '∆', 'Ô'],
|
18372 | KeyK: ['k', 'K', '˚', ''],
|
18373 | KeyL: ['l', 'L', '¬', 'Ò'],
|
18374 | KeyM: ['m', 'M', 'µ', 'Â'],
|
18375 | KeyN: ['n', 'N', '˜', '˜'],
|
18376 | KeyO: ['o', 'O', 'ø', 'Ø'],
|
18377 | KeyP: ['p', 'P', 'π', '∏'],
|
18378 | KeyQ: ['q', 'Q', 'œ', 'Œ'],
|
18379 | KeyR: ['r', 'R', '®', '‰'],
|
18380 | KeyS: ['s', 'S', 'ß', 'Í'],
|
18381 | KeyT: ['t', 'T', '†', 'ˇ'],
|
18382 | KeyU: ['u', 'U', '¨', '¨'],
|
18383 | KeyV: ['v', 'V', '√', '◊'],
|
18384 | KeyW: ['w', 'W', '∑', '„'],
|
18385 | KeyX: ['x', 'X', '≈', '˛'],
|
18386 | KeyY: ['y', 'Y', '¥', 'Á'],
|
18387 | KeyZ: ['z', 'Z', 'Ω', '¸'],
|
18388 | Digit1: ['1', '!', '¡', '⁄'],
|
18389 | Digit2: ['2', '@', '™', '€'],
|
18390 | Digit3: ['3', '#', '£', '‹'],
|
18391 | Digit4: ['4', '$', '¢', '›'],
|
18392 | Digit5: ['5', '%', '∞', 'fi'],
|
18393 | Digit6: ['6', '^', '§', 'fl'],
|
18394 | Digit7: ['7', '&', '¶', '‡'],
|
18395 | Digit8: ['8', '*', '•', '°'],
|
18396 | Digit9: ['9', '(', 'ª', '·'],
|
18397 | Digit0: ['0', ')', 'º', '‚'],
|
18398 | Space: [' ', ' ', ' ', ' '],
|
18399 | Minus: ['-', '_', '–', '—'],
|
18400 | Equal: ['=', '+', '≠', '±'],
|
18401 | BracketLeft: ['[', '{', '“', '”'],
|
18402 | BracketRight: [']', '}', '‘', '’'],
|
18403 | Backslash: ['\\', '|', '«', '»'],
|
18404 | Semicolon: [';', ':', '…', 'Ú'],
|
18405 | Quote: ["'", '"', 'æ', 'Æ'],
|
18406 | Backquote: ['`', '˜', '`', '`'],
|
18407 | Comma: [',', '<', '≤', '¯'],
|
18408 | Period: ['.', '>', '≥', '˘'],
|
18409 | Slash: ['/', '?', '÷', '¿'],
|
18410 | NumpadDivide: ['/', '/', '/', '/'],
|
18411 | NumpadMultiply: ['*', '*', '*', '*'],
|
18412 | NumpadSubtract: ['-', '-', '-', '-'],
|
18413 | NumpadAdd: ['+', '+', '+', '+'],
|
18414 | Numpad1: ['1', '1', '1', '1'],
|
18415 | Numpad2: ['2', '2', '2', '2'],
|
18416 | Numpad3: ['3', '3', '3', '3'],
|
18417 | Numpad4: ['4', '4', '4', '4'],
|
18418 | Numpad5: ['5', '5', '5', '5'],
|
18419 | Numpad6: ['6', '6', '6', '6'],
|
18420 | Numpad7: ['7', '7', '7', '7'],
|
18421 | Numpad8: ['8', '8', '8', '8'],
|
18422 | Numpad9: ['9', '9', '9', '9'],
|
18423 | Numpad0: ['0', '0', '0', '0'],
|
18424 | NumpadDecimal: ['.', '.', '.', '.'],
|
18425 | IntlBackslash: ['§', '±', '§', '±'],
|
18426 | NumpadEqual: ['=', '=', '=', '='],
|
18427 | AudioVolumeUp: ['', '=', '', '='],
|
18428 | },
|
18429 | }
|
18430 | : platform() === 'windows'
|
18431 | ? {
|
18432 | id: 'windows.en-intl',
|
18433 | displayName: 'English (international)',
|
18434 | platform: 'windows',
|
18435 | virtualLayout: 'qwerty',
|
18436 | locale: 'en',
|
18437 | score: 0,
|
18438 | mapping: {
|
18439 | KeyA: ['a', 'A', 'á', 'Á'],
|
18440 | KeyB: ['b', 'B', '', ''],
|
18441 | KeyC: ['c', 'C', '©', '¢'],
|
18442 | KeyD: ['d', 'D', 'ð', 'Ð'],
|
18443 | KeyE: ['e', 'E', 'é', 'É'],
|
18444 | KeyF: ['f', 'F', '', ''],
|
18445 | KeyG: ['g', 'G', '', ''],
|
18446 | KeyH: ['h', 'H', '', ''],
|
18447 | KeyI: ['i', 'I', 'í', 'Í'],
|
18448 | KeyJ: ['j', 'J', '', ''],
|
18449 | KeyK: ['k', 'K', '', ''],
|
18450 | KeyL: ['l', 'L', 'ø', 'Ø'],
|
18451 | KeyM: ['m', 'M', 'µ', ''],
|
18452 | KeyN: ['n', 'N', 'ñ', 'Ñ'],
|
18453 | KeyO: ['o', 'O', 'ó', 'Ó'],
|
18454 | KeyP: ['p', 'P', 'ö', 'Ö'],
|
18455 | KeyQ: ['q', 'Q', 'ä', 'Ä'],
|
18456 | KeyR: ['r', 'R', '®', ''],
|
18457 | KeyS: ['s', 'S', 'ß', '§'],
|
18458 | KeyT: ['t', 'T', 'þ', 'Þ'],
|
18459 | KeyU: ['u', 'U', 'ú', 'Ú'],
|
18460 | KeyV: ['v', 'V', '', ''],
|
18461 | KeyW: ['w', 'W', 'å', 'Å'],
|
18462 | KeyX: ['x', 'X', '', ''],
|
18463 | KeyY: ['y', 'Y', 'ü', 'Ü'],
|
18464 | KeyZ: ['z', 'Z', 'æ', 'Æ'],
|
18465 | Digit1: ['1', '!', '¡', '¹'],
|
18466 | Digit2: ['2', '@', '²', ''],
|
18467 | Digit3: ['3', '#', '³', ''],
|
18468 | Digit4: ['4', '$', '¤', '£'],
|
18469 | Digit5: ['5', '%', '€', ''],
|
18470 | Digit6: ['6', '^', '¼', ''],
|
18471 | Digit7: ['7', '&', '½', ''],
|
18472 | Digit8: ['8', '*', '¾', ''],
|
18473 | Digit9: ['9', '(', '‘', ''],
|
18474 | Digit0: ['0', ')', '’', ''],
|
18475 | Space: [' ', ' ', '', ''],
|
18476 | Minus: ['-', '_', '¥', ''],
|
18477 | Equal: ['=', '+', '×', '÷'],
|
18478 | BracketLeft: ['[', '{', '«', ''],
|
18479 | BracketRight: [']', '}', '»', ''],
|
18480 | Backslash: ['\\', '|', '¬', '¦'],
|
18481 | Semicolon: [';', ':', '¶', '°'],
|
18482 | Quote: ["'", '"', '´', '¨'],
|
18483 | Backquote: ['`', '~', '', ''],
|
18484 | Comma: [',', '<', 'ç', 'Ç'],
|
18485 | Period: ['.', '>', '', ''],
|
18486 | Slash: ['/', '?', '¿', ''],
|
18487 | NumpadDivide: ['/', '/', '', ''],
|
18488 | NumpadMultiply: ['*', '*', '', ''],
|
18489 | NumpadSubtract: ['-', '-', '', ''],
|
18490 | NumpadAdd: ['+', '+', '', ''],
|
18491 | IntlBackslash: ['\\', '|', '', ''],
|
18492 | },
|
18493 | }
|
18494 | : {
|
18495 | id: 'linux.en',
|
18496 | displayName: 'English',
|
18497 | platform: 'linux',
|
18498 | virtualLayout: 'qwerty',
|
18499 | locale: 'en',
|
18500 | score: 0,
|
18501 | mapping: {
|
18502 | KeyA: ['a', 'A', 'a', 'A'],
|
18503 | KeyB: ['b', 'B', 'b', 'B'],
|
18504 | KeyC: ['c', 'C', 'c', 'C'],
|
18505 | KeyD: ['d', 'D', 'd', 'D'],
|
18506 | KeyE: ['e', 'E', 'e', 'E'],
|
18507 | KeyF: ['f', 'F', 'f', 'F'],
|
18508 | KeyG: ['g', 'G', 'g', 'G'],
|
18509 | KeyH: ['h', 'H', 'h', 'H'],
|
18510 | KeyI: ['i', 'I', 'i', 'I'],
|
18511 | KeyJ: ['j', 'J', 'j', 'J'],
|
18512 | KeyK: ['k', 'K', 'k', 'K'],
|
18513 | KeyL: ['l', 'L', 'l', 'L'],
|
18514 | KeyM: ['m', 'M', 'm', 'M'],
|
18515 | KeyN: ['n', 'N', 'n', 'N'],
|
18516 | KeyO: ['o', 'O', 'o', 'O'],
|
18517 | KeyP: ['p', 'P', 'p', 'P'],
|
18518 | KeyQ: ['q', 'Q', 'q', 'Q'],
|
18519 | KeyR: ['r', 'R', 'r', 'R'],
|
18520 | KeyS: ['s', 'S', 's', 'S'],
|
18521 | KeyT: ['t', 'T', 't', 'T'],
|
18522 | KeyU: ['u', 'U', 'u', 'U'],
|
18523 | KeyV: ['v', 'V', 'v', 'V'],
|
18524 | KeyW: ['w', 'W', 'w', 'W'],
|
18525 | KeyX: ['x', 'X', 'x', 'X'],
|
18526 | KeyY: ['y', 'Y', 'y', 'Y'],
|
18527 | KeyZ: ['z', 'Z', 'z', 'Z'],
|
18528 | Digit1: ['1', '!', '1', '!'],
|
18529 | Digit2: ['2', '@', '2', '@'],
|
18530 | Digit3: ['3', '#', '3', '#'],
|
18531 | Digit4: ['4', '$', '4', '$'],
|
18532 | Digit5: ['5', '%', '5', '%'],
|
18533 | Digit6: ['6', '^', '6', '^'],
|
18534 | Digit7: ['7', '&', '7', '&'],
|
18535 | Digit8: ['8', '*', '8', '*'],
|
18536 | Digit9: ['9', '(', '9', '('],
|
18537 | Digit0: ['0', ')', '0', ')'],
|
18538 | Space: [' ', ' ', ' ', ' '],
|
18539 | Minus: ['-', '_', '-', '_'],
|
18540 | Equal: ['=', '+', '=', '+'],
|
18541 | BracketLeft: ['[', '{', '[', '{'],
|
18542 | BracketRight: [']', '}', ']', '}'],
|
18543 | Backslash: ['\\', '|', '\\', '|'],
|
18544 | Semicolon: [';', ':', ';', ':'],
|
18545 | Quote: ["'", '"', "'", '"'],
|
18546 | Backquote: ['`', '~', '`', '~'],
|
18547 | Comma: [',', '<', ',', '<'],
|
18548 | Period: ['.', '>', '.', '>'],
|
18549 | Slash: ['/', '?', '/', '?'],
|
18550 | NumpadDivide: ['/', '/', '/', '/'],
|
18551 | NumpadMultiply: ['*', '*', '*', '*'],
|
18552 | NumpadSubtract: ['-', '-', '-', '-'],
|
18553 | NumpadAdd: ['+', '+', '+', '+'],
|
18554 | Numpad1: ['1', '1', '1', '1'],
|
18555 | Numpad2: ['2', '2', '2', '2'],
|
18556 | Numpad3: ['3', '3', '3', '3'],
|
18557 | Numpad4: ['4', '4', '4', '4'],
|
18558 | Numpad5: ['5', '5', '5', '5'],
|
18559 | Numpad6: ['6', '6', '6', '6'],
|
18560 | Numpad7: ['7', '7', '7', '7'],
|
18561 | Numpad8: ['8', '8', '8', '8'],
|
18562 | Numpad9: ['9', '9', '9', '9'],
|
18563 | Numpad0: ['0', '0', '0', '0'],
|
18564 | NumpadDecimal: ['', '.', '', '.'],
|
18565 | IntlBackslash: ['<', '>', '|', '¦'],
|
18566 | NumpadEqual: ['=', '=', '=', '='],
|
18567 | NumpadComma: ['.', '.', '.', '.'],
|
18568 | NumpadParenLeft: ['(', '(', '(', '('],
|
18569 | NumpadParenRight: [')', ')', ')', ')'],
|
18570 | },
|
18571 | };
|
18572 |
|
18573 | const BASE_LAYOUT_MAPPING = {
|
18574 | enter: '[Enter]',
|
18575 | escape: '[Escape]',
|
18576 | backspace: '[Backspace]',
|
18577 | tab: '[Tab]',
|
18578 | space: '[Space]',
|
18579 | pausebreak: '[Pause]',
|
18580 | insert: '[Insert]',
|
18581 | home: '[Home]',
|
18582 | pageup: '[PageUp]',
|
18583 | delete: '[Delete]',
|
18584 | end: '[End]',
|
18585 | pagedown: '[PageDown]',
|
18586 | right: '[ArrowRight]',
|
18587 | left: '[ArrowLeft]',
|
18588 | down: '[ArrowDown]',
|
18589 | up: '[ArrowUp]',
|
18590 | numpad0: '[Numpad0]',
|
18591 | numpad1: '[Numpad1]',
|
18592 | numpad2: '[Numpad2]',
|
18593 | numpad3: '[Numpad3]',
|
18594 | numpad4: '[Numpad4]',
|
18595 | numpad5: '[Numpad5]',
|
18596 | numpad6: '[Numpad6]',
|
18597 | numpad7: '[Numpad7]',
|
18598 | numpad8: '[Numpad8]',
|
18599 | numpad9: '[Numpad9]',
|
18600 | 'numpad_divide': '[NumpadDivide]',
|
18601 | 'numpad_multiply': '[NumpadMultiply]',
|
18602 | 'numpad_subtract': '[NumpadSubtract]',
|
18603 | 'numpad_add': '[NumpadAdd]',
|
18604 | 'numpad_decimal': '[NumpadDecimal]',
|
18605 | 'numpad_separator': '[NumpadComma]',
|
18606 | capslock: '[Capslock]',
|
18607 | f1: '[F1]',
|
18608 | f2: '[F2]',
|
18609 | f3: '[F3]',
|
18610 | f4: '[F4]',
|
18611 | f5: '[F5]',
|
18612 | f6: '[F6]',
|
18613 | f7: '[F7]',
|
18614 | f8: '[F8]',
|
18615 | f9: '[F9]',
|
18616 | f10: '[F10]',
|
18617 | f11: '[F11]',
|
18618 | f12: '[F12]',
|
18619 | f13: '[F13]',
|
18620 | f14: '[F14]',
|
18621 | f15: '[F15]',
|
18622 | f16: '[F16]',
|
18623 | f17: '[F17]',
|
18624 | f18: '[F18]',
|
18625 | f19: '[F19]',
|
18626 | };
|
18627 | const gKeyboardLayouts = [];
|
18628 | let gKeyboardLayout;
|
18629 | function platform() {
|
18630 | switch (osPlatform()) {
|
18631 | case 'macos':
|
18632 | case 'ios':
|
18633 | return 'apple';
|
18634 | case 'windows':
|
18635 | return 'windows';
|
18636 |
|
18637 |
|
18638 | }
|
18639 | return 'linux';
|
18640 | }
|
18641 | function register$1(layout) {
|
18642 | if (!layout.platform || layout.platform === platform()) {
|
18643 | gKeyboardLayouts.push(layout);
|
18644 | }
|
18645 | }
|
18646 |
|
18647 |
|
18648 |
|
18649 |
|
18650 |
|
18651 |
|
18652 |
|
18653 |
|
18654 |
|
18655 |
|
18656 |
|
18657 |
|
18658 |
|
18659 |
|
18660 |
|
18661 |
|
18662 |
|
18663 |
|
18664 |
|
18665 |
|
18666 |
|
18667 |
|
18668 |
|
18669 |
|
18670 |
|
18671 |
|
18672 |
|
18673 |
|
18674 |
|
18675 |
|
18676 | function getCodeForKey(k, layout) {
|
18677 | var _a;
|
18678 | const result = {
|
18679 | shift: false,
|
18680 | alt: false,
|
18681 | cmd: false,
|
18682 | win: false,
|
18683 | meta: false,
|
18684 | ctrl: false,
|
18685 | key: '',
|
18686 | };
|
18687 | if (!k)
|
18688 | return result;
|
18689 | for (const [key, value] of Object.entries(layout.mapping)) {
|
18690 | if (value[0] === k) {
|
18691 | result.key = `[${key}]`;
|
18692 | return result;
|
18693 | }
|
18694 | if (value[1] === k) {
|
18695 | result.shift = true;
|
18696 | result.key = `[${key}]`;
|
18697 | return result;
|
18698 | }
|
18699 | if (value[2] === k) {
|
18700 | result.alt = true;
|
18701 | result.key = `[${key}]`;
|
18702 | return result;
|
18703 | }
|
18704 | if (value[3] === k) {
|
18705 | result.shift = true;
|
18706 | result.alt = true;
|
18707 | result.key = `[${key}]`;
|
18708 | return result;
|
18709 | }
|
18710 | }
|
18711 | result.key = (_a = BASE_LAYOUT_MAPPING[k]) !== null && _a !== void 0 ? _a : '';
|
18712 | return result;
|
18713 | }
|
18714 | function normalizeKeyboardEvent(evt) {
|
18715 | if (!evt.code) {
|
18716 |
|
18717 |
|
18718 |
|
18719 |
|
18720 | const mapping = Object.entries(getActiveKeyboardLayout().mapping);
|
18721 | let altKey = false;
|
18722 | let shiftKey = false;
|
18723 | let code = '';
|
18724 | for (let index = 0; index < 4; index++) {
|
18725 | for (const [key, value] of mapping) {
|
18726 | if (value[index] === evt.key) {
|
18727 | code = key;
|
18728 | if (index === 3) {
|
18729 | altKey = true;
|
18730 | shiftKey = true;
|
18731 | }
|
18732 | else if (index === 2) {
|
18733 | altKey = true;
|
18734 | }
|
18735 | else if (index === 1) {
|
18736 | shiftKey = true;
|
18737 | }
|
18738 | break;
|
18739 | }
|
18740 | }
|
18741 | if (code)
|
18742 | break;
|
18743 | }
|
18744 | return new KeyboardEvent(evt.type, { ...evt, altKey, shiftKey, code });
|
18745 | }
|
18746 | return new KeyboardEvent(evt.type, evt);
|
18747 | }
|
18748 |
|
18749 |
|
18750 |
|
18751 |
|
18752 | function validateKeyboardLayout(evt) {
|
18753 | var _a, _b;
|
18754 | if (!evt)
|
18755 | return;
|
18756 | const index = evt.shiftKey && evt.altKey ? 3 : evt.altKey ? 2 : evt.shiftKey ? 1 : 0;
|
18757 | if (evt.key === 'Unidentified')
|
18758 | return;
|
18759 |
|
18760 |
|
18761 | if (evt.key === 'Dead')
|
18762 | return;
|
18763 | for (const layout of gKeyboardLayouts) {
|
18764 | if (((_a = layout.mapping[evt.code]) === null || _a === void 0 ? void 0 : _a[index]) === evt.key) {
|
18765 |
|
18766 |
|
18767 | layout.score += 1;
|
18768 | }
|
18769 | else if ((_b = layout.mapping[evt.code]) === null || _b === void 0 ? void 0 : _b[index]) {
|
18770 |
|
18771 |
|
18772 | layout.score = 0;
|
18773 | }
|
18774 | }
|
18775 | gKeyboardLayouts.sort((a, b) => b.score - a.score);
|
18776 | }
|
18777 | function setKeyboardLayoutLocale(locale) {
|
18778 | gKeyboardLayout = gKeyboardLayouts.find((x) => locale.startsWith(x.locale));
|
18779 | }
|
18780 | function getActiveKeyboardLayout() {
|
18781 | return gKeyboardLayout !== null && gKeyboardLayout !== void 0 ? gKeyboardLayout : gKeyboardLayouts[0];
|
18782 | }
|
18783 | register$1(DEFAULT_KEYBOARD_LAYOUT);
|
18784 | register$1({
|
18785 | id: 'apple.french',
|
18786 | locale: 'fr',
|
18787 | displayName: 'French',
|
18788 | platform: 'apple',
|
18789 | virtualLayout: 'azerty',
|
18790 | score: 0,
|
18791 | mapping: {
|
18792 | KeyA: ['q', 'Q', '‡', 'Ω'],
|
18793 | KeyB: ['b', 'B', 'ß', '∫'],
|
18794 | KeyC: ['c', 'C', '©', '¢'],
|
18795 | KeyD: ['d', 'D', '∂', '∆'],
|
18796 | KeyE: ['e', 'E', 'ê', 'Ê'],
|
18797 | KeyF: ['f', 'F', 'ƒ', '·'],
|
18798 | KeyG: ['g', 'G', 'fi', 'fl'],
|
18799 | KeyH: ['h', 'H', 'Ì', 'Î'],
|
18800 | KeyI: ['i', 'I', 'î', 'ï'],
|
18801 | KeyJ: ['j', 'J', 'Ï', 'Í'],
|
18802 | KeyK: ['k', 'K', 'È', 'Ë'],
|
18803 | KeyL: ['l', 'L', '¬', '|'],
|
18804 | KeyM: [',', '?', '∞', '¿'],
|
18805 | KeyN: ['n', 'N', '~', 'ı'],
|
18806 | KeyO: ['o', 'O', 'œ', 'Œ'],
|
18807 | KeyP: ['p', 'P', 'π', '∏'],
|
18808 | KeyQ: ['a', 'A', 'æ', 'Æ'],
|
18809 | KeyR: ['r', 'R', '®', '‚'],
|
18810 | KeyS: ['s', 'S', 'Ò', '∑'],
|
18811 | KeyT: ['t', 'T', '†', '™'],
|
18812 | KeyU: ['u', 'U', 'º', 'ª'],
|
18813 | KeyV: ['v', 'V', '◊', '√'],
|
18814 | KeyW: ['z', 'Z', 'Â', 'Å'],
|
18815 | KeyX: ['x', 'X', '≈', '⁄'],
|
18816 | KeyY: ['y', 'Y', 'Ú', 'Ÿ'],
|
18817 | KeyZ: ['w', 'W', '‹', '›'],
|
18818 | Digit1: ['&', '1', '', '´'],
|
18819 | Digit2: ['é', '2', 'ë', '„'],
|
18820 | Digit3: ['"', '3', '“', '”'],
|
18821 | Digit4: ["'", '4', '‘', '’'],
|
18822 | Digit5: ['(', '5', '{', '['],
|
18823 | Digit6: ['§', '6', '¶', 'å'],
|
18824 | Digit7: ['è', '7', '«', '»'],
|
18825 | Digit8: ['!', '8', '¡', 'Û'],
|
18826 | Digit9: ['ç', '9', 'Ç', 'Á'],
|
18827 | Digit0: ['à', '0', 'ø', 'Ø'],
|
18828 | Space: [' ', ' ', ' ', ' '],
|
18829 | Minus: [')', '°', '}', ']'],
|
18830 | Equal: ['-', '_', '—', '–'],
|
18831 | BracketLeft: ['^', '¨', 'ô', 'Ô'],
|
18832 | BracketRight: ['$', '*', '€', '¥'],
|
18833 | Backslash: ['`', '£', '@', '#'],
|
18834 | Semicolon: ['m', 'M', 'µ', 'Ó'],
|
18835 | Quote: ['ù', '%', 'Ù', '‰'],
|
18836 | Backquote: ['<', '>', '≤', '≥'],
|
18837 | Comma: [';', '.', '…', '•'],
|
18838 | Period: [':', '/', '÷', '\\'],
|
18839 | Slash: ['=', '+', '≠', '±'],
|
18840 | NumpadDivide: ['/', '/', '/', '/'],
|
18841 | NumpadMultiply: ['*', '*', '*', '*'],
|
18842 | NumpadSubtract: ['-', '-', '-', '-'],
|
18843 | NumpadAdd: ['+', '+', '+', '+'],
|
18844 | NumpadDecimal: [',', '.', ',', '.'],
|
18845 | IntlBackslash: ['@', '#', '•', 'Ÿ'],
|
18846 | NumpadEqual: ['=', '=', '=', '='],
|
18847 | },
|
18848 | });
|
18849 | register$1({
|
18850 | id: 'apple.spanish',
|
18851 | locale: 'es',
|
18852 | displayName: 'Spanish ISO',
|
18853 | platform: 'apple',
|
18854 | virtualLayout: 'qwerty',
|
18855 | score: 0,
|
18856 | mapping: {
|
18857 | KeyA: ['a', 'A', 'å', 'Å'],
|
18858 | KeyB: ['b', 'B', 'ß', ''],
|
18859 | KeyC: ['c', 'C', '©', ' '],
|
18860 | KeyD: ['d', 'D', '∂', '∆'],
|
18861 | KeyE: ['e', 'E', '€', '€'],
|
18862 | KeyF: ['f', 'F', 'ƒ', 'fi'],
|
18863 | KeyG: ['g', 'G', '', 'fl'],
|
18864 | KeyH: ['h', 'H', '™', ' '],
|
18865 | KeyI: ['i', 'I', ' ', ' '],
|
18866 | KeyJ: ['j', 'J', '¶', '¯'],
|
18867 | KeyK: ['k', 'K', '§', 'ˇ'],
|
18868 | KeyL: ['l', 'L', ' ', '˘'],
|
18869 | KeyM: ['m', 'M', 'µ', '˚'],
|
18870 | KeyN: ['n', 'N', ' ', '˙'],
|
18871 | KeyO: ['o', 'O', 'ø', 'Ø'],
|
18872 | KeyP: ['p', 'P', 'π', '∏'],
|
18873 | KeyQ: ['q', 'Q', 'œ', 'Œ'],
|
18874 | KeyR: ['r', 'R', '®', ' '],
|
18875 | KeyS: ['s', 'S', '∫', ' '],
|
18876 | KeyT: ['t', 'T', '†', '‡'],
|
18877 | KeyU: ['u', 'U', ' ', ' '],
|
18878 | KeyV: ['v', 'V', '√', '◊'],
|
18879 | KeyW: ['w', 'W', 'æ', 'Æ'],
|
18880 | KeyX: ['x', 'X', '∑', '›'],
|
18881 | KeyY: ['y', 'Y', '¥', ' '],
|
18882 | KeyZ: ['z', 'Z', 'Ω', '‹'],
|
18883 | Digit1: ['1', '!', '|', 'ı'],
|
18884 | Digit2: ['2', '"', '@', '˝'],
|
18885 | Digit3: ['3', '·', '#', '•'],
|
18886 | Digit4: ['4', '$', '¢', '£'],
|
18887 | Digit5: ['5', '%', '∞', '‰'],
|
18888 | Digit6: ['6', '&', '¬', ' '],
|
18889 | Digit7: ['7', '/', '÷', '⁄'],
|
18890 | Digit8: ['8', '(', '“', '‘'],
|
18891 | Digit9: ['9', ')', '”', '’'],
|
18892 | Digit0: ['0', '=', '≠', '≈'],
|
18893 | Space: [' ', ' ', ' ', ' '],
|
18894 | Minus: ["'", '?', '´', '¸'],
|
18895 | Equal: ['¡', '¿', '‚', '˛'],
|
18896 | BracketLeft: ['`', '^', '[', 'ˆ'],
|
18897 | BracketRight: ['+', '*', ']', '±'],
|
18898 | Backslash: ['ç', 'Ç', '}', '»'],
|
18899 | Semicolon: ['ñ', 'Ñ', '~', '˜'],
|
18900 | Quote: ['´', '¨', '{', '«'],
|
18901 | Backquote: ['<', '>', '≤', '≥'],
|
18902 | Comma: [',', ';', '„', ''],
|
18903 | Period: ['.', ':', '…', '…'],
|
18904 | Slash: ['-', '_', '–', '—'],
|
18905 | NumpadDivide: ['/', '/', '/', '/'],
|
18906 | NumpadMultiply: ['*', '*', '*', '*'],
|
18907 | NumpadSubtract: ['-', '-', '-', '-'],
|
18908 | NumpadAdd: ['+', '+', '+', '+'],
|
18909 | Numpad1: ['1', '1', '1', '1'],
|
18910 | Numpad2: ['2', '2', '2', '2'],
|
18911 | Numpad3: ['3', '3', '3', '3'],
|
18912 | Numpad4: ['4', '4', '4', '4'],
|
18913 | Numpad5: ['5', '5', '5', '5'],
|
18914 | Numpad6: ['6', '6', '6', '6'],
|
18915 | Numpad7: ['7', '7', '7', '7'],
|
18916 | Numpad8: ['8', '8', '8', '8'],
|
18917 | Numpad9: ['9', '9', '9', '9'],
|
18918 | Numpad0: ['0', '0', '0', '0'],
|
18919 | NumpadDecimal: [',', ',', ',', ','],
|
18920 | IntlBackslash: ['º', 'ª', '\\', '°'],
|
18921 | },
|
18922 | });
|
18923 | register$1({
|
18924 | id: 'windows.spanish',
|
18925 | locale: 'es',
|
18926 | displayName: 'Spanish',
|
18927 | platform: 'windows',
|
18928 | virtualLayout: 'qwerty',
|
18929 | score: 0,
|
18930 | mapping: {
|
18931 | KeyA: ['a', 'A', '', ''],
|
18932 | KeyB: ['b', 'B', '', ''],
|
18933 | KeyC: ['c', 'C', '', ''],
|
18934 | KeyD: ['d', 'D', '', ''],
|
18935 | KeyE: ['e', 'E', '€', ''],
|
18936 | KeyF: ['f', 'F', '', ''],
|
18937 | KeyG: ['g', 'G', '', ''],
|
18938 | KeyH: ['h', 'H', '', ''],
|
18939 | KeyI: ['i', 'I', '', ''],
|
18940 | KeyJ: ['j', 'J', '', ''],
|
18941 | KeyK: ['k', 'K', '', ''],
|
18942 | KeyL: ['l', 'L', '', ''],
|
18943 | KeyM: ['m', 'M', '', ''],
|
18944 | KeyN: ['n', 'N', '', ''],
|
18945 | KeyO: ['o', 'O', '', ''],
|
18946 | KeyP: ['p', 'P', '', ''],
|
18947 | KeyQ: ['q', 'Q', '', ''],
|
18948 | KeyR: ['r', 'R', '', ''],
|
18949 | KeyS: ['s', 'S', '', ''],
|
18950 | KeyT: ['t', 'T', '', ''],
|
18951 | KeyU: ['u', 'U', '', ''],
|
18952 | KeyV: ['v', 'V', '', ''],
|
18953 | KeyW: ['w', 'W', '', ''],
|
18954 | KeyX: ['x', 'X', '', ''],
|
18955 | KeyY: ['y', 'Y', '', ''],
|
18956 | KeyZ: ['z', 'Z', '', ''],
|
18957 | Digit1: ['1', '!', '|', ''],
|
18958 | Digit2: ['2', '"', '@', ''],
|
18959 | Digit3: ['3', '·', '#', ''],
|
18960 | Digit4: ['4', '$', '~', ''],
|
18961 | Digit5: ['5', '%', '€', ''],
|
18962 | Digit6: ['6', '&', '¬', ''],
|
18963 | Digit7: ['7', '/', '', ''],
|
18964 | Digit8: ['8', '(', '', ''],
|
18965 | Digit9: ['9', ')', '', ''],
|
18966 | Digit0: ['0', '=', '', ''],
|
18967 | Space: [' ', ' ', '', ''],
|
18968 | Minus: ["'", '?', '', ''],
|
18969 | Equal: ['¡', '¿', '', ''],
|
18970 | BracketLeft: ['`', '^', '[', ''],
|
18971 | BracketRight: ['+', '*', ']', ''],
|
18972 | Backslash: ['ç', 'Ç', '}', ''],
|
18973 | Semicolon: ['ñ', 'Ñ', '', ''],
|
18974 | Quote: ['´', '¨', '{', ''],
|
18975 | Backquote: ['º', 'ª', '\\', ''],
|
18976 | Comma: [',', ';', '', ''],
|
18977 | Period: ['.', ':', '', ''],
|
18978 | Slash: ['-', '_', '', ''],
|
18979 | NumpadDivide: ['/', '/', '', ''],
|
18980 | NumpadMultiply: ['*', '*', '', ''],
|
18981 | NumpadSubtract: ['-', '-', '', ''],
|
18982 | NumpadAdd: ['+', '+', '', ''],
|
18983 | IntlBackslash: ['<', '>', '', ''],
|
18984 | },
|
18985 | });
|
18986 | register$1({
|
18987 | id: 'linux.spanish',
|
18988 | locale: 'es',
|
18989 | displayName: 'Spanish',
|
18990 | platform: 'linux',
|
18991 | virtualLayout: 'qwerty',
|
18992 | score: 0,
|
18993 | mapping: {
|
18994 | KeyA: ['a', 'A', 'æ', 'Æ'],
|
18995 | KeyB: ['b', 'B', '”', '’'],
|
18996 | KeyC: ['c', 'C', '¢', '©'],
|
18997 | KeyD: ['d', 'D', 'ð', 'Ð'],
|
18998 | KeyE: ['e', 'E', '€', '¢'],
|
18999 | KeyF: ['f', 'F', 'đ', 'ª'],
|
19000 | KeyG: ['g', 'G', 'ŋ', 'Ŋ'],
|
19001 | KeyH: ['h', 'H', 'ħ', 'Ħ'],
|
19002 | KeyI: ['i', 'I', '→', 'ı'],
|
19003 | KeyJ: ['j', 'J', '̉', '̛'],
|
19004 | KeyK: ['k', 'K', 'ĸ', '&'],
|
19005 | KeyL: ['l', 'L', 'ł', 'Ł'],
|
19006 | KeyM: ['m', 'M', 'µ', 'º'],
|
19007 | KeyN: ['n', 'N', 'n', 'N'],
|
19008 | KeyO: ['o', 'O', 'ø', 'Ø'],
|
19009 | KeyP: ['p', 'P', 'þ', 'Þ'],
|
19010 | KeyQ: ['q', 'Q', '@', 'Ω'],
|
19011 | KeyR: ['r', 'R', '¶', '®'],
|
19012 | KeyS: ['s', 'S', 'ß', '§'],
|
19013 | KeyT: ['t', 'T', 'ŧ', 'Ŧ'],
|
19014 | KeyU: ['u', 'U', '↓', '↑'],
|
19015 | KeyV: ['v', 'V', '“', '‘'],
|
19016 | KeyW: ['w', 'W', 'ł', 'Ł'],
|
19017 | KeyX: ['x', 'X', '»', '>'],
|
19018 | KeyY: ['y', 'Y', '←', '¥'],
|
19019 | KeyZ: ['z', 'Z', '«', '<'],
|
19020 | Digit1: ['1', '!', '|', '¡'],
|
19021 | Digit2: ['2', '"', '@', '⅛'],
|
19022 | Digit3: ['3', '·', '#', '£'],
|
19023 | Digit4: ['4', '$', '~', '$'],
|
19024 | Digit5: ['5', '%', '½', '⅜'],
|
19025 | Digit6: ['6', '&', '¬', '⅝'],
|
19026 | Digit7: ['7', '/', '{', '⅞'],
|
19027 | Digit8: ['8', '(', '[', '™'],
|
19028 | Digit9: ['9', ')', ']', '±'],
|
19029 | Digit0: ['0', '=', '}', '°'],
|
19030 | Enter: ['\r', '\r', '\r', '\r'],
|
19031 | Escape: ['\u001B', '\u001B', '\u001B', '\u001B'],
|
19032 | Backspace: ['\b', '\b', '\b', '\b'],
|
19033 | Tab: ['\t', '', '\t', ''],
|
19034 | Space: [' ', ' ', ' ', ' '],
|
19035 | Minus: ["'", '?', '\\', '¿'],
|
19036 | Equal: ['¡', '¿', '̃', '~'],
|
19037 | BracketLeft: ['̀', '̂', '[', '̊'],
|
19038 | BracketRight: ['+', '*', ']', '̄'],
|
19039 | Backslash: ['ç', 'Ç', '}', '̆'],
|
19040 | Semicolon: ['ñ', 'Ñ', '~', '̋'],
|
19041 | Quote: ['́', '̈', '{', '{'],
|
19042 | Backquote: ['º', 'ª', '\\', '\\'],
|
19043 | Comma: [',', ';', '─', '×'],
|
19044 | Period: ['.', ':', '·', '÷'],
|
19045 | Slash: ['-', '_', '̣', '̇'],
|
19046 | NumpadDivide: ['/', '/', '/', '/'],
|
19047 | NumpadMultiply: ['*', '*', '*', '*'],
|
19048 | NumpadSubtract: ['-', '-', '-', '-'],
|
19049 | NumpadAdd: ['+', '+', '+', '+'],
|
19050 | NumpadEnter: ['\r', '\r', '\r', '\r'],
|
19051 | Numpad1: ['', '1', '', '1'],
|
19052 | Numpad2: ['', '2', '', '2'],
|
19053 | Numpad3: ['', '3', '', '3'],
|
19054 | Numpad4: ['', '4', '', '4'],
|
19055 | Numpad5: ['', '5', '', '5'],
|
19056 | Numpad6: ['', '6', '', '6'],
|
19057 | Numpad7: ['', '7', '', '7'],
|
19058 | Numpad8: ['', '8', '', '8'],
|
19059 | Numpad9: ['', '9', '', '9'],
|
19060 | Numpad0: ['', '0', '', '0'],
|
19061 | NumpadDecimal: ['', '.', '', '.'],
|
19062 | IntlBackslash: ['<', '>', '|', '¦'],
|
19063 | NumpadEqual: ['=', '=', '=', '='],
|
19064 | NumpadComma: ['.', '.', '.', '.'],
|
19065 | NumpadParenLeft: ['(', '(', '(', '('],
|
19066 | NumpadParenRight: [')', ')', ')', ')'],
|
19067 | },
|
19068 | });
|
19069 | register$1({
|
19070 | id: 'linux.french',
|
19071 | locale: 'fr',
|
19072 | displayName: 'French',
|
19073 | virtualLayout: 'azerty',
|
19074 | platform: 'linux',
|
19075 | score: 0,
|
19076 | mapping: {
|
19077 | KeyA: ['q', 'Q', '@', 'Ω'],
|
19078 | KeyB: ['b', 'B', '”', '’'],
|
19079 | KeyC: ['c', 'C', '¢', '©'],
|
19080 | KeyD: ['d', 'D', 'ð', 'Ð'],
|
19081 | KeyE: ['e', 'E', '€', '¢'],
|
19082 | KeyF: ['f', 'F', 'đ', 'ª'],
|
19083 | KeyG: ['g', 'G', 'ŋ', 'Ŋ'],
|
19084 | KeyH: ['h', 'H', 'ħ', 'Ħ'],
|
19085 | KeyI: ['i', 'I', '→', 'ı'],
|
19086 | KeyJ: ['j', 'J', '̉', '̛'],
|
19087 | KeyK: ['k', 'K', 'ĸ', '&'],
|
19088 | KeyL: ['l', 'L', 'ł', 'Ł'],
|
19089 | KeyM: [',', '?', '́', '̋'],
|
19090 | KeyN: ['n', 'N', 'n', 'N'],
|
19091 | KeyO: ['o', 'O', 'ø', 'Ø'],
|
19092 | KeyP: ['p', 'P', 'þ', 'Þ'],
|
19093 | KeyQ: ['a', 'A', 'æ', 'Æ'],
|
19094 | KeyR: ['r', 'R', '¶', '®'],
|
19095 | KeyS: ['s', 'S', 'ß', '§'],
|
19096 | KeyT: ['t', 'T', 'ŧ', 'Ŧ'],
|
19097 | KeyU: ['u', 'U', '↓', '↑'],
|
19098 | KeyV: ['v', 'V', '“', '‘'],
|
19099 | KeyW: ['z', 'Z', '«', '<'],
|
19100 | KeyX: ['x', 'X', '»', '>'],
|
19101 | KeyY: ['y', 'Y', '←', '¥'],
|
19102 | KeyZ: ['w', 'W', 'ł', 'Ł'],
|
19103 | Digit1: ['&', '1', '¹', '¡'],
|
19104 | Digit2: ['é', '2', '~', '⅛'],
|
19105 | Digit3: ['"', '3', '#', '£'],
|
19106 | Digit4: ["'", '4', '{', '$'],
|
19107 | Digit5: ['(', '5', '[', '⅜'],
|
19108 | Digit6: ['-', '6', '|', '⅝'],
|
19109 | Digit7: ['è', '7', '`', '⅞'],
|
19110 | Digit8: ['_', '8', '\\', '™'],
|
19111 | Digit9: ['ç', '9', '^', '±'],
|
19112 | Digit0: ['à', '0', '@', '°'],
|
19113 | Enter: ['\r', '\r', '\r', '\r'],
|
19114 | Escape: ['\u001B', '\u001B', '\u001B', '\u001B'],
|
19115 | Backspace: ['\b', '\b', '\b', '\b'],
|
19116 | Tab: ['\t', '', '\t', ''],
|
19117 | Space: [' ', ' ', ' ', ' '],
|
19118 | Minus: [')', '°', ']', '¿'],
|
19119 | Equal: ['=', '+', '}', '̨'],
|
19120 | BracketLeft: ['̂', '̈', '̈', '̊'],
|
19121 | BracketRight: ['$', '£', '¤', '̄'],
|
19122 | Backslash: ['*', 'µ', '̀', '̆'],
|
19123 | Semicolon: ['m', 'M', 'µ', 'º'],
|
19124 | Quote: ['ù', '%', '̂', '̌'],
|
19125 | Backquote: ['²', '~', '¬', '¬'],
|
19126 | Comma: [';', '.', '─', '×'],
|
19127 | Period: [':', '/', '·', '÷'],
|
19128 | Slash: ['!', '§', '̣', '̇'],
|
19129 | NumpadMultiply: ['*', '*', '*', '*'],
|
19130 | NumpadSubtract: ['-', '-', '-', '-'],
|
19131 | NumpadAdd: ['+', '+', '+', '+'],
|
19132 | NumpadDecimal: ['', '.', '', '.'],
|
19133 | IntlBackslash: ['<', '>', '|', '¦'],
|
19134 | },
|
19135 | });
|
19136 | register$1({
|
19137 | id: 'windows.french',
|
19138 | locale: 'fr',
|
19139 | displayName: 'French',
|
19140 | virtualLayout: 'azerty',
|
19141 | platform: 'windows',
|
19142 | score: 0,
|
19143 | mapping: {
|
19144 | KeyA: ['q', 'Q', '', ''],
|
19145 | KeyB: ['b', 'B', '', ''],
|
19146 | KeyC: ['c', 'C', '', ''],
|
19147 | KeyD: ['d', 'D', '', ''],
|
19148 | KeyE: ['e', 'E', '€', ''],
|
19149 | KeyF: ['f', 'F', '', ''],
|
19150 | KeyG: ['g', 'G', '', ''],
|
19151 | KeyH: ['h', 'H', '', ''],
|
19152 | KeyI: ['i', 'I', '', ''],
|
19153 | KeyJ: ['j', 'J', '', ''],
|
19154 | KeyK: ['k', 'K', '', ''],
|
19155 | KeyL: ['l', 'L', '', ''],
|
19156 | KeyM: [',', '?', '', ''],
|
19157 | KeyN: ['n', 'N', '', ''],
|
19158 | KeyO: ['o', 'O', '', ''],
|
19159 | KeyP: ['p', 'P', '', ''],
|
19160 | KeyQ: ['a', 'A', '', ''],
|
19161 | KeyR: ['r', 'R', '', ''],
|
19162 | KeyS: ['s', 'S', '', ''],
|
19163 | KeyT: ['t', 'T', '', ''],
|
19164 | KeyU: ['u', 'U', '', ''],
|
19165 | KeyV: ['v', 'V', '', ''],
|
19166 | KeyW: ['z', 'Z', '', ''],
|
19167 | KeyX: ['x', 'X', '', ''],
|
19168 | KeyY: ['y', 'Y', '', ''],
|
19169 | KeyZ: ['w', 'W', '', ''],
|
19170 | Digit1: ['&', '1', '', ''],
|
19171 | Digit2: ['é', '2', '~', ''],
|
19172 | Digit3: ['"', '3', '#', ''],
|
19173 | Digit4: ["'", '4', '{', ''],
|
19174 | Digit5: ['(', '5', '[', ''],
|
19175 | Digit6: ['-', '6', '|', ''],
|
19176 | Digit7: ['è', '7', '`', ''],
|
19177 | Digit8: ['_', '8', '\\', ''],
|
19178 | Digit9: ['ç', '9', '^', ''],
|
19179 | Digit0: ['à', '0', '@', ''],
|
19180 | Space: [' ', ' ', '', ''],
|
19181 | Minus: [')', '°', ']', ''],
|
19182 | Equal: ['=', '+', '}', ''],
|
19183 | BracketLeft: ['^', '¨', '', ''],
|
19184 | BracketRight: ['$', '£', '¤', ''],
|
19185 | Backslash: ['*', 'µ', '', ''],
|
19186 | Semicolon: ['m', 'M', '', ''],
|
19187 | Quote: ['ù', '%', '', ''],
|
19188 | Backquote: ['²', '', '', ''],
|
19189 | Comma: [';', '.', '', ''],
|
19190 | Period: [':', '/', '', ''],
|
19191 | Slash: ['!', '§', '', ''],
|
19192 | NumpadDivide: ['/', '/', '', ''],
|
19193 | NumpadMultiply: ['*', '*', '', ''],
|
19194 | NumpadSubtract: ['-', '-', '', ''],
|
19195 | NumpadAdd: ['+', '+', '', ''],
|
19196 | IntlBackslash: ['<', '>', '', ''],
|
19197 | },
|
19198 | });
|
19199 | register$1({
|
19200 | id: 'windows.german',
|
19201 | locale: 'de',
|
19202 | displayName: 'German',
|
19203 | platform: 'windows',
|
19204 | virtualLayout: 'qwertz',
|
19205 | score: 0,
|
19206 | mapping: {
|
19207 | KeyA: ['a', 'A', '', ''],
|
19208 | KeyB: ['b', 'B', '', ''],
|
19209 | KeyC: ['c', 'C', '', ''],
|
19210 | KeyD: ['d', 'D', '', ''],
|
19211 | KeyE: ['e', 'E', '€', ''],
|
19212 | KeyF: ['f', 'F', '', ''],
|
19213 | KeyG: ['g', 'G', '', ''],
|
19214 | KeyH: ['h', 'H', '', ''],
|
19215 | KeyI: ['i', 'I', '', ''],
|
19216 | KeyJ: ['j', 'J', '', ''],
|
19217 | KeyK: ['k', 'K', '', ''],
|
19218 | KeyL: ['l', 'L', '', ''],
|
19219 | KeyM: ['m', 'M', 'µ', ''],
|
19220 | KeyN: ['n', 'N', '', ''],
|
19221 | KeyO: ['o', 'O', '', ''],
|
19222 | KeyP: ['p', 'P', '', ''],
|
19223 | KeyQ: ['q', 'Q', '@', ''],
|
19224 | KeyR: ['r', 'R', '', ''],
|
19225 | KeyS: ['s', 'S', '', ''],
|
19226 | KeyT: ['t', 'T', '', ''],
|
19227 | KeyU: ['u', 'U', '', ''],
|
19228 | KeyV: ['v', 'V', '', ''],
|
19229 | KeyW: ['w', 'W', '', ''],
|
19230 | KeyX: ['x', 'X', '', ''],
|
19231 | KeyY: ['z', 'Z', '', ''],
|
19232 | KeyZ: ['y', 'Y', '', ''],
|
19233 | Digit1: ['1', '!', '', ''],
|
19234 | Digit2: ['2', '"', '²', ''],
|
19235 | Digit3: ['3', '§', '³', ''],
|
19236 | Digit4: ['4', '$', '', ''],
|
19237 | Digit5: ['5', '%', '', ''],
|
19238 | Digit6: ['6', '&', '', ''],
|
19239 | Digit7: ['7', '/', '{', ''],
|
19240 | Digit8: ['8', '(', '[', ''],
|
19241 | Digit9: ['9', ')', ']', ''],
|
19242 | Digit0: ['0', '=', '}', ''],
|
19243 | Space: [' ', ' ', '', ''],
|
19244 | Minus: ['ß', '?', '\\', 'ẞ'],
|
19245 | Equal: ['´', '`', '', ''],
|
19246 | BracketLeft: ['ü', 'Ü', '', ''],
|
19247 | BracketRight: ['+', '*', '~', ''],
|
19248 | Backslash: ['#', "'", '', ''],
|
19249 | Semicolon: ['ö', 'Ö', '', ''],
|
19250 | Quote: ['ä', 'Ä', '', ''],
|
19251 | Backquote: ['^', '°', '', ''],
|
19252 | Comma: [',', ';', '', ''],
|
19253 | Period: ['.', ':', '', ''],
|
19254 | Slash: ['-', '_', '', ''],
|
19255 | NumpadDivide: ['/', '/', '', ''],
|
19256 | NumpadMultiply: ['*', '*', '', ''],
|
19257 | NumpadSubtract: ['-', '-', '', ''],
|
19258 | NumpadAdd: ['+', '+', '', ''],
|
19259 | IntlBackslash: ['<', '>', '|', ''],
|
19260 | },
|
19261 | });
|
19262 | register$1({
|
19263 | id: 'apple.german',
|
19264 | locale: 'de',
|
19265 | displayName: 'German',
|
19266 | virtualLayout: 'qwertz',
|
19267 | platform: 'apple',
|
19268 | score: 0,
|
19269 | mapping: {
|
19270 | KeyA: ['a', 'A', 'å', 'Å'],
|
19271 | KeyB: ['b', 'B', '∫', '‹'],
|
19272 | KeyC: ['c', 'C', 'ç', 'Ç'],
|
19273 | KeyD: ['d', 'D', '∂', '™'],
|
19274 | KeyE: ['e', 'E', '€', '‰'],
|
19275 | KeyF: ['f', 'F', 'ƒ', 'Ï'],
|
19276 | KeyG: ['g', 'G', '©', 'Ì'],
|
19277 | KeyH: ['h', 'H', 'ª', 'Ó'],
|
19278 | KeyI: ['i', 'I', '⁄', 'Û'],
|
19279 | KeyJ: ['j', 'J', 'º', 'ı'],
|
19280 | KeyK: ['k', 'K', '∆', 'ˆ'],
|
19281 | KeyL: ['l', 'L', '@', 'fl'],
|
19282 | KeyM: ['m', 'M', 'µ', '˘'],
|
19283 | KeyN: ['n', 'N', '~', '›'],
|
19284 | KeyO: ['o', 'O', 'ø', 'Ø'],
|
19285 | KeyP: ['p', 'P', 'π', '∏'],
|
19286 | KeyQ: ['q', 'Q', '«', '»'],
|
19287 | KeyR: ['r', 'R', '®', '¸'],
|
19288 | KeyS: ['s', 'S', '‚', 'Í'],
|
19289 | KeyT: ['t', 'T', '†', '˝'],
|
19290 | KeyU: ['u', 'U', '¨', 'Á'],
|
19291 | KeyV: ['v', 'V', '√', '◊'],
|
19292 | KeyW: ['w', 'W', '∑', '„'],
|
19293 | KeyX: ['x', 'X', '≈', 'Ù'],
|
19294 | KeyY: ['z', 'Z', 'Ω', 'ˇ'],
|
19295 | KeyZ: ['y', 'Y', '¥', '‡'],
|
19296 | Digit1: ['1', '!', '¡', '¬'],
|
19297 | Digit2: ['2', '"', '“', '”'],
|
19298 | Digit3: ['3', '§', '¶', '#'],
|
19299 | Digit4: ['4', '$', '¢', '£'],
|
19300 | Digit5: ['5', '%', '[', 'fi'],
|
19301 | Digit6: ['6', '&', ']', '^'],
|
19302 | Digit7: ['7', '/', '|', '\\'],
|
19303 | Digit8: ['8', '(', '{', '˜'],
|
19304 | Digit9: ['9', ')', '}', '·'],
|
19305 | Digit0: ['0', '=', '≠', '¯'],
|
19306 | Space: [' ', ' ', ' ', ' '],
|
19307 | Minus: ['ß', '?', '¿', '˙'],
|
19308 | Equal: ['´', '`', "'", '˚'],
|
19309 | BracketLeft: ['ü', 'Ü', '•', '°'],
|
19310 | BracketRight: ['+', '*', '±', ''],
|
19311 | Backslash: ['#', "'", '‘', '’'],
|
19312 | Semicolon: ['ö', 'Ö', 'œ', 'Œ'],
|
19313 | Quote: ['ä', 'Ä', 'æ', 'Æ'],
|
19314 | Backquote: ['<', '>', '≤', '≥'],
|
19315 | Comma: [',', ';', '∞', '˛'],
|
19316 | Period: ['.', ':', '…', '÷'],
|
19317 | Slash: ['-', '_', '–', '—'],
|
19318 | NumpadDivide: ['/', '/', '/', '/'],
|
19319 | NumpadMultiply: ['*', '*', '*', '*'],
|
19320 | NumpadSubtract: ['-', '-', '-', '-'],
|
19321 | NumpadAdd: ['+', '+', '+', '+'],
|
19322 | NumpadDecimal: [',', ',', '.', '.'],
|
19323 | IntlBackslash: ['^', '°', '„', '“'],
|
19324 | NumpadEqual: ['=', '=', '=', '='],
|
19325 | },
|
19326 | });
|
19327 | register$1({
|
19328 | id: 'dvorak',
|
19329 | locale: 'en',
|
19330 | displayName: 'Dvorak',
|
19331 | virtualLayout: 'dvorak',
|
19332 | platform: '',
|
19333 | score: 0,
|
19334 | mapping: {
|
19335 | KeyA: ['a', 'A', 'å', 'Å'],
|
19336 | KeyB: ['x', 'X', '≈', '˛'],
|
19337 | KeyC: ['j', 'J', '∆', 'Ô'],
|
19338 | KeyD: ['e', 'E', '´', '´'],
|
19339 | KeyE: ['.', '>', '≥', '˘'],
|
19340 | KeyF: ['u', 'U', '¨', '¨'],
|
19341 | KeyG: ['i', 'I', 'ˆ', 'ˆ'],
|
19342 | KeyH: ['d', 'D', '∂', 'Î'],
|
19343 | KeyI: ['c', 'C', 'ç', 'Ç'],
|
19344 | KeyJ: ['h', 'H', '˙', 'Ó'],
|
19345 | KeyK: ['t', 'T', '†', 'ˇ'],
|
19346 | KeyL: ['n', 'N', '˜', '˜'],
|
19347 | KeyM: ['m', 'M', 'µ', 'Â'],
|
19348 | KeyN: ['b', 'B', '∫', 'ı'],
|
19349 | KeyO: ['r', 'R', '®', '‰'],
|
19350 | KeyP: ['l', 'L', '¬', 'Ò'],
|
19351 | KeyQ: ["'", '"', 'æ', 'Æ'],
|
19352 | KeyR: ['p', 'P', 'π', '∏'],
|
19353 | KeyS: ['o', 'O', 'ø', 'Ø'],
|
19354 | KeyT: ['y', 'Y', '¥', 'Á'],
|
19355 | KeyU: ['g', 'G', '©', '˝'],
|
19356 | KeyV: ['k', 'K', '˚', ''],
|
19357 | KeyW: [',', '<', '≤', '¯'],
|
19358 | KeyX: ['q', 'Q', 'œ', 'Œ'],
|
19359 | KeyY: ['f', 'F', 'ƒ', 'Ï'],
|
19360 | KeyZ: [';', ':', '…', 'Ú'],
|
19361 | Digit1: ['1', '!', '¡', '⁄'],
|
19362 | Digit2: ['2', '@', '™', '€'],
|
19363 | Digit3: ['3', '#', '£', '‹'],
|
19364 | Digit4: ['4', '$', '¢', '›'],
|
19365 | Digit5: ['5', '%', '∞', 'fi'],
|
19366 | Digit6: ['6', '^', '§', 'fl'],
|
19367 | Digit7: ['7', '&', '¶', '‡'],
|
19368 | Digit8: ['8', '*', '•', '°'],
|
19369 | Digit9: ['9', '(', 'ª', '·'],
|
19370 | Digit0: ['0', ')', 'º', '‚'],
|
19371 | Space: [' ', ' ', ' ', ' '],
|
19372 | Minus: ['[', '{', '“', '”'],
|
19373 | Equal: [']', '}', '‘', '’'],
|
19374 | BracketLeft: ['/', '?', '÷', '¿'],
|
19375 | BracketRight: ['=', '+', '≠', '±'],
|
19376 | Backslash: ['\\', '|', '«', '»'],
|
19377 | Semicolon: ['s', 'S', 'ß', 'Í'],
|
19378 | Quote: ['-', '_', '–', '—'],
|
19379 | Backquote: ['`', '~', '`', '`'],
|
19380 | Comma: ['w', 'W', '∑', '„'],
|
19381 | Period: ['v', 'V', '√', '◊'],
|
19382 | Slash: ['z', 'Z', 'Ω', '¸'],
|
19383 | NumpadDivide: ['/', '/', '/', '/'],
|
19384 | NumpadMultiply: ['*', '*', '*', '*'],
|
19385 | NumpadSubtract: ['-', '-', '-', '-'],
|
19386 | NumpadAdd: ['+', '+', '+', '+'],
|
19387 | Numpad1: ['1', '1', '1', '1'],
|
19388 | Numpad2: ['2', '2', '2', '2'],
|
19389 | Numpad3: ['3', '3', '3', '3'],
|
19390 | Numpad4: ['4', '4', '4', '4'],
|
19391 | Numpad5: ['5', '5', '5', '5'],
|
19392 | Numpad6: ['6', '6', '6', '6'],
|
19393 | Numpad7: ['7', '7', '7', '7'],
|
19394 | Numpad8: ['8', '8', '8', '8'],
|
19395 | Numpad9: ['9', '9', '9', '9'],
|
19396 | Numpad0: ['0', '0', '0', '0'],
|
19397 | NumpadDecimal: ['.', '.', '.', '.'],
|
19398 | IntlBackslash: ['§', '±', '§', '±'],
|
19399 | NumpadEqual: ['=', '=', '=', '='],
|
19400 | AudioVolumeUp: ['', '=', '', '='],
|
19401 | },
|
19402 | });
|
19403 |
|
19404 |
|
19405 |
|
19406 |
|
19407 | function matchPlatform(p) {
|
19408 | if (isBrowser() && navigator.platform && navigator.userAgent) {
|
19409 | const plat = osPlatform();
|
19410 | const isNeg = p.startsWith('!');
|
19411 | const isMatch = p.endsWith(plat);
|
19412 | if (isNeg && !isMatch)
|
19413 | return true;
|
19414 | if (!isNeg && isMatch)
|
19415 | return true;
|
19416 | }
|
19417 | if (p === '!other')
|
19418 | return false;
|
19419 | return p === 'other';
|
19420 | }
|
19421 |
|
19422 |
|
19423 |
|
19424 |
|
19425 |
|
19426 |
|
19427 | function getCommandForKeybinding(keybindings, mode, inKeystroke) {
|
19428 | if (keybindings.length === 0)
|
19429 | return '';
|
19430 |
|
19431 | const keystroke = keystrokeModifiersToString(keystrokeModifiersFromString(inKeystroke));
|
19432 |
|
19433 | for (let i = keybindings.length - 1; i >= 0; i--) {
|
19434 | if (keybindings[i].key === keystroke) {
|
19435 | if (!keybindings[i].ifMode || keybindings[i].ifMode === mode) {
|
19436 | return keybindings[i].command;
|
19437 | }
|
19438 | }
|
19439 | }
|
19440 | return '';
|
19441 | }
|
19442 | function commandToString(command) {
|
19443 | let result = command;
|
19444 | if (isArray(result)) {
|
19445 | result =
|
19446 | result.length > 0 ? result[0] + '(' + result.slice(1).join('') + ')' : '';
|
19447 | }
|
19448 | return result;
|
19449 | }
|
19450 | function getKeybindingsForCommand(keybindings, command) {
|
19451 | let result = [];
|
19452 | if (typeof command === 'string') {
|
19453 | const candidate = REVERSE_KEYBINDINGS[command];
|
19454 | if (isArray(candidate)) {
|
19455 | result = candidate.slice();
|
19456 | }
|
19457 | else if (candidate) {
|
19458 | result.push(candidate);
|
19459 | }
|
19460 | }
|
19461 |
|
19462 |
|
19463 | const normalizedCommand = commandToString(command);
|
19464 | const regex = new RegExp('^' +
|
19465 | normalizedCommand
|
19466 | .replace('\\', '\\\\')
|
19467 | .replace('|', '\\|')
|
19468 | .replace('*', '\\*')
|
19469 | .replace('$', '\\$')
|
19470 | .replace('^', '\\^') +
|
19471 | '([^*a-zA-Z]|$)');
|
19472 | for (const keybinding of keybindings) {
|
19473 | if (regex.test(commandToString(keybinding.command))) {
|
19474 | result.push(keybinding.key);
|
19475 | }
|
19476 | }
|
19477 | return result.map(getKeybindingMarkup);
|
19478 | }
|
19479 |
|
19480 |
|
19481 |
|
19482 |
|
19483 | function getKeybindingMarkup(keystroke) {
|
19484 | var _a;
|
19485 | const useSymbol = /macos|ios|/.test(osPlatform());
|
19486 | const segments = keystroke.split('+');
|
19487 | let result = '';
|
19488 | for (const segment of segments) {
|
19489 | if (!useSymbol && result) {
|
19490 | result += '<span class="ML__shortcut-join">+</span>';
|
19491 | }
|
19492 | if (segment.startsWith('[Key')) {
|
19493 | result += segment.slice(4, 5);
|
19494 | }
|
19495 | else if (segment.startsWith('Key')) {
|
19496 | result += segment.slice(3, 4);
|
19497 | }
|
19498 | else if (segment.startsWith('[Digit')) {
|
19499 | result += segment.slice(6, 7);
|
19500 | }
|
19501 | else if (segment.startsWith('Digit')) {
|
19502 | result += segment.slice(5, 6);
|
19503 | }
|
19504 | else {
|
19505 | result +=
|
19506 | (_a = {
|
19507 | 'cmd': '\u2318',
|
19508 | 'meta': useSymbol ? '\u2318' : 'command',
|
19509 | 'shift': useSymbol ? '\u21E7' : 'shift',
|
19510 | 'alt': useSymbol ? '\u2325' : 'alt',
|
19511 | 'ctrl': useSymbol ? '\u2303' : 'control',
|
19512 | '\n': useSymbol ? '\u23CE' : 'return',
|
19513 | '[return]': useSymbol ? '\u23CE' : 'return',
|
19514 | '[enter]': useSymbol ? '\u2324' : 'enter',
|
19515 | '[tab]': useSymbol ? '\u21E5' : 'tab',
|
19516 |
|
19517 | '[escape]': 'esc',
|
19518 | '[backspace]': useSymbol ? '\u232B' : 'backspace',
|
19519 | '[delete]': useSymbol ? '\u2326' : 'del',
|
19520 | '[pageup]': useSymbol ? '\u21DE' : 'page up',
|
19521 | '[pagedown]': useSymbol ? '\u21DF' : 'page down',
|
19522 | '[home]': useSymbol ? '\u2912' : 'home',
|
19523 | '[end]': useSymbol ? '\u2913' : 'end',
|
19524 | '[space]': 'space',
|
19525 | '[equal]': '=',
|
19526 | '[minus]': '-',
|
19527 | '[comma]': ',',
|
19528 | '[slash]': '/',
|
19529 | '[backslash]': '\\',
|
19530 | '[bracketleft]': '[',
|
19531 | '[bracketright]': ']',
|
19532 | 'semicolon': ';',
|
19533 | 'period': '.',
|
19534 | 'comma': ',',
|
19535 | 'minus': '-',
|
19536 | 'equal': '=',
|
19537 | 'quote': "'",
|
19538 | 'bracketLeft': '[',
|
19539 | 'bracketRight': ']',
|
19540 | 'backslash': '\\',
|
19541 | 'intlbackslash': '\\',
|
19542 | 'backquote': '`',
|
19543 | 'slash': '/',
|
19544 | 'numpadmultiply': '* 🔢',
|
19545 | 'numpaddivide': '/ 🔢',
|
19546 | 'numpadsubtract': '- 🔢',
|
19547 | 'numpadadd': '+ 🔢',
|
19548 | 'numpaddecimal': '. 🔢',
|
19549 | 'numpadcomma': ', 🔢',
|
19550 | 'help': 'help',
|
19551 | 'left': '\u21E0',
|
19552 | 'up': '\u21E1',
|
19553 | 'right': '\u21E2',
|
19554 | 'down': '\u21E3',
|
19555 | '[arrowleft]': '\u21E0',
|
19556 | '[arrowup]': '\u21E1',
|
19557 | '[arrowright]': '\u21E2',
|
19558 | '[arrowdown]': '\u21E3',
|
19559 | '[digit0]': '0',
|
19560 | '[digit1]': '1',
|
19561 | '[digit2]': '2',
|
19562 | '[digit3]': '3',
|
19563 | '[digit4]': '4',
|
19564 | '[digit5]': '5',
|
19565 | '[digit6]': '6',
|
19566 | '[digit7]': '7',
|
19567 | '[digit8]': '8',
|
19568 | '[digit9]': '9',
|
19569 | }[segment.toLowerCase()]) !== null && _a !== void 0 ? _a : segment.toUpperCase();
|
19570 | }
|
19571 | }
|
19572 | return result;
|
19573 | }
|
19574 | function normalizeKeybinding(keybinding, layout) {
|
19575 | if (keybinding.ifPlatform &&
|
19576 | !/^!?(macos|windows|android|ios|chromeos|other)$/.test(keybinding.ifPlatform)) {
|
19577 | throw new Error(`Unexpected platform "${keybinding.ifPlatform}" for keybinding ${keybinding.key}`);
|
19578 | }
|
19579 | if (keybinding.ifLayout !== undefined &&
|
19580 | (layout.score === 0 || !keybinding.ifLayout.includes(layout.id))) {
|
19581 | return undefined;
|
19582 | }
|
19583 | const modifiers = keystrokeModifiersFromString(keybinding.key);
|
19584 | let platform = keybinding.ifPlatform;
|
19585 | if (modifiers.cmd) {
|
19586 | if (platform && platform !== 'macos' && platform !== 'ios') {
|
19587 | throw new Error('Unexpected "cmd" modifier with platform "' +
|
19588 | platform +
|
19589 | '"' +
|
19590 | '\n' +
|
19591 | '"cmd" modifier can only be used with macOS or iOS platform.');
|
19592 | }
|
19593 | if (!platform) {
|
19594 | platform = osPlatform() === 'ios' ? 'ios' : 'macos';
|
19595 | }
|
19596 | modifiers.win = false;
|
19597 | modifiers.cmd = false;
|
19598 | modifiers.meta = true;
|
19599 | }
|
19600 | if (modifiers.win) {
|
19601 | if (platform && platform !== 'windows') {
|
19602 | throw new Error('Unexpected "win" modifier with platform "' +
|
19603 | platform +
|
19604 | '"' +
|
19605 | '\n' +
|
19606 | '"win" modifier can only be used with Windows platform.');
|
19607 | }
|
19608 | platform = 'windows';
|
19609 | modifiers.win = false;
|
19610 | modifiers.cmd = false;
|
19611 | modifiers.meta = true;
|
19612 | }
|
19613 | if (platform && !matchPlatform(platform))
|
19614 | return undefined;
|
19615 | if (!/^\[(.*)]$/.test(modifiers.key)) {
|
19616 |
|
19617 |
|
19618 | const code = getCodeForKey(modifiers.key, layout);
|
19619 | if (!code) {
|
19620 | throw new Error('Invalid keybinding key "' + keybinding.key + '"');
|
19621 | }
|
19622 | if ((code.shift && modifiers.shift) || (code.alt && modifiers.alt)) {
|
19623 | throw new Error(`The keybinding ${keybinding.key} (${selectorToString(keybinding.command)}) is conflicting with the key combination ${keystrokeModifiersToString(code)} using the ${layout.displayName} keyboard layout`);
|
19624 | }
|
19625 | code.shift = code.shift || modifiers.shift;
|
19626 | code.alt = code.alt || modifiers.alt;
|
19627 | code.meta = modifiers.meta;
|
19628 | code.ctrl = modifiers.ctrl;
|
19629 | return {
|
19630 | ...keybinding,
|
19631 | ifPlatform: platform,
|
19632 | key: keystrokeModifiersToString(code),
|
19633 | };
|
19634 | }
|
19635 | return {
|
19636 | ...keybinding,
|
19637 | ifPlatform: platform,
|
19638 | key: keystrokeModifiersToString(modifiers),
|
19639 | };
|
19640 | }
|
19641 | function selectorToString(selector) {
|
19642 | if (Array.isArray(selector)) {
|
19643 | const sel = [...selector];
|
19644 | return (sel.shift() +
|
19645 | '(' +
|
19646 | sel
|
19647 | .map((x) => (typeof x === 'string' ? `"${x}"` : x.toString()))
|
19648 | .join(', ') +
|
19649 | ')');
|
19650 | }
|
19651 | return selector;
|
19652 | }
|
19653 |
|
19654 |
|
19655 |
|
19656 |
|
19657 |
|
19658 | function normalizeKeybindings(keybindings, layout, onError) {
|
19659 | const result = [];
|
19660 | const errors = [];
|
19661 | for (const x of keybindings) {
|
19662 | try {
|
19663 | const keybinding = normalizeKeybinding(x, layout);
|
19664 | if (keybinding) {
|
19665 | const matches = result.filter((x) => x.key === keybinding.key && x.ifMode === keybinding.ifMode);
|
19666 | if (matches.length > 0) {
|
19667 | throw new Error(`Ambiguous key binding ${x.key} (${selectorToString(x.command)}) matches ${matches[0].key} (${selectorToString(matches[0].command)}) with the ${layout.displayName} keyboard layout`);
|
19668 | }
|
19669 | result.push(keybinding);
|
19670 | }
|
19671 | }
|
19672 | catch (error) {
|
19673 | if (error instanceof Error) {
|
19674 | errors.push(error.message);
|
19675 | }
|
19676 | }
|
19677 | }
|
19678 | if (errors.length > 0)
|
19679 | onError(errors);
|
19680 | return result;
|
19681 | }
|
19682 |
|
19683 | const SPECIAL_IDENTIFIERS = {
|
19684 | '\u2212': '-',
|
19685 | '-': '-',
|
19686 | '\\alpha': 'alpha',
|
19687 | '\\beta': 'beta',
|
19688 | '\\gamma': 'gamma',
|
19689 | '\\delta': 'delta',
|
19690 | '\\epsilon': 'epsilon',
|
19691 | '\\varepsilon': 'varepsilon',
|
19692 | '\\zeta': 'zeta',
|
19693 | '\\eta': 'eta',
|
19694 | '\\theta': 'theta',
|
19695 | '\\vartheta': 'vartheta',
|
19696 | '\\iota': 'iota',
|
19697 | '\\kappa': 'kappa',
|
19698 | '\\lambda': 'lambda',
|
19699 | '\\mu': 'mu',
|
19700 | '\\nu': 'nu',
|
19701 | '\\xi': 'xi',
|
19702 | '\\pi': 'pi',
|
19703 | '\\rho': 'rho',
|
19704 | '\\sigma': 'sigma',
|
19705 | '\\tau': 'tau',
|
19706 | '\\upsilon': 'upsilon',
|
19707 | '\\phi': 'phi',
|
19708 | '\\varphi': 'varphi',
|
19709 | '\\chi': 'chi',
|
19710 | '\\psi': 'psi',
|
19711 | '\\omega': 'omega',
|
19712 | '\\Gamma': 'Gamma',
|
19713 | '\\Delta': 'Delta',
|
19714 | '\\Theta': 'Theta',
|
19715 | '\\Lambda': 'Lambda',
|
19716 | '\\Xi': 'Xi',
|
19717 | '\\Pi': 'Pi',
|
19718 | '\\Sigma': 'Sigma',
|
19719 | '\\Phi': 'Phi',
|
19720 | '\\Psi': 'Psi',
|
19721 | '\\Omega': 'Omega',
|
19722 | '\\exponentialE': 'e',
|
19723 | '\\imaginaryI': 'i',
|
19724 | '\\imaginaryJ': 'j',
|
19725 | };
|
19726 | const SPECIAL_OPERATORS$1 = {
|
19727 | '\\pm': '+-',
|
19728 | '\\times': 'xx',
|
19729 | '\\colon': ':',
|
19730 | '\\vert': '|',
|
19731 | '\\Vert': '||',
|
19732 | '\\mid': '|',
|
19733 | '\\lbrace': '{',
|
19734 | '\\rbrace': '}',
|
19735 | '\\lparen': '(',
|
19736 | '\\rparen': ')',
|
19737 | '\\langle': '(:',
|
19738 | '\\rangle': ':)',
|
19739 |
|
19740 |
|
19741 |
|
19742 |
|
19743 |
|
19744 |
|
19745 |
|
19746 |
|
19747 |
|
19748 |
|
19749 |
|
19750 |
|
19751 |
|
19752 |
|
19753 | };
|
19754 | function atomToAsciiMath(atom) {
|
19755 | var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
19756 | if (!atom)
|
19757 | return '';
|
19758 | if (isArray(atom)) {
|
19759 | let result = '';
|
19760 | if (atom.length === 0)
|
19761 | return '';
|
19762 | if (atom[0].type === 'first')
|
19763 | atom = atom.slice(1);
|
19764 | if (atom.length === 0)
|
19765 | return '';
|
19766 | if (atom[0].mode === 'text') {
|
19767 |
|
19768 | let i = 0;
|
19769 | result = '"';
|
19770 | while (((_a = atom[i]) === null || _a === void 0 ? void 0 : _a.mode) === 'text') {
|
19771 | result += atom[i].body ? atomToAsciiMath(atom[i].body) : atom[i].value;
|
19772 | i++;
|
19773 | }
|
19774 | result += '"' + atomToAsciiMath(atom.slice(i));
|
19775 | }
|
19776 | else if (atom[0].mode === 'math') {
|
19777 | let i = 0;
|
19778 | while (atom[i] && atom[i].mode === 'math') {
|
19779 | result += atomToAsciiMath(atom[i]);
|
19780 | i++;
|
19781 | }
|
19782 | result += atomToAsciiMath(atom.slice(i));
|
19783 | }
|
19784 | else {
|
19785 | console.warn('toASCIIMath: Unexpected mode');
|
19786 | }
|
19787 | return result.trim();
|
19788 | }
|
19789 | if (atom.mode === 'text') {
|
19790 | return '"' + atom.value + '"';
|
19791 | }
|
19792 | let result = '';
|
19793 | const { command } = atom;
|
19794 | let m;
|
19795 | switch (atom.type) {
|
19796 | case 'first':
|
19797 | return '';
|
19798 | case 'group':
|
19799 | case 'root':
|
19800 | result = atomToAsciiMath(atom.body);
|
19801 | break;
|
19802 | case 'genfrac':
|
19803 | {
|
19804 | const genfracAtom = atom;
|
19805 | if (genfracAtom.leftDelim || genfracAtom.rightDelim) {
|
19806 | result +=
|
19807 | genfracAtom.leftDelim === '.' || !genfracAtom.leftDelim
|
19808 | ? '{:'
|
19809 | : genfracAtom.leftDelim;
|
19810 | }
|
19811 | if (genfracAtom.hasBarLine) {
|
19812 | result += '(';
|
19813 | result += atomToAsciiMath(genfracAtom.above);
|
19814 | result += ')/(';
|
19815 | result += atomToAsciiMath(genfracAtom.below);
|
19816 | result += ')';
|
19817 | }
|
19818 | else {
|
19819 |
|
19820 | result += '(' + atomToAsciiMath(genfracAtom.above) + '),';
|
19821 | result += '(' + atomToAsciiMath(genfracAtom.below) + ')';
|
19822 | }
|
19823 | if (genfracAtom.leftDelim || genfracAtom.rightDelim) {
|
19824 | result +=
|
19825 | genfracAtom.rightDelim === '.' || !genfracAtom.rightDelim
|
19826 | ? '{:'
|
19827 | : genfracAtom.rightDelim;
|
19828 | }
|
19829 | }
|
19830 | break;
|
19831 | case 'surd':
|
19832 | result += !atom.hasEmptyBranch('above')
|
19833 | ? 'root(' +
|
19834 | atomToAsciiMath(atom.above) +
|
19835 | ')(' +
|
19836 | atomToAsciiMath(atom.body) +
|
19837 | ')'
|
19838 | : 'sqrt(' + atomToAsciiMath(atom.body) + ')';
|
19839 | break;
|
19840 | case 'leftright':
|
19841 | {
|
19842 | const leftrightAtom = atom;
|
19843 | result +=
|
19844 | leftrightAtom.leftDelim === '.' || !leftrightAtom.leftDelim
|
19845 | ? '{:'
|
19846 | : leftrightAtom.leftDelim;
|
19847 | result += atomToAsciiMath(leftrightAtom.body);
|
19848 | result +=
|
19849 | leftrightAtom.rightDelim === '.' || !leftrightAtom.rightDelim
|
19850 | ? ':}'
|
19851 | : leftrightAtom.rightDelim;
|
19852 | }
|
19853 | break;
|
19854 | case 'sizeddelim':
|
19855 | case 'delim':
|
19856 |
|
19857 | break;
|
19858 | case 'overlap':
|
19859 | break;
|
19860 | case 'overunder':
|
19861 | break;
|
19862 | case 'mord':
|
19863 | result =
|
19864 | (_c = (_b = SPECIAL_IDENTIFIERS[command]) !== null && _b !== void 0 ? _b : command) !== null && _c !== void 0 ? _c : (typeof atom.value === 'string' ? atom.value : '');
|
19865 | if (result.startsWith('\\'))
|
19866 | result += ' ';
|
19867 | m = command ? command.match(/{?\\char"([\dabcdefABCDEF]*)}?/) : null;
|
19868 | if (m) {
|
19869 |
|
19870 | result = String.fromCodePoint(Number.parseInt('0x' + m[1]));
|
19871 | }
|
19872 | else if (result.length > 0 && result.startsWith('\\')) {
|
19873 |
|
19874 |
|
19875 | result =
|
19876 | typeof atom.value === 'string'
|
19877 | ? atom.value.charAt(0)
|
19878 | : atom.command;
|
19879 | }
|
19880 | break;
|
19881 | case 'mbin':
|
19882 | case 'mrel':
|
19883 | case 'minner':
|
19884 | result =
|
19885 | (_e = (_d = SPECIAL_IDENTIFIERS[command]) !== null && _d !== void 0 ? _d : SPECIAL_OPERATORS$1[command]) !== null && _e !== void 0 ? _e : atom.value;
|
19886 | break;
|
19887 | case 'mopen':
|
19888 | case 'mclose':
|
19889 | result += atom.value;
|
19890 | break;
|
19891 | case 'mpunct':
|
19892 | result = (_f = SPECIAL_OPERATORS$1[command]) !== null && _f !== void 0 ? _f : command;
|
19893 | break;
|
19894 | case 'mop':
|
19895 | if (atom.value !== '\u200B') {
|
19896 |
|
19897 | result = '';
|
19898 | result +=
|
19899 | command === '\\operatorname'
|
19900 | ? atomToAsciiMath(atom.body)
|
19901 | : (_g = atom.value) !== null && _g !== void 0 ? _g : command;
|
19902 | result += ' ';
|
19903 | }
|
19904 | break;
|
19905 | case 'array':
|
19906 | const array = atom.array;
|
19907 | const environment = atom.environmentName;
|
19908 | const rowDelim = (_h = {
|
19909 | 'bmatrix': ['[', ']'],
|
19910 | 'bmatrix*': ['[', ']'],
|
19911 | }[environment]) !== null && _h !== void 0 ? _h : ['(', ')'];
|
19912 | const rows = [];
|
19913 | for (const row of array) {
|
19914 | const cells = [];
|
19915 | for (const cell of row) {
|
19916 | cells.push(rowDelim[0] + atomToAsciiMath(cell) + rowDelim[1]);
|
19917 | }
|
19918 | rows.push(cells.join(','));
|
19919 | }
|
19920 | const delim = (_j = {
|
19921 | 'bmatrix': ['[', ']'],
|
19922 | 'bmatrix*': ['[', ']'],
|
19923 | 'cases': ['{', ':}'],
|
19924 | }[environment]) !== null && _j !== void 0 ? _j : ['(', ')'];
|
19925 | result = delim[0] + rows.join(',') + delim[1];
|
19926 | break;
|
19927 | case 'box':
|
19928 | break;
|
19929 | case 'spacing':
|
19930 | break;
|
19931 | case 'enclose':
|
19932 | result = '(' + atomToAsciiMath(atom.body) + ')';
|
19933 | break;
|
19934 | case 'space':
|
19935 | result = ' ';
|
19936 | break;
|
19937 | case 'msubsup':
|
19938 | result = '';
|
19939 | break;
|
19940 | case 'macro':
|
19941 | result =
|
19942 | (_l = (_k = SPECIAL_IDENTIFIERS[command]) !== null && _k !== void 0 ? _k : SPECIAL_OPERATORS$1[command]) !== null && _l !== void 0 ? _l : atomToAsciiMath(atom.body);
|
19943 | break;
|
19944 | }
|
19945 |
|
19946 | if (!atom.hasEmptyBranch('subscript')) {
|
19947 | result += '_';
|
19948 | const arg = atomToAsciiMath(atom.subscript);
|
19949 | result += arg.length > 1 ? '(' + arg + ')' : arg;
|
19950 | }
|
19951 | if (!atom.hasEmptyBranch('superscript')) {
|
19952 | result += '^';
|
19953 | const arg = atomToAsciiMath(atom.superscript);
|
19954 | result += arg.length > 1 ? '(' + arg + ')' : arg;
|
19955 | }
|
19956 | return result;
|
19957 | }
|
19958 |
|
19959 |
|
19960 |
|
19961 |
|
19962 |
|
19963 |
|
19964 | function latexToAsciiMath(latex, mode = 'math') {
|
19965 | const root = new Atom('root', { mode: 'math' });
|
19966 | root.body = parseLatex(latex, { parseMode: mode });
|
19967 | return atomToAsciiMath(root);
|
19968 | }
|
19969 | function asciiMathToLatex(ascii) {
|
19970 | return parseMathString(ascii, { format: 'ascii-math' })[1];
|
19971 | }
|
19972 | const MathliveDebug = {
|
19973 | latexToAsciiMath,
|
19974 | asciiMathToLatex,
|
19975 | FUNCTIONS: LEGACY_COMMANDS,
|
19976 | MATH_SYMBOLS,
|
19977 | TEXT_SYMBOLS,
|
19978 | ENVIRONMENTS,
|
19979 | DEFAULT_KEYBINDINGS,
|
19980 | getKeybindingMarkup,
|
19981 | };
|
19982 |
|
19983 | const SPECIAL_OPERATORS = {
|
19984 | '\\pm': '±',
|
19985 | '\\times': '×',
|
19986 | '\\colon': ':',
|
19987 | '\\vert': '|',
|
19988 | '\\Vert': '\u2225',
|
19989 | '\\mid': '\u2223',
|
19990 | '\\lbrace': '{',
|
19991 | '\\rbrace': '}',
|
19992 | '\\lparen': '(',
|
19993 | '\\rparen': ')',
|
19994 | '\\langle': '\u27E8',
|
19995 | '\\rangle': '\u27E9',
|
19996 | '\\lfloor': '\u230A',
|
19997 | '\\rfloor': '\u230B',
|
19998 | '\\lceil': '\u2308',
|
19999 | '\\rceil': '\u2309',
|
20000 | '\\vec': '⃗',
|
20001 | '\\acute': '´',
|
20002 | '\\grave': '`',
|
20003 | '\\dot': '˙',
|
20004 | '\\ddot': '¨',
|
20005 | '\\tilde': '~',
|
20006 | '\\bar': '¯',
|
20007 | '\\breve': '˘',
|
20008 | '\\check': 'ˇ',
|
20009 | '\\hat': '^',
|
20010 | };
|
20011 | const APPLY_FUNCTION = '⁡';
|
20012 | const INVISIBLE_TIMES = '⁢';
|
20013 | function xmlEscape(string) {
|
20014 | return (string
|
20015 |
|
20016 | .replace(/"/g, '"')
|
20017 | .replace(/'/g, ''')
|
20018 | .replace(/</g, '<')
|
20019 | .replace(/>/g, '>'));
|
20020 | }
|
20021 | function makeID(id, options) {
|
20022 | if (!id || !options.generateID)
|
20023 | return '';
|
20024 |
|
20025 |
|
20026 | return ' extid="' + id + '"';
|
20027 | }
|
20028 | function scanIdentifier(stream, final, options) {
|
20029 | let result = false;
|
20030 | final = final || stream.atoms.length;
|
20031 | let mathML = '';
|
20032 | let body = '';
|
20033 | const atom = stream.atoms[stream.index];
|
20034 | if (stream.index < final &&
|
20035 | atom.type === 'mord' &&
|
20036 | !'0123456789,.'.includes(atom.value)) {
|
20037 | body = atomToMathML(atom, options);
|
20038 | stream.index += 1;
|
20039 | }
|
20040 | if (body.length > 0) {
|
20041 | result = true;
|
20042 | mathML = body;
|
20043 | if ((stream.lastType === 'mi' ||
|
20044 | stream.lastType === 'mn' ||
|
20045 | stream.lastType === 'mtext' ||
|
20046 | stream.lastType === 'fence') &&
|
20047 | !/^<mo>(.*)<\/mo>$/.test(mathML)) {
|
20048 | mathML = `<mo>${INVISIBLE_TIMES}</mo>${mathML}`;
|
20049 | }
|
20050 | if (body.endsWith('>f</mi>') || body.endsWith('>g</mi>')) {
|
20051 | mathML += `<mo>${APPLY_FUNCTION}</mo>`;
|
20052 | stream.lastType = 'applyfunction';
|
20053 | }
|
20054 | else {
|
20055 | stream.lastType = /^<mo>(.*)<\/mo>$/.test(mathML) ? 'mo' : 'mi';
|
20056 | }
|
20057 | if (!parseSubsup(body, stream, options)) {
|
20058 | stream.mathML += mathML;
|
20059 | }
|
20060 | }
|
20061 | return result;
|
20062 | }
|
20063 |
|
20064 |
|
20065 |
|
20066 |
|
20067 |
|
20068 |
|
20069 |
|
20070 | function isSuperscriptAtom(stream) {
|
20071 | return (stream.index < stream.atoms.length &&
|
20072 | stream.atoms[stream.index].superscript &&
|
20073 | stream.atoms[stream.index].type === 'msubsup');
|
20074 | }
|
20075 | function isSubscriptAtom(stream) {
|
20076 | return (stream.index < stream.atoms.length &&
|
20077 | stream.atoms[stream.index].subscript &&
|
20078 | stream.atoms[stream.index].type === 'msubsup');
|
20079 | }
|
20080 | function indexOfSuperscriptInNumber(stream) {
|
20081 | let result = -1;
|
20082 | let i = stream.index;
|
20083 | let done = false;
|
20084 | let found = false;
|
20085 | while (i < stream.atoms.length && !done && !found) {
|
20086 | done =
|
20087 | stream.atoms[i].type !== 'mord' ||
|
20088 | !'0123456789,.'.includes(stream.atoms[i].body);
|
20089 | found = !done && stream.atoms[i].superscript;
|
20090 | i++;
|
20091 | }
|
20092 | if (found) {
|
20093 | result = i - 1;
|
20094 | }
|
20095 | return result;
|
20096 | }
|
20097 | function parseSubsup(base, stream, options) {
|
20098 | let result = false;
|
20099 | let mathML = '';
|
20100 | let atom = stream.atoms[stream.index - 1];
|
20101 | if (!atom)
|
20102 | return false;
|
20103 | if (!atom.superscript && !atom.subscript) {
|
20104 | if (isSuperscriptAtom(stream) || isSubscriptAtom(stream)) {
|
20105 | atom = stream.atoms[stream.index];
|
20106 | stream.index += 1;
|
20107 | }
|
20108 | }
|
20109 | if (!atom)
|
20110 | return false;
|
20111 | const superscript = toMathML(atom.superscript, 0, 0, options).mathML;
|
20112 | const subscript = toMathML(atom.subscript, 0, 0, options).mathML;
|
20113 | if (superscript && subscript) {
|
20114 | mathML = `<msubsup>${base}${subscript}${superscript}</msubsup>`;
|
20115 | }
|
20116 | else if (superscript) {
|
20117 | mathML = `<msup>${base}${superscript}</msup>`;
|
20118 | }
|
20119 | else if (subscript) {
|
20120 | mathML = `<msub>${base}${subscript}</msub>`;
|
20121 | }
|
20122 | if (mathML.length > 0) {
|
20123 | result = true;
|
20124 | stream.mathML += mathML;
|
20125 | stream.lastType = '';
|
20126 | }
|
20127 | return result;
|
20128 | }
|
20129 | function scanText(stream, final, options) {
|
20130 | let result = false;
|
20131 | final = final || stream.atoms.length;
|
20132 | const initial = stream.index;
|
20133 | let mathML = '';
|
20134 | while (stream.index < final && stream.atoms[stream.index].mode === 'text') {
|
20135 | mathML += stream.atoms[stream.index].value
|
20136 | ? stream.atoms[stream.index].value
|
20137 | : ' ';
|
20138 | stream.index += 1;
|
20139 | }
|
20140 | if (mathML.length > 0) {
|
20141 | result = true;
|
20142 | mathML =
|
20143 | '<mtext' +
|
20144 | makeID(stream.atoms[initial].id, options) +
|
20145 | '>' +
|
20146 | mathML +
|
20147 | '</mtext>';
|
20148 | stream.mathML += mathML;
|
20149 | stream.lastType = 'mtext';
|
20150 | }
|
20151 | return result;
|
20152 | }
|
20153 | function scanNumber(stream, final, options) {
|
20154 | let result = false;
|
20155 | final = final || stream.atoms.length;
|
20156 | const initial = stream.index;
|
20157 | let mathML = '';
|
20158 | let superscript = indexOfSuperscriptInNumber(stream);
|
20159 | if (superscript >= 0 && superscript < final) {
|
20160 | final = superscript;
|
20161 | }
|
20162 | while (stream.index < final &&
|
20163 | stream.atoms[stream.index].type === 'mord' &&
|
20164 | '0123456789,.'.includes(stream.atoms[stream.index].value)) {
|
20165 | mathML += stream.atoms[stream.index].value;
|
20166 | stream.index += 1;
|
20167 | }
|
20168 | if (mathML.length > 0) {
|
20169 | result = true;
|
20170 | mathML =
|
20171 | '<mn' +
|
20172 | makeID(stream.atoms[initial].id, options) +
|
20173 | '>' +
|
20174 | mathML +
|
20175 | '</mn>';
|
20176 | if (superscript < 0 && isSuperscriptAtom(stream)) {
|
20177 | superscript = stream.index;
|
20178 | stream.index += 1;
|
20179 | }
|
20180 | if (!parseSubsup(mathML, stream, options)) {
|
20181 | stream.mathML += mathML;
|
20182 | stream.lastType = 'mn';
|
20183 | }
|
20184 | }
|
20185 | return result;
|
20186 | }
|
20187 | function scanFence(stream, final, options) {
|
20188 | let result = false;
|
20189 | final = final || stream.atoms.length;
|
20190 | let mathML = '';
|
20191 | let lastType = '';
|
20192 | if (stream.index < final && stream.atoms[stream.index].type === 'mopen') {
|
20193 | let found = false;
|
20194 | let depth = 0;
|
20195 | const openIndex = stream.index;
|
20196 | let closeIndex = -1;
|
20197 | let index = openIndex + 1;
|
20198 | while (index < final && !found) {
|
20199 | if (stream.atoms[index].type === 'mopen') {
|
20200 | depth += 1;
|
20201 | }
|
20202 | else if (stream.atoms[index].type === 'mclose') {
|
20203 | depth -= 1;
|
20204 | }
|
20205 | if (depth === -1) {
|
20206 | found = true;
|
20207 | closeIndex = index;
|
20208 | }
|
20209 | index += 1;
|
20210 | }
|
20211 | if (found) {
|
20212 |
|
20213 | mathML = '<mrow>';
|
20214 | mathML += toMo(stream.atoms[openIndex], options);
|
20215 | mathML += toMathML(stream.atoms, openIndex + 1, closeIndex, options).mathML;
|
20216 |
|
20217 | mathML += toMo(stream.atoms[closeIndex], options);
|
20218 | mathML += '</mrow>';
|
20219 | if (stream.lastType === 'mi' ||
|
20220 | stream.lastType === 'mn' ||
|
20221 | stream.lastType === 'mfrac' ||
|
20222 | stream.lastType === 'fence') {
|
20223 | mathML = `<mo>${INVISIBLE_TIMES}</mo>${mathML}`;
|
20224 | }
|
20225 | stream.index = closeIndex + 1;
|
20226 | if (parseSubsup(mathML, stream, options)) {
|
20227 | result = true;
|
20228 | stream.lastType = '';
|
20229 | mathML = '';
|
20230 | }
|
20231 | lastType = 'fence';
|
20232 | }
|
20233 | }
|
20234 | if (mathML.length > 0) {
|
20235 | result = true;
|
20236 | stream.mathML += mathML;
|
20237 | stream.lastType = lastType;
|
20238 | }
|
20239 | return result;
|
20240 | }
|
20241 | function scanOperator(stream, final, options) {
|
20242 | let result = false;
|
20243 | final = final || stream.atoms.length;
|
20244 | let mathML = '';
|
20245 | let lastType = '';
|
20246 | const atom = stream.atoms[stream.index];
|
20247 | if (stream.index < final && (atom.type === 'mbin' || atom.type === 'mrel')) {
|
20248 | mathML += atomToMathML(stream.atoms[stream.index], options);
|
20249 | stream.index += 1;
|
20250 | lastType = 'mo';
|
20251 | }
|
20252 | else if (stream.index < final && atom.type === 'mop') {
|
20253 |
|
20254 | if (atom.subsupPlacement === 'over-under' &&
|
20255 | (atom.superscript || atom.subscript)) {
|
20256 |
|
20257 | const op = toMo(atom, options);
|
20258 | if (atom.superscript && atom.subscript) {
|
20259 |
|
20260 | mathML += '<munderover>' + op;
|
20261 | mathML += toMathML(atom.subscript, 0, 0, options).mathML;
|
20262 | mathML += toMathML(atom.superscript, 0, 0, options).mathML;
|
20263 | mathML += '</munderover>';
|
20264 | }
|
20265 | else if (atom.superscript) {
|
20266 |
|
20267 | mathML += '<mover>' + op;
|
20268 | mathML += toMathML(atom.superscript, 0, 0, options).mathML;
|
20269 | mathML += '</mover>';
|
20270 | }
|
20271 | else {
|
20272 |
|
20273 | mathML += '<munder>' + op;
|
20274 | mathML += toMathML(atom.subscript, 0, 0, options).mathML;
|
20275 | mathML += '</munder>';
|
20276 | }
|
20277 | lastType = 'mo';
|
20278 | }
|
20279 | else {
|
20280 | const atom = stream.atoms[stream.index];
|
20281 | const isUnit = atom.symbol === '\\operatorname';
|
20282 | const op = isUnit
|
20283 | ? '<mi class="MathML-Unit"' +
|
20284 | makeID(atom.id, options) +
|
20285 | '>' +
|
20286 | toString(atom.value) +
|
20287 | '</mi>'
|
20288 | : toMo(atom, options);
|
20289 | mathML += op;
|
20290 | stream.index += 1;
|
20291 | if (parseSubsup(mathML, stream, options)) {
|
20292 | result = true;
|
20293 | stream.lastType = '';
|
20294 | mathML = '';
|
20295 | }
|
20296 | stream.index -= 1;
|
20297 | if (!isUnit && !/^<mo>(.*)<\/mo>$/.test(op)) {
|
20298 | mathML += `<mo>${APPLY_FUNCTION}</mo>`;
|
20299 |
|
20300 | lastType = 'applyfunction';
|
20301 | }
|
20302 | else {
|
20303 | lastType = isUnit ? 'mi' : 'mo';
|
20304 | }
|
20305 | }
|
20306 |
|
20307 | if ((stream.lastType === 'mi' || stream.lastType === 'mn') &&
|
20308 | !/^<mo>(.*)<\/mo>$/.test(mathML)) {
|
20309 | mathML = `<mo>${INVISIBLE_TIMES}</mo>${mathML}`;
|
20310 | }
|
20311 | stream.index += 1;
|
20312 | }
|
20313 | if (!parseSubsup(mathML, stream, options)) {
|
20314 | if (mathML.length > 0) {
|
20315 | result = true;
|
20316 | stream.mathML += mathML;
|
20317 | stream.lastType = lastType;
|
20318 | }
|
20319 | }
|
20320 | return result;
|
20321 | }
|
20322 |
|
20323 |
|
20324 |
|
20325 |
|
20326 |
|
20327 |
|
20328 |
|
20329 | function toMathML(input, initial, final, options) {
|
20330 | const result = {
|
20331 | atoms: input,
|
20332 | index: initial !== null && initial !== void 0 ? initial : 0,
|
20333 | mathML: '',
|
20334 | lastType: '',
|
20335 | };
|
20336 | if (typeof input === 'number' || typeof input === 'boolean') {
|
20337 | result.mathML = input.toString();
|
20338 | }
|
20339 | else if (typeof input === 'string') {
|
20340 | result.mathML = input;
|
20341 | }
|
20342 | else if (input instanceof Atom) {
|
20343 | result.mathML = atomToMathML(input, options);
|
20344 | }
|
20345 | else if (Array.isArray(input)) {
|
20346 | let count = 0;
|
20347 | final = final ? final : input ? input.length : 0;
|
20348 | while (result.index < final) {
|
20349 | if (scanText(result, final, options) ||
|
20350 | scanNumber(result, final, options) ||
|
20351 | scanIdentifier(result, final, options) ||
|
20352 | scanOperator(result, final, options) ||
|
20353 | scanFence(result, final, options)) {
|
20354 | count += 1;
|
20355 | }
|
20356 | else if (result.index < final) {
|
20357 | let mathML = atomToMathML(result.atoms[result.index], options);
|
20358 | if (result.lastType === 'mn' &&
|
20359 | mathML.length > 0 &&
|
20360 | result.atoms[result.index].type === 'genfrac') {
|
20361 |
|
20362 |
|
20363 | mathML = '<mo>⁤</mo>' + mathML;
|
20364 | }
|
20365 | if (result.atoms[result.index].type === 'genfrac') {
|
20366 | result.lastType = 'mfrac';
|
20367 | }
|
20368 | else {
|
20369 | result.lastType = '';
|
20370 | }
|
20371 | if (mathML.length > 0) {
|
20372 | result.mathML += mathML;
|
20373 | count += 1;
|
20374 | }
|
20375 | result.index += 1;
|
20376 | }
|
20377 | }
|
20378 |
|
20379 | if (count > 1) {
|
20380 | result.mathML = '<mrow>' + result.mathML + '</mrow>';
|
20381 | }
|
20382 | }
|
20383 | return result;
|
20384 | }
|
20385 | function toMo(atom, options) {
|
20386 | let result = '';
|
20387 | const body = toString(atom.value);
|
20388 | if (body) {
|
20389 | result = '<mo' + makeID(atom.id, options) + '>' + body + '</mo>';
|
20390 | }
|
20391 | return result;
|
20392 | }
|
20393 | function toString(atoms) {
|
20394 | if (!atoms)
|
20395 | return '';
|
20396 | if (typeof atoms === 'string')
|
20397 | return xmlEscape(atoms);
|
20398 | if (!Array.isArray(atoms) && typeof atoms.body === 'string') {
|
20399 | return xmlEscape(atoms.body);
|
20400 | }
|
20401 | let result = '';
|
20402 | for (const atom of atoms) {
|
20403 | if (typeof atom.value === 'string') {
|
20404 | result += atom.value;
|
20405 | }
|
20406 | }
|
20407 | return xmlEscape(result);
|
20408 | }
|
20409 |
|
20410 |
|
20411 |
|
20412 |
|
20413 | function atomToMathML(atom, options) {
|
20414 | var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
20415 |
|
20416 | const SVG_CODE_POINTS = {
|
20417 | widehat: '^',
|
20418 | widecheck: 'ˇ',
|
20419 | widetilde: '~',
|
20420 | utilde: '~',
|
20421 | overleftarrow: '\u2190',
|
20422 | underleftarrow: '\u2190',
|
20423 | xleftarrow: '\u2190',
|
20424 | overrightarrow: '\u2192',
|
20425 | underrightarrow: '\u2192',
|
20426 | xrightarrow: '\u2192',
|
20427 | underbrace: '\u23DF',
|
20428 | overbrace: '\u23DE',
|
20429 | overgroup: '\u23E0',
|
20430 | undergroup: '\u23E1',
|
20431 | overleftrightarrow: '\u2194',
|
20432 | underleftrightarrow: '\u2194',
|
20433 | xleftrightarrow: '\u2194',
|
20434 | Overrightarrow: '\u21D2',
|
20435 | xRightarrow: '\u21D2',
|
20436 | overleftharpoon: '\u21BC',
|
20437 | xleftharpoonup: '\u21BC',
|
20438 | overrightharpoon: '\u21C0',
|
20439 | xrightharpoonup: '\u21C0',
|
20440 | xLeftarrow: '\u21D0',
|
20441 | xLeftrightarrow: '\u21D4',
|
20442 | xhookleftarrow: '\u21A9',
|
20443 | xhookrightarrow: '\u21AA',
|
20444 | xmapsto: '\u21A6',
|
20445 | xrightharpoondown: '\u21C1',
|
20446 | xleftharpoondown: '\u21BD',
|
20447 | xrightleftharpoons: '\u21CC',
|
20448 | xleftrightharpoons: '\u21CB',
|
20449 | xtwoheadleftarrow: '\u219E',
|
20450 | xtwoheadrightarrow: '\u21A0',
|
20451 | xlongequal: '=',
|
20452 | xtofrom: '\u21C4',
|
20453 | xrightleftarrows: '\u21C4',
|
20454 | xrightequilibrium: '\u21CC',
|
20455 | xleftequilibrium: '\u21CB',
|
20456 | };
|
20457 | const SPECIAL_IDENTIFIERS = {
|
20458 | '\\exponentialE': 'ⅇ',
|
20459 | '\\imaginaryI': 'ⅈ',
|
20460 | '\\differentialD': 'ⅆ',
|
20461 | '\\capitalDifferentialD': 'ⅅ',
|
20462 | '\\alpha': 'α',
|
20463 | '\\pi': 'π',
|
20464 | '\\infty': '∞',
|
20465 | '\\forall': '∀',
|
20466 | '\\nexists': '∄',
|
20467 | '\\exists': '∃',
|
20468 | '\\hbar': '\u210F',
|
20469 | '\\cdotp': '\u22C5',
|
20470 | '\\ldots': '\u2026',
|
20471 | '\\cdots': '\u22EF',
|
20472 | '\\ddots': '\u22F1',
|
20473 | '\\vdots': '\u22EE',
|
20474 | '\\ldotp': '\u002E',
|
20475 | };
|
20476 | const MATH_VARIANTS = {
|
20477 | cal: 'script',
|
20478 | frak: 'fraktur',
|
20479 | bb: 'double-struck',
|
20480 | scr: 'script',
|
20481 | cmtt: 'monospace',
|
20482 | cmss: 'sans-serif',
|
20483 | };
|
20484 | const SPACING = {
|
20485 | '\\!': -3 / 18,
|
20486 | '\\ ': 6 / 18,
|
20487 | '\\,': 3 / 18,
|
20488 | '\\:': 4 / 18,
|
20489 | '\\;': 5 / 18,
|
20490 | '\\enspace': 0.5,
|
20491 | '\\quad': 1,
|
20492 | '\\qquad': 2,
|
20493 | '\\enskip': 0.5,
|
20494 | };
|
20495 | let result = '';
|
20496 | let sep = '';
|
20497 | let col;
|
20498 | let row;
|
20499 | let i;
|
20500 | let underscript;
|
20501 | let overscript;
|
20502 | let body;
|
20503 | let variant = MATH_VARIANTS[atom.fontFamily || atom.font] || '';
|
20504 | if (variant) {
|
20505 | variant = ' mathvariant="' + variant + '"';
|
20506 | }
|
20507 | const { command } = atom;
|
20508 | if (atom.mode === 'text') {
|
20509 | result = '<mi' + makeID(atom.id, options) + '>' + atom.value + '</mi>';
|
20510 | }
|
20511 | else {
|
20512 | switch (atom.type) {
|
20513 | case 'first':
|
20514 | break;
|
20515 | case 'group':
|
20516 | case 'root':
|
20517 | result = toMathML(atom.body, 0, 0, options).mathML;
|
20518 | break;
|
20519 | case 'array':
|
20520 | if ((atom.leftDelim && atom.leftDelim !== '.') ||
|
20521 | (atom.rightDelim && atom.rightDelim !== '.')) {
|
20522 | result += '<mrow>';
|
20523 | if (atom.leftDelim && atom.leftDelim !== '.') {
|
20524 | result +=
|
20525 | '<mo>' +
|
20526 | (SPECIAL_OPERATORS[atom.leftDelim] || atom.leftDelim) +
|
20527 | '</mo>';
|
20528 | }
|
20529 | }
|
20530 | result += '<mtable';
|
20531 | if (atom.colFormat) {
|
20532 | result += ' columnalign="';
|
20533 | for (i = 0; i < atom.colFormat.length; i++) {
|
20534 | if (atom.colFormat[i].align) {
|
20535 | result +=
|
20536 | { l: 'left', c: 'center', r: 'right' }[atom.colFormat[i].align] + ' ';
|
20537 | }
|
20538 | }
|
20539 | result += '"';
|
20540 | }
|
20541 | result += '>';
|
20542 | for (row = 0; row < atom.array.length; row++) {
|
20543 | result += '<mtr>';
|
20544 | for (col = 0; col < atom.array[row].length; col++) {
|
20545 | result +=
|
20546 | '<mtd>' +
|
20547 | toMathML(atom.array[row][col], 0, 0, options).mathML +
|
20548 | '</mtd>';
|
20549 | }
|
20550 | result += '</mtr>';
|
20551 | }
|
20552 | result += '</mtable>';
|
20553 | if ((atom.leftDelim && atom.leftDelim !== '.') ||
|
20554 | (atom.rightDelim && atom.rightDelim !== '.')) {
|
20555 | if (atom.rightDelim && atom.rightDelim !== '.') {
|
20556 | result +=
|
20557 | '<mo>' +
|
20558 | (SPECIAL_OPERATORS[atom.leftDelim] || atom.rightDelim) +
|
20559 | '</mo>';
|
20560 | }
|
20561 | result += '</mrow>';
|
20562 | }
|
20563 | break;
|
20564 | case 'genfrac':
|
20565 | if (atom.leftDelim || atom.rightDelim) {
|
20566 | result += '<mrow>';
|
20567 | }
|
20568 | if (atom.leftDelim && atom.leftDelim !== '.') {
|
20569 | result +=
|
20570 | '<mo' +
|
20571 | makeID(atom.id, options) +
|
20572 | '>' +
|
20573 | (SPECIAL_OPERATORS[atom.leftDelim] || atom.leftDelim) +
|
20574 | '</mo>';
|
20575 | }
|
20576 | if (atom.hasBarLine) {
|
20577 | result += '<mfrac>';
|
20578 | result +=
|
20579 | toMathML(atom.above, 0, 0, options).mathML || '<mi> </mi>';
|
20580 | result +=
|
20581 | toMathML(atom.below, 0, 0, options).mathML || '<mi> </mi>';
|
20582 | result += '</mfrac>';
|
20583 | }
|
20584 | else {
|
20585 |
|
20586 | result += '<mtable' + makeID(atom.id, options) + '>';
|
20587 | result +=
|
20588 | '<mtr>' + toMathML(atom.above, 0, 0, options).mathML + '</mtr>';
|
20589 | result +=
|
20590 | '<mtr>' + toMathML(atom.below, 0, 0, options).mathML + '</mtr>';
|
20591 | result += '</mtable>';
|
20592 | }
|
20593 | if (atom.rightDelim && atom.rightDelim !== '.') {
|
20594 | result +=
|
20595 | '<mo' +
|
20596 | makeID(atom.id, options) +
|
20597 | '>' +
|
20598 | (SPECIAL_OPERATORS[atom.rightDelim] || atom.rightDelim) +
|
20599 | '</mo>';
|
20600 | }
|
20601 | if (atom.leftDelim || atom.rightDelim) {
|
20602 | result += '</mrow>';
|
20603 | }
|
20604 | break;
|
20605 | case 'surd':
|
20606 | if (!atom.hasEmptyBranch('above')) {
|
20607 | result += '<mroot' + makeID(atom.id, options) + '>';
|
20608 | result += toMathML(atom.body, 0, 0, options).mathML;
|
20609 | result += toMathML(atom.above, 0, 0, options).mathML;
|
20610 | result += '</mroot>';
|
20611 | }
|
20612 | else {
|
20613 | result += '<msqrt' + makeID(atom.id, options) + '>';
|
20614 | result += toMathML(atom.body, 0, 0, options).mathML;
|
20615 | result += '</msqrt>';
|
20616 | }
|
20617 | break;
|
20618 | case 'leftright':
|
20619 |
|
20620 | result = '<mrow>';
|
20621 | if (atom.leftDelim && atom.leftDelim !== '.') {
|
20622 | result +=
|
20623 | '<mo' +
|
20624 | makeID(atom.id, options) +
|
20625 | '>' +
|
20626 | ((_a = SPECIAL_OPERATORS[atom.leftDelim]) !== null && _a !== void 0 ? _a : atom.leftDelim) +
|
20627 | '</mo>';
|
20628 | }
|
20629 | if (atom.body) {
|
20630 | result += toMathML(atom.body, 0, 0, options).mathML;
|
20631 | }
|
20632 | if (atom.rightDelim && atom.rightDelim !== '.') {
|
20633 | result +=
|
20634 | '<mo' +
|
20635 | makeID(atom.id, options) +
|
20636 | '>' +
|
20637 | ((_b = SPECIAL_OPERATORS[atom.rightDelim]) !== null && _b !== void 0 ? _b : atom.rightDelim) +
|
20638 | '</mo>';
|
20639 | }
|
20640 | result += '</mrow>';
|
20641 | break;
|
20642 | case 'sizeddelim':
|
20643 | case 'delim':
|
20644 | result +=
|
20645 | '<mo separator="true"' +
|
20646 | makeID(atom.id, options) +
|
20647 | '>' +
|
20648 | (SPECIAL_OPERATORS[atom.delim] || atom.delim) +
|
20649 | '</mo>';
|
20650 | break;
|
20651 | case 'accent':
|
20652 | result += '<mover accent="true"' + makeID(atom.id, options) + '>';
|
20653 | result += toMathML(atom.body, 0, 0, options).mathML;
|
20654 | result +=
|
20655 | '<mo>' + (SPECIAL_OPERATORS[command] || atom.accent) + '</mo>';
|
20656 | result += '</mover>';
|
20657 | break;
|
20658 | case 'line':
|
20659 | case 'overlap':
|
20660 | break;
|
20661 | case 'overunder':
|
20662 | overscript = atom.above;
|
20663 | underscript = atom.below;
|
20664 | if ((atom.svgAbove || overscript) && (atom.svgBelow || underscript)) {
|
20665 | body = atom.body;
|
20666 | }
|
20667 | else if (overscript && overscript.length > 0) {
|
20668 | body = atom.body;
|
20669 | if ((_d = (_c = atom.body) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.below) {
|
20670 | underscript = atom.body[0].below;
|
20671 | body = atom.body[0].body;
|
20672 | }
|
20673 | else if (((_f = (_e = atom.body) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.type) === 'first' &&
|
20674 | ((_h = (_g = atom.body) === null || _g === void 0 ? void 0 : _g[1]) === null || _h === void 0 ? void 0 : _h.below)) {
|
20675 | underscript = atom.body[1].below;
|
20676 | body = atom.body[1].body;
|
20677 | }
|
20678 | }
|
20679 | else if (underscript && underscript.length > 0) {
|
20680 | body = atom.body;
|
20681 | if ((_k = (_j = atom.body) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.above) {
|
20682 | overscript = atom.body[0].above;
|
20683 | body = atom.body[0].body;
|
20684 | }
|
20685 | else if (((_m = (_l = atom.body) === null || _l === void 0 ? void 0 : _l[0]) === null || _m === void 0 ? void 0 : _m.type) === 'first' &&
|
20686 | ((_p = (_o = atom.body) === null || _o === void 0 ? void 0 : _o[1]) === null || _p === void 0 ? void 0 : _p.above)) {
|
20687 | overscript = atom.body[1].overscript;
|
20688 | body = atom.body[1].body;
|
20689 | }
|
20690 | }
|
20691 | if ((atom.svgAbove || overscript) && (atom.svgBelow || underscript)) {
|
20692 | result += `<munderover ${variant} ${makeID(atom.id, options)}>`;
|
20693 | result +=
|
20694 | SVG_CODE_POINTS[atom.svgBody] ||
|
20695 | toMathML(body, 0, 0, options).mathML;
|
20696 | result +=
|
20697 | SVG_CODE_POINTS[atom.svgBelow] ||
|
20698 | toMathML(underscript, 0, 0, options).mathML;
|
20699 | result +=
|
20700 | SVG_CODE_POINTS[atom.svgAbove] ||
|
20701 | toMathML(overscript, 0, 0, options).mathML;
|
20702 | result += '</munderover>';
|
20703 | }
|
20704 | else if (atom.svgAbove || overscript) {
|
20705 | result +=
|
20706 | `<mover ${variant} ${makeID(atom.id, options)}>` +
|
20707 | (SVG_CODE_POINTS[atom.svgBody] ||
|
20708 | toMathML(body, 0, 0, options).mathML);
|
20709 | result +=
|
20710 | SVG_CODE_POINTS[atom.svgAbove] ||
|
20711 | toMathML(overscript, 0, 0, options).mathML;
|
20712 | result += '</mover>';
|
20713 | }
|
20714 | else if (atom.svgBelow || underscript) {
|
20715 | result +=
|
20716 | `<munder ${variant} ${makeID(atom.id, options)}>` +
|
20717 | (SVG_CODE_POINTS[atom.svgBody] ||
|
20718 | toMathML(body, 0, 0, options).mathML);
|
20719 | result +=
|
20720 | SVG_CODE_POINTS[atom.svgBelow] ||
|
20721 | toMathML(underscript, 0, 0, options).mathML;
|
20722 | result += '</munder>';
|
20723 | }
|
20724 | break;
|
20725 | case 'placeholder':
|
20726 | case 'mord': {
|
20727 | result =
|
20728 | SPECIAL_IDENTIFIERS[command] ||
|
20729 | command ||
|
20730 | (typeof atom.value === 'string' ? atom.value : '');
|
20731 | const m = command
|
20732 | ? command.match(/{?\\char"([\dabcdefABCDEF]*)}?/)
|
20733 | : null;
|
20734 | if (m) {
|
20735 |
|
20736 | result = '&#x' + m[1] + ';';
|
20737 | }
|
20738 | else if (result.length > 0 && result.startsWith('\\')) {
|
20739 |
|
20740 |
|
20741 | if (typeof atom.value === 'string' &&
|
20742 | atom.value.charCodeAt(0) > 255) {
|
20743 | result =
|
20744 | '&#x' +
|
20745 | ('000000' + atom.value.charCodeAt(0).toString(16)).slice(-4) +
|
20746 | ';';
|
20747 | }
|
20748 | else if (typeof atom.value === 'string') {
|
20749 | result = atom.value.charAt(0);
|
20750 | }
|
20751 | else {
|
20752 | console.log('Did not expect this');
|
20753 | result = '';
|
20754 | }
|
20755 | }
|
20756 | const tag = /\d/.test(result) ? 'mn' : 'mi';
|
20757 | result =
|
20758 | '<' +
|
20759 | tag +
|
20760 | variant +
|
20761 | makeID(atom.id, options) +
|
20762 | '>' +
|
20763 | xmlEscape(result) +
|
20764 | '</' +
|
20765 | tag +
|
20766 | '>';
|
20767 | break;
|
20768 | }
|
20769 | case 'mbin':
|
20770 | case 'mrel':
|
20771 | case 'minner':
|
20772 | if (command && SPECIAL_IDENTIFIERS[command]) {
|
20773 |
|
20774 | result =
|
20775 | '<mi' +
|
20776 | makeID(atom.id, options) +
|
20777 | '>' +
|
20778 | SPECIAL_IDENTIFIERS[command] +
|
20779 | '</mi>';
|
20780 | }
|
20781 | else if (command && SPECIAL_OPERATORS[command]) {
|
20782 | result =
|
20783 | '<mo' +
|
20784 | makeID(atom.id, options) +
|
20785 | '>' +
|
20786 | SPECIAL_OPERATORS[command] +
|
20787 | '</mo>';
|
20788 | }
|
20789 | else {
|
20790 | result = toMo(atom, options);
|
20791 | }
|
20792 | break;
|
20793 | case 'mpunct':
|
20794 | result =
|
20795 | '<mo separator="true"' +
|
20796 | makeID(atom.id, options) +
|
20797 | '>' +
|
20798 | (SPECIAL_OPERATORS[command] || command) +
|
20799 | '</mo>';
|
20800 | break;
|
20801 | case 'mop':
|
20802 | if (atom.body !== '\u200B') {
|
20803 |
|
20804 | result = '<mo' + makeID(atom.id, options) + '>';
|
20805 | result +=
|
20806 | command === '\\operatorname' ? atom.body : command || atom.body;
|
20807 | result += '</mo>';
|
20808 | }
|
20809 | break;
|
20810 |
|
20811 |
|
20812 |
|
20813 |
|
20814 |
|
20815 |
|
20816 |
|
20817 |
|
20818 |
|
20819 |
|
20820 | case 'box':
|
20821 | result = '<menclose notation="box"';
|
20822 | if (atom.backgroundcolor) {
|
20823 | result += ' mathbackground="' + atom.backgroundcolor + '"';
|
20824 | }
|
20825 | result +=
|
20826 | makeID(atom.id, options) +
|
20827 | '>' +
|
20828 | toMathML(atom.body, 0, 0, options).mathML +
|
20829 | '</menclose>';
|
20830 | break;
|
20831 | case 'spacing':
|
20832 | result += '<mspace width="' + (SPACING[command] || 0) + 'em"/>';
|
20833 | break;
|
20834 | case 'enclose':
|
20835 | result = '<menclose notation="';
|
20836 | for (const notation in atom.notation) {
|
20837 | if (Object.prototype.hasOwnProperty.call(atom.notation, notation) &&
|
20838 | atom.notation[notation]) {
|
20839 | result += sep + notation;
|
20840 | sep = ' ';
|
20841 | }
|
20842 | }
|
20843 | result +=
|
20844 | makeID(atom.id, options) +
|
20845 | '">' +
|
20846 | toMathML(atom.body, 0, 0, options).mathML +
|
20847 | '</menclose>';
|
20848 | break;
|
20849 | case 'space':
|
20850 | result += ' ';
|
20851 | break;
|
20852 | case 'msubsup':
|
20853 |
|
20854 |
|
20855 |
|
20856 |
|
20857 |
|
20858 |
|
20859 |
|
20860 |
|
20861 |
|
20862 |
|
20863 |
|
20864 |
|
20865 |
|
20866 |
|
20867 | break;
|
20868 | case 'phantom':
|
20869 | break;
|
20870 | case 'composition':
|
20871 | break;
|
20872 | case 'rule':
|
20873 | console.log('In conversion to MathML, unknown type : ' + atom.type);
|
20874 | break;
|
20875 | case 'chem':
|
20876 | break;
|
20877 | case 'mopen':
|
20878 | result += toMo(atom, options);
|
20879 | break;
|
20880 | case 'mclose':
|
20881 | result += toMo(atom, options);
|
20882 | break;
|
20883 | case 'macro':
|
20884 | {
|
20885 | const body = toString(atom.macroLatex);
|
20886 | if (body) {
|
20887 | result += `<mo ${makeID(atom.id, options)}>${body}</mo>`;
|
20888 | }
|
20889 | }
|
20890 | break;
|
20891 | case 'error':
|
20892 | console.log('In conversion to MathML, unknown type : ' + atom.type);
|
20893 | break;
|
20894 | default:
|
20895 | console.log('In conversion to MathML, unknown type : ' + atom.type);
|
20896 | }
|
20897 | }
|
20898 | return result;
|
20899 | }
|
20900 | function atomsToMathML(atoms, options) {
|
20901 | return toMathML(atoms, 0, 0, options).mathML;
|
20902 | }
|
20903 |
|
20904 |
|
20905 |
|
20906 |
|
20907 |
|
20908 |
|
20909 |
|
20910 |
|
20911 |
|
20912 |
|
20913 |
|
20914 |
|
20915 |
|
20916 |
|
20917 |
|
20918 |
|
20919 | const PRONUNCIATION = {
|
20920 | '\\alpha': 'alpha ',
|
20921 | '\\mu': 'mew ',
|
20922 | '\\sigma': 'sigma ',
|
20923 | '\\pi': 'pie ',
|
20924 | '\\imaginaryI': 'eye ',
|
20925 | '\\sum': 'Summation ',
|
20926 | '\\prod': 'Product ',
|
20927 | 'a': '<phoneme alphabet="ipa" ph="eɪ">a</phoneme>',
|
20928 | 'A': 'capital <phoneme alphabet="ipa" ph="eɪ">A</phoneme>',
|
20929 | '+': 'plus ',
|
20930 | '-': 'minus ',
|
20931 | ';': '<break time="150ms"/> semi-colon <break time="150ms"/>',
|
20932 | ',': '<break time="150ms"/> comma <break time="150ms"/>',
|
20933 | '|': '<break time="150ms"/>Vertical bar<break time="150ms"/>',
|
20934 | '(': '<break time="150ms"/>Open paren. <break time="150ms"/>',
|
20935 | ')': '<break time="150ms"/> Close paren. <break time="150ms"/>',
|
20936 | '=': 'equals ',
|
20937 | '<': 'is less than ',
|
20938 | '\\lt': 'is less than ',
|
20939 | '<=': 'is less than or equal to ',
|
20940 | '\\le': 'is less than or equal to ',
|
20941 | '\\gt': 'is greater than ',
|
20942 | '>': 'is greater than ',
|
20943 | '\\ge': 'is greater than or equal to ',
|
20944 | '\\geq': 'is greater than or equal to ',
|
20945 | '\\leq': 'is less than or equal to ',
|
20946 | '!': 'factorial ',
|
20947 | '\\sin': 'sine ',
|
20948 | '\\cos': 'cosine ',
|
20949 | '\u200B': '',
|
20950 | '\u2212': 'minus ',
|
20951 | ':': '<break time="150ms"/> such that <break time="200ms"/> ',
|
20952 | '\\colon': '<break time="150ms"/> such that <break time="200ms"/> ',
|
20953 | '\\hbar': 'etch bar ',
|
20954 | '\\iff': '<break time="200ms"/>if, and only if, <break time="200ms"/>',
|
20955 | '\\Longleftrightarrow': '<break time="200ms"/>if, and only if, <break time="200ms"/>',
|
20956 | '\\land': 'and ',
|
20957 | '\\lor': 'or ',
|
20958 | '\\neg': 'not ',
|
20959 | '\\div': 'divided by ',
|
20960 | '\\forall': 'for all ',
|
20961 | '\\exists': 'there exists ',
|
20962 | '\\nexists': 'there does not exists ',
|
20963 | '\\in': 'element of ',
|
20964 | '\\N': 'the set <break time="150ms"/><say-as interpret-as="character">n</say-as>',
|
20965 | '\\C': 'the set <break time="150ms"/><say-as interpret-as="character">c</say-as>',
|
20966 | '\\Z': 'the set <break time="150ms"/><say-as interpret-as="character">z</say-as>',
|
20967 | '\\Q': 'the set <break time="150ms"/><say-as interpret-as="character">q</say-as>',
|
20968 | '\\infty': 'infinity ',
|
20969 | '\\nabla': 'nabla ',
|
20970 | '\\partial': 'partial derivative of ',
|
20971 | '\\cdot': 'times ',
|
20972 | '\\cdots': 'dot dot dot ',
|
20973 | '\\Rightarrow': 'implies ',
|
20974 | '\\lparen': '<break time="150ms"/>open paren<break time="150ms"/>',
|
20975 | '\\rparen': '<break time="150ms"/>close paren<break time="150ms"/>',
|
20976 | '\\lbrace': '<break time="150ms"/>open brace<break time="150ms"/>',
|
20977 | '\\{': '<break time="150ms"/>open brace<break time="150ms"/>',
|
20978 | '\\rbrace': '<break time="150ms"/>close brace<break time="150ms"/>',
|
20979 | '\\}': '<break time="150ms"/>close brace<break time="150ms"/>',
|
20980 | '\\langle': '<break time="150ms"/>left angle bracket<break time="150ms"/>',
|
20981 | '\\rangle': '<break time="150ms"/>right angle bracket<break time="150ms"/>',
|
20982 | '\\lfloor': '<break time="150ms"/>open floor<break time="150ms"/>',
|
20983 | '\\rfloor': '<break time="150ms"/>close floor<break time="150ms"/>',
|
20984 | '\\lceil': '<break time="150ms"/>open ceiling<break time="150ms"/>',
|
20985 | '\\rceil': '<break time="150ms"/>close ceiling<break time="150ms"/>',
|
20986 | '\\vert': '<break time="150ms"/>vertical bar<break time="150ms"/>',
|
20987 | '\\mvert': '<break time="150ms"/>divides<break time="150ms"/>',
|
20988 | '\\lvert': '<break time="150ms"/>left vertical bar<break time="150ms"/>',
|
20989 | '\\rvert': '<break time="150ms"/>right vertical bar<break time="150ms"/>',
|
20990 |
|
20991 |
|
20992 | '\\lbrack': '<break time="150ms"/> open square bracket <break time="150ms"/>',
|
20993 | '\\rbrack': '<break time="150ms"/> close square bracket <break time="150ms"/>',
|
20994 |
|
20995 |
|
20996 |
|
20997 |
|
20998 | 'mm': 'millimeters',
|
20999 | 'cm': 'centimeters',
|
21000 | 'km': 'kilometers',
|
21001 | 'kg': 'kilograms',
|
21002 | };
|
21003 | function getSpokenName(latex) {
|
21004 | let result = '';
|
21005 | if (latex.startsWith('\\')) {
|
21006 | result = ' ' + latex.replace('\\', '') + ' ';
|
21007 | }
|
21008 | return result;
|
21009 | }
|
21010 | function isAtomic(atoms) {
|
21011 | let count = 0;
|
21012 | if (isArray(atoms)) {
|
21013 | for (const atom of atoms) {
|
21014 | if (atom.type !== 'first') {
|
21015 | count += 1;
|
21016 | }
|
21017 | }
|
21018 | }
|
21019 | return count === 1;
|
21020 | }
|
21021 | function atomicID(atoms) {
|
21022 | if (isArray(atoms)) {
|
21023 | for (const atom of atoms) {
|
21024 | if (atom.type !== 'first' && atom.id) {
|
21025 | return atom.id.toString();
|
21026 | }
|
21027 | }
|
21028 | }
|
21029 | return '';
|
21030 | }
|
21031 | function atomicValue(atoms) {
|
21032 | let result = '';
|
21033 | if (isArray(atoms)) {
|
21034 | for (const atom of atoms) {
|
21035 | if (atom.type !== 'first' && typeof atom.value === 'string') {
|
21036 | result += atom.value;
|
21037 | }
|
21038 | }
|
21039 | }
|
21040 | return result;
|
21041 | }
|
21042 | function atomsAsText(atoms, _options) {
|
21043 | if (!atoms)
|
21044 | return '';
|
21045 | return atoms.map((atom) => atom.value).join('');
|
21046 | }
|
21047 | function atomToSpeakableFragment(mode, atom, options) {
|
21048 | var _a, _b, _c, _d;
|
21049 | function letter(c) {
|
21050 | let result = '';
|
21051 | if (!options.textToSpeechMarkup) {
|
21052 | if (/[a-z]/.test(c)) {
|
21053 | result += " '" + c.toUpperCase() + "'";
|
21054 | }
|
21055 | else if (/[A-Z]/.test(c)) {
|
21056 | result += " 'capital " + c.toUpperCase() + "'";
|
21057 | }
|
21058 | else {
|
21059 | result += c;
|
21060 | }
|
21061 | }
|
21062 | else if (/[a-z]/.test(c)) {
|
21063 | result += ' <say-as interpret-as="character">' + c + '</say-as>';
|
21064 | }
|
21065 | else if (/[A-Z]/.test(c)) {
|
21066 | result += String('capital ' + c.toLowerCase());
|
21067 | }
|
21068 | else {
|
21069 | result += c;
|
21070 | }
|
21071 | return result;
|
21072 | }
|
21073 | function emph(s) {
|
21074 | return '<emphasis>' + s + '</emphasis>';
|
21075 | }
|
21076 | if (!atom)
|
21077 | return '';
|
21078 | let result = '';
|
21079 | if (isArray(atom)) {
|
21080 | let isInDigitRun = false;
|
21081 | let isInTextRun = false;
|
21082 | for (let i = 0; i < atom.length; i++) {
|
21083 | if (atom[i].mode !== 'text') {
|
21084 | isInTextRun = false;
|
21085 | }
|
21086 | if (i < atom.length - 2 &&
|
21087 | atom[i].type === 'mopen' &&
|
21088 | atom[i + 2].type === 'mclose' &&
|
21089 | atom[i + 1].type === 'mord') {
|
21090 | result += ' of ';
|
21091 | result += emph(atomToSpeakableFragment(mode, atom[i + 1], options));
|
21092 | i += 2;
|
21093 | }
|
21094 | else if (atom[i].mode === 'text') {
|
21095 | if (isInTextRun) {
|
21096 | result += (_a = atom[i].value) !== null && _a !== void 0 ? _a : ' ';
|
21097 | }
|
21098 | else {
|
21099 | isInTextRun = true;
|
21100 | result += atomToSpeakableFragment('text', atom[i], options);
|
21101 | }
|
21102 |
|
21103 |
|
21104 |
|
21105 | }
|
21106 | else if (atom[i].type === 'mord' &&
|
21107 | /[0123456789,.]/.test(atom[i].value)) {
|
21108 | if (isInDigitRun) {
|
21109 | result += atom[i].value;
|
21110 | }
|
21111 | else {
|
21112 | isInDigitRun = true;
|
21113 | result += atomToSpeakableFragment(mode, atom[i], options);
|
21114 | }
|
21115 | }
|
21116 | else {
|
21117 | isInDigitRun = false;
|
21118 | result += atomToSpeakableFragment(mode, atom[i], options);
|
21119 | }
|
21120 | }
|
21121 | }
|
21122 | else if (atom.mode === 'text') {
|
21123 | if (atom.id && mode === 'math') {
|
21124 | result += '<mark name="' + atom.id.toString() + '"/>';
|
21125 | }
|
21126 | result += atom.value;
|
21127 | }
|
21128 | else {
|
21129 | if (atom.id && mode === 'math') {
|
21130 | result += '<mark name="' + atom.id.toString() + '"/>';
|
21131 | }
|
21132 | let numer = '';
|
21133 | let denom = '';
|
21134 | let body = '';
|
21135 | let supsubHandled = false;
|
21136 | switch (atom.type) {
|
21137 | case 'group':
|
21138 | case 'root':
|
21139 | result += atomToSpeakableFragment('math', atom.body, options);
|
21140 | break;
|
21141 | case 'genfrac':
|
21142 | numer = atomToSpeakableFragment('math', atom.above, options);
|
21143 | denom = atomToSpeakableFragment('math', atom.below, options);
|
21144 | if (isAtomic(atom.above) && isAtomic(atom.below)) {
|
21145 | const COMMON_FRACTIONS = {
|
21146 | '1/2': ' half ',
|
21147 | '1/3': ' one third ',
|
21148 | '2/3': ' two third',
|
21149 | '1/4': ' one quarter ',
|
21150 | '3/4': ' three quarter ',
|
21151 | '1/5': ' one fifth ',
|
21152 | '2/5': ' two fifths ',
|
21153 | '3/5': ' three fifths ',
|
21154 | '4/5': ' four fifths ',
|
21155 | '1/6': ' one sixth ',
|
21156 | '5/6': ' five sixths ',
|
21157 | '1/8': ' one eight ',
|
21158 | '3/8': ' three eights ',
|
21159 | '5/8': ' five eights ',
|
21160 | '7/8': ' seven eights ',
|
21161 | '1/9': ' one ninth ',
|
21162 | '2/9': ' two ninths ',
|
21163 | '4/9': ' four ninths ',
|
21164 | '5/9': ' five ninths ',
|
21165 | '7/9': ' seven ninths ',
|
21166 | '8/9': ' eight ninths ',
|
21167 |
|
21168 |
|
21169 |
|
21170 | };
|
21171 | const commonFraction = COMMON_FRACTIONS[atomicValue(atom.above) + '/' + atomicValue(atom.below)];
|
21172 | if (commonFraction) {
|
21173 | result = commonFraction;
|
21174 | }
|
21175 | else {
|
21176 | result += numer + ' over ' + denom;
|
21177 | }
|
21178 | }
|
21179 | else {
|
21180 | result +=
|
21181 | ' the fraction <break time="150ms"/>' +
|
21182 | numer +
|
21183 | ', over <break time="150ms"/>' +
|
21184 | denom +
|
21185 | '.<break time="150ms"/> End fraction.<break time="150ms"/>';
|
21186 | }
|
21187 | break;
|
21188 | case 'surd':
|
21189 | body = atomToSpeakableFragment('math', atom.body, options);
|
21190 | if (atom.hasEmptyBranch('above')) {
|
21191 | result += isAtomic(atom.body)
|
21192 | ? ' the square root of ' + body + ' , '
|
21193 | : ' the square root of <break time="200ms"/>' +
|
21194 | body +
|
21195 | '. <break time="200ms"/> End square root';
|
21196 | }
|
21197 | else {
|
21198 | let index = atomToSpeakableFragment('math', atom.above, options);
|
21199 | index = index.trim();
|
21200 | const index2 = index.replace(/<mark([^/]*)\/>/g, '');
|
21201 | if (index2 === '3') {
|
21202 | result +=
|
21203 | ' the cube root of <break time="200ms"/>' +
|
21204 | body +
|
21205 | '. <break time="200ms"/> End cube root';
|
21206 | }
|
21207 | else if (index2 === 'n') {
|
21208 | result +=
|
21209 | ' the nth root of <break time="200ms"/>' +
|
21210 | body +
|
21211 | '. <break time="200ms"/> End root';
|
21212 | }
|
21213 | else {
|
21214 | result +=
|
21215 | ' the root with index: <break time="200ms"/>' +
|
21216 | index +
|
21217 | ', of <break time="200ms"/>' +
|
21218 | body +
|
21219 | '. <break time="200ms"/> End root';
|
21220 | }
|
21221 | }
|
21222 | break;
|
21223 | case 'leftright':
|
21224 | {
|
21225 | const delimAtom = atom;
|
21226 | result +=
|
21227 | (_b = (delimAtom.leftDelim
|
21228 | ? PRONUNCIATION[delimAtom.leftDelim]
|
21229 | : undefined)) !== null && _b !== void 0 ? _b : delimAtom.leftDelim;
|
21230 | result += atomToSpeakableFragment('math', atom.body, options);
|
21231 | result +=
|
21232 | (_c = (delimAtom.rightDelim
|
21233 | ? PRONUNCIATION[delimAtom.rightDelim]
|
21234 | : undefined)) !== null && _c !== void 0 ? _c : delimAtom.rightDelim;
|
21235 | }
|
21236 | break;
|
21237 | case 'rule':
|
21238 |
|
21239 | break;
|
21240 | case 'overunder':
|
21241 |
|
21242 | break;
|
21243 | case 'overlap':
|
21244 |
|
21245 | break;
|
21246 | case 'placeholder':
|
21247 | result += 'placeholder ';
|
21248 | break;
|
21249 | case 'delim':
|
21250 | case 'sizeddelim':
|
21251 | case 'mord':
|
21252 | case 'minner':
|
21253 | case 'mbin':
|
21254 | case 'mrel':
|
21255 | case 'mpunct':
|
21256 | case 'mopen':
|
21257 | case 'mclose': {
|
21258 | const { command } = atom;
|
21259 | if (command === '\\mathbin' ||
|
21260 | command === '\\mathrel' ||
|
21261 | command === '\\mathopen' ||
|
21262 | command === '\\mathclose' ||
|
21263 | command === '\\mathpunct' ||
|
21264 | command === '\\mathord' ||
|
21265 | command === '\\mathinner') {
|
21266 | result = atomToSpeakableFragment(mode, atom.body, options);
|
21267 | break;
|
21268 | }
|
21269 | let atomValue = atom.value;
|
21270 | let latexValue = atom.command;
|
21271 | if (atom.type === 'delim' || atom.type === 'sizeddelim') {
|
21272 | latexValue = atom.value;
|
21273 | atomValue = latexValue;
|
21274 | }
|
21275 | if (mode === 'text') {
|
21276 | result += atomValue;
|
21277 | }
|
21278 | else {
|
21279 | if (atom.type === 'mbin') {
|
21280 | result += '<break time="150ms"/>';
|
21281 | }
|
21282 | if (atomValue) {
|
21283 | const value = PRONUNCIATION[atomValue] ||
|
21284 | (latexValue ? PRONUNCIATION[latexValue.trim()] : '');
|
21285 | if (value) {
|
21286 | result += ' ' + value;
|
21287 | }
|
21288 | else {
|
21289 | const spokenName = latexValue
|
21290 | ? getSpokenName(latexValue.trim())
|
21291 | : '';
|
21292 | result += spokenName ? spokenName : letter(atomValue);
|
21293 | }
|
21294 | }
|
21295 | else {
|
21296 | result += atomToSpeakableFragment('math', atom.body, options);
|
21297 | }
|
21298 | if (atom.type === 'mbin') {
|
21299 | result += '<break time="150ms"/>';
|
21300 | }
|
21301 | }
|
21302 | break;
|
21303 | }
|
21304 | case 'mop':
|
21305 |
|
21306 | if (atom.value !== '\u200B') {
|
21307 |
|
21308 | const trimLatex = atom.command;
|
21309 | if (trimLatex === '\\sum') {
|
21310 | if (!atom.hasEmptyBranch('superscript') &&
|
21311 | !atom.hasEmptyBranch('subscript')) {
|
21312 | let sup = atomToSpeakableFragment('math', atom.superscript, options);
|
21313 | sup = sup.trim();
|
21314 | let sub = atomToSpeakableFragment('math', atom.subscript, options);
|
21315 | sub = sub.trim();
|
21316 | result +=
|
21317 | ' the summation from <break time="200ms"/>' +
|
21318 | sub +
|
21319 | '<break time="200ms"/> to <break time="200ms"/>' +
|
21320 | sup +
|
21321 | '<break time="200ms"/> of <break time="150ms"/>';
|
21322 | supsubHandled = true;
|
21323 | }
|
21324 | else if (!atom.hasEmptyBranch('subscript')) {
|
21325 | let sub = atomToSpeakableFragment('math', atom.subscript, options);
|
21326 | sub = sub.trim();
|
21327 | result +=
|
21328 | ' the summation from <break time="200ms"/>' +
|
21329 | sub +
|
21330 | '<break time="200ms"/> of <break time="150ms"/>';
|
21331 | supsubHandled = true;
|
21332 | }
|
21333 | else {
|
21334 | result += ' the summation of';
|
21335 | }
|
21336 | }
|
21337 | else if (trimLatex === '\\prod') {
|
21338 | if (!atom.hasEmptyBranch('superscript') &&
|
21339 | !atom.hasEmptyBranch('subscript')) {
|
21340 | let sup = atomToSpeakableFragment('math', atom.superscript, options);
|
21341 | sup = sup.trim();
|
21342 | let sub = atomToSpeakableFragment('math', atom.subscript, options);
|
21343 | sub = sub.trim();
|
21344 | result +=
|
21345 | ' the product from <break time="200ms"/>' +
|
21346 | sub +
|
21347 | '<break time="200ms"/> to <break time="200ms"/>' +
|
21348 | sup +
|
21349 | '<break time="200ms"/> of <break time="150ms"/>';
|
21350 | supsubHandled = true;
|
21351 | }
|
21352 | else if (!atom.hasEmptyBranch('subscript')) {
|
21353 | let sub = atomToSpeakableFragment('math', atom.subscript, options);
|
21354 | sub = sub.trim();
|
21355 | result +=
|
21356 | ' the product from <break time="200ms"/>' +
|
21357 | sub +
|
21358 | '<break time="200ms"/> of <break time="150ms"/>';
|
21359 | supsubHandled = true;
|
21360 | }
|
21361 | else {
|
21362 | result += ' the product of ';
|
21363 | }
|
21364 | }
|
21365 | else if (trimLatex === '\\int') {
|
21366 | if (!atom.hasEmptyBranch('superscript') &&
|
21367 | !atom.hasEmptyBranch('subscript')) {
|
21368 | let sup = atomToSpeakableFragment('math', atom.superscript, options);
|
21369 | sup = sup.trim();
|
21370 | let sub = atomToSpeakableFragment('math', atom.subscript, options);
|
21371 | sub = sub.trim();
|
21372 | result +=
|
21373 | ' the integral from <break time="200ms"/>' +
|
21374 | emph(sub) +
|
21375 | '<break time="200ms"/> to <break time="200ms"/>' +
|
21376 | emph(sup) +
|
21377 | ' <break time="200ms"/> of ';
|
21378 | supsubHandled = true;
|
21379 | }
|
21380 | else {
|
21381 | result += ' the integral of <break time="200ms"/> ';
|
21382 | }
|
21383 | }
|
21384 | else if (typeof atom.value === 'string') {
|
21385 | const value = (_d = PRONUNCIATION[atom.value]) !== null && _d !== void 0 ? _d : (atom.command ? PRONUNCIATION[atom.command] : undefined);
|
21386 | result += value ? value : ' ' + atom.value;
|
21387 | }
|
21388 | else if (atom.command) {
|
21389 | if (atom.command === '\\mathop') {
|
21390 | result += atomToSpeakableFragment('math', atom.body, options);
|
21391 | }
|
21392 | else if (atom.command === '\\operatorname') {
|
21393 | result += atomsAsText(atom.body);
|
21394 | }
|
21395 | else {
|
21396 | result += atom.command.startsWith('\\')
|
21397 | ? ' ' + atom.command.slice(1)
|
21398 | : ' ' + atom.command;
|
21399 | }
|
21400 | }
|
21401 | }
|
21402 | break;
|
21403 | case 'enclose':
|
21404 | body = atomToSpeakableFragment('math', atom.body, options);
|
21405 | result += isAtomic(atom.body)
|
21406 | ? ' crossed out ' + body + ' , '
|
21407 | : ' crossed out ' + body + '. End cross out';
|
21408 | break;
|
21409 | }
|
21410 | if (!supsubHandled && !atom.hasEmptyBranch('superscript')) {
|
21411 | let sup = atomToSpeakableFragment(mode, atom.superscript, options);
|
21412 | sup = sup.trim();
|
21413 | const sup2 = sup.replace(/<[^>]*>/g, '');
|
21414 | if (isAtomic(atom.superscript)) {
|
21415 | if (mode === 'math') {
|
21416 | const id = atomicID(atom.superscript);
|
21417 | if (id) {
|
21418 | result += '<mark name="' + id + '"/>';
|
21419 | }
|
21420 | }
|
21421 | if (sup2 === '\u2032') {
|
21422 | result += ' prime ';
|
21423 | }
|
21424 | else if (sup2 === '2') {
|
21425 | result += ' squared ';
|
21426 | }
|
21427 | else if (sup2 === '3') {
|
21428 | result += ' cubed ';
|
21429 | }
|
21430 | else if (Number.isNaN(Number.parseInt(sup2))) {
|
21431 | result += ' to the ' + sup + '; ';
|
21432 | }
|
21433 | else {
|
21434 | result +=
|
21435 | ' to the <say-as interpret-as="ordinal">' +
|
21436 | sup2 +
|
21437 | '</say-as> power; ';
|
21438 | }
|
21439 | }
|
21440 | else if (Number.isNaN(Number.parseInt(sup2))) {
|
21441 | result += ' raised to the ' + sup + '; ';
|
21442 | }
|
21443 | else {
|
21444 | result +=
|
21445 | ' raised to the <say-as interpret-as="ordinal">' +
|
21446 | sup2 +
|
21447 | '</say-as> power; ';
|
21448 | }
|
21449 | }
|
21450 | if (!supsubHandled && !atom.hasEmptyBranch('subscript')) {
|
21451 | let sub = atomToSpeakableFragment('math', atom.subscript, options);
|
21452 | sub = sub.trim();
|
21453 | result += isAtomic(atom.subscript)
|
21454 | ? ' sub ' + sub
|
21455 | : ' subscript ' + sub + '. End subscript. ';
|
21456 | }
|
21457 | }
|
21458 | return result;
|
21459 | }
|
21460 |
|
21461 |
|
21462 |
|
21463 | function atomToSpeakableText(atoms, speechOptions) {
|
21464 | var _a;
|
21465 | const options = {
|
21466 | ...speechOptions,
|
21467 | textToSpeechRulesOptions: { ...speechOptions.textToSpeechRulesOptions },
|
21468 | };
|
21469 | if (window.sre && options.textToSpeechRules === 'sre') {
|
21470 | const mathML = atomsToMathML(atoms, options);
|
21471 | if (mathML) {
|
21472 | if (options.textToSpeechMarkup) {
|
21473 | options.textToSpeechRulesOptions =
|
21474 | (_a = options.textToSpeechRulesOptions) !== null && _a !== void 0 ? _a : {};
|
21475 | options.textToSpeechRulesOptions.markup = options.textToSpeechMarkup;
|
21476 | if (options.textToSpeechRulesOptions.markup === 'ssml') {
|
21477 | options.textToSpeechRulesOptions.markup = 'ssml_step';
|
21478 | }
|
21479 | options.textToSpeechRulesOptions.rate = options.speechEngineRate;
|
21480 | }
|
21481 | if (options.textToSpeechRulesOptions) {
|
21482 | window.sre.System.getInstance().setupEngine(options.textToSpeechRulesOptions);
|
21483 | }
|
21484 | return window.sre.System.getInstance().toSpeech(mathML);
|
21485 | }
|
21486 | return '';
|
21487 | }
|
21488 | let result = atomToSpeakableFragment('math', atoms, options);
|
21489 | if (options.textToSpeechMarkup === 'ssml') {
|
21490 | let prosody = '';
|
21491 | if (options.speechEngineRate) {
|
21492 | prosody = '<prosody rate="' + options.speechEngineRate + '">';
|
21493 | }
|
21494 | result =
|
21495 | `<?xml version="1.0"?><speak version="1.1" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-US">` +
|
21496 | '<amazon:auto-breaths>' +
|
21497 | prosody +
|
21498 | '<p><s>' +
|
21499 | result +
|
21500 | '</s></p>' +
|
21501 | (prosody ? '</prosody>' : '') +
|
21502 | '</amazon:auto-breaths>' +
|
21503 | '</speak>';
|
21504 | }
|
21505 | else if (options.textToSpeechMarkup === 'mac' && osPlatform() === 'macos') {
|
21506 |
|
21507 | result = result
|
21508 | .replace(/<mark([^/]*)\/>/g, '')
|
21509 | .replace(/<emphasis>/g, '[[emph+]]')
|
21510 | .replace(/<\/emphasis>/g, '')
|
21511 | .replace(/<break time="(\d*)ms"\/>/g, '[[slc $1]]')
|
21512 | .replace(/<say-as[^>]*>/g, '')
|
21513 | .replace(/<\/say-as>/g, '');
|
21514 | }
|
21515 | else {
|
21516 |
|
21517 |
|
21518 |
|
21519 | result = result.replace(/<[^>]*>/g, '').replace(/\s{2,}/g, ' ');
|
21520 | }
|
21521 | return result;
|
21522 | }
|
21523 |
|
21524 |
|
21525 |
|
21526 |
|
21527 |
|
21528 |
|
21529 |
|
21530 | const CRYPTIC = 0;
|
21531 | const ARCANE = 200;
|
21532 | const RARE = 1200;
|
21533 | const UNCOMMON = 2000;
|
21534 | const COMMON = 3000;
|
21535 | const SUPERCOMMON = 4000;
|
21536 |
|
21537 |
|
21538 |
|
21539 |
|
21540 |
|
21541 |
|
21542 | function metadata(category, symbols, frequency = COMMON, template = '$0') {
|
21543 | for (const symbol of symbols) {
|
21544 | if (MATH_SYMBOLS[symbol]) {
|
21545 | MATH_SYMBOLS[symbol].frequency = frequency;
|
21546 | MATH_SYMBOLS[symbol].category = category;
|
21547 | MATH_SYMBOLS[symbol].template = template.replace(/\$0/g, symbol);
|
21548 | }
|
21549 | if (LEGACY_COMMANDS[symbol]) {
|
21550 |
|
21551 |
|
21552 | LEGACY_COMMANDS[symbol] = {
|
21553 | ...LEGACY_COMMANDS[symbol],
|
21554 | frequency,
|
21555 | category,
|
21556 | template: template.replace(/\$0/g, symbol),
|
21557 | };
|
21558 | }
|
21559 | }
|
21560 | }
|
21561 | metadata('Trigonometry', ['\\cos', '\\sin', '\\tan'], SUPERCOMMON);
|
21562 | metadata('Trigonometry', [
|
21563 | '\\arcsin',
|
21564 | '\\arccos',
|
21565 | '\\arctan',
|
21566 | '\\arctg',
|
21567 | '\\arcctg',
|
21568 | '\\arcsec',
|
21569 | '\\arccsc',
|
21570 | '\\arsinh',
|
21571 | '\\arcosh',
|
21572 | '\\artanh',
|
21573 | '\\arcsech',
|
21574 | '\\arccsch',
|
21575 | '\\arg',
|
21576 | '\\ch',
|
21577 | '\\cosec',
|
21578 | '\\cosh',
|
21579 | '\\cot',
|
21580 | '\\cotg',
|
21581 | '\\coth',
|
21582 | '\\csc',
|
21583 | '\\ctg',
|
21584 | '\\cth',
|
21585 | '\\lg',
|
21586 | '\\lb',
|
21587 | '\\sec',
|
21588 | '\\sinh',
|
21589 | '\\sh',
|
21590 | '\\tanh',
|
21591 | '\\tg',
|
21592 | '\\th',
|
21593 | ], UNCOMMON);
|
21594 | metadata('Functions', ['\\ln', '\\log', '\\exp', '\\lim'], SUPERCOMMON);
|
21595 | metadata('Functions', ['\\dim', '\\ker', '\\deg', '\\det', '\\mod', '\\min', '\\max'], COMMON);
|
21596 | metadata('Functions', ['\\hom'], RARE);
|
21597 | metadata('Decoration', ['\\rule'], ARCANE, '$0{2em}{1em}');
|
21598 | metadata('Decoration', ['\\color', '\\textcolor'], ARCANE, '{$0{m0}A}{$0{m1}B}{$0{m2}C }{$0{m3}a}{$0{m4}b}{$0{m5}c}{$0{m6}8}');
|
21599 | metadata('Decoration', ['\\overline', '\\underline'], COMMON, '$0{\\placeholder{}}');
|
21600 | metadata('Decoration', ['\\enclose'], RARE, '\\enclose{updiagonalstrike,roundedbox}[1px solid red, mathbackground="#fbc0bd"]{x=0}');
|
21601 | metadata('Decoration', ['\\fcolorbox'], RARE, '\\fcolorbox{#cd0030}{#ffd400}{\\unicode{"2B1A}}');
|
21602 | metadata('Decoration', ['\\colorbox'], RARE, '\\colorbox{#fbc0bd}{\\unicode{"2B1A}}');
|
21603 | metadata('Decoration', ['\\boxed', '\\cancel', '\\bcancel', '\\xcancel'], RARE, '$0{\\placeholder{}}');
|
21604 | metadata('Decoration', ['\\bbox'], RARE, '\\bbox[#ffd400, solid 2px #ffd400]{\\unicode{"2B1A}}');
|
21605 | metadata('Styling', ['\\mathbb'], SUPERCOMMON, '$0{Don Knuth}');
|
21606 | metadata('Styling', [
|
21607 | '\\textbf',
|
21608 | '\\textup',
|
21609 | '\\textit',
|
21610 | '\\textrm',
|
21611 | '\\textsf',
|
21612 | '\\texttt',
|
21613 | '\\textnormal',
|
21614 | '\\textmd',
|
21615 | '\\textsl',
|
21616 | '\\textsc',
|
21617 | '\\mathsf',
|
21618 | '\\mathtt',
|
21619 | '\\mathrm',
|
21620 | '\\mathfrak',
|
21621 | '\\mathcal',
|
21622 | '\\mathscr',
|
21623 | '\\mathbf',
|
21624 | '\\mathmd',
|
21625 | '\\mathit',
|
21626 | '\\text',
|
21627 | '\\mbox',
|
21628 | '\\Bbb',
|
21629 | '\\bold',
|
21630 | '\\bm',
|
21631 | '\\boldsymbol',
|
21632 | ], COMMON, '$0{Don Knuth}');
|
21633 | metadata('Styling', [
|
21634 | '\\frak',
|
21635 | '\\tt',
|
21636 | '\\bf',
|
21637 | '\\it',
|
21638 | '\\rmfamily',
|
21639 | '\\sffamily',
|
21640 | '\\ttfamily',
|
21641 | '\\class',
|
21642 | '\\cssId',
|
21643 | '\\htmlData',
|
21644 | ], RARE, '{$0 Don Knuth}');
|
21645 | metadata('Styling', ['\\bfseries', '\\mdseries', '\\upshape', '\\slshape', '\\scshape'], RARE, '\\text{$0 Don Knuth}');
|
21646 | metadata('Styling', ['\\class', '\\cssId'], RARE, '$0{testIdentifier}{Don Knuth}');
|
21647 |
|
21648 |
|
21649 | metadata('Styling', ['\\fontseries'], RARE, '\\text{$0{b}Don Knuth}');
|
21650 | metadata('Styling', ['\\fontfamily'], RARE, '\\text{$0{cmtt}Don Knuth}');
|
21651 | metadata('Styling', ['\\fontshape'], RARE, '\\text{$0{sc}Don Knuth}');
|
21652 | metadata('Styling', ['\\selectfont'], RARE, '\\text{$0}');
|
21653 | metadata('Styling', ['\\emph'], RARE, 'Don$0{Knuth}');
|
21654 | metadata('Styling', ['\\em'], RARE, 'Don{$0 Knuth}');
|
21655 | metadata('Layout', [
|
21656 | '\\mathop',
|
21657 | '\\mathbin',
|
21658 | '\\mathrel',
|
21659 | '\\mathopen',
|
21660 | '\\mathclose',
|
21661 | '\\mathpunct',
|
21662 | '\\mathord',
|
21663 | '\\mathinner',
|
21664 | '\\operatorname',
|
21665 | '\\operatorname*',
|
21666 | ], RARE, 'x=$0{arg}=0');
|
21667 | metadata('Layout', ['\\middle'], RARE, '\\left\\{x$0|x>0\\right\\}');
|
21668 | metadata('Layout', ['\\overset', '\\underset', '\\stackrel', '\\stackbin'], RARE, '$0{arg}{x=0}');
|
21669 | metadata('Layout', ['\\rlap', '\\mathrlap'], RARE, '$0{/}0');
|
21670 | metadata('Layout', ['\\llap', '\\mathllap'], RARE, 'o$0{/}');
|
21671 | metadata('Fractions', ['\\frac'], SUPERCOMMON, '$0{\\placeholder{}}{\\placeholder{}}');
|
21672 | metadata('Fractions', [
|
21673 | '\\binom',
|
21674 | '\\dfrac',
|
21675 | '\\tfrac',
|
21676 | '\\dbinom',
|
21677 | '\\tbinom',
|
21678 | '\\pdiff',
|
21679 | '\\cfrac',
|
21680 | ], RARE, '$0{\\placeholder{}}{\\placeholder{}}');
|
21681 | metadata('Fractions', ['\\over', '\\atop', '\\choose'], RARE, '\\unicode{"2B1A} $0 \\unicode{"2B1A}');
|
21682 | metadata('Fractions', ['\\overwithdelims', '\\atopwithdelims'], RARE, '{\\unicode{"2B1A} $0{\\lbrace}{\\rbrace} \\unicode{"2B1A}}');
|
21683 | metadata('Extensible Operators', ['\\sum', '\\prod', '\\bigcap', '\\bigcup', '\\int'], SUPERCOMMON);
|
21684 | metadata('Extensible Operators', ['\\bigoplus', '\\smallint', '\\iint', '\\oint'], COMMON);
|
21685 | metadata('Extensible Operators', [
|
21686 | '\\bigwedge',
|
21687 | '\\bigvee',
|
21688 | '\\coprod',
|
21689 | '\\bigsqcup',
|
21690 | '\\bigotimes',
|
21691 | '\\bigodot',
|
21692 | '\\biguplus',
|
21693 | '\\intop',
|
21694 | '\\sqcup',
|
21695 | '\\sqcap',
|
21696 | '\\uplus',
|
21697 | '\\wr',
|
21698 | '\\Cap',
|
21699 | '\\Cup',
|
21700 | '\\doublecap',
|
21701 | '\\doublecup',
|
21702 | '\\amalg',
|
21703 | '\\iiint',
|
21704 | '\\oiint',
|
21705 | '\\oiiint',
|
21706 | '\\intclockwise',
|
21707 | '\\varointclockwise',
|
21708 | '\\ointctrclockwise',
|
21709 | '\\intctrclockwise',
|
21710 | ], RARE);
|
21711 | metadata('Accents', ['\\vec'], SUPERCOMMON);
|
21712 | metadata('Accents', ['\\bar', '\\ddot', '\\acute', '\\tilde', '\\check'], COMMON, '$0{\\placeholder{}}');
|
21713 | metadata('Accents', ['\\^', '\\`', "\\'"], RARE, '$0{e}');
|
21714 | metadata('Accents', ['\\c'], RARE, '$0{c}');
|
21715 | metadata('Accents', ['\\~'], RARE, '$0{n}');
|
21716 | metadata('Accents', ['\\mathring', '\\hat', '\\dot', '\\breve', '\\grave'], RARE, '$0{\\placeholder{}}');
|
21717 | metadata('Extensible Symbols', [
|
21718 | '\\overrightarrow',
|
21719 | '\\overleftarrow',
|
21720 | '\\Overrightarrow',
|
21721 | '\\overleftharpoon',
|
21722 | '\\overrightharpoon',
|
21723 | '\\overleftrightarrow',
|
21724 | '\\overbrace',
|
21725 | '\\overlinesegment',
|
21726 | '\\overgroup',
|
21727 | '\\widehat',
|
21728 | '\\widecheck',
|
21729 | '\\widetilde',
|
21730 | ], COMMON, '$0{ABC}');
|
21731 | metadata('Extensible Symbols', [
|
21732 | '\\underrightarrow',
|
21733 | '\\underleftarrow',
|
21734 | '\\underleftrightarrow',
|
21735 | '\\underbrace',
|
21736 | '\\underlinesegment',
|
21737 | '\\undergroup',
|
21738 | '\\utilde',
|
21739 | ], COMMON, '$0{ABC}');
|
21740 | metadata('Sizing', [
|
21741 | '\\tiny',
|
21742 | '\\scriptsize',
|
21743 | '\\footnotesize',
|
21744 | '\\small',
|
21745 | '\\normalsize',
|
21746 | '\\large',
|
21747 | '\\Large',
|
21748 | '\\LARGE',
|
21749 | '\\huge',
|
21750 | '\\Huge',
|
21751 | ], RARE, '$0{x=0}');
|
21752 | metadata('Sizing', ['\\big', '\\Big', '\\bigg', '\\Bigg'], RARE, '$0($0)');
|
21753 | metadata('Sizing', ['\\bigl', '\\Bigl', '\\biggl', '\\Biggl'], RARE, '$0(');
|
21754 | metadata('Sizing', ['\\bigr', '\\Bigr', '\\biggr', '\\Biggr'], RARE, '$0)');
|
21755 | metadata('Sizing', ['\\bigm', '\\Bigm', '\\biggm', '\\Biggm'], RARE, '$0|');
|
21756 | metadata('Letterlike Symbols', [
|
21757 | '\\nabla',
|
21758 | '\\partial',
|
21759 | '\\N',
|
21760 | '\\R',
|
21761 | '\\Q',
|
21762 | '\\C',
|
21763 | '\\Z',
|
21764 | '\\exponentialE',
|
21765 | '\\forall',
|
21766 | '\\exists',
|
21767 | '\\nexists',
|
21768 | ], SUPERCOMMON);
|
21769 | metadata('Letterlike Symbols', [
|
21770 | '\\doubleStruckCapitalP',
|
21771 | '\\P',
|
21772 | '\\ell',
|
21773 | '\\hbar',
|
21774 | '\\hslash',
|
21775 | '\\imath',
|
21776 | '\\jmath',
|
21777 | '\\imaginaryI',
|
21778 | '\\imaginaryJ',
|
21779 | '\\differentialD',
|
21780 | '\\rd',
|
21781 | '\\capitalDifferentialD',
|
21782 | '\\doubleStruckCapitalN',
|
21783 | '\\doubleStruckCapitalR',
|
21784 | '\\doubleStruckCapitalQ',
|
21785 | '\\doubleStruckCapitalC',
|
21786 | '\\doubleStruckCapitalZ',
|
21787 | '\\rD',
|
21788 | '\\differencedelta',
|
21789 | '\\mid',
|
21790 | '@',
|
21791 | '\\Re',
|
21792 | '\\Im',
|
21793 | '\\$',
|
21794 | '\\%',
|
21795 | '\\And',
|
21796 | '\\degree',
|
21797 | ], COMMON);
|
21798 | metadata('Letterlike Symbols', [
|
21799 | '\\top',
|
21800 | '\\bot',
|
21801 | '\\scriptCapitalE',
|
21802 | '\\scriptCapitalH',
|
21803 | '\\scriptCapitalL',
|
21804 | '\\gothicCapitalC',
|
21805 | '\\gothicCapitalH',
|
21806 | '\\gothicCapitalI',
|
21807 | '\\gothicCapitalR',
|
21808 | '\\Bbbk',
|
21809 | '\\Finv',
|
21810 | '\\Game',
|
21811 | '\\wp',
|
21812 | '\\eth',
|
21813 | '\\mho',
|
21814 | '\\pounds',
|
21815 | '\\yen',
|
21816 | '\\euro',
|
21817 | ], RARE);
|
21818 | metadata('Crosses', ['\\dagger', '\\dag'], SUPERCOMMON);
|
21819 | metadata('Crosses', ['\\ddag', '\\ddagger', '\\maltese', '\\textdagger', '\\textdaggerdbl'], RARE);
|
21820 | metadata('Various', [
|
21821 | '\\checkmark',
|
21822 | '\\diagup',
|
21823 | '\\diagdown',
|
21824 | '\\angle',
|
21825 | '\\measuredangle',
|
21826 | '\\sphericalangle',
|
21827 | '\\prime',
|
21828 | '\\doubleprime',
|
21829 | '\\backprime',
|
21830 | '\\backdoubleprime',
|
21831 | '\\sharp',
|
21832 | '\\flat',
|
21833 | '\\natural',
|
21834 | '\\&',
|
21835 | '\\#',
|
21836 | '\\clubsuit',
|
21837 | '\\spadesuit',
|
21838 | '\\diamondsuit',
|
21839 | '\\heartsuit',
|
21840 | '\\backslash',
|
21841 | '\\infty',
|
21842 | '/',
|
21843 | '\\_',
|
21844 | '\\/',
|
21845 | '|',
|
21846 | "'",
|
21847 | ], RARE);
|
21848 | metadata('Various', ['\\unicode'], RARE, '$0{"2B1A}');
|
21849 | metadata('Arrows', ['\\longrightarrow', '\\rightarrow', '\\Longrightarrow', '\\Rightarrow'], SUPERCOMMON);
|
21850 | metadata('Arrows', [
|
21851 | '\\longmapsto',
|
21852 | '\\mapsto',
|
21853 | '\\Longleftrightarrow',
|
21854 | '\\rightleftarrows',
|
21855 | '\\leftarrow',
|
21856 | '\\curvearrowleft',
|
21857 | '\\uparrow',
|
21858 | '\\downarrow',
|
21859 | '\\hookrightarrow',
|
21860 | '\\rightharpoonup',
|
21861 | '\\rightleftharpoons',
|
21862 | ], COMMON);
|
21863 | metadata('Arrows', [
|
21864 | '\\Leftarrow',
|
21865 | '\\longleftrightarrow',
|
21866 | '\\longleftarrow',
|
21867 | '\\Longleftarrow',
|
21868 | '\\searrow',
|
21869 | '\\nearrow',
|
21870 | '\\swarrow',
|
21871 | '\\nwarrow',
|
21872 | '\\Uparrow',
|
21873 | '\\Downarrow',
|
21874 | '\\updownarrow',
|
21875 | '\\Updownarrow',
|
21876 | '\\hookleftarrow',
|
21877 | '\\leftharpoonup',
|
21878 | '\\leftharpoondown',
|
21879 | '\\rightharpoondown',
|
21880 | '\\leftrightarrows',
|
21881 | '\\dashrightarrow',
|
21882 | '\\dashleftarrow',
|
21883 | '\\leftleftarrows',
|
21884 | '\\Lleftarrow',
|
21885 | '\\twoheadleftarrow',
|
21886 | '\\leftarrowtail',
|
21887 | '\\looparrowleft',
|
21888 | '\\leftrightharpoons',
|
21889 | '\\circlearrowleft',
|
21890 | '\\Lsh',
|
21891 | '\\upuparrows',
|
21892 | '\\downharpoonleft',
|
21893 | '\\multimap',
|
21894 | '\\leftrightsquigarrow',
|
21895 | '\\twoheadrightarrow',
|
21896 | '\\rightarrowtail',
|
21897 | '\\looparrowright',
|
21898 | '\\curvearrowright',
|
21899 | '\\circlearrowright',
|
21900 | '\\Rsh',
|
21901 | '\\downdownarrows',
|
21902 | '\\upharpoonright',
|
21903 | '\\downharpoonright',
|
21904 | '\\rightsquigarrow',
|
21905 | '\\leadsto',
|
21906 | '\\Rrightarrow',
|
21907 | '\\restriction',
|
21908 | ], RARE);
|
21909 | metadata('Arrows', ['\\upharpoonleft', '\\rightrightarrows'], CRYPTIC);
|
21910 |
|
21911 | metadata('Negated Arrows', [
|
21912 | '\\nrightarrow',
|
21913 | '\\nRightarrow',
|
21914 | '\\nleftrightarrow',
|
21915 | '\\nLeftrightarrow',
|
21916 | '\\nleftarrow',
|
21917 | '\\nLeftarrow',
|
21918 | ], RARE);
|
21919 | metadata('Extensible Symbols', [
|
21920 | '\\xrightarrow',
|
21921 | '\\xleftarrow',
|
21922 | '\\xRightarrow',
|
21923 | '\\xLeftarrow',
|
21924 | '\\xleftharpoonup',
|
21925 | '\\xleftharpoondown',
|
21926 | '\\xrightharpoonup',
|
21927 | '\\xrightharpoondown',
|
21928 | '\\xlongequal',
|
21929 | '\\xtwoheadleftarrow',
|
21930 | '\\xtwoheadrightarrow',
|
21931 | '\\xleftrightarrow',
|
21932 | '\\xLeftrightarrow',
|
21933 | '\\xrightleftharpoons',
|
21934 | '\\xleftrightharpoons',
|
21935 | '\\xhookleftarrow',
|
21936 | '\\xhookrightarrow',
|
21937 | '\\xmapsto',
|
21938 | '\\xtofrom',
|
21939 | '\\xrightleftarrows',
|
21940 | '\\xrightequilibrium',
|
21941 | '\\xleftequilibrium',
|
21942 | ], RARE, '$0[below]{above}=0');
|
21943 |
|
21944 | metadata('Negated Relations', [
|
21945 | '\\nless',
|
21946 | '\\nleqslant',
|
21947 | '\\lneq',
|
21948 | '\\lneqq',
|
21949 | '\\nleqq',
|
21950 | '\\unlhd',
|
21951 | '\\unrhd',
|
21952 | '\\lvertneqq',
|
21953 | '\\lnsim',
|
21954 | '\\lnapprox',
|
21955 | '\\nprec',
|
21956 | '\\npreceq',
|
21957 | '\\precnsim',
|
21958 | '\\precnapprox',
|
21959 | '\\nsim',
|
21960 | '\\nshortmid',
|
21961 | '\\nmid',
|
21962 | '\\nvdash',
|
21963 | '\\nvDash',
|
21964 | '\\ngtr',
|
21965 | '\\ngeqslant',
|
21966 | '\\ngeqq',
|
21967 | '\\gneq',
|
21968 | '\\gneqq',
|
21969 | '\\gvertneqq',
|
21970 | '\\gnsim',
|
21971 | '\\nsucc',
|
21972 | '\\succnsim',
|
21973 | '\\ncong',
|
21974 | '\\nshortparallel',
|
21975 | '\\nparallel',
|
21976 | '\\nVDash',
|
21977 | '\\nVdash',
|
21978 | '\\precneqq',
|
21979 | '\\succneqq',
|
21980 | '\\gnapprox',
|
21981 | '\\succnapprox',
|
21982 | '\\nsucceq',
|
21983 | ], RARE);
|
21984 |
|
21985 | metadata('Hebrew', ['\\aleph', '\\beth', '\\daleth', '\\gimel'], RARE);
|
21986 | metadata('Fences', [
|
21987 | '\\lbrace',
|
21988 | '\\rbrace',
|
21989 | '\\vert',
|
21990 | '\\Vert',
|
21991 | '\\{',
|
21992 | '\\}',
|
21993 | '(',
|
21994 | ')',
|
21995 | '[',
|
21996 | ']',
|
21997 | ], SUPERCOMMON);
|
21998 | metadata('Fences', [
|
21999 | '\\langle',
|
22000 | '\\rangle',
|
22001 | '\\lfloor',
|
22002 | '\\rfloor',
|
22003 | '\\lceil',
|
22004 | '\\rceil',
|
22005 | '\\mvert',
|
22006 | '\\|',
|
22007 | '\\mVert',
|
22008 | ], COMMON);
|
22009 | metadata('Fences', [
|
22010 | '\\lvert',
|
22011 | '\\rvert',
|
22012 | '\\lVert',
|
22013 | '\\rVert',
|
22014 | '\\lbrack',
|
22015 | '\\rbrack',
|
22016 | '\\ulcorner',
|
22017 | '\\urcorner',
|
22018 | '\\llcorner',
|
22019 | '\\lrcorner',
|
22020 | '\\lgroup',
|
22021 | '\\rgroup',
|
22022 | '\\lmoustache',
|
22023 | '\\rmoustache',
|
22024 | ], RARE);
|
22025 | metadata('Relations', ['=', '\\ne', '\\neq', '<', '>', '\\leqslant', '\\geqslant', '\\approx'], SUPERCOMMON);
|
22026 | metadata('Relations', [
|
22027 | '\\lt',
|
22028 | '\\gt',
|
22029 | '\\le',
|
22030 | '\\ge',
|
22031 | '\\leq',
|
22032 | '\\geq',
|
22033 | '\\gg',
|
22034 | '\\cong',
|
22035 | '\\equiv',
|
22036 | '\\prec',
|
22037 | '\\preceq',
|
22038 | '\\succ',
|
22039 | '\\perp',
|
22040 | '\\parallel',
|
22041 | '\\propto',
|
22042 | '\\smile',
|
22043 | '\\frown',
|
22044 | '\\sim',
|
22045 | '\\gtrsim',
|
22046 | ], COMMON);
|
22047 | metadata('Relations', [
|
22048 | '\\coloneq',
|
22049 | '\\succeq',
|
22050 | '\\approxeq',
|
22051 | '\\thickapprox',
|
22052 | '\\lessapprox',
|
22053 | '\\gtrapprox',
|
22054 | '\\precapprox',
|
22055 | '\\succapprox',
|
22056 | '\\thicksim',
|
22057 | '\\succsim',
|
22058 | '\\precsim',
|
22059 | '\\backsim',
|
22060 | '\\eqsim',
|
22061 | '\\backsimeq',
|
22062 | '\\simeq',
|
22063 | '\\lesssim',
|
22064 | '\\nleq',
|
22065 | '\\ngeq',
|
22066 | '\\smallsmile',
|
22067 | '\\smallfrown',
|
22068 | '\\bowtie',
|
22069 | '\\asymp',
|
22070 | '\\leqq',
|
22071 | '\\eqslantless',
|
22072 | '\\ll',
|
22073 | '\\lll',
|
22074 | '\\lessgtr',
|
22075 | '\\lesseqgtr',
|
22076 | '\\lesseqqgtr',
|
22077 | '\\risingdotseq',
|
22078 | '\\fallingdotseq',
|
22079 | '\\preccurlyeq',
|
22080 | '\\curlyeqprec',
|
22081 | '\\vDash',
|
22082 | '\\Vvdash',
|
22083 | '\\bumpeq',
|
22084 | '\\Bumpeq',
|
22085 | '\\geqq',
|
22086 | '\\eqslantgtr',
|
22087 | '\\ggg',
|
22088 | '\\gtrless',
|
22089 | '\\gtreqless',
|
22090 | '\\gtreqqless',
|
22091 | '\\succcurlyeq',
|
22092 | '\\curlyeqsucc',
|
22093 | '\\Vdash',
|
22094 | '\\shortmid',
|
22095 | '\\shortparallel',
|
22096 | '\\between',
|
22097 | '\\pitchfork',
|
22098 | '\\varpropto',
|
22099 | '\\backepsilon',
|
22100 | '\\llless',
|
22101 | '\\gggtr',
|
22102 | '\\lhd',
|
22103 | '\\rhd',
|
22104 | '\\Join',
|
22105 | '\\doteq',
|
22106 | '\\doteqdot',
|
22107 | '\\Doteq',
|
22108 | '\\eqcirc',
|
22109 | '\\circeq',
|
22110 | '\\lessdot',
|
22111 | '\\gtrdot',
|
22112 | '\\measeq',
|
22113 | '\\eqdef',
|
22114 | '\\questeq',
|
22115 | ], RARE);
|
22116 | metadata('Logic', ['\\leftrightarrow', '\\Leftrightarrow', '\\to'], SUPERCOMMON);
|
22117 | metadata('Logic', ['\\models', '\\vdash'], COMMON);
|
22118 | metadata('Logic', [
|
22119 | '\\therefore',
|
22120 | '\\because',
|
22121 | '\\implies',
|
22122 | '\\gets',
|
22123 | '\\dashv',
|
22124 | '\\impliedby',
|
22125 | '\\biconditional',
|
22126 | '\\roundimplies',
|
22127 | ], RARE);
|
22128 | metadata('Operators', ['+', '-', '*', '\\cdot'], SUPERCOMMON);
|
22129 | metadata('Operators', ['\\sqrt'], SUPERCOMMON, '$0{\\placeholder{}}');
|
22130 | metadata('Operators', ['\\pm', '\\mp', '\\times', '\\div', '\\surd'], COMMON);
|
22131 | metadata('Operators', [
|
22132 | '\\ltimes',
|
22133 | '\\rtimes',
|
22134 | '\\leftthreetimes',
|
22135 | '\\rightthreetimes',
|
22136 | '\\intercal',
|
22137 | '\\dotplus',
|
22138 | '\\centerdot',
|
22139 | '\\doublebarwedge',
|
22140 | '\\divideontimes',
|
22141 | '\\divides',
|
22142 | ], RARE);
|
22143 | metadata('Logic', ['\\wedge', '\\vee', '\\neg'], SUPERCOMMON);
|
22144 | metadata('Logic', ['\\lnot'], COMMON);
|
22145 | metadata('Logic', [
|
22146 | '\\land',
|
22147 | '\\lor',
|
22148 | '\\barwedge',
|
22149 | '\\veebar',
|
22150 | '\\nor',
|
22151 | '\\curlywedge',
|
22152 | '\\curlyvee',
|
22153 | ], RARE);
|
22154 | metadata('Greek', [
|
22155 | '\\alpha',
|
22156 | '\\beta',
|
22157 | '\\gamma',
|
22158 | '\\delta',
|
22159 | '\\epsilon',
|
22160 | '\\varepsilon',
|
22161 | '\\zeta',
|
22162 | '\\eta',
|
22163 | '\\theta',
|
22164 | '\\vartheta',
|
22165 | '\\iota',
|
22166 | '\\kappa',
|
22167 | '\\varkappa',
|
22168 | '\\lambda',
|
22169 | '\\mu',
|
22170 | '\\nu',
|
22171 | '\\xi',
|
22172 | '\\pi',
|
22173 | '\\varpi',
|
22174 | '\\rho',
|
22175 | '\\varrho',
|
22176 | '\\sigma',
|
22177 | '\\varsigma',
|
22178 | '\\tau',
|
22179 | '\\phi',
|
22180 | '\\varphi',
|
22181 | '\\upsilon',
|
22182 | '\\chi',
|
22183 | '\\psi',
|
22184 | '\\omega',
|
22185 | '\\Gamma',
|
22186 | '\\Delta',
|
22187 | '\\Theta',
|
22188 | '\\Lambda',
|
22189 | '\\Xi',
|
22190 | '\\Pi',
|
22191 | '\\Sigma',
|
22192 | '\\Upsilon',
|
22193 | '\\Phi',
|
22194 | '\\Psi',
|
22195 | '\\Omega',
|
22196 | '\\digamma',
|
22197 | '\\omicron',
|
22198 | ], COMMON);
|
22199 | metadata('Sets', [
|
22200 | '\\emptyset',
|
22201 | '\\varnothing',
|
22202 | '\\cap',
|
22203 | '\\cup',
|
22204 | '\\in',
|
22205 | '\\notin',
|
22206 | '\\subset',
|
22207 | '\\supset',
|
22208 | '\\subseteq',
|
22209 | '\\supseteq',
|
22210 | '\\sqsubseteq',
|
22211 | ], SUPERCOMMON);
|
22212 | metadata('Sets', [
|
22213 | '\\setminus',
|
22214 | '\\not',
|
22215 | '\\ni',
|
22216 | '\\sqsupseteq',
|
22217 | '\\nsupseteqq',
|
22218 | '\\supsetneq',
|
22219 | '\\varsupsetneq',
|
22220 | '\\supsetneqq',
|
22221 | '\\varsupsetneqq',
|
22222 | ], COMMON);
|
22223 | metadata('Sets', [
|
22224 | '\\smallsetminus',
|
22225 | '\\complement',
|
22226 | '\\owns',
|
22227 | '\\subsetneq',
|
22228 | '\\varsubsetneq',
|
22229 | '\\subsetneqq',
|
22230 | '\\varsubsetneqq',
|
22231 | '\\nsubset',
|
22232 | '\\nsupset',
|
22233 | '\\nsubseteq',
|
22234 | '\\nsupseteq',
|
22235 | '\\nsubseteqq',
|
22236 | '\\subseteqq',
|
22237 | '\\Subset',
|
22238 | '\\sqsubset',
|
22239 | '\\supseteqq',
|
22240 | '\\Supset',
|
22241 | '\\sqsupset',
|
22242 | ], RARE);
|
22243 | metadata('Spacing', ['\\space, \\quad', '\\qquad'], COMMON, '\\unicode{"203A}$0\\unicode{"2039}');
|
22244 | metadata('Spacing', ['\\!', '\\,', '\\:', '\\;', '\\enskip', '\\enspace'], RARE, '\\unicode{"203A}$0\\unicode{"2039}');
|
22245 | metadata('Spacing', ['\\hspace', '\\hspace*'], RARE, '\\unicode{"203A}$0{1em}\\unicode{"2039}');
|
22246 | metadata('Punctuation', [
|
22247 | '\\colon',
|
22248 | '\\cdotp',
|
22249 | '\\ldots',
|
22250 | '\\cdots',
|
22251 | '\\ddots',
|
22252 | '\\vdots',
|
22253 | '?',
|
22254 | '!',
|
22255 | ':',
|
22256 | '"',
|
22257 | ',',
|
22258 | '.',
|
22259 | ';',
|
22260 | ], COMMON);
|
22261 | metadata('Punctuation', ['\\mathellipsis', '\\ldotp', '\\Colon'], RARE);
|
22262 | metadata('Boxes', ['\\square', '\\Box'], COMMON);
|
22263 | metadata('Boxes', ['\\blacksquare', '\\boxminus', '\\boxplus', '\\boxtimes', '\\boxdot'], RARE);
|
22264 | metadata('Circles', ['\\circ', '\\bullet', '\\circleddash', '\\oplus', '\\otimes'], COMMON);
|
22265 | metadata('Circles', [
|
22266 | '\\bigcirc',
|
22267 | '\\circledast',
|
22268 | '\\ominus',
|
22269 | '\\circledcirc',
|
22270 | '\\oslash',
|
22271 | '\\circledS',
|
22272 | '\\circledR',
|
22273 | '\\odot',
|
22274 | ], RARE);
|
22275 | metadata('Triangles', ['\\triangle', '\\triangleq'], COMMON);
|
22276 | metadata('Triangles', [
|
22277 | '\\bigtriangleup',
|
22278 | '\\vartriangle',
|
22279 | '\\triangledown',
|
22280 | '\\bigtriangledown',
|
22281 | '\\triangleleft',
|
22282 | '\\vartriangleleft',
|
22283 | '\\trianglelefteq',
|
22284 | '\\ntriangleleft',
|
22285 | '\\ntrianglelefteq',
|
22286 | '\\triangleright',
|
22287 | '\\vartriangleright',
|
22288 | '\\trianglerighteq',
|
22289 | '\\ntriangleright',
|
22290 | '\\ntrianglerighteq',
|
22291 | '\\blacktriangle',
|
22292 | '\\blacktriangledown',
|
22293 | '\\blacktriangleleft',
|
22294 | '\\blacktriangleright',
|
22295 | ], RARE);
|
22296 | metadata('Shapes', ['\\ast', '\\star'], COMMON);
|
22297 | metadata('Shapes', ['\\diamond', '\\Diamond', '\\lozenge', '\\blacklozenge', '\\bigstar'], RARE);
|
22298 |
|
22299 | const STRINGS = {
|
22300 | en: {
|
22301 | 'keyboard.tooltip.functions': 'Functions',
|
22302 | 'keyboard.tooltip.symbols': 'Symbols',
|
22303 | 'keyboard.tooltip.greek': 'Greek Letters',
|
22304 | 'keyboard.tooltip.command': 'LaTeX Command Mode',
|
22305 | 'keyboard.tooltip.numeric': 'Numeric',
|
22306 | 'keyboard.tooltip.roman': 'Roman Letters',
|
22307 | 'tooltip.copy to clipboard': 'Copy to Clipboard',
|
22308 | 'tooltip.redo': 'Redo',
|
22309 | 'tooltip.toggle virtual keyboard': 'Toggle Virtual Keyboard',
|
22310 | 'tooltip.undo': 'Undo',
|
22311 | 'menu.insert matrix': 'Insert Matrix',
|
22312 | 'menu.insert vector': 'Insert Vector',
|
22313 | 'submenu.array.matrix delimiters': 'Matrix Delimiters',
|
22314 | 'menu.array.add row above': 'Add Row After',
|
22315 | 'menu.array.add row below': 'Add Row Before',
|
22316 | 'menu.array.add column after': 'Add Column After',
|
22317 | 'menu.array.add column before': 'Add Column Before',
|
22318 | 'menu.array.delete row': 'Delete Row',
|
22319 | 'menu.array.delete rows': 'Delete Selected Rows',
|
22320 | 'menu.array.delete column': 'Delete Column',
|
22321 | 'menu.array.delete columns': 'Delete Selected Columns',
|
22322 | 'submenu.array.insert separator': 'Insert Separator',
|
22323 | 'menu.insert table': 'Insert Table',
|
22324 | 'submenu.table style': 'Table Style',
|
22325 | },
|
22326 |
|
22327 | ar: {
|
22328 | 'keyboard.tooltip.functions': 'مهام',
|
22329 | 'keyboard.tooltip.symbols': 'حرف او رمز',
|
22330 | 'keyboard.tooltip.greek': 'حروف يونانية',
|
22331 | 'keyboard.tooltip.command': 'حالة تلقي الأوامر اللاتك',
|
22332 | 'keyboard.tooltip.numeric': 'الرقمية',
|
22333 | 'keyboard.tooltip.roman': 'رموز الاحرف الرومانية',
|
22334 | 'tooltip.copy to clipboard': 'نسخ إلى الحافظة',
|
22335 | 'tooltip.redo': 'الإعادة',
|
22336 | 'tooltip.toggle virtual keyboard': 'تبديل لوحة المفاتيح الإفتراضية',
|
22337 | 'tooltip.undo': 'إلغاء',
|
22338 | 'menu.insert matrix': 'أدخل المصفوفة',
|
22339 | 'menu.insert vector': 'أدخل متجه',
|
22340 | 'submenu.array.matrix delimiters': 'محددات المصفوفة',
|
22341 | 'menu.array.add row above': 'أضف صفًا بعد ذلك',
|
22342 | 'menu.array.add row below': 'أضف الصف قبل',
|
22343 | 'menu.array.add column after': 'أضف العمود بعد ذلك',
|
22344 | 'menu.array.add column before': 'أضف العمود قبل',
|
22345 | 'menu.array.delete row': 'احذف صف',
|
22346 | 'menu.array.delete rows': 'حذف الصفوف المحددة',
|
22347 | 'menu.array.delete column': 'حذف العمود',
|
22348 | 'menu.array.delete columns': 'حذف الأعمدة المحددة',
|
22349 | 'submenu.array.insert separator': 'أدخل فاصل',
|
22350 | 'menu.insert table': 'إدراج جدول',
|
22351 | 'submenu.table style': 'نمط الجدول',
|
22352 | },
|
22353 |
|
22354 | bg: {
|
22355 | 'keyboard.tooltip.functions': 'Функции',
|
22356 | 'keyboard.tooltip.symbols': 'Символи',
|
22357 | 'keyboard.tooltip.greek': 'Гръцки букви',
|
22358 | 'keyboard.tooltip.command': 'Команден режим на латекс',
|
22359 | 'keyboard.tooltip.numeric': 'Числови',
|
22360 | 'keyboard.tooltip.roman': 'Римски букви',
|
22361 | 'tooltip.copy to clipboard': 'Копиране в клипборда',
|
22362 | 'tooltip.redo': 'Повторно',
|
22363 | 'tooltip.toggle virtual keyboard': 'Превключване на виртуална клавиатура',
|
22364 | 'tooltip.undo': 'Отмяна',
|
22365 | 'menu.insert matrix': 'Вмъкване на матрица',
|
22366 | 'menu.insert vector': 'Вмъкване на вектор',
|
22367 | 'submenu.array.matrix delimiters': 'Матрични разделители',
|
22368 | 'menu.array.add row above': 'Добавяне на ред след',
|
22369 | 'menu.array.add row below': 'Добавяне на ред преди',
|
22370 | 'menu.array.add column after': 'Добавяне на колона след',
|
22371 | 'menu.array.add column before': 'Добавяне на колона преди',
|
22372 | 'menu.array.delete row': 'Изтриване на реда',
|
22373 | 'menu.array.delete rows': 'Изтриване на избраните редове',
|
22374 | 'menu.array.delete column': 'Изтриване на колона',
|
22375 | 'menu.array.delete columns': 'Изтриване на избраните колони',
|
22376 | 'submenu.array.insert separator': 'Поставете разделител',
|
22377 | 'menu.insert table': 'Вмъкване на таблица',
|
22378 | 'submenu.table style': 'Табличен стил',
|
22379 | },
|
22380 |
|
22381 | bs: {
|
22382 | 'keyboard.tooltip.functions': 'Funkcije',
|
22383 | 'keyboard.tooltip.symbols': 'Simboli',
|
22384 | 'keyboard.tooltip.greek': 'Grčka slova',
|
22385 | 'keyboard.tooltip.command': 'LaTeX naredbeni način',
|
22386 | 'keyboard.tooltip.numeric': 'Numerički',
|
22387 | 'keyboard.tooltip.roman': 'Rimska slova',
|
22388 | 'tooltip.copy to clipboard': 'Kopirati u clipboard',
|
22389 | 'tooltip.redo': 'Ponovi',
|
22390 | 'tooltip.toggle virtual keyboard': 'Uključi / isključi virtualnu tipkovnicu',
|
22391 | 'tooltip.undo': 'Poništi',
|
22392 | 'menu.insert matrix': 'Umetni matricu',
|
22393 | 'menu.insert vector': 'Umetni vektor',
|
22394 | 'submenu.array.matrix delimiters': 'Matrični razdjelnici',
|
22395 | 'menu.array.add row above': 'Dodaj redak nakon',
|
22396 | 'menu.array.add row below': 'Dodaj red prije',
|
22397 | 'menu.array.add column after': 'Dodaj stupac nakon',
|
22398 | 'menu.array.add column before': 'Dodaj stupac prije',
|
22399 | 'menu.array.delete row': 'Izbriši red',
|
22400 | 'menu.array.delete rows': 'Izbriši odabrane redove',
|
22401 | 'menu.array.delete column': 'Izbriši stupac',
|
22402 | 'menu.array.delete columns': 'Izbriši odabrane stupce',
|
22403 | 'submenu.array.insert separator': 'Umetni separator',
|
22404 | 'menu.insert table': 'Ubaci tabelu',
|
22405 | 'submenu.table style': 'Stil tabele',
|
22406 | },
|
22407 |
|
22408 | cs: {
|
22409 | 'keyboard.tooltip.functions': 'Funkce',
|
22410 | 'keyboard.tooltip.symbols': 'Symboly',
|
22411 | 'keyboard.tooltip.greek': 'Řecké dopisy',
|
22412 | 'keyboard.tooltip.command': 'Příkazový režim LaTeX',
|
22413 | 'keyboard.tooltip.numeric': 'Číselné',
|
22414 | 'keyboard.tooltip.roman': 'Římské dopisy',
|
22415 | 'tooltip.copy to clipboard': 'Zkopírovat do schránky',
|
22416 | 'tooltip.redo': 'Předělat',
|
22417 | 'tooltip.toggle virtual keyboard': 'Přepnout virtuální klávesnici',
|
22418 | 'tooltip.undo': 'Vrátit',
|
22419 | 'menu.insert matrix': 'Vložte matici',
|
22420 | 'menu.insert vector': 'Vložit vektor',
|
22421 | 'submenu.array.matrix delimiters': 'Oddělovače matic',
|
22422 | 'menu.array.add row above': 'Přidat řádek za',
|
22423 | 'menu.array.add row below': 'Přidat řádek před',
|
22424 | 'menu.array.add column after': 'Přidat sloupec za',
|
22425 | 'menu.array.add column before': 'Přidat sloupec dříve',
|
22426 | 'menu.array.delete row': 'Odstranit řádek',
|
22427 | 'menu.array.delete rows': 'Odstranit vybrané řádky',
|
22428 | 'menu.array.delete column': 'Odstranit sloupec',
|
22429 | 'menu.array.delete columns': 'Odstranit vybrané sloupce',
|
22430 | 'submenu.array.insert separator': 'Vložte oddělovač',
|
22431 | 'menu.insert table': 'Vložit tabulku',
|
22432 | 'submenu.table style': 'Styl tabulky',
|
22433 | },
|
22434 |
|
22435 | da: {
|
22436 | 'keyboard.tooltip.functions': 'Funktioner',
|
22437 | 'keyboard.tooltip.symbols': 'Symboler',
|
22438 | 'keyboard.tooltip.greek': 'Græske bogstaver',
|
22439 | 'keyboard.tooltip.command': 'LaTeX kommandotilstand',
|
22440 | 'keyboard.tooltip.numeric': 'Numerisk',
|
22441 | 'keyboard.tooltip.roman': 'Romerske breve',
|
22442 | 'tooltip.copy to clipboard': 'Kopier til udklipsholder',
|
22443 | 'tooltip.redo': 'Gentag igen',
|
22444 | 'tooltip.toggle virtual keyboard': 'Skift virtuelt tastatur',
|
22445 | 'tooltip.undo': 'Fortryd',
|
22446 | 'menu.insert matrix': 'Indsæt matrix',
|
22447 | 'menu.insert vector': 'Indsæt vektor',
|
22448 | 'submenu.array.matrix delimiters': 'Matrixafgrænsere',
|
22449 | 'menu.array.add row above': 'Tilføj række efter',
|
22450 | 'menu.array.add row below': 'Tilføj række før',
|
22451 | 'menu.array.add column after': 'Tilføj kolonne efter',
|
22452 | 'menu.array.add column before': 'Tilføj kolonne før',
|
22453 | 'menu.array.delete row': 'Slet række',
|
22454 | 'menu.array.delete rows': 'Slet valgte rækker',
|
22455 | 'menu.array.delete column': 'Slet kolonne',
|
22456 | 'menu.array.delete columns': 'Slet valgte kolonner',
|
22457 | 'submenu.array.insert separator': 'Indsæt separator',
|
22458 | 'menu.insert table': 'Indsæt tabel',
|
22459 | 'submenu.table style': 'Tabelstil',
|
22460 | },
|
22461 |
|
22462 | de: {
|
22463 | 'keyboard.tooltip.functions': 'Funktionen',
|
22464 | 'keyboard.tooltip.symbols': 'Symbole',
|
22465 | 'keyboard.tooltip.greek': 'Griechische Buchstaben',
|
22466 | 'keyboard.tooltip.command': 'LaTeX-Befehlsmodus',
|
22467 | 'keyboard.tooltip.numeric': 'Numerisch',
|
22468 | 'keyboard.tooltip.roman': 'Römische Buchstaben',
|
22469 | 'tooltip.copy to clipboard': 'In die Zwischenablage kopieren',
|
22470 | 'tooltip.redo': 'Wiederholen',
|
22471 | 'tooltip.toggle virtual keyboard': 'Virtuelle Tastatur umschalten',
|
22472 | 'tooltip.undo': 'Widerrufen',
|
22473 | 'menu.insert matrix': 'Matrix einfügen',
|
22474 | 'menu.insert vector': 'Vektor einfügen',
|
22475 | 'submenu.array.matrix delimiters': 'Matrixtrennzeichen',
|
22476 | 'menu.array.add row above': 'Zeile hinzufügen nach',
|
22477 | 'menu.array.add row below': 'Zeile hinzufügen vor',
|
22478 | 'menu.array.add column after': 'Spalte hinzufügen nach',
|
22479 | 'menu.array.add column before': 'Spalte hinzufügen vor',
|
22480 | 'menu.array.delete row': 'Zeile löschen',
|
22481 | 'menu.array.delete rows': 'Ausgewählte Zeilen löschen',
|
22482 | 'menu.array.delete column': 'Spalte löschen',
|
22483 | 'menu.array.delete columns': 'Ausgewählte Spalten löschen',
|
22484 | 'submenu.array.insert separator': 'Trennzeichen einfügen',
|
22485 | 'menu.insert table': 'Tabelle einfügen',
|
22486 | 'submenu.table style': 'Tabellenstil',
|
22487 | },
|
22488 |
|
22489 | el: {
|
22490 | 'keyboard.tooltip.functions': 'συναρτήσεις',
|
22491 | 'keyboard.tooltip.symbols': 'σύμβολα',
|
22492 | 'keyboard.tooltip.greek': 'ελληνικά γράμματα',
|
22493 | 'keyboard.tooltip.command': 'Λειτουργία εντολών LaTeX',
|
22494 | 'keyboard.tooltip.numeric': 'Αριθμητικός',
|
22495 | 'keyboard.tooltip.roman': 'Ρωμαϊκά γράμματα',
|
22496 | 'tooltip.copy to clipboard': 'Αντιγραφή στο πρόχειρο',
|
22497 | 'tooltip.redo': 'Ξανακάνω',
|
22498 | 'tooltip.toggle virtual keyboard': 'Εναλλαγή εικονικού πληκτρολογίου',
|
22499 | 'tooltip.undo': 'Ξεκάνω',
|
22500 | 'menu.insert matrix': 'Εισαγωγή Matrix',
|
22501 | 'menu.insert vector': 'Εισαγωγή διανύσματος',
|
22502 | 'submenu.array.matrix delimiters': 'Οριοθέτες Matrix',
|
22503 | 'menu.array.add row above': 'Προσθήκη σειράς μετά',
|
22504 | 'menu.array.add row below': 'Προσθήκη σειράς πριν',
|
22505 | 'menu.array.add column after': 'Προσθήκη στήλης μετά',
|
22506 | 'menu.array.add column before': 'Προσθήκη στήλης πριν',
|
22507 | 'menu.array.delete row': 'Διαγραφή σειράς',
|
22508 | 'menu.array.delete rows': 'Διαγραφή επιλεγμένων σειρών',
|
22509 | 'menu.array.delete column': 'Διαγραφή στήλης',
|
22510 | 'menu.array.delete columns': 'Διαγραφή επιλεγμένων στηλών',
|
22511 | 'submenu.array.insert separator': 'Εισαγωγή διαχωριστικού',
|
22512 | 'menu.insert table': 'Εισαγωγή πίνακα',
|
22513 | 'submenu.table style': 'Στυλ πίνακα',
|
22514 | },
|
22515 |
|
22516 | es: {
|
22517 | 'keyboard.tooltip.functions': 'Funciones',
|
22518 | 'keyboard.tooltip.symbols': 'Símbolos',
|
22519 | 'keyboard.tooltip.greek': 'Letras griegas',
|
22520 | 'keyboard.tooltip.command': 'Modo Comando LaTeX',
|
22521 | 'keyboard.tooltip.numeric': 'Numérico',
|
22522 | 'keyboard.tooltip.roman': 'Letras romanas',
|
22523 | 'tooltip.copy to clipboard': 'Copiar al portapapeles',
|
22524 | 'tooltip.redo': 'Rehacer',
|
22525 | 'tooltip.toggle virtual keyboard': 'Alternar teclado virtual',
|
22526 | 'tooltip.undo': 'Deshacer',
|
22527 | 'menu.insert matrix': 'Añadir Matriz',
|
22528 | 'menu.insert vector': 'Añadir vector',
|
22529 | 'submenu.array.matrix delimiters': 'Delimitadores de Matriz',
|
22530 | 'menu.array.add row above': 'Añadir Línea Antes',
|
22531 | 'menu.array.add row below': 'Añadir Línea Despues',
|
22532 | 'menu.array.add column after': 'Añadir Columna Despues',
|
22533 | 'menu.array.add column before': 'Añadir Columna Antes',
|
22534 | 'menu.array.delete row': 'Borrar Línea',
|
22535 | 'menu.array.delete rows': 'Borrar Líneas Seleccionadas',
|
22536 | 'menu.array.delete column': 'Borrar Columna',
|
22537 | 'menu.array.delete columns': 'Borrar Columnas Seleccionadas',
|
22538 | 'submenu.array.insert separator': 'Insertar un Separador',
|
22539 | 'menu.insert table': 'Insertar Tabla',
|
22540 | 'submenu.table style': 'Estilo de Tabla',
|
22541 | },
|
22542 |
|
22543 | et: {
|
22544 | 'keyboard.tooltip.functions': 'Funktsioonid',
|
22545 | 'keyboard.tooltip.symbols': 'Sümbolid',
|
22546 | 'keyboard.tooltip.greek': 'Kreeka kirjad',
|
22547 | 'keyboard.tooltip.command': 'LaTeXi käsurežiim',
|
22548 | 'keyboard.tooltip.numeric': 'Numbriline',
|
22549 | 'keyboard.tooltip.roman': 'Rooma kirjad',
|
22550 | 'tooltip.copy to clipboard': 'Kopeerida lõikelauale',
|
22551 | 'tooltip.redo': 'Tee uuesti',
|
22552 | 'tooltip.toggle virtual keyboard': 'Lülitage sisse virtuaalne klaviatuur',
|
22553 | 'tooltip.undo': 'Võta tagasi',
|
22554 | 'menu.insert matrix': 'Sisesta maatriks',
|
22555 | 'menu.insert vector': 'Sisesta vektor',
|
22556 | 'submenu.array.matrix delimiters': 'Maatriksi eraldajad',
|
22557 | 'menu.array.add row above': 'Lisa rida pärast',
|
22558 | 'menu.array.add row below': 'Lisa rida enne',
|
22559 | 'menu.array.add column after': 'Lisa veerg pärast',
|
22560 | 'menu.array.add column before': 'Lisa veerg enne',
|
22561 | 'menu.array.delete row': 'Kustuta rida',
|
22562 | 'menu.array.delete rows': 'Kustuta valitud read',
|
22563 | 'menu.array.delete column': 'Kustuta veerg',
|
22564 | 'menu.array.delete columns': 'Kustuta valitud veerud',
|
22565 | 'submenu.array.insert separator': 'Sisestage eraldaja',
|
22566 | 'menu.insert table': 'Sisesta tabeli',
|
22567 | 'submenu.table style': 'Tabeli stiilis',
|
22568 | },
|
22569 |
|
22570 | fa: {
|
22571 | 'keyboard.tooltip.functions': 'توابع',
|
22572 | 'keyboard.tooltip.symbols': 'نمادها',
|
22573 | 'keyboard.tooltip.greek': 'حروف یونانی',
|
22574 | 'keyboard.tooltip.command': 'حالت دستور لاتک',
|
22575 | 'keyboard.tooltip.numeric': 'عددی',
|
22576 | 'keyboard.tooltip.roman': 'حروف رومی',
|
22577 | 'tooltip.copy to clipboard': 'کپی به کلیپبورد',
|
22578 | 'tooltip.redo': 'بازگشت به بعد',
|
22579 | 'tooltip.toggle virtual keyboard': 'نمایش/نهفتن کیبورد مجازی',
|
22580 | 'tooltip.undo': 'بازگشت به قبل',
|
22581 | 'menu.insert matrix': 'ماتریس را وارد کنید',
|
22582 | 'menu.insert vector': 'درج بردار',
|
22583 | 'submenu.array.matrix delimiters': 'مرزهای ماتریس',
|
22584 | 'menu.array.add row above': 'بعد از آن ردیف اضافه کنید',
|
22585 | 'menu.array.add row below': 'ردیف را قبل اضافه کنید',
|
22586 | 'menu.array.add column after': 'اضافه کردن ستون بعد',
|
22587 | 'menu.array.add column before': 'ستون قبل را اضافه کنید',
|
22588 | 'menu.array.delete row': 'ردیف را حذف کنید',
|
22589 | 'menu.array.delete rows': 'ردیف های انتخاب شده را حذف کنید',
|
22590 | 'menu.array.delete column': 'حذف ستون',
|
22591 | 'menu.array.delete columns': 'ستون های انتخاب شده را حذف کنید',
|
22592 | 'submenu.array.insert separator': 'درج جدا کننده',
|
22593 | 'menu.insert table': 'قرار دادن جدول',
|
22594 | 'submenu.table style': 'سبک میز',
|
22595 | },
|
22596 |
|
22597 | fi: {
|
22598 | 'keyboard.tooltip.functions': 'Toiminnot',
|
22599 | 'keyboard.tooltip.symbols': 'Symbolit',
|
22600 | 'keyboard.tooltip.greek': 'Kreikkalaiset kirjeet',
|
22601 | 'keyboard.tooltip.command': 'LaTeX-komentotila',
|
22602 | 'keyboard.tooltip.numeric': 'Numeerinen',
|
22603 | 'keyboard.tooltip.roman': 'Roomalaiset kirjeet',
|
22604 | 'tooltip.copy to clipboard': 'Kopioi leikepöydälle',
|
22605 | 'tooltip.redo': 'Tee uudelleen',
|
22606 | 'tooltip.toggle virtual keyboard': 'Vaihda virtuaalinäppäimistö',
|
22607 | 'tooltip.undo': 'Kumoa',
|
22608 | 'menu.insert matrix': 'Lisää matriisi',
|
22609 | 'menu.insert vector': 'Lisää vektori',
|
22610 | 'submenu.array.matrix delimiters': 'Matriisin erottimet',
|
22611 | 'menu.array.add row above': 'Lisää rivi jälkeen',
|
22612 | 'menu.array.add row below': 'Lisää rivi ennen',
|
22613 | 'menu.array.add column after': 'Lisää sarake jälkeen',
|
22614 | 'menu.array.add column before': 'Lisää sarake ennen',
|
22615 | 'menu.array.delete row': 'Poista rivi',
|
22616 | 'menu.array.delete rows': 'Poista valitut rivit',
|
22617 | 'menu.array.delete column': 'Poista sarake',
|
22618 | 'menu.array.delete columns': 'Poista valitut sarakkeet',
|
22619 | 'submenu.array.insert separator': 'Aseta erotin',
|
22620 | 'menu.insert table': 'Lisää taulukko',
|
22621 | 'submenu.table style': 'Taulukon tyyli',
|
22622 | },
|
22623 |
|
22624 | fr: {
|
22625 | 'keyboard.tooltip.functions': 'Fonctions',
|
22626 | 'keyboard.tooltip.symbols': 'Symboles',
|
22627 | 'keyboard.tooltip.greek': 'Lettres grecques',
|
22628 | 'keyboard.tooltip.command': 'Mode de commandes LaTeX',
|
22629 | 'keyboard.tooltip.numeric': 'Numérique',
|
22630 | 'keyboard.tooltip.roman': 'Lettres romaines',
|
22631 | 'tooltip.copy to clipboard': 'Copier dans le presse-papiers',
|
22632 | 'tooltip.redo': 'Rétablir',
|
22633 | 'tooltip.toggle virtual keyboard': 'Afficher/Masquer le clavier virtuel',
|
22634 | 'tooltip.undo': 'Annuler',
|
22635 | 'menu.insert matrix': 'Insérer une Matrice',
|
22636 | 'menu.insert vector': 'Insérer un Vecteur',
|
22637 | 'submenu.array.matrix delimiters': 'Délimiteurs de la Matrice',
|
22638 | 'menu.array.add row above': 'Ajouter une Ligne Avant',
|
22639 | 'menu.array.add row below': 'Ajouter une Ligne Après',
|
22640 | 'menu.array.add column before': 'Ajouter une Colonne Avant',
|
22641 | 'menu.array.add column after': 'Ajouter une Colonne Après',
|
22642 | 'menu.array.delete row': 'Enlever une Ligne',
|
22643 | 'menu.array.delete rows': 'Enlever les Lignes Sélectionées',
|
22644 | 'menu.array.delete column': 'Enlever une Colone',
|
22645 | 'menu.array.delete columns': 'Enlever les Colonnes Sélectionées',
|
22646 | 'submenu.array.insert separator': 'Insérer un Séparateur',
|
22647 | 'menu.insert table': 'Insérer une Table',
|
22648 | 'submenu.table style': 'Style de la Table',
|
22649 | },
|
22650 |
|
22651 | ga: {
|
22652 | 'keyboard.tooltip.functions': 'Feidhmeanna',
|
22653 | 'keyboard.tooltip.symbols': 'Siombailí',
|
22654 | 'keyboard.tooltip.greek': 'Litreacha na Gréige',
|
22655 | 'keyboard.tooltip.command': 'Mód Ordú LaTeX',
|
22656 | 'keyboard.tooltip.numeric': 'Uimhriúil',
|
22657 | 'keyboard.tooltip.roman': 'Litreacha Rómhánacha',
|
22658 | 'tooltip.copy to clipboard': 'Cóipeáil chuig an Ghearrthaisce',
|
22659 | 'tooltip.redo': 'Athdhéan',
|
22660 | 'tooltip.toggle virtual keyboard': 'Méarchláir Fíorúil a Fháil',
|
22661 | 'tooltip.undo': 'Cealaigh',
|
22662 | 'menu.insert matrix': 'Cuir isteach Maitrís',
|
22663 | 'menu.insert vector': 'Cuir isteach Veicteoir',
|
22664 | 'submenu.array.matrix delimiters': 'Delimiters Maitrís',
|
22665 | 'menu.array.add row above': 'Cuir Rae Tar éis',
|
22666 | 'menu.array.add row below': 'Cuir Rae Roimh',
|
22667 | 'menu.array.add column after': 'Cuir Colún Tar éis',
|
22668 | 'menu.array.add column before': 'Cuir Colún Roimh',
|
22669 | 'menu.array.delete row': 'Scrios Rae',
|
22670 | 'menu.array.delete rows': 'Scrios Sraitheanna Roghnaithe',
|
22671 | 'menu.array.delete column': 'Scrios Colún',
|
22672 | 'menu.array.delete columns': 'Scrios Colúin Roghnaithe',
|
22673 | 'submenu.array.insert separator': 'Cuir Deighilteoir isteach',
|
22674 | 'menu.insert table': 'Ionsáigh Tábla',
|
22675 | 'submenu.table style': 'Stíl Tábla',
|
22676 | },
|
22677 |
|
22678 | he: {
|
22679 | 'keyboard.tooltip.functions': 'פונקציות',
|
22680 | 'keyboard.tooltip.symbols': 'סמלים',
|
22681 | 'keyboard.tooltip.greek': 'אותיות יווניות',
|
22682 | 'keyboard.tooltip.command': 'מצב פקודה לטקס',
|
22683 | 'keyboard.tooltip.numeric': 'מספרי',
|
22684 | 'keyboard.tooltip.roman': 'מכתבים רומיים',
|
22685 | 'tooltip.copy to clipboard': 'העתק ללוח',
|
22686 | 'tooltip.redo': 'לַעֲשׂוֹת שׁוּב',
|
22687 | 'tooltip.toggle virtual keyboard': 'החלף את המקלדת הווירטואלית',
|
22688 | 'tooltip.undo': 'לבטל',
|
22689 | 'menu.insert matrix': 'הכנס מטריקס',
|
22690 | 'menu.insert vector': 'הכנס וקטור',
|
22691 | 'submenu.array.matrix delimiters': 'מפרידי מטריקס',
|
22692 | 'menu.array.add row above': 'הוסף שורה אחרי',
|
22693 | 'menu.array.add row below': 'הוסף שורה לפני',
|
22694 | 'menu.array.add column after': 'הוסף עמודה אחרי',
|
22695 | 'menu.array.add column before': 'הוסף עמודה לפני',
|
22696 | 'menu.array.delete row': 'מחק שורה',
|
22697 | 'menu.array.delete rows': 'מחק שורות שנבחרו',
|
22698 | 'menu.array.delete column': 'מחק עמודה',
|
22699 | 'menu.array.delete columns': 'מחק עמודות שנבחרו',
|
22700 | 'submenu.array.insert separator': 'הכנס מפריד',
|
22701 | 'menu.insert table': 'הכנס טבלה',
|
22702 | 'submenu.table style': 'טבלה סִגְנוֹן',
|
22703 | },
|
22704 |
|
22705 | hr: {
|
22706 | 'keyboard.tooltip.functions': 'Funkcije',
|
22707 | 'keyboard.tooltip.symbols': 'Simboli',
|
22708 | 'keyboard.tooltip.greek': 'Grčka slova',
|
22709 | 'keyboard.tooltip.command': 'LaTeX naredbeni način',
|
22710 | 'keyboard.tooltip.numeric': 'Numerički',
|
22711 | 'keyboard.tooltip.roman': 'Rimska slova',
|
22712 | 'tooltip.copy to clipboard': 'Kopirati u međuspremnik',
|
22713 | 'tooltip.redo': 'Ponovi',
|
22714 | 'tooltip.toggle virtual keyboard': 'Uključi / isključi virtualnu tipkovnicu',
|
22715 | 'tooltip.undo': 'Poništi',
|
22716 | 'menu.insert matrix': 'Umetni matricu',
|
22717 | 'menu.insert vector': 'Umetni vektor',
|
22718 | 'submenu.array.matrix delimiters': 'Matrični razdjelnici',
|
22719 | 'menu.array.add row above': 'Dodaj redak nakon',
|
22720 | 'menu.array.add row below': 'Dodaj redak prije',
|
22721 | 'menu.array.add column after': 'Dodaj stupac nakon',
|
22722 | 'menu.array.add column before': 'Dodaj stupac prije',
|
22723 | 'menu.array.delete row': 'Izbriši redak',
|
22724 | 'menu.array.delete rows': 'Izbriši odabrane retke',
|
22725 | 'menu.array.delete column': 'Izbriši stupac',
|
22726 | 'menu.array.delete columns': 'Izbriši odabrane stupce',
|
22727 | 'submenu.array.insert separator': 'Umetni separator',
|
22728 | 'menu.insert table': 'Umetni tablicu',
|
22729 | 'submenu.table style': 'Stil tabele',
|
22730 | },
|
22731 |
|
22732 | id: {
|
22733 | 'keyboard.tooltip.functions': 'Fungsi',
|
22734 | 'keyboard.tooltip.symbols': 'Simbol',
|
22735 | 'keyboard.tooltip.greek': 'Huruf Yunani',
|
22736 | 'keyboard.tooltip.command': 'Mode Perintah LaTeX',
|
22737 | 'keyboard.tooltip.numeric': 'Numerik',
|
22738 | 'keyboard.tooltip.roman': 'Surat Romawi',
|
22739 | 'tooltip.copy to clipboard': 'Menyalin ke clipboard',
|
22740 | 'tooltip.redo': 'Mengulangi',
|
22741 | 'tooltip.toggle virtual keyboard': 'Alihkan Keyboard Virtual',
|
22742 | 'tooltip.undo': 'Membuka',
|
22743 | 'menu.insert matrix': 'Sisipkan Matriks',
|
22744 | 'menu.insert vector': 'Sisipkan Vektor',
|
22745 | 'submenu.array.matrix delimiters': 'Pembatas Matriks',
|
22746 | 'menu.array.add row above': 'Tambahkan Baris Setelah',
|
22747 | 'menu.array.add row below': 'Tambahkan Baris Sebelumnya',
|
22748 | 'menu.array.add column after': 'Tambahkan Kolom Setelah',
|
22749 | 'menu.array.add column before': 'Tambahkan Kolom Sebelumnya',
|
22750 | 'menu.array.delete row': 'Hapus Baris',
|
22751 | 'menu.array.delete rows': 'Hapus Baris yang Dipilih',
|
22752 | 'menu.array.delete column': 'Hapus Kolom',
|
22753 | 'menu.array.delete columns': 'Hapus Kolom yang Dipilih',
|
22754 | 'submenu.array.insert separator': 'Sisipkan Pemisah',
|
22755 | 'menu.insert table': 'Sisipkan Tabel',
|
22756 | 'submenu.table style': 'Gaya Tabel',
|
22757 | },
|
22758 |
|
22759 | hi: {
|
22760 | 'keyboard.tooltip.functions': 'कार्यों',
|
22761 | 'keyboard.tooltip.symbols': 'प्रतीक',
|
22762 | 'keyboard.tooltip.greek': 'ग्रीक अक्षर',
|
22763 | 'keyboard.tooltip.command': 'लाटेक्स कमांड मोड',
|
22764 | 'keyboard.tooltip.numeric': 'संख्यात्मक',
|
22765 | 'keyboard.tooltip.roman': 'रोमन पत्र',
|
22766 | 'tooltip.copy to clipboard': 'क्लिपबोर्ड पर कॉपी करें',
|
22767 | 'tooltip.redo': 'फिर से करें',
|
22768 | 'tooltip.toggle virtual keyboard': 'वर्चुअल कीबोर्ड टॉगल करें',
|
22769 | 'tooltip.undo': 'पूर्ववत',
|
22770 | 'menu.insert matrix': 'मैट्रिक्स डालें',
|
22771 | 'menu.insert vector': 'वेक्टर डालें',
|
22772 | 'submenu.array.matrix delimiters': 'मैट्रिक्स सीमांकक',
|
22773 | 'menu.array.add row above': 'बाद में पंक्ति जोड़ें',
|
22774 | 'menu.array.add row below': 'पहले पंक्ति जोड़ें',
|
22775 | 'menu.array.add column after': 'बाद में कॉलम जोड़ें',
|
22776 | 'menu.array.add column before': 'पहले कॉलम जोड़ें',
|
22777 | 'menu.array.delete row': 'पंक्ति को हटाएं',
|
22778 | 'menu.array.delete rows': 'चयनित पंक्तियों को हटाएं',
|
22779 | 'menu.array.delete column': 'कॉलम हटाएं',
|
22780 | 'menu.array.delete columns': 'चयनित कॉलम हटाएं',
|
22781 | 'submenu.array.insert separator': 'विभाजक डालें',
|
22782 | 'menu.insert table': 'टेबल इंसर्ट करें',
|
22783 | 'submenu.table style': 'टेबल स्टाइल',
|
22784 | },
|
22785 |
|
22786 | hu: {
|
22787 | 'keyboard.tooltip.functions': 'Funkciók',
|
22788 | 'keyboard.tooltip.symbols': 'Szimbólumok',
|
22789 | 'keyboard.tooltip.greek': 'Görög levelek',
|
22790 | 'keyboard.tooltip.command': 'LaTeX Parancs mód',
|
22791 | 'keyboard.tooltip.numeric': 'Numerikus',
|
22792 | 'keyboard.tooltip.roman': 'Római levelek',
|
22793 | 'tooltip.copy to clipboard': 'Másolja a vágólapra',
|
22794 | 'tooltip.redo': 'Újra',
|
22795 | 'tooltip.toggle virtual keyboard': 'Váltás a virtuális billentyűzetre',
|
22796 | 'tooltip.undo': 'Visszavonás',
|
22797 | 'menu.insert matrix': 'Helyezze be a Mátrixot',
|
22798 | 'menu.insert vector': 'Vektor beszúrása',
|
22799 | 'submenu.array.matrix delimiters': 'Mátrixhatárolók',
|
22800 | 'menu.array.add row above': 'Sor hozzáadása után',
|
22801 | 'menu.array.add row below': 'Add Add Sor előtt',
|
22802 | 'menu.array.add column after': 'Oszlop hozzáadása után',
|
22803 | 'menu.array.add column before': 'Add oszlop előtt',
|
22804 | 'menu.array.delete row': 'Sor törlése',
|
22805 | 'menu.array.delete rows': 'Kijelölt sorok törlése',
|
22806 | 'menu.array.delete column': 'Oszlop törlése',
|
22807 | 'menu.array.delete columns': 'A kijelölt oszlopok törlése',
|
22808 | 'submenu.array.insert separator': 'Helyezze be az elválasztót',
|
22809 | 'menu.insert table': 'Helyezze be a táblázatot',
|
22810 | 'submenu.table style': 'Táblázatos stílus',
|
22811 | },
|
22812 |
|
22813 | it: {
|
22814 | 'keyboard.tooltip.functions': 'Funzioni',
|
22815 | 'keyboard.tooltip.symbols': 'Simboli',
|
22816 | 'keyboard.tooltip.greek': 'Lettere greche',
|
22817 | 'keyboard.tooltip.command': 'Modalità di comando LaTeX',
|
22818 | 'keyboard.tooltip.numeric': 'Numerico',
|
22819 | 'keyboard.tooltip.roman': 'Lettere romane',
|
22820 | 'tooltip.copy to clipboard': 'Copia negli appunti',
|
22821 | 'tooltip.redo': 'Rifare',
|
22822 | 'tooltip.toggle virtual keyboard': 'Attiva / disattiva la tastiera virtuale',
|
22823 | 'tooltip.undo': 'Disfare',
|
22824 | 'menu.insert matrix': 'Inserisci una Matrice',
|
22825 | 'menu.insert vector': 'Inserisci Vettore',
|
22826 | 'submenu.array.matrix delimiters': 'Delimitatori di Matrice',
|
22827 | 'menu.array.add row above': 'Aggiungi una Riga Prima',
|
22828 | 'menu.array.add row below': 'Aggiungi una Riga Dopo',
|
22829 | 'menu.array.add column before': 'Aggiungi una Colonna Prima',
|
22830 | 'menu.array.add column after': 'Aggiungi una Colonna Dopo',
|
22831 | 'menu.array.delete row': 'Rimuovi una Riga',
|
22832 | 'menu.array.delete rows': 'Rimuovi le Righe Selezionate',
|
22833 | 'menu.array.delete column': 'Rimuovi una Colonna',
|
22834 | 'menu.array.delete columns': 'Rimuovi le Colonne Selezionate',
|
22835 | 'submenu.array.insert separator': 'Inserisci un Separatore',
|
22836 | 'menu.insert table': 'Inserisci Tabella',
|
22837 | 'submenu.table style': 'Stile tabella',
|
22838 | },
|
22839 |
|
22840 | is: {
|
22841 | 'keyboard.tooltip.functions': 'Aðgerðir',
|
22842 | 'keyboard.tooltip.symbols': 'Tákn',
|
22843 | 'keyboard.tooltip.greek': 'Grísk bréf',
|
22844 | 'keyboard.tooltip.command': 'LaTeX stjórnunarstilling',
|
22845 | 'keyboard.tooltip.numeric': 'Tölulegt',
|
22846 | 'keyboard.tooltip.roman': 'Rómversk bréf',
|
22847 | 'tooltip.copy to clipboard': 'Afritaðu á klemmuspjald',
|
22848 | 'tooltip.redo': 'Endurtaka',
|
22849 | 'tooltip.toggle virtual keyboard': 'Skiptu um sýndarlyklaborð',
|
22850 | 'tooltip.undo': 'Afturkalla',
|
22851 | 'menu.insert matrix': 'Settu fylki inn',
|
22852 | 'menu.insert vector': 'Settu inn Vector',
|
22853 | 'submenu.array.matrix delimiters': 'Matrix afmörkun',
|
22854 | 'menu.array.add row above': 'Bæta við röð á eftir',
|
22855 | 'menu.array.add row below': 'Bæta við röð áður',
|
22856 | 'menu.array.add column after': 'Bæta við dálki á eftir',
|
22857 | 'menu.array.add column before': 'Bæta við dálki áður',
|
22858 | 'menu.array.delete row': 'Eyða röð',
|
22859 | 'menu.array.delete rows': 'Eyða völdum línum',
|
22860 | 'menu.array.delete column': 'Eyða dálki',
|
22861 | 'menu.array.delete columns': 'Eyða völdum dálkum',
|
22862 | 'submenu.array.insert separator': 'Settu skiljuna í',
|
22863 | 'menu.insert table': 'Settu inn töflu',
|
22864 | 'submenu.table style': 'Töflu stíl',
|
22865 | },
|
22866 |
|
22867 | ja: {
|
22868 | 'keyboard.tooltip.functions': '関数',
|
22869 | 'keyboard.tooltip.symbols': 'シンボル',
|
22870 | 'keyboard.tooltip.greek': 'ギリシャ文字',
|
22871 | 'keyboard.tooltip.command': 'ラテックスコマンドモード',
|
22872 | 'keyboard.tooltip.numeric': '数値',
|
22873 | 'keyboard.tooltip.roman': 'ローマ字',
|
22874 | 'tooltip.copy to clipboard': 'クリップボードにコピー',
|
22875 | 'tooltip.redo': 'やり直し',
|
22876 | 'tooltip.toggle virtual keyboard': '仮想キーボードの切り替え',
|
22877 | 'tooltip.undo': '元に戻す',
|
22878 | 'menu.insert matrix': 'マトリックスを挿入',
|
22879 | 'menu.insert vector': 'ベクトルを挿入',
|
22880 | 'submenu.array.matrix delimiters': '行列区切り文字',
|
22881 | 'menu.array.add row above': '後に行を追加',
|
22882 | 'menu.array.add row below': '前に行を追加',
|
22883 | 'menu.array.add column after': '後に列を追加',
|
22884 | 'menu.array.add column before': '前に列を追加',
|
22885 | 'menu.array.delete row': '行を削除',
|
22886 | 'menu.array.delete rows': '選択した行を削除する',
|
22887 | 'menu.array.delete column': '列を削除',
|
22888 | 'menu.array.delete columns': '選択した列を削除する',
|
22889 | 'submenu.array.insert separator': 'セパレーターを挿入',
|
22890 | 'menu.insert table': 'テーブルを挿入',
|
22891 | 'submenu.table style': 'テーブルスタイル',
|
22892 | },
|
22893 |
|
22894 | ko: {
|
22895 | 'keyboard.tooltip.functions': '기능',
|
22896 | 'keyboard.tooltip.symbols': '기호',
|
22897 | 'keyboard.tooltip.greek': '그리스 문자',
|
22898 | 'keyboard.tooltip.command': '유액 명령 모드',
|
22899 | 'keyboard.tooltip.numeric': '숫자',
|
22900 | 'keyboard.tooltip.roman': '로마 문자',
|
22901 | 'tooltip.copy to clipboard': '클립 보드에 복사',
|
22902 | 'tooltip.redo': '다시 하다',
|
22903 | 'tooltip.toggle virtual keyboard': '가상 키보드 전환',
|
22904 | 'tooltip.undo': '실행 취소',
|
22905 | 'menu.insert matrix': '매트릭스 삽입',
|
22906 | 'menu.insert vector': '벡터 삽입',
|
22907 | 'submenu.array.matrix delimiters': '행렬 구분 기호',
|
22908 | 'menu.array.add row above': '뒤에 행 추가',
|
22909 | 'menu.array.add row below': '앞에 행 추가',
|
22910 | 'menu.array.add column after': '뒤에 열 추가',
|
22911 | 'menu.array.add column before': '앞에 열 추가',
|
22912 | 'menu.array.delete row': '행 삭제',
|
22913 | 'menu.array.delete rows': '선택한 행 삭제',
|
22914 | 'menu.array.delete column': '열 삭제',
|
22915 | 'menu.array.delete columns': '선택한 열 삭제',
|
22916 | 'submenu.array.insert separator': '구분자 삽입',
|
22917 | 'menu.insert table': '표 삽입',
|
22918 | 'submenu.table style': '테이블 스타일',
|
22919 | },
|
22920 |
|
22921 | lv: {
|
22922 | 'keyboard.tooltip.functions': 'Funkcijas',
|
22923 | 'keyboard.tooltip.symbols': 'Simboli',
|
22924 | 'keyboard.tooltip.greek': 'Grieķu burti',
|
22925 | 'keyboard.tooltip.command': 'LaTeX komandu režīms',
|
22926 | 'keyboard.tooltip.numeric': 'Ciparu skaitlis',
|
22927 | 'keyboard.tooltip.roman': 'Romiešu vēstules',
|
22928 | 'tooltip.copy to clipboard': 'Kopēt starpliktuvē',
|
22929 | 'tooltip.redo': 'Pārtaisīt',
|
22930 | 'tooltip.toggle virtual keyboard': 'Pārslēgt virtuālo tastatūru',
|
22931 | 'tooltip.undo': 'Atsaukt',
|
22932 | 'menu.insert matrix': 'Ievietojiet matricu',
|
22933 | 'menu.insert vector': 'Ievietot vektoru',
|
22934 | 'submenu.array.matrix delimiters': 'Matricas norobežotāji',
|
22935 | 'menu.array.add row above': 'Pievienot rindu pēc',
|
22936 | 'menu.array.add row below': 'Pievienot rindu pirms',
|
22937 | 'menu.array.add column after': 'Pievienot kolonnu pēc',
|
22938 | 'menu.array.add column before': 'Pievienot kolonnu pirms',
|
22939 | 'menu.array.delete row': 'Dzēst rindu',
|
22940 | 'menu.array.delete rows': 'Dzēst atlasītās rindas',
|
22941 | 'menu.array.delete column': 'Dzēst kolonnu',
|
22942 | 'menu.array.delete columns': 'Dzēst atlasītās kolonnas',
|
22943 | 'submenu.array.insert separator': 'Ievietojiet atdalītāju',
|
22944 | 'menu.insert table': 'Ievietojiet tabulu',
|
22945 | 'submenu.table style': 'Galda stils',
|
22946 | },
|
22947 |
|
22948 | lt: {
|
22949 | 'keyboard.tooltip.functions': 'Funkcijos',
|
22950 | 'keyboard.tooltip.symbols': 'Simboliai',
|
22951 | 'keyboard.tooltip.greek': 'Graikiškos raidės',
|
22952 | 'keyboard.tooltip.command': 'LaTeX komandų režimas',
|
22953 | 'keyboard.tooltip.numeric': 'Skaitmeninis',
|
22954 | 'keyboard.tooltip.roman': 'Romos laiškai',
|
22955 | 'tooltip.copy to clipboard': 'Nukopijuoti į iškarpinę',
|
22956 | 'tooltip.redo': 'Perdaryti',
|
22957 | 'tooltip.toggle virtual keyboard': 'Perjungti virtualiąją klaviatūrą',
|
22958 | 'tooltip.undo': 'Atšaukti',
|
22959 | 'menu.insert matrix': 'Ievietojiet matricu',
|
22960 | 'menu.insert vector': 'Ievietot vektoru',
|
22961 | 'submenu.array.matrix delimiters': 'Matricas norobežotāji',
|
22962 | 'menu.array.add row above': 'Pievienot rindu pēc',
|
22963 | 'menu.array.add row below': 'Pievienot rindu pirms',
|
22964 | 'menu.array.add column after': 'Pievienot kolonnu pēc',
|
22965 | 'menu.array.add column before': 'Pievienot kolonnu pirms',
|
22966 | 'menu.array.delete row': 'Dzēst rindu',
|
22967 | 'menu.array.delete rows': 'Dzēst atlasītās rindas',
|
22968 | 'menu.array.delete column': 'Dzēst kolonnu',
|
22969 | 'menu.array.delete columns': 'Dzēst atlasītās kolonnas',
|
22970 | 'submenu.array.insert separator': 'Ievietojiet atdalītāju',
|
22971 | 'menu.insert table': 'Ievietojiet tabulu',
|
22972 | 'submenu.table style': 'Tabulas stili',
|
22973 | },
|
22974 |
|
22975 | lu: {
|
22976 | 'keyboard.tooltip.functions': 'Funktiounen',
|
22977 | 'keyboard.tooltip.symbols': 'Symboler',
|
22978 | 'keyboard.tooltip.greek': 'Griichesch Bréiwer',
|
22979 | 'keyboard.tooltip.command': 'Latex Kommando Modus',
|
22980 | 'keyboard.tooltip.numeric': 'Numeresch',
|
22981 | 'keyboard.tooltip.roman': 'Réimesch Bréiwer',
|
22982 | 'tooltip.copy to clipboard': 'Kopéiert op Clipboard',
|
22983 | 'tooltip.redo': 'Nees nei maachen',
|
22984 | 'tooltip.toggle virtual keyboard': 'Wiesselt Virtuell Tastatur',
|
22985 | 'tooltip.undo': 'Undoen',
|
22986 | 'menu.insert matrix': 'Matrix asetzen',
|
22987 | 'menu.insert vector': 'Insert Vector',
|
22988 | 'submenu.array.matrix delimiters': 'Matrix Ofgrenzer',
|
22989 | 'menu.array.add row above': 'Dobäizemaachen Rei No',
|
22990 | 'menu.array.add row below': 'Füügt Rei vir',
|
22991 | 'menu.array.add column after': 'Dobäizemaachen Kolonn No',
|
22992 | 'menu.array.add column before': 'Kolonn derbäi Virun',
|
22993 | 'menu.array.delete row': 'Rad läschen',
|
22994 | 'menu.array.delete rows': 'Läscht Ausgewielte Reien',
|
22995 | 'menu.array.delete column': 'Läscht Kolonn',
|
22996 | 'menu.array.delete columns': 'Läscht Ausgewielte Kolonnen',
|
22997 | 'submenu.array.insert separator': 'Insert Separator',
|
22998 | 'menu.insert table': 'Dësch anzeginn',
|
22999 | 'submenu.table style': 'Dësch Style',
|
23000 | },
|
23001 |
|
23002 | nl: {
|
23003 | 'keyboard.tooltip.functions': 'Functies',
|
23004 | 'keyboard.tooltip.symbols': 'Symbolen',
|
23005 | 'keyboard.tooltip.greek': 'Griekse letters',
|
23006 | 'keyboard.tooltip.command': 'LaTeX commando mode',
|
23007 | 'keyboard.tooltip.numeric': 'Numeriek',
|
23008 | 'keyboard.tooltip.roman': 'Romeinse letters',
|
23009 | 'tooltip.copy to clipboard': 'Kopiëren naar klembord',
|
23010 | 'tooltip.redo': 'Opnieuw',
|
23011 | 'tooltip.toggle virtual keyboard': 'Schakel naar virtueel toetsenbord',
|
23012 | 'tooltip.undo': 'Ongedaan maken',
|
23013 | 'menu.insert matrix': 'Matrix invoegen',
|
23014 | 'menu.insert vector': 'Vector invoegen',
|
23015 | 'submenu.array.matrix delimiters': 'Matrixscheidingstekens',
|
23016 | 'menu.array.add row above': 'Rij toevoegen na',
|
23017 | 'menu.array.add row below': 'Rij toevoegen eerder',
|
23018 | 'menu.array.add column after': 'Kolom toevoegen na',
|
23019 | 'menu.array.add column before': 'Kolom toevoegen voor',
|
23020 | 'menu.array.delete row': 'Verwijder rij',
|
23021 | 'menu.array.delete rows': 'Geselecteerde rijen verwijderen',
|
23022 | 'menu.array.delete column': 'Kolom verwijderen',
|
23023 | 'menu.array.delete columns': 'Geselecteerde kolommen verwijderen',
|
23024 | 'submenu.array.insert separator': 'Scheidingsteken invoegen',
|
23025 | 'menu.insert table': 'Tabel invoegen',
|
23026 | 'submenu.table style': 'Tabelstijl',
|
23027 | },
|
23028 |
|
23029 | no: {
|
23030 | 'keyboard.tooltip.functions': 'Funksjoner',
|
23031 | 'keyboard.tooltip.symbols': 'Symboler',
|
23032 | 'keyboard.tooltip.greek': 'Greske bokstaver',
|
23033 | 'keyboard.tooltip.command': 'LaTeX kommandomodus',
|
23034 | 'keyboard.tooltip.numeric': 'Numerisk',
|
23035 | 'keyboard.tooltip.roman': 'Romerske bokstaver',
|
23036 | 'tooltip.copy to clipboard': 'Kopiere til utklippstavle',
|
23037 | 'tooltip.redo': 'Gjøre om',
|
23038 | 'tooltip.toggle virtual keyboard': 'Bytt virtuelt tastatur',
|
23039 | 'tooltip.undo': 'Angre',
|
23040 | 'menu.insert matrix': 'Sett inn matrise',
|
23041 | 'menu.insert vector': 'Sett inn vektor',
|
23042 | 'submenu.array.matrix delimiters': 'Matrix avgrensere',
|
23043 | 'menu.array.add row above': 'Legg til rad etter',
|
23044 | 'menu.array.add row below': 'Legg til rad før',
|
23045 | 'menu.array.add column after': 'Legg til kolonne etter',
|
23046 | 'menu.array.add column before': 'Legg til kolonne før',
|
23047 | 'menu.array.delete row': 'Slett rad',
|
23048 | 'menu.array.delete rows': 'Slett valgte rader',
|
23049 | 'menu.array.delete column': 'Slett kolonne',
|
23050 | 'menu.array.delete columns': 'Slett valgte kolonner',
|
23051 | 'submenu.array.insert separator': 'Sett inn skilletegn',
|
23052 | 'menu.insert table': 'Sett inn tabell',
|
23053 | 'submenu.table style': 'Tabellstil',
|
23054 | },
|
23055 |
|
23056 | mk: {
|
23057 | 'keyboard.tooltip.functions': 'Функции',
|
23058 | 'keyboard.tooltip.symbols': 'Симболи',
|
23059 | 'keyboard.tooltip.greek': 'Грчки букви',
|
23060 | 'keyboard.tooltip.command': 'Режим на команда во латекс',
|
23061 | 'keyboard.tooltip.numeric': 'Нумерички',
|
23062 | 'keyboard.tooltip.roman': 'Римски писма',
|
23063 | 'tooltip.copy to clipboard': 'Копирајте во клипборд',
|
23064 | 'tooltip.redo': 'Повторно',
|
23065 | 'tooltip.toggle virtual keyboard': 'Вклучете ја виртуелната тастатура',
|
23066 | 'tooltip.undo': 'Врати',
|
23067 | 'menu.insert matrix': 'Вметнете матрица',
|
23068 | 'menu.insert vector': 'Вметни вектор',
|
23069 | 'submenu.array.matrix delimiters': 'Разграничувачи на матрица',
|
23070 | 'menu.array.add row above': 'Додадете ред после',
|
23071 | 'menu.array.add row below': 'Додади ред пред тоа',
|
23072 | 'menu.array.add column after': 'Додадете колона после',
|
23073 | 'menu.array.add column before': 'Додадете колона пред тоа',
|
23074 | 'menu.array.delete row': 'Избриши го редот',
|
23075 | 'menu.array.delete rows': 'Избришете ги избраните редови',
|
23076 | 'menu.array.delete column': 'Избриши ја колоната',
|
23077 | 'menu.array.delete columns': 'Избриши ја колоната',
|
23078 | 'submenu.array.insert separator': 'Вметнете сепаратор',
|
23079 | 'menu.insert table': 'Вметни табела',
|
23080 | 'submenu.table style': 'Табела стил',
|
23081 | },
|
23082 |
|
23083 | pl: {
|
23084 | 'keyboard.tooltip.functions': 'Funkcje',
|
23085 | 'keyboard.tooltip.symbols': 'Symbolika',
|
23086 | 'keyboard.tooltip.greek': 'Litery greckie',
|
23087 | 'keyboard.tooltip.command': 'Tryb poleceń LaTeX',
|
23088 | 'keyboard.tooltip.numeric': 'Numeryczne',
|
23089 | 'keyboard.tooltip.roman': 'Litery rzymskie',
|
23090 | 'tooltip.copy to clipboard': 'Kopiuj do Schowka',
|
23091 | 'tooltip.redo': 'Przywróć',
|
23092 | 'tooltip.toggle virtual keyboard': 'Przełącz wirtualną klawiaturę',
|
23093 | 'tooltip.undo': 'Cofnij',
|
23094 | 'menu.insert matrix': 'Wstaw macierz',
|
23095 | 'menu.insert vector': 'Wstaw wektor',
|
23096 | 'submenu.array.matrix delimiters': 'Ograniczniki macierzy',
|
23097 | 'menu.array.add row above': 'Dodaj wiersz po',
|
23098 | 'menu.array.add row below': 'Dodaj wiersz przed',
|
23099 | 'menu.array.add column after': 'Dodaj kolumnę po',
|
23100 | 'menu.array.add column before': 'Dodaj kolumnę przed',
|
23101 | 'menu.array.delete row': 'Usuń wiersz',
|
23102 | 'menu.array.delete rows': 'Usuń wybrane wiersze',
|
23103 | 'menu.array.delete column': 'Usuń kolumnę',
|
23104 | 'menu.array.delete columns': 'Usuń wybrane kolumny',
|
23105 | 'submenu.array.insert separator': 'Wstaw separator',
|
23106 | 'menu.insert table': 'Wypełnij tabelę',
|
23107 | 'submenu.table style': 'Styl tabelę',
|
23108 | },
|
23109 |
|
23110 | pt: {
|
23111 | 'keyboard.tooltip.functions': 'Functions',
|
23112 | 'keyboard.tooltip.symbols': 'Símbolos',
|
23113 | 'keyboard.tooltip.greek': 'Letras gregas',
|
23114 | 'keyboard.tooltip.command': 'Modo de Comando LaTeX',
|
23115 | 'keyboard.tooltip.numeric': 'Numérico',
|
23116 | 'keyboard.tooltip.roman': 'Letras romanas',
|
23117 | 'tooltip.copy to clipboard': 'Copiar para área de transferência',
|
23118 | 'tooltip.redo': 'Refazer',
|
23119 | 'tooltip.toggle virtual keyboard': 'Alternar teclado virtual',
|
23120 | 'tooltip.undo': 'Desfazer',
|
23121 | 'menu.insert matrix': 'Inserir Matriz',
|
23122 | 'menu.insert vector': 'Inserir vetor',
|
23123 | 'submenu.array.matrix delimiters': 'Delimitadores de matriz',
|
23124 | 'menu.array.add row above': 'Adicionar linha depois',
|
23125 | 'menu.array.add row below': 'Adicionar linha antes',
|
23126 | 'menu.array.add column after': 'Adicionar coluna depois',
|
23127 | 'menu.array.add column before': 'Adicionar coluna antes',
|
23128 | 'menu.array.delete row': 'Excluir linha',
|
23129 | 'menu.array.delete rows': 'Excluir linhas selecionadas',
|
23130 | 'menu.array.delete column': 'Apagar Coluna',
|
23131 | 'menu.array.delete columns': 'Excluir Colunas Selecionadas',
|
23132 | 'submenu.array.insert separator': 'Inserir Separador',
|
23133 | 'menu.insert table': 'Insira a tabela',
|
23134 | 'submenu.table style': 'Estilo tabela',
|
23135 | },
|
23136 |
|
23137 | ro: {
|
23138 | 'keyboard.tooltip.functions': 'Funcții',
|
23139 | 'keyboard.tooltip.symbols': 'Simboluri',
|
23140 | 'keyboard.tooltip.greek': 'Scrisori grecești',
|
23141 | 'keyboard.tooltip.command': 'Modul de comandă latex',
|
23142 | 'keyboard.tooltip.numeric': 'Numeric',
|
23143 | 'keyboard.tooltip.roman': 'Scrisori romane',
|
23144 | 'tooltip.copy to clipboard': 'Copiați în clipboard',
|
23145 | 'tooltip.redo': 'A reface',
|
23146 | 'tooltip.toggle virtual keyboard': 'Comutați tastatura virtuală',
|
23147 | 'tooltip.undo': 'Anula',
|
23148 | 'menu.insert matrix': 'Introduceți Matrix',
|
23149 | 'menu.insert vector': 'Inserați Vector',
|
23150 | 'submenu.array.matrix delimiters': 'Delimitatori de matrice',
|
23151 | 'menu.array.add row above': 'Adăugați rândul după',
|
23152 | 'menu.array.add row below': 'Adăugați rândul înainte',
|
23153 | 'menu.array.add column after': 'Adăugați o coloană după',
|
23154 | 'menu.array.add column before': 'Adăugați o coloană înainte',
|
23155 | 'menu.array.delete row': 'Ștergeți rândul',
|
23156 | 'menu.array.delete rows': 'Ștergeți rândurile selectate',
|
23157 | 'menu.array.delete column': 'Ștergeți coloana',
|
23158 | 'menu.array.delete columns': 'Ștergeți coloanele selectate',
|
23159 | 'submenu.array.insert separator': 'Introduceți separatorul',
|
23160 | 'menu.insert table': 'Introduceți tabelul',
|
23161 | 'submenu.table style': 'Table style',
|
23162 | },
|
23163 |
|
23164 | ru: {
|
23165 | 'keyboard.tooltip.functions': 'Функции',
|
23166 | 'keyboard.tooltip.symbols': 'Символы',
|
23167 | 'keyboard.tooltip.greek': 'Греческие буквы',
|
23168 | 'keyboard.tooltip.command': 'Режим командной строки Латекс',
|
23169 | 'keyboard.tooltip.numeric': 'числовой',
|
23170 | 'keyboard.tooltip.roman': 'Латинские буквы',
|
23171 | 'tooltip.copy to clipboard': 'Скопировать в буфер обмена',
|
23172 | 'tooltip.redo': 'переделывать',
|
23173 | 'tooltip.toggle virtual keyboard': 'Переключить виртуальную клавиатуру',
|
23174 | 'tooltip.undo': 'расстегивать',
|
23175 | 'menu.insert matrix': 'Вставить матрицу',
|
23176 | 'menu.insert vector': 'Вставить вектор',
|
23177 | 'submenu.array.matrix delimiters': 'Матричные разделители',
|
23178 | 'menu.array.add row above': 'Добавить строку после',
|
23179 | 'menu.array.add row below': 'Добавить строку перед',
|
23180 | 'menu.array.add column after': 'Добавить столбец после',
|
23181 | 'menu.array.add column before': 'Добавить столбец перед',
|
23182 | 'menu.array.delete row': 'Удалить строку',
|
23183 | 'menu.array.delete rows': 'Удалить выбранные строки',
|
23184 | 'menu.array.delete column': 'Удалить столбец',
|
23185 | 'menu.array.delete columns': 'Удалить выбранные столбцы',
|
23186 | 'submenu.array.insert separator': 'Вставить разделитель',
|
23187 | 'menu.insert table': 'Вставить таблицу',
|
23188 | 'submenu.table style': 'Табличный стиль',
|
23189 | },
|
23190 |
|
23191 | sk: {
|
23192 | 'keyboard.tooltip.functions': 'Functions',
|
23193 | 'keyboard.tooltip.symbols': 'Symboly',
|
23194 | 'keyboard.tooltip.greek': 'Grécke listy',
|
23195 | 'keyboard.tooltip.command': 'Príkazový režim LaTeX',
|
23196 | 'keyboard.tooltip.numeric': 'Numerické',
|
23197 | 'keyboard.tooltip.roman': 'Rímske listy',
|
23198 | 'tooltip.copy to clipboard': 'Skopírovať do schránky',
|
23199 | 'tooltip.redo': 'Znova',
|
23200 | 'tooltip.toggle virtual keyboard': 'Prepnúť virtuálnu klávesnicu',
|
23201 | 'tooltip.undo': 'Vrátenie späť',
|
23202 | 'menu.insert matrix': 'Vložte maticu',
|
23203 | 'menu.insert vector': 'Vložte vektor',
|
23204 | 'submenu.array.matrix delimiters': 'Oddeľovače matíc',
|
23205 | 'menu.array.add row above': 'Pridajte riadok za',
|
23206 | 'menu.array.add row below': 'Pridajte riadok pred',
|
23207 | 'menu.array.add column after': 'Pridať stĺpec za',
|
23208 | 'menu.array.add column before': 'Pridajte stĺpec predtým',
|
23209 | 'menu.array.delete row': 'Odstrániť riadok',
|
23210 | 'menu.array.delete rows': 'Odstrániť vybraté riadky',
|
23211 | 'menu.array.delete column': 'Odstrániť stĺpec',
|
23212 | 'menu.array.delete columns': 'Odstrániť vybraté stĺpce',
|
23213 | 'submenu.array.insert separator': 'Vložte oddeľovač',
|
23214 | 'menu.insert table': 'Vložte tabuľku',
|
23215 | 'submenu.table style': 'Štýl tabuľky',
|
23216 | },
|
23217 |
|
23218 | sl: {
|
23219 | 'keyboard.tooltip.functions': 'Funkcije',
|
23220 | 'keyboard.tooltip.symbols': 'Simboli',
|
23221 | 'keyboard.tooltip.greek': 'Grška pisma',
|
23222 | 'keyboard.tooltip.command': 'Ukazni način LaTeX',
|
23223 | 'keyboard.tooltip.numeric': 'Številsko',
|
23224 | 'keyboard.tooltip.roman': 'Rimska pisma',
|
23225 | 'tooltip.copy to clipboard': 'Kopirati v odložišče',
|
23226 | 'tooltip.redo': 'Ponovi',
|
23227 | 'tooltip.toggle virtual keyboard': 'Preklop navidezne tipkovnice',
|
23228 | 'tooltip.undo': 'Razveljavi',
|
23229 | 'menu.insert matrix': 'Vstavi matrico',
|
23230 | 'menu.insert vector': 'Vstavi vektor',
|
23231 | 'submenu.array.matrix delimiters': 'Matrični ločevalniki',
|
23232 | 'menu.array.add row above': 'Dodaj vrstico po',
|
23233 | 'menu.array.add row below': 'Dodaj vrstico prej',
|
23234 | 'menu.array.add column after': 'Dodaj stolpec po',
|
23235 | 'menu.array.add column before': 'Dodaj stolpec prej',
|
23236 | 'menu.array.delete row': 'Izbriši vrstico',
|
23237 | 'menu.array.delete rows': 'Izbriši izbrane vrstice',
|
23238 | 'menu.array.delete column': 'Izbriši stolpec',
|
23239 | 'menu.array.delete columns': 'Izbriši izbrane stolpce',
|
23240 | 'submenu.array.insert separator': 'Vstavi ločilo',
|
23241 | 'menu.insert table': 'Vstavi tabelo',
|
23242 | 'submenu.table style': 'Tabela slog',
|
23243 | },
|
23244 |
|
23245 | sq: {
|
23246 | 'keyboard.tooltip.functions': 'Funksione',
|
23247 | 'keyboard.tooltip.symbols': 'Simbolet',
|
23248 | 'keyboard.tooltip.greek': 'Letrat Greke',
|
23249 | 'keyboard.tooltip.command': 'Modaliteti i komandës latex',
|
23250 | 'keyboard.tooltip.numeric': 'Numerike',
|
23251 | 'keyboard.tooltip.roman': 'Letrat romake',
|
23252 | 'tooltip.copy to clipboard': 'Kopjoni në Clipboard',
|
23253 | 'tooltip.redo': 'Riparo',
|
23254 | 'tooltip.toggle virtual keyboard': 'Aktivizo tastierën virtuale',
|
23255 | 'tooltip.undo': 'Zhbëj',
|
23256 | 'menu.insert matrix': 'Vendosni Matricën',
|
23257 | 'menu.insert vector': 'Vendos vektorin',
|
23258 | 'submenu.array.matrix delimiters': 'Përcaktuesit e matricës',
|
23259 | 'menu.array.add row above': 'Shto Rreshtin Pas',
|
23260 | 'menu.array.add row below': 'Shto Rreshtin Para',
|
23261 | 'menu.array.add column after': 'Shto kolonën pas',
|
23262 | 'menu.array.add column before': 'Shto kolonën para',
|
23263 | 'menu.array.delete row': 'Fshi Rreshtin',
|
23264 | 'menu.array.delete rows': 'Fshi rreshtat e zgjedhur',
|
23265 | 'menu.array.delete column': 'Fshi kolonën',
|
23266 | 'menu.array.delete columns': 'Fshi kolonat e zgjedhura',
|
23267 | 'submenu.array.insert separator': 'Vendos Ndarësin',
|
23268 | 'menu.insert table': 'Vendos tabelën',
|
23269 | 'submenu.table style': 'Stili tabelën',
|
23270 | },
|
23271 |
|
23272 | sr: {
|
23273 | 'keyboard.tooltip.functions': 'Функције',
|
23274 | 'keyboard.tooltip.symbols': 'Симболи',
|
23275 | 'keyboard.tooltip.greek': 'Греек Леттерс',
|
23276 | 'keyboard.tooltip.command': 'ЛаТеКс командни режим',
|
23277 | 'keyboard.tooltip.numeric': 'Нумерички',
|
23278 | 'keyboard.tooltip.roman': 'Римска писма',
|
23279 | 'tooltip.copy to clipboard': 'Копирајте у међуспремник',
|
23280 | 'tooltip.redo': 'Понови',
|
23281 | 'tooltip.toggle virtual keyboard': 'Укључи / искључи виртуелну тастатуру',
|
23282 | 'tooltip.undo': 'Опозови',
|
23283 | 'menu.insert matrix': 'Уметни матрицу',
|
23284 | 'menu.insert vector': 'Уметни вектор',
|
23285 | 'submenu.array.matrix delimiters': 'Матрик Делимитерс',
|
23286 | 'menu.array.add row above': 'Додај ред после',
|
23287 | 'menu.array.add row below': 'Додај ред пре',
|
23288 | 'menu.array.add column after': 'Додај колону после',
|
23289 | 'menu.array.add column before': 'Додај колону пре',
|
23290 | 'menu.array.delete row': 'Избриши ред',
|
23291 | 'menu.array.delete rows': 'Избриши изабране редове',
|
23292 | 'menu.array.delete column': 'Избриши колону',
|
23293 | 'menu.array.delete columns': 'Избриши изабране колоне',
|
23294 | 'submenu.array.insert separator': 'Уметни сепаратор',
|
23295 | 'menu.insert table': 'Убаци табелу',
|
23296 | 'submenu.table style': 'Табеларни стил',
|
23297 | },
|
23298 |
|
23299 | sv: {
|
23300 | 'keyboard.tooltip.functions': 'Funktioner',
|
23301 | 'keyboard.tooltip.symbols': 'Symboler',
|
23302 | 'keyboard.tooltip.greek': 'Grekiska bokstäver',
|
23303 | 'keyboard.tooltip.command': 'LaTeX kommandoläge',
|
23304 | 'keyboard.tooltip.numeric': 'Numerisk',
|
23305 | 'keyboard.tooltip.roman': 'Romerska bokstäver',
|
23306 | 'tooltip.copy to clipboard': 'Kopiera till Urklipp',
|
23307 | 'tooltip.redo': 'Göra om',
|
23308 | 'tooltip.toggle virtual keyboard': 'Växla virtuellt tangentbord',
|
23309 | 'tooltip.undo': 'Ångra',
|
23310 | 'menu.insert matrix': 'Sätt in matris',
|
23311 | 'menu.insert vector': 'Infoga vektor',
|
23312 | 'submenu.array.matrix delimiters': 'Matrisavgränsare',
|
23313 | 'menu.array.add row above': 'Lägg till rad efter',
|
23314 | 'menu.array.add row below': 'Lägg till rad före',
|
23315 | 'menu.array.add column after': 'Lägg till kolumn efter',
|
23316 | 'menu.array.add column before': 'Lägg till kolumn före',
|
23317 | 'menu.array.delete row': 'Radera rad',
|
23318 | 'menu.array.delete rows': 'Ta bort valda rader',
|
23319 | 'menu.array.delete column': 'Ta bort kolumn',
|
23320 | 'menu.array.delete columns': 'Ta bort valda kolumner',
|
23321 | 'submenu.array.insert separator': 'Sätt i separator',
|
23322 | 'menu.insert table': 'Infoga tabell',
|
23323 | 'submenu.table style': 'Tabellstil',
|
23324 | },
|
23325 |
|
23326 | th: {
|
23327 | 'keyboard.tooltip.functions': 'ฟังก์ชั่น',
|
23328 | 'keyboard.tooltip.symbols': 'สัญลักษณ์',
|
23329 | 'keyboard.tooltip.greek': 'อักษรกรีก',
|
23330 | 'keyboard.tooltip.command': 'โหมดคำสั่ง น้ำยาง',
|
23331 | 'keyboard.tooltip.numeric': 'ตัวเลข',
|
23332 | 'keyboard.tooltip.roman': 'อักษรโรมัน',
|
23333 | 'tooltip.copy to clipboard': 'คัดลอกไปที่คลิปบอร์ด',
|
23334 | 'tooltip.redo': 'ทำซ้ำ',
|
23335 | 'tooltip.toggle virtual keyboard': 'สลับแป้นพิมพ์เสมือน',
|
23336 | 'tooltip.undo': 'เลิกทำ',
|
23337 | 'menu.insert matrix': 'แทรกเมทริกซ์',
|
23338 | 'menu.insert vector': 'แทรกเวกเตอร์',
|
23339 | 'submenu.array.matrix delimiters': 'ตัวคั่นเมทริกซ์',
|
23340 | 'menu.array.add row above': 'เพิ่มแถวหลัง',
|
23341 | 'menu.array.add row below': 'เพิ่มแถวก่อน',
|
23342 | 'menu.array.add column after': 'เพิ่มคอลัมน์หลัง',
|
23343 | 'menu.array.add column before': 'เพิ่มคอลัมน์ก่อน',
|
23344 | 'menu.array.delete row': 'ลบแถว',
|
23345 | 'menu.array.delete rows': 'ลบแถวที่เลือก',
|
23346 | 'menu.array.delete column': 'ลบคอลัมน์',
|
23347 | 'menu.array.delete columns': 'ลบคอลัมน์ที่เลือก',
|
23348 | 'submenu.array.insert separator': 'ตัวคั่นแทรก',
|
23349 | 'menu.insert table': 'แทรกตาราง',
|
23350 | 'submenu.table style': 'สไตล์ตาราง',
|
23351 | },
|
23352 |
|
23353 | tr: {
|
23354 | 'keyboard.tooltip.functions': 'Fonksiyonlar',
|
23355 | 'keyboard.tooltip.symbols': 'Semboller',
|
23356 | 'keyboard.tooltip.greek': 'Yunan harfleri',
|
23357 | 'keyboard.tooltip.command': 'LaTeX Komut Modu',
|
23358 | 'keyboard.tooltip.numeric': 'Sayısal',
|
23359 | 'keyboard.tooltip.roman': 'Roma Harfleri',
|
23360 | 'tooltip.copy to clipboard': 'Panoya kopyala',
|
23361 | 'tooltip.redo': 'Yeniden yap',
|
23362 | 'tooltip.toggle virtual keyboard': 'Sanal Klavyeyi Aç/Kapat',
|
23363 | 'tooltip.undo': 'Geri alma',
|
23364 | 'menu.insert matrix': 'Matris Ekle',
|
23365 | 'menu.insert vector': 'Vektör Ekle',
|
23366 | 'submenu.array.matrix delimiters': 'Matris Sınırlayıcılar',
|
23367 | 'menu.array.add row above': 'Satırdan Sonra Ekle',
|
23368 | 'menu.array.add row below': 'Önce Satır Ekle',
|
23369 | 'menu.array.add column after': 'Sonra Sütun Ekle',
|
23370 | 'menu.array.add column before': 'Önce Sütun Ekle',
|
23371 | 'menu.array.delete row': 'Sırayı sil',
|
23372 | 'menu.array.delete rows': 'Seçili Satırları Sil',
|
23373 | 'menu.array.delete column': 'Sütunu Sil',
|
23374 | 'menu.array.delete columns': 'Seçili Sütunları Sil',
|
23375 | 'submenu.array.insert separator': 'Ayırıcı Ekle',
|
23376 | 'menu.insert table': 'Tablo Ekle',
|
23377 | 'submenu.table style': 'Tablo Stili',
|
23378 | },
|
23379 |
|
23380 | uk: {
|
23381 | 'keyboard.tooltip.functions': 'Функції',
|
23382 | 'keyboard.tooltip.symbols': 'Символи',
|
23383 | 'keyboard.tooltip.greek': 'Грецькі літери',
|
23384 | 'keyboard.tooltip.command': 'Командний режим латексу',
|
23385 | 'keyboard.tooltip.numeric': 'Числовий',
|
23386 | 'keyboard.tooltip.roman': 'Римські літери',
|
23387 | 'tooltip.copy to clipboard': 'Копіювати в буфер обміну',
|
23388 | 'tooltip.redo': 'Повторити',
|
23389 | 'tooltip.toggle virtual keyboard': 'Переключити віртуальну клавіатуру',
|
23390 | 'tooltip.undo': 'Скасувати',
|
23391 | 'menu.insert matrix': 'Вставити матрицю',
|
23392 | 'menu.insert vector': 'Вставити вектор',
|
23393 | 'submenu.array.matrix delimiters': 'Матричні роздільники',
|
23394 | 'menu.array.add row above': 'Додати рядок після',
|
23395 | 'menu.array.add row below': 'Додати рядок до',
|
23396 | 'menu.array.add column after': 'Додати стовпець після',
|
23397 | 'menu.array.add column before': 'Додати стовпець перед',
|
23398 | 'menu.array.delete row': 'Видалити рядок',
|
23399 | 'menu.array.delete rows': 'Видалити вибрані рядки',
|
23400 | 'menu.array.delete column': 'Видалити стовпець',
|
23401 | 'menu.array.delete columns': 'Видалити вибрані стовпці',
|
23402 | 'submenu.array.insert separator': 'Вставте роздільник',
|
23403 | 'menu.insert table': 'Вставити таблицю',
|
23404 | 'submenu.table style': 'Стиль таблиці',
|
23405 | },
|
23406 |
|
23407 | vi: {
|
23408 | 'keyboard.tooltip.functions': 'Chức năng',
|
23409 | 'keyboard.tooltip.symbols': 'Ký hiệu',
|
23410 | 'keyboard.tooltip.greek': 'Chữ Hy Lạp',
|
23411 | 'keyboard.tooltip.command': 'Chế độ lệnh LaTeX',
|
23412 | 'keyboard.tooltip.numeric': 'Số',
|
23413 | 'keyboard.tooltip.roman': 'Chữ cái La mã',
|
23414 | 'tooltip.copy to clipboard': 'Sao chép vào clipboard',
|
23415 | 'tooltip.redo': 'Làm lại',
|
23416 | 'tooltip.toggle virtual keyboard': 'Chuyển đổi bàn phím ảo',
|
23417 | 'tooltip.undo': 'Hoàn tác',
|
23418 | 'menu.insert matrix': 'Chèn ma trận',
|
23419 | 'menu.insert vector': 'Insert Vector',
|
23420 | 'submenu.array.matrix delimiters': 'Dấu phân cách ma trận',
|
23421 | 'menu.array.add row above': 'Thêm hàng sau',
|
23422 | 'menu.array.add row below': 'Thêm hàng trước',
|
23423 | 'menu.array.add column after': 'Thêm cột sau',
|
23424 | 'menu.array.add column before': 'Thêm cột trước',
|
23425 | 'menu.array.delete row': 'Xóa hàng',
|
23426 | 'menu.array.delete rows': 'Xóa hàng đã chọn',
|
23427 | 'menu.array.delete column': 'Xóa cột',
|
23428 | 'menu.array.delete columns': 'Xóa các cột đã chọn',
|
23429 | 'submenu.array.insert separator': 'Chèn dấu phân cách',
|
23430 | 'menu.insert table': 'Chèn bảng',
|
23431 | 'submenu.table style': 'Kiểu bảng',
|
23432 | },
|
23433 |
|
23434 | zh_cn: {
|
23435 | 'keyboard.tooltip.functions': '职能',
|
23436 | 'keyboard.tooltip.symbols': '符号',
|
23437 | 'keyboard.tooltip.greek': '希腊字母',
|
23438 | 'keyboard.tooltip.command': '乳胶 命令模式',
|
23439 | 'keyboard.tooltip.numeric': '数字',
|
23440 | 'keyboard.tooltip.roman': '罗马字母',
|
23441 | 'tooltip.copy to clipboard': '复制到剪贴板',
|
23442 | 'tooltip.redo': '重做',
|
23443 | 'tooltip.toggle virtual keyboard': '切换虚拟键盘',
|
23444 | 'tooltip.undo': '撤消',
|
23445 | 'menu.insert matrix': '插入矩阵',
|
23446 | 'menu.insert vector': '插入向量',
|
23447 | 'submenu.array.matrix delimiters': '矩阵分隔符',
|
23448 | 'menu.array.add row above': '在后面添加行',
|
23449 | 'menu.array.add row below': '在前面添加行',
|
23450 | 'menu.array.add column after': '在后面添加列r',
|
23451 | 'menu.array.add column before': '在前面添加列',
|
23452 | 'menu.array.delete row': '删除行',
|
23453 | 'menu.array.delete rows': '删除选定行',
|
23454 | 'menu.array.delete column': '删除列',
|
23455 | 'menu.array.delete columns': '删除选定的列',
|
23456 | 'submenu.array.insert separator': '插入分隔符',
|
23457 | 'menu.insert table': '插入表格',
|
23458 | 'submenu.table style': '表格样式',
|
23459 | },
|
23460 |
|
23461 | zh_tw: {
|
23462 | 'keyboard.tooltip.functions': '職能',
|
23463 | 'keyboard.tooltip.symbols': '符號',
|
23464 | 'keyboard.tooltip.greek': '希臘字母',
|
23465 | 'keyboard.tooltip.command': '乳膠命令模式',
|
23466 | 'keyboard.tooltip.numeric': '數字',
|
23467 | 'keyboard.tooltip.roman': '羅馬字母',
|
23468 | 'tooltip.copy to clipboard': '複製到剪貼板',
|
23469 | 'tooltip.redo': '重做',
|
23470 | 'tooltip.toggle virtual keyboard': '切換虛擬鍵盤',
|
23471 | 'tooltip.undo': '撤消',
|
23472 | 'menu.insert matrix': '插入矩陣',
|
23473 | 'menu.insert vector': '插入向量',
|
23474 | 'submenu.array.matrix delimiters': '矩陣分隔符',
|
23475 | 'menu.array.add row above': '在後面添加行',
|
23476 | 'menu.array.add row below': '在前面添加行',
|
23477 | 'menu.array.add column after': '在後面添加列',
|
23478 | 'menu.array.add column before': '在前面添加列',
|
23479 | 'menu.array.delete row': '刪除行',
|
23480 | 'menu.array.delete rows': '刪除選定行',
|
23481 | 'menu.array.delete column': '刪除列',
|
23482 | 'menu.array.delete columns': '刪除選定的列',
|
23483 | 'submenu.array.insert separator': '插入分隔符',
|
23484 | 'menu.insert table': '插入表格',
|
23485 | 'submenu.table style': '表格樣式',
|
23486 | },
|
23487 | };
|
23488 |
|
23489 |
|
23490 |
|
23491 |
|
23492 |
|
23493 |
|
23494 |
|
23495 |
|
23496 |
|
23497 | const l10n = {
|
23498 | strings: STRINGS,
|
23499 | _locale: 'en',
|
23500 |
|
23501 | get locale() {
|
23502 | var _a;
|
23503 |
|
23504 |
|
23505 | if (!l10n._locale) {
|
23506 |
|
23507 | l10n._locale =
|
23508 | (_a = (isBrowser() ? navigator.language.slice(0, 5) : null)) !== null && _a !== void 0 ? _a : 'en';
|
23509 | }
|
23510 | return l10n._locale;
|
23511 | },
|
23512 | set locale(value) {
|
23513 | l10n._locale = value;
|
23514 | },
|
23515 | |
23516 |
|
23517 |
|
23518 |
|
23519 |
|
23520 |
|
23521 |
|
23522 |
|
23523 | merge(locale, strings) {
|
23524 | if (locale && strings) {
|
23525 | const savedLocale = l10n._locale;
|
23526 | l10n.locale = locale;
|
23527 | l10n.strings[locale] = {
|
23528 | ...l10n.strings[locale],
|
23529 | ...strings,
|
23530 | };
|
23531 | l10n.locale = savedLocale;
|
23532 | }
|
23533 | else if (locale && !strings) {
|
23534 | for (const l of Object.keys(locale)) {
|
23535 | l10n.merge(l, locale[l]);
|
23536 | }
|
23537 | }
|
23538 | },
|
23539 | };
|
23540 |
|
23541 |
|
23542 |
|
23543 | function localize(key) {
|
23544 | if (key === undefined)
|
23545 | return undefined;
|
23546 | const language = l10n.locale.slice(0, 2);
|
23547 | let result = '';
|
23548 |
|
23549 | if (l10n.strings[l10n.locale])
|
23550 | result = l10n.strings[l10n.locale][key];
|
23551 |
|
23552 | if (!result && l10n.strings[language])
|
23553 | result = l10n.strings[language][key];
|
23554 |
|
23555 | if (!result)
|
23556 | result = l10n.strings.en[key];
|
23557 |
|
23558 | if (!result)
|
23559 | return undefined;
|
23560 | return result;
|
23561 | }
|
23562 |
|
23563 | function on(element, inSelectors, listener, options) {
|
23564 | const selectors = inSelectors.split(' ');
|
23565 | for (const sel of selectors) {
|
23566 | const m = sel.match(/(.*):(.*)/);
|
23567 | if (m) {
|
23568 | const options2 = options !== null && options !== void 0 ? options : {};
|
23569 | if (m[2] === 'active') {
|
23570 | options2.passive = false;
|
23571 | }
|
23572 | else {
|
23573 | options2[m[2]] = true;
|
23574 | }
|
23575 | element.addEventListener(m[1], listener, options2);
|
23576 | }
|
23577 | else {
|
23578 | element.addEventListener(sel, listener, options);
|
23579 | }
|
23580 | }
|
23581 | }
|
23582 | function off(element, inSelectors, listener, options) {
|
23583 | const selectors = inSelectors.split(' ');
|
23584 | for (const sel of selectors) {
|
23585 | const m = sel.match(/(.*):(.*)/);
|
23586 | if (m) {
|
23587 | const options2 = options !== null && options !== void 0 ? options : {};
|
23588 | if (m[2] === 'active') {
|
23589 | options2.passive = false;
|
23590 | }
|
23591 | else {
|
23592 | options2[m[2]] = true;
|
23593 | }
|
23594 | element.removeEventListener(m[1], listener, options2);
|
23595 | }
|
23596 | else {
|
23597 | element.removeEventListener(sel, listener, options);
|
23598 | }
|
23599 | }
|
23600 | }
|
23601 | function getSharedElement(id) {
|
23602 | var _a;
|
23603 | throwIfNotInBrowser();
|
23604 | let result = document.getElementById(id);
|
23605 | if (result) {
|
23606 | result.dataset.refcount = Number(Number.parseInt((_a = result.getAttribute('data-refcount')) !== null && _a !== void 0 ? _a : '0') + 1).toString();
|
23607 | }
|
23608 | else {
|
23609 | result = document.createElement('div');
|
23610 | result.setAttribute('aria-hidden', 'true');
|
23611 | result.dataset.refcount = '1';
|
23612 | result.id = id;
|
23613 | document.body.append(result);
|
23614 | }
|
23615 | return result;
|
23616 | }
|
23617 |
|
23618 | function releaseSharedElement(element) {
|
23619 | var _a;
|
23620 | if (!element)
|
23621 | return;
|
23622 | const refcount = Number.parseInt((_a = element.getAttribute('data-refcount')) !== null && _a !== void 0 ? _a : '0');
|
23623 | if (refcount <= 1) {
|
23624 | element.remove();
|
23625 | }
|
23626 | else {
|
23627 | element.dataset.refcount = Number(refcount - 1).toString();
|
23628 | }
|
23629 | }
|
23630 |
|
23631 |
|
23632 |
|
23633 |
|
23634 |
|
23635 |
|
23636 |
|
23637 | function isValidMathfield(mf) {
|
23638 | return mf.element !== undefined && mf.element.mathfield === mf;
|
23639 | }
|
23640 |
|
23641 |
|
23642 |
|
23643 | function findElementWithCaret(element) {
|
23644 | var _a, _b;
|
23645 | return ((_b = (_a = element.querySelector('.ML__caret')) !== null && _a !== void 0 ? _a : element.querySelector('.ML__text-caret')) !== null && _b !== void 0 ? _b : element.querySelector('.ML__latex-caret'));
|
23646 | }
|
23647 |
|
23648 |
|
23649 |
|
23650 | function getCaretPoint(element) {
|
23651 | const caret = findElementWithCaret(element);
|
23652 | if (!caret)
|
23653 | return null;
|
23654 | const bounds = caret.getBoundingClientRect();
|
23655 | return {
|
23656 | x: bounds.right,
|
23657 | y: bounds.bottom,
|
23658 | height: bounds.height,
|
23659 | };
|
23660 | }
|
23661 | function branchId(atom) {
|
23662 | var _a;
|
23663 | if (!atom.parent)
|
23664 | return 'root';
|
23665 | let result = (_a = atom.parent.id) !== null && _a !== void 0 ? _a : '';
|
23666 | result +=
|
23667 | typeof atom.treeBranch === 'string'
|
23668 | ? '-' + atom.treeBranch
|
23669 | : `-${atom.treeBranch[0]}/${atom.treeBranch[0]}`;
|
23670 | return result;
|
23671 | }
|
23672 | function adjustForScrolling(mathfield, rect) {
|
23673 | if (!rect)
|
23674 | return null;
|
23675 | const fieldRect = mathfield.field.getBoundingClientRect();
|
23676 | const w = rect.right - rect.left;
|
23677 | const h = rect.bottom - rect.top;
|
23678 | const left = Math.ceil(rect.left - fieldRect.left + mathfield.field.scrollLeft);
|
23679 | const top = Math.ceil(rect.top - fieldRect.top);
|
23680 | return {
|
23681 | left,
|
23682 | right: left + w,
|
23683 | top,
|
23684 | bottom: top + h,
|
23685 | };
|
23686 | }
|
23687 | function getNodeBounds(node) {
|
23688 | const bounds = node.getBoundingClientRect();
|
23689 | const marginRight = parseInt(getComputedStyle(node).marginRight);
|
23690 | const result = {
|
23691 | top: bounds.top - 1,
|
23692 | bottom: bounds.bottom,
|
23693 | left: bounds.left,
|
23694 | right: bounds.right - 1 + marginRight,
|
23695 | };
|
23696 | if (node.children.length > 0 && node.tagName.toUpperCase() !== 'SVG') {
|
23697 | for (const child of node.children) {
|
23698 | if (child.nodeType === 1) {
|
23699 | if ('atom-id' in child.dataset &&
|
23700 | !child.classList.contains('pstrut')) {
|
23701 | const r = getNodeBounds(child);
|
23702 | result.left = Math.min(result.left, r.left);
|
23703 | result.right = Math.max(result.right, r.right);
|
23704 | result.top = Math.min(result.top, r.top);
|
23705 | result.bottom = Math.max(result.bottom, r.bottom);
|
23706 | }
|
23707 | }
|
23708 | }
|
23709 | }
|
23710 | return result;
|
23711 | }
|
23712 | function getAtomBounds(mathfield, atom) {
|
23713 | var _a, _b;
|
23714 | if (!atom.id)
|
23715 | return null;
|
23716 | let result = (_b = (_a = mathfield._atomBoundsCache) === null || _a === void 0 ? void 0 : _a.get(atom.id)) !== null && _b !== void 0 ? _b : null;
|
23717 | if (result !== null)
|
23718 | return result;
|
23719 | const node = mathfield.field.querySelector(`[data-atom-id="${atom.id}"]`);
|
23720 | if (!node) {
|
23721 | console.log(atom.id);
|
23722 | }
|
23723 | result = node ? getNodeBounds(node) : null;
|
23724 | if (mathfield._atomBoundsCache) {
|
23725 | if (result) {
|
23726 | mathfield._atomBoundsCache.set(atom.id, result);
|
23727 | }
|
23728 | else {
|
23729 | mathfield._atomBoundsCache.delete(atom.id);
|
23730 | }
|
23731 | }
|
23732 | return result !== null && result !== void 0 ? result : null;
|
23733 | }
|
23734 |
|
23735 |
|
23736 |
|
23737 |
|
23738 | function getRangeBounds(mathfield, range, options) {
|
23739 |
|
23740 | const rects = new Map();
|
23741 | for (const atom of mathfield.model.getAtoms(range, {
|
23742 | includeChildren: true,
|
23743 | })) {
|
23744 | if ((options === null || options === void 0 ? void 0 : options.excludeAtomsWithBackground) && atom.style.backgroundColor) {
|
23745 | break;
|
23746 | }
|
23747 | const bounds = adjustForScrolling(mathfield, getAtomBounds(mathfield, atom));
|
23748 | if (bounds) {
|
23749 | const id = branchId(atom);
|
23750 | if (rects.has(id)) {
|
23751 | const r = rects.get(id);
|
23752 | rects.set(id, {
|
23753 | left: Math.min(r.left, bounds.left),
|
23754 | right: Math.max(r.right, bounds.right),
|
23755 | top: Math.min(r.top, bounds.top),
|
23756 | bottom: Math.max(r.bottom, bounds.bottom),
|
23757 | });
|
23758 | }
|
23759 | else {
|
23760 | rects.set(id, bounds);
|
23761 | }
|
23762 | }
|
23763 | }
|
23764 | return [...rects.values()];
|
23765 | }
|
23766 | function getSelectionBounds(mathfield, options) {
|
23767 | return mathfield.model.selection.ranges.reduce((acc, x) => acc.concat(...getRangeBounds(mathfield, x, options)), []);
|
23768 | }
|
23769 | function validateOrigin(origin, originValidator) {
|
23770 | if (originValidator === 'none') {
|
23771 | return true;
|
23772 | }
|
23773 | if (originValidator === 'same-origin') {
|
23774 | return origin === window.origin;
|
23775 | }
|
23776 | if (typeof originValidator === 'function') {
|
23777 | return originValidator(origin);
|
23778 | }
|
23779 | return false;
|
23780 | }
|
23781 |
|
23782 |
|
23783 |
|
23784 |
|
23785 |
|
23786 |
|
23787 |
|
23788 |
|
23789 |
|
23790 |
|
23791 |
|
23792 |
|
23793 |
|
23794 |
|
23795 |
|
23796 |
|
23797 |
|
23798 |
|
23799 |
|
23800 |
|
23801 |
|
23802 |
|
23803 |
|
23804 |
|
23805 |
|
23806 |
|
23807 | function attachButtonHandlers(executeCommand, element, command) {
|
23808 | if (typeof command === 'object' &&
|
23809 | ('default' in command || 'pressed' in command)) {
|
23810 |
|
23811 | if (command.default) {
|
23812 | element.dataset.command = JSON.stringify(command.default);
|
23813 | }
|
23814 | if (command.alt) {
|
23815 | element.dataset.commandAlt = JSON.stringify(command.alt);
|
23816 | }
|
23817 | if (command.altshift) {
|
23818 | element.dataset.commandAltshift = JSON.stringify(command.altshift);
|
23819 | }
|
23820 | if (command.shift) {
|
23821 | element.dataset.commandShift = JSON.stringify(command.shift);
|
23822 | }
|
23823 |
|
23824 |
|
23825 |
|
23826 | if (command.pressed) {
|
23827 | element.dataset.commandPressed = JSON.stringify(command.pressed);
|
23828 | }
|
23829 | if (command.pressAndHoldStart) {
|
23830 | element.dataset.commandPressAndHoldStart = JSON.stringify(command.pressAndHoldStart);
|
23831 | }
|
23832 | if (command.pressAndHoldEnd) {
|
23833 | element.dataset.commandPressAndHoldEnd = JSON.stringify(command.pressAndHoldEnd);
|
23834 | }
|
23835 | }
|
23836 | else {
|
23837 |
|
23838 |
|
23839 |
|
23840 | element.dataset.command = JSON.stringify(command);
|
23841 | }
|
23842 | let pressHoldStart;
|
23843 | let pressHoldElement;
|
23844 | let touchID;
|
23845 | let syntheticTarget;
|
23846 | let pressAndHoldTimer;
|
23847 | on(element, 'mousedown touchstart:passive', (ev) => {
|
23848 | if (ev.type !== 'mousedown' || ev.buttons === 1) {
|
23849 |
|
23850 | ev.stopPropagation();
|
23851 |
|
23852 | if (ev.type !== 'touchstart') {
|
23853 | ev.preventDefault();
|
23854 | }
|
23855 |
|
23856 |
|
23857 |
|
23858 |
|
23859 | document.body.style['-webkit-user-select'] = 'none';
|
23860 | element.classList.add('is-pressed');
|
23861 | pressHoldStart = Date.now();
|
23862 |
|
23863 | if (ev.type === 'touchstart') {
|
23864 | touchID = ev.changedTouches[0].identifier;
|
23865 | }
|
23866 |
|
23867 |
|
23868 | const command = element.getAttribute('data-command-pressed');
|
23869 | if (command) {
|
23870 | executeCommand(JSON.parse(command));
|
23871 | }
|
23872 |
|
23873 |
|
23874 | const pressAndHoldStartCommand = element.getAttribute('data-command-press-and-hold-start');
|
23875 | if (pressAndHoldStartCommand) {
|
23876 | pressHoldElement = element;
|
23877 | if (pressAndHoldTimer) {
|
23878 | clearTimeout(pressAndHoldTimer);
|
23879 | }
|
23880 | pressAndHoldTimer = setTimeout(() => {
|
23881 | if (element.classList.contains('is-pressed')) {
|
23882 | executeCommand(JSON.parse(pressAndHoldStartCommand));
|
23883 | }
|
23884 | }, 300);
|
23885 | }
|
23886 | }
|
23887 | });
|
23888 | on(element, 'mouseleave touchcancel', () => {
|
23889 | element.classList.remove('is-pressed');
|
23890 | });
|
23891 | on(element, 'touchmove:passive', (ev) => {
|
23892 |
|
23893 |
|
23894 |
|
23895 |
|
23896 |
|
23897 | for (let i = 0; i < ev.changedTouches.length; i++) {
|
23898 | if (ev.changedTouches[i].identifier === touchID) {
|
23899 |
|
23900 | const target = document.elementFromPoint(ev.changedTouches[i].clientX, ev.changedTouches[i].clientY);
|
23901 | if (target !== syntheticTarget && syntheticTarget) {
|
23902 | syntheticTarget.dispatchEvent(new MouseEvent('mouseleave'), {
|
23903 | bubbles: true,
|
23904 | });
|
23905 | syntheticTarget = null;
|
23906 | }
|
23907 | if (target) {
|
23908 | syntheticTarget = target;
|
23909 | target.dispatchEvent(new MouseEvent('mouseenter', {
|
23910 | bubbles: true,
|
23911 | buttons: 1,
|
23912 | }));
|
23913 | }
|
23914 | }
|
23915 | }
|
23916 | });
|
23917 | on(element, 'mouseenter', (ev) => {
|
23918 | if (ev.buttons === 1) {
|
23919 | element.classList.add('is-pressed');
|
23920 | }
|
23921 | });
|
23922 | on(element, 'mouseup touchend click', (ev) => {
|
23923 | document.body.style['-webkit-user-select'] = '';
|
23924 | if (syntheticTarget) {
|
23925 | ev.stopPropagation();
|
23926 | ev.preventDefault();
|
23927 | const target = syntheticTarget;
|
23928 | syntheticTarget = null;
|
23929 | target.dispatchEvent(new MouseEvent('mouseup', { bubbles: true }));
|
23930 | return;
|
23931 | }
|
23932 | element.classList.remove('is-pressed');
|
23933 | element.classList.add('is-active');
|
23934 | if (ev.type === 'click' && ev.detail !== 0) {
|
23935 |
|
23936 |
|
23937 |
|
23938 | ev.stopPropagation();
|
23939 | ev.preventDefault();
|
23940 | return;
|
23941 | }
|
23942 |
|
23943 |
|
23944 | window.setTimeout(() => {
|
23945 | element.classList.remove('is-active');
|
23946 | }, 150);
|
23947 | let command = element.getAttribute('data-command-press-and-hold-end');
|
23948 | const now = Date.now();
|
23949 |
|
23950 |
|
23951 |
|
23952 | if (element !== pressHoldElement || now < pressHoldStart + 300) {
|
23953 | command = null;
|
23954 | }
|
23955 | if (!command && ev.altKey && ev.shiftKey) {
|
23956 | command = element.getAttribute('data-command-altshift');
|
23957 | }
|
23958 | if (!command && ev.altKey) {
|
23959 | command = element.getAttribute('data-command-alt');
|
23960 | }
|
23961 | if (!command && ev.shiftKey) {
|
23962 | command = element.getAttribute('data-command-shift');
|
23963 | }
|
23964 | if (!command) {
|
23965 | command = element.getAttribute('data-command');
|
23966 | }
|
23967 | if (command) {
|
23968 |
|
23969 |
|
23970 | executeCommand(JSON.parse(command));
|
23971 | }
|
23972 | ev.stopPropagation();
|
23973 | ev.preventDefault();
|
23974 | });
|
23975 | }
|
23976 |
|
23977 | var css_248z$3 = ".ML__keyboard{--keyboard-background:rgba(209,213,217,.97);--keyboard-text:#000;--keyboard-text-active:var(--primary,hsl(var(--hue,212),40%,50%));--keyboard-background-border:#ddd;--keycap-background:#fff;--keycap-background-active:#e5e5e5;--keycap-background-border:#e5e6e9;--keycap-background-border-bottom:#8d8f92;--keycap-text:#000;--keycap-text-active:#fff;--keycap-secondary-text:#000;--keycap-modifier-background:#b9bdc7;--keycap-modifier-border:#c5c9d0;--keycap-modifier-border-bottom:#989da6;--keyboard-alternate-background:#fff;--keyboard-alternate-background-active:var(--primary,hsl(var(--hue,212),40%,50%));--keyboard-alternate-text:var(--keycap-text,#000);--keyboard-alternate-text-active:#fff;--keyboard-alternate-key-length:70px;--keyboard-alternate-key-font-size:30px;--keyboard-alternate-key-aside-font-size:12px;--keyboard-height:276px;--keycap-height:52px;--keycap-font-size:20px;--keycap-small-font-size:calc(var(--keycap-font-size)*0.8);--keycap-extra-small-font-size:calc(var(--keycap-font-size)/1.42);--keycap-tt-font-size:calc(var(--keycap-font-size)*1.5);height:100%;pointer-events:none;position:fixed;top:0;width:100%}.ML__keyboard.is-visible .ML__keyboard--plate{opacity:1;transform:translateY(calc(var(--keyboard-height, 276px)*-1));transition-timing-function:cubic-bezier(.4,0,1,1);visibility:visible}.ML__keyboard.alternate-keys{align-content:center;background-color:var(--keyboard-alternate-background);border-radius:6px;bottom:auto;box-shadow:0 14px 28px rgba(0,0,0,.25),0 10px 10px rgba(0,0,0,.22);box-sizing:content-box;display:flex;flex-direction:row;justify-content:center;max-width:286px;position:fixed;text-align:center;top:0;transform:none;transition:none;visibility:hidden;z-index:calc(var(--keyboard-zindex, 105) + 1)}@media only screen and (max-height:412px){.ML__keyboard.alternate-keys{max-width:320px}}.ML__keyboard.alternate-keys.is-visible{visibility:visible}.ML__keyboard.alternate-keys.compact{--keyboard-alternate-key-length:50px;--keyboard-alternate-key-font-size:24px;--keyboard-alternate-key-aside-font-size:10px}.ML__keyboard.alternate-keys ul{display:flex;flex-flow:row wrap-reverse;justify-content:center;list-style:none;margin:3px;padding:0}.ML__keyboard.alternate-keys ul>li{fill:currentColor;align-items:center;background:transparent;border:1px solid transparent;border-radius:5px;box-sizing:border-box;color:var(--keyboard-alternate-text);display:flex;flex-flow:column;font-size:var(--keyboard-alternate-key-font-size);height:var(--keyboard-alternate-key-length);justify-content:center;margin:0;pointer-events:all;width:var(--keyboard-alternate-key-length)}@media only screen and (max-height:412px){.ML__keyboard.alternate-keys ul>li{font-size:24px;height:50px;width:50px}}.ML__keyboard.alternate-keys ul>li.is-active,.ML__keyboard.alternate-keys ul>li.is-pressed,.ML__keyboard.alternate-keys ul>li:hover{background:var(--keyboard-alternate-background-active);color:var(--keyboard-alternate-text-active)}.ML__keyboard.alternate-keys ul>li.small{font-size:var(--keycap-small-font-size,16px)}.ML__keyboard.alternate-keys ul>li.small-button{background:#fbfbfb;height:42px;margin:2px;width:42px}.ML__keyboard.alternate-keys ul>li.small-button:hover{background:var(--keyboard-alternate-background-active)}.ML__keyboard.alternate-keys ul>li.box>div,.ML__keyboard.alternate-keys ul>li.box>span{border:1px dashed rgba(0,0,0,.24)}.ML__keyboard.alternate-keys ul>li .warning{align-items:center;background:#cd0030;border-radius:5px;color:#fff;display:flex;justify-content:center;min-height:60px;min-width:60px;padding:5px}.ML__keyboard.alternate-keys ul>li .warning.is-active,.ML__keyboard.alternate-keys ul>li .warning.is-pressed,.ML__keyboard.alternate-keys ul>li .warning:hover{background:red}.ML__keyboard.alternate-keys ul>li .warning svg.svg-glyph{height:50px;width:50px}.ML__keyboard.alternate-keys ul>li aside{font-size:var(--keyboard-alternate-key-aside-font-size);line-height:12px;opacity:.78;padding-top:2px}.ML__keyboard .ML__keyboard--plate{-webkit-backdrop-filter:grayscale(50%);backdrop-filter:grayscale(50%);background-color:var(--keyboard-background);border:1px solid var(--keyboard-background-border);bottom:calc(var(--keyboard-height, 276px)*-1);box-shadow:0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23);box-sizing:border-box;cursor:pointer;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:16px;font-weight:400;left:0;margin:0;opacity:0;padding-top:5px;position:absolute;text-shadow:none;touch-action:none;transform:translate(0);transition:.28s cubic-bezier(0,0,.2,1);transition-property:transform,opacity;-webkit-user-select:none;user-select:none;visibility:hidden;width:100%;z-index:var(--keyboard-zindex,105)}.ML__keyboard .ML__keyboard--plate .tex{font-family:KaTeX_Math,KaTeX_Main,Cambria Math,Asana Math,OpenSymbol,Symbola,STIX,Times,serif!important}.ML__keyboard .ML__keyboard--plate .tex-math{font-family:KaTeX_Math,Cambria Math,Asana Math,OpenSymbol,Symbola,STIX,Times,serif!important}.ML__keyboard .ML__keyboard--plate .tt{font-family:IBM Plex Mono,Source Code Pro,Consolas,Roboto Mono,Menlo,Bitstream Vera Sans Mono,DejaVu Sans Mono,Monaco,Courier,monospace!important;font-size:var(--keycap-tt-font-size,30px);font-weight:400}.ML__keyboard .ML__keyboard--plate>div.keyboard-layer{display:none;outline:none}.ML__keyboard .ML__keyboard--plate>div.keyboard-layer.is-visible{display:flex;flex-flow:column}.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar{align-self:center;display:flex;flex-flow:row;justify-content:space-between;width:736px}@media only screen and (min-width:768px) and (max-width:1024px){.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar{width:556px}}@media only screen and (max-width:767px){.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar{max-width:100vw;width:365px}}.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar svg{height:20px;width:20px}@media only screen and (max-width:767px){.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar svg{height:13px;width:17px}}.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar>.left{display:flex;flex-flow:row;justify-content:flex-start;position:relative}.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar>.right{display:flex;flex-flow:row;justify-content:flex-end}.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar>div>div{fill:currentColor;align-items:baseline;background:0;border:none;border-bottom:2px solid transparent;box-shadow:none;color:var(--keyboard-text);cursor:pointer;display:flex;font-size:110%;justify-content:center;margin:7px 4px 6px;min-height:0;padding:4px 10px;pointer-events:all}.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar>div>div.disabled.is-pressed svg,.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar>div>div.disabled:hover svg,.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar>div>div.disabled svg{color:var(--keyboard-text);opacity:.2}@media only screen and (max-width:414px){.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar>div>div{font-size:100%;padding:0 6px 0 0}}@media only screen and (max-width:767px){.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar>div>div{font-size:90%;padding-left:4px;padding-right:4px}}.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar>div>div.is-active,.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar>div>div.is-pressed,.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar>div>div:active,.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar>div>div:hover{color:var(--keyboard-text-active)}.ML__keyboard .ML__keyboard--plate>div>div.keyboard-toolbar>div>div.selected{border-bottom:2px solid var(--keyboard-text-active);color:var(--keyboard-text-active);margin-bottom:8px;padding-bottom:0}.ML__keyboard .ML__keyboard--plate div .rows{align-items:center;border:0;border-collapse:separate;clear:both;display:flex;flex-flow:column;margin:auto}.ML__keyboard .ML__keyboard--plate div .rows>ul{height:40px;list-style:none;margin:0 0 3px;padding:0}.ML__keyboard .ML__keyboard--plate div .rows>ul>li{fill:currentColor;-webkit-tap-highlight-color:transparent;align-items:center;background:var(--keycap-background);border:1px solid var(--keycap-background-border);border-bottom-color:var(--keycap-background-border-bottom);border-radius:5px;box-sizing:border-box;color:var(--keycap-text);display:flex;flex-flow:column;float:left;font-size:var(--keycap-font-size,20px);height:40px;justify-content:center;margin-right:2px;overflow:hidden;padding:8px 0;pointer-events:all;position:relative;text-align:center;-webkit-user-select:none;user-select:none;vertical-align:top;width:34px}.ML__keyboard .ML__keyboard--plate div .rows>ul>li:last-child{margin-right:0}.ML__keyboard .ML__keyboard--plate div .rows>ul>li.small{font-size:var(--keycap-small-font-size,16px)}.ML__keyboard .ML__keyboard--plate div .rows>ul>li.tt{color:var(--keyboard-text-active)}.ML__keyboard .ML__keyboard--plate div .rows>ul>li.bottom{justify-content:flex-end}.ML__keyboard .ML__keyboard--plate div .rows>ul>li.left{align-items:flex-start;padding-left:4px}.ML__keyboard .ML__keyboard--plate div .rows>ul>li.right{align-items:flex-end;padding-right:4px}.ML__keyboard .ML__keyboard--plate div .rows>ul>li svg.svg-glyph{height:20px;width:20px}.ML__keyboard .ML__keyboard--plate div .rows>ul>li .warning{align-items:center;background:#cd0030;border-radius:100%;color:#fff;display:flex;height:25px;justify-content:center;margin-bottom:-2px;min-height:25px;min-width:25px;padding:5px;width:25px}.ML__keyboard .ML__keyboard--plate div .rows>ul>li .warning svg.svg-glyph{height:16px;width:16px}@media only screen and (max-width:768px){.ML__keyboard .ML__keyboard--plate div .rows>ul>li .warning{height:16px;min-height:16px;min-width:16px;width:16px}.ML__keyboard .ML__keyboard--plate div .rows>ul>li .warning svg.svg-glyph{height:14px;width:14px}}.ML__keyboard .ML__keyboard--plate div .rows>ul>li>.w0{width:0}.ML__keyboard .ML__keyboard--plate div .rows>ul>li>.w5{width:16px}.ML__keyboard .ML__keyboard--plate div .rows>ul>li>.w15{width:52px}.ML__keyboard .ML__keyboard--plate div .rows>ul>li>.w20{width:70px}.ML__keyboard .ML__keyboard--plate div .rows>ul>li>.w50{width:178px}.ML__keyboard .ML__keyboard--plate div .rows>ul>li.separator{background:transparent;border:none;pointer-events:none}@media only screen and (max-width:560px){.ML__keyboard .ML__keyboard--plate div .rows>ul>li.if-wide{display:none}}.ML__keyboard .ML__keyboard--plate div .rows>ul>li.tex-math{font-size:25px}.ML__keyboard .ML__keyboard--plate div .rows>ul>li.is-pressed,.ML__keyboard .ML__keyboard--plate div .rows>ul>li:hover{background:var(--keycap-background-active);color:var(--keyboard-text-active)}.ML__keyboard .ML__keyboard--plate div .rows>ul>li.action.is-active,.ML__keyboard .ML__keyboard--plate div .rows>ul>li.action:active,.ML__keyboard .ML__keyboard--plate div .rows>ul>li.keycap.is-active,.ML__keyboard .ML__keyboard--plate div .rows>ul>li.keycap:active{color:var(--keyboard-text-active);transform:translateY(calc(var(--keycap-height, 52px)*-.2)) scale(1.4);z-index:calc(var(--keyboard-zindex, 105) - 5)}.ML__keyboard .ML__keyboard--plate div .rows>ul>li.modifier.is-active,.ML__keyboard .ML__keyboard--plate div .rows>ul>li.modifier:active{background:var(--keyboard-text-active);color:var(--keycap-text-active)}.ML__keyboard .ML__keyboard--plate div .rows>ul>li.action.font-glyph,.ML__keyboard .ML__keyboard--plate div .rows>ul>li.modifier.font-glyph{font-size:18px}@media only screen and (max-width:767px){.ML__keyboard .ML__keyboard--plate div .rows>ul>li.action.font-glyph,.ML__keyboard .ML__keyboard--plate div .rows>ul>li.modifier.font-glyph{font-size:16px}}@media only screen and (max-width:767px){.ML__keyboard .ML__keyboard--plate div .rows>ul>li.fnbutton{font-size:12px}}.ML__keyboard .ML__keyboard--plate div .rows>ul>li.bigfnbutton{font-size:var(--keycap-extra-small-font-size,14px)}@media only screen and (max-width:767px){.ML__keyboard .ML__keyboard--plate div .rows>ul>li.bigfnbutton{font-size:calc(var(--keycap-extra-small-font-size, 14px)/1.55)}}.ML__keyboard .ML__keyboard--plate div .rows>ul>li.action,.ML__keyboard .ML__keyboard--plate div .rows>ul>li.modifier{background-color:var(--keycap-modifier-background);border-bottom-color:var(--keycap-modifier-border);border-color:var(--keycap-modifier-border) var(--keycap-modifier-border) var(--keycap-modifier-border-bottom);font-size:65%;font-weight:100}.ML__keyboard .ML__keyboard--plate div .rows>ul>li.action.selected,.ML__keyboard .ML__keyboard--plate div .rows>ul>li.modifier.selected{color:var(--keyboard-text-active)}.ML__keyboard .ML__keyboard--plate div .rows>ul>li.action.selected.is-active,.ML__keyboard .ML__keyboard--plate div .rows>ul>li.action.selected.is-pressed,.ML__keyboard .ML__keyboard--plate div .rows>ul>li.action.selected:active,.ML__keyboard .ML__keyboard--plate div .rows>ul>li.action.selected:hover,.ML__keyboard .ML__keyboard--plate div .rows>ul>li.modifier.selected.is-active,.ML__keyboard .ML__keyboard--plate div .rows>ul>li.modifier.selected.is-pressed,.ML__keyboard .ML__keyboard--plate div .rows>ul>li.modifier.selected:active,.ML__keyboard .ML__keyboard--plate div .rows>ul>li.modifier.selected:hover{color:#fff}.ML__keyboard .ML__keyboard--plate div .rows>ul>li.keycap.w50{font-size:80%;font-weight:100;padding-top:10px}.ML__keyboard .ML__keyboard--plate div .rows>ul>li small{color:#555}@media only screen and (max-width:767px){.ML__keyboard .ML__keyboard--plate div .rows>ul>li small{font-size:9px}}.ML__keyboard .ML__keyboard--plate div .rows>ul>li aside{color:#666;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:10px;line-height:10px}@media only screen and (max-width:767px){.ML__keyboard .ML__keyboard--plate div .rows>ul>li aside{display:none}}@media only screen and (max-width:414px){.ML__keyboard .ML__keyboard--plate div .rows>ul>li{margin-right:2px;width:calc(10vw - 2px)}.ML__keyboard .ML__keyboard--plate div .rows>ul>.w5{width:calc(5vw - 2px)}.ML__keyboard .ML__keyboard--plate div .rows>ul>.w15{width:calc(15vw - 2px)}.ML__keyboard .ML__keyboard--plate div .rows>ul>.w20{width:calc(20vw - 2px)}.ML__keyboard .ML__keyboard--plate div .rows>ul>.w50{width:calc(50vw - 2px)}}@media only screen and (min-width:415px) and (max-width:768px){.ML__keyboard .ML__keyboard--plate div .rows>ul>li{margin-right:3px;width:37px}.ML__keyboard .ML__keyboard--plate div .rows>ul>.w5{width:17px}.ML__keyboard .ML__keyboard--plate div .rows>ul>.w15{width:57px}.ML__keyboard .ML__keyboard--plate div .rows>ul>.w20{width:77px}.ML__keyboard .ML__keyboard--plate div .rows>ul>.w50{width:197px}}@media only screen and (min-width:768px) and (max-width:1024px){.ML__keyboard .ML__keyboard--plate div .rows>ul{height:var(--keycap-height,52px)}.ML__keyboard .ML__keyboard--plate div .rows>ul>li{height:var(--keycap-height,52px);margin-right:4px;width:51px}.ML__keyboard .ML__keyboard--plate div .rows>ul>.w5{width:23.5px}.ML__keyboard .ML__keyboard--plate div .rows>ul>.w15{width:78.5px}.ML__keyboard .ML__keyboard--plate div .rows>ul>.w20{width:106px}.ML__keyboard .ML__keyboard--plate div .rows>ul>.w50{width:271px}}@media only screen and (min-width:1025px){.ML__keyboard .ML__keyboard--plate div .rows>ul{height:var(--keycap-height,52px)}.ML__keyboard .ML__keyboard--plate div .rows>ul>li{height:var(--keycap-height,52px);margin-right:6px;width:66px}.ML__keyboard .ML__keyboard--plate div .rows>ul>.action,.ML__keyboard .ML__keyboard--plate div .rows>ul>.modifier{font-size:80%}.ML__keyboard .ML__keyboard--plate div .rows>ul>.w5{width:30px}.ML__keyboard .ML__keyboard--plate div .rows>ul>.w15{width:102px}.ML__keyboard .ML__keyboard--plate div .rows>ul>.w20{width:138px}.ML__keyboard .ML__keyboard--plate div .rows>ul>.w50{width:354px}}@media (prefers-color-scheme:dark){body:not([theme=light]) .ML__keyboard{--hue:206;--keyboard-background:hsl(var(--hue,212),19%,38%);--keyboard-text:#f0f0f0;--keyboard-text-active:hsl(var(--hue,212),100%,60%);--keyboard-background-border:#333;--keycap-background:hsl(var(--hue,212),25%,39%);--keycap-background-active:hsl(var(--hue,212),35%,42%);--keycap-background-border:hsl(var(--hue,212),25%,35%);--keycap-background-border-bottom:#426b8a;--keycap-text:#d0d0d0;--keycap-text-active:#000;--keycap-secondary-text:#fff;--keycap-modifier-background:hsl(var(--hue,212),35%,40%);--keycap-modifier-border:hsl(var(--hue,212),35%,35%);--keycap-modifier-border-bottom:hsl(var(--hue,212),35%,42%);--keyboard-alternate-background:hsl(var(--hue,212),19%,38%)}}body[theme=dark] .ML__keyboard{--hue:206;--keyboard-background:hsl(var(--hue,212),19%,38%);--keyboard-text:#f0f0f0;--keyboard-text-active:hsl(var(--hue,212),100%,60%);--keyboard-background-border:#333;--keycap-background:hsl(var(--hue,212),25%,39%);--keycap-background-active:hsl(var(--hue,212),35%,42%);--keycap-background-border:hsl(var(--hue,212),25%,35%);--keycap-background-border-bottom:#426b8a;--keycap-text:#d0d0d0;--keycap-text-active:#000;--keycap-secondary-text:#fff;--keycap-modifier-background:hsl(var(--hue,212),35%,40%);--keycap-modifier-border:hsl(var(--hue,212),35%,35%);--keycap-modifier-border-bottom:hsl(var(--hue,212),35%,42%);--keyboard-alternate-background:hsl(var(--hue,212),19%,38%)}div.ML__keyboard.material{--keyboard-background:rgba(209,213,217,.9);--keyboard-background-border:#ddd;--keycap-background:transparent;--keycap-background-active:#cccfd1;--keycap-background-border:transparent;--keyboard-alternate-background:#efefef;--keyboard-alternate-text:#000;font-family:Roboto,sans-serif}div.ML__keyboard.material.alternate-keys{background:var(--keyboard-alternate-background);border:1px solid transparent;border-radius:5px;box-shadow:0 14px 28px rgba(0,0,0,.25),0 10px 10px rgba(0,0,0,.22)}div.ML__keyboard.material.alternate-keys ul li.is-active,div.ML__keyboard.material.alternate-keys ul li.is-pressed,div.ML__keyboard.material.alternate-keys ul li:active,div.ML__keyboard.material.alternate-keys ul li:hover{fill:currentColor;background:#5f97fc;border:1px solid transparent;color:#fff}div.ML__keyboard.material .ML__keyboard__plate .keyboard-toolbar>div>div{font-size:16px}div.ML__keyboard.material .ML__keyboard__plate .keyboard-toolbar div.div.is-active,div.ML__keyboard.material .ML__keyboard__plate .keyboard-toolbar div.div.is-pressed,div.ML__keyboard.material .ML__keyboard__plate .keyboard-toolbar div div:active,div.ML__keyboard.material .ML__keyboard__plate .keyboard-toolbar div div:hover{fill:currentColor;color:#5f97fc}div.ML__keyboard.material .ML__keyboard__plate .keyboard-toolbar>div>.selected{fill:currentColor;border-bottom:2px solid #5f97fc;color:#5f97fc;margin-bottom:8px;padding-bottom:0}div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap{fill:currentColor;background:transparent;border:1px solid transparent;border-radius:5px;color:var(--keycap-text);transition:none}div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap.tt{color:#5f97fc}div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap[data-key=\" \"]{background:#e0e0e0;height:20px;margin-bottom:10px;margin-top:10px}div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap[data-key=\" \"].is-active,div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap[data-key=\" \"].is-pressed,div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap[data-key=\" \"]:active,div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap[data-key=\" \"]:hover{background:#d0d0d0;box-shadow:none;transform:none}div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap:not([data-key=\" \"]):hover{background:var(--keycap-background-active);border:1px solid transparent;box-shadow:none}div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap:not([data-key=\" \"]).is-active,div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap:not([data-key=\" \"]).is-pressed,div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap:not([data-key=\" \"]):active{background:var(--keyboard-alternate-background);box-shadow:0 10px 20px rgba(0,0,0,.19),0 6px 6px rgba(0,0,0,.23);color:var(--keyboard-alternate-text)}@media only screen and (max-width:767px){div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap:not([data-key=\" \"]).is-active,div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap:not([data-key=\" \"]).is-pressed,div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap:not([data-key=\" \"]):active{box-shadow:0 10px 20px rgba(0,0,0,.19),0 6px 6px rgba(0,0,0,.23);font-size:10px;justify-content:flex-start;margin-left:10px;margin-right:10px;padding:2px 0 0;transform:translateY(-10px) scale(2);transition:none;vertical-align:top;width:19.5px;z-index:calc(var(--ML_keyboard-zindex, 105) - 5)}}@media only screen and (max-width:414px){div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap:not([data-key=\" \"]).is-active,div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap:not([data-key=\" \"]).is-pressed,div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap:not([data-key=\" \"]):active{width:16.5px}}@media only screen and (max-width:767px){div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap:last-child.is-active,div.ML__keyboard.material .ML__keyboard__plate div>.rows>ul>.keycap:last-child:active{margin-left:14px;margin-right:0}}div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.action,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.modifier{fill:currentColor;background:transparent;border:0;color:#869096;font-size:16px;transition:none}div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.action.selected,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.modifier.selected{border-bottom:2px solid #5f97fc;border-radius:0;color:#5f97fc}div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.action.is-active,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.action.is-pressed,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.action:active,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.action:hover,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.modifier.is-active,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.modifier.is-pressed,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.modifier:active,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.modifier:hover{background:var(--keycap-background-active);border:0;box-shadow:none;color:var(--keycap-text)}div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.bigfnbutton,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.fnbutton{background:transparent;border:0}div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.bigfnbutton.selected,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.fnbutton.selected{fill:currentColor;border-bottom:2px solid #5f97fc;border-radius:0;color:#5f97fc}div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.bigfnbutton.is-active,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.bigfnbutton.is-pressed,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.bigfnbutton:active,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.bigfnbutton:hover,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.fnbutton.is-active,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.fnbutton.is-pressed,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.fnbutton:active,div.ML__keyboard.material .ML__keyboard__plate div div.rows ul li.fnbutton:hover{fill:currentColor;background:var(--keycap-background-active);border:0;box-shadow:none;color:#5f97fc}@media (prefers-color-scheme:dark){body:not([theme=light]) div.ML__keyboard.material{--hue:198;--keyboard-background:hsl(var(--hue,212),19%,18%);--keyboard-text:#d4d6d7;--keyboard-text-active:#5f97fc;--keyboard-background-border:#333;--keycap-background:hsl(var(--hue,212),25%,39%);--keycap-background-active:#5f97fc;--keycap-background-border:transparent;--keycap-background-border-bottom:transparent;--keycap-text:#d0d0d0;--keycap-text-active:#d4d6d7;--keycap-secondary-text:#5f97fc;--keycap-modifier-background:hsl(var(--hue,212),35%,40%);--keycap-modifier-border:hsl(var(--hue,212),35%,35%);--keycap-modifier-border-bottom:hsl(var(--hue,212),35%,42%);--keyboard-alternate-background:hsl(var(--hue,212),8%,2%);--keyboard-alternate-background-active:hsl(var(--hue,212),35%,42%);--keyboard-alternate-text:#d1d1d1}}body[theme=dark] div.ML__keyboard.material{--hue:198;--keyboard-background:hsl(var(--hue,212),19%,18%);--keyboard-text:#d4d6d7;--keyboard-text-active:#5f97fc;--keyboard-background-border:#333;--keycap-background:hsl(var(--hue,212),25%,39%);--keycap-background-active:#5f97fc;--keycap-background-border:transparent;--keycap-background-border-bottom:transparent;--keycap-text:#d0d0d0;--keycap-text-active:#d4d6d7;--keycap-secondary-text:#5f97fc;--keycap-modifier-background:hsl(var(--hue,212),35%,40%);--keycap-modifier-border:hsl(var(--hue,212),35%,35%);--keycap-modifier-border-bottom:hsl(var(--hue,212),35%,42%);--keyboard-alternate-background:hsl(var(--hue,212),8%,2%);--keyboard-alternate-background-active:hsl(var(--hue,212),35%,42%);--keyboard-alternate-text:#d1d1d1}";
|
23978 |
|
23979 |
|
23980 |
|
23981 |
|
23982 |
|
23983 | const VARIANTS = {
|
23984 |
|
23985 | 'main': ['Main-Regular', 'ML__cmr'],
|
23986 | 'main-italic': ['Main-Italic', 'ML__cmr ML__it'],
|
23987 | 'main-bold': ['Main-Bold', 'ML__cmr ML__bold'],
|
23988 | 'main-bolditalic': ['Main-BoldItalic', 'ML__cmr ML__bold ML__it'],
|
23989 | 'normal': ['Main-Regular', 'ML__cmr'],
|
23990 | 'normal-bold': ['Main-Bold', 'ML__mathbf'],
|
23991 | 'normal-italic': ['Math-Italic', 'ML__mathit'],
|
23992 | 'normal-bolditalic': ['Math-BoldItalic', 'ML__mathbfit'],
|
23993 |
|
23994 | 'ams': ['AMS-Regular', 'ML__ams'],
|
23995 | 'ams-bold': ['AMS-Regular', 'ML__ams'],
|
23996 | 'ams-italic': ['AMS-Regular', 'ML__ams'],
|
23997 | 'ams-bolditalic': ['AMS-Regular', 'ML__ams'],
|
23998 | 'sans-serif': ['SansSerif-Regular', 'ML__sans'],
|
23999 | 'sans-serif-bold': ['SansSerif-Regular', 'ML__sans ML__bold'],
|
24000 | 'sans-serif-italic': ['SansSerif-Regular', 'ML__sans'],
|
24001 | 'sans-serif-bolditalic': ['SansSerif-Regular', 'ML__sans'],
|
24002 | 'calligraphic': ['Caligraphic-Regular', 'ML__cal'],
|
24003 | 'calligraphic-bold': ['Caligraphic-Regular', 'ML__cal ML__bold'],
|
24004 | 'calligraphic-italic': ['Caligraphic-Regular', 'ML__cal ML__it'],
|
24005 | 'calligraphic-bolditalic': ['Caligraphic-Regular', 'ML__cal ML__bold ML__it'],
|
24006 | 'script': ['Script-Regular', 'ML__script'],
|
24007 | 'script-bold': ['Script-Regular', 'ML__script ML__bold'],
|
24008 | 'script-italic': ['Script-Regular', 'ML__script ML__it'],
|
24009 | 'script-bolditalic': ['Script-Regular', 'ML__script ML__bold ML__it'],
|
24010 | 'fraktur': ['Fraktur-Regular', 'ML__frak'],
|
24011 | 'fraktur-bold': ['Fraktur-Regular', 'ML__frak'],
|
24012 | 'fraktur-italic': ['Fraktur-Regular', 'ML__frak'],
|
24013 | 'fraktur-bolditalic': ['Fraktur-Regular', 'ML__frak'],
|
24014 | 'monospace': ['Typewriter-Regular', 'ML__tt'],
|
24015 | 'monospace-bold': ['Typewriter-Regular', 'ML__tt ML__bold'],
|
24016 | 'monospace-italic': ['Typewriter-Regular', 'ML__tt ML__it'],
|
24017 | 'monospace-bolditalic': ['Typewriter-Regular', 'ML__tt ML__bold ML__it'],
|
24018 |
|
24019 | 'double-struck': ['AMS-Regular', 'ML__bb'],
|
24020 | 'double-struck-bold': ['AMS-Regular', 'ML__bb'],
|
24021 | 'double-struck-italic': ['AMS-Regular', 'ML__bb'],
|
24022 | 'double-struck-bolditalic': ['AMS-Regular', 'ML__bb'],
|
24023 | };
|
24024 | const VARIANT_REPERTOIRE = {
|
24025 | 'double-struck': /^[A-Z ]$/,
|
24026 | 'script': /^[A-Z ]$/,
|
24027 | 'calligraphic': /^[\dA-Z ]$/,
|
24028 | 'fraktur': /^[\dA-Za-z ]$|^[!"#$%&'()*+,\-./:;=?[]^’‘]$/,
|
24029 | 'monospace': /^[\dA-Za-z ]$|^[!"&'()*+,\-./:;=?@[\]^_~\u0131\u0237\u0393\u0394\u0398\u039B\u039E\u03A0\u03A3\u03A5\u03A8\u03A9]$/,
|
24030 | 'sans-serif': /^[\dA-Za-z ]$|^[!"&'()*+,\-./:;=?@[\]^_~\u0131\u0237\u0393\u0394\u0398\u039B\u039E\u03A0\u03A3\u03A5\u03A8\u03A9]$/,
|
24031 | };
|
24032 | const GREEK_LOWERCASE = /^[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5]$/;
|
24033 | const GREEK_UPPERCASE = /^[\u0393|\u0394\u0398\u039B\u039E\u03A0\u03A3\u03A5\u03A6\u03A8\u03A9]$/;
|
24034 | const LETTER_SHAPE_RANGES = [
|
24035 | /^[a-z]$/,
|
24036 | /^[A-Z]$/,
|
24037 | GREEK_LOWERCASE,
|
24038 | GREEK_UPPERCASE,
|
24039 | ];
|
24040 |
|
24041 |
|
24042 | const LETTER_SHAPE_MODIFIER = {
|
24043 | iso: ['it', 'it', 'it', 'it'],
|
24044 | tex: ['it', 'it', 'it', 'up'],
|
24045 | french: ['it', 'up', 'up', 'up'],
|
24046 | upright: ['up', 'up', 'up', 'up'],
|
24047 | };
|
24048 |
|
24049 | class MathMode extends Mode {
|
24050 | constructor() {
|
24051 | super('math');
|
24052 | }
|
24053 | createAtom(command, style) {
|
24054 | var _a, _b;
|
24055 | const info = getInfo(command, 'math');
|
24056 | const result = new Atom((_a = info === null || info === void 0 ? void 0 : info.type) !== null && _a !== void 0 ? _a : 'mord', {
|
24057 | mode: 'math',
|
24058 | command,
|
24059 | value: (info === null || info === void 0 ? void 0 : info.codepoint) ? String.fromCodePoint(info === null || info === void 0 ? void 0 : info.codepoint) : command,
|
24060 | style,
|
24061 | });
|
24062 | if ((_b = info === null || info === void 0 ? void 0 : info.isFunction) !== null && _b !== void 0 ? _b : false) {
|
24063 | result.isFunction = true;
|
24064 | }
|
24065 | if (command.startsWith('\\')) {
|
24066 | result.verbatimLatex = command;
|
24067 | }
|
24068 | return result;
|
24069 | }
|
24070 | serialize(run, options) {
|
24071 | const { parent } = run[0];
|
24072 | const contextFontsize = parent === null || parent === void 0 ? void 0 : parent.computedStyle.fontSize;
|
24073 | return joinLatex(getPropertyRuns(run, 'fontSize').map((x) => {
|
24074 | const result = this.emitBackgroundColorRun(x, options);
|
24075 | const fontsize = x[0].computedStyle.fontSize;
|
24076 | if (fontsize && (!parent || contextFontsize !== fontsize)) {
|
24077 | return ('\\' +
|
24078 | [
|
24079 | '',
|
24080 | 'tiny',
|
24081 | 'scriptsize',
|
24082 | 'footnotesize',
|
24083 | 'small',
|
24084 | 'normalsize',
|
24085 | 'large',
|
24086 | 'Large',
|
24087 | 'LARGE',
|
24088 | 'huge',
|
24089 | 'Huge',
|
24090 | ][fontsize] +
|
24091 | ' ' +
|
24092 | result);
|
24093 | }
|
24094 | return result;
|
24095 | }));
|
24096 | }
|
24097 | emitBackgroundColorRun(run, options) {
|
24098 | const { parent } = run[0];
|
24099 | const parentColor = parent === null || parent === void 0 ? void 0 : parent.computedStyle.backgroundColor;
|
24100 | return joinLatex(getPropertyRuns(run, 'backgroundColor').map((x) => {
|
24101 | var _a;
|
24102 | let result = this.emitColorRun(x, options);
|
24103 | const style = x[0].computedStyle;
|
24104 | if (style.backgroundColor &&
|
24105 | (!parent || parentColor !== style.backgroundColor) &&
|
24106 | (x.length > 0 || !(x[0] instanceof BoxAtom))) {
|
24107 | if (options.defaultMode === 'inline-math') {
|
24108 | result = `\\( ${result} \\)`;
|
24109 | }
|
24110 | else {
|
24111 | result = `\\[ ${result} \\]`;
|
24112 | }
|
24113 | result = `\\colorbox{${(_a = style.verbatimBackgroundColor) !== null && _a !== void 0 ? _a : style.backgroundColor}}{${result}}`;
|
24114 | }
|
24115 | return result;
|
24116 | }));
|
24117 | }
|
24118 | emitColorRun(run, options) {
|
24119 | var _a;
|
24120 | const { parent } = run[0];
|
24121 | const parentMode = (_a = parent === null || parent === void 0 ? void 0 : parent.mode) !== null && _a !== void 0 ? _a : 'math';
|
24122 | const contextVariant = variantString(parent);
|
24123 | const contextColor = parent === null || parent === void 0 ? void 0 : parent.computedStyle.color;
|
24124 | return joinLatex(getPropertyRuns(run, 'color').map((x) => {
|
24125 | var _a;
|
24126 | const result = joinLatex(getPropertyRuns(x, 'variant').map((x) => {
|
24127 | const variant = variantString(x[0]);
|
24128 |
|
24129 |
|
24130 |
|
24131 | if (x.every((x) => {
|
24132 | const info = getInfo(x.command, parentMode);
|
24133 | if (!info || !info.variant)
|
24134 | return false;
|
24135 | return variantString(x) === variant;
|
24136 | })) {
|
24137 | return joinLatex(x.map((x) => Atom.serialize(x, options)));
|
24138 | }
|
24139 | let command = '';
|
24140 | if (variant && variant !== contextVariant) {
|
24141 | command = {
|
24142 | 'calligraphic': '\\mathcal{',
|
24143 | 'fraktur': '\\mathfrak{',
|
24144 | 'double-struck': '\\mathbb{',
|
24145 | 'script': '\\mathscr{',
|
24146 | 'monospace': '\\mathtt{',
|
24147 | 'sans-serif': '\\mathsf{',
|
24148 | 'normal': '\\mathrm{',
|
24149 | 'normal-italic': '\\mathit{',
|
24150 | 'normal-bold': '\\mathbf{',
|
24151 | 'normal-bolditalic': '\\mathbfit{',
|
24152 | 'ams': '',
|
24153 | 'ams-italic': '\\mathit{',
|
24154 | 'ams-bold': '\\mathbf{',
|
24155 | 'ams-bolditalic': '\\mathbfit{',
|
24156 | 'main': '',
|
24157 | 'main-italic': '\\mathit{',
|
24158 | 'main-bold': '\\mathbf{',
|
24159 | 'main-bolditalic': '\\mathbfit{',
|
24160 |
|
24161 |
|
24162 |
|
24163 |
|
24164 |
|
24165 | }[variant];
|
24166 | console.assert(command !== undefined);
|
24167 | }
|
24168 | return (joinLatex([
|
24169 | command,
|
24170 | ...x.map((x) => Atom.serialize(x, options)),
|
24171 | ]) + (command ? '}' : ''));
|
24172 | }));
|
24173 | const style = x[0].computedStyle;
|
24174 | if (style.color && (!parent || contextColor !== style.color)) {
|
24175 | return ('\\textcolor{' +
|
24176 | ((_a = style.verbatimColor) !== null && _a !== void 0 ? _a : style.color) +
|
24177 | '}{' +
|
24178 | result +
|
24179 | '}');
|
24180 | }
|
24181 | return result;
|
24182 | }));
|
24183 | }
|
24184 | applyStyle(box, style) {
|
24185 |
|
24186 | if (style.variant === undefined)
|
24187 | return '';
|
24188 |
|
24189 |
|
24190 |
|
24191 | const letterShapeStyle = style.letterShapeStyle === 'auto' || !style.letterShapeStyle
|
24192 | ? 'tex'
|
24193 | : style.letterShapeStyle;
|
24194 | let { variant } = style;
|
24195 | let { variantStyle } = style;
|
24196 |
|
24197 |
|
24198 |
|
24199 |
|
24200 |
|
24201 |
|
24202 |
|
24203 |
|
24204 | if (variant === 'normal' &&
|
24205 | !variantStyle &&
|
24206 | /[\u00A3\u0131\u0237]/.test(box.value)) {
|
24207 | variant = 'main';
|
24208 | variantStyle = 'italic';
|
24209 | }
|
24210 |
|
24211 |
|
24212 | if (variant === 'normal' && !variantStyle && box.value.length === 1) {
|
24213 | LETTER_SHAPE_RANGES.forEach((x, i) => {
|
24214 | if (x.test(box.value) &&
|
24215 | LETTER_SHAPE_MODIFIER[letterShapeStyle][i] === 'it') {
|
24216 | variantStyle = 'italic';
|
24217 | }
|
24218 | });
|
24219 | }
|
24220 |
|
24221 | if (variantStyle === 'up') {
|
24222 | variantStyle = undefined;
|
24223 | }
|
24224 | const styledVariant = variantStyle ? variant + '-' + variantStyle : variant;
|
24225 | console.assert(VARIANTS[styledVariant] !== undefined);
|
24226 | const [fontName, classes] = VARIANTS[styledVariant];
|
24227 |
|
24228 |
|
24229 | if (VARIANT_REPERTOIRE[variant] &&
|
24230 | !VARIANT_REPERTOIRE[variant].test(box.value)) {
|
24231 |
|
24232 | box.value = mathVariantToUnicode(box.value, variant, variantStyle);
|
24233 |
|
24234 | return null;
|
24235 | }
|
24236 |
|
24237 |
|
24238 | if (GREEK_LOWERCASE.test(box.value)) {
|
24239 | box.classes += ' lcGreek';
|
24240 | }
|
24241 |
|
24242 | if (classes) {
|
24243 | box.classes += ' ' + classes;
|
24244 | }
|
24245 | return fontName;
|
24246 | }
|
24247 | }
|
24248 | function variantString(atom) {
|
24249 | if (!atom)
|
24250 | return '';
|
24251 | const { style } = atom;
|
24252 | if (style.variant === undefined)
|
24253 | return '';
|
24254 | let result = style.variant;
|
24255 | if (style.variantStyle && style.variantStyle !== 'up') {
|
24256 | result += '-' + style.variantStyle;
|
24257 | }
|
24258 | return result;
|
24259 | }
|
24260 |
|
24261 | new MathMode();
|
24262 |
|
24263 | function emitStringTextRun(run, options) {
|
24264 | return joinLatex(run.map((x) => Atom.serialize(x, options)));
|
24265 | }
|
24266 | function emitFontShapeTextRun(run, options) {
|
24267 | return joinLatex(getPropertyRuns(run, 'fontShape').map((x) => {
|
24268 | const result = emitStringTextRun(x, options);
|
24269 | const { fontShape } = x[0].style;
|
24270 | if (fontShape === 'it') {
|
24271 | return '\\textit{' + result + '}';
|
24272 | }
|
24273 | if (fontShape === 'sl') {
|
24274 | return '\\textsl{' + result + '}';
|
24275 | }
|
24276 | if (fontShape === 'sc') {
|
24277 | return '\\textsc{' + result + '}';
|
24278 | }
|
24279 | if (fontShape === 'n') {
|
24280 | return '\\textup{' + result + '}';
|
24281 | }
|
24282 | if (fontShape) {
|
24283 | return '\\fontshape{' + x[0].style.fontShape + '}' + result;
|
24284 | }
|
24285 | return result;
|
24286 | }));
|
24287 | }
|
24288 | function emitFontSeriesTextRun(run, options) {
|
24289 | return joinLatex(getPropertyRuns(run, 'fontSeries').map((x) => {
|
24290 | const result = emitFontShapeTextRun(x, options);
|
24291 | const { fontSeries } = x[0].style;
|
24292 | if (fontSeries === 'b') {
|
24293 | return '\\textbf{' + result + '}';
|
24294 | }
|
24295 | if (fontSeries === 'l') {
|
24296 | return '\\textlf{' + result + '}';
|
24297 | }
|
24298 | if (fontSeries === 'm') {
|
24299 | return '\\textmd{' + result + '}';
|
24300 | }
|
24301 | if (fontSeries) {
|
24302 | return '\\fontseries{' + fontSeries + '}' + result;
|
24303 | }
|
24304 | return result;
|
24305 | }));
|
24306 | }
|
24307 | function emitSizeTextRun(run, options) {
|
24308 | return joinLatex(getPropertyRuns(run, 'fontSize').map((x) => {
|
24309 | var _a, _b;
|
24310 | const result = emitFontSeriesTextRun(x, options);
|
24311 | const command = (_b = [
|
24312 | '',
|
24313 | 'tiny',
|
24314 | 'scriptsize',
|
24315 | 'footnotesize',
|
24316 | 'small',
|
24317 | 'normalsize',
|
24318 | 'large',
|
24319 | 'Large',
|
24320 | 'LARGE',
|
24321 | 'huge',
|
24322 | 'Huge',
|
24323 | ][(_a = x[0].style.fontSize) !== null && _a !== void 0 ? _a : '']) !== null && _b !== void 0 ? _b : '';
|
24324 | if (command) {
|
24325 | return `\\${command} ${result}`;
|
24326 | }
|
24327 | return result;
|
24328 | }));
|
24329 | }
|
24330 | function emitFontFamilyTextRun(run, options) {
|
24331 | return joinLatex(getPropertyRuns(run, 'fontFamily').map((x) => {
|
24332 | var _a, _b;
|
24333 | const result = emitSizeTextRun(x, options);
|
24334 | const command = (_b = {
|
24335 | 'roman': 'textrm',
|
24336 | 'monospace': 'texttt',
|
24337 | 'sans-serif': 'textsf',
|
24338 | }[(_a = x[0].style.fontFamily) !== null && _a !== void 0 ? _a : '']) !== null && _b !== void 0 ? _b : '';
|
24339 | if (command)
|
24340 | return `\\${command}{${result}}`;
|
24341 | if (x[0].style.fontFamily) {
|
24342 | return '\\fontfamily{' + x[0].style.fontFamily + '}' + result;
|
24343 | }
|
24344 | return result;
|
24345 | }));
|
24346 | }
|
24347 | function emitStyledTextRun(run, options) {
|
24348 | return emitFontFamilyTextRun(run, options);
|
24349 | }
|
24350 | function emitBackgroundColorRun(run, options) {
|
24351 | const { parent } = run[0];
|
24352 | const parentColor = parent === null || parent === void 0 ? void 0 : parent.computedStyle.backgroundColor;
|
24353 | return joinLatex(getPropertyRuns(run, 'backgroundColor').map((x) => {
|
24354 | var _a;
|
24355 | let result = emitColorRun(x, options);
|
24356 | const style = x[0].computedStyle;
|
24357 | if (style.backgroundColor &&
|
24358 | (!parent || parentColor !== style.backgroundColor) &&
|
24359 | (x.length > 0 || !(x[0] instanceof BoxAtom))) {
|
24360 | result = `\\colorbox{${(_a = style.verbatimBackgroundColor) !== null && _a !== void 0 ? _a : style.backgroundColor}}{${result}}`;
|
24361 | }
|
24362 | return result;
|
24363 | }));
|
24364 | }
|
24365 | function emitColorRun(run, options) {
|
24366 | var _a;
|
24367 | if (!run || run.length === 0)
|
24368 | return '';
|
24369 | const parentColor = (_a = run[0].parent) === null || _a === void 0 ? void 0 : _a.style.color;
|
24370 | return joinLatex(getPropertyRuns(run, 'color').map((x) => {
|
24371 | var _a;
|
24372 | const result = emitStyledTextRun(x, options);
|
24373 | if (x[0].style.color &&
|
24374 | x[0].style.color !== 'none' &&
|
24375 | parentColor !== x[0].style.color) {
|
24376 |
|
24377 |
|
24378 | return ('\\textcolor{' +
|
24379 | ((_a = x[0].style.verbatimColor) !== null && _a !== void 0 ? _a : x[0].style.color) +
|
24380 | '}{' +
|
24381 | result +
|
24382 | '}');
|
24383 | }
|
24384 | return result;
|
24385 | }));
|
24386 | }
|
24387 | const TEXT_FONT_CLASS = {
|
24388 | 'roman': '',
|
24389 | 'sans-serif': 'ML__sans',
|
24390 | 'monospace': 'ML__tt',
|
24391 | };
|
24392 | class TextMode extends Mode {
|
24393 | constructor() {
|
24394 | super('text');
|
24395 | }
|
24396 | createAtom(command, style) {
|
24397 | const info = getInfo(command, 'text');
|
24398 | return new TextAtom(command, (info === null || info === void 0 ? void 0 : info.codepoint) ? String.fromCodePoint(info === null || info === void 0 ? void 0 : info.codepoint) : command, style);
|
24399 | }
|
24400 | serialize(inRun, options) {
|
24401 | var _a, _b, _c;
|
24402 | const run = [...inRun];
|
24403 | let prefix = '';
|
24404 | while ((_b = (_a = run[0]) === null || _a === void 0 ? void 0 : _a.changeMode) !== null && _b !== void 0 ? _b : false) {
|
24405 | prefix += emitBackgroundColorRun([run[0]], options);
|
24406 | run.shift();
|
24407 | }
|
24408 | let suffix = '';
|
24409 | if (run.length > 0) {
|
24410 | suffix += emitBackgroundColorRun(run, options);
|
24411 | }
|
24412 | if ((_c = options.skipModeCommand) !== null && _c !== void 0 ? _c : false)
|
24413 | return prefix + suffix;
|
24414 | if (suffix) {
|
24415 | const allAtomsHaveShapeOrSeriesOrFontFamily = run.every((x) => x.style.fontSeries !== undefined ||
|
24416 | x.style.fontShape !== undefined ||
|
24417 | x.style.fontFamily !== undefined);
|
24418 | if (!allAtomsHaveShapeOrSeriesOrFontFamily) {
|
24419 |
|
24420 |
|
24421 |
|
24422 | suffix = `\\text{${suffix}}`;
|
24423 | }
|
24424 | }
|
24425 | return prefix + suffix;
|
24426 | }
|
24427 | |
24428 |
|
24429 |
|
24430 | applyStyle(box, style) {
|
24431 | var _a, _b, _c, _d, _e, _f;
|
24432 | const { fontFamily } = style;
|
24433 | if (TEXT_FONT_CLASS[fontFamily]) {
|
24434 | box.classes += (_a = ' ' + TEXT_FONT_CLASS[fontFamily]) !== null && _a !== void 0 ? _a : '';
|
24435 | }
|
24436 | else if (fontFamily) {
|
24437 |
|
24438 | box.setStyle('font-family', fontFamily);
|
24439 | }
|
24440 | if (style.fontShape) {
|
24441 | box.classes += ' ';
|
24442 | box.classes +=
|
24443 | (_b = {
|
24444 | it: 'ML__it',
|
24445 | sl: 'ML__shape_sl',
|
24446 | sc: 'ML__shape_sc',
|
24447 | ol: 'ML__shape_ol',
|
24448 | }[style.fontShape]) !== null && _b !== void 0 ? _b : '';
|
24449 | }
|
24450 | if (style.fontSeries) {
|
24451 | const m = style.fontSeries.match(/(.?[lbm])?(.?[cx])?/);
|
24452 | if (m) {
|
24453 | box.classes += ' ';
|
24454 | box.classes +=
|
24455 | (_d = {
|
24456 | ul: 'ML__series_ul',
|
24457 | el: 'ML__series_el',
|
24458 | l: 'ML__series_l',
|
24459 | sl: 'ML__series_sl',
|
24460 | m: '',
|
24461 | sb: 'ML__series_sb',
|
24462 | b: 'ML__bold',
|
24463 | eb: 'ML__series_eb',
|
24464 | ub: 'ML__series_ub',
|
24465 | }[(_c = m[1]) !== null && _c !== void 0 ? _c : '']) !== null && _d !== void 0 ? _d : '';
|
24466 | box.classes += ' ';
|
24467 | box.classes +=
|
24468 | (_f = {
|
24469 | uc: 'ML__series_uc',
|
24470 | ec: 'ML__series_ec',
|
24471 | c: 'ML__series_c',
|
24472 | sc: 'ML__series_sc',
|
24473 | n: '',
|
24474 | sx: 'ML__series_sx',
|
24475 | x: 'ML__series_x',
|
24476 | ex: 'ML__series_ex',
|
24477 | ux: 'ML__series_ux',
|
24478 | }[(_e = m[2]) !== null && _e !== void 0 ? _e : '']) !== null && _f !== void 0 ? _f : '';
|
24479 | }
|
24480 | }
|
24481 |
|
24482 | return 'Main-Regular';
|
24483 | }
|
24484 |
|
24485 |
|
24486 |
|
24487 |
|
24488 |
|
24489 |
|
24490 | parse(tokens, error, options) {
|
24491 | let result = [];
|
24492 | let atom;
|
24493 | while (tokens.length > 0) {
|
24494 | const token = tokens.shift();
|
24495 | if (token === '<space>') {
|
24496 | result.push(new TextAtom(' ', ' ', options.style));
|
24497 | }
|
24498 | else if (!!token && token.startsWith('\\')) {
|
24499 |
|
24500 | tokens.unshift(token);
|
24501 | let atoms;
|
24502 | [atoms, tokens] = options.parse('text', tokens, options);
|
24503 | result = [...result, ...atoms];
|
24504 | }
|
24505 | else if (token === '<$>' || token === '<$$>') {
|
24506 |
|
24507 | const subtokens = tokens.slice(0, tokens.findIndex((x) => x === token));
|
24508 | tokens = tokens.slice(subtokens.length + 1);
|
24509 | const [atoms] = options.parse('math', subtokens, options);
|
24510 | result = [...result, ...atoms];
|
24511 | }
|
24512 | else if (token === '<{>' || token === '<}>') ;
|
24513 | else if (token) {
|
24514 | const info = getInfo(token, 'text', options.macros);
|
24515 | if (!info || (info.ifMode && !info.ifMode.includes('text'))) {
|
24516 | error({ code: 'unexpected-token' });
|
24517 | }
|
24518 | else if (info.codepoint) {
|
24519 | atom = new TextAtom(token, String.fromCodePoint(info.codepoint), options.style);
|
24520 | atom.verbatimLatex = charToLatex('text', token.codePointAt(0));
|
24521 | result.push(atom);
|
24522 | }
|
24523 | }
|
24524 | }
|
24525 | return [result, tokens];
|
24526 | }
|
24527 | }
|
24528 |
|
24529 | new TextMode();
|
24530 |
|
24531 |
|
24532 |
|
24533 |
|
24534 | class LatexAtom extends Atom {
|
24535 | constructor(value, options) {
|
24536 | var _a;
|
24537 | super('latex', { value, mode: 'latex' });
|
24538 | this.isSuggestion = (_a = options === null || options === void 0 ? void 0 : options.isSuggestion) !== null && _a !== void 0 ? _a : false;
|
24539 | this.isError = false;
|
24540 | this.verbatimLatex = value;
|
24541 | }
|
24542 | get computedStyle() {
|
24543 | return {};
|
24544 | }
|
24545 | render(context) {
|
24546 | const result = new Box(this.value, {
|
24547 | classes: this.isSuggestion
|
24548 | ? 'ML__suggestion'
|
24549 | : this.isError
|
24550 | ? 'ML__error'
|
24551 | : '',
|
24552 | type: 'latex',
|
24553 | maxFontSize: 1.0,
|
24554 | });
|
24555 | if (!result)
|
24556 | return null;
|
24557 | if (this.caret)
|
24558 | result.caret = this.caret;
|
24559 | return this.bind(context, result);
|
24560 | }
|
24561 | }
|
24562 |
|
24563 |
|
24564 |
|
24565 |
|
24566 | class LatexGroupAtom extends Atom {
|
24567 | constructor(latex) {
|
24568 | super('group', { mode: 'latex' });
|
24569 | this.body = [...latex].map((x) => new LatexAtom(x));
|
24570 | this.skipBoundary = false;
|
24571 | }
|
24572 | render(context) {
|
24573 | const box = Atom.createBox(context, this.body, { newList: true });
|
24574 | if (!box)
|
24575 | return null;
|
24576 | if (this.caret)
|
24577 | box.caret = this.caret;
|
24578 |
|
24579 |
|
24580 |
|
24581 | return this.bind(context, box);
|
24582 | }
|
24583 | serialize(_options) {
|
24584 | var _a, _b;
|
24585 | return (_b = (_a = this.body) === null || _a === void 0 ? void 0 : _a.map((x) => x.value).join('')) !== null && _b !== void 0 ? _b : '';
|
24586 | }
|
24587 | }
|
24588 |
|
24589 |
|
24590 | class LatexMode extends Mode {
|
24591 | constructor() {
|
24592 | super('latex');
|
24593 | }
|
24594 | createAtom(command, _style) {
|
24595 | return new LatexAtom(command);
|
24596 | }
|
24597 | serialize(run, _options) {
|
24598 | return run
|
24599 | .filter((x) => x instanceof LatexAtom && !x.isSuggestion)
|
24600 | .map((x) => x.value)
|
24601 | .join('');
|
24602 | }
|
24603 | }
|
24604 | new LatexMode();
|
24605 |
|
24606 |
|
24607 |
|
24608 |
|
24609 |
|
24610 |
|
24611 |
|
24612 |
|
24613 |
|
24614 |
|
24615 |
|
24616 |
|
24617 |
|
24618 |
|
24619 |
|
24620 |
|
24621 |
|
24622 |
|
24623 |
|
24624 |
|
24625 |
|
24626 |
|
24627 |
|
24628 |
|
24629 |
|
24630 |
|
24631 |
|
24632 |
|
24633 |
|
24634 |
|
24635 |
|
24636 |
|
24637 |
|
24638 |
|
24639 |
|
24640 |
|
24641 |
|
24642 |
|
24643 |
|
24644 |
|
24645 |
|
24646 |
|
24647 |
|
24648 |
|
24649 |
|
24650 |
|
24651 | const DEFAULT_DIMENSION_REGISTERS = {
|
24652 | 'p@': '1pt ',
|
24653 | 'z@': '0pt',
|
24654 | 'maxdimen': '16383.99999pt',
|
24655 | 'hfuzz': '0.1pt',
|
24656 | 'vfuzz': '0.1pt',
|
24657 | 'overfullrule': '5pt',
|
24658 | 'hsize': '6.5in',
|
24659 | 'vsize': '8.9in',
|
24660 | 'parindent': '20pt',
|
24661 | 'maxdepth': '4pt',
|
24662 | 'splitmaxdepth': '\\maxdimen',
|
24663 | 'boxmaxdepth': '\\maxdimen',
|
24664 | 'delimitershortfall': '5pt',
|
24665 | 'nulldelimiterspace': '1.2pt',
|
24666 | 'scriptspace': '0.5pt',
|
24667 | 'topskip': '10pt',
|
24668 | 'splittopskip': '10pt',
|
24669 | 'normalbaselineskip': '12pt',
|
24670 | 'normallineskip': '1pt',
|
24671 | 'normallineskiplimit': '0pt',
|
24672 |
|
24673 |
|
24674 | 'jot': '3pt',
|
24675 |
|
24676 |
|
24677 | 'doublerulesep': '2pt',
|
24678 |
|
24679 | 'arrayrulewidth': '0.4pt',
|
24680 | 'arraycolsep': '5pt',
|
24681 |
|
24682 | 'fboxsep': '3pt',
|
24683 | 'fboxrule': '0.4pt',
|
24684 | };
|
24685 | const DEFAULT_GLUE_REGISTERS = {
|
24686 | 'z@skip': '0pt plust0pt minus0pt',
|
24687 | 'hideskip': '-1000pt plust 1fill',
|
24688 | '@flushglue': '0pt plust 1fill',
|
24689 | 'parskip': '0pt plus 1pt',
|
24690 |
|
24691 |
|
24692 | 'abovedisplayskip': '12pt plus 3pt minus 9pt',
|
24693 | 'abovedisplayshortskip': '0pt plus 3pt',
|
24694 | 'belowdisplayskip': '12pt plus 3pt minus 9pt',
|
24695 | 'belowdisplayshortskip': '7pt plus 3pt minus 4pt',
|
24696 | 'parfillskip': '0pt plus 1fil',
|
24697 | 'thinmuskip': '3mu',
|
24698 | 'medmuskip': '4mu plus 2mu minus 4mu',
|
24699 | 'thickmuskip': '5mu plus 5mu',
|
24700 | 'smallskipamount': '3pt plus1pt minus1pt',
|
24701 | 'medskipamount': '6pt plus2pt minus2pt',
|
24702 | 'bigskipamount': '12pt plus4pt minus4pt',
|
24703 | };
|
24704 |
|
24705 |
|
24706 | const DEFAULT_NUMBER_REGISTERS = {
|
24707 |
|
24708 | pretolerance: 100,
|
24709 | tolerance: 200,
|
24710 | hbadness: 1000,
|
24711 | vbadness: 1000,
|
24712 | linepenalty: 10,
|
24713 | hyphenpenalty: 50,
|
24714 | exhyphenpenalty: 50,
|
24715 | binoppenalty: 700,
|
24716 | relpenalty: 500,
|
24717 | clubpenalty: 150,
|
24718 | widowpenalty: 150,
|
24719 | displaywidowpenalty: 50,
|
24720 | brokenpenalty: 100,
|
24721 | predisplaypenalty: 10000,
|
24722 | doublehyphendemerits: 10000,
|
24723 | finalhyphendemerits: 5000,
|
24724 | adjdemerits: 10000,
|
24725 | tracinglostchars: 1,
|
24726 | uchyph: 1,
|
24727 | delimiterfactor: 901,
|
24728 | defaulthyphenchar: '\\-',
|
24729 | defaultskewchar: -1,
|
24730 | newlinechar: -1,
|
24731 | showboxbreadth: 5,
|
24732 | showboxdepth: 3,
|
24733 | errorcontextlines: 5,
|
24734 | interdisplaylinepenalty: 100,
|
24735 | interfootnotelinepenalty: 100,
|
24736 | baselineSkip: 1.2,
|
24737 |
|
24738 | arraystretch: '',
|
24739 | month: new Date().getMonth() + 1,
|
24740 | day: new Date().getDate(),
|
24741 | year: new Date().getFullYear(),
|
24742 | };
|
24743 | let _DEFAULT_REGISTERS;
|
24744 | function getDefaultRegisters() {
|
24745 | var _a, _b;
|
24746 | if (_DEFAULT_REGISTERS)
|
24747 | return _DEFAULT_REGISTERS;
|
24748 | _DEFAULT_REGISTERS = {
|
24749 | ...DEFAULT_NUMBER_REGISTERS,
|
24750 | };
|
24751 | for (const reg of Object.keys(DEFAULT_DIMENSION_REGISTERS)) {
|
24752 | _DEFAULT_REGISTERS[reg] =
|
24753 | (_a = convertToDimension(DEFAULT_DIMENSION_REGISTERS[reg], _DEFAULT_REGISTERS)) !== null && _a !== void 0 ? _a : 0;
|
24754 | }
|
24755 | for (const reg of Object.keys(DEFAULT_GLUE_REGISTERS)) {
|
24756 | _DEFAULT_REGISTERS[reg] =
|
24757 | (_b = convertToGlue(DEFAULT_GLUE_REGISTERS[reg], _DEFAULT_REGISTERS)) !== null && _b !== void 0 ? _b : 0;
|
24758 | }
|
24759 | return _DEFAULT_REGISTERS;
|
24760 | }
|
24761 |
|
24762 |
|
24763 |
|
24764 |
|
24765 |
|
24766 |
|
24767 |
|
24768 |
|
24769 |
|
24770 |
|
24771 |
|
24772 |
|
24773 |
|
24774 |
|
24775 |
|
24776 |
|
24777 |
|
24778 |
|
24779 |
|
24780 |
|
24781 |
|
24782 |
|
24783 |
|
24784 |
|
24785 |
|
24786 |
|
24787 |
|
24788 |
|
24789 |
|
24790 |
|
24791 |
|
24792 |
|
24793 |
|
24794 |
|
24795 |
|
24796 |
|
24797 |
|
24798 |
|
24799 |
|
24800 |
|
24801 |
|
24802 |
|
24803 |
|
24804 |
|
24805 |
|
24806 |
|
24807 | function typesetRecursive(atoms, _options) {
|
24808 |
|
24809 | return atoms;
|
24810 | }
|
24811 | function typeset(atoms, options) {
|
24812 |
|
24813 | return typesetRecursive(atoms, {
|
24814 | registers: (options === null || options === void 0 ? void 0 : options.registers) ? options.registers : getDefaultRegisters(),
|
24815 | });
|
24816 | }
|
24817 |
|
24818 | var css_248z$2 = "#mathlive-popover-panel{background-color:rgba(97,97,97,.95);border-radius:6px;box-shadow:0 14px 28px rgba(0,0,0,.25),0 10px 10px rgba(0,0,0,.22);color:#fff;display:flex;flex-direction:column;justify-content:center;min-width:160px;position:fixed;text-align:center;transition:all .2s cubic-bezier(.64,.09,.08,1);visibility:hidden;z-index:1}#mathlive-popover-panel:after{border-bottom:5px solid rgba(97,97,97,.9);border-left:5px solid transparent;border-right:5px solid transparent;content:\"\";font-size:1rem;height:0;left:calc(50% - 3px);position:absolute;top:-5px;width:0}.ML__popover--reverse-direction:after{border-bottom:0;border-top:5px solid rgba(97,97,97,.9);bottom:-5px;top:auto}#mathlive-popover-panel.is-visible{animation:ML__fade-in .15s cubic-bezier(0,0,.2,1);visibility:inherit}@keyframes ML__fade-in{0%{opacity:0}to{opacity:1}}.ML__popover__content{border-radius:6px;cursor:pointer;display:flex;flex-direction:column;justify-content:center;margin-left:8px;margin-right:8px;min-height:100px;padding:2px}.ML__popover__content a{color:#5ea6fd;display:block;margin-top:.4em;padding-top:.3em}.ML__popover__content a:hover{color:#5ea6fd;text-decoration:underline}.ML__popover__content.is-active,.ML__popover__content.is-pressed,.ML__popover__content:hover{background:hsla(0,0%,100%,.1)}.ML__popover__command{font-family:KaTeX_Main;font-size:1.6rem}.ML__popover__prev-shortcut{cursor:pointer;height:31px;margin-left:8px;margin-right:8px;opacity:.1;padding-bottom:2px;padding-top:4px}.ML__popover__next-shortcut:hover,.ML__popover__prev-shortcut:hover{opacity:.3}.ML__popover__next-shortcut.is-active,.ML__popover__next-shortcut.is-pressed,.ML__popover__prev-shortcut.is-active,.ML__popover__prev-shortcut.is-pressed{opacity:1}.ML__popover__next-shortcut>span,.ML__popover__prev-shortcut>span{border-radius:8px;display:inline-block;height:20px;padding:5px;width:20px}.ML__popover__prev-shortcut>span>span{display:block;margin-top:-2px}.ML__popover__next-shortcut>span>span{display:block;margin-top:2px}.ML__popover__next-shortcut:hover>span,.ML__popover__prev-shortcut:hover>span{background:hsla(0,0%,100%,.1)}.ML__popover__next-shortcut{cursor:pointer;height:34px;margin-left:8px;margin-right:8px;opacity:.1;padding-bottom:4px;padding-top:2px}.ML__popover__shortcut{font-size:.8em;margin-top:.25em}.ML__popover__note,.ML__popover__shortcut{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;opacity:.7;padding-top:.25em}.ML__popover__note{font-size:.8rem;line-height:1em;padding-left:.5em;padding-right:.5em}.ML__shortcut-join{opacity:.5}";
|
24819 |
|
24820 | let POPOVER_STYLESHEET_HASH = undefined;
|
24821 | let gPopoverStylesheet = null;
|
24822 | let gCoreStylesheet$1 = null;
|
24823 |
|
24824 |
|
24825 |
|
24826 |
|
24827 |
|
24828 | const NOTES = {
|
24829 | '\\text': 'roman text',
|
24830 | '\\textrm': 'roman text',
|
24831 | '\\textnormal': 'roman text',
|
24832 | '\\textit': 'italic text',
|
24833 | '\\textbf': 'bold text',
|
24834 | '\\texttt': 'monospaced text',
|
24835 | '\\textsf': 'sans-serif text',
|
24836 | '\\mathrm': ['roman', '(upright)'],
|
24837 | '\\mathbf': 'bold',
|
24838 | '\\bf': 'bold',
|
24839 | '\\bold': 'bold',
|
24840 | '\\mathit': 'italic',
|
24841 | '\\mathbb': 'blackboard',
|
24842 | '\\mathscr': 'script',
|
24843 | '\\mathtt': ['typewriter', '(monospaced)'],
|
24844 | '\\mathsf': 'sans-serif',
|
24845 | '\\mathcal': 'caligraphic',
|
24846 | '\\frak': ['fraktur', '(gothic)'],
|
24847 | '\\mathfrak': ['fraktur', '(gothic)'],
|
24848 | '\\textcolor': 'text color',
|
24849 | '\\color': 'color',
|
24850 | '\\forall': 'for all',
|
24851 | '\\exists': 'there exists',
|
24852 | '\\nexists': 'there does not exist',
|
24853 | '\\frac': 'fraction',
|
24854 | '\\dfrac': 'display fraction',
|
24855 | '\\cfrac': 'continuous fraction',
|
24856 | '\\tfrac': 'text fraction',
|
24857 | '\\binom': 'binomial coefficient',
|
24858 | '\\dbinom': 'display binomial coefficient',
|
24859 | '\\tbinom': 'text binomial coefficient',
|
24860 | '\\pdiff': 'partial differential',
|
24861 | '\\vec': 'vector',
|
24862 | '\\check': 'caron',
|
24863 | '\\acute': 'acute',
|
24864 | '\\breve': 'breve',
|
24865 | '\\tilde': 'tilde',
|
24866 | '\\dot': 'dot',
|
24867 | '\\hat': ['hat', 'circumflex'],
|
24868 | '\\ddot': 'double dot',
|
24869 | '\\bar': 'bar',
|
24870 | '\\prime': 'prime',
|
24871 | '\\doubleprime': 'double prime',
|
24872 | '\\varnothing': 'empty set',
|
24873 | '\\emptyset': 'empty set',
|
24874 | '\\subseteq': 'subset of or <br>equal to',
|
24875 | '\\supseteq': 'superset of or <br>equal to',
|
24876 | '\\supset': 'superset of',
|
24877 | '\\subset': 'subset of',
|
24878 | '\\partial': 'partial derivative',
|
24879 | '\\bigcup': 'union',
|
24880 | '\\bigcap': 'intersection',
|
24881 | '\\approx': 'approximately equal to',
|
24882 | '\\notin': 'not an element of',
|
24883 | '\\in': ['element of', 'included in'],
|
24884 | '\\infty': 'infinity',
|
24885 | '\\land': 'logical and',
|
24886 | '\\sqrt': 'square root',
|
24887 | '\\prod': 'product',
|
24888 | '\\sum': 'summation',
|
24889 | '\\amalg': ['amalgamation', 'coproduct', 'free product', 'disjoint union'],
|
24890 | '\\cup': 'union with',
|
24891 | '\\cap': 'intersection with',
|
24892 | '\\int': 'integral',
|
24893 | '\\iint': 'surface integral',
|
24894 | '\\oint': 'curve integral',
|
24895 | '\\iiint': 'volume integral',
|
24896 | '\\iff': 'if and only if',
|
24897 | '\\ln': 'natural logarithm',
|
24898 | '\\boldsymbol': 'bold',
|
24899 | '\\setminus': 'set subtraction',
|
24900 | '\\stackrel': 'relation with symbol above',
|
24901 | '\\stackbin': 'operator with symbol above',
|
24902 | '\\underset': 'symbol with annotation below',
|
24903 | '\\overset': 'symbol with annotation above',
|
24904 | '\\hslash': ['h-bar', 'Planck constant'],
|
24905 | '\\gtrsim': 'greater than or <br>similar to',
|
24906 | '\\propto': 'proportional to',
|
24907 | '\\equiv': 'equivalent to',
|
24908 | '\\!': ['negative thin space', '(-3 mu)'],
|
24909 | '\\ ': ['space', '(6 mu)'],
|
24910 | '\\,': ['thin space', '(3 mu)'],
|
24911 | '\\:': ['medium space', '(4 mu)'],
|
24912 | '\\;': ['thick space', '(5 mu)'],
|
24913 | '\\quad': ['1 em space', '(18 mu)'],
|
24914 | '\\qquad': ['2 em space', '(36 mu)'],
|
24915 | '\\enskip': ['½ em space', '(9 mu)'],
|
24916 | '\\mp': 'minus or plus',
|
24917 | '\\pm': 'plus or minus',
|
24918 | '\\Im': 'Imaginary part of',
|
24919 | '\\Re': 'Real part of',
|
24920 | '\\gothicCapitalR': 'Real part of',
|
24921 | '\\gothicCapitalI': 'Imaginary part part of',
|
24922 | '\\differentialD': 'differential d',
|
24923 | '\\aleph': [
|
24924 | 'aleph',
|
24925 | 'infinite cardinal',
|
24926 | '<a target="_blank" href="https://en.wikipedia.org/wiki/Cardinal_number">Wikipedia <big>›</big></a>',
|
24927 | ],
|
24928 | '\\beth': [
|
24929 | 'beth',
|
24930 | 'beth number',
|
24931 | '<a target="_blank" href="https://en.wikipedia.org/wiki/Beth_number">Wikipedia <big>›</big></a>',
|
24932 | ],
|
24933 | '\\gimel': [
|
24934 | 'gimel',
|
24935 | 'gimel function',
|
24936 | '<a target="_blank" href="https://en.wikipedia.org/wiki/Gimel_function">Wikipedia <big>›</big></a>',
|
24937 | ],
|
24938 | '\\O': 'empty set',
|
24939 | '\\N': 'set of <br>natural numbers',
|
24940 | '\\Z': 'set of <br>integers',
|
24941 | '\\Q': 'set of <br>rational numbers',
|
24942 | '\\C': 'set of <br>complex numbers',
|
24943 | '\\R': 'set of <br>real numbers',
|
24944 | '\\P': 'set of <br>prime numbers',
|
24945 | '\\lesseqqgtr': 'less than, equal to or<br> greater than',
|
24946 | '\\gnapprox': 'greater than and <br>not approximately',
|
24947 | '\\lnapprox': 'lesser than and <br>not approximately',
|
24948 | '\\j': 'dotless j',
|
24949 | '\\i': 'dotless i',
|
24950 | '\\cdot': 'centered dot',
|
24951 | '\\lmoustache': 'left moustache',
|
24952 | '\\rmoustache': 'right moustache',
|
24953 | '\\nabla': ['nabla', 'del', 'differential vector operator'],
|
24954 | '\\square': [
|
24955 | 'square',
|
24956 | 'd’Alembert operator',
|
24957 | '<a target="_blank" href="https://en.wikipedia.org/wiki/D%27Alembert_operator">Wikipedia <big>›</big></a>',
|
24958 | ],
|
24959 | '\\blacksquare': [
|
24960 | 'black square',
|
24961 | 'end of proof',
|
24962 | 'tombstone',
|
24963 | 'Halmos symbol',
|
24964 | ],
|
24965 | '\\Box': 'end of proof',
|
24966 | '\\colon': ['such that', 'ratio'],
|
24967 | '\\coloneq': ['is defined by', 'is assigned'],
|
24968 | '\\Colon': ['is defined by', 'as'],
|
24969 | '\\_': ['underbar', 'underscore'],
|
24970 | '\\ll': 'much less than',
|
24971 | '\\gg': 'much greater than',
|
24972 | '\\doteq': 'approximately equal to',
|
24973 | '\\Doteq': 'approximately equal to',
|
24974 | '\\doteqdot': 'approximately equal to',
|
24975 | '\\cong': ['isomorphism of', '(for algebras, modules...)'],
|
24976 | '\\det': ['determinant of', '(of a matrix)'],
|
24977 | '\\dotplus': 'Cartesian product algebra',
|
24978 | '\\otimes': [
|
24979 | 'tensor product',
|
24980 | '(of algebras)',
|
24981 | 'Kronecker product',
|
24982 | '(of matrices)',
|
24983 | ],
|
24984 | '\\oplus': ['direct sum', '(of modules)'],
|
24985 | '\\lb': 'base-2 logarithm',
|
24986 | '\\lg': 'base-10 logarithm',
|
24987 | '\\wp': [
|
24988 | 'Weierstrass P',
|
24989 | '<a target="_blank" href="https://en.wikipedia.org/wiki/Weierstrass%27s_elliptic_functions">Wikipedia <big>›</big></a>',
|
24990 | ],
|
24991 | '\\wr': [
|
24992 | 'wreath product',
|
24993 | '<a target="_blank" href="https://en.wikipedia.org/wiki/Wreath_product">Wikipedia <big>›</big></a>',
|
24994 | ],
|
24995 | '\\top': ['tautology', 'Proposition P is universally true'],
|
24996 | '\\bot': ['contradiction', 'Proposition P is contradictory'],
|
24997 | '\\mid': ['probability', 'of event A given B'],
|
24998 | '\\mho': [
|
24999 | 'Siemens',
|
25000 | 'electrical conductance in SI unit',
|
25001 | '<a target="_blank" href="https://en.wikipedia.org/wiki/Siemens_(unit)">Wikipedia <big>›</big></a>',
|
25002 | ],
|
25003 | '\\Longrightarrow': 'implies',
|
25004 | '\\Longleftrightarrow': 'if, and only if,',
|
25005 | '\\prec': 'precedes',
|
25006 | '\\preceq': 'precedes or is equal to',
|
25007 | '\\succ': 'succeedes',
|
25008 | '\\succeq': 'succeedes or is equal to',
|
25009 | '\\perp': ['is perpendicular to', 'is independent of'],
|
25010 | '\\models': [
|
25011 | 'entails',
|
25012 | 'double-turnstyle, models',
|
25013 | 'is a semantic consequence of',
|
25014 | '<a target="_blank" href="https://en.wikipedia.org/wiki/Double_turnstile">Wikipedia <big>›</big></a>',
|
25015 | ],
|
25016 | '\\vdash': [
|
25017 | 'satisfies',
|
25018 | 'turnstyle, assertion sign',
|
25019 | 'syntactic inference',
|
25020 | '<a target="_blank" href="https://en.wikipedia.org/wiki/Turnstile_(symbol)">Wikipedia <big>›</big></a>',
|
25021 | ],
|
25022 | '\\implies': ['implies', 'logical consequence'],
|
25023 | '\\impliedby': ['implied by', 'logical consequence'],
|
25024 | '\\surd': ['surd', 'root of', 'checkmark'],
|
25025 | '\\ltimes': [
|
25026 | 'semi direct product',
|
25027 | '<a target="_blank" href="https://en.wikipedia.org/wiki/Semidirect_product">Wikipedia <big>›</big></a>',
|
25028 | ],
|
25029 | '\\rtimes': [
|
25030 | 'semi direct product',
|
25031 | '<a target="_blank" href="https://en.wikipedia.org/wiki/Semidirect_product">Wikipedia <big>›</big></a>',
|
25032 | ],
|
25033 | '\\leftthreetimes': [
|
25034 | 'semi direct product',
|
25035 | '<a target="_blank" href="https://en.wikipedia.org/wiki/Semidirect_product">Wikipedia <big>›</big></a>',
|
25036 | ],
|
25037 | '\\rightthreetimes': [
|
25038 | 'semi direct product',
|
25039 | '<a target="_blank" href="https://en.wikipedia.org/wiki/Semidirect_product">Wikipedia <big>›</big></a>',
|
25040 | ],
|
25041 | '\\divideontimes': ['divide on times'],
|
25042 | '\\curlywedge': 'nor',
|
25043 | '\\curlyvee': 'nand',
|
25044 | '\\simeq': 'is group isomorphic with',
|
25045 | '\\vartriangleleft': ['is a normal subgroup of', 'is an ideal ring of'],
|
25046 | '\\circ': ['circle', 'ring', 'function composition'],
|
25047 | '\\rlap': ['overlap right', '\\rlap{x}o'],
|
25048 | '\\llap': ['overlap left', 'o\\llap{/}'],
|
25049 | '\\colorbox': ['color box', '\\colorbox{#fbc0bd}{...}'],
|
25050 | '\\ast': ['asterisk', 'reflexive closure (as a superscript)'],
|
25051 | '\\bullet': 'bullet',
|
25052 | '\\lim': 'limit',
|
25053 | };
|
25054 | function getNote(symbol) {
|
25055 | var _a;
|
25056 | let result = (_a = NOTES[symbol]) !== null && _a !== void 0 ? _a : '';
|
25057 | if (isArray(result)) {
|
25058 | result = result.join('<br>');
|
25059 | }
|
25060 | return result;
|
25061 | }
|
25062 | function latexToMarkup$1(latex) {
|
25063 | const root = new Atom('root', { mode: 'math' });
|
25064 | root.body = typeset(parseLatex(latex, {
|
25065 | parseMode: 'math',
|
25066 | macros: getMacros(),
|
25067 | registers: getDefaultRegisters(),
|
25068 | }));
|
25069 | const box = coalesce(adjustInterAtomSpacing(new Box(root.render(new Context({
|
25070 | macros: getMacros(),
|
25071 | registers: getDefaultRegisters(),
|
25072 | smartFence: false,
|
25073 | }, {
|
25074 | fontSize: DEFAULT_FONT_SIZE,
|
25075 | }, 'displaystyle')), { classes: 'ML__base' })));
|
25076 | return makeStruts(box, { classes: 'ML__mathlive' }).toMarkup();
|
25077 | }
|
25078 | function showPopoverWithLatex(mf, latex, displayArrows) {
|
25079 | if (!latex || latex.length === 0) {
|
25080 | hidePopover(mf);
|
25081 | return;
|
25082 | }
|
25083 | const command = latex;
|
25084 | const commandMarkup = latexToMarkup$1(latex);
|
25085 | const commandNote = getNote(command);
|
25086 | const keybinding = getKeybindingsForCommand(mf.keybindings, command).join('<br>');
|
25087 | let template = displayArrows
|
25088 | ? '<div class="ML__popover__prev-shortcut" role="button" aria-label="Previous suggestion"><span><span>▲</span></span></div>'
|
25089 | : '';
|
25090 | template += '<span class="ML__popover__content" role="button">';
|
25091 | template += '<div class="ML__popover__command">' + commandMarkup + '</div>';
|
25092 | if (commandNote) {
|
25093 | template += '<div class="ML__popover__note">' + commandNote + '</div>';
|
25094 | }
|
25095 | if (keybinding) {
|
25096 | template += '<div class="ML__popover__shortcut">' + keybinding + '</div>';
|
25097 | }
|
25098 | template += '</span>';
|
25099 | template += displayArrows
|
25100 | ? '<div class="ML__popover__next-shortcut" role="button" aria-label="Next suggestion"><span><span>▼</span></span></div>'
|
25101 | : '';
|
25102 | mf.popover = createPopover(mf, template);
|
25103 | let element = mf.popover.querySelectorAll('.ML__popover__content');
|
25104 | if (element && element.length > 0) {
|
25105 | attachButtonHandlers((command) => mf.executeCommand(command), element[0], {
|
25106 | default: ['complete', 'accept-suggestion'],
|
25107 | });
|
25108 | }
|
25109 | element = mf.popover.querySelectorAll('.ML__popover__prev-shortcut');
|
25110 | if (element && element.length > 0) {
|
25111 | attachButtonHandlers((command) => mf.executeCommand(command), element[0], 'previousSuggestion');
|
25112 | }
|
25113 | element = mf.popover.querySelectorAll('.ML__popover__next-shortcut');
|
25114 | if (element && element.length > 0) {
|
25115 | attachButtonHandlers((command) => mf.executeCommand(command), element[0], 'nextSuggestion');
|
25116 | }
|
25117 | setTimeout(() => {
|
25118 | const caretPoint = getCaretPoint(mf.field);
|
25119 | if (caretPoint)
|
25120 | setPopoverPosition(mf, caretPoint);
|
25121 | if (mf.popover) {
|
25122 | mf.popover.classList.add('is-visible');
|
25123 | mf.popoverVisible = true;
|
25124 | }
|
25125 | }, 32);
|
25126 | }
|
25127 | function updatePopoverPosition(mf, options) {
|
25128 | var _a;
|
25129 |
|
25130 |
|
25131 |
|
25132 | if (!mf.element || mf.element.mathfield !== mf)
|
25133 | return;
|
25134 | if (!mf.popover || !mf.popoverVisible)
|
25135 | return;
|
25136 |
|
25137 | if (options === null || options === void 0 ? void 0 : options.deferred) {
|
25138 |
|
25139 |
|
25140 |
|
25141 | setTimeout(() => updatePopoverPosition(mf), 100);
|
25142 | return;
|
25143 | }
|
25144 | if (((_a = mf.model.at(mf.model.position)) === null || _a === void 0 ? void 0 : _a.type) !== 'latex') {
|
25145 | hidePopover(mf);
|
25146 | }
|
25147 | else {
|
25148 |
|
25149 | const caretPoint = getCaretPoint(mf.field);
|
25150 | if (caretPoint)
|
25151 | setPopoverPosition(mf, caretPoint);
|
25152 | }
|
25153 | }
|
25154 | function setPopoverPosition(mf, position) {
|
25155 | throwIfNotInBrowser();
|
25156 | if (!mf.popover || !mf.popoverVisible)
|
25157 | return;
|
25158 |
|
25159 | const screenHeight = window.innerHeight ||
|
25160 | document.documentElement.clientHeight ||
|
25161 | document.body.clientHeight;
|
25162 | const screenWidth = window.innerWidth ||
|
25163 | document.documentElement.clientWidth ||
|
25164 | document.body.clientWidth;
|
25165 |
|
25166 | const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
25167 | const scrollbarHeight = window.innerHeight - document.documentElement.clientHeight;
|
25168 | const virtualkeyboardHeight = mf.virtualKeyboard.height;
|
25169 |
|
25170 | if (position.x + mf.popover.offsetWidth / 2 > screenWidth - scrollbarWidth) {
|
25171 | mf.popover.style.left = `${screenWidth - mf.popover.offsetWidth - scrollbarWidth}px`;
|
25172 | }
|
25173 | else if (position.x - mf.popover.offsetWidth / 2 < 0) {
|
25174 | mf.popover.style.left = '0';
|
25175 | }
|
25176 | else {
|
25177 | mf.popover.style.left = `${position.x - mf.popover.offsetWidth / 2}px`;
|
25178 | }
|
25179 |
|
25180 | if (position.y + mf.popover.offsetHeight + 5 >
|
25181 | screenHeight - scrollbarHeight - virtualkeyboardHeight) {
|
25182 | mf.popover.classList.add('ML__popover--reverse-direction');
|
25183 | mf.popover.style.top = `${position.y - position.height - mf.popover.offsetHeight - 5}px`;
|
25184 | }
|
25185 | else {
|
25186 | mf.popover.classList.remove('ML__popover--reverse-direction');
|
25187 | mf.popover.style.top = `${position.y + 5}px`;
|
25188 | }
|
25189 | }
|
25190 | function hidePopover(mf) {
|
25191 | mf.suggestionIndex = 0;
|
25192 | mf.popoverVisible = false;
|
25193 | if (mf.popover) {
|
25194 | mf.popover.classList.remove('is-visible');
|
25195 | mf.popover.innerHTML = '';
|
25196 | }
|
25197 | }
|
25198 | function createPopover(mf, html) {
|
25199 | if (mf.popover) {
|
25200 | mf.popover.innerHTML = mf.options.createHTML(html);
|
25201 | return mf.popover;
|
25202 | }
|
25203 | mf.popover = getSharedElement('mathlive-popover-panel');
|
25204 | if (POPOVER_STYLESHEET_HASH === undefined) {
|
25205 | POPOVER_STYLESHEET_HASH = hashCode(css_248z$2).toString(36);
|
25206 | }
|
25207 | gPopoverStylesheet = inject(null, css_248z$2, POPOVER_STYLESHEET_HASH);
|
25208 | gCoreStylesheet$1 = inject(null, css_248z$4, hashCode(css_248z$4).toString(36));
|
25209 | mf.popover.innerHTML = mf.options.createHTML(html);
|
25210 | return mf.popover;
|
25211 | }
|
25212 | function disposePopover(mf) {
|
25213 | releaseSharedElement(mf.popover);
|
25214 | if (gPopoverStylesheet)
|
25215 | gPopoverStylesheet.release();
|
25216 | if (gCoreStylesheet$1)
|
25217 | gCoreStylesheet$1.release();
|
25218 | delete mf.popover;
|
25219 | }
|
25220 |
|
25221 |
|
25222 |
|
25223 |
|
25224 |
|
25225 | function hash(latex) {
|
25226 | let result = 0;
|
25227 | for (let i = 0; i < latex.length; i++) {
|
25228 | result = result * 31 + latex.charCodeAt(i);
|
25229 | result = result | 0;
|
25230 | }
|
25231 | return Math.abs(result);
|
25232 | }
|
25233 | function requestUpdate(mathfield, options) {
|
25234 | if (!mathfield.dirty) {
|
25235 | mathfield.dirty = true;
|
25236 | requestAnimationFrame(() => {
|
25237 | if (isValidMathfield(mathfield) && mathfield.dirty) {
|
25238 | mathfield._atomBoundsCache = new Map();
|
25239 | render(mathfield, options);
|
25240 | mathfield._atomBoundsCache = undefined;
|
25241 | }
|
25242 | });
|
25243 | }
|
25244 | }
|
25245 |
|
25246 |
|
25247 |
|
25248 |
|
25249 |
|
25250 |
|
25251 |
|
25252 |
|
25253 | function render(mathfield, renderOptions) {
|
25254 | var _a, _b;
|
25255 | throwIfNotInBrowser();
|
25256 | if (!isValidMathfield(mathfield))
|
25257 | return;
|
25258 | renderOptions = renderOptions !== null && renderOptions !== void 0 ? renderOptions : {};
|
25259 | mathfield.dirty = false;
|
25260 | const { model } = mathfield;
|
25261 |
|
25262 |
|
25263 |
|
25264 | if (window.mathlive === undefined) {
|
25265 | window.mathlive = {};
|
25266 | }
|
25267 |
|
25268 |
|
25269 |
|
25270 | model.root.caret = '';
|
25271 | model.root.isSelected = false;
|
25272 | model.root.containsCaret = true;
|
25273 | for (const atom of model.atoms) {
|
25274 | atom.caret = '';
|
25275 | atom.isSelected = false;
|
25276 | atom.containsCaret = false;
|
25277 | }
|
25278 | const hasFocus = mathfield.hasFocus() && !mathfield.options.readOnly;
|
25279 | if (model.selectionIsCollapsed) {
|
25280 | model.at(model.position).caret = hasFocus ? mathfield.mode : '';
|
25281 | }
|
25282 | else {
|
25283 | for (const atom of model.getAtoms(model.selection, {
|
25284 | includeChildren: true,
|
25285 | })) {
|
25286 | atom.isSelected = true;
|
25287 | }
|
25288 | }
|
25289 | if (hasFocus) {
|
25290 | let ancestor = model.at(model.position).parent;
|
25291 | while (ancestor) {
|
25292 | ancestor.containsCaret = true;
|
25293 | ancestor = ancestor.parent;
|
25294 | }
|
25295 | }
|
25296 |
|
25297 |
|
25298 |
|
25299 | const base = model.root.render(new Context({
|
25300 | macros: mathfield.options.macros,
|
25301 | registers: mathfield.options.registers,
|
25302 | atomIdsSettings: {
|
25303 |
|
25304 |
|
25305 | seed: hash(Atom.serialize(model.root, {
|
25306 | expandMacro: false,
|
25307 | defaultMode: mathfield.options.defaultMode,
|
25308 | })),
|
25309 |
|
25310 |
|
25311 |
|
25312 | groupNumbers: (_a = renderOptions.forHighlighting) !== null && _a !== void 0 ? _a : false,
|
25313 | },
|
25314 | smartFence: mathfield.options.smartFence,
|
25315 | renderPlaceholder: mathfield.options.readOnly
|
25316 | ? (context, p) => {
|
25317 | if (p.placeholderId) {
|
25318 | const field = mathfield.getPlaceholderField(p.placeholderId);
|
25319 | return p.createMathfieldBox(context, {
|
25320 | placeholderId: p.placeholderId,
|
25321 | element: field,
|
25322 | });
|
25323 | }
|
25324 | return p.createBox(context);
|
25325 | }
|
25326 | : undefined,
|
25327 | isSelected: model.root.isSelected,
|
25328 | }, {
|
25329 | fontSize: DEFAULT_FONT_SIZE,
|
25330 | letterShapeStyle: mathfield.options.letterShapeStyle,
|
25331 | }, mathfield.options.defaultMode === 'inline-math'
|
25332 | ? 'textstyle'
|
25333 | : 'displaystyle'));
|
25334 |
|
25335 |
|
25336 |
|
25337 | const wrapper = makeStruts(adjustInterAtomSpacing(base, mathfield.options.horizontalSpacingScale), {
|
25338 | classes: 'ML__mathlive',
|
25339 | attributes: {
|
25340 |
|
25341 |
|
25342 | 'translate': 'no',
|
25343 |
|
25344 |
|
25345 | 'aria-hidden': 'true',
|
25346 | },
|
25347 | });
|
25348 |
|
25349 |
|
25350 |
|
25351 | const field = mathfield.field;
|
25352 | const isFocused = field.classList.contains('ML__focused');
|
25353 | if (isFocused && !hasFocus) {
|
25354 | field.classList.remove('ML__focused');
|
25355 | }
|
25356 | else if (!isFocused && hasFocus) {
|
25357 | field.classList.add('ML__focused');
|
25358 | }
|
25359 | field.innerHTML = mathfield.options.createHTML(wrapper.toMarkup());
|
25360 | mathfield.fieldContent = field.querySelector('.ML__mathlive');
|
25361 | mathfield.accessibleNode.innerHTML = mathfield.options.createHTML('<math xmlns="http://www.w3.org/1998/Math/MathML">' +
|
25362 | atomsToMathML(model.root, mathfield.options) +
|
25363 | '</math>');
|
25364 |
|
25365 |
|
25366 |
|
25367 | renderSelection(mathfield);
|
25368 | if (mathfield.options.readOnly) {
|
25369 | mathfield.attachNestedMathfield();
|
25370 | }
|
25371 | if (!((_b = renderOptions.interactive) !== null && _b !== void 0 ? _b : false)) {
|
25372 |
|
25373 |
|
25374 |
|
25375 | setTimeout(() => renderSelection(mathfield), 32);
|
25376 | }
|
25377 | }
|
25378 | function renderSelection(mathfield) {
|
25379 | throwIfNotInBrowser();
|
25380 |
|
25381 |
|
25382 | if (!mathfield.field)
|
25383 | return;
|
25384 |
|
25385 | for (const element of mathfield.field.querySelectorAll('.ML__selection, .ML__contains-highlight')) {
|
25386 | element.remove();
|
25387 | }
|
25388 | if (!mathfield.hasFocus())
|
25389 | return;
|
25390 | const model = mathfield.model;
|
25391 | if (model.selectionIsCollapsed) {
|
25392 |
|
25393 |
|
25394 |
|
25395 | setTimeout(() => updatePopoverPosition(mathfield), 32);
|
25396 |
|
25397 |
|
25398 |
|
25399 | let atom = model.at(model.position);
|
25400 | while (atom && !(atom.containsCaret && atom.displayContainsHighlight)) {
|
25401 | atom = atom.parent;
|
25402 | }
|
25403 | if ((atom === null || atom === void 0 ? void 0 : atom.containsCaret) && atom.displayContainsHighlight) {
|
25404 | const bounds = adjustForScrolling(mathfield, getAtomBounds(mathfield, atom));
|
25405 | if (bounds) {
|
25406 | const element = document.createElement('div');
|
25407 | element.classList.add('ML__contains-highlight');
|
25408 | element.style.position = 'absolute';
|
25409 | element.style.left = `${bounds.left}px`;
|
25410 | element.style.top = `${bounds.top}px`;
|
25411 | element.style.width = `${Math.ceil(bounds.right - bounds.left)}px`;
|
25412 | element.style.height = `${Math.ceil(bounds.bottom - bounds.top - 1)}px`;
|
25413 | mathfield.field.insertBefore(element, mathfield.field.childNodes[0]);
|
25414 | }
|
25415 | }
|
25416 | return;
|
25417 | }
|
25418 |
|
25419 |
|
25420 |
|
25421 | for (const x of unionRects(getSelectionBounds(mathfield, { excludeAtomsWithBackground: true }))) {
|
25422 | const selectionElement = document.createElement('div');
|
25423 | selectionElement.classList.add('ML__selection');
|
25424 | selectionElement.style.position = 'absolute';
|
25425 | selectionElement.style.left = `${x.left}px`;
|
25426 | selectionElement.style.top = `${x.top}px`;
|
25427 | selectionElement.style.width = `${Math.ceil(x.right - x.left)}px`;
|
25428 | selectionElement.style.height = `${Math.ceil(x.bottom - x.top - 1)}px`;
|
25429 | mathfield.field.insertBefore(selectionElement, mathfield.field.childNodes[0]);
|
25430 | }
|
25431 | }
|
25432 |
|
25433 |
|
25434 |
|
25435 | function unionRects(rects) {
|
25436 | const result = [];
|
25437 |
|
25438 | for (const rect of rects) {
|
25439 | let found = false;
|
25440 | for (const rect2 of result) {
|
25441 | if (rect.left === rect2.left &&
|
25442 | rect.right === rect2.right &&
|
25443 | rect.top === rect2.top &&
|
25444 | rect.bottom === rect2.bottom) {
|
25445 | found = true;
|
25446 | break;
|
25447 | }
|
25448 | }
|
25449 | if (!found)
|
25450 | result.push(rect);
|
25451 | }
|
25452 | for (const rect of rects) {
|
25453 | let count = 0;
|
25454 | for (const rect2 of rects) {
|
25455 | if (rect.left >= rect2.left &&
|
25456 | rect.right <= rect2.right &&
|
25457 | rect.top >= rect2.top &&
|
25458 | rect.bottom <= rect2.bottom) {
|
25459 | count += 1;
|
25460 | if (count > 1)
|
25461 | break;
|
25462 | }
|
25463 | }
|
25464 | if (count === 1)
|
25465 | result.push(rect);
|
25466 | }
|
25467 | return result;
|
25468 | }
|
25469 |
|
25470 | function compareSelection(a, b) {
|
25471 | if (a.direction === b.direction) {
|
25472 | const l = a.ranges.length;
|
25473 | if (b.ranges.length === l) {
|
25474 | let i = 0;
|
25475 | while (i < l && compareRange(a.ranges[i], b.ranges[i]) === 'equal') {
|
25476 | i++;
|
25477 | }
|
25478 | return i === l ? 'equal' : 'different';
|
25479 | }
|
25480 | }
|
25481 | return 'different';
|
25482 | }
|
25483 | function compareRange(a, b) {
|
25484 | if (a[0] === b[0] && a[1] === b[1])
|
25485 | return 'equal';
|
25486 | return 'different';
|
25487 | }
|
25488 |
|
25489 |
|
25490 |
|
25491 | function range(selection) {
|
25492 | let first = Infinity;
|
25493 | let last = -Infinity;
|
25494 | for (const range of selection.ranges) {
|
25495 | first = Math.min(first, range[0], range[1]);
|
25496 | last = Math.max(last, range[0], range[1]);
|
25497 | }
|
25498 | return [first, last];
|
25499 | }
|
25500 |
|
25501 | const CLIPBOARD_LATEX_BEGIN = '\\begin{equation*}';
|
25502 | const CLIPBOARD_LATEX_END = '\\end{equation*}';
|
25503 | const defaultExportHook = (_from, latex, _range) => {
|
25504 |
|
25505 | if (!MODE_SHIFT_COMMANDS.some((x) => latex.startsWith(x[0]) && latex.endsWith(x[1]))) {
|
25506 | latex = `${CLIPBOARD_LATEX_BEGIN} ${latex} ${CLIPBOARD_LATEX_END}`;
|
25507 | }
|
25508 | return latex;
|
25509 | };
|
25510 | class ModeEditor {
|
25511 | constructor(name) {
|
25512 | ModeEditor._registry[name] = this;
|
25513 | }
|
25514 | static onPaste(mode, mathfield, ev) {
|
25515 | return ModeEditor._registry[mode].onPaste(mathfield, ev);
|
25516 | }
|
25517 | static onCopy(mathfield, ev) {
|
25518 | if (!ev.clipboardData)
|
25519 | return;
|
25520 | const model = mathfield.model;
|
25521 | const exportRange = model.selectionIsCollapsed
|
25522 | ? [0, model.lastOffset]
|
25523 | : range(model.selection);
|
25524 | const atoms = model.getAtoms(exportRange);
|
25525 | if (atoms.every((x) => x.mode === 'text' || !x.mode)) {
|
25526 |
|
25527 |
|
25528 | ev.clipboardData.setData('text/plain', atoms
|
25529 | .filter((x) => x instanceof TextAtom)
|
25530 | .map((x) => x.value)
|
25531 | .join(''));
|
25532 | }
|
25533 | else if (atoms.every((x) => x.mode === 'latex')) {
|
25534 |
|
25535 |
|
25536 | ev.clipboardData.setData('text/plain', model
|
25537 | .getAtoms(exportRange, { includeChildren: true })
|
25538 | .map((x) => { var _a; return (_a = x.value) !== null && _a !== void 0 ? _a : ''; })
|
25539 | .join(''));
|
25540 | }
|
25541 | else {
|
25542 |
|
25543 |
|
25544 |
|
25545 | let latex = '';
|
25546 | if (atoms.length === 1 && atoms[0].verbatimLatex) {
|
25547 | latex = atoms[0].verbatimLatex;
|
25548 | }
|
25549 | if (!latex) {
|
25550 | latex = model.getValue(exportRange, 'latex-expanded');
|
25551 | }
|
25552 |
|
25553 |
|
25554 |
|
25555 | ev.clipboardData.setData('application/x-latex', latex);
|
25556 |
|
25557 |
|
25558 |
|
25559 |
|
25560 | ev.clipboardData.setData('text/plain', mathfield.options.onExport(mathfield, latex, exportRange));
|
25561 |
|
25562 |
|
25563 |
|
25564 | const mathJson = model.getValue(exportRange, 'math-json');
|
25565 | if (mathJson) {
|
25566 | ev.clipboardData.setData('application/json', mathJson);
|
25567 | }
|
25568 | const mathMl = model.getValue(exportRange, 'math-ml');
|
25569 | if (mathMl) {
|
25570 | ev.clipboardData.setData('application/mathml+xml', mathMl);
|
25571 | }
|
25572 | }
|
25573 |
|
25574 | ev.preventDefault();
|
25575 | }
|
25576 | static insert(mode, model, text, options = {}) {
|
25577 | return ModeEditor._registry[mode].insert(model, text, options);
|
25578 | }
|
25579 |
|
25580 | onPaste(_mathfield, _ev) {
|
25581 | return false;
|
25582 | }
|
25583 | insert(_model, _text, _options) {
|
25584 | return false;
|
25585 | }
|
25586 | }
|
25587 | ModeEditor._registry = {};
|
25588 |
|
25589 | function selectionDidChange(model) {
|
25590 | var _a;
|
25591 | if (typeof ((_a = model.listeners) === null || _a === void 0 ? void 0 : _a.onSelectionDidChange) === 'function' &&
|
25592 | !model.suppressChangeNotifications) {
|
25593 | model.suppressChangeNotifications = true;
|
25594 | model.listeners.onSelectionDidChange(model);
|
25595 | model.suppressChangeNotifications = false;
|
25596 | }
|
25597 | }
|
25598 | function contentDidChange(model) {
|
25599 | var _a;
|
25600 | if (typeof ((_a = model.listeners) === null || _a === void 0 ? void 0 : _a.onContentDidChange) === 'function' &&
|
25601 | !model.suppressChangeNotifications) {
|
25602 | model.suppressChangeNotifications = true;
|
25603 | model.listeners.onContentDidChange(model);
|
25604 | model.suppressChangeNotifications = false;
|
25605 | }
|
25606 | }
|
25607 | function placeholderDidChange(model, placeholderId) {
|
25608 | var _a;
|
25609 | if (typeof ((_a = model.listeners) === null || _a === void 0 ? void 0 : _a.onPlaceholderDidChange) === 'function' &&
|
25610 | !model.suppressChangeNotifications) {
|
25611 | model.suppressChangeNotifications = true;
|
25612 | model.listeners.onPlaceholderDidChange(model, placeholderId);
|
25613 | model.suppressChangeNotifications = false;
|
25614 | }
|
25615 | }
|
25616 |
|
25617 |
|
25618 |
|
25619 |
|
25620 |
|
25621 |
|
25622 |
|
25623 |
|
25624 |
|
25625 |
|
25626 |
|
25627 |
|
25628 |
|
25629 |
|
25630 |
|
25631 |
|
25632 |
|
25633 |
|
25634 |
|
25635 |
|
25636 |
|
25637 |
|
25638 |
|
25639 |
|
25640 |
|
25641 |
|
25642 |
|
25643 |
|
25644 |
|
25645 |
|
25646 |
|
25647 |
|
25648 |
|
25649 |
|
25650 |
|
25651 |
|
25652 |
|
25653 |
|
25654 |
|
25655 |
|
25656 |
|
25657 |
|
25658 |
|
25659 |
|
25660 | class LatexModeEditor extends ModeEditor {
|
25661 | constructor() {
|
25662 | super('latex');
|
25663 | }
|
25664 | createAtom(command, _style) {
|
25665 | return new LatexAtom(command);
|
25666 | }
|
25667 | onPaste(mathfield, ev) {
|
25668 | if (!ev.clipboardData)
|
25669 | return false;
|
25670 | const text = ev.clipboardData.getData('text/plain');
|
25671 | if (text) {
|
25672 | mathfield.snapshot();
|
25673 | if (this.insert(mathfield.model, text)) {
|
25674 | requestUpdate(mathfield);
|
25675 | }
|
25676 | ev.preventDefault();
|
25677 | ev.stopPropagation();
|
25678 | return true;
|
25679 | }
|
25680 | return false;
|
25681 | }
|
25682 | insert(model, text, options) {
|
25683 | if (!options)
|
25684 | options = {};
|
25685 | if (!options.insertionMode)
|
25686 | options.insertionMode = 'replaceSelection';
|
25687 | if (!options.selectionMode)
|
25688 | options.selectionMode = 'placeholder';
|
25689 | const { suppressChangeNotifications } = model;
|
25690 | if (options.suppressChangeNotifications) {
|
25691 | model.suppressChangeNotifications = true;
|
25692 | }
|
25693 | const savedSuppressChangeNotifications = model.suppressChangeNotifications;
|
25694 | model.suppressChangeNotifications = true;
|
25695 |
|
25696 | if (options.insertionMode === 'replaceSelection' &&
|
25697 | !model.selectionIsCollapsed) {
|
25698 | model.position = model.deleteAtoms(range(model.selection));
|
25699 | }
|
25700 | else if (options.insertionMode === 'replaceAll') {
|
25701 | model.root.setChildren([], 'body');
|
25702 | model.position = 0;
|
25703 | }
|
25704 | else if (options.insertionMode === 'insertBefore') {
|
25705 | model.collapseSelection('backward');
|
25706 | }
|
25707 | else if (options.insertionMode === 'insertAfter') {
|
25708 | model.collapseSelection('forward');
|
25709 | }
|
25710 |
|
25711 | const newAtoms = [];
|
25712 | for (const c of text) {
|
25713 | if (COMMAND_MODE_CHARACTERS.test(c)) {
|
25714 | newAtoms.push(new LatexAtom(c));
|
25715 | }
|
25716 | }
|
25717 |
|
25718 |
|
25719 |
|
25720 | const cursor = model.at(model.position);
|
25721 | const lastNewAtom = cursor.parent.addChildrenAfter(newAtoms, cursor);
|
25722 |
|
25723 | model.suppressChangeNotifications = savedSuppressChangeNotifications;
|
25724 | if (options.selectionMode === 'before') ;
|
25725 | else if (options.selectionMode === 'item') {
|
25726 | model.setSelection(model.anchor, model.offsetOf(lastNewAtom));
|
25727 | }
|
25728 | else if (lastNewAtom) {
|
25729 | model.position = model.offsetOf(lastNewAtom);
|
25730 | }
|
25731 | contentDidChange(model);
|
25732 | model.suppressChangeNotifications = suppressChangeNotifications;
|
25733 | return true;
|
25734 | }
|
25735 | }
|
25736 | function getLatexGroup(model) {
|
25737 | return model.atoms.find((x) => x instanceof LatexGroupAtom);
|
25738 | }
|
25739 | function getLatexGroupBody(model) {
|
25740 | var _a, _b;
|
25741 | const atom = model.atoms.find((x) => x instanceof LatexGroupAtom);
|
25742 | if (!atom)
|
25743 | return [];
|
25744 | return ((_b = (_a = atom.body) === null || _a === void 0 ? void 0 : _a.filter((x) => x instanceof LatexAtom)) !== null && _b !== void 0 ? _b : []);
|
25745 | }
|
25746 | function getCommandSuggestionRange(model, options) {
|
25747 | var _a;
|
25748 | let start = 0;
|
25749 | let found = false;
|
25750 | const last = Number.isFinite(options === null || options === void 0 ? void 0 : options.before)
|
25751 | ? (_a = options === null || options === void 0 ? void 0 : options.before) !== null && _a !== void 0 ? _a : 0
|
25752 | : model.lastOffset;
|
25753 | while (start <= last && !found) {
|
25754 | const atom = model.at(start);
|
25755 | found = atom instanceof LatexAtom && atom.isSuggestion;
|
25756 | if (!found)
|
25757 | start++;
|
25758 | }
|
25759 | if (!found)
|
25760 | return [undefined, undefined];
|
25761 | let end = start;
|
25762 | let done = false;
|
25763 | while (end <= last && !done) {
|
25764 | const atom = model.at(end);
|
25765 | done = !(atom instanceof LatexAtom && atom.isSuggestion);
|
25766 | if (!done)
|
25767 | end++;
|
25768 | }
|
25769 | return [start - 1, end - 1];
|
25770 | }
|
25771 | new LatexModeEditor();
|
25772 |
|
25773 | function updateAutocomplete(mathfield, options) {
|
25774 | var _a;
|
25775 | const { model } = mathfield;
|
25776 |
|
25777 | for (const atom of getLatexGroupBody(model)) {
|
25778 | if (atom.isSuggestion) {
|
25779 | atom.parent.removeChild(atom);
|
25780 | }
|
25781 | else {
|
25782 | atom.isError = false;
|
25783 | }
|
25784 | }
|
25785 | if (!model.selectionIsCollapsed) {
|
25786 | hidePopover(mathfield);
|
25787 | return;
|
25788 | }
|
25789 |
|
25790 |
|
25791 |
|
25792 | const command = [];
|
25793 | let atom = model.at(model.position);
|
25794 | while (atom && atom instanceof LatexAtom && /[a-zA-Z*]$/.test(atom.value)) {
|
25795 | command.unshift(atom);
|
25796 | atom = atom.leftSibling;
|
25797 | }
|
25798 | const leftSibling = atom === null || atom === void 0 ? void 0 : atom.leftSibling;
|
25799 | if (atom &&
|
25800 | atom instanceof LatexAtom &&
|
25801 | atom.value === '\\' &&
|
25802 | !(leftSibling instanceof LatexAtom && atom.value === '\\')) {
|
25803 |
|
25804 |
|
25805 | command.unshift(atom);
|
25806 | atom = model.at(model.position).rightSibling;
|
25807 | while (atom && atom instanceof LatexAtom && /[a-zA-Z*]$/.test(atom.value)) {
|
25808 | command.push(atom);
|
25809 | atom = atom.rightSibling;
|
25810 | }
|
25811 | }
|
25812 | const commandString = command.map((x) => x.value).join('');
|
25813 | const suggestions = commandString ? suggest(commandString) : [];
|
25814 | if (suggestions.length === 0) {
|
25815 | if (/^\\[a-zA-Z\*]+$/.test(commandString)) {
|
25816 |
|
25817 | command.forEach((x) => {
|
25818 | x.isError = true;
|
25819 | });
|
25820 | }
|
25821 | hidePopover(mathfield);
|
25822 | return;
|
25823 | }
|
25824 | mathfield.suggestionIndex = (_a = options === null || options === void 0 ? void 0 : options.atIndex) !== null && _a !== void 0 ? _a : 0;
|
25825 | if (mathfield.suggestionIndex < 0) {
|
25826 | mathfield.suggestionIndex = suggestions.length - 1;
|
25827 | }
|
25828 | const suggestion = suggestions[mathfield.suggestionIndex % suggestions.length].match;
|
25829 | if (suggestion !== commandString) {
|
25830 | const lastAtom = command[command.length - 1];
|
25831 | lastAtom.parent.addChildrenAfter([...suggestion.slice(commandString.length - suggestion.length)].map((x) => new LatexAtom(x, { isSuggestion: true })), lastAtom);
|
25832 | requestUpdate(mathfield);
|
25833 | }
|
25834 | showPopoverWithLatex(mathfield, suggestion, suggestions.length > 1);
|
25835 | }
|
25836 | function acceptCommandSuggestion(model) {
|
25837 | const [from, to] = getCommandSuggestionRange(model, {
|
25838 | before: model.position,
|
25839 | });
|
25840 | if (from === undefined || to === undefined)
|
25841 | return false;
|
25842 | let result = false;
|
25843 | model.getAtoms([from, to]).forEach((x) => {
|
25844 | if (x.isSuggestion) {
|
25845 | x.isSuggestion = false;
|
25846 | result = true;
|
25847 | }
|
25848 | });
|
25849 | return result;
|
25850 | }
|
25851 |
|
25852 |
|
25853 |
|
25854 |
|
25855 | function complete(mathfield, completion = 'accept', options) {
|
25856 | var _a, _b;
|
25857 | hidePopover(mathfield);
|
25858 | const latexGroup = getLatexGroup(mathfield.model);
|
25859 | if (!latexGroup)
|
25860 | return false;
|
25861 | if (completion === 'accept-suggestion') {
|
25862 | const suggestions = getLatexGroupBody(mathfield.model).filter((x) => x.isSuggestion);
|
25863 | if (suggestions.length === 0)
|
25864 | return false;
|
25865 | for (const suggestion of suggestions)
|
25866 | suggestion.isSuggestion = false;
|
25867 | mathfield.model.position = mathfield.model.offsetOf(suggestions[suggestions.length - 1]);
|
25868 | return true;
|
25869 | }
|
25870 | const body = getLatexGroupBody(mathfield.model).filter((x) => !x.isSuggestion);
|
25871 | const latex = body.map((x) => x.value).join('');
|
25872 | const newPos = latexGroup.leftSibling;
|
25873 | latexGroup.parent.removeChild(latexGroup);
|
25874 | mathfield.model.position = mathfield.model.offsetOf(newPos);
|
25875 | mathfield.mode = (_a = options === null || options === void 0 ? void 0 : options.mode) !== null && _a !== void 0 ? _a : 'math';
|
25876 | if (completion === 'reject')
|
25877 | return true;
|
25878 | ModeEditor.insert('math', mathfield.model, latex, {
|
25879 | macros: mathfield.options.macros,
|
25880 | selectionMode: ((_b = options === null || options === void 0 ? void 0 : options.selectItem) !== null && _b !== void 0 ? _b : false) ? 'item' : 'placeholder',
|
25881 | format: 'latex',
|
25882 | });
|
25883 | mathfield.snapshot();
|
25884 | mathfield.model.announce('replacement');
|
25885 | return true;
|
25886 | }
|
25887 |
|
25888 |
|
25889 | const HAPTIC_FEEDBACK_DURATION = 3;
|
25890 | const COMMANDS = {};
|
25891 |
|
25892 |
|
25893 |
|
25894 |
|
25895 | function register(commands, options) {
|
25896 | options = options !== null && options !== void 0 ? options : { target: 'mathfield', canUndo: false };
|
25897 | for (const selector of Object.keys(commands)) {
|
25898 | console.assert(!COMMANDS[selector], 'Selector already defined: ', selector);
|
25899 | COMMANDS[selector] = { ...options, fn: commands[selector] };
|
25900 | }
|
25901 | }
|
25902 | function getCommandTarget(command) {
|
25903 | var _a;
|
25904 | let selector;
|
25905 | selector = isArray(command) ? command[0] : command;
|
25906 |
|
25907 | selector = selector.replace(/-\w/g, (m) => m[1].toUpperCase());
|
25908 | return (_a = COMMANDS[selector]) === null || _a === void 0 ? void 0 : _a.target;
|
25909 | }
|
25910 | function perform(mathfield, command) {
|
25911 | var _a, _b, _c;
|
25912 | if (!command) {
|
25913 | return false;
|
25914 | }
|
25915 | let selector;
|
25916 | let args = [];
|
25917 | let handled = false;
|
25918 | let dirty = false;
|
25919 | if (isArray(command)) {
|
25920 | selector = command[0];
|
25921 | args = command.slice(1);
|
25922 | }
|
25923 | else {
|
25924 | selector = command;
|
25925 | }
|
25926 |
|
25927 | selector = selector.replace(/-\w/g, (m) => m[1].toUpperCase());
|
25928 | const commandTarget = (_a = COMMANDS[selector]) === null || _a === void 0 ? void 0 : _a.target;
|
25929 |
|
25930 |
|
25931 |
|
25932 |
|
25933 |
|
25934 |
|
25935 |
|
25936 | if (commandTarget === 'model') {
|
25937 |
|
25938 |
|
25939 | if (mathfield.options.readOnly &&
|
25940 | /^(paste|cut|insert|delete|transpose|add)/.test(selector)) {
|
25941 | mathfield.model.announce('plonk');
|
25942 | return false;
|
25943 | }
|
25944 | if (/^(delete|transpose|add)/.test(selector)) {
|
25945 | if (selector !== 'deleteBackward') {
|
25946 | mathfield.resetKeystrokeBuffer();
|
25947 | }
|
25948 | }
|
25949 | if (/^(delete|transpose|add)/.test(selector) &&
|
25950 | mathfield.mode !== 'latex') {
|
25951 |
|
25952 | mathfield.popUndoStack();
|
25953 | mathfield.snapshot();
|
25954 | }
|
25955 | COMMANDS[selector].fn(mathfield.model, ...args);
|
25956 | if (/^(delete|transpose|add)/.test(selector) &&
|
25957 | mathfield.mode !== 'latex') {
|
25958 | mathfield.snapshot();
|
25959 | }
|
25960 | if (mathfield.mode === 'latex') {
|
25961 | updateAutocomplete(mathfield);
|
25962 | }
|
25963 | dirty = true;
|
25964 | handled = true;
|
25965 | }
|
25966 | else if (commandTarget === 'virtual-keyboard') {
|
25967 | dirty = (_c = (_b = mathfield.virtualKeyboard) === null || _b === void 0 ? void 0 : _b.executeCommand(command)) !== null && _c !== void 0 ? _c : false;
|
25968 | handled = true;
|
25969 | }
|
25970 | else if (COMMANDS[selector]) {
|
25971 | dirty = COMMANDS[selector].fn(mathfield, ...args);
|
25972 | handled = true;
|
25973 | }
|
25974 | else {
|
25975 | throw new Error('Unknown command "' + selector + '"');
|
25976 | }
|
25977 |
|
25978 | if (commandTarget !== 'virtual-keyboard') {
|
25979 |
|
25980 |
|
25981 |
|
25982 | if (!mathfield.model.selectionIsCollapsed ||
|
25983 | /^(transpose|paste|complete|((moveToNextChar|moveToPreviousChar|extend).*))_$/.test(selector)) {
|
25984 | mathfield.resetKeystrokeBuffer();
|
25985 | mathfield.style = {};
|
25986 | }
|
25987 | }
|
25988 |
|
25989 | if (dirty) {
|
25990 | requestUpdate(mathfield);
|
25991 | }
|
25992 | return handled;
|
25993 | }
|
25994 |
|
25995 |
|
25996 |
|
25997 |
|
25998 |
|
25999 |
|
26000 |
|
26001 | function performWithFeedback(mathfield, selector) {
|
26002 | var _a, _b, _c;
|
26003 |
|
26004 | mathfield.focus();
|
26005 | if (mathfield.options.keypressVibration && canVibrate()) {
|
26006 | navigator.vibrate(HAPTIC_FEEDBACK_DURATION);
|
26007 | }
|
26008 |
|
26009 | selector = selector.replace(/-\w/g, (m) => m[1].toUpperCase());
|
26010 | if (selector === 'moveToNextPlaceholder' ||
|
26011 | selector === 'moveToPreviousPlaceholder' ||
|
26012 | selector === 'complete') {
|
26013 | (_a = mathfield.returnKeypressSound) === null || _a === void 0 ? void 0 : _a.play().catch(console.warn);
|
26014 | }
|
26015 | else if (selector === 'deleteBackward' ||
|
26016 | selector === 'deleteForward' ||
|
26017 | selector === 'deletePreviousWord' ||
|
26018 | selector === 'deleteNextWord' ||
|
26019 | selector === 'deleteToGroupStart' ||
|
26020 | selector === 'deleteToGroupEnd' ||
|
26021 | selector === 'deleteToMathFieldStart' ||
|
26022 | selector === 'deleteToMathFieldEnd') {
|
26023 | (_b = mathfield.deleteKeypressSound) === null || _b === void 0 ? void 0 : _b.play().catch(console.warn);
|
26024 | }
|
26025 | else {
|
26026 | (_c = mathfield.keypressSound) === null || _c === void 0 ? void 0 : _c.play().catch(console.warn);
|
26027 | }
|
26028 | const result = mathfield.executeCommand(selector);
|
26029 | mathfield.scrollIntoView();
|
26030 | return result;
|
26031 | }
|
26032 | register({
|
26033 | performWithFeedback: (mathfield, command) => performWithFeedback(mathfield, command),
|
26034 | });
|
26035 | function nextSuggestion(mathfield) {
|
26036 |
|
26037 |
|
26038 | updateAutocomplete(mathfield, { atIndex: mathfield.suggestionIndex + 1 });
|
26039 | return false;
|
26040 | }
|
26041 | function previousSuggestion(mathfield) {
|
26042 | updateAutocomplete(mathfield, { atIndex: mathfield.suggestionIndex - 1 });
|
26043 | return false;
|
26044 | }
|
26045 | register({
|
26046 | complete,
|
26047 | nextSuggestion,
|
26048 | previousSuggestion,
|
26049 | }, { target: 'mathfield', category: 'autocomplete' });
|
26050 |
|
26051 | class Scrim {
|
26052 | |
26053 |
|
26054 |
|
26055 |
|
26056 |
|
26057 |
|
26058 |
|
26059 |
|
26060 |
|
26061 | constructor(options) {
|
26062 | var _a, _b;
|
26063 | this.preventOverlayClose = (_a = options === null || options === void 0 ? void 0 : options.preventOverlayClose) !== null && _a !== void 0 ? _a : false;
|
26064 | this.translucent = (_b = options === null || options === void 0 ? void 0 : options.translucent) !== null && _b !== void 0 ? _b : false;
|
26065 | this.state = 'closed';
|
26066 | }
|
26067 | get element() {
|
26068 | if (this._element)
|
26069 | return this._element;
|
26070 | const element = document.createElement('div');
|
26071 | element.setAttribute('role', 'presentation');
|
26072 | element.style.position = 'fixed';
|
26073 | element.style['contain'] = 'content';
|
26074 | element.style.top = '0';
|
26075 | element.style.left = '0';
|
26076 | element.style.right = '0';
|
26077 | element.style.bottom = '0';
|
26078 | element.style.zIndex = 'var(--scrim-zindex, 10099)';
|
26079 | element.style.outline = 'none';
|
26080 | if (this.translucent) {
|
26081 | element.style.background = 'rgba(255, 255, 255, .2)';
|
26082 | element.style['backdropFilter'] = 'contrast(40%)';
|
26083 | }
|
26084 | else {
|
26085 | element.style.background = 'transparent';
|
26086 | }
|
26087 | this._element = element;
|
26088 | return element;
|
26089 | }
|
26090 | open(options) {
|
26091 | var _a;
|
26092 | if (this.state !== 'closed')
|
26093 | return;
|
26094 | this.state = 'opening';
|
26095 |
|
26096 | this.savedActiveElement = deepActiveElement$1();
|
26097 | const { element } = this;
|
26098 | ((_a = options === null || options === void 0 ? void 0 : options.root) !== null && _a !== void 0 ? _a : document.body).appendChild(element);
|
26099 | element.addEventListener('click', this);
|
26100 | document.addEventListener('touchmove', this, false);
|
26101 | document.addEventListener('scroll', this, false);
|
26102 |
|
26103 |
|
26104 | const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
26105 | this.savedMarginRight = document.body.style.marginRight;
|
26106 | this.savedOverflow = document.body.style.overflow;
|
26107 | document.body.style.overflow = 'hidden';
|
26108 | const marginRight = Number.parseFloat(getComputedStyle(document.body).marginRight);
|
26109 | document.body.style.marginRight = `${marginRight + scrollbarWidth}px`;
|
26110 | if (options === null || options === void 0 ? void 0 : options.child) {
|
26111 | element.append(options.child);
|
26112 | }
|
26113 | this.state = 'open';
|
26114 | }
|
26115 | close() {
|
26116 | var _a, _b, _c, _d;
|
26117 | if (this.state !== 'open')
|
26118 | return;
|
26119 | this.state = 'closing';
|
26120 | if (typeof this.onClose === 'function')
|
26121 | this.onClose();
|
26122 | const { element } = this;
|
26123 | element.removeEventListener('click', this);
|
26124 | document.removeEventListener('touchmove', this, false);
|
26125 | document.removeEventListener('scroll', this, false);
|
26126 | element.remove();
|
26127 |
|
26128 | document.body.style.overflow = (_a = this.savedOverflow) !== null && _a !== void 0 ? _a : '';
|
26129 | document.body.style.marginRight = (_b = this.savedMarginRight) !== null && _b !== void 0 ? _b : '';
|
26130 |
|
26131 | if (document.activeElement !== this.savedActiveElement) {
|
26132 | (_d = (_c = this.savedActiveElement) === null || _c === void 0 ? void 0 : _c.focus) === null || _d === void 0 ? void 0 : _d.call(_c);
|
26133 | }
|
26134 |
|
26135 | element.innerHTML = '';
|
26136 | this.state = 'closed';
|
26137 | }
|
26138 | handleEvent(ev) {
|
26139 | if (!this.preventOverlayClose) {
|
26140 | if (ev.target === this._element && ev.type === 'click') {
|
26141 | this.close();
|
26142 | ev.preventDefault();
|
26143 | ev.stopPropagation();
|
26144 | }
|
26145 | else if (ev.target === document &&
|
26146 | (ev.type === 'touchmove' || ev.type === 'scroll')) {
|
26147 |
|
26148 | this.close();
|
26149 | ev.preventDefault();
|
26150 | ev.stopPropagation();
|
26151 | }
|
26152 | }
|
26153 | }
|
26154 | }
|
26155 | function deepActiveElement$1() {
|
26156 | var _a;
|
26157 | let a = document.activeElement;
|
26158 | while ((_a = a === null || a === void 0 ? void 0 : a.shadowRoot) === null || _a === void 0 ? void 0 : _a.activeElement) {
|
26159 | a = a.shadowRoot.activeElement;
|
26160 | }
|
26161 | return a;
|
26162 | }
|
26163 |
|
26164 | let gScrim = null;
|
26165 | let VIRTUAL_KEYBOARD_STYLESHEET_HASH = undefined;
|
26166 | function showAlternateKeys(keyboard, altKeysetId) {
|
26167 | var _a;
|
26168 | throwIfNotInBrowser();
|
26169 | const altKeys = ALT_KEYS[altKeysetId];
|
26170 | const altContainer = document.createElement('div');
|
26171 | altContainer.setAttribute('aria-hidden', 'true');
|
26172 | altContainer.className =
|
26173 | 'ML__keyboard alternate-keys' +
|
26174 | (keyboard.element.classList.contains('material') ? ' material' : '');
|
26175 | altContainer.id = 'mathlive-alternate-keys-panel';
|
26176 | if (altKeys.length >= 14) {
|
26177 |
|
26178 | altContainer.style.width = '236px';
|
26179 | }
|
26180 | else if (altKeys.length >= 7) {
|
26181 |
|
26182 | altContainer.style.width = '286px';
|
26183 | }
|
26184 | else if (altKeys.length === 4 || altKeys.length === 2) {
|
26185 |
|
26186 | altContainer.style.width = '146px';
|
26187 | }
|
26188 | else if (altKeys.length === 1) {
|
26189 |
|
26190 | altContainer.style.width = '86px';
|
26191 | }
|
26192 | else {
|
26193 |
|
26194 | altContainer.style.width = '146px';
|
26195 | }
|
26196 |
|
26197 | altContainer.style.height = 'auto';
|
26198 | let markup = '';
|
26199 | for (const altKey of altKeys) {
|
26200 | markup += '<li';
|
26201 | if (typeof altKey === 'string') {
|
26202 | markup += ' data-latex="' + altKey.replace(/"/g, '"') + '"';
|
26203 | }
|
26204 | else {
|
26205 | if (altKey.latex) {
|
26206 | markup += ' data-latex="' + altKey.latex.replace(/"/g, '"') + '"';
|
26207 | }
|
26208 | if (altKey.content) {
|
26209 | markup +=
|
26210 | ' data-content="' + altKey.content.replace(/"/g, '"') + '"';
|
26211 | }
|
26212 | if (altKey.insert) {
|
26213 | markup +=
|
26214 | ' data-insert="' + altKey.insert.replace(/"/g, '"') + '"';
|
26215 | }
|
26216 | if (altKey.command) {
|
26217 | if (typeof altKey.command === 'string') {
|
26218 | markup += ` data-command="${altKey.command.replace(/"/g, '"')}"`;
|
26219 | }
|
26220 | else {
|
26221 | markup +=
|
26222 | " data-command='" +
|
26223 | JSON.stringify(altKey.command).replace(/"/g, '"') +
|
26224 | "'";
|
26225 | }
|
26226 | }
|
26227 | if (altKey.aside) {
|
26228 | markup += ` data-aside="${altKey.aside.replace(/"/g, '"')}"`;
|
26229 | }
|
26230 | if (altKey.class) {
|
26231 | markup += ` data-classes="${altKey.class}"`;
|
26232 | }
|
26233 | }
|
26234 | markup += '>';
|
26235 | markup += typeof altKey === 'string' ? altKey : (_a = altKey.label) !== null && _a !== void 0 ? _a : '';
|
26236 | markup += '</li>';
|
26237 | }
|
26238 | markup = '<ul>' + markup + '</ul>';
|
26239 | altContainer.innerHTML = keyboard.options.createHTML(markup);
|
26240 |
|
26241 |
|
26242 |
|
26243 | makeKeycap(keyboard, [...altContainer.querySelectorAll('li')], 'performAlternateKeys');
|
26244 |
|
26245 |
|
26246 |
|
26247 | if (gScrim === null)
|
26248 | gScrim = new Scrim();
|
26249 | gScrim.open({
|
26250 | root: keyboard.options.virtualKeyboardContainer,
|
26251 | child: altContainer,
|
26252 | });
|
26253 |
|
26254 |
|
26255 |
|
26256 | const keycapElement = keyboard === null || keyboard === void 0 ? void 0 : keyboard.element.querySelector('div.keyboard-layer.is-visible div.rows ul li[data-alt-keys="' +
|
26257 | altKeysetId +
|
26258 | '"]');
|
26259 | const position = keycapElement === null || keycapElement === void 0 ? void 0 : keycapElement.getBoundingClientRect();
|
26260 | if (position) {
|
26261 | if (position.top - altContainer.clientHeight < 0) {
|
26262 |
|
26263 | altContainer.style.width = 'auto';
|
26264 | if (altKeys.length <= 6) {
|
26265 | altContainer.style.height = '56px';
|
26266 | }
|
26267 | else if (altKeys.length <= 12) {
|
26268 | altContainer.style.height = '108px';
|
26269 | }
|
26270 | else if (altKeys.length <= 18) {
|
26271 | altContainer.style.height = '205px';
|
26272 | }
|
26273 | else {
|
26274 | altContainer.classList.add('compact');
|
26275 | }
|
26276 | }
|
26277 | const top = (position.top - altContainer.clientHeight + 5).toString() + 'px';
|
26278 | const left = Math.max(0, Math.min(window.innerWidth - altContainer.offsetWidth, (position.left + position.right - altContainer.offsetWidth) / 2)) + 'px';
|
26279 | altContainer.style.transform = 'translate(' + left + ',' + top + ')';
|
26280 | altContainer.classList.add('is-visible');
|
26281 | }
|
26282 | return false;
|
26283 | }
|
26284 | function hideAlternateKeys() {
|
26285 | throwIfNotInBrowser();
|
26286 | const altContainer = document.querySelector('#mathlive-alternate-keys-panel');
|
26287 | if (altContainer) {
|
26288 | altContainer.classList.remove('is-visible');
|
26289 | altContainer.innerHTML = '';
|
26290 | }
|
26291 | gScrim === null || gScrim === void 0 ? void 0 : gScrim.close();
|
26292 | return false;
|
26293 | }
|
26294 | class VirtualKeyboard {
|
26295 | constructor(options, mathfield) {
|
26296 | this.options = options;
|
26297 | this.visible = false;
|
26298 | this._mathfield = mathfield;
|
26299 | this.coreStylesheet = null;
|
26300 | this.virtualKeyboardStylesheet = null;
|
26301 | }
|
26302 | setOptions(options) {
|
26303 | var _a;
|
26304 | this.visible = false;
|
26305 | (_a = this._element) === null || _a === void 0 ? void 0 : _a.remove();
|
26306 | this._element = undefined;
|
26307 | this.options = options;
|
26308 | }
|
26309 | get element() {
|
26310 | return this._element;
|
26311 | }
|
26312 | set element(val) {
|
26313 | var _a;
|
26314 | (_a = this._element) === null || _a === void 0 ? void 0 : _a.remove();
|
26315 | this._element = val;
|
26316 | }
|
26317 | get visible() {
|
26318 | return this._visible;
|
26319 | }
|
26320 | set visible(val) {
|
26321 | this._visible = val;
|
26322 | }
|
26323 | get height() {
|
26324 | var _a, _b;
|
26325 | return (_b = (_a = this.element) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0;
|
26326 | }
|
26327 | handleEvent(evt) {
|
26328 | if (!this.element) {
|
26329 | return;
|
26330 | }
|
26331 | switch (evt.type) {
|
26332 | case 'mouseup':
|
26333 | case 'blur':
|
26334 | case 'touchend':
|
26335 | case 'touchcancel':
|
26336 |
|
26337 |
|
26338 | document.body.style.userSelect = '';
|
26339 | unshiftKeyboardLayer(this);
|
26340 | break;
|
26341 | }
|
26342 | }
|
26343 | focusMathfield() {
|
26344 | var _a, _b;
|
26345 | (_b = (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
|
26346 | }
|
26347 | blurMathfield() {
|
26348 | var _a, _b;
|
26349 | (_b = (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.blur) === null || _b === void 0 ? void 0 : _b.call(_a);
|
26350 | }
|
26351 | stateChanged() {
|
26352 | var _a, _b;
|
26353 | (_b = (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.element) === null || _b === void 0 ? void 0 : _b.dispatchEvent(new Event('virtual-keyboard-toggle', {
|
26354 | bubbles: true,
|
26355 | cancelable: false,
|
26356 | composed: true,
|
26357 | }));
|
26358 | }
|
26359 | executeCommand(command) {
|
26360 | var _a, _b, _c;
|
26361 | let selector;
|
26362 | let args = [];
|
26363 | if (isArray(command)) {
|
26364 | selector = command[0];
|
26365 | args = command.slice(1);
|
26366 | }
|
26367 | else {
|
26368 | selector = command;
|
26369 | }
|
26370 |
|
26371 | selector = selector.replace(/-\w/g, (m) => m[1].toUpperCase());
|
26372 | if (((_a = COMMANDS[selector]) === null || _a === void 0 ? void 0 : _a.target) === 'virtual-keyboard') {
|
26373 | return COMMANDS[selector].fn(this, ...args);
|
26374 | }
|
26375 | return ((_c = (_b = this._mathfield) === null || _b === void 0 ? void 0 : _b.executeCommand(command)) !== null && _c !== void 0 ? _c : false);
|
26376 | }
|
26377 | create() {
|
26378 | if (!VIRTUAL_KEYBOARD_STYLESHEET_HASH) {
|
26379 | VIRTUAL_KEYBOARD_STYLESHEET_HASH = hashCode(css_248z$3).toString(36);
|
26380 | }
|
26381 | this.virtualKeyboardStylesheet = this.virtualKeyboardStylesheet =
|
26382 | inject(null, css_248z$3, VIRTUAL_KEYBOARD_STYLESHEET_HASH);
|
26383 | this.coreStylesheet = inject(null, css_248z$4, hashCode(css_248z$4).toString(36));
|
26384 | void loadFonts(this.options.fontsDirectory);
|
26385 | }
|
26386 | enable() {
|
26387 |
|
26388 |
|
26389 |
|
26390 |
|
26391 |
|
26392 |
|
26393 |
|
26394 | window.addEventListener('mouseup', this);
|
26395 | window.addEventListener('blur', this);
|
26396 | window.addEventListener('touchend', this);
|
26397 | window.addEventListener('touchcancel', this);
|
26398 | }
|
26399 | disable() {
|
26400 | var _a, _b, _c;
|
26401 | window.removeEventListener('mouseup', this);
|
26402 | window.removeEventListener('blur', this);
|
26403 | window.removeEventListener('touchend', this);
|
26404 | window.removeEventListener('touchcancel', this);
|
26405 | hideAlternateKeys();
|
26406 | this.visible = false;
|
26407 | (_a = this.coreStylesheet) === null || _a === void 0 ? void 0 : _a.release();
|
26408 | this.coreStylesheet = null;
|
26409 | (_b = this.virtualKeyboardStylesheet) === null || _b === void 0 ? void 0 : _b.release();
|
26410 | this.virtualKeyboardStylesheet = null;
|
26411 | (_c = this._element) === null || _c === void 0 ? void 0 : _c.remove();
|
26412 | this._element = undefined;
|
26413 | }
|
26414 | dispose() { }
|
26415 | }
|
26416 | const KEYBOARDS = {
|
26417 | numeric: {
|
26418 | tooltip: 'keyboard.tooltip.numeric',
|
26419 | layer: 'math',
|
26420 | label: '123',
|
26421 | layers: ['math'],
|
26422 | },
|
26423 | roman: {
|
26424 | tooltip: 'keyboard.tooltip.roman',
|
26425 | layer: 'lower-roman',
|
26426 | label: 'ABC',
|
26427 | layers: ['lower-roman', 'upper-roman'],
|
26428 | },
|
26429 | greek: {
|
26430 | tooltip: 'keyboard.tooltip.greek',
|
26431 | layer: 'lower-greek',
|
26432 | label: 'αβγ',
|
26433 | classes: 'tex-math',
|
26434 | layers: ['lower-greek', 'upper-greek'],
|
26435 | },
|
26436 | functions: {
|
26437 | tooltip: 'keyboard.tooltip.functions',
|
26438 | layer: 'functions',
|
26439 | label: '<i>f</i> ()',
|
26440 | classes: 'tex',
|
26441 | layers: ['functions'],
|
26442 | },
|
26443 | symbols: {
|
26444 | tooltip: 'keyboard.tooltip.symbols',
|
26445 | layer: 'symbols',
|
26446 | label: '∞≠∈',
|
26447 | classes: 'tex',
|
26448 | layers: ['symbols'],
|
26449 | },
|
26450 | latex: {
|
26451 | tooltip: 'keyboard.tooltip.command',
|
26452 |
|
26453 |
|
26454 |
|
26455 | command: ['switchMode', 'latex'],
|
26456 | label: `<svg class="svg-glyph"><use xlink:href='#svg-command' /></svg>`,
|
26457 | layers: ['latex-lower', 'latex-upper', 'latex-symbols'],
|
26458 | },
|
26459 | style: {
|
26460 | tooltip: 'keyboard.tooltip.style',
|
26461 | layer: 'style',
|
26462 | label: '<b>b</b><i>i</i>𝔹',
|
26463 | },
|
26464 | };
|
26465 | const SHIFTED_KEYS = {
|
26466 | '\\varphi ': ['Φ', '\\Phi '],
|
26467 | '\\varsigma ': ['Σ', '\\Sigma '],
|
26468 | '\\epsilon ': ['Ɛ', '{\\char"0190}'],
|
26469 | '\\rho ': ['Ρ', '{\\char"3A1}'],
|
26470 | '\\tau ': ['Τ', '{\\char"3A4}'],
|
26471 | '\\upsilon ': ['Υ', '\\Upsilon '],
|
26472 | '\\theta ': ['Θ', '\\Theta '],
|
26473 | '\\iota ': ['Ι', '{\\char"399}'],
|
26474 | '\\omicron ': ['Ο', '{\\char"39F}'],
|
26475 | '\\pi ': ['Π', '\\Pi '],
|
26476 | '\\alpha ': ['Α', '{\\char"391}'],
|
26477 | '\\sigma ': ['Σ', '\\Sigma '],
|
26478 | '\\delta ': ['Δ', '\\Delta '],
|
26479 | '\\phi ': ['Φ', '\\Phi '],
|
26480 | '\\gamma ': ['Γ', '\\Gamma '],
|
26481 | '\\eta ': ['Η', '{\\char"397}'],
|
26482 | '\\xi ': ['Ξ', '\\Xi '],
|
26483 | '\\kappa ': ['Κ', '{\\char"39A}'],
|
26484 | '\\lambda ': ['Λ', '\\Lambda '],
|
26485 | '\\zeta ': ['Ζ', '{\\char"396}'],
|
26486 | '\\chi ': ['Χ', '{\\char"3A7}'],
|
26487 | '\\psi ': ['Ψ', '\\Psi '],
|
26488 | '\\omega ': ['Ω', '\\Omega '],
|
26489 | '\\beta ': ['Β', '{\\char"392}'],
|
26490 | '\\nu ': ['Ν', '{\\char"39D}'],
|
26491 | '\\mu ': ['Μ', '{\\char"39C}'],
|
26492 | };
|
26493 | const ALT_KEYS_BASE = {
|
26494 | '0': [
|
26495 | '\\emptyset',
|
26496 | '\\varnothing',
|
26497 | '\\infty',
|
26498 | { latex: '#?_0', insert: '#@_0' },
|
26499 | '\\circ',
|
26500 | '\\bigcirc',
|
26501 | '\\bullet',
|
26502 | ],
|
26503 | '2': ['\\frac{1}{2}', { latex: '#?^2', insert: '#@^2' }],
|
26504 | '3': ['\\frac{1}{3}', { latex: '#?^3', insert: '#@^3' }],
|
26505 | '.': [
|
26506 | ',',
|
26507 | ';',
|
26508 | '\\colon',
|
26509 | { latex: ':', aside: 'ratio' },
|
26510 | { latex: '\\cdotp', aside: 'center dot', class: 'box' },
|
26511 | { latex: '\\cdots', aside: 'center ellipsis', class: 'box' },
|
26512 | { latex: '\\ldotp', aside: 'low dot', class: 'box' },
|
26513 | { latex: '\\ldots', aside: 'low ellipsis', class: 'box' },
|
26514 | { latex: '\\vdots', aside: '', class: 'box' },
|
26515 | { latex: '\\ddots', aside: '', class: 'box' },
|
26516 | '\\odot',
|
26517 | '\\oslash',
|
26518 | '\\circledcirc',
|
26519 | ],
|
26520 | '*': [
|
26521 | '\\cdot',
|
26522 | '\\ast',
|
26523 | '\\star',
|
26524 | '\\bigstar',
|
26525 | '\\ltimes',
|
26526 | '\\rtimes',
|
26527 | '\\rightthreetimes',
|
26528 | '\\leftthreetimes',
|
26529 | '\\intercal',
|
26530 | '\\prod',
|
26531 | { latex: '\\prod_{n\\mathop=0}^{\\infty}', class: 'small' },
|
26532 | ],
|
26533 | '+': [
|
26534 | '\\pm',
|
26535 | '\\mp',
|
26536 | '\\sum',
|
26537 | { latex: '\\sum_{n\\mathop=0}^{\\infty}', class: 'small' },
|
26538 | '\\dotplus',
|
26539 | '\\oplus',
|
26540 | ],
|
26541 | '-': ['\\pm', '\\mp', '\\ominus', '\\vert #0 \\vert'],
|
26542 | '/': ['\\divideontimes', '/', '\\div', '\\%'],
|
26543 | '(': [
|
26544 | '\\left( #0\\right)',
|
26545 | '\\left[ #0\\right]',
|
26546 | '\\left\\{ #0\\right\\}',
|
26547 | '\\left\\langle #0\\right\\rangle',
|
26548 | '\\lfloor',
|
26549 | '\\llcorner',
|
26550 | '(',
|
26551 | '\\lbrack',
|
26552 | '\\lvert',
|
26553 | '\\lVert',
|
26554 | '\\lgroup',
|
26555 | '\\langle',
|
26556 | '\\lceil',
|
26557 | '\\ulcorner',
|
26558 | '\\lmoustache',
|
26559 | '\\lbrace',
|
26560 | ],
|
26561 | ')': [
|
26562 | '\\rfloor',
|
26563 | '\\lrcorner',
|
26564 | ')',
|
26565 | '\\rbrack',
|
26566 | '\\rvert',
|
26567 | '\\rVert',
|
26568 | '\\rgroup',
|
26569 | '\\rangle',
|
26570 | '\\rceil',
|
26571 | '\\urcorner',
|
26572 | '\\rmoustache',
|
26573 | '\\rbrace',
|
26574 | ],
|
26575 | '=': [
|
26576 | '\\cong',
|
26577 | '\\asymp',
|
26578 | '\\equiv',
|
26579 | '\\differencedelta',
|
26580 | '\\varpropto',
|
26581 | '\\thickapprox',
|
26582 | '\\approxeq',
|
26583 | '\\thicksim',
|
26584 | '\\backsim',
|
26585 | '\\eqsim',
|
26586 | '\\simeq',
|
26587 | '\\Bumpeq',
|
26588 | '\\bumpeq',
|
26589 | '\\doteq',
|
26590 | '\\Doteq',
|
26591 | '\\fallingdotseq',
|
26592 | '\\risingdotseq',
|
26593 | '\\coloneq',
|
26594 | '\\eqcirc',
|
26595 | '\\circeq',
|
26596 | '\\triangleq',
|
26597 | '\\between',
|
26598 | ],
|
26599 | '!=': ['\\neq', '\\ncong', '', '\\nsim'],
|
26600 | '<': [
|
26601 | '\\leq',
|
26602 | '\\leqq',
|
26603 | '\\lneqq',
|
26604 | '\\ll',
|
26605 | '\\lessgtr',
|
26606 | '\\nless',
|
26607 | '\\nleq',
|
26608 | '\\lesssim',
|
26609 | '\\precsim',
|
26610 | '\\prec',
|
26611 | '\\nprec',
|
26612 | '\\preccurlyeq',
|
26613 | '\\lessdot',
|
26614 | ],
|
26615 | '>': [
|
26616 | '\\geq',
|
26617 | '\\geqq',
|
26618 | '\\gneqq',
|
26619 | '\\gg',
|
26620 | '\\gtrless',
|
26621 | '\\ngtr',
|
26622 | '\\ngeq',
|
26623 | '\\gtrsim',
|
26624 | '\\succsim',
|
26625 | '\\succ',
|
26626 | '\\nsucc',
|
26627 | '\\succcurlyeq',
|
26628 | '\\gtrdot',
|
26629 | ],
|
26630 | 'in': ['\\owns'],
|
26631 | '!in': ['\\backepsilon'],
|
26632 | 'subset': ['\\subseteq', '\\nsubset', '\\nsubseteq'],
|
26633 | 'superset': ['\\supseteq', '\\nsupset', '\\nsupseteq'],
|
26634 | 'infinity': ['\\aleph_0', '\\aleph_1', '\\omega', '\\mathfrak{m}'],
|
26635 | 'numeric-pi': ['\\prod', '\\theta', '\\rho', '\\sin', '\\cos', '\\tan'],
|
26636 | 'ee': ['\\times 10^{#?}', '\\ln', '\\ln_{10}', '\\log'],
|
26637 | '^': ['_{#?}'],
|
26638 |
|
26639 | 'int': [
|
26640 | { latex: '\\int_{#?}^{#?}', class: 'small' },
|
26641 | { latex: '\\int', class: 'small' },
|
26642 | { latex: '\\smallint', class: 'small' },
|
26643 | { latex: '\\iint', class: 'small' },
|
26644 | { latex: '\\iiint', class: 'small' },
|
26645 | { latex: '\\oint', class: 'small' },
|
26646 | { latex: '\\dfrac{\\rd}{\\rd x}', class: 'small' },
|
26647 | { latex: '\\frac{\\partial}{\\partial x}', class: 'small' },
|
26648 | '\\capitalDifferentialD',
|
26649 | '\\rd',
|
26650 | '\\partial',
|
26651 | ],
|
26652 | 'nabla': ['\\nabla\\times', '\\nabla\\cdot', '\\nabla^{2}'],
|
26653 | '!': ['!!', '\\Gamma', '\\Pi'],
|
26654 | 'accents': [
|
26655 | '\\bar{#@}',
|
26656 | '\\vec{#@}',
|
26657 | '\\hat{#@}',
|
26658 | '\\check{#@}',
|
26659 | '\\dot{#@}',
|
26660 | '\\ddot{#@}',
|
26661 | '\\mathring{#@}',
|
26662 | '\\breve{#@}',
|
26663 | '\\acute{#@}',
|
26664 | '\\tilde{#@}',
|
26665 | '\\grave{#@}',
|
26666 | ],
|
26667 | 'underline': [
|
26668 | '\\underbrace{#@}',
|
26669 | '\\underlinesegment{#@}',
|
26670 | '\\underleftrightarrow{#@}',
|
26671 | '\\underrightarrow{#@}',
|
26672 | '\\underleftarrow{#@}',
|
26673 | '\\undergroup{#@}',
|
26674 | ],
|
26675 | 'overline': [
|
26676 | '\\overbrace{#@}',
|
26677 | '\\overlinesegment{#@}',
|
26678 | '\\overleftrightarrow{#@}',
|
26679 | '\\overrightarrow{#@}',
|
26680 | '\\overleftarrow{#@}',
|
26681 | '\\overgroup{#@}',
|
26682 | ],
|
26683 | 'xleftarrows': [
|
26684 | '\\xlongequal{}',
|
26685 | '\\xleftrightarrow{}',
|
26686 | '\\xLeftrightarrow{}',
|
26687 | '\\xleftrightharpoons{}',
|
26688 | '\\xLeftarrow{}',
|
26689 | '\\xleftharpoonup{}',
|
26690 | '\\xleftharpoondown{}',
|
26691 | '\\xtwoheadleftarrow{}',
|
26692 | '\\xhookleftarrow{}',
|
26693 | '\\xtofrom{}',
|
26694 | '\\xleftequilibrium{}',
|
26695 | '\\xrightleftarrows{}',
|
26696 | ],
|
26697 | 'xrightarrows': [
|
26698 | '\\xlongequal{}',
|
26699 | '\\xleftrightarrow{}',
|
26700 | '\\xLeftrightarrow{}',
|
26701 | '\\xleftrightharpoons{}',
|
26702 | '\\xRightarrow{}',
|
26703 | '\\xrightharpoonup{}',
|
26704 | '\\xrightharpoondown{}',
|
26705 | '\\xtwoheadrightarrow{}',
|
26706 | '\\xrightleftharpoons{}',
|
26707 | '\\xhookrightarrow{}',
|
26708 | '\\xmapsto{}',
|
26709 | '\\xrightequilibrium{}',
|
26710 | '\\xrightleftarrows{}',
|
26711 | ],
|
26712 |
|
26713 |
|
26714 |
|
26715 |
|
26716 |
|
26717 |
|
26718 | 'A': [
|
26719 | { latex: '\\aleph', aside: 'aleph' },
|
26720 | { latex: '\\forall', aside: 'for all' },
|
26721 | ],
|
26722 | 'a': [
|
26723 | { latex: '\\aleph', aside: 'aleph' },
|
26724 | { latex: '\\forall', aside: 'for all' },
|
26725 | ],
|
26726 | 'b': [{ latex: '\\beth', aside: 'beth' }],
|
26727 | 'B': [{ latex: '\\beth', aside: 'beth' }],
|
26728 | 'c': [{ latex: '\\C', aside: 'set of complex numbers' }],
|
26729 | 'd': [{ latex: '\\daleth', aside: 'daleth' }],
|
26730 | 'D': [{ latex: '\\daleth', aside: 'daleth' }],
|
26731 | 'e': [
|
26732 | { latex: '\\exponentialE', aside: 'exponential e' },
|
26733 | { latex: '\\exists', aside: 'there is' },
|
26734 | { latex: '\\nexists', aside: 'there isn’t' },
|
26735 | ],
|
26736 | 'g': [{ latex: '\\gimel', aside: 'gimel' }],
|
26737 | 'G': [{ latex: '\\gimel', aside: 'gimel' }],
|
26738 | 'h': [
|
26739 | { latex: '\\hbar', aside: 'h bar' },
|
26740 | { latex: '\\hslash', aside: 'h slash' },
|
26741 | ],
|
26742 | 'i': [{ latex: '\\imaginaryI', aside: 'imaginary i' }],
|
26743 | 'j': [{ latex: '\\imaginaryJ', aside: 'imaginary j' }],
|
26744 | 'l': [{ latex: '\\ell', aside: 'ell' }],
|
26745 | 'n': [{ latex: '\\N', aside: 'set of natural numbers' }],
|
26746 | 'p': [{ latex: '\\P', aside: 'set of primes' }],
|
26747 | 'q': [{ latex: '\\Q', aside: 'set of rational numbers' }],
|
26748 | 'r': [{ latex: '\\R', aside: 'set of real numbers' }],
|
26749 | 'z': [{ latex: '\\Z', aside: 'set of integers' }],
|
26750 | 'x-var': [
|
26751 | 'y',
|
26752 | 'z',
|
26753 | 't',
|
26754 | 'r',
|
26755 | { latex: 'f(#?)', class: 'small' },
|
26756 | { latex: 'g(#?)', class: 'small' },
|
26757 | 'x^2',
|
26758 | 'x^n',
|
26759 | 'x_n',
|
26760 | 'x_{n+1}',
|
26761 | 'x_i',
|
26762 | 'x_{i+1}',
|
26763 | ],
|
26764 | 'n-var': ['i', 'j', 'p', 'k', 'a', 'u'],
|
26765 | 'ii': ['\\Re', '\\Im', '\\imaginaryJ', '\\Vert #0 \\Vert'],
|
26766 | 'logic': [
|
26767 | { latex: '\\exists', aside: 'there is' },
|
26768 | { latex: '\\nexists', aside: 'there isn’t' },
|
26769 | { latex: '\\ni', aside: 'such that' },
|
26770 | { latex: '\\Colon', aside: 'such that' },
|
26771 | { latex: '\\implies', aside: 'implies' },
|
26772 | { latex: '\\impliedby', aside: 'implied by' },
|
26773 | { latex: '\\iff', aside: 'if and only if' },
|
26774 | { latex: '\\land', aside: 'and' },
|
26775 | { latex: '\\lor', aside: 'or' },
|
26776 | { latex: '\\oplus', aside: 'xor' },
|
26777 | { latex: '\\lnot', aside: 'not' },
|
26778 | { latex: '\\downarrow', aside: 'nor' },
|
26779 | { latex: '\\uparrow', aside: 'nand' },
|
26780 | { latex: '\\curlywedge', aside: 'nor' },
|
26781 | { latex: '\\bar\\curlywedge', aside: 'nand' },
|
26782 |
|
26783 |
|
26784 |
|
26785 | { latex: '\\therefore', aside: 'therefore' },
|
26786 | { latex: '\\because', aside: 'because' },
|
26787 | { latex: '^\\biconditional', aside: 'biconditional' },
|
26788 | '\\leftrightarrow',
|
26789 | '\\Leftrightarrow',
|
26790 | '\\to',
|
26791 | '\\models',
|
26792 | '\\vdash',
|
26793 | '\\gets',
|
26794 | '\\dashv',
|
26795 | '\\roundimplies',
|
26796 | ],
|
26797 | 'set-operators': [
|
26798 | '\\cap',
|
26799 | '\\cup',
|
26800 | '\\setminus',
|
26801 | '\\smallsetminus',
|
26802 | '\\complement',
|
26803 | ],
|
26804 | 'set-relations': [
|
26805 | '\\in',
|
26806 | '\\notin',
|
26807 | '\\ni',
|
26808 | '\\owns',
|
26809 | '\\subset',
|
26810 | '\\supset',
|
26811 | '\\subseteq',
|
26812 | '\\supseteq',
|
26813 | '\\subsetneq',
|
26814 | '\\supsetneq',
|
26815 | '\\varsubsetneq',
|
26816 | '\\subsetneqq',
|
26817 | '\\nsubset',
|
26818 | '\\nsupset',
|
26819 | '\\nsubseteq',
|
26820 | '\\nsupseteq',
|
26821 | ],
|
26822 | 'space': [
|
26823 | {
|
26824 | latex: '\\char"203A\\!\\char"2039',
|
26825 | insert: '\\!',
|
26826 | aside: 'negative thin space<br>⁻³⧸₁₈ em',
|
26827 | },
|
26828 | {
|
26829 | latex: '\\unicode{"203A}\\,\\unicode{"2039}',
|
26830 | insert: '\\,',
|
26831 | aside: 'thin space<br>³⧸₁₈ em',
|
26832 | },
|
26833 | {
|
26834 | latex: '\\unicode{"203A}\\:\\unicode{"2039}',
|
26835 | insert: '\\:',
|
26836 | aside: 'medium space<br>⁴⧸₁₈ em',
|
26837 | },
|
26838 | {
|
26839 | latex: '\\unicode{"203A}\\;\\unicode{"2039}',
|
26840 | insert: '\\;',
|
26841 | aside: 'thick space<br>⁵⧸₁₈ em',
|
26842 | },
|
26843 | {
|
26844 | latex: '\\unicode{"203A}\\ \\unicode{"2039}',
|
26845 | insert: '\\ ',
|
26846 | aside: '⅓ em',
|
26847 | },
|
26848 | {
|
26849 | latex: '\\unicode{"203A}\\enspace\\unicode{"2039}',
|
26850 | insert: '\\enspace',
|
26851 | aside: '½ em',
|
26852 | },
|
26853 | {
|
26854 | latex: '\\unicode{"203A}\\quad\\unicode{"2039}',
|
26855 | insert: '\\quad',
|
26856 | aside: '1 em',
|
26857 | },
|
26858 | {
|
26859 | latex: '\\unicode{"203A}\\qquad\\unicode{"2039}',
|
26860 | insert: '\\qquad',
|
26861 | aside: '2 em',
|
26862 | },
|
26863 | ],
|
26864 |
|
26865 | 'delete': [
|
26866 | {
|
26867 | label: '<span class="warning"><svg class="svg-glyph"><use xlink:href="#svg-trash" /></svg></span>',
|
26868 | command: 'deleteAll',
|
26869 | },
|
26870 | ],
|
26871 |
|
26872 | '->|': [],
|
26873 | };
|
26874 | let ALT_KEYS = {};
|
26875 | const LAYERS = {
|
26876 | 'math': `
|
26877 | <div class='rows'>
|
26878 | <ul>
|
26879 | <li class='keycap tex' data-alt-keys='x-var'><i>x</i></li>
|
26880 | <li class='keycap tex' data-alt-keys='n-var'><i>n</i></li>
|
26881 | <li class='separator w5'></li>
|
26882 | <row name='numpad-1'/>
|
26883 | <li class='separator w5'></li>
|
26884 | <li class='keycap tex' data-latex='\\exponentialE' data-alt-keys='ee'>e</li>
|
26885 | <li class='keycap tex' data-latex='\\imaginaryI' data-alt-keys='ii'>i</li>
|
26886 | <li class='keycap tex' data-latex='\\pi' data-alt-keys='numeric-pi'></li>
|
26887 | </ul>
|
26888 | <ul>
|
26889 | <li class='keycap tex' data-key='<' data-alt-keys='<'><</li>
|
26890 | <li class='keycap tex' data-key='>' data-alt-keys='>'>></li>
|
26891 | <li class='separator w5'></li>
|
26892 | <row name='numpad-2'/>
|
26893 | <li class='separator w5'></li>
|
26894 | <li class='keycap tex' data-latex='#@^{2}' data-latex='x^2'></li>
|
26895 | <li class='keycap tex' data-alt-keys='^' data-insert='#@^{#?}' data-latex='x^\\placeholder'></li>
|
26896 | <li class='keycap tex small' data-insert='\\sqrt{#0}' data-latex='\\sqrt{#0}'></li>
|
26897 | </ul>
|
26898 | <ul>
|
26899 | <li class='keycap tex' data-alt-keys='(' >(</li>
|
26900 | <li class='keycap tex' data-alt-keys=')' >)</li>
|
26901 | <li class='separator w5'></li>
|
26902 | <row name='numpad-3'/>
|
26903 | <li class='separator w5'></li>
|
26904 | <li class='keycap small' data-alt-keys='int' data-latex='\\int_0^\\infty'></li>
|
26905 | <li class='keycap' data-latex='\\forall' data-alt-keys='logic' ></li>
|
26906 | <li class='action font-glyph bottom right' data-alt-keys='delete' data-command='["performWithFeedback","deleteBackward"]'>⌫</li></ul>
|
26907 | </ul>
|
26908 | <ul>
|
26909 | <li class='keycap' data-alt-keys='foreground-color' data-command='["applyStyle",{"color":"red"}]'><span style='border-radius: 50%;width:22px;height:22px; border: 3px solid #cc2428; box-sizing: border-box'></span></li>
|
26910 | <li class='keycap' data-alt-keys='background-color' data-command='["applyStyle",{"backgroundColor":"yellow"}]'><span style='border-radius: 50%;width:22px;height:22px; background:#fff590; box-sizing: border-box'></span></li>
|
26911 | <li class='separator w5'></li>
|
26912 | <row name='numpad-4'/>
|
26913 | <li class='separator w5'></li>
|
26914 | <arrows/>
|
26915 | </ul>
|
26916 | </div>
|
26917 | `,
|
26918 | 'lower-roman': `
|
26919 | <div class='rows'>
|
26920 | <ul>
|
26921 | <row name='numpad-1' class='if-wide'/>
|
26922 | <row name='lower-1' shift-layer='upper-roman'/>
|
26923 | </ul>
|
26924 | <ul>
|
26925 | <row name='numpad-2' class='if-wide'/>
|
26926 | <row name='lower-2' shift-layer='upper-roman''/>
|
26927 | </ul>
|
26928 | <ul>
|
26929 | <row name='numpad-3' class='if-wide'/>
|
26930 | <row name='lower-3' shift-layer='upper-roman''/>
|
26931 | </ul>
|
26932 | <ul>
|
26933 | <row name='numpad-4' class='if-wide'/>
|
26934 | <li class='keycap' >;</li>
|
26935 | <li class='keycap' >,</li>
|
26936 | <li class='keycap w50' data-key=' ' data-alt-keys='space'> </li>
|
26937 | <arrows/>
|
26938 | </ul>
|
26939 | </div>`,
|
26940 | 'upper-roman': `
|
26941 | <div class='rows'>
|
26942 | <ul>
|
26943 | <row name='numpad-1' class='if-wide'/>
|
26944 | <row name='upper-1' shift-layer='lower-roman'/>
|
26945 | </ul>
|
26946 | <ul>
|
26947 | <row name='numpad-2' class='if-wide'/>
|
26948 | <row name='upper-2' shift-layer='lower-roman'/>
|
26949 | </ul>
|
26950 | <ul>
|
26951 | <row name='numpad-3' class='if-wide'/>
|
26952 | <row name='upper-3' shift-layer='lower-roman'/>
|
26953 | </ul>
|
26954 | <ul>
|
26955 | <row name='numpad-4' class='if-wide'/>
|
26956 | <li class='keycap' >;</li>
|
26957 | <li class='keycap' data-alt-keys='.'>;</li>
|
26958 | <li class='keycap w50' data-key=' '> </li>
|
26959 | <arrows/>
|
26960 | </ul>
|
26961 | </div>`,
|
26962 | 'symbols': `
|
26963 | <div class='rows'>
|
26964 | <ul>
|
26965 | <row name='numpad-1' class='if-wide'/>
|
26966 | <li class='keycap tex' data-alt-keys='(' data-insert='\\lbrace '>{</li>
|
26967 | <li class='keycap tex' data-alt-keys=')' data-insert='\\rbrace '>}</li>
|
26968 | <li class='separator w5'></li>
|
26969 | <li class='keycap tex' data-alt-keys='in' data-insert='\\in '>∈</li>
|
26970 | <li class='keycap tex' data-alt-keys='!in' data-insert='\\notin '>∉</li>
|
26971 | <li class='keycap tex' data-insert='\\Re '>ℜ<aside>Real</aside></li>
|
26972 | <li class='keycap tex' data-insert='\\Im '>ℑ<aside>Imaginary</aside></li>
|
26973 | <li class='keycap w15' data-insert='\\ulcorner#0\\urcorner '><span><sup>┌</sup><span><span style='color:#ddd'>o</span><sup>┐</sup></span><aside>ceil</aside></li>
|
26974 | <li class='keycap tex' data-alt-keys='nabla' data-insert='\\nabla '>∇<aside>nabla</aside></li>
|
26975 | <li class='keycap tex' data-alt-keys='infinity' data-insert='\\infty '>∞</li>
|
26976 |
|
26977 | </ul>
|
26978 | <ul>
|
26979 | <row name='numpad-2' class='if-wide'/>
|
26980 | <li class='keycap tex' data-alt-keys='(' data-insert='\\lbrack '>[</li>
|
26981 | <li class='keycap tex' data-alt-keys=')' data-insert='\\rbrack '>]</li>
|
26982 | <li class='separator w5'></li>
|
26983 | <li class='keycap tex' data-alt-keys='subset' data-insert='\\subset '>⊂</li>
|
26984 | <li class='keycap tex' data-alt-keys='superset' data-insert='\\supset '>⊃</li>
|
26985 | <li class='keycap tex' data-key='!' data-alt-keys='!'>!<aside>factorial</aside></li>
|
26986 | <li class='keycap' data-latex='^{\\prime} '><span><sup><span><span style='color:#ddd'>o</span>′</sup></span><aside>prime</aside></li>
|
26987 | <li class='keycap w15' data-insert='\\llcorner#0\\lrcorner '><span><sub>└</sub><span style='color:#ddd'>o</span><sub>┘</sub></span><aside>floor</aside></li>
|
26988 | <li class='keycap tex' data-insert='\\partial '>∂<aside>partial<br>derivative</aside></li>
|
26989 | <li class='keycap tex' data-insert='\\emptyset '>∅<aside>empty set</aside></li>
|
26990 |
|
26991 | </ul>
|
26992 | <ul>
|
26993 | <row name='numpad-3' class='if-wide'/>
|
26994 | <li class='keycap tex' data-alt-keys='(' data-insert='\\langle '>⟨</li>
|
26995 | <li class='keycap tex' data-alt-keys=')' data-insert='\\rangle '>⟩</li>
|
26996 | <li class='separator w5'></li>
|
26997 | <li class='keycap tex' data-alt-keys='overline' data-latex='\\overline{#?}' data-aside='overline'></li>
|
26998 | <li class='keycap tex' data-alt-keys='underline' data-latex='\\underline{#?}' data-aside='underline'></li>
|
26999 | <li class='keycap tex' data-alt-keys='accents' data-insert='\\vec{#@}' data-latex='\\vec{#?}' data-aside='vector'></li>
|
27000 | <li class='keycap tex small' data-alt-keys='xleftarrows' data-latex='\\xleftarrow{}' ></li>
|
27001 | <li class='keycap tex small' data-alt-keys='xrightarrows' data-latex='\\xrightarrow{}' ></li>
|
27002 | <li class='keycap tex' data-alt-keys='absnorm' data-insert='\\left| #0 \\right|' data-latex='\\left| #? \\right|' data-aside='abs'></li>
|
27003 |
|
27004 | <li class='action font-glyph bottom right w15'
|
27005 | data-shifted='<span class="warning"><svg class="svg-glyph"><use xlink:href="#svg-trash" /></svg></span>'
|
27006 | data-shifted-command='"deleteAll"'
|
27007 | data-alt-keys='delete' data-command='["performWithFeedback","deleteBackward"]'
|
27008 | >⌫</li>
|
27009 | </ul>
|
27010 | <ul>
|
27011 | <row name='numpad-4' class='if-wide'/>
|
27012 | <li class='keycap tex' data-insert=','>,</li>
|
27013 | <li class='keycap tex' data-insert='\\cdot '>⋅<aside>centered dot</aside></li>
|
27014 | <li class='keycap tex' data-insert='\\colon '>:<aside>colon</aside></li>
|
27015 | <li class='keycap tex' data-insert='\\circ '>∘<aside>circle</aside></li>
|
27016 | <li class='keycap tex' data-insert='\\approx '>≈<aside>approx.</aside></li>
|
27017 | <li class='keycap tex' data-insert='\\ne '>≠</li>
|
27018 | <li class='keycap tex' data-insert='\\pm '>±</li>
|
27019 | <arrows/>
|
27020 | </ul>
|
27021 | </div>`,
|
27022 | 'lower-greek': `
|
27023 | <div class='rows'>
|
27024 | <ul><li class='keycap tex' data-insert='\\varphi '><i>φ</i><aside>phi var.</aside></li>
|
27025 | <li class='keycap tex' data-insert='\\varsigma '><i>ς</i><aside>sigma var.</aside></li>
|
27026 | <li class='keycap tex' data-insert='\\epsilon '><i>ϵ</i></li>
|
27027 | <li class='keycap tex' data-insert='\\rho '><i>ρ</i></li>
|
27028 | <li class='keycap tex' data-insert='\\tau '><i>τ</i></li>
|
27029 | <li class='keycap tex' data-insert='\\upsilon '><i>υ</i></li>
|
27030 | <li class='keycap tex' data-insert='\\theta '><i>θ</i></li>
|
27031 | <li class='keycap tex' data-insert='\\iota '><i>ι</i></li>
|
27032 | <li class='keycap tex' data-insert='\\omicron '>ο</i></li>
|
27033 | <li class='keycap tex' data-insert='\\pi '><i>π</i></li>
|
27034 | </ul>
|
27035 | <ul><li class='keycap tex' data-insert='\\alpha ' data-shifted='Α' data-shifted-command='["insert","{\\\\char\\"391}"]'><i>α</i></li>
|
27036 | <li class='keycap tex' data-insert='\\sigma '><i>σ</i></li>
|
27037 | <li class='keycap tex' data-insert='\\delta '><i>δ</i></li>
|
27038 | <li class='keycap tex' data-insert='\\phi '><i>ϕ</i></i></li>
|
27039 | <li class='keycap tex' data-insert='\\gamma '><i>γ</i></li>
|
27040 | <li class='keycap tex' data-insert='\\eta '><i>η</i></li>
|
27041 | <li class='keycap tex' data-insert='\\xi '><i>ξ</i></li>
|
27042 | <li class='keycap tex' data-insert='\\kappa '><i>κ</i></li>
|
27043 | <li class='keycap tex' data-insert='\\lambda '><i>λ</i></li>
|
27044 | </ul>
|
27045 | <ul><li class='shift modifier font-glyph bottom left w15 layer-switch' data-layer='upper-greek'>⇧</li>
|
27046 | <li class='keycap tex' data-insert='\\zeta '><i>ζ</i></li>
|
27047 | <li class='keycap tex' data-insert='\\chi '><i>χ</i></li>
|
27048 | <li class='keycap tex' data-insert='\\psi '><i>ψ</i></li>
|
27049 | <li class='keycap tex' data-insert='\\omega '><i>ω</i></li>
|
27050 | <li class='keycap tex' data-insert='\\beta '><i>β</i></li>
|
27051 | <li class='keycap tex' data-insert='\\nu '><i>ν</i></li>
|
27052 | <li class='keycap tex' data-insert='\\mu '><i>μ</i></li>
|
27053 | <li class='action font-glyph bottom right w15'
|
27054 | data-shifted='<span class="warning"><svg class="svg-glyph"><use xlink:href="#svg-trash" /></svg></span>'
|
27055 | data-shifted-command='"deleteAll"'
|
27056 | data-alt-keys='delete' data-command='["performWithFeedback","deleteBackward"]'
|
27057 | >⌫</li>
|
27058 | </ul>
|
27059 | <ul>
|
27060 | <li class='keycap ' data-key=' '> </li>
|
27061 | <li class='keycap'>,</li>
|
27062 | <li class='keycap tex' data-insert='\\varepsilon '><i>ε</i><aside>epsilon var.</aside></li>
|
27063 | <li class='keycap tex' data-insert='\\vartheta '><i>ϑ</i><aside>theta var.</aside></li>
|
27064 | <li class='keycap tex' data-insert='\\varkappa '><i>ϰ</i><aside>kappa var.</aside></li>
|
27065 | <li class='keycap tex' data-insert='\\varpi '><i>ϖ<aside>pi var.</aside></i></li>
|
27066 | <li class='keycap tex' data-insert='\\varrho '><i>ϱ</i><aside>rho var.</aside></li>
|
27067 | <arrows/>
|
27068 | </ul>
|
27069 | </div>`,
|
27070 | 'upper-greek': `
|
27071 | <div class='rows'>
|
27072 | <ul><li class='keycap tex' data-insert='\\Phi '>Φ<aside>phi</aside></li>
|
27073 | <li class='keycap tex' data-insert='\\Sigma '>Σ<aside>sigma</aside></li>
|
27074 | <li class='keycap tex' data-insert='{\\char"0190}'>Ɛ<aside>epsilon</aside></li>
|
27075 | <li class='keycap tex' data-insert='{\\char"3A1}'>Ρ<aside>rho</aside></li>
|
27076 | <li class='keycap tex' data-insert='{\\char"3A4}'>Τ<aside>tau</aside></li>
|
27077 | <li class='keycap tex' data-insert='\\Upsilon '>Υ<aside>upsilon</aside></li>
|
27078 | <li class='keycap tex' data-insert='\\Theta '>Θ<aside>theta</aside></li>
|
27079 | <li class='keycap tex' data-insert='{\\char"399}'>Ι<aside>iota</aside></li>
|
27080 | <li class='keycap tex' data-insert='{\\char"39F}'>Ο<aside>omicron</aside></li>
|
27081 | <li class='keycap tex' data-insert='\\Pi '>Π<aside>pi</aside></li></ul>
|
27082 | <ul><li class='keycap tex' data-insert='{\\char"391}'>Α<aside>alpha</aside></li>
|
27083 | <li class='keycap tex' data-insert='\\Sigma '>Σ<aside>sigma</aside></li>
|
27084 | <li class='keycap tex' data-insert='\\Delta '>Δ<aside>delta</aside></li>
|
27085 | <li class='keycap tex' data-insert='\\Phi '>Φ<aside>phi</aside></li>
|
27086 | <li class='keycap tex' data-insert='\\Gamma '>Γ<aside>gamma</aside></li>
|
27087 | <li class='keycap tex' data-insert='{\\char"397}'>Η<aside>eta</aside></li>
|
27088 | <li class='keycap tex' data-insert='\\Xi '>Ξ<aside>xi</aside></li>
|
27089 | <li class='keycap tex' data-insert='{\\char"39A}'>Κ<aside>kappa</aside></li>
|
27090 | <li class='keycap tex' data-insert='\\Lambda '>Λ<aside>lambda</aside></li></ul>
|
27091 | <ul><li class='shift modifier font-glyph bottom left selected w15 layer-switch' data-layer='lower-greek'>⇧</li>
|
27092 | <li class='keycap tex' data-insert='{\\char"396}'>Ζ<aside>zeta</aside></li>
|
27093 | <li class='keycap tex' data-insert='{\\char"3A7}'>Χ<aside>chi</aside></li>
|
27094 | <li class='keycap tex' data-insert='\\Psi '>Ψ<aside>psi</aside></li>
|
27095 | <li class='keycap tex' data-insert='\\Omega '>Ω<aside>omega</aside></li>
|
27096 | <li class='keycap tex' data-insert='{\\char"392}'>Β<aside>beta</aside></li>
|
27097 | <li class='keycap tex' data-insert='{\\char"39D}'>Ν<aside>nu</aside></li>
|
27098 | <li class='keycap tex' data-insert='{\\char"39C}'>Μ<aside>mu</aside></li>
|
27099 | <li class='action font-glyph bottom right w15' data-command='["performWithFeedback","deleteBackward"]'>⌫</li></ul>
|
27100 | <ul>
|
27101 | <li class='separator w10'> </li>
|
27102 | <li class='keycap'>.</li>
|
27103 | <li class='keycap w50' data-key=' '> </li>
|
27104 | <arrows/>
|
27105 | </ul>
|
27106 | </div>`,
|
27107 | 'latex-lower': `
|
27108 | <div class='rows'>
|
27109 | <ul><row name='lower-1' class='tt' shift-layer='latex-upper'/></ul>
|
27110 | <ul><row name='lower-2' class='tt' shift-layer='latex-upper'/></ul>
|
27111 | <ul><row name='lower-3' class='tt' shift-layer='latex-upper'/></ul>
|
27112 | <ul>
|
27113 | <li class='layer-switch font-glyph modifier bottom left' data-layer='latex-symbols'>01#</li>
|
27114 | <li class='keycap tt' data-shifted='[' data-shifted-command='["insertAndUnshiftKeyboardLayer", "["]'>{</li>
|
27115 | <li class='keycap tt' data-shifted=']' data-shifted-command='["insertAndUnshiftKeyboardLayer", "]"]'>}</li>
|
27116 | <li class='keycap tt' data-shifted='(' data-shifted-command='["insertAndUnshiftKeyboardLayer", "("]'>^</li>
|
27117 | <li class='keycap tt' data-shifted=')' data-shifted-command='["insertAndUnshiftKeyboardLayer", ")"]'>_</li>
|
27118 | <li class='keycap w20' data-key=' '> </li>
|
27119 | <arrows/>
|
27120 | </ul>
|
27121 | </div>`,
|
27122 | 'latex-upper': `
|
27123 | <div class='rows'>
|
27124 | <ul><row name='upper-1' class='tt' shift-layer='latex-lower'/></ul>
|
27125 | <ul><row name='upper-2' class='tt' shift-layer='latex-lower'/></ul>
|
27126 | <ul><row name='upper-3' class='tt' shift-layer='latex-lower'/></ul>
|
27127 | <ul>
|
27128 | <li class='layer-switch font-glyph modifier bottom left' data-layer='latex-symbols'01#</li>
|
27129 | <li class='keycap tt'>[</li>
|
27130 | <li class='keycap tt'>]</li>
|
27131 | <li class='keycap tt'>(</li>
|
27132 | <li class='keycap tt'>)</li>
|
27133 | <li class='keycap w20' data-key=' '> </li>
|
27134 | <arrows/>
|
27135 | </ul>
|
27136 | </div>`,
|
27137 | 'latex-symbols': `
|
27138 | <div class='rows'>
|
27139 | <ul><li class='keycap tt'>1</li><li class='keycap tt'>2</li><li class='keycap tt'>3</li><li class='keycap tt'>4</li><li class='keycap tt'>5</li><li class='keycap tt'>6</li><li class='keycap tt'>7</li><li class='keycap tt'>8</li><li class='keycap tt'>9</li><li class='keycap tt'>0</li></ul>
|
27140 | <ul><li class='keycap tt'>!</li><li class='keycap tt'>@</li><li class='keycap tt'>#</li><li class='keycap tt'>$</li><li class='keycap tt'>%</li><li class='keycap tt'>^</li><li class='keycap tt'>&</li><li class='keycap tt'>*</li><li class='keycap tt'>+</li><li class='keycap tt'>=</li></ul>
|
27141 | <ul>
|
27142 | <li class='keycap tt'>\\</li>
|
27143 | <li class='keycap tt'>|</li>
|
27144 | <li class='keycap tt'>/</li>
|
27145 | <li class='keycap tt'>\`</li>
|
27146 | <li class='keycap tt'>;</li>
|
27147 | <li class='keycap tt'>:</li>
|
27148 | <li class='keycap tt'>?</li>
|
27149 | <li class='keycap tt'>'</li>
|
27150 | <li class='keycap tt'>"</li>
|
27151 | <li class='action font-glyph bottom right'
|
27152 | data-shifted='<span class="warning"><svg class="svg-glyph"><use xlink:href="#svg-trash" /></svg></span>'
|
27153 | data-shifted-command='"deleteAll"'
|
27154 | data-alt-keys='delete' data-command='["performWithFeedback","deleteBackward"]'
|
27155 | >⌫</li>
|
27156 | </ul>
|
27157 | <ul>
|
27158 | <li class='layer-switch font-glyph modifier bottom left' data-layer='latex-lower'>abc</li>
|
27159 | <li class='keycap tt'><</li>
|
27160 | <li class='keycap tt'>></li>
|
27161 | <li class='keycap tt'>~</li>
|
27162 | <li class='keycap tt'>,</li>
|
27163 | <li class='keycap tt'>.</li>
|
27164 | <li class='keycap' data-key=' '> </li>
|
27165 | <arrows/>
|
27166 | </ul>
|
27167 | </div>`,
|
27168 | 'functions': `
|
27169 | <div class='rows'>
|
27170 | <ul><li class='separator'></li>
|
27171 | <li class='fnbutton' data-insert='\\sin'></li>
|
27172 | <li class='fnbutton' data-insert='\\sin^{-1}'></li>
|
27173 | <li class='fnbutton' data-insert='\\ln'></li>
|
27174 | <li class='fnbutton' data-insert='\\exponentialE^{#?}'></li>
|
27175 | <li class='bigfnbutton' data-insert='\\operatorname{lcm}(#?)' data-latex='\\operatorname{lcm}()'></li>
|
27176 | <li class='bigfnbutton' data-insert='\\operatorname{ceil}(#?)' data-latex='\\operatorname{ceil}()'></li>
|
27177 | <li class='bigfnbutton' data-insert='\\lim_{n\\to\\infty}'></li>
|
27178 | <li class='bigfnbutton' data-insert='\\int'></li>
|
27179 | <li class='bigfnbutton' data-insert='\\operatorname{abs}(#?)' data-latex='\\operatorname{abs}()'></li>
|
27180 | </ul>
|
27181 | <ul><li class='separator'></li>
|
27182 | <li class='fnbutton' data-latex='\\cos'></li>
|
27183 | <li class='fnbutton' data-latex='\\cos^{-1}'></li>
|
27184 | <li class='fnbutton' data-latex='\\ln_{10}'></li>
|
27185 | <li class='fnbutton' data-latex='10^{#?}'></li>
|
27186 | <li class='bigfnbutton' data-latex='\\operatorname{gcd}(#?)' data-latex='\\operatorname{gcd}()'></li>
|
27187 | <li class='bigfnbutton' data-latex='\\operatorname{floor}(#?)' data-latex='\\operatorname{floor}()'></li>
|
27188 | <li class='bigfnbutton' data-latex='\\sum_{n\\mathop=0}^{\\infty}'></li>
|
27189 | <li class='bigfnbutton' data-latex='\\int_{0}^{\\infty}'></li>
|
27190 | <li class='bigfnbutton' data-latex='\\operatorname{sign}(#?)' data-latex='\\operatorname{sign}()'></li>
|
27191 | </ul>
|
27192 | <ul><li class='separator'></li>
|
27193 | <li class='fnbutton' data-latex='\\tan'></li>
|
27194 | <li class='fnbutton' data-latex='\\tan^{-1}'></li>
|
27195 | <li class='fnbutton' data-latex='\\log_{#?}'></li>
|
27196 | <li class='fnbutton' data-latex='\\sqrt[#?]{#0}'></li>
|
27197 | <li class='bigfnbutton' data-insert='#0 \\mod' data-latex='\\mod'></li>
|
27198 | <li class='bigfnbutton' data-insert='\\operatorname{round}(#?) ' data-latex='\\operatorname{round}()'></li>
|
27199 | <li class='bigfnbutton' data-insert='\\prod_{n\\mathop=0}^{\\infty}' data-latex='{\\scriptstyle \\prod_{n=0}^{\\infty}}'></li>
|
27200 | <li class='bigfnbutton' data-insert='\\frac{\\differentialD #0}{\\differentialD x}'></li>
|
27201 | <li class='action font-glyph bottom right' data-command='["performWithFeedback","deleteBackward"]'>⌫</li></ul>
|
27202 | <ul><li class='separator'></li>
|
27203 | <li class='fnbutton'>(</li>
|
27204 | <li class='fnbutton'>)</li>
|
27205 | <li class='fnbutton' data-insert='^{#?}' data-latex='x^{#?}'></li>
|
27206 | <li class='fnbutton' data-insert='_{#?}' data-latex='x_{#?}'></li>
|
27207 | <li class='keycap w20 ' data-key=' '> </li>
|
27208 | <arrows/>
|
27209 | </ul>
|
27210 | </div>`,
|
27211 | 'style': `
|
27212 | <div class='rows'>
|
27213 | <ul>
|
27214 | <li class='keycap' data-alt-keys='foreground-color' data-command='["applyStyle",{"color":"red"}]'><span style='border-radius: 50%;width:22px;height:22px; border: 3px solid #cc2428'></span></li>
|
27215 | <li class='keycap' data-alt-keys='background-color' data-command='["applyStyle",{"backgroundColor":"yellow"}]'><span style='border-radius: 50%;width:22px;height:22px; background:#fff590'></span></li>
|
27216 | <li class='separator w5'></li>
|
27217 | <li class='keycap' data-command='["applyStyle",{"size":"3"}]' data-latex='\\scriptsize\\text{small}'></li>
|
27218 | <li class='keycap' data-command='["applyStyle",{"size":"5"}]' data-latex='\\scriptsize\\text{normal}'></li>
|
27219 | <li class='keycap' data-command='["applyStyle",{"size":"9"}]' data-latex='\\huge\\text{big}'></li>
|
27220 | <li class='separator w5'></li>
|
27221 | <li class='keycap' data-latex='\\langle' data-command='["insert", "\\\\langle", {"smartFence":true}]'></li>
|
27222 | </ul>
|
27223 | <ul>
|
27224 | <li class='keycap' data-command='["applyStyle",{"series":"l"}]' data-latex='\\fontseries{l}\\text{Ab}'></li>
|
27225 | <li class='keycap' data-command='["applyStyle",{"series":"m"}]' data-latex='\\fontseries{m}\\text{Ab}'></li>
|
27226 | <li class='keycap' data-command='["applyStyle",{"series":"b"}]' data-latex='\\fontseries{b}\\text{Ab}'></li>
|
27227 | <li class='keycap' data-command='["applyStyle",{"series":"bx"}]' data-latex='\\fontseries{bx}\\text{Ab}'></li>
|
27228 | <li class='keycap' data-command='["applyStyle",{"series":"sb"}]' data-latex='\\fontseries{sb}\\text{Ab}'></li>
|
27229 | <li class='keycap' data-command='["applyStyle",{"series":"c"}]' data-latex='\\fontseries{c}\\text{Ab}'></li>
|
27230 | </ul>
|
27231 | <ul>
|
27232 | <li class='keycap' data-command='["applyStyle",{"shape":"up"}]' data-latex='\\textup{Ab}'></li>
|
27233 | <li class='keycap' data-command='["applyStyle",{"shape":"it"}]' data-latex='\\textit{Ab}'></li>
|
27234 | <li class='keycap' data-command='["applyStyle",{"shape":"sl"}]' data-latex='\\textsl{Ab}'></li>
|
27235 | <li class='keycap' data-command='["applyStyle",{"shape":"sc"}]' data-latex='\\textsc{Ab}'></li>
|
27236 | <li class='separator w5'></li>
|
27237 | <li class='keycap' data-insert='\\emph{#?} ' data-latex='\\text{\\emph{emph}}'></li>
|
27238 | </ul>
|
27239 | <ul>
|
27240 | <li class='keycap' data-command='["applyStyle",{"fontFamily":"cmr"}]' data-latex='\\textrm{Az}'></li>
|
27241 | <li class='keycap' data-command='["applyStyle",{"fontFamily":"cmtt"}]' data-latex='\\texttt{Az}'></li>
|
27242 | <li class='keycap' data-command='["applyStyle",{"fontFamily":"cmss"}]' data-latex='\\textsf{Az}'></li>
|
27243 |
|
27244 | <li class='keycap' data-command='["applyStyle",{"fontFamily":"bb"}]' data-latex='\\mathbb{AZ}'></li>
|
27245 | <li class='keycap' data-command='["applyStyle",{"fontFamily":"scr"}]' data-latex='\\mathscr{AZ}'></li>
|
27246 | <li class='keycap' data-command='["applyStyle",{"fontFamily":"cal"}]' data-latex='\\mathcal{A1}'></li>
|
27247 | <li class='keycap' data-command='["applyStyle",{"fontFamily":"frak"}]' data-latex='\\mathfrak{Az}'></li>
|
27248 | </ul>
|
27249 | </div>`,
|
27250 | };
|
27251 | function latexToMarkup(latex, arg) {
|
27252 |
|
27253 | latex = latex.replace(/(^|[^\\])#@/g, '$1#?');
|
27254 | const root = new Atom('root', { mode: 'math' });
|
27255 | root.body = typeset(parseLatex(latex, {
|
27256 | parseMode: 'math',
|
27257 | args: arg,
|
27258 | macros: getMacros(),
|
27259 | registers: getDefaultRegisters(),
|
27260 | }));
|
27261 | const box = coalesce(adjustInterAtomSpacing(new Box(root.render(new Context({
|
27262 | macros: getMacros(),
|
27263 | registers: getDefaultRegisters(),
|
27264 | smartFence: false,
|
27265 | }, {
|
27266 | fontSize: DEFAULT_FONT_SIZE,
|
27267 | }, 'displaystyle')), { classes: 'ML__base' })));
|
27268 | return makeStruts(box, { classes: 'ML__mathlive' }).toMarkup();
|
27269 | }
|
27270 |
|
27271 |
|
27272 |
|
27273 | function makeKeyboardToolbar(options, keyboardIDs, currentKeyboard) {
|
27274 | var _a, _b, _c;
|
27275 |
|
27276 | let result = "<div class='left'>";
|
27277 | const keyboardList = keyboardIDs.replace(/\s+/g, ' ').split(' ');
|
27278 | if (keyboardList.length > 1) {
|
27279 | const keyboards = {
|
27280 | ...KEYBOARDS,
|
27281 | ...((_a = options.customVirtualKeyboards) !== null && _a !== void 0 ? _a : {}),
|
27282 | };
|
27283 | for (const keyboard of keyboardList) {
|
27284 | if (!keyboards[keyboard]) {
|
27285 | console.error('Unknown virtual keyboard "', keyboard, '"');
|
27286 | break;
|
27287 | }
|
27288 | result += "<div class='";
|
27289 | if (keyboard === currentKeyboard) {
|
27290 | result += 'selected ';
|
27291 | }
|
27292 | else if (keyboards[keyboard].command) {
|
27293 | result += 'action ';
|
27294 | }
|
27295 | else {
|
27296 | result += 'layer-switch ';
|
27297 | }
|
27298 | result += ((_b = keyboards[keyboard].classes) !== null && _b !== void 0 ? _b : '') + "'";
|
27299 | if (keyboards[keyboard].tooltip) {
|
27300 | result +=
|
27301 | "data-ML__tooltip='" +
|
27302 | ((_c = localize(keyboards[keyboard].tooltip)) !== null && _c !== void 0 ? _c : keyboards[keyboard].tooltip) +
|
27303 | "' ";
|
27304 | result += "data-placement='top' data-delay='1s'";
|
27305 | }
|
27306 | if (keyboard !== currentKeyboard) {
|
27307 | if (typeof keyboards[keyboard].command === 'string') {
|
27308 | result += `data-command='"${keyboards[keyboard].command}"'`;
|
27309 | }
|
27310 | else if (Array.isArray(keyboards[keyboard].command)) {
|
27311 | result += `data-command='"${keyboards[keyboard].command.join('')}"'`;
|
27312 | }
|
27313 | if (keyboards[keyboard].layer) {
|
27314 | result += "data-layer='" + keyboards[keyboard].layer + "'";
|
27315 | }
|
27316 | }
|
27317 | result += '>' + keyboards[keyboard].label + '</div>';
|
27318 | }
|
27319 | }
|
27320 | result += '</div>';
|
27321 | const toolbarOptions = options.virtualKeyboardToolbar;
|
27322 | const availableActions = toolbarOptions === 'default' ? ['copyToClipboard', 'undo', 'redo'] : [];
|
27323 | const actionsMarkup = {
|
27324 | copyToClipboard: `
|
27325 | <div class='action'
|
27326 | data-command='"copyToClipboard"'
|
27327 | data-ML__tooltip='${localize('tooltip.copy to clipboard')}' data-placement='top' data-delay='1s'>
|
27328 | <svg><use xlink:href='#svg-copy' /></svg>
|
27329 | </div>
|
27330 | `,
|
27331 | undo: `
|
27332 | <div class='action disabled'
|
27333 | data-command='"undo"'
|
27334 | data-ML__tooltip='${localize('tooltip.undo')}' data-placement='top' data-delay='1s'>
|
27335 | <svg><use xlink:href='#svg-undo' /></svg>
|
27336 | </div>
|
27337 | `,
|
27338 | redo: `
|
27339 | <div class='action disabled'
|
27340 | data-command='"redo"'
|
27341 | data-ML__tooltip='${localize('tooltip.redo')}' data-placement='top' data-delay='1s'>
|
27342 | <svg><use xlink:href='#svg-redo' /></svg>
|
27343 | </div>
|
27344 | `,
|
27345 | };
|
27346 |
|
27347 | if (availableActions.length > 0) {
|
27348 | result += `
|
27349 | <div class='right'>
|
27350 | ${availableActions
|
27351 | .map((action) => actionsMarkup[action])
|
27352 | .join('')}
|
27353 | </div>
|
27354 | `;
|
27355 | }
|
27356 | return "<div class='keyboard-toolbar' role='toolbar'>" + result + '</div>';
|
27357 | }
|
27358 | function makeKeycap(keyboard, elementList, chainedCommand) {
|
27359 | var _a, _b;
|
27360 | for (const element of elementList) {
|
27361 | let html = undefined;
|
27362 |
|
27363 | if (element.getAttribute('data-latex')) {
|
27364 | html = latexToMarkup(element.getAttribute('data-latex').replace(/"/g, '"'), () => '\\placeholder{}');
|
27365 | }
|
27366 | else if (element.getAttribute('data-insert') &&
|
27367 | element.innerHTML === '') {
|
27368 | html = latexToMarkup(element.getAttribute('data-insert').replace(/"/g, '"'), () => '\\placeholder{}');
|
27369 | }
|
27370 | else if (element.getAttribute('data-content')) {
|
27371 | html = element.getAttribute('data-content').replace(/"/g, '"');
|
27372 | }
|
27373 | if (element.getAttribute('data-aside')) {
|
27374 | html =
|
27375 | (html !== null && html !== void 0 ? html : '') +
|
27376 | '<aside>' +
|
27377 | element.getAttribute('data-aside').replace(/"/g, '"') +
|
27378 | '</aside>';
|
27379 | }
|
27380 | if (html !== undefined) {
|
27381 | element.innerHTML = keyboard.options.createHTML(html);
|
27382 | }
|
27383 | if (element.getAttribute('data-classes')) {
|
27384 | element.classList.add(element.getAttribute('data-classes'));
|
27385 | }
|
27386 | const key = (_a = element.getAttribute('data-insert')) === null || _a === void 0 ? void 0 : _a.replace(/"/g, '"');
|
27387 | if (key && SHIFTED_KEYS[key]) {
|
27388 | element.dataset.shifted = SHIFTED_KEYS[key][0];
|
27389 | element.dataset.shiftedCommand = JSON.stringify([
|
27390 | 'insertAndUnshiftKeyboardLayer',
|
27391 | SHIFTED_KEYS[key][1],
|
27392 | ]);
|
27393 | }
|
27394 |
|
27395 | let selector;
|
27396 | if (element.getAttribute('data-command')) {
|
27397 | selector = JSON.parse(element.getAttribute('data-command'));
|
27398 | }
|
27399 | else if (element.getAttribute('data-insert')) {
|
27400 | selector = [
|
27401 | 'insert',
|
27402 | element.getAttribute('data-insert'),
|
27403 | {
|
27404 | focus: true,
|
27405 | feedback: true,
|
27406 | scrollIntoView: true,
|
27407 | mode: 'math',
|
27408 | format: 'latex',
|
27409 | resetStyle: true,
|
27410 | },
|
27411 | ];
|
27412 | }
|
27413 | else if (element.getAttribute('data-latex')) {
|
27414 | selector = [
|
27415 | 'insert',
|
27416 | element.getAttribute('data-latex'),
|
27417 | {
|
27418 | focus: true,
|
27419 | feedback: true,
|
27420 | scrollIntoView: true,
|
27421 | mode: 'math',
|
27422 | format: 'latex',
|
27423 | resetStyle: true,
|
27424 | },
|
27425 | ];
|
27426 | }
|
27427 | else {
|
27428 | selector = [
|
27429 | 'typedText',
|
27430 | (_b = element.getAttribute('data-key')) !== null && _b !== void 0 ? _b : element.textContent,
|
27431 | { focus: true, feedback: true, simulateKeystroke: true },
|
27432 | ];
|
27433 | }
|
27434 | if (chainedCommand) {
|
27435 | selector = [chainedCommand, selector];
|
27436 | }
|
27437 | let handlers = selector;
|
27438 | const altKeysetId = element.getAttribute('data-alt-keys');
|
27439 | if (altKeysetId) {
|
27440 | const altKeys = ALT_KEYS[altKeysetId];
|
27441 | if (altKeys) {
|
27442 | handlers = {
|
27443 | default: selector,
|
27444 | pressAndHoldStart: ['showAlternateKeys', altKeysetId],
|
27445 | pressAndHoldEnd: 'hideAlternateKeys',
|
27446 | };
|
27447 |
|
27448 |
|
27449 | }
|
27450 | }
|
27451 | attachButtonHandlers((command) => keyboard.executeCommand(command), element, handlers);
|
27452 | }
|
27453 | }
|
27454 |
|
27455 |
|
27456 |
|
27457 | function expandLayerMarkup(options, layer) {
|
27458 | var _a, _b, _c;
|
27459 | const ROWS = {
|
27460 |
|
27461 |
|
27462 |
|
27463 |
|
27464 |
|
27465 | qwerty: {
|
27466 | 'lower-1': 'qwertyuiop',
|
27467 | 'lower-2': ' asdfghjkl ',
|
27468 | 'lower-3': '^zxcvbnm~',
|
27469 | 'upper-1': 'QWERTYUIOP',
|
27470 | 'upper-2': ' ASDFGHJKL ',
|
27471 | 'upper-3': '^ZXCVBNM~',
|
27472 | 'numpad-1': '789/',
|
27473 | 'numpad-2': '456*',
|
27474 | 'numpad-3': '123-',
|
27475 | 'numpad-4': '0.=+',
|
27476 | },
|
27477 | azerty: {
|
27478 | 'lower-1': 'azertyuiop',
|
27479 | 'lower-2': 'qsdfghjklm',
|
27480 | 'lower-3': '^ wxcvbn ~',
|
27481 | 'upper-1': 'AZERTYUIOP',
|
27482 | 'upper-2': 'QSDFGHJKLM',
|
27483 | 'upper-3': '^ WXCVBN ~',
|
27484 | },
|
27485 | qwertz: {
|
27486 | 'lower-1': 'qwertzuiop',
|
27487 | 'lower-2': ' asdfghjkl ',
|
27488 | 'lower-3': '^yxcvbnm~',
|
27489 | 'upper-1': 'QWERTZUIOP',
|
27490 | 'upper-2': ' ASDFGHJKL',
|
27491 | 'upper-3': '^YXCVBNM~',
|
27492 | },
|
27493 | dvorak: {
|
27494 | 'lower-1': '^ pyfgcrl ',
|
27495 | 'lower-2': 'aoeuidhtns',
|
27496 | 'lower-3': 'qjkxbmwvz~',
|
27497 | 'upper-1': '^ PYFGCRL ',
|
27498 | 'upper-2': 'AOEUIDHTNS',
|
27499 | 'upper-3': 'QJKXBMWVZ~',
|
27500 | },
|
27501 | colemak: {
|
27502 | 'lower-1': ' qwfpgjluy ',
|
27503 | 'lower-2': 'arstdhneio',
|
27504 | 'lower-3': '^zxcvbkm~',
|
27505 | 'upper-1': ' QWFPGNLUY ',
|
27506 | 'upper-2': 'ARSTDHNEIO',
|
27507 | 'upper-3': '^ZXCVBKM~',
|
27508 | },
|
27509 | };
|
27510 |
|
27511 |
|
27512 | let layoutName = options.virtualKeyboardLayout;
|
27513 | if (layoutName === 'auto') {
|
27514 | const activeLayout = getActiveKeyboardLayout();
|
27515 | if (activeLayout) {
|
27516 | layoutName = activeLayout.virtualLayout;
|
27517 | }
|
27518 | if (!layoutName || layoutName === 'auto') {
|
27519 | layoutName =
|
27520 | (_a = {
|
27521 | fr: 'azerty',
|
27522 | be: 'azerty',
|
27523 | al: 'qwertz',
|
27524 | ba: 'qwertz',
|
27525 | cz: 'qwertz',
|
27526 | de: 'qwertz',
|
27527 | hu: 'qwertz',
|
27528 | sk: 'qwertz',
|
27529 | ch: 'qwertz',
|
27530 | }[l10n.locale.slice(0, 2)]) !== null && _a !== void 0 ? _a : 'qwerty';
|
27531 | }
|
27532 | }
|
27533 | const layout = (_b = ROWS[layoutName]) !== null && _b !== void 0 ? _b : ROWS.qwerty;
|
27534 | let result = layer;
|
27535 | let row;
|
27536 | result = result.replace(/<arrows\/>/g, `
|
27537 | <li class='action' data-command='["performWithFeedback","moveToPreviousChar"]'
|
27538 | data-shifted='<svg class="svg-glyph"><use xlink:href="#svg-angle-double-left" /></svg>'
|
27539 | data-shifted-command='["performWithFeedback","extendToPreviousChar"]'>
|
27540 | <svg class="svg-glyph"><use xlink:href='#svg-arrow-left' /></svg>
|
27541 | </li>
|
27542 | <li class='action' data-command='["performWithFeedback","moveToNextChar"]'
|
27543 | data-shifted='<svg class="svg-glyph"><use xlink:href="#svg-angle-double-right" /></svg>'
|
27544 | data-shifted-command='["performWithFeedback","extendToNextChar"]'>
|
27545 | <svg class="svg-glyph"><use xlink:href='#svg-arrow-right' /></svg>
|
27546 | </li>
|
27547 | <li class='action' data-command='["performWithFeedback","moveToNextPlaceholder"]'>
|
27548 | <svg class="svg-glyph"><use xlink:href='#svg-tab' /></svg></li>`);
|
27549 | let m = result.match(/(<row\s+)(.*)((?:<\/row|\/)>)/);
|
27550 | while (m) {
|
27551 | row = '';
|
27552 | const attributesArray = m[2].match(/[a-zA-Z][a-zA-Z\d-]*=(['"])(.*?)\1/g);
|
27553 | const attributes = {};
|
27554 | if (attributesArray) {
|
27555 | for (const attribute of attributesArray) {
|
27556 | const m2 = attribute.match(/([a-zA-Z][a-zA-Z\d-]*)=(['"])(.*?)\2/);
|
27557 | if (m2) {
|
27558 | attributes[m2[1]] = m2[3];
|
27559 | }
|
27560 | }
|
27561 | }
|
27562 | let keys = layout[attributes.name];
|
27563 | if (!keys)
|
27564 | keys = ROWS.qwerty[attributes.name];
|
27565 | if (!keys) {
|
27566 | console.warn('Unknown roman keyboard row:', attributes.name);
|
27567 | }
|
27568 | else {
|
27569 | for (const c of keys) {
|
27570 | let cls = (_c = attributes.class) !== null && _c !== void 0 ? _c : '';
|
27571 | if (cls)
|
27572 | cls = ` ${cls}`;
|
27573 | if (c === '~') {
|
27574 | row += `<li class='action font-glyph bottom right `;
|
27575 | row +=
|
27576 | keys.length - (keys.match(/ /g) || []).length / 2 === 10
|
27577 | ? 'w10'
|
27578 | : 'w15';
|
27579 | row += `' data-shifted='<span class="warning"><svg class="svg-glyph"><use xlink:href="#svg-trash" /></svg></span>'
|
27580 | data-shifted-command='"deleteAll"'
|
27581 | data-alt-keys='delete' data-command='["performWithFeedback","deleteBackward"]'
|
27582 | >⌫</li>`;
|
27583 | }
|
27584 | else if (c === ' ') {
|
27585 |
|
27586 | row += "<li class='separator w5'></li>";
|
27587 | }
|
27588 | else if (c === '^') {
|
27589 |
|
27590 | row +=
|
27591 | `<li class='shift modifier font-glyph bottom left w15 layer-switch' data-layer='` +
|
27592 | attributes['shift-layer'] +
|
27593 | `'>⇧</li>`;
|
27594 | }
|
27595 | else if (c === '/') {
|
27596 | row +=
|
27597 | "<li class='keycap" +
|
27598 | cls +
|
27599 | "' data-alt-keys='/' data-insert='\\frac{#@}{#?}'>÷</li>";
|
27600 | }
|
27601 | else if (c === '*') {
|
27602 | row +=
|
27603 | "<li class='keycap" +
|
27604 | cls +
|
27605 | "' data-alt-keys='*' data-insert='\\times '>×</li>";
|
27606 | }
|
27607 | else if (c === '-') {
|
27608 | row +=
|
27609 | "<li class='keycap" +
|
27610 | cls +
|
27611 | "' data-alt-keys='-' data-key='-' data-alt-keys='-'>−</li>";
|
27612 | }
|
27613 | else if (cls.includes('tt')) {
|
27614 | row +=
|
27615 | `<li class='keycap${cls}' data-alt-keys='${c}' ` +
|
27616 | `data-command='["typedText","${c}",{"mode":"command", "focus":true, "feedback":true}]'` +
|
27617 | `>${c}</li>`;
|
27618 | }
|
27619 | else {
|
27620 | row +=
|
27621 | "<li class='keycap" +
|
27622 | cls +
|
27623 | "' data-alt-keys='" +
|
27624 | c +
|
27625 | "'>" +
|
27626 | c +
|
27627 | '</li>';
|
27628 | }
|
27629 | }
|
27630 | }
|
27631 | result = result.replace(new RegExp(m[1] + m[2] + m[3]), row);
|
27632 | m = result.match(/(<row\s+)(.*)((?:<\/row|\/)>)/);
|
27633 | }
|
27634 | return result;
|
27635 | }
|
27636 |
|
27637 |
|
27638 |
|
27639 |
|
27640 | function makeKeyboardElement(keyboard, theme) {
|
27641 | var _a, _b, _c, _d;
|
27642 | throwIfNotInBrowser();
|
27643 | const svgIcons = `<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
|
27644 |
|
27645 | <symbol id="svg-command" viewBox="0 0 640 512">
|
27646 | <path d="M34.495 36.465l211.051 211.05c4.686 4.686 4.686 12.284 0 16.971L34.495 475.535c-4.686 4.686-12.284 4.686-16.97 0l-7.071-7.07c-4.686-4.686-4.686-12.284 0-16.971L205.947 256 10.454 60.506c-4.686-4.686-4.686-12.284 0-16.971l7.071-7.07c4.686-4.687 12.284-4.687 16.97 0zM640 468v-10c0-6.627-5.373-12-12-12H300c-6.627 0-12 5.373-12 12v10c0 6.627 5.373 12 12 12h328c6.627 0 12-5.373 12-12z"/>
|
27647 | </symbol>
|
27648 |
|
27649 | <symbol id="svg-undo" viewBox="0 0 512 512">
|
27650 | <path d="M20 8h10c6.627 0 12 5.373 12 12v110.625C85.196 57.047 165.239 7.715 256.793 8.001 393.18 8.428 504.213 120.009 504 256.396 503.786 393.181 392.834 504 256 504c-63.926 0-122.202-24.187-166.178-63.908-5.113-4.618-5.354-12.561-.482-17.433l7.069-7.069c4.503-4.503 11.749-4.714 16.482-.454C150.782 449.238 200.935 470 256 470c117.744 0 214-95.331 214-214 0-117.744-95.331-214-214-214-82.862 0-154.737 47.077-190.289 116H180c6.627 0 12 5.373 12 12v10c0 6.627-5.373 12-12 12H20c-6.627 0-12-5.373-12-12V20c0-6.627 5.373-12 12-12z"/>
|
27651 | </symbol>
|
27652 | <symbol id="svg-redo" viewBox="0 0 512 512">
|
27653 | <path d="M492 8h-10c-6.627 0-12 5.373-12 12v110.625C426.804 57.047 346.761 7.715 255.207 8.001 118.82 8.428 7.787 120.009 8 256.396 8.214 393.181 119.166 504 256 504c63.926 0 122.202-24.187 166.178-63.908 5.113-4.618 5.354-12.561.482-17.433l-7.069-7.069c-4.503-4.503-11.749-4.714-16.482-.454C361.218 449.238 311.065 470 256 470c-117.744 0-214-95.331-214-214 0-117.744 95.331-214 214-214 82.862 0 154.737 47.077 190.289 116H332c-6.627 0-12 5.373-12 12v10c0 6.627 5.373 12 12 12h160c6.627 0 12-5.373 12-12V20c0-6.627-5.373-12-12-12z"/>
|
27654 | </symbol>
|
27655 | <symbol id="svg-arrow-left" viewBox="0 0 192 512">
|
27656 | <path d="M25.1 247.5l117.8-116c4.7-4.7 12.3-4.7 17 0l7.1 7.1c4.7 4.7 4.7 12.3 0 17L64.7 256l102.2 100.4c4.7 4.7 4.7 12.3 0 17l-7.1 7.1c-4.7 4.7-12.3 4.7-17 0L25 264.5c-4.6-4.7-4.6-12.3.1-17z"/>
|
27657 | </symbol>
|
27658 | <symbol id="svg-arrow-right" viewBox="0 0 192 512">
|
27659 | <path d="M166.9 264.5l-117.8 116c-4.7 4.7-12.3 4.7-17 0l-7.1-7.1c-4.7-4.7-4.7-12.3 0-17L127.3 256 25.1 155.6c-4.7-4.7-4.7-12.3 0-17l7.1-7.1c4.7-4.7 12.3-4.7 17 0l117.8 116c4.6 4.7 4.6 12.3-.1 17z"/>
|
27660 | </symbol>
|
27661 | <symbol id="svg-tab" viewBox="0 0 448 512">
|
27662 | <path d="M32 217.1c0-8.8 7.2-16 16-16h144v-93.9c0-7.1 8.6-10.7 13.6-5.7l143.5 143.1c6.3 6.3 6.3 16.4 0 22.7L205.6 410.4c-5 5-13.6 1.5-13.6-5.7v-93.9H48c-8.8 0-16-7.2-16-16v-77.7m-32 0v77.7c0 26.5 21.5 48 48 48h112v61.9c0 35.5 43 53.5 68.2 28.3l143.6-143c18.8-18.8 18.8-49.2 0-68L228.2 78.9c-25.1-25.1-68.2-7.3-68.2 28.3v61.9H48c-26.5 0-48 21.6-48 48zM436 64h-8c-6.6 0-12 5.4-12 12v360c0 6.6 5.4 12 12 12h8c6.6 0 12-5.4 12-12V76c0-6.6-5.4-12-12-12z"/>
|
27663 | </symbol>
|
27664 | <symbol id="svg-copy" viewBox="0 0 448 512">
|
27665 | <path d="M433.941 65.941l-51.882-51.882A48 48 0 0 0 348.118 0H176c-26.51 0-48 21.49-48 48v48H48c-26.51 0-48 21.49-48 48v320c0 26.51 21.49 48 48 48h224c26.51 0 48-21.49 48-48v-48h80c26.51 0 48-21.49 48-48V99.882a48 48 0 0 0-14.059-33.941zM352 32.491a15.88 15.88 0 0 1 7.431 4.195l51.882 51.883A15.885 15.885 0 0 1 415.508 96H352V32.491zM288 464c0 8.822-7.178 16-16 16H48c-8.822 0-16-7.178-16-16V144c0-8.822 7.178-16 16-16h80v240c0 26.51 21.49 48 48 48h112v48zm128-96c0 8.822-7.178 16-16 16H176c-8.822 0-16-7.178-16-16V48c0-8.822 7.178-16 16-16h144v72c0 13.2 10.8 24 24 24h72v240z"/>
|
27666 | </symbol>
|
27667 | <symbol id="svg-angle-double-right" viewBox="0 0 320 512">
|
27668 | <path d="M166.9 264.5l-117.8 116c-4.7 4.7-12.3 4.7-17 0l-7.1-7.1c-4.7-4.7-4.7-12.3 0-17L127.3 256 25.1 155.6c-4.7-4.7-4.7-12.3 0-17l7.1-7.1c4.7-4.7 12.3-4.7 17 0l117.8 116c4.6 4.7 4.6 12.3-.1 17zm128-17l-117.8-116c-4.7-4.7-12.3-4.7-17 0l-7.1 7.1c-4.7 4.7-4.7 12.3 0 17L255.3 256 153.1 356.4c-4.7 4.7-4.7 12.3 0 17l7.1 7.1c4.7 4.7 12.3 4.7 17 0l117.8-116c4.6-4.7 4.6-12.3-.1-17z"/>
|
27669 | </symbol>
|
27670 | <symbol id="svg-angle-double-left" viewBox="0 0 320 512">
|
27671 | <path d="M153.1 247.5l117.8-116c4.7-4.7 12.3-4.7 17 0l7.1 7.1c4.7 4.7 4.7 12.3 0 17L192.7 256l102.2 100.4c4.7 4.7 4.7 12.3 0 17l-7.1 7.1c-4.7 4.7-12.3 4.7-17 0L153 264.5c-4.6-4.7-4.6-12.3.1-17zm-128 17l117.8 116c4.7 4.7 12.3 4.7 17 0l7.1-7.1c4.7-4.7 4.7-12.3 0-17L64.7 256l102.2-100.4c4.7-4.7 4.7-12.3 0-17l-7.1-7.1c-4.7-4.7-12.3-4.7-17 0L25 247.5c-4.6 4.7-4.6 12.3.1 17z"/>
|
27672 | </symbol>
|
27673 | <symbol id="svg-trash" viewBox="0 0 448 512">
|
27674 | <path d="M336 64l-33.6-44.8C293.3 7.1 279.1 0 264 0h-80c-15.1 0-29.3 7.1-38.4 19.2L112 64H24C10.7 64 0 74.7 0 88v2c0 3.3 2.7 6 6 6h26v368c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V96h26c3.3 0 6-2.7 6-6v-2c0-13.3-10.7-24-24-24h-88zM184 32h80c5 0 9.8 2.4 12.8 6.4L296 64H152l19.2-25.6c3-4 7.8-6.4 12.8-6.4zm200 432c0 8.8-7.2 16-16 16H80c-8.8 0-16-7.2-16-16V96h320v368zm-176-44V156c0-6.6 5.4-12 12-12h8c6.6 0 12 5.4 12 12v264c0 6.6-5.4 12-12 12h-8c-6.6 0-12-5.4-12-12zm-80 0V156c0-6.6 5.4-12 12-12h8c6.6 0 12 5.4 12 12v264c0 6.6-5.4 12-12 12h-8c-6.6 0-12-5.4-12-12zm160 0V156c0-6.6 5.4-12 12-12h8c6.6 0 12 5.4 12 12v264c0 6.6-5.4 12-12 12h-8c-6.6 0-12-5.4-12-12z"/>
|
27675 | </symbol>
|
27676 | </svg>
|
27677 | `;
|
27678 |
|
27679 |
|
27680 |
|
27681 |
|
27682 |
|
27683 |
|
27684 |
|
27685 |
|
27686 |
|
27687 |
|
27688 |
|
27689 |
|
27690 | let markup = svgIcons;
|
27691 | keyboard.create();
|
27692 |
|
27693 | ALT_KEYS_BASE['foreground-color'] = [];
|
27694 | for (const color of Object.keys(FOREGROUND_COLORS)) {
|
27695 | ALT_KEYS_BASE['foreground-color'].push({
|
27696 | class: 'small-button',
|
27697 | content: '<span style="border-radius:50%;width:32px;height:32px; box-sizing: border-box; border: 3px solid ' +
|
27698 | FOREGROUND_COLORS[color] +
|
27699 | '"></span>',
|
27700 | command: ['applyStyle', { color }],
|
27701 | });
|
27702 | }
|
27703 | ALT_KEYS_BASE['background-color'] = [];
|
27704 | for (const color of Object.keys(BACKGROUND_COLORS)) {
|
27705 | ALT_KEYS_BASE['background-color'].push({
|
27706 | class: 'small-button',
|
27707 | content: '<span style="border-radius:50%;width:32px;height:32px; background:' +
|
27708 | BACKGROUND_COLORS[color] +
|
27709 | '"></span>',
|
27710 | command: ['applyStyle', { backgroundColor: color }],
|
27711 | });
|
27712 | }
|
27713 | ALT_KEYS = { ...ALT_KEYS_BASE };
|
27714 | for (const key of Object.keys(ALT_KEYS)) {
|
27715 | ALT_KEYS[key] = ALT_KEYS[key].slice();
|
27716 | }
|
27717 | const UPPER_ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
27718 | const LOWER_ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
27719 | const DIGITS = '0123456789';
|
27720 |
|
27721 | for (let i = 0; i < 26; i++) {
|
27722 | const key = UPPER_ALPHA[i];
|
27723 | if (!ALT_KEYS[key])
|
27724 | ALT_KEYS[key] = [];
|
27725 | ALT_KEYS[key].unshift({
|
27726 | latex: '\\mathbb{' + key + '}',
|
27727 | aside: 'blackboard',
|
27728 | insert: '\\mathbb{' + key + '}',
|
27729 | });
|
27730 | ALT_KEYS[key].unshift({
|
27731 | latex: '\\mathbf{' + key + '}',
|
27732 | aside: 'bold',
|
27733 | insert: '\\mathbf{' + key + '}',
|
27734 | });
|
27735 | ALT_KEYS[key].unshift({
|
27736 | latex: '\\mathsf{' + key + '}',
|
27737 | aside: 'sans',
|
27738 | insert: '\\mathsf{' + key + '}',
|
27739 | });
|
27740 | ALT_KEYS[key].unshift({
|
27741 | latex: '\\mathtt{' + key + '}',
|
27742 | aside: 'monospace',
|
27743 | insert: '\\mathtt{' + key + '}',
|
27744 | });
|
27745 | ALT_KEYS[key].unshift({
|
27746 | latex: '\\mathcal{' + key + '}',
|
27747 | aside: 'calligraphy',
|
27748 | insert: '\\mathcal{' + key + '}',
|
27749 | });
|
27750 | ALT_KEYS[key].unshift({
|
27751 | latex: '\\mathfrak{' + key + '}',
|
27752 | aside: 'fraktur',
|
27753 | insert: '\\mathfrak{' + key + '}',
|
27754 | });
|
27755 | }
|
27756 |
|
27757 | for (let i = 0; i <= 26; i++) {
|
27758 | const key = LOWER_ALPHA[i];
|
27759 | if (!ALT_KEYS[key])
|
27760 | ALT_KEYS[key] = [];
|
27761 | ALT_KEYS[key].unshift({
|
27762 | latex: '\\mathsf{' + key + '}',
|
27763 | aside: 'sans',
|
27764 | insert: '\\mathsf{' + key + '}',
|
27765 | });
|
27766 | ALT_KEYS[key].unshift({
|
27767 | latex: '\\mathbf{' + key + '}',
|
27768 | aside: 'bold',
|
27769 | insert: '\\mathbf{' + key + '}',
|
27770 | });
|
27771 | ALT_KEYS[key].unshift({
|
27772 | latex: '\\mathtt{' + key + '}',
|
27773 | aside: 'monospace',
|
27774 | insert: '\\mathtt{' + key + '}',
|
27775 | });
|
27776 | ALT_KEYS[key].unshift({
|
27777 | latex: '\\mathfrak{' + key + '}',
|
27778 | aside: 'fraktur',
|
27779 | insert: '\\mathfrak{' + key + '}',
|
27780 | });
|
27781 | }
|
27782 | for (let i = 0; i < 10; i++) {
|
27783 | const key = DIGITS[i];
|
27784 | if (!ALT_KEYS[key])
|
27785 | ALT_KEYS[key] = [];
|
27786 |
|
27787 |
|
27788 |
|
27789 |
|
27790 |
|
27791 | ALT_KEYS[key].unshift({
|
27792 | latex: '\\mathbf{' + key + '}',
|
27793 | aside: 'bold',
|
27794 | insert: '\\mathbf{' + key + '}',
|
27795 | });
|
27796 | ALT_KEYS[key].unshift({
|
27797 | latex: '\\mathsf{' + key + '}',
|
27798 | aside: 'sans',
|
27799 | insert: '\\mathsf{' + key + '}',
|
27800 | });
|
27801 | ALT_KEYS[key].unshift({
|
27802 | latex: '\\mathtt{' + key + '}',
|
27803 | aside: 'monospace',
|
27804 | insert: '\\mathtt{' + key + '}',
|
27805 | });
|
27806 | ALT_KEYS[key].unshift({
|
27807 | latex: '\\mathcal{' + key + '}',
|
27808 | aside: 'script',
|
27809 | insert: '\\mathcal{' + key + '}',
|
27810 | });
|
27811 | ALT_KEYS[key].unshift({
|
27812 | latex: '\\mathfrak{' + key + '}',
|
27813 | aside: 'fraktur',
|
27814 | insert: '\\mathfrak{' + key + '}',
|
27815 | });
|
27816 | }
|
27817 | let keyboardIDs = keyboard.options.virtualKeyboards;
|
27818 | if (!keyboardIDs) {
|
27819 | keyboardIDs = 'all';
|
27820 | }
|
27821 | keyboardIDs = keyboardIDs.replace(/\ball\b/i, 'numeric functions symbols roman greek');
|
27822 | const layers = {
|
27823 | ...LAYERS,
|
27824 | ...((_a = keyboard.options.customVirtualKeyboardLayers) !== null && _a !== void 0 ? _a : {}),
|
27825 | };
|
27826 | const keyboards = {
|
27827 | ...KEYBOARDS,
|
27828 | ...((_b = keyboard.options.customVirtualKeyboards) !== null && _b !== void 0 ? _b : {}),
|
27829 | };
|
27830 | const keyboardList = keyboardIDs.replace(/\s+/g, ' ').split(' ');
|
27831 | for (const keyboardName of keyboardList) {
|
27832 | if (!keyboards[keyboardName]) {
|
27833 | console.error('Unknown virtual keyboard "' + keyboardName + '"');
|
27834 | continue;
|
27835 | }
|
27836 |
|
27837 |
|
27838 | let keyboardLayers = (_c = keyboards[keyboardName].layers) !== null && _c !== void 0 ? _c : [];
|
27839 | if (keyboards[keyboardName].layer) {
|
27840 | keyboardLayers.push(keyboards[keyboardName].layer);
|
27841 | }
|
27842 | keyboardLayers = [...new Set(keyboardLayers)];
|
27843 | for (const layerName of keyboardLayers) {
|
27844 | if (!layers[layerName]) {
|
27845 | console.error('Unknown virtual keyboard layer: "', layerName, '"');
|
27846 | break;
|
27847 | }
|
27848 | if (typeof layers[layerName] === 'object') {
|
27849 | const layer = layers[layerName];
|
27850 |
|
27851 | let layerMarkup = '';
|
27852 | if (layer.styles) {
|
27853 | layerMarkup += `<style>${layer.styles}</style>`;
|
27854 | }
|
27855 | if (layer.backdrop) {
|
27856 | layerMarkup += `<div class='${layer.backdrop}'>`;
|
27857 | }
|
27858 | if (layer.container) {
|
27859 | layerMarkup += `<div class='${layer.container}'>`;
|
27860 | }
|
27861 | if (layer.rows) {
|
27862 | layerMarkup += `<div class='rows'>`;
|
27863 | for (const row of layer.rows) {
|
27864 | layerMarkup += `<ul>`;
|
27865 | for (const keycap of row) {
|
27866 | layerMarkup += `<li`;
|
27867 | if (keycap.class && /separator/.test(keycap.class)) {
|
27868 | layerMarkup += ` class="${keycap.class}"`;
|
27869 | }
|
27870 | else if (keycap.class) {
|
27871 | layerMarkup += ` class="keycap ${keycap.class}"`;
|
27872 | }
|
27873 | else {
|
27874 | layerMarkup += ` class="keycap"`;
|
27875 | }
|
27876 | if (keycap.key) {
|
27877 | layerMarkup += ` data-key="${keycap.key}"`;
|
27878 | }
|
27879 | if (keycap.command) {
|
27880 | if (typeof keycap.command === 'string') {
|
27881 | layerMarkup += ` data-command='"${keycap.command}"'`;
|
27882 | }
|
27883 | else {
|
27884 | layerMarkup += ` data-command='`;
|
27885 | layerMarkup += JSON.stringify(keycap.command);
|
27886 | layerMarkup += `'`;
|
27887 | }
|
27888 | }
|
27889 | if (keycap.insert) {
|
27890 | layerMarkup += ` data-insert="${keycap.insert}"`;
|
27891 | }
|
27892 | if (keycap.latex) {
|
27893 | layerMarkup += ` data-latex="${keycap.latex}"`;
|
27894 | }
|
27895 | if (keycap.aside) {
|
27896 | layerMarkup += ` data-aside="${keycap.aside}"`;
|
27897 | }
|
27898 | if (keycap.variants) {
|
27899 | const keysetId = Date.now().toString(36).slice(-2) +
|
27900 | Math.floor(Math.random() * 0x186a0).toString(36);
|
27901 | ALT_KEYS[keysetId] = keycap.variants;
|
27902 | layerMarkup += ` data-alt-keys="${keysetId}"`;
|
27903 | }
|
27904 | if (keycap.shifted) {
|
27905 | layerMarkup += ` data-shifted="${keycap.shifted}"`;
|
27906 | }
|
27907 | if (keycap.shiftedCommand) {
|
27908 | layerMarkup += ` data-shifted-command="${keycap.shiftedCommand}"`;
|
27909 | }
|
27910 | layerMarkup += `>${keycap.label ? keycap.label : ''}</li>`;
|
27911 | }
|
27912 | layerMarkup += `</ul>`;
|
27913 | }
|
27914 | layerMarkup += `</div>`;
|
27915 | }
|
27916 | if (layer.container) {
|
27917 | layerMarkup += '</div>';
|
27918 | }
|
27919 | if (layer.backdrop) {
|
27920 | layerMarkup += '</div>';
|
27921 | }
|
27922 | layers[layerName] = layerMarkup;
|
27923 | }
|
27924 | markup += `<div tabindex="-1" class='keyboard-layer' data-layer='${layerName}'>`;
|
27925 | markup += makeKeyboardToolbar(keyboard.options, keyboardIDs, keyboardName);
|
27926 | const layerMarkup = layers[layerName];
|
27927 |
|
27928 |
|
27929 | markup += expandLayerMarkup(keyboard.options, layerMarkup);
|
27930 | markup += '</div>';
|
27931 | }
|
27932 | }
|
27933 | const result = document.createElement('div');
|
27934 | result.className = 'ML__keyboard';
|
27935 | if (theme) {
|
27936 | result.classList.add(theme);
|
27937 | }
|
27938 | else if (keyboard.options.virtualKeyboardTheme) {
|
27939 | result.classList.add(keyboard.options.virtualKeyboardTheme);
|
27940 | }
|
27941 |
|
27942 |
|
27943 | const plate = document.createElement('div');
|
27944 | plate.className = 'ML__keyboard--plate';
|
27945 | plate.innerHTML = keyboard.options.createHTML(markup);
|
27946 | result.appendChild(plate);
|
27947 |
|
27948 | const keycaps = result.querySelectorAll('.keycap, .action, .fnbutton, .bigfnbutton');
|
27949 | for (const keycap of keycaps) {
|
27950 | keycap.id =
|
27951 | 'ML__k' +
|
27952 | Date.now().toString(36).slice(-2) +
|
27953 | Math.floor(Math.random() * 0x186a0).toString(36);
|
27954 | }
|
27955 | makeKeycap(keyboard, [...keycaps]);
|
27956 | const elementList = result.querySelectorAll('.layer-switch');
|
27957 | for (const element of elementList) {
|
27958 | if (element.classList.contains('shift')) {
|
27959 |
|
27960 | attachButtonHandlers((command) => keyboard.executeCommand(command), element, {
|
27961 |
|
27962 |
|
27963 | pressed: 'shiftKeyboardLayer',
|
27964 |
|
27965 | default: ['switchKeyboardLayer', element.getAttribute('data-layer')],
|
27966 |
|
27967 |
|
27968 | pressAndHoldEnd: 'unshiftKeyboardLayer',
|
27969 | });
|
27970 | }
|
27971 | else {
|
27972 |
|
27973 | attachButtonHandlers((command) => keyboard.executeCommand(command), element, {
|
27974 | default: ['switchKeyboardLayer', element.getAttribute('data-layer')],
|
27975 | });
|
27976 | }
|
27977 | }
|
27978 |
|
27979 | const layerElements = result.querySelectorAll('.keyboard-layer');
|
27980 | for (const x of layerElements) {
|
27981 | x.addEventListener('mousedown', (evt) => {
|
27982 | evt.preventDefault();
|
27983 | evt.stopPropagation();
|
27984 | });
|
27985 | x.addEventListener('touchstart', (evt) => {
|
27986 | evt.preventDefault();
|
27987 | evt.stopPropagation();
|
27988 | }, { passive: false });
|
27989 | }
|
27990 | console.assert(layerElements.length > 0, 'No virtual keyboards available');
|
27991 | (_d = layerElements[0]) === null || _d === void 0 ? void 0 : _d.classList.add('is-visible');
|
27992 | return result;
|
27993 | }
|
27994 |
|
27995 |
|
27996 |
|
27997 |
|
27998 |
|
27999 | function unshiftKeyboardLayer(keyboard) {
|
28000 | hideAlternateKeys();
|
28001 | const keycaps = keyboard.element.querySelectorAll('div.keyboard-layer.is-visible .rows .keycap, div.keyboard-layer.is-visible .rows .action');
|
28002 | if (keycaps) {
|
28003 | for (const keycap of keycaps) {
|
28004 | const content = keycap.getAttribute('data-unshifted-content');
|
28005 | if (content) {
|
28006 | keycap.innerHTML = keyboard.options.createHTML(content);
|
28007 | }
|
28008 | const command = keycap.getAttribute('data-unshifted-command');
|
28009 | if (command) {
|
28010 | keycap.dataset.command = command;
|
28011 | }
|
28012 | }
|
28013 | }
|
28014 | return false;
|
28015 | }
|
28016 | function onUndoStateChanged(keyboard, canUndoState, canRedoState) {
|
28017 | var _a;
|
28018 | const toolbar = (_a = keyboard.element) === null || _a === void 0 ? void 0 : _a.querySelector('.keyboard-toolbar');
|
28019 | if (!toolbar)
|
28020 | return false;
|
28021 | const undoButton = toolbar.querySelector('[data-command=\'"undo"\']');
|
28022 | const redoButton = toolbar.querySelector('[data-command=\'"redo"\']');
|
28023 | if (redoButton) {
|
28024 | if (canRedoState) {
|
28025 | redoButton.classList.remove('disabled');
|
28026 | }
|
28027 | else {
|
28028 | redoButton.classList.add('disabled');
|
28029 | }
|
28030 | }
|
28031 | if (undoButton) {
|
28032 | if (canUndoState) {
|
28033 | undoButton.classList.remove('disabled');
|
28034 | }
|
28035 | else {
|
28036 | undoButton.classList.add('disabled');
|
28037 | }
|
28038 | }
|
28039 | return false;
|
28040 | }
|
28041 |
|
28042 |
|
28043 |
|
28044 |
|
28045 |
|
28046 |
|
28047 | register({
|
28048 | showAlternateKeys,
|
28049 | }, { target: 'virtual-keyboard' });
|
28050 | function switchKeyboardLayer(keyboard, layer) {
|
28051 |
|
28052 | if (keyboard.options.virtualKeyboardMode !== 'off') {
|
28053 | if (layer !== 'lower-command' &&
|
28054 | layer !== 'upper-command' &&
|
28055 | layer !== 'symbols-command') {
|
28056 |
|
28057 | keyboard.executeCommand('complete');
|
28058 | }
|
28059 | showVirtualKeyboard(keyboard);
|
28060 |
|
28061 | hideAlternateKeys();
|
28062 |
|
28063 |
|
28064 | unshiftKeyboardLayer(keyboard);
|
28065 | const layers = keyboard === null || keyboard === void 0 ? void 0 : keyboard.element.querySelectorAll('.keyboard-layer');
|
28066 |
|
28067 | let found = false;
|
28068 | for (const layer_ of layers) {
|
28069 | if (layer_.dataset.layer === layer) {
|
28070 | found = true;
|
28071 | break;
|
28072 | }
|
28073 | }
|
28074 |
|
28075 |
|
28076 | if (found) {
|
28077 | for (const layer_ of layers) {
|
28078 | if (layer_.dataset.layer === layer) {
|
28079 | layer_.classList.add('is-visible');
|
28080 | }
|
28081 | else {
|
28082 | layer_.classList.remove('is-visible');
|
28083 | }
|
28084 | }
|
28085 | }
|
28086 | keyboard.focusMathfield();
|
28087 | }
|
28088 | return true;
|
28089 | }
|
28090 | function shiftKeyboardLayer(keyboard) {
|
28091 | const keycaps = keyboard === null || keyboard === void 0 ? void 0 : keyboard.element.querySelectorAll('div.keyboard-layer.is-visible .rows .keycap, div.keyboard-layer.is-visible .rows .action');
|
28092 | if (keycaps) {
|
28093 | for (const keycap of keycaps) {
|
28094 | let shiftedContent = keycap.getAttribute('data-shifted');
|
28095 | if (shiftedContent || /^[a-z]$/.test(keycap.innerHTML)) {
|
28096 | keycap.dataset.unshiftedContent = keycap.innerHTML;
|
28097 | if (!shiftedContent) {
|
28098 | shiftedContent = keycap.innerHTML.toUpperCase();
|
28099 | }
|
28100 | keycap.innerHTML = keyboard.options.createHTML(shiftedContent);
|
28101 | const command = keycap.getAttribute('data-command');
|
28102 | if (command) {
|
28103 | keycap.dataset.unshiftedCommand = command;
|
28104 | const shifteCommand = keycap.getAttribute('data-shifted-command');
|
28105 | if (shifteCommand) {
|
28106 | keycap.dataset.command = shifteCommand;
|
28107 | }
|
28108 | else {
|
28109 | const commandObject = JSON.parse(command);
|
28110 | if (isArray(commandObject)) {
|
28111 | commandObject[1] = commandObject[1].toUpperCase();
|
28112 | }
|
28113 | keycap.dataset.command = JSON.stringify(commandObject);
|
28114 | }
|
28115 | }
|
28116 | }
|
28117 | }
|
28118 | }
|
28119 | return false;
|
28120 | }
|
28121 |
|
28122 |
|
28123 |
|
28124 |
|
28125 | register({
|
28126 | shiftKeyboardLayer,
|
28127 | }, { target: 'virtual-keyboard' });
|
28128 | function performAlternateKeys(keyboard, command) {
|
28129 | hideAlternateKeys();
|
28130 | return keyboard.executeCommand(command);
|
28131 | }
|
28132 | function insertAndUnshiftKeyboardLayer(keyboard, c) {
|
28133 | keyboard.executeCommand(['insert', c]);
|
28134 | unshiftKeyboardLayer(keyboard);
|
28135 | return true;
|
28136 | }
|
28137 | register({
|
28138 | hideAlternateKeys: () => hideAlternateKeys(),
|
28139 | |
28140 |
|
28141 |
|
28142 |
|
28143 |
|
28144 | performAlternateKeys,
|
28145 | switchKeyboardLayer: (keyboard, layer) => switchKeyboardLayer(keyboard, layer),
|
28146 | unshiftKeyboardLayer: (keyboard) => unshiftKeyboardLayer(keyboard),
|
28147 | insertAndUnshiftKeyboardLayer,
|
28148 | }, { target: 'virtual-keyboard' });
|
28149 | function toggleVirtualKeyboardAlt(keyboard) {
|
28150 | let hadAltTheme = false;
|
28151 | if (keyboard === null || keyboard === void 0 ? void 0 : keyboard.element) {
|
28152 | hadAltTheme = keyboard === null || keyboard === void 0 ? void 0 : keyboard.element.classList.contains('material');
|
28153 | keyboard.disable();
|
28154 | }
|
28155 | showVirtualKeyboard(keyboard, hadAltTheme ? '' : 'material');
|
28156 | return false;
|
28157 | }
|
28158 | function toggleVirtualKeyboardShift(keyboard) {
|
28159 | var _a, _b;
|
28160 | keyboard.options.virtualKeyboardLayout = {
|
28161 | qwerty: 'azerty',
|
28162 | azerty: 'qwertz',
|
28163 | qwertz: 'dvorak',
|
28164 | dvorak: 'colemak',
|
28165 | colemak: 'qwerty',
|
28166 | }[keyboard.options.virtualKeyboardLayout];
|
28167 | const layer = (_b = (_a = keyboard === null || keyboard === void 0 ? void 0 : keyboard.element.querySelector('div.keyboard-layer.is-visible')) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : '';
|
28168 | if (keyboard) {
|
28169 | keyboard.disable();
|
28170 | }
|
28171 | showVirtualKeyboard(keyboard);
|
28172 | if (layer) {
|
28173 | switchKeyboardLayer(keyboard, layer);
|
28174 | }
|
28175 | return false;
|
28176 | }
|
28177 | register({
|
28178 |
|
28179 | toggleVirtualKeyboardAlt,
|
28180 |
|
28181 | toggleVirtualKeyboardShift,
|
28182 | }, { target: 'virtual-keyboard' });
|
28183 | function showVirtualKeyboard(keyboard, theme = '') {
|
28184 | keyboard.visible = false;
|
28185 | toggleVirtualKeyboard(keyboard, theme);
|
28186 | return false;
|
28187 | }
|
28188 | function hideVirtualKeyboard(keyboard) {
|
28189 | keyboard.visible = true;
|
28190 | toggleVirtualKeyboard(keyboard);
|
28191 | return false;
|
28192 | }
|
28193 | function toggleVirtualKeyboard(keyboard, theme) {
|
28194 | if (!keyboard.options.virtualKeyboardContainer)
|
28195 | return false;
|
28196 | keyboard.visible = !keyboard.visible;
|
28197 | if (keyboard.visible) {
|
28198 | keyboard.focusMathfield();
|
28199 | if (keyboard.element) {
|
28200 | keyboard.element.classList.add('is-visible');
|
28201 | }
|
28202 | else {
|
28203 |
|
28204 | keyboard.element = makeKeyboardElement(keyboard, theme !== null && theme !== void 0 ? theme : '');
|
28205 |
|
28206 | on(keyboard.element, 'touchstart:passive mousedown', () => keyboard.focusMathfield());
|
28207 | keyboard.options.virtualKeyboardContainer.appendChild(keyboard.element);
|
28208 | }
|
28209 |
|
28210 |
|
28211 | window.setTimeout(() => {
|
28212 | var _a;
|
28213 | (_a = keyboard === null || keyboard === void 0 ? void 0 : keyboard.element) === null || _a === void 0 ? void 0 : _a.classList.add('is-visible');
|
28214 | }, 1);
|
28215 | }
|
28216 | else if (keyboard.element) {
|
28217 |
|
28218 | keyboard.disable();
|
28219 | }
|
28220 | keyboard.stateChanged();
|
28221 | return false;
|
28222 | }
|
28223 | register({
|
28224 | toggleVirtualKeyboard: (keyboard, theme) => toggleVirtualKeyboard(keyboard, theme),
|
28225 | hideVirtualKeyboard: (keyboard) => hideVirtualKeyboard(keyboard),
|
28226 | showVirtualKeyboard: (keyboard, theme) => showVirtualKeyboard(keyboard, theme),
|
28227 | onUndoStateChanged: (keyboard, canUndoState, canRedoState) => onUndoStateChanged(keyboard, canUndoState, canRedoState),
|
28228 | }, { target: 'virtual-keyboard' });
|
28229 |
|
28230 | function speakableText(speechOptions, prefix, atoms) {
|
28231 | const options = {
|
28232 | ...speechOptions,
|
28233 | textToSpeechMarkup: '',
|
28234 | textToSpeechRulesOptions: {
|
28235 | ...speechOptions.textToSpeechRulesOptions,
|
28236 | markup: 'none',
|
28237 | },
|
28238 | };
|
28239 | return prefix + atomToSpeakableText(atoms, options);
|
28240 | }
|
28241 |
|
28242 |
|
28243 |
|
28244 |
|
28245 |
|
28246 |
|
28247 |
|
28248 | register({
|
28249 | speak: (mathfield, scope, options) => {
|
28250 | return speak(mathfield, scope, options);
|
28251 | },
|
28252 | }, { target: 'mathfield', category: 'speech' });
|
28253 | function speak(mathfield, scope, speakOptions) {
|
28254 | var _a, _b;
|
28255 | speakOptions = speakOptions !== null && speakOptions !== void 0 ? speakOptions : { withHighlighting: false };
|
28256 | const { model } = mathfield;
|
28257 | function getAtoms(scope) {
|
28258 | let result = null;
|
28259 | switch (scope) {
|
28260 | case 'all':
|
28261 | result = model.root;
|
28262 | break;
|
28263 | case 'selection':
|
28264 | result = model.getAtoms(model.selection);
|
28265 | break;
|
28266 | case 'left': {
|
28267 | result = model.getAtoms(model.offsetOf(model.at(model.position).leftSibling), model.position);
|
28268 | break;
|
28269 | }
|
28270 | case 'right': {
|
28271 | result = model.getAtoms(model.position, model.offsetOf(model.at(model.position).rightSibling));
|
28272 | break;
|
28273 | }
|
28274 | case 'group':
|
28275 | result = model.getAtoms(model.getSiblingsRange(model.position));
|
28276 | break;
|
28277 | case 'parent': {
|
28278 | const { parent } = model.at(model.position);
|
28279 | if (parent && parent.type !== 'root') {
|
28280 | result = parent;
|
28281 | }
|
28282 | else {
|
28283 | result = model.root;
|
28284 | }
|
28285 | break;
|
28286 | }
|
28287 | default:
|
28288 | result = model.root;
|
28289 | }
|
28290 | return result;
|
28291 | }
|
28292 | function getFailedSpeech(scope) {
|
28293 | let result = '';
|
28294 | switch (scope) {
|
28295 | case 'all':
|
28296 | console.log('Internal failure: speak all failed');
|
28297 | break;
|
28298 | case 'selection':
|
28299 | result = 'no selection';
|
28300 | break;
|
28301 | case 'left':
|
28302 | result = 'at start';
|
28303 | break;
|
28304 | case 'right':
|
28305 | result = 'at end';
|
28306 | break;
|
28307 | case 'group':
|
28308 | console.log('Internal failure: speak group failed');
|
28309 | break;
|
28310 | case 'parent':
|
28311 | result = 'no parent';
|
28312 | break;
|
28313 | default:
|
28314 | console.log('unknown speak_ param value: "' + scope + '"');
|
28315 | break;
|
28316 | }
|
28317 | return result;
|
28318 | }
|
28319 | const atoms = getAtoms(scope);
|
28320 | if (atoms === null) {
|
28321 | (_b = (_a = mathfield.options).speakHook) === null || _b === void 0 ? void 0 : _b.call(_a, getFailedSpeech(scope), mathfield.options);
|
28322 | return false;
|
28323 | }
|
28324 | const options = { ...mathfield.options };
|
28325 | if (speakOptions.withHighlighting || options.speechEngine === 'amazon') {
|
28326 | options.textToSpeechMarkup =
|
28327 | window.sre && options.textToSpeechRules === 'sre' ? 'ssml_step' : 'ssml';
|
28328 | }
|
28329 | const text = atomToSpeakableText(atoms, options);
|
28330 | if (speakOptions.withHighlighting) {
|
28331 | window.mathlive.readAloudMathField = mathfield;
|
28332 | render(mathfield, { forHighlighting: true });
|
28333 | if (mathfield.options.readAloudHook) {
|
28334 | mathfield.options.readAloudHook(mathfield.field, text, mathfield.options);
|
28335 | }
|
28336 | }
|
28337 | else if (mathfield.options.speakHook) {
|
28338 | mathfield.options.speakHook(text, options);
|
28339 | }
|
28340 | return false;
|
28341 | }
|
28342 | function defaultSpeakHook(text, config) {
|
28343 | var _a, _b;
|
28344 | if (!config && (window === null || window === void 0 ? void 0 : window.mathlive)) {
|
28345 | config = window.mathlive.config;
|
28346 | }
|
28347 | config = config !== null && config !== void 0 ? config : {};
|
28348 | if (!config.speechEngine || config.speechEngine === 'local') {
|
28349 |
|
28350 |
|
28351 | const utterance = new SpeechSynthesisUtterance(text);
|
28352 | if (window) {
|
28353 | window.speechSynthesis.speak(utterance);
|
28354 | }
|
28355 | else {
|
28356 | console.log('Speak:', text);
|
28357 | }
|
28358 | }
|
28359 | else if (config.speechEngine === 'amazon') {
|
28360 | if (!window || !window.AWS) {
|
28361 | console.warn('AWS SDK not loaded. See https://www.npmjs.com/package/aws-sdk');
|
28362 | }
|
28363 | else {
|
28364 | const polly = new window.AWS.Polly({ apiVersion: '2016-06-10' });
|
28365 | const parameters = {
|
28366 | OutputFormat: 'mp3',
|
28367 | VoiceId: (_a = config.speechEngineVoice) !== null && _a !== void 0 ? _a : 'Joanna',
|
28368 | Engine: [
|
28369 | 'Amy',
|
28370 | 'Emma',
|
28371 | 'Brian',
|
28372 | 'Ivy',
|
28373 | 'Joanna',
|
28374 | 'Kendra',
|
28375 | 'Kimberly',
|
28376 | 'Salli',
|
28377 | 'Joey',
|
28378 | 'Justin',
|
28379 | 'Matthew',
|
28380 | ].includes((_b = config.speechEngineVoice) !== null && _b !== void 0 ? _b : 'Joanna')
|
28381 | ? 'neural'
|
28382 | : 'standard',
|
28383 |
|
28384 | Text: text,
|
28385 | TextType: 'ssml',
|
28386 |
|
28387 | };
|
28388 |
|
28389 | polly.synthesizeSpeech(parameters, (err, data) => {
|
28390 | if (err) {
|
28391 | console.warn('polly.synthesizeSpeech() error:', err, err.stack);
|
28392 |
|
28393 | }
|
28394 | else if (data === null || data === void 0 ? void 0 : data.AudioStream) {
|
28395 | const uInt8Array = new Uint8Array(data.AudioStream);
|
28396 | const blob = new Blob([uInt8Array.buffer], {
|
28397 | type: 'audio/mpeg',
|
28398 | });
|
28399 | const url = URL.createObjectURL(blob);
|
28400 | const audioElement = new Audio(url);
|
28401 | audioElement.play().catch((error) => console.log(error));
|
28402 | }
|
28403 | else {
|
28404 | console.log('polly.synthesizeSpeech():', data);
|
28405 | }
|
28406 | });
|
28407 |
|
28408 | }
|
28409 | }
|
28410 | else if (config.speechEngine === 'google') {
|
28411 | console.warn('The Google speech engine is not supported yet. Please come again.');
|
28412 |
|
28413 |
|
28414 |
|
28415 |
|
28416 |
|
28417 |
|
28418 |
|
28419 |
|
28420 |
|
28421 |
|
28422 |
|
28423 |
|
28424 |
|
28425 |
|
28426 |
|
28427 |
|
28428 |
|
28429 |
|
28430 |
|
28431 |
|
28432 | }
|
28433 | }
|
28434 |
|
28435 |
|
28436 |
|
28437 |
|
28438 |
|
28439 |
|
28440 | function relationName(atom) {
|
28441 | let result = undefined;
|
28442 | if (atom.treeBranch === 'body') {
|
28443 | result = {
|
28444 | enclose: 'cross out',
|
28445 | leftright: 'fence',
|
28446 | surd: 'square root',
|
28447 | root: 'math field',
|
28448 | mop: 'operator',
|
28449 | }[atom.parent.type];
|
28450 | }
|
28451 | else if (atom.parent.type === 'genfrac') {
|
28452 | if (atom.treeBranch === 'above') {
|
28453 | return 'numerator';
|
28454 | }
|
28455 | if (atom.treeBranch === 'below') {
|
28456 | return 'denominator';
|
28457 | }
|
28458 | }
|
28459 | else if (atom.parent.type === 'surd') {
|
28460 | if (atom.treeBranch === 'above') {
|
28461 | result = 'index';
|
28462 | }
|
28463 | }
|
28464 | else if (atom.treeBranch === 'superscript') {
|
28465 | result = 'superscript';
|
28466 | }
|
28467 | else if (atom.treeBranch === 'subscript') {
|
28468 | result = 'subscript';
|
28469 | }
|
28470 | if (!result) {
|
28471 | console.log('unknown relationship');
|
28472 | }
|
28473 | return result !== null && result !== void 0 ? result : 'parent';
|
28474 | }
|
28475 |
|
28476 |
|
28477 |
|
28478 |
|
28479 |
|
28480 |
|
28481 | function defaultAnnounceHook(mathfield, action, previousPosition, atoms) {
|
28482 | var _a;
|
28483 |
|
28484 | let liveText = '';
|
28485 |
|
28486 | if (action === 'plonk') {
|
28487 |
|
28488 |
|
28489 | (_a = mathfield.plonkSound) === null || _a === void 0 ? void 0 : _a.play().catch((error) => console.warn(error));
|
28490 |
|
28491 | mathfield.resetKeystrokeBuffer();
|
28492 | }
|
28493 | else if (action === 'delete') {
|
28494 | liveText = speakableText(mathfield.options, 'deleted: ', atoms);
|
28495 |
|
28496 | }
|
28497 | else if (action === 'focus' || action.includes('move')) {
|
28498 |
|
28499 | liveText =
|
28500 | getRelationshipAsSpokenText(mathfield.model, previousPosition) +
|
28501 | (mathfield.model.selectionIsCollapsed ? '' : 'selected: ') +
|
28502 | getNextAtomAsSpokenText(mathfield.model, mathfield.options);
|
28503 | }
|
28504 | else if (action === 'replacement') {
|
28505 |
|
28506 | liveText = speakableText(mathfield.options, '', mathfield.model.at(mathfield.model.position));
|
28507 | }
|
28508 | else if (action === 'line') {
|
28509 |
|
28510 |
|
28511 |
|
28512 |
|
28513 |
|
28514 |
|
28515 | liveText = speakableText(mathfield.options, '', mathfield.model.root);
|
28516 | mathfield.keyboardDelegate.setAriaLabel('after: ' + liveText);
|
28517 |
|
28518 |
|
28519 |
|
28520 |
|
28521 |
|
28522 |
|
28523 |
|
28524 | }
|
28525 | else {
|
28526 | liveText = atoms
|
28527 | ? speakableText(mathfield.options, action + ' ', atoms)
|
28528 | : action;
|
28529 | }
|
28530 |
|
28531 |
|
28532 | const ariaLiveChangeHack = mathfield.ariaLiveText.textContent.includes('\u00a0')
|
28533 | ? ' \u202F '
|
28534 | : ' \u00A0 ';
|
28535 | mathfield.ariaLiveText.textContent = liveText + ariaLiveChangeHack;
|
28536 |
|
28537 | }
|
28538 | function getRelationshipAsSpokenText(model, previousOffset) {
|
28539 | if (Number.isNaN(previousOffset))
|
28540 | return '';
|
28541 | const previous = model.at(previousOffset);
|
28542 | if (!previous)
|
28543 | return '';
|
28544 | if (previous.treeDepth <= model.at(model.position).treeDepth) {
|
28545 | return '';
|
28546 | }
|
28547 | let result = '';
|
28548 | let ancestor = previous.parent;
|
28549 | const newParent = model.at(model.position).parent;
|
28550 | while (ancestor !== model.root && ancestor !== newParent) {
|
28551 | result += `out of ${relationName(ancestor)};`;
|
28552 | ancestor = ancestor.parent;
|
28553 | }
|
28554 | return result;
|
28555 | }
|
28556 |
|
28557 |
|
28558 |
|
28559 |
|
28560 |
|
28561 |
|
28562 | function getNextAtomAsSpokenText(model, options) {
|
28563 | if (!model.selectionIsCollapsed) {
|
28564 | return speakableText(options, '', model.getAtoms(model.selection));
|
28565 | }
|
28566 | let result = '';
|
28567 |
|
28568 | const cursor = model.at(model.position);
|
28569 | const relation = relationName(cursor);
|
28570 | if (cursor.isFirstSibling) {
|
28571 | result = (relation ? 'start of ' + relation : 'unknown') + ': ';
|
28572 | }
|
28573 | if (cursor.isLastSibling) {
|
28574 |
|
28575 | if (!cursor.isFirstSibling) {
|
28576 | result += relation ? 'end of ' + relation : 'unknown';
|
28577 | }
|
28578 | }
|
28579 | else {
|
28580 | result += speakableText(options, '', cursor);
|
28581 | }
|
28582 | return result;
|
28583 | }
|
28584 |
|
28585 | function removeHighlight(element) {
|
28586 | element.classList.remove('ML__highlight');
|
28587 | if (element.children) {
|
28588 | for (const child of element.children) {
|
28589 | removeHighlight(child);
|
28590 | }
|
28591 | }
|
28592 | }
|
28593 |
|
28594 |
|
28595 |
|
28596 |
|
28597 |
|
28598 |
|
28599 |
|
28600 |
|
28601 |
|
28602 | function highlightAtomID(element, atomID) {
|
28603 | var _a;
|
28604 | if (!atomID || ((_a = element.dataset) === null || _a === void 0 ? void 0 : _a.atomId) === atomID) {
|
28605 | element.classList.add('ML__highlight');
|
28606 | if (element.children && element.children.length > 0) {
|
28607 | [...element.children].forEach((x) => {
|
28608 | if (x instanceof HTMLElement) {
|
28609 | highlightAtomID(x);
|
28610 | }
|
28611 | });
|
28612 | }
|
28613 | }
|
28614 | else {
|
28615 | element.classList.remove('ML__highlight');
|
28616 | if (element.children && element.children.length > 0) {
|
28617 | [...element.children].forEach((x) => {
|
28618 | if (x instanceof HTMLElement) {
|
28619 | highlightAtomID(x, atomID);
|
28620 | }
|
28621 | });
|
28622 | }
|
28623 | }
|
28624 | }
|
28625 |
|
28626 |
|
28627 |
|
28628 |
|
28629 |
|
28630 |
|
28631 |
|
28632 | function defaultReadAloudHook(element, text, config) {
|
28633 | var _a, _b, _c;
|
28634 | if (typeof window === 'undefined') {
|
28635 | return;
|
28636 | }
|
28637 | if (!config && window.mathlive) {
|
28638 | config = window.mathlive.config;
|
28639 | }
|
28640 | if (config.speechEngine !== 'amazon') {
|
28641 | console.warn('Use Amazon TTS Engine for synchronized highlighting');
|
28642 | if (config.speakHook)
|
28643 | config.speakHook(text, config);
|
28644 | return;
|
28645 | }
|
28646 | if (!window.AWS) {
|
28647 | console.warn('AWS SDK not loaded. See https://www.npmjs.com/package/aws-sdk');
|
28648 | return;
|
28649 | }
|
28650 | const polly = new window.AWS.Polly({ apiVersion: '2016-06-10' });
|
28651 | const parameters = {
|
28652 | OutputFormat: 'json',
|
28653 | VoiceId: (_a = config.speechEngineVoice) !== null && _a !== void 0 ? _a : 'Joanna',
|
28654 | Engine: 'standard',
|
28655 | Text: text,
|
28656 | TextType: 'ssml',
|
28657 | SpeechMarkTypes: ['ssml'],
|
28658 | };
|
28659 | window.mathlive = (_b = window.mathlive) !== null && _b !== void 0 ? _b : {};
|
28660 | window.mathlive.readAloudElement = element;
|
28661 | const statusHook = (_c = config.onReadAloudStatus) !== null && _c !== void 0 ? _c : window.mathlive.onReadAloudStatus;
|
28662 |
|
28663 | polly.synthesizeSpeech(parameters, (err, data) => {
|
28664 | if (err) {
|
28665 | console.warn('polly.synthesizeSpeech() error:', err, err.stack);
|
28666 | return;
|
28667 | }
|
28668 | if (!data || !data.AudioStream) {
|
28669 | console.log('polly.synthesizeSpeech():', data);
|
28670 | return;
|
28671 | }
|
28672 | const response = new TextDecoder('utf-8').decode(new Uint8Array(data.AudioStream));
|
28673 | window.mathlive.readAloudMarks = response
|
28674 | .split('\n')
|
28675 | .map((x) => (x ? JSON.parse(x) : {}));
|
28676 | window.mathlive.readAloudTokens = [];
|
28677 | for (const mark of window.mathlive.readAloudMarks) {
|
28678 | if (mark.value) {
|
28679 | window.mathlive.readAloudTokens.push(mark.value);
|
28680 | }
|
28681 | }
|
28682 | window.mathlive.readAloudCurrentMark = '';
|
28683 |
|
28684 | parameters.OutputFormat = 'mp3';
|
28685 | parameters.SpeechMarkTypes = [];
|
28686 | polly.synthesizeSpeech(parameters, (err, data) => {
|
28687 | if (err) {
|
28688 | console.warn('polly.synthesizeSpeech(', text, ') error:', err, err.stack);
|
28689 | return;
|
28690 | }
|
28691 | if (!data || !data.AudioStream) {
|
28692 | return;
|
28693 | }
|
28694 | const uInt8Array = new Uint8Array(data.AudioStream);
|
28695 | const blob = new Blob([uInt8Array.buffer], {
|
28696 | type: 'audio/mpeg',
|
28697 | });
|
28698 | const url = URL.createObjectURL(blob);
|
28699 | if (!window.mathlive.readAloudAudio) {
|
28700 | window.mathlive.readAloudAudio = new Audio();
|
28701 | window.mathlive.readAloudAudio.addEventListener('ended', () => {
|
28702 | const mathfield = window.mathlive.readAloudMathField;
|
28703 | if (statusHook) {
|
28704 | statusHook(mathfield, 'ended');
|
28705 | }
|
28706 | if (mathfield) {
|
28707 | render(mathfield);
|
28708 | window.mathlive.readAloudElement = null;
|
28709 | window.mathlive.readAloudMathField = null;
|
28710 | window.mathlive.readAloudTokens = [];
|
28711 | window.mathlive.readAloudMarks = [];
|
28712 | window.mathlive.readAloudCurrentMark = '';
|
28713 | }
|
28714 | else {
|
28715 | removeHighlight(window.mathlive.readAloudElement);
|
28716 | }
|
28717 | });
|
28718 | window.mathlive.readAloudAudio.addEventListener('timeupdate', () => {
|
28719 | let value = '';
|
28720 |
|
28721 |
|
28722 |
|
28723 | const target = window.mathlive.readAloudAudio.currentTime * 1000 + 100;
|
28724 |
|
28725 | for (const mark of window.mathlive.readAloudMarks) {
|
28726 | if (mark.time < target) {
|
28727 | value = mark.value;
|
28728 | }
|
28729 | }
|
28730 | if (window.mathlive.readAloudCurrentMark !== value) {
|
28731 | window.mathlive.readAloudCurrentToken = value;
|
28732 | if (value && value === window.mathlive.readAloudFinalToken) {
|
28733 | window.mathlive.readAloudAudio.pause();
|
28734 | }
|
28735 | else {
|
28736 | window.mathlive.readAloudCurrentMark = value;
|
28737 | highlightAtomID(window.mathlive.readAloudElement, window.mathlive.readAloudCurrentMark);
|
28738 | }
|
28739 | }
|
28740 | });
|
28741 | }
|
28742 | else {
|
28743 | window.mathlive.readAloudAudio.pause();
|
28744 | }
|
28745 | window.mathlive.readAloudAudio.src = url;
|
28746 | if (statusHook) {
|
28747 | statusHook(window.mathlive.readAloudMathField, 'playing');
|
28748 | }
|
28749 | window.mathlive.readAloudAudio.play();
|
28750 | });
|
28751 | });
|
28752 | }
|
28753 |
|
28754 | const AUDIO_FEEDBACK_VOLUME = 0.5;
|
28755 | const NO_OP_LISTENER = () => { };
|
28756 | function loadSound(soundDirectory, sound) {
|
28757 | if (sound === null ||
|
28758 | sound === undefined ||
|
28759 | sound === 'none' ||
|
28760 | sound === 'null') {
|
28761 | return null;
|
28762 | }
|
28763 | if (sound instanceof HTMLAudioElement) {
|
28764 | sound.load();
|
28765 | return sound;
|
28766 | }
|
28767 | sound = sound.trim();
|
28768 | if (sound.length === 0)
|
28769 | return null;
|
28770 | const url = resolveRelativeUrl((soundDirectory === undefined || soundDirectory.length === 0
|
28771 | ? './sounds'
|
28772 | : soundDirectory) +
|
28773 | '/' +
|
28774 | sound).toString();
|
28775 | const result = new Audio();
|
28776 | result.src = url;
|
28777 |
|
28778 | result.volume = AUDIO_FEEDBACK_VOLUME;
|
28779 | result.load();
|
28780 | return result;
|
28781 | }
|
28782 | function unloadSound(sound) {
|
28783 | if (sound instanceof HTMLAudioElement) {
|
28784 | sound.pause();
|
28785 | sound.removeAttribute('src');
|
28786 |
|
28787 |
|
28788 | sound.load();
|
28789 | }
|
28790 | }
|
28791 | function update(current, updates) {
|
28792 | var _a, _b, _c, _d, _e, _f, _g;
|
28793 | const soundsDirectory = (_b = (_a = updates.soundsDirectory) !== null && _a !== void 0 ? _a : current.soundsDirectory) !== null && _b !== void 0 ? _b : './sounds';
|
28794 | const result = get(current, Object.keys(current));
|
28795 | for (const key of Object.keys(updates)) {
|
28796 | switch (key) {
|
28797 | case 'scriptDepth':
|
28798 | if (isArray(updates.scriptDepth)) {
|
28799 | result.scriptDepth = [updates.scriptDepth[0], updates.scriptDepth[1]];
|
28800 | }
|
28801 | else if (typeof updates.scriptDepth === 'number') {
|
28802 | result.scriptDepth = [updates.scriptDepth, updates.scriptDepth];
|
28803 | }
|
28804 | else {
|
28805 | throw new TypeError('Unexpected value for scriptDepth');
|
28806 | }
|
28807 | break;
|
28808 | case 'locale':
|
28809 | result.locale =
|
28810 | updates.locale === 'auto'
|
28811 | ? (_c = (isBrowser() ? navigator.language.slice(0, 5) : null)) !== null && _c !== void 0 ? _c : 'en'
|
28812 | : updates.locale;
|
28813 | l10n.locale = result.locale;
|
28814 | break;
|
28815 | case 'strings':
|
28816 | l10n.merge(updates.strings);
|
28817 | result.strings = l10n.strings;
|
28818 | break;
|
28819 | case 'virtualKeyboardLayout':
|
28820 | result.virtualKeyboardLayout = updates.virtualKeyboardLayout;
|
28821 | break;
|
28822 | case 'virtualKeyboardMode':
|
28823 | if (updates.virtualKeyboardMode === 'auto') {
|
28824 | result.virtualKeyboardMode = isTouchCapable() ? 'onfocus' : 'off';
|
28825 | }
|
28826 | else {
|
28827 | result.virtualKeyboardMode = updates.virtualKeyboardMode;
|
28828 | }
|
28829 | break;
|
28830 | case 'customVirtualKeyboardLayers':
|
28831 | result.customVirtualKeyboardLayers = {
|
28832 | ...result.customVirtualKeyboardLayers,
|
28833 | ...updates.customVirtualKeyboardLayers,
|
28834 | };
|
28835 | break;
|
28836 | case 'customVirtualKeyboards':
|
28837 | result.customVirtualKeyboards = {
|
28838 | ...result.customVirtualKeyboards,
|
28839 | ...updates.customVirtualKeyboards,
|
28840 | };
|
28841 | break;
|
28842 | case 'letterShapeStyle':
|
28843 | if (updates.letterShapeStyle === 'auto') {
|
28844 |
|
28845 | if (l10n.locale.startsWith('fr')) {
|
28846 | result.letterShapeStyle = 'french';
|
28847 | }
|
28848 | else {
|
28849 | result.letterShapeStyle = 'tex';
|
28850 | }
|
28851 | }
|
28852 | else {
|
28853 | result.letterShapeStyle = updates.letterShapeStyle;
|
28854 | }
|
28855 | break;
|
28856 | case 'plonkSound':
|
28857 | unloadSound(result.plonkSound);
|
28858 | result.plonkSound = loadSound(soundsDirectory, updates.plonkSound);
|
28859 | break;
|
28860 | case 'keypressSound':
|
28861 | if (typeof result.keypressSound === 'object' &&
|
28862 | result.keypressSound !== null &&
|
28863 | 'default' in result.keypressSound) {
|
28864 | unloadSound(result.keypressSound.default);
|
28865 | unloadSound(result.keypressSound.delete);
|
28866 | unloadSound(result.keypressSound.return);
|
28867 | unloadSound(result.keypressSound.spacebar);
|
28868 | }
|
28869 | if (updates.keypressSound === null) {
|
28870 | result.keypressSound = {
|
28871 | default: null,
|
28872 | delete: null,
|
28873 | return: null,
|
28874 | spacebar: null,
|
28875 | };
|
28876 | }
|
28877 | else if (typeof updates.keypressSound === 'string') {
|
28878 | const sound = loadSound(soundsDirectory, updates.keypressSound);
|
28879 | result.keypressSound = {
|
28880 | delete: sound,
|
28881 | return: sound,
|
28882 | spacebar: sound,
|
28883 | default: sound,
|
28884 | };
|
28885 | }
|
28886 | else if (updates.keypressSound instanceof HTMLAudioElement) {
|
28887 | result.keypressSound = {
|
28888 | delete: updates.keypressSound,
|
28889 | return: updates.keypressSound,
|
28890 | spacebar: updates.keypressSound,
|
28891 | default: updates.keypressSound,
|
28892 | };
|
28893 | }
|
28894 | else if (typeof updates.keypressSound === 'object' &&
|
28895 | 'default' in updates.keypressSound) {
|
28896 | result.keypressSound = { ...updates.keypressSound };
|
28897 | result.keypressSound.default = loadSound(soundsDirectory, result.keypressSound.default);
|
28898 | result.keypressSound.delete =
|
28899 | (_d = loadSound(soundsDirectory, result.keypressSound.delete)) !== null && _d !== void 0 ? _d : updates.keypressSound.default;
|
28900 | result.keypressSound.return =
|
28901 | (_e = loadSound(soundsDirectory, result.keypressSound.return)) !== null && _e !== void 0 ? _e : updates.keypressSound.default;
|
28902 | result.keypressSound.spacebar =
|
28903 | (_f = loadSound(soundsDirectory, result.keypressSound.spacebar)) !== null && _f !== void 0 ? _f : updates.keypressSound.default;
|
28904 | }
|
28905 | break;
|
28906 | case 'virtualKeyboardContainer':
|
28907 | result.virtualKeyboardContainer = updates.virtualKeyboardContainer;
|
28908 | break;
|
28909 | case 'macros':
|
28910 | result.macros = (_g = normalizeMacroDictionary(updates.macros)) !== null && _g !== void 0 ? _g : {};
|
28911 | break;
|
28912 | case 'onBlur':
|
28913 | case 'onFocus':
|
28914 | case 'onContentWillChange':
|
28915 | case 'onContentDidChange':
|
28916 | case 'onSelectionWillChange':
|
28917 | case 'onSelectionDidChange':
|
28918 | case 'onUndoStateWillChange':
|
28919 | case 'onUndoStateDidChange':
|
28920 | case 'onModeChange':
|
28921 | case 'onCommit':
|
28922 | case 'onReadAloudStatus':
|
28923 | case 'onError':
|
28924 | if (updates[key] === null) {
|
28925 | result[key] = NO_OP_LISTENER;
|
28926 | }
|
28927 | else if (typeof updates[key] !== 'function') {
|
28928 | throw new TypeError(key + ' must be a function or null');
|
28929 | }
|
28930 | result[key] = updates[key];
|
28931 | break;
|
28932 | default:
|
28933 | if (isArray(updates[key])) {
|
28934 | result[key] = [...updates[key]];
|
28935 | }
|
28936 | else if (typeof updates[key] === 'object') {
|
28937 | result[key] = { ...updates[key] };
|
28938 | }
|
28939 | else {
|
28940 | result[key] = updates[key];
|
28941 | }
|
28942 | }
|
28943 | }
|
28944 | return result;
|
28945 | }
|
28946 | function get(config, keys) {
|
28947 | let resolvedKeys;
|
28948 | if (typeof keys === 'string') {
|
28949 | resolvedKeys = [keys];
|
28950 | }
|
28951 | else if (keys === undefined) {
|
28952 | resolvedKeys = Object.keys(config);
|
28953 | }
|
28954 | else {
|
28955 | resolvedKeys = keys;
|
28956 | }
|
28957 | const result = {};
|
28958 | for (const x of resolvedKeys) {
|
28959 | if (isArray(config[x])) {
|
28960 | result[x] = [...config[x]];
|
28961 | }
|
28962 | else if (config[x] instanceof HTMLElement) {
|
28963 |
|
28964 | result[x] = config[x];
|
28965 | }
|
28966 | else if (config[x] === null) {
|
28967 | result[x] = null;
|
28968 | }
|
28969 | else if (typeof config[x] === 'object') {
|
28970 |
|
28971 | result[x] = { ...config[x] };
|
28972 | }
|
28973 | else {
|
28974 | result[x] = config[x];
|
28975 | }
|
28976 | }
|
28977 |
|
28978 | if (typeof keys === 'string') {
|
28979 | return result[keys];
|
28980 | }
|
28981 | return result;
|
28982 | }
|
28983 | const DEFAULT_KEYBOARD_TOGGLE_GLYPH = `<span style="width: 21px; margin-top: 4px;"><svg style="width: 21px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M528 64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h480c26.51 0 48-21.49 48-48V112c0-26.51-21.49-48-48-48zm16 336c0 8.823-7.177 16-16 16H48c-8.823 0-16-7.177-16-16V112c0-8.823 7.177-16 16-16h480c8.823 0 16 7.177 16 16v288zM168 268v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm-336 80v-24c0-6.627-5.373-12-12-12H84c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm384 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zM120 188v-24c0-6.627-5.373-12-12-12H84c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm-96 152v-8c0-6.627-5.373-12-12-12H180c-6.627 0-12 5.373-12 12v8c0 6.627 5.373 12 12 12h216c6.627 0 12-5.373 12-12z"/></svg></span>`;
|
28984 | function getDefault() {
|
28985 | var _a, _b, _c, _d;
|
28986 | return {
|
28987 | readOnly: false,
|
28988 | createHTML: (s) => s,
|
28989 | fontsDirectory: './fonts',
|
28990 | soundsDirectory: './sounds',
|
28991 | defaultMode: 'math',
|
28992 | macros: getMacros(),
|
28993 | registers: { ...getDefaultRegisters() },
|
28994 | colorMap: defaultColorMap,
|
28995 | backgroundColorMap: defaultBackgroundColorMap,
|
28996 | horizontalSpacingScale: 1,
|
28997 | letterShapeStyle: l10n.locale.startsWith('fr') ? 'french' : 'tex',
|
28998 | smartMode: false,
|
28999 | smartFence: true,
|
29000 | smartSuperscript: true,
|
29001 | scriptDepth: [Infinity, Infinity],
|
29002 | removeExtraneousParentheses: true,
|
29003 | mathModeSpace: '',
|
29004 | locale: (_a = l10n.locale) !== null && _a !== void 0 ? _a : 'en',
|
29005 | strings: l10n.strings,
|
29006 | keybindings: DEFAULT_KEYBINDINGS,
|
29007 | inlineShortcuts: INLINE_SHORTCUTS,
|
29008 | inlineShortcutTimeout: 0,
|
29009 | virtualKeyboardToggleGlyph: DEFAULT_KEYBOARD_TOGGLE_GLYPH,
|
29010 | virtualKeyboardMode: 'auto',
|
29011 | virtualKeyboards: 'all',
|
29012 | virtualKeyboardLayout: 'auto',
|
29013 | customVirtualKeyboardLayers: {},
|
29014 | customVirtualKeyboards: {},
|
29015 | virtualKeyboardTheme: isBrowser() && /android|cros/i.test(navigator.userAgent)
|
29016 | ? 'material'
|
29017 | : 'apple',
|
29018 | keypressVibration: true,
|
29019 | keypressSound: null,
|
29020 | plonkSound: null,
|
29021 | virtualKeyboardToolbar: 'default',
|
29022 | virtualKeyboardContainer: (_c = (_b = globalThis.document) === null || _b === void 0 ? void 0 : _b.body) !== null && _c !== void 0 ? _c : null,
|
29023 | useSharedVirtualKeyboard: false,
|
29024 | sharedVirtualKeyboardTargetOrigin: (_d = globalThis.window) === null || _d === void 0 ? void 0 : _d.origin,
|
29025 | originValidator: 'same-origin',
|
29026 | textToSpeechRules: 'mathlive',
|
29027 | textToSpeechMarkup: '',
|
29028 | textToSpeechRulesOptions: {},
|
29029 | speechEngine: 'local',
|
29030 | speechEngineVoice: 'Joanna',
|
29031 | speechEngineRate: '100%',
|
29032 | speakHook: defaultSpeakHook,
|
29033 | readAloudHook: defaultReadAloudHook,
|
29034 | onAnnounce: defaultAnnounceHook,
|
29035 | onKeystroke: () => true,
|
29036 | onMoveOutOf: () => true,
|
29037 | onTabOutOf: () => true,
|
29038 | onPlaceholderDidChange: () => { },
|
29039 | onBlur: NO_OP_LISTENER,
|
29040 | onFocus: NO_OP_LISTENER,
|
29041 | onContentWillChange: NO_OP_LISTENER,
|
29042 | onContentDidChange: NO_OP_LISTENER,
|
29043 | onSelectionWillChange: NO_OP_LISTENER,
|
29044 | onSelectionDidChange: NO_OP_LISTENER,
|
29045 | onUndoStateWillChange: NO_OP_LISTENER,
|
29046 | onUndoStateDidChange: NO_OP_LISTENER,
|
29047 | onModeChange: NO_OP_LISTENER,
|
29048 | onReadAloudStatus: NO_OP_LISTENER,
|
29049 | onCommit: NO_OP_LISTENER,
|
29050 | onExport: defaultExportHook,
|
29051 | onError: () => { },
|
29052 | value: '',
|
29053 | };
|
29054 | }
|
29055 | function effectiveMode(options) {
|
29056 | if (options.defaultMode === 'inline-math')
|
29057 | return 'math';
|
29058 | return options.defaultMode;
|
29059 | }
|
29060 |
|
29061 | const POST_MESSAGE_TYPE = 'ml#systemPostMessage';
|
29062 |
|
29063 |
|
29064 |
|
29065 | class VirtualKeyboardDelegate {
|
29066 | |
29067 |
|
29068 |
|
29069 |
|
29070 |
|
29071 |
|
29072 | constructor(options) {
|
29073 | var _a, _b;
|
29074 | this.targetOrigin = (_a = options.targetOrigin) !== null && _a !== void 0 ? _a : window.origin;
|
29075 | this.originValidator = (_b = options.originValidator) !== null && _b !== void 0 ? _b : 'same-origin';
|
29076 | this._mathfield = options.mathfield;
|
29077 | this.enable();
|
29078 | }
|
29079 | setOptions(_options) {
|
29080 |
|
29081 |
|
29082 | }
|
29083 | create() { }
|
29084 | dispose() {
|
29085 | this.disable();
|
29086 | }
|
29087 | enable() {
|
29088 | if (!this.enabled) {
|
29089 | this.enabled = true;
|
29090 | window.addEventListener('message', this);
|
29091 | }
|
29092 | }
|
29093 | disable() {
|
29094 | if (this.enabled) {
|
29095 | window.removeEventListener('message', this);
|
29096 | this.enabled = false;
|
29097 | }
|
29098 | }
|
29099 | executeCommand(command) {
|
29100 | var _a;
|
29101 | if (getCommandTarget(command) === 'virtual-keyboard') {
|
29102 | this.sendMessage('executeCommand', { command });
|
29103 | return false;
|
29104 | }
|
29105 | return (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.executeCommand(command);
|
29106 | }
|
29107 | focusMathfield() { }
|
29108 | blurMathfield() { }
|
29109 | stateChanged() { }
|
29110 | handleEvent(event) {
|
29111 | var _a, _b, _c, _d;
|
29112 | if (event.type === 'message' &&
|
29113 | event.data &&
|
29114 | event.data.type === POST_MESSAGE_TYPE) {
|
29115 | if (!validateOrigin(event.origin, this.originValidator)) {
|
29116 | throw new Error(`Message from unknown origin (${event.origin}) cannot be handled`);
|
29117 | }
|
29118 | const { action } = event.data;
|
29119 | if (action === 'executeCommand') {
|
29120 | this.executeCommand(event.data.command);
|
29121 | }
|
29122 | else if (action === 'updateState') {
|
29123 | this.visible = event.data.state.visible;
|
29124 | this.height = event.data.state.height;
|
29125 | }
|
29126 | else if (action === 'focus') {
|
29127 | (_b = (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
|
29128 | }
|
29129 | else if (action === 'blur') {
|
29130 | (_d = (_c = this._mathfield) === null || _c === void 0 ? void 0 : _c.blur) === null || _d === void 0 ? void 0 : _d.call(_c);
|
29131 | }
|
29132 | }
|
29133 | }
|
29134 | sendMessage(action, payload = {}) {
|
29135 | if (window.parent) {
|
29136 | window.parent.postMessage({
|
29137 | type: POST_MESSAGE_TYPE,
|
29138 | action,
|
29139 | ...payload,
|
29140 | }, this.targetOrigin);
|
29141 | return true;
|
29142 | }
|
29143 | return false;
|
29144 | }
|
29145 | }
|
29146 |
|
29147 |
|
29148 |
|
29149 | class RemoteVirtualKeyboard extends VirtualKeyboard {
|
29150 | constructor(options) {
|
29151 | super({
|
29152 | ...RemoteVirtualKeyboard.defaultOptions,
|
29153 | ...(options !== null && options !== void 0 ? options : {}),
|
29154 | });
|
29155 | window.addEventListener('message', this);
|
29156 | }
|
29157 | static get defaultOptions() {
|
29158 | var _a, _b;
|
29159 | return {
|
29160 | createHTML: (s) => s,
|
29161 | fontsDirectory: './fonts',
|
29162 | soundsDirectory: './sounds',
|
29163 | targetOrigin: window.origin,
|
29164 | originValidator: 'same-origin',
|
29165 | virtualKeyboards: 'all',
|
29166 | virtualKeyboardLayout: 'auto',
|
29167 | customVirtualKeyboardLayers: {},
|
29168 | customVirtualKeyboards: {},
|
29169 | virtualKeyboardTheme: /macos|ios/.test(osPlatform())
|
29170 | ? 'apple'
|
29171 | : 'material',
|
29172 | keypressVibration: true,
|
29173 | keypressSound: null,
|
29174 | plonkSound: null,
|
29175 | virtualKeyboardToolbar: 'default',
|
29176 | virtualKeyboardToggleGlyph: DEFAULT_KEYBOARD_TOGGLE_GLYPH,
|
29177 | virtualKeyboardMode: 'auto',
|
29178 | virtualKeyboardContainer: (_b = (_a = globalThis.document) === null || _a === void 0 ? void 0 : _a.body) !== null && _b !== void 0 ? _b : null,
|
29179 | };
|
29180 | }
|
29181 | handleEvent(event) {
|
29182 | if (event.type === 'message' &&
|
29183 | event.data &&
|
29184 | event.data.type === POST_MESSAGE_TYPE) {
|
29185 | if (!validateOrigin(event.origin, this.options.originValidator)) {
|
29186 | throw new Error(`Can not handle message from unknown origin (${event.origin}).`);
|
29187 | }
|
29188 | const { action } = event.data;
|
29189 | if (action === 'executeCommand') {
|
29190 | const { command } = event.data;
|
29191 | this.sourceFrame = event.source;
|
29192 | this.executeCommand(command);
|
29193 | }
|
29194 | }
|
29195 | }
|
29196 | stateChanged() {
|
29197 | var _a, _b;
|
29198 | this.sendMessage('stateChanged', {
|
29199 | state: {
|
29200 | visible: this.visible,
|
29201 | height: (_b = (_a = this.element) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0,
|
29202 | },
|
29203 | });
|
29204 | }
|
29205 | executeCommand(command) {
|
29206 | const commandTarget = getCommandTarget(command);
|
29207 |
|
29208 | if (commandTarget === 'virtual-keyboard') {
|
29209 | return super.executeCommand(command);
|
29210 | }
|
29211 | this.sendMessage('executeCommand', { command });
|
29212 | return false;
|
29213 | }
|
29214 | |
29215 |
|
29216 |
|
29217 | focus() {
|
29218 | this.sendMessage('focus');
|
29219 | }
|
29220 | |
29221 |
|
29222 |
|
29223 | blur() {
|
29224 | this.sendMessage('blur');
|
29225 | }
|
29226 | canUndo() {
|
29227 | return this.canUndoState;
|
29228 | }
|
29229 | canRedo() {
|
29230 | return this.canRedoState;
|
29231 | }
|
29232 | dispose() {
|
29233 | window.removeEventListener('message', this);
|
29234 | }
|
29235 | sendMessage(action, payload = {}) {
|
29236 | var _a;
|
29237 | (_a = this.sourceFrame) === null || _a === void 0 ? void 0 : _a.postMessage({
|
29238 | type: POST_MESSAGE_TYPE,
|
29239 | action,
|
29240 | ...payload,
|
29241 | }, this.options.targetOrigin);
|
29242 | }
|
29243 | }
|
29244 |
|
29245 | function isOffset(value) {
|
29246 | return typeof value === 'number' && !Number.isNaN(value);
|
29247 | }
|
29248 | function isRange(value) {
|
29249 | return Array.isArray(value) && value.length === 2;
|
29250 | }
|
29251 | function isSelection(value) {
|
29252 | return (value !== undefined &&
|
29253 | value !== null &&
|
29254 | typeof value === 'object' &&
|
29255 | 'ranges' in value &&
|
29256 | Array.isArray(value.ranges));
|
29257 | }
|
29258 |
|
29259 | const e$1 = [127462, 127487];
|
29260 | function i$1(e) { return 8205 === e || 65038 === e || 65039 === e || e >= 127995 && e <= 128e3 || e >= 129456 && e <= 129460 || e >= 917536 && e <= 917632; }
|
29261 | function t$1(i) { return i >= e$1[0] && i <= e$1[1]; }
|
29262 | class r$1 {
|
29263 | constructor(e) { this.obeyspaces = !1, this.s = function (e) { if (/^[\u0020-\u00FF]*$/.test(e))
|
29264 | return e; const r = [], n = function (e) { const i = []; for (let t = 0; t < e.length; t++) {
|
29265 | let r = e.charCodeAt(t);
|
29266 | if (r >= 55296 && r <= 56319) {
|
29267 | const i = e.charCodeAt(t + 1);
|
29268 | i >= 56320 && i <= 57343 && (r = 65536 + 1024 * (r - 55296) + (i - 56320), t++);
|
29269 | }
|
29270 | i.push(r);
|
29271 | } return i; }(e); let s = 0; for (; s < n.length;) {
|
29272 | const e = n[s++], a = n[s];
|
29273 | if (8205 === a) {
|
29274 | const e = s - 1;
|
29275 | for (s += 2; 8205 === n[s];)
|
29276 | s += 2;
|
29277 | r.push(String.fromCodePoint(...n.slice(e, 2 * s - e + 1)));
|
29278 | }
|
29279 | else if (i$1(a)) {
|
29280 | const e = s - 1;
|
29281 | for (; i$1(n[s]);)
|
29282 | s += 8205 === n[s] ? 2 : 1;
|
29283 | r.push(String.fromCodePoint(...n.slice(e, 2 * s - e - 1)));
|
29284 | }
|
29285 | else
|
29286 | t$1(e) ? (s += 1, r.push(String.fromCodePoint(...n.slice(s - 2, 2)))) : r.push(String.fromCodePoint(e));
|
29287 | } return r; }(e), this.pos = 0; }
|
29288 | end() { return this.pos >= this.s.length; }
|
29289 | get() { return this.pos < this.s.length ? this.s[this.pos++] : ""; }
|
29290 | peek() { return this.s[this.pos]; }
|
29291 | match(e) { let i; return i = "string" == typeof this.s ? e.exec(this.s.slice(this.pos)) : e.exec(this.s.slice(this.pos).join("")), (null == i ? void 0 : i[0]) ? (this.pos += i[0].length, i[0]) : null; }
|
29292 | next() { if (this.end())
|
29293 | return null; if (!this.obeyspaces && this.match(/^[ \f\n\r\t\v\xA0\u2028\u2029]+/))
|
29294 | return "<space>"; if (this.obeyspaces && this.match(/^[ \f\n\r\t\v\xA0\u2028\u2029]/))
|
29295 | return "<space>"; const e = this.get(); if ("\\" === e) {
|
29296 | if (!this.end()) {
|
29297 | let e = this.match(/^[a-zA-Z*]+/);
|
29298 | if (e)
|
29299 | this.match(/^[ \f\n\r\t\v\xA0\u2028\u2029]*/);
|
29300 | else if (e = this.get(), " " === e)
|
29301 | return "<space>";
|
29302 | return "\\" + e;
|
29303 | }
|
29304 | }
|
29305 | else {
|
29306 | if ("{" === e)
|
29307 | return "<{>";
|
29308 | if ("}" === e)
|
29309 | return "<}>";
|
29310 | if ("^" === e) {
|
29311 | if ("^" === this.peek()) {
|
29312 | this.get();
|
29313 | const e = this.match(/^(\^(\^(\^(\^[0-9a-f])?[0-9a-f])?[0-9a-f])?[0-9a-f])?[0-9a-f][0-9a-f]/);
|
29314 | if (e)
|
29315 | return String.fromCodePoint(parseInt(e.slice(e.lastIndexOf("^") + 1), 16));
|
29316 | }
|
29317 | return e;
|
29318 | }
|
29319 | if ("#" === e) {
|
29320 | if (!this.end()) {
|
29321 | let e = !1;
|
29322 | if (/[0-9?]/.test(this.peek()) && (e = !0, this.pos + 1 < this.s.length)) {
|
29323 | const i = this.s[this.pos + 1];
|
29324 | e = /[^0-9A-Za-z]/.test(i);
|
29325 | }
|
29326 | return e ? "#" + this.get() : "#";
|
29327 | }
|
29328 | }
|
29329 | else if ("$" === e)
|
29330 | return "$" === this.peek() ? (this.get(), "<$$>") : "<$>";
|
29331 | } return e; }
|
29332 | }
|
29333 | function n$1(e, i) { var t, r, n, a; let o = [], l = e.next(); if (l)
|
29334 | if ("\\relax" === l)
|
29335 | ;
|
29336 | else if ("\\noexpand" === l)
|
29337 | l = e.next(), l && o.push(l);
|
29338 | else if ("\\obeyspaces" === l)
|
29339 | e.obeyspaces = !0;
|
29340 | else if ("\\space" === l || "~" === l)
|
29341 | o.push("<space>");
|
29342 | else if ("\\bgroup" === l)
|
29343 | o.push("<{>");
|
29344 | else if ("\\egroup" === l)
|
29345 | o.push("<}>");
|
29346 | else if ("\\string" === l)
|
29347 | l = e.next(), l && ("\\" === l[0] ? Array.from(l).forEach((e => o.push("\\" === e ? "\\backslash" : e))) : "<{>" === l ? o.push("\\{") : "<space>" === l ? o.push("~") : "<}>" === l && o.push("\\}"));
|
29348 | else if ("\\csname" === l) {
|
29349 | for (; "<space>" === e.peek();)
|
29350 | e.next();
|
29351 | let n = "", a = !1, u = [];
|
29352 | do {
|
29353 | if (0 === u.length)
|
29354 | if (/^#[0-9?]$/.test(e.peek())) {
|
29355 | const n = e.get().slice(1);
|
29356 | u = s$1(null !== (r = null !== (t = null == i ? void 0 : i[n]) && void 0 !== t ? t : null == i ? void 0 : i["?"]) && void 0 !== r ? r : "\\placeholder{}", i), l = u[0];
|
29357 | }
|
29358 | else
|
29359 | l = e.next(), u = l ? [l] : [];
|
29360 | a = 0 === u.length, a || "\\endcsname" !== l || (a = !0, u.shift()), a || (a = "<$>" === l || "<$$>" === l || "<{>" === l || "<}>" === l || !!l && l.length > 1 && "\\" === l[0]), a || (n += u.shift());
|
29361 | } while (!a);
|
29362 | n && o.push("\\" + n), o = o.concat(u);
|
29363 | }
|
29364 | else if ("\\endcsname" === l)
|
29365 | ;
|
29366 | else if (l.length > 1 && "#" === l[0]) {
|
29367 | const e = l.slice(1);
|
29368 | o = o.concat(s$1(null !== (a = null !== (n = null == i ? void 0 : i[e]) && void 0 !== n ? n : null == i ? void 0 : i["?"]) && void 0 !== a ? a : "\\placeholder{}", i));
|
29369 | }
|
29370 | else
|
29371 | o.push(l); return o; }
|
29372 | function s$1(e, i) { const t = e.toString().split(/\r?\n/); let s = "", a = ""; for (const e of t) {
|
29373 | s += a, a = " ";
|
29374 | const i = e.match(/((?:\\%)|[^%])*/);
|
29375 | null !== i && (s += i[0]);
|
29376 | } const o = new r$1(s); let l = []; do {
|
29377 | l = l.concat(n$1(o, i));
|
29378 | } while (!o.end()); return l; }
|
29379 | function a$1(e) { let i = "", t = ""; for (const r of e)
|
29380 | r && (/[a-zA-Z*]/.test(r[0]) && (t += i), i = /\\[a-zA-Z]+\*?$/.test(r) ? " " : "", t += r); return t; }
|
29381 | function o$1(e) { let i = []; if (Array.isArray(e))
|
29382 | for (const t of e)
|
29383 | Array.isArray(t) ? i = [...i, ...t] : i.push(t);
|
29384 | else
|
29385 | i = [e]; return a$1(i.map((e => { var i; return null !== (i = { "<space>": " ", "<$$>": "$$", "<$>": "$", "<{>": "{", "<}>": "}" }[e]) && void 0 !== i ? i : e; }))); }
|
29386 | var l$1, u$1 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {}, c$1 = { exports: {} };
|
29387 | l$1 = c$1, function (e) { var i, t, r, n, s = 9e15, a = 1e9, o = "0123456789abcdef", u = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", c = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", h = { precision: 20, rounding: 4, modulo: 1, toExpNeg: -7, toExpPos: 21, minE: -s, maxE: s, crypto: !1 }, g = !0, p = "[DecimalError] ", f = p + "Invalid argument: ", m = p + "Precision limit exceeded", d = p + "crypto unavailable", v = Math.floor, x = Math.pow, y = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i, b = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i, w = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i, N = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, q = 1e7, E = u.length - 1, M = c.length - 1, S = { name: "[object Decimal]" }; function A(e) { var i, t, r, n = e.length - 1, s = "", a = e[0]; if (n > 0) {
|
29388 | for (s += a, i = 1; i < n; i++)
|
29389 | (t = 7 - (r = e[i] + "").length) && (s += R(t)), s += r;
|
29390 | (t = 7 - (r = (a = e[i]) + "").length) && (s += R(t));
|
29391 | }
|
29392 | else if (0 === a)
|
29393 | return "0"; for (; a % 10 == 0;)
|
29394 | a /= 10; return s + a; } function z(e, i, t) { if (e !== ~~e || e < i || e > t)
|
29395 | throw Error(f + e); } function k(e, i, t, r) { var n, s, a, o; for (s = e[0]; s >= 10; s /= 10)
|
29396 | --i; return --i < 0 ? (i += 7, n = 0) : (n = Math.ceil((i + 1) / 7), i %= 7), s = x(10, 7 - i), o = e[n] % s | 0, null == r ? i < 3 ? (0 == i ? o = o / 100 | 0 : 1 == i && (o = o / 10 | 0), a = t < 4 && 99999 == o || t > 3 && 49999 == o || 5e4 == o || 0 == o) : a = (t < 4 && o + 1 == s || t > 3 && o + 1 == s / 2) && (e[n + 1] / s / 100 | 0) == x(10, i - 2) - 1 || (o == s / 2 || 0 == o) && 0 == (e[n + 1] / s / 100 | 0) : i < 4 ? (0 == i ? o = o / 1e3 | 0 : 1 == i ? o = o / 100 | 0 : 2 == i && (o = o / 10 | 0), a = (r || t < 4) && 9999 == o || !r && t > 3 && 4999 == o) : a = ((r || t < 4) && o + 1 == s || !r && t > 3 && o + 1 == s / 2) && (e[n + 1] / s / 1e3 | 0) == x(10, i - 3) - 1, a; } function I(e, i, t) { for (var r, n, s = [0], a = 0, l = e.length; a < l;) {
|
29397 | for (n = s.length; n--;)
|
29398 | s[n] *= i;
|
29399 | for (s[0] += o.indexOf(e.charAt(a++)), r = 0; r < s.length; r++)
|
29400 | s[r] > t - 1 && (void 0 === s[r + 1] && (s[r + 1] = 0), s[r + 1] += s[r] / t | 0, s[r] %= t);
|
29401 | } return s.reverse(); } S.absoluteValue = S.abs = function () { var e = new this.constructor(this); return e.s < 0 && (e.s = 1), L(e); }, S.ceil = function () { return L(new this.constructor(this), this.e + 1, 2); }, S.comparedTo = S.cmp = function (e) { var i, t, r, n, s = this, a = s.d, o = (e = new s.constructor(e)).d, l = s.s, u = e.s; if (!a || !o)
|
29402 | return l && u ? l !== u ? l : a === o ? 0 : !a ^ l < 0 ? 1 : -1 : NaN; if (!a[0] || !o[0])
|
29403 | return a[0] ? l : o[0] ? -u : 0; if (l !== u)
|
29404 | return l; if (s.e !== e.e)
|
29405 | return s.e > e.e ^ l < 0 ? 1 : -1; for (i = 0, t = (r = a.length) < (n = o.length) ? r : n; i < t; ++i)
|
29406 | if (a[i] !== o[i])
|
29407 | return a[i] > o[i] ^ l < 0 ? 1 : -1; return r === n ? 0 : r > n ^ l < 0 ? 1 : -1; }, S.cosine = S.cos = function () { var e, i, t = this, r = t.constructor; return t.d ? t.d[0] ? (e = r.precision, i = r.rounding, r.precision = e + Math.max(t.e, t.sd()) + 7, r.rounding = 1, t = function (e, i) { var t, r, n = i.d.length; n < 32 ? r = (1 / V(4, t = Math.ceil(n / 3))).toString() : (t = 16, r = "2.3283064365386962890625e-10"), e.precision += t, i = W(e, 1, i.times(r), new e(1)); for (var s = t; s--;) {
|
29408 | var a = i.times(i);
|
29409 | i = a.times(a).minus(a).times(8).plus(1);
|
29410 | } return e.precision -= t, i; }(r, Q(r, t)), r.precision = e, r.rounding = i, L(2 == n || 3 == n ? t.neg() : t, e, i, !0)) : new r(1) : new r(NaN); }, S.cubeRoot = S.cbrt = function () { var e, i, t, r, n, s, a, o, l, u, c = this, h = c.constructor; if (!c.isFinite() || c.isZero())
|
29411 | return new h(c); for (g = !1, (s = c.s * x(c.s * c, 1 / 3)) && Math.abs(s) != 1 / 0 ? r = new h(s.toString()) : (t = A(c.d), (s = ((e = c.e) - t.length + 1) % 3) && (t += 1 == s || -2 == s ? "0" : "00"), s = x(t, 1 / 3), e = v((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2)), (r = new h(t = s == 1 / 0 ? "5e" + e : (t = s.toExponential()).slice(0, t.indexOf("e") + 1) + e)).s = c.s), a = (e = h.precision) + 3;;)
|
29412 | if (u = (l = (o = r).times(o).times(o)).plus(c), r = O(u.plus(c).times(o), u.plus(l), a + 2, 1), A(o.d).slice(0, a) === (t = A(r.d)).slice(0, a)) {
|
29413 | if ("9999" != (t = t.slice(a - 3, a + 1)) && (n || "4999" != t)) {
|
29414 | +t && (+t.slice(1) || "5" != t.charAt(0)) || (L(r, e + 1, 1), i = !r.times(r).times(r).eq(c));
|
29415 | break;
|
29416 | }
|
29417 | if (!n && (L(o, e + 1, 0), o.times(o).times(o).eq(c))) {
|
29418 | r = o;
|
29419 | break;
|
29420 | }
|
29421 | a += 4, n = 1;
|
29422 | } return g = !0, L(r, e, h.rounding, i); }, S.decimalPlaces = S.dp = function () { var e, i = this.d, t = NaN; if (i) {
|
29423 | if (t = 7 * ((e = i.length - 1) - v(this.e / 7)), e = i[e])
|
29424 | for (; e % 10 == 0; e /= 10)
|
29425 | t--;
|
29426 | t < 0 && (t = 0);
|
29427 | } return t; }, S.dividedBy = S.div = function (e) { return O(this, new this.constructor(e)); }, S.dividedToIntegerBy = S.divToInt = function (e) { var i = this.constructor; return L(O(this, new i(e), 0, 1, 1), i.precision, i.rounding); }, S.equals = S.eq = function (e) { return 0 === this.cmp(e); }, S.floor = function () { return L(new this.constructor(this), this.e + 1, 3); }, S.greaterThan = S.gt = function (e) { return this.cmp(e) > 0; }, S.greaterThanOrEqualTo = S.gte = function (e) { var i = this.cmp(e); return 1 == i || 0 === i; }, S.hyperbolicCosine = S.cosh = function () { var e, i, t, r, n, s = this, a = s.constructor, o = new a(1); if (!s.isFinite())
|
29428 | return new a(s.s ? 1 / 0 : NaN); if (s.isZero())
|
29429 | return o; t = a.precision, r = a.rounding, a.precision = t + Math.max(s.e, s.sd()) + 4, a.rounding = 1, (n = s.d.length) < 32 ? i = (1 / V(4, e = Math.ceil(n / 3))).toString() : (e = 16, i = "2.3283064365386962890625e-10"), s = W(a, 1, s.times(i), new a(1), !0); for (var l, u = e, c = new a(8); u--;)
|
29430 | l = s.times(s), s = o.minus(l.times(c.minus(l.times(c)))); return L(s, a.precision = t, a.rounding = r, !0); }, S.hyperbolicSine = S.sinh = function () { var e, i, t, r, n = this, s = n.constructor; if (!n.isFinite() || n.isZero())
|
29431 | return new s(n); if (i = s.precision, t = s.rounding, s.precision = i + Math.max(n.e, n.sd()) + 4, s.rounding = 1, (r = n.d.length) < 3)
|
29432 | n = W(s, 2, n, n, !0);
|
29433 | else {
|
29434 | e = (e = 1.4 * Math.sqrt(r)) > 16 ? 16 : 0 | e, n = W(s, 2, n = n.times(1 / V(5, e)), n, !0);
|
29435 | for (var a, o = new s(5), l = new s(16), u = new s(20); e--;)
|
29436 | a = n.times(n), n = n.times(o.plus(a.times(l.times(a).plus(u))));
|
29437 | } return s.precision = i, s.rounding = t, L(n, i, t, !0); }, S.hyperbolicTangent = S.tanh = function () { var e, i, t = this, r = t.constructor; return t.isFinite() ? t.isZero() ? new r(t) : (e = r.precision, i = r.rounding, r.precision = e + 7, r.rounding = 1, O(t.sinh(), t.cosh(), r.precision = e, r.rounding = i)) : new r(t.s); }, S.inverseCosine = S.acos = function () { var e, i = this, t = i.constructor, r = i.abs().cmp(1), n = t.precision, s = t.rounding; return -1 !== r ? 0 === r ? i.isNeg() ? T(t, n, s) : new t(0) : new t(NaN) : i.isZero() ? T(t, n + 4, s).times(.5) : (t.precision = n + 6, t.rounding = 1, i = i.asin(), e = T(t, n + 4, s).times(.5), t.precision = n, t.rounding = s, e.minus(i)); }, S.inverseHyperbolicCosine = S.acosh = function () { var e, i, t = this, r = t.constructor; return t.lte(1) ? new r(t.eq(1) ? 0 : NaN) : t.isFinite() ? (e = r.precision, i = r.rounding, r.precision = e + Math.max(Math.abs(t.e), t.sd()) + 4, r.rounding = 1, g = !1, t = t.times(t).minus(1).sqrt().plus(t), g = !0, r.precision = e, r.rounding = i, t.ln()) : new r(t); }, S.inverseHyperbolicSine = S.asinh = function () { var e, i, t = this, r = t.constructor; return !t.isFinite() || t.isZero() ? new r(t) : (e = r.precision, i = r.rounding, r.precision = e + 2 * Math.max(Math.abs(t.e), t.sd()) + 6, r.rounding = 1, g = !1, t = t.times(t).plus(1).sqrt().plus(t), g = !0, r.precision = e, r.rounding = i, t.ln()); }, S.inverseHyperbolicTangent = S.atanh = function () { var e, i, t, r, n = this, s = n.constructor; return n.isFinite() ? n.e >= 0 ? new s(n.abs().eq(1) ? n.s / 0 : n.isZero() ? n : NaN) : (e = s.precision, i = s.rounding, r = n.sd(), Math.max(r, e) < 2 * -n.e - 1 ? L(new s(n), e, i, !0) : (s.precision = t = r - n.e, n = O(n.plus(1), new s(1).minus(n), t + e, 1), s.precision = e + 4, s.rounding = 1, n = n.ln(), s.precision = e, s.rounding = i, n.times(.5))) : new s(NaN); }, S.inverseSine = S.asin = function () { var e, i, t, r, n = this, s = n.constructor; return n.isZero() ? new s(n) : (i = n.abs().cmp(1), t = s.precision, r = s.rounding, -1 !== i ? 0 === i ? ((e = T(s, t + 4, r).times(.5)).s = n.s, e) : new s(NaN) : (s.precision = t + 6, s.rounding = 1, n = n.div(new s(1).minus(n.times(n)).sqrt().plus(1)).atan(), s.precision = t, s.rounding = r, n.times(2))); }, S.inverseTangent = S.atan = function () { var e, i, t, r, n, s, a, o, l, u = this, c = u.constructor, h = c.precision, p = c.rounding; if (u.isFinite()) {
|
29438 | if (u.isZero())
|
29439 | return new c(u);
|
29440 | if (u.abs().eq(1) && h + 4 <= M)
|
29441 | return (a = T(c, h + 4, p).times(.25)).s = u.s, a;
|
29442 | }
|
29443 | else {
|
29444 | if (!u.s)
|
29445 | return new c(NaN);
|
29446 | if (h + 4 <= M)
|
29447 | return (a = T(c, h + 4, p).times(.5)).s = u.s, a;
|
29448 | } for (c.precision = o = h + 10, c.rounding = 1, e = t = Math.min(28, o / 7 + 2 | 0); e; --e)
|
29449 | u = u.div(u.times(u).plus(1).sqrt().plus(1)); for (g = !1, i = Math.ceil(o / 7), r = 1, l = u.times(u), a = new c(u), n = u; -1 !== e;)
|
29450 | if (n = n.times(l), s = a.minus(n.div(r += 2)), n = n.times(l), void 0 !== (a = s.plus(n.div(r += 2))).d[i])
|
29451 | for (e = i; a.d[e] === s.d[e] && e--;)
|
29452 | ; return t && (a = a.times(2 << t - 1)), g = !0, L(a, c.precision = h, c.rounding = p, !0); }, S.isFinite = function () { return !!this.d; }, S.isInteger = S.isInt = function () { return !!this.d && v(this.e / 7) > this.d.length - 2; }, S.isNaN = function () { return !this.s; }, S.isNegative = S.isNeg = function () { return this.s < 0; }, S.isPositive = S.isPos = function () { return this.s > 0; }, S.isZero = function () { return !!this.d && 0 === this.d[0]; }, S.lessThan = S.lt = function (e) { return this.cmp(e) < 0; }, S.lessThanOrEqualTo = S.lte = function (e) { return this.cmp(e) < 1; }, S.logarithm = S.log = function (e) { var i, t, r, n, s, a, o, l, u = this, c = u.constructor, h = c.precision, p = c.rounding; if (null == e)
|
29453 | e = new c(10), i = !0;
|
29454 | else {
|
29455 | if (t = (e = new c(e)).d, e.s < 0 || !t || !t[0] || e.eq(1))
|
29456 | return new c(NaN);
|
29457 | i = e.eq(10);
|
29458 | } if (t = u.d, u.s < 0 || !t || !t[0] || u.eq(1))
|
29459 | return new c(t && !t[0] ? -1 / 0 : 1 != u.s ? NaN : t ? 0 : 1 / 0); if (i)
|
29460 | if (t.length > 1)
|
29461 | s = !0;
|
29462 | else {
|
29463 | for (n = t[0]; n % 10 == 0;)
|
29464 | n /= 10;
|
29465 | s = 1 !== n;
|
29466 | } if (g = !1, a = U(u, o = h + 5), r = i ? F(c, o + 10) : U(e, o), k((l = O(a, r, o, 1)).d, n = h, p))
|
29467 | do {
|
29468 | if (a = U(u, o += 10), r = i ? F(c, o + 10) : U(e, o), l = O(a, r, o, 1), !s) {
|
29469 | +A(l.d).slice(n + 1, n + 15) + 1 == 1e14 && (l = L(l, h + 1, 0));
|
29470 | break;
|
29471 | }
|
29472 | } while (k(l.d, n += 10, p)); return g = !0, L(l, h, p); }, S.minus = S.sub = function (e) { var i, t, r, n, s, a, o, l, u, c, h, p, f = this, m = f.constructor; if (e = new m(e), !f.d || !e.d)
|
29473 | return f.s && e.s ? f.d ? e.s = -e.s : e = new m(e.d || f.s !== e.s ? f : NaN) : e = new m(NaN), e; if (f.s != e.s)
|
29474 | return e.s = -e.s, f.plus(e); if (u = f.d, p = e.d, o = m.precision, l = m.rounding, !u[0] || !p[0]) {
|
29475 | if (p[0])
|
29476 | e.s = -e.s;
|
29477 | else {
|
29478 | if (!u[0])
|
29479 | return new m(3 === l ? -0 : 0);
|
29480 | e = new m(f);
|
29481 | }
|
29482 | return g ? L(e, o, l) : e;
|
29483 | } if (t = v(e.e / 7), c = v(f.e / 7), u = u.slice(), s = c - t) {
|
29484 | for ((h = s < 0) ? (i = u, s = -s, a = p.length) : (i = p, t = c, a = u.length), s > (r = Math.max(Math.ceil(o / 7), a) + 2) && (s = r, i.length = 1), i.reverse(), r = s; r--;)
|
29485 | i.push(0);
|
29486 | i.reverse();
|
29487 | }
|
29488 | else {
|
29489 | for ((h = (r = u.length) < (a = p.length)) && (a = r), r = 0; r < a; r++)
|
29490 | if (u[r] != p[r]) {
|
29491 | h = u[r] < p[r];
|
29492 | break;
|
29493 | }
|
29494 | s = 0;
|
29495 | } for (h && (i = u, u = p, p = i, e.s = -e.s), a = u.length, r = p.length - a; r > 0; --r)
|
29496 | u[a++] = 0; for (r = p.length; r > s;) {
|
29497 | if (u[--r] < p[r]) {
|
29498 | for (n = r; n && 0 === u[--n];)
|
29499 | u[n] = q - 1;
|
29500 | --u[n], u[r] += q;
|
29501 | }
|
29502 | u[r] -= p[r];
|
29503 | } for (; 0 === u[--a];)
|
29504 | u.pop(); for (; 0 === u[0]; u.shift())
|
29505 | --t; return u[0] ? (e.d = u, e.e = D(u, t), g ? L(e, o, l) : e) : new m(3 === l ? -0 : 0); }, S.modulo = S.mod = function (e) { var i, t = this, r = t.constructor; return e = new r(e), !t.d || !e.s || e.d && !e.d[0] ? new r(NaN) : !e.d || t.d && !t.d[0] ? L(new r(t), r.precision, r.rounding) : (g = !1, 9 == r.modulo ? (i = O(t, e.abs(), 0, 3, 1)).s *= e.s : i = O(t, e, 0, r.modulo, 1), i = i.times(e), g = !0, t.minus(i)); }, S.naturalExponential = S.exp = function () { return _(this); }, S.naturalLogarithm = S.ln = function () { return U(this); }, S.negated = S.neg = function () { var e = new this.constructor(this); return e.s = -e.s, L(e); }, S.plus = S.add = function (e) { var i, t, r, n, s, a, o, l, u, c, h = this, p = h.constructor; if (e = new p(e), !h.d || !e.d)
|
29506 | return h.s && e.s ? h.d || (e = new p(e.d || h.s === e.s ? h : NaN)) : e = new p(NaN), e; if (h.s != e.s)
|
29507 | return e.s = -e.s, h.minus(e); if (u = h.d, c = e.d, o = p.precision, l = p.rounding, !u[0] || !c[0])
|
29508 | return c[0] || (e = new p(h)), g ? L(e, o, l) : e; if (s = v(h.e / 7), r = v(e.e / 7), u = u.slice(), n = s - r) {
|
29509 | for (n < 0 ? (t = u, n = -n, a = c.length) : (t = c, r = s, a = u.length), n > (a = (s = Math.ceil(o / 7)) > a ? s + 1 : a + 1) && (n = a, t.length = 1), t.reverse(); n--;)
|
29510 | t.push(0);
|
29511 | t.reverse();
|
29512 | } for ((a = u.length) - (n = c.length) < 0 && (n = a, t = c, c = u, u = t), i = 0; n;)
|
29513 | i = (u[--n] = u[n] + c[n] + i) / q | 0, u[n] %= q; for (i && (u.unshift(i), ++r), a = u.length; 0 == u[--a];)
|
29514 | u.pop(); return e.d = u, e.e = D(u, r), g ? L(e, o, l) : e; }, S.precision = S.sd = function (e) { var i, t = this; if (void 0 !== e && e !== !!e && 1 !== e && 0 !== e)
|
29515 | throw Error(f + e); return t.d ? (i = C(t.d), e && t.e + 1 > i && (i = t.e + 1)) : i = NaN, i; }, S.round = function () { var e = this, i = e.constructor; return L(new i(e), e.e + 1, i.rounding); }, S.sine = S.sin = function () { var e, i, t = this, r = t.constructor; return t.isFinite() ? t.isZero() ? new r(t) : (e = r.precision, i = r.rounding, r.precision = e + Math.max(t.e, t.sd()) + 7, r.rounding = 1, t = function (e, i) { var t, r = i.d.length; if (r < 3)
|
29516 | return W(e, 2, i, i); t = (t = 1.4 * Math.sqrt(r)) > 16 ? 16 : 0 | t, i = W(e, 2, i = i.times(1 / V(5, t)), i); for (var n, s = new e(5), a = new e(16), o = new e(20); t--;)
|
29517 | n = i.times(i), i = i.times(s.plus(n.times(a.times(n).minus(o)))); return i; }(r, Q(r, t)), r.precision = e, r.rounding = i, L(n > 2 ? t.neg() : t, e, i, !0)) : new r(NaN); }, S.squareRoot = S.sqrt = function () { var e, i, t, r, n, s, a = this, o = a.d, l = a.e, u = a.s, c = a.constructor; if (1 !== u || !o || !o[0])
|
29518 | return new c(!u || u < 0 && (!o || o[0]) ? NaN : o ? a : 1 / 0); for (g = !1, 0 == (u = Math.sqrt(+a)) || u == 1 / 0 ? (((i = A(o)).length + l) % 2 == 0 && (i += "0"), u = Math.sqrt(i), l = v((l + 1) / 2) - (l < 0 || l % 2), r = new c(i = u == 1 / 0 ? "5e" + l : (i = u.toExponential()).slice(0, i.indexOf("e") + 1) + l)) : r = new c(u.toString()), t = (l = c.precision) + 3;;)
|
29519 | if (r = (s = r).plus(O(a, s, t + 2, 1)).times(.5), A(s.d).slice(0, t) === (i = A(r.d)).slice(0, t)) {
|
29520 | if ("9999" != (i = i.slice(t - 3, t + 1)) && (n || "4999" != i)) {
|
29521 | +i && (+i.slice(1) || "5" != i.charAt(0)) || (L(r, l + 1, 1), e = !r.times(r).eq(a));
|
29522 | break;
|
29523 | }
|
29524 | if (!n && (L(s, l + 1, 0), s.times(s).eq(a))) {
|
29525 | r = s;
|
29526 | break;
|
29527 | }
|
29528 | t += 4, n = 1;
|
29529 | } return g = !0, L(r, l, c.rounding, e); }, S.tangent = S.tan = function () { var e, i, t = this, r = t.constructor; return t.isFinite() ? t.isZero() ? new r(t) : (e = r.precision, i = r.rounding, r.precision = e + 10, r.rounding = 1, (t = t.sin()).s = 1, t = O(t, new r(1).minus(t.times(t)).sqrt(), e + 10, 0), r.precision = e, r.rounding = i, L(2 == n || 4 == n ? t.neg() : t, e, i, !0)) : new r(NaN); }, S.times = S.mul = function (e) { var i, t, r, n, s, a, o, l, u, c = this, h = c.constructor, p = c.d, f = (e = new h(e)).d; if (e.s *= c.s, !(p && p[0] && f && f[0]))
|
29530 | return new h(!e.s || p && !p[0] && !f || f && !f[0] && !p ? NaN : p && f ? 0 * e.s : e.s / 0); for (t = v(c.e / 7) + v(e.e / 7), (l = p.length) < (u = f.length) && (s = p, p = f, f = s, a = l, l = u, u = a), s = [], r = a = l + u; r--;)
|
29531 | s.push(0); for (r = u; --r >= 0;) {
|
29532 | for (i = 0, n = l + r; n > r;)
|
29533 | o = s[n] + f[r] * p[n - r - 1] + i, s[n--] = o % q | 0, i = o / q | 0;
|
29534 | s[n] = (s[n] + i) % q | 0;
|
29535 | } for (; !s[--a];)
|
29536 | s.pop(); return i ? ++t : s.shift(), e.d = s, e.e = D(s, t), g ? L(e, h.precision, h.rounding) : e; }, S.toBinary = function (e, i) { return Y(this, 2, e, i); }, S.toDecimalPlaces = S.toDP = function (e, i) { var t = this, r = t.constructor; return t = new r(t), void 0 === e ? t : (z(e, 0, a), void 0 === i ? i = r.rounding : z(i, 0, 8), L(t, e + t.e + 1, i)); }, S.toExponential = function (e, i) { var t, r = this, n = r.constructor; return void 0 === e ? t = P(r, !0) : (z(e, 0, a), void 0 === i ? i = n.rounding : z(i, 0, 8), t = P(r = L(new n(r), e + 1, i), !0, e + 1)), r.isNeg() && !r.isZero() ? "-" + t : t; }, S.toFixed = function (e, i) { var t, r, n = this, s = n.constructor; return void 0 === e ? t = P(n) : (z(e, 0, a), void 0 === i ? i = s.rounding : z(i, 0, 8), t = P(r = L(new s(n), e + n.e + 1, i), !1, e + r.e + 1)), n.isNeg() && !n.isZero() ? "-" + t : t; }, S.toFraction = function (e) { var i, t, r, n, s, a, o, l, u, c, h, p, m = this, d = m.d, v = m.constructor; if (!d)
|
29537 | return new v(m); if (u = t = new v(1), r = l = new v(0), a = (s = (i = new v(r)).e = C(d) - m.e - 1) % 7, i.d[0] = x(10, a < 0 ? 7 + a : a), null == e)
|
29538 | e = s > 0 ? i : u;
|
29539 | else {
|
29540 | if (!(o = new v(e)).isInt() || o.lt(u))
|
29541 | throw Error(f + o);
|
29542 | e = o.gt(i) ? s > 0 ? i : u : o;
|
29543 | } for (g = !1, o = new v(A(d)), c = v.precision, v.precision = s = 7 * d.length * 2; h = O(o, i, 0, 1, 1), 1 != (n = t.plus(h.times(r))).cmp(e);)
|
29544 | t = r, r = n, n = u, u = l.plus(h.times(n)), l = n, n = i, i = o.minus(h.times(n)), o = n; return n = O(e.minus(t), r, 0, 1, 1), l = l.plus(n.times(u)), t = t.plus(n.times(r)), l.s = u.s = m.s, p = O(u, r, s, 1).minus(m).abs().cmp(O(l, t, s, 1).minus(m).abs()) < 1 ? [u, r] : [l, t], v.precision = c, g = !0, p; }, S.toHexadecimal = S.toHex = function (e, i) { return Y(this, 16, e, i); }, S.toNearest = function (e, i) { var t = this, r = t.constructor; if (t = new r(t), null == e) {
|
29545 | if (!t.d)
|
29546 | return t;
|
29547 | e = new r(1), i = r.rounding;
|
29548 | }
|
29549 | else {
|
29550 | if (e = new r(e), void 0 === i ? i = r.rounding : z(i, 0, 8), !t.d)
|
29551 | return e.s ? t : e;
|
29552 | if (!e.d)
|
29553 | return e.s && (e.s = t.s), e;
|
29554 | } return e.d[0] ? (g = !1, t = O(t, e, 0, i, 1).times(e), g = !0, L(t)) : (e.s = t.s, t = e), t; }, S.toNumber = function () { return +this; }, S.toOctal = function (e, i) { return Y(this, 8, e, i); }, S.toPower = S.pow = function (e) { var i, t, r, n, s, a, o = this, l = o.constructor, u = +(e = new l(e)); if (!(o.d && e.d && o.d[0] && e.d[0]))
|
29555 | return new l(x(+o, u)); if ((o = new l(o)).eq(1))
|
29556 | return o; if (r = l.precision, s = l.rounding, e.eq(1))
|
29557 | return L(o, r, s); if ((i = v(e.e / 7)) >= e.d.length - 1 && (t = u < 0 ? -u : u) <= 9007199254740991)
|
29558 | return n = $(l, o, t, r), e.s < 0 ? new l(1).div(n) : L(n, r, s); if ((a = o.s) < 0) {
|
29559 | if (i < e.d.length - 1)
|
29560 | return new l(NaN);
|
29561 | if (0 == (1 & e.d[i]) && (a = 1), 0 == o.e && 1 == o.d[0] && 1 == o.d.length)
|
29562 | return o.s = a, o;
|
29563 | } return (i = 0 != (t = x(+o, u)) && isFinite(t) ? new l(t + "").e : v(u * (Math.log("0." + A(o.d)) / Math.LN10 + o.e + 1))) > l.maxE + 1 || i < l.minE - 1 ? new l(i > 0 ? a / 0 : 0) : (g = !1, l.rounding = o.s = 1, t = Math.min(12, (i + "").length), (n = _(e.times(U(o, r + t)), r)).d && k((n = L(n, r + 5, 1)).d, r, s) && (i = r + 10, +A((n = L(_(e.times(U(o, i + t)), i), i + 5, 1)).d).slice(r + 1, r + 15) + 1 == 1e14 && (n = L(n, r + 1, 0))), n.s = a, g = !0, l.rounding = s, L(n, r, s)); }, S.toPrecision = function (e, i) { var t, r = this, n = r.constructor; return void 0 === e ? t = P(r, r.e <= n.toExpNeg || r.e >= n.toExpPos) : (z(e, 1, a), void 0 === i ? i = n.rounding : z(i, 0, 8), t = P(r = L(new n(r), e, i), e <= r.e || r.e <= n.toExpNeg, e)), r.isNeg() && !r.isZero() ? "-" + t : t; }, S.toSignificantDigits = S.toSD = function (e, i) { var t = this.constructor; return void 0 === e ? (e = t.precision, i = t.rounding) : (z(e, 1, a), void 0 === i ? i = t.rounding : z(i, 0, 8)), L(new t(this), e, i); }, S.toString = function () { var e = this, i = e.constructor, t = P(e, e.e <= i.toExpNeg || e.e >= i.toExpPos); return e.isNeg() && !e.isZero() ? "-" + t : t; }, S.truncated = S.trunc = function () { return L(new this.constructor(this), this.e + 1, 1); }, S.valueOf = S.toJSON = function () { var e = this, i = e.constructor, t = P(e, e.e <= i.toExpNeg || e.e >= i.toExpPos); return e.isNeg() ? "-" + t : t; }; var O = function () { function e(e, i, t) { var r, n = 0, s = e.length; for (e = e.slice(); s--;)
|
29564 | r = e[s] * i + n, e[s] = r % t | 0, n = r / t | 0; return n && e.unshift(n), e; } function i(e, i, t, r) { var n, s; if (t != r)
|
29565 | s = t > r ? 1 : -1;
|
29566 | else
|
29567 | for (n = s = 0; n < t; n++)
|
29568 | if (e[n] != i[n]) {
|
29569 | s = e[n] > i[n] ? 1 : -1;
|
29570 | break;
|
29571 | } return s; } function r(e, i, t, r) { for (var n = 0; t--;)
|
29572 | e[t] -= n, n = e[t] < i[t] ? 1 : 0, e[t] = n * r + e[t] - i[t]; for (; !e[0] && e.length > 1;)
|
29573 | e.shift(); } return function (n, s, a, o, l, u) { var c, h, g, p, f, m, d, x, y, b, w, N, E, M, S, A, z, k, I, O, P = n.constructor, D = n.s == s.s ? 1 : -1, F = n.d, T = s.d; if (!(F && F[0] && T && T[0]))
|
29574 | return new P(n.s && s.s && (F ? !T || F[0] != T[0] : T) ? F && 0 == F[0] || !T ? 0 * D : D / 0 : NaN); for (u ? (f = 1, h = n.e - s.e) : (u = q, f = 7, h = v(n.e / f) - v(s.e / f)), I = T.length, z = F.length, b = (y = new P(D)).d = [], g = 0; T[g] == (F[g] || 0); g++)
|
29575 | ; if (T[g] > (F[g] || 0) && h--, null == a ? (M = a = P.precision, o = P.rounding) : M = l ? a + (n.e - s.e) + 1 : a, M < 0)
|
29576 | b.push(1), m = !0;
|
29577 | else {
|
29578 | if (M = M / f + 2 | 0, g = 0, 1 == I) {
|
29579 | for (p = 0, T = T[0], M++; (g < z || p) && M--; g++)
|
29580 | S = p * u + (F[g] || 0), b[g] = S / T | 0, p = S % T | 0;
|
29581 | m = p || g < z;
|
29582 | }
|
29583 | else {
|
29584 | for ((p = u / (T[0] + 1) | 0) > 1 && (T = e(T, p, u), F = e(F, p, u), I = T.length, z = F.length), A = I, N = (w = F.slice(0, I)).length; N < I;)
|
29585 | w[N++] = 0;
|
29586 | (O = T.slice()).unshift(0), k = T[0], T[1] >= u / 2 && ++k;
|
29587 | do {
|
29588 | p = 0, (c = i(T, w, I, N)) < 0 ? (E = w[0], I != N && (E = E * u + (w[1] || 0)), (p = E / k | 0) > 1 ? (p >= u && (p = u - 1), 1 == (c = i(d = e(T, p, u), w, x = d.length, N = w.length)) && (p--, r(d, I < x ? O : T, x, u))) : (0 == p && (c = p = 1), d = T.slice()), (x = d.length) < N && d.unshift(0), r(w, d, N, u), -1 == c && (c = i(T, w, I, N = w.length)) < 1 && (p++, r(w, I < N ? O : T, N, u)), N = w.length) : 0 === c && (p++, w = [0]), b[g++] = p, c && w[0] ? w[N++] = F[A] || 0 : (w = [F[A]], N = 1);
|
29589 | } while ((A++ < z || void 0 !== w[0]) && M--);
|
29590 | m = void 0 !== w[0];
|
29591 | }
|
29592 | b[0] || b.shift();
|
29593 | } if (1 == f)
|
29594 | y.e = h, t = m;
|
29595 | else {
|
29596 | for (g = 1, p = b[0]; p >= 10; p /= 10)
|
29597 | g++;
|
29598 | y.e = g + h * f - 1, L(y, l ? a + y.e + 1 : a, o, m);
|
29599 | } return y; }; }(); function L(e, i, t, r) { var n, s, a, o, l, u, c, h, p, f = e.constructor; e: if (null != i) {
|
29600 | if (!(h = e.d))
|
29601 | return e;
|
29602 | for (n = 1, o = h[0]; o >= 10; o /= 10)
|
29603 | n++;
|
29604 | if ((s = i - n) < 0)
|
29605 | s += 7, a = i, l = (c = h[p = 0]) / x(10, n - a - 1) % 10 | 0;
|
29606 | else if ((p = Math.ceil((s + 1) / 7)) >= (o = h.length)) {
|
29607 | if (!r)
|
29608 | break e;
|
29609 | for (; o++ <= p;)
|
29610 | h.push(0);
|
29611 | c = l = 0, n = 1, a = (s %= 7) - 7 + 1;
|
29612 | }
|
29613 | else {
|
29614 | for (c = o = h[p], n = 1; o >= 10; o /= 10)
|
29615 | n++;
|
29616 | l = (a = (s %= 7) - 7 + n) < 0 ? 0 : c / x(10, n - a - 1) % 10 | 0;
|
29617 | }
|
29618 | if (r = r || i < 0 || void 0 !== h[p + 1] || (a < 0 ? c : c % x(10, n - a - 1)), u = t < 4 ? (l || r) && (0 == t || t == (e.s < 0 ? 3 : 2)) : l > 5 || 5 == l && (4 == t || r || 6 == t && (s > 0 ? a > 0 ? c / x(10, n - a) : 0 : h[p - 1]) % 10 & 1 || t == (e.s < 0 ? 8 : 7)), i < 1 || !h[0])
|
29619 | return h.length = 0, u ? (i -= e.e + 1, h[0] = x(10, (7 - i % 7) % 7), e.e = -i || 0) : h[0] = e.e = 0, e;
|
29620 | if (0 == s ? (h.length = p, o = 1, p--) : (h.length = p + 1, o = x(10, 7 - s), h[p] = a > 0 ? (c / x(10, n - a) % x(10, a) | 0) * o : 0), u)
|
29621 | for (;;) {
|
29622 | if (0 == p) {
|
29623 | for (s = 1, a = h[0]; a >= 10; a /= 10)
|
29624 | s++;
|
29625 | for (a = h[0] += o, o = 1; a >= 10; a /= 10)
|
29626 | o++;
|
29627 | s != o && (e.e++, h[0] == q && (h[0] = 1));
|
29628 | break;
|
29629 | }
|
29630 | if (h[p] += o, h[p] != q)
|
29631 | break;
|
29632 | h[p--] = 0, o = 1;
|
29633 | }
|
29634 | for (s = h.length; 0 === h[--s];)
|
29635 | h.pop();
|
29636 | } return g && (e.e > f.maxE ? (e.d = null, e.e = NaN) : e.e < f.minE && (e.e = 0, e.d = [0])), e; } function P(e, i, t) { if (!e.isFinite())
|
29637 | return j(e); var r, n = e.e, s = A(e.d), a = s.length; return i ? (t && (r = t - a) > 0 ? s = s.charAt(0) + "." + s.slice(1) + R(r) : a > 1 && (s = s.charAt(0) + "." + s.slice(1)), s = s + (e.e < 0 ? "e" : "e+") + e.e) : n < 0 ? (s = "0." + R(-n - 1) + s, t && (r = t - a) > 0 && (s += R(r))) : n >= a ? (s += R(n + 1 - a), t && (r = t - n - 1) > 0 && (s = s + "." + R(r))) : ((r = n + 1) < a && (s = s.slice(0, r) + "." + s.slice(r)), t && (r = t - a) > 0 && (n + 1 === a && (s += "."), s += R(r))), s; } function D(e, i) { var t = e[0]; for (i *= 7; t >= 10; t /= 10)
|
29638 | i++; return i; } function F(e, i, t) { if (i > E)
|
29639 | throw g = !0, t && (e.precision = t), Error(m); return L(new e(u), i, 1, !0); } function T(e, i, t) { if (i > M)
|
29640 | throw Error(m); return L(new e(c), i, t, !0); } function C(e) { var i = e.length - 1, t = 7 * i + 1; if (i = e[i]) {
|
29641 | for (; i % 10 == 0; i /= 10)
|
29642 | t--;
|
29643 | for (i = e[0]; i >= 10; i /= 10)
|
29644 | t++;
|
29645 | } return t; } function R(e) { for (var i = ""; e--;)
|
29646 | i += "0"; return i; } function $(e, i, t, r) { var n, s = new e(1), a = Math.ceil(r / 7 + 4); for (g = !1;;) {
|
29647 | if (t % 2 && J((s = s.times(i)).d, a) && (n = !0), 0 === (t = v(t / 2))) {
|
29648 | t = s.d.length - 1, n && 0 === s.d[t] && ++s.d[t];
|
29649 | break;
|
29650 | }
|
29651 | J((i = i.times(i)).d, a);
|
29652 | } return g = !0, s; } function Z(e) { return 1 & e.d[e.d.length - 1]; } function B(e, i, t) { for (var r, n = new e(i[0]), s = 0; ++s < i.length;) {
|
29653 | if (!(r = new e(i[s])).s) {
|
29654 | n = r;
|
29655 | break;
|
29656 | }
|
29657 | n[t](r) && (n = r);
|
29658 | } return n; } function _(e, i) { var t, r, n, s, a, o, l, u = 0, c = 0, h = 0, p = e.constructor, f = p.rounding, m = p.precision; if (!e.d || !e.d[0] || e.e > 17)
|
29659 | return new p(e.d ? e.d[0] ? e.s < 0 ? 0 : 1 / 0 : 1 : e.s ? e.s < 0 ? 0 : e : NaN); for (null == i ? (g = !1, l = m) : l = i, o = new p(.03125); e.e > -2;)
|
29660 | e = e.times(o), h += 5; for (l += r = Math.log(x(2, h)) / Math.LN10 * 2 + 5 | 0, t = s = a = new p(1), p.precision = l;;) {
|
29661 | if (s = L(s.times(e), l, 1), t = t.times(++c), A((o = a.plus(O(s, t, l, 1))).d).slice(0, l) === A(a.d).slice(0, l)) {
|
29662 | for (n = h; n--;)
|
29663 | a = L(a.times(a), l, 1);
|
29664 | if (null != i)
|
29665 | return p.precision = m, a;
|
29666 | if (!(u < 3 && k(a.d, l - r, f, u)))
|
29667 | return L(a, p.precision = m, f, g = !0);
|
29668 | p.precision = l += 10, t = s = o = new p(1), c = 0, u++;
|
29669 | }
|
29670 | a = o;
|
29671 | } } function U(e, i) { var t, r, n, s, a, o, l, u, c, h, p, f = 1, m = e, d = m.d, v = m.constructor, x = v.rounding, y = v.precision; if (m.s < 0 || !d || !d[0] || !m.e && 1 == d[0] && 1 == d.length)
|
29672 | return new v(d && !d[0] ? -1 / 0 : 1 != m.s ? NaN : d ? 0 : m); if (null == i ? (g = !1, c = y) : c = i, v.precision = c += 10, r = (t = A(d)).charAt(0), !(Math.abs(s = m.e) < 15e14))
|
29673 | return u = F(v, c + 2, y).times(s + ""), m = U(new v(r + "." + t.slice(1)), c - 10).plus(u), v.precision = y, null == i ? L(m, y, x, g = !0) : m; for (; r < 7 && 1 != r || 1 == r && t.charAt(1) > 3;)
|
29674 | r = (t = A((m = m.times(e)).d)).charAt(0), f++; for (s = m.e, r > 1 ? (m = new v("0." + t), s++) : m = new v(r + "." + t.slice(1)), h = m, l = a = m = O(m.minus(1), m.plus(1), c, 1), p = L(m.times(m), c, 1), n = 3;;) {
|
29675 | if (a = L(a.times(p), c, 1), A((u = l.plus(O(a, new v(n), c, 1))).d).slice(0, c) === A(l.d).slice(0, c)) {
|
29676 | if (l = l.times(2), 0 !== s && (l = l.plus(F(v, c + 2, y).times(s + ""))), l = O(l, new v(f), c, 1), null != i)
|
29677 | return v.precision = y, l;
|
29678 | if (!k(l.d, c - 10, x, o))
|
29679 | return L(l, v.precision = y, x, g = !0);
|
29680 | v.precision = c += 10, u = a = m = O(h.minus(1), h.plus(1), c, 1), p = L(m.times(m), c, 1), n = o = 1;
|
29681 | }
|
29682 | l = u, n += 2;
|
29683 | } } function j(e) { return String(e.s * e.s / 0); } function H(e, i) { var t, r, n; for ((t = i.indexOf(".")) > -1 && (i = i.replace(".", "")), (r = i.search(/e/i)) > 0 ? (t < 0 && (t = r), t += +i.slice(r + 1), i = i.substring(0, r)) : t < 0 && (t = i.length), r = 0; 48 === i.charCodeAt(r); r++)
|
29684 | ; for (n = i.length; 48 === i.charCodeAt(n - 1); --n)
|
29685 | ; if (i = i.slice(r, n)) {
|
29686 | if (n -= r, e.e = t = t - r - 1, e.d = [], r = (t + 1) % 7, t < 0 && (r += 7), r < n) {
|
29687 | for (r && e.d.push(+i.slice(0, r)), n -= 7; r < n;)
|
29688 | e.d.push(+i.slice(r, r += 7));
|
29689 | r = 7 - (i = i.slice(r)).length;
|
29690 | }
|
29691 | else
|
29692 | r -= n;
|
29693 | for (; r--;)
|
29694 | i += "0";
|
29695 | e.d.push(+i), g && (e.e > e.constructor.maxE ? (e.d = null, e.e = NaN) : e.e < e.constructor.minE && (e.e = 0, e.d = [0]));
|
29696 | }
|
29697 | else
|
29698 | e.e = 0, e.d = [0]; return e; } function G(e, t) { var r, n, s, a, o, l, u, c, h; if ("Infinity" === t || "NaN" === t)
|
29699 | return +t || (e.s = NaN), e.e = NaN, e.d = null, e; if (b.test(t))
|
29700 | r = 16, t = t.toLowerCase();
|
29701 | else if (y.test(t))
|
29702 | r = 2;
|
29703 | else {
|
29704 | if (!w.test(t))
|
29705 | throw Error(f + t);
|
29706 | r = 8;
|
29707 | } for ((a = t.search(/p/i)) > 0 ? (u = +t.slice(a + 1), t = t.substring(2, a)) : t = t.slice(2), o = (a = t.indexOf(".")) >= 0, n = e.constructor, o && (a = (l = (t = t.replace(".", "")).length) - a, s = $(n, new n(r), a, 2 * a)), a = h = (c = I(t, r, q)).length - 1; 0 === c[a]; --a)
|
29708 | c.pop(); return a < 0 ? new n(0 * e.s) : (e.e = D(c, h), e.d = c, g = !1, o && (e = O(e, s, 4 * l)), u && (e = e.times(Math.abs(u) < 54 ? x(2, u) : i.pow(2, u))), g = !0, e); } function W(e, i, t, r, n) { var s, a, o, l, u = e.precision, c = Math.ceil(u / 7); for (g = !1, l = t.times(t), o = new e(r);;) {
|
29709 | if (a = O(o.times(l), new e(i++ * i++), u, 1), o = n ? r.plus(a) : r.minus(a), r = O(a.times(l), new e(i++ * i++), u, 1), void 0 !== (a = o.plus(r)).d[c]) {
|
29710 | for (s = c; a.d[s] === o.d[s] && s--;)
|
29711 | ;
|
29712 | if (-1 == s)
|
29713 | break;
|
29714 | }
|
29715 | s = o, o = r, r = a, a = s;
|
29716 | } return g = !0, a.d.length = c + 1, a; } function V(e, i) { for (var t = e; --i;)
|
29717 | t *= e; return t; } function Q(e, i) { var t, r = i.s < 0, s = T(e, e.precision, 1), a = s.times(.5); if ((i = i.abs()).lte(a))
|
29718 | return n = r ? 4 : 1, i; if ((t = i.divToInt(s)).isZero())
|
29719 | n = r ? 3 : 2;
|
29720 | else {
|
29721 | if ((i = i.minus(t.times(s))).lte(a))
|
29722 | return n = Z(t) ? r ? 2 : 3 : r ? 4 : 1, i;
|
29723 | n = Z(t) ? r ? 1 : 4 : r ? 3 : 2;
|
29724 | } return i.minus(s).abs(); } function Y(e, i, r, n) { var s, l, u, c, h, g, p, f, m, d = e.constructor, v = void 0 !== r; if (v ? (z(r, 1, a), void 0 === n ? n = d.rounding : z(n, 0, 8)) : (r = d.precision, n = d.rounding), e.isFinite()) {
|
29725 | for (v ? (s = 2, 16 == i ? r = 4 * r - 3 : 8 == i && (r = 3 * r - 2)) : s = i, (u = (p = P(e)).indexOf(".")) >= 0 && (p = p.replace(".", ""), (m = new d(1)).e = p.length - u, m.d = I(P(m), 10, s), m.e = m.d.length), l = h = (f = I(p, 10, s)).length; 0 == f[--h];)
|
29726 | f.pop();
|
29727 | if (f[0]) {
|
29728 | if (u < 0 ? l-- : ((e = new d(e)).d = f, e.e = l, f = (e = O(e, m, r, n, 0, s)).d, l = e.e, g = t), u = f[r], c = s / 2, g = g || void 0 !== f[r + 1], g = n < 4 ? (void 0 !== u || g) && (0 === n || n === (e.s < 0 ? 3 : 2)) : u > c || u === c && (4 === n || g || 6 === n && 1 & f[r - 1] || n === (e.s < 0 ? 8 : 7)), f.length = r, g)
|
29729 | for (; ++f[--r] > s - 1;)
|
29730 | f[r] = 0, r || (++l, f.unshift(1));
|
29731 | for (h = f.length; !f[h - 1]; --h)
|
29732 | ;
|
29733 | for (u = 0, p = ""; u < h; u++)
|
29734 | p += o.charAt(f[u]);
|
29735 | if (v) {
|
29736 | if (h > 1)
|
29737 | if (16 == i || 8 == i) {
|
29738 | for (u = 16 == i ? 4 : 3, --h; h % u; h++)
|
29739 | p += "0";
|
29740 | for (h = (f = I(p, s, i)).length; !f[h - 1]; --h)
|
29741 | ;
|
29742 | for (u = 1, p = "1."; u < h; u++)
|
29743 | p += o.charAt(f[u]);
|
29744 | }
|
29745 | else
|
29746 | p = p.charAt(0) + "." + p.slice(1);
|
29747 | p = p + (l < 0 ? "p" : "p+") + l;
|
29748 | }
|
29749 | else if (l < 0) {
|
29750 | for (; ++l;)
|
29751 | p = "0" + p;
|
29752 | p = "0." + p;
|
29753 | }
|
29754 | else if (++l > h)
|
29755 | for (l -= h; l--;)
|
29756 | p += "0";
|
29757 | else
|
29758 | l < h && (p = p.slice(0, l) + "." + p.slice(l));
|
29759 | }
|
29760 | else
|
29761 | p = v ? "0p+0" : "0";
|
29762 | p = (16 == i ? "0x" : 2 == i ? "0b" : 8 == i ? "0o" : "") + p;
|
29763 | }
|
29764 | else
|
29765 | p = j(e); return e.s < 0 ? "-" + p : p; } function J(e, i) { if (e.length > i)
|
29766 | return e.length = i, !0; } function K(e) { return new this(e).abs(); } function X(e) { return new this(e).acos(); } function ee(e) { return new this(e).acosh(); } function ie(e, i) { return new this(e).plus(i); } function te(e) { return new this(e).asin(); } function re(e) { return new this(e).asinh(); } function ne(e) { return new this(e).atan(); } function se(e) { return new this(e).atanh(); } function ae(e, i) { e = new this(e), i = new this(i); var t, r = this.precision, n = this.rounding, s = r + 4; return e.s && i.s ? e.d || i.d ? !i.d || e.isZero() ? (t = i.s < 0 ? T(this, r, n) : new this(0)).s = e.s : !e.d || i.isZero() ? (t = T(this, s, 1).times(.5)).s = e.s : i.s < 0 ? (this.precision = s, this.rounding = 1, t = this.atan(O(e, i, s, 1)), i = T(this, s, 1), this.precision = r, this.rounding = n, t = e.s < 0 ? t.minus(i) : t.plus(i)) : t = this.atan(O(e, i, s, 1)) : (t = T(this, s, 1).times(i.s > 0 ? .25 : .75)).s = e.s : t = new this(NaN), t; } function oe(e) { return new this(e).cbrt(); } function le(e) { return L(e = new this(e), e.e + 1, 2); } function ue(e) { if (!e || "object" != typeof e)
|
29767 | throw Error(p + "Object expected"); var i, t, r, n = !0 === e.defaults, o = ["precision", 1, a, "rounding", 0, 8, "toExpNeg", -s, 0, "toExpPos", 0, s, "maxE", 0, s, "minE", -s, 0, "modulo", 0, 9]; for (i = 0; i < o.length; i += 3)
|
29768 | if (t = o[i], n && (this[t] = h[t]), void 0 !== (r = e[t])) {
|
29769 | if (!(v(r) === r && r >= o[i + 1] && r <= o[i + 2]))
|
29770 | throw Error(f + t + ": " + r);
|
29771 | this[t] = r;
|
29772 | } if (t = "crypto", n && (this[t] = h[t]), void 0 !== (r = e[t])) {
|
29773 | if (!0 !== r && !1 !== r && 0 !== r && 1 !== r)
|
29774 | throw Error(f + t + ": " + r);
|
29775 | if (r) {
|
29776 | if ("undefined" == typeof crypto || !crypto || !crypto.getRandomValues && !crypto.randomBytes)
|
29777 | throw Error(d);
|
29778 | this[t] = !0;
|
29779 | }
|
29780 | else
|
29781 | this[t] = !1;
|
29782 | } return this; } function ce(e) { return new this(e).cos(); } function he(e) { return new this(e).cosh(); } function ge(e, i) { return new this(e).div(i); } function pe(e) { return new this(e).exp(); } function fe(e) { return L(e = new this(e), e.e + 1, 3); } function me() { var e, i, t = new this(0); for (g = !1, e = 0; e < arguments.length;)
|
29783 | if ((i = new this(arguments[e++])).d)
|
29784 | t.d && (t = t.plus(i.times(i)));
|
29785 | else {
|
29786 | if (i.s)
|
29787 | return g = !0, new this(1 / 0);
|
29788 | t = i;
|
29789 | } return g = !0, t.sqrt(); } function de(e) { return e instanceof i || e && "[object Decimal]" === e.name || !1; } function ve(e) { return new this(e).ln(); } function xe(e, i) { return new this(e).log(i); } function ye(e) { return new this(e).log(2); } function be(e) { return new this(e).log(10); } function we() { return B(this, arguments, "lt"); } function Ne() { return B(this, arguments, "gt"); } function qe(e, i) { return new this(e).mod(i); } function Ee(e, i) { return new this(e).mul(i); } function Me(e, i) { return new this(e).pow(i); } function Se(e) { var i, t, r, n, s = 0, o = new this(1), l = []; if (void 0 === e ? e = this.precision : z(e, 1, a), r = Math.ceil(e / 7), this.crypto)
|
29790 | if (crypto.getRandomValues)
|
29791 | for (i = crypto.getRandomValues(new Uint32Array(r)); s < r;)
|
29792 | (n = i[s]) >= 429e7 ? i[s] = crypto.getRandomValues(new Uint32Array(1))[0] : l[s++] = n % 1e7;
|
29793 | else {
|
29794 | if (!crypto.randomBytes)
|
29795 | throw Error(d);
|
29796 | for (i = crypto.randomBytes(r *= 4); s < r;)
|
29797 | (n = i[s] + (i[s + 1] << 8) + (i[s + 2] << 16) + ((127 & i[s + 3]) << 24)) >= 214e7 ? crypto.randomBytes(4).copy(i, s) : (l.push(n % 1e7), s += 4);
|
29798 | s = r / 4;
|
29799 | }
|
29800 | else
|
29801 | for (; s < r;)
|
29802 | l[s++] = 1e7 * Math.random() | 0; for (e %= 7, (r = l[--s]) && e && (n = x(10, 7 - e), l[s] = (r / n | 0) * n); 0 === l[s]; s--)
|
29803 | l.pop(); if (s < 0)
|
29804 | t = 0, l = [0];
|
29805 | else {
|
29806 | for (t = -1; 0 === l[0]; t -= 7)
|
29807 | l.shift();
|
29808 | for (r = 1, n = l[0]; n >= 10; n /= 10)
|
29809 | r++;
|
29810 | r < 7 && (t -= 7 - r);
|
29811 | } return o.e = t, o.d = l, o; } function Ae(e) { return L(e = new this(e), e.e + 1, this.rounding); } function ze(e) { return (e = new this(e)).d ? e.d[0] ? e.s : 0 * e.s : e.s || NaN; } function ke(e) { return new this(e).sin(); } function Ie(e) { return new this(e).sinh(); } function Oe(e) { return new this(e).sqrt(); } function Le(e, i) { return new this(e).sub(i); } function Pe(e) { return new this(e).tan(); } function De(e) { return new this(e).tanh(); } function Fe(e) { return L(e = new this(e), e.e + 1, 1); } (i = function e(i) { var t, r, n; function s(e) { var i, t, r, n = this; if (!(n instanceof s))
|
29812 | return new s(e); if (n.constructor = s, e instanceof s)
|
29813 | return n.s = e.s, void (g ? !e.d || e.e > s.maxE ? (n.e = NaN, n.d = null) : e.e < s.minE ? (n.e = 0, n.d = [0]) : (n.e = e.e, n.d = e.d.slice()) : (n.e = e.e, n.d = e.d ? e.d.slice() : e.d)); if ("number" == (r = typeof e)) {
|
29814 | if (0 === e)
|
29815 | return n.s = 1 / e < 0 ? -1 : 1, n.e = 0, void (n.d = [0]);
|
29816 | if (e < 0 ? (e = -e, n.s = -1) : n.s = 1, e === ~~e && e < 1e7) {
|
29817 | for (i = 0, t = e; t >= 10; t /= 10)
|
29818 | i++;
|
29819 | return void (g ? i > s.maxE ? (n.e = NaN, n.d = null) : i < s.minE ? (n.e = 0, n.d = [0]) : (n.e = i, n.d = [e]) : (n.e = i, n.d = [e]));
|
29820 | }
|
29821 | return 0 * e != 0 ? (e || (n.s = NaN), n.e = NaN, void (n.d = null)) : H(n, e.toString());
|
29822 | } if ("string" !== r)
|
29823 | throw Error(f + e); return 45 === (t = e.charCodeAt(0)) ? (e = e.slice(1), n.s = -1) : (43 === t && (e = e.slice(1)), n.s = 1), N.test(e) ? H(n, e) : G(n, e); } if (s.prototype = S, s.ROUND_UP = 0, s.ROUND_DOWN = 1, s.ROUND_CEIL = 2, s.ROUND_FLOOR = 3, s.ROUND_HALF_UP = 4, s.ROUND_HALF_DOWN = 5, s.ROUND_HALF_EVEN = 6, s.ROUND_HALF_CEIL = 7, s.ROUND_HALF_FLOOR = 8, s.EUCLID = 9, s.config = s.set = ue, s.clone = e, s.isDecimal = de, s.abs = K, s.acos = X, s.acosh = ee, s.add = ie, s.asin = te, s.asinh = re, s.atan = ne, s.atanh = se, s.atan2 = ae, s.cbrt = oe, s.ceil = le, s.cos = ce, s.cosh = he, s.div = ge, s.exp = pe, s.floor = fe, s.hypot = me, s.ln = ve, s.log = xe, s.log10 = be, s.log2 = ye, s.max = we, s.min = Ne, s.mod = qe, s.mul = Ee, s.pow = Me, s.random = Se, s.round = Ae, s.sign = ze, s.sin = ke, s.sinh = Ie, s.sqrt = Oe, s.sub = Le, s.tan = Pe, s.tanh = De, s.trunc = Fe, void 0 === i && (i = {}), i && !0 !== i.defaults)
|
29824 | for (n = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"], t = 0; t < n.length;)
|
29825 | i.hasOwnProperty(r = n[t++]) || (i[r] = this[r]); return s.config(i), s; }(h)).default = i.Decimal = i, u = new i(u), c = new i(c), l$1.exports ? ("function" == typeof Symbol && "symbol" == typeof Symbol.iterator && (S[Symbol.for("nodejs.util.inspect.custom")] = S.toString, S[Symbol.toStringTag] = "Decimal"), l$1.exports = i) : (e || (e = "undefined" != typeof self && self && self.self == self ? self : window), r = e.Decimal, i.noConflict = function () { return e.Decimal = r, i; }, e.Decimal = i); }(u$1);
|
29826 | var h$1 = { exports: {} };
|
29827 | /**
|
29828 | * @license Complex.js v2.0.13 12/05/2020
|
29829 | *
|
29830 | * Copyright (c) 2020, Robert Eisele (robert@xarg.org)
|
29831 | * Dual licensed under the MIT or GPL Version 2 licenses.
|
29832 | **/ !function (e, i) { !function (i) { var t = function (e) { return .5 * (Math.exp(e) + Math.exp(-e)); }, r = function (e) { return .5 * (Math.exp(e) - Math.exp(-e)); }, n = function () { throw SyntaxError("Invalid Param"); }; function s(e, i) { var t = Math.abs(e), r = Math.abs(i); return 0 === e ? Math.log(r) : 0 === i ? Math.log(t) : t < 3e3 && r < 3e3 ? .5 * Math.log(e * e + i * i) : Math.log(e / Math.cos(Math.atan2(i, e))); } function a(e, i) { if (!(this instanceof a))
|
29833 | return new a(e, i); var t = function (e, i) { var t = { re: 0, im: 0 }; if (null == e)
|
29834 | t.re = t.im = 0;
|
29835 | else if (void 0 !== i)
|
29836 | t.re = e, t.im = i;
|
29837 | else
|
29838 | switch (typeof e) {
|
29839 | case "object":
|
29840 | if ("im" in e && "re" in e)
|
29841 | t.re = e.re, t.im = e.im;
|
29842 | else if ("abs" in e && "arg" in e) {
|
29843 | if (!Number.isFinite(e.abs) && Number.isFinite(e.arg))
|
29844 | return a.INFINITY;
|
29845 | t.re = e.abs * Math.cos(e.arg), t.im = e.abs * Math.sin(e.arg);
|
29846 | }
|
29847 | else if ("r" in e && "phi" in e) {
|
29848 | if (!Number.isFinite(e.r) && Number.isFinite(e.phi))
|
29849 | return a.INFINITY;
|
29850 | t.re = e.r * Math.cos(e.phi), t.im = e.r * Math.sin(e.phi);
|
29851 | }
|
29852 | else
|
29853 | 2 === e.length ? (t.re = e[0], t.im = e[1]) : n();
|
29854 | break;
|
29855 | case "string":
|
29856 | t.im = t.re = 0;
|
29857 | var r = e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g), s = 1, o = 0;
|
29858 | null === r && n();
|
29859 | for (var l = 0; l < r.length; l++) {
|
29860 | var u = r[l];
|
29861 | " " === u || "\t" === u || "\n" === u || ("+" === u ? s++ : "-" === u ? o++ : "i" === u || "I" === u ? (s + o === 0 && n(), " " === r[l + 1] || isNaN(r[l + 1]) ? t.im += parseFloat((o % 2 ? "-" : "") + "1") : (t.im += parseFloat((o % 2 ? "-" : "") + r[l + 1]), l++), s = o = 0) : ((s + o === 0 || isNaN(u)) && n(), "i" === r[l + 1] || "I" === r[l + 1] ? (t.im += parseFloat((o % 2 ? "-" : "") + u), l++) : t.re += parseFloat((o % 2 ? "-" : "") + u), s = o = 0));
|
29862 | }
|
29863 | s + o > 0 && n();
|
29864 | break;
|
29865 | case "number":
|
29866 | t.im = 0, t.re = e;
|
29867 | break;
|
29868 | default: n();
|
29869 | } return isNaN(t.re) || isNaN(t.im), t; }(e, i); this.re = t.re, this.im = t.im; } a.prototype = { re: 0, im: 0, sign: function () { var e = this.abs(); return new a(this.re / e, this.im / e); }, add: function (e, i) { var t = new a(e, i); return this.isInfinite() && t.isInfinite() ? a.NAN : this.isInfinite() || t.isInfinite() ? a.INFINITY : new a(this.re + t.re, this.im + t.im); }, sub: function (e, i) { var t = new a(e, i); return this.isInfinite() && t.isInfinite() ? a.NAN : this.isInfinite() || t.isInfinite() ? a.INFINITY : new a(this.re - t.re, this.im - t.im); }, mul: function (e, i) { var t = new a(e, i); return this.isInfinite() && t.isZero() || this.isZero() && t.isInfinite() ? a.NAN : this.isInfinite() || t.isInfinite() ? a.INFINITY : 0 === t.im && 0 === this.im ? new a(this.re * t.re, 0) : new a(this.re * t.re - this.im * t.im, this.re * t.im + this.im * t.re); }, div: function (e, i) { var t = new a(e, i); if (this.isZero() && t.isZero() || this.isInfinite() && t.isInfinite())
|
29870 | return a.NAN; if (this.isInfinite() || t.isZero())
|
29871 | return a.INFINITY; if (this.isZero() || t.isInfinite())
|
29872 | return a.ZERO; e = this.re, i = this.im; var r, n, s = t.re, o = t.im; return 0 === o ? new a(e / s, i / s) : Math.abs(s) < Math.abs(o) ? new a((e * (n = s / o) + i) / (r = s * n + o), (i * n - e) / r) : new a((e + i * (n = o / s)) / (r = o * n + s), (i - e * n) / r); }, pow: function (e, i) { var t = new a(e, i); if (e = this.re, i = this.im, t.isZero())
|
29873 | return a.ONE; if (0 === t.im) {
|
29874 | if (0 === i && e > 0)
|
29875 | return new a(Math.pow(e, t.re), 0);
|
29876 | if (0 === e)
|
29877 | switch ((t.re % 4 + 4) % 4) {
|
29878 | case 0: return new a(Math.pow(i, t.re), 0);
|
29879 | case 1: return new a(0, Math.pow(i, t.re));
|
29880 | case 2: return new a(-Math.pow(i, t.re), 0);
|
29881 | case 3: return new a(0, -Math.pow(i, t.re));
|
29882 | }
|
29883 | } if (0 === e && 0 === i && t.re > 0 && t.im >= 0)
|
29884 | return a.ZERO; var r = Math.atan2(i, e), n = s(e, i); return e = Math.exp(t.re * n - t.im * r), i = t.im * n + t.re * r, new a(e * Math.cos(i), e * Math.sin(i)); }, sqrt: function () { var e, i, t = this.re, r = this.im, n = this.abs(); if (t >= 0) {
|
29885 | if (0 === r)
|
29886 | return new a(Math.sqrt(t), 0);
|
29887 | e = .5 * Math.sqrt(2 * (n + t));
|
29888 | }
|
29889 | else
|
29890 | e = Math.abs(r) / Math.sqrt(2 * (n - t)); return i = t <= 0 ? .5 * Math.sqrt(2 * (n - t)) : Math.abs(r) / Math.sqrt(2 * (n + t)), new a(e, r < 0 ? -i : i); }, exp: function () { var e = Math.exp(this.re); return this.im, new a(e * Math.cos(this.im), e * Math.sin(this.im)); }, expm1: function () { var e = this.re, i = this.im; return new a(Math.expm1(e) * Math.cos(i) + function (e) { var i = Math.PI / 4; if (e < -i || e > i)
|
29891 | return Math.cos(e) - 1; var t = e * e; return t * (t * (1 / 24 + t * (-1 / 720 + t * (1 / 40320 + t * (-1 / 3628800 + t * (1 / 4790014600 + t * (-1 / 87178291200 + t * (1 / 20922789888e3))))))) - .5); }(i), Math.exp(e) * Math.sin(i)); }, log: function () { var e = this.re, i = this.im; return new a(s(e, i), Math.atan2(i, e)); }, abs: function () { return e = this.re, i = this.im, t = Math.abs(e), r = Math.abs(i), t < 3e3 && r < 3e3 ? Math.sqrt(t * t + r * r) : (t < r ? (t = r, r = e / i) : r = i / e, t * Math.sqrt(1 + r * r)); var e, i, t, r; }, arg: function () { return Math.atan2(this.im, this.re); }, sin: function () { var e = this.re, i = this.im; return new a(Math.sin(e) * t(i), Math.cos(e) * r(i)); }, cos: function () { var e = this.re, i = this.im; return new a(Math.cos(e) * t(i), -Math.sin(e) * r(i)); }, tan: function () { var e = 2 * this.re, i = 2 * this.im, n = Math.cos(e) + t(i); return new a(Math.sin(e) / n, r(i) / n); }, cot: function () { var e = 2 * this.re, i = 2 * this.im, n = Math.cos(e) - t(i); return new a(-Math.sin(e) / n, r(i) / n); }, sec: function () { var e = this.re, i = this.im, n = .5 * t(2 * i) + .5 * Math.cos(2 * e); return new a(Math.cos(e) * t(i) / n, Math.sin(e) * r(i) / n); }, csc: function () { var e = this.re, i = this.im, n = .5 * t(2 * i) - .5 * Math.cos(2 * e); return new a(Math.sin(e) * t(i) / n, -Math.cos(e) * r(i) / n); }, asin: function () { var e = this.re, i = this.im, t = new a(i * i - e * e + 1, -2 * e * i).sqrt(), r = new a(t.re - i, t.im + e).log(); return new a(r.im, -r.re); }, acos: function () { var e = this.re, i = this.im, t = new a(i * i - e * e + 1, -2 * e * i).sqrt(), r = new a(t.re - i, t.im + e).log(); return new a(Math.PI / 2 - r.im, r.re); }, atan: function () { var e = this.re, i = this.im; if (0 === e) {
|
29892 | if (1 === i)
|
29893 | return new a(0, 1 / 0);
|
29894 | if (-1 === i)
|
29895 | return new a(0, -1 / 0);
|
29896 | } var t = e * e + (1 - i) * (1 - i), r = new a((1 - i * i - e * e) / t, -2 * e / t).log(); return new a(-.5 * r.im, .5 * r.re); }, acot: function () { var e = this.re, i = this.im; if (0 === i)
|
29897 | return new a(Math.atan2(1, e), 0); var t = e * e + i * i; return 0 !== t ? new a(e / t, -i / t).atan() : new a(0 !== e ? e / 0 : 0, 0 !== i ? -i / 0 : 0).atan(); }, asec: function () { var e = this.re, i = this.im; if (0 === e && 0 === i)
|
29898 | return new a(0, 1 / 0); var t = e * e + i * i; return 0 !== t ? new a(e / t, -i / t).acos() : new a(0 !== e ? e / 0 : 0, 0 !== i ? -i / 0 : 0).acos(); }, acsc: function () { var e = this.re, i = this.im; if (0 === e && 0 === i)
|
29899 | return new a(Math.PI / 2, 1 / 0); var t = e * e + i * i; return 0 !== t ? new a(e / t, -i / t).asin() : new a(0 !== e ? e / 0 : 0, 0 !== i ? -i / 0 : 0).asin(); }, sinh: function () { var e = this.re, i = this.im; return new a(r(e) * Math.cos(i), t(e) * Math.sin(i)); }, cosh: function () { var e = this.re, i = this.im; return new a(t(e) * Math.cos(i), r(e) * Math.sin(i)); }, tanh: function () { var e = 2 * this.re, i = 2 * this.im, n = t(e) + Math.cos(i); return new a(r(e) / n, Math.sin(i) / n); }, coth: function () { var e = 2 * this.re, i = 2 * this.im, n = t(e) - Math.cos(i); return new a(r(e) / n, -Math.sin(i) / n); }, csch: function () { var e = this.re, i = this.im, n = Math.cos(2 * i) - t(2 * e); return new a(-2 * r(e) * Math.cos(i) / n, 2 * t(e) * Math.sin(i) / n); }, sech: function () { var e = this.re, i = this.im, n = Math.cos(2 * i) + t(2 * e); return new a(2 * t(e) * Math.cos(i) / n, -2 * r(e) * Math.sin(i) / n); }, asinh: function () { var e = this.im; this.im = -this.re, this.re = e; var i = this.asin(); return this.re = -this.im, this.im = e, e = i.re, i.re = -i.im, i.im = e, i; }, acosh: function () { var e = this.acos(); if (e.im <= 0) {
|
29900 | var i = e.re;
|
29901 | e.re = -e.im, e.im = i;
|
29902 | }
|
29903 | else
|
29904 | i = e.im, e.im = -e.re, e.re = i; return e; }, atanh: function () { var e = this.re, i = this.im, t = e > 1 && 0 === i, r = 1 - e, n = 1 + e, o = r * r + i * i, l = 0 !== o ? new a((n * r - i * i) / o, (i * r + n * i) / o) : new a(-1 !== e ? e / 0 : 0, 0 !== i ? i / 0 : 0), u = l.re; return l.re = s(l.re, l.im) / 2, l.im = Math.atan2(l.im, u) / 2, t && (l.im = -l.im), l; }, acoth: function () { var e = this.re, i = this.im; if (0 === e && 0 === i)
|
29905 | return new a(0, Math.PI / 2); var t = e * e + i * i; return 0 !== t ? new a(e / t, -i / t).atanh() : new a(0 !== e ? e / 0 : 0, 0 !== i ? -i / 0 : 0).atanh(); }, acsch: function () { var e = this.re, i = this.im; if (0 === i)
|
29906 | return new a(0 !== e ? Math.log(e + Math.sqrt(e * e + 1)) : 1 / 0, 0); var t = e * e + i * i; return 0 !== t ? new a(e / t, -i / t).asinh() : new a(0 !== e ? e / 0 : 0, 0 !== i ? -i / 0 : 0).asinh(); }, asech: function () { var e = this.re, i = this.im; if (this.isZero())
|
29907 | return a.INFINITY; var t = e * e + i * i; return 0 !== t ? new a(e / t, -i / t).acosh() : new a(0 !== e ? e / 0 : 0, 0 !== i ? -i / 0 : 0).acosh(); }, inverse: function () { if (this.isZero())
|
29908 | return a.INFINITY; if (this.isInfinite())
|
29909 | return a.ZERO; var e = this.re, i = this.im, t = e * e + i * i; return new a(e / t, -i / t); }, conjugate: function () { return new a(this.re, -this.im); }, neg: function () { return new a(-this.re, -this.im); }, ceil: function (e) { return e = Math.pow(10, e || 0), new a(Math.ceil(this.re * e) / e, Math.ceil(this.im * e) / e); }, floor: function (e) { return e = Math.pow(10, e || 0), new a(Math.floor(this.re * e) / e, Math.floor(this.im * e) / e); }, round: function (e) { return e = Math.pow(10, e || 0), new a(Math.round(this.re * e) / e, Math.round(this.im * e) / e); }, equals: function (e, i) { var t = new a(e, i); return Math.abs(t.re - this.re) <= a.EPSILON && Math.abs(t.im - this.im) <= a.EPSILON; }, clone: function () { return new a(this.re, this.im); }, toString: function () { var e = this.re, i = this.im, t = ""; return this.isNaN() ? "NaN" : this.isInfinite() ? "Infinity" : (Math.abs(e) < a.EPSILON && (e = 0), Math.abs(i) < a.EPSILON && (i = 0), 0 === i ? t + e : (0 !== e ? (t += e, t += " ", i < 0 ? (i = -i, t += "-") : t += "+", t += " ") : i < 0 && (i = -i, t += "-"), 1 !== i && (t += i), t + "i")); }, toVector: function () { return [this.re, this.im]; }, valueOf: function () { return 0 === this.im ? this.re : null; }, isNaN: function () { return isNaN(this.re) || isNaN(this.im); }, isZero: function () { return 0 === this.im && 0 === this.re; }, isFinite: function () { return isFinite(this.re) && isFinite(this.im); }, isInfinite: function () { return !(this.isNaN() || this.isFinite()); } }, a.ZERO = new a(0, 0), a.ONE = new a(1, 0), a.I = new a(0, 1), a.PI = new a(Math.PI, 0), a.E = new a(Math.E, 0), a.INFINITY = new a(1 / 0, 1 / 0), a.NAN = new a(NaN, NaN), a.EPSILON = 1e-15, Object.defineProperty(a, "__esModule", { value: !0 }), a.default = a, a.Complex = a, e.exports = a; }(); }(h$1), new c$1.exports.Decimal(0), new c$1.exports.Decimal(1), new c$1.exports.Decimal(-1), new c$1.exports.Decimal(NaN), new c$1.exports.Decimal(1 / 0), new c$1.exports.Decimal(-1 / 0), [.9999999999998099, 676.5203681218851, -1259.1392167224028, 771.3234287776531, -176.6150291621406, 12.507343278686905, -.13857109526572012, 9984369578019572e-21, 1.5056327351493116e-7].map((e => new c$1.exports.Decimal(e))), new c$1.exports.Decimal(607).div(128), [.9999999999999971, 57.15623566586292, -59.59796035547549, 14.136097974741746, -.4919138160976202, 3399464998481189e-20, 4652362892704858e-20, -9837447530487956e-20, .0001580887032249125, -.00021026444172410488, .00021743961811521265, -.0001643181065367639, 8441822398385275e-20, -26190838401581408e-21, 36899182659531625e-22].map((e => new c$1.exports.Decimal(e)));
|
29910 | const g$1 = "List", p$1 = "Missing", f$1 = "Nothing", m$1 = "Add", d$1 = "Divide", v$1 = "Multiply", x$1 = "Power";
|
29911 | function y$1(e) { return null !== e && "object" == typeof e && "num" in e; }
|
29912 | function b$1(e) { return null !== e && "object" == typeof e && "sym" in e; }
|
29913 | function w$1(e) { return null !== e && "object" == typeof e && "fn" in e; }
|
29914 | function N$1(e) { if ("number" == typeof e)
|
29915 | return e; if (null === e)
|
29916 | return null; if (y$1(e))
|
29917 | return e.num.endsWith("d") || e.num.endsWith("n") ? null : parseFloat(e.num); const i = z$1(e); return null === i ? null : "NaN" === i ? NaN : "+Infinity" === i ? 1 / 0 : "-Infinity" === i ? -1 / 0 : "Complex" === A$1(e) && 0 === N$1(O$1(e, 2)) ? N$1(O$1(e, 1)) : null; }
|
29918 | function q$1(e) { return null === e ? null : "object" == typeof e && "str" in e ? e.str : "string" != typeof e || e.length < 2 || "'" !== e[0] || "'" !== e[e.length - 1] ? null : e.substring(1, e.length - 1); }
|
29919 | function E$1(e) { var i, t, r, n, s, a; const o = z$1(e); if ("ThreeQuarter" === o)
|
29920 | return [3, 4]; if ("TwoThird" === o)
|
29921 | return [2, 3]; if ("Half" === o)
|
29922 | return [1, 2]; if ("Third" === o)
|
29923 | return [1, 3]; if ("Quarter" === o)
|
29924 | return [1, 4]; if (S$1(e))
|
29925 | return [null, null]; const l = A$1(e); if (!l)
|
29926 | return [null, null]; let u = null, c = null; if (l === x$1) {
|
29927 | const r = N$1(O$1(e, 2));
|
29928 | 1 === r ? (u = null !== (i = N$1(O$1(e, 1))) && void 0 !== i ? i : null, c = 1) : -1 === r && (u = 1, c = null !== (t = N$1(O$1(e, 1))) && void 0 !== t ? t : null);
|
29929 | } return l === d$1 && (u = null !== (r = N$1(O$1(e, 1))) && void 0 !== r ? r : null, c = null !== (n = N$1(O$1(e, 2))) && void 0 !== n ? n : null), l === v$1 && A$1(O$1(e, 2)) === x$1 && -1 === N$1(O$1(O$1(e, 2), 2)) && (u = null !== (s = N$1(O$1(e, 1))) && void 0 !== s ? s : null, c = null !== (a = N$1(O$1(O$1(e, 2), 1))) && void 0 !== a ? a : null), null === u || null === c ? [null, null] : Number.isInteger(u) && Number.isInteger(c) ? [u, c] : [null, null]; }
|
29930 | function M(e) { return null === e ? null : Array.isArray(e) ? e[0] : w$1(e) ? e.fn[0] : null; }
|
29931 | function S$1(e) { return null === e || !Array.isArray(e) && ("object" != typeof e || !("fn" in e || "dic" in e)); }
|
29932 | function A$1(e) { if (null === e)
|
29933 | return ""; const i = M(e); return "string" == typeof i ? i : ""; }
|
29934 | function z$1(e) { return null === e ? null : "string" == typeof e ? e.length >= 2 && "'" === e[0] && "'" === e[e.length - 1] ? null : e : b$1(e) ? e.sym : null; }
|
29935 | function k$1(e) { return Array.isArray(e) ? e.slice(1) : w$1(e) ? e.fn.slice(1) : []; }
|
29936 | function I$1(e, i) { let t = null; if (Array.isArray(e) && (t = e), w$1(e) && (t = e.fn), null === t)
|
29937 | return []; let r = 1; const n = []; for (; r < t.length;)
|
29938 | n.push(i(t[r])), r += 1; return n; }
|
29939 | function O$1(e, i) { var t, r; return null === e ? null : Array.isArray(e) ? null !== (t = e[i]) && void 0 !== t ? t : null : w$1(e) && null !== (r = e.fn[i]) && void 0 !== r ? r : null; }
|
29940 | function L$1(e) { return Array.isArray(e) ? Math.max(0, e.length - 1) : w$1(e) ? Math.max(0, e.fn.length - 1) : 0; }
|
29941 | function P$1(e) { return "object" == typeof e && "dict" in e ? e.dict : null; }
|
29942 | const D = [{ name: "Overscript", trigger: { infix: "\\overset" }, precedence: 700 }, { name: "Underscript", trigger: { infix: "\\underset" }, precedence: 700 }, { name: "Increment", trigger: { postfix: ["+", "+"] }, precedence: 880 }, { name: "Decrement", trigger: { postfix: ["-", "-"] }, precedence: 880 }, { name: "PreIncrement", trigger: { prefix: ["+", "+"] }, precedence: 880 }, { name: "PreDecrement", trigger: { prefix: ["-", "-"] }, precedence: 880 }, { name: "Ring", trigger: { infix: "\\circ" }, precedence: 265 }, { name: "Transpose", trigger: { superfix: "T" } }, { name: "ConjugateTranspose", trigger: { superfix: "H" } }, { name: "StringJoin", trigger: { infix: ["\\lt", "\\gt"] }, precedence: 780 }, { name: "Starstar", trigger: { infix: ["\\star", "\\star"] }, precedence: 780 }, { name: "PartialDerivative", trigger: { prefix: "\\partial" }, parse: (e, i, t) => { var r, n; let s = !1, a = f$1, o = f$1; for (; !s;)
|
29943 | i.skipSpace(), i.match("_") ? o = i.matchRequiredLatexArgument() : i.match("^") ? a = i.matchRequiredLatexArgument() : s = !0; if ("Sequence" === A$1(o) && (o = [g$1, ...k$1(o)]), !o || !a)
|
29944 | return [e, null]; let l = null !== (r = i.matchRequiredLatexArgument()) && void 0 !== r ? r : f$1; return l !== f$1 && (l = [l, ...null !== (n = i.matchArguments("group")) && void 0 !== n ? n : f$1]), [null, ["PartialDerivative", l, o, a]]; }, serialize: (e, i) => { let t = "\\partial"; const r = O$1(i, 1), n = O$1(i, 2), s = O$1(i, 3); return null !== n && n !== f$1 && (M(n) === g$1 ? t += "_{" + e.serialize(["Sequence", ...k$1(n)]) + "}" : t += "_{" + e.serialize(n) + "}"), null !== s && s !== f$1 && (t += "^{" + e.serialize(s) + "}"), null !== r && r !== f$1 && (t += e.serialize(r)), t; }, precedence: 740 }, { name: "OverBar", trigger: { symbol: "\\overline" }, requiredLatexArg: 1 }, { name: "UnderBar", trigger: { symbol: "\\underline" }, requiredLatexArg: 1 }, { name: "OverVector", trigger: { symbol: "\\vec" }, requiredLatexArg: 1 }, { name: "OverTile", trigger: { symbol: "\\tilde" }, requiredLatexArg: 1 }, { name: "OverHat", trigger: { symbol: "\\hat" }, requiredLatexArg: 1 }, { name: "OverHat", trigger: { symbol: "\\hat" }, requiredLatexArg: 1 }, { name: "OverRightArrow", trigger: { symbol: "\\overrightarrow" }, requiredLatexArg: 1 }, { name: "OverLeftArrow", trigger: { symbol: "\\overleftarrow" }, requiredLatexArg: 1 }, { name: "OverRightDoubleArrow", trigger: { symbol: "\\Overrightarrow" }, requiredLatexArg: 1 }, { name: "OverLeftHarpoon", trigger: { symbol: "\\overleftharpoon" }, requiredLatexArg: 1 }, { name: "OverRightHarpoon", trigger: { symbol: "\\overrightharpoon" }, requiredLatexArg: 1 }, { name: "OverLeftRightArrow", trigger: { symbol: "\\overleftrightarrow" }, requiredLatexArg: 1 }, { name: "OverBrace", trigger: { symbol: "\\overbrace" }, requiredLatexArg: 1 }, { name: "OverLineSegment", trigger: { symbol: "\\overlinesegment" }, requiredLatexArg: 1 }, { name: "OverGroup", trigger: { symbol: "\\overgroup" }, requiredLatexArg: 1 }];
|
29945 | function F$1(e, i) { return i > 2 ? "solidus" : "radical"; }
|
29946 | function T$1(e) { return "<space>" === e || "\\qquad" === e || "\\quad" === e || "\\enskip" === e || "\\;" === e || "\\," === e || "\\ " === e || "~" === e; }
|
29947 | function C$1(e, i, t) { return (r, n, s) => { if (s >= i)
|
29948 | return [r, null]; n.skipSpace(), n.match(t), "Missing" === r && (r = f$1); const a = [e, null != r ? r : f$1]; let o = !1; for (; !o;) {
|
29949 | for (o = !0, n.skipSpace(); n.match(t);)
|
29950 | a.push(f$1), n.skipSpace();
|
29951 | if (n.atEnd)
|
29952 | a.push(f$1);
|
29953 | else {
|
29954 | const e = n.matchExpression(i);
|
29955 | a.push(null != e ? e : f$1), o = null === e;
|
29956 | }
|
29957 | o || (n.skipSpace(), o = !n.match(t));
|
29958 | } return [null, a]; }; }
|
29959 | function R$1(e) { return (i, t) => k$1(t).map((e => i.serialize(e))).join(e); }
|
29960 | const $$1 = [{ name: "LatexTokens", serialize: function (e, i) { return k$1(i).map((i => { const t = q$1(i); return null === t ? e.serialize(i) : "<{>" === t ? "{" : "<}>" === t ? "}" : "<$>" === t ? "$" : "<$$>" === t ? "$$" : "<space>'" === t ? " " : t; })).join(""); } }, { name: "Parentheses", trigger: { matchfix: "(" }, parse: (e, i, t) => { var r; const n = i.index; if (!i.match("("))
|
29961 | return [e, null]; let s = !1, a = !0, o = !1, l = 0, u = ""; for (; !s && a;) {
|
29962 | const e = i.next();
|
29963 | i.atEnd || ")" === e ? s = !0 : "\\mathtt" === e ? (i.match("<{>"), o = !0) : T$1(e) || (/^[0-9a-zA-Z]$/.test(e) ? (l = Math.max(l, parseInt(e, 36)), u += e) : a = !1), o && i.match("<}>");
|
29964 | } if (i.skipSpace(), a && i.match("_")) {
|
29965 | const t = null !== (r = N$1(i.matchRequiredLatexArgument())) && void 0 !== r ? r : NaN;
|
29966 | return !isFinite(t) || t < 2 || t > 36 || l >= t ? (i.onError({ code: "base-out-of-range" }), [e, f$1]) : [e, ["BaseForm", parseInt(u, t), t]];
|
29967 | } i.index = n; const c = i.matchBalancedExpression("(", ")", i.onError); return c ? "Sequence" === A$1(c) ? [e, ["Parentheses", ...k$1(c)]] : [e, ["Parentheses", c]] : [e, ["Parentheses"]]; }, serialize: (e, i) => e.wrapString(R$1(",")(e, i), (e.level, "paren")), separator: ",", closeFence: ")", precedence: 20 }, { name: g$1, trigger: { matchfix: "\\lbrack" }, separator: ",", closeFence: "\\rbrack", precedence: 20, parse: (e, i, t) => { if (null === e) {
|
29968 | const t = i.matchBalancedExpression("\\lbrack", "\\rbrack", i.onError);
|
29969 | return t ? "Sequence" === A$1(t) ? [e, [g$1, ...k$1(t)]] : [e, [g$1, t]] : [null, [g$1]];
|
29970 | } return [e, null]; } }, { name: "BaseForm", serialize: (e, i) => { var t, r; const n = null !== (t = N$1(O$1(i, 2))) && void 0 !== t ? t : NaN; if (isFinite(n) && n >= 2 && n <= 36) {
|
29971 | const e = null !== (r = N$1(O$1(i, 1))) && void 0 !== r ? r : NaN;
|
29972 | if (isFinite(e)) {
|
29973 | let i = Number(e).toString(n), t = 0;
|
29974 | if (2 === n || 10 === n ? t = 4 : 16 === n ? t = 2 : n > 16 && (t = 4), t > 0) {
|
29975 | const e = i;
|
29976 | i = "";
|
29977 | for (let r = 0; r < e.length; r++)
|
29978 | r > 0 && r % t == 0 && (i = "\\, " + i), i = e[e.length - r - 1] + i;
|
29979 | }
|
29980 | return `(\\mathtt{${i}})_{${n}}`;
|
29981 | }
|
29982 | } return "\\operatorname{BaseForm}(" + e.serialize(O$1(i, 1)) + ", " + e.serialize(O$1(i, 2)) + ")"; } }, { name: "Set", trigger: { matchfix: "\\lbrace" }, separator: ",", closeFence: "\\rbrace", precedence: 20 }, { name: "Sequence", trigger: { infix: "," }, parse: C$1("Sequence", 20, ","), serialize: R$1(", "), precedence: 20 }, { name: "Sequence2", trigger: { infix: ";" }, parse: C$1("Sequence2", 19, ";"), serialize: R$1("; "), precedence: 19 }, { name: p$1, trigger: "\\placeholder", serialize: "\\placeholder", requiredLatexArg: 1 }, { name: "Subscript", trigger: { infix: "_" }, precedence: 720, serialize: (e, i) => 2 === L$1(i) ? e.serialize(O$1(i, 1)) + "_{" + e.serialize(O$1(i, 2)) + "}" : "_{" + e.serialize(O$1(i, 1)) + "}", parse: (e, i, t) => { var r; if (!i.match("_"))
|
29983 | return [e, null]; const n = null !== (r = i.matchRequiredLatexArgument()) && void 0 !== r ? r : p$1; return e ? [null, ["Subscript", e, n]] : [null, ["Subscript", n]]; } }, { name: "Superplus", trigger: { superfix: "+" } }, { name: "Subplus", trigger: { subfix: "+" } }, { name: "Superminus", trigger: { superfix: "-" } }, { name: "Subminus", trigger: { subfix: "-" } }, { name: "Superstar", trigger: { superfix: "*" } }, { name: "Superstar", trigger: { superfix: "\\star" } }, { name: "Substar", trigger: { subfix: "*" } }, { name: "Substar", trigger: { subfix: "\\star" } }, { name: "Superdagger", trigger: { superfix: "\\dagger" } }, { name: "Superdagger", trigger: { superfix: "\\dag" } }, { name: "Prime", trigger: { superfix: "\\prime" }, arguments: "group" }, { trigger: { superfix: "\\doubleprime" }, parse: (e, i) => [null, ["Prime", null != e ? e : f$1, 2]], arguments: "group" }, { name: "InverseFunction", serialize: (e, i) => e.serialize(O$1(i, 1)) + "^{-1}" }, { name: "Derivative", trigger: "D", parse: (e, i) => [e, ["Derivative", 1]], serialize: (e, i) => { var t; const r = null !== (t = N$1(O$1(i, 1))) && void 0 !== t ? t : NaN; if (!isFinite(r))
|
29984 | return ""; const n = e.serialize(O$1(i, 2)); return 1 === r ? n + "^{\\prime}" : 2 === r ? n + "^{\\doubleprime}" : n + "^{(" + Number(r).toString() + ")}"; } }, { name: "Piecewise", trigger: { environment: "cases" }, parse: (e, i) => { var t; return [e, ["Piecewise", null !== (t = i.matchTabular()) && void 0 !== t ? t : f$1]]; }, serialize: (e, i) => { if (A$1(O$1(i, 1)) !== g$1)
|
29985 | return ""; const t = k$1(O$1(i, 1)); let r = "", n = ""; for (const i of t) {
|
29986 | r += n;
|
29987 | const t = O$1(i, 1);
|
29988 | if (null !== t) {
|
29989 | r += e.serialize(t);
|
29990 | const n = O$1(i, 2);
|
29991 | null !== n && (r += "&" + e.serialize(n));
|
29992 | }
|
29993 | n = "\\\\";
|
29994 | } return "\\begin{cases}" + r + "\\end{cases}"; } }];
|
29995 | function Z$1(e) { var i, t, r, n; if ("number" == typeof (e = B$1(e)))
|
29996 | return -e; if (e && y$1(e))
|
29997 | return "-" === e.num[0] ? { num: e.num.slice(1) } : "+" === e.num[0] ? { num: "-" + e.num.slice(1) } : { num: "-" + e.num }; if (e instanceof c$1.exports.Decimal)
|
29998 | return e.mul(-1); if (e instanceof h$1.exports.Complex)
|
29999 | return e.mul(-1); const s = A$1(e), a = L$1(e); if ("Negate" === s && 1 === a)
|
30000 | return null !== (i = O$1(e, 1)) && void 0 !== i ? i : p$1; if (s === v$1) {
|
30001 | const i = Z$1(null !== (t = O$1(e, 1)) && void 0 !== t ? t : p$1);
|
30002 | return [v$1, i, ...k$1(e).slice(1)];
|
30003 | } return s === m$1 ? [m$1, ...I$1(e, Z$1)] : "Subtract" === s ? ["Subtract", null !== (r = O$1(e, 2)) && void 0 !== r ? r : p$1, null !== (n = O$1(e, 1)) && void 0 !== n ? n : p$1] : "Parentheses" === s && 1 === a ? Z$1(O$1(O$1(e, 1), 1)) : ["Negate", null != e ? e : p$1]; }
|
30004 | function B$1(e) { return null === e ? f$1 : S$1(e) ? e : "Parentheses" === M(e) && 1 === L$1(e) ? B$1(O$1(e, 1)) : function (e, i) { const t = M(e); if (null !== t)
|
30005 | return [i(t), ...k$1(e).map(i)]; const r = P$1(e); if (null !== r) {
|
30006 | const e = Object.keys(r), t = {};
|
30007 | for (const n of e)
|
30008 | t[n] = i(r[n]);
|
30009 | return { dict: t };
|
30010 | } return i(e); }(e, B$1); }
|
30011 | function _$1(e, i, t, r) { return null === t ? "\\sqrt{}" : (r = null != r ? r : 2, "solidus" === i ? e.wrapShort(t) + "^{1\\/" + e.serialize(r) + "}" : "quotient" === i ? e.wrapShort(t) + "^{\\frac{1}{" + e.serialize(r) + "}}" : 2 === N$1(r) ? "\\sqrt{" + e.serialize(t) + "}" : "\\sqrt[" + e.serialize(r) + "]{" + e.serialize(t) + "}"); }
|
30012 | function U(e, i, t) { if (!i.match("\\sqrt"))
|
30013 | return [e, null]; const r = i.matchOptionalLatexArgument(), n = i.matchRequiredLatexArgument(); return null === n ? null !== r ? [e, ["Root", f$1, r]] : [e, ["Sqrt"]] : null !== r ? [e, ["Root", n, r]] : [e, ["Sqrt", n]]; }
|
30014 | function j(e, i, t) { if (276 < t)
|
30015 | return [e, null]; const r = i.index; if (!i.match("-"))
|
30016 | return [e, null]; const n = i.matchExpression(null === e ? 400 : 277); return null === n ? (i.index = r, [e, null]) : null === e ? [null, ["Negate", n]] : [null, ["Subtract", e, n]]; }
|
30017 | function H$1(e, i) { var t; if (null === i)
|
30018 | return ""; e.level -= 1; let r = ""; const [n, s] = function (e) { var i, t, r, n, s, a; if (A$1(e) !== v$1)
|
30019 | return [[], []]; const o = [], l = [], u = k$1(e); for (const e of u)
|
30020 | if (A$1(e) === x$1)
|
30021 | if ("Negate" === A$1(O$1(e, 2))) {
|
30022 | const r = null !== (i = O$1(e, 1)) && void 0 !== i ? i : f$1, n = null !== (t = O$1(O$1(e, 2), 1)) && void 0 !== t ? t : f$1;
|
30023 | l.push([x$1, r, n]);
|
30024 | }
|
30025 | else {
|
30026 | const i = null !== (r = N$1(O$1(e, 2))) && void 0 !== r ? r : NaN;
|
30027 | -1 === i ? l.push(null !== (n = O$1(e, 1)) && void 0 !== n ? n : f$1) : i < 0 ? l.push([x$1, null !== (s = O$1(e, 1)) && void 0 !== s ? s : f$1, null !== (a = Z$1(O$1(e, 2))) && void 0 !== a ? a : f$1]) : o.push(e);
|
30028 | }
|
30029 | else
|
30030 | o.push(e); return [o, l]; }(i); if (s.length > 0 && (r = 1 === s.length && 1 === s[0] ? 0 === n.length ? "1" : 1 === n.length ? e.serialize(n[0]) : H$1(e, [v$1, ...n]) : e.serialize([d$1, 1 === n.length ? n[0] : [v$1, ...n], 1 === s.length ? s[0] : [v$1, ...s]])), r)
|
30031 | return e.level += 1, r; let o = !1, l = null; const u = L$1(i) + 1; let c = !1; for (let n = 1; n < u; n++)
|
30032 | if (l = O$1(i, n), null !== l) {
|
30033 | let i;
|
30034 | "number" == typeof l || y$1(l) ? (i = e.serialize(l), "-1" !== i || r ? ("-" === i[0] && (i = i.slice(1), o = !o), r = r ? a$1([r, e.options.multiply, i]) : i) : r = "-", c = !0) : A$1(l) !== x$1 || isNaN(null !== (t = N$1(O$1(l, 1))) && void 0 !== t ? t : NaN) ? ("Negate" === A$1(l) && (l = O$1(l, 1), o = !o), i = e.wrap(l, 390), r = r ? c && A$1(l) === d$1 ? a$1([r, "\\times", i]) : e.options.invisibleMultiply ? a$1([r, e.options.invisibleMultiply, i]) : a$1([r, i]) : i, c = !1) : (r = r ? a$1([r, e.options.multiply, e.serialize(l)]) : e.serialize(l), c = !0);
|
30035 | } return e.level += 1, o ? "-" + r : r; }
|
30036 | function G$1(e, i) { if (null === i)
|
30037 | return ""; if (1 === L$1(i))
|
30038 | return e.serialize(O$1(i, 1)); const t = e.level > 3 ? "inline-solidus" : "quotient"; if ("inline-solidus" === t || "nice-solidus" === t) {
|
30039 | const r = e.wrapShort(O$1(i, 1)), n = e.wrapShort(O$1(i, 2));
|
30040 | return "nice-solidus" === t ? `^{${r}}\\!\\!/\\!_{${n}}` : `${r}\\/${n}`;
|
30041 | } return "reciprocal" === t ? e.wrap(O$1(i, 1)) + e.wrap(O$1(i, 2)) + "^{-1}" : "factor" === t ? "\\frac{1}{" + e.serialize(O$1(i, 2)) + "}" + e.wrap(O$1(i, 1)) : "\\frac{" + e.serialize(O$1(i, 1)) + "}{" + e.serialize(O$1(i, 2)) + "}"; }
|
30042 | function W$1(e, i) { var t; const r = O$1(i, 1), n = O$1(i, 2); if (null === n)
|
30043 | return e.serialize(r); if (null === r)
|
30044 | return ""; const s = A$1(i); if ("Sqrt" === s || "Root" === s)
|
30045 | return _$1(e, F$1(0, e.level), O$1(i, 1), O$1(i, 2)); const a = null !== (t = N$1(n)) && void 0 !== t ? t : 1; if (-1 === a)
|
30046 | return e.serialize([d$1, "1", r]); if (a < 0)
|
30047 | return e.serialize([d$1, "1", [x$1, r, -a]]); if (A$1(n) === d$1) {
|
30048 | if (1 === N$1(O$1(n, 1)))
|
30049 | return _$1(e, F$1(0, e.level), r, O$1(n, 2));
|
30050 | }
|
30051 | else if (A$1(n) === x$1 && -1 === N$1(O$1(n, 2)))
|
30052 | return _$1(e, F$1(0, e.level), r, O$1(n, 1)); return e.wrapShort(r) + "^{" + e.serialize(n) + "}"; }
|
30053 | function V$1(e, i, t) { var r; const n = i.next(); let s = !1, a = 0; if (i.skipSpace(), i.match("^")) {
|
30054 | if (i.skipSpace(), i.match("<{>")) {
|
30055 | i.skipSpace(), i.match("-") && i.match("1") && (s = !0);
|
30056 | do {
|
30057 | i.match("\\doubleprime") && (a += 2), i.match("\\prime") && (a += 1), i.match("'") && (a += 1);
|
30058 | } while (!i.match("<}>") && !i.atEnd);
|
30059 | }
|
30060 | let e = !1;
|
30061 | for (; !e;)
|
30062 | i.skipSpace(), i.match("\\doubleprime") ? a += 2 : i.match("\\prime") || i.match("'") ? a += 1 : e = !0;
|
30063 | } let o = null !== (r = { "\\arcsin": "Arcsin", "\\arccos": "Arccos", "\\arctan": "Arctan", "\\arctg": "Arctan", "\\arcctg": "Arctan", "\\arcsec": "Arcsec", "\\arccsc": " Arccsc", "\\arsinh": "Arsinh", "\\arcosh": "Arcosh", "\\artanh": "Artanh", "\\arcsech": "Arcsech", "\\arccsch": "Arcsch", "\\ch": "Cosh", "\\cos": "Cos", "\\cosec": "Csc", "\\cosh": "Csch", "\\cot": "Cot", "\\cotg": "Cot", "\\coth": "Coth", "\\csc": "Csc", "\\ctg": "Cot", "\\cth": "Coth", "\\sec": "Sec", "\\sin": "Sin", "\\sinh": "Sinh", "\\sh": "Sinh", "\\tan": "Tan", "\\tanh": "Tanh", "\\tg": "Tan", "\\th": "Tanh" }[n]) && void 0 !== r ? r : n; s && (o = ["InverseFunction", o]), a >= 1 && (o = ["Derivative", a, o]); const l = i.matchArguments("implicit"); return null === l ? [null, o] : [null, [o, ...l]]; }
|
30064 | function Q$1(e) { return o$1(e); }
|
30065 | Number.EPSILON.toString();
|
30066 | const Y$1 = { algebra: [{ name: "To", trigger: { infix: "\\to" }, precedence: 270 }], arithmetic: [{ name: "ThreeQuarter", serialize: "\\frac{3}{4}" }, { name: "TwoThird", serialize: "\\frac{2}{3}" }, { name: "Half", serialize: "\\frac{1}{2}" }, { name: "Third", serialize: "\\frac{1}{3}" }, { name: "Quarter", serialize: "\\frac{1}{4}" }, { name: "CatalanConstant", serialize: "G" }, { name: "GoldenRatio", serialize: "\\varphi" }, { name: "EulerGamma", serialize: "\\gamma" }, { name: "Degrees", serialize: "\\frac{\\pi}{180}" }, { name: "MinusDoublePi", serialize: "-2\\pi" }, { name: "MinusPi", serialize: "-\\pi" }, { name: "MinusHalfPi", serialize: "-\\frac{\\pi}{2}" }, { name: "QuarterPi", serialize: "\\frac{\\pi}{4}" }, { name: "ThirdPi", serialize: "\\frac{\\pi}{3}" }, { name: "HalfPi", serialize: "\\frac{\\pi}{2}" }, { name: "TwoThirdPi", serialize: "\\frac{2\\pi}{3}" }, { name: "ThreeQuarterPi", serialize: "\\frac{3\\pi}{4}" }, { name: "DoublePi", serialize: "2\\pi" }, { name: "Complex", precedence: 275, serialize: (e, i) => { const t = N$1(O$1(i, 1)), r = N$1(O$1(i, 2)); if (0 === r)
|
30067 | return e.serialize(O$1(i, 1)); const n = 1 === r ? "\\imaginaryI" : -1 === r ? "-\\imaginaryI" : a$1([e.serialize(O$1(i, 2)), "\\imaginaryI"]); return 0 === t ? n : a$1([e.serialize(O$1(i, 1)), "+", n]); } }, { name: "Exp", serialize: (e, i) => { var t; return a$1(["\\exponentialE^{", e.serialize(null !== (t = O$1(i, 1)) && void 0 !== t ? t : f$1), "}"]); } }, { name: "Square", serialize: (e, i) => e.wrapShort(O$1(i, 1)) + "^2" }, { trigger: { symbol: "\\infty" }, parse: { num: "+Infinity" } }, { name: "ComplexInfinity", trigger: { symbol: ["\\tilde", "\\infty"] }, serialize: "\\tilde\\infty" }, { name: "ComplexInfinity", trigger: { symbol: ["\\tilde", "<{>", "\\infty", "<}>"] }, serialize: "\\tilde\\infty" }, { name: "Pi", trigger: { symbol: "\\pi" } }, { name: "Pi", trigger: { symbol: "π" }, serialize: "\\pi" }, { name: "ExponentialE", trigger: { symbol: "e" }, serialize: "e" }, { name: "ImaginaryUnit", trigger: { symbol: "i" }, serialize: "\\imaginaryI" }, { name: "ImaginaryUnit", trigger: { symbol: "\\imaginaryI" } }, { name: m$1, trigger: { prefix: "+", infix: "+" }, parse: function (e, i, t) { if (275 < t)
|
30068 | return [e, null]; const r = i.index; if (!i.match("+"))
|
30069 | return [e, null]; const n = i.matchExpression(null === e ? 400 : 275); return null === n ? (i.index = r, [e, null]) : null === e ? [null, n] : i.applyOperator(m$1, e, n); }, serialize: function (e, i) { var t, r; e.level -= 1; const n = A$1(i); let s = "", a = O$1(i, 1), o = !Number.isNaN(null !== (t = N$1(a)) && void 0 !== t ? t : NaN); if ("Negate" === n)
|
30070 | s = "-" + e.wrap(a, 276);
|
30071 | else if (n === m$1) {
|
30072 | s = e.serialize(a);
|
30073 | const t = L$1(i) + 1;
|
30074 | for (let n = 2; n < t; n++) {
|
30075 | a = O$1(i, n);
|
30076 | const t = null !== (r = N$1(a)) && void 0 !== r ? r : NaN, l = !Number.isNaN(t);
|
30077 | let u = !1;
|
30078 | if (null !== a && o) {
|
30079 | const [i, t] = E$1(a);
|
30080 | null !== i && null !== t && isFinite(i) && isFinite(t) && 1 !== t && (s += e.options.invisiblePlus + e.serialize(a), u = !0);
|
30081 | }
|
30082 | if (!u)
|
30083 | if (t < 0)
|
30084 | s += e.serialize(a);
|
30085 | else if ("Negate" === A$1(a))
|
30086 | s += e.wrap(a, 275);
|
30087 | else {
|
30088 | const i = e.wrap(a, 275);
|
30089 | "-" === i[0] || "+" === i[0] ? s += i : s = s + "+" + i;
|
30090 | }
|
30091 | o = l;
|
30092 | }
|
30093 | }
|
30094 | else if ("Subtract" === n) {
|
30095 | const t = O$1(i, 2);
|
30096 | s = null !== t ? e.wrap(a, 275) + "-" + e.wrap(t, 275) : e.wrap(a, 275);
|
30097 | } return e.level += 1, s; }, associativity: "both", precedence: 275 }, { name: "Negate", trigger: { prefix: "-" }, parse: j, associativity: "left", precedence: 275 }, { name: "Subtract", trigger: { infix: "-" }, parse: j, associativity: "both", precedence: 275 }, { name: "PlusMinus", trigger: { infix: "\\pm" }, associativity: "both", precedence: 270 }, { name: "MinusPlus", trigger: { infix: "\\mp" }, associativity: "both", precedence: 270 }, { name: v$1, trigger: { infix: "\\times" }, serialize: H$1, associativity: "both", precedence: 390 }, { name: v$1, trigger: { infix: "\\cdot" }, serialize: H$1, associativity: "both", precedence: 390 }, { name: v$1, trigger: { infix: "*" }, serialize: H$1, associativity: "both", precedence: 390 }, { name: d$1, trigger: "\\frac", parse: function (e, i, t) { var r, n, s, a; if (!i.match("\\frac"))
|
30098 | return [e, null]; const o = null !== (r = i.matchRequiredLatexArgument()) && void 0 !== r ? r : p$1, l = null !== (n = i.matchRequiredLatexArgument()) && void 0 !== n ? n : p$1; if ("PartialDerivative" === A$1(o) && ("PartialDerivative" === A$1(l) || A$1(l) === v$1 && "PartialDerivative" === A$1(O$1(l, 1)))) {
|
30099 | const t = null !== (s = O$1(o, 3)) && void 0 !== s ? s : f$1;
|
30100 | let r = O$1(o, 1);
|
30101 | null !== r && r !== f$1 || (r = null !== (a = i.matchExpression()) && void 0 !== a ? a : f$1);
|
30102 | let n = [];
|
30103 | if (A$1(l) === v$1) {
|
30104 | for (const e of k$1(l))
|
30105 | if ("PartialDerivative" === M(e)) {
|
30106 | const i = O$1(e, 2);
|
30107 | i && n.push(i);
|
30108 | }
|
30109 | }
|
30110 | else {
|
30111 | const e = O$1(l, 2);
|
30112 | e && n.push(e);
|
30113 | }
|
30114 | return n.length > 1 && (n = [g$1, ...n]), [e, ["PartialDerivative", r, n, t === f$1 ? 1 : t]];
|
30115 | } return [e, [d$1, o, l]]; }, serialize: G$1, requiredLatexArg: 2 }, { name: d$1, trigger: { infix: "\\/" }, serialize: G$1, associativity: "non", precedence: 660 }, { name: d$1, trigger: { infix: "/" }, serialize: G$1, associativity: "non", precedence: 660 }, { name: d$1, trigger: { infix: "\\div" }, serialize: G$1, associativity: "non", precedence: 660 }, { name: x$1, trigger: { infix: "^" }, associativity: "non", precedence: 720, serialize: W$1 }, { name: x$1, trigger: { infix: ["*", "*"] }, associativity: "non", precedence: 720, serialize: W$1 }, { name: "Sqrt", trigger: "\\sqrt", optionalLatexArg: 1, requiredLatexArg: 1, parse: U, serialize: W$1 }, { name: "Root", trigger: "\\sqrt", optionalLatexArg: 1, requiredLatexArg: 1, parse: U }, { name: "Norm", trigger: { matchfix: "\\lVert" }, closeFence: "\\rVert" }, { name: "Norm", trigger: { matchfix: "\\|" }, closeFence: "\\|" }, { name: "Norm", trigger: { matchfix: ["|", "|"] }, closeFence: ["|", "|"] }, { name: "Abs", trigger: { matchfix: "|" }, closeFence: "|" }, { name: "Abs", trigger: { matchfix: "\\lvert" }, closeFence: "\\rvert" }, { name: "Factorial", trigger: { postfix: "!" }, precedence: 810 }, { name: "Factorial2", trigger: { postfix: ["!", "!"] }, precedence: 810 }, { name: "Lcm", trigger: { symbol: ["\\operatorname", "<{>", "l", "c", "m", "<}>"] } }, { name: "Gcd", trigger: { symbol: ["\\operatorname", "<{>", "g", "c", "d", "<}>"] } }, { name: "Ceil", trigger: { symbol: ["\\operatorname", "<{>", "c", "e", "i", "l", "<}>"] } }, { name: "Floor", trigger: { symbol: ["\\operatorname", "<{>", "f", "l", "o", "o", "r", "<}>"] } }, { name: "Round", trigger: { symbol: ["\\operatorname", "<{>", "r", "o", "u", "n", "d", "<}>"] } }, { name: "Sign", trigger: { symbol: ["\\operatorname", "<{>", "s", "g", "n", "<}>"] } }], calculus: [{ trigger: { symbol: "\\int" }, parse: function (e, i, t) { if (!i.match("\\int"))
|
30116 | return [e, null]; let r = f$1, n = f$1, s = !1; for (; !s;)
|
30117 | i.skipSpace(), i.match("_") ? n = i.matchRequiredLatexArgument() : i.match("^") ? r = i.matchRequiredLatexArgument() : s = !0; const a = i.matchBalancedExpression("<{>", "<}>"); return [e, ["Integral", null != a ? a : "", null != r ? r : f$1, null != n ? n : f$1]]; }, serialize: function (e, i) { return ""; } }], core: $$1, inequalities: [{ name: "NotLess", trigger: { infix: ["!", "<"] }, associativity: "right", precedence: 246 }, { name: "NotLess", trigger: { infix: "\\nless" }, associativity: "right", precedence: 246 }, { name: "Less", trigger: { infix: "<" }, associativity: "right", precedence: 245 }, { name: "Less", trigger: { infix: "\\lt" }, associativity: "right", precedence: 245 }, { name: "LessEqual", trigger: { infix: ["<", "="] }, associativity: "right", precedence: 241 }, { name: "LessEqual", trigger: { infix: "\\le" }, associativity: "right", precedence: 241 }, { name: "LessEqual", trigger: { infix: "\\leq" }, associativity: "right", precedence: 241 }, { name: "LessEqual", trigger: { infix: "\\leqslant" }, associativity: "right", precedence: 265 }, { name: "LessNotEqual", trigger: { infix: "\\lneqq" }, associativity: "right", precedence: 260 }, { name: "NotLessNotEqual", trigger: { infix: "\\nleqq" }, associativity: "right", precedence: 260 }, { name: "LessOverEqual", trigger: { infix: "\\leqq" }, associativity: "right", precedence: 265 }, { name: "GreaterOverEqual", trigger: { infix: "\\geqq" }, associativity: "right", precedence: 265 }, { name: "Equal", trigger: { infix: "=" }, associativity: "right", precedence: 260 }, { name: "StarEqual", trigger: { infix: ["*", "="] }, associativity: "right", precedence: 260 }, { name: "StarEqual", trigger: { infix: ["\\star", "="] }, associativity: "right", precedence: 260 }, { name: "PlusEqual", trigger: { infix: ["+", "="] }, associativity: "right", precedence: 260 }, { name: "MinusEqual", trigger: { infix: ["-", "="] }, associativity: "right", precedence: 260 }, { name: "SlashEqual", trigger: { infix: ["/", "="] }, associativity: "right", precedence: 260 }, { name: "EqualEqual", trigger: { infix: ["=", "="] }, associativity: "right", precedence: 260 }, { name: "EqualEqualEqual", trigger: { infix: ["=", "=", "="] }, associativity: "right", precedence: 265 }, { name: "TildeFullEqual", trigger: { infix: "\\cong" }, associativity: "right", precedence: 260 }, { name: "NotTildeFullEqual", trigger: { infix: "\\ncong" }, associativity: "right", precedence: 260 }, { name: "Assign", trigger: { infix: [":", "="] }, associativity: "right", precedence: 260 }, { name: "Assign", trigger: { infix: "\\coloneq" }, associativity: "right", precedence: 260 }, { name: "Approx", trigger: { infix: "\\approx" }, associativity: "right", precedence: 247 }, { name: "NotApprox", trigger: { infix: "\\approx" }, associativity: "right", precedence: 247 }, { name: "ApproxEqual", trigger: { infix: "\\approxeq" }, associativity: "right", precedence: 260 }, { name: "NotApproxEqual", trigger: { infix: ["!", "\\approxeq"] }, associativity: "right", precedence: 250 }, { name: "NotEqual", trigger: { infix: "\\ne" }, associativity: "right", precedence: 255 }, { name: "Unequal", trigger: { infix: ["!", "="] }, associativity: "right", precedence: 260 }, { name: "GreaterEqual", trigger: { infix: "\\ge" }, associativity: "right", precedence: 242 }, { name: "GreaterEqual", trigger: { infix: "\\geq" }, associativity: "right", precedence: 242 }, { name: "GreaterEqual", trigger: { infix: [">", "="] }, associativity: "right", precedence: 243 }, { name: "GreaterEqual", trigger: { infix: "\\geqslant" }, associativity: "right", precedence: 265 }, { name: "GreaterNotEqual", trigger: { infix: "\\gneqq" }, associativity: "right", precedence: 260 }, { name: "NotGreaterNotEqual", trigger: { infix: "\\ngeqq" }, associativity: "right", precedence: 260 }, { name: "Greater", trigger: { infix: ">" }, associativity: "right", precedence: 245 }, { name: "Greater", trigger: { infix: "\\gt" }, associativity: "right", precedence: 245 }, { name: "NotGreater", trigger: { infix: "\\ngtr" }, associativity: "right", precedence: 244 }, { name: "NotGreater", trigger: { infix: ["!", ">"] }, associativity: "right", precedence: 244 }, { name: "RingEqual", trigger: { infix: "\\circeq" }, associativity: "right", precedence: 260 }, { name: "TriangleEqual", trigger: { infix: "\\triangleq" }, associativity: "right", precedence: 260 }, { name: "DotEqual", trigger: { infix: "\\doteq" }, associativity: "right", precedence: 265 }, { name: "DotEqualDot", trigger: { infix: "\\doteqdot" }, associativity: "right", precedence: 265 }, { name: "FallingDotEqual", trigger: { infix: "\\fallingdotseq" }, associativity: "right", precedence: 265 }, { name: "RisingDotEqual", trigger: { infix: "\\fallingdotseq" }, associativity: "right", precedence: 265 }, { name: "QuestionEqual", trigger: { infix: "\\questeq" }, associativity: "right", precedence: 260 }, { name: "Equivalent", trigger: { infix: "\\equiv" }, associativity: "right", precedence: 260 }, { name: "MuchLess", trigger: { infix: "\\ll" }, associativity: "right", precedence: 260 }, { name: "MuchGreater", trigger: { infix: "\\gg" }, associativity: "right", precedence: 260 }, { name: "Precedes", trigger: { infix: "\\prec" }, associativity: "right", precedence: 260 }, { name: "Succeeds", trigger: { infix: "\\succ" }, associativity: "right", precedence: 260 }, { name: "PrecedesEqual", trigger: { infix: "\\preccurlyeq" }, associativity: "right", precedence: 260 }, { name: "SucceedsEqual", trigger: { infix: "\\curlyeqprec" }, associativity: "right", precedence: 260 }, { name: "NotPrecedes", trigger: { infix: "\\nprec" }, associativity: "right", precedence: 260 }, { name: "NotSucceeds", trigger: { infix: "\\nsucc" }, associativity: "right", precedence: 260 }, { name: "Between", trigger: { infix: "\\between" }, associativity: "right", precedence: 265 }], other: D, physics: [{ name: "mu-0", trigger: { symbol: ["\\mu", "_", "0"] } }], sets: [{ trigger: { symbol: "\\N" }, parse: "NaturalNumber" }, { trigger: { symbol: "\\Z" }, parse: "Integer" }, { trigger: { symbol: "\\Q" }, parse: "RationalNumber" }, { trigger: { symbol: ["\\mathbb", "<{>", "A", "<}>"] }, parse: "AlgebraicNumber" }, { trigger: { symbol: "\\R" }, parse: "RealNumber" }, { trigger: { symbol: "\\C" }, parse: "ComplexNumber" }, { trigger: { symbol: "\\varnothing" }, parse: "EmptySet" }, { trigger: { symbol: "\\emptyset" }, parse: "EmptySet" }, { name: "Complement", trigger: { infix: "\\complement" }, precedence: 240 }, { name: "Element", trigger: { infix: "\\in" }, precedence: 240 }, { name: "Intersection", trigger: { infix: "\\Cap" }, precedence: 350 }, { name: "NotElement", trigger: { infix: "\\notin" }, precedence: 240 }, { name: "SetMinus", trigger: { infix: "\\setminus" }, precedence: 650 }, { name: "SubsetEqual", trigger: { infix: "\\subseteq" }, precedence: 240 }, { name: "SymmetricDifference", trigger: { infix: "\\triangle" }, precedence: 260 }, { name: "Union", trigger: { infix: "\\cup" }, precedence: 350 }, { name: "Contains", trigger: { infix: "\\ni" }, associativity: "right", precedence: 160 }, { name: "Subset", trigger: { infix: "\\subset" }, associativity: "right", precedence: 240 }, { name: "SquareSubset", trigger: { infix: "\\sqsubset" }, associativity: "right", precedence: 265 }, { name: "SquareSubsetEqual", trigger: { infix: "\\sqsubseteq" }, associativity: "right", precedence: 265 }, { name: "Superset", trigger: { infix: "\\supset" }, associativity: "right", precedence: 240 }, { name: "SquareSuperset", trigger: { infix: "\\sqsupset" }, associativity: "right", precedence: 265 }, { name: "SquareSupersetEqual", trigger: { infix: "\\sqsupseteq" }, associativity: "right", precedence: 265 }, { name: "NotSubset", trigger: { infix: "\\nsubset" }, associativity: "right", precedence: 240 }, { name: "NotSuperset", trigger: { infix: "\\nsupset" }, associativity: "right", precedence: 240 }, { name: "SupersetEqual", trigger: { infix: "\\supseteq" }, associativity: "right", precedence: 240 }, { name: "NotSubsetNotEqual", trigger: { infix: "\\nsubseteq" }, associativity: "right", precedence: 240 }, { name: "NotSupersetNotEqual", trigger: { infix: "\\nsupseteq" }, associativity: "right", precedence: 240 }, { name: "SubsetNotEqual", trigger: { infix: "\\subsetneq" }, associativity: "right", precedence: 240 }, { name: "SubsetNotEqual", trigger: { infix: "\\varsupsetneqq" }, associativity: "right", precedence: 240 }, { name: "SupersetNotEqual", trigger: { infix: "\\supsetneq" }, associativity: "right", precedence: 240 }, { name: "SupersetNotEqual", trigger: { infix: "\\varsupsetneq" }, associativity: "right", precedence: 240 }], symbols: [{ trigger: { symbol: "\\alpha" }, parse: "α" }, { trigger: { symbol: "\\beta" }, parse: "β" }, { trigger: { symbol: "\\gamma" }, parse: "γ" }, { trigger: { symbol: "\\delta" }, parse: "δ" }, { trigger: { symbol: "\\epsilon" }, parse: "ϵ" }, { trigger: { symbol: "\\varepsilon" }, parse: "ε" }, { trigger: { symbol: "\\zeta" }, parse: "ζ" }, { trigger: { symbol: "\\eta" }, parse: "η" }, { trigger: { symbol: "\\theta" }, parse: "θ" }, { trigger: { symbol: "\\vartheta" }, parse: "ϑ" }, { trigger: { symbol: "\\iota" }, parse: "ι" }, { trigger: { symbol: "\\kappa" }, parse: "κ" }, { trigger: { symbol: "\\varkappa" }, parse: "ϰ" }, { trigger: { symbol: "\\lambda" }, parse: "λ" }, { trigger: { symbol: "\\mu" }, parse: "μ" }, { trigger: { symbol: "\\nu" }, parse: "ν" }, { trigger: { symbol: "\\xi" }, parse: "ξ" }, { trigger: { symbol: "\\omicron" }, parse: "ο" }, { trigger: { symbol: "\\varpi" }, parse: "ϖ" }, { trigger: { symbol: "\\rho" }, parse: "ρ" }, { trigger: { symbol: "\\varrho" }, parse: "ϱ" }, { trigger: { symbol: "\\sigma" }, parse: "σ" }, { trigger: { symbol: "\\varsigma" }, parse: "ς" }, { trigger: { symbol: "\\tau" }, parse: "τ" }, { trigger: { symbol: "\\phi" }, parse: "ϕ" }, { trigger: { symbol: "\\varphi" }, parse: "φ" }, { trigger: { symbol: "\\upsilon" }, parse: "υ" }, { trigger: { symbol: "\\chi" }, parse: "χ" }, { trigger: { symbol: "\\psi" }, parse: "ψ" }, { trigger: { symbol: "\\omega" }, parse: "ω" }, { trigger: { symbol: "\\Gamma" }, parse: "Γ" }, { trigger: { symbol: "\\Delta" }, parse: "Δ" }, { trigger: { symbol: "\\Theta" }, parse: "Θ" }, { trigger: { symbol: "\\Lambda" }, parse: "Λ" }, { trigger: { symbol: "\\Xi" }, parse: "Ξ" }, { trigger: { symbol: "\\Pi" }, parse: "Π" }, { trigger: { symbol: "\\Sigma" }, parse: "Σ" }, { trigger: { symbol: "\\Upsilon" }, parse: "Υ" }, { trigger: { symbol: "\\Phi" }, parse: "Φ" }, { trigger: { symbol: "\\Psi" }, parse: "Ψ" }, { trigger: { symbol: "\\Omega" }, parse: "Ω" }, { trigger: { symbol: "\\digamma" }, parse: "ϝ" }, { trigger: { symbol: "\\aleph" }, parse: "ℵ" }, { trigger: { symbol: "\\beth" }, parse: "ℶ" }, { trigger: { symbol: "\\daleth" }, parse: "ℸ" }, { trigger: { symbol: "\\gimel" }, parse: "ℷ" }, { trigger: { symbol: "\\Finv" }, parse: "Ⅎ" }, { trigger: { symbol: "\\Game" }, parse: "⅁" }, { trigger: { symbol: "\\wp" }, parse: "℘" }, { trigger: { symbol: "\\eth" }, parse: "ð" }, { trigger: { symbol: "\\mho" }, parse: "℧" }, { trigger: { symbol: "\\clubsuit" }, parse: "♣" }, { trigger: { symbol: "\\heartsuit" }, parse: "♡" }, { trigger: { symbol: "\\spadesuit" }, parse: "♠" }, { trigger: { symbol: "\\diamondsuit" }, parse: "♢" }, { trigger: { symbol: "\\sharp" }, parse: "♯" }, { trigger: { symbol: "\\flat" }, parse: "♭" }, { trigger: { symbol: "\\natural" }, parse: "♮" }], trigonometry: [{ name: "Arcsin", trigger: "\\arcsin", arguments: "implicit", parse: V$1 }, { name: "Arccos", trigger: "\\arccos", arguments: "implicit", parse: V$1 }, { name: "Arctan", trigger: "\\arctan", arguments: "implicit", parse: V$1 }, { name: "Arctan", trigger: "\\arctg", arguments: "implicit", parse: V$1 }, { name: "Arccot", trigger: "\\arcctg", arguments: "implicit", parse: V$1 }, { name: "Arcsec", trigger: "\\arcsec", arguments: "implicit", parse: V$1 }, { name: "Arccsc", trigger: "\\arccsc", arguments: "implicit", parse: V$1 }, { name: "Arsinh", trigger: "\\arsinh", arguments: "implicit", parse: V$1 }, { name: "Arcosh", trigger: "\\arcosh", arguments: "implicit", parse: V$1 }, { name: "Artanh", trigger: "\\artanh", arguments: "implicit", parse: V$1 }, { name: "Arsech", trigger: "\\arsech", arguments: "implicit", parse: V$1 }, { name: "Arcsch", trigger: "\\arcsch", arguments: "implicit", parse: V$1 }, { name: "Cosh", trigger: "\\ch", arguments: "implicit", parse: V$1 }, { name: "Cosec", trigger: "\\cosec", arguments: "implicit", parse: V$1 }, { name: "Cosh", trigger: "\\cosh", arguments: "implicit", parse: V$1 }, { name: "Cot", trigger: "\\cot", arguments: "implicit", parse: V$1 }, { name: "Cot", trigger: "\\cotg", arguments: "implicit", parse: V$1 }, { name: "Coth", trigger: "\\coth", arguments: "implicit", parse: V$1 }, { name: "Csc", trigger: "\\csc", arguments: "implicit", parse: V$1 }, { name: "Cot", trigger: "\\ctg", arguments: "implicit", parse: V$1 }, { name: "Coth", trigger: "\\cth", arguments: "implicit", parse: V$1 }, { name: "Sec", trigger: "\\sec", arguments: "implicit", parse: V$1 }, { name: "Sinh", trigger: "\\sinh", arguments: "implicit", parse: V$1 }, { name: "Sinh", trigger: "\\sh", arguments: "implicit", parse: V$1 }, { name: "Tan", trigger: "\\tan", arguments: "implicit", parse: V$1 }, { name: "Tan", trigger: "\\tg", arguments: "implicit", parse: V$1 }, { name: "Tanh", trigger: "\\tanh", arguments: "implicit", parse: V$1 }, { name: "Tanh", trigger: "\\th", arguments: "implicit", parse: V$1 }, { name: "Cos", trigger: "\\cos", arguments: "implicit", parse: V$1 }, { name: "Sin", trigger: "\\sin", arguments: "implicit", parse: V$1 }] }, J$1 = { precision: 15, positiveInfinity: "\\infty", negativeInfinity: "-\\infty", notANumber: "\\operatorname{NaN}", decimalMarker: ".", groupSeparator: ",", exponentProduct: "\\cdot", beginExponentMarker: "10^{", endExponentMarker: "}", notation: "auto", truncationMarker: "\\ldots", beginRepeatingDigits: "\\overline{", endRepeatingDigits: "}", imaginaryNumber: "\\imaginaryI" }, K = { invisibleOperator: v$1, skipSpace: !0, parseArgumentsOfUnknownLatexCommands: !0, parseNumbers: !0, promoteUnknownSymbols: /^[a-zA-Z]$/, promoteUnknownFunctions: /^[fg]$/, ignoreCommands: ["\\displaystyle", "\\!", "\\:", "\\enskip", "\\quad", "\\,", "\\;", "\\enspace", "\\qquad", "\\selectfont", "\\tiny", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"], idempotentCommands: ["\\left", "\\right", "\\mleft", "\\mright", "\\middle", "\\bigl", "\\bigm", "\\bigr", "\\Bigl", "\\Bigm", "\\Bigr", "\\biggl", "\\biggm", "\\biggr", "\\Biggl", "\\Biggm", "\\Biggr"], invisiblePlusOperator: m$1, preserveLatex: !1 }, X$1 = { invisibleMultiply: "", invisiblePlus: "", multiply: "\\times" };
|
30118 | function ee(e, i) { var t; let r = e; for (let e = 0; e < i.length; e++) {
|
30119 | let n = null !== (t = i[e]) && void 0 !== t ? t : "";
|
30120 | if (/[a-zA-Z*]/.test(n[0])) {
|
30121 | const i = r.match(new RegExp("(.*)#" + Number(e + 1).toString()));
|
30122 | i && /\\[a-zA-Z*]+/.test(i[1]) && (n = " " + n);
|
30123 | }
|
30124 | r = r.replace("#" + Number(e + 1).toString(), n);
|
30125 | } return r; }
|
30126 | class ie$1 {
|
30127 | constructor(e, i, t, r) { let n; this.index = 0, this.options = { ...J$1, ...K, ...i }, this.tokens = e, this.onError = e => r({ ...e, before: this.latexBefore(), after: this.latexAfter() }), this.dictionary = t, this.invisibleOperatorPrecedence = 0, this.options.invisibleOperator && (n = this.dictionary.name.get(this.options.invisibleOperator), void 0 === n ? r({ code: "unknown-operator", arg: "invisible operator " + this.options.invisibleOperator }) : void 0 === n.precedence ? r({ code: "expected-operator", arg: "invisible operator " + this.options.invisibleOperator }) : this.invisibleOperatorPrecedence = n.precedence); }
|
30128 | clone(e, i) { return new ie$1(this.tokens.slice(e, i), this.options, this.dictionary, this.onError); }
|
30129 | balancedClone(e, i, t = !0) { if (!this.matchAll(e))
|
30130 | return t || this.onError({ code: "syntax-error", arg: "Expected " + o$1(e) }), null; const r = this.index; let n = r, s = 1; for (; !this.atEnd && 0 !== s;)
|
30131 | this.skipSpace(), n = this.index, this.matchAll(i) ? s -= 1 : this.matchAll(e) ? s += 1 : this.next(); return 0 !== s ? (t || this.onError({ code: "unbalanced-symbols", arg: o$1(e) + o$1(i) }), this.index = r, null) : this.clone(r, n); }
|
30132 | get atEnd() { return this.index >= this.tokens.length; }
|
30133 | get peek() { return this.tokens[this.index]; }
|
30134 | latex(e, i) { return o$1(this.tokens.slice(e, i)); }
|
30135 | latexAhead(e) { return o$1(this.tokens.slice(this.index, this.index + e)); }
|
30136 | latexBefore() { return this.latex(0, this.index); }
|
30137 | latexAfter() { return this.latex(this.index); }
|
30138 | lookAhead() { let e = Math.min(this.dictionary.lookahead, this.tokens.length - this.index); const i = []; for (; e > 0;)
|
30139 | i[e] = this.latexAhead(e--); return i; }
|
30140 | peekDefinition(e) { let i; i = "operator" === e ? this.lookAhead().map(((e, i) => { var t, r, n, s, a; return null !== (s = null !== (r = null === (t = this.dictionary.infix[i]) || void 0 === t ? void 0 : t.get(e)) && void 0 !== r ? r : null === (n = this.dictionary.postfix[i]) || void 0 === n ? void 0 : n.get(e)) && void 0 !== s ? s : null === (a = this.dictionary.prefix[i]) || void 0 === a ? void 0 : a.get(e); })) : this.lookAhead().map(((i, t) => { var r; return null === (r = this.dictionary[e][t]) || void 0 === r ? void 0 : r.get(i); })); for (let e = i.length; e > 0; e--)
|
30141 | if (void 0 !== i[e])
|
30142 | return [i[e], e]; return [null, 0]; }
|
30143 | next() { return this.tokens[this.index++]; }
|
30144 | skipSpace() { if (!this.atEnd && "<{>" === this.peek && "<}>" === this.tokens[this.index + 1])
|
30145 | return this.index += 2, this.skipSpace(), !0; let e = !1; for (; !this.atEnd && (this.options.ignoreCommands.includes(this.peek) || this.options.idempotentCommands.includes(this.peek));)
|
30146 | this.index += 1, this.skipSpace(), e = !0; if (!this.options.skipSpace)
|
30147 | return !1; for (; this.match("<space>");)
|
30148 | e = !0; return e && this.skipSpace(), e; }
|
30149 | match(e) { return this.tokens[this.index] === e && (this.index++, !0); }
|
30150 | matchAll(e) { let i = !0; "string" == typeof e && (e = [e]); let t = 0; do {
|
30151 | i = this.tokens[this.index + t] === e[t++];
|
30152 | } while (i && t < e.length); return i && (this.index += t), i; }
|
30153 | matchAny(e) { return e.includes(this.tokens[this.index]) ? this.tokens[this.index++] : ""; }
|
30154 | matchWhile(e) { const i = []; for (; e.includes(this.tokens[this.index]);)
|
30155 | i.push(this.tokens[this.index++]); return i; }
|
30156 | matchSign() { let e = !1, i = !1; for (; !i;)
|
30157 | this.skipSpace() ? i = !1 : this.match("-") ? (e = !e, i = !1) : i = !this.match("+"); return e ? "-" : "+"; }
|
30158 | matchDecimalDigits() { let e = "", i = !1; for (; !i;)
|
30159 | if (e += this.matchWhile(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]).join(""), i = !0, this.options.groupSeparator) {
|
30160 | const e = this.index;
|
30161 | this.match(this.options.groupSeparator) && (/[0-9]/.test(this.peek) ? i = !1 : this.index = e);
|
30162 | } return e; }
|
30163 | matchSignedInteger() { const e = this.index, i = this.matchSign(), t = this.matchDecimalDigits(); return t ? ("-" === i ? "-" : "") + t : (this.index = e, ""); }
|
30164 | matchExponent() { const e = this.index; let i = ""; if (this.matchAny(["e", "E", "d", "D"])) {
|
30165 | const e = this.matchSignedInteger();
|
30166 | e && (i = "e" + e);
|
30167 | } if (i)
|
30168 | return i; if (this.match("\\times") && (this.skipSpace(), this.match("1") && this.match("0") && this.match("^"))) {
|
30169 | if (/[0-9]/.test(this.peek))
|
30170 | return "e" + this.next();
|
30171 | if (this.match("<{>")) {
|
30172 | this.skipSpace();
|
30173 | const e = this.matchSignedInteger();
|
30174 | if (this.skipSpace(), this.match("<}>") && e)
|
30175 | return "e" + e;
|
30176 | }
|
30177 | } return this.index = e, ""; }
|
30178 | matchNumber() { var e, i; if (!this.options.parseNumbers)
|
30179 | return ""; const t = this.index, r = this.matchSign(); let n = this.matchDecimalDigits(); if (!n)
|
30180 | return this.index = t, ""; n = ("-" === r ? "-" : "") + n; let s = !1, a = !1; this.match(null !== (e = this.options.decimalMarker) && void 0 !== e ? e : "") && (s = !0, n += "." + (null !== (i = this.matchDecimalDigits()) && void 0 !== i ? i : "0")); const o = this.matchExponent(); return o && (a = !0), n ? n.length + o.length > 12 ? s || a ? n + o + "d" : n + "n" : n + o : (this.index = t, ""); }
|
30181 | matchOperator(e, i = null, t = 0) { const [r, n] = this.peekDefinition(e); if (null === r)
|
30182 | return null; if ("function" == typeof r.parse) {
|
30183 | let e = null;
|
30184 | return [i, e] = r.parse(i, this, t), null === e ? null : this.applyInvisibleOperator(i, e);
|
30185 | } let s = r.precedence; if (void 0 === s || s < t)
|
30186 | return null; s += "left" === r.associativity ? 1 : 0, this.index += n; const a = this.matchExpression(s); return this.applyInvisibleOperator(...this.applyOperator(r.parse, i, a)); }
|
30187 | matchArguments(e) { if (!e)
|
30188 | return null; const i = this.index; let t = null; const r = this.matchMatchfixOperator(); if ("group" === e && "Parentheses" === A$1(r))
|
30189 | t = k$1(r);
|
30190 | else if ("implicit" === e)
|
30191 | if ("Parentheses" === A$1(r))
|
30192 | t = k$1(r);
|
30193 | else if (null !== r)
|
30194 | t = [r];
|
30195 | else {
|
30196 | const e = this.matchPrimary();
|
30197 | null !== e && (t = [e]);
|
30198 | }
|
30199 | else
|
30200 | this.index = i; return t; }
|
30201 | matchMatchfixOperator() { const [e] = this.peekDefinition("matchfix"); if (null === e)
|
30202 | return null; if ("function" == typeof e.parse)
|
30203 | return this.applyInvisibleOperator(...e.parse(null, this, 0)); const i = "object" == typeof e.trigger ? e.trigger.matchfix : e.trigger; if (!i || !e.closeFence || !e.parse)
|
30204 | return null; const t = this.matchBalancedExpression(i, e.closeFence, this.onError); return t ? [e.parse, t] : [e.parse]; }
|
30205 | matchDefinition(e) { const [i, t] = this.peekDefinition(e); if ("function" == typeof (null == i ? void 0 : i.parse)) {
|
30206 | const [, e] = i.parse(null, this, 0);
|
30207 | return [i, e];
|
30208 | } return this.index += t, [i, null]; }
|
30209 | matchSymbol() { var e, i, t, r; const [n, s] = this.matchDefinition("symbol"); if (null !== s)
|
30210 | return s; if (null === n) {
|
30211 | if (null === (e = this.options.promoteUnknownFunctions) || void 0 === e ? void 0 : e.test(this.peek)) {
|
30212 | const e = this.next(), i = this.matchMatchfixOperator();
|
30213 | return null === i ? e : "Parentheses" !== A$1(i) ? null : [e, ...k$1(i)];
|
30214 | }
|
30215 | return (null === (i = this.options.promoteUnknownSymbols) || void 0 === i ? void 0 : i.test(this.peek)) ? this.next() : this.matchUnknownLatexCommand();
|
30216 | } const a = [], o = []; let l, u = null !== (t = n.optionalLatexArg) && void 0 !== t ? t : 0; for (; u > 0;)
|
30217 | l = this.matchOptionalLatexArgument(), null !== l && o.push(l), u--; for (u = null !== (r = n.requiredLatexArg) && void 0 !== r ? r : 0; u > 0;)
|
30218 | l = this.matchRequiredLatexArgument(), null === l && this.onError({ code: "expected-argument" }), null !== l && a.push(l), u--; const c = this.matchArguments(n.arguments); return null === c ? 0 === a.length && 0 === o.length ? n.parse : [n.parse, ...a, ...o] : [n.parse, ...a, ...c, ...o]; }
|
30219 | matchOptionalLatexArgument() { return this.skipSpace(), this.matchBalancedExpression("[", "]"); }
|
30220 | matchRequiredLatexArgument() { return this.skipSpace(), this.matchBalancedExpression("<{>", "<}>") || (/^[0-9]$/.test(this.peek) ? parseFloat(this.next()) : /^[^\\#]$/.test(this.peek) ? this.next() : this.matchSymbol()); }
|
30221 | matchSupsub(e) { if (null === e)
|
30222 | return null; let i = null; return this.skipSpace(), [["^", "superfix"], ["_", "subfix"]].forEach((t => { var r, n, s; if (null !== i)
|
30223 | return; const [a, o] = t, l = this.index; if (!this.match(a))
|
30224 | return; const u = this.index; let c, h = 0; if (this.match("<{>") ? ([c, h] = this.peekDefinition(o), c ? "function" == typeof c.parse ? i = c.parse(e, this, 0)[1] : (this.index += h, this.match("<}>") ? i = [null !== (r = c.parse) && void 0 !== r ? r : c.name, e] : this.index = u) : this.index = u) : ([c, h] = this.peekDefinition(o), c ? "function" == typeof c.parse ? i = c.parse(e, this, 0)[1] : (this.index += h, i = [null !== (n = c.parse) && void 0 !== n ? n : c.name, e]) : this.index = u), null === i && (c = null === (s = this.dictionary.infix[1]) || void 0 === s ? void 0 : s.get(a), "function" == typeof (null == c ? void 0 : c.parse) ? (this.index = l, i = c.parse(e, this, 0)[1]) : "string" == typeof (null == c ? void 0 : c.parse) ? ([e, i] = this.applyOperator(c.parse, e, this.matchRequiredLatexArgument()), i = this.applyInvisibleOperator(e, i)) : i = this.applyInvisibleOperator(e, a)), null !== i) {
|
30225 | const e = this.matchArguments(null == c ? void 0 : c.arguments);
|
30226 | null !== e && (i = [i, ...e]);
|
30227 | } })), i; }
|
30228 | matchPostfix(e) { if (null === e)
|
30229 | return null; const [i, t] = this.peekDefinition("postfix"); return null == i ? null : "function" == typeof i.parse ? ([, e] = i.parse(e, this, 0), null === e ? null : e) : (this.index += t, [i.parse, e]); }
|
30230 | matchString() { let e = "", i = this.atEnd; for (; !i;) {
|
30231 | if (this.match("<space>"))
|
30232 | e += " ";
|
30233 | else {
|
30234 | const t = this.peek;
|
30235 | "]" === t ? i = !0 : /^<({|}|\$|\$\$|space)>$/.test(t) ? "\\" === t[0] ? (this.onError({ code: "unexpected-command" }), e += this.next()) : i = !0 : e += this.next();
|
30236 | }
|
30237 | i = i || this.atEnd;
|
30238 | } return e; }
|
30239 | matchEnvironmentName(e, i) { if (this.match(e)) {
|
30240 | const e = this.index;
|
30241 | if (this.match("<{>")) {
|
30242 | const e = this.matchString();
|
30243 | if (this.match("<}>") && e === i)
|
30244 | return !0;
|
30245 | }
|
30246 | this.index = e;
|
30247 | } return !1; }
|
30248 | matchTabular() { const e = ["list"]; let i = ["list"], t = null, r = !1; for (; !this.atEnd && !r;)
|
30249 | if (this.match("&"))
|
30250 | i.push(null != t ? t : f$1), t = null;
|
30251 | else if (this.match("\\\\") || this.match("\\cr"))
|
30252 | this.skipSpace(), this.matchOptionalLatexArgument(), null !== t && i.push(t), e.push(i), i = ["list"], t = null;
|
30253 | else {
|
30254 | const e = this.matchExpression();
|
30255 | null === e && (r = !0), t = null !== t ? this.applyInvisibleOperator(t, e) : e;
|
30256 | } return i.length > 1 && e.push(i), e; }
|
30257 | matchEnvironment() { var e; if (this.match("\\begin") && this.match("<{>")) {
|
30258 | const i = this.matchString();
|
30259 | if (this.match("<}>")) {
|
30260 | const t = this.index;
|
30261 | let r = this.index, n = 1;
|
30262 | for (; !this.atEnd && 0 !== n;)
|
30263 | r = this.index, this.matchEnvironmentName("\\begin", i) ? n += 1 : this.matchEnvironmentName("\\end", i) ? n -= 1 : this.next();
|
30264 | const s = this.dictionary.environment.get(i);
|
30265 | return "function" == typeof (null == s ? void 0 : s.parse) ? s.parse(null, this.clone(t, r), 0)[1] : null !== (e = null == s ? void 0 : s.parse) && void 0 !== e ? e : null;
|
30266 | }
|
30267 | } return null; }
|
30268 | applyOperator(e, i, t) { var r, n, s, a; const o = this.dictionary.name.get(e); if (void 0 === o)
|
30269 | return this.onError({ code: "unknown-operator" }), [i, t]; if (void 0 !== (null === (r = o.trigger) || void 0 === r ? void 0 : r.prefix) && null === i && null !== t)
|
30270 | return [null, [o.name, t]]; if (void 0 !== (null === (n = o.trigger) || void 0 === n ? void 0 : n.postfix) && null !== i)
|
30271 | return [null, [o.name, i]]; if (void 0 !== (null === (s = o.trigger) || void 0 === s ? void 0 : s.matchfix) || void 0 !== (null === (a = o.trigger) || void 0 === a ? void 0 : a.infix)) {
|
30272 | if ("non" === o.associativity)
|
30273 | return [null, [e, null != i ? i : "Missing", null != t ? t : "Missing"]];
|
30274 | if (A$1(i) === e) {
|
30275 | if ("both" === o.associativity) {
|
30276 | if (A$1(t) === e) {
|
30277 | if (Array.isArray(i))
|
30278 | return [null, i.concat(k$1(t))];
|
30279 | if (w$1(i))
|
30280 | return [null, i.fn.concat(k$1(t))];
|
30281 | }
|
30282 | else
|
30283 | t && (Array.isArray(i) && i.push(t), w$1(i) && i.fn.push(t));
|
30284 | return [null, i];
|
30285 | }
|
30286 | return "left" === o.associativity ? [null, [e, null != i ? i : p$1, null != t ? t : p$1]] : Array.isArray(i) ? [null, [e, i[1], [e, i[2], null != t ? t : p$1]]] : (w$1(i) && (i.fn[2] = [e, i.fn[2], null != t ? t : p$1]), [null, i]);
|
30287 | }
|
30288 | return A$1(t) === e ? "both" === o.associativity ? (Array.isArray(t) && i && t.splice(1, 0, i), w$1(t) && i && t.fn.splice(1, 0, i), [null, t]) : "right" === o.associativity ? [null, [e, null != i ? i : p$1, null != t ? t : p$1]] : Array.isArray(t) ? [null, [e, t[1], [e, t[2], null != i ? i : p$1]]] : (w$1(t) && (t.fn[2] = [e, t.fn[2], null != i ? i : p$1]), [null, t]) : [null, [e, null != i ? i : "Missing", null != t ? t : "Missing"]];
|
30289 | } return [i, null]; }
|
30290 | applyInvisibleOperator(e, i) { if (null === e)
|
30291 | return i; if (null === i)
|
30292 | return e; if (this.options.invisiblePlusOperator && ("number" == typeof e || y$1(e)) && function (e) { var i, t; const r = z$1(e); if (null !== r && ["ThreeQuarter", "TwoThird", "Half", "Third", "Quarter"].includes(r))
|
30293 | return !0; if (A$1(e) !== d$1)
|
30294 | return !1; const n = null !== (i = N$1(O$1(e, 1))) && void 0 !== i ? i : NaN, s = null !== (t = N$1(O$1(e, 2))) && void 0 !== t ? t : NaN; return Number.isInteger(n) && Number.isInteger(s); }(i))
|
30295 | return [e, i] = this.applyOperator(this.options.invisiblePlusOperator, e, i), null === e ? i : null; if (this.options.invisibleOperator)
|
30296 | return [e, i] = this.applyOperator(this.options.invisibleOperator, e, i), null === e ? i : null; let t = ["LatexTokens"]; return "LatexTokens" === A$1(e) ? t = t.concat(k$1(e)) : t.push(e), null !== i && ("LatexTokens" === A$1(i) ? t = t.concat(k$1(i)) : t.push(i)), this.options.invisibleOperator && this.onError({ code: "unexpected-sequence" }), t; }
|
30297 | matchUnknownLatexCommand() { var e; const i = this.peek; if (!i || "\\" !== i[0])
|
30298 | return null; if (this.next(), "\\operatorname" === i) {
|
30299 | if (this.skipSpace(), "<{>" === this.peek) {
|
30300 | let e = "";
|
30301 | for (this.next(); !this.atEnd && "<}>" !== this.tokens[this.index];)
|
30302 | e += this.next();
|
30303 | return e;
|
30304 | }
|
30305 | return null !== (e = this.next()) && void 0 !== e ? e : p$1;
|
30306 | } const t = [], r = []; let n = !1; do {
|
30307 | n = !0;
|
30308 | let e = this.matchOptionalLatexArgument();
|
30309 | null !== e && (t.push(e), n = !1), this.skipSpace(), "<{>" === this.peek && (e = this.matchRequiredLatexArgument(), null !== e && (r.push(e), n = !1));
|
30310 | } while (!n); return t.length > 0 || r.length > 0 ? [i, ...r, ...t] : i; }
|
30311 | matchPrimary(e) { let i = null; const t = this.index, r = this.matchNumber(); r && (i = { num: r }), null === i && (i = this.matchMatchfixOperator()), null === i && (i = this.matchEnvironment()), null === i && (i = this.matchSymbol()); let n = null; do {
|
30312 | n = this.matchSupsub(i), i = null != n ? n : i;
|
30313 | } while (null !== n); let s = null; do {
|
30314 | s = this.matchPostfix(i), i = null != s ? s : i;
|
30315 | } while (null !== s); return this.decorate(i, t); }
|
30316 | matchBalancedExpression(e, i, t) { const r = this.balancedClone(e, i); if (!r)
|
30317 | return null == t || t({ code: "unbalanced-symbols", arg: o$1(e) + o$1(i) }), null; const n = r.matchExpression(); return r.atEnd || null == t || t({ code: "unbalanced-symbols", arg: o$1(e) + o$1(i) }), n; }
|
30318 | matchExpression(e = 0) { let i = null; const t = this.index; this.skipSpace(), i = this.matchPrimary(e), null === i && (i = this.matchOperator("prefix")); let r = !1; for (; !this.atEnd && !r;) {
|
30319 | this.skipSpace();
|
30320 | let t = this.matchOperator("infix", i, e);
|
30321 | if (null === t && null !== i) {
|
30322 | const [e] = this.peekDefinition("operator");
|
30323 | if (null === e) {
|
30324 | const e = this.matchExpression(this.invisibleOperatorPrecedence);
|
30325 | null !== e && (t = this.applyInvisibleOperator(i, e));
|
30326 | }
|
30327 | }
|
30328 | null !== t ? i = t : r = !0;
|
30329 | } return this.decorate(i, t); }
|
30330 | decorate(e, i) { if (null === e)
|
30331 | return null; if (this.options.preserveLatex) {
|
30332 | const t = this.latex(i, this.index);
|
30333 | Array.isArray(e) ? e = { latex: t, fn: e } : "number" == typeof e ? e = { latex: t, num: Number(e).toString() } : "string" == typeof e ? e = { latex: t, sym: e } : "object" == typeof e && null !== e && (e.latex = t);
|
30334 | } return e; }
|
30335 | }
|
30336 | function te$1(e, i) { const t = e.length, r = e; e = e.slice(0, -1); for (let t = 0; t < e.length - 16; t++) {
|
30337 | const r = e.substr(0, t);
|
30338 | for (let n = 0; n < 17; n++) {
|
30339 | const s = e.substr(t, n + 1), a = Math.floor((e.length - r.length) / s.length);
|
30340 | if (a > 1 && (r + s.repeat(a + 1)).startsWith(e))
|
30341 | return "0" === s ? r.replace(/(\d{3})/g, "$1" + i.groupSeparator) : r.replace(/(\d{3})/g, "$1" + i.groupSeparator) + i.beginRepeatingDigits + s + i.endRepeatingDigits;
|
30342 | }
|
30343 | } const n = t > i.precision - 1; return e = r, n && (e = e.substr(0, i.precision - 1)), i.groupSeparator && (e = e.replace(/(\d{3})/g, "$1" + i.groupSeparator)).endsWith(i.groupSeparator) && (e = e.slice(0, -i.groupSeparator.length)), n ? e + i.truncationMarker : e; }
|
30344 | function re$1(e, i) { var t; return e ? i.beginExponentMarker ? i.beginExponentMarker + e + (null !== (t = i.endExponentMarker) && void 0 !== t ? t : "") : "10^{" + e + "}" : ""; }
|
30345 | class ne$1 {
|
30346 | constructor(e, i, t) { this.level = -1, this.options = e, e.invisibleMultiply && (/#1/.test(e.invisibleMultiply) && /#2/.test(e.invisibleMultiply) || t({ code: "expected-argument", arg: "invisibleMultiply" })), this.onError = t, this.dictionary = i; }
|
30347 | wrap(e, i) { if (null === e)
|
30348 | return ""; if (void 0 === i)
|
30349 | return "(" + this.serialize(e) + ")"; if ("number" == typeof e || y$1(e) || "string" == typeof e || b$1(e))
|
30350 | return this.serialize(e); const t = A$1(e); if (t && "Parentheses" !== t) {
|
30351 | const r = this.dictionary.name.get(t);
|
30352 | if (r && void 0 !== r.precedence && r.precedence < i)
|
30353 | return this.wrapString(this.serialize(e), (this.level, "paren"));
|
30354 | } return this.serialize(e); }
|
30355 | wrapShort(e) { if (null === e)
|
30356 | return ""; const i = this.serialize(e); return "Parentheses" === A$1(e) || "number" == typeof e || y$1(e) || /(^(.|\\[a-zA-Z*]+))$/.test(i) ? i : this.wrapString(i, (this.level, "paren")); }
|
30357 | wrapString(e, i) { return "none" === i ? e : "(" + e + ")"; }
|
30358 | serializeSymbol(e, i) { const t = M(e); if (!t) {
|
30359 | if ("string" == typeof (null == i ? void 0 : i.serialize))
|
30360 | return i.serialize;
|
30361 | const t = z$1(e);
|
30362 | if (null === t)
|
30363 | return "";
|
30364 | switch (function (e, i) { const t = z$1(e); return null === t ? "asis" : t.length > 1 ? "upright" : "asis"; }(e, this.level)) {
|
30365 | case "upright": return "\\operatorname{" + t + "}";
|
30366 | default: return t;
|
30367 | }
|
30368 | } const r = k$1(e); if (!i) {
|
30369 | if ("string" == typeof t && t.length > 0 && "\\" === t[0]) {
|
30370 | let e = t;
|
30371 | for (const i of r)
|
30372 | e += "{" + this.serialize(i) + "}";
|
30373 | return e;
|
30374 | }
|
30375 | return `${this.serialize(t)}(${r.map((e => this.serialize(e))).join(", ")})`;
|
30376 | } if (i.requiredLatexArg > 0) {
|
30377 | let e = "", t = "", n = 0;
|
30378 | for (; n < i.requiredLatexArg;)
|
30379 | t += "{" + this.serialize(r[n++]) + "}";
|
30380 | for (; n < Math.min(r.length, i.optionalLatexArg + i.requiredLatexArg);) {
|
30381 | const i = this.serialize(r[1 + n++]);
|
30382 | i && (e += "[" + i + "]");
|
30383 | }
|
30384 | return i.serialize + (e + t);
|
30385 | } return this.level, i.serialize + this.serialize(["Parentheses", ...r]); }
|
30386 | serializeDictionary(e) { return `\\left[\\begin{array}{lll}${Object.keys(e).map((i => `\\textbf{${i}} & \\rightarrow & ${this.serialize(e[i])}`)).join("\\\\")}\\end{array}\\right]`; }
|
30387 | serialize(e) { if (null === e)
|
30388 | return ""; this.level += 1; const i = (() => { var i, t, r, n; const s = function (e, i) { var t, r; let n; if ("number" == typeof e)
|
30389 | n = e;
|
30390 | else {
|
30391 | if (!y$1(e))
|
30392 | return "";
|
30393 | n = e.num;
|
30394 | } if (n === 1 / 0 || "Infinity" === n || "+Infinity" === n)
|
30395 | return i.positiveInfinity; if (n === -1 / 0 || "-Infinity" === n)
|
30396 | return i.negativeInfinity; if ("NaN" === n || "number" == typeof n && Number.isNaN(n))
|
30397 | return i.notANumber; if ("number" == typeof n)
|
30398 | return "engineering" === i.notation ? function (e, i) { if (0 === e)
|
30399 | return "0"; const t = Math.abs(e); let r = Math.round(Math.log10(t)); r -= r % 3, t < 1e3 && (r = 0); const n = t / Math.pow(10, r); let s = ""; const a = n.toString().match(/^(.*)\.(.*)$/); (null == a ? void 0 : a[1]) && a[2] && (s = a[1] + i.decimalMarker + a[2]), i.groupSeparator && (s = te$1(n.toExponential(), i)); let o = ""; return 0 !== r && (o = re$1(r.toString(), i)), (e < 0 ? "-" : "") + s + o; }(n, i) : function (e, i) { let t, r = e.match(/^(.*)[e|E]([-+]?[0-9]+)$/i); (null == r ? void 0 : r[1]) && r[2] && (t = re$1(r[2], i), t && (t = i.exponentProduct + t)); let n = e, s = ""; return r = (t ? r[1] : e).match(/^(.*)\.(.*)$/), (null == r ? void 0 : r[1]) && r[2] && (n = r[1], s = r[2]), i.groupSeparator && (n = n.replace(/\B(?=(\d{3})+(?!\d))/g, i.groupSeparator), s = te$1(s, i)), s && (s = i.decimalMarker + s), n + s + (null != t ? t : ""); }(n.toString(), i); /[a-zA-Z]$/.test(n) && (n = n.slice(0, -1)); let s = ""; for ("-" === n[0] ? (s = "-", n = n.substr(1)) : "+" === n[0] && (n = n.substr(1)); "0" === n[0];)
|
30400 | n = n.substr(1); if (0 === n.length)
|
30401 | return s + "0"; "." === n[0] && (n = "0" + n); let a = ""; if (n.indexOf(".") >= 0) {
|
30402 | const e = n.match(/(\d*)\.(\d*)([e|E]([-+]?[0-9]*))?/);
|
30403 | if (!e)
|
30404 | return "";
|
30405 | const r = e[1], o = e[2];
|
30406 | if (a = null !== (t = e[4]) && void 0 !== t ? t : "", "0" === r) {
|
30407 | let e = 0;
|
30408 | for (; "0" === o[e] && e < o.length;)
|
30409 | e += 1;
|
30410 | let t = "";
|
30411 | if (e <= 4)
|
30412 | t = "0" + i.decimalMarker, t += o.substr(0, e), t += te$1(n.substr(t.length), i);
|
30413 | else if (e + 1 >= i.precision)
|
30414 | t = "0", s = "";
|
30415 | else {
|
30416 | t = n[e];
|
30417 | const r = te$1(n.substr(e + 1), i);
|
30418 | r && (t += i.decimalMarker + r);
|
30419 | }
|
30420 | "0" !== t && (!(n.length - 1 > i.precision) || i.endRepeatingDigits && t.endsWith(i.endRepeatingDigits) || !i.truncationMarker || t.endsWith(i.truncationMarker) || (t += i.truncationMarker), e > 4 && (t += i.exponentProduct + re$1((1 - e).toString(), i))), n = t;
|
30421 | }
|
30422 | else {
|
30423 | n = r.replace(/\B(?=(\d{3})+(?!\d))/g, i.groupSeparator);
|
30424 | const e = te$1(o, i);
|
30425 | e && (n += i.decimalMarker + e);
|
30426 | }
|
30427 | }
|
30428 | else if (n.length > i.precision) {
|
30429 | const e = n.length;
|
30430 | let t = n[0];
|
30431 | const r = te$1(n.substr(1), i);
|
30432 | r && (t += i.decimalMarker + r, i.truncationMarker && !t.endsWith(i.truncationMarker) && i.endRepeatingDigits && !t.endsWith(i.endRepeatingDigits) && (t += i.truncationMarker)), "1" !== t ? t += i.exponentProduct : t = "", n = t + re$1((e - 1).toString(), i);
|
30433 | }
|
30434 | else {
|
30435 | const e = n.match(/([0-9]*)\.?([0-9]*)([e|E]([-+]?[0-9]+))?/);
|
30436 | e && (n = e[1], e[2] && (n += i.decimalMarker + e[2]), a = null !== (r = e[4]) && void 0 !== r ? r : ""), n = n.replace(/\B(?=(\d{3})+(?!\d))/g, i.groupSeparator);
|
30437 | } const o = re$1(a, i); return s + n + (o ? i.exponentProduct + o : ""); }(e, this.options); if (s)
|
30438 | return s; const l = q$1(e); if (null !== l)
|
30439 | return `\\text{${l}}`; const u = z$1(e); if (null !== u)
|
30440 | return this.serializeSymbol(e, this.dictionary.name.get(u)); const c = P$1(e); if (null !== c)
|
30441 | return this.serializeDictionary(c); const h = A$1(e); if (h) {
|
30442 | if ("\\" === h[0]) {
|
30443 | const i = k$1(e);
|
30444 | return 0 === i.length ? h : h + "{" + i.map((e => this.serialize(e))).filter((e => Boolean(e))).join("}{") + "}";
|
30445 | }
|
30446 | const s = this.dictionary.name.get(h);
|
30447 | if (s) {
|
30448 | let l = "";
|
30449 | return "function" == typeof s.serialize && (l = s.serialize(this, e)), l || void 0 === s.precedence && !(null === (i = s.trigger) || void 0 === i ? void 0 : i.superfix) && !(null === (t = s.trigger) || void 0 === t ? void 0 : t.subfix) || (l = function (e, i, t) { var r, n, s, a, o; let l = ""; const u = L$1(i), c = A$1(i); if ((null === (r = t.trigger) || void 0 === r ? void 0 : r.superfix) || (null === (n = t.trigger) || void 0 === n ? void 0 : n.subfix))
|
30450 | return 1 !== u && e.onError({ code: "operator-requires-one-operand", arg: e.serializeSymbol(c) }), ee(t.serialize, [e.serialize(O$1(i, 1))]); if (null === (s = t.trigger) || void 0 === s ? void 0 : s.postfix)
|
30451 | return 1 !== u && e.onError({ code: "postfix-operator-requires-one-operand", arg: e.serializeSymbol(c) }), ee(t.serialize, [e.wrap(O$1(i, 1), t.precedence)]); if (null === (a = t.trigger) || void 0 === a ? void 0 : a.prefix)
|
30452 | return 1 !== u && e.onError({ code: "prefix-operator-requires-one-operand", arg: e.serializeSymbol(c) }), ee(t.serialize, [e.wrap(O$1(i, 1), t.precedence + 1)]); if (null === (o = t.trigger) || void 0 === o ? void 0 : o.infix) {
|
30453 | l = e.wrap(O$1(i, 1), t.precedence);
|
30454 | for (let r = 2; r < u + 1; r++) {
|
30455 | const n = O$1(i, r);
|
30456 | null !== n && (l = ee(t.serialize, [l, e.wrap(n, t.precedence)]));
|
30457 | }
|
30458 | } return l; }(this, e, s)), !l && (null === (r = s.trigger) || void 0 === r ? void 0 : r.matchfix) && (l = function (e, i, t) { var r, n; let s = []; if ("string" == typeof (null === (r = t.trigger) || void 0 === r ? void 0 : r.matchfix) ? s.push(null === (n = t.trigger) || void 0 === n ? void 0 : n.matchfix) : t.trigger && Array.isArray(t.trigger.matchfix) && (s = [...t.trigger.matchfix]), L$1(i) >= 1) {
|
30459 | let r = "";
|
30460 | for (const n of k$1(i))
|
30461 | n && (s.push(r), s.push(e.serialize(n)), r = t.separator);
|
30462 | } return s.push(o$1(t.closeFence)), a$1(s); }(this, e, s)), !l && (null === (n = s.trigger) || void 0 === n ? void 0 : n.symbol) && (l = this.serializeSymbol(e, s)), l;
|
30463 | }
|
30464 | } if (Array.isArray(e) || w$1(e))
|
30465 | return this.serializeSymbol(e); this.onError({ code: "syntax-error", arg: JSON.stringify(e) }); })(); return this.level -= 1, null != i ? i : ""; }
|
30466 | }
|
30467 | class se$1 {
|
30468 | constructor(e) { var i, t; this.onError = null !== (i = null == e ? void 0 : e.onError) && void 0 !== i ? i : e => { "undefined" != typeof window && (!e.before || e.after); }; const r = { ...null != e ? e : {} }; delete r.dictionary, delete r.onError, this.options = { ...J$1, ...X$1, ...K, ...r }, this.dictionary = function (e, i) { var t, r, n, s, a, o, l, u, c, h, g, p, f, m, d; const v = { lookahead: 1, name: new Map, prefix: [], infix: [], postfix: [], matchfix: [], superfix: [], subfix: [], symbol: [], environment: new Map }; for (const x of e)
|
30469 | void 0 === x.parse && (x.parse = x.name), "string" == typeof x.trigger && (x.trigger = { symbol: x.trigger }), "string" == typeof x.serialize && void 0 !== (null === (t = x.trigger) || void 0 === t ? void 0 : t.symbol) && /#[0-9]/.test(x.serialize) && i({ code: "unexpected-argument", arg: x.name }), void 0 === x.serialize && (void 0 !== (null === (r = x.trigger) || void 0 === r ? void 0 : r.postfix) ? x.serialize = "#1" + Q$1(x.trigger.postfix) : void 0 !== (null === (n = x.trigger) || void 0 === n ? void 0 : n.prefix) ? x.serialize = Q$1(x.trigger.prefix) + "#1" : void 0 !== (null === (s = x.trigger) || void 0 === s ? void 0 : s.infix) ? x.serialize = "#1" + Q$1(x.trigger.infix) + "#2" : void 0 !== (null === (a = x.trigger) || void 0 === a ? void 0 : a.symbol) ? x.serialize = Q$1(x.trigger.symbol) : void 0 !== (null === (o = x.trigger) || void 0 === o ? void 0 : o.superfix) ? x.serialize = "#1^{" + Q$1(null === (l = x.trigger) || void 0 === l ? void 0 : l.superfix) + "}" : void 0 !== (null === (u = x.trigger) || void 0 === u ? void 0 : u.subfix) ? x.serialize = "#1_{" + Q$1(null === (c = x.trigger) || void 0 === c ? void 0 : c.subfix) + "}" : x.serialize = ""), void 0 !== (null === (h = x.trigger) || void 0 === h ? void 0 : h.infix) && (void 0 === x.precedence && i({ code: "syntax-error", arg: "Infix operators require a precedence" }), x.associativity || (x.associativity = "non")), void 0 !== (null === (g = x.trigger) || void 0 === g ? void 0 : g.symbol) && (x.arguments = null !== (p = x.arguments) && void 0 !== p ? p : "", x.optionalLatexArg = null !== (f = x.optionalLatexArg) && void 0 !== f ? f : 0, x.requiredLatexArg = null !== (m = x.requiredLatexArg) && void 0 !== m ? m : 0), void 0 !== (null === (d = x.trigger) || void 0 === d ? void 0 : d.matchfix) && ("function" === x.parse || x.closeFence || i({ code: "syntax-error", arg: "Matchfix operators require a close fence or a custom parse function" })), void 0 !== x.trigger && (["infix", "prefix", "postfix", "symbol", "matchfix", "superfix", "subfix"].forEach((e => { if (x.trigger[e]) {
|
30470 | const t = (i = x.trigger[e], Array.isArray(i) ? i.length : 1);
|
30471 | v.lookahead = Math.max(v.lookahead, t), void 0 === v[e][t] && (v[e][t] = new Map), v[e][t].set(Q$1(x.trigger[e]), x);
|
30472 | } var i; })), void 0 !== x.trigger.environment && v.environment.set(x.trigger.environment, x)), void 0 !== x.name ? v.name.set(Q$1(x.name), x) : "string" == typeof x.parse && v.name.set(x.parse, x), void 0 !== x.trigger || x.name || i({ code: "syntax-error", arg: "Need at least a trigger or a name" }); return v; }(null !== (t = null == e ? void 0 : e.dictionary) && void 0 !== t ? t : se$1.getDictionary(), this.onError); }
|
30473 | static getDictionary(e = "all") { if ("all" === e) {
|
30474 | let e = [];
|
30475 | for (const i of Object.keys(Y$1))
|
30476 | e = [...e, ...Y$1[i]];
|
30477 | return e;
|
30478 | } return Y$1[e] ? [...Y$1[e]] : []; }
|
30479 | parse(e) { var i; const t = new ie$1(s$1(e, []), this.options, this.dictionary, this.onError), r = t.matchExpression(); return t.atEnd || null === (i = this.onError) || void 0 === i || i.call(this, { code: "syntax-error" }), null != r ? r : ""; }
|
30480 | serialize(e) { return new ne$1(this.options, this.dictionary, this.onError).serialize(e); }
|
30481 | }
|
30482 | function ae$1(e, i) { return new se$1(i).parse(e); }
|
30483 | function oe$1(e, i) { return new se$1(i).serialize(e); }
|
30484 |
|
30485 | class ModelPrivate {
|
30486 | constructor(options, listeners, hooks, target) {
|
30487 | this.options = options;
|
30488 | this.root = new Atom('root', { mode: this.options.mode });
|
30489 | this.root.body = [];
|
30490 | this._selection = { ranges: [[0, 0]], direction: 'none' };
|
30491 | this._anchor = 0;
|
30492 | this._position = 0;
|
30493 | this.setListeners(listeners);
|
30494 | this.setHooks(hooks);
|
30495 | this.mathfield = target;
|
30496 | this.suppressChangeNotifications = false;
|
30497 | }
|
30498 | get atoms() {
|
30499 | return this.root.children;
|
30500 | }
|
30501 | /**
|
30502 | * The selection, accounting for the common ancestors
|
30503 | */
|
30504 | get selection() {
|
30505 | return this._selection;
|
30506 | }
|
30507 | set selection(value) {
|
30508 | this.setSelection(value);
|
30509 | }
|
30510 | setSelection(arg1, arg2) {
|
30511 | return this.deferNotifications({ selection: true }, () => {
|
30512 | //
|
30513 | // 1/ Normalize the input
|
30514 | // (account for offset < 0, etc...)
|
30515 | //
|
30516 | const value = this.normalizeSelection(arg1, arg2);
|
30517 | if (value === undefined) {
|
30518 | throw new TypeError('Invalid selection');
|
30519 | }
|
30520 | //
|
30521 | // 2/ Short-circuit a common case...
|
30522 | //
|
30523 | if (value.ranges.length === 1 &&
|
30524 | value.ranges[0][0] === value.ranges[0][1]) {
|
30525 | const pos = value.ranges[0][0];
|
30526 | console.assert(pos >= 0 && pos <= this.lastOffset);
|
30527 | this._position = pos;
|
30528 | this._anchor = pos;
|
30529 | this._selection = value;
|
30530 | }
|
30531 | else {
|
30532 | //
|
30533 | // 2b/ Determine the anchor and position
|
30534 | // (smallest, largest offsets, oriented as per `direction`)
|
30535 | //
|
30536 | const selRange = range(value);
|
30537 | if (value.direction === 'backward') {
|
30538 | [this._position, this._anchor] = selRange;
|
30539 | }
|
30540 | else {
|
30541 | [this._anchor, this._position] = selRange;
|
30542 | }
|
30543 | const first = this.at(selRange[0]);
|
30544 | const last = this.at(selRange[1]);
|
30545 | const commonAncestor = Atom.commonAncestor(first, last);
|
30546 | if ((commonAncestor === null || commonAncestor === void 0 ? void 0 : commonAncestor.type) === 'array' &&
|
30547 | first.parent === commonAncestor &&
|
30548 | last.parent === commonAncestor) ;
|
30549 | else {
|
30550 | this._selection = {
|
30551 | ranges: [[this.offsetOf(first), this.offsetOf(last)]],
|
30552 | direction: value.direction,
|
30553 | };
|
30554 | // 3b.3/ Adjust the position to match the selection
|
30555 | if (value.direction === 'backward') {
|
30556 | this._position = this._selection.ranges[0][0];
|
30557 | }
|
30558 | else {
|
30559 | this._position = this._selection.ranges[0][1];
|
30560 | }
|
30561 | console.assert(this._position >= 0 && this._position <= this.lastOffset);
|
30562 | }
|
30563 | }
|
30564 | });
|
30565 | }
|
30566 | /**
|
30567 | * The "focus" or "cursor" (i.e. not the anchor) a.k.a the insertion point
|
30568 | * or caret: where things are going to be inserted next.
|
30569 | *
|
30570 | */
|
30571 | get position() {
|
30572 | return this._position;
|
30573 | }
|
30574 | set position(value) {
|
30575 | this.setSelection(value, value);
|
30576 | }
|
30577 | /**
|
30578 | * The offset from which the selection is extended
|
30579 | */
|
30580 | get anchor() {
|
30581 | return this._anchor;
|
30582 | }
|
30583 | get selectionIsCollapsed() {
|
30584 | return this._anchor === this._position;
|
30585 | }
|
30586 | get selectionIsPlaceholder() {
|
30587 | if (Math.abs(this._anchor - this._position) === 1) {
|
30588 | return (this.at(Math.max(this._anchor, this._position)).type === 'placeholder');
|
30589 | }
|
30590 | return false;
|
30591 | }
|
30592 | collapseSelection(direction = 'forward') {
|
30593 | if (this._anchor === this._position)
|
30594 | return false;
|
30595 | if (direction === 'backward') {
|
30596 | this.position = Math.min(this._anchor, this._position);
|
30597 | }
|
30598 | else {
|
30599 | this.position = Math.max(this._anchor, this._position);
|
30600 | }
|
30601 | return true;
|
30602 | }
|
30603 | get lastOffset() {
|
30604 | return this.atoms.length - 1;
|
30605 | }
|
30606 | at(index) {
|
30607 | return this.atoms[index];
|
30608 | }
|
30609 | offsetOf(atom) {
|
30610 | return this.atoms.indexOf(atom);
|
30611 | }
|
30612 | getSiblingsRange(offset) {
|
30613 | const atom = this.at(offset);
|
30614 | const { parent } = atom;
|
30615 | if (!parent)
|
30616 | return [0, this.lastOffset];
|
30617 | const branch = atom.parent.branch(atom.treeBranch);
|
30618 | return [this.offsetOf(branch[0]), this.offsetOf(branch[branch.length - 1])];
|
30619 | }
|
30620 | getBranchRange(offset, branchName) {
|
30621 | const branch = this.at(offset).branch(branchName);
|
30622 | return [this.offsetOf(branch[0]), this.offsetOf(branch[branch.length - 1])];
|
30623 | }
|
30624 | getAtoms(arg1, arg2, arg3) {
|
30625 | var _a, _b;
|
30626 | let options = arg3 !== null && arg3 !== void 0 ? arg3 : {};
|
30627 | if (isSelection(arg1)) {
|
30628 | options = (_a = arg2) !== null && _a !== void 0 ? _a : {};
|
30629 | if (arg1.ranges.length > 1) {
|
30630 | return arg1.ranges.reduce((acc, range) => [...acc, ...this.getAtoms(range, options)], []);
|
30631 | }
|
30632 | arg1 = arg1.ranges[0];
|
30633 | }
|
30634 | let start;
|
30635 | let end;
|
30636 | if (isOffset(arg1)) {
|
30637 | start = arg1;
|
30638 | if (!isOffset(arg2))
|
30639 | return [];
|
30640 | end = arg2;
|
30641 | }
|
30642 | else {
|
30643 | [start, end] = arg1;
|
30644 | options = (_b = arg2) !== null && _b !== void 0 ? _b : {};
|
30645 | }
|
30646 | if (!Number.isFinite(start))
|
30647 | return [];
|
30648 | if (options.includeChildren === undefined) {
|
30649 | options.includeChildren = false;
|
30650 | }
|
30651 | if (start < 0)
|
30652 | start = this.lastOffset - start + 1;
|
30653 | if (end < 0)
|
30654 | end = this.lastOffset - end + 1;
|
30655 | const first = Math.min(start, end) + 1;
|
30656 | const last = Math.max(start, end);
|
30657 | if (first === 1 && last === this.lastOffset) {
|
30658 | // This is the entire selection,
|
30659 | // return the root
|
30660 | return [this.root];
|
30661 | }
|
30662 | let result = [];
|
30663 | for (let i = first; i <= last; i++) {
|
30664 | const atom = this.atoms[i];
|
30665 | if (atomIsInRange(this, atom, first, last)) {
|
30666 | result.push(atom);
|
30667 | }
|
30668 | }
|
30669 | if (!options.includeChildren) {
|
30670 | // Remove any atoms whose ancestor is also included
|
30671 | result = result.filter((atom) => {
|
30672 | let ancestorIncluded = false;
|
30673 | let { parent } = atom;
|
30674 | while (parent && !ancestorIncluded) {
|
30675 | ancestorIncluded = atomIsInRange(this, parent, first, last);
|
30676 | parent = parent.parent;
|
30677 | }
|
30678 | return !ancestorIncluded;
|
30679 | });
|
30680 | }
|
30681 | return result;
|
30682 | }
|
30683 | /**
|
30684 | * Unlike `getAtoms()`, the argument here is an index
|
30685 | * Return all the atoms, in order, starting at startingIndex
|
30686 | * then looping back at the beginning
|
30687 | */
|
30688 | getAllAtoms(startingIndex) {
|
30689 | const result = [];
|
30690 | const last = this.lastOffset;
|
30691 | for (let i = startingIndex; i <= last; i++) {
|
30692 | result.push(this.atoms[i]);
|
30693 | }
|
30694 | for (let i = 0; i < startingIndex; i++) {
|
30695 | result.push(this.atoms[i]);
|
30696 | }
|
30697 | return result;
|
30698 | }
|
30699 | extractAtoms(range) {
|
30700 | let result = this.getAtoms(range);
|
30701 | if (result.length === 1 && result[0].type === 'root') {
|
30702 | result = result[0].children;
|
30703 | }
|
30704 | for (const child of result)
|
30705 | child.parent.removeChild(child);
|
30706 | return result;
|
30707 | }
|
30708 | deleteAtoms(range) {
|
30709 | this.extractAtoms(range);
|
30710 | return range[0];
|
30711 | }
|
30712 | atomToString(atom, inFormat) {
|
30713 | const format = inFormat !== null && inFormat !== void 0 ? inFormat : 'latex';
|
30714 | let result = '';
|
30715 | if (format === 'latex' || format === 'latex-expanded') {
|
30716 | result = Atom.serialize(atom, {
|
30717 | expandMacro: format === 'latex-expanded',
|
30718 | defaultMode: this.mathfield.options.defaultMode,
|
30719 | });
|
30720 | }
|
30721 | else if (format === 'math-ml') {
|
30722 | result = atomsToMathML(atom, this.mathfield.options);
|
30723 | }
|
30724 | else if (format === 'spoken') {
|
30725 | result = atomToSpeakableText(atom, this.mathfield.options);
|
30726 | }
|
30727 | else if (format === 'spoken-text') {
|
30728 | const saveTextToSpeechMarkup = this.mathfield.options.textToSpeechMarkup;
|
30729 | this.mathfield.options.textToSpeechMarkup = '';
|
30730 | result = atomToSpeakableText(atom, this.mathfield.options);
|
30731 | this.mathfield.options.textToSpeechMarkup = saveTextToSpeechMarkup;
|
30732 | }
|
30733 | else if (format === 'spoken-ssml' ||
|
30734 | format === 'spoken-ssml-with-highlighting') {
|
30735 | const saveTextToSpeechMarkup = this.mathfield.options.textToSpeechMarkup;
|
30736 | // Const savedAtomIdsSettings = this.config.atomIdsSettings; // @revisit
|
30737 | this.mathfield.options.textToSpeechMarkup = 'ssml';
|
30738 | // If (format === 'spoken-ssml-with-highlighting') { // @revisit
|
30739 | // this.config.atomIdsSettings = { seed: 'random' };
|
30740 | // }
|
30741 | result = atomToSpeakableText(atom, this.mathfield.options);
|
30742 | this.mathfield.options.textToSpeechMarkup = saveTextToSpeechMarkup;
|
30743 | // This.config.atomIdsSettings = savedAtomIdsSettings; // @revisit
|
30744 | }
|
30745 | else if (format === 'math-json') {
|
30746 | try {
|
30747 | const json = ae$1(Atom.serialize(atom, { expandMacro: false, defaultMode: 'math' }), {
|
30748 | onError: this.mathfield.options.onError,
|
30749 | });
|
30750 | result = JSON.stringify(json);
|
30751 | }
|
30752 | catch (e) {
|
30753 | return '';
|
30754 | }
|
30755 | }
|
30756 | else if (format === 'ascii-math') {
|
30757 | result = atomToAsciiMath(atom);
|
30758 | }
|
30759 | else {
|
30760 | console.warn('Unknown format :', format);
|
30761 | }
|
30762 | return result;
|
30763 | }
|
30764 | // getValue(): string;
|
30765 | // getValue(format: OutputFormat): string;
|
30766 | // getValue(start: Offset, end: Offset, format?: OutputFormat): string;
|
30767 | // getValue(range: Range, format?: OutputFormat): string;
|
30768 | // getValue(selection: Selection, format?: OutputFormat): string;
|
30769 | getValue(arg1, arg2, arg3) {
|
30770 | if (arg1 === undefined) {
|
30771 | // GetValue()
|
30772 | return this.atomToString(this.root, 'latex');
|
30773 | }
|
30774 | if (typeof arg1 === 'string') {
|
30775 | // GetValue(format): Output format only
|
30776 | return this.atomToString(this.root, arg1);
|
30777 | }
|
30778 | let ranges;
|
30779 | let format;
|
30780 | if (isOffset(arg1) && isOffset(arg2)) {
|
30781 | ranges = [this.normalizeRange([arg1, arg2])];
|
30782 | format = arg3 !== null && arg3 !== void 0 ? arg3 : 'latex';
|
30783 | }
|
30784 | else if (isRange(arg1)) {
|
30785 | ranges = [this.normalizeRange(arg1)];
|
30786 | format = arg2;
|
30787 | }
|
30788 | else if (isSelection(arg1)) {
|
30789 | ranges = arg1.ranges;
|
30790 | format = arg2;
|
30791 | }
|
30792 | else {
|
30793 | ranges = [];
|
30794 | format = 'latex';
|
30795 | }
|
30796 | if (format === 'latex' || format === 'latex-expanded') {
|
30797 | const options = {
|
30798 | expandMacro: format === 'latex-expanded',
|
30799 | defaultMode: this.mathfield.options.defaultMode,
|
30800 | };
|
30801 | return joinLatex(ranges.map((range) => Atom.serialize(this.getAtoms(range), options)));
|
30802 | }
|
30803 | return ranges
|
30804 | .map((range) => this.getAtoms(range)
|
30805 | .map((atom) => this.atomToString(atom, format))
|
30806 | .join(''))
|
30807 | .join('');
|
30808 | }
|
30809 | /**
|
30810 | * Method called in response to a user interaction
|
30811 | */
|
30812 | extendSelection(direction) {
|
30813 | let anchor = this._anchor;
|
30814 | // Keep the anchor anchored, move the position forward or back
|
30815 | if (direction === 'forward') {
|
30816 | let pos = this._position;
|
30817 | do {
|
30818 | let atom = this.at(pos + 1);
|
30819 | if (atom === null || atom === void 0 ? void 0 : atom.inCaptureSelection) {
|
30820 | // When going forward, if in a capture selection, jump to
|
30821 | // after
|
30822 | while (!atom.captureSelection)
|
30823 | atom = atom.parent;
|
30824 | pos = this.offsetOf(atom === null || atom === void 0 ? void 0 : atom.parent.lastChild) + 1;
|
30825 | }
|
30826 | else {
|
30827 | pos += 1;
|
30828 | }
|
30829 | } while (pos <= this.lastOffset && this.at(pos).isFirstSibling);
|
30830 | if (pos === anchor - 1 && this.at(anchor).type === 'first') {
|
30831 | pos = anchor;
|
30832 | }
|
30833 | return this.extendSelectionTo(anchor, pos);
|
30834 | }
|
30835 | //
|
30836 | // Extending backward
|
30837 | //
|
30838 | let pos = this._position - 1;
|
30839 | if (pos < 0)
|
30840 | return false;
|
30841 | while (pos >= 0 && this.at(pos).isLastSibling) {
|
30842 | let atom = this.at(pos);
|
30843 | if (atom === null || atom === void 0 ? void 0 : atom.inCaptureSelection) {
|
30844 | // When going backward, if in a capture selection, jump to
|
30845 | // before
|
30846 | while (!atom.captureSelection)
|
30847 | atom = atom.parent;
|
30848 | pos = this.offsetOf(atom === null || atom === void 0 ? void 0 : atom.parent.firstChild) - 1;
|
30849 | }
|
30850 | else {
|
30851 | pos -= 1;
|
30852 | }
|
30853 | }
|
30854 | if (pos < 0)
|
30855 | pos = 0;
|
30856 | if (pos === anchor + 1 && this.at(pos).type === 'first') {
|
30857 | anchor = pos;
|
30858 | }
|
30859 | return this.extendSelectionTo(anchor, pos);
|
30860 | }
|
30861 | /**
|
30862 | * Unlike `setSelection`, this method is intended to be used in response
|
30863 | * to a user action, and it performs various adjustments to result
|
30864 | * in a more intuitive selection.
|
30865 | * For example:
|
30866 | * - when all the children of an atom are selected, the atom
|
30867 | * become selected.
|
30868 | * - this method will *not* change the anchor, but may result
|
30869 | * in a selection whose boundary is outside the anchor
|
30870 | */
|
30871 | extendSelectionTo(anchor, position) {
|
30872 | return this.deferNotifications({ selection: true }, () => {
|
30873 | const range = this.normalizeRange([anchor, position]);
|
30874 | let [start, end] = range;
|
30875 | // Include the parent if all the chidlren are selected
|
30876 | let { parent } = this.at(end);
|
30877 | while (parent !== this.root &&
|
30878 | childrenInRange(this, parent, [start, end])) {
|
30879 | end = this.offsetOf(parent);
|
30880 | parent = parent.parent;
|
30881 | }
|
30882 | parent = this.at(start).parent;
|
30883 | while (parent !== this.root &&
|
30884 | childrenInRange(this, parent, [start, end])) {
|
30885 | start = this.offsetOf(parent.leftSibling);
|
30886 | parent = parent.parent;
|
30887 | }
|
30888 | // Now that the start has potentially changed, check again
|
30889 | // if end needs to be updated
|
30890 | parent = this.at(end).parent;
|
30891 | while (parent !== this.root &&
|
30892 | childrenInRange(this, parent, [start, end])) {
|
30893 | end = this.offsetOf(parent);
|
30894 | console.assert(end >= 0);
|
30895 | parent = parent.parent;
|
30896 | }
|
30897 | this._position = this.normalizeOffset(position);
|
30898 | this._selection = {
|
30899 | ranges: [[start, end]],
|
30900 | direction: 'none',
|
30901 | };
|
30902 | });
|
30903 | }
|
30904 | setListeners(listeners) {
|
30905 | this.listeners = listeners;
|
30906 | }
|
30907 | setHooks(hooks) {
|
30908 | this.hooks = {
|
30909 | announce: (hooks === null || hooks === void 0 ? void 0 : hooks.announce)
|
30910 | ? hooks.announce
|
30911 | : (_target, _command, _previousPosition, _atoms) => { },
|
30912 | moveOut: (hooks === null || hooks === void 0 ? void 0 : hooks.moveOut) ? hooks.moveOut : () => true,
|
30913 | tabOut: (hooks === null || hooks === void 0 ? void 0 : hooks.tabOut) ? hooks.tabOut : () => true,
|
30914 | };
|
30915 | }
|
30916 | /**
|
30917 | * This method is called to provide feedback when using a screen reader
|
30918 | * or other assistive device, for example when changing the selection or
|
30919 | * moving the insertion point.
|
30920 | *
|
30921 | * It can also be used with the 'plonk' command to provide an audible
|
30922 | * feedback when a command is not possible.
|
30923 | *
|
30924 | * This method should not be called from other methods of the model
|
30925 | * (such as `setSelection`) as these methods can also be called
|
30926 | * programmatically and a feedback in these case would be innapropriate,
|
30927 | * however they should be called from functions called as a result of a user
|
30928 | * action, such as the functions in `commands.ts`
|
30929 | */
|
30930 | announce(command, previousPosition, atoms = []) {
|
30931 | this.hooks.announce(this.mathfield, command, previousPosition, atoms);
|
30932 | }
|
30933 | // Suppress notification while scope is executed,
|
30934 | // then notify of content change, and selection change (if actual change)
|
30935 | deferNotifications(options, f) {
|
30936 | const oldSelection = this._selection;
|
30937 | const oldAnchor = this._anchor;
|
30938 | const oldPosition = this._position;
|
30939 | let selectionChanged = false;
|
30940 | const saved = this.suppressChangeNotifications;
|
30941 | this.suppressChangeNotifications = true;
|
30942 | const previousCounter = this.root.changeCounter;
|
30943 | f();
|
30944 | const contentChanged = this.root.changeCounter !== previousCounter;
|
30945 | if (oldAnchor !== this._anchor ||
|
30946 | oldPosition !== this._position ||
|
30947 | compareSelection(this._selection, oldSelection) === 'different') {
|
30948 | selectionChanged = true;
|
30949 | }
|
30950 | this.suppressChangeNotifications = saved;
|
30951 | if (!this.suppressChangeNotifications) {
|
30952 | // Notify of content change, if requested
|
30953 | if (options.content && contentChanged) {
|
30954 | contentDidChange(this);
|
30955 | }
|
30956 | // If the selection has effectively changed, notify
|
30957 | if (options.selection && selectionChanged) {
|
30958 | selectionDidChange(this);
|
30959 | }
|
30960 | }
|
30961 | return contentChanged || selectionChanged;
|
30962 | }
|
30963 | normalizeOffset(value) {
|
30964 | if (value > 0) {
|
30965 | value = Math.min(value, this.lastOffset);
|
30966 | }
|
30967 | else if (value < 0) {
|
30968 | value = this.lastOffset + value + 1;
|
30969 | }
|
30970 | return value;
|
30971 | }
|
30972 | /**
|
30973 | * Ensure that the range is valid and canonical, i.e.
|
30974 | * - start <= end
|
30975 | * - collapsed = start === end
|
30976 | * - start >= 0, end >=0
|
30977 | */
|
30978 | normalizeRange(range) {
|
30979 | // 1. Normalize the offsets
|
30980 | let [start, end] = range;
|
30981 | start = this.normalizeOffset(start);
|
30982 | end = this.normalizeOffset(end);
|
30983 | return start < end ? [start, end] : [end, start];
|
30984 | }
|
30985 | normalizeSelection(value, value2) {
|
30986 | var _a;
|
30987 | let result = undefined;
|
30988 | if (isOffset(value)) {
|
30989 | const offset = this.normalizeOffset(value);
|
30990 | if (isOffset(value2)) {
|
30991 | const offset2 = this.normalizeOffset(value2);
|
30992 | result =
|
30993 | offset <= offset2
|
30994 | ? { ranges: [[offset, offset2]], direction: 'none' }
|
30995 | : {
|
30996 | ranges: [[offset2, offset]],
|
30997 | direction: 'backward',
|
30998 | };
|
30999 | }
|
31000 | else {
|
31001 | result = { ranges: [[offset, offset]], direction: 'none' };
|
31002 | }
|
31003 | }
|
31004 | else if (isRange(value)) {
|
31005 | const start = this.normalizeOffset(value[0]);
|
31006 | const end = this.normalizeOffset(value[1]);
|
31007 | result =
|
31008 | start <= end
|
31009 | ? { ranges: [[start, end]], direction: 'none' }
|
31010 | : { ranges: [[end, start]], direction: 'backward' };
|
31011 | }
|
31012 | else if (isSelection(value)) {
|
31013 | result = {
|
31014 | ranges: value.ranges.map((x) => this.normalizeRange(x)),
|
31015 | direction: (_a = value.direction) !== null && _a !== void 0 ? _a : 'none',
|
31016 | };
|
31017 | }
|
31018 | console.assert(result !== undefined);
|
31019 | return result;
|
31020 | }
|
31021 | }
|
31022 | function atomIsInRange(model, atom, first, last) {
|
31023 | const offset = model.offsetOf(atom);
|
31024 | if (offset < first || offset > last) {
|
31025 | return false;
|
31026 | }
|
31027 | if (!atom.hasChildren)
|
31028 | return true;
|
31029 | const firstOffset = model.offsetOf(atom.firstChild);
|
31030 | if (firstOffset >= first && firstOffset <= last) {
|
31031 | const lastOffset = model.offsetOf(atom.lastChild);
|
31032 | if (lastOffset >= first && lastOffset <= last) {
|
31033 | return true;
|
31034 | }
|
31035 | }
|
31036 | return false;
|
31037 | }
|
31038 | function childrenInRange(model, atom, range) {
|
31039 | if (!(atom === null || atom === void 0 ? void 0 : atom.hasChildren))
|
31040 | return false;
|
31041 | const [start, end] = range;
|
31042 | const first = model.offsetOf(atom.firstChild);
|
31043 | const last = model.offsetOf(atom.lastChild);
|
31044 | if (first >= start && first <= end && last >= first && last <= end) {
|
31045 | return true;
|
31046 | }
|
31047 | return false;
|
31048 | }
|
31049 |
|
31050 | // Import { getEnvironmentDefinition } from '../core/definitions';
|
31051 | function addRowAfter(model) {
|
31052 | contentDidChange(model);
|
31053 | return true;
|
31054 | }
|
31055 | function addRowBefore(model) {
|
31056 | contentDidChange(model);
|
31057 | return true;
|
31058 | }
|
31059 | function addColumnAfter(model) {
|
31060 | contentDidChange(model);
|
31061 | return true;
|
31062 | }
|
31063 | function addColumnBefore(model) {
|
31064 | contentDidChange(model);
|
31065 | return true;
|
31066 | }
|
31067 | register({
|
31068 | addRowAfter,
|
31069 | addColumnAfter,
|
31070 | addRowBefore,
|
31071 | addColumnBefore,
|
31072 | }, { target: 'model', category: 'array-edit' });
|
31073 |
|
31074 | // Import {
|
31075 | // arrayFirstCellByRow,
|
31076 | // arrayColRow,
|
31077 | // arrayAdjustRow,
|
31078 | // arrayIndex,
|
31079 | // arrayJoinColumns,
|
31080 | // arrayRemoveRow,
|
31081 | // arrayColumnCellCount,
|
31082 | // arrayRemoveColumn,
|
31083 | // arrayJoinRows,
|
31084 | // } from './model-array';
|
31085 | // function deleteFirstSiblingInArray(model: ModelPrivate): boolean {
|
31086 | // const contentWasChanging = model.suppressChangeNotifications;
|
31087 | // model.suppressChangeNotifications = true;
|
31088 | // const array = model.parent.array;
|
31089 | // if (arrayFirstCellByRow(array) === model.relation) {
|
31090 | // // (1) First cell:
|
31091 | // // delete array, replace it with linearized content
|
31092 | // const atoms = arrayJoinRows(array);
|
31093 | // model.path.pop();
|
31094 | // model.siblings().splice(model.anchorOffset(), 1, ...atoms);
|
31095 | // model._iter = null;
|
31096 | // setSelectionOffset(model, model.anchorOffset() - 1, atoms.length);
|
31097 | // } else {
|
31098 | // const colRow = arrayColRow(array, model.relation);
|
31099 | // if (colRow.col === 0) {
|
31100 | // // (2) First (non-empty) column (but not first row):
|
31101 | // // Move to the end of the last cell of the previous row
|
31102 | // const dest = arrayAdjustRow(array, colRow, -1);
|
31103 | // dest.col = array[dest.row].length - 1;
|
31104 | // model.path[model.path.length - 1].relation = ('cell' +
|
31105 | // arrayIndex(array, dest)) as Relation;
|
31106 | // const destLength = array[dest.row][dest.col].length;
|
31107 | // // (2.1) Linearize it and merge it with last cell of previous row
|
31108 | // // (note that atoms could be empty if there are no non-empty
|
31109 | // // cells left in the row)
|
31110 | // const atoms = arrayJoinColumns(array[colRow.row]);
|
31111 | // array[dest.row][dest.col] = array[dest.row][dest.col].concat(atoms);
|
31112 | // setSelectionOffset(model, destLength - 1, atoms.length);
|
31113 | // // (2.2) Remove row
|
31114 | // arrayRemoveRow(array, colRow.row);
|
31115 | // } else {
|
31116 | // // (3) Non-first column
|
31117 | // // (3.1) If column is empty, remove it
|
31118 | // if (arrayColumnCellCount(array, colRow.col) === 0) {
|
31119 | // arrayRemoveColumn(array, colRow.col);
|
31120 | // colRow.col -= 1;
|
31121 | // model.path[model.path.length - 1].relation = ('cell' +
|
31122 | // arrayIndex(array, colRow)) as Relation;
|
31123 | // const destCell = array[colRow.row][colRow.col];
|
31124 | // setSelectionOffset(model, destCell.length - 1, 0);
|
31125 | // }
|
31126 | // // (3.2) merge cell with cell in previous column
|
31127 | // }
|
31128 | // }
|
31129 | // // Dispatch notifications
|
31130 | // model.suppressChangeNotifications = contentWasChanging;
|
31131 | // selectionDidChange(model);
|
31132 | // contentDidChange(model);
|
31133 | // return true;
|
31134 | // }
|
31135 | /**
|
31136 | * Handle special cases when deleting an atom as per the table below
|
31137 | * - deleting an empty numerator: demote fraction
|
31138 | * - forward-deleting a square root: demote it
|
31139 | * - delete last atom inside a square root: delete the square root
|
31140 | * - delete last atom in a subsup: delete the subsup
|
31141 | * - etc...
|
31142 | *
|
31143 | *
|
31144 | * @param branch: if deleting inside an atom, the branch being delete
|
31145 | * (always the first or last atom of the branch). If undefined, the atom
|
31146 | * itself is about to be deleted.
|
31147 | *
|
31148 | * @return true if handled
|
31149 | */
|
31150 | function onDelete(model, direction, atom, branch) {
|
31151 | var _a, _b, _c, _d, _e, _f;
|
31152 | const parent = atom.parent;
|
31153 | if (atom instanceof LeftRightAtom) {
|
31154 | //
|
31155 | // 'leftright': \left\right
|
31156 | //
|
31157 | const atStart = (!branch && direction === 'forward') ||
|
31158 | (branch === 'body' && direction === 'backward');
|
31159 | const pos = atStart
|
31160 | ? model.offsetOf(atom) - 1
|
31161 | : model.offsetOf(atom.lastChild);
|
31162 | if (!atStart && atom.leftDelim !== '?' && atom.leftDelim !== '.') {
|
31163 | // Insert open fence
|
31164 | parent.addChildBefore(new Atom('mopen', { value: atom.leftDelim }), atom);
|
31165 | }
|
31166 | else if (atStart && atom.rightDelim !== '?' && atom.rightDelim !== '.') {
|
31167 | // Insert closing fence
|
31168 | parent.addChildAfter(new Atom('mclose', { value: atom.rightDelim }), atom);
|
31169 | }
|
31170 | // Hoist body
|
31171 | parent.addChildrenAfter(atom.removeBranch('body'), atom);
|
31172 | parent.removeChild(atom);
|
31173 | model.position = pos;
|
31174 | return true;
|
31175 | }
|
31176 | if (atom.type === 'surd') {
|
31177 | //
|
31178 | // 'surd': square root
|
31179 | //
|
31180 | if ((direction === 'forward' && !branch) ||
|
31181 | (direction === 'backward' && branch === 'body')) {
|
31182 | // Before fwd or body 1st bwd: Demote body
|
31183 | const pos = atom.leftSibling;
|
31184 | if (atom.hasChildren) {
|
31185 | parent.addChildrenAfter(atom.removeBranch('body'), atom);
|
31186 | }
|
31187 | parent.removeChild(atom);
|
31188 | model.position = model.offsetOf(pos);
|
31189 | }
|
31190 | else if (direction === 'forward' && branch === 'body') {
|
31191 | // Body last fwd: move to after
|
31192 | model.position = model.offsetOf(atom);
|
31193 | }
|
31194 | else if (!branch && direction === 'backward') {
|
31195 | // After bwd: move to last of body
|
31196 | if (atom.hasChildren) {
|
31197 | model.position = model.offsetOf(atom.lastChild);
|
31198 | }
|
31199 | else {
|
31200 | model.position = Math.max(model.offsetOf(atom) - 1);
|
31201 | parent.removeChild(atom);
|
31202 | }
|
31203 | }
|
31204 | else if (branch === 'above') {
|
31205 | if (atom.hasEmptyBranch('above')) {
|
31206 | atom.removeBranch('above');
|
31207 | }
|
31208 | if (direction === 'backward') {
|
31209 | // Above 1st
|
31210 | model.position = model.offsetOf(atom.leftSibling);
|
31211 | }
|
31212 | else {
|
31213 | // Above last
|
31214 | model.position = model.offsetOf(atom.body[0]);
|
31215 | }
|
31216 | }
|
31217 | return true;
|
31218 | }
|
31219 | if (atom.type === 'box' || atom.type === 'enclose') {
|
31220 | //
|
31221 | // 'box': \boxed, \fbox 'enclose': \cancel
|
31222 | //
|
31223 | const pos = (branch && direction === 'backward') ||
|
31224 | (!branch && direction === 'forward')
|
31225 | ? atom.leftSibling
|
31226 | : atom.lastChild;
|
31227 | parent.addChildrenAfter(atom.removeBranch('body'), atom);
|
31228 | parent.removeChild(atom);
|
31229 | model.position = model.offsetOf(pos);
|
31230 | return true;
|
31231 | }
|
31232 | if (atom.type === 'genfrac' || atom.type === 'overunder') {
|
31233 | //
|
31234 | // 'genfrac': \frac, \choose, etc...
|
31235 | //
|
31236 | if (!branch) {
|
31237 | // After or before atom
|
31238 | if (!atom.hasChildren)
|
31239 | return false;
|
31240 | model.position = model.offsetOf(direction === 'forward' ? atom.firstChild : atom.lastChild);
|
31241 | return true;
|
31242 | }
|
31243 | if ((direction === 'forward' && branch === 'above') ||
|
31244 | (direction === 'backward' && branch === 'below')) {
|
31245 | // Above last or below first: hoist
|
31246 | const above = atom.removeBranch('above');
|
31247 | const below = atom.removeBranch('below');
|
31248 | parent.addChildrenAfter([...above, ...below], atom);
|
31249 | parent.removeChild(atom);
|
31250 | model.position = model.offsetOf(above.length > 0 ? above[above.length - 1] : below[0]);
|
31251 | return true;
|
31252 | }
|
31253 | if (direction === 'backward') {
|
31254 | // Above first: move to before
|
31255 | model.position = model.offsetOf(atom.leftSibling);
|
31256 | return true;
|
31257 | }
|
31258 | // Below last: move to after
|
31259 | model.position = model.offsetOf(atom);
|
31260 | return true;
|
31261 | }
|
31262 | if (atom.isExtensibleSymbol || atom.type === 'msubsup') {
|
31263 | //
|
31264 | // Extensible operator: \sum, \int, etc...
|
31265 | // Superscript/subscript carrier
|
31266 | //
|
31267 | if (!branch && direction === 'forward')
|
31268 | return false;
|
31269 | if (!branch) {
|
31270 | if (atom.subscript || atom.superscript) {
|
31271 | const pos = direction === 'forward'
|
31272 | ? (_b = (_a = atom.superscript) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : (_c = atom.subscript) === null || _c === void 0 ? void 0 : _c[0]
|
31273 | : (_e = (_d = atom.subscript) === null || _d === void 0 ? void 0 : _d[0].lastSibling) !== null && _e !== void 0 ? _e : (_f = atom.superscript) === null || _f === void 0 ? void 0 : _f[0].lastSibling;
|
31274 | if (pos)
|
31275 | model.position = model.offsetOf(pos);
|
31276 | return true;
|
31277 | }
|
31278 | return false;
|
31279 | }
|
31280 | if (branch && atom.hasEmptyBranch(branch)) {
|
31281 | atom.removeBranch(branch);
|
31282 | }
|
31283 | if (!atom.hasChildren) {
|
31284 | // We've removed the last branch of a msubsup
|
31285 | const pos = direction === 'forward'
|
31286 | ? model.offsetOf(atom)
|
31287 | : Math.max(0, model.offsetOf(atom) - 1);
|
31288 | atom.parent.removeChild(atom);
|
31289 | model.position = pos;
|
31290 | return true;
|
31291 | }
|
31292 | if (branch === 'superscript') {
|
31293 | if (direction === 'backward') {
|
31294 | const pos = model.offsetOf(atom.firstChild) - 1;
|
31295 | console.assert(pos >= 0);
|
31296 | model.position = pos;
|
31297 | }
|
31298 | else if (atom.subscript) {
|
31299 | model.position = model.offsetOf(atom.subscript[0]);
|
31300 | }
|
31301 | else {
|
31302 | model.position = model.offsetOf(atom);
|
31303 | }
|
31304 | }
|
31305 | else if (branch === 'subscript') {
|
31306 | if (direction === 'backward' && atom.superscript) {
|
31307 | // Subscript first: move to superscript end
|
31308 | model.position = model.offsetOf(atom.superscript[0].lastSibling);
|
31309 | }
|
31310 | else if (direction === 'backward') {
|
31311 | // Subscript first: move to before
|
31312 | model.position = model.offsetOf(atom.firstChild) - 1;
|
31313 | }
|
31314 | else {
|
31315 | // Subscript last: move after
|
31316 | model.position = model.offsetOf(atom);
|
31317 | }
|
31318 | }
|
31319 | return true;
|
31320 | }
|
31321 | return false;
|
31322 | }
|
31323 | /**
|
31324 | * Delete the item at the current position
|
31325 | */
|
31326 | function deleteBackward(model) {
|
31327 | if (!model.selectionIsCollapsed) {
|
31328 | return deleteRange(model, range(model.selection));
|
31329 | }
|
31330 | return model.deferNotifications({ content: true, selection: true }, () => {
|
31331 | let target = model.at(model.position);
|
31332 | if (target && onDelete(model, 'backward', target))
|
31333 | return;
|
31334 | if (target === null || target === void 0 ? void 0 : target.isFirstSibling) {
|
31335 | if (onDelete(model, 'backward', target.parent, target.treeBranch)) {
|
31336 | return;
|
31337 | }
|
31338 | target = null;
|
31339 | }
|
31340 | // At the first position: nothing to delete...
|
31341 | if (!target) {
|
31342 | model.announce('plonk');
|
31343 | return;
|
31344 | }
|
31345 | const offset = model.offsetOf(target.leftSibling);
|
31346 | target.parent.removeChild(target);
|
31347 | model.announce('delete', undefined, [target]);
|
31348 | model.position = offset;
|
31349 | });
|
31350 | }
|
31351 | /**
|
31352 | * Delete the item forward of the current position, update the position and
|
31353 | * send notifications
|
31354 | */
|
31355 | function deleteForward(model) {
|
31356 | if (!model.selectionIsCollapsed) {
|
31357 | return deleteRange(model, range(model.selection));
|
31358 | }
|
31359 | return model.deferNotifications({ content: true, selection: true }, () => {
|
31360 | var _a, _b;
|
31361 | let target = model.at(model.position).rightSibling;
|
31362 | if (target && onDelete(model, 'forward', target))
|
31363 | return;
|
31364 | if (!target) {
|
31365 | target = model.at(model.position);
|
31366 | if (target.isLastSibling &&
|
31367 | onDelete(model, 'forward', target.parent, target.treeBranch)) {
|
31368 | return;
|
31369 | }
|
31370 | target = null;
|
31371 | }
|
31372 | else if (model.at(model.position).isLastSibling &&
|
31373 | onDelete(model, 'forward', target.parent, target.treeBranch)) {
|
31374 | return;
|
31375 | }
|
31376 | if (model.position === model.lastOffset || !target) {
|
31377 | model.announce('plonk');
|
31378 | return;
|
31379 | }
|
31380 | target.parent.removeChild(target);
|
31381 | let sibling = (_a = model.at(model.position)) === null || _a === void 0 ? void 0 : _a.rightSibling;
|
31382 | while ((sibling === null || sibling === void 0 ? void 0 : sibling.type) === 'msubsup') {
|
31383 | sibling.parent.removeChild(sibling);
|
31384 | sibling = (_b = model.at(model.position)) === null || _b === void 0 ? void 0 : _b.rightSibling;
|
31385 | }
|
31386 | model.announce('delete', undefined, [target]);
|
31387 | });
|
31388 | }
|
31389 | /**
|
31390 | * Delete the specified range, as a result of a user action: this will
|
31391 | * account for special cases such as deleting empty denominator, and will
|
31392 | * provide appropriate feedback to screen readers.
|
31393 | *
|
31394 | * Use model.deleteAtoms() for operations that are not a result of
|
31395 | * user action.
|
31396 | */
|
31397 | function deleteRange(model, range) {
|
31398 | return model.deferNotifications({ content: true, selection: true }, () => {
|
31399 | model.deleteAtoms(range);
|
31400 | model.position = range[0];
|
31401 | });
|
31402 | }
|
31403 |
|
31404 | class CompositionAtom extends Atom {
|
31405 | constructor(value, options) {
|
31406 | var _a;
|
31407 | super('composition', { mode: (_a = options === null || options === void 0 ? void 0 : options.mode) !== null && _a !== void 0 ? _a : 'math', value });
|
31408 | }
|
31409 | get computedStyle() {
|
31410 | return {};
|
31411 | }
|
31412 | render(context) {
|
31413 | // In theory one would like to be able to draw the clauses
|
31414 | // in an active composition. Unfortunately, there are
|
31415 | // no API to give access to those clauses :(
|
31416 | const result = new Box(this.value, {
|
31417 | classes: 'ML__composition',
|
31418 | type: 'composition',
|
31419 | });
|
31420 | this.bind(context, result);
|
31421 | if (this.caret)
|
31422 | result.caret = this.caret;
|
31423 | return result;
|
31424 | }
|
31425 | serialize(_options) {
|
31426 | return '';
|
31427 | }
|
31428 | }
|
31429 |
|
31430 | /**
|
31431 | * Create, remove or update a composition atom at the current location
|
31432 | */
|
31433 | function updateComposition(model, s) {
|
31434 | const cursor = model.at(model.position);
|
31435 | // We're creating or updating a composition
|
31436 | if (cursor.type === 'composition') {
|
31437 | // Composition already in progress, update it
|
31438 | cursor.value = s;
|
31439 | }
|
31440 | else {
|
31441 | // No composition yet, create one
|
31442 | // Remove previous caret
|
31443 | const { caret } = cursor;
|
31444 | cursor.caret = '';
|
31445 | // Create 'composition' atom, with caret
|
31446 | const atom = new CompositionAtom(s, { mode: cursor.mode });
|
31447 | atom.caret = caret;
|
31448 | cursor.parent.addChildAfter(atom, cursor);
|
31449 | // Move cursor one past the composition zone
|
31450 | model.position += 1;
|
31451 | }
|
31452 | }
|
31453 | /**
|
31454 | * Remove the composition zone
|
31455 | */
|
31456 | function removeComposition(model) {
|
31457 | const cursor = model.at(model.position);
|
31458 | if (cursor.type === 'composition') {
|
31459 | cursor.parent.removeChild(cursor);
|
31460 | model.position -= 1;
|
31461 | }
|
31462 | }
|
31463 |
|
31464 | function getMode(model, offset) {
|
31465 | const atom = model.at(offset);
|
31466 | let result;
|
31467 | if (atom) {
|
31468 | result = atom.mode;
|
31469 | let ancestor = atom.parent;
|
31470 | while (!result && ancestor) {
|
31471 | if (ancestor)
|
31472 | result = ancestor.mode;
|
31473 | ancestor = ancestor.parent;
|
31474 | }
|
31475 | }
|
31476 | return result;
|
31477 | }
|
31478 |
|
31479 | function applyStyleToUnstyledAtoms(atom, style) {
|
31480 | if (!atom || !style)
|
31481 | return;
|
31482 | if (isArray(atom)) {
|
31483 | // Apply styling options to each atom
|
31484 | atom.forEach((x) => applyStyleToUnstyledAtoms(x, style));
|
31485 | }
|
31486 | else if (typeof atom === 'object') {
|
31487 | if (!atom.style.color &&
|
31488 | !atom.style.backgroundColor &&
|
31489 | !atom.style.fontFamily &&
|
31490 | !atom.style.fontShape &&
|
31491 | !atom.style.fontSeries &&
|
31492 | !atom.style.fontSize &&
|
31493 | !atom.style.variant &&
|
31494 | !atom.style.variantStyle) {
|
31495 | atom.applyStyle(style);
|
31496 | applyStyleToUnstyledAtoms(atom.body, style);
|
31497 | applyStyleToUnstyledAtoms(atom.above, style);
|
31498 | applyStyleToUnstyledAtoms(atom.below, style);
|
31499 | applyStyleToUnstyledAtoms(atom.subscript, style);
|
31500 | applyStyleToUnstyledAtoms(atom.superscript, style);
|
31501 | }
|
31502 | }
|
31503 | }
|
31504 | /**
|
31505 | * Apply a style (color, background) to the selection.
|
31506 | *
|
31507 | * If the style is already applied to the selection, remove it. If the selection
|
31508 | * has the style partially applied (i.e. only some sections), remove it from
|
31509 | * those sections, and apply it to the entire selection.
|
31510 | */
|
31511 | function applyStyle$1(model, range, style, options) {
|
31512 | function everyStyle(property, value) {
|
31513 | for (const atom of atoms) {
|
31514 | if (atom.style[property] !== value)
|
31515 | return false;
|
31516 | }
|
31517 | return true;
|
31518 | }
|
31519 | range = model.normalizeRange(range);
|
31520 | if (range[0] === range[1])
|
31521 | return false;
|
31522 | const atoms = model.getAtoms(range, { includeChildren: true });
|
31523 | if (options.operation === 'toggle') {
|
31524 | if (style.color && everyStyle('color', style.color)) {
|
31525 | // If the selection already has this color, turn it off
|
31526 | style.color = 'none';
|
31527 | style.verbatimColor = undefined;
|
31528 | }
|
31529 | if (style.backgroundColor &&
|
31530 | everyStyle('backgroundColor', style.backgroundColor)) {
|
31531 | // If the selection already has this color, turn it off
|
31532 | style.backgroundColor = 'none';
|
31533 | style.verbatimBackgroundColor = undefined;
|
31534 | }
|
31535 | if (style.fontFamily && everyStyle('fontFamily', style.fontFamily)) {
|
31536 | // If the selection already has this font family, turn it off
|
31537 | style.fontFamily = 'none';
|
31538 | }
|
31539 | // If (style.series) style.fontSeries = style.series;
|
31540 | if (style.fontSeries && everyStyle('fontSeries', style.fontSeries)) {
|
31541 | // If the selection already has this series (weight), turn it off
|
31542 | style.fontSeries = 'auto';
|
31543 | }
|
31544 | // If (style.shape) style.fontShape = style.shape;
|
31545 | if (style.fontShape && everyStyle('fontShape', style.fontShape)) {
|
31546 | // If the selection already has this shape (italic), turn it off
|
31547 | style.fontShape = 'auto';
|
31548 | }
|
31549 | // If (style.size) style.fontSize = style.size;
|
31550 | if (style.fontSize && everyStyle('fontSize', style.fontSize)) {
|
31551 | // If the selection already has this size, reset it to default size
|
31552 | style.fontSize = DEFAULT_FONT_SIZE;
|
31553 | }
|
31554 | }
|
31555 | for (const atom of atoms)
|
31556 | atom.applyStyle(style);
|
31557 | return true;
|
31558 | }
|
31559 |
|
31560 | /*
|
31561 | * Calculates the offset of the "next word".
|
31562 | * This is inspired by the behavior of text editors on macOS, namely:
|
31563 | blue yellow
|
31564 | ^-
|
31565 | ^-------
|
31566 | * That is:
|
31567 |
|
31568 | * (1) If starts with an alphanumerical character, find the first alphanumerical
|
31569 | * character which is followed by a non-alphanumerical character
|
31570 | *
|
31571 | * The behavior regarding non-alphanumeric characters is less consistent.
|
31572 | * Here's the behavior we use:
|
31573 | *
|
31574 | * +=-()_:” blue
|
31575 | * ^---------
|
31576 | * +=-()_:” blue
|
31577 | * ^---------
|
31578 | * +=-()_:”blue
|
31579 | * ^--------
|
31580 | *
|
31581 | * (2) If starts in whitespace, skip whitespace, then find first non-whitespace*
|
31582 | * followed by whitespace
|
31583 | * (*) Pages actually uses the character class of the first non-whitespace
|
31584 | * encountered.
|
31585 | *
|
31586 | * (3) If starts in a non-whitespace, non alphanumerical character, find the first
|
31587 | * whitespace
|
31588 | *
|
31589 | */
|
31590 | function wordBoundaryOffset(model, offset, direction) {
|
31591 | if (model.at(offset).mode !== 'text')
|
31592 | return offset;
|
31593 | const dir = direction === 'backward' ? -1 : +1;
|
31594 | let result;
|
31595 | if (LETTER_AND_DIGITS.test(model.at(offset).value)) {
|
31596 | // (1) We start with an alphanumerical character
|
31597 | let i = offset;
|
31598 | let match;
|
31599 | do {
|
31600 | match =
|
31601 | model.at(i).mode === 'text' &&
|
31602 | LETTER_AND_DIGITS.test(model.at(i).value);
|
31603 | i += dir;
|
31604 | } while (model.at(i) && match);
|
31605 | result = model.at(i) ? i - 2 * dir : i - dir;
|
31606 | }
|
31607 | else if (/\s/.test(model.at(offset).value)) {
|
31608 | // (2) We start with whitespace
|
31609 | // Skip whitespace
|
31610 | let i = offset;
|
31611 | while (model.at(i) &&
|
31612 | model.at(i).mode === 'text' &&
|
31613 | /\s/.test(model.at(i).value)) {
|
31614 | i += dir;
|
31615 | }
|
31616 | if (!model.at(i)) {
|
31617 | // We've reached the end
|
31618 | result = i - dir;
|
31619 | }
|
31620 | else {
|
31621 | let match = true;
|
31622 | do {
|
31623 | match = model.at(i).mode === 'text' && !/\s/.test(model.at(i).value);
|
31624 | i += dir;
|
31625 | } while (model.at(i) && match);
|
31626 | result = model.at(i) ? i - 2 * dir : i - dir;
|
31627 | }
|
31628 | }
|
31629 | else {
|
31630 | // (3)
|
31631 | let i = offset;
|
31632 | // Skip non-whitespace
|
31633 | while (model.at(i) &&
|
31634 | model.at(i).mode === 'text' &&
|
31635 | !/\s/.test(model.at(i).value)) {
|
31636 | i += dir;
|
31637 | }
|
31638 | result = model.at(i) ? i : i - dir;
|
31639 | let match = true;
|
31640 | while (model.at(i) && match) {
|
31641 | match = model.at(i).mode === 'text' && /\s/.test(model.at(i).value);
|
31642 | if (match)
|
31643 | result = i;
|
31644 | i += dir;
|
31645 | }
|
31646 | result = model.at(i) ? i - 2 * dir : i - dir;
|
31647 | }
|
31648 | return result - (dir > 0 ? 0 : 1);
|
31649 | }
|
31650 | /**
|
31651 | * Keyboard navigation with alt/option:
|
31652 | * Move the insertion point to the next/previous point of interest.
|
31653 | * A point of interest is an atom of a different type (mbin, mord, etc...)
|
31654 | * than the current focus.
|
31655 | * If `extend` is true, the selection will be extended. Otherwise, it is
|
31656 | * collapsed, then moved.
|
31657 | * @todo array
|
31658 | */
|
31659 | function skip(model, direction, options) {
|
31660 | var _a, _b, _c, _d, _e, _f, _g;
|
31661 | const previousPosition = model.position;
|
31662 | if (!((_a = options === null || options === void 0 ? void 0 : options.extend) !== null && _a !== void 0 ? _a : false)) {
|
31663 | model.collapseSelection(direction);
|
31664 | }
|
31665 | let atom = model.at(model.position);
|
31666 | if (direction === 'forward') {
|
31667 | if (atom.type === 'msubsup') {
|
31668 | atom = atom.rightSibling;
|
31669 | if (!atom) {
|
31670 | atom = model.at(model.position + 1);
|
31671 | }
|
31672 | }
|
31673 | else {
|
31674 | atom = model.at(model.position + 1);
|
31675 | }
|
31676 | }
|
31677 | if (!atom) {
|
31678 | model.announce('plonk');
|
31679 | return false;
|
31680 | }
|
31681 | let offset = model.offsetOf(atom);
|
31682 | if (atom instanceof TextAtom) {
|
31683 | //
|
31684 | // We're in a text zone, skip word by word
|
31685 | //
|
31686 | offset = wordBoundaryOffset(model, offset, direction);
|
31687 | }
|
31688 | else if (atom instanceof LatexAtom) {
|
31689 | //
|
31690 | // We're in a Latex mode zone, skip suggestion
|
31691 | //
|
31692 | if (atom.isSuggestion) {
|
31693 | // Since suggestions are always at the end, this must be forward
|
31694 | console.assert(direction === 'forward');
|
31695 | while (atom && atom instanceof LatexAtom) {
|
31696 | atom.isSuggestion = false;
|
31697 | offset = model.offsetOf(atom);
|
31698 | atom = atom.rightSibling;
|
31699 | }
|
31700 | }
|
31701 | else if (direction === 'forward') {
|
31702 | atom = atom.rightSibling;
|
31703 | if (!atom || !(atom instanceof LatexAtom)) {
|
31704 | // At the end of the command
|
31705 | model.announce('plonk');
|
31706 | return false;
|
31707 | }
|
31708 | while (atom &&
|
31709 | atom instanceof LatexAtom &&
|
31710 | /[a-zA-Z*]/.test(atom.value)) {
|
31711 | offset = model.offsetOf(atom);
|
31712 | atom = atom.rightSibling;
|
31713 | }
|
31714 | }
|
31715 | else {
|
31716 | atom = atom.leftSibling;
|
31717 | if (!atom || !(atom instanceof LatexAtom)) {
|
31718 | // At the start of the command
|
31719 | model.announce('plonk');
|
31720 | return false;
|
31721 | }
|
31722 | while (atom &&
|
31723 | atom instanceof LatexAtom &&
|
31724 | /[a-zA-Z*]/.test(atom.value)) {
|
31725 | offset = model.offsetOf(atom);
|
31726 | atom = atom.leftSibling;
|
31727 | }
|
31728 | }
|
31729 | }
|
31730 | else if (direction === 'forward' && atom.type === 'mopen') {
|
31731 | //
|
31732 | // Right before a 'mopen', skip to the corresponding balanced fence
|
31733 | //
|
31734 | let level = 0;
|
31735 | do {
|
31736 | if (atom.type === 'mopen') {
|
31737 | level += 1;
|
31738 | }
|
31739 | else if (atom.type === 'mclose') {
|
31740 | level -= 1;
|
31741 | }
|
31742 | atom = atom.rightSibling;
|
31743 | } while (!atom.isLastSibling && level !== 0);
|
31744 | offset = model.offsetOf(atom.leftSibling);
|
31745 | }
|
31746 | else if (direction === 'backward' && atom.type === 'mclose') {
|
31747 | //
|
31748 | // Right after a 'mclose', skip to the corresponding balanced fence
|
31749 | //
|
31750 | let level = 0;
|
31751 | do {
|
31752 | if (atom.type === 'mopen') {
|
31753 | level += 1;
|
31754 | }
|
31755 | else if (atom.type === 'mclose') {
|
31756 | level -= 1;
|
31757 | }
|
31758 | atom = atom.leftSibling;
|
31759 | } while (!atom.isFirstSibling && level !== 0);
|
31760 | offset = model.offsetOf(atom);
|
31761 | }
|
31762 | else if (direction === 'backward') {
|
31763 | //
|
31764 | // We're in a regular math zone (not before/after a fence)
|
31765 | //
|
31766 | if (atom.type === 'first') {
|
31767 | while (offset > 0 && atom.type === 'first') {
|
31768 | offset -= 1;
|
31769 | atom = model.at(offset);
|
31770 | }
|
31771 | }
|
31772 | else {
|
31773 | const type = atom.type;
|
31774 | if (atom.type === 'msubsup') {
|
31775 | // If we're after a 'msubsup', skip to its left sibling
|
31776 | // (the base of the super/subscript)
|
31777 | offset = model.offsetOf(model.at(offset).leftSibling);
|
31778 | }
|
31779 | offset -= 1;
|
31780 | let nextType = (_b = model.at(offset)) === null || _b === void 0 ? void 0 : _b.type;
|
31781 | // If (nextType === 'msubsup') {
|
31782 | // offset = model.offsetOf(model.at(offset).leftSibling);
|
31783 | // }
|
31784 | while (offset >= 0 && nextType === type) {
|
31785 | if (((_c = model.at(offset)) === null || _c === void 0 ? void 0 : _c.type) === 'msubsup') {
|
31786 | offset = model.offsetOf(model.at(offset).leftSibling);
|
31787 | }
|
31788 | else {
|
31789 | offset -= 1;
|
31790 | }
|
31791 | nextType = model.at(offset).type;
|
31792 | }
|
31793 | }
|
31794 | }
|
31795 | else {
|
31796 | const { type } = atom;
|
31797 | // If (atom.type === 'msubsup') {
|
31798 | // offset = model.offsetOf(model.at(offset).rightSibling);
|
31799 | // }
|
31800 | let nextType = (_d = model.at(offset)) === null || _d === void 0 ? void 0 : _d.type;
|
31801 | const { lastOffset } = model;
|
31802 | while (offset <= lastOffset &&
|
31803 | (nextType === type || nextType === 'msubsup')) {
|
31804 | while (((_e = model.at(offset).rightSibling) === null || _e === void 0 ? void 0 : _e.type) === 'msubsup') {
|
31805 | offset = model.offsetOf(model.at(offset).rightSibling);
|
31806 | }
|
31807 | offset += 1;
|
31808 | nextType = (_f = model.at(offset)) === null || _f === void 0 ? void 0 : _f.type;
|
31809 | }
|
31810 | offset -= 1;
|
31811 | }
|
31812 | if ((_g = options === null || options === void 0 ? void 0 : options.extend) !== null && _g !== void 0 ? _g : false) {
|
31813 | if (!model.setSelection(model.anchor, offset)) {
|
31814 | model.announce('plonk');
|
31815 | return false;
|
31816 | }
|
31817 | }
|
31818 | else {
|
31819 | if (offset === model.position) {
|
31820 | model.announce('plonk');
|
31821 | return false;
|
31822 | }
|
31823 | model.position = offset;
|
31824 | }
|
31825 | model.announce('move', previousPosition);
|
31826 | return true;
|
31827 | }
|
31828 | /**
|
31829 | * Handle keyboard navigation (arrow keys)
|
31830 | */
|
31831 | function move(model, direction, options) {
|
31832 | var _a, _b, _c;
|
31833 | options = options !== null && options !== void 0 ? options : { extend: false };
|
31834 | if (direction !== 'forward') {
|
31835 | const [from, to] = getCommandSuggestionRange(model);
|
31836 | if (from !== undefined && to !== undefined) {
|
31837 | model.deleteAtoms([from, to]);
|
31838 | }
|
31839 | }
|
31840 | if (direction === 'upward')
|
31841 | return moveUpward(model, options);
|
31842 | if (direction === 'downward')
|
31843 | return moveDownward(model, options);
|
31844 | const previousPosition = model.position;
|
31845 | if (options.extend) {
|
31846 | return model.extendSelection(direction);
|
31847 | }
|
31848 | if (model.selectionIsPlaceholder) {
|
31849 | model.collapseSelection(direction);
|
31850 | return move(model, direction);
|
31851 | }
|
31852 | if (!model.collapseSelection(direction)) {
|
31853 | let pos = model.position + (direction === 'forward' ? +1 : -1);
|
31854 | //
|
31855 | // 1. Handle `captureSelection` and `skipBoundary`
|
31856 | //
|
31857 | if (direction === 'forward') {
|
31858 | let atom = model.at(pos);
|
31859 | if (atom === null || atom === void 0 ? void 0 : atom.inCaptureSelection) {
|
31860 | // If in a capture selection, while going forward jump to
|
31861 | // after
|
31862 | while (!atom.captureSelection)
|
31863 | atom = atom.parent;
|
31864 | pos = model.offsetOf(atom);
|
31865 | }
|
31866 | else if (!(atom === null || atom === void 0 ? void 0 : atom.isFirstSibling) &&
|
31867 | (atom === null || atom === void 0 ? void 0 : atom.isLastSibling) &&
|
31868 | ((_a = atom.parent) === null || _a === void 0 ? void 0 : _a.skipBoundary)) {
|
31869 | // When going forward if next is skipboundary, move 2
|
31870 | if (pos + 1 === model.lastOffset) {
|
31871 | pos = pos + 1;
|
31872 | }
|
31873 | else {
|
31874 | model.position = pos + 1;
|
31875 | return move(model, 'forward', options);
|
31876 | }
|
31877 | }
|
31878 | else if (atom instanceof LatexAtom && atom.isSuggestion) {
|
31879 | atom.isSuggestion = false;
|
31880 | }
|
31881 | }
|
31882 | else if (direction === 'backward') {
|
31883 | let atom = model.at(pos);
|
31884 | if (atom === null || atom === void 0 ? void 0 : atom.inCaptureSelection) {
|
31885 | // If in a capture selection while going backward, jump to
|
31886 | // before
|
31887 | while (!atom.captureSelection)
|
31888 | atom = atom.parent;
|
31889 | pos = Math.max(0, model.offsetOf(atom.leftSibling));
|
31890 | }
|
31891 | else if (!(atom === null || atom === void 0 ? void 0 : atom.isLastSibling) &&
|
31892 | (atom === null || atom === void 0 ? void 0 : atom.isFirstSibling) &&
|
31893 | ((_b = atom.parent) === null || _b === void 0 ? void 0 : _b.skipBoundary)) {
|
31894 | // When going backward, if land on first of group and previous is
|
31895 | // skipbounday, move -2
|
31896 | pos = Math.max(0, pos - 1);
|
31897 | }
|
31898 | }
|
31899 | //
|
31900 | // 2. Handle out of bounds
|
31901 | //
|
31902 | if (pos < 0 || pos > model.lastOffset) {
|
31903 | // We're going out of bounds
|
31904 | let result = true; // True => perform default handling
|
31905 | if (!model.suppressChangeNotifications) {
|
31906 | result = (_c = model.hooks) === null || _c === void 0 ? void 0 : _c.moveOut(model, direction);
|
31907 | }
|
31908 | if (result)
|
31909 | model.announce('plonk');
|
31910 | return result;
|
31911 | }
|
31912 | //
|
31913 | // 3. Handle placeholder
|
31914 | //
|
31915 | setPositionHandlingPlaceholder(model, pos);
|
31916 | }
|
31917 | model.announce('move', previousPosition);
|
31918 | return true;
|
31919 | }
|
31920 | function setPositionHandlingPlaceholder(model, pos) {
|
31921 | var _a, _b, _c;
|
31922 | if (((_a = model.at(pos)) === null || _a === void 0 ? void 0 : _a.type) === 'placeholder') {
|
31923 | // We're going right of a placeholder: select it
|
31924 | model.setSelection(pos - 1, pos);
|
31925 | }
|
31926 | else if (((_c = (_b = model.at(pos)) === null || _b === void 0 ? void 0 : _b.rightSibling) === null || _c === void 0 ? void 0 : _c.type) === 'placeholder') {
|
31927 | // We're going left of a placeholder: select it
|
31928 | model.setSelection(pos, pos + 1);
|
31929 | }
|
31930 | else {
|
31931 | model.position = pos;
|
31932 | }
|
31933 | }
|
31934 | function moveUpward(model, options) {
|
31935 | var _a, _b, _c;
|
31936 | const extend = (_a = options === null || options === void 0 ? void 0 : options.extend) !== null && _a !== void 0 ? _a : false;
|
31937 | model.collapseSelection('backward');
|
31938 | // Find a target branch
|
31939 | // This is to handle the case: `\frac{x}{\sqrt{y}}`. If we're at `y`
|
31940 | // we'd expectto move to `x`, even though `\sqrt` doesn't have an 'above'
|
31941 | // branch, but one of its ancestor does.
|
31942 | let atom = model.at(model.position);
|
31943 | while (atom && atom.treeBranch !== 'below') {
|
31944 | atom = atom.parent;
|
31945 | }
|
31946 | if (atom) {
|
31947 | if (extend) {
|
31948 | model.setSelection(model.offsetOf(atom.parent.leftSibling), model.offsetOf(atom.parent));
|
31949 | }
|
31950 | else {
|
31951 | // If branch doesn't exist, create it
|
31952 | const branch = (_b = atom.parent.branch('above')) !== null && _b !== void 0 ? _b : atom.parent.createBranch('above');
|
31953 | // Move to the last atom of the branch
|
31954 | setPositionHandlingPlaceholder(model, model.offsetOf(branch[branch.length - 1]));
|
31955 | }
|
31956 | model.announce('move up');
|
31957 | // } else if (model.parent.array) {
|
31958 | // // In an array
|
31959 | // let colRow = arrayColRow(model.parent.array, relation);
|
31960 | // colRow = arrayAdjustRow(model.parent.array, colRow, -1);
|
31961 | // if (colRow && arrayCell(model.parent.array, colRow)) {
|
31962 | // model.path[model.path.length - 1].relation = ('cell' +
|
31963 | // arrayIndex(model.parent.array, colRow)) as Relation;
|
31964 | // setSelectionOffset(model, model.anchorOffset());
|
31965 | // model.announce('moveUp');
|
31966 | // } else {
|
31967 | // move(model, 'backward', options);
|
31968 | // }
|
31969 | }
|
31970 | else {
|
31971 | let result = true; // True => perform default handling
|
31972 | if (!model.suppressChangeNotifications) {
|
31973 | result = (_c = model.hooks) === null || _c === void 0 ? void 0 : _c.moveOut(model, 'upward');
|
31974 | }
|
31975 | model.announce(result ? 'plonk' : 'line');
|
31976 | return result;
|
31977 | }
|
31978 | return true;
|
31979 | }
|
31980 | function moveDownward(model, options) {
|
31981 | var _a, _b, _c;
|
31982 | const extend = (_a = options === null || options === void 0 ? void 0 : options.extend) !== null && _a !== void 0 ? _a : false;
|
31983 | model.collapseSelection('forward');
|
31984 | let atom = model.at(model.position);
|
31985 | while (atom && atom.treeBranch !== 'above') {
|
31986 | atom = atom.parent;
|
31987 | }
|
31988 | if (atom) {
|
31989 | if (extend) {
|
31990 | model.setSelection(model.offsetOf(atom.parent.leftSibling), model.offsetOf(atom.parent));
|
31991 | }
|
31992 | else {
|
31993 | // If branch doesn't exist, create it
|
31994 | const branch = (_b = atom.parent.branch('below')) !== null && _b !== void 0 ? _b : atom.parent.createBranch('below');
|
31995 | // Move to the last atom of the branch
|
31996 | setPositionHandlingPlaceholder(model, model.offsetOf(branch[branch.length - 1]));
|
31997 | }
|
31998 | model.announce('move down');
|
31999 | // // In an array
|
32000 | // let colRow = arrayColRow(model.parent.array, relation);
|
32001 | // colRow = arrayAdjustRow(model.parent.array, colRow, +1);
|
32002 | // // @revisit: validate this codepath
|
32003 | // if (colRow && arrayCell(model.parent.array, colRow)) {
|
32004 | // model.path[model.path.length - 1].relation = ('cell' +
|
32005 | // arrayIndex(model.parent.array, colRow)) as Relation;
|
32006 | // setSelectionOffset(model, model.anchorOffset());
|
32007 | // model.announce('moveDown');
|
32008 | // } else {
|
32009 | // move(model, 'forward', options);
|
32010 | // }
|
32011 | }
|
32012 | else {
|
32013 | let result = true; // True => perform default handling
|
32014 | if (!model.suppressChangeNotifications) {
|
32015 | result = (_c = model.hooks) === null || _c === void 0 ? void 0 : _c.moveOut(model, 'downward');
|
32016 | }
|
32017 | model.announce(result ? 'plonk' : 'line');
|
32018 | return result;
|
32019 | }
|
32020 | return true;
|
32021 | }
|
32022 |
|
32023 | register({
|
32024 | deleteAll: (model) => {
|
32025 | return deleteRange(model, [0, -1]);
|
32026 | },
|
32027 | deleteForward: (model) => deleteForward(model),
|
32028 | deleteBackward: (model) => deleteBackward(model),
|
32029 | deleteNextWord: (model) => deleteRange(model, [
|
32030 | model.anchor,
|
32031 | wordBoundaryOffset(model, model.position, 'forward'),
|
32032 | ]),
|
32033 | deletePreviousWord: (model) => deleteRange(model, [
|
32034 | model.anchor,
|
32035 | wordBoundaryOffset(model, model.position, 'backward'),
|
32036 | ]),
|
32037 | deleteToGroupStart: (model) => deleteRange(model, [
|
32038 | model.anchor,
|
32039 | model.offsetOf(model.at(model.position).firstSibling),
|
32040 | ]),
|
32041 | deleteToGroupEnd: (model) => deleteRange(model, [
|
32042 | model.anchor,
|
32043 | model.offsetOf(model.at(model.position).lastSibling),
|
32044 | ]),
|
32045 | deleteToMathFieldStart: (model) => deleteRange(model, [model.anchor, 0]),
|
32046 | deleteToMathFieldEnd: (model) => deleteRange(model, [model.anchor, -1]),
|
32047 | }, { target: 'model', category: 'delete' });
|
32048 |
|
32049 | function moveAfterParent(model) {
|
32050 | const previousPosition = model.position;
|
32051 | if (!model.at(previousPosition).parent) {
|
32052 | model.announce('plonk');
|
32053 | return false;
|
32054 | }
|
32055 | model.position = model.offsetOf(model.at(model.position).parent);
|
32056 | model.announce('move', previousPosition);
|
32057 | return true;
|
32058 | }
|
32059 | function superscriptDepth(model) {
|
32060 | let result = 0;
|
32061 | let atom = model.at(model.position);
|
32062 | let wasSuperscript = false;
|
32063 | while (atom) {
|
32064 | if (!atom.hasEmptyBranch('superscript') ||
|
32065 | !atom.hasEmptyBranch('subscript')) {
|
32066 | result += 1;
|
32067 | }
|
32068 | if (!atom.hasEmptyBranch('superscript')) {
|
32069 | wasSuperscript = true;
|
32070 | }
|
32071 | else if (!atom.hasEmptyBranch('subscript')) {
|
32072 | wasSuperscript = false;
|
32073 | }
|
32074 | atom = atom.parent;
|
32075 | }
|
32076 | return wasSuperscript ? result : 0;
|
32077 | }
|
32078 | function subscriptDepth(model) {
|
32079 | let result = 0;
|
32080 | let atom = model.at(model.position);
|
32081 | let wasSubscript = false;
|
32082 | while (atom) {
|
32083 | if (!atom.hasEmptyBranch('superscript') ||
|
32084 | !atom.hasEmptyBranch('subscript')) {
|
32085 | result += 1;
|
32086 | }
|
32087 | if (!atom.hasEmptyBranch('superscript')) {
|
32088 | wasSubscript = false;
|
32089 | }
|
32090 | else if (!atom.hasEmptyBranch('subscript')) {
|
32091 | wasSubscript = true;
|
32092 | }
|
32093 | atom = atom.parent;
|
32094 | }
|
32095 | return wasSubscript ? result : 0;
|
32096 | }
|
32097 | /**
|
32098 | * Switch the cursor to the superscript and select it. If there is no subscript
|
32099 | * yet, create one.
|
32100 | */
|
32101 | function moveToSuperscript(model) {
|
32102 | var _a;
|
32103 | model.collapseSelection();
|
32104 | if (superscriptDepth(model) >= model.mathfield.options.scriptDepth[1]) {
|
32105 | model.announce('plonk');
|
32106 | return false;
|
32107 | }
|
32108 | let target = model.at(model.position);
|
32109 | if (target.subsupPlacement === undefined) {
|
32110 | // This atom can't have a superscript/subscript:
|
32111 | // add an adjacent `msubsup` atom instead.
|
32112 | if (((_a = target.rightSibling) === null || _a === void 0 ? void 0 : _a.type) !== 'msubsup') {
|
32113 | target.parent.addChildAfter(new SubsupAtom({ style: target.computedStyle }), target);
|
32114 | }
|
32115 | target = target.rightSibling;
|
32116 | }
|
32117 | // Ensure there is a superscript branch
|
32118 | target.createBranch('superscript');
|
32119 | model.setSelection(model.getSiblingsRange(model.offsetOf(target.superscript[0])));
|
32120 | return true;
|
32121 | }
|
32122 | /**
|
32123 | * Switch the cursor to the subscript and select it. If there is no subscript
|
32124 | * yet, create one.
|
32125 | */
|
32126 | function moveToSubscript(model) {
|
32127 | var _a;
|
32128 | model.collapseSelection();
|
32129 | if (subscriptDepth(model) >= model.mathfield.options.scriptDepth[0]) {
|
32130 | model.announce('plonk');
|
32131 | return false;
|
32132 | }
|
32133 | let target = model.at(model.position);
|
32134 | if (target.subsupPlacement === undefined) {
|
32135 | // This atom can't have a superscript/subscript:
|
32136 | // add an adjacent `msubsup` atom instead.
|
32137 | if (((_a = model.at(model.position + 1)) === null || _a === void 0 ? void 0 : _a.type) !== 'msubsup') {
|
32138 | target.parent.addChildAfter(new SubsupAtom({
|
32139 | style: model.at(model.position).computedStyle,
|
32140 | }), target);
|
32141 | }
|
32142 | target = model.at(model.position + 1);
|
32143 | }
|
32144 | // Ensure there is a subscript branch
|
32145 | target.createBranch('subscript');
|
32146 | model.setSelection(model.getSiblingsRange(model.offsetOf(target.subscript[0])));
|
32147 | return true;
|
32148 | }
|
32149 | /**
|
32150 | * Return an array of tabbable elements, approximately in the order a browser
|
32151 | * would (the browsers are inconsistent), which is first by accounting
|
32152 | * for non-null tabIndex, then null tabIndex, then document order of focusable
|
32153 | * elements.
|
32154 | */
|
32155 | function getTabbableElements() {
|
32156 | function tabbable(element) {
|
32157 | const regularTabbables = [];
|
32158 | const orderedTabbables = [];
|
32159 | const candidates = [
|
32160 | ...element.querySelectorAll(`input, select, textarea, a[href], button,
|
32161 | [tabindex], audio[controls], video[controls],
|
32162 | [contenteditable]:not([contenteditable="false"]), details>summary`),
|
32163 | ].filter(isNodeMatchingSelectorTabbable);
|
32164 | candidates.forEach((candidate, i) => {
|
32165 | const candidateTabindex = getTabindex(candidate);
|
32166 | if (candidateTabindex === 0) {
|
32167 | regularTabbables.push(candidate);
|
32168 | }
|
32169 | else {
|
32170 | orderedTabbables.push({
|
32171 | documentOrder: i,
|
32172 | tabIndex: candidateTabindex,
|
32173 | node: candidate,
|
32174 | });
|
32175 | }
|
32176 | });
|
32177 | return orderedTabbables
|
32178 | .sort((a, b) => a.tabIndex === b.tabIndex
|
32179 | ? a.documentOrder - b.documentOrder
|
32180 | : a.tabIndex - b.tabIndex)
|
32181 | .map((a) => a.node)
|
32182 | .concat(regularTabbables);
|
32183 | }
|
32184 | function isNodeMatchingSelectorTabbable(element) {
|
32185 | if (!isNodeMatchingSelectorFocusable(element) ||
|
32186 | isNonTabbableRadio(element) ||
|
32187 | getTabindex(element) < 0) {
|
32188 | return false;
|
32189 | }
|
32190 | return true;
|
32191 | }
|
32192 | function isNodeMatchingSelectorFocusable(node) {
|
32193 | if (node.disabled ||
|
32194 | (node.type === 'hidden' && node.tagName.toUpperCase() === 'INPUT') ||
|
32195 | isHidden(node)) {
|
32196 | return false;
|
32197 | }
|
32198 | return true;
|
32199 | }
|
32200 | function getTabindex(node) {
|
32201 | var _a;
|
32202 | const tabindexAttr = Number.parseInt((_a = node.getAttribute('tabindex')) !== null && _a !== void 0 ? _a : 'NaN', 10);
|
32203 | if (!Number.isNaN(tabindexAttr)) {
|
32204 | return tabindexAttr;
|
32205 | }
|
32206 | // Browsers do not return `tabIndex` correctly for contentEditable nodes;
|
32207 | // so if they don't have a tabindex attribute specifically set, assume it's 0.
|
32208 | if (node.contentEditable === 'true') {
|
32209 | return 0;
|
32210 | }
|
32211 | // In Chrome, <audio controls/> and <video controls/> elements get a default
|
32212 | // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
|
32213 | // yet they are still part of the regular tab order; in FF, they get a default
|
32214 | // `tabIndex` of 0; since Chrome still puts those elements in the regular tab
|
32215 | // order, consider their tab index to be 0
|
32216 | if ((node.nodeName === 'AUDIO' || node.nodeName === 'VIDEO') &&
|
32217 | node.getAttribute('tabindex') === null) {
|
32218 | return 0;
|
32219 | }
|
32220 | return node.tabIndex;
|
32221 | }
|
32222 | function isNonTabbableRadio(node) {
|
32223 | return (node.tagName.toUpperCase() === 'INPUT' &&
|
32224 | node.type === 'radio' &&
|
32225 | !isTabbableRadio(node));
|
32226 | }
|
32227 | function getCheckedRadio(nodes, form) {
|
32228 | for (const node of nodes) {
|
32229 | if (node.checked && node.form === form) {
|
32230 | return node;
|
32231 | }
|
32232 | }
|
32233 | return null;
|
32234 | }
|
32235 | function isTabbableRadio(node) {
|
32236 | var _a;
|
32237 | if (!node.name) {
|
32238 | return true;
|
32239 | }
|
32240 | const radioScope = (_a = node.form) !== null && _a !== void 0 ? _a : node.ownerDocument;
|
32241 | const radioSet = radioScope.querySelectorAll('input[type="radio"][name="' + node.name + '"]');
|
32242 | const checked = getCheckedRadio(radioSet, node.form);
|
32243 | return !checked || checked === node;
|
32244 | }
|
32245 | function isHidden(element) {
|
32246 | if (!isBrowser() ||
|
32247 | element === document.activeElement ||
|
32248 | element.contains(document.activeElement)) {
|
32249 | return false;
|
32250 | }
|
32251 | if (getComputedStyle(element).visibility === 'hidden')
|
32252 | return true;
|
32253 | // Note that browsers generally don't consider the bounding rect
|
32254 | // as a criteria to determine if an item is focusable, but we want
|
32255 | // to exclude the invisible textareas used to capture keyoard input.
|
32256 | const bounds = element.getBoundingClientRect();
|
32257 | if (bounds.width === 0 || bounds.height === 0)
|
32258 | return true;
|
32259 | while (element) {
|
32260 | if (getComputedStyle(element).display === 'none')
|
32261 | return true;
|
32262 | element = element.parentElement;
|
32263 | }
|
32264 | return false;
|
32265 | }
|
32266 | if (!isBrowser())
|
32267 | return [];
|
32268 | return tabbable(document.body);
|
32269 | }
|
32270 | /**
|
32271 | * Move to the next/previous placeholder or empty child list.
|
32272 | * @return False if no placeholder found and did not move
|
32273 | */
|
32274 | function leap(model, dir, callHooks = true) {
|
32275 | var _a, _b;
|
32276 | const dist = dir === 'forward' ? 1 : -1;
|
32277 | if (model.at(model.anchor).type === 'placeholder') {
|
32278 | // If we're already at a placeholder, move by one more (the placeholder
|
32279 | // is right after the insertion point)
|
32280 | move(model, dir);
|
32281 | }
|
32282 | // Candidate placeholders are atom of type 'placeholder'
|
32283 | // or empty children list (except for the root: if the root is empty,
|
32284 | // it is not a valid placeholder)
|
32285 | const atoms = model.getAllAtoms(model.position + dist);
|
32286 | if (dir === 'backward')
|
32287 | atoms.reverse();
|
32288 | const placeholders = atoms.filter((atom) => atom.type === 'placeholder' ||
|
32289 | (atom.treeDepth > 0 && atom.isFirstSibling && atom.isLastSibling));
|
32290 | // If no placeholders were found, call handler or move to the next focusable
|
32291 | // element in the document
|
32292 | if (placeholders.length === 0) {
|
32293 | const handled = !callHooks || !((_b = (_a = model.hooks).tabOut) === null || _b === void 0 ? void 0 : _b.call(_a, model, dir));
|
32294 | if (handled) {
|
32295 | model.announce('plonk');
|
32296 | return false;
|
32297 | }
|
32298 | const tabbable = getTabbableElements();
|
32299 | if (!document.activeElement || tabbable.length === 1) {
|
32300 | model.announce('plonk');
|
32301 | return false;
|
32302 | }
|
32303 | let index = tabbable.indexOf(document.activeElement) + dist;
|
32304 | if (document.activeElement instanceof MathfieldElement &&
|
32305 | moveToNextNestedMathfield(document.activeElement, dir, dist)) {
|
32306 | return true;
|
32307 | }
|
32308 | if (index < 0)
|
32309 | index = tabbable.length - 1;
|
32310 | if (index >= tabbable.length)
|
32311 | index = 0;
|
32312 | if (tabbable[index] instanceof MathfieldElement &&
|
32313 | moveToNextNestedMathfield(tabbable[index], dir, dist)) {
|
32314 | return true;
|
32315 | }
|
32316 | tabbable[index].focus();
|
32317 | if (index === 0) {
|
32318 | model.announce('plonk');
|
32319 | return false;
|
32320 | }
|
32321 | return true;
|
32322 | }
|
32323 | /**
|
32324 | *
|
32325 | */
|
32326 | function moveToNextNestedMathfield(element, dir, dist) {
|
32327 | var _a, _b, _c;
|
32328 | const nestedMathfield = [
|
32329 | ...((_b = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('math-field')) !== null && _b !== void 0 ? _b : []),
|
32330 | ];
|
32331 | if (nestedMathfield.length) {
|
32332 | const activeMathfield = (_c = element.shadowRoot) === null || _c === void 0 ? void 0 : _c.activeElement;
|
32333 | console.log(activeMathfield);
|
32334 | const activeIndex = nestedMathfield.indexOf(activeMathfield);
|
32335 | let newMathfieldIndex = activeIndex + dist;
|
32336 | console.log(activeIndex);
|
32337 | if (activeIndex < 0 && dir === 'backward') {
|
32338 | newMathfieldIndex = nestedMathfield.length - 1;
|
32339 | }
|
32340 | if (newMathfieldIndex >= 0 &&
|
32341 | newMathfieldIndex < nestedMathfield.length) {
|
32342 | console.log(newMathfieldIndex, nestedMathfield, 'forward');
|
32343 | nestedMathfield[newMathfieldIndex].focus();
|
32344 | return true;
|
32345 | }
|
32346 | }
|
32347 | return false;
|
32348 | }
|
32349 | // Set the selection to the next placeholder
|
32350 | const previousPosition = model.position;
|
32351 | const newPosition = model.offsetOf(placeholders[0]);
|
32352 | if (placeholders[0].type === 'placeholder') {
|
32353 | model.setSelection(newPosition - 1, newPosition);
|
32354 | }
|
32355 | else {
|
32356 | model.position = newPosition;
|
32357 | }
|
32358 | model.announce('move', previousPosition);
|
32359 | return true;
|
32360 | }
|
32361 | /**
|
32362 | * If cursor is currently in:
|
32363 | * - superscript: move to subscript, creating it if necessary
|
32364 | * - subscript: move to superscript, creating it if necessary
|
32365 | * - numerator: move to denominator
|
32366 | * - denominator: move to numerator
|
32367 | * - otherwise: move to superscript
|
32368 | */
|
32369 | register({
|
32370 | moveToOpposite: (model) => {
|
32371 | const OPPOSITE_RELATIONS = {
|
32372 | superscript: 'subscript',
|
32373 | subscript: 'superscript',
|
32374 | above: 'below',
|
32375 | below: 'above',
|
32376 | };
|
32377 | const cursor = model.at(model.position);
|
32378 | const { parent } = cursor;
|
32379 | if (!parent) {
|
32380 | model.announce('plonk');
|
32381 | return false;
|
32382 | }
|
32383 | const relation = cursor.treeBranch;
|
32384 | let oppositeRelation;
|
32385 | if (typeof relation === 'string') {
|
32386 | oppositeRelation = OPPOSITE_RELATIONS[relation];
|
32387 | }
|
32388 | if (!oppositeRelation) {
|
32389 | if (!cursor.subsupPlacement) {
|
32390 | return moveToSuperscript(model);
|
32391 | }
|
32392 | return moveToSubscript(model);
|
32393 | }
|
32394 | if (!parent.branch(oppositeRelation)) {
|
32395 | // Don't have children of the opposite relation yet
|
32396 | // Add them
|
32397 | parent.createBranch(oppositeRelation);
|
32398 | }
|
32399 | return model.setSelection(model.getBranchRange(model.offsetOf(parent), oppositeRelation));
|
32400 | },
|
32401 | moveBeforeParent: (model) => {
|
32402 | const { parent } = model.at(model.position);
|
32403 | if (!parent) {
|
32404 | model.announce('plonk');
|
32405 | return false;
|
32406 | }
|
32407 | model.position = model.offsetOf(parent);
|
32408 | return true;
|
32409 | },
|
32410 | moveAfterParent: (model) => moveAfterParent(model),
|
32411 | moveToNextPlaceholder: (model) => leap(model, 'forward'),
|
32412 | moveToPreviousPlaceholder: (model) => leap(model, 'backward'),
|
32413 | moveToNextChar: (model) => move(model, 'forward'),
|
32414 | moveToPreviousChar: (model) => move(model, 'backward'),
|
32415 | moveUp: (model) => move(model, 'upward'),
|
32416 | moveDown: (model) => move(model, 'downward'),
|
32417 | moveToNextWord: (model) => skip(model, 'forward'),
|
32418 | moveToPreviousWord: (model) => skip(model, 'backward'),
|
32419 | moveToGroupStart: (model) => {
|
32420 | const pos = model.offsetOf(model.at(model.position).firstSibling);
|
32421 | if (pos === model.position) {
|
32422 | model.announce('plonk');
|
32423 | return false;
|
32424 | }
|
32425 | model.position = pos;
|
32426 | return true;
|
32427 | },
|
32428 | moveToGroupEnd: (model) => {
|
32429 | const pos = model.offsetOf(model.at(model.position).lastSibling);
|
32430 | if (pos === model.position) {
|
32431 | model.announce('plonk');
|
32432 | return false;
|
32433 | }
|
32434 | model.position = pos;
|
32435 | return true;
|
32436 | },
|
32437 | moveToMathFieldStart: (model) => {
|
32438 | if (model.position === 0) {
|
32439 | model.announce('plonk');
|
32440 | return false;
|
32441 | }
|
32442 | model.position = 0;
|
32443 | return true;
|
32444 | },
|
32445 | moveToMathFieldEnd: (model) => {
|
32446 | if (model.position === model.lastOffset) {
|
32447 | model.announce('plonk');
|
32448 | return false;
|
32449 | }
|
32450 | model.position = model.lastOffset;
|
32451 | return true;
|
32452 | },
|
32453 | moveToSuperscript: (model) => moveToSuperscript(model),
|
32454 | moveToSubscript: (model) => moveToSubscript(model),
|
32455 | }, { target: 'model', category: 'selection-anchor' });
|
32456 |
|
32457 | /**
|
32458 | * Return true if the atom could be a part of a number
|
32459 | * i.e. "-12354.568"
|
32460 | */
|
32461 | function isNumber(atom) {
|
32462 | if (!atom)
|
32463 | return false;
|
32464 | return ((atom.type === 'mord' && /[\d.]/.test(atom.value)) ||
|
32465 | (atom.type === 'mpunct' && atom.value === ','));
|
32466 | }
|
32467 | /**
|
32468 | * Select all the atoms in the current group, that is all the siblings.
|
32469 | * When the selection is in a numerator, the group is the numerator. When
|
32470 | * the selection is a superscript or subscript, the group is the supsub.
|
32471 | * When the selection is in a text zone, the "group" is a word.
|
32472 | */
|
32473 | function selectGroup(model) {
|
32474 | if (getMode(model, model.position) === 'text') {
|
32475 | let start = Math.min(model.anchor, model.position);
|
32476 | let end = Math.max(model.anchor, model.position);
|
32477 | //
|
32478 | let done = false;
|
32479 | while (!done && start > 0) {
|
32480 | const atom = model.at(start);
|
32481 | if (atom.mode === 'text' && LETTER_AND_DIGITS.test(atom.value)) {
|
32482 | start -= 1;
|
32483 | }
|
32484 | else {
|
32485 | done = true;
|
32486 | }
|
32487 | }
|
32488 | done = false;
|
32489 | while (!done && end <= model.lastOffset) {
|
32490 | const atom = model.at(end);
|
32491 | if (atom.mode === 'text' && LETTER_AND_DIGITS.test(atom.value)) {
|
32492 | end += 1;
|
32493 | }
|
32494 | else {
|
32495 | done = true;
|
32496 | }
|
32497 | }
|
32498 | if (done) {
|
32499 | end -= 1;
|
32500 | }
|
32501 | if (start >= end) {
|
32502 | // No word found. Select a single character
|
32503 | model.setSelection(end - 1, end);
|
32504 | return true;
|
32505 | }
|
32506 | model.setSelection(start, end);
|
32507 | }
|
32508 | else {
|
32509 | const atom = model.at(model.position);
|
32510 | // In a math zone, select all the sibling nodes
|
32511 | if (isNumber(atom)) {
|
32512 | // In a number, select all the digits
|
32513 | let start = Math.min(model.anchor, model.position);
|
32514 | let end = Math.max(model.anchor, model.position);
|
32515 | //
|
32516 | while (isNumber(model.at(start)))
|
32517 | start -= 1;
|
32518 | while (isNumber(model.at(end)))
|
32519 | end += 1;
|
32520 | model.setSelection(start, end - 1);
|
32521 | }
|
32522 | else {
|
32523 | model.setSelection(model.offsetOf(atom.firstSibling), model.offsetOf(atom.lastSibling));
|
32524 | }
|
32525 | }
|
32526 | return true;
|
32527 | }
|
32528 | register({
|
32529 | selectGroup: (model) => {
|
32530 | const result = selectGroup(model);
|
32531 | if (!result)
|
32532 | model.announce('plonk');
|
32533 | return result;
|
32534 | },
|
32535 | selectAll: (model) => model.setSelection(0, model.lastOffset),
|
32536 | extendSelectionForward: (model) => {
|
32537 | const result = model.extendSelection('forward');
|
32538 | if (!result)
|
32539 | model.announce('plonk');
|
32540 | return result;
|
32541 | },
|
32542 | extendSelectionBackward: (model) => {
|
32543 | const result = model.extendSelection('backward');
|
32544 | if (!result)
|
32545 | model.announce('plonk');
|
32546 | return result;
|
32547 | },
|
32548 | extendToNextWord: (model) => skip(model, 'forward', { extend: true }),
|
32549 | extendToPreviousWord: (model) => skip(model, 'backward', { extend: true }),
|
32550 | extendSelectionUpward: (model) => move(model, 'upward', { extend: true }),
|
32551 | extendSelectionDownward: (model) => move(model, 'downward', { extend: true }),
|
32552 | /**
|
32553 | * Extend the selection until the next boundary is reached. A boundary
|
32554 | * is defined by an atom of a different type (mbin, mord, etc...)
|
32555 | * than the current focus. For example, in "1234+x=y", if the focus is between
|
32556 | * "1" and "2", invoking `extendToNextBoundary_` would extend the selection
|
32557 | * to "234".
|
32558 | */
|
32559 | extendToNextBoundary: (model) => skip(model, 'forward', { extend: true }),
|
32560 | /**
|
32561 | * Extend the selection until the previous boundary is reached. A boundary
|
32562 | * is defined by an atom of a different type (mbin, mord, etc...)
|
32563 | * than the current focus. For example, in "1+23456", if the focus is between
|
32564 | * "5" and "6", invoking `extendToPreviousBoundary` would extend the selection
|
32565 | * to "2345".
|
32566 | */
|
32567 | extendToPreviousBoundary: (model) => skip(model, 'backward', { extend: true }),
|
32568 | extendToGroupStart: (model) => {
|
32569 | const result = model.setSelection(model.anchor, model.offsetOf(model.at(model.position).firstSibling));
|
32570 | if (!result)
|
32571 | model.announce('plonk');
|
32572 | return result;
|
32573 | },
|
32574 | extendToGroupEnd: (model) => {
|
32575 | const result = model.setSelection(model.anchor, model.offsetOf(model.at(model.position).lastSibling));
|
32576 | if (!result)
|
32577 | model.announce('plonk');
|
32578 | return result;
|
32579 | },
|
32580 | extendToMathFieldStart: (model) => {
|
32581 | const result = model.setSelection(model.anchor, 0);
|
32582 | if (!result)
|
32583 | model.announce('plonk');
|
32584 | return result;
|
32585 | },
|
32586 | extendToMathFieldEnd: (model) => {
|
32587 | const result = model.setSelection(model.anchor, model.lastOffset);
|
32588 | if (!result)
|
32589 | model.announce('plonk');
|
32590 | return result;
|
32591 | },
|
32592 | }, { target: 'model', category: 'selection-extend' });
|
32593 |
|
32594 | /**
|
32595 | * This modules handles low-level keyboard events and normalize them across
|
32596 | * browsers.
|
32597 | *
|
32598 | * See https://dvcs.w3.org/hg/d4e/raw-file/tip/key-event-test.html
|
32599 | * (also at https://w3c.github.io/uievents/tools/key-event-viewer.html)
|
32600 | *
|
32601 | *
|
32602 | * - **KeyboardEvent.key** (the printable value associated with the key or a string
|
32603 | * for special keys)
|
32604 | * https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
|
32605 | * https://www.w3.org/TR/uievents-key/
|
32606 | *
|
32607 | * - **KeyboardEvent.code** (the physical key being pressed. On an AZERTY keyboard
|
32608 | * the key labelled "A" is KeyQ)
|
32609 | * https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code/code_values
|
32610 | * https://www.w3.org/TR/uievents-code/
|
32611 | *
|
32612 | * Note:
|
32613 | * - `charCode`, `keyCode` and `which` are deprecated
|
32614 | *
|
32615 | * For background, see this info regarding keybinding in VSCode:
|
32616 | * - https://github.com/microsoft/vscode/tree/master/src/vs/workbench/services/keybinding
|
32617 | * - https://github.com/microsoft/vscode/wiki/Keybinding-Issues
|
32618 | */
|
32619 | const PRINTABLE_KEYCODE = new Set([
|
32620 | 'Backquote',
|
32621 | 'Digit0',
|
32622 | 'Digit1',
|
32623 | 'Digit2',
|
32624 | 'Digit3',
|
32625 | 'Digit4',
|
32626 | 'Digit5',
|
32627 | 'Digit6',
|
32628 | 'Digit7',
|
32629 | 'Digit8',
|
32630 | 'Digit9',
|
32631 | 'Minus',
|
32632 | 'Equal',
|
32633 | 'IntlYen',
|
32634 | 'KeyQ',
|
32635 | 'KeyW',
|
32636 | 'KeyE',
|
32637 | 'KeyR',
|
32638 | 'KeyT',
|
32639 | 'KeyY',
|
32640 | 'KeyU',
|
32641 | 'KeyI',
|
32642 | 'KeyO',
|
32643 | 'KeyP',
|
32644 | 'BracketLeft',
|
32645 | 'BracketRight',
|
32646 | 'Backslash',
|
32647 | 'KeyA',
|
32648 | 'KeyS',
|
32649 | 'KeyD',
|
32650 | 'KeyF',
|
32651 | 'KeyG',
|
32652 | 'KeyH',
|
32653 | 'KeyJ',
|
32654 | 'KeyK',
|
32655 | 'KeyL',
|
32656 | 'Semicolon',
|
32657 | 'Quote',
|
32658 | 'IntlBackslash',
|
32659 | 'KeyZ',
|
32660 | 'KeyX',
|
32661 | 'KeyC',
|
32662 | 'KeyV',
|
32663 | 'KeyB',
|
32664 | 'KeyN',
|
32665 | 'KeyM',
|
32666 | 'Comma',
|
32667 | 'Period',
|
32668 | 'Slash',
|
32669 | 'IntlRo',
|
32670 | 'Space',
|
32671 | 'Numpad0',
|
32672 | 'Numpad1',
|
32673 | 'Numpad2',
|
32674 | 'Numpad3',
|
32675 | 'Numpad4',
|
32676 | 'Numpad5',
|
32677 | 'Numpad6',
|
32678 | 'Numpad7',
|
32679 | 'Numpad8',
|
32680 | 'Numpad9',
|
32681 | 'NumpadAdd',
|
32682 | 'NumpadComma',
|
32683 | 'NumpadDecimal',
|
32684 | 'NumpadDivide',
|
32685 | 'NumpadEqual',
|
32686 | 'NumpadHash',
|
32687 | 'NumpadMultiply',
|
32688 | 'NumpadParenLeft',
|
32689 | 'NumpadParenRight',
|
32690 | 'NumpadStar',
|
32691 | 'NumpadSubstract',
|
32692 | ]);
|
32693 | function mightProducePrintableCharacter(evt) {
|
32694 | if (evt.ctrlKey || evt.metaKey) {
|
32695 | // ignore ctrl/cmd-combination but not shift/alt-combinations
|
32696 | return false;
|
32697 | }
|
32698 | // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
|
32699 | if (evt.key === 'Dead')
|
32700 | return false;
|
32701 | // When issued via a composition, the `code` field is empty
|
32702 | if (evt.code === '')
|
32703 | return true;
|
32704 | return PRINTABLE_KEYCODE.has(evt.code);
|
32705 | }
|
32706 | /**
|
32707 | * Create a normalized representation of a keyboard event,
|
32708 | * i.e., key code and modifier keys. For example:
|
32709 | * - `ctrl+Shift+alt+[KeyF]`
|
32710 | *
|
32711 | * Note: the key code corresponds to a physical key, e.g. 'KeyQ' is
|
32712 | * the key labeled 'A' on a French keyboard
|
32713 | *
|
32714 | */
|
32715 | function keyboardEventToString(evt) {
|
32716 | evt = normalizeKeyboardEvent(evt);
|
32717 | const modifiers = [];
|
32718 | if (evt.ctrlKey)
|
32719 | modifiers.push('ctrl');
|
32720 | if (evt.metaKey)
|
32721 | modifiers.push('meta');
|
32722 | if (evt.altKey)
|
32723 | modifiers.push('alt');
|
32724 | if (evt.shiftKey)
|
32725 | modifiers.push('shift');
|
32726 | // If no modifiers, simply return the key name
|
32727 | if (modifiers.length === 0)
|
32728 | return '[' + evt.code + ']';
|
32729 | modifiers.push('[' + evt.code + ']');
|
32730 | return modifiers.join('+');
|
32731 | }
|
32732 | /**
|
32733 | * Setup to capture the keyboard events from a `TextArea` and redispatch them to
|
32734 | * handlers.
|
32735 | *
|
32736 | * In general, commands (arrows, delete, etc..) should be handled
|
32737 | * in the `keystroke()` handler while text input should be handled in
|
32738 | * `typedtext()`.
|
32739 | *
|
32740 | * @param {HTMLElement} textarea A `TextArea` element that will capture the keyboard
|
32741 | * events. While this element will usually be a `TextArea`, it could be any
|
32742 | * element that is focusable and can receive keyboard events.
|
32743 | * @param {Object.<string, any>} handlers
|
32744 | * @param {function} handlers.keystroke invoked on a key down event, including
|
32745 | * for special keys such as ESC, arrow keys, tab, etc... and their variants
|
32746 | * with modifiers.
|
32747 | * @param {function} handlers.typedtext invoked on a keypress or other events
|
32748 | * when a key corresponding to a character has been pressed. This include `a-z`,
|
32749 | * `0-9`, `{}`, `^_()`, etc...
|
32750 | * This does not include arrow keys, tab, etc... but does include 'space'
|
32751 | * When a 'character' key is pressed, both `keystroke()` and `typedtext()` will
|
32752 | * be invoked. When a control/function key is pressed, only `keystroke()` will
|
32753 | * be invoked. In some cases, for example when using input methods or entering
|
32754 | * emoji, only `typedtext()` will be invoked.
|
32755 | */
|
32756 | function delegateKeyboardEvents(textarea, handlers) {
|
32757 | let keydownEvent = null;
|
32758 | let keypressEvent = null;
|
32759 | let compositionInProgress = false;
|
32760 | let focusInProgress = false;
|
32761 | let blurInProgress = false;
|
32762 | // This callback is invoked after a keyboard event has been processed
|
32763 | // by the textarea
|
32764 | let callbackTimeoutID;
|
32765 | function defer(cb) {
|
32766 | clearTimeout(callbackTimeoutID);
|
32767 | callbackTimeoutID = setTimeout(() => {
|
32768 | clearTimeout(callbackTimeoutID);
|
32769 | cb();
|
32770 | });
|
32771 | }
|
32772 | function handleTypedText() {
|
32773 | // Some browsers (Firefox, Opera) fire a keypress event for commands
|
32774 | // such as cmd+C where there might be a non-empty selection.
|
32775 | // We need to ignore these.
|
32776 | if (textarea.selectionStart !== textarea.selectionEnd)
|
32777 | return;
|
32778 | const text = textarea.value;
|
32779 | textarea.value = '';
|
32780 | if (text.length > 0)
|
32781 | handlers.typedText(text);
|
32782 | }
|
32783 | const target = textarea;
|
32784 | target.addEventListener('keydown', (event) => {
|
32785 | // "Process" key indicates commit of IME session (on Firefox)
|
32786 | // It's handled with compositionEnd so it can be safely ignored
|
32787 | if (compositionInProgress ||
|
32788 | event.key === 'Process' ||
|
32789 | event.code === 'CapsLock' ||
|
32790 | /(Control|Meta|Alt|Shift)(Left|Right)/.test(event.code)) {
|
32791 | keydownEvent = null;
|
32792 | return;
|
32793 | }
|
32794 | keydownEvent = event;
|
32795 | keypressEvent = null;
|
32796 | if (!handlers.keystroke(keyboardEventToString(event), event)) {
|
32797 | keydownEvent = null;
|
32798 | textarea.value = '';
|
32799 | }
|
32800 | else if (isTouchCapable()) {
|
32801 | // If we did not create a text-area because we're on a mobile
|
32802 | // device and we don't want to use the OS virtual keyboard, capture
|
32803 | // the key events possibly coming from an attached hardware keyboard
|
32804 | handlers.typedText(event.key);
|
32805 | }
|
32806 | }, true);
|
32807 | target.addEventListener('keypress', (event) => {
|
32808 | if (compositionInProgress)
|
32809 | return;
|
32810 | // If this is not the first keypress after a keydown, that is,
|
32811 | // if this is a repeated keystroke, call the keystroke handler.
|
32812 | if (!compositionInProgress) {
|
32813 | if (keydownEvent && keypressEvent) {
|
32814 | handlers.keystroke(keyboardEventToString(keydownEvent), keydownEvent);
|
32815 | }
|
32816 | keypressEvent = event;
|
32817 | defer(handleTypedText);
|
32818 | }
|
32819 | }, true);
|
32820 | target.addEventListener('keyup', () => {
|
32821 | if (compositionInProgress)
|
32822 | return;
|
32823 | // If we've received a keydown, but no keypress, check what's in the
|
32824 | // textarea field.
|
32825 | if (keydownEvent && !keypressEvent) {
|
32826 | handleTypedText();
|
32827 | }
|
32828 | }, true);
|
32829 | target.addEventListener('paste', (event) => {
|
32830 | // In some cases (Linux browsers), the text area might not be focused
|
32831 | // when doing a middle-click paste command.
|
32832 | textarea.focus();
|
32833 | textarea.value = '';
|
32834 | handlers.paste(event);
|
32835 | }, true);
|
32836 | target.addEventListener('cut', (ev) => handlers.cut(ev), true);
|
32837 | target.addEventListener('copy', (ev) => handlers.copy(ev), true);
|
32838 | target.addEventListener('blur', (event) => {
|
32839 | // If the relatedTarget (the element that is gaining the focus)
|
32840 | // is contained in our shadow host, ignore the blur event
|
32841 | if (event.relatedTarget ===
|
32842 | event.target.getRootNode().host) {
|
32843 | event.preventDefault();
|
32844 | event.stopPropagation();
|
32845 | return;
|
32846 | }
|
32847 | if (blurInProgress || focusInProgress)
|
32848 | return;
|
32849 | blurInProgress = true;
|
32850 | keydownEvent = null;
|
32851 | keypressEvent = null;
|
32852 | if (handlers.blur)
|
32853 | handlers.blur();
|
32854 | blurInProgress = false;
|
32855 | }, true);
|
32856 | target.addEventListener('focus', (_ev) => {
|
32857 | if (blurInProgress || focusInProgress)
|
32858 | return;
|
32859 | focusInProgress = true;
|
32860 | if (handlers.focus)
|
32861 | handlers.focus();
|
32862 | focusInProgress = false;
|
32863 | }, true);
|
32864 | target.addEventListener('compositionstart', (event) => {
|
32865 | compositionInProgress = true;
|
32866 | textarea.value = '';
|
32867 | if (handlers.compositionStart) {
|
32868 | handlers.compositionStart(event.data);
|
32869 | }
|
32870 | }, true);
|
32871 | target.addEventListener('compositionupdate', (ev) => {
|
32872 | if (!compositionInProgress)
|
32873 | return;
|
32874 | if (handlers.compositionUpdate)
|
32875 | handlers.compositionUpdate(ev.data);
|
32876 | }, true);
|
32877 | target.addEventListener('compositionend', (ev) => {
|
32878 | textarea.value = '';
|
32879 | if (!compositionInProgress)
|
32880 | return;
|
32881 | compositionInProgress = false;
|
32882 | if (handlers.compositionEnd)
|
32883 | handlers.compositionEnd(ev.data);
|
32884 | }, true);
|
32885 | // The `input` handler gets called when the field is changed,
|
32886 | // but no other relevant events have been triggered
|
32887 | // for example with emoji input...
|
32888 | target.addEventListener('input', (ev) => {
|
32889 | if (compositionInProgress)
|
32890 | return;
|
32891 | // If this was an `input` event sent as a result of a commit of
|
32892 | // IME, ignore it.
|
32893 | // (This is what FireFox does, even though the spec says it shouldn't happen)
|
32894 | // See https://github.com/w3c/uievents/issues/202
|
32895 | if (ev.inputType === 'insertCompositionText')
|
32896 | return;
|
32897 | // Paste is handled in paste handler
|
32898 | if (ev.inputType === 'insertFromPaste') {
|
32899 | ev.preventDefault();
|
32900 | ev.stopPropagation();
|
32901 | return;
|
32902 | }
|
32903 | defer(handleTypedText);
|
32904 | // Do not propagate the event (it crosses the shadow dom barrier)
|
32905 | ev.preventDefault();
|
32906 | ev.stopPropagation();
|
32907 | });
|
32908 | return {
|
32909 | cancelComposition: () => {
|
32910 | const savedBlur = handlers.blur;
|
32911 | const savedFocus = handlers.focus;
|
32912 | handlers.blur = null;
|
32913 | handlers.focus = null;
|
32914 | textarea.blur();
|
32915 | textarea.focus();
|
32916 | handlers.blur = savedBlur;
|
32917 | handlers.focus = savedFocus;
|
32918 | },
|
32919 | blur: () => {
|
32920 | if (typeof textarea.blur === 'function') {
|
32921 | textarea.blur();
|
32922 | }
|
32923 | },
|
32924 | focus: () => {
|
32925 | if (typeof textarea.focus === 'function') {
|
32926 | textarea.focus();
|
32927 | }
|
32928 | },
|
32929 | hasFocus: () => {
|
32930 | return deepActiveElement() === textarea;
|
32931 | },
|
32932 | setValue: (value) => {
|
32933 | if (value) {
|
32934 | textarea.value = value;
|
32935 | // The textarea may be a span (on mobile, for example), so check that
|
32936 | // it has a select() before calling it.
|
32937 | if (deepActiveElement() === textarea && textarea.select) {
|
32938 | textarea.select();
|
32939 | }
|
32940 | }
|
32941 | else {
|
32942 | textarea.value = '';
|
32943 | textarea.setAttribute('aria-label', '');
|
32944 | }
|
32945 | },
|
32946 | setAriaLabel: (value) => {
|
32947 | textarea.setAttribute('aria-label', 'after: ' + value);
|
32948 | },
|
32949 | moveTo: (x, y) => {
|
32950 | textarea.style.top = `${y}px`;
|
32951 | textarea.style.left = `${x}px`;
|
32952 | },
|
32953 | };
|
32954 | }
|
32955 | function deepActiveElement() {
|
32956 | var _a;
|
32957 | if (!isBrowser())
|
32958 | return null;
|
32959 | let a = document.activeElement;
|
32960 | while ((_a = a === null || a === void 0 ? void 0 : a.shadowRoot) === null || _a === void 0 ? void 0 : _a.activeElement) {
|
32961 | a = a.shadowRoot.activeElement;
|
32962 | }
|
32963 | return a;
|
32964 | }
|
32965 | function eventToChar(evt) {
|
32966 | var _a;
|
32967 | if (!evt)
|
32968 | return '';
|
32969 | let result;
|
32970 | if (evt.key === 'Unidentified') {
|
32971 | // On Android, the evt.key seems to always be 'Unidentified'.
|
32972 | // Get the value entered in the event target
|
32973 | if (evt.target) {
|
32974 | result = evt.target.value;
|
32975 | }
|
32976 | }
|
32977 | result = (_a = result !== null && result !== void 0 ? result : evt.key) !== null && _a !== void 0 ? _a : evt.code;
|
32978 | if (/^(Dead|Return|Enter|Tab|Escape|Delete|PageUp|PageDown|Home|End|Help|ArrowLeft|ArrowRight|ArrowUp|ArrowDown)$/.test(result)) {
|
32979 | result = '';
|
32980 | }
|
32981 | return result;
|
32982 | }
|
32983 |
|
32984 | class UndoManager {
|
32985 | constructor(model) {
|
32986 | this.record = false;
|
32987 | this.canCoalesce = false;
|
32988 | this.model = model;
|
32989 | this.reset();
|
32990 | }
|
32991 | get maximumDepth() {
|
32992 | return 1000;
|
32993 | } // Maximum number of undo/redo states
|
32994 | reset() {
|
32995 | this.stack = [];
|
32996 | this.index = -1;
|
32997 | }
|
32998 | startRecording() {
|
32999 | this.record = true;
|
33000 | }
|
33001 | canUndo() {
|
33002 | return this.index > 0;
|
33003 | }
|
33004 | canRedo() {
|
33005 | return this.index !== this.stack.length - 1;
|
33006 | }
|
33007 | undo(options) {
|
33008 | if (this.canUndo()) {
|
33009 | if (typeof (options === null || options === void 0 ? void 0 : options.onUndoStateWillChange) === 'function') {
|
33010 | options.onUndoStateWillChange(this.model.mathfield, 'undo');
|
33011 | }
|
33012 | this.restore(this.stack[this.index - 1], options);
|
33013 | this.index -= 1;
|
33014 | if (options && typeof options.onUndoStateDidChange === 'function') {
|
33015 | options.onUndoStateDidChange(this.model.mathfield, 'undo');
|
33016 | }
|
33017 | this.canCoalesce = false;
|
33018 | }
|
33019 | }
|
33020 | redo(options) {
|
33021 | if (this.canRedo()) {
|
33022 | if (typeof (options === null || options === void 0 ? void 0 : options.onUndoStateWillChange) === 'function') {
|
33023 | options.onUndoStateWillChange(this.model.mathfield, 'redo');
|
33024 | }
|
33025 | this.index += 1;
|
33026 | this.restore(this.stack[this.index], options);
|
33027 | if (options && typeof options.onUndoStateDidChange === 'function') {
|
33028 | options.onUndoStateDidChange(this.model.mathfield, 'redo');
|
33029 | }
|
33030 | this.canCoalesce = false;
|
33031 | }
|
33032 | }
|
33033 | pop() {
|
33034 | if (this.canUndo()) {
|
33035 | this.index -= 1;
|
33036 | this.stack.pop();
|
33037 | }
|
33038 | }
|
33039 | /**
|
33040 | * Push a snapshot of the content and selection of the mathfield onto the
|
33041 | * undo stack so that it can potentially be reverted to later.
|
33042 | */
|
33043 | snapshot(options) {
|
33044 | if (!this.record)
|
33045 | return;
|
33046 | if (typeof (options === null || options === void 0 ? void 0 : options.onUndoStateWillChange) === 'function') {
|
33047 | options.onUndoStateWillChange(this.model.mathfield, 'snapshot');
|
33048 | }
|
33049 | // Drop any entries that are part of the redo stack
|
33050 | this.stack.splice(this.index + 1, this.stack.length - this.index - 1);
|
33051 | // Add a new entry
|
33052 | this.stack.push({
|
33053 | latex: Atom.serialize(this.model.root, {
|
33054 | expandMacro: false,
|
33055 | defaultMode: this.model.mathfield.options.defaultMode,
|
33056 | }),
|
33057 | selection: this.model.selection,
|
33058 | });
|
33059 | this.index++;
|
33060 | // If we've reached the maximum number of undo operations, forget the
|
33061 | // oldest one.
|
33062 | if (this.stack.length > this.maximumDepth) {
|
33063 | this.stack.shift();
|
33064 | }
|
33065 | if (options && typeof options.onUndoStateDidChange === 'function') {
|
33066 | options.onUndoStateDidChange(this.model.mathfield, 'snapshot');
|
33067 | }
|
33068 | this.canCoalesce = false;
|
33069 | }
|
33070 | snapshotAndCoalesce(options) {
|
33071 | if (this.canCoalesce) {
|
33072 | this.pop();
|
33073 | }
|
33074 | this.snapshot(options);
|
33075 | this.canCoalesce = true;
|
33076 | }
|
33077 | /**
|
33078 | * Return an object capturing the state of the content and selection of the
|
33079 | * mathfield. Pass this object to restore() to reset the value of the math
|
33080 | * field to this saved value. This does not affect the undo stack.
|
33081 | */
|
33082 | save() {
|
33083 | return {
|
33084 | latex: Atom.serialize(this.model.root, {
|
33085 | expandMacro: false,
|
33086 | defaultMode: this.model.mathfield.options.defaultMode,
|
33087 | }),
|
33088 | selection: this.model.selection,
|
33089 | };
|
33090 | }
|
33091 | /**
|
33092 | * Set the content and selection of the mathfield to a value previously
|
33093 | * captured with save() or stored in the undo stack.
|
33094 | * This does not affect the undo stack.
|
33095 | */
|
33096 | restore(state, options) {
|
33097 | const wasSuppressing = this.model.suppressChangeNotifications;
|
33098 | if (options.suppressChangeNotifications !== undefined) {
|
33099 | this.model.suppressChangeNotifications =
|
33100 | options.suppressChangeNotifications;
|
33101 | }
|
33102 | // Restore the content
|
33103 | ModeEditor.insert('math', this.model, state ? state.latex : '', {
|
33104 | ...options,
|
33105 | format: 'latex',
|
33106 | insertionMode: 'replaceAll',
|
33107 | selectionMode: 'after',
|
33108 | smartFence: false,
|
33109 | });
|
33110 | // Restore the selection
|
33111 | this.model.selection = state ? state.selection : { ranges: [[0, 0]] };
|
33112 | this.model.suppressChangeNotifications = wasSuppressing;
|
33113 | }
|
33114 | }
|
33115 |
|
33116 | function match(pattern, latex) {
|
33117 | if (typeof pattern === 'string') {
|
33118 | return pattern === latex;
|
33119 | }
|
33120 | return pattern.test(latex);
|
33121 | }
|
33122 | function findInBranch(model, atom, branchName, value, options) {
|
33123 | const branch = atom.branch(branchName);
|
33124 | if (!branch)
|
33125 | return [];
|
33126 | const result = [];
|
33127 | let { length } = branch;
|
33128 | // For each length...
|
33129 | while (length > 0) {
|
33130 | // Consider each possible position in the branch
|
33131 | for (let i = 1; i < branch.length - length + 1; i++) {
|
33132 | const latex = Atom.serialize(branch.slice(i, i + length), {
|
33133 | expandMacro: false,
|
33134 | defaultMode: model.mathfield.options.defaultMode,
|
33135 | });
|
33136 | if (match(value, latex)) {
|
33137 | result.push([
|
33138 | model.offsetOf(branch[i].leftSibling),
|
33139 | model.offsetOf(branch[i + length - 1]),
|
33140 | ]);
|
33141 | i += length;
|
33142 | }
|
33143 | }
|
33144 | length--;
|
33145 | }
|
33146 | return branch.reduce((acc, x) => [...acc, ...findInAtom(model, x, value, options)], result);
|
33147 | }
|
33148 | function findInAtom(model, atom, value, options) {
|
33149 | if (atom.type === 'first')
|
33150 | return [];
|
33151 | // If the mode doesn't match, ignore this atom
|
33152 | if ((options === null || options === void 0 ? void 0 : options.mode) && options.mode !== atom.mode)
|
33153 | return [];
|
33154 | return atom.branches.reduce((acc, x) => {
|
33155 | return [...acc, ...findInBranch(model, atom, x, value, options)];
|
33156 | }, []);
|
33157 | }
|
33158 | function find(model, value, options) {
|
33159 | return findInBranch(model, model.root, 'body', value, options).sort((a, b) => {
|
33160 | if (b[0] === a[0]) {
|
33161 | return b[1] - a[1];
|
33162 | }
|
33163 | return b[0] - a[0];
|
33164 | });
|
33165 | }
|
33166 | function replaceInBranch(model, atom, branchName, pattern, replacement, options) {
|
33167 | const branch = atom.branch(branchName);
|
33168 | if (!branch)
|
33169 | return;
|
33170 | branch.forEach((x) => replaceInAtom(model, x, pattern, replacement, options));
|
33171 | let i = 1;
|
33172 | while (i < branch.length) {
|
33173 | let length = branch.length - i;
|
33174 | while (length > 0) {
|
33175 | let matched = false;
|
33176 | const latex = Atom.serialize(branch.slice(i, i + length), {
|
33177 | expandMacro: false,
|
33178 | defaultMode: model.mathfield.options.defaultMode,
|
33179 | });
|
33180 | const replacementArgs = { latex };
|
33181 | if (typeof pattern === 'string' && latex === pattern) {
|
33182 | matched = true;
|
33183 | }
|
33184 | else if (pattern instanceof RegExp) {
|
33185 | const match = latex.match(pattern);
|
33186 | if (match !== null) {
|
33187 | matched = true;
|
33188 | if (match.length > 0) {
|
33189 | replacementArgs.p = [...match];
|
33190 | }
|
33191 | replacementArgs.groups = match.groups;
|
33192 | }
|
33193 | }
|
33194 | if (matched) {
|
33195 | // Remove the atoms that matched
|
33196 | for (let j = i + length - 1; j >= i; j--) {
|
33197 | atom.removeChild(branch[j]);
|
33198 | }
|
33199 | let replacementString;
|
33200 | if (typeof replacement === 'string') {
|
33201 | replacementString = replacement;
|
33202 | if (replacementArgs.p) {
|
33203 | replacementArgs.p.forEach((x, index) => {
|
33204 | if (typeof x === 'string') {
|
33205 | replacementString = replacementString.replace('$' + Number(index).toString(), x);
|
33206 | }
|
33207 | });
|
33208 | }
|
33209 | if (replacementArgs.groups) {
|
33210 | Object.keys(replacementArgs.groups).forEach((x) => {
|
33211 | if (typeof x === 'string') {
|
33212 | replacementString = replacementString.replace('$' + x, replacementArgs.groups[x]);
|
33213 | }
|
33214 | });
|
33215 | }
|
33216 | replacementString = replacementString.replace('$$', '$');
|
33217 | }
|
33218 | else {
|
33219 | replacementString = replacement(replacementArgs);
|
33220 | }
|
33221 | const lastChild = atom.addChildrenAfter(parseLatex(replacementString, { parseMode: atom.mode }), branch[i - 1]);
|
33222 | i = branch.indexOf(lastChild) + 1;
|
33223 | length = branch.length - i;
|
33224 | }
|
33225 | else {
|
33226 | length--;
|
33227 | }
|
33228 | }
|
33229 | i++;
|
33230 | }
|
33231 | }
|
33232 | function replaceInAtom(model, atom, pattern, replacement, options) {
|
33233 | if (atom.type === 'first')
|
33234 | return;
|
33235 | // If the mode doesn't match, ignore this atom
|
33236 | if ((options === null || options === void 0 ? void 0 : options.mode) && options.mode !== atom.mode)
|
33237 | return;
|
33238 | atom.branches.forEach((x) => replaceInBranch(model, atom, x, pattern, replacement, options));
|
33239 | }
|
33240 | function replace(model, pattern, replacement, options) {
|
33241 | replaceInBranch(model, model.root, 'body', pattern, replacement, options);
|
33242 | model.position = model.normalizeOffset(model.position);
|
33243 | }
|
33244 |
|
33245 | /**
|
33246 | * Convert the atoms before the anchor to 'text' mode
|
33247 | * @param count - how many atoms back to look at
|
33248 | * @param {function} until - callback to indicate when to stop
|
33249 | * @private
|
33250 | */
|
33251 | function convertLastAtomsToText(model, count, until) {
|
33252 | if (typeof count === 'function') {
|
33253 | until = count;
|
33254 | count = Infinity;
|
33255 | }
|
33256 | if (count === undefined) {
|
33257 | count = Infinity;
|
33258 | }
|
33259 | let i = model.position;
|
33260 | let done = false;
|
33261 | while (!done) {
|
33262 | const atom = model.at(i);
|
33263 | done =
|
33264 | count === 0 ||
|
33265 | atom === undefined ||
|
33266 | atom.mode !== 'math' ||
|
33267 | !(/mord|textord|mpunct/.test(atom.type) ||
|
33268 | (atom.type === 'mop' && /[a-zA-Z]+/.test(atom.value))) ||
|
33269 | !atom.hasEmptyBranch('superscript') ||
|
33270 | !atom.hasEmptyBranch('subscript') ||
|
33271 | (typeof until === 'function' && !until(atom));
|
33272 | if (!done) {
|
33273 | atom.mode = 'text';
|
33274 | atom.command = atom.value;
|
33275 | atom.verbatimLatex = undefined;
|
33276 | }
|
33277 | i -= 1;
|
33278 | count -= 1;
|
33279 | }
|
33280 | contentDidChange(model);
|
33281 | }
|
33282 | /**
|
33283 | * Convert the atoms before the anchor to 'math' mode 'mord'
|
33284 | * @param {number} count - how many atoms back to look at
|
33285 | * @param {function} until - callback to indicate when to stop
|
33286 | * @private
|
33287 | */
|
33288 | function convertLastAtomsToMath(model, count, until) {
|
33289 | if (typeof count === 'function') {
|
33290 | until = count;
|
33291 | count = Infinity;
|
33292 | }
|
33293 | if (count === undefined) {
|
33294 | count = Infinity;
|
33295 | }
|
33296 | let i = model.position;
|
33297 | let done = false;
|
33298 | while (!done) {
|
33299 | const atom = model.at(i);
|
33300 | done =
|
33301 | count === 0 ||
|
33302 | !atom ||
|
33303 | atom.isFirstSibling ||
|
33304 | atom.mode !== 'text' ||
|
33305 | atom.value === ' ' ||
|
33306 | (until && !until(atom));
|
33307 | if (!done) {
|
33308 | atom.mode = 'math';
|
33309 | }
|
33310 | i -= 1;
|
33311 | count -= 1;
|
33312 | }
|
33313 | removeIsolatedSpace(model);
|
33314 | contentDidChange(model);
|
33315 | }
|
33316 | // Export function applyMode(
|
33317 | // _mathfield: MathfieldPrivate,
|
33318 | // _range: Range,
|
33319 | // _mode: ParseMode
|
33320 | // ): boolean {
|
33321 | // const model = mathfield.model;
|
33322 | // There's a mode ('text', 'math', 'command') change
|
33323 | // if (model.selectionIsCollapsed) {
|
33324 | // // Nothing selected
|
33325 | // mathfield.switchMode(mode as ParseMode);
|
33326 | // return
|
33327 | // }
|
33328 | // Convert the selection from one mode to another
|
33329 | // const previousMode = mathfield.mode;
|
33330 | // const targetMode =
|
33331 | // (getMode(model, model.position) ??
|
33332 | // mathfield.options.defaultMode) === 'math'
|
33333 | // ? 'text'
|
33334 | // : 'math';
|
33335 | // let convertedSelection = mathfield.getValue(
|
33336 | // mathfield.selection,
|
33337 | // 'ascii-math'
|
33338 | // );
|
33339 | // if (targetMode === 'math' && /^"[^"]+"$/.test(convertedSelection)) {
|
33340 | // convertedSelection = convertedSelection.slice(1, -1);
|
33341 | // }
|
33342 | // mathfield.insert(convertedSelection, {
|
33343 | // mode: targetMode,
|
33344 | // selectionMode: 'item',
|
33345 | // format: targetMode === 'text' ? 'text' : 'ascii-math',
|
33346 | // });
|
33347 | // mathfield.mode = targetMode;
|
33348 | // const [groupStart, groupEnd] = model.getSiblingsRange(
|
33349 | // model.position
|
33350 | // );
|
33351 | // const first = Math.min(model.anchor, model.position);
|
33352 | // const last = Math.max(model.anchor, model.position);
|
33353 | // if (
|
33354 | // groupStart >= first &&
|
33355 | // groupStart <= last &&
|
33356 | // groupEnd >= first &&
|
33357 | // groupEnd <= last
|
33358 | // ) {
|
33359 | // // The entire group was selected. Adjust parent mode if
|
33360 | // // appropriate
|
33361 | // const parent = model.at(model.position).parent;
|
33362 | // if (
|
33363 | // parent &&
|
33364 | // (parent.type === 'group' || parent.type === 'root')
|
33365 | // ) {
|
33366 | // parent.mode = targetMode;
|
33367 | // }
|
33368 | // }
|
33369 | // // Notify of mode change
|
33370 | // if (
|
33371 | // mathfield.mode !== previousMode &&
|
33372 | // typeof mathfield.options.onModeChange === 'function'
|
33373 | // ) {
|
33374 | // mathfield.options.onModeChange(mathfield, mathfield.mode);
|
33375 | // }
|
33376 | // }
|
33377 | // return false;
|
33378 | // }
|
33379 | /**
|
33380 | * Going backwards from the anchor, if a text zone consisting of a single
|
33381 | * space character is found (i.e. it is surrounded by math zone),
|
33382 | * remove it.
|
33383 | */
|
33384 | function removeIsolatedSpace(model) {
|
33385 | var _a;
|
33386 | let i = model.position - 1;
|
33387 | while (i >= 0 && ((_a = model.at(i)) === null || _a === void 0 ? void 0 : _a.mode) === 'math') {
|
33388 | i -= 1;
|
33389 | }
|
33390 | if (i < 0)
|
33391 | return;
|
33392 | // If the atom before the last one converted is a
|
33393 | // text mode space, preceded by a math mode atom,
|
33394 | // remove the space
|
33395 | if (model.at(i).mode === 'text' &&
|
33396 | model.at(i).value === ' ' &&
|
33397 | model.at(i - 1).mode === 'math') {
|
33398 | model.at(i - 1).parent.removeChild(model.at(i - 1));
|
33399 | contentDidChange(model);
|
33400 | // We need to adjust the selection after doing some surgery on the atoms list
|
33401 | // But we don't want to receive selection notification changes
|
33402 | // which could have a side effect of changing the mode :(
|
33403 | const save = model.suppressChangeNotifications;
|
33404 | model.suppressChangeNotifications = true;
|
33405 | model.position -= 1;
|
33406 | model.suppressChangeNotifications = save;
|
33407 | }
|
33408 | }
|
33409 | /**
|
33410 | * Return the characters before the insertion point that could potentially be
|
33411 | * turned into text mode.
|
33412 | * This excludes things like 'mop' (e.g. \sin)
|
33413 | */
|
33414 | function getTextBeforePosition(model) {
|
33415 | // Going backwards, accumulate
|
33416 | let result = '';
|
33417 | let i = model.position;
|
33418 | let done = false;
|
33419 | while (!done) {
|
33420 | const atom = model.at(i);
|
33421 | done = !(atom &&
|
33422 | (atom.mode === 'text' ||
|
33423 | (atom.mode === 'math' && /mord|textord|mpunct/.test(atom.type))));
|
33424 | if (!done) {
|
33425 | result = atom.value + result;
|
33426 | }
|
33427 | i -= 1;
|
33428 | }
|
33429 | return result;
|
33430 | }
|
33431 | /**
|
33432 | * Consider whether to switch mode give the content before the insertion point
|
33433 | * and the character being input
|
33434 | *
|
33435 | * @param keystroke
|
33436 | * @param evt - a Event corresponding to the keystroke
|
33437 | * @return true if the mode should change
|
33438 | */
|
33439 | function smartMode(mathfield, keystroke, evt) {
|
33440 | if (mathfield.smartModeSuppressed) {
|
33441 | return false;
|
33442 | }
|
33443 | const { model } = mathfield;
|
33444 | // Are we at the end of a group?
|
33445 | if (!model.at(model.position).isLastSibling) {
|
33446 | return false;
|
33447 | }
|
33448 | // Is there an event that would produce a printable char?
|
33449 | // (i.e. not an arrow key, etc...)
|
33450 | if (!evt || !mightProducePrintableCharacter(evt)) {
|
33451 | return false;
|
33452 | }
|
33453 | const c = eventToChar(evt);
|
33454 | if (!model.selectionIsCollapsed) {
|
33455 | // There is a selection
|
33456 | if (mathfield.mode === 'text') {
|
33457 | // If the character is '/' or '_' or '^', switch to 'math'
|
33458 | if (/[/_^]/.test(c)) {
|
33459 | return true;
|
33460 | }
|
33461 | }
|
33462 | return false;
|
33463 | }
|
33464 | const context = getTextBeforePosition(model) + c;
|
33465 | if (mathfield.mode === 'text') {
|
33466 | // We're in text mode. Should we switch to math?
|
33467 | if (keystroke === 'Esc' || /[/\\]/.test(c)) {
|
33468 | // If this is a command for a fraction,
|
33469 | // or the '\' command mode key
|
33470 | // switch to 'math'
|
33471 | return true;
|
33472 | }
|
33473 | if (/[\^_]/.test(c)) {
|
33474 | // If this is a superscript or subscript
|
33475 | // switch to 'math'
|
33476 | if (/(^|\s)[a-zA-Z][^_]$/.test(context)) {
|
33477 | // If left hand context is a single letter,
|
33478 | // convert it to math
|
33479 | convertLastAtomsToMath(model, 1);
|
33480 | }
|
33481 | return true;
|
33482 | }
|
33483 | // If this is a closing matching fence
|
33484 | // switch to 'math' mode
|
33485 | const lFence = { ')': '(', '}': '{', ']': '[' }[c];
|
33486 | const { parent } = model.at(model.position);
|
33487 | if (lFence &&
|
33488 | parent instanceof LeftRightAtom &&
|
33489 | parent.leftDelim === lFence) {
|
33490 | return true;
|
33491 | }
|
33492 | if (/(^|[^a-zA-Z])(a|I) $/.test(context)) {
|
33493 | // Single letters that are valid words in the current language
|
33494 | // Do nothing. @todo: localization
|
33495 | return false;
|
33496 | }
|
33497 | if (/[$€£₤₺¥¤฿¢₡₧₨₹₩₱]/u.test(c)) {
|
33498 | // A currency symbol.
|
33499 | // Switch to math mode
|
33500 | return true;
|
33501 | }
|
33502 | if (/(^|[^a-zA-Z'’])[a-zA-Z] $/.test(context)) {
|
33503 | // An isolated letter, followed by a space:
|
33504 | // Convert the letter to math, stay in text mode.
|
33505 | convertLastAtomsToMath(model, 1);
|
33506 | return false;
|
33507 | }
|
33508 | if (/\D\.[^\d\s]$/.test(context)) {
|
33509 | // A period followed by something other than space or a digit
|
33510 | // and not preceded by a digit.
|
33511 | // We thought this was a text period, but turns out it's not
|
33512 | // Turn it into a \cdot
|
33513 | convertLastAtomsToMath(model, 1);
|
33514 | const atom = model.at(model.position);
|
33515 | atom.value = '⋅'; // Centered dot
|
33516 | atom.style.variant = 'normal'; // @revisit. Was 'auto'. Check for proper conversion.
|
33517 | atom.command = '\\cdot';
|
33518 | atom.verbatimLatex = undefined;
|
33519 | contentDidChange(model);
|
33520 | return true;
|
33521 | }
|
33522 | if (/(^|\s)[a-zA-Z][^a-zA-Z]$/.test(context)) {
|
33523 | // Single letter (x), followed by a non-letter (>, =...)
|
33524 | convertLastAtomsToMath(model, 1);
|
33525 | return true;
|
33526 | }
|
33527 | if (/\.\d$/.test(context)) {
|
33528 | // If the new character is a digit,
|
33529 | // and it was preceded by a dot (which may have been converted
|
33530 | // to text)
|
33531 | // turn the dot back into 'math'
|
33532 | convertLastAtomsToMath(model, 1);
|
33533 | return true;
|
33534 | }
|
33535 | if (/\([\d+\-.]$/.test(context)) {
|
33536 | // An open paren followed by a number
|
33537 | // Turn the paren back to math and switch.
|
33538 | convertLastAtomsToMath(model, 1);
|
33539 | return true;
|
33540 | }
|
33541 | if (/\([a-z][,;]$/.test(context)) {
|
33542 | // An open paren followed by a single letter, then a "," or ";"
|
33543 | // Turn the paren back and letter to math and switch.
|
33544 | convertLastAtomsToMath(model, 2);
|
33545 | return true;
|
33546 | }
|
33547 | // The tests above can look behind and change what had previously
|
33548 | // been entered. Now, let's just look at the typed character.
|
33549 | if (/[\d+\-=><*|]$/.test(c)) {
|
33550 | // If this new character looks like a number,
|
33551 | // or a relational operator (=, <, >)
|
33552 | // or a "*" or "|"
|
33553 | // (note that <=, >=, etc... are handled separately as shortcuts)
|
33554 | // switch to 'math'
|
33555 | removeIsolatedSpace(model);
|
33556 | return true;
|
33557 | }
|
33558 | }
|
33559 | else {
|
33560 | // We're in math mode. Should we switch to text?
|
33561 | if (keystroke === '[Space]') {
|
33562 | convertLastAtomsToText(model, undefined, (a) => /[a-z][:,;.]$/.test(a.value));
|
33563 | return true;
|
33564 | }
|
33565 | if (/[a-zA-Z]{3,}$/.test(context) && !/(dxd|abc|xyz|uvw)$/.test(context)) {
|
33566 | // A sequence of three characters
|
33567 | // (except for some exceptions)
|
33568 | // Convert them to text.
|
33569 | convertLastAtomsToText(model, undefined, (a) => /[a-zA-Z]/.test(a.value));
|
33570 | return true;
|
33571 | }
|
33572 | if (/(^|\W)(if)$/i.test(context)) {
|
33573 | // @todo localization
|
33574 | convertLastAtomsToText(model, 1);
|
33575 | return true;
|
33576 | }
|
33577 | if (/(\u0393|\u0394|\u0398|\u039B|\u039E|\u03A0|\u03A3|\u03A5|\u03A6|\u03A8|\u03A9|[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5){3,}$/u.test(context) &&
|
33578 | !/(αβγ)$/.test(context)) {
|
33579 | // A sequence of three *greek* characters
|
33580 | // (except for one exception)
|
33581 | // Convert them to text.
|
33582 | convertLastAtomsToText(model, undefined, (a) => /(:|,|;|.|\u0393|\u0394|\u0398|\u039B|\u039E|\u03A0|\u03A3|\u03A5|\u03A6|\u03A8|\u03A9|[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5)/u.test(a.value));
|
33583 | return true;
|
33584 | }
|
33585 | if (c === '?') {
|
33586 | // If the last character is a question mark,
|
33587 | // turn it to 'text'
|
33588 | return true;
|
33589 | }
|
33590 | if (c === '.' && !/[\d-+]\.$/.test(context)) {
|
33591 | // A period after something other than a digit (or minus)
|
33592 | return true;
|
33593 | }
|
33594 | }
|
33595 | return false;
|
33596 | }
|
33597 |
|
33598 | class MathModeEditor extends ModeEditor {
|
33599 | constructor() {
|
33600 | super('math');
|
33601 | }
|
33602 | onPaste(mathfield, ev) {
|
33603 | if (!ev.clipboardData)
|
33604 | return false;
|
33605 | let text = '';
|
33606 | let format = 'auto';
|
33607 | // Try to get a MathJSON data type
|
33608 | const json = ev.clipboardData.getData('application/json');
|
33609 | if (json) {
|
33610 | try {
|
33611 | text = oe$1(JSON.parse(json), {});
|
33612 | format = 'latex';
|
33613 | }
|
33614 | catch {
|
33615 | text = '';
|
33616 | }
|
33617 | }
|
33618 | // If that didn't work, try some plain text
|
33619 | if (!text) {
|
33620 | text = ev.clipboardData.getData('text/plain');
|
33621 | }
|
33622 | if (text) {
|
33623 | mathfield.snapshot();
|
33624 | if (this.insert(mathfield.model, text, {
|
33625 | smartFence: mathfield.options.smartFence,
|
33626 | colorMap: mathfield.colorMap,
|
33627 | backgroundColorMap: mathfield.backgroundColorMap,
|
33628 | format,
|
33629 | })) {
|
33630 | requestUpdate(mathfield);
|
33631 | }
|
33632 | ev.preventDefault();
|
33633 | ev.stopPropagation();
|
33634 | }
|
33635 | return true;
|
33636 | }
|
33637 | insert(model, text, options) {
|
33638 | var _a, _b;
|
33639 | if (!options.insertionMode)
|
33640 | options.insertionMode = 'replaceSelection';
|
33641 | if (!options.selectionMode)
|
33642 | options.selectionMode = 'placeholder';
|
33643 | if (!options.format)
|
33644 | options.format = 'auto';
|
33645 | options.macros = (_a = options.macros) !== null && _a !== void 0 ? _a : model.options.macros;
|
33646 | //
|
33647 | // Try to insert a smart fence.
|
33648 | //
|
33649 | if (!((_b = options.smartFence) !== null && _b !== void 0 ? _b : false)) {
|
33650 | // When smartFence is turned off, only do a "smart" fence insert
|
33651 | // if we're inside a `leftright`, at the last char
|
33652 | if (options.insertionMode !== 'replaceAll') {
|
33653 | const { parent } = model.at(model.position);
|
33654 | if (parent instanceof LeftRightAtom &&
|
33655 | parent.rightDelim === '?' &&
|
33656 | model.at(model.position).isLastSibling &&
|
33657 | /^[)}\]|]$/.test(text)) {
|
33658 | parent.rightDelim = text;
|
33659 | model.position += 1;
|
33660 | selectionDidChange(model);
|
33661 | contentDidChange(model);
|
33662 | return true;
|
33663 | }
|
33664 | }
|
33665 | }
|
33666 | else if (model.selectionIsCollapsed &&
|
33667 | insertSmartFence(model, text, options.style)) {
|
33668 | return true;
|
33669 | }
|
33670 | const { suppressChangeNotifications } = model;
|
33671 | if (options.suppressChangeNotifications) {
|
33672 | model.suppressChangeNotifications = true;
|
33673 | }
|
33674 | const contentWasChanging = model.suppressChangeNotifications;
|
33675 | model.suppressChangeNotifications = true;
|
33676 | //
|
33677 | // Save the content of the selection, if any
|
33678 | //
|
33679 | const args = {};
|
33680 | args[0] = model.getValue(model.selection);
|
33681 | args['?'] = '\\placeholder{}';
|
33682 | args['@'] = args['?'];
|
33683 | //
|
33684 | // Delete any selected items
|
33685 | //
|
33686 | if (options.insertionMode === 'replaceSelection' &&
|
33687 | !model.selectionIsCollapsed) {
|
33688 | model.position = model.deleteAtoms(range(model.selection));
|
33689 | }
|
33690 | else if (options.insertionMode === 'replaceAll') {
|
33691 | model.root.setChildren([], 'body');
|
33692 | model.position = 0;
|
33693 | }
|
33694 | else if (options.insertionMode === 'insertBefore') {
|
33695 | model.collapseSelection('backward');
|
33696 | }
|
33697 | else if (options.insertionMode === 'insertAfter') {
|
33698 | model.collapseSelection('forward');
|
33699 | }
|
33700 | //
|
33701 | // Delete any placeholders before or after the insertion point
|
33702 | //
|
33703 | if (!model.at(model.position).isLastSibling &&
|
33704 | model.at(model.position + 1).type === 'placeholder') {
|
33705 | // Before a `placeholder`
|
33706 | model.deleteAtoms([model.position, model.position + 1]);
|
33707 | }
|
33708 | else if (model.at(model.position).type === 'placeholder') {
|
33709 | // After a `placeholder`
|
33710 | model.deleteAtoms([model.position - 1, model.position]);
|
33711 | model.position -= 1;
|
33712 | }
|
33713 | //
|
33714 | // Calculate the implicit argument (#@)
|
33715 | //
|
33716 | if (args[0]) {
|
33717 | // There was a selection, we'll use it for #@
|
33718 | args['@'] = args[0];
|
33719 | }
|
33720 | else if (/(^|[^\\])#@/.test(text)) {
|
33721 | // We'll use the preceding `mord`s or text mode atoms for it (implicit argument)
|
33722 | const offset = getImplicitArgOffset(model);
|
33723 | if (offset >= 0) {
|
33724 | args['@'] = model.getValue(offset, model.position);
|
33725 | model.deleteAtoms([offset, model.position]);
|
33726 | model.position = offset;
|
33727 | }
|
33728 | }
|
33729 | if (!args[0])
|
33730 | args[0] = args['?'];
|
33731 | let usedArg = false;
|
33732 | const argFunction = (arg) => {
|
33733 | usedArg = true;
|
33734 | return args[arg];
|
33735 | };
|
33736 | const [format, newAtoms] = convertStringToAtoms$1(model, text, argFunction, options);
|
33737 | if (!newAtoms)
|
33738 | return false;
|
33739 | const placeholdersFound = findPlaceholders(newAtoms);
|
33740 | const newPlaceholders = placeholdersFound.filter((atom) => atom.placeholderId &&
|
33741 | !model.mathfield._placeholders.has(atom.placeholderId));
|
33742 | const idsFound = placeholdersFound.map((atom) => atom.placeholderId);
|
33743 | const removedPlaceholder = [...model.mathfield._placeholders.keys()].filter((placeholderId) => !idsFound.includes(placeholderId));
|
33744 | removedPlaceholder.forEach((placeholderId) => {
|
33745 | var _a;
|
33746 | if (model.mathfield._placeholders.has(placeholderId)) {
|
33747 | (_a = model.mathfield._placeholders.get(placeholderId)) === null || _a === void 0 ? void 0 : _a.field.remove();
|
33748 | model.mathfield._placeholders.delete(placeholderId);
|
33749 | }
|
33750 | });
|
33751 | newPlaceholders.forEach((placeholder) => {
|
33752 | var _a, _b;
|
33753 | if (placeholder.placeholderId &&
|
33754 | !model.mathfield._placeholders.has(placeholder.placeholderId)) {
|
33755 | const element = new MathfieldElement({
|
33756 | virtualKeyboardMode: 'onfocus',
|
33757 | readOnly: false,
|
33758 | fontsDirectory: model.mathfield.options.fontsDirectory,
|
33759 | });
|
33760 | const container = (_a = model.mathfield.element) === null || _a === void 0 ? void 0 : _a.querySelector('.ML__placeholdercontainer');
|
33761 | element.value = ((_b = placeholder.defaultValue) === null || _b === void 0 ? void 0 : _b.length)
|
33762 | ? Atom.serialize(placeholder.defaultValue, { defaultMode: 'text' })
|
33763 | : '';
|
33764 | element.classList.add('nested-mathfield');
|
33765 | element.style.display = 'inline-block';
|
33766 | element.style.zIndex = '1001';
|
33767 | element.style.position = 'absolute';
|
33768 | element.style.minWidth = '30px';
|
33769 | const style = document.createElement('style');
|
33770 | style.innerHTML = `.nested-mathfield {
|
33771 | border: 1px solid black;
|
33772 | }
|
33773 | .ML__fieldcontainer{
|
33774 | min-height:auto !important;
|
33775 | }
|
33776 |
|
33777 | `;
|
33778 | element.appendChild(style);
|
33779 | element.addEventListener('input', () => {
|
33780 | placeholderDidChange(model, placeholder.placeholderId);
|
33781 | /**
|
33782 | * this timeout give some time when is a placeholder to render properly
|
33783 | * before rendering the main field.
|
33784 | */
|
33785 | setTimeout(() => {
|
33786 | requestUpdate(model.mathfield);
|
33787 | });
|
33788 | });
|
33789 | container === null || container === void 0 ? void 0 : container.appendChild(element);
|
33790 | model.mathfield._placeholders.set(placeholder.placeholderId, {
|
33791 | atom: placeholder,
|
33792 | field: element,
|
33793 | });
|
33794 | }
|
33795 | });
|
33796 | //
|
33797 | // Insert the new atoms
|
33798 | //
|
33799 | const { parent } = model.at(model.position);
|
33800 | // Are we inserting a fraction inside a lefright?
|
33801 | if (format !== 'latex' &&
|
33802 | model.options.removeExtraneousParentheses &&
|
33803 | parent instanceof LeftRightAtom &&
|
33804 | parent.leftDelim === '(' &&
|
33805 | parent.hasEmptyBranch('body') &&
|
33806 | newAtoms.length === 1 &&
|
33807 | newAtoms[0].type === 'genfrac') {
|
33808 | // Remove the leftright
|
33809 | // i.e. `\left(\frac{}{}\right))` -> `\frac{}{}`
|
33810 | const newParent = parent.parent;
|
33811 | const branch = parent.treeBranch;
|
33812 | newParent.removeChild(parent);
|
33813 | newParent.setChildren(newAtoms, branch);
|
33814 | }
|
33815 | const hadEmptyBody = parent.hasEmptyBranch('body');
|
33816 | const cursor = model.at(model.position);
|
33817 | cursor.parent.addChildrenAfter(newAtoms, cursor);
|
33818 | if (format === 'latex') {
|
33819 | // If we are given a latex string with no arguments, store it as
|
33820 | // "verbatim latex".
|
33821 | // Caution: we can only do this if the `serialize()` for this parent
|
33822 | // would return an empty string. If the latex is generated using other
|
33823 | // properties than parent.body, for example by adding '\left.' and
|
33824 | // '\right.' with a 'leftright' type, we can't use this shortcut.
|
33825 | if (parent.type === 'root' && hadEmptyBody && !usedArg) {
|
33826 | parent.verbatimLatex = text;
|
33827 | }
|
33828 | }
|
33829 | // Prepare to dispatch notifications
|
33830 | // (for selection changes, then content change)
|
33831 | model.suppressChangeNotifications = contentWasChanging;
|
33832 | const lastNewAtom = newAtoms[newAtoms.length - 1];
|
33833 | // Update the anchor's location
|
33834 | if (options.selectionMode === 'placeholder') {
|
33835 | // Move to the next placeholder
|
33836 | const newPlaceholders = newAtoms.reduce((acc, atom) => [
|
33837 | ...acc,
|
33838 | ...atom.children.filter((x) => x.type === 'placeholder'),
|
33839 | ], []);
|
33840 | if (newPlaceholders.length > 0) {
|
33841 | const placeholderOffset = model.offsetOf(newPlaceholders[0]);
|
33842 | model.setSelection(placeholderOffset - 1, placeholderOffset);
|
33843 | model.announce('move'); // Should have placeholder selected
|
33844 | }
|
33845 | else if (lastNewAtom) {
|
33846 | // No placeholder found, move to right after what we just inserted
|
33847 | model.position = model.offsetOf(lastNewAtom);
|
33848 | }
|
33849 | }
|
33850 | else if (options.selectionMode === 'before') ;
|
33851 | else if (options.selectionMode === 'after') {
|
33852 | if (lastNewAtom) {
|
33853 | model.position = model.offsetOf(lastNewAtom);
|
33854 | }
|
33855 | }
|
33856 | else if (options.selectionMode === 'item') {
|
33857 | model.setSelection(model.anchor, model.offsetOf(lastNewAtom));
|
33858 | }
|
33859 | contentDidChange(model);
|
33860 | model.suppressChangeNotifications = suppressChangeNotifications;
|
33861 | return true;
|
33862 | }
|
33863 | }
|
33864 | function convertStringToAtoms$1(model, s, args, options) {
|
33865 | let format = undefined;
|
33866 | let result = [];
|
33867 | if (options.format === 'ascii-math') {
|
33868 | [format, s] = parseMathString(s, {
|
33869 | format: 'ascii-math',
|
33870 | inlineShortcuts: model.mathfield.options.inlineShortcuts,
|
33871 | });
|
33872 | result = parseLatex(s, {
|
33873 | parseMode: 'math',
|
33874 | macros: options === null || options === void 0 ? void 0 : options.macros,
|
33875 | onError: model.listeners.onError,
|
33876 | colorMap: options.colorMap,
|
33877 | backgroundColorMap: options.backgroundColorMap,
|
33878 | });
|
33879 | // Simplify result.
|
33880 | if (format !== 'latex' && model.options.removeExtraneousParentheses) {
|
33881 | simplifyParen(result);
|
33882 | }
|
33883 | }
|
33884 | else if (options.format === 'auto' || options.format === 'latex') {
|
33885 | if (options.format === 'auto') {
|
33886 | [format, s] = parseMathString(s, {
|
33887 | format: 'auto',
|
33888 | inlineShortcuts: model.mathfield.options.inlineShortcuts,
|
33889 | });
|
33890 | }
|
33891 | // If the whole string is bracketed by a mode shift command, remove it
|
33892 | if (options.format === 'latex')
|
33893 | [, s] = trimModeShiftCommand(s);
|
33894 | result = parseLatex(s, {
|
33895 | parseMode: 'math',
|
33896 | args: args,
|
33897 | macros: options.macros,
|
33898 | smartFence: options.smartFence,
|
33899 | onError: model.listeners.onError,
|
33900 | colorMap: options.colorMap,
|
33901 | backgroundColorMap: options.backgroundColorMap,
|
33902 | });
|
33903 | // Simplify result.
|
33904 | if (options.format !== 'latex' &&
|
33905 | model.options.removeExtraneousParentheses) {
|
33906 | simplifyParen(result);
|
33907 | }
|
33908 | }
|
33909 | //
|
33910 | // Some atoms may already have a style (for example if there was an
|
33911 | // argument, i.e. the selection, that this was applied to).
|
33912 | // So, don't apply style to atoms that are already styled, but *do*
|
33913 | // apply it to newly created atoms that have no style yet.
|
33914 | //
|
33915 | applyStyleToUnstyledAtoms(result, options.style);
|
33916 | return [format !== null && format !== void 0 ? format : 'latex', result];
|
33917 | }
|
33918 | function removeParen(atoms) {
|
33919 | if (!atoms)
|
33920 | return null;
|
33921 | console.assert(atoms[0].type === 'first');
|
33922 | if (atoms.length > 1)
|
33923 | return null;
|
33924 | const atom = atoms[0];
|
33925 | if (atom instanceof LeftRightAtom &&
|
33926 | atom.leftDelim === '(' &&
|
33927 | atom.rightDelim === ')') {
|
33928 | return atom.removeBranch('body');
|
33929 | }
|
33930 | return null;
|
33931 | }
|
33932 | /**
|
33933 | * If it's a fraction with a parenthesized numerator or denominator
|
33934 | * remove the parentheses
|
33935 | * @revisit: don't need model, only need to know if removeExtraneousParentheses
|
33936 | * Check at callsites.
|
33937 | */
|
33938 | function simplifyParen(atoms) {
|
33939 | if (!atoms)
|
33940 | return;
|
33941 | for (let i = 0; atoms[i]; i++) {
|
33942 | const atom = atoms[i];
|
33943 | if (atom instanceof LeftRightAtom && atom.leftDelim === '(') {
|
33944 | let genFracCount = 0;
|
33945 | let genFracIndex = 0;
|
33946 | let nonGenFracCount = 0;
|
33947 | for (let j = 0; atom.body[j]; j++) {
|
33948 | if (atom.body[j].type === 'genfrac') {
|
33949 | genFracCount++;
|
33950 | genFracIndex = j;
|
33951 | }
|
33952 | nonGenFracCount++;
|
33953 | }
|
33954 | if (nonGenFracCount === 0 && genFracCount === 1) {
|
33955 | // This is a single frac inside a leftright: remove the leftright
|
33956 | atoms[i] = atom.body[genFracIndex];
|
33957 | }
|
33958 | }
|
33959 | }
|
33960 | for (const atom of atoms) {
|
33961 | for (const branch of atom.branches) {
|
33962 | if (!atom.hasEmptyBranch(branch)) {
|
33963 | simplifyParen(atom.branch(branch));
|
33964 | const newChildren = removeParen(atom.branch(branch));
|
33965 | if (newChildren)
|
33966 | atom.setChildren(newChildren, branch);
|
33967 | }
|
33968 | }
|
33969 | if (atom instanceof ArrayAtom) {
|
33970 | for (const x of atom.cells)
|
33971 | simplifyParen(x);
|
33972 | }
|
33973 | }
|
33974 | }
|
33975 | function findPlaceholders(atoms) {
|
33976 | if (!atoms)
|
33977 | return [];
|
33978 | let result = [];
|
33979 | for (const atom of atoms) {
|
33980 | for (const branch of atom.branches) {
|
33981 | if (!atom.hasEmptyBranch(branch)) {
|
33982 | const branchPlaceholder = findPlaceholders(atom.branch(branch));
|
33983 | result = result.concat(branchPlaceholder);
|
33984 | }
|
33985 | }
|
33986 | if (atom instanceof PlaceholderAtom) {
|
33987 | result.push(atom);
|
33988 | }
|
33989 | }
|
33990 | return result;
|
33991 | }
|
33992 | /**
|
33993 | * Locate the offset before the insertion point that would indicate
|
33994 | * a good place to select as an implicit argument.
|
33995 | *
|
33996 | * For example with '1+\sin(x)', if the insertion point is at the
|
33997 | * end, the implicit arg offset would be after the plus. As a result,
|
33998 | * inserting a fraction after the sin would yield: '1+\frac{\sin(c)}{\placeholder{}}'
|
33999 | */
|
34000 | function getImplicitArgOffset(model) {
|
34001 | let atom = model.at(model.position);
|
34002 | if (atom.mode === 'text') {
|
34003 | while (!atom.isFirstSibling && atom.mode === 'text') {
|
34004 | atom = atom.leftSibling;
|
34005 | }
|
34006 | return model.offsetOf(atom);
|
34007 | }
|
34008 | if (!isImplicitArg(atom)) {
|
34009 | return -1;
|
34010 | }
|
34011 | // Find the first 'mrel', etc... to the left of the insertion point
|
34012 | // until the first sibling
|
34013 | while (!atom.isFirstSibling && isImplicitArg(atom)) {
|
34014 | atom = atom.leftSibling;
|
34015 | }
|
34016 | return model.offsetOf(atom);
|
34017 | }
|
34018 | /**
|
34019 | *
|
34020 | * Predicate returns true if the atom should be considered an implicit argument.
|
34021 | *
|
34022 | * Used for example when typing "/" to insert a fraction: all the atoms to
|
34023 | * the left of insertion point that return true for `isImplicitArg()` will
|
34024 | * be included as the numerator
|
34025 | */
|
34026 | function isImplicitArg(atom) {
|
34027 | if (/^(mord|surd|msubsup|leftright|mop)$/.test(atom.type)) {
|
34028 | // Exclude `\int`, \`sum`, etc...
|
34029 | if (atom.isExtensibleSymbol)
|
34030 | return false;
|
34031 | return true;
|
34032 | }
|
34033 | return false;
|
34034 | }
|
34035 | /**
|
34036 | * Insert a smart fence '(', '{', '[', etc...
|
34037 | * If not handled (because `fence` wasn't a fence), return false.
|
34038 | */
|
34039 | function insertSmartFence(model, fence, style) {
|
34040 | console.assert(model.selectionIsCollapsed);
|
34041 | const atom = model.at(model.position);
|
34042 | const { parent } = atom;
|
34043 | let delims = parent instanceof LeftRightAtom
|
34044 | ? parent.leftDelim + parent.rightDelim
|
34045 | : '';
|
34046 | if (delims === '\\lbrace\\rbrace')
|
34047 | delims = '{}';
|
34048 | if (delims === '\\{\\}')
|
34049 | delims = '{}';
|
34050 | if (delims === '\\lparen\\rparen')
|
34051 | delims = '()';
|
34052 | //
|
34053 | // 1. Are we inserting a middle fence?
|
34054 | // ...as in {...|...}
|
34055 | //
|
34056 | if (delims === '{}' && /\||\\vert|\\Vert|\\mvert|\\mid/.test(fence)) {
|
34057 | ModeEditor.insert('math', model, '\\,\\middle' + fence + '\\, ', {
|
34058 | format: 'latex',
|
34059 | style,
|
34060 | });
|
34061 | return true;
|
34062 | }
|
34063 | // Normalize some fences.
|
34064 | // Note that '{' and '}' are not valid braces.
|
34065 | // They should be '\{' or '\lbrace' and '\}' or '\rbrace'
|
34066 | if (fence === '{' || fence === '\\{')
|
34067 | fence = '\\lbrace';
|
34068 | if (fence === '}' || fence === '\\}')
|
34069 | fence = '\\rbrace';
|
34070 | if (fence === '[')
|
34071 | fence = '\\lbrack';
|
34072 | if (fence === ']')
|
34073 | fence = '\\rbrack';
|
34074 | //
|
34075 | // 2. Is it an open fence?
|
34076 | //
|
34077 | const rDelim = RIGHT_DELIM[fence];
|
34078 | if (rDelim &&
|
34079 | !(parent instanceof LeftRightAtom && parent.leftDelim === '|')) {
|
34080 | // We have a valid open fence as input
|
34081 | let s = '';
|
34082 | // If we're before a function (e.g. `\sin`, or 'f'): this is an
|
34083 | // argument list: Use `\mleft...\mright'.
|
34084 | s = atom.isFunction
|
34085 | ? `\\mleft${fence}\\mright${rDelim}`
|
34086 | : `\\left${fence}\\right?`;
|
34087 | const lastSiblingOffset = model.offsetOf(atom.lastSibling);
|
34088 | const content = model.extractAtoms([model.position, lastSiblingOffset]);
|
34089 | ModeEditor.insert('math', model, s, {
|
34090 | format: 'latex',
|
34091 | style,
|
34092 | });
|
34093 | // Move everything that was after the anchor into the leftright
|
34094 | model.at(model.position).body = content;
|
34095 | model.position -= 1;
|
34096 | return true;
|
34097 | }
|
34098 | //
|
34099 | // 3. Is it a close fence?
|
34100 | //
|
34101 | let lDelim = '';
|
34102 | Object.keys(RIGHT_DELIM).forEach((delim) => {
|
34103 | if (fence === RIGHT_DELIM[delim])
|
34104 | lDelim = delim;
|
34105 | });
|
34106 | if (lDelim) {
|
34107 | // We found a matching open fence, so it was a valid close fence.
|
34108 | // Note that `lDelim` may not match `fence`. That's OK.
|
34109 | // If we're the last atom inside a 'leftright',
|
34110 | // update the parent
|
34111 | if (parent instanceof LeftRightAtom && atom.isLastSibling) {
|
34112 | parent.rightDelim = fence;
|
34113 | model.position += 1;
|
34114 | contentDidChange(model);
|
34115 | return true;
|
34116 | }
|
34117 | // If we have a `leftright` sibling to our left
|
34118 | // with an indeterminate right fence,
|
34119 | // move what's between us and the `leftright` inside the `leftright`
|
34120 | const firstSibling = model.offsetOf(atom.firstSibling);
|
34121 | let i;
|
34122 | for (i = model.position; i >= firstSibling; i--) {
|
34123 | const atom = model.at(i);
|
34124 | if (atom instanceof LeftRightAtom && atom.rightDelim === '?') {
|
34125 | break;
|
34126 | }
|
34127 | }
|
34128 | const match = model.at(i);
|
34129 | if (i >= firstSibling && match instanceof LeftRightAtom) {
|
34130 | match.rightDelim = fence;
|
34131 | match.addChildren(model.extractAtoms([i, model.position]), atom.treeBranch);
|
34132 | model.position = i;
|
34133 | contentDidChange(model);
|
34134 | return true;
|
34135 | }
|
34136 | // If we're inside a `leftright`, but not the last atom,
|
34137 | // and the `leftright` right delim is indeterminate
|
34138 | // adjust the body (put everything after the insertion point outside)
|
34139 | if (parent instanceof LeftRightAtom && parent.rightDelim === '?') {
|
34140 | parent.rightDelim = fence;
|
34141 | parent.parent.addChildren(model.extractAtoms([model.position, model.offsetOf(atom.lastSibling)]), parent.treeBranch);
|
34142 | model.position = model.offsetOf(parent);
|
34143 | contentDidChange(model);
|
34144 | return true;
|
34145 | }
|
34146 | // Is our grand-parent a 'leftright'?
|
34147 | // If `\left(\frac{1}{x|}\right?` with the cursor at `|`
|
34148 | // go up to the 'leftright' and apply it there instead
|
34149 | const grandparent = parent.parent;
|
34150 | if (grandparent instanceof LeftRightAtom &&
|
34151 | grandparent.rightDelim === '?' &&
|
34152 | model.at(model.position).isLastSibling) {
|
34153 | model.position = model.offsetOf(grandparent);
|
34154 | return insertSmartFence(model, fence, style);
|
34155 | }
|
34156 | // Meh... We couldn't find a matching open fence. Just insert the
|
34157 | // closing fence as a regular character
|
34158 | return false;
|
34159 | }
|
34160 | return false;
|
34161 | }
|
34162 | new MathModeEditor();
|
34163 |
|
34164 | var css_248z$1 = "#mathlive-keystroke-caption-panel{--keystroke:#fff;--on-keystroke:#555;--keystroke-border:#f7f7f7;background:var(--secondary,hsl(var(--hue,212),19%,26%));border-color:var(--secondary-border,#e8e8e8);border-radius:6px;box-shadow:0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23);display:flex;flex-direction:row-reverse;justify-content:center;padding:16px;position:absolute;text-align:center;visibility:hidden;z-index:1}@media (prefers-color-scheme:dark){body:not([theme=light]) #mathlive-keystroke-caption-panel{--keystroke:hsl(var(--hue,212),50%,30%);--on-keystroke:#fafafa;--keystroke-border:hsl(var(--hue,212),50%,25%)}}body[theme=dark] #mathlive-keystroke-caption-panel{--keystroke:hsl(var(--hue,212),50%,30%);--on-keystroke:#fafafa;--keystroke-border:hsl(var(--hue,212),50%,25%)}#mathlive-keystroke-caption-panel>span{fill:currentColor;background-color:var(--keystroke);border:2px solid var(--keystroke-border);border-radius:6px;color:var(--on-keystroke);font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:1em;margin:0 8px 0 0;min-width:14px;padding:4px}";
|
34165 |
|
34166 | let KEYSTROKE_CAPTION_STYLESHEET_HASH = undefined;
|
34167 | let gKeystrokeCaptionStylesheet = null;
|
34168 | let gCoreStylesheet = null;
|
34169 | function showKeystroke(mathfield, keystroke) {
|
34170 | if (mathfield.options.readOnly || !mathfield.keystrokeCaptionVisible)
|
34171 | return;
|
34172 | const vb = createKeystrokeCaption(mathfield);
|
34173 | const bounds = mathfield.element.getBoundingClientRect();
|
34174 | vb.style.left = `${bounds.left}px`;
|
34175 | vb.style.top = `${bounds.top - 64}px`;
|
34176 | vb.innerHTML = mathfield.options.createHTML('<span>' +
|
34177 | (getKeybindingMarkup(keystroke) || keystroke) +
|
34178 | '</span>' +
|
34179 | vb.innerHTML);
|
34180 | vb.style.visibility = 'visible';
|
34181 | setTimeout(() => {
|
34182 | if (vb.childNodes.length > 0) {
|
34183 | vb.childNodes[vb.childNodes.length - 1].remove();
|
34184 | }
|
34185 | if (vb.childNodes.length === 0) {
|
34186 | vb.style.visibility = 'hidden';
|
34187 | }
|
34188 | }, 3000);
|
34189 | }
|
34190 | function toggleKeystrokeCaption(mathfield) {
|
34191 | mathfield.keystrokeCaptionVisible = !mathfield.keystrokeCaptionVisible;
|
34192 | if (!mathfield.keystrokeCaptionVisible) {
|
34193 | if (mathfield.keystrokeCaption) {
|
34194 | mathfield.keystrokeCaption.style.visibility = 'hidden';
|
34195 | }
|
34196 | }
|
34197 | else {
|
34198 | mathfield.keystrokeCaption = createKeystrokeCaption(mathfield);
|
34199 | mathfield.keystrokeCaption.innerHTML = '';
|
34200 | }
|
34201 | return false;
|
34202 | }
|
34203 | function createKeystrokeCaption(mf) {
|
34204 | if (mf.keystrokeCaption)
|
34205 | return mf.keystrokeCaption;
|
34206 | mf.keystrokeCaption = getSharedElement('mathlive-keystroke-caption-panel');
|
34207 | if (KEYSTROKE_CAPTION_STYLESHEET_HASH === undefined) {
|
34208 | KEYSTROKE_CAPTION_STYLESHEET_HASH = hashCode(css_248z$1).toString(36);
|
34209 | }
|
34210 | gKeystrokeCaptionStylesheet = inject(null, css_248z$1, KEYSTROKE_CAPTION_STYLESHEET_HASH);
|
34211 | gCoreStylesheet = inject(null, css_248z$4, hashCode(css_248z$4).toString(36));
|
34212 | return mf.keystrokeCaption;
|
34213 | }
|
34214 | function disposeKeystrokeCaption(mf) {
|
34215 | releaseSharedElement(mf.keystrokeCaption);
|
34216 | if (gKeystrokeCaptionStylesheet)
|
34217 | gKeystrokeCaptionStylesheet.release();
|
34218 | if (gCoreStylesheet)
|
34219 | gCoreStylesheet.release();
|
34220 | delete mf.keystrokeCaption;
|
34221 | }
|
34222 |
|
34223 | /**
|
34224 | * @param evt - An Event corresponding to the keystroke.
|
34225 | */
|
34226 | function onKeystroke(mathfield, keystroke, evt) {
|
34227 | const { model } = mathfield;
|
34228 | // 1. Update the keybindings according to the current keyboard layout
|
34229 | // 1.1 Possibly update the current keyboard layout based on this event
|
34230 | validateKeyboardLayout(evt);
|
34231 | const activeLayout = getActiveKeyboardLayout();
|
34232 | if (mathfield.keyboardLayout !== activeLayout.id) {
|
34233 | // console.log('Switching to keyboard layout ' + activeLayout.id);
|
34234 | mathfield.keyboardLayout = activeLayout.id;
|
34235 | mathfield._keybindings = undefined;
|
34236 | }
|
34237 | // 2. Display the keystroke in the keystroke panel (if visible)
|
34238 | showKeystroke(mathfield, keystroke);
|
34239 | // 3. Reset the timer for the keystroke buffer reset
|
34240 | clearTimeout(mathfield.keystrokeBufferResetTimer);
|
34241 | // 4. Give a chance to the custom keystroke handler to intercept the event
|
34242 | if (!mathfield.options.readOnly &&
|
34243 | mathfield.options.onKeystroke &&
|
34244 | !mathfield.options.onKeystroke(mathfield, keystroke, evt)) {
|
34245 | if (evt === null || evt === void 0 ? void 0 : evt.preventDefault) {
|
34246 | evt.preventDefault();
|
34247 | evt.stopPropagation();
|
34248 | }
|
34249 | return false;
|
34250 | }
|
34251 | // 5. Let's try to find a matching shortcut or command
|
34252 | let shortcut;
|
34253 | let stateIndex;
|
34254 | let selector = '';
|
34255 | let resetKeystrokeBuffer = false;
|
34256 | // 5.1 Check if the keystroke, prefixed with the previously typed keystrokes,
|
34257 | // would match a long shortcut (i.e. '~~')
|
34258 | // Ignore the key if command or control is pressed (it may be a keybinding,
|
34259 | // see 5.3)
|
34260 | if (mathfield.mode !== 'latex' && (!evt || (!evt.ctrlKey && !evt.metaKey))) {
|
34261 | if (keystroke === '[Backspace]') {
|
34262 | // Special case for backspace
|
34263 | mathfield.keystrokeBuffer = mathfield.keystrokeBuffer.slice(0, -1);
|
34264 | mathfield.keystrokeBufferStates.pop();
|
34265 | mathfield.resetKeystrokeBuffer({ defer: true });
|
34266 | }
|
34267 | else if (evt && !mightProducePrintableCharacter(evt)) {
|
34268 | // It was a non-alpha character (PageUp, End, etc...)
|
34269 | mathfield.resetKeystrokeBuffer();
|
34270 | }
|
34271 | else {
|
34272 | const c = eventToChar(evt);
|
34273 | // Find the longest substring that matches a shortcut
|
34274 | const candidate = mathfield.keystrokeBuffer + c;
|
34275 | let i = 0;
|
34276 | while (!shortcut && i < candidate.length) {
|
34277 | const context = mathfield.keystrokeBufferStates[i]
|
34278 | ? parseLatex(mathfield.keystrokeBufferStates[i].latex, {
|
34279 | parseMode: effectiveMode(mathfield.options),
|
34280 | macros: mathfield.options.macros,
|
34281 | })
|
34282 | : // The context is from the start of the group to the current position
|
34283 | model.getAtoms(model.offsetOf(model.at(model.position).firstSibling), model.position);
|
34284 | shortcut = getInlineShortcut(context, candidate.slice(i), mathfield.options.inlineShortcuts);
|
34285 | i += 1;
|
34286 | }
|
34287 | stateIndex =
|
34288 | mathfield.keystrokeBufferStates.length - (candidate.length - i);
|
34289 | mathfield.keystrokeBuffer += c;
|
34290 | mathfield.keystrokeBufferStates.push(mathfield.getUndoRecord());
|
34291 | if (getInlineShortcutsStartingWith(candidate, mathfield.options).length <= 1) {
|
34292 | // There's only a single shortcut matching this sequence.
|
34293 | // We can confidently reset the keystroke buffer
|
34294 | resetKeystrokeBuffer = true;
|
34295 | }
|
34296 | else {
|
34297 | // There are several potential shortcuts matching this sequence
|
34298 | // Don't reset the keystroke buffer yet, in case some
|
34299 | // keys typed later disambiguate the desirted shortcut,
|
34300 | // but schedule a defered reset. This handles the case if there
|
34301 | // was a shortcut for "sin" and "sinh", to avoid the detecting
|
34302 | // of the "sin" shortcut from ever having the "sinh" shortcut
|
34303 | // triggered.
|
34304 | mathfield.resetKeystrokeBuffer({ defer: true });
|
34305 | }
|
34306 | }
|
34307 | }
|
34308 | // 5.2. Should we switch mode?
|
34309 | // Need to check this before determing if there's a valid shortcut
|
34310 | // since if we switch to math mode, we may want to apply the shortcut
|
34311 | // e.g. "slope = rise/run"
|
34312 | if (mathfield.options.smartMode) {
|
34313 | const previousMode = mathfield.mode;
|
34314 | if (shortcut) {
|
34315 | // If we found a shortcut (e.g. "alpha"),
|
34316 | // switch to math mode and insert it
|
34317 | mathfield.mode = 'math';
|
34318 | }
|
34319 | else if (smartMode(mathfield, keystroke, evt)) {
|
34320 | mathfield.mode = { math: 'text', text: 'math' }[mathfield.mode];
|
34321 | selector = '';
|
34322 | }
|
34323 | // Notify of mode change
|
34324 | if (mathfield.mode !== previousMode &&
|
34325 | typeof mathfield.options.onModeChange === 'function') {
|
34326 | mathfield.options.onModeChange(mathfield, mathfield.mode);
|
34327 | }
|
34328 | }
|
34329 | // 5.3 Check if this matches a keybinding
|
34330 | // Need to check this **after** checking for inline shortcuts because
|
34331 | // shift+backquote is a keybinding that inserts "\~"", but "~~" is a
|
34332 | // shortcut for "\approx" and needs to have priority over shift+backquote
|
34333 | if (!shortcut && !selector) {
|
34334 | selector = getCommandForKeybinding(mathfield.keybindings, mathfield.mode, keystroke);
|
34335 | }
|
34336 | if (!shortcut &&
|
34337 | !selector &&
|
34338 | (keystroke === '[Enter]' || keystroke === '[Return]')) {
|
34339 | // No matching keybinding: trigger a commit
|
34340 | if (typeof mathfield.options.onCommit === 'function') {
|
34341 | mathfield.options.onCommit(mathfield);
|
34342 | if (evt === null || evt === void 0 ? void 0 : evt.preventDefault) {
|
34343 | evt.preventDefault();
|
34344 | evt.stopPropagation();
|
34345 | }
|
34346 | return false;
|
34347 | }
|
34348 | }
|
34349 | // No shortcut :( We're done.
|
34350 | if (!shortcut && !selector) {
|
34351 | return true;
|
34352 | }
|
34353 | //
|
34354 | // 6. Perform the action matching this selector or insert the shortcut
|
34355 | //
|
34356 | //
|
34357 | // 6.1 If we have a `moveAfterParent` selector (usually triggered with
|
34358 | // `spacebar), and we're at the end of a smart fence, close the fence with
|
34359 | // an empty (.) right delimiter
|
34360 | //
|
34361 | const child = model.at(Math.max(model.position, model.anchor));
|
34362 | const { parent } = child;
|
34363 | if (selector === 'moveAfterParent' &&
|
34364 | parent &&
|
34365 | parent.type === 'leftright' &&
|
34366 | child.isLastSibling &&
|
34367 | mathfield.options.smartFence &&
|
34368 | insertSmartFence(model, '.', mathfield.style)) {
|
34369 | // Pressing the space bar (moveAfterParent selector) when at the end
|
34370 | // of a potential smartFence will close it as a semi-open fence
|
34371 | selector = '';
|
34372 | requestUpdate(mathfield); // Re-render the closed smartFence
|
34373 | }
|
34374 | //
|
34375 | // 6.2 If this is the Space bar and we're just before or right after
|
34376 | // a text zone, or if `mathModeSpace` is enabled, insert the space
|
34377 | //
|
34378 | if (mathfield.mode === 'math' && keystroke === '[Space]' && !shortcut) {
|
34379 | if (mathfield.options.mathModeSpace) {
|
34380 | mathfield.snapshot();
|
34381 | ModeEditor.insert('math', model, mathfield.options.mathModeSpace);
|
34382 | selector = '';
|
34383 | mathfield.dirty = true;
|
34384 | }
|
34385 | else {
|
34386 | const nextSibling = model.at(model.position + 1);
|
34387 | const previousSibling = model.at(model.position - 1);
|
34388 | if ((nextSibling && nextSibling.mode === 'text') ||
|
34389 | (previousSibling && previousSibling.mode === 'text')) {
|
34390 | mathfield.snapshot();
|
34391 | ModeEditor.insert('text', model, ' ');
|
34392 | mathfield.dirty = true;
|
34393 | }
|
34394 | }
|
34395 | }
|
34396 | //
|
34397 | // 6.3 If there's a selector, perform it.
|
34398 | //
|
34399 | if (selector) {
|
34400 | mathfield.executeCommand(selector);
|
34401 | }
|
34402 | else if (shortcut) {
|
34403 | //
|
34404 | // 6.5 Cancel the (upcoming) composition
|
34405 | // This is to prevent starting a composition when the keyboard event
|
34406 | // has already been handled.
|
34407 | // Example: alt+U -> \cup, but could also be diaeresis deak key (¨) which
|
34408 | // starts a composition
|
34409 | //
|
34410 | mathfield.keyboardDelegate.cancelComposition();
|
34411 | //
|
34412 | // 6.6 Insert the shortcut
|
34413 | // If the shortcut is a mandatory escape sequence (\}, etc...)
|
34414 | // don't make it undoable, this would result in syntactically incorrect
|
34415 | // formulas
|
34416 | //
|
34417 | const style = {
|
34418 | ...model.at(model.position).computedStyle,
|
34419 | ...mathfield.style,
|
34420 | };
|
34421 | if (!/^(\\{|\\}|\\[|\\]|\\@|\\#|\\$|\\%|\\^|\\_|\\backslash)$/.test(shortcut)) {
|
34422 | // To enable the substitution to be undoable,
|
34423 | // insert the character before applying the substitution
|
34424 | const saveMode = mathfield.mode;
|
34425 | ModeEditor.insert(mathfield.mode, model, eventToChar(evt), {
|
34426 | suppressChangeNotifications: true,
|
34427 | style,
|
34428 | });
|
34429 | // Create a snapshot with the inserted character
|
34430 | mathfield.snapshot();
|
34431 | // Revert to the state before the beginning of the shortcut
|
34432 | // (restore doesn't change the undo stack)
|
34433 | mathfield.restoreToUndoRecord(mathfield.keystrokeBufferStates[stateIndex]);
|
34434 | mathfield.mode = saveMode;
|
34435 | }
|
34436 | model.deferNotifications({ content: true, selection: true }, () => {
|
34437 | // Insert the substitute, possibly as a smart fence
|
34438 | ModeEditor.insert(mathfield.mode, model, shortcut, {
|
34439 | format: 'latex',
|
34440 | style,
|
34441 | smartFence: true,
|
34442 | });
|
34443 | // Check if as a result of the substitution there is now an isolated
|
34444 | // (text mode) space (surrounded by math). In which case, remove it.
|
34445 | removeIsolatedSpace(mathfield.model);
|
34446 | // Switch (back) to text mode if the shortcut ended with a space
|
34447 | if (shortcut.endsWith(' ')) {
|
34448 | mathfield.mode = 'text';
|
34449 | ModeEditor.insert('text', model, ' ', { style });
|
34450 | }
|
34451 | return true; // Content changed
|
34452 | });
|
34453 | mathfield.snapshot();
|
34454 | mathfield.dirty = true; // Mark the field as dirty. It will get rendered in scrollIntoView()
|
34455 | model.announce('replacement');
|
34456 | // If we're done with the shortcuts (found a unique one), reset it.
|
34457 | if (resetKeystrokeBuffer) {
|
34458 | mathfield.resetKeystrokeBuffer();
|
34459 | }
|
34460 | }
|
34461 | //
|
34462 | // 7. Make sure the insertion point is scrolled into view
|
34463 | //
|
34464 | mathfield.scrollIntoView();
|
34465 | //
|
34466 | // 8. Keystroke has been handled, if it wasn't caught in the default
|
34467 | // case, so prevent propagation
|
34468 | //
|
34469 | if (evt === null || evt === void 0 ? void 0 : evt.preventDefault) {
|
34470 | evt.preventDefault();
|
34471 | evt.stopPropagation();
|
34472 | }
|
34473 | return false;
|
34474 | }
|
34475 | /**
|
34476 | * This handler is invoked when text has been typed, pasted in or input with
|
34477 | * an input method. As a result, `text` can be a sequence of characters to
|
34478 | * be inserted.
|
34479 | * @param {object} options
|
34480 | * @param {boolean} options.focus - If true, the mathfield will be focused
|
34481 | * @param {boolean} options.feedback - If true, provide audio and haptic feedback
|
34482 | * @param {boolean} options.simulateKeystroke - If true, generate some synthetic
|
34483 | * keystrokes (useful to trigger inline shortcuts, for example)
|
34484 | * @private
|
34485 | */
|
34486 | function onTypedText(mathfield, text, options) {
|
34487 | var _a;
|
34488 | const { model } = mathfield;
|
34489 | if (mathfield.options.readOnly) {
|
34490 | model.announce('plonk');
|
34491 | return;
|
34492 | }
|
34493 | options = options !== null && options !== void 0 ? options : {};
|
34494 | //
|
34495 | // 1/ Focus, then provide audio and haptic feedback
|
34496 | //
|
34497 | if (options.focus) {
|
34498 | mathfield.focus();
|
34499 | }
|
34500 | if (options.feedback) {
|
34501 | if (mathfield.options.keypressVibration && canVibrate()) {
|
34502 | navigator.vibrate(HAPTIC_FEEDBACK_DURATION);
|
34503 | }
|
34504 | (_a = mathfield.keypressSound) === null || _a === void 0 ? void 0 : _a.play().catch(console.warn);
|
34505 | }
|
34506 | //
|
34507 | // 2/ Switch mode if requested
|
34508 | //
|
34509 | if (typeof options.mode === 'string' && mathfield.mode !== options.mode) {
|
34510 | mathfield.switchMode(options.mode);
|
34511 | }
|
34512 | //
|
34513 | // 3/ Simulate keystroke, if requested
|
34514 | //
|
34515 | if (options.simulateKeystroke) {
|
34516 | // For (const c of text) {
|
34517 | const c = text.charAt(0);
|
34518 | const ev = new KeyboardEvent('keypress', { key: c });
|
34519 | if (!onKeystroke(mathfield, c, ev)) {
|
34520 | return;
|
34521 | }
|
34522 | // }
|
34523 | }
|
34524 | //
|
34525 | // 4/ Insert the specified text at the current insertion point.
|
34526 | // If the selection is not collapsed, the content will be deleted first.
|
34527 | //
|
34528 | const style = {
|
34529 | ...model.at(model.position).computedStyle,
|
34530 | // Variant: 'main',
|
34531 | ...mathfield.style,
|
34532 | };
|
34533 | if (!model.selectionIsCollapsed) {
|
34534 | model.position = model.deleteAtoms(range(model.selection));
|
34535 | mathfield.snapshot();
|
34536 | }
|
34537 | // Decompose the string into an array of graphemes.
|
34538 | // This is necessary to correctly process what is displayed as a single
|
34539 | // glyph (a grapheme) but which is composed of multiple Unicode
|
34540 | // codepoints. This is the case in particular for some emojis, such as
|
34541 | // those with a skin tone modifier, the country flags emojis or
|
34542 | // compound emojis such as the professional emojis, including the
|
34543 | // David Bowie emoji: 👨🏻🎤
|
34544 | const graphemes = splitGraphemes(text);
|
34545 | if (mathfield.mode === 'latex') {
|
34546 | model.deferNotifications({ content: true, selection: true }, () => {
|
34547 | for (const c of graphemes) {
|
34548 | ModeEditor.insert('latex', model, c);
|
34549 | }
|
34550 | updateAutocomplete(mathfield);
|
34551 | });
|
34552 | }
|
34553 | else if (mathfield.mode === 'text') {
|
34554 | for (const c of graphemes) {
|
34555 | ModeEditor.insert('text', model, c, { style });
|
34556 | }
|
34557 | }
|
34558 | else if (mathfield.mode === 'math') {
|
34559 | for (const c of graphemes) {
|
34560 | // Some characters are mapped to commands. Handle them here.
|
34561 | // This is important to handle synthetic text input and
|
34562 | // non-US keyboards, on which, fop example, the '^' key is
|
34563 | // not mapped to 'Shift-Digit6'.
|
34564 | let selector = {
|
34565 | '^': 'moveToSuperscript',
|
34566 | '_': 'moveToSubscript',
|
34567 | ' ': 'moveAfterParent',
|
34568 | }[c];
|
34569 | if (c === ' ' && mathfield.options.mathModeSpace) {
|
34570 | selector = ['insert', mathfield.options.mathModeSpace];
|
34571 | }
|
34572 | if (selector) {
|
34573 | mathfield.executeCommand(selector);
|
34574 | }
|
34575 | else if (/\d/.test(c) &&
|
34576 | mathfield.options.smartSuperscript &&
|
34577 | model.at(model.position).treeBranch === 'superscript' &&
|
34578 | model.at(model.position).hasNoSiblings) {
|
34579 | // We are inserting a digit into an empty superscript
|
34580 | // If smartSuperscript is on, insert the digit, and
|
34581 | // exit the superscript.
|
34582 | ModeEditor.insert('math', model, c, { style });
|
34583 | moveAfterParent(model);
|
34584 | }
|
34585 | else {
|
34586 | ModeEditor.insert('math', model, c, {
|
34587 | style,
|
34588 | smartFence: mathfield.options.smartFence,
|
34589 | });
|
34590 | }
|
34591 | }
|
34592 | }
|
34593 | //
|
34594 | // 5/ Take a snapshot for undo stack
|
34595 | //
|
34596 | mathfield.snapshotAndCoalesce();
|
34597 | //
|
34598 | // 6/ Render the mathfield
|
34599 | //
|
34600 | mathfield.dirty = true;
|
34601 | // Render and make sure the insertion point is visible
|
34602 | mathfield.scrollIntoView();
|
34603 | }
|
34604 |
|
34605 | register({
|
34606 | undo: (mathfield) => {
|
34607 | complete(mathfield, 'accept');
|
34608 | // Undo to the previous state
|
34609 | mathfield.undo();
|
34610 | return true;
|
34611 | },
|
34612 | redo: (mathfield) => {
|
34613 | complete(mathfield, 'accept');
|
34614 | mathfield.redo();
|
34615 | return true;
|
34616 | },
|
34617 | scrollIntoView: (mathfield) => {
|
34618 | mathfield.scrollIntoView();
|
34619 | return true;
|
34620 | },
|
34621 | scrollToStart: (mathfield) => {
|
34622 | mathfield.field.scroll(0, 0);
|
34623 | return true;
|
34624 | },
|
34625 | scrollToEnd: (mathfield) => {
|
34626 | const fieldBounds = mathfield.field.getBoundingClientRect();
|
34627 | mathfield.field.scroll(fieldBounds.left - window.scrollX, 0);
|
34628 | return true;
|
34629 | },
|
34630 | enterLatexMode: (mathfield) => {
|
34631 | mathfield.switchMode('latex');
|
34632 | return true;
|
34633 | },
|
34634 | toggleKeystrokeCaption: toggleKeystrokeCaption,
|
34635 | switchMode: (mathfield, mode, prefix, suffix) => {
|
34636 | mathfield.switchMode(mode, prefix, suffix);
|
34637 | return true;
|
34638 | },
|
34639 | insert: (mathfield, s, options) => mathfield.insert(s, options),
|
34640 | typedText: (mathfield, text, options) => {
|
34641 | onTypedText(mathfield, text, options);
|
34642 | return true;
|
34643 | },
|
34644 | commit: (mathfield) => {
|
34645 | if (typeof mathfield.options.onCommit === 'function') {
|
34646 | mathfield.options.onCommit(mathfield);
|
34647 | }
|
34648 | return true;
|
34649 | },
|
34650 | });
|
34651 | register({
|
34652 | copyToClipboard: (mathfield) => {
|
34653 | mathfield.focus();
|
34654 | // If the selection is empty, select the entire field before
|
34655 | // copying it.
|
34656 | if (mathfield.model.selectionIsCollapsed) {
|
34657 | mathfield.select();
|
34658 | }
|
34659 | document.execCommand('copy');
|
34660 | return false;
|
34661 | },
|
34662 | cutToClipboard: (mathfield) => {
|
34663 | mathfield.focus();
|
34664 | document.execCommand('cut');
|
34665 | return true;
|
34666 | },
|
34667 | pasteFromClipboard: (mathfield) => {
|
34668 | mathfield.focus();
|
34669 | document.execCommand('paste');
|
34670 | return true;
|
34671 | },
|
34672 | }, { target: 'mathfield', category: 'clipboard' });
|
34673 |
|
34674 | function applyStyle(mathfield, inStyle) {
|
34675 | const style = validateStyle(mathfield, inStyle);
|
34676 | mathfield.resetKeystrokeBuffer();
|
34677 | const { model } = mathfield;
|
34678 | if (model.selectionIsCollapsed) {
|
34679 | // No selection, let's update the 'current' style
|
34680 | if (mathfield.style.fontSeries &&
|
34681 | style.fontSeries === mathfield.style.fontSeries) {
|
34682 | style.fontSeries = 'auto';
|
34683 | }
|
34684 | if (style.fontShape && style.fontShape === mathfield.style.fontShape) {
|
34685 | style.fontShape = 'auto';
|
34686 | }
|
34687 | if (style.color && style.color === mathfield.style.color) {
|
34688 | style.color = 'none';
|
34689 | }
|
34690 | if (style.backgroundColor &&
|
34691 | style.backgroundColor === mathfield.style.backgroundColor) {
|
34692 | style.backgroundColor = 'none';
|
34693 | }
|
34694 | if (style.fontSize && style.fontSize === mathfield.style.fontSize) {
|
34695 | style.fontSize = 'auto';
|
34696 | }
|
34697 | // This global style will be used the next time an atom is inserted
|
34698 | mathfield.style = { ...mathfield.style, ...style };
|
34699 | }
|
34700 | else {
|
34701 | mathfield.model.deferNotifications({ content: true }, () => {
|
34702 | // Change the style of the selection
|
34703 | model.selection.ranges.forEach((range) => applyStyle$1(model, range, style, { operation: 'toggle' }));
|
34704 | mathfield.snapshot();
|
34705 | });
|
34706 | }
|
34707 | return true;
|
34708 | }
|
34709 | register({ applyStyle }, { target: 'mathfield' });
|
34710 | /**
|
34711 | * Validate a style specification object
|
34712 | */
|
34713 | function validateStyle(mathfield, style) {
|
34714 | var _a, _b;
|
34715 | const result = {};
|
34716 | if (typeof style.color === 'string') {
|
34717 | if (!result.verbatimColor)
|
34718 | result.verbatimColor = style.color;
|
34719 | result.color = mathfield.colorMap(style.color);
|
34720 | }
|
34721 | if (typeof style.backgroundColor === 'string') {
|
34722 | if (!result.verbatimBackgroundColor) {
|
34723 | result.verbatimBackgroundColor = style.backgroundColor;
|
34724 | }
|
34725 | result.backgroundColor = mathfield.backgroundColorMap(style.backgroundColor);
|
34726 | }
|
34727 | if (typeof style.fontFamily === 'string') {
|
34728 | result.fontFamily = style.fontFamily;
|
34729 | }
|
34730 | if (typeof style.series === 'string') {
|
34731 | result.fontSeries = style.series;
|
34732 | }
|
34733 | if (typeof style.fontSeries === 'string') {
|
34734 | result.fontSeries = style.fontSeries.toLowerCase();
|
34735 | }
|
34736 | if (result.fontSeries) {
|
34737 | result.fontSeries =
|
34738 | {
|
34739 | bold: 'b',
|
34740 | medium: 'm',
|
34741 | normal: 'm',
|
34742 | }[result.fontSeries] || result.fontSeries;
|
34743 | }
|
34744 | if (typeof style.shape === 'string') {
|
34745 | result.fontShape = style.shape;
|
34746 | }
|
34747 | if (typeof style.fontShape === 'string') {
|
34748 | result.fontShape = style.fontShape.toLowerCase();
|
34749 | }
|
34750 | if (result.fontShape) {
|
34751 | result.fontShape =
|
34752 | {
|
34753 | italic: 'it',
|
34754 | up: 'n',
|
34755 | upright: 'n',
|
34756 | normal: 'n',
|
34757 | }[result.fontShape] || result.fontShape;
|
34758 | }
|
34759 | const size = (_a = style.size) !== null && _a !== void 0 ? _a : style.fontSize;
|
34760 | if (typeof size === 'number') {
|
34761 | result.fontSize = Math.max(1, Math.min(10, size));
|
34762 | }
|
34763 | else if (typeof size === 'string') {
|
34764 | result.fontSize =
|
34765 | (_b = {
|
34766 | size1: 1,
|
34767 | size2: 2,
|
34768 | size3: 3,
|
34769 | size4: 4,
|
34770 | size5: 5,
|
34771 | size6: 6,
|
34772 | size7: 7,
|
34773 | size8: 8,
|
34774 | size9: 9,
|
34775 | size10: 10,
|
34776 | }[size.toLowerCase()]) !== null && _b !== void 0 ? _b : {
|
34777 | tiny: 1,
|
34778 | scriptsize: 2,
|
34779 | footnotesize: 3,
|
34780 | small: 4,
|
34781 | normal: 5,
|
34782 | normalsize: 5,
|
34783 | large: 6,
|
34784 | Large: 7,
|
34785 | LARGE: 8,
|
34786 | huge: 9,
|
34787 | Huge: 10,
|
34788 | }[size];
|
34789 | }
|
34790 | return result;
|
34791 | }
|
34792 |
|
34793 | let gLastTap = null;
|
34794 | let gTapCount = 0;
|
34795 | function isTouchEvent(evt) {
|
34796 | return globalThis.TouchEvent !== undefined && evt instanceof TouchEvent;
|
34797 | }
|
34798 | function onPointerDown(mathfield, evt) {
|
34799 | var _a;
|
34800 | //Reset the atom bounds cache
|
34801 | mathfield._atomBoundsCache = new Map();
|
34802 | const that = mathfield;
|
34803 | let anchor;
|
34804 | let trackingPointer = false;
|
34805 | let dirty = 'none';
|
34806 | // If a mouse button other than the main one was pressed, return.
|
34807 | // On iOS 12.4 Safari and Firefox on Android (which do not support
|
34808 | // PointerEvent) the touchstart event is sent with event.buttons = 0
|
34809 | // which for a mouse event would normally be an invalid button.
|
34810 | // Accept this button 0.
|
34811 | if (evt instanceof PointerEvent && evt.buttons !== 1 && evt.buttons !== 0) {
|
34812 | return;
|
34813 | }
|
34814 | let scrollLeft = false;
|
34815 | let scrollRight = false;
|
34816 | // Note: evt['touches'] is for touchstart (when PointerEvent is not supported)
|
34817 | const anchorX = isTouchEvent(evt) ? evt.touches[0].clientX : evt.clientX;
|
34818 | const anchorY = isTouchEvent(evt) ? evt.touches[0].clientY : evt.clientY;
|
34819 | const anchorTime = Date.now();
|
34820 | const field = that.field;
|
34821 | const scrollInterval = setInterval(() => {
|
34822 | if (scrollLeft) {
|
34823 | field.scroll({ top: 0, left: field.scrollLeft - 16 });
|
34824 | }
|
34825 | else if (scrollRight) {
|
34826 | field.scroll({ top: 0, left: field.scrollLeft + 16 });
|
34827 | }
|
34828 | }, 32);
|
34829 | function endPointerTracking(evt) {
|
34830 | if (window.PointerEvent) {
|
34831 | off(field, 'pointermove', onPointerMove);
|
34832 | off(field, 'pointerup pointercancel', endPointerTracking);
|
34833 | if (evt instanceof PointerEvent) {
|
34834 | field.releasePointerCapture(evt.pointerId);
|
34835 | }
|
34836 | }
|
34837 | else {
|
34838 | off(field, 'touchmove', onPointerMove);
|
34839 | off(field, 'touchcancel touchend', endPointerTracking);
|
34840 | off(window, 'mousemove', onPointerMove);
|
34841 | off(window, 'mouseup blur', endPointerTracking);
|
34842 | }
|
34843 | trackingPointer = false;
|
34844 | clearInterval(scrollInterval);
|
34845 | mathfield.element.classList.remove('tracking');
|
34846 | if (evt) {
|
34847 | evt.preventDefault();
|
34848 | evt.stopPropagation();
|
34849 | }
|
34850 | }
|
34851 | function onPointerMove(evt) {
|
34852 | // If we've somehow lost focus, end tracking
|
34853 | if (!that.hasFocus()) {
|
34854 | endPointerTracking(null);
|
34855 | return;
|
34856 | }
|
34857 | const x = isTouchEvent(evt) ? evt.touches[0].clientX : evt.clientX;
|
34858 | const y = isTouchEvent(evt) ? evt.touches[0].clientY : evt.clientY;
|
34859 | // Ignore events that are within small spatial and temporal bounds
|
34860 | // of the pointer down
|
34861 | const hysteresis = isTouchEvent(evt) || evt.pointerType === 'touch' ? 20 : 5;
|
34862 | if (Date.now() < anchorTime + 500 &&
|
34863 | Math.abs(anchorX - x) < hysteresis &&
|
34864 | Math.abs(anchorY - y) < hysteresis) {
|
34865 | evt.preventDefault();
|
34866 | evt.stopPropagation();
|
34867 | return;
|
34868 | }
|
34869 | const fieldBounds = field.getBoundingClientRect();
|
34870 | scrollRight = x > fieldBounds.right;
|
34871 | scrollLeft = x < fieldBounds.left;
|
34872 | let actualAnchor = anchor;
|
34873 | if (evt instanceof PointerEvent) {
|
34874 | if (!evt.isPrimary) {
|
34875 | actualAnchor = offsetFromPoint(that, evt.clientX, evt.clientY, {
|
34876 | bias: 0,
|
34877 | });
|
34878 | }
|
34879 | }
|
34880 | else if (evt.touches && evt.touches.length === 2) {
|
34881 | actualAnchor = offsetFromPoint(that, evt.touches[1].clientX, evt.touches[1].clientY, { bias: 0 });
|
34882 | }
|
34883 | const focus = offsetFromPoint(that, x, y, {
|
34884 | bias: x <= anchorX ? (x === anchorX ? 0 : -1) : +1,
|
34885 | });
|
34886 | if (actualAnchor >= 0 && focus >= 0) {
|
34887 | that.model.extendSelectionTo(actualAnchor, focus);
|
34888 | requestUpdate(mathfield);
|
34889 | }
|
34890 | // Prevent synthetic mouseMove event when this is a touch event
|
34891 | evt.preventDefault();
|
34892 | evt.stopPropagation();
|
34893 | }
|
34894 | // Calculate the tap count
|
34895 | if (gLastTap &&
|
34896 | Math.abs(gLastTap.x - anchorX) < 5 &&
|
34897 | Math.abs(gLastTap.y - anchorY) < 5 &&
|
34898 | Date.now() < gLastTap.time + 500) {
|
34899 | gTapCount += 1;
|
34900 | gLastTap.time = anchorTime;
|
34901 | }
|
34902 | else {
|
34903 | gLastTap = {
|
34904 | x: anchorX,
|
34905 | y: anchorY,
|
34906 | time: anchorTime,
|
34907 | };
|
34908 | gTapCount = 1;
|
34909 | }
|
34910 | const bounds = field.getBoundingClientRect();
|
34911 | if (anchorX >= bounds.left &&
|
34912 | anchorX <= bounds.right &&
|
34913 | anchorY >= bounds.top &&
|
34914 | anchorY <= bounds.bottom) {
|
34915 | // Focus the mathfield
|
34916 | if (!mathfield.hasFocus()) {
|
34917 | dirty = 'all';
|
34918 | mathfield.keyboardDelegate.focus();
|
34919 | }
|
34920 | // Clicking or tapping the field resets the keystroke buffer and
|
34921 | // smart mode
|
34922 | mathfield.resetKeystrokeBuffer();
|
34923 | mathfield.smartModeSuppressed = false;
|
34924 | anchor = offsetFromPoint(mathfield, anchorX, anchorY, {
|
34925 | bias: 0,
|
34926 | });
|
34927 | if (anchor >= 0) {
|
34928 | // Set a `tracking` class to avoid triggering the hover of the virtual
|
34929 | // keyboard toggle, for example
|
34930 | mathfield.element.classList.add('tracking');
|
34931 | if (evt.shiftKey) {
|
34932 | // If the Shift key is down, extend the selection
|
34933 | // (in that case, 'anchor' is actually the focus
|
34934 | const wasCollapsed = mathfield.model.selectionIsCollapsed;
|
34935 | mathfield.model.extendSelectionTo(mathfield.model.anchor, anchor);
|
34936 | if (acceptCommandSuggestion(mathfield.model) || wasCollapsed) {
|
34937 | dirty = 'all';
|
34938 | }
|
34939 | else {
|
34940 | dirty = 'selection';
|
34941 | }
|
34942 | }
|
34943 | else if (mathfield.model.at(anchor).type === 'placeholder') {
|
34944 | mathfield.model.setSelection(anchor - 1, anchor);
|
34945 | dirty = 'selection';
|
34946 | }
|
34947 | else if (((_a = mathfield.model.at(anchor).rightSibling) === null || _a === void 0 ? void 0 : _a.type) === 'placeholder') {
|
34948 | mathfield.model.setSelection(anchor, anchor + 1);
|
34949 | dirty = 'selection';
|
34950 | }
|
34951 | else {
|
34952 | mathfield.model.position = anchor;
|
34953 | if (acceptCommandSuggestion(mathfield.model)) {
|
34954 | dirty = 'all';
|
34955 | }
|
34956 | else {
|
34957 | dirty = 'selection';
|
34958 | }
|
34959 | }
|
34960 | // Reset any user-specified style
|
34961 | mathfield.style = {};
|
34962 | // `evt.detail` contains the number of consecutive clicks
|
34963 | // for double-click, triple-click, etc...
|
34964 | // (note that `evt.detail` is not set when using pointerEvent)
|
34965 | if (evt.detail === 3 || gTapCount > 2) {
|
34966 | endPointerTracking(evt);
|
34967 | if (evt.detail === 3 || gTapCount === 3) {
|
34968 | // This is a triple-click
|
34969 | mathfield.model.selection = {
|
34970 | ranges: [[0, mathfield.model.lastOffset]],
|
34971 | };
|
34972 | dirty = 'all';
|
34973 | }
|
34974 | }
|
34975 | else if (!trackingPointer) {
|
34976 | trackingPointer = true;
|
34977 | if (window.PointerEvent) {
|
34978 | on(field, 'pointermove', onPointerMove);
|
34979 | on(field, 'pointerup pointercancel', endPointerTracking);
|
34980 | if (evt instanceof PointerEvent) {
|
34981 | field.setPointerCapture(evt.pointerId);
|
34982 | }
|
34983 | }
|
34984 | else {
|
34985 | on(window, 'blur', endPointerTracking);
|
34986 | if (isTouchEvent(evt) && evt.touches) {
|
34987 | // This is a touchstart event (and PointerEvent is not supported)
|
34988 | // To receive the subsequent touchmove/touch, need to
|
34989 | // listen to this evt.target.
|
34990 | // This was a touch event
|
34991 | on(evt.target, 'touchmove', onPointerMove);
|
34992 | on(evt.target, 'touchcancel touchend', endPointerTracking);
|
34993 | }
|
34994 | else {
|
34995 | on(window, 'mousemove', onPointerMove);
|
34996 | on(window, 'mouseup', endPointerTracking);
|
34997 | }
|
34998 | }
|
34999 | if (evt.detail === 2 || gTapCount === 2) {
|
35000 | selectGroup(mathfield.model);
|
35001 | dirty = 'all';
|
35002 | }
|
35003 | }
|
35004 | }
|
35005 | }
|
35006 | else {
|
35007 | gLastTap = null;
|
35008 | }
|
35009 | if (dirty !== 'none') {
|
35010 | if (mathfield.model.selectionIsCollapsed)
|
35011 | dirty = 'all';
|
35012 | requestUpdate(mathfield);
|
35013 | }
|
35014 | // Prevent the browser from handling. In particular when this is a
|
35015 | // touch event, prevent the synthetic mouseDown event from being generated
|
35016 | evt.preventDefault();
|
35017 | }
|
35018 | function distance(x, y, r) {
|
35019 | const dx = x - (r.left + r.right) / 2;
|
35020 | const dy = y - (r.top + r.bottom) / 2;
|
35021 | return dx * dx + dy * dy;
|
35022 | }
|
35023 | function nearestAtomFromPointRecursive(mathfield, cache, atom, x, y) {
|
35024 | if (!atom.id)
|
35025 | return [Infinity, null];
|
35026 | if (cache.has(atom.id))
|
35027 | return cache.get(atom.id);
|
35028 | const bounds = getAtomBounds(mathfield, atom);
|
35029 | if (!bounds)
|
35030 | return [Infinity, null];
|
35031 | let result = [
|
35032 | distance(x, y, bounds),
|
35033 | atom,
|
35034 | ];
|
35035 | //
|
35036 | // 1. Consider any children within the horizontal bounds
|
35037 | //
|
35038 | if (!atom.captureSelection &&
|
35039 | x >= bounds.left &&
|
35040 | x <= bounds.right &&
|
35041 | atom.hasChildren) {
|
35042 | for (const child of atom.children) {
|
35043 | const r = nearestAtomFromPointRecursive(mathfield, cache, child, x, y);
|
35044 | if (r[0] < result[0])
|
35045 | result = r;
|
35046 | }
|
35047 | }
|
35048 | //
|
35049 | // 2. If no children matched, this atom matches
|
35050 | //
|
35051 | if (!result[1]) {
|
35052 | result = [distance(x, y, bounds), atom];
|
35053 | }
|
35054 | cache.set(atom.id, result);
|
35055 | return result;
|
35056 | }
|
35057 | function nearestAtomFromPoint(mathfield, x, y) {
|
35058 | const [, atom] = nearestAtomFromPointRecursive(mathfield, new Map(), mathfield.model.root, x, y);
|
35059 | return atom;
|
35060 | }
|
35061 | /**
|
35062 | * @param options.bias if 0, the midpoint of the bounding box
|
35063 | * is considered to return the sibling. If <0, the left sibling is
|
35064 | * favored, if >0, the right sibling
|
35065 | */
|
35066 | function offsetFromPoint(mathfield, x, y, options) {
|
35067 | var _a;
|
35068 | //
|
35069 | // 1/ Check if we're inside the mathfield bounding box
|
35070 | //
|
35071 | const bounds = mathfield.fieldContent.getBoundingClientRect();
|
35072 | if (x > bounds.right || y > bounds.bottom + 8) {
|
35073 | return mathfield.model.lastOffset;
|
35074 | }
|
35075 | if (x < bounds.left || y < bounds.top - 8) {
|
35076 | return 0;
|
35077 | }
|
35078 | options = options !== null && options !== void 0 ? options : {};
|
35079 | options.bias = (_a = options.bias) !== null && _a !== void 0 ? _a : 0;
|
35080 | //
|
35081 | // 2/ Find the deepest element that is near the point that was
|
35082 | // clicked on (the point could be outside of the element)
|
35083 | //
|
35084 | let atom = nearestAtomFromPoint(mathfield, x, y);
|
35085 | //
|
35086 | // 3/ Find the first parent from root that doesn't have a `captureSelection`
|
35087 | // flag
|
35088 | //
|
35089 | const parents = [];
|
35090 | let parent = atom;
|
35091 | while (parent) {
|
35092 | parents.unshift(parent);
|
35093 | parent = parent.parent;
|
35094 | }
|
35095 | for (const x of parents) {
|
35096 | if (x.captureSelection) {
|
35097 | atom = x;
|
35098 | break;
|
35099 | }
|
35100 | }
|
35101 | let result = mathfield.model.offsetOf(atom);
|
35102 | if (result < 0)
|
35103 | return -1;
|
35104 | //
|
35105 | // 4/ Account for the desired biad
|
35106 | //
|
35107 | if (atom.leftSibling) {
|
35108 | if (options.bias === 0 && atom.type !== 'placeholder') {
|
35109 | // If the point clicked is to the left of the vertical midline,
|
35110 | // adjust the offset to *before* the atom (i.e. after the
|
35111 | // preceding atom)
|
35112 | const bounds = getAtomBounds(mathfield, atom);
|
35113 | if (bounds && x < (bounds.left + bounds.right) / 2) {
|
35114 | result = mathfield.model.offsetOf(atom.leftSibling);
|
35115 | }
|
35116 | }
|
35117 | else if (options.bias < 0) {
|
35118 | result = mathfield.model.offsetOf(atom.leftSibling);
|
35119 | }
|
35120 | }
|
35121 | return result;
|
35122 | }
|
35123 |
|
35124 | var css_248z = "@keyframes ML__caret-blink{0%,to{opacity:1}50%{opacity:0}}.ML__caret:after{animation:ML__caret-blink 1.05s step-end infinite forwards;border:none;border-radius:2px;border-right:2px solid var(--caret,hsl(var(--hue,212),40%,49%));content:\"\";left:-1px;margin-right:-2px;position:relative}.ML__text-caret:after{animation:ML__caret-blink 1.05s step-end infinite forwards;border:none;border-radius:1px;border-right:1px solid var(--caret,hsl(var(--hue,212),40%,49%));content:\"\";left:0;margin-right:-1px;position:relative}.ML__latex-caret:after{animation:ML__caret-blink 1.05s step-end infinite forwards;border:none;color:var(--caret,hsl(var(--hue,212),40%,49%));content:\"_\";margin-right:calc(-1ex - 2px);position:relative}.ML__fieldcontainer{align-items:flex-end;display:flex;flex-flow:row;justify-content:space-between;min-height:39px;touch-action:none;width:100%}.ML__fieldcontainer__field{align-items:center;align-self:center;display:flex;overflow:hidden;padding:2px 0 2px 1px;position:relative;width:100%}.ML__virtual-keyboard-toggle{display:none}.ML__virtual-keyboard-toggle>span{align-items:center;align-self:center;display:flex}.ML__virtual-keyboard-toggle.is-visible{fill:currentColor;align-items:center;align-self:center;background:transparent;border:1px solid transparent;border-radius:8px;box-sizing:border-box;color:var(--primary,hsl(var(--hue,212),40%,50%));cursor:pointer;display:flex;flex-direction:column;flex-shrink:0;height:34px;justify-content:center;margin-right:4px;padding:0;transition:background .2s cubic-bezier(.64,.09,.08,1);width:34px}.ML__virtual-keyboard-toggle.is-visible:hover{fill:currentColor;background:hsla(0,0%,70%,.5);border-radius:8px;color:#333}.ML__textarea__textarea{clip:rect(0 0 0 0);border:none;display:inline-block;font-family:KaTeX_Main;font-size:1em;height:1px;outline:none;position:absolute;resize:none;transform:scale(0);width:1px}.ML__focused .ML__text{background:hsla(var(--hue,212),40%,50%,.1)}.ML__smart-fence__close{color:var(--smart-fence-color,currentColor);opacity:var(--smart-fence-opacity,.5)}.ML__selection{background:var(--highlight-inactive,#ccc);box-sizing:border-box}.ML__focused .ML__selection{background:var(--highlight,hsl(var(--hue,212),97%,85%))!important;color:var(--on-highlight)}.ML__contains-caret.ML__close,.ML__contains-caret.ML__open,.ML__contains-caret .ML__sqrt-line,.ML__contains-caret .ML__sqrt-sign,.ML__contains-caret>.ML__close,.ML__contains-caret>.ML__open{color:var(--caret,hsl(var(--hue,212),40%,49%))}.ML__contains-highlight{background:var(--contains-highlight,var(--highlight,hsl(var(--hue,212),40%,95%)));box-sizing:border-box}.ML__latex{color:var(--primary,hsl(var(--hue,212),40%,50%));font-family:IBM Plex Mono,Source Code Pro,Consolas,Roboto Mono,Menlo,Bitstream Vera Sans Mono,DejaVu Sans Mono,Monaco,Courier,monospace;font-weight:400}:not(.ML__latex)+.ML__latex{margin-left:.25em}.ML__latex+:not(.ML__latex){padding-left:.25em}.ML__suggestion{opacity:.5}.ML__virtual-keyboard-toggle.is-visible.is-pressed:hover{fill:currentColor;background:hsl(var(--hue,212),25%,35%);color:#fafafa}.ML__virtual-keyboard-toggle:focus{border:2px solid var(--primary,hsl(var(--hue,212),40%,50%));border-radius:8px;outline:none}.ML__virtual-keyboard-toggle.is-active,.ML__virtual-keyboard-toggle.is-active:hover,.ML__virtual-keyboard-toggle.is-pressed{fill:currentColor;background:hsl(var(--hue,212),25%,35%);color:#fafafa}.ML__scroller{height:100vh;position:fixed;top:0;width:200px;z-index:1}[data-ML__tooltip]{position:relative}[data-ML__tooltip][data-placement=top]:after{bottom:100%;top:inherit}[data-ML__tooltip]:after{background:#616161;border-radius:2px;box-shadow:0 2px 2px 0 rgba(0,0,0,.14),0 1px 5px 0 rgba(0,0,0,.12),0 3px 1px -2px rgba(0,0,0,.2);color:#fff;content:attr(data-ML__tooltip);display:none;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:12px;font-weight:400;max-width:200px;opacity:0;padding:8px;position:absolute;text-align:center;top:110%;transform:scale(.5);transition:all .15s cubic-bezier(.4,0,1,1);width:max-content;z-index:2}@media only screen and (max-width:767px){[data-ML__tooltip]:after{font-size:14px;padding:8px 16px}}:not(.tracking) [data-ML__tooltip]:hover{position:relative}:not(.tracking) [data-ML__tooltip]:hover:after{display:inline-table;opacity:1;transform:scale(1);visibility:visible}[data-ML__tooltip][data-delay]:after{transition-delay:0s}[data-ML__tooltip][data-delay]:hover:after{transition-delay:1s}";
|
35125 |
|
35126 | class TextModeEditor extends ModeEditor {
|
35127 | constructor() {
|
35128 | super('text');
|
35129 | }
|
35130 | onPaste(mathfield, ev) {
|
35131 | if (!ev.clipboardData)
|
35132 | return false;
|
35133 | const text = ev.clipboardData.getData('text/plain');
|
35134 | if (text) {
|
35135 | mathfield.snapshot();
|
35136 | if (this.insert(mathfield.model, text)) {
|
35137 | requestUpdate(mathfield);
|
35138 | }
|
35139 | ev.preventDefault();
|
35140 | ev.stopPropagation();
|
35141 | return true;
|
35142 | }
|
35143 | return false;
|
35144 | }
|
35145 | insert(model, text, options = {}) {
|
35146 | var _a;
|
35147 | if (!options.insertionMode)
|
35148 | options.insertionMode = 'replaceSelection';
|
35149 | if (!options.selectionMode)
|
35150 | options.selectionMode = 'placeholder';
|
35151 | if (!options.format)
|
35152 | options.format = 'auto';
|
35153 | options.macros = (_a = options.macros) !== null && _a !== void 0 ? _a : model.options.macros;
|
35154 | const { suppressChangeNotifications } = model;
|
35155 | if (options.suppressChangeNotifications) {
|
35156 | model.suppressChangeNotifications = true;
|
35157 | }
|
35158 | const contentWasChanging = model.suppressChangeNotifications;
|
35159 | model.suppressChangeNotifications = true;
|
35160 | //
|
35161 | // Delete any selected items
|
35162 | //
|
35163 | if (options.insertionMode === 'replaceSelection' &&
|
35164 | !model.selectionIsCollapsed) {
|
35165 | model.position = model.deleteAtoms(range(model.selection));
|
35166 | }
|
35167 | else if (options.insertionMode === 'replaceAll') {
|
35168 | model.root.setChildren([], 'body');
|
35169 | model.position = 0;
|
35170 | }
|
35171 | else if (options.insertionMode === 'insertBefore') {
|
35172 | model.collapseSelection('backward');
|
35173 | }
|
35174 | else if (options.insertionMode === 'insertAfter') {
|
35175 | model.collapseSelection('forward');
|
35176 | }
|
35177 | const newAtoms = convertStringToAtoms(text);
|
35178 | // Some atoms may already have a style (for example if there was an
|
35179 | // argument, i.e. the selection, that this was applied to).
|
35180 | // So, don't apply style to atoms that are already styled, but *do*
|
35181 | // apply it to newly created atoms that have no style yet.
|
35182 | applyStyleToUnstyledAtoms(newAtoms, options.style);
|
35183 | if (!newAtoms)
|
35184 | return false;
|
35185 | const cursor = model.at(model.position);
|
35186 | const lastNewAtom = cursor.parent.addChildrenAfter(newAtoms, cursor);
|
35187 | // Prepare to dispatch notifications
|
35188 | // (for selection changes, then content change)
|
35189 | model.suppressChangeNotifications = contentWasChanging;
|
35190 | if (options.selectionMode === 'before') ;
|
35191 | else if (options.selectionMode === 'item') {
|
35192 | model.setSelection(model.anchor, model.offsetOf(lastNewAtom));
|
35193 | }
|
35194 | else if (lastNewAtom) {
|
35195 | model.position = model.offsetOf(lastNewAtom);
|
35196 | }
|
35197 | contentDidChange(model);
|
35198 | model.suppressChangeNotifications = suppressChangeNotifications;
|
35199 | return true;
|
35200 | }
|
35201 | }
|
35202 | function convertStringToAtoms(s) {
|
35203 | // Map special TeX characters to alternatives
|
35204 | // Must do this one first, since other replacements include backslash
|
35205 | s = s.replace(/\\/g, '\\textbackslash ');
|
35206 | s = s.replace(/#/g, '\\#');
|
35207 | s = s.replace(/\$/g, '\\$');
|
35208 | s = s.replace(/%/g, '\\%');
|
35209 | s = s.replace(/&/g, '\\&');
|
35210 | // S = s.replace(/:/g, '\\colon'); // text colon?
|
35211 | // s = s.replace(/\[/g, '\\lbrack');
|
35212 | // s = s.replace(/]/g, '\\rbrack');
|
35213 | s = s.replace(/_/g, '\\_');
|
35214 | s = s.replace(/{/g, '\\textbraceleft ');
|
35215 | s = s.replace(/}/g, '\\textbraceright ');
|
35216 | s = s.replace(/\^/g, '\\textasciicircum ');
|
35217 | s = s.replace(/~/g, '\\textasciitilde ');
|
35218 | s = s.replace(/£/g, '\\textsterling ');
|
35219 | return parseLatex(s, { parseMode: 'text', registers: {} });
|
35220 | }
|
35221 | new TextModeEditor();
|
35222 |
|
35223 | let CORE_STYLESHEET_HASH = undefined;
|
35224 | let MATHFIELD_STYLESHEET_HASH = undefined;
|
35225 | class MathfieldPrivate {
|
35226 | /**
|
35227 | *
|
35228 | * @param element - The DOM element that this mathfield is attached to.
|
35229 | * Note that `element.mathfield` is this object.
|
35230 | */
|
35231 | constructor(element, options) {
|
35232 | var _a, _b, _c;
|
35233 | this.eventHandlingInProgress = '';
|
35234 | this.stylesheets = [];
|
35235 | // Setup default config options
|
35236 | this.options = update(getDefault(), options.readOnly
|
35237 | ? { ...options, virtualKeyboardMode: 'off' }
|
35238 | : {
|
35239 | plonkSound: 'plonk.wav',
|
35240 | keypressSound: {
|
35241 | spacebar: 'keypress-spacebar.wav',
|
35242 | return: 'keypress-return.wav',
|
35243 | delete: 'keypress-delete.wav',
|
35244 | default: 'keypress-standard.wav',
|
35245 | },
|
35246 | ...options,
|
35247 | });
|
35248 | this.macros = this.options.macros;
|
35249 | this._placeholders = new Map();
|
35250 | this.colorMap = (name) => {
|
35251 | let result = undefined;
|
35252 | if (typeof this.options.colorMap === 'function') {
|
35253 | result = this.options.colorMap(name);
|
35254 | }
|
35255 | if (!result)
|
35256 | result = defaultColorMap(name);
|
35257 | return result;
|
35258 | };
|
35259 | this.backgroundColorMap = (name) => {
|
35260 | let result = undefined;
|
35261 | if (typeof this.options.backgroundColorMap === 'function') {
|
35262 | result = this.options.backgroundColorMap(name);
|
35263 | }
|
35264 | if (!result && typeof this.options.colorMap === 'function') {
|
35265 | result = this.options.colorMap(name);
|
35266 | }
|
35267 | if (!result)
|
35268 | result = defaultBackgroundColorMap(name);
|
35269 | return result;
|
35270 | };
|
35271 | // The virtual keyboard can be either attached to this mathfield
|
35272 | // or a delegate that mirrors a global virtual keyboard attached
|
35273 | // to the document. This is useful for example when using
|
35274 | // mathfield in iframes so that all the mathfields share the keyboard
|
35275 | // at the document level (rather than having one in each iframe)
|
35276 | if (!this.options.readOnly) {
|
35277 | this.virtualKeyboard = options.useSharedVirtualKeyboard
|
35278 | ? new VirtualKeyboardDelegate({
|
35279 | targetOrigin: this.options.sharedVirtualKeyboardTargetOrigin,
|
35280 | originValidator: this.options.originValidator,
|
35281 | mathfield: this,
|
35282 | })
|
35283 | : new VirtualKeyboard(this.options, this);
|
35284 | }
|
35285 | this.plonkSound = this.options.plonkSound;
|
35286 | if (!this.options.keypressSound) {
|
35287 | this.keypressSound = null;
|
35288 | this.spacebarKeypressSound = null;
|
35289 | this.returnKeypressSound = null;
|
35290 | this.deleteKeypressSound = null;
|
35291 | }
|
35292 | else if (this.options.keypressSound &&
|
35293 | typeof this.options.keypressSound !== 'string' &&
|
35294 | !(this.options.keypressSound instanceof HTMLAudioElement)) {
|
35295 | this.keypressSound = this.options.keypressSound
|
35296 | .default;
|
35297 | this.spacebarKeypressSound = this.options.keypressSound
|
35298 | .spacebar;
|
35299 | this.returnKeypressSound = this.options.keypressSound
|
35300 | .return;
|
35301 | this.deleteKeypressSound = this.options.keypressSound
|
35302 | .delete;
|
35303 | }
|
35304 | this.element = element;
|
35305 | element.mathfield = this;
|
35306 | let elementText = (_a = options.value) !== null && _a !== void 0 ? _a : this.element.textContent;
|
35307 | if (elementText) {
|
35308 | elementText = elementText.trim();
|
35309 | }
|
35310 | // Load the fonts, inject the core and mathfield stylesheets
|
35311 | void loadFonts(this.options.fontsDirectory, this.options.onError);
|
35312 | if (!CORE_STYLESHEET_HASH) {
|
35313 | CORE_STYLESHEET_HASH = hashCode(css_248z$4).toString(36);
|
35314 | }
|
35315 | this.stylesheets.push(inject(element, css_248z$4, CORE_STYLESHEET_HASH));
|
35316 | if (!MATHFIELD_STYLESHEET_HASH) {
|
35317 | MATHFIELD_STYLESHEET_HASH = hashCode(css_248z).toString(36);
|
35318 | }
|
35319 | this.stylesheets.push(inject(element, css_248z, MATHFIELD_STYLESHEET_HASH));
|
35320 | // Additional elements used for UI.
|
35321 | // They are retrieved in order a bit later, so they need to be kept in sync
|
35322 | let markup = '';
|
35323 | // 1/ The keyboard event capture element.
|
35324 | // On touch capable device, we do not create a textarea to capture keyboard
|
35325 | // events as this has the side effect of triggering the OS virtual keyboard
|
35326 | // which we want to avoid
|
35327 | markup += "<span class='ML__textarea'>";
|
35328 | markup += isTouchCapable()
|
35329 | ? `<span class='ML__textarea__textarea' tabindex="-1" role="textbox"></span>`
|
35330 | : '<textarea class="ML__textarea__textarea" autocapitalize="off" autocomplete="off" ' +
|
35331 | `autocorrect="off" spellcheck="false" aria-hidden="true" tabindex="${(_b = element.tabIndex) !== null && _b !== void 0 ? _b : 0}"></textarea>`;
|
35332 | markup += '</span>';
|
35333 | // 2/ The field, where the math equation will be displayed
|
35334 | markup +=
|
35335 | '<span class="ML__fieldcontainer"><span class="ML__fieldcontainer__field"></span>';
|
35336 | // 2.1/ The virtual keyboard toggle
|
35337 | markup += `<div part='virtual-keyboard-toggle' class="ML__virtual-keyboard-toggle" role="button" data-ML__tooltip="${localize('tooltip.toggle virtual keyboard')}">`;
|
35338 | markup +=
|
35339 | (_c = this.options.virtualKeyboardToggleGlyph) !== null && _c !== void 0 ? _c : DEFAULT_KEYBOARD_TOGGLE_GLYPH;
|
35340 | markup += '</div>';
|
35341 | markup += "<div class='ML__placeholdercontainer'></div>";
|
35342 | markup += '</span>';
|
35343 | // 3.1/ The aria-live region for announcements
|
35344 | // 3.1/ The area to stick MathML for screen reading larger exprs
|
35345 | // (not used right now). The idea for the area is that focus would bounce
|
35346 | // their and then back triggering the screen reader to read it
|
35347 | markup +=
|
35348 | '<div class="ML__sr-only">' +
|
35349 | '<span aria-live="assertive" aria-atomic="true"></span>' +
|
35350 | '<span></span>' +
|
35351 | '</div>';
|
35352 | this.element.innerHTML = this.options.createHTML(markup);
|
35353 | if (!this.element.children) {
|
35354 | console.error('%cMathlive: Something went wrong and the mathfield could not be created.%c\n' +
|
35355 | 'If you are using Vue, this may be because you are using the ' +
|
35356 | 'runtime-only build of Vue. Make sure to include ' +
|
35357 | "'runtimeCompiler: true' in your Vue configuration. There" +
|
35358 | 'may a warning from Vue in the log above.', 'color:red;font-family:system-ui;font-size:1.2rem;font-weight:bold', 'color:inherith;font-family:system-ui;font-size:inherit;font-weight:inherit');
|
35359 | return;
|
35360 | }
|
35361 | let iChild = 0; // Index of child -- used to make changes below easier
|
35362 | const textarea = this.element.children[iChild++]
|
35363 | .firstElementChild;
|
35364 | this.field = this.element.children[iChild].children[0];
|
35365 | // Listen to 'wheel' events to scroll (horizontally) the field when it overflows
|
35366 | this.field.addEventListener('wheel', (ev) => {
|
35367 | const wheelDelta = -ev.deltaX;
|
35368 | if (Number.isFinite(wheelDelta) && wheelDelta !== 0) {
|
35369 | this.field.scrollBy({
|
35370 | top: 0,
|
35371 | left: -wheelDelta * 5,
|
35372 | });
|
35373 | ev.preventDefault();
|
35374 | ev.stopPropagation();
|
35375 | }
|
35376 | }, { passive: false });
|
35377 | iChild++;
|
35378 | this.virtualKeyboardToggle = this.element.querySelector('.ML__virtual-keyboard-toggle');
|
35379 | if (!this.options.readOnly &&
|
35380 | this.options.virtualKeyboardMode === 'manual') {
|
35381 | this.virtualKeyboardToggle.classList.add('is-visible');
|
35382 | }
|
35383 | else {
|
35384 | this.virtualKeyboardToggle.classList.remove('is-visible');
|
35385 | }
|
35386 | if (this.options.readOnly) {
|
35387 | this.element.classList.add('ML__isReadOnly');
|
35388 | }
|
35389 | else {
|
35390 | this.element.classList.remove('ML__isReadOnly');
|
35391 | }
|
35392 | if (this.options.defaultMode === 'inline-math') {
|
35393 | this.element.classList.add('ML__isInline');
|
35394 | }
|
35395 | else {
|
35396 | this.element.classList.remove('ML__isInline');
|
35397 | }
|
35398 | attachButtonHandlers((command) => this.executeCommand(command), this.virtualKeyboardToggle, {
|
35399 | default: 'toggleVirtualKeyboard',
|
35400 | alt: 'toggleVirtualKeyboardAlt',
|
35401 | shift: 'toggleVirtualKeyboardShift',
|
35402 | });
|
35403 | this.ariaLiveText = this.element.children[iChild]
|
35404 | .children[0];
|
35405 | this.accessibleNode = this.element.children[iChild++]
|
35406 | .children[1];
|
35407 | // The keystroke caption panel and the popover are initially hidden
|
35408 | this.keystrokeCaptionVisible = false;
|
35409 | this.popoverVisible = false;
|
35410 | // This index indicates which of the suggestions available to
|
35411 | // display in the popover panel
|
35412 | this.suggestionIndex = 0;
|
35413 | this.keystrokeBuffer = '';
|
35414 | this.keystrokeBufferStates = [];
|
35415 | this.keystrokeBufferResetTimer = 0;
|
35416 | // The input mode (text, math, command)
|
35417 | // While model.getMode() represent the mode of the current selection,
|
35418 | // this.mode is the mode chosen by the user. It indicates the mode the
|
35419 | // next character typed will be interpreted in.
|
35420 | // It is often identical to getAnchorMode() since changing the selection
|
35421 | // changes the mode, but sometimes it is not, for example when a user
|
35422 | // enters a mode changing command.
|
35423 | this.mode = effectiveMode(this.options);
|
35424 | this.smartModeSuppressed = false;
|
35425 | // Current style (color, weight, italic, etc...):
|
35426 | // reflects the style to be applied on next insertion.
|
35427 | this.style = {};
|
35428 | // Focus/blur state
|
35429 | this.blurred = true;
|
35430 | on(this.element, 'focus', this);
|
35431 | on(this.element, 'blur', this);
|
35432 | // Capture clipboard events
|
35433 | // Delegate keyboard events
|
35434 | this.keyboardDelegate = delegateKeyboardEvents(textarea, {
|
35435 | typedText: (text) => onTypedText(this, text),
|
35436 | cut: (_ev) => {
|
35437 | // Ignore if in read-only mode
|
35438 | if (this.options.readOnly) {
|
35439 | this.model.announce('plonk');
|
35440 | return;
|
35441 | }
|
35442 | // Snapshot the undo state
|
35443 | this.snapshot();
|
35444 | // Clearing the selection will have the side effect of clearing the
|
35445 | // content of the textarea. However, the textarea value is what will
|
35446 | // be copied to the clipboard, so defer the clearing of the selection
|
35447 | // to later, after the cut operation has been handled.
|
35448 | setTimeout(() => {
|
35449 | deleteRange(this.model, range(this.model.selection));
|
35450 | requestUpdate(this);
|
35451 | }, 0);
|
35452 | },
|
35453 | copy: (ev) => ModeEditor.onCopy(this, ev),
|
35454 | paste: (ev) => {
|
35455 | // Ignore if in read-only mode
|
35456 | if (this.options.readOnly) {
|
35457 | this.model.announce('plonk');
|
35458 | return;
|
35459 | }
|
35460 | ModeEditor.onPaste(this.model.at(this.model.position).mode, this, ev);
|
35461 | },
|
35462 | keystroke: (keystroke, event) => onKeystroke(this, keystroke, event),
|
35463 | focus: () => this.onFocus(),
|
35464 | blur: () => this.onBlur(),
|
35465 | compositionStart: (composition) => this.onCompositionStart(composition),
|
35466 | compositionUpdate: (composition) => this.onCompositionUpdate(composition),
|
35467 | compositionEnd: (composition) => this.onCompositionEnd(composition),
|
35468 | });
|
35469 | // Delegate mouse and touch events
|
35470 | if (window.PointerEvent) {
|
35471 | // Use modern pointer events if available
|
35472 | on(this.field, 'pointerdown', this);
|
35473 | }
|
35474 | else {
|
35475 | on(this.field, 'touchstart:active mousedown', this);
|
35476 | }
|
35477 | // Request notification for when the window is resized (
|
35478 | // or the device switched from portrait to landscape) to adjust
|
35479 | // the UI (popover, etc...)
|
35480 | on(window, 'resize', this);
|
35481 | // Setup the model
|
35482 | this.model = new ModelPrivate({
|
35483 | mode: effectiveMode(this.options),
|
35484 | macros: this.macros,
|
35485 | removeExtraneousParentheses: this.options.removeExtraneousParentheses,
|
35486 | }, {
|
35487 | onContentDidChange: (_sender) => this.options.onContentDidChange(this),
|
35488 | onSelectionDidChange: (_sender) => this._onSelectionDidChange(),
|
35489 | onContentWillChange: () => this.options.onContentWillChange(this),
|
35490 | onSelectionWillChange: () => this.options.onSelectionWillChange(this),
|
35491 | onError: this.options.onError,
|
35492 | onPlaceholderDidChange: (_sender, placeholderId) => this.options.onPlaceholderDidChange(this, placeholderId),
|
35493 | }, {
|
35494 | announce: (_sender, command, previousPosition, atoms) => { var _a, _b; return (_b = (_a = this.options).onAnnounce) === null || _b === void 0 ? void 0 : _b.call(_a, this, command, previousPosition, atoms); },
|
35495 | moveOut: (_sender, direction) => this.options.onMoveOutOf(this, direction),
|
35496 | tabOut: (_sender, direction) => this.options.onTabOutOf(this, direction),
|
35497 | }, this);
|
35498 | // Prepare to manage undo/redo
|
35499 | this.undoManager = new UndoManager(this.model);
|
35500 | // Use the content of the element for the initial value of the mathfield
|
35501 | if (elementText) {
|
35502 | ModeEditor.insert('math', this.model, elementText, {
|
35503 | insertionMode: 'replaceAll',
|
35504 | selectionMode: 'after',
|
35505 | format: 'latex',
|
35506 | suppressChangeNotifications: true,
|
35507 | macros: this.options.macros,
|
35508 | });
|
35509 | }
|
35510 | // Now start recording potentially undoable actions
|
35511 | this.undoManager.startRecording();
|
35512 | this.undoManager.snapshot(this.options);
|
35513 | this.model.setListeners({
|
35514 | onContentDidChange: (_sender) => this.options.onContentDidChange(this),
|
35515 | onSelectionDidChange: (_sender) => this._onSelectionDidChange(),
|
35516 | onContentWillChange: () => this.options.onContentWillChange(this),
|
35517 | onSelectionWillChange: () => this.options.onSelectionWillChange(this),
|
35518 | onError: this.options.onError,
|
35519 | onPlaceholderDidChange: (_sender, placeholderId) => this.options.onPlaceholderDidChange(this, placeholderId),
|
35520 | });
|
35521 | this.model.setHooks({
|
35522 | announce: (_sender, command, previousPosition, atoms) => { var _a, _b; return (_b = (_a = this.options).onAnnounce) === null || _b === void 0 ? void 0 : _b.call(_a, this, command, previousPosition, atoms); },
|
35523 | moveOut: (_sender, direction) => this.options.onMoveOutOf(this, direction),
|
35524 | tabOut: (_sender, direction) => this.options.onTabOutOf(this, direction),
|
35525 | });
|
35526 | if (!this.options.locale.startsWith(getActiveKeyboardLayout().locale)) {
|
35527 | setKeyboardLayoutLocale(this.options.locale);
|
35528 | }
|
35529 | requestUpdate(this);
|
35530 | // When fonts are done loading, re-render
|
35531 | // (the selection highlighting may be out of date due to the HTML layout
|
35532 | // having been updated with the new font metrics)
|
35533 | if (isBrowser()) {
|
35534 | document.fonts.ready.then(() => render(this));
|
35535 | }
|
35536 | }
|
35537 | get virtualKeyboardState() {
|
35538 | var _a;
|
35539 | if ((_a = this.virtualKeyboard) === null || _a === void 0 ? void 0 : _a.visible)
|
35540 | return 'visible';
|
35541 | return 'hidden';
|
35542 | }
|
35543 | set virtualKeyboardState(value) {
|
35544 | if (!this.virtualKeyboard)
|
35545 | return;
|
35546 | if (value === 'hidden') {
|
35547 | this.virtualKeyboard.executeCommand('hideVirtualKeyboard');
|
35548 | }
|
35549 | else if (value === 'visible') {
|
35550 | this.virtualKeyboard.executeCommand('showVirtualKeyboard');
|
35551 | }
|
35552 | }
|
35553 | get keybindings() {
|
35554 | var _a;
|
35555 | if (this._keybindings)
|
35556 | return this._keybindings;
|
35557 | this._keybindings = normalizeKeybindings(this.options.keybindings, (_a = getActiveKeyboardLayout()) !== null && _a !== void 0 ? _a : DEFAULT_KEYBOARD_LAYOUT, (e) => {
|
35558 | if (typeof this.options.onError === 'function') {
|
35559 | this.options.onError({
|
35560 | code: 'invalid-keybinding',
|
35561 | arg: e.join('\n'),
|
35562 | });
|
35563 | }
|
35564 | console.error(e.join('\n'));
|
35565 | });
|
35566 | return this._keybindings;
|
35567 | }
|
35568 | setOptions(config) {
|
35569 | var _a, _b, _c, _d;
|
35570 | this.options = update(this.options, config);
|
35571 | this.model.setListeners({
|
35572 | onContentDidChange: (_sender) => this.options.onContentDidChange(this),
|
35573 | onSelectionDidChange: (_sender) => this._onSelectionDidChange(),
|
35574 | onContentWillChange: () => this.options.onContentWillChange(this),
|
35575 | onSelectionWillChange: () => this.options.onSelectionWillChange(this),
|
35576 | onError: this.options.onError,
|
35577 | onPlaceholderDidChange: (_sender, placeholderId) => this.options.onPlaceholderDidChange(this, placeholderId),
|
35578 | });
|
35579 | this.model.setHooks({
|
35580 | announce: (_sender, command, previousPosition, atoms) => { var _a, _b; return (_b = (_a = this.options).onAnnounce) === null || _b === void 0 ? void 0 : _b.call(_a, this, command, previousPosition, atoms); },
|
35581 | moveOut: (_sender, direction) => this.options.onMoveOutOf(this, direction),
|
35582 | tabOut: (_sender, direction) => this.options.onTabOutOf(this, direction),
|
35583 | });
|
35584 | if (!this.options.locale.startsWith(getActiveKeyboardLayout().locale)) {
|
35585 | setKeyboardLayoutLocale(this.options.locale);
|
35586 | }
|
35587 | this._keybindings = undefined;
|
35588 | this.plonkSound = this.options.plonkSound;
|
35589 | if (this.options.keypressSound &&
|
35590 | typeof this.options.keypressSound !== 'string' &&
|
35591 | !(this.options.keypressSound instanceof HTMLAudioElement)) {
|
35592 | this.keypressSound = this.options.keypressSound
|
35593 | .default;
|
35594 | this.spacebarKeypressSound = this.options.keypressSound
|
35595 | .spacebar;
|
35596 | this.returnKeypressSound = this.options.keypressSound
|
35597 | .return;
|
35598 | this.deleteKeypressSound = this.options.keypressSound
|
35599 | .delete;
|
35600 | }
|
35601 | if (this.options.readOnly) {
|
35602 | this.onBlur();
|
35603 | this.element.classList.add('ML__isReadOnly');
|
35604 | }
|
35605 | else {
|
35606 | this.element.classList.remove('ML__isReadOnly');
|
35607 | }
|
35608 | if (this.options.defaultMode === 'inline-math') {
|
35609 | this.element.classList.add('ML__isInline');
|
35610 | }
|
35611 | else {
|
35612 | this.element.classList.remove('ML__isInline');
|
35613 | }
|
35614 | (_a = this.virtualKeyboard) === null || _a === void 0 ? void 0 : _a.setOptions(this.options);
|
35615 | if (!this.options.readOnly &&
|
35616 | this.options.virtualKeyboardMode === 'manual') {
|
35617 | (_b = this.virtualKeyboardToggle) === null || _b === void 0 ? void 0 : _b.classList.add('is-visible');
|
35618 | }
|
35619 | else {
|
35620 | (_c = this.virtualKeyboardToggle) === null || _c === void 0 ? void 0 : _c.classList.remove('is-visible');
|
35621 | }
|
35622 | if ('virtualKeyboardToggleGlyph' in config) {
|
35623 | const toggle = (_d = this.element) === null || _d === void 0 ? void 0 : _d.querySelector('.ML__virtual-keyboard-toggle');
|
35624 | if (toggle) {
|
35625 | toggle.innerHTML = this.options.createHTML(this.options.virtualKeyboardToggleGlyph);
|
35626 | }
|
35627 | }
|
35628 | this.colorMap = (name) => {
|
35629 | let result = undefined;
|
35630 | if (typeof this.options.colorMap === 'function') {
|
35631 | result = this.options.colorMap(name);
|
35632 | }
|
35633 | if (!result)
|
35634 | result = defaultColorMap(name);
|
35635 | return result;
|
35636 | };
|
35637 | this.backgroundColorMap = (name) => {
|
35638 | let result = undefined;
|
35639 | if (typeof this.options.backgroundColorMap === 'function') {
|
35640 | result = this.options.backgroundColorMap(name);
|
35641 | }
|
35642 | if (!result && typeof this.options.colorMap === 'function') {
|
35643 | result = this.options.colorMap(name);
|
35644 | }
|
35645 | if (!result)
|
35646 | result = defaultBackgroundColorMap(name);
|
35647 | return result;
|
35648 | };
|
35649 | // Changing some config options (i.e. `macros`) may
|
35650 | // require the content to be reparsed and re-rendered
|
35651 | const content = Atom.serialize(this.model.root, {
|
35652 | expandMacro: false,
|
35653 | defaultMode: this.options.defaultMode,
|
35654 | });
|
35655 | if ('macros' in config || this.model.getValue() !== content) {
|
35656 | ModeEditor.insert('math', this.model, content, {
|
35657 | insertionMode: 'replaceAll',
|
35658 | selectionMode: 'after',
|
35659 | format: 'latex',
|
35660 | suppressChangeNotifications: true,
|
35661 | macros: this.options.macros,
|
35662 | });
|
35663 | }
|
35664 | requestUpdate(this);
|
35665 | }
|
35666 | getOptions(keys) {
|
35667 | return get(this.options, keys);
|
35668 | }
|
35669 | getOption(key) {
|
35670 | return get(this.options, key);
|
35671 | }
|
35672 | /*
|
35673 | * HandleEvent is a function invoked when an event is registered with an
|
35674 | * object instead ( see `addEventListener()` in `on()`)
|
35675 | * The name is defined by `addEventListener()` and cannot be changed.
|
35676 | * This pattern is used to be able to release bound event handlers,
|
35677 | * (event handlers that need access to `this`) as the bind() function
|
35678 | * would create a new function that would have to be kept track off
|
35679 | * to be able to properly remove the event handler later.
|
35680 | */
|
35681 | handleEvent(evt) {
|
35682 | switch (evt.type) {
|
35683 | case 'focus':
|
35684 | if (!this.eventHandlingInProgress) {
|
35685 | this.eventHandlingInProgress = 'focus';
|
35686 | this.onFocus();
|
35687 | this.eventHandlingInProgress = '';
|
35688 | }
|
35689 | break;
|
35690 | case 'blur':
|
35691 | if (!this.eventHandlingInProgress) {
|
35692 | this.eventHandlingInProgress = 'blur';
|
35693 | this.onBlur();
|
35694 | this.eventHandlingInProgress = '';
|
35695 | }
|
35696 | break;
|
35697 | case 'touchstart':
|
35698 | case 'mousedown':
|
35699 | // IOS <=13 Safari and Firefox on Android
|
35700 | onPointerDown(this, evt);
|
35701 | break;
|
35702 | case 'pointerdown':
|
35703 | onPointerDown(this, evt);
|
35704 | break;
|
35705 | case 'resize': {
|
35706 | if (this.resizeTimer) {
|
35707 | cancelAnimationFrame(this.resizeTimer);
|
35708 | }
|
35709 | this.resizeTimer = requestAnimationFrame(() => isValidMathfield(this) && this.onResize());
|
35710 | break;
|
35711 | }
|
35712 | default:
|
35713 | console.warn('Unexpected event type', evt.type);
|
35714 | }
|
35715 | }
|
35716 | dispose() {
|
35717 | if (!isValidMathfield(this))
|
35718 | return;
|
35719 | off(this.element, 'pointerdown', this);
|
35720 | off(this.element, 'touchstart:active mousedown', this);
|
35721 | off(this.element, 'focus', this);
|
35722 | off(this.element, 'blur', this);
|
35723 | off(window, 'resize', this);
|
35724 | this.element.innerHTML = this.getValue();
|
35725 | delete this.element.mathfield;
|
35726 | delete this.accessibleNode;
|
35727 | delete this.ariaLiveText;
|
35728 | delete this.field;
|
35729 | delete this.fieldContent;
|
35730 | delete this.keyboardDelegate;
|
35731 | this.virtualKeyboardToggle.remove();
|
35732 | delete this.virtualKeyboardToggle;
|
35733 | if (this.virtualKeyboard) {
|
35734 | this.virtualKeyboard.dispose();
|
35735 | delete this.virtualKeyboard;
|
35736 | }
|
35737 | disposePopover(this);
|
35738 | disposeKeystrokeCaption(this);
|
35739 | delete this.element;
|
35740 | this.stylesheets.forEach((x) => x === null || x === void 0 ? void 0 : x.release());
|
35741 | }
|
35742 | resetKeystrokeBuffer(options) {
|
35743 | options = options !== null && options !== void 0 ? options : { defer: false };
|
35744 | if (options.defer) {
|
35745 | // If there is a timeout greater than 0, defer the reset
|
35746 | // If the timeout is 0, never do the reset: regardless of the amount
|
35747 | // of time between keystrokes, consider them as candidates for
|
35748 | // a shortcut
|
35749 | if (this.options.inlineShortcutTimeout > 0) {
|
35750 | // Set a timer to reset the shortcut buffer
|
35751 | this.keystrokeBufferResetTimer = setTimeout(() => {
|
35752 | this.resetKeystrokeBuffer();
|
35753 | }, this.options.inlineShortcutTimeout);
|
35754 | }
|
35755 | return;
|
35756 | }
|
35757 | this.keystrokeBuffer = '';
|
35758 | this.keystrokeBufferStates = [];
|
35759 | clearTimeout(this.keystrokeBufferResetTimer);
|
35760 | }
|
35761 | executeCommand(command) {
|
35762 | var _a, _b;
|
35763 | if (getCommandTarget(command) === 'virtual-keyboard') {
|
35764 | return (_b = (_a = this.virtualKeyboard) === null || _a === void 0 ? void 0 : _a.executeCommand(command)) !== null && _b !== void 0 ? _b : false;
|
35765 | }
|
35766 | return perform(this, command);
|
35767 | }
|
35768 | get lastOffset() {
|
35769 | return this.model.lastOffset;
|
35770 | }
|
35771 | get selection() {
|
35772 | return this.model.selection;
|
35773 | }
|
35774 | set selection(value) {
|
35775 | this.model.selection = value;
|
35776 | }
|
35777 | getValue(arg1, arg2, arg3) {
|
35778 | return this.model.getValue(arg1, arg2, arg3);
|
35779 | }
|
35780 | setValue(value, options) {
|
35781 | var _a;
|
35782 | options = options !== null && options !== void 0 ? options : { mode: 'math' };
|
35783 | if (options.insertionMode === undefined) {
|
35784 | options.insertionMode = 'replaceAll';
|
35785 | }
|
35786 | if (options.format === undefined || options.format === 'auto') {
|
35787 | options.format = 'latex';
|
35788 | }
|
35789 | let mode = 'math';
|
35790 | if (options.mode === undefined || options.mode === 'auto') {
|
35791 | mode = (_a = getMode(this.model, this.model.position)) !== null && _a !== void 0 ? _a : 'math';
|
35792 | }
|
35793 | if (ModeEditor.insert(mode, this.model, value, {
|
35794 | ...options,
|
35795 | colorMap: this.colorMap,
|
35796 | backgroundColorMap: this.backgroundColorMap,
|
35797 | })) {
|
35798 | this.undoManager.snapshot(this.options);
|
35799 | requestUpdate(this);
|
35800 | }
|
35801 | }
|
35802 | find(value, options) {
|
35803 | return find(this.model, value, options);
|
35804 | }
|
35805 | replace(searchValue, newValue, options) {
|
35806 | replace(this.model, searchValue, newValue, options);
|
35807 | }
|
35808 | getPlaceholderField(placeholderId) {
|
35809 | var _a;
|
35810 | return (_a = this._placeholders.get(placeholderId)) === null || _a === void 0 ? void 0 : _a.field;
|
35811 | }
|
35812 | scrollIntoView() {
|
35813 | var _a;
|
35814 | // If a render is pending, do it now to make sure we have correct layout
|
35815 | // and caret position
|
35816 | if (this.dirty) {
|
35817 | render(this);
|
35818 | }
|
35819 | const fieldBounds = this.field.getBoundingClientRect();
|
35820 | let caretPoint = undefined;
|
35821 | if (this.model.selectionIsCollapsed) {
|
35822 | caretPoint = (_a = getCaretPoint(this.field)) === null || _a === void 0 ? void 0 : _a.x;
|
35823 | }
|
35824 | else {
|
35825 | const selectionBounds = getSelectionBounds(this);
|
35826 | if (selectionBounds.length > 0) {
|
35827 | let maxRight = -Infinity;
|
35828 | for (const r of selectionBounds) {
|
35829 | if (r.right > maxRight)
|
35830 | maxRight = r.right;
|
35831 | }
|
35832 | caretPoint = maxRight + fieldBounds.left - this.field.scrollLeft;
|
35833 | }
|
35834 | }
|
35835 | if (caretPoint !== undefined) {
|
35836 | const x = caretPoint - window.scrollX;
|
35837 | if (x < fieldBounds.left) {
|
35838 | this.field.scroll({
|
35839 | top: 0,
|
35840 | left: x - fieldBounds.left + this.field.scrollLeft - 20,
|
35841 | behavior: 'smooth',
|
35842 | });
|
35843 | }
|
35844 | else if (x > fieldBounds.right) {
|
35845 | this.field.scroll({
|
35846 | top: 0,
|
35847 | left: x - fieldBounds.right + this.field.scrollLeft + 20,
|
35848 | behavior: 'smooth',
|
35849 | });
|
35850 | }
|
35851 | }
|
35852 | }
|
35853 | insert(s, options) {
|
35854 | var _a;
|
35855 | if (typeof s === 'string' && s.length > 0) {
|
35856 | options = options !== null && options !== void 0 ? options : { mode: 'math' };
|
35857 | if (options.focus) {
|
35858 | this.focus();
|
35859 | }
|
35860 | if (options.feedback) {
|
35861 | if (this.options.keypressVibration && canVibrate()) {
|
35862 | navigator.vibrate(HAPTIC_FEEDBACK_DURATION);
|
35863 | }
|
35864 | void ((_a = this.keypressSound) === null || _a === void 0 ? void 0 : _a.play().catch(console.warn));
|
35865 | }
|
35866 | if (options.scrollIntoView) {
|
35867 | this.scrollIntoView();
|
35868 | }
|
35869 | if (s === '\\\\') {
|
35870 | // This string is interpreted as an "insert row after" command
|
35871 | addRowAfter(this.model);
|
35872 | }
|
35873 | else if (s === '&') {
|
35874 | addColumnAfter(this.model);
|
35875 | }
|
35876 | else {
|
35877 | const savedStyle = this.style;
|
35878 | ModeEditor.insert(this.mode, this.model, s, {
|
35879 | style: this.model.at(this.model.position).computedStyle,
|
35880 | ...options,
|
35881 | });
|
35882 | if (options.resetStyle) {
|
35883 | this.style = savedStyle;
|
35884 | }
|
35885 | }
|
35886 | this.undoManager.snapshot(this.options);
|
35887 | requestUpdate(this);
|
35888 | return true;
|
35889 | }
|
35890 | return false;
|
35891 | }
|
35892 | switchMode(mode, prefix = '', suffix = '') {
|
35893 | if (this.mode === mode || this.options.readOnly)
|
35894 | return;
|
35895 | const { model } = this;
|
35896 | model.deferNotifications({ content: Boolean(suffix) || Boolean(prefix), selection: true }, () => {
|
35897 | var _a;
|
35898 | let contentChanged = false;
|
35899 | this.resetKeystrokeBuffer();
|
35900 | // Suppress (temporarily) smart mode if switching to/from text or math
|
35901 | // This prevents switching to/from command mode from suppressing smart mode.
|
35902 | this.smartModeSuppressed =
|
35903 | /text|math/.test(this.mode) && /text|math/.test(mode);
|
35904 | if (prefix && mode !== 'latex') {
|
35905 | const atoms = parseLatex(prefix, {
|
35906 | parseMode: { math: 'text', text: 'math' }[mode],
|
35907 | });
|
35908 | model.collapseSelection('forward');
|
35909 | const cursor = model.at(model.position);
|
35910 | model.position = model.offsetOf(cursor.parent.addChildrenAfter(atoms, cursor));
|
35911 | contentChanged = true;
|
35912 | }
|
35913 | this.mode = mode;
|
35914 | if (mode === 'latex') {
|
35915 | let wasCollapsed = model.selectionIsCollapsed;
|
35916 | // We can have only a single latex group at a time.
|
35917 | // If a latex group is open, close it first
|
35918 | complete(this, 'accept');
|
35919 | // Switch to the command mode keyboard layer
|
35920 | if ((_a = this.virtualKeyboard) === null || _a === void 0 ? void 0 : _a.visible) {
|
35921 | this.executeCommand(['switchKeyboardLayer', 'latex-lower']);
|
35922 | }
|
35923 | // Insert a latex group atom
|
35924 | let latex;
|
35925 | let cursor = model.at(model.position);
|
35926 | if (wasCollapsed) {
|
35927 | latex = '\\';
|
35928 | }
|
35929 | else {
|
35930 | const selRange = range(model.selection);
|
35931 | latex = this.model.getValue(selRange, 'latex');
|
35932 | const extractedAtoms = this.model.extractAtoms(selRange);
|
35933 | if (extractedAtoms.length === 1 &&
|
35934 | extractedAtoms[0] instanceof PlaceholderAtom) {
|
35935 | // If we just had a placeholder selected, pretend we had an empty
|
35936 | // selection
|
35937 | latex = prefix;
|
35938 | wasCollapsed = true;
|
35939 | }
|
35940 | cursor = model.at(selRange[0]);
|
35941 | }
|
35942 | const atom = new LatexGroupAtom(latex);
|
35943 | cursor.parent.addChildAfter(atom, cursor);
|
35944 | if (wasCollapsed) {
|
35945 | model.position = model.offsetOf(atom.lastChild);
|
35946 | }
|
35947 | else {
|
35948 | model.setSelection(model.offsetOf(atom.firstChild), model.offsetOf(atom.lastChild));
|
35949 | }
|
35950 | }
|
35951 | else {
|
35952 | // Remove any error indicator on the current command sequence (if there is one)
|
35953 | getLatexGroupBody(model).forEach((x) => {
|
35954 | x.isError = false;
|
35955 | });
|
35956 | }
|
35957 | if (suffix) {
|
35958 | const atoms = parseLatex(suffix, {
|
35959 | parseMode: { math: 'text', text: 'math' }[mode],
|
35960 | });
|
35961 | model.collapseSelection('forward');
|
35962 | const cursor = model.at(model.position);
|
35963 | model.position = model.offsetOf(cursor.parent.addChildrenAfter(atoms, cursor));
|
35964 | contentChanged = true;
|
35965 | }
|
35966 | // Notify of mode change
|
35967 | if (typeof this.options.onModeChange === 'function') {
|
35968 | this.options.onModeChange(this, this.mode);
|
35969 | }
|
35970 | requestUpdate(this);
|
35971 | return contentChanged;
|
35972 | });
|
35973 | }
|
35974 | hasFocus() {
|
35975 | return (isBrowser() && document.hasFocus() && this.keyboardDelegate.hasFocus());
|
35976 | }
|
35977 | focus() {
|
35978 | if (!this.hasFocus()) {
|
35979 | this.keyboardDelegate.focus();
|
35980 | this.model.announce('line');
|
35981 | }
|
35982 | }
|
35983 | blur() {
|
35984 | if (this.hasFocus()) {
|
35985 | this.keyboardDelegate.blur();
|
35986 | }
|
35987 | }
|
35988 | select() {
|
35989 | this.model.selection = { ranges: [[0, this.model.lastOffset]] };
|
35990 | }
|
35991 | applyStyle(inStyle, inOptions = {}) {
|
35992 | var _a, _b;
|
35993 | const options = {
|
35994 | operation: 'set',
|
35995 | suppressChangeNotifications: false,
|
35996 | };
|
35997 | if (isRange(inOptions)) {
|
35998 | options.range = inOptions;
|
35999 | }
|
36000 | else {
|
36001 | options.range = inOptions.range;
|
36002 | options.suppressChangeNotifications =
|
36003 | (_a = inOptions.suppressChangeNotifications) !== null && _a !== void 0 ? _a : false;
|
36004 | }
|
36005 | const style = validateStyle(this, inStyle);
|
36006 | const operation = (_b = options.operation) !== null && _b !== void 0 ? _b : 'set';
|
36007 | this.model.deferNotifications({ content: !options.suppressChangeNotifications }, () => {
|
36008 | if (options.range === undefined) {
|
36009 | this.model.selection.ranges.forEach((range) => applyStyle$1(this.model, range, style, { operation }));
|
36010 | }
|
36011 | else {
|
36012 | applyStyle$1(this.model, options.range, style, { operation });
|
36013 | }
|
36014 | });
|
36015 | requestUpdate(this);
|
36016 | }
|
36017 | getCaretPoint() {
|
36018 | const caretOffset = getCaretPoint(this.field);
|
36019 | return caretOffset ? { x: caretOffset.x, y: caretOffset.y } : null;
|
36020 | }
|
36021 | setCaretPoint(x, y) {
|
36022 | const newPosition = offsetFromPoint(this, x, y, { bias: 0 });
|
36023 | if (newPosition < 0)
|
36024 | return false;
|
36025 | const previousPosition = this.model.position;
|
36026 | this.model.position = newPosition;
|
36027 | this.model.announce('move', previousPosition);
|
36028 | requestUpdate(this);
|
36029 | return true;
|
36030 | }
|
36031 | attachNestedMathfield() {
|
36032 | let needsUpdate = false;
|
36033 | this._placeholders.forEach((v) => {
|
36034 | var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
36035 | const container = (_a = this.field) === null || _a === void 0 ? void 0 : _a.querySelector(`[data-placeholder-id=${v.atom.placeholderId}]`);
|
36036 | if (container) {
|
36037 | const placeholderPosition = container.getBoundingClientRect();
|
36038 | const parentPosition = (_b = this.field) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
|
36039 | const scaleDownFontsize = parseInt(window.getComputedStyle(container).fontSize) * 0.6;
|
36040 | if (!v.field.style.fontSize ||
|
36041 | Math.abs(scaleDownFontsize - parseFloat(v.field.style.fontSize)) >=
|
36042 | 0.2) {
|
36043 | needsUpdate = true;
|
36044 | v.field.style.fontSize = `${scaleDownFontsize}px`;
|
36045 | }
|
36046 | const newTop = ((_c = placeholderPosition === null || placeholderPosition === void 0 ? void 0 : placeholderPosition.top) !== null && _c !== void 0 ? _c : 0) -
|
36047 | ((_d = parentPosition === null || parentPosition === void 0 ? void 0 : parentPosition.top) !== null && _d !== void 0 ? _d : 0) +
|
36048 | ((_f = (_e = this.element) === null || _e === void 0 ? void 0 : _e.offsetTop) !== null && _f !== void 0 ? _f : 0);
|
36049 | const newLeft = ((_g = placeholderPosition === null || placeholderPosition === void 0 ? void 0 : placeholderPosition.left) !== null && _g !== void 0 ? _g : 0) -
|
36050 | ((_h = parentPosition === null || parentPosition === void 0 ? void 0 : parentPosition.left) !== null && _h !== void 0 ? _h : 0) +
|
36051 | ((_k = (_j = this.element) === null || _j === void 0 ? void 0 : _j.offsetLeft) !== null && _k !== void 0 ? _k : 0);
|
36052 | if (!v.field.style.left ||
|
36053 | Math.abs(newLeft - parseFloat(v.field.style.left)) >= 1) {
|
36054 | needsUpdate = true;
|
36055 | v.field.style.left = `${newLeft}px`;
|
36056 | }
|
36057 | if (!v.field.style.top ||
|
36058 | Math.abs(newTop - parseFloat(v.field.style.top)) >= 1) {
|
36059 | needsUpdate = true;
|
36060 | v.field.style.top = `${newTop}px`;
|
36061 | }
|
36062 | console.log('attaching', !!v.field.style.left, !!v.field.style.top);
|
36063 | }
|
36064 | });
|
36065 | if (needsUpdate) {
|
36066 | requestUpdate(this);
|
36067 | }
|
36068 | }
|
36069 | canUndo() {
|
36070 | return this.undoManager.canUndo();
|
36071 | }
|
36072 | canRedo() {
|
36073 | return this.undoManager.canRedo();
|
36074 | }
|
36075 | popUndoStack() {
|
36076 | this.undoManager.pop();
|
36077 | }
|
36078 | snapshot() {
|
36079 | this.undoManager.snapshot({
|
36080 | ...this.options,
|
36081 | onUndoStateDidChange: (mf, reason) => {
|
36082 | var _a;
|
36083 | (_a = this.virtualKeyboard) === null || _a === void 0 ? void 0 : _a.executeCommand([
|
36084 | 'onUndoStateChanged',
|
36085 | this.canUndo(),
|
36086 | this.canRedo(),
|
36087 | ]);
|
36088 | this.options.onUndoStateDidChange(mf, reason);
|
36089 | },
|
36090 | });
|
36091 | }
|
36092 | snapshotAndCoalesce() {
|
36093 | this.undoManager.snapshotAndCoalesce({
|
36094 | ...this.options,
|
36095 | onUndoStateDidChange: (mf, reason) => {
|
36096 | var _a;
|
36097 | (_a = this.virtualKeyboard) === null || _a === void 0 ? void 0 : _a.executeCommand([
|
36098 | 'onUndoStateChanged',
|
36099 | this.canUndo(),
|
36100 | this.canRedo(),
|
36101 | ]);
|
36102 | this.options.onUndoStateDidChange(mf, reason);
|
36103 | },
|
36104 | });
|
36105 | }
|
36106 | getUndoRecord() {
|
36107 | return this.undoManager.save();
|
36108 | }
|
36109 | restoreToUndoRecord(s) {
|
36110 | this.undoManager.restore(s, {
|
36111 | ...this.options,
|
36112 | suppressChangeNotifications: true,
|
36113 | });
|
36114 | }
|
36115 | undo() {
|
36116 | return this.undoManager.undo({
|
36117 | ...this.options,
|
36118 | onUndoStateDidChange: (mf, reason) => {
|
36119 | this.virtualKeyboard.executeCommand([
|
36120 | 'onUndoStateChanged',
|
36121 | this.canUndo(),
|
36122 | this.canRedo(),
|
36123 | ]);
|
36124 | this.options.onUndoStateDidChange(mf, reason);
|
36125 | },
|
36126 | });
|
36127 | }
|
36128 | redo() {
|
36129 | return this.undoManager.redo({
|
36130 | ...this.options,
|
36131 | onUndoStateDidChange: (mf, reason) => {
|
36132 | var _a;
|
36133 | (_a = this.virtualKeyboard) === null || _a === void 0 ? void 0 : _a.executeCommand([
|
36134 | 'onUndoStateChanged',
|
36135 | this.canUndo(),
|
36136 | this.canRedo(),
|
36137 | ]);
|
36138 | this.options.onUndoStateDidChange(mf, reason);
|
36139 | },
|
36140 | });
|
36141 | }
|
36142 | _onSelectionDidChange() {
|
36143 | var _a, _b;
|
36144 | // Keep the content of the textarea in sync wiht the selection.
|
36145 | // This will allow cut/copy to work.
|
36146 | this.keyboardDelegate.setValue(this.getValue(this.model.selection, 'latex-expanded'));
|
36147 | const selectedAtoms = this.model.getAtoms(this.model.selection);
|
36148 | if (selectedAtoms.length === 1 && selectedAtoms[0].type === 'placeholder') {
|
36149 | const placeholder = selectedAtoms[0];
|
36150 | if (this.model.mathfield._placeholders.has(placeholder.placeholderId)) {
|
36151 | (_a = this.model.mathfield._placeholders
|
36152 | .get(placeholder.placeholderId)) === null || _a === void 0 ? void 0 : _a.field.focus();
|
36153 | }
|
36154 | }
|
36155 | // Adjust mode
|
36156 | {
|
36157 | const cursor = this.model.at(this.model.position);
|
36158 | const newMode = (_b = cursor.mode) !== null && _b !== void 0 ? _b : effectiveMode(this.options);
|
36159 | if (this.mode !== newMode) {
|
36160 | if (this.mode === 'latex') {
|
36161 | complete(this, 'accept', { mode: newMode });
|
36162 | this.model.position = this.model.offsetOf(cursor);
|
36163 | }
|
36164 | else {
|
36165 | this.switchMode(newMode);
|
36166 | }
|
36167 | }
|
36168 | }
|
36169 | // Invoke client listeners, if provided.
|
36170 | if (typeof this.options.onSelectionDidChange === 'function') {
|
36171 | this.options.onSelectionDidChange(this);
|
36172 | }
|
36173 | }
|
36174 | onFocus() {
|
36175 | var _a, _b, _c;
|
36176 | if (this.blurred) {
|
36177 | this.blurred = false;
|
36178 | this.keyboardDelegate.focus();
|
36179 | (_a = this.virtualKeyboard) === null || _a === void 0 ? void 0 : _a.enable();
|
36180 | if (this.options.virtualKeyboardMode === 'onfocus') {
|
36181 | this.executeCommand('showVirtualKeyboard');
|
36182 | }
|
36183 | updatePopoverPosition(this);
|
36184 | (_c = (_b = this.options).onFocus) === null || _c === void 0 ? void 0 : _c.call(_b, this);
|
36185 | // Save the current value.
|
36186 | // It will be compared in `onBlur()` to see if the
|
36187 | // `onCommit` listener needs to be invoked. This
|
36188 | // mimic the `<input>` and `<textarea>` behavior
|
36189 | this.valueOnFocus = this.getValue();
|
36190 | requestUpdate(this);
|
36191 | }
|
36192 | }
|
36193 | onBlur() {
|
36194 | var _a;
|
36195 | if (!this.blurred) {
|
36196 | this.blurred = true;
|
36197 | this.ariaLiveText.textContent = '';
|
36198 | if (/onfocus|manual/.test(this.options.virtualKeyboardMode)) {
|
36199 | this.executeCommand('hideVirtualKeyboard');
|
36200 | }
|
36201 | complete(this, 'accept');
|
36202 | requestUpdate(this);
|
36203 | if (typeof this.options.onBlur === 'function') {
|
36204 | this.options.onBlur(this);
|
36205 | }
|
36206 | (_a = this.virtualKeyboard) === null || _a === void 0 ? void 0 : _a.disable();
|
36207 | if (typeof this.options.onCommit === 'function' &&
|
36208 | this.getValue() !== this.valueOnFocus) {
|
36209 | this.options.onCommit(this);
|
36210 | }
|
36211 | }
|
36212 | }
|
36213 | onCompositionStart(_composition) {
|
36214 | // Clear the selection if there is one
|
36215 | this.model.position = this.model.deleteAtoms(range(this.model.selection));
|
36216 | requestAnimationFrame(() => {
|
36217 | render(this); // Recalculate the position of the caret
|
36218 | // Synchronize the location and style of textarea
|
36219 | // so that the IME candidate window can align with the composition
|
36220 | const caretPoint = getCaretPoint(this.field);
|
36221 | if (!caretPoint)
|
36222 | return;
|
36223 | this.keyboardDelegate.moveTo(caretPoint.x, caretPoint.y);
|
36224 | });
|
36225 | }
|
36226 | onCompositionUpdate(composition) {
|
36227 | updateComposition(this.model, composition);
|
36228 | requestUpdate(this);
|
36229 | }
|
36230 | onCompositionEnd(composition) {
|
36231 | removeComposition(this.model);
|
36232 | onTypedText(this, composition, {
|
36233 | simulateKeystroke: true,
|
36234 | });
|
36235 | }
|
36236 | onResize() {
|
36237 | if (!isValidMathfield(this))
|
36238 | return;
|
36239 | this.element.classList.remove('ML__isNarrowWidth', 'ML__isWideWidth', 'ML__isExtendedWidth');
|
36240 | if (window.innerWidth >= 1024) {
|
36241 | this.element.classList.add('ML__isExtendedWidth');
|
36242 | }
|
36243 | else if (window.innerWidth >= 768) {
|
36244 | this.element.classList.add('ML__isWideWidth');
|
36245 | }
|
36246 | else {
|
36247 | this.element.classList.add('ML__isNarrowWidth');
|
36248 | }
|
36249 | updatePopoverPosition(this);
|
36250 | }
|
36251 | }
|
36252 |
|
36253 | var _a, _b;
|
36254 | //
|
36255 | // Note: the `position: relative` is required to fix https://github.com/arnog/mathlive/issues/971
|
36256 | //
|
36257 | const MATHFIELD_TEMPLATE = document.createElement('template');
|
36258 | MATHFIELD_TEMPLATE.innerHTML = `<style>
|
36259 | :host { display: block; position: relative; }
|
36260 | :host([hidden]) { display: none; }
|
36261 | :host([disabled]) { opacity: .5; }
|
36262 | :host(:focus), :host(:focus-within) {
|
36263 | outline: Highlight auto 1px; /* For Firefox */
|
36264 | outline: -webkit-focus-ring-color auto 1px;
|
36265 | }
|
36266 | :host([readonly]), :host([read-only]) { outline: none; }
|
36267 | </style>
|
36268 | <div></div><slot style="display:none"></slot>`;
|
36269 | //
|
36270 | // Deferred State
|
36271 | //
|
36272 | // Methods such as `setOptions()` or `getOptions()` could be called before
|
36273 | // the element has been connected (i.e. `mf = new MathfieldElement(); mf.setConfig()`...)
|
36274 | // and therefore before the mathfield instance has been created.
|
36275 | // So we'll stash any deferred operations on options (and value) here, and
|
36276 | // will apply them to the element when it gets connected to the DOM.
|
36277 | //
|
36278 | const gDeferredState = new WeakMap();
|
36279 | /**
|
36280 | * The `MathfieldElement` class provides special properties and
|
36281 | * methods to control the display and behavior of `<math-field>`
|
36282 | * elements.
|
36283 | *
|
36284 | * It inherits many useful properties and methods from [[`HTMLElement`]] such
|
36285 | * as `style`, `tabIndex`, `addEventListener()`, `getAttribute()`, etc...
|
36286 | *
|
36287 | * To create a new `MathfieldElement`:
|
36288 | *
|
36289 | * ```javascript
|
36290 | * // 1. Create a new MathfieldElement
|
36291 | * const mfe = new MathfieldElement();
|
36292 | * // 2. Attach it to the DOM
|
36293 | * document.body.appendChild(mfe);
|
36294 | * ```
|
36295 | *
|
36296 | * The `MathfieldElement` constructor has an optional argument of
|
36297 | * [[`MathfieldOptions`]] to configure the element. The options can also
|
36298 | * be modified later:
|
36299 | *
|
36300 | * ```javascript
|
36301 | * // Setting options during construction
|
36302 | * const mfe = new MathfieldElement({smartFence: false});
|
36303 | * // Modifying options after construction
|
36304 | * mfe.setOptions({smartFence: true});
|
36305 | * ```
|
36306 | *
|
36307 | * ### CSS Variables
|
36308 | *
|
36309 | * To customize the appearance of the mathfield, declare the following CSS
|
36310 | * variables (custom properties) in a ruleset that applied to the mathfield.
|
36311 | * ```css
|
36312 | * math-field {
|
36313 | * --hue: 10 // Set the highlight color and caret to a reddish hue
|
36314 | * }
|
36315 | * ```
|
36316 | *
|
36317 | * | CSS Variable | Usage |
|
36318 | * |:---|:---|
|
36319 | * | `--hue` | Hue of the highlight color and the caret |
|
36320 | * | `--highlight` | Color of the selection |
|
36321 | * | `--contains-highlight` | Backround property for items that contain the caret |
|
36322 | * | `--highlight-inactive` | Color of the selection, when the mathfield is not focused |
|
36323 | * | `--caret` | Color of the caret/insertion point |
|
36324 | * | `--primary` | Primary accent color, used for example in the virtual keyboard |
|
36325 | * | `--text-font-family` | The font stack used in text mode |
|
36326 | * | `--keyboard-zindex` | The z-index attribute of the virtual keyboard panel |
|
36327 | * | `--smart-fence-opacity` | Opacity of a smart gence (default is 50%) |
|
36328 | * | `--smart-fence-color` | Color of a smart fence (default is current color) |
|
36329 | *
|
36330 | * ### CSS Parts
|
36331 | *
|
36332 | * To style the virtual keyboard toggle, use the `virtual-keyboard-toggle` CSS
|
36333 | * part. To use it, define a CSS rule with a `::part()` selector
|
36334 | * for example:
|
36335 | * ```css
|
36336 | * math-field::part(virtual-keyboard-toggle) {
|
36337 | * color: red;
|
36338 | * }
|
36339 | * ```
|
36340 | *
|
36341 | *
|
36342 | * ### Attributes
|
36343 | *
|
36344 | * An attribute is a key-value pair set as part of the tag:
|
36345 | *
|
36346 | * ```html
|
36347 | * <math-field locale="fr"></math-field>
|
36348 | * ```
|
36349 | *
|
36350 | * The supported attributes are listed in the table below with their correspnding
|
36351 | * property.
|
36352 | *
|
36353 | * The property can be changed either directly on the
|
36354 | * `MathfieldElement` object, or using `setOptions()` if it is prefixed with
|
36355 | * `options.`, for example
|
36356 | * ```javascript
|
36357 | * getElementById('mf').value = '\\sin x';
|
36358 | * getElementById('mf').setOptions({horizontalSpacingScale: 1.1});
|
36359 | * ```
|
36360 | *
|
36361 | * The values of attributes and properties are reflected, which means you can change one or the
|
36362 | * other, for example:
|
36363 | * ```javascript
|
36364 | * getElementById('mf').setAttribute('virtual-keyboard-mode', 'manual');
|
36365 | * console.log(getElementById('mf').getOption('virtualKeyboardMode'));
|
36366 | * // Result: "manual"
|
36367 | * getElementById('mf').setOptions({virtualKeyboardMode: 'onfocus');
|
36368 | * console.log(getElementById('mf').getAttribute('virtual-keyboard-mode');
|
36369 | * // Result: 'onfocus'
|
36370 | * ```
|
36371 | *
|
36372 | * An exception is the `value` property, which is not reflected on the `value`
|
36373 | * attribute: the `value` attribute remains at its initial value.
|
36374 | *
|
36375 | *
|
36376 | * | Attribute | Property |
|
36377 | * |:---|:---|
|
36378 | * | `disabled` | `disabled` |
|
36379 | * | `default-mode` | `options.defaultMode` |
|
36380 | * | `fonts-directory` | `options.fontsDirectory` |
|
36381 | * | `sounds-directory` | `options.soundsDirectory` |
|
36382 | * | `horizontal-spacing-scale` | `options.horizontalSpacingScale` |
|
36383 | * | `inline-shortcut-timeout` | `options.inlineShortcutTimeout` |
|
36384 | * | `keypress-vibration` | `options.keypressVibration` |
|
36385 | * | `keypress-sound` | `options.keypressSound` |
|
36386 | * | `plonk-sound` | `options.plonkSound` |
|
36387 | * | `letter-shape-style` | `options.letterShapeStyle` |
|
36388 | * | `locale` | `options.locale` |
|
36389 | * | `math-mode-space` | `options.mathModeSpace` |
|
36390 | * | `read-only` | `options.readOnly` |
|
36391 | * | `remove-extraneous-parentheses` | `options.removeExtraneousParentheses` |
|
36392 | * | `smart-fence` | `options.smartFence` |
|
36393 | * | `smart-mode` | `options.smartMode` |
|
36394 | * | `smart-superscript` | `options.superscript` |
|
36395 | * | `speech-engine` | `options.speechEngine` |
|
36396 | * | `speech-engine-rate` | `options.speechEngineRate` |
|
36397 | * | `speech-engine-voice` | `options.speechEngineVoice` |
|
36398 | * | `text-to-speech-markup` | `options.textToSpeechMarkup` |
|
36399 | * | `text-to-speech-rules` | `options.textToSpeechRules` |
|
36400 | * | `value` | value |
|
36401 | * | `virtual-keyboard-layout` | `options.keyboardLayout` |
|
36402 | * | `virtual-keyboard-mode` | `options.keyboardMode` |
|
36403 | * | `virtual-keyboard-theme` | `options.keyboardTheme` |
|
36404 | * | `virtual-keyboards` | `options.keyboards` |
|
36405 | *
|
36406 | * See [[`MathfieldOptions`]] for more details about these options.
|
36407 | *
|
36408 | * In addition, the following [global attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes)
|
36409 | * can also be used:
|
36410 | * - `class`
|
36411 | * - `data-*`
|
36412 | * - `hidden`
|
36413 | * - `id`
|
36414 | * - `item*`
|
36415 | * - `style`
|
36416 | * - `tabindex`
|
36417 | *
|
36418 | *
|
36419 | * ### Events
|
36420 | *
|
36421 | * Listen to these events by using `addEventListener()`. For events with additional
|
36422 | * arguments, the arguments are availble in `event.detail`.
|
36423 | *
|
36424 | * | Event Name | Description |
|
36425 | * |:---|:---|
|
36426 | * | `input` | The value of the mathfield has been modified. This happens on almost every keystroke in the mathfield. |
|
36427 | * | `change` | The user has commited the value of the mathfield. This happens when the user presses **Return** or leaves the mathfield. |
|
36428 | * | `selection-change` | The selection (or caret position) in the mathfield has changed |
|
36429 | * | `mode-change` | The mode (`math`, `text`) of the mathfield has changed |
|
36430 | * | `undo-state-change` | The state of the undo stack has changed |
|
36431 | * | `read-aloud-status-change` | The status of a read aloud operation has changed |
|
36432 | * | `virtual-keyboard-toggle` | The visibility of the virtual keyboard panel has changed |
|
36433 | * | `blur` | The mathfield is losing focus |
|
36434 | * | `focus` | The mathfield is gaining focus |
|
36435 | * | `focus-out` | The user is navigating out of the mathfield, typically using the **tab** key<br> `detail: {direction: 'forward' | 'backward' | 'upward' | 'downward'}` **cancellable**|
|
36436 | * | `move-out` | The user has pressed an **arrow** key, but there is nowhere to go. This is an opportunity to change the focus to another element if desired. <br> `detail: {direction: 'forward' | 'backward' | 'upward' | 'downward'}` **cancellable**|
|
36437 | * | `math-error` | A parsing or configuration error happened <br> `detail: ErrorListener<ParserErrorCode | MathfieldErrorCode>` |
|
36438 | * | `keystroke` | The user typed a keystroke with a physical keyboard <br> `detail: {keystroke: string, event: KeyboardEvent}` |
|
36439 | * | `mount` | The element has been attached to the DOM |
|
36440 | * | `unmount` | The element is about to be removed from the DOM |
|
36441 | *
|
36442 | */
|
36443 | class MathfieldElement extends HTMLElement {
|
36444 | /**
|
36445 | * To create programmatically a new mahfield use:
|
36446 | * ```javascript
|
36447 | let mfe = new MathfieldElement();
|
36448 |
|
36449 | // Set initial value and options
|
36450 | mfe.value = "\\frac{\\sin(x)}{\\cos(x)}";
|
36451 |
|
36452 | // Options can be set either as an attribute (for simple options)...
|
36453 | mfe.setAttribute('virtual-keyboard-layout', 'dvorak');
|
36454 |
|
36455 | // ... or using `setOptions()`
|
36456 | mfe.setOptions({
|
36457 | virtualKeyboardMode: 'manual',
|
36458 | });
|
36459 |
|
36460 | // Attach the element to the DOM
|
36461 | document.body.appendChild(mfe);
|
36462 | * ```
|
36463 | */
|
36464 | constructor(options) {
|
36465 | throwIfNotInBrowser();
|
36466 | super();
|
36467 | this.attachShadow({ mode: 'open' });
|
36468 | this.shadowRoot.append(MATHFIELD_TEMPLATE.content.cloneNode(true));
|
36469 | // When the elements get focused (through tabbing for example)
|
36470 | // focus the mathfield
|
36471 | const slot = this.shadowRoot.querySelector('slot:not([name])');
|
36472 | this._slotValue = slot
|
36473 | .assignedNodes()
|
36474 | .map((x) => (x.nodeType === 3 ? x.textContent : ''))
|
36475 | .join('')
|
36476 | .trim();
|
36477 | // Record the (optional) configuration options, as a deferred state
|
36478 | if (options) {
|
36479 | this.setOptions(options);
|
36480 | }
|
36481 | this.shadowRoot.host.addEventListener('focus', (_event) => {
|
36482 | var _a;
|
36483 | if (!this.readOnly) {
|
36484 | (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.focus();
|
36485 | }
|
36486 | }, true);
|
36487 | this.shadowRoot.host.addEventListener('blur', (_event) => {
|
36488 | var _a;
|
36489 | if (!this.readOnly) {
|
36490 | (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.blur();
|
36491 | }
|
36492 | }, true);
|
36493 | }
|
36494 | /**
|
36495 | * Private lifecycle hooks
|
36496 | * @internal
|
36497 | */
|
36498 | static get optionsAttributes() {
|
36499 | return {
|
36500 | 'default-mode': 'string',
|
36501 | 'fonts-directory': 'string',
|
36502 | 'sounds-directory': 'string',
|
36503 | 'horizontal-spacing-scale': 'string',
|
36504 | 'math-mode-space': 'string',
|
36505 | 'inline-shortcut-timeout': 'string',
|
36506 | 'keypress-vibration': 'boolean',
|
36507 | 'keypress-sound': 'string',
|
36508 | 'plonk-sound': 'string',
|
36509 | 'letter-shape-style': 'string',
|
36510 | 'locale': 'string',
|
36511 | 'read-only': 'boolean',
|
36512 | 'remove-extraneous-parentheses': 'boolean',
|
36513 | 'smart-fence': 'boolean',
|
36514 | 'smart-mode': 'boolean',
|
36515 | 'smart-superscript': 'boolean',
|
36516 | 'speech-engine': 'string',
|
36517 | 'speech-engine-rate': 'string',
|
36518 | 'speech-engine-voice': 'string',
|
36519 | 'text-to-speech-markup': 'string',
|
36520 | 'text-to-speech-rules': 'string',
|
36521 | 'virtual-keyboard-layout': 'string',
|
36522 | 'virtual-keyboard-mode': 'string',
|
36523 | 'virtual-keyboard-theme': 'string',
|
36524 | 'virtual-keyboards': 'string',
|
36525 | 'use-shared-virtual-keyboard': 'boolean',
|
36526 | 'shared-virtual-keyboard-target-origin': 'string',
|
36527 | };
|
36528 | }
|
36529 | /**
|
36530 | * Custom elements lifecycle hooks
|
36531 | * @internal
|
36532 | */
|
36533 | static get observedAttributes() {
|
36534 | return [
|
36535 | ...Object.keys(MathfieldElement.optionsAttributes),
|
36536 | 'disabled',
|
36537 | 'readonly', // A semi-global attribute (not all standard elements support it, but some do)
|
36538 | ];
|
36539 | }
|
36540 | getPlaceholderField(placeholderId) {
|
36541 | var _a;
|
36542 | return (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.getPlaceholderField(placeholderId);
|
36543 | }
|
36544 | addEventListener(type, listener, options) {
|
36545 | return super.addEventListener(type, listener, options);
|
36546 | }
|
36547 | removeEventListener(type, listener, options) {
|
36548 | super.removeEventListener(type, listener, options);
|
36549 | }
|
36550 | get mode() {
|
36551 | var _a, _b;
|
36552 | return (_b = (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.mode) !== null && _b !== void 0 ? _b : 'math';
|
36553 | }
|
36554 | set mode(value) {
|
36555 | if (!this._mathfield)
|
36556 | return;
|
36557 | this._mathfield.mode = value;
|
36558 | }
|
36559 | getOptions(keys) {
|
36560 | if (this._mathfield) {
|
36561 | return get(this._mathfield.options, keys);
|
36562 | }
|
36563 | if (!gDeferredState.has(this))
|
36564 | return null;
|
36565 | return get(update(getDefault(), gDeferredState.get(this).options), keys);
|
36566 | }
|
36567 | /**
|
36568 | * @category Options
|
36569 | */
|
36570 | getOption(key) {
|
36571 | return this.getOptions([key])[key];
|
36572 | }
|
36573 | /**
|
36574 | * @category Options
|
36575 | */
|
36576 | setOptions(options) {
|
36577 | if (this._mathfield) {
|
36578 | this._mathfield.setOptions(options);
|
36579 | this._mathfield._placeholders.forEach((placeholder) => {
|
36580 | placeholder.field.setOptions({
|
36581 | ...options,
|
36582 | virtualKeyboardMode: 'onfocus',
|
36583 | readOnly: false,
|
36584 | });
|
36585 | });
|
36586 | }
|
36587 | else if (gDeferredState.has(this)) {
|
36588 | const mergedOptions = {
|
36589 | ...gDeferredState.get(this).options,
|
36590 | ...options,
|
36591 | };
|
36592 | gDeferredState.set(this, {
|
36593 | value: gDeferredState.get(this).value,
|
36594 | selection: { ranges: mergedOptions.readOnly ? [[0, 0]] : [[0, -1]] },
|
36595 | options: mergedOptions,
|
36596 | });
|
36597 | }
|
36598 | else {
|
36599 | gDeferredState.set(this, {
|
36600 | value: '',
|
36601 | selection: { ranges: [[0, 0]] },
|
36602 | options,
|
36603 | });
|
36604 | }
|
36605 | // Reflect options to attributes
|
36606 | reflectAttributes(this);
|
36607 | }
|
36608 | /**
|
36609 | * Execute a [[`Commands`|command]] defined by a selector.
|
36610 | * ```javascript
|
36611 | * mfe.executeCommand('add-column-after');
|
36612 | * mfe.executeCommand(['switch-mode', 'math']);
|
36613 | * ```
|
36614 | *
|
36615 | * @param command - A selector, or an array whose first element
|
36616 | * is a selector, and whose subsequent elements are arguments to the selector.
|
36617 | *
|
36618 | * Selectors can be passed either in camelCase or kebab-case.
|
36619 | *
|
36620 | * ```javascript
|
36621 | * // Both calls do the same thing
|
36622 | * mfe.executeCommand('selectAll');
|
36623 | * mfe.executeCommand('select-all');
|
36624 | * ```
|
36625 | */
|
36626 | executeCommand(command) {
|
36627 | var _a, _b;
|
36628 | return (_b = (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.executeCommand(command)) !== null && _b !== void 0 ? _b : false;
|
36629 | }
|
36630 | getValue(arg1, arg2, arg3) {
|
36631 | if (this._mathfield) {
|
36632 | return this._mathfield.getValue(arg1, arg2, arg3);
|
36633 | }
|
36634 | if (gDeferredState.has(this)) {
|
36635 | let start;
|
36636 | let end;
|
36637 | let format = undefined;
|
36638 | if (isSelection(arg1)) {
|
36639 | [start, end] = arg1.ranges[0];
|
36640 | format = arg2;
|
36641 | }
|
36642 | else if (isRange(arg1)) {
|
36643 | [start, end] = arg1;
|
36644 | format = arg2;
|
36645 | }
|
36646 | else if (isOffset(arg1) && isOffset(arg2)) {
|
36647 | start = arg1;
|
36648 | end = arg2;
|
36649 | format = arg3;
|
36650 | }
|
36651 | else {
|
36652 | start = 0;
|
36653 | end = -1;
|
36654 | format = arg1;
|
36655 | }
|
36656 | if ((format === undefined || format === 'latex') &&
|
36657 | start === 0 &&
|
36658 | end === -1) {
|
36659 | return gDeferredState.get(this).value;
|
36660 | }
|
36661 | }
|
36662 | return '';
|
36663 | }
|
36664 | /**
|
36665 | * @category Accessing and changing the content
|
36666 | */
|
36667 | setValue(value, options) {
|
36668 | if (this._mathfield) {
|
36669 | this._mathfield.setValue(value !== null && value !== void 0 ? value : '', options);
|
36670 | return;
|
36671 | }
|
36672 | if (gDeferredState.has(this)) {
|
36673 | const options = gDeferredState.get(this).options;
|
36674 | gDeferredState.set(this, {
|
36675 | value: value !== null && value !== void 0 ? value : '',
|
36676 | selection: {
|
36677 | ranges: options.readOnly ? [[0, 0]] : [[0, -1]],
|
36678 | direction: 'forward',
|
36679 | },
|
36680 | options,
|
36681 | });
|
36682 | return;
|
36683 | }
|
36684 | const attrOptions = getOptionsFromAttributes(this);
|
36685 | gDeferredState.set(this, {
|
36686 | value: value !== null && value !== void 0 ? value : '',
|
36687 | selection: {
|
36688 | ranges: attrOptions.readOnly ? [[0, 0]] : [[0, -1]],
|
36689 | direction: 'forward',
|
36690 | },
|
36691 | options: attrOptions,
|
36692 | });
|
36693 | }
|
36694 | /**
|
36695 | * Return true if the mathfield is currently focused (responds to keyboard
|
36696 | * input).
|
36697 | *
|
36698 | * @category Focus
|
36699 | *
|
36700 | */
|
36701 | hasFocus() {
|
36702 | var _a, _b;
|
36703 | return (_b = (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.hasFocus()) !== null && _b !== void 0 ? _b : false;
|
36704 | }
|
36705 | get virtualKeyboardState() {
|
36706 | var _a, _b;
|
36707 | return (_b = (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.virtualKeyboardState) !== null && _b !== void 0 ? _b : 'hidden';
|
36708 | }
|
36709 | set virtualKeyboardState(value) {
|
36710 | if (this._mathfield) {
|
36711 | this._mathfield.virtualKeyboardState = value;
|
36712 | }
|
36713 | }
|
36714 | /**
|
36715 | * Sets the focus to the mathfield (will respond to keyboard input).
|
36716 | *
|
36717 | * @category Focus
|
36718 | *
|
36719 | */
|
36720 | focus() {
|
36721 | super.focus();
|
36722 | }
|
36723 | /**
|
36724 | * Remove the focus from the mathfield (will no longer respond to keyboard
|
36725 | * input).
|
36726 | *
|
36727 | * @category Focus
|
36728 | *
|
36729 | */
|
36730 | blur() {
|
36731 | super.blur();
|
36732 | }
|
36733 | /**
|
36734 | * Select the content of the mathfield.
|
36735 | * @category Selection
|
36736 | */
|
36737 | select() {
|
36738 | var _a;
|
36739 | (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.select();
|
36740 | }
|
36741 | /**
|
36742 | * Inserts a block of text at the current insertion point.
|
36743 | *
|
36744 | * This method can be called explicitly or invoked as a selector with
|
36745 | * `executeCommand("insert")`.
|
36746 | *
|
36747 | * After the insertion, the selection will be set according to the
|
36748 | * `options.selectionMode`.
|
36749 | *
|
36750 | * @category Accessing and changing the content
|
36751 | */
|
36752 | insert(s, options) {
|
36753 | var _a, _b;
|
36754 | return (_b = (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.insert(s, options)) !== null && _b !== void 0 ? _b : false;
|
36755 | }
|
36756 | /**
|
36757 | * Updates the style (color, bold, italic, etc...) of the selection or sets
|
36758 | * the style to be applied to future input.
|
36759 | *
|
36760 | * If there is no selection and no range is specified, the style will
|
36761 | * apply to the next character typed.
|
36762 | *
|
36763 | * If a range is specified, the style is applied to the range, otherwise,
|
36764 | * if there is a selection, the style is applied to the selection.
|
36765 | *
|
36766 | * If the operation is 'toggle' and the range already has this style,
|
36767 | * remove it. If the range
|
36768 | * has the style partially applied (i.e. only some sections), remove it from
|
36769 | * those sections, and apply it to the entire range.
|
36770 | *
|
36771 | * If the operation is 'set', the style is applied to the range,
|
36772 | * whether it already has the style or not.
|
36773 | *
|
36774 | * The default operation is 'set'.
|
36775 | *
|
36776 | * @category Accessing and changing the content
|
36777 | */
|
36778 | applyStyle(style, options) {
|
36779 | var _a;
|
36780 | return (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.applyStyle(style, options);
|
36781 | }
|
36782 | /**
|
36783 | * The bottom location of the caret (insertion point) in viewport
|
36784 | * coordinates.
|
36785 | *
|
36786 | * See also [[`setCaretPoint`]]
|
36787 | * @category Selection
|
36788 | */
|
36789 | get caretPoint() {
|
36790 | var _a, _b;
|
36791 | return (_b = (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.getCaretPoint()) !== null && _b !== void 0 ? _b : null;
|
36792 | }
|
36793 | set caretPoint(point) {
|
36794 | var _a;
|
36795 | if (!point)
|
36796 | return;
|
36797 | (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.setCaretPoint(point.x, point.y);
|
36798 | }
|
36799 | /**
|
36800 | * `x` and `y` are in viewport coordinates.
|
36801 | *
|
36802 | * Return true if the location of the point is a valid caret location.
|
36803 | *
|
36804 | * See also [[`caretPoint`]]
|
36805 | * @category Selection
|
36806 | */
|
36807 | setCaretPoint(x, y) {
|
36808 | var _a, _b;
|
36809 | return (_b = (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.setCaretPoint(x, y)) !== null && _b !== void 0 ? _b : false;
|
36810 | }
|
36811 | /**
|
36812 | * Return an array of ranges matching the argument.
|
36813 | *
|
36814 | * An array is always returned, but it has no element if there are no
|
36815 | * matching items.
|
36816 | */
|
36817 | find(pattern, options) {
|
36818 | var _a, _b;
|
36819 | return (_b = (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.find(pattern, options)) !== null && _b !== void 0 ? _b : [];
|
36820 | }
|
36821 | /**
|
36822 | * Replace the pattern items matching the **pattern** with the
|
36823 | * **replacement** value.
|
36824 | *
|
36825 | * If **replacement** is a function, the function is called
|
36826 | * for each match and the function return value will be
|
36827 | * used as the replacement.
|
36828 | */
|
36829 | replace(pattern, replacement, options) {
|
36830 | var _a;
|
36831 | (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.replace(pattern, replacement, options);
|
36832 | }
|
36833 | /**
|
36834 | * Custom elements lifecycle hooks
|
36835 | * @internal
|
36836 | */
|
36837 | connectedCallback() {
|
36838 | var _a, _b;
|
36839 | if (!this.hasAttribute('role'))
|
36840 | this.setAttribute('role', 'textbox');
|
36841 | // This.setAttribute('aria-multiline', 'false');
|
36842 | if (!this.hasAttribute('tabindex'))
|
36843 | this.setAttribute('tabindex', '0');
|
36844 | const slot = this.shadowRoot.querySelector('slot:not([name])');
|
36845 | try {
|
36846 | this._style = slot
|
36847 | .assignedElements()
|
36848 | .filter((x) => x.tagName.toLowerCase() === 'style')
|
36849 | .map((x) => x.textContent)
|
36850 | .join('');
|
36851 | }
|
36852 | catch (error) {
|
36853 | console.log(error);
|
36854 | }
|
36855 | // Add shadowed stylesheet if one was provided
|
36856 | if (this._style) {
|
36857 | const styleElement = document.createElement('style');
|
36858 | styleElement.textContent = this._style;
|
36859 | this.shadowRoot.appendChild(styleElement);
|
36860 | }
|
36861 | // Inline options (as a JSON structure in the markup)
|
36862 | try {
|
36863 | const json = slot
|
36864 | .assignedElements()
|
36865 | .filter((x) => x.tagName.toLowerCase() === 'script' &&
|
36866 | x.type === 'application/json')
|
36867 | .map((x) => x.textContent)
|
36868 | .join('');
|
36869 | if (json) {
|
36870 | this.setOptions(JSON.parse(json));
|
36871 | }
|
36872 | }
|
36873 | catch (error) {
|
36874 | console.log(error);
|
36875 | }
|
36876 | let value = '';
|
36877 | // Check if there is a `value` attribute and set the initial value
|
36878 | // of the mathfield from it
|
36879 | if (this.hasAttribute('value')) {
|
36880 | value = (_a = this.getAttribute('value')) !== null && _a !== void 0 ? _a : '';
|
36881 | }
|
36882 | else {
|
36883 | value =
|
36884 | (_b = slot === null || slot === void 0 ? void 0 : slot.assignedNodes().map((x) => (x.nodeType === 3 ? x.textContent : '')).join('').trim()) !== null && _b !== void 0 ? _b : '';
|
36885 | }
|
36886 | this._mathfield = new MathfieldPrivate(this.shadowRoot.querySelector(':host > div'), {
|
36887 | onBlur: () => {
|
36888 | this.dispatchEvent(new Event('blur', {
|
36889 | cancelable: false,
|
36890 | bubbles: false,
|
36891 | composed: true,
|
36892 | }));
|
36893 | },
|
36894 | onContentDidChange: () => {
|
36895 | this.dispatchEvent(new Event('input', {
|
36896 | cancelable: false,
|
36897 | bubbles: true,
|
36898 | composed: true,
|
36899 | }));
|
36900 | },
|
36901 | onError: (err) => {
|
36902 | this.dispatchEvent(new CustomEvent('math-error', {
|
36903 | detail: {
|
36904 | code: err.code,
|
36905 | arg: err.arg,
|
36906 | latex: err.latex,
|
36907 | before: err.before,
|
36908 | after: err.after,
|
36909 | },
|
36910 | cancelable: false,
|
36911 | bubbles: true,
|
36912 | composed: true,
|
36913 | }));
|
36914 | },
|
36915 | onFocus: () => {
|
36916 | this.dispatchEvent(new Event('focus', {
|
36917 | cancelable: false,
|
36918 | bubbles: false,
|
36919 | composed: true,
|
36920 | }));
|
36921 | },
|
36922 | onKeystroke: (_sender, keystroke, ev) => {
|
36923 | return this.dispatchEvent(new CustomEvent('keystroke', {
|
36924 | detail: {
|
36925 | keystroke,
|
36926 | event: ev,
|
36927 | },
|
36928 | cancelable: true,
|
36929 | bubbles: true,
|
36930 | composed: true,
|
36931 | }));
|
36932 | },
|
36933 | onModeChange: (_sender, _mode) => {
|
36934 | this.dispatchEvent(new Event('mode-change', {
|
36935 | cancelable: false,
|
36936 | bubbles: true,
|
36937 | composed: true,
|
36938 | }));
|
36939 | },
|
36940 | onCommit: (_sender) => {
|
36941 | // Match the DOM event sent by `<input>`, `<textarea>`, etc...
|
36942 | // Sent when the [Return] or [Enter] key is pressed, or on
|
36943 | // focus loss if the content has changed.
|
36944 | this.dispatchEvent(new Event('change', {
|
36945 | cancelable: false,
|
36946 | bubbles: true,
|
36947 | composed: true,
|
36948 | }));
|
36949 | },
|
36950 | onMoveOutOf: (_sender, direction) => {
|
36951 | return this.dispatchEvent(new CustomEvent('move-out', {
|
36952 | detail: { direction },
|
36953 | cancelable: true,
|
36954 | bubbles: true,
|
36955 | composed: true,
|
36956 | }));
|
36957 | },
|
36958 | onTabOutOf: (_sender, direction) => {
|
36959 | return this.dispatchEvent(new CustomEvent('focus-out', {
|
36960 | detail: { direction },
|
36961 | cancelable: true,
|
36962 | bubbles: true,
|
36963 | composed: true,
|
36964 | }));
|
36965 | },
|
36966 | onReadAloudStatus: () => {
|
36967 | this.dispatchEvent(new Event('read-aloud-status-change', {
|
36968 | cancelable: false,
|
36969 | bubbles: true,
|
36970 | composed: true,
|
36971 | }));
|
36972 | },
|
36973 | onSelectionDidChange: () => {
|
36974 | this.dispatchEvent(new Event('selection-change', {
|
36975 | cancelable: false,
|
36976 | bubbles: true,
|
36977 | composed: true,
|
36978 | }));
|
36979 | },
|
36980 | onUndoStateDidChange: () => {
|
36981 | this.dispatchEvent(new Event('undo-state-change', {
|
36982 | cancelable: false,
|
36983 | bubbles: true,
|
36984 | composed: true,
|
36985 | }));
|
36986 | },
|
36987 | ...(gDeferredState.has(this)
|
36988 | ? gDeferredState.get(this).options
|
36989 | : getOptionsFromAttributes(this)),
|
36990 | value,
|
36991 | });
|
36992 | if (!gDeferredState.has(this)) {
|
36993 | this.upgradeProperty('disabled');
|
36994 | this.upgradeProperty('readonly');
|
36995 | for (const attr of Object.keys(MathfieldElement.optionsAttributes)) {
|
36996 | this.upgradeProperty(toCamelCase(attr));
|
36997 | }
|
36998 | }
|
36999 | // The mathfield creation could have failed
|
37000 | if (!this._mathfield || !this._mathfield.model) {
|
37001 | this._mathfield = null;
|
37002 | return;
|
37003 | }
|
37004 | if (gDeferredState.has(this)) {
|
37005 | this._mathfield.model.deferNotifications({ content: false, selection: false }, () => {
|
37006 | this._mathfield.setValue(gDeferredState.get(this).value);
|
37007 | this._mathfield.selection = gDeferredState.get(this).selection;
|
37008 | gDeferredState.delete(this);
|
37009 | });
|
37010 | }
|
37011 | slot.addEventListener('slotchange', (event) => {
|
37012 | if (event.target !== slot)
|
37013 | return;
|
37014 | const value = slot
|
37015 | .assignedNodes()
|
37016 | .map((x) => (x.nodeType === 3 ? x.textContent : ''))
|
37017 | .join('')
|
37018 | .trim();
|
37019 | if (value === this._slotValue)
|
37020 | return;
|
37021 | if (!this._mathfield) {
|
37022 | this.value = value;
|
37023 | }
|
37024 | else {
|
37025 | // Don't suppress notification changes. We need to know
|
37026 | // if the value has changed indirectly through slot manipulation
|
37027 | this._mathfield.setValue(value);
|
37028 | }
|
37029 | });
|
37030 | // Notify listeners that we're mounted and ready
|
37031 | this.dispatchEvent(new Event('mount', { cancelable: false, bubbles: true, composed: true }));
|
37032 | }
|
37033 | /**
|
37034 | * Custom elements lifecycle hooks
|
37035 | * @internal
|
37036 | */
|
37037 | disconnectedCallback() {
|
37038 | // Notify listeners that we're about to be unmounted
|
37039 | this.dispatchEvent(new Event('unmount', { cancelable: false, bubbles: true, composed: true }));
|
37040 | if (!this._mathfield)
|
37041 | return;
|
37042 | // Save the state (in case the element gets reconnected later)
|
37043 | const options = get(this._mathfield.options, Object.keys(MathfieldElement.optionsAttributes).map((x) => toCamelCase(x)));
|
37044 | gDeferredState.set(this, {
|
37045 | value: this._mathfield.getValue(),
|
37046 | selection: this._mathfield.selection,
|
37047 | options,
|
37048 | });
|
37049 | // Dispose of the mathfield
|
37050 | this._mathfield.dispose();
|
37051 | this._mathfield = null;
|
37052 | }
|
37053 | /**
|
37054 | * Private lifecycle hooks
|
37055 | * @internal
|
37056 | */
|
37057 | upgradeProperty(prop) {
|
37058 | if (this.hasOwnProperty(prop)) {
|
37059 | const value = this[prop];
|
37060 | // A property may have already been set on the object, before
|
37061 | // the element was connected: delete the property (after saving its value)
|
37062 | // and use the setter to (re-)set its value.
|
37063 | delete this[prop];
|
37064 | if (prop === 'readonly')
|
37065 | prop = 'readOnly';
|
37066 | this[prop] = value;
|
37067 | }
|
37068 | }
|
37069 | /**
|
37070 | * Custom elements lifecycle hooks
|
37071 | * @internal
|
37072 | */
|
37073 | attributeChangedCallback(name, oldValue, newValue) {
|
37074 | if (oldValue === newValue)
|
37075 | return;
|
37076 | const hasValue = newValue !== null;
|
37077 | switch (name) {
|
37078 | case 'disabled':
|
37079 | this.disabled = hasValue;
|
37080 | break;
|
37081 | case 'readonly':
|
37082 | this.readOnly = hasValue;
|
37083 | break;
|
37084 | }
|
37085 | }
|
37086 | get readonly() {
|
37087 | return this.hasAttribute('readonly') || this.hasAttribute('read-only');
|
37088 | }
|
37089 | set readonly(value) {
|
37090 | const isDisabled = Boolean(value);
|
37091 | if (isDisabled)
|
37092 | this.setAttribute('disabled', '');
|
37093 | else
|
37094 | this.removeAttribute('disabled');
|
37095 | this.setAttribute('aria-disabled', isDisabled ? 'true' : 'false');
|
37096 | this.setOptions({ readOnly: isDisabled });
|
37097 | }
|
37098 | get disabled() {
|
37099 | return this.hasAttribute('disabled');
|
37100 | }
|
37101 | set disabled(value) {
|
37102 | const isDisabled = Boolean(value);
|
37103 | if (isDisabled)
|
37104 | this.setAttribute('disabled', '');
|
37105 | else
|
37106 | this.removeAttribute('disabled');
|
37107 | this.setAttribute('aria-disabled', isDisabled ? 'true' : 'false');
|
37108 | this.setOptions({ readOnly: isDisabled });
|
37109 | }
|
37110 | /**
|
37111 | * The content of the mathfield as a Latex expression.
|
37112 | * ```
|
37113 | * document.querySelector('mf').value = '\\frac{1}{\\pi}'
|
37114 | * ```
|
37115 | * @category Accessing and changing the content
|
37116 | */
|
37117 | get value() {
|
37118 | return this.getValue();
|
37119 | }
|
37120 | /**
|
37121 | * @category Accessing and changing the content
|
37122 | */
|
37123 | set value(value) {
|
37124 | this.setValue(value);
|
37125 | }
|
37126 | get defaultMode() {
|
37127 | return this.getOption('defaultMode');
|
37128 | }
|
37129 | set defaultMode(value) {
|
37130 | this.setOptions({ defaultMode: value });
|
37131 | }
|
37132 | get fontsDirectory() {
|
37133 | return this.getOption('fontsDirectory');
|
37134 | }
|
37135 | set fontsDirectory(value) {
|
37136 | this.setOptions({ fontsDirectory: value });
|
37137 | }
|
37138 | get mathModeSpace() {
|
37139 | return this.getOption('fontsDirectory');
|
37140 | }
|
37141 | set mathModeSpace(value) {
|
37142 | this.setOptions({ mathModeSpace: value });
|
37143 | }
|
37144 | get inlineShortcutTimeout() {
|
37145 | return this.getOption('inlineShortcutTimeout');
|
37146 | }
|
37147 | set inlineShortcutTimeout(value) {
|
37148 | this.setOptions({ inlineShortcutTimeout: value });
|
37149 | }
|
37150 | get keypressVibration() {
|
37151 | return this.getOption('keypressVibration');
|
37152 | }
|
37153 | set keypressVibration(value) {
|
37154 | this.setOptions({ keypressVibration: value });
|
37155 | }
|
37156 | get keypressSound() {
|
37157 | return this.getOption('keypressSound');
|
37158 | }
|
37159 | set keypressSound(value) {
|
37160 | this.setOptions({ keypressSound: value });
|
37161 | }
|
37162 | get plonkSound() {
|
37163 | var _a;
|
37164 | return (_a = this.getOption('plonkSound')) !== null && _a !== void 0 ? _a : null;
|
37165 | }
|
37166 | set plonkSound(value) {
|
37167 | this.setOptions({ plonkSound: value });
|
37168 | }
|
37169 | get letterShapeStyle() {
|
37170 | return this.getOption('letterShapeStyle');
|
37171 | }
|
37172 | set letterShapeStyle(value) {
|
37173 | this.setOptions({ letterShapeStyle: value });
|
37174 | }
|
37175 | get locale() {
|
37176 | return this.getOption('locale');
|
37177 | }
|
37178 | set locale(value) {
|
37179 | this.setOptions({ locale: value });
|
37180 | }
|
37181 | get readOnly() {
|
37182 | return this.getOption('readOnly');
|
37183 | }
|
37184 | set readOnly(value) {
|
37185 | this.setOptions({ readOnly: value });
|
37186 | }
|
37187 | get removeExtraneousParentheses() {
|
37188 | return this.getOption('removeExtraneousParentheses');
|
37189 | }
|
37190 | set removeExtraneousParentheses(value) {
|
37191 | this.setOptions({ removeExtraneousParentheses: value });
|
37192 | }
|
37193 | get smartFence() {
|
37194 | return this.getOption('smartFence');
|
37195 | }
|
37196 | set smartFence(value) {
|
37197 | this.setOptions({ smartFence: value });
|
37198 | }
|
37199 | get smartMode() {
|
37200 | return this.getOption('smartMode');
|
37201 | }
|
37202 | set smartMode(value) {
|
37203 | this.setOptions({ smartMode: value });
|
37204 | }
|
37205 | get smartSuperscript() {
|
37206 | return this.getOption('smartSuperscript');
|
37207 | }
|
37208 | set smartSuperscript(value) {
|
37209 | this.setOptions({ smartSuperscript: value });
|
37210 | }
|
37211 | get speechEngine() {
|
37212 | return this.getOption('speechEngine');
|
37213 | }
|
37214 | set speechEngine(value) {
|
37215 | this.setOptions({ speechEngine: value });
|
37216 | }
|
37217 | get speechEngineRate() {
|
37218 | return this.getOption('speechEngineRate');
|
37219 | }
|
37220 | set speechEngineRate(value) {
|
37221 | this.setOptions({ speechEngineRate: value });
|
37222 | }
|
37223 | get speechEngineVoice() {
|
37224 | return this.getOption('speechEngineVoice');
|
37225 | }
|
37226 | set speechEngineVoice(value) {
|
37227 | this.setOptions({ speechEngineVoice: value });
|
37228 | }
|
37229 | get textToSpeechMarkup() {
|
37230 | return this.getOption('textToSpeechMarkup');
|
37231 | }
|
37232 | set textToSpeechMarkup(value) {
|
37233 | this.setOptions({ textToSpeechMarkup: value });
|
37234 | }
|
37235 | get textToSpeechRules() {
|
37236 | return this.getOption('textToSpeechRules');
|
37237 | }
|
37238 | set textToSpeechRule(value) {
|
37239 | this.setOptions({ textToSpeechRules: value });
|
37240 | }
|
37241 | get virtualKeyboardLayout() {
|
37242 | return this.getOption('virtualKeyboardLayout');
|
37243 | }
|
37244 | set virtualKeyboardLayout(value) {
|
37245 | this.setOptions({ virtualKeyboardLayout: value });
|
37246 | }
|
37247 | get virtualKeyboardMode() {
|
37248 | return this.getOption('virtualKeyboardMode');
|
37249 | }
|
37250 | set virtualKeyboardMode(value) {
|
37251 | this.setOptions({ virtualKeyboardMode: value });
|
37252 | }
|
37253 | get virtualKeyboardTheme() {
|
37254 | return this.getOption('virtualKeyboardTheme');
|
37255 | }
|
37256 | set virtualKeyboardTheme(value) {
|
37257 | this.setOptions({ virtualKeyboardTheme: value });
|
37258 | }
|
37259 | get virtualKeyboards() {
|
37260 | return this.getOption('virtualKeyboards');
|
37261 | }
|
37262 | set virtualKeyboards(value) {
|
37263 | this.setOptions({ virtualKeyboards: value });
|
37264 | }
|
37265 | get useSharedVirtualKeyboard() {
|
37266 | return this.getOption('useSharedVirtualKeyboard');
|
37267 | }
|
37268 | set useSharedVirtualKeyboard(value) {
|
37269 | this.setOptions({ useSharedVirtualKeyboard: value });
|
37270 | }
|
37271 | get sharedVirtualKeyboardTargetOrigin() {
|
37272 | return this.getOption('sharedVirtualKeyboardTargetOrigin');
|
37273 | }
|
37274 | set sharedVirtualKeyboardTargetOrigin(value) {
|
37275 | this.setOptions({ sharedVirtualKeyboardTargetOrigin: value });
|
37276 | }
|
37277 | /**
|
37278 | * An array of ranges representing the selection.
|
37279 | *
|
37280 | * It is guaranteed there will be at least one element. If a discontinuous
|
37281 | * selection is present, the result will include more than one element.
|
37282 | *
|
37283 | * @category Selection
|
37284 | *
|
37285 | */
|
37286 | get selection() {
|
37287 | if (this._mathfield) {
|
37288 | return this._mathfield.selection;
|
37289 | }
|
37290 | if (gDeferredState.has(this)) {
|
37291 | return gDeferredState.get(this).selection;
|
37292 | }
|
37293 | return { ranges: [[0, 0]], direction: 'forward' };
|
37294 | }
|
37295 | /**
|
37296 | *
|
37297 | * @category Selection
|
37298 | */
|
37299 | set selection(value) {
|
37300 | if (typeof value === 'number') {
|
37301 | value = { ranges: [[value, value]] };
|
37302 | }
|
37303 | if (this._mathfield) {
|
37304 | this._mathfield.selection = value;
|
37305 | return;
|
37306 | }
|
37307 | if (gDeferredState.has(this)) {
|
37308 | gDeferredState.set(this, {
|
37309 | value: gDeferredState.get(this).value,
|
37310 | selection: value,
|
37311 | options: gDeferredState.get(this).options,
|
37312 | });
|
37313 | return;
|
37314 | }
|
37315 | gDeferredState.set(this, {
|
37316 | value: '',
|
37317 | selection: value,
|
37318 | options: getOptionsFromAttributes(this),
|
37319 | });
|
37320 | }
|
37321 | /**
|
37322 | * The position of the caret/insertion point, from 0 to `lastOffset`.
|
37323 | *
|
37324 | * @category Selection
|
37325 | *
|
37326 | */
|
37327 | get position() {
|
37328 | if (this._mathfield) {
|
37329 | return this._mathfield.model.position;
|
37330 | }
|
37331 | if (gDeferredState.has(this)) {
|
37332 | return gDeferredState.get(this).selection.ranges[0][0];
|
37333 | }
|
37334 | return 0;
|
37335 | }
|
37336 | /**
|
37337 | * @category Selection
|
37338 | */
|
37339 | set position(offset) {
|
37340 | if (this._mathfield) {
|
37341 | this._mathfield.model.position = offset;
|
37342 | }
|
37343 | if (gDeferredState.has(this)) {
|
37344 | gDeferredState.set(this, {
|
37345 | value: gDeferredState.get(this).value,
|
37346 | selection: { ranges: [[offset, offset]] },
|
37347 | options: gDeferredState.get(this).options,
|
37348 | });
|
37349 | return;
|
37350 | }
|
37351 | gDeferredState.set(this, {
|
37352 | value: '',
|
37353 | selection: { ranges: [[offset, offset]] },
|
37354 | options: getOptionsFromAttributes(this),
|
37355 | });
|
37356 | }
|
37357 | /**
|
37358 | * The depth of an offset represent the depth in the expression tree.
|
37359 | */
|
37360 | getOffsetDepth(offset) {
|
37361 | var _a, _b;
|
37362 | if (this._mathfield) {
|
37363 | return (_b = ((_a = this._mathfield.model.at(offset)) === null || _a === void 0 ? void 0 : _a.treeDepth) - 2) !== null && _b !== void 0 ? _b : 0;
|
37364 | }
|
37365 | return 0;
|
37366 | }
|
37367 | /**
|
37368 | * The last valid offset.
|
37369 | * @category Selection
|
37370 | */
|
37371 | get lastOffset() {
|
37372 | var _a, _b;
|
37373 | return (_b = (_a = this._mathfield) === null || _a === void 0 ? void 0 : _a.lastOffset) !== null && _b !== void 0 ? _b : -1;
|
37374 | }
|
37375 | }
|
37376 | function toCamelCase(s) {
|
37377 | return s.toLowerCase().replace(/[^a-zA-Z\d]+(.)/g, (m, c) => c.toUpperCase());
|
37378 | }
|
37379 | function reflectAttributes(element) {
|
37380 | const defaultOptions = getDefault();
|
37381 | const options = element.getOptions();
|
37382 | Object.keys(MathfieldElement.optionsAttributes).forEach((x) => {
|
37383 | const prop = toCamelCase(x);
|
37384 | if (defaultOptions[prop] !== options[prop]) {
|
37385 | if (MathfieldElement.optionsAttributes[x] === 'boolean') {
|
37386 | if (options[prop]) {
|
37387 | // Add attribute
|
37388 | element.setAttribute(x, '');
|
37389 | }
|
37390 | else {
|
37391 | // Remove attribute
|
37392 | element.removeAttribute(x);
|
37393 | }
|
37394 | }
|
37395 | else {
|
37396 | // Set attribute (as string)
|
37397 | if (typeof options[prop] === 'string' ||
|
37398 | typeof options[prop] === 'number') {
|
37399 | element.setAttribute(x, options[prop].toString());
|
37400 | }
|
37401 | }
|
37402 | }
|
37403 | });
|
37404 | }
|
37405 | // Function toKebabCase(s: string): string {
|
37406 | // return s
|
37407 | // .match(
|
37408 | // /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g
|
37409 | // )
|
37410 | // .map((x: string) => x.toLowerCase())
|
37411 | // .join('-');
|
37412 | // }
|
37413 | function getOptionsFromAttributes(mfe) {
|
37414 | const result = {};
|
37415 | const attribs = MathfieldElement.optionsAttributes;
|
37416 | Object.keys(attribs).forEach((x) => {
|
37417 | if (mfe.hasAttribute(x)) {
|
37418 | const value = mfe.getAttribute(x);
|
37419 | if (attribs[x] === 'boolean') {
|
37420 | result[toCamelCase(x)] = true;
|
37421 | }
|
37422 | else if (attribs[x] === 'number') {
|
37423 | result[toCamelCase(x)] = Number.parseFloat(value !== null && value !== void 0 ? value : '0');
|
37424 | }
|
37425 | else {
|
37426 | result[toCamelCase(x)] = value;
|
37427 | }
|
37428 | }
|
37429 | else if (attribs[x] === 'boolean') {
|
37430 | result[toCamelCase(x)] = false;
|
37431 | }
|
37432 | });
|
37433 | return result;
|
37434 | }
|
37435 | if (isBrowser() && !((_a = window.customElements) === null || _a === void 0 ? void 0 : _a.get('math-field'))) {
|
37436 | window.MathfieldElement = MathfieldElement;
|
37437 | (_b = window.customElements) === null || _b === void 0 ? void 0 : _b.define('math-field', MathfieldElement);
|
37438 | }
|
37439 |
|
37440 | const e = [127462, 127487];
|
37441 | function i(e) { return 8205 === e || 65038 === e || 65039 === e || e >= 127995 && e <= 128e3 || e >= 129456 && e <= 129460 || e >= 917536 && e <= 917632; }
|
37442 | function n(i) { return i >= e[0] && i <= e[1]; }
|
37443 | class t {
|
37444 | constructor(e) { this.obeyspaces = !1, this.s = function (e) { if (/^[\u0020-\u00FF]*$/.test(e))
|
37445 | return e; const t = [], r = function (e) { const i = []; for (let n = 0; n < e.length; n++) {
|
37446 | let t = e.charCodeAt(n);
|
37447 | if (t >= 55296 && t <= 56319) {
|
37448 | const i = e.charCodeAt(n + 1);
|
37449 | i >= 56320 && i <= 57343 && (t = 65536 + 1024 * (t - 55296) + (i - 56320), n++);
|
37450 | }
|
37451 | i.push(t);
|
37452 | } return i; }(e); let o = 0; for (; o < r.length;) {
|
37453 | const e = r[o++], s = r[o];
|
37454 | if (8205 === s) {
|
37455 | const e = o - 1;
|
37456 | for (o += 2; 8205 === r[o];)
|
37457 | o += 2;
|
37458 | t.push(String.fromCodePoint(...r.slice(e, 2 * o - e + 1)));
|
37459 | }
|
37460 | else if (i(s)) {
|
37461 | const e = o - 1;
|
37462 | for (; i(r[o]);)
|
37463 | o += 8205 === r[o] ? 2 : 1;
|
37464 | t.push(String.fromCodePoint(...r.slice(e, 2 * o - e - 1)));
|
37465 | }
|
37466 | else
|
37467 | n(e) ? (o += 1, t.push(String.fromCodePoint(...r.slice(o - 2, 2)))) : t.push(String.fromCodePoint(e));
|
37468 | } return t; }(e), this.pos = 0; }
|
37469 | end() { return this.pos >= this.s.length; }
|
37470 | get() { return this.pos < this.s.length ? this.s[this.pos++] : ""; }
|
37471 | peek() { return this.s[this.pos]; }
|
37472 | match(e) { let i; return i = "string" == typeof this.s ? e.exec(this.s.slice(this.pos)) : e.exec(this.s.slice(this.pos).join("")), (null == i ? void 0 : i[0]) ? (this.pos += i[0].length, i[0]) : null; }
|
37473 | next() { if (this.end())
|
37474 | return null; if (!this.obeyspaces && this.match(/^[ \f\n\r\t\v\xA0\u2028\u2029]+/))
|
37475 | return "<space>"; if (this.obeyspaces && this.match(/^[ \f\n\r\t\v\xA0\u2028\u2029]/))
|
37476 | return "<space>"; const e = this.get(); if ("\\" === e) {
|
37477 | if (!this.end()) {
|
37478 | let e = this.match(/^[a-zA-Z*]+/);
|
37479 | if (e)
|
37480 | this.match(/^[ \f\n\r\t\v\xA0\u2028\u2029]*/);
|
37481 | else if (e = this.get(), " " === e)
|
37482 | return "<space>";
|
37483 | return "\\" + e;
|
37484 | }
|
37485 | }
|
37486 | else {
|
37487 | if ("{" === e)
|
37488 | return "<{>";
|
37489 | if ("}" === e)
|
37490 | return "<}>";
|
37491 | if ("^" === e) {
|
37492 | if ("^" === this.peek()) {
|
37493 | this.get();
|
37494 | const e = this.match(/^(\^(\^(\^(\^[0-9a-f])?[0-9a-f])?[0-9a-f])?[0-9a-f])?[0-9a-f][0-9a-f]/);
|
37495 | if (e)
|
37496 | return String.fromCodePoint(parseInt(e.slice(e.lastIndexOf("^") + 1), 16));
|
37497 | }
|
37498 | return e;
|
37499 | }
|
37500 | if ("#" === e) {
|
37501 | if (!this.end()) {
|
37502 | let e = !1;
|
37503 | if (/[0-9?]/.test(this.peek()) && (e = !0, this.pos + 1 < this.s.length)) {
|
37504 | const i = this.s[this.pos + 1];
|
37505 | e = /[^0-9A-Za-z]/.test(i);
|
37506 | }
|
37507 | return e ? "#" + this.get() : "#";
|
37508 | }
|
37509 | }
|
37510 | else if ("$" === e)
|
37511 | return "$" === this.peek() ? (this.get(), "<$$>") : "<$>";
|
37512 | } return e; }
|
37513 | }
|
37514 | function r(e, i) { var n, t, r, s; let a = [], l = e.next(); if (l)
|
37515 | if ("\\relax" === l)
|
37516 | ;
|
37517 | else if ("\\noexpand" === l)
|
37518 | l = e.next(), l && a.push(l);
|
37519 | else if ("\\obeyspaces" === l)
|
37520 | e.obeyspaces = !0;
|
37521 | else if ("\\space" === l || "~" === l)
|
37522 | a.push("<space>");
|
37523 | else if ("\\bgroup" === l)
|
37524 | a.push("<{>");
|
37525 | else if ("\\egroup" === l)
|
37526 | a.push("<}>");
|
37527 | else if ("\\string" === l)
|
37528 | l = e.next(), l && ("\\" === l[0] ? Array.from(l).forEach((e => a.push("\\" === e ? "\\backslash" : e))) : "<{>" === l ? a.push("\\{") : "<space>" === l ? a.push("~") : "<}>" === l && a.push("\\}"));
|
37529 | else if ("\\csname" === l) {
|
37530 | for (; "<space>" === e.peek();)
|
37531 | e.next();
|
37532 | let r = "", s = !1, u = [];
|
37533 | do {
|
37534 | if (0 === u.length)
|
37535 | if (/^#[0-9?]$/.test(e.peek())) {
|
37536 | const r = e.get().slice(1);
|
37537 | u = o(null !== (t = null !== (n = null == i ? void 0 : i[r]) && void 0 !== n ? n : null == i ? void 0 : i["?"]) && void 0 !== t ? t : "\\placeholder{}", i), l = u[0];
|
37538 | }
|
37539 | else
|
37540 | l = e.next(), u = l ? [l] : [];
|
37541 | s = 0 === u.length, s || "\\endcsname" !== l || (s = !0, u.shift()), s || (s = "<$>" === l || "<$$>" === l || "<{>" === l || "<}>" === l || !!l && l.length > 1 && "\\" === l[0]), s || (r += u.shift());
|
37542 | } while (!s);
|
37543 | r && a.push("\\" + r), a = a.concat(u);
|
37544 | }
|
37545 | else if ("\\endcsname" === l)
|
37546 | ;
|
37547 | else if (l.length > 1 && "#" === l[0]) {
|
37548 | const e = l.slice(1);
|
37549 | a = a.concat(o(null !== (s = null !== (r = null == i ? void 0 : i[e]) && void 0 !== r ? r : null == i ? void 0 : i["?"]) && void 0 !== s ? s : "\\placeholder{}", i));
|
37550 | }
|
37551 | else
|
37552 | a.push(l); return a; }
|
37553 | function o(e, i) { const n = e.toString().split(/\r?\n/); let o = "", s = ""; for (const e of n) {
|
37554 | o += s, s = " ";
|
37555 | const i = e.match(/((?:\\%)|[^%])*/);
|
37556 | null !== i && (o += i[0]);
|
37557 | } const a = new t(o); let l = []; do {
|
37558 | l = l.concat(r(a, i));
|
37559 | } while (!a.end()); return l; }
|
37560 | function s(e) { let i = "", n = ""; for (const t of e)
|
37561 | t && (/[a-zA-Z*]/.test(t[0]) && (n += i), i = /\\[a-zA-Z]+\*?$/.test(t) ? " " : "", n += t); return n; }
|
37562 | function a(e) { let i = []; if (Array.isArray(e))
|
37563 | for (const n of e)
|
37564 | Array.isArray(n) ? i = [...i, ...n] : i.push(n);
|
37565 | else
|
37566 | i = [e]; return s(i.map((e => { var i; return null !== (i = { "<space>": " ", "<$$>": "$$", "<$>": "$", "<{>": "{", "<}>": "}" }[e]) && void 0 !== i ? i : e; }))); }
|
37567 | var l, u = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {}, c = { exports: {} };
|
37568 | l = c, function (e) { var i, n, t, r, o = 9e15, s = 1e9, a = "0123456789abcdef", u = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", c = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", m = { precision: 20, rounding: 4, modulo: 1, toExpNeg: -7, toExpPos: 21, minE: -o, maxE: o, crypto: !1 }, f = !0, h = "[DecimalError] ", p = h + "Invalid argument: ", g = h + "Precision limit exceeded", d = h + "crypto unavailable", v = Math.floor, x = Math.pow, y = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i, b = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i, N = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i, w = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, S = 1e7, M = u.length - 1, E = c.length - 1, D = { name: "[object Decimal]" }; function A(e) { var i, n, t, r = e.length - 1, o = "", s = e[0]; if (r > 0) {
|
37569 | for (o += s, i = 1; i < r; i++)
|
37570 | (n = 7 - (t = e[i] + "").length) && (o += _(n)), o += t;
|
37571 | (n = 7 - (t = (s = e[i]) + "").length) && (o += _(n));
|
37572 | }
|
37573 | else if (0 === s)
|
37574 | return "0"; for (; s % 10 == 0;)
|
37575 | s /= 10; return o + s; } function C(e, i, n) { if (e !== ~~e || e < i || e > n)
|
37576 | throw Error(p + e); } function q(e, i, n, t) { var r, o, s, a; for (o = e[0]; o >= 10; o /= 10)
|
37577 | --i; return --i < 0 ? (i += 7, r = 0) : (r = Math.ceil((i + 1) / 7), i %= 7), o = x(10, 7 - i), a = e[r] % o | 0, null == t ? i < 3 ? (0 == i ? a = a / 100 | 0 : 1 == i && (a = a / 10 | 0), s = n < 4 && 99999 == a || n > 3 && 49999 == a || 5e4 == a || 0 == a) : s = (n < 4 && a + 1 == o || n > 3 && a + 1 == o / 2) && (e[r + 1] / o / 100 | 0) == x(10, i - 2) - 1 || (a == o / 2 || 0 == a) && 0 == (e[r + 1] / o / 100 | 0) : i < 4 ? (0 == i ? a = a / 1e3 | 0 : 1 == i ? a = a / 100 | 0 : 2 == i && (a = a / 10 | 0), s = (t || n < 4) && 9999 == a || !t && n > 3 && 4999 == a) : s = ((t || n < 4) && a + 1 == o || !t && n > 3 && a + 1 == o / 2) && (e[r + 1] / o / 1e3 | 0) == x(10, i - 3) - 1, s; } function F(e, i, n) { for (var t, r, o = [0], s = 0, l = e.length; s < l;) {
|
37578 | for (r = o.length; r--;)
|
37579 | o[r] *= i;
|
37580 | for (o[0] += a.indexOf(e.charAt(s++)), t = 0; t < o.length; t++)
|
37581 | o[t] > n - 1 && (void 0 === o[t + 1] && (o[t + 1] = 0), o[t + 1] += o[t] / n | 0, o[t] %= n);
|
37582 | } return o.reverse(); } D.absoluteValue = D.abs = function () { var e = new this.constructor(this); return e.s < 0 && (e.s = 1), k(e); }, D.ceil = function () { return k(new this.constructor(this), this.e + 1, 2); }, D.comparedTo = D.cmp = function (e) { var i, n, t, r, o = this, s = o.d, a = (e = new o.constructor(e)).d, l = o.s, u = e.s; if (!s || !a)
|
37583 | return l && u ? l !== u ? l : s === a ? 0 : !s ^ l < 0 ? 1 : -1 : NaN; if (!s[0] || !a[0])
|
37584 | return s[0] ? l : a[0] ? -u : 0; if (l !== u)
|
37585 | return l; if (o.e !== e.e)
|
37586 | return o.e > e.e ^ l < 0 ? 1 : -1; for (i = 0, n = (t = s.length) < (r = a.length) ? t : r; i < n; ++i)
|
37587 | if (s[i] !== a[i])
|
37588 | return s[i] > a[i] ^ l < 0 ? 1 : -1; return t === r ? 0 : t > r ^ l < 0 ? 1 : -1; }, D.cosine = D.cos = function () { var e, i, n = this, t = n.constructor; return n.d ? n.d[0] ? (e = t.precision, i = t.rounding, t.precision = e + Math.max(n.e, n.sd()) + 7, t.rounding = 1, n = function (e, i) { var n, t, r = i.d.length; r < 32 ? t = (1 / W(4, n = Math.ceil(r / 3))).toString() : (n = 16, t = "2.3283064365386962890625e-10"), e.precision += n, i = G(e, 1, i.times(t), new e(1)); for (var o = n; o--;) {
|
37589 | var s = i.times(i);
|
37590 | i = s.times(s).minus(s).times(8).plus(1);
|
37591 | } return e.precision -= n, i; }(t, V(t, n)), t.precision = e, t.rounding = i, k(2 == r || 3 == r ? n.neg() : n, e, i, !0)) : new t(1) : new t(NaN); }, D.cubeRoot = D.cbrt = function () { var e, i, n, t, r, o, s, a, l, u, c = this, m = c.constructor; if (!c.isFinite() || c.isZero())
|
37592 | return new m(c); for (f = !1, (o = c.s * x(c.s * c, 1 / 3)) && Math.abs(o) != 1 / 0 ? t = new m(o.toString()) : (n = A(c.d), (o = ((e = c.e) - n.length + 1) % 3) && (n += 1 == o || -2 == o ? "0" : "00"), o = x(n, 1 / 3), e = v((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2)), (t = new m(n = o == 1 / 0 ? "5e" + e : (n = o.toExponential()).slice(0, n.indexOf("e") + 1) + e)).s = c.s), s = (e = m.precision) + 3;;)
|
37593 | if (u = (l = (a = t).times(a).times(a)).plus(c), t = I(u.plus(c).times(a), u.plus(l), s + 2, 1), A(a.d).slice(0, s) === (n = A(t.d)).slice(0, s)) {
|
37594 | if ("9999" != (n = n.slice(s - 3, s + 1)) && (r || "4999" != n)) {
|
37595 | +n && (+n.slice(1) || "5" != n.charAt(0)) || (k(t, e + 1, 1), i = !t.times(t).times(t).eq(c));
|
37596 | break;
|
37597 | }
|
37598 | if (!r && (k(a, e + 1, 0), a.times(a).times(a).eq(c))) {
|
37599 | t = a;
|
37600 | break;
|
37601 | }
|
37602 | s += 4, r = 1;
|
37603 | } return f = !0, k(t, e, m.rounding, i); }, D.decimalPlaces = D.dp = function () { var e, i = this.d, n = NaN; if (i) {
|
37604 | if (n = 7 * ((e = i.length - 1) - v(this.e / 7)), e = i[e])
|
37605 | for (; e % 10 == 0; e /= 10)
|
37606 | n--;
|
37607 | n < 0 && (n = 0);
|
37608 | } return n; }, D.dividedBy = D.div = function (e) { return I(this, new this.constructor(e)); }, D.dividedToIntegerBy = D.divToInt = function (e) { var i = this.constructor; return k(I(this, new i(e), 0, 1, 1), i.precision, i.rounding); }, D.equals = D.eq = function (e) { return 0 === this.cmp(e); }, D.floor = function () { return k(new this.constructor(this), this.e + 1, 3); }, D.greaterThan = D.gt = function (e) { return this.cmp(e) > 0; }, D.greaterThanOrEqualTo = D.gte = function (e) { var i = this.cmp(e); return 1 == i || 0 === i; }, D.hyperbolicCosine = D.cosh = function () { var e, i, n, t, r, o = this, s = o.constructor, a = new s(1); if (!o.isFinite())
|
37609 | return new s(o.s ? 1 / 0 : NaN); if (o.isZero())
|
37610 | return a; n = s.precision, t = s.rounding, s.precision = n + Math.max(o.e, o.sd()) + 4, s.rounding = 1, (r = o.d.length) < 32 ? i = (1 / W(4, e = Math.ceil(r / 3))).toString() : (e = 16, i = "2.3283064365386962890625e-10"), o = G(s, 1, o.times(i), new s(1), !0); for (var l, u = e, c = new s(8); u--;)
|
37611 | l = o.times(o), o = a.minus(l.times(c.minus(l.times(c)))); return k(o, s.precision = n, s.rounding = t, !0); }, D.hyperbolicSine = D.sinh = function () { var e, i, n, t, r = this, o = r.constructor; if (!r.isFinite() || r.isZero())
|
37612 | return new o(r); if (i = o.precision, n = o.rounding, o.precision = i + Math.max(r.e, r.sd()) + 4, o.rounding = 1, (t = r.d.length) < 3)
|
37613 | r = G(o, 2, r, r, !0);
|
37614 | else {
|
37615 | e = (e = 1.4 * Math.sqrt(t)) > 16 ? 16 : 0 | e, r = G(o, 2, r = r.times(1 / W(5, e)), r, !0);
|
37616 | for (var s, a = new o(5), l = new o(16), u = new o(20); e--;)
|
37617 | s = r.times(r), r = r.times(a.plus(s.times(l.times(s).plus(u))));
|
37618 | } return o.precision = i, o.rounding = n, k(r, i, n, !0); }, D.hyperbolicTangent = D.tanh = function () { var e, i, n = this, t = n.constructor; return n.isFinite() ? n.isZero() ? new t(n) : (e = t.precision, i = t.rounding, t.precision = e + 7, t.rounding = 1, I(n.sinh(), n.cosh(), t.precision = e, t.rounding = i)) : new t(n.s); }, D.inverseCosine = D.acos = function () { var e, i = this, n = i.constructor, t = i.abs().cmp(1), r = n.precision, o = n.rounding; return -1 !== t ? 0 === t ? i.isNeg() ? z(n, r, o) : new n(0) : new n(NaN) : i.isZero() ? z(n, r + 4, o).times(.5) : (n.precision = r + 6, n.rounding = 1, i = i.asin(), e = z(n, r + 4, o).times(.5), n.precision = r, n.rounding = o, e.minus(i)); }, D.inverseHyperbolicCosine = D.acosh = function () { var e, i, n = this, t = n.constructor; return n.lte(1) ? new t(n.eq(1) ? 0 : NaN) : n.isFinite() ? (e = t.precision, i = t.rounding, t.precision = e + Math.max(Math.abs(n.e), n.sd()) + 4, t.rounding = 1, f = !1, n = n.times(n).minus(1).sqrt().plus(n), f = !0, t.precision = e, t.rounding = i, n.ln()) : new t(n); }, D.inverseHyperbolicSine = D.asinh = function () { var e, i, n = this, t = n.constructor; return !n.isFinite() || n.isZero() ? new t(n) : (e = t.precision, i = t.rounding, t.precision = e + 2 * Math.max(Math.abs(n.e), n.sd()) + 6, t.rounding = 1, f = !1, n = n.times(n).plus(1).sqrt().plus(n), f = !0, t.precision = e, t.rounding = i, n.ln()); }, D.inverseHyperbolicTangent = D.atanh = function () { var e, i, n, t, r = this, o = r.constructor; return r.isFinite() ? r.e >= 0 ? new o(r.abs().eq(1) ? r.s / 0 : r.isZero() ? r : NaN) : (e = o.precision, i = o.rounding, t = r.sd(), Math.max(t, e) < 2 * -r.e - 1 ? k(new o(r), e, i, !0) : (o.precision = n = t - r.e, r = I(r.plus(1), new o(1).minus(r), n + e, 1), o.precision = e + 4, o.rounding = 1, r = r.ln(), o.precision = e, o.rounding = i, r.times(.5))) : new o(NaN); }, D.inverseSine = D.asin = function () { var e, i, n, t, r = this, o = r.constructor; return r.isZero() ? new o(r) : (i = r.abs().cmp(1), n = o.precision, t = o.rounding, -1 !== i ? 0 === i ? ((e = z(o, n + 4, t).times(.5)).s = r.s, e) : new o(NaN) : (o.precision = n + 6, o.rounding = 1, r = r.div(new o(1).minus(r.times(r)).sqrt().plus(1)).atan(), o.precision = n, o.rounding = t, r.times(2))); }, D.inverseTangent = D.atan = function () { var e, i, n, t, r, o, s, a, l, u = this, c = u.constructor, m = c.precision, h = c.rounding; if (u.isFinite()) {
|
37619 | if (u.isZero())
|
37620 | return new c(u);
|
37621 | if (u.abs().eq(1) && m + 4 <= E)
|
37622 | return (s = z(c, m + 4, h).times(.25)).s = u.s, s;
|
37623 | }
|
37624 | else {
|
37625 | if (!u.s)
|
37626 | return new c(NaN);
|
37627 | if (m + 4 <= E)
|
37628 | return (s = z(c, m + 4, h).times(.5)).s = u.s, s;
|
37629 | } for (c.precision = a = m + 10, c.rounding = 1, e = n = Math.min(28, a / 7 + 2 | 0); e; --e)
|
37630 | u = u.div(u.times(u).plus(1).sqrt().plus(1)); for (f = !1, i = Math.ceil(a / 7), t = 1, l = u.times(u), s = new c(u), r = u; -1 !== e;)
|
37631 | if (r = r.times(l), o = s.minus(r.div(t += 2)), r = r.times(l), void 0 !== (s = o.plus(r.div(t += 2))).d[i])
|
37632 | for (e = i; s.d[e] === o.d[e] && e--;)
|
37633 | ; return n && (s = s.times(2 << n - 1)), f = !0, k(s, c.precision = m, c.rounding = h, !0); }, D.isFinite = function () { return !!this.d; }, D.isInteger = D.isInt = function () { return !!this.d && v(this.e / 7) > this.d.length - 2; }, D.isNaN = function () { return !this.s; }, D.isNegative = D.isNeg = function () { return this.s < 0; }, D.isPositive = D.isPos = function () { return this.s > 0; }, D.isZero = function () { return !!this.d && 0 === this.d[0]; }, D.lessThan = D.lt = function (e) { return this.cmp(e) < 0; }, D.lessThanOrEqualTo = D.lte = function (e) { return this.cmp(e) < 1; }, D.logarithm = D.log = function (e) { var i, n, t, r, o, s, a, l, u = this, c = u.constructor, m = c.precision, h = c.rounding; if (null == e)
|
37634 | e = new c(10), i = !0;
|
37635 | else {
|
37636 | if (n = (e = new c(e)).d, e.s < 0 || !n || !n[0] || e.eq(1))
|
37637 | return new c(NaN);
|
37638 | i = e.eq(10);
|
37639 | } if (n = u.d, u.s < 0 || !n || !n[0] || u.eq(1))
|
37640 | return new c(n && !n[0] ? -1 / 0 : 1 != u.s ? NaN : n ? 0 : 1 / 0); if (i)
|
37641 | if (n.length > 1)
|
37642 | o = !0;
|
37643 | else {
|
37644 | for (r = n[0]; r % 10 == 0;)
|
37645 | r /= 10;
|
37646 | o = 1 !== r;
|
37647 | } if (f = !1, s = $(u, a = m + 5), t = i ? O(c, a + 10) : $(e, a), q((l = I(s, t, a, 1)).d, r = m, h))
|
37648 | do {
|
37649 | if (s = $(u, a += 10), t = i ? O(c, a + 10) : $(e, a), l = I(s, t, a, 1), !o) {
|
37650 | +A(l.d).slice(r + 1, r + 15) + 1 == 1e14 && (l = k(l, m + 1, 0));
|
37651 | break;
|
37652 | }
|
37653 | } while (q(l.d, r += 10, h)); return f = !0, k(l, m, h); }, D.minus = D.sub = function (e) { var i, n, t, r, o, s, a, l, u, c, m, h, p = this, g = p.constructor; if (e = new g(e), !p.d || !e.d)
|
37654 | return p.s && e.s ? p.d ? e.s = -e.s : e = new g(e.d || p.s !== e.s ? p : NaN) : e = new g(NaN), e; if (p.s != e.s)
|
37655 | return e.s = -e.s, p.plus(e); if (u = p.d, h = e.d, a = g.precision, l = g.rounding, !u[0] || !h[0]) {
|
37656 | if (h[0])
|
37657 | e.s = -e.s;
|
37658 | else {
|
37659 | if (!u[0])
|
37660 | return new g(3 === l ? -0 : 0);
|
37661 | e = new g(p);
|
37662 | }
|
37663 | return f ? k(e, a, l) : e;
|
37664 | } if (n = v(e.e / 7), c = v(p.e / 7), u = u.slice(), o = c - n) {
|
37665 | for ((m = o < 0) ? (i = u, o = -o, s = h.length) : (i = h, n = c, s = u.length), o > (t = Math.max(Math.ceil(a / 7), s) + 2) && (o = t, i.length = 1), i.reverse(), t = o; t--;)
|
37666 | i.push(0);
|
37667 | i.reverse();
|
37668 | }
|
37669 | else {
|
37670 | for ((m = (t = u.length) < (s = h.length)) && (s = t), t = 0; t < s; t++)
|
37671 | if (u[t] != h[t]) {
|
37672 | m = u[t] < h[t];
|
37673 | break;
|
37674 | }
|
37675 | o = 0;
|
37676 | } for (m && (i = u, u = h, h = i, e.s = -e.s), s = u.length, t = h.length - s; t > 0; --t)
|
37677 | u[s++] = 0; for (t = h.length; t > o;) {
|
37678 | if (u[--t] < h[t]) {
|
37679 | for (r = t; r && 0 === u[--r];)
|
37680 | u[r] = S - 1;
|
37681 | --u[r], u[t] += S;
|
37682 | }
|
37683 | u[t] -= h[t];
|
37684 | } for (; 0 === u[--s];)
|
37685 | u.pop(); for (; 0 === u[0]; u.shift())
|
37686 | --n; return u[0] ? (e.d = u, e.e = T(u, n), f ? k(e, a, l) : e) : new g(3 === l ? -0 : 0); }, D.modulo = D.mod = function (e) { var i, n = this, t = n.constructor; return e = new t(e), !n.d || !e.s || e.d && !e.d[0] ? new t(NaN) : !e.d || n.d && !n.d[0] ? k(new t(n), t.precision, t.rounding) : (f = !1, 9 == t.modulo ? (i = I(n, e.abs(), 0, 3, 1)).s *= e.s : i = I(n, e, 0, t.modulo, 1), i = i.times(e), f = !0, n.minus(i)); }, D.naturalExponential = D.exp = function () { return H(this); }, D.naturalLogarithm = D.ln = function () { return $(this); }, D.negated = D.neg = function () { var e = new this.constructor(this); return e.s = -e.s, k(e); }, D.plus = D.add = function (e) { var i, n, t, r, o, s, a, l, u, c, m = this, h = m.constructor; if (e = new h(e), !m.d || !e.d)
|
37687 | return m.s && e.s ? m.d || (e = new h(e.d || m.s === e.s ? m : NaN)) : e = new h(NaN), e; if (m.s != e.s)
|
37688 | return e.s = -e.s, m.minus(e); if (u = m.d, c = e.d, a = h.precision, l = h.rounding, !u[0] || !c[0])
|
37689 | return c[0] || (e = new h(m)), f ? k(e, a, l) : e; if (o = v(m.e / 7), t = v(e.e / 7), u = u.slice(), r = o - t) {
|
37690 | for (r < 0 ? (n = u, r = -r, s = c.length) : (n = c, t = o, s = u.length), r > (s = (o = Math.ceil(a / 7)) > s ? o + 1 : s + 1) && (r = s, n.length = 1), n.reverse(); r--;)
|
37691 | n.push(0);
|
37692 | n.reverse();
|
37693 | } for ((s = u.length) - (r = c.length) < 0 && (r = s, n = c, c = u, u = n), i = 0; r;)
|
37694 | i = (u[--r] = u[r] + c[r] + i) / S | 0, u[r] %= S; for (i && (u.unshift(i), ++t), s = u.length; 0 == u[--s];)
|
37695 | u.pop(); return e.d = u, e.e = T(u, t), f ? k(e, a, l) : e; }, D.precision = D.sd = function (e) { var i, n = this; if (void 0 !== e && e !== !!e && 1 !== e && 0 !== e)
|
37696 | throw Error(p + e); return n.d ? (i = L(n.d), e && n.e + 1 > i && (i = n.e + 1)) : i = NaN, i; }, D.round = function () { var e = this, i = e.constructor; return k(new i(e), e.e + 1, i.rounding); }, D.sine = D.sin = function () { var e, i, n = this, t = n.constructor; return n.isFinite() ? n.isZero() ? new t(n) : (e = t.precision, i = t.rounding, t.precision = e + Math.max(n.e, n.sd()) + 7, t.rounding = 1, n = function (e, i) { var n, t = i.d.length; if (t < 3)
|
37697 | return G(e, 2, i, i); n = (n = 1.4 * Math.sqrt(t)) > 16 ? 16 : 0 | n, i = G(e, 2, i = i.times(1 / W(5, n)), i); for (var r, o = new e(5), s = new e(16), a = new e(20); n--;)
|
37698 | r = i.times(i), i = i.times(o.plus(r.times(s.times(r).minus(a)))); return i; }(t, V(t, n)), t.precision = e, t.rounding = i, k(r > 2 ? n.neg() : n, e, i, !0)) : new t(NaN); }, D.squareRoot = D.sqrt = function () { var e, i, n, t, r, o, s = this, a = s.d, l = s.e, u = s.s, c = s.constructor; if (1 !== u || !a || !a[0])
|
37699 | return new c(!u || u < 0 && (!a || a[0]) ? NaN : a ? s : 1 / 0); for (f = !1, 0 == (u = Math.sqrt(+s)) || u == 1 / 0 ? (((i = A(a)).length + l) % 2 == 0 && (i += "0"), u = Math.sqrt(i), l = v((l + 1) / 2) - (l < 0 || l % 2), t = new c(i = u == 1 / 0 ? "5e" + l : (i = u.toExponential()).slice(0, i.indexOf("e") + 1) + l)) : t = new c(u.toString()), n = (l = c.precision) + 3;;)
|
37700 | if (t = (o = t).plus(I(s, o, n + 2, 1)).times(.5), A(o.d).slice(0, n) === (i = A(t.d)).slice(0, n)) {
|
37701 | if ("9999" != (i = i.slice(n - 3, n + 1)) && (r || "4999" != i)) {
|
37702 | +i && (+i.slice(1) || "5" != i.charAt(0)) || (k(t, l + 1, 1), e = !t.times(t).eq(s));
|
37703 | break;
|
37704 | }
|
37705 | if (!r && (k(o, l + 1, 0), o.times(o).eq(s))) {
|
37706 | t = o;
|
37707 | break;
|
37708 | }
|
37709 | n += 4, r = 1;
|
37710 | } return f = !0, k(t, l, c.rounding, e); }, D.tangent = D.tan = function () { var e, i, n = this, t = n.constructor; return n.isFinite() ? n.isZero() ? new t(n) : (e = t.precision, i = t.rounding, t.precision = e + 10, t.rounding = 1, (n = n.sin()).s = 1, n = I(n, new t(1).minus(n.times(n)).sqrt(), e + 10, 0), t.precision = e, t.rounding = i, k(2 == r || 4 == r ? n.neg() : n, e, i, !0)) : new t(NaN); }, D.times = D.mul = function (e) { var i, n, t, r, o, s, a, l, u, c = this, m = c.constructor, h = c.d, p = (e = new m(e)).d; if (e.s *= c.s, !(h && h[0] && p && p[0]))
|
37711 | return new m(!e.s || h && !h[0] && !p || p && !p[0] && !h ? NaN : h && p ? 0 * e.s : e.s / 0); for (n = v(c.e / 7) + v(e.e / 7), (l = h.length) < (u = p.length) && (o = h, h = p, p = o, s = l, l = u, u = s), o = [], t = s = l + u; t--;)
|
37712 | o.push(0); for (t = u; --t >= 0;) {
|
37713 | for (i = 0, r = l + t; r > t;)
|
37714 | a = o[r] + p[t] * h[r - t - 1] + i, o[r--] = a % S | 0, i = a / S | 0;
|
37715 | o[r] = (o[r] + i) % S | 0;
|
37716 | } for (; !o[--s];)
|
37717 | o.pop(); return i ? ++n : o.shift(), e.d = o, e.e = T(o, n), f ? k(e, m.precision, m.rounding) : e; }, D.toBinary = function (e, i) { return Y(this, 2, e, i); }, D.toDecimalPlaces = D.toDP = function (e, i) { var n = this, t = n.constructor; return n = new t(n), void 0 === e ? n : (C(e, 0, s), void 0 === i ? i = t.rounding : C(i, 0, 8), k(n, e + n.e + 1, i)); }, D.toExponential = function (e, i) { var n, t = this, r = t.constructor; return void 0 === e ? n = P(t, !0) : (C(e, 0, s), void 0 === i ? i = r.rounding : C(i, 0, 8), n = P(t = k(new r(t), e + 1, i), !0, e + 1)), t.isNeg() && !t.isZero() ? "-" + n : n; }, D.toFixed = function (e, i) { var n, t, r = this, o = r.constructor; return void 0 === e ? n = P(r) : (C(e, 0, s), void 0 === i ? i = o.rounding : C(i, 0, 8), n = P(t = k(new o(r), e + r.e + 1, i), !1, e + t.e + 1)), r.isNeg() && !r.isZero() ? "-" + n : n; }, D.toFraction = function (e) { var i, n, t, r, o, s, a, l, u, c, m, h, g = this, d = g.d, v = g.constructor; if (!d)
|
37718 | return new v(g); if (u = n = new v(1), t = l = new v(0), s = (o = (i = new v(t)).e = L(d) - g.e - 1) % 7, i.d[0] = x(10, s < 0 ? 7 + s : s), null == e)
|
37719 | e = o > 0 ? i : u;
|
37720 | else {
|
37721 | if (!(a = new v(e)).isInt() || a.lt(u))
|
37722 | throw Error(p + a);
|
37723 | e = a.gt(i) ? o > 0 ? i : u : a;
|
37724 | } for (f = !1, a = new v(A(d)), c = v.precision, v.precision = o = 7 * d.length * 2; m = I(a, i, 0, 1, 1), 1 != (r = n.plus(m.times(t))).cmp(e);)
|
37725 | n = t, t = r, r = u, u = l.plus(m.times(r)), l = r, r = i, i = a.minus(m.times(r)), a = r; return r = I(e.minus(n), t, 0, 1, 1), l = l.plus(r.times(u)), n = n.plus(r.times(t)), l.s = u.s = g.s, h = I(u, t, o, 1).minus(g).abs().cmp(I(l, n, o, 1).minus(g).abs()) < 1 ? [u, t] : [l, n], v.precision = c, f = !0, h; }, D.toHexadecimal = D.toHex = function (e, i) { return Y(this, 16, e, i); }, D.toNearest = function (e, i) { var n = this, t = n.constructor; if (n = new t(n), null == e) {
|
37726 | if (!n.d)
|
37727 | return n;
|
37728 | e = new t(1), i = t.rounding;
|
37729 | }
|
37730 | else {
|
37731 | if (e = new t(e), void 0 === i ? i = t.rounding : C(i, 0, 8), !n.d)
|
37732 | return e.s ? n : e;
|
37733 | if (!e.d)
|
37734 | return e.s && (e.s = n.s), e;
|
37735 | } return e.d[0] ? (f = !1, n = I(n, e, 0, i, 1).times(e), f = !0, k(n)) : (e.s = n.s, n = e), n; }, D.toNumber = function () { return +this; }, D.toOctal = function (e, i) { return Y(this, 8, e, i); }, D.toPower = D.pow = function (e) { var i, n, t, r, o, s, a = this, l = a.constructor, u = +(e = new l(e)); if (!(a.d && e.d && a.d[0] && e.d[0]))
|
37736 | return new l(x(+a, u)); if ((a = new l(a)).eq(1))
|
37737 | return a; if (t = l.precision, o = l.rounding, e.eq(1))
|
37738 | return k(a, t, o); if ((i = v(e.e / 7)) >= e.d.length - 1 && (n = u < 0 ? -u : u) <= 9007199254740991)
|
37739 | return r = R(l, a, n, t), e.s < 0 ? new l(1).div(r) : k(r, t, o); if ((s = a.s) < 0) {
|
37740 | if (i < e.d.length - 1)
|
37741 | return new l(NaN);
|
37742 | if (0 == (1 & e.d[i]) && (s = 1), 0 == a.e && 1 == a.d[0] && 1 == a.d.length)
|
37743 | return a.s = s, a;
|
37744 | } return (i = 0 != (n = x(+a, u)) && isFinite(n) ? new l(n + "").e : v(u * (Math.log("0." + A(a.d)) / Math.LN10 + a.e + 1))) > l.maxE + 1 || i < l.minE - 1 ? new l(i > 0 ? s / 0 : 0) : (f = !1, l.rounding = a.s = 1, n = Math.min(12, (i + "").length), (r = H(e.times($(a, t + n)), t)).d && q((r = k(r, t + 5, 1)).d, t, o) && (i = t + 10, +A((r = k(H(e.times($(a, i + n)), i), i + 5, 1)).d).slice(t + 1, t + 15) + 1 == 1e14 && (r = k(r, t + 1, 0))), r.s = s, f = !0, l.rounding = o, k(r, t, o)); }, D.toPrecision = function (e, i) { var n, t = this, r = t.constructor; return void 0 === e ? n = P(t, t.e <= r.toExpNeg || t.e >= r.toExpPos) : (C(e, 1, s), void 0 === i ? i = r.rounding : C(i, 0, 8), n = P(t = k(new r(t), e, i), e <= t.e || t.e <= r.toExpNeg, e)), t.isNeg() && !t.isZero() ? "-" + n : n; }, D.toSignificantDigits = D.toSD = function (e, i) { var n = this.constructor; return void 0 === e ? (e = n.precision, i = n.rounding) : (C(e, 1, s), void 0 === i ? i = n.rounding : C(i, 0, 8)), k(new n(this), e, i); }, D.toString = function () { var e = this, i = e.constructor, n = P(e, e.e <= i.toExpNeg || e.e >= i.toExpPos); return e.isNeg() && !e.isZero() ? "-" + n : n; }, D.truncated = D.trunc = function () { return k(new this.constructor(this), this.e + 1, 1); }, D.valueOf = D.toJSON = function () { var e = this, i = e.constructor, n = P(e, e.e <= i.toExpNeg || e.e >= i.toExpPos); return e.isNeg() ? "-" + n : n; }; var I = function () { function e(e, i, n) { var t, r = 0, o = e.length; for (e = e.slice(); o--;)
|
37745 | t = e[o] * i + r, e[o] = t % n | 0, r = t / n | 0; return r && e.unshift(r), e; } function i(e, i, n, t) { var r, o; if (n != t)
|
37746 | o = n > t ? 1 : -1;
|
37747 | else
|
37748 | for (r = o = 0; r < n; r++)
|
37749 | if (e[r] != i[r]) {
|
37750 | o = e[r] > i[r] ? 1 : -1;
|
37751 | break;
|
37752 | } return o; } function t(e, i, n, t) { for (var r = 0; n--;)
|
37753 | e[n] -= r, r = e[n] < i[n] ? 1 : 0, e[n] = r * t + e[n] - i[n]; for (; !e[0] && e.length > 1;)
|
37754 | e.shift(); } return function (r, o, s, a, l, u) { var c, m, f, h, p, g, d, x, y, b, N, w, M, E, D, A, C, q, F, I, P = r.constructor, T = r.s == o.s ? 1 : -1, O = r.d, z = o.d; if (!(O && O[0] && z && z[0]))
|
37755 | return new P(r.s && o.s && (O ? !z || O[0] != z[0] : z) ? O && 0 == O[0] || !z ? 0 * T : T / 0 : NaN); for (u ? (p = 1, m = r.e - o.e) : (u = S, p = 7, m = v(r.e / p) - v(o.e / p)), F = z.length, C = O.length, b = (y = new P(T)).d = [], f = 0; z[f] == (O[f] || 0); f++)
|
37756 | ; if (z[f] > (O[f] || 0) && m--, null == s ? (E = s = P.precision, a = P.rounding) : E = l ? s + (r.e - o.e) + 1 : s, E < 0)
|
37757 | b.push(1), g = !0;
|
37758 | else {
|
37759 | if (E = E / p + 2 | 0, f = 0, 1 == F) {
|
37760 | for (h = 0, z = z[0], E++; (f < C || h) && E--; f++)
|
37761 | D = h * u + (O[f] || 0), b[f] = D / z | 0, h = D % z | 0;
|
37762 | g = h || f < C;
|
37763 | }
|
37764 | else {
|
37765 | for ((h = u / (z[0] + 1) | 0) > 1 && (z = e(z, h, u), O = e(O, h, u), F = z.length, C = O.length), A = F, w = (N = O.slice(0, F)).length; w < F;)
|
37766 | N[w++] = 0;
|
37767 | (I = z.slice()).unshift(0), q = z[0], z[1] >= u / 2 && ++q;
|
37768 | do {
|
37769 | h = 0, (c = i(z, N, F, w)) < 0 ? (M = N[0], F != w && (M = M * u + (N[1] || 0)), (h = M / q | 0) > 1 ? (h >= u && (h = u - 1), 1 == (c = i(d = e(z, h, u), N, x = d.length, w = N.length)) && (h--, t(d, F < x ? I : z, x, u))) : (0 == h && (c = h = 1), d = z.slice()), (x = d.length) < w && d.unshift(0), t(N, d, w, u), -1 == c && (c = i(z, N, F, w = N.length)) < 1 && (h++, t(N, F < w ? I : z, w, u)), w = N.length) : 0 === c && (h++, N = [0]), b[f++] = h, c && N[0] ? N[w++] = O[A] || 0 : (N = [O[A]], w = 1);
|
37770 | } while ((A++ < C || void 0 !== N[0]) && E--);
|
37771 | g = void 0 !== N[0];
|
37772 | }
|
37773 | b[0] || b.shift();
|
37774 | } if (1 == p)
|
37775 | y.e = m, n = g;
|
37776 | else {
|
37777 | for (f = 1, h = b[0]; h >= 10; h /= 10)
|
37778 | f++;
|
37779 | y.e = f + m * p - 1, k(y, l ? s + y.e + 1 : s, a, g);
|
37780 | } return y; }; }(); function k(e, i, n, t) { var r, o, s, a, l, u, c, m, h, p = e.constructor; e: if (null != i) {
|
37781 | if (!(m = e.d))
|
37782 | return e;
|
37783 | for (r = 1, a = m[0]; a >= 10; a /= 10)
|
37784 | r++;
|
37785 | if ((o = i - r) < 0)
|
37786 | o += 7, s = i, l = (c = m[h = 0]) / x(10, r - s - 1) % 10 | 0;
|
37787 | else if ((h = Math.ceil((o + 1) / 7)) >= (a = m.length)) {
|
37788 | if (!t)
|
37789 | break e;
|
37790 | for (; a++ <= h;)
|
37791 | m.push(0);
|
37792 | c = l = 0, r = 1, s = (o %= 7) - 7 + 1;
|
37793 | }
|
37794 | else {
|
37795 | for (c = a = m[h], r = 1; a >= 10; a /= 10)
|
37796 | r++;
|
37797 | l = (s = (o %= 7) - 7 + r) < 0 ? 0 : c / x(10, r - s - 1) % 10 | 0;
|
37798 | }
|
37799 | if (t = t || i < 0 || void 0 !== m[h + 1] || (s < 0 ? c : c % x(10, r - s - 1)), u = n < 4 ? (l || t) && (0 == n || n == (e.s < 0 ? 3 : 2)) : l > 5 || 5 == l && (4 == n || t || 6 == n && (o > 0 ? s > 0 ? c / x(10, r - s) : 0 : m[h - 1]) % 10 & 1 || n == (e.s < 0 ? 8 : 7)), i < 1 || !m[0])
|
37800 | return m.length = 0, u ? (i -= e.e + 1, m[0] = x(10, (7 - i % 7) % 7), e.e = -i || 0) : m[0] = e.e = 0, e;
|
37801 | if (0 == o ? (m.length = h, a = 1, h--) : (m.length = h + 1, a = x(10, 7 - o), m[h] = s > 0 ? (c / x(10, r - s) % x(10, s) | 0) * a : 0), u)
|
37802 | for (;;) {
|
37803 | if (0 == h) {
|
37804 | for (o = 1, s = m[0]; s >= 10; s /= 10)
|
37805 | o++;
|
37806 | for (s = m[0] += a, a = 1; s >= 10; s /= 10)
|
37807 | a++;
|
37808 | o != a && (e.e++, m[0] == S && (m[0] = 1));
|
37809 | break;
|
37810 | }
|
37811 | if (m[h] += a, m[h] != S)
|
37812 | break;
|
37813 | m[h--] = 0, a = 1;
|
37814 | }
|
37815 | for (o = m.length; 0 === m[--o];)
|
37816 | m.pop();
|
37817 | } return f && (e.e > p.maxE ? (e.d = null, e.e = NaN) : e.e < p.minE && (e.e = 0, e.d = [0])), e; } function P(e, i, n) { if (!e.isFinite())
|
37818 | return j(e); var t, r = e.e, o = A(e.d), s = o.length; return i ? (n && (t = n - s) > 0 ? o = o.charAt(0) + "." + o.slice(1) + _(t) : s > 1 && (o = o.charAt(0) + "." + o.slice(1)), o = o + (e.e < 0 ? "e" : "e+") + e.e) : r < 0 ? (o = "0." + _(-r - 1) + o, n && (t = n - s) > 0 && (o += _(t))) : r >= s ? (o += _(r + 1 - s), n && (t = n - r - 1) > 0 && (o = o + "." + _(t))) : ((t = r + 1) < s && (o = o.slice(0, t) + "." + o.slice(t)), n && (t = n - s) > 0 && (r + 1 === s && (o += "."), o += _(t))), o; } function T(e, i) { var n = e[0]; for (i *= 7; n >= 10; n /= 10)
|
37819 | i++; return i; } function O(e, i, n) { if (i > M)
|
37820 | throw f = !0, n && (e.precision = n), Error(g); return k(new e(u), i, 1, !0); } function z(e, i, n) { if (i > E)
|
37821 | throw Error(g); return k(new e(c), i, n, !0); } function L(e) { var i = e.length - 1, n = 7 * i + 1; if (i = e[i]) {
|
37822 | for (; i % 10 == 0; i /= 10)
|
37823 | n--;
|
37824 | for (i = e[0]; i >= 10; i /= 10)
|
37825 | n++;
|
37826 | } return n; } function _(e) { for (var i = ""; e--;)
|
37827 | i += "0"; return i; } function R(e, i, n, t) { var r, o = new e(1), s = Math.ceil(t / 7 + 4); for (f = !1;;) {
|
37828 | if (n % 2 && J((o = o.times(i)).d, s) && (r = !0), 0 === (n = v(n / 2))) {
|
37829 | n = o.d.length - 1, r && 0 === o.d[n] && ++o.d[n];
|
37830 | break;
|
37831 | }
|
37832 | J((i = i.times(i)).d, s);
|
37833 | } return f = !0, o; } function Z(e) { return 1 & e.d[e.d.length - 1]; } function Q(e, i, n) { for (var t, r = new e(i[0]), o = 0; ++o < i.length;) {
|
37834 | if (!(t = new e(i[o])).s) {
|
37835 | r = t;
|
37836 | break;
|
37837 | }
|
37838 | r[n](t) && (r = t);
|
37839 | } return r; } function H(e, i) { var n, t, r, o, s, a, l, u = 0, c = 0, m = 0, h = e.constructor, p = h.rounding, g = h.precision; if (!e.d || !e.d[0] || e.e > 17)
|
37840 | return new h(e.d ? e.d[0] ? e.s < 0 ? 0 : 1 / 0 : 1 : e.s ? e.s < 0 ? 0 : e : NaN); for (null == i ? (f = !1, l = g) : l = i, a = new h(.03125); e.e > -2;)
|
37841 | e = e.times(a), m += 5; for (l += t = Math.log(x(2, m)) / Math.LN10 * 2 + 5 | 0, n = o = s = new h(1), h.precision = l;;) {
|
37842 | if (o = k(o.times(e), l, 1), n = n.times(++c), A((a = s.plus(I(o, n, l, 1))).d).slice(0, l) === A(s.d).slice(0, l)) {
|
37843 | for (r = m; r--;)
|
37844 | s = k(s.times(s), l, 1);
|
37845 | if (null != i)
|
37846 | return h.precision = g, s;
|
37847 | if (!(u < 3 && q(s.d, l - t, p, u)))
|
37848 | return k(s, h.precision = g, p, f = !0);
|
37849 | h.precision = l += 10, n = o = a = new h(1), c = 0, u++;
|
37850 | }
|
37851 | s = a;
|
37852 | } } function $(e, i) { var n, t, r, o, s, a, l, u, c, m, h, p = 1, g = e, d = g.d, v = g.constructor, x = v.rounding, y = v.precision; if (g.s < 0 || !d || !d[0] || !g.e && 1 == d[0] && 1 == d.length)
|
37853 | return new v(d && !d[0] ? -1 / 0 : 1 != g.s ? NaN : d ? 0 : g); if (null == i ? (f = !1, c = y) : c = i, v.precision = c += 10, t = (n = A(d)).charAt(0), !(Math.abs(o = g.e) < 15e14))
|
37854 | return u = O(v, c + 2, y).times(o + ""), g = $(new v(t + "." + n.slice(1)), c - 10).plus(u), v.precision = y, null == i ? k(g, y, x, f = !0) : g; for (; t < 7 && 1 != t || 1 == t && n.charAt(1) > 3;)
|
37855 | t = (n = A((g = g.times(e)).d)).charAt(0), p++; for (o = g.e, t > 1 ? (g = new v("0." + n), o++) : g = new v(t + "." + n.slice(1)), m = g, l = s = g = I(g.minus(1), g.plus(1), c, 1), h = k(g.times(g), c, 1), r = 3;;) {
|
37856 | if (s = k(s.times(h), c, 1), A((u = l.plus(I(s, new v(r), c, 1))).d).slice(0, c) === A(l.d).slice(0, c)) {
|
37857 | if (l = l.times(2), 0 !== o && (l = l.plus(O(v, c + 2, y).times(o + ""))), l = I(l, new v(p), c, 1), null != i)
|
37858 | return v.precision = y, l;
|
37859 | if (!q(l.d, c - 10, x, a))
|
37860 | return k(l, v.precision = y, x, f = !0);
|
37861 | v.precision = c += 10, u = s = g = I(m.minus(1), m.plus(1), c, 1), h = k(g.times(g), c, 1), r = a = 1;
|
37862 | }
|
37863 | l = u, r += 2;
|
37864 | } } function j(e) { return String(e.s * e.s / 0); } function B(e, i) { var n, t, r; for ((n = i.indexOf(".")) > -1 && (i = i.replace(".", "")), (t = i.search(/e/i)) > 0 ? (n < 0 && (n = t), n += +i.slice(t + 1), i = i.substring(0, t)) : n < 0 && (n = i.length), t = 0; 48 === i.charCodeAt(t); t++)
|
37865 | ; for (r = i.length; 48 === i.charCodeAt(r - 1); --r)
|
37866 | ; if (i = i.slice(t, r)) {
|
37867 | if (r -= t, e.e = n = n - t - 1, e.d = [], t = (n + 1) % 7, n < 0 && (t += 7), t < r) {
|
37868 | for (t && e.d.push(+i.slice(0, t)), r -= 7; t < r;)
|
37869 | e.d.push(+i.slice(t, t += 7));
|
37870 | t = 7 - (i = i.slice(t)).length;
|
37871 | }
|
37872 | else
|
37873 | t -= r;
|
37874 | for (; t--;)
|
37875 | i += "0";
|
37876 | e.d.push(+i), f && (e.e > e.constructor.maxE ? (e.d = null, e.e = NaN) : e.e < e.constructor.minE && (e.e = 0, e.d = [0]));
|
37877 | }
|
37878 | else
|
37879 | e.e = 0, e.d = [0]; return e; } function U(e, n) { var t, r, o, s, a, l, u, c, m; if ("Infinity" === n || "NaN" === n)
|
37880 | return +n || (e.s = NaN), e.e = NaN, e.d = null, e; if (b.test(n))
|
37881 | t = 16, n = n.toLowerCase();
|
37882 | else if (y.test(n))
|
37883 | t = 2;
|
37884 | else {
|
37885 | if (!N.test(n))
|
37886 | throw Error(p + n);
|
37887 | t = 8;
|
37888 | } for ((s = n.search(/p/i)) > 0 ? (u = +n.slice(s + 1), n = n.substring(2, s)) : n = n.slice(2), a = (s = n.indexOf(".")) >= 0, r = e.constructor, a && (s = (l = (n = n.replace(".", "")).length) - s, o = R(r, new r(t), s, 2 * s)), s = m = (c = F(n, t, S)).length - 1; 0 === c[s]; --s)
|
37889 | c.pop(); return s < 0 ? new r(0 * e.s) : (e.e = T(c, m), e.d = c, f = !1, a && (e = I(e, o, 4 * l)), u && (e = e.times(Math.abs(u) < 54 ? x(2, u) : i.pow(2, u))), f = !0, e); } function G(e, i, n, t, r) { var o, s, a, l, u = e.precision, c = Math.ceil(u / 7); for (f = !1, l = n.times(n), a = new e(t);;) {
|
37890 | if (s = I(a.times(l), new e(i++ * i++), u, 1), a = r ? t.plus(s) : t.minus(s), t = I(s.times(l), new e(i++ * i++), u, 1), void 0 !== (s = a.plus(t)).d[c]) {
|
37891 | for (o = c; s.d[o] === a.d[o] && o--;)
|
37892 | ;
|
37893 | if (-1 == o)
|
37894 | break;
|
37895 | }
|
37896 | o = a, a = t, t = s, s = o;
|
37897 | } return f = !0, s.d.length = c + 1, s; } function W(e, i) { for (var n = e; --i;)
|
37898 | n *= e; return n; } function V(e, i) { var n, t = i.s < 0, o = z(e, e.precision, 1), s = o.times(.5); if ((i = i.abs()).lte(s))
|
37899 | return r = t ? 4 : 1, i; if ((n = i.divToInt(o)).isZero())
|
37900 | r = t ? 3 : 2;
|
37901 | else {
|
37902 | if ((i = i.minus(n.times(o))).lte(s))
|
37903 | return r = Z(n) ? t ? 2 : 3 : t ? 4 : 1, i;
|
37904 | r = Z(n) ? t ? 1 : 4 : t ? 3 : 2;
|
37905 | } return i.minus(o).abs(); } function Y(e, i, t, r) { var o, l, u, c, m, f, h, p, g, d = e.constructor, v = void 0 !== t; if (v ? (C(t, 1, s), void 0 === r ? r = d.rounding : C(r, 0, 8)) : (t = d.precision, r = d.rounding), e.isFinite()) {
|
37906 | for (v ? (o = 2, 16 == i ? t = 4 * t - 3 : 8 == i && (t = 3 * t - 2)) : o = i, (u = (h = P(e)).indexOf(".")) >= 0 && (h = h.replace(".", ""), (g = new d(1)).e = h.length - u, g.d = F(P(g), 10, o), g.e = g.d.length), l = m = (p = F(h, 10, o)).length; 0 == p[--m];)
|
37907 | p.pop();
|
37908 | if (p[0]) {
|
37909 | if (u < 0 ? l-- : ((e = new d(e)).d = p, e.e = l, p = (e = I(e, g, t, r, 0, o)).d, l = e.e, f = n), u = p[t], c = o / 2, f = f || void 0 !== p[t + 1], f = r < 4 ? (void 0 !== u || f) && (0 === r || r === (e.s < 0 ? 3 : 2)) : u > c || u === c && (4 === r || f || 6 === r && 1 & p[t - 1] || r === (e.s < 0 ? 8 : 7)), p.length = t, f)
|
37910 | for (; ++p[--t] > o - 1;)
|
37911 | p[t] = 0, t || (++l, p.unshift(1));
|
37912 | for (m = p.length; !p[m - 1]; --m)
|
37913 | ;
|
37914 | for (u = 0, h = ""; u < m; u++)
|
37915 | h += a.charAt(p[u]);
|
37916 | if (v) {
|
37917 | if (m > 1)
|
37918 | if (16 == i || 8 == i) {
|
37919 | for (u = 16 == i ? 4 : 3, --m; m % u; m++)
|
37920 | h += "0";
|
37921 | for (m = (p = F(h, o, i)).length; !p[m - 1]; --m)
|
37922 | ;
|
37923 | for (u = 1, h = "1."; u < m; u++)
|
37924 | h += a.charAt(p[u]);
|
37925 | }
|
37926 | else
|
37927 | h = h.charAt(0) + "." + h.slice(1);
|
37928 | h = h + (l < 0 ? "p" : "p+") + l;
|
37929 | }
|
37930 | else if (l < 0) {
|
37931 | for (; ++l;)
|
37932 | h = "0" + h;
|
37933 | h = "0." + h;
|
37934 | }
|
37935 | else if (++l > m)
|
37936 | for (l -= m; l--;)
|
37937 | h += "0";
|
37938 | else
|
37939 | l < m && (h = h.slice(0, l) + "." + h.slice(l));
|
37940 | }
|
37941 | else
|
37942 | h = v ? "0p+0" : "0";
|
37943 | h = (16 == i ? "0x" : 2 == i ? "0b" : 8 == i ? "0o" : "") + h;
|
37944 | }
|
37945 | else
|
37946 | h = j(e); return e.s < 0 ? "-" + h : h; } function J(e, i) { if (e.length > i)
|
37947 | return e.length = i, !0; } function X(e) { return new this(e).abs(); } function K(e) { return new this(e).acos(); } function ee(e) { return new this(e).acosh(); } function ie(e, i) { return new this(e).plus(i); } function ne(e) { return new this(e).asin(); } function te(e) { return new this(e).asinh(); } function re(e) { return new this(e).atan(); } function oe(e) { return new this(e).atanh(); } function se(e, i) { e = new this(e), i = new this(i); var n, t = this.precision, r = this.rounding, o = t + 4; return e.s && i.s ? e.d || i.d ? !i.d || e.isZero() ? (n = i.s < 0 ? z(this, t, r) : new this(0)).s = e.s : !e.d || i.isZero() ? (n = z(this, o, 1).times(.5)).s = e.s : i.s < 0 ? (this.precision = o, this.rounding = 1, n = this.atan(I(e, i, o, 1)), i = z(this, o, 1), this.precision = t, this.rounding = r, n = e.s < 0 ? n.minus(i) : n.plus(i)) : n = this.atan(I(e, i, o, 1)) : (n = z(this, o, 1).times(i.s > 0 ? .25 : .75)).s = e.s : n = new this(NaN), n; } function ae(e) { return new this(e).cbrt(); } function le(e) { return k(e = new this(e), e.e + 1, 2); } function ue(e) { if (!e || "object" != typeof e)
|
37948 | throw Error(h + "Object expected"); var i, n, t, r = !0 === e.defaults, a = ["precision", 1, s, "rounding", 0, 8, "toExpNeg", -o, 0, "toExpPos", 0, o, "maxE", 0, o, "minE", -o, 0, "modulo", 0, 9]; for (i = 0; i < a.length; i += 3)
|
37949 | if (n = a[i], r && (this[n] = m[n]), void 0 !== (t = e[n])) {
|
37950 | if (!(v(t) === t && t >= a[i + 1] && t <= a[i + 2]))
|
37951 | throw Error(p + n + ": " + t);
|
37952 | this[n] = t;
|
37953 | } if (n = "crypto", r && (this[n] = m[n]), void 0 !== (t = e[n])) {
|
37954 | if (!0 !== t && !1 !== t && 0 !== t && 1 !== t)
|
37955 | throw Error(p + n + ": " + t);
|
37956 | if (t) {
|
37957 | if ("undefined" == typeof crypto || !crypto || !crypto.getRandomValues && !crypto.randomBytes)
|
37958 | throw Error(d);
|
37959 | this[n] = !0;
|
37960 | }
|
37961 | else
|
37962 | this[n] = !1;
|
37963 | } return this; } function ce(e) { return new this(e).cos(); } function me(e) { return new this(e).cosh(); } function fe(e, i) { return new this(e).div(i); } function he(e) { return new this(e).exp(); } function pe(e) { return k(e = new this(e), e.e + 1, 3); } function ge() { var e, i, n = new this(0); for (f = !1, e = 0; e < arguments.length;)
|
37964 | if ((i = new this(arguments[e++])).d)
|
37965 | n.d && (n = n.plus(i.times(i)));
|
37966 | else {
|
37967 | if (i.s)
|
37968 | return f = !0, new this(1 / 0);
|
37969 | n = i;
|
37970 | } return f = !0, n.sqrt(); } function de(e) { return e instanceof i || e && "[object Decimal]" === e.name || !1; } function ve(e) { return new this(e).ln(); } function xe(e, i) { return new this(e).log(i); } function ye(e) { return new this(e).log(2); } function be(e) { return new this(e).log(10); } function Ne() { return Q(this, arguments, "lt"); } function we() { return Q(this, arguments, "gt"); } function Se(e, i) { return new this(e).mod(i); } function Me(e, i) { return new this(e).mul(i); } function Ee(e, i) { return new this(e).pow(i); } function De(e) { var i, n, t, r, o = 0, a = new this(1), l = []; if (void 0 === e ? e = this.precision : C(e, 1, s), t = Math.ceil(e / 7), this.crypto)
|
37971 | if (crypto.getRandomValues)
|
37972 | for (i = crypto.getRandomValues(new Uint32Array(t)); o < t;)
|
37973 | (r = i[o]) >= 429e7 ? i[o] = crypto.getRandomValues(new Uint32Array(1))[0] : l[o++] = r % 1e7;
|
37974 | else {
|
37975 | if (!crypto.randomBytes)
|
37976 | throw Error(d);
|
37977 | for (i = crypto.randomBytes(t *= 4); o < t;)
|
37978 | (r = i[o] + (i[o + 1] << 8) + (i[o + 2] << 16) + ((127 & i[o + 3]) << 24)) >= 214e7 ? crypto.randomBytes(4).copy(i, o) : (l.push(r % 1e7), o += 4);
|
37979 | o = t / 4;
|
37980 | }
|
37981 | else
|
37982 | for (; o < t;)
|
37983 | l[o++] = 1e7 * Math.random() | 0; for (e %= 7, (t = l[--o]) && e && (r = x(10, 7 - e), l[o] = (t / r | 0) * r); 0 === l[o]; o--)
|
37984 | l.pop(); if (o < 0)
|
37985 | n = 0, l = [0];
|
37986 | else {
|
37987 | for (n = -1; 0 === l[0]; n -= 7)
|
37988 | l.shift();
|
37989 | for (t = 1, r = l[0]; r >= 10; r /= 10)
|
37990 | t++;
|
37991 | t < 7 && (n -= 7 - t);
|
37992 | } return a.e = n, a.d = l, a; } function Ae(e) { return k(e = new this(e), e.e + 1, this.rounding); } function Ce(e) { return (e = new this(e)).d ? e.d[0] ? e.s : 0 * e.s : e.s || NaN; } function qe(e) { return new this(e).sin(); } function Fe(e) { return new this(e).sinh(); } function Ie(e) { return new this(e).sqrt(); } function ke(e, i) { return new this(e).sub(i); } function Pe(e) { return new this(e).tan(); } function Te(e) { return new this(e).tanh(); } function Oe(e) { return k(e = new this(e), e.e + 1, 1); } (i = function e(i) { var n, t, r; function o(e) { var i, n, t, r = this; if (!(r instanceof o))
|
37993 | return new o(e); if (r.constructor = o, e instanceof o)
|
37994 | return r.s = e.s, void (f ? !e.d || e.e > o.maxE ? (r.e = NaN, r.d = null) : e.e < o.minE ? (r.e = 0, r.d = [0]) : (r.e = e.e, r.d = e.d.slice()) : (r.e = e.e, r.d = e.d ? e.d.slice() : e.d)); if ("number" == (t = typeof e)) {
|
37995 | if (0 === e)
|
37996 | return r.s = 1 / e < 0 ? -1 : 1, r.e = 0, void (r.d = [0]);
|
37997 | if (e < 0 ? (e = -e, r.s = -1) : r.s = 1, e === ~~e && e < 1e7) {
|
37998 | for (i = 0, n = e; n >= 10; n /= 10)
|
37999 | i++;
|
38000 | return void (f ? i > o.maxE ? (r.e = NaN, r.d = null) : i < o.minE ? (r.e = 0, r.d = [0]) : (r.e = i, r.d = [e]) : (r.e = i, r.d = [e]));
|
38001 | }
|
38002 | return 0 * e != 0 ? (e || (r.s = NaN), r.e = NaN, void (r.d = null)) : B(r, e.toString());
|
38003 | } if ("string" !== t)
|
38004 | throw Error(p + e); return 45 === (n = e.charCodeAt(0)) ? (e = e.slice(1), r.s = -1) : (43 === n && (e = e.slice(1)), r.s = 1), w.test(e) ? B(r, e) : U(r, e); } if (o.prototype = D, o.ROUND_UP = 0, o.ROUND_DOWN = 1, o.ROUND_CEIL = 2, o.ROUND_FLOOR = 3, o.ROUND_HALF_UP = 4, o.ROUND_HALF_DOWN = 5, o.ROUND_HALF_EVEN = 6, o.ROUND_HALF_CEIL = 7, o.ROUND_HALF_FLOOR = 8, o.EUCLID = 9, o.config = o.set = ue, o.clone = e, o.isDecimal = de, o.abs = X, o.acos = K, o.acosh = ee, o.add = ie, o.asin = ne, o.asinh = te, o.atan = re, o.atanh = oe, o.atan2 = se, o.cbrt = ae, o.ceil = le, o.cos = ce, o.cosh = me, o.div = fe, o.exp = he, o.floor = pe, o.hypot = ge, o.ln = ve, o.log = xe, o.log10 = be, o.log2 = ye, o.max = Ne, o.min = we, o.mod = Se, o.mul = Me, o.pow = Ee, o.random = De, o.round = Ae, o.sign = Ce, o.sin = qe, o.sinh = Fe, o.sqrt = Ie, o.sub = ke, o.tan = Pe, o.tanh = Te, o.trunc = Oe, void 0 === i && (i = {}), i && !0 !== i.defaults)
|
38005 | for (r = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"], n = 0; n < r.length;)
|
38006 | i.hasOwnProperty(t = r[n++]) || (i[t] = this[t]); return o.config(i), o; }(m)).default = i.Decimal = i, u = new i(u), c = new i(c), l.exports ? ("function" == typeof Symbol && "symbol" == typeof Symbol.iterator && (D[Symbol.for("nodejs.util.inspect.custom")] = D.toString, D[Symbol.toStringTag] = "Decimal"), l.exports = i) : (e || (e = "undefined" != typeof self && self && self.self == self ? self : window), t = e.Decimal, i.noConflict = function () { return e.Decimal = t, i; }, e.Decimal = i); }(u);
|
38007 | var m = { exports: {} };
|
38008 | /**
|
38009 | * @license Complex.js v2.0.13 12/05/2020
|
38010 | *
|
38011 | * Copyright (c) 2020, Robert Eisele (robert@xarg.org)
|
38012 | * Dual licensed under the MIT or GPL Version 2 licenses.
|
38013 | **/ !function (e, i) { !function (i) { var n = function (e) { return .5 * (Math.exp(e) + Math.exp(-e)); }, t = function (e) { return .5 * (Math.exp(e) - Math.exp(-e)); }, r = function () { throw SyntaxError("Invalid Param"); }; function o(e, i) { var n = Math.abs(e), t = Math.abs(i); return 0 === e ? Math.log(t) : 0 === i ? Math.log(n) : n < 3e3 && t < 3e3 ? .5 * Math.log(e * e + i * i) : Math.log(e / Math.cos(Math.atan2(i, e))); } function s(e, i) { if (!(this instanceof s))
|
38014 | return new s(e, i); var n = function (e, i) { var n = { re: 0, im: 0 }; if (null == e)
|
38015 | n.re = n.im = 0;
|
38016 | else if (void 0 !== i)
|
38017 | n.re = e, n.im = i;
|
38018 | else
|
38019 | switch (typeof e) {
|
38020 | case "object":
|
38021 | if ("im" in e && "re" in e)
|
38022 | n.re = e.re, n.im = e.im;
|
38023 | else if ("abs" in e && "arg" in e) {
|
38024 | if (!Number.isFinite(e.abs) && Number.isFinite(e.arg))
|
38025 | return s.INFINITY;
|
38026 | n.re = e.abs * Math.cos(e.arg), n.im = e.abs * Math.sin(e.arg);
|
38027 | }
|
38028 | else if ("r" in e && "phi" in e) {
|
38029 | if (!Number.isFinite(e.r) && Number.isFinite(e.phi))
|
38030 | return s.INFINITY;
|
38031 | n.re = e.r * Math.cos(e.phi), n.im = e.r * Math.sin(e.phi);
|
38032 | }
|
38033 | else
|
38034 | 2 === e.length ? (n.re = e[0], n.im = e[1]) : r();
|
38035 | break;
|
38036 | case "string":
|
38037 | n.im = n.re = 0;
|
38038 | var t = e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g), o = 1, a = 0;
|
38039 | null === t && r();
|
38040 | for (var l = 0; l < t.length; l++) {
|
38041 | var u = t[l];
|
38042 | " " === u || "\t" === u || "\n" === u || ("+" === u ? o++ : "-" === u ? a++ : "i" === u || "I" === u ? (o + a === 0 && r(), " " === t[l + 1] || isNaN(t[l + 1]) ? n.im += parseFloat((a % 2 ? "-" : "") + "1") : (n.im += parseFloat((a % 2 ? "-" : "") + t[l + 1]), l++), o = a = 0) : ((o + a === 0 || isNaN(u)) && r(), "i" === t[l + 1] || "I" === t[l + 1] ? (n.im += parseFloat((a % 2 ? "-" : "") + u), l++) : n.re += parseFloat((a % 2 ? "-" : "") + u), o = a = 0));
|
38043 | }
|
38044 | o + a > 0 && r();
|
38045 | break;
|
38046 | case "number":
|
38047 | n.im = 0, n.re = e;
|
38048 | break;
|
38049 | default: r();
|
38050 | } return isNaN(n.re) || isNaN(n.im), n; }(e, i); this.re = n.re, this.im = n.im; } s.prototype = { re: 0, im: 0, sign: function () { var e = this.abs(); return new s(this.re / e, this.im / e); }, add: function (e, i) { var n = new s(e, i); return this.isInfinite() && n.isInfinite() ? s.NAN : this.isInfinite() || n.isInfinite() ? s.INFINITY : new s(this.re + n.re, this.im + n.im); }, sub: function (e, i) { var n = new s(e, i); return this.isInfinite() && n.isInfinite() ? s.NAN : this.isInfinite() || n.isInfinite() ? s.INFINITY : new s(this.re - n.re, this.im - n.im); }, mul: function (e, i) { var n = new s(e, i); return this.isInfinite() && n.isZero() || this.isZero() && n.isInfinite() ? s.NAN : this.isInfinite() || n.isInfinite() ? s.INFINITY : 0 === n.im && 0 === this.im ? new s(this.re * n.re, 0) : new s(this.re * n.re - this.im * n.im, this.re * n.im + this.im * n.re); }, div: function (e, i) { var n = new s(e, i); if (this.isZero() && n.isZero() || this.isInfinite() && n.isInfinite())
|
38051 | return s.NAN; if (this.isInfinite() || n.isZero())
|
38052 | return s.INFINITY; if (this.isZero() || n.isInfinite())
|
38053 | return s.ZERO; e = this.re, i = this.im; var t, r, o = n.re, a = n.im; return 0 === a ? new s(e / o, i / o) : Math.abs(o) < Math.abs(a) ? new s((e * (r = o / a) + i) / (t = o * r + a), (i * r - e) / t) : new s((e + i * (r = a / o)) / (t = a * r + o), (i - e * r) / t); }, pow: function (e, i) { var n = new s(e, i); if (e = this.re, i = this.im, n.isZero())
|
38054 | return s.ONE; if (0 === n.im) {
|
38055 | if (0 === i && e > 0)
|
38056 | return new s(Math.pow(e, n.re), 0);
|
38057 | if (0 === e)
|
38058 | switch ((n.re % 4 + 4) % 4) {
|
38059 | case 0: return new s(Math.pow(i, n.re), 0);
|
38060 | case 1: return new s(0, Math.pow(i, n.re));
|
38061 | case 2: return new s(-Math.pow(i, n.re), 0);
|
38062 | case 3: return new s(0, -Math.pow(i, n.re));
|
38063 | }
|
38064 | } if (0 === e && 0 === i && n.re > 0 && n.im >= 0)
|
38065 | return s.ZERO; var t = Math.atan2(i, e), r = o(e, i); return e = Math.exp(n.re * r - n.im * t), i = n.im * r + n.re * t, new s(e * Math.cos(i), e * Math.sin(i)); }, sqrt: function () { var e, i, n = this.re, t = this.im, r = this.abs(); if (n >= 0) {
|
38066 | if (0 === t)
|
38067 | return new s(Math.sqrt(n), 0);
|
38068 | e = .5 * Math.sqrt(2 * (r + n));
|
38069 | }
|
38070 | else
|
38071 | e = Math.abs(t) / Math.sqrt(2 * (r - n)); return i = n <= 0 ? .5 * Math.sqrt(2 * (r - n)) : Math.abs(t) / Math.sqrt(2 * (r + n)), new s(e, t < 0 ? -i : i); }, exp: function () { var e = Math.exp(this.re); return this.im, new s(e * Math.cos(this.im), e * Math.sin(this.im)); }, expm1: function () { var e = this.re, i = this.im; return new s(Math.expm1(e) * Math.cos(i) + function (e) { var i = Math.PI / 4; if (e < -i || e > i)
|
38072 | return Math.cos(e) - 1; var n = e * e; return n * (n * (1 / 24 + n * (-1 / 720 + n * (1 / 40320 + n * (-1 / 3628800 + n * (1 / 4790014600 + n * (-1 / 87178291200 + n * (1 / 20922789888e3))))))) - .5); }(i), Math.exp(e) * Math.sin(i)); }, log: function () { var e = this.re, i = this.im; return new s(o(e, i), Math.atan2(i, e)); }, abs: function () { return e = this.re, i = this.im, n = Math.abs(e), t = Math.abs(i), n < 3e3 && t < 3e3 ? Math.sqrt(n * n + t * t) : (n < t ? (n = t, t = e / i) : t = i / e, n * Math.sqrt(1 + t * t)); var e, i, n, t; }, arg: function () { return Math.atan2(this.im, this.re); }, sin: function () { var e = this.re, i = this.im; return new s(Math.sin(e) * n(i), Math.cos(e) * t(i)); }, cos: function () { var e = this.re, i = this.im; return new s(Math.cos(e) * n(i), -Math.sin(e) * t(i)); }, tan: function () { var e = 2 * this.re, i = 2 * this.im, r = Math.cos(e) + n(i); return new s(Math.sin(e) / r, t(i) / r); }, cot: function () { var e = 2 * this.re, i = 2 * this.im, r = Math.cos(e) - n(i); return new s(-Math.sin(e) / r, t(i) / r); }, sec: function () { var e = this.re, i = this.im, r = .5 * n(2 * i) + .5 * Math.cos(2 * e); return new s(Math.cos(e) * n(i) / r, Math.sin(e) * t(i) / r); }, csc: function () { var e = this.re, i = this.im, r = .5 * n(2 * i) - .5 * Math.cos(2 * e); return new s(Math.sin(e) * n(i) / r, -Math.cos(e) * t(i) / r); }, asin: function () { var e = this.re, i = this.im, n = new s(i * i - e * e + 1, -2 * e * i).sqrt(), t = new s(n.re - i, n.im + e).log(); return new s(t.im, -t.re); }, acos: function () { var e = this.re, i = this.im, n = new s(i * i - e * e + 1, -2 * e * i).sqrt(), t = new s(n.re - i, n.im + e).log(); return new s(Math.PI / 2 - t.im, t.re); }, atan: function () { var e = this.re, i = this.im; if (0 === e) {
|
38073 | if (1 === i)
|
38074 | return new s(0, 1 / 0);
|
38075 | if (-1 === i)
|
38076 | return new s(0, -1 / 0);
|
38077 | } var n = e * e + (1 - i) * (1 - i), t = new s((1 - i * i - e * e) / n, -2 * e / n).log(); return new s(-.5 * t.im, .5 * t.re); }, acot: function () { var e = this.re, i = this.im; if (0 === i)
|
38078 | return new s(Math.atan2(1, e), 0); var n = e * e + i * i; return 0 !== n ? new s(e / n, -i / n).atan() : new s(0 !== e ? e / 0 : 0, 0 !== i ? -i / 0 : 0).atan(); }, asec: function () { var e = this.re, i = this.im; if (0 === e && 0 === i)
|
38079 | return new s(0, 1 / 0); var n = e * e + i * i; return 0 !== n ? new s(e / n, -i / n).acos() : new s(0 !== e ? e / 0 : 0, 0 !== i ? -i / 0 : 0).acos(); }, acsc: function () { var e = this.re, i = this.im; if (0 === e && 0 === i)
|
38080 | return new s(Math.PI / 2, 1 / 0); var n = e * e + i * i; return 0 !== n ? new s(e / n, -i / n).asin() : new s(0 !== e ? e / 0 : 0, 0 !== i ? -i / 0 : 0).asin(); }, sinh: function () { var e = this.re, i = this.im; return new s(t(e) * Math.cos(i), n(e) * Math.sin(i)); }, cosh: function () { var e = this.re, i = this.im; return new s(n(e) * Math.cos(i), t(e) * Math.sin(i)); }, tanh: function () { var e = 2 * this.re, i = 2 * this.im, r = n(e) + Math.cos(i); return new s(t(e) / r, Math.sin(i) / r); }, coth: function () { var e = 2 * this.re, i = 2 * this.im, r = n(e) - Math.cos(i); return new s(t(e) / r, -Math.sin(i) / r); }, csch: function () { var e = this.re, i = this.im, r = Math.cos(2 * i) - n(2 * e); return new s(-2 * t(e) * Math.cos(i) / r, 2 * n(e) * Math.sin(i) / r); }, sech: function () { var e = this.re, i = this.im, r = Math.cos(2 * i) + n(2 * e); return new s(2 * n(e) * Math.cos(i) / r, -2 * t(e) * Math.sin(i) / r); }, asinh: function () { var e = this.im; this.im = -this.re, this.re = e; var i = this.asin(); return this.re = -this.im, this.im = e, e = i.re, i.re = -i.im, i.im = e, i; }, acosh: function () { var e = this.acos(); if (e.im <= 0) {
|
38081 | var i = e.re;
|
38082 | e.re = -e.im, e.im = i;
|
38083 | }
|
38084 | else
|
38085 | i = e.im, e.im = -e.re, e.re = i; return e; }, atanh: function () { var e = this.re, i = this.im, n = e > 1 && 0 === i, t = 1 - e, r = 1 + e, a = t * t + i * i, l = 0 !== a ? new s((r * t - i * i) / a, (i * t + r * i) / a) : new s(-1 !== e ? e / 0 : 0, 0 !== i ? i / 0 : 0), u = l.re; return l.re = o(l.re, l.im) / 2, l.im = Math.atan2(l.im, u) / 2, n && (l.im = -l.im), l; }, acoth: function () { var e = this.re, i = this.im; if (0 === e && 0 === i)
|
38086 | return new s(0, Math.PI / 2); var n = e * e + i * i; return 0 !== n ? new s(e / n, -i / n).atanh() : new s(0 !== e ? e / 0 : 0, 0 !== i ? -i / 0 : 0).atanh(); }, acsch: function () { var e = this.re, i = this.im; if (0 === i)
|
38087 | return new s(0 !== e ? Math.log(e + Math.sqrt(e * e + 1)) : 1 / 0, 0); var n = e * e + i * i; return 0 !== n ? new s(e / n, -i / n).asinh() : new s(0 !== e ? e / 0 : 0, 0 !== i ? -i / 0 : 0).asinh(); }, asech: function () { var e = this.re, i = this.im; if (this.isZero())
|
38088 | return s.INFINITY; var n = e * e + i * i; return 0 !== n ? new s(e / n, -i / n).acosh() : new s(0 !== e ? e / 0 : 0, 0 !== i ? -i / 0 : 0).acosh(); }, inverse: function () { if (this.isZero())
|
38089 | return s.INFINITY; if (this.isInfinite())
|
38090 | return s.ZERO; var e = this.re, i = this.im, n = e * e + i * i; return new s(e / n, -i / n); }, conjugate: function () { return new s(this.re, -this.im); }, neg: function () { return new s(-this.re, -this.im); }, ceil: function (e) { return e = Math.pow(10, e || 0), new s(Math.ceil(this.re * e) / e, Math.ceil(this.im * e) / e); }, floor: function (e) { return e = Math.pow(10, e || 0), new s(Math.floor(this.re * e) / e, Math.floor(this.im * e) / e); }, round: function (e) { return e = Math.pow(10, e || 0), new s(Math.round(this.re * e) / e, Math.round(this.im * e) / e); }, equals: function (e, i) { var n = new s(e, i); return Math.abs(n.re - this.re) <= s.EPSILON && Math.abs(n.im - this.im) <= s.EPSILON; }, clone: function () { return new s(this.re, this.im); }, toString: function () { var e = this.re, i = this.im, n = ""; return this.isNaN() ? "NaN" : this.isInfinite() ? "Infinity" : (Math.abs(e) < s.EPSILON && (e = 0), Math.abs(i) < s.EPSILON && (i = 0), 0 === i ? n + e : (0 !== e ? (n += e, n += " ", i < 0 ? (i = -i, n += "-") : n += "+", n += " ") : i < 0 && (i = -i, n += "-"), 1 !== i && (n += i), n + "i")); }, toVector: function () { return [this.re, this.im]; }, valueOf: function () { return 0 === this.im ? this.re : null; }, isNaN: function () { return isNaN(this.re) || isNaN(this.im); }, isZero: function () { return 0 === this.im && 0 === this.re; }, isFinite: function () { return isFinite(this.re) && isFinite(this.im); }, isInfinite: function () { return !(this.isNaN() || this.isFinite()); } }, s.ZERO = new s(0, 0), s.ONE = new s(1, 0), s.I = new s(0, 1), s.PI = new s(Math.PI, 0), s.E = new s(Math.E, 0), s.INFINITY = new s(1 / 0, 1 / 0), s.NAN = new s(NaN, NaN), s.EPSILON = 1e-15, Object.defineProperty(s, "__esModule", { value: !0 }), s.default = s, s.Complex = s, e.exports = s; }(); }(m);
|
38091 | const f = new c.exports.Decimal(0), h = new c.exports.Decimal(1), p = new c.exports.Decimal(-1), g = new c.exports.Decimal(NaN), d = new c.exports.Decimal(1 / 0), v = new c.exports.Decimal(-1 / 0);
|
38092 | function x(e) { if ("number" == typeof e && (e = new c.exports.Decimal(e)), !e.isInteger() || e.isNegative())
|
38093 | return g; if (e.lessThan(10))
|
38094 | return new c.exports.Decimal([1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800][e.toNumber()]); if (e.gt(Number.MAX_SAFE_INTEGER)) {
|
38095 | let i = h, n = new c.exports.Decimal(2);
|
38096 | for (; n.lessThan(e);)
|
38097 | i = i.mul(n), n = n.add(1);
|
38098 | return i;
|
38099 | } if (e.modulo(2).eq(1))
|
38100 | return e.times(x(e.minus(1))); let i = e.toNumber(), n = e.toNumber(), t = e; for (; i > 2;)
|
38101 | i -= 2, n += i, t = t.mul(n); return t; }
|
38102 | const y = [.9999999999998099, 676.5203681218851, -1259.1392167224028, 771.3234287776531, -176.6150291621406, 12.507343278686905, -.13857109526572012, 9984369578019572e-21, 1.5056327351493116e-7].map((e => new c.exports.Decimal(e))), b = new c.exports.Decimal(607).div(128), N = [.9999999999999971, 57.15623566586292, -59.59796035547549, 14.136097974741746, -.4919138160976202, 3399464998481189e-20, 4652362892704858e-20, -9837447530487956e-20, .0001580887032249125, -.00021026444172410488, .00021743961811521265, -.0001643181065367639, 8441822398385275e-20, -26190838401581408e-21, 36899182659531625e-22].map((e => new c.exports.Decimal(e)));
|
38103 | function w(e) { if ("number" == typeof e && (e = new c.exports.Decimal(e)), e.isNegative())
|
38104 | return g; let i = N[0]; for (let n = N.length - 1; n > 0; --n)
|
38105 | i = i.add(N[n].div(e.add(n))); const n = e.add(b).add(.5); return c.exports.Decimal.acos(-1).mul(2).log().mul(.5).add(n.log().mul(e.add(.5)).minus(n).add(i.log()).minus(e.log())); }
|
38106 | function S(e) { if ("number" == typeof e && (e = new c.exports.Decimal(e)), e.lessThan(.5)) {
|
38107 | const i = c.exports.Decimal.acos(-1);
|
38108 | return i.div(i.mul(e).sin().mul(S(c.exports.Decimal.sub(1, e))));
|
38109 | } if (e.greaterThan(100))
|
38110 | return w(e).exp(); {
|
38111 | e = e.sub(1);
|
38112 | let i = y[0];
|
38113 | for (let n = 1; n < 9; n++)
|
38114 | i = i.add(y[n].div(e.add(n)));
|
38115 | const n = e.add(7).add(.5);
|
38116 | return c.exports.Decimal.acos(-1).times(2).sqrt().mul(i.mul(n.neg().exp()).mul(c.exports.Decimal.pow(n, e.add(.5))));
|
38117 | } }
|
38118 | const E = Math.pow(10, -10);
|
38119 | function A(e, i) { if (!Number.isInteger(e) || !Number.isInteger(i))
|
38120 | return NaN; for (; 0 !== i;)
|
38121 | [e, i] = [i, e % i]; return e < 0 ? -e : e; }
|
38122 | const C = [.9999999999998099, 676.5203681218851, -1259.1392167224028, 771.3234287776531, -176.6150291621406, 12.507343278686905, -.13857109526572012, 9984369578019572e-21, 1.5056327351493116e-7], q = [.9999999999999971, 57.15623566586292, -59.59796035547549, 14.136097974741746, -.4919138160976202, 3399464998481189e-20, 4652362892704858e-20, -9837447530487956e-20, .0001580887032249125, -.00021026444172410488, .00021743961811521265, -.0001643181065367639, 8441822398385275e-20, -26190838401581408e-21, 36899182659531625e-22];
|
38123 | function F(e) { if (e < 0)
|
38124 | return NaN; let i = q[0]; for (let n = q.length - 1; n > 0; --n)
|
38125 | i += q[n] / (e + n); const n = e + 4.7421875 + .5; return .5 * Math.log(2 * Math.PI) + (e + .5) * Math.log(n) - n + Math.log(i) - Math.log(e); }
|
38126 | function I(e) { if (e < .5)
|
38127 | return Math.PI / (Math.sin(Math.PI * e) * I(1 - e)); if (e > 100)
|
38128 | return Math.exp(F(e)); {
|
38129 | e -= 1;
|
38130 | let i = C[0];
|
38131 | for (let n = 1; n < 9; n++)
|
38132 | i += C[n] / (e + n);
|
38133 | const n = e + 7 + .5;
|
38134 | return Math.sqrt(2 * Math.PI) * Math.pow(n, e + .5) * Math.exp(-n) * i;
|
38135 | } }
|
38136 | const k = "List", P = "Missing", T = "Nothing", O = "Add", z = "Divide", L = "Multiply", _ = "Negate", R = "Power", Z = "Root", Q = "Sqrt";
|
38137 | function H(e) { return null !== e && "object" == typeof e && "num" in e; }
|
38138 | function $(e) { return null !== e && "object" == typeof e && "sym" in e; }
|
38139 | function B(e) { return null !== e && "object" == typeof e && "fn" in e; }
|
38140 | function G(e) { if ("number" == typeof e)
|
38141 | return e; if (null === e)
|
38142 | return null; if (H(e))
|
38143 | return e.num.endsWith("d") || e.num.endsWith("n") ? null : parseFloat(e.num); const i = re(e); return null === i ? null : "NaN" === i ? NaN : "+Infinity" === i ? 1 / 0 : "-Infinity" === i ? -1 / 0 : "Complex" === te(e) && 0 === G(le(e, 2)) ? G(le(e, 1)) : null; }
|
38144 | function W(e) { if (null === e)
|
38145 | return null; if (e instanceof m.exports.Complex)
|
38146 | return e; const i = re(e); if (null !== i) {
|
38147 | if ("ComplexInfinity" === i)
|
38148 | return m.exports.Complex.INFINITY;
|
38149 | if ("ImaginaryUnit" === i)
|
38150 | return m.exports.Complex.I;
|
38151 | } const n = te(e); if ("Complex" === n) {
|
38152 | const i = G(le(e, 1)), n = G(le(e, 2));
|
38153 | return null === i || null === n ? null : new m.exports.Complex(i, n);
|
38154 | } let t = V(e); if (null !== t)
|
38155 | return new m.exports.Complex(0, t); if ("Add" === n && 2 === ue(e)) {
|
38156 | let i = G(le(e, 1));
|
38157 | if (null !== i ? t = V(le(e, 2)) : (t = V(le(e, 1)), null !== t && (i = G(le(e, 2)))), null !== i && null !== t)
|
38158 | return new m.exports.Complex(i, t);
|
38159 | } if ("Subtract" === n) {
|
38160 | const i = G(le(e, 1)), n = le(e, 2);
|
38161 | if (null !== i) {
|
38162 | if ("ImaginaryUnit" === re(n))
|
38163 | return new m.exports.Complex(i, -1);
|
38164 | if ("Multiply" === te(n) && "ImaginaryUnit" === le(n, 2)) {
|
38165 | const e = G(le(n, 1));
|
38166 | if (null !== e)
|
38167 | return new m.exports.Complex(i, -e);
|
38168 | }
|
38169 | }
|
38170 | } if ("Multiply" === n && 2 === ue(e)) {
|
38171 | let i = null;
|
38172 | if ("ImaginaryUnit" === re(le(e, 2)) ? i = G(le(e, 2)) : "ImaginaryUnit" === re(le(e, 1)) && (i = G(le(e, 1))), null !== i && Number.isInteger(i))
|
38173 | return 0 === i ? m.exports.Complex.ZERO : 1 === i ? m.exports.Complex.ONE : -1 === i ? m.exports.Complex.ONE.neg() : new m.exports.Complex(0, i);
|
38174 | } if ("Negate" === n) {
|
38175 | const i = W(le(e, 1));
|
38176 | if (null !== i)
|
38177 | return i.neg();
|
38178 | } return null; }
|
38179 | function V(e) { if ("ImaginaryUnit" === re(e))
|
38180 | return 1; let i = null; const n = te(e); return "Multiply" === n && 2 === ue(e) ? "ImaginaryUnit" === re(le(e, 1)) ? i = G(le(e, 2)) : "ImaginaryUnit" === re(le(e, 2)) && (i = G(le(e, 1))) : "Negate" === n && 1 === ue(e) && "ImaginaryUnit" === re(le(e, 1)) && (i = -1), 0 === i ? null : i; }
|
38181 | function Y(e) { var i, n; if (e instanceof c.exports.Decimal)
|
38182 | return e; const t = re(e); if (null !== t) {
|
38183 | if ("NaN" === t)
|
38184 | return g;
|
38185 | if ("+Infinity" === t)
|
38186 | return d;
|
38187 | if ("-Infinity" === t)
|
38188 | return v;
|
38189 | } if (H(e))
|
38190 | return e.num.endsWith("d") || e.num.endsWith("n") ? new c.exports.Decimal(e.num.slice(0, -1)) : new c.exports.Decimal(null !== (i = G(e)) && void 0 !== i ? i : NaN); if (null !== e && e instanceof m.exports.Complex) {
|
38191 | const i = e;
|
38192 | return 0 === i.im ? new c.exports.Decimal(i.re) : null;
|
38193 | } return "Complex" === te(e) && 0 === G(le(e, 2)) ? new c.exports.Decimal(null !== (n = G(le(e, 1))) && void 0 !== n ? n : NaN) : null; }
|
38194 | function J(e) { return null === e ? null : "object" == typeof e && "str" in e ? e.str : "string" != typeof e || e.length < 2 || "'" !== e[0] || "'" !== e[e.length - 1] ? null : e.substring(1, e.length - 1); }
|
38195 | function X(e) { var i, n, t, r, o, s; const a = re(e); if ("ThreeQuarter" === a)
|
38196 | return [3, 4]; if ("TwoThird" === a)
|
38197 | return [2, 3]; if ("Half" === a)
|
38198 | return [1, 2]; if ("Third" === a)
|
38199 | return [1, 3]; if ("Quarter" === a)
|
38200 | return [1, 4]; if (ne(e))
|
38201 | return [null, null]; const l = te(e); if (!l)
|
38202 | return [null, null]; let u = null, c = null; if (l === R) {
|
38203 | const t = G(le(e, 2));
|
38204 | 1 === t ? (u = null !== (i = G(le(e, 1))) && void 0 !== i ? i : null, c = 1) : -1 === t && (u = 1, c = null !== (n = G(le(e, 1))) && void 0 !== n ? n : null);
|
38205 | } return l === z && (u = null !== (t = G(le(e, 1))) && void 0 !== t ? t : null, c = null !== (r = G(le(e, 2))) && void 0 !== r ? r : null), l === L && te(le(e, 2)) === R && -1 === G(le(le(e, 2), 2)) && (u = null !== (o = G(le(e, 1))) && void 0 !== o ? o : null, c = null !== (s = G(le(le(e, 2), 1))) && void 0 !== s ? s : null), null === u || null === c ? [null, null] : Number.isInteger(u) && Number.isInteger(c) ? [u, c] : [null, null]; }
|
38206 | function ie(e) { return null === e ? null : Array.isArray(e) ? e[0] : B(e) ? e.fn[0] : null; }
|
38207 | function ne(e) { return null === e || !Array.isArray(e) && ("object" != typeof e || !("fn" in e || "dic" in e)); }
|
38208 | function te(e) { if (null === e)
|
38209 | return ""; const i = ie(e); return "string" == typeof i ? i : ""; }
|
38210 | function re(e) { return null === e ? null : "string" == typeof e ? e.length >= 2 && "'" === e[0] && "'" === e[e.length - 1] ? null : e : $(e) ? e.sym : null; }
|
38211 | function oe(e) { return Array.isArray(e) ? e.slice(1) : B(e) ? e.fn.slice(1) : []; }
|
38212 | function se(e, i) { const n = ie(e); if (null !== n)
|
38213 | return [i(n), ...oe(e).map(i)]; const t = ce(e); if (null !== t) {
|
38214 | const e = Object.keys(t), n = {};
|
38215 | for (const r of e)
|
38216 | n[r] = i(t[r]);
|
38217 | return { dict: n };
|
38218 | } return i(e); }
|
38219 | function ae(e, i) { let n = null; if (Array.isArray(e) && (n = e), B(e) && (n = e.fn), null === n)
|
38220 | return []; let t = 1; const r = []; for (; t < n.length;)
|
38221 | r.push(i(n[t])), t += 1; return r; }
|
38222 | function le(e, i) { var n, t; return null === e ? null : Array.isArray(e) ? null !== (n = e[i]) && void 0 !== n ? n : null : B(e) && null !== (t = e.fn[i]) && void 0 !== t ? t : null; }
|
38223 | function ue(e) { return Array.isArray(e) ? Math.max(0, e.length - 1) : B(e) ? Math.max(0, e.fn.length - 1) : 0; }
|
38224 | function ce(e) { return "object" == typeof e && "dict" in e ? e.dict : null; }
|
38225 | const fe = [{ name: "Overscript", trigger: { infix: "\\overset" }, precedence: 700 }, { name: "Underscript", trigger: { infix: "\\underset" }, precedence: 700 }, { name: "Increment", trigger: { postfix: ["+", "+"] }, precedence: 880 }, { name: "Decrement", trigger: { postfix: ["-", "-"] }, precedence: 880 }, { name: "PreIncrement", trigger: { prefix: ["+", "+"] }, precedence: 880 }, { name: "PreDecrement", trigger: { prefix: ["-", "-"] }, precedence: 880 }, { name: "Ring", trigger: { infix: "\\circ" }, precedence: 265 }, { name: "Transpose", trigger: { superfix: "T" } }, { name: "ConjugateTranspose", trigger: { superfix: "H" } }, { name: "StringJoin", trigger: { infix: ["\\lt", "\\gt"] }, precedence: 780 }, { name: "Starstar", trigger: { infix: ["\\star", "\\star"] }, precedence: 780 }, { name: "PartialDerivative", trigger: { prefix: "\\partial" }, parse: (e, i, n) => { var t, r; let o = !1, s = T, a = T; for (; !o;)
|
38226 | i.skipSpace(), i.match("_") ? a = i.matchRequiredLatexArgument() : i.match("^") ? s = i.matchRequiredLatexArgument() : o = !0; if ("Sequence" === te(a) && (a = [k, ...oe(a)]), !a || !s)
|
38227 | return [e, null]; let l = null !== (t = i.matchRequiredLatexArgument()) && void 0 !== t ? t : T; return l !== T && (l = [l, ...null !== (r = i.matchArguments("group")) && void 0 !== r ? r : T]), [null, ["PartialDerivative", l, a, s]]; }, serialize: (e, i) => { let n = "\\partial"; const t = le(i, 1), r = le(i, 2), o = le(i, 3); return null !== r && r !== T && (ie(r) === k ? n += "_{" + e.serialize(["Sequence", ...oe(r)]) + "}" : n += "_{" + e.serialize(r) + "}"), null !== o && o !== T && (n += "^{" + e.serialize(o) + "}"), null !== t && t !== T && (n += e.serialize(t)), n; }, precedence: 740 }, { name: "OverBar", trigger: { symbol: "\\overline" }, requiredLatexArg: 1 }, { name: "UnderBar", trigger: { symbol: "\\underline" }, requiredLatexArg: 1 }, { name: "OverVector", trigger: { symbol: "\\vec" }, requiredLatexArg: 1 }, { name: "OverTile", trigger: { symbol: "\\tilde" }, requiredLatexArg: 1 }, { name: "OverHat", trigger: { symbol: "\\hat" }, requiredLatexArg: 1 }, { name: "OverHat", trigger: { symbol: "\\hat" }, requiredLatexArg: 1 }, { name: "OverRightArrow", trigger: { symbol: "\\overrightarrow" }, requiredLatexArg: 1 }, { name: "OverLeftArrow", trigger: { symbol: "\\overleftarrow" }, requiredLatexArg: 1 }, { name: "OverRightDoubleArrow", trigger: { symbol: "\\Overrightarrow" }, requiredLatexArg: 1 }, { name: "OverLeftHarpoon", trigger: { symbol: "\\overleftharpoon" }, requiredLatexArg: 1 }, { name: "OverRightHarpoon", trigger: { symbol: "\\overrightharpoon" }, requiredLatexArg: 1 }, { name: "OverLeftRightArrow", trigger: { symbol: "\\overleftrightarrow" }, requiredLatexArg: 1 }, { name: "OverBrace", trigger: { symbol: "\\overbrace" }, requiredLatexArg: 1 }, { name: "OverLineSegment", trigger: { symbol: "\\overlinesegment" }, requiredLatexArg: 1 }, { name: "OverGroup", trigger: { symbol: "\\overgroup" }, requiredLatexArg: 1 }];
|
38228 | function he(e, i) { return i > 2 ? "solidus" : "radical"; }
|
38229 | function pe(e) { return "<space>" === e || "\\qquad" === e || "\\quad" === e || "\\enskip" === e || "\\;" === e || "\\," === e || "\\ " === e || "~" === e; }
|
38230 | function ge(e, i, n) { return (t, r, o) => { if (o >= i)
|
38231 | return [t, null]; r.skipSpace(), r.match(n), "Missing" === t && (t = T); const s = [e, null != t ? t : T]; let a = !1; for (; !a;) {
|
38232 | for (a = !0, r.skipSpace(); r.match(n);)
|
38233 | s.push(T), r.skipSpace();
|
38234 | if (r.atEnd)
|
38235 | s.push(T);
|
38236 | else {
|
38237 | const e = r.matchExpression(i);
|
38238 | s.push(null != e ? e : T), a = null === e;
|
38239 | }
|
38240 | a || (r.skipSpace(), a = !r.match(n));
|
38241 | } return [null, s]; }; }
|
38242 | function de(e) { return (i, n) => oe(n).map((e => i.serialize(e))).join(e); }
|
38243 | const ve = [{ name: "LatexTokens", serialize: function (e, i) { return oe(i).map((i => { const n = J(i); return null === n ? e.serialize(i) : "<{>" === n ? "{" : "<}>" === n ? "}" : "<$>" === n ? "$" : "<$$>" === n ? "$$" : "<space>'" === n ? " " : n; })).join(""); } }, { name: "Parentheses", trigger: { matchfix: "(" }, parse: (e, i, n) => { var t; const r = i.index; if (!i.match("("))
|
38244 | return [e, null]; let o = !1, s = !0, a = !1, l = 0, u = ""; for (; !o && s;) {
|
38245 | const e = i.next();
|
38246 | i.atEnd || ")" === e ? o = !0 : "\\mathtt" === e ? (i.match("<{>"), a = !0) : pe(e) || (/^[0-9a-zA-Z]$/.test(e) ? (l = Math.max(l, parseInt(e, 36)), u += e) : s = !1), a && i.match("<}>");
|
38247 | } if (i.skipSpace(), s && i.match("_")) {
|
38248 | const n = null !== (t = G(i.matchRequiredLatexArgument())) && void 0 !== t ? t : NaN;
|
38249 | return !isFinite(n) || n < 2 || n > 36 || l >= n ? (i.onError({ code: "base-out-of-range" }), [e, T]) : [e, ["BaseForm", parseInt(u, n), n]];
|
38250 | } i.index = r; const c = i.matchBalancedExpression("(", ")", i.onError); return c ? "Sequence" === te(c) ? [e, ["Parentheses", ...oe(c)]] : [e, ["Parentheses", c]] : [e, ["Parentheses"]]; }, serialize: (e, i) => e.wrapString(de(",")(e, i), (e.level, "paren")), separator: ",", closeFence: ")", precedence: 20 }, { name: k, trigger: { matchfix: "\\lbrack" }, separator: ",", closeFence: "\\rbrack", precedence: 20, parse: (e, i, n) => { if (null === e) {
|
38251 | const n = i.matchBalancedExpression("\\lbrack", "\\rbrack", i.onError);
|
38252 | return n ? "Sequence" === te(n) ? [e, [k, ...oe(n)]] : [e, [k, n]] : [null, [k]];
|
38253 | } return [e, null]; } }, { name: "BaseForm", serialize: (e, i) => { var n, t; const r = null !== (n = G(le(i, 2))) && void 0 !== n ? n : NaN; if (isFinite(r) && r >= 2 && r <= 36) {
|
38254 | const e = null !== (t = G(le(i, 1))) && void 0 !== t ? t : NaN;
|
38255 | if (isFinite(e)) {
|
38256 | let i = Number(e).toString(r), n = 0;
|
38257 | if (2 === r || 10 === r ? n = 4 : 16 === r ? n = 2 : r > 16 && (n = 4), n > 0) {
|
38258 | const e = i;
|
38259 | i = "";
|
38260 | for (let t = 0; t < e.length; t++)
|
38261 | t > 0 && t % n == 0 && (i = "\\, " + i), i = e[e.length - t - 1] + i;
|
38262 | }
|
38263 | return `(\\mathtt{${i}})_{${r}}`;
|
38264 | }
|
38265 | } return "\\operatorname{BaseForm}(" + e.serialize(le(i, 1)) + ", " + e.serialize(le(i, 2)) + ")"; } }, { name: "Set", trigger: { matchfix: "\\lbrace" }, separator: ",", closeFence: "\\rbrace", precedence: 20 }, { name: "Sequence", trigger: { infix: "," }, parse: ge("Sequence", 20, ","), serialize: de(", "), precedence: 20 }, { name: "Sequence2", trigger: { infix: ";" }, parse: ge("Sequence2", 19, ";"), serialize: de("; "), precedence: 19 }, { name: P, trigger: "\\placeholder", serialize: "\\placeholder", requiredLatexArg: 1 }, { name: "Subscript", trigger: { infix: "_" }, precedence: 720, serialize: (e, i) => 2 === ue(i) ? e.serialize(le(i, 1)) + "_{" + e.serialize(le(i, 2)) + "}" : "_{" + e.serialize(le(i, 1)) + "}", parse: (e, i, n) => { var t; if (!i.match("_"))
|
38266 | return [e, null]; const r = null !== (t = i.matchRequiredLatexArgument()) && void 0 !== t ? t : P; return e ? [null, ["Subscript", e, r]] : [null, ["Subscript", r]]; } }, { name: "Superplus", trigger: { superfix: "+" } }, { name: "Subplus", trigger: { subfix: "+" } }, { name: "Superminus", trigger: { superfix: "-" } }, { name: "Subminus", trigger: { subfix: "-" } }, { name: "Superstar", trigger: { superfix: "*" } }, { name: "Superstar", trigger: { superfix: "\\star" } }, { name: "Substar", trigger: { subfix: "*" } }, { name: "Substar", trigger: { subfix: "\\star" } }, { name: "Superdagger", trigger: { superfix: "\\dagger" } }, { name: "Superdagger", trigger: { superfix: "\\dag" } }, { name: "Prime", trigger: { superfix: "\\prime" }, arguments: "group" }, { trigger: { superfix: "\\doubleprime" }, parse: (e, i) => [null, ["Prime", null != e ? e : T, 2]], arguments: "group" }, { name: "InverseFunction", serialize: (e, i) => e.serialize(le(i, 1)) + "^{-1}" }, { name: "Derivative", trigger: "D", parse: (e, i) => [e, ["Derivative", 1]], serialize: (e, i) => { var n; const t = null !== (n = G(le(i, 1))) && void 0 !== n ? n : NaN; if (!isFinite(t))
|
38267 | return ""; const r = e.serialize(le(i, 2)); return 1 === t ? r + "^{\\prime}" : 2 === t ? r + "^{\\doubleprime}" : r + "^{(" + Number(t).toString() + ")}"; } }, { name: "Piecewise", trigger: { environment: "cases" }, parse: (e, i) => { var n; return [e, ["Piecewise", null !== (n = i.matchTabular()) && void 0 !== n ? n : T]]; }, serialize: (e, i) => { if (te(le(i, 1)) !== k)
|
38268 | return ""; const n = oe(le(i, 1)); let t = "", r = ""; for (const i of n) {
|
38269 | t += r;
|
38270 | const n = le(i, 1);
|
38271 | if (null !== n) {
|
38272 | t += e.serialize(n);
|
38273 | const r = le(i, 2);
|
38274 | null !== r && (t += "&" + e.serialize(r));
|
38275 | }
|
38276 | r = "\\\\";
|
38277 | } return "\\begin{cases}" + t + "\\end{cases}"; } }];
|
38278 | function xe(e, i) { const n = G(i); return null !== n ? 0 === n : !!e.is(["Equal", i, 0]) || !0 !== e.is(["NotEqual", i, 0]) && !0 !== e.is(["Greater", i, 0]) && !0 !== e.is(["Less", i, 0]) && null === n && void 0; }
|
38279 | function ye(e, i) { const n = xe(e, i); return void 0 === n ? void 0 : !n; }
|
38280 | function be(e, i) { if (null === i)
|
38281 | return; const n = G(i); if (null !== n && !Number.isFinite(n))
|
38282 | return !0; if (null !== n && isNaN(n))
|
38283 | return; const t = re(i); if ("ComplexInfinity" === t)
|
38284 | return !0; if (t === P || t === T)
|
38285 | return !1; if (e.is(i, "ComplexNumber"))
|
38286 | return !1; const r = te(i); if ("Negate" === r) {
|
38287 | if (be(e, le(i, 1)))
|
38288 | return !0;
|
38289 | }
|
38290 | else if ("Multiply" === r) {
|
38291 | const n = oe(i);
|
38292 | if (n.some((i => !0 === be(e, i))) && n.every((i => !0 === ye(e, i))))
|
38293 | return !0;
|
38294 | } return null === n && void 0; }
|
38295 | function Ne(e, i) { if (null === i)
|
38296 | return; const n = G(i); if (null !== n)
|
38297 | return n > 0; const t = re(i); if (t && ["Quarter", "Third", "Half", "TwoThird", "ThreeQuarter", "MinusDoublePi", "MinusPi", "QuarterPi", "ThirdPi", "HalfPi", "TwoThirdPi", "ThreeQuarterPi", "Pi", "DoublePi", "MachineEpsilon", "CatalanConstant", "GoldenRatio", "EulerGamma", "ExponentialE"].includes(t))
|
38298 | return !0; if (e.is(["Greater", i, 0]))
|
38299 | return !0; if (e.is(["LessEqual", i, 0]))
|
38300 | return !1; if (e.is(["Less", i, 0]))
|
38301 | return !1; const r = te(i); if (r) {
|
38302 | if (("Cosh" === r || "Exp" === r) && Se(0, le(i, 1)))
|
38303 | return !0;
|
38304 | if ("Sqrt" === r && Ne(e, le(i, 1)))
|
38305 | return !0;
|
38306 | if (r === L || r === O)
|
38307 | return oe(i).every((i => !0 === Ne(e, i)));
|
38308 | if (r === z && Ne(e, le(i, 1)) && Ne(e, le(i, 2)))
|
38309 | return !0;
|
38310 | if (r === R && Ne(e, le(i, 1)))
|
38311 | return !0;
|
38312 | } }
|
38313 | function we(e, i) { const n = Ne(e, i); return !0 !== n && (void 0 !== n ? !1 === xe(e, i) : void 0); }
|
38314 | function Se(e, i) { return null !== i && null !== G(i); }
|
38315 | const Ee = { MachineEpsilon: { domain: "RealNumber", constant: !0, value: { num: Number.EPSILON.toString() } }, ImaginaryUnit: { domain: "ImaginaryNumber", constant: !0, wikidata: "Q193796" }, ExponentialE: { domain: "TranscendentalNumber", wikidata: "Q82435", constant: !0, value: e => "decimal" === e.numericFormat ? c.exports.Decimal.exp(1) : "complex" === e.numericFormat ? m.exports.Complex.E : 2.718281828459045 }, GoldenRatio: { domain: "IrrationalNumber", wikidata: "Q41690", constant: !0, hold: !1, value: ["Divide", ["Add", 1, ["Sqrt", 5]], 2] }, CatalanConstant: { domain: "RealNumber", wikidata: "Q855282", constant: !0, value: { num: "0.91596559417721901505" } }, EulerGamma: { domain: "RealNumber", wikidata: "Q273023", constant: !0, value: { num: "0.577215664901532860606" } }, Quarter: { domain: "RationalNumber", wikidata: "Q2310416", constant: !0, hold: !1, value: [z, 3, 4] }, Third: { domain: "RationalNumber", wikidata: "Q20021125", constant: !0, hold: !1, value: [z, 1, 3] }, Half: { domain: "RationalNumber", wikidata: "Q2114394", constant: !0, hold: !1, value: [z, 1, 2] }, TwoThird: { domain: "RationalNumber", constant: !0, hold: !1, value: [z, 2, 3] }, ThreeQuarter: { domain: "RationalNumber", constant: !0, hold: !1, value: [z, 3, 4] }, Abs: { domain: "Function", wikidata: "Q3317982", threadable: !0, idempotent: !0, numeric: !0, range: ["Interval", 0, 1 / 0], evalNumber: (e, i) => Math.abs(i), evalComplex: (e, i) => m.exports.Complex.abs(i), evalDecimal: (e, i) => c.exports.Decimal.abs(i) }, Add: { domain: "Function", wikidata: "Q32043", associative: !0, commutative: !0, threadable: !0, idempotent: !0, range: "Number", numeric: !0, simplify: function (e, ...i) { var n, t; if (0 === i.length)
|
38316 | return 0; if (1 === i.length)
|
38317 | return i[0]; let r = 0, o = 1, s = f, a = m.exports.Complex.ZERO, l = !1, u = !1; const c = []; for (const n of i) {
|
38318 | const i = re(n);
|
38319 | if (i === P || i === T)
|
38320 | return NaN;
|
38321 | if ("ComplexInfinity" === i)
|
38322 | return "ComplexInfinity";
|
38323 | be(e, n) && (Ne(e, n) ? l = !0 : u = !0);
|
38324 | const [t, m] = X(n);
|
38325 | if (null !== t && null !== m) {
|
38326 | if (isNaN(t) || isNaN(m))
|
38327 | return NaN;
|
38328 | r = r * m + t * o, o *= m;
|
38329 | }
|
38330 | else {
|
38331 | const i = W(n);
|
38332 | if (null !== i)
|
38333 | Number.isInteger(i.re) && Number.isInteger(i.im) ? a = a.add(i) : c.push(n);
|
38334 | else {
|
38335 | const i = Y(n);
|
38336 | if (null !== i && i.isInteger())
|
38337 | s = s.add(i);
|
38338 | else {
|
38339 | const i = G(n);
|
38340 | null !== i && Number.isInteger(i) ? r += i : !1 !== ye(e, n) && c.push(n);
|
38341 | }
|
38342 | }
|
38343 | }
|
38344 | } if (l && u)
|
38345 | return NaN; if (l)
|
38346 | return 1 / 0; if (u)
|
38347 | return -1 / 0; if (s.isZero() || c.push(s), a.isZero() || c.push(a), 0 === c.length)
|
38348 | return 0 === r ? 0 : 1 === o ? r : ["Divide", r, o]; if (0 !== r) {
|
38349 | const e = A(r, o);
|
38350 | r /= e, o /= e, 1 === o ? c.push(r) : c.push(["Divide", r, o]);
|
38351 | } return 1 === c.length ? c[0] : 2 === c.length && te(c[1]) === _ ? ["Subtract", c[0], null !== (n = le(c[1], 1)) && void 0 !== n ? n : P] : 2 === c.length && te(c[0]) === _ ? ["Subtract", c[1], null !== (t = le(c[0], 1)) && void 0 !== t ? t : P] : ["Add", ...c]; }, evalNumber: (e, ...i) => { if (0 === i.length)
|
38352 | return 0; let n = 0; for (const e of i)
|
38353 | n += e; return n; }, evalComplex: (e, ...i) => { if (0 === i.length)
|
38354 | return m.exports.Complex.ZERO; let n = m.exports.Complex.ZERO; for (const e of i)
|
38355 | n = n.add(e); return n; }, evalDecimal: (e, ...i) => { if (0 === i.length)
|
38356 | return f; let n = f; for (const e of i)
|
38357 | n = n.add(e); return n; }, evaluate: (e, ...i) => { if (0 === i.length)
|
38358 | return 0; let n = ["Add"]; const t = i.filter((e => e instanceof c.exports.Decimal)); t.length > 0 && (1 === t.length ? n.push(t[0]) : n.push(e.N(["Add", ...t]))); const r = i.filter((e => e instanceof m.exports.Complex)); r.length > 0 && (1 === r.length ? n.push(r[0]) : n.push(e.N(["Add", ...r]))); const o = i.filter((e => "number" == typeof e)); o.length > 0 && (1 === o.length ? n.push(o[0]) : n.push(e.N(["Add", ...o]))); const s = i.filter((e => !("number" == typeof e || e instanceof c.exports.Decimal || e instanceof m.exports.Complex))); return n = [...n, ...s], 0 === n.length ? 0 : 1 === n.length ? n[1] : n; } }, Chop: { domain: "Function", associative: !0, threadable: !0, idempotent: !0, numeric: !0, range: "Number", evalNumber: (e, i) => e.chop(i), evalComplex: (e, i) => e.chop(i), evalDecimal: (e, i) => e.chop(i) }, Ceil: { domain: "Function", range: "Number", numeric: !0, evalNumber: (e, i) => Math.ceil(i), evalComplex: (e, i) => m.exports.Complex.ceil(i), evalDecimal: (e, i) => c.exports.Decimal.ceil(i) }, Divide: { domain: "Function", range: "Number", numeric: !0, evalNumber: (e, i, n) => i / n, evalComplex: (e, i, n) => "number" == typeof i ? new m.exports.Complex(i).div(n) : i.div(n), evalDecimal: (e, i, n) => c.exports.Decimal.div(i, n) }, Exp: { domain: ["ContinuousFunction", "MonotonicFunction"], wikidata: "Q168698", threadable: !0, range: "Number", numeric: !0, evalNumber: (e, i) => Math.exp(i), evalComplex: (e, i) => "number" == typeof i ? new m.exports.Complex(i).exp() : i.exp(), evalDecimal: (e, i) => c.exports.Decimal.exp(i) }, Erf: { domain: ["ContinuousFunction", "MonotonicFunction"], range: "Number", numeric: !0 }, Erfc: { domain: ["ContinuousFunction", "MonotonicFunction"], range: "Number", numeric: !0 }, Factorial: { wikidata: "Q120976", domain: "MonotonicFunction", range: "Integer", numeric: !0, evalNumber: (e, i) => function (e) { if (!Number.isInteger(e) || e < 0)
|
38359 | return NaN; let i = 1; for (let n = 2; n <= e; n++)
|
38360 | i *= n; return i; }(i), evalComplex: (e, i) => "number" == typeof i ? new m.exports.Complex(i + 1) : i.add(1), evalDecimal: (e, i) => x(i) }, Floor: { domain: "Function", wikidata: "Q56860783", range: "Number", numeric: !0, evalNumber: (e, i) => Math.floor(i), evalDecimal: (e, i) => c.exports.Decimal.floor(i) }, Gamma: { domain: "Function", wikidata: "Q190573", range: "Number", numeric: !0, evalNumber: (e, i) => I(i), evalDecimal: (e, i) => S(i) }, LogGamma: { domain: "Function", range: "Number", numeric: !0, evalNumber: (e, i) => F(i), evalDecimal: (e, i) => w(i) }, Ln: { domain: "Function", wikidata: "Q11197", range: "Number", numeric: !0, evalNumber: (e, i) => Math.log(i), evalComplex: (e, i) => "number" == typeof i ? new m.exports.Complex(i).log() : i.log(), evalDecimal: (e, i) => c.exports.Decimal.log(i) }, Log: { domain: "Function", range: "Number", numeric: !0, evalNumber: (e, i, n) => Math.log(n) / Math.log(i), evalComplex: (e, i, n) => { const t = "number" == typeof i ? new m.exports.Complex(i) : i; return ("number" == typeof n ? new m.exports.Complex(n) : n).log().div(t.log()); }, evalDecimal: (e, i, n) => c.exports.Decimal.log(n).div(c.exports.Decimal.log(i)) }, Lb: { domain: "Function", wikidata: "Q581168", range: "Number", numeric: !0, evalNumber: (e, i) => Math.log2(i), evalComplex: (e, i, n) => ("number" == typeof n ? new m.exports.Complex(n) : n).log().div(m.exports.Complex.log(2)), evalDecimal: (e, i) => c.exports.Decimal.log(i).div(c.exports.Decimal.log(2)) }, Lg: { domain: "Function", wikidata: "Q966582", range: "Number", numeric: !0, evalNumber: (e, i) => Math.log10(i), evalComplex: (e, i, n) => ("number" == typeof n ? new m.exports.Complex(n) : n).log().div(m.exports.Complex.log(10)), evalDecimal: (e, i) => c.exports.Decimal.log(i).div(c.exports.Decimal.log(10)) }, Multiply: { domain: "Function", wikidata: "Q40276", associative: !0, commutative: !0, idempotent: !0, range: "Number", simplify: function (e, ...i) { if (0 === i.length)
|
38361 | return 1; if (1 === i.length)
|
38362 | return i[0]; const n = []; let t = 1, r = 1, o = m.exports.Complex.ONE; for (const s of i) {
|
38363 | const i = G(s);
|
38364 | if (0 === i)
|
38365 | return 0;
|
38366 | if (null === i || Number.isFinite(i) && !Number.isInteger(i)) {
|
38367 | const [i, a] = [null, null];
|
38368 | if (null !== i && null !== a)
|
38369 | t *= i, r *= a;
|
38370 | else {
|
38371 | const i = W(s);
|
38372 | if (null !== i)
|
38373 | Number.isInteger(i.re) && Number.isInteger(i.im) ? o = o.mul(i) : n.push(s);
|
38374 | else {
|
38375 | if (xe(e, s))
|
38376 | return 0;
|
38377 | n.push(s);
|
38378 | }
|
38379 | }
|
38380 | }
|
38381 | else
|
38382 | t *= i;
|
38383 | } return 0 !== o.im ? (o = o.mul(t), t = 1) : (t *= o.re, o = m.exports.Complex.ONE), 0 !== t && isFinite(t) ? (o.equals(m.exports.Complex.ONE) || n.push(["Complex", o.re, o.im]), 0 === n.length ? 1 === r ? t : ["Divide", t, r] : (1 !== r && (n.unshift(["Divide", t, r]), t = 1, r = 1), 1 === n.length && 1 === t ? n[0] : 1 === n.length && -1 === t ? ["Negate", n[0]] : 1 === t ? ["Multiply", ...n] : -1 === t ? ["Negate", ["Multiply", ...n]] : ["Multiply", t, ...n])) : t / r; }, numeric: !0, evalNumber: function (e, ...i) { if (0 === i.length)
|
38384 | return 1; if (1 === i.length)
|
38385 | return i[0]; let n = 1; for (const e of i)
|
38386 | n *= e; return n; }, evalComplex: (e, ...i) => { if (0 === i.length)
|
38387 | return m.exports.Complex.ONE; let n = m.exports.Complex.ONE; for (const e of i)
|
38388 | n = n.mul(e); return n; }, evalDecimal: (e, ...i) => { if (0 === i.length)
|
38389 | return h; let n = h; for (const e of i)
|
38390 | n = n.mul(e); return n; }, evaluate: (e, ...i) => { if (0 === i.length)
|
38391 | return 0; let n = ["Multiply"]; const t = i.filter((e => e instanceof c.exports.Decimal)); t.length > 0 && (1 === t.length ? n.push(t[0]) : n.push(e.N(["Multiply", ...t]))); const r = i.filter((e => e instanceof m.exports.Complex)); r.length > 0 && (1 === r.length ? n.push(r[0]) : n.push(e.N(["Multiply", ...r]))); const o = i.filter((e => "number" == typeof e)); o.length > 0 && (1 === o.length ? n.push(o[0]) : n.push(e.N(["Multiply", ...o]))); const s = i.filter((e => !("number" == typeof e || e instanceof c.exports.Decimal || e instanceof m.exports.Complex))); return n = [...n, ...s], 0 === n.length ? 1 : 1 === n.length ? n[1] : n; } }, Negate: { domain: "Function", wikidata: "Q715358", range: "Number", simplify: (e, i) => { var n; return null !== (n = De(i)) && void 0 !== n ? n : ["Negate", i]; }, numeric: !0, evalNumber: (e, i) => -i, evalComplex: (e, i) => "number" == typeof i ? new m.exports.Complex(-i) : i.neg(), evalDecimal: (e, i) => "number" == typeof i ? new c.exports.Decimal(-i) : i.neg() }, Power: { domain: "Function", wikidata: "Q33456", commutative: !1, numeric: !0, range: "Number", simplify: (e, ...i) => Ce(e, ["Power", ...i]), evalNumber: (e, i, n) => Math.pow(i, n), evalComplex: (e, i, n) => { const t = "number" == typeof i ? new m.exports.Complex(i) : i, r = "number" == typeof n ? new m.exports.Complex(n) : n; return m.exports.Complex.pow(t, r); }, evalDecimal: (e, i, n) => c.exports.Decimal.pow(i, n) }, Round: { domain: "Function", range: "Number", numeric: !0, evalNumber: (e, i) => Math.round(i), evalComplex: (e, i) => "number" == typeof i ? new m.exports.Complex(i).round() : i.round(), evalDecimal: (e, i) => c.exports.Decimal.round(i) }, Sign: { domain: "Function", range: ["Range", -1, 1], numeric: !0, simplify: (e, i) => xe(e, i) ? 0 : we(e, i) ? -1 : 1, evalNumber: (e, i) => 0 === i ? 0 : i < 0 ? -1 : 1, evalComplex: (e, i) => { const n = "number" == typeof i ? new m.exports.Complex(i) : i; return n.div(n.abs()); }, evalDecimal: (e, i) => "number" == typeof i ? 0 === i ? f : i < 0 ? p : h : i.isZero() ? f : i.isNeg() ? p : h }, SignGamma: { domain: "Function", range: "Number", numeric: !0 }, Sqrt: { domain: "Function", wikidata: "Q134237", range: "Number", numeric: !0, evalNumber: (e, i) => Math.sqrt(i), evalComplex: (e, i) => "number" == typeof i ? new m.exports.Complex(i).sqrt() : i.sqrt(), evalDecimal: (e, i) => c.exports.Decimal.sqrt(i) }, Square: { domain: "Function", wikidata: "Q3075175", range: "Number", numeric: !0, evalNumber: (e, i) => i * i, evalComplex: (e, i) => "number" == typeof i ? new m.exports.Complex(i).multiply(i) : i.mul(i), evalDecimal: (e, i) => c.exports.Decimal.mul(i, i) }, Root: { domain: "Function", commutative: !1, range: "Number", numeric: !0, evalNumber: (e, i, n) => Math.pow(i, 1 / n), evalComplex: (e, i, n) => { const t = "number" == typeof i ? new m.exports.Complex(i) : i, r = "number" == typeof n ? new m.exports.Complex(1 / n) : new m.exports.Complex(m.exports.Complex.ONE.div(n)); return m.exports.Complex.pow(t, r); }, evalDecimal: (e, i, n) => c.exports.Decimal.pow(i, h.div(n)) }, Subtract: { domain: "Function", wikidata: "Q32043", range: "Number", numeric: !0, evalNumber: (e, i, n) => i - n, evalComplex: (e, i, n) => "number" == typeof i ? new m.exports.Complex(i).sub(n) : i.sub(n), evalDecimal: (e, i, n) => c.exports.Decimal.sub(i, n) } };
|
38392 | function De(e) { var i, n, t, r; if ("number" == typeof (e = Ae(e)))
|
38393 | return -e; if (e && H(e))
|
38394 | return "-" === e.num[0] ? { num: e.num.slice(1) } : "+" === e.num[0] ? { num: "-" + e.num.slice(1) } : { num: "-" + e.num }; if (e instanceof c.exports.Decimal)
|
38395 | return e.mul(-1); if (e instanceof m.exports.Complex)
|
38396 | return e.mul(-1); const o = te(e), s = ue(e); if (o === _ && 1 === s)
|
38397 | return null !== (i = le(e, 1)) && void 0 !== i ? i : P; if (o === L) {
|
38398 | const i = De(null !== (n = le(e, 1)) && void 0 !== n ? n : P);
|
38399 | return [L, i, ...oe(e).slice(1)];
|
38400 | } return o === O ? [O, ...ae(e, De)] : "Subtract" === o ? ["Subtract", null !== (t = le(e, 2)) && void 0 !== t ? t : P, null !== (r = le(e, 1)) && void 0 !== r ? r : P] : "Parentheses" === o && 1 === s ? De(le(le(e, 1), 1)) : [_, null != e ? e : P]; }
|
38401 | function Ae(e) { return null === e ? T : ne(e) ? e : "Parentheses" === ie(e) && 1 === ue(e) ? Ae(le(e, 1)) : se(e, Ae); }
|
38402 | function Ce(e, i) { var n, t; if (2 !== ue(i = Ae(i)))
|
38403 | return i; const r = le(i, 1), o = null !== (n = G(r)) && void 0 !== n ? n : NaN, s = le(i, 2); if ("ComplexInfinity" === re(s))
|
38404 | return NaN; const a = null !== (t = G(s)) && void 0 !== t ? t : NaN; if (xe(e, s))
|
38405 | return 1; if (1 === a)
|
38406 | return r; if (2 === a)
|
38407 | return ["Square", r]; if (-1 === a)
|
38408 | return -1 === o || 1 === o ? -1 : Number.isFinite(o) ? ["Divide", 1, r] : 0; if (!Number.isFinite(a)) {
|
38409 | if (0 === o && a < 0)
|
38410 | return "ComplexInfinity";
|
38411 | if (1 === o || -1 === o)
|
38412 | return NaN;
|
38413 | if (o === 1 / 0) {
|
38414 | if (a > 0)
|
38415 | return 1 / 0;
|
38416 | if (a < 0)
|
38417 | return 0;
|
38418 | }
|
38419 | if (o === -1 / 0 && !Number.isFinite(a))
|
38420 | return NaN;
|
38421 | } return i; }
|
38422 | function Fe(e, i, n, t) { return null === n ? "\\sqrt{}" : (t = null != t ? t : 2, "solidus" === i ? e.wrapShort(n) + "^{1\\/" + e.serialize(t) + "}" : "quotient" === i ? e.wrapShort(n) + "^{\\frac{1}{" + e.serialize(t) + "}}" : 2 === G(t) ? "\\sqrt{" + e.serialize(n) + "}" : "\\sqrt[" + e.serialize(t) + "]{" + e.serialize(n) + "}"); }
|
38423 | function Ie(e, i, n) { if (!i.match("\\sqrt"))
|
38424 | return [e, null]; const t = i.matchOptionalLatexArgument(), r = i.matchRequiredLatexArgument(); return null === r ? null !== t ? [e, [Z, T, t]] : [e, [Q]] : null !== t ? [e, [Z, r, t]] : [e, [Q, r]]; }
|
38425 | function ke(e, i, n) { if (276 < n)
|
38426 | return [e, null]; const t = i.index; if (!i.match("-"))
|
38427 | return [e, null]; const r = i.matchExpression(null === e ? 400 : 277); return null === r ? (i.index = t, [e, null]) : null === e ? [null, [_, r]] : [null, ["Subtract", e, r]]; }
|
38428 | function Pe(e, i) { var n; if (null === i)
|
38429 | return ""; e.level -= 1; let t = ""; const [r, o] = function (e) { var i, n, t, r, o, s; if (te(e) !== L)
|
38430 | return [[], []]; const a = [], l = [], u = oe(e); for (const e of u)
|
38431 | if (te(e) === R)
|
38432 | if (te(le(e, 2)) === _) {
|
38433 | const t = null !== (i = le(e, 1)) && void 0 !== i ? i : T, r = null !== (n = le(le(e, 2), 1)) && void 0 !== n ? n : T;
|
38434 | l.push([R, t, r]);
|
38435 | }
|
38436 | else {
|
38437 | const i = null !== (t = G(le(e, 2))) && void 0 !== t ? t : NaN;
|
38438 | -1 === i ? l.push(null !== (r = le(e, 1)) && void 0 !== r ? r : T) : i < 0 ? l.push([R, null !== (o = le(e, 1)) && void 0 !== o ? o : T, null !== (s = De(le(e, 2))) && void 0 !== s ? s : T]) : a.push(e);
|
38439 | }
|
38440 | else
|
38441 | a.push(e); return [a, l]; }(i); if (o.length > 0 && (t = 1 === o.length && 1 === o[0] ? 0 === r.length ? "1" : 1 === r.length ? e.serialize(r[0]) : Pe(e, [L, ...r]) : e.serialize([z, 1 === r.length ? r[0] : [L, ...r], 1 === o.length ? o[0] : [L, ...o]])), t)
|
38442 | return e.level += 1, t; let a = !1, l = null; const u = ue(i) + 1; let c = !1; for (let r = 1; r < u; r++)
|
38443 | if (l = le(i, r), null !== l) {
|
38444 | let i;
|
38445 | "number" == typeof l || H(l) ? (i = e.serialize(l), "-1" !== i || t ? ("-" === i[0] && (i = i.slice(1), a = !a), t = t ? s([t, e.options.multiply, i]) : i) : t = "-", c = !0) : te(l) !== R || isNaN(null !== (n = G(le(l, 1))) && void 0 !== n ? n : NaN) ? (te(l) === _ && (l = le(l, 1), a = !a), i = e.wrap(l, 390), t = t ? c && te(l) === z ? s([t, "\\times", i]) : e.options.invisibleMultiply ? s([t, e.options.invisibleMultiply, i]) : s([t, i]) : i, c = !1) : (t = t ? s([t, e.options.multiply, e.serialize(l)]) : e.serialize(l), c = !0);
|
38446 | } return e.level += 1, a ? "-" + t : t; }
|
38447 | function Te(e, i) { if (null === i)
|
38448 | return ""; if (1 === ue(i))
|
38449 | return e.serialize(le(i, 1)); const n = e.level > 3 ? "inline-solidus" : "quotient"; if ("inline-solidus" === n || "nice-solidus" === n) {
|
38450 | const t = e.wrapShort(le(i, 1)), r = e.wrapShort(le(i, 2));
|
38451 | return "nice-solidus" === n ? `^{${t}}\\!\\!/\\!_{${r}}` : `${t}\\/${r}`;
|
38452 | } return "reciprocal" === n ? e.wrap(le(i, 1)) + e.wrap(le(i, 2)) + "^{-1}" : "factor" === n ? "\\frac{1}{" + e.serialize(le(i, 2)) + "}" + e.wrap(le(i, 1)) : "\\frac{" + e.serialize(le(i, 1)) + "}{" + e.serialize(le(i, 2)) + "}"; }
|
38453 | function Oe(e, i) { var n; const t = le(i, 1), r = le(i, 2); if (null === r)
|
38454 | return e.serialize(t); if (null === t)
|
38455 | return ""; const o = te(i); if (o === Q || o === Z)
|
38456 | return Fe(e, he(0, e.level), le(i, 1), le(i, 2)); const s = null !== (n = G(r)) && void 0 !== n ? n : 1; if (-1 === s)
|
38457 | return e.serialize([z, "1", t]); if (s < 0)
|
38458 | return e.serialize([z, "1", [R, t, -s]]); if (te(r) === z) {
|
38459 | if (1 === G(le(r, 1)))
|
38460 | return Fe(e, he(0, e.level), t, le(r, 2));
|
38461 | }
|
38462 | else if (te(r) === R && -1 === G(le(r, 2)))
|
38463 | return Fe(e, he(0, e.level), t, le(r, 1)); return e.wrapShort(t) + "^{" + e.serialize(r) + "}"; }
|
38464 | function ze(e, i, n) { var t; const r = i.next(); let o = !1, s = 0; if (i.skipSpace(), i.match("^")) {
|
38465 | if (i.skipSpace(), i.match("<{>")) {
|
38466 | i.skipSpace(), i.match("-") && i.match("1") && (o = !0);
|
38467 | do {
|
38468 | i.match("\\doubleprime") && (s += 2), i.match("\\prime") && (s += 1), i.match("'") && (s += 1);
|
38469 | } while (!i.match("<}>") && !i.atEnd);
|
38470 | }
|
38471 | let e = !1;
|
38472 | for (; !e;)
|
38473 | i.skipSpace(), i.match("\\doubleprime") ? s += 2 : i.match("\\prime") || i.match("'") ? s += 1 : e = !0;
|
38474 | } let a = null !== (t = { "\\arcsin": "Arcsin", "\\arccos": "Arccos", "\\arctan": "Arctan", "\\arctg": "Arctan", "\\arcctg": "Arctan", "\\arcsec": "Arcsec", "\\arccsc": " Arccsc", "\\arsinh": "Arsinh", "\\arcosh": "Arcosh", "\\artanh": "Artanh", "\\arcsech": "Arcsech", "\\arccsch": "Arcsch", "\\ch": "Cosh", "\\cos": "Cos", "\\cosec": "Csc", "\\cosh": "Csch", "\\cot": "Cot", "\\cotg": "Cot", "\\coth": "Coth", "\\csc": "Csc", "\\ctg": "Cot", "\\cth": "Coth", "\\sec": "Sec", "\\sin": "Sin", "\\sinh": "Sinh", "\\sh": "Sinh", "\\tan": "Tan", "\\tanh": "Tanh", "\\tg": "Tan", "\\th": "Tanh" }[r]) && void 0 !== t ? t : r; o && (a = ["InverseFunction", a]), s >= 1 && (a = ["Derivative", s, a]); const l = i.matchArguments("implicit"); return null === l ? [null, a] : [null, [a, ...l]]; }
|
38475 | function Le(e) { return a(e); }
|
38476 | const _e = { algebra: [{ name: "To", trigger: { infix: "\\to" }, precedence: 270 }], arithmetic: [{ name: "ThreeQuarter", serialize: "\\frac{3}{4}" }, { name: "TwoThird", serialize: "\\frac{2}{3}" }, { name: "Half", serialize: "\\frac{1}{2}" }, { name: "Third", serialize: "\\frac{1}{3}" }, { name: "Quarter", serialize: "\\frac{1}{4}" }, { name: "CatalanConstant", serialize: "G" }, { name: "GoldenRatio", serialize: "\\varphi" }, { name: "EulerGamma", serialize: "\\gamma" }, { name: "Degrees", serialize: "\\frac{\\pi}{180}" }, { name: "MinusDoublePi", serialize: "-2\\pi" }, { name: "MinusPi", serialize: "-\\pi" }, { name: "MinusHalfPi", serialize: "-\\frac{\\pi}{2}" }, { name: "QuarterPi", serialize: "\\frac{\\pi}{4}" }, { name: "ThirdPi", serialize: "\\frac{\\pi}{3}" }, { name: "HalfPi", serialize: "\\frac{\\pi}{2}" }, { name: "TwoThirdPi", serialize: "\\frac{2\\pi}{3}" }, { name: "ThreeQuarterPi", serialize: "\\frac{3\\pi}{4}" }, { name: "DoublePi", serialize: "2\\pi" }, { name: "Complex", precedence: 275, serialize: (e, i) => { const n = G(le(i, 1)), t = G(le(i, 2)); if (0 === t)
|
38477 | return e.serialize(le(i, 1)); const r = 1 === t ? "\\imaginaryI" : -1 === t ? "-\\imaginaryI" : s([e.serialize(le(i, 2)), "\\imaginaryI"]); return 0 === n ? r : s([e.serialize(le(i, 1)), "+", r]); } }, { name: "Exp", serialize: (e, i) => { var n; return s(["\\exponentialE^{", e.serialize(null !== (n = le(i, 1)) && void 0 !== n ? n : T), "}"]); } }, { name: "Square", serialize: (e, i) => e.wrapShort(le(i, 1)) + "^2" }, { trigger: { symbol: "\\infty" }, parse: { num: "+Infinity" } }, { name: "ComplexInfinity", trigger: { symbol: ["\\tilde", "\\infty"] }, serialize: "\\tilde\\infty" }, { name: "ComplexInfinity", trigger: { symbol: ["\\tilde", "<{>", "\\infty", "<}>"] }, serialize: "\\tilde\\infty" }, { name: "Pi", trigger: { symbol: "\\pi" } }, { name: "Pi", trigger: { symbol: "π" }, serialize: "\\pi" }, { name: "ExponentialE", trigger: { symbol: "e" }, serialize: "e" }, { name: "ImaginaryUnit", trigger: { symbol: "i" }, serialize: "\\imaginaryI" }, { name: "ImaginaryUnit", trigger: { symbol: "\\imaginaryI" } }, { name: O, trigger: { prefix: "+", infix: "+" }, parse: function (e, i, n) { if (275 < n)
|
38478 | return [e, null]; const t = i.index; if (!i.match("+"))
|
38479 | return [e, null]; const r = i.matchExpression(null === e ? 400 : 275); return null === r ? (i.index = t, [e, null]) : null === e ? [null, r] : i.applyOperator(O, e, r); }, serialize: function (e, i) { var n, t; e.level -= 1; const r = te(i); let o = "", s = le(i, 1), a = !Number.isNaN(null !== (n = G(s)) && void 0 !== n ? n : NaN); if (r === _)
|
38480 | o = "-" + e.wrap(s, 276);
|
38481 | else if (r === O) {
|
38482 | o = e.serialize(s);
|
38483 | const n = ue(i) + 1;
|
38484 | for (let r = 2; r < n; r++) {
|
38485 | s = le(i, r);
|
38486 | const n = null !== (t = G(s)) && void 0 !== t ? t : NaN, l = !Number.isNaN(n);
|
38487 | let u = !1;
|
38488 | if (null !== s && a) {
|
38489 | const [i, n] = X(s);
|
38490 | null !== i && null !== n && isFinite(i) && isFinite(n) && 1 !== n && (o += e.options.invisiblePlus + e.serialize(s), u = !0);
|
38491 | }
|
38492 | if (!u)
|
38493 | if (n < 0)
|
38494 | o += e.serialize(s);
|
38495 | else if (te(s) === _)
|
38496 | o += e.wrap(s, 275);
|
38497 | else {
|
38498 | const i = e.wrap(s, 275);
|
38499 | "-" === i[0] || "+" === i[0] ? o += i : o = o + "+" + i;
|
38500 | }
|
38501 | a = l;
|
38502 | }
|
38503 | }
|
38504 | else if ("Subtract" === r) {
|
38505 | const n = le(i, 2);
|
38506 | o = null !== n ? e.wrap(s, 275) + "-" + e.wrap(n, 275) : e.wrap(s, 275);
|
38507 | } return e.level += 1, o; }, associativity: "both", precedence: 275 }, { name: _, trigger: { prefix: "-" }, parse: ke, associativity: "left", precedence: 275 }, { name: "Subtract", trigger: { infix: "-" }, parse: ke, associativity: "both", precedence: 275 }, { name: "PlusMinus", trigger: { infix: "\\pm" }, associativity: "both", precedence: 270 }, { name: "MinusPlus", trigger: { infix: "\\mp" }, associativity: "both", precedence: 270 }, { name: L, trigger: { infix: "\\times" }, serialize: Pe, associativity: "both", precedence: 390 }, { name: L, trigger: { infix: "\\cdot" }, serialize: Pe, associativity: "both", precedence: 390 }, { name: L, trigger: { infix: "*" }, serialize: Pe, associativity: "both", precedence: 390 }, { name: z, trigger: "\\frac", parse: function (e, i, n) { var t, r, o, s; if (!i.match("\\frac"))
|
38508 | return [e, null]; const a = null !== (t = i.matchRequiredLatexArgument()) && void 0 !== t ? t : P, l = null !== (r = i.matchRequiredLatexArgument()) && void 0 !== r ? r : P; if ("PartialDerivative" === te(a) && ("PartialDerivative" === te(l) || te(l) === L && "PartialDerivative" === te(le(l, 1)))) {
|
38509 | const n = null !== (o = le(a, 3)) && void 0 !== o ? o : T;
|
38510 | let t = le(a, 1);
|
38511 | null !== t && t !== T || (t = null !== (s = i.matchExpression()) && void 0 !== s ? s : T);
|
38512 | let r = [];
|
38513 | if (te(l) === L) {
|
38514 | for (const e of oe(l))
|
38515 | if ("PartialDerivative" === ie(e)) {
|
38516 | const i = le(e, 2);
|
38517 | i && r.push(i);
|
38518 | }
|
38519 | }
|
38520 | else {
|
38521 | const e = le(l, 2);
|
38522 | e && r.push(e);
|
38523 | }
|
38524 | return r.length > 1 && (r = [k, ...r]), [e, ["PartialDerivative", t, r, n === T ? 1 : n]];
|
38525 | } return [e, [z, a, l]]; }, serialize: Te, requiredLatexArg: 2 }, { name: z, trigger: { infix: "\\/" }, serialize: Te, associativity: "non", precedence: 660 }, { name: z, trigger: { infix: "/" }, serialize: Te, associativity: "non", precedence: 660 }, { name: z, trigger: { infix: "\\div" }, serialize: Te, associativity: "non", precedence: 660 }, { name: R, trigger: { infix: "^" }, associativity: "non", precedence: 720, serialize: Oe }, { name: R, trigger: { infix: ["*", "*"] }, associativity: "non", precedence: 720, serialize: Oe }, { name: Q, trigger: "\\sqrt", optionalLatexArg: 1, requiredLatexArg: 1, parse: Ie, serialize: Oe }, { name: Z, trigger: "\\sqrt", optionalLatexArg: 1, requiredLatexArg: 1, parse: Ie }, { name: "Norm", trigger: { matchfix: "\\lVert" }, closeFence: "\\rVert" }, { name: "Norm", trigger: { matchfix: "\\|" }, closeFence: "\\|" }, { name: "Norm", trigger: { matchfix: ["|", "|"] }, closeFence: ["|", "|"] }, { name: "Abs", trigger: { matchfix: "|" }, closeFence: "|" }, { name: "Abs", trigger: { matchfix: "\\lvert" }, closeFence: "\\rvert" }, { name: "Factorial", trigger: { postfix: "!" }, precedence: 810 }, { name: "Factorial2", trigger: { postfix: ["!", "!"] }, precedence: 810 }, { name: "Lcm", trigger: { symbol: ["\\operatorname", "<{>", "l", "c", "m", "<}>"] } }, { name: "Gcd", trigger: { symbol: ["\\operatorname", "<{>", "g", "c", "d", "<}>"] } }, { name: "Ceil", trigger: { symbol: ["\\operatorname", "<{>", "c", "e", "i", "l", "<}>"] } }, { name: "Floor", trigger: { symbol: ["\\operatorname", "<{>", "f", "l", "o", "o", "r", "<}>"] } }, { name: "Round", trigger: { symbol: ["\\operatorname", "<{>", "r", "o", "u", "n", "d", "<}>"] } }, { name: "Sign", trigger: { symbol: ["\\operatorname", "<{>", "s", "g", "n", "<}>"] } }], calculus: [{ trigger: { symbol: "\\int" }, parse: function (e, i, n) { if (!i.match("\\int"))
|
38526 | return [e, null]; let t = T, r = T, o = !1; for (; !o;)
|
38527 | i.skipSpace(), i.match("_") ? r = i.matchRequiredLatexArgument() : i.match("^") ? t = i.matchRequiredLatexArgument() : o = !0; const s = i.matchBalancedExpression("<{>", "<}>"); return [e, ["Integral", null != s ? s : "", null != t ? t : T, null != r ? r : T]]; }, serialize: function (e, i) { return ""; } }], core: ve, inequalities: [{ name: "NotLess", trigger: { infix: ["!", "<"] }, associativity: "right", precedence: 246 }, { name: "NotLess", trigger: { infix: "\\nless" }, associativity: "right", precedence: 246 }, { name: "Less", trigger: { infix: "<" }, associativity: "right", precedence: 245 }, { name: "Less", trigger: { infix: "\\lt" }, associativity: "right", precedence: 245 }, { name: "LessEqual", trigger: { infix: ["<", "="] }, associativity: "right", precedence: 241 }, { name: "LessEqual", trigger: { infix: "\\le" }, associativity: "right", precedence: 241 }, { name: "LessEqual", trigger: { infix: "\\leq" }, associativity: "right", precedence: 241 }, { name: "LessEqual", trigger: { infix: "\\leqslant" }, associativity: "right", precedence: 265 }, { name: "LessNotEqual", trigger: { infix: "\\lneqq" }, associativity: "right", precedence: 260 }, { name: "NotLessNotEqual", trigger: { infix: "\\nleqq" }, associativity: "right", precedence: 260 }, { name: "LessOverEqual", trigger: { infix: "\\leqq" }, associativity: "right", precedence: 265 }, { name: "GreaterOverEqual", trigger: { infix: "\\geqq" }, associativity: "right", precedence: 265 }, { name: "Equal", trigger: { infix: "=" }, associativity: "right", precedence: 260 }, { name: "StarEqual", trigger: { infix: ["*", "="] }, associativity: "right", precedence: 260 }, { name: "StarEqual", trigger: { infix: ["\\star", "="] }, associativity: "right", precedence: 260 }, { name: "PlusEqual", trigger: { infix: ["+", "="] }, associativity: "right", precedence: 260 }, { name: "MinusEqual", trigger: { infix: ["-", "="] }, associativity: "right", precedence: 260 }, { name: "SlashEqual", trigger: { infix: ["/", "="] }, associativity: "right", precedence: 260 }, { name: "EqualEqual", trigger: { infix: ["=", "="] }, associativity: "right", precedence: 260 }, { name: "EqualEqualEqual", trigger: { infix: ["=", "=", "="] }, associativity: "right", precedence: 265 }, { name: "TildeFullEqual", trigger: { infix: "\\cong" }, associativity: "right", precedence: 260 }, { name: "NotTildeFullEqual", trigger: { infix: "\\ncong" }, associativity: "right", precedence: 260 }, { name: "Assign", trigger: { infix: [":", "="] }, associativity: "right", precedence: 260 }, { name: "Assign", trigger: { infix: "\\coloneq" }, associativity: "right", precedence: 260 }, { name: "Approx", trigger: { infix: "\\approx" }, associativity: "right", precedence: 247 }, { name: "NotApprox", trigger: { infix: "\\approx" }, associativity: "right", precedence: 247 }, { name: "ApproxEqual", trigger: { infix: "\\approxeq" }, associativity: "right", precedence: 260 }, { name: "NotApproxEqual", trigger: { infix: ["!", "\\approxeq"] }, associativity: "right", precedence: 250 }, { name: "NotEqual", trigger: { infix: "\\ne" }, associativity: "right", precedence: 255 }, { name: "Unequal", trigger: { infix: ["!", "="] }, associativity: "right", precedence: 260 }, { name: "GreaterEqual", trigger: { infix: "\\ge" }, associativity: "right", precedence: 242 }, { name: "GreaterEqual", trigger: { infix: "\\geq" }, associativity: "right", precedence: 242 }, { name: "GreaterEqual", trigger: { infix: [">", "="] }, associativity: "right", precedence: 243 }, { name: "GreaterEqual", trigger: { infix: "\\geqslant" }, associativity: "right", precedence: 265 }, { name: "GreaterNotEqual", trigger: { infix: "\\gneqq" }, associativity: "right", precedence: 260 }, { name: "NotGreaterNotEqual", trigger: { infix: "\\ngeqq" }, associativity: "right", precedence: 260 }, { name: "Greater", trigger: { infix: ">" }, associativity: "right", precedence: 245 }, { name: "Greater", trigger: { infix: "\\gt" }, associativity: "right", precedence: 245 }, { name: "NotGreater", trigger: { infix: "\\ngtr" }, associativity: "right", precedence: 244 }, { name: "NotGreater", trigger: { infix: ["!", ">"] }, associativity: "right", precedence: 244 }, { name: "RingEqual", trigger: { infix: "\\circeq" }, associativity: "right", precedence: 260 }, { name: "TriangleEqual", trigger: { infix: "\\triangleq" }, associativity: "right", precedence: 260 }, { name: "DotEqual", trigger: { infix: "\\doteq" }, associativity: "right", precedence: 265 }, { name: "DotEqualDot", trigger: { infix: "\\doteqdot" }, associativity: "right", precedence: 265 }, { name: "FallingDotEqual", trigger: { infix: "\\fallingdotseq" }, associativity: "right", precedence: 265 }, { name: "RisingDotEqual", trigger: { infix: "\\fallingdotseq" }, associativity: "right", precedence: 265 }, { name: "QuestionEqual", trigger: { infix: "\\questeq" }, associativity: "right", precedence: 260 }, { name: "Equivalent", trigger: { infix: "\\equiv" }, associativity: "right", precedence: 260 }, { name: "MuchLess", trigger: { infix: "\\ll" }, associativity: "right", precedence: 260 }, { name: "MuchGreater", trigger: { infix: "\\gg" }, associativity: "right", precedence: 260 }, { name: "Precedes", trigger: { infix: "\\prec" }, associativity: "right", precedence: 260 }, { name: "Succeeds", trigger: { infix: "\\succ" }, associativity: "right", precedence: 260 }, { name: "PrecedesEqual", trigger: { infix: "\\preccurlyeq" }, associativity: "right", precedence: 260 }, { name: "SucceedsEqual", trigger: { infix: "\\curlyeqprec" }, associativity: "right", precedence: 260 }, { name: "NotPrecedes", trigger: { infix: "\\nprec" }, associativity: "right", precedence: 260 }, { name: "NotSucceeds", trigger: { infix: "\\nsucc" }, associativity: "right", precedence: 260 }, { name: "Between", trigger: { infix: "\\between" }, associativity: "right", precedence: 265 }], other: fe, physics: [{ name: "mu-0", trigger: { symbol: ["\\mu", "_", "0"] } }], sets: [{ trigger: { symbol: "\\N" }, parse: "NaturalNumber" }, { trigger: { symbol: "\\Z" }, parse: "Integer" }, { trigger: { symbol: "\\Q" }, parse: "RationalNumber" }, { trigger: { symbol: ["\\mathbb", "<{>", "A", "<}>"] }, parse: "AlgebraicNumber" }, { trigger: { symbol: "\\R" }, parse: "RealNumber" }, { trigger: { symbol: "\\C" }, parse: "ComplexNumber" }, { trigger: { symbol: "\\varnothing" }, parse: "EmptySet" }, { trigger: { symbol: "\\emptyset" }, parse: "EmptySet" }, { name: "Complement", trigger: { infix: "\\complement" }, precedence: 240 }, { name: "Element", trigger: { infix: "\\in" }, precedence: 240 }, { name: "Intersection", trigger: { infix: "\\Cap" }, precedence: 350 }, { name: "NotElement", trigger: { infix: "\\notin" }, precedence: 240 }, { name: "SetMinus", trigger: { infix: "\\setminus" }, precedence: 650 }, { name: "SubsetEqual", trigger: { infix: "\\subseteq" }, precedence: 240 }, { name: "SymmetricDifference", trigger: { infix: "\\triangle" }, precedence: 260 }, { name: "Union", trigger: { infix: "\\cup" }, precedence: 350 }, { name: "Contains", trigger: { infix: "\\ni" }, associativity: "right", precedence: 160 }, { name: "Subset", trigger: { infix: "\\subset" }, associativity: "right", precedence: 240 }, { name: "SquareSubset", trigger: { infix: "\\sqsubset" }, associativity: "right", precedence: 265 }, { name: "SquareSubsetEqual", trigger: { infix: "\\sqsubseteq" }, associativity: "right", precedence: 265 }, { name: "Superset", trigger: { infix: "\\supset" }, associativity: "right", precedence: 240 }, { name: "SquareSuperset", trigger: { infix: "\\sqsupset" }, associativity: "right", precedence: 265 }, { name: "SquareSupersetEqual", trigger: { infix: "\\sqsupseteq" }, associativity: "right", precedence: 265 }, { name: "NotSubset", trigger: { infix: "\\nsubset" }, associativity: "right", precedence: 240 }, { name: "NotSuperset", trigger: { infix: "\\nsupset" }, associativity: "right", precedence: 240 }, { name: "SupersetEqual", trigger: { infix: "\\supseteq" }, associativity: "right", precedence: 240 }, { name: "NotSubsetNotEqual", trigger: { infix: "\\nsubseteq" }, associativity: "right", precedence: 240 }, { name: "NotSupersetNotEqual", trigger: { infix: "\\nsupseteq" }, associativity: "right", precedence: 240 }, { name: "SubsetNotEqual", trigger: { infix: "\\subsetneq" }, associativity: "right", precedence: 240 }, { name: "SubsetNotEqual", trigger: { infix: "\\varsupsetneqq" }, associativity: "right", precedence: 240 }, { name: "SupersetNotEqual", trigger: { infix: "\\supsetneq" }, associativity: "right", precedence: 240 }, { name: "SupersetNotEqual", trigger: { infix: "\\varsupsetneq" }, associativity: "right", precedence: 240 }], symbols: [{ trigger: { symbol: "\\alpha" }, parse: "α" }, { trigger: { symbol: "\\beta" }, parse: "β" }, { trigger: { symbol: "\\gamma" }, parse: "γ" }, { trigger: { symbol: "\\delta" }, parse: "δ" }, { trigger: { symbol: "\\epsilon" }, parse: "ϵ" }, { trigger: { symbol: "\\varepsilon" }, parse: "ε" }, { trigger: { symbol: "\\zeta" }, parse: "ζ" }, { trigger: { symbol: "\\eta" }, parse: "η" }, { trigger: { symbol: "\\theta" }, parse: "θ" }, { trigger: { symbol: "\\vartheta" }, parse: "ϑ" }, { trigger: { symbol: "\\iota" }, parse: "ι" }, { trigger: { symbol: "\\kappa" }, parse: "κ" }, { trigger: { symbol: "\\varkappa" }, parse: "ϰ" }, { trigger: { symbol: "\\lambda" }, parse: "λ" }, { trigger: { symbol: "\\mu" }, parse: "μ" }, { trigger: { symbol: "\\nu" }, parse: "ν" }, { trigger: { symbol: "\\xi" }, parse: "ξ" }, { trigger: { symbol: "\\omicron" }, parse: "ο" }, { trigger: { symbol: "\\varpi" }, parse: "ϖ" }, { trigger: { symbol: "\\rho" }, parse: "ρ" }, { trigger: { symbol: "\\varrho" }, parse: "ϱ" }, { trigger: { symbol: "\\sigma" }, parse: "σ" }, { trigger: { symbol: "\\varsigma" }, parse: "ς" }, { trigger: { symbol: "\\tau" }, parse: "τ" }, { trigger: { symbol: "\\phi" }, parse: "ϕ" }, { trigger: { symbol: "\\varphi" }, parse: "φ" }, { trigger: { symbol: "\\upsilon" }, parse: "υ" }, { trigger: { symbol: "\\chi" }, parse: "χ" }, { trigger: { symbol: "\\psi" }, parse: "ψ" }, { trigger: { symbol: "\\omega" }, parse: "ω" }, { trigger: { symbol: "\\Gamma" }, parse: "Γ" }, { trigger: { symbol: "\\Delta" }, parse: "Δ" }, { trigger: { symbol: "\\Theta" }, parse: "Θ" }, { trigger: { symbol: "\\Lambda" }, parse: "Λ" }, { trigger: { symbol: "\\Xi" }, parse: "Ξ" }, { trigger: { symbol: "\\Pi" }, parse: "Π" }, { trigger: { symbol: "\\Sigma" }, parse: "Σ" }, { trigger: { symbol: "\\Upsilon" }, parse: "Υ" }, { trigger: { symbol: "\\Phi" }, parse: "Φ" }, { trigger: { symbol: "\\Psi" }, parse: "Ψ" }, { trigger: { symbol: "\\Omega" }, parse: "Ω" }, { trigger: { symbol: "\\digamma" }, parse: "ϝ" }, { trigger: { symbol: "\\aleph" }, parse: "ℵ" }, { trigger: { symbol: "\\beth" }, parse: "ℶ" }, { trigger: { symbol: "\\daleth" }, parse: "ℸ" }, { trigger: { symbol: "\\gimel" }, parse: "ℷ" }, { trigger: { symbol: "\\Finv" }, parse: "Ⅎ" }, { trigger: { symbol: "\\Game" }, parse: "⅁" }, { trigger: { symbol: "\\wp" }, parse: "℘" }, { trigger: { symbol: "\\eth" }, parse: "ð" }, { trigger: { symbol: "\\mho" }, parse: "℧" }, { trigger: { symbol: "\\clubsuit" }, parse: "♣" }, { trigger: { symbol: "\\heartsuit" }, parse: "♡" }, { trigger: { symbol: "\\spadesuit" }, parse: "♠" }, { trigger: { symbol: "\\diamondsuit" }, parse: "♢" }, { trigger: { symbol: "\\sharp" }, parse: "♯" }, { trigger: { symbol: "\\flat" }, parse: "♭" }, { trigger: { symbol: "\\natural" }, parse: "♮" }], trigonometry: [{ name: "Arcsin", trigger: "\\arcsin", arguments: "implicit", parse: ze }, { name: "Arccos", trigger: "\\arccos", arguments: "implicit", parse: ze }, { name: "Arctan", trigger: "\\arctan", arguments: "implicit", parse: ze }, { name: "Arctan", trigger: "\\arctg", arguments: "implicit", parse: ze }, { name: "Arccot", trigger: "\\arcctg", arguments: "implicit", parse: ze }, { name: "Arcsec", trigger: "\\arcsec", arguments: "implicit", parse: ze }, { name: "Arccsc", trigger: "\\arccsc", arguments: "implicit", parse: ze }, { name: "Arsinh", trigger: "\\arsinh", arguments: "implicit", parse: ze }, { name: "Arcosh", trigger: "\\arcosh", arguments: "implicit", parse: ze }, { name: "Artanh", trigger: "\\artanh", arguments: "implicit", parse: ze }, { name: "Arsech", trigger: "\\arsech", arguments: "implicit", parse: ze }, { name: "Arcsch", trigger: "\\arcsch", arguments: "implicit", parse: ze }, { name: "Cosh", trigger: "\\ch", arguments: "implicit", parse: ze }, { name: "Cosec", trigger: "\\cosec", arguments: "implicit", parse: ze }, { name: "Cosh", trigger: "\\cosh", arguments: "implicit", parse: ze }, { name: "Cot", trigger: "\\cot", arguments: "implicit", parse: ze }, { name: "Cot", trigger: "\\cotg", arguments: "implicit", parse: ze }, { name: "Coth", trigger: "\\coth", arguments: "implicit", parse: ze }, { name: "Csc", trigger: "\\csc", arguments: "implicit", parse: ze }, { name: "Cot", trigger: "\\ctg", arguments: "implicit", parse: ze }, { name: "Coth", trigger: "\\cth", arguments: "implicit", parse: ze }, { name: "Sec", trigger: "\\sec", arguments: "implicit", parse: ze }, { name: "Sinh", trigger: "\\sinh", arguments: "implicit", parse: ze }, { name: "Sinh", trigger: "\\sh", arguments: "implicit", parse: ze }, { name: "Tan", trigger: "\\tan", arguments: "implicit", parse: ze }, { name: "Tan", trigger: "\\tg", arguments: "implicit", parse: ze }, { name: "Tanh", trigger: "\\tanh", arguments: "implicit", parse: ze }, { name: "Tanh", trigger: "\\th", arguments: "implicit", parse: ze }, { name: "Cos", trigger: "\\cos", arguments: "implicit", parse: ze }, { name: "Sin", trigger: "\\sin", arguments: "implicit", parse: ze }] }, Re = { precision: 15, positiveInfinity: "\\infty", negativeInfinity: "-\\infty", notANumber: "\\operatorname{NaN}", decimalMarker: ".", groupSeparator: ",", exponentProduct: "\\cdot", beginExponentMarker: "10^{", endExponentMarker: "}", notation: "auto", truncationMarker: "\\ldots", beginRepeatingDigits: "\\overline{", endRepeatingDigits: "}", imaginaryNumber: "\\imaginaryI" }, Ze = { invisibleOperator: L, skipSpace: !0, parseArgumentsOfUnknownLatexCommands: !0, parseNumbers: !0, promoteUnknownSymbols: /^[a-zA-Z]$/, promoteUnknownFunctions: /^[fg]$/, ignoreCommands: ["\\displaystyle", "\\!", "\\:", "\\enskip", "\\quad", "\\,", "\\;", "\\enspace", "\\qquad", "\\selectfont", "\\tiny", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"], idempotentCommands: ["\\left", "\\right", "\\mleft", "\\mright", "\\middle", "\\bigl", "\\bigm", "\\bigr", "\\Bigl", "\\Bigm", "\\Bigr", "\\biggl", "\\biggm", "\\biggr", "\\Biggl", "\\Biggm", "\\Biggr"], invisiblePlusOperator: O, preserveLatex: !1 }, Qe = { invisibleMultiply: "", invisiblePlus: "", multiply: "\\times" };
|
38528 | function He(e, i) { var n; let t = e; for (let e = 0; e < i.length; e++) {
|
38529 | let r = null !== (n = i[e]) && void 0 !== n ? n : "";
|
38530 | if (/[a-zA-Z*]/.test(r[0])) {
|
38531 | const i = t.match(new RegExp("(.*)#" + Number(e + 1).toString()));
|
38532 | i && /\\[a-zA-Z*]+/.test(i[1]) && (r = " " + r);
|
38533 | }
|
38534 | t = t.replace("#" + Number(e + 1).toString(), r);
|
38535 | } return t; }
|
38536 | class $e {
|
38537 | constructor(e, i, n, t) { let r; this.index = 0, this.options = { ...Re, ...Ze, ...i }, this.tokens = e, this.onError = e => t({ ...e, before: this.latexBefore(), after: this.latexAfter() }), this.dictionary = n, this.invisibleOperatorPrecedence = 0, this.options.invisibleOperator && (r = this.dictionary.name.get(this.options.invisibleOperator), void 0 === r ? t({ code: "unknown-operator", arg: "invisible operator " + this.options.invisibleOperator }) : void 0 === r.precedence ? t({ code: "expected-operator", arg: "invisible operator " + this.options.invisibleOperator }) : this.invisibleOperatorPrecedence = r.precedence); }
|
38538 | clone(e, i) { return new $e(this.tokens.slice(e, i), this.options, this.dictionary, this.onError); }
|
38539 | balancedClone(e, i, n = !0) { if (!this.matchAll(e))
|
38540 | return n || this.onError({ code: "syntax-error", arg: "Expected " + a(e) }), null; const t = this.index; let r = t, o = 1; for (; !this.atEnd && 0 !== o;)
|
38541 | this.skipSpace(), r = this.index, this.matchAll(i) ? o -= 1 : this.matchAll(e) ? o += 1 : this.next(); return 0 !== o ? (n || this.onError({ code: "unbalanced-symbols", arg: a(e) + a(i) }), this.index = t, null) : this.clone(t, r); }
|
38542 | get atEnd() { return this.index >= this.tokens.length; }
|
38543 | get peek() { return this.tokens[this.index]; }
|
38544 | latex(e, i) { return a(this.tokens.slice(e, i)); }
|
38545 | latexAhead(e) { return a(this.tokens.slice(this.index, this.index + e)); }
|
38546 | latexBefore() { return this.latex(0, this.index); }
|
38547 | latexAfter() { return this.latex(this.index); }
|
38548 | lookAhead() { let e = Math.min(this.dictionary.lookahead, this.tokens.length - this.index); const i = []; for (; e > 0;)
|
38549 | i[e] = this.latexAhead(e--); return i; }
|
38550 | peekDefinition(e) { let i; i = "operator" === e ? this.lookAhead().map(((e, i) => { var n, t, r, o, s; return null !== (o = null !== (t = null === (n = this.dictionary.infix[i]) || void 0 === n ? void 0 : n.get(e)) && void 0 !== t ? t : null === (r = this.dictionary.postfix[i]) || void 0 === r ? void 0 : r.get(e)) && void 0 !== o ? o : null === (s = this.dictionary.prefix[i]) || void 0 === s ? void 0 : s.get(e); })) : this.lookAhead().map(((i, n) => { var t; return null === (t = this.dictionary[e][n]) || void 0 === t ? void 0 : t.get(i); })); for (let e = i.length; e > 0; e--)
|
38551 | if (void 0 !== i[e])
|
38552 | return [i[e], e]; return [null, 0]; }
|
38553 | next() { return this.tokens[this.index++]; }
|
38554 | skipSpace() { if (!this.atEnd && "<{>" === this.peek && "<}>" === this.tokens[this.index + 1])
|
38555 | return this.index += 2, this.skipSpace(), !0; let e = !1; for (; !this.atEnd && (this.options.ignoreCommands.includes(this.peek) || this.options.idempotentCommands.includes(this.peek));)
|
38556 | this.index += 1, this.skipSpace(), e = !0; if (!this.options.skipSpace)
|
38557 | return !1; for (; this.match("<space>");)
|
38558 | e = !0; return e && this.skipSpace(), e; }
|
38559 | match(e) { return this.tokens[this.index] === e && (this.index++, !0); }
|
38560 | matchAll(e) { let i = !0; "string" == typeof e && (e = [e]); let n = 0; do {
|
38561 | i = this.tokens[this.index + n] === e[n++];
|
38562 | } while (i && n < e.length); return i && (this.index += n), i; }
|
38563 | matchAny(e) { return e.includes(this.tokens[this.index]) ? this.tokens[this.index++] : ""; }
|
38564 | matchWhile(e) { const i = []; for (; e.includes(this.tokens[this.index]);)
|
38565 | i.push(this.tokens[this.index++]); return i; }
|
38566 | matchSign() { let e = !1, i = !1; for (; !i;)
|
38567 | this.skipSpace() ? i = !1 : this.match("-") ? (e = !e, i = !1) : i = !this.match("+"); return e ? "-" : "+"; }
|
38568 | matchDecimalDigits() { let e = "", i = !1; for (; !i;)
|
38569 | if (e += this.matchWhile(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]).join(""), i = !0, this.options.groupSeparator) {
|
38570 | const e = this.index;
|
38571 | this.match(this.options.groupSeparator) && (/[0-9]/.test(this.peek) ? i = !1 : this.index = e);
|
38572 | } return e; }
|
38573 | matchSignedInteger() { const e = this.index, i = this.matchSign(), n = this.matchDecimalDigits(); return n ? ("-" === i ? "-" : "") + n : (this.index = e, ""); }
|
38574 | matchExponent() { const e = this.index; let i = ""; if (this.matchAny(["e", "E", "d", "D"])) {
|
38575 | const e = this.matchSignedInteger();
|
38576 | e && (i = "e" + e);
|
38577 | } if (i)
|
38578 | return i; if (this.match("\\times") && (this.skipSpace(), this.match("1") && this.match("0") && this.match("^"))) {
|
38579 | if (/[0-9]/.test(this.peek))
|
38580 | return "e" + this.next();
|
38581 | if (this.match("<{>")) {
|
38582 | this.skipSpace();
|
38583 | const e = this.matchSignedInteger();
|
38584 | if (this.skipSpace(), this.match("<}>") && e)
|
38585 | return "e" + e;
|
38586 | }
|
38587 | } return this.index = e, ""; }
|
38588 | matchNumber() { var e, i; if (!this.options.parseNumbers)
|
38589 | return ""; const n = this.index, t = this.matchSign(); let r = this.matchDecimalDigits(); if (!r)
|
38590 | return this.index = n, ""; r = ("-" === t ? "-" : "") + r; let o = !1, s = !1; this.match(null !== (e = this.options.decimalMarker) && void 0 !== e ? e : "") && (o = !0, r += "." + (null !== (i = this.matchDecimalDigits()) && void 0 !== i ? i : "0")); const a = this.matchExponent(); return a && (s = !0), r ? r.length + a.length > 12 ? o || s ? r + a + "d" : r + "n" : r + a : (this.index = n, ""); }
|
38591 | matchOperator(e, i = null, n = 0) { const [t, r] = this.peekDefinition(e); if (null === t)
|
38592 | return null; if ("function" == typeof t.parse) {
|
38593 | let e = null;
|
38594 | return [i, e] = t.parse(i, this, n), null === e ? null : this.applyInvisibleOperator(i, e);
|
38595 | } let o = t.precedence; if (void 0 === o || o < n)
|
38596 | return null; o += "left" === t.associativity ? 1 : 0, this.index += r; const s = this.matchExpression(o); return this.applyInvisibleOperator(...this.applyOperator(t.parse, i, s)); }
|
38597 | matchArguments(e) { if (!e)
|
38598 | return null; const i = this.index; let n = null; const t = this.matchMatchfixOperator(); if ("group" === e && "Parentheses" === te(t))
|
38599 | n = oe(t);
|
38600 | else if ("implicit" === e)
|
38601 | if ("Parentheses" === te(t))
|
38602 | n = oe(t);
|
38603 | else if (null !== t)
|
38604 | n = [t];
|
38605 | else {
|
38606 | const e = this.matchPrimary();
|
38607 | null !== e && (n = [e]);
|
38608 | }
|
38609 | else
|
38610 | this.index = i; return n; }
|
38611 | matchMatchfixOperator() { const [e] = this.peekDefinition("matchfix"); if (null === e)
|
38612 | return null; if ("function" == typeof e.parse)
|
38613 | return this.applyInvisibleOperator(...e.parse(null, this, 0)); const i = "object" == typeof e.trigger ? e.trigger.matchfix : e.trigger; if (!i || !e.closeFence || !e.parse)
|
38614 | return null; const n = this.matchBalancedExpression(i, e.closeFence, this.onError); return n ? [e.parse, n] : [e.parse]; }
|
38615 | matchDefinition(e) { const [i, n] = this.peekDefinition(e); if ("function" == typeof (null == i ? void 0 : i.parse)) {
|
38616 | const [, e] = i.parse(null, this, 0);
|
38617 | return [i, e];
|
38618 | } return this.index += n, [i, null]; }
|
38619 | matchSymbol() { var e, i, n, t; const [r, o] = this.matchDefinition("symbol"); if (null !== o)
|
38620 | return o; if (null === r) {
|
38621 | if (null === (e = this.options.promoteUnknownFunctions) || void 0 === e ? void 0 : e.test(this.peek)) {
|
38622 | const e = this.next(), i = this.matchMatchfixOperator();
|
38623 | return null === i ? e : "Parentheses" !== te(i) ? null : [e, ...oe(i)];
|
38624 | }
|
38625 | return (null === (i = this.options.promoteUnknownSymbols) || void 0 === i ? void 0 : i.test(this.peek)) ? this.next() : this.matchUnknownLatexCommand();
|
38626 | } const s = [], a = []; let l, u = null !== (n = r.optionalLatexArg) && void 0 !== n ? n : 0; for (; u > 0;)
|
38627 | l = this.matchOptionalLatexArgument(), null !== l && a.push(l), u--; for (u = null !== (t = r.requiredLatexArg) && void 0 !== t ? t : 0; u > 0;)
|
38628 | l = this.matchRequiredLatexArgument(), null === l && this.onError({ code: "expected-argument" }), null !== l && s.push(l), u--; const c = this.matchArguments(r.arguments); return null === c ? 0 === s.length && 0 === a.length ? r.parse : [r.parse, ...s, ...a] : [r.parse, ...s, ...c, ...a]; }
|
38629 | matchOptionalLatexArgument() { return this.skipSpace(), this.matchBalancedExpression("[", "]"); }
|
38630 | matchRequiredLatexArgument() { return this.skipSpace(), this.matchBalancedExpression("<{>", "<}>") || (/^[0-9]$/.test(this.peek) ? parseFloat(this.next()) : /^[^\\#]$/.test(this.peek) ? this.next() : this.matchSymbol()); }
|
38631 | matchSupsub(e) { if (null === e)
|
38632 | return null; let i = null; return this.skipSpace(), [["^", "superfix"], ["_", "subfix"]].forEach((n => { var t, r, o; if (null !== i)
|
38633 | return; const [s, a] = n, l = this.index; if (!this.match(s))
|
38634 | return; const u = this.index; let c, m = 0; if (this.match("<{>") ? ([c, m] = this.peekDefinition(a), c ? "function" == typeof c.parse ? i = c.parse(e, this, 0)[1] : (this.index += m, this.match("<}>") ? i = [null !== (t = c.parse) && void 0 !== t ? t : c.name, e] : this.index = u) : this.index = u) : ([c, m] = this.peekDefinition(a), c ? "function" == typeof c.parse ? i = c.parse(e, this, 0)[1] : (this.index += m, i = [null !== (r = c.parse) && void 0 !== r ? r : c.name, e]) : this.index = u), null === i && (c = null === (o = this.dictionary.infix[1]) || void 0 === o ? void 0 : o.get(s), "function" == typeof (null == c ? void 0 : c.parse) ? (this.index = l, i = c.parse(e, this, 0)[1]) : "string" == typeof (null == c ? void 0 : c.parse) ? ([e, i] = this.applyOperator(c.parse, e, this.matchRequiredLatexArgument()), i = this.applyInvisibleOperator(e, i)) : i = this.applyInvisibleOperator(e, s)), null !== i) {
|
38635 | const e = this.matchArguments(null == c ? void 0 : c.arguments);
|
38636 | null !== e && (i = [i, ...e]);
|
38637 | } })), i; }
|
38638 | matchPostfix(e) { if (null === e)
|
38639 | return null; const [i, n] = this.peekDefinition("postfix"); return null == i ? null : "function" == typeof i.parse ? ([, e] = i.parse(e, this, 0), null === e ? null : e) : (this.index += n, [i.parse, e]); }
|
38640 | matchString() { let e = "", i = this.atEnd; for (; !i;) {
|
38641 | if (this.match("<space>"))
|
38642 | e += " ";
|
38643 | else {
|
38644 | const n = this.peek;
|
38645 | "]" === n ? i = !0 : /^<({|}|\$|\$\$|space)>$/.test(n) ? "\\" === n[0] ? (this.onError({ code: "unexpected-command" }), e += this.next()) : i = !0 : e += this.next();
|
38646 | }
|
38647 | i = i || this.atEnd;
|
38648 | } return e; }
|
38649 | matchEnvironmentName(e, i) { if (this.match(e)) {
|
38650 | const e = this.index;
|
38651 | if (this.match("<{>")) {
|
38652 | const e = this.matchString();
|
38653 | if (this.match("<}>") && e === i)
|
38654 | return !0;
|
38655 | }
|
38656 | this.index = e;
|
38657 | } return !1; }
|
38658 | matchTabular() { const e = ["list"]; let i = ["list"], n = null, t = !1; for (; !this.atEnd && !t;)
|
38659 | if (this.match("&"))
|
38660 | i.push(null != n ? n : T), n = null;
|
38661 | else if (this.match("\\\\") || this.match("\\cr"))
|
38662 | this.skipSpace(), this.matchOptionalLatexArgument(), null !== n && i.push(n), e.push(i), i = ["list"], n = null;
|
38663 | else {
|
38664 | const e = this.matchExpression();
|
38665 | null === e && (t = !0), n = null !== n ? this.applyInvisibleOperator(n, e) : e;
|
38666 | } return i.length > 1 && e.push(i), e; }
|
38667 | matchEnvironment() { var e; if (this.match("\\begin") && this.match("<{>")) {
|
38668 | const i = this.matchString();
|
38669 | if (this.match("<}>")) {
|
38670 | const n = this.index;
|
38671 | let t = this.index, r = 1;
|
38672 | for (; !this.atEnd && 0 !== r;)
|
38673 | t = this.index, this.matchEnvironmentName("\\begin", i) ? r += 1 : this.matchEnvironmentName("\\end", i) ? r -= 1 : this.next();
|
38674 | const o = this.dictionary.environment.get(i);
|
38675 | return "function" == typeof (null == o ? void 0 : o.parse) ? o.parse(null, this.clone(n, t), 0)[1] : null !== (e = null == o ? void 0 : o.parse) && void 0 !== e ? e : null;
|
38676 | }
|
38677 | } return null; }
|
38678 | applyOperator(e, i, n) { var t, r, o, s; const a = this.dictionary.name.get(e); if (void 0 === a)
|
38679 | return this.onError({ code: "unknown-operator" }), [i, n]; if (void 0 !== (null === (t = a.trigger) || void 0 === t ? void 0 : t.prefix) && null === i && null !== n)
|
38680 | return [null, [a.name, n]]; if (void 0 !== (null === (r = a.trigger) || void 0 === r ? void 0 : r.postfix) && null !== i)
|
38681 | return [null, [a.name, i]]; if (void 0 !== (null === (o = a.trigger) || void 0 === o ? void 0 : o.matchfix) || void 0 !== (null === (s = a.trigger) || void 0 === s ? void 0 : s.infix)) {
|
38682 | if ("non" === a.associativity)
|
38683 | return [null, [e, null != i ? i : "Missing", null != n ? n : "Missing"]];
|
38684 | if (te(i) === e) {
|
38685 | if ("both" === a.associativity) {
|
38686 | if (te(n) === e) {
|
38687 | if (Array.isArray(i))
|
38688 | return [null, i.concat(oe(n))];
|
38689 | if (B(i))
|
38690 | return [null, i.fn.concat(oe(n))];
|
38691 | }
|
38692 | else
|
38693 | n && (Array.isArray(i) && i.push(n), B(i) && i.fn.push(n));
|
38694 | return [null, i];
|
38695 | }
|
38696 | return "left" === a.associativity ? [null, [e, null != i ? i : P, null != n ? n : P]] : Array.isArray(i) ? [null, [e, i[1], [e, i[2], null != n ? n : P]]] : (B(i) && (i.fn[2] = [e, i.fn[2], null != n ? n : P]), [null, i]);
|
38697 | }
|
38698 | return te(n) === e ? "both" === a.associativity ? (Array.isArray(n) && i && n.splice(1, 0, i), B(n) && i && n.fn.splice(1, 0, i), [null, n]) : "right" === a.associativity ? [null, [e, null != i ? i : P, null != n ? n : P]] : Array.isArray(n) ? [null, [e, n[1], [e, n[2], null != i ? i : P]]] : (B(n) && (n.fn[2] = [e, n.fn[2], null != i ? i : P]), [null, n]) : [null, [e, null != i ? i : "Missing", null != n ? n : "Missing"]];
|
38699 | } return [i, null]; }
|
38700 | applyInvisibleOperator(e, i) { if (null === e)
|
38701 | return i; if (null === i)
|
38702 | return e; if (this.options.invisiblePlusOperator && ("number" == typeof e || H(e)) && function (e) { var i, n; const t = re(e); if (null !== t && ["ThreeQuarter", "TwoThird", "Half", "Third", "Quarter"].includes(t))
|
38703 | return !0; if (te(e) !== z)
|
38704 | return !1; const r = null !== (i = G(le(e, 1))) && void 0 !== i ? i : NaN, o = null !== (n = G(le(e, 2))) && void 0 !== n ? n : NaN; return Number.isInteger(r) && Number.isInteger(o); }(i))
|
38705 | return [e, i] = this.applyOperator(this.options.invisiblePlusOperator, e, i), null === e ? i : null; if (this.options.invisibleOperator)
|
38706 | return [e, i] = this.applyOperator(this.options.invisibleOperator, e, i), null === e ? i : null; let n = ["LatexTokens"]; return "LatexTokens" === te(e) ? n = n.concat(oe(e)) : n.push(e), null !== i && ("LatexTokens" === te(i) ? n = n.concat(oe(i)) : n.push(i)), this.options.invisibleOperator && this.onError({ code: "unexpected-sequence" }), n; }
|
38707 | matchUnknownLatexCommand() { var e; const i = this.peek; if (!i || "\\" !== i[0])
|
38708 | return null; if (this.next(), "\\operatorname" === i) {
|
38709 | if (this.skipSpace(), "<{>" === this.peek) {
|
38710 | let e = "";
|
38711 | for (this.next(); !this.atEnd && "<}>" !== this.tokens[this.index];)
|
38712 | e += this.next();
|
38713 | return e;
|
38714 | }
|
38715 | return null !== (e = this.next()) && void 0 !== e ? e : P;
|
38716 | } const n = [], t = []; let r = !1; do {
|
38717 | r = !0;
|
38718 | let e = this.matchOptionalLatexArgument();
|
38719 | null !== e && (n.push(e), r = !1), this.skipSpace(), "<{>" === this.peek && (e = this.matchRequiredLatexArgument(), null !== e && (t.push(e), r = !1));
|
38720 | } while (!r); return n.length > 0 || t.length > 0 ? [i, ...t, ...n] : i; }
|
38721 | matchPrimary(e) { let i = null; const n = this.index, t = this.matchNumber(); t && (i = { num: t }), null === i && (i = this.matchMatchfixOperator()), null === i && (i = this.matchEnvironment()), null === i && (i = this.matchSymbol()); let r = null; do {
|
38722 | r = this.matchSupsub(i), i = null != r ? r : i;
|
38723 | } while (null !== r); let o = null; do {
|
38724 | o = this.matchPostfix(i), i = null != o ? o : i;
|
38725 | } while (null !== o); return this.decorate(i, n); }
|
38726 | matchBalancedExpression(e, i, n) { const t = this.balancedClone(e, i); if (!t)
|
38727 | return null == n || n({ code: "unbalanced-symbols", arg: a(e) + a(i) }), null; const r = t.matchExpression(); return t.atEnd || null == n || n({ code: "unbalanced-symbols", arg: a(e) + a(i) }), r; }
|
38728 | matchExpression(e = 0) { let i = null; const n = this.index; this.skipSpace(), i = this.matchPrimary(e), null === i && (i = this.matchOperator("prefix")); let t = !1; for (; !this.atEnd && !t;) {
|
38729 | this.skipSpace();
|
38730 | let n = this.matchOperator("infix", i, e);
|
38731 | if (null === n && null !== i) {
|
38732 | const [e] = this.peekDefinition("operator");
|
38733 | if (null === e) {
|
38734 | const e = this.matchExpression(this.invisibleOperatorPrecedence);
|
38735 | null !== e && (n = this.applyInvisibleOperator(i, e));
|
38736 | }
|
38737 | }
|
38738 | null !== n ? i = n : t = !0;
|
38739 | } return this.decorate(i, n); }
|
38740 | decorate(e, i) { if (null === e)
|
38741 | return null; if (this.options.preserveLatex) {
|
38742 | const n = this.latex(i, this.index);
|
38743 | Array.isArray(e) ? e = { latex: n, fn: e } : "number" == typeof e ? e = { latex: n, num: Number(e).toString() } : "string" == typeof e ? e = { latex: n, sym: e } : "object" == typeof e && null !== e && (e.latex = n);
|
38744 | } return e; }
|
38745 | }
|
38746 | function je(e, i) { const n = e.length, t = e; e = e.slice(0, -1); for (let n = 0; n < e.length - 16; n++) {
|
38747 | const t = e.substr(0, n);
|
38748 | for (let r = 0; r < 17; r++) {
|
38749 | const o = e.substr(n, r + 1), s = Math.floor((e.length - t.length) / o.length);
|
38750 | if (s > 1 && (t + o.repeat(s + 1)).startsWith(e))
|
38751 | return "0" === o ? t.replace(/(\d{3})/g, "$1" + i.groupSeparator) : t.replace(/(\d{3})/g, "$1" + i.groupSeparator) + i.beginRepeatingDigits + o + i.endRepeatingDigits;
|
38752 | }
|
38753 | } const r = n > i.precision - 1; return e = t, r && (e = e.substr(0, i.precision - 1)), i.groupSeparator && (e = e.replace(/(\d{3})/g, "$1" + i.groupSeparator)).endsWith(i.groupSeparator) && (e = e.slice(0, -i.groupSeparator.length)), r ? e + i.truncationMarker : e; }
|
38754 | function Be(e, i) { var n; return e ? i.beginExponentMarker ? i.beginExponentMarker + e + (null !== (n = i.endExponentMarker) && void 0 !== n ? n : "") : "10^{" + e + "}" : ""; }
|
38755 | class Ue {
|
38756 | constructor(e, i, n) { this.level = -1, this.options = e, e.invisibleMultiply && (/#1/.test(e.invisibleMultiply) && /#2/.test(e.invisibleMultiply) || n({ code: "expected-argument", arg: "invisibleMultiply" })), this.onError = n, this.dictionary = i; }
|
38757 | wrap(e, i) { if (null === e)
|
38758 | return ""; if (void 0 === i)
|
38759 | return "(" + this.serialize(e) + ")"; if ("number" == typeof e || H(e) || "string" == typeof e || $(e))
|
38760 | return this.serialize(e); const n = te(e); if (n && "Parentheses" !== n) {
|
38761 | const t = this.dictionary.name.get(n);
|
38762 | if (t && void 0 !== t.precedence && t.precedence < i)
|
38763 | return this.wrapString(this.serialize(e), (this.level, "paren"));
|
38764 | } return this.serialize(e); }
|
38765 | wrapShort(e) { if (null === e)
|
38766 | return ""; const i = this.serialize(e); return "Parentheses" === te(e) || "number" == typeof e || H(e) || /(^(.|\\[a-zA-Z*]+))$/.test(i) ? i : this.wrapString(i, (this.level, "paren")); }
|
38767 | wrapString(e, i) { return "none" === i ? e : "(" + e + ")"; }
|
38768 | serializeSymbol(e, i) { const n = ie(e); if (!n) {
|
38769 | if ("string" == typeof (null == i ? void 0 : i.serialize))
|
38770 | return i.serialize;
|
38771 | const n = re(e);
|
38772 | if (null === n)
|
38773 | return "";
|
38774 | switch (function (e, i) { const n = re(e); return null === n ? "asis" : n.length > 1 ? "upright" : "asis"; }(e, this.level)) {
|
38775 | case "upright": return "\\operatorname{" + n + "}";
|
38776 | default: return n;
|
38777 | }
|
38778 | } const t = oe(e); if (!i) {
|
38779 | if ("string" == typeof n && n.length > 0 && "\\" === n[0]) {
|
38780 | let e = n;
|
38781 | for (const i of t)
|
38782 | e += "{" + this.serialize(i) + "}";
|
38783 | return e;
|
38784 | }
|
38785 | return `${this.serialize(n)}(${t.map((e => this.serialize(e))).join(", ")})`;
|
38786 | } if (i.requiredLatexArg > 0) {
|
38787 | let e = "", n = "", r = 0;
|
38788 | for (; r < i.requiredLatexArg;)
|
38789 | n += "{" + this.serialize(t[r++]) + "}";
|
38790 | for (; r < Math.min(t.length, i.optionalLatexArg + i.requiredLatexArg);) {
|
38791 | const i = this.serialize(t[1 + r++]);
|
38792 | i && (e += "[" + i + "]");
|
38793 | }
|
38794 | return i.serialize + (e + n);
|
38795 | } return this.level, i.serialize + this.serialize(["Parentheses", ...t]); }
|
38796 | serializeDictionary(e) { return `\\left[\\begin{array}{lll}${Object.keys(e).map((i => `\\textbf{${i}} & \\rightarrow & ${this.serialize(e[i])}`)).join("\\\\")}\\end{array}\\right]`; }
|
38797 | serialize(e) { if (null === e)
|
38798 | return ""; this.level += 1; const i = (() => { var i, n, t, r; const o = function (e, i) { var n, t; let r; if ("number" == typeof e)
|
38799 | r = e;
|
38800 | else {
|
38801 | if (!H(e))
|
38802 | return "";
|
38803 | r = e.num;
|
38804 | } if (r === 1 / 0 || "Infinity" === r || "+Infinity" === r)
|
38805 | return i.positiveInfinity; if (r === -1 / 0 || "-Infinity" === r)
|
38806 | return i.negativeInfinity; if ("NaN" === r || "number" == typeof r && Number.isNaN(r))
|
38807 | return i.notANumber; if ("number" == typeof r)
|
38808 | return "engineering" === i.notation ? function (e, i) { if (0 === e)
|
38809 | return "0"; const n = Math.abs(e); let t = Math.round(Math.log10(n)); t -= t % 3, n < 1e3 && (t = 0); const r = n / Math.pow(10, t); let o = ""; const s = r.toString().match(/^(.*)\.(.*)$/); (null == s ? void 0 : s[1]) && s[2] && (o = s[1] + i.decimalMarker + s[2]), i.groupSeparator && (o = je(r.toExponential(), i)); let a = ""; return 0 !== t && (a = Be(t.toString(), i)), (e < 0 ? "-" : "") + o + a; }(r, i) : function (e, i) { let n, t = e.match(/^(.*)[e|E]([-+]?[0-9]+)$/i); (null == t ? void 0 : t[1]) && t[2] && (n = Be(t[2], i), n && (n = i.exponentProduct + n)); let r = e, o = ""; return t = (n ? t[1] : e).match(/^(.*)\.(.*)$/), (null == t ? void 0 : t[1]) && t[2] && (r = t[1], o = t[2]), i.groupSeparator && (r = r.replace(/\B(?=(\d{3})+(?!\d))/g, i.groupSeparator), o = je(o, i)), o && (o = i.decimalMarker + o), r + o + (null != n ? n : ""); }(r.toString(), i); /[a-zA-Z]$/.test(r) && (r = r.slice(0, -1)); let o = ""; for ("-" === r[0] ? (o = "-", r = r.substr(1)) : "+" === r[0] && (r = r.substr(1)); "0" === r[0];)
|
38810 | r = r.substr(1); if (0 === r.length)
|
38811 | return o + "0"; "." === r[0] && (r = "0" + r); let s = ""; if (r.indexOf(".") >= 0) {
|
38812 | const e = r.match(/(\d*)\.(\d*)([e|E]([-+]?[0-9]*))?/);
|
38813 | if (!e)
|
38814 | return "";
|
38815 | const t = e[1], a = e[2];
|
38816 | if (s = null !== (n = e[4]) && void 0 !== n ? n : "", "0" === t) {
|
38817 | let e = 0;
|
38818 | for (; "0" === a[e] && e < a.length;)
|
38819 | e += 1;
|
38820 | let n = "";
|
38821 | if (e <= 4)
|
38822 | n = "0" + i.decimalMarker, n += a.substr(0, e), n += je(r.substr(n.length), i);
|
38823 | else if (e + 1 >= i.precision)
|
38824 | n = "0", o = "";
|
38825 | else {
|
38826 | n = r[e];
|
38827 | const t = je(r.substr(e + 1), i);
|
38828 | t && (n += i.decimalMarker + t);
|
38829 | }
|
38830 | "0" !== n && (!(r.length - 1 > i.precision) || i.endRepeatingDigits && n.endsWith(i.endRepeatingDigits) || !i.truncationMarker || n.endsWith(i.truncationMarker) || (n += i.truncationMarker), e > 4 && (n += i.exponentProduct + Be((1 - e).toString(), i))), r = n;
|
38831 | }
|
38832 | else {
|
38833 | r = t.replace(/\B(?=(\d{3})+(?!\d))/g, i.groupSeparator);
|
38834 | const e = je(a, i);
|
38835 | e && (r += i.decimalMarker + e);
|
38836 | }
|
38837 | }
|
38838 | else if (r.length > i.precision) {
|
38839 | const e = r.length;
|
38840 | let n = r[0];
|
38841 | const t = je(r.substr(1), i);
|
38842 | t && (n += i.decimalMarker + t, i.truncationMarker && !n.endsWith(i.truncationMarker) && i.endRepeatingDigits && !n.endsWith(i.endRepeatingDigits) && (n += i.truncationMarker)), "1" !== n ? n += i.exponentProduct : n = "", r = n + Be((e - 1).toString(), i);
|
38843 | }
|
38844 | else {
|
38845 | const e = r.match(/([0-9]*)\.?([0-9]*)([e|E]([-+]?[0-9]+))?/);
|
38846 | e && (r = e[1], e[2] && (r += i.decimalMarker + e[2]), s = null !== (t = e[4]) && void 0 !== t ? t : ""), r = r.replace(/\B(?=(\d{3})+(?!\d))/g, i.groupSeparator);
|
38847 | } const a = Be(s, i); return o + r + (a ? i.exponentProduct + a : ""); }(e, this.options); if (o)
|
38848 | return o; const l = J(e); if (null !== l)
|
38849 | return `\\text{${l}}`; const u = re(e); if (null !== u)
|
38850 | return this.serializeSymbol(e, this.dictionary.name.get(u)); const c = ce(e); if (null !== c)
|
38851 | return this.serializeDictionary(c); const m = te(e); if (m) {
|
38852 | if ("\\" === m[0]) {
|
38853 | const i = oe(e);
|
38854 | return 0 === i.length ? m : m + "{" + i.map((e => this.serialize(e))).filter((e => Boolean(e))).join("}{") + "}";
|
38855 | }
|
38856 | const o = this.dictionary.name.get(m);
|
38857 | if (o) {
|
38858 | let l = "";
|
38859 | return "function" == typeof o.serialize && (l = o.serialize(this, e)), l || void 0 === o.precedence && !(null === (i = o.trigger) || void 0 === i ? void 0 : i.superfix) && !(null === (n = o.trigger) || void 0 === n ? void 0 : n.subfix) || (l = function (e, i, n) { var t, r, o, s, a; let l = ""; const u = ue(i), c = te(i); if ((null === (t = n.trigger) || void 0 === t ? void 0 : t.superfix) || (null === (r = n.trigger) || void 0 === r ? void 0 : r.subfix))
|
38860 | return 1 !== u && e.onError({ code: "operator-requires-one-operand", arg: e.serializeSymbol(c) }), He(n.serialize, [e.serialize(le(i, 1))]); if (null === (o = n.trigger) || void 0 === o ? void 0 : o.postfix)
|
38861 | return 1 !== u && e.onError({ code: "postfix-operator-requires-one-operand", arg: e.serializeSymbol(c) }), He(n.serialize, [e.wrap(le(i, 1), n.precedence)]); if (null === (s = n.trigger) || void 0 === s ? void 0 : s.prefix)
|
38862 | return 1 !== u && e.onError({ code: "prefix-operator-requires-one-operand", arg: e.serializeSymbol(c) }), He(n.serialize, [e.wrap(le(i, 1), n.precedence + 1)]); if (null === (a = n.trigger) || void 0 === a ? void 0 : a.infix) {
|
38863 | l = e.wrap(le(i, 1), n.precedence);
|
38864 | for (let t = 2; t < u + 1; t++) {
|
38865 | const r = le(i, t);
|
38866 | null !== r && (l = He(n.serialize, [l, e.wrap(r, n.precedence)]));
|
38867 | }
|
38868 | } return l; }(this, e, o)), !l && (null === (t = o.trigger) || void 0 === t ? void 0 : t.matchfix) && (l = function (e, i, n) { var t, r; let o = []; if ("string" == typeof (null === (t = n.trigger) || void 0 === t ? void 0 : t.matchfix) ? o.push(null === (r = n.trigger) || void 0 === r ? void 0 : r.matchfix) : n.trigger && Array.isArray(n.trigger.matchfix) && (o = [...n.trigger.matchfix]), ue(i) >= 1) {
|
38869 | let t = "";
|
38870 | for (const r of oe(i))
|
38871 | r && (o.push(t), o.push(e.serialize(r)), t = n.separator);
|
38872 | } return o.push(a(n.closeFence)), s(o); }(this, e, o)), !l && (null === (r = o.trigger) || void 0 === r ? void 0 : r.symbol) && (l = this.serializeSymbol(e, o)), l;
|
38873 | }
|
38874 | } if (Array.isArray(e) || B(e))
|
38875 | return this.serializeSymbol(e); this.onError({ code: "syntax-error", arg: JSON.stringify(e) }); })(); return this.level -= 1, null != i ? i : ""; }
|
38876 | }
|
38877 | class Ge {
|
38878 | constructor(e) { var i, n; this.onError = null !== (i = null == e ? void 0 : e.onError) && void 0 !== i ? i : e => { "undefined" != typeof window && (!e.before || e.after); }; const t = { ...null != e ? e : {} }; delete t.dictionary, delete t.onError, this.options = { ...Re, ...Qe, ...Ze, ...t }, this.dictionary = function (e, i) { var n, t, r, o, s, a, l, u, c, m, f, h, p, g, d; const v = { lookahead: 1, name: new Map, prefix: [], infix: [], postfix: [], matchfix: [], superfix: [], subfix: [], symbol: [], environment: new Map }; for (const x of e)
|
38879 | void 0 === x.parse && (x.parse = x.name), "string" == typeof x.trigger && (x.trigger = { symbol: x.trigger }), "string" == typeof x.serialize && void 0 !== (null === (n = x.trigger) || void 0 === n ? void 0 : n.symbol) && /#[0-9]/.test(x.serialize) && i({ code: "unexpected-argument", arg: x.name }), void 0 === x.serialize && (void 0 !== (null === (t = x.trigger) || void 0 === t ? void 0 : t.postfix) ? x.serialize = "#1" + Le(x.trigger.postfix) : void 0 !== (null === (r = x.trigger) || void 0 === r ? void 0 : r.prefix) ? x.serialize = Le(x.trigger.prefix) + "#1" : void 0 !== (null === (o = x.trigger) || void 0 === o ? void 0 : o.infix) ? x.serialize = "#1" + Le(x.trigger.infix) + "#2" : void 0 !== (null === (s = x.trigger) || void 0 === s ? void 0 : s.symbol) ? x.serialize = Le(x.trigger.symbol) : void 0 !== (null === (a = x.trigger) || void 0 === a ? void 0 : a.superfix) ? x.serialize = "#1^{" + Le(null === (l = x.trigger) || void 0 === l ? void 0 : l.superfix) + "}" : void 0 !== (null === (u = x.trigger) || void 0 === u ? void 0 : u.subfix) ? x.serialize = "#1_{" + Le(null === (c = x.trigger) || void 0 === c ? void 0 : c.subfix) + "}" : x.serialize = ""), void 0 !== (null === (m = x.trigger) || void 0 === m ? void 0 : m.infix) && (void 0 === x.precedence && i({ code: "syntax-error", arg: "Infix operators require a precedence" }), x.associativity || (x.associativity = "non")), void 0 !== (null === (f = x.trigger) || void 0 === f ? void 0 : f.symbol) && (x.arguments = null !== (h = x.arguments) && void 0 !== h ? h : "", x.optionalLatexArg = null !== (p = x.optionalLatexArg) && void 0 !== p ? p : 0, x.requiredLatexArg = null !== (g = x.requiredLatexArg) && void 0 !== g ? g : 0), void 0 !== (null === (d = x.trigger) || void 0 === d ? void 0 : d.matchfix) && ("function" === x.parse || x.closeFence || i({ code: "syntax-error", arg: "Matchfix operators require a close fence or a custom parse function" })), void 0 !== x.trigger && (["infix", "prefix", "postfix", "symbol", "matchfix", "superfix", "subfix"].forEach((e => { if (x.trigger[e]) {
|
38880 | const n = (i = x.trigger[e], Array.isArray(i) ? i.length : 1);
|
38881 | v.lookahead = Math.max(v.lookahead, n), void 0 === v[e][n] && (v[e][n] = new Map), v[e][n].set(Le(x.trigger[e]), x);
|
38882 | } var i; })), void 0 !== x.trigger.environment && v.environment.set(x.trigger.environment, x)), void 0 !== x.name ? v.name.set(Le(x.name), x) : "string" == typeof x.parse && v.name.set(x.parse, x), void 0 !== x.trigger || x.name || i({ code: "syntax-error", arg: "Need at least a trigger or a name" }); return v; }(null !== (n = null == e ? void 0 : e.dictionary) && void 0 !== n ? n : Ge.getDictionary(), this.onError); }
|
38883 | static getDictionary(e = "all") { if ("all" === e) {
|
38884 | let e = [];
|
38885 | for (const i of Object.keys(_e))
|
38886 | e = [...e, ..._e[i]];
|
38887 | return e;
|
38888 | } return _e[e] ? [..._e[e]] : []; }
|
38889 | parse(e) { var i; const n = new $e(o(e, []), this.options, this.dictionary, this.onError), t = n.matchExpression(); return n.atEnd || null === (i = this.onError) || void 0 === i || i.call(this, { code: "syntax-error" }), null != t ? t : ""; }
|
38890 | serialize(e) { return new Ue(this.options, this.dictionary, this.onError).serialize(e); }
|
38891 | }
|
38892 | function We(e, i) { return new Ge(i).parse(e); }
|
38893 | function Ve(e, i) { return new Ge(i).serialize(e); }
|
38894 | const ii = { Anything: [], Expression: "Anything", Domain: ["Set", "Symbol"], ParametricDomain: ["Domain", "Function"], MaybeBoolean: "Expression", Boolean: "MaybeBoolean", Collection: "Expression", Dictionary: "Collection", List: "Collection", Sequence: "Collection", Tuple: "Collection", Set: "Collection", FiniteSet: "Set", InfiniteSet: "Set", EmptySet: "FiniteSet", String: "Expression", Symbol: "String", Function: "Expression", Predicate: "Function", LogicalFunction: "Predicate", TranscendentalFunction: "Function", AlgebraicFunction: "Function", PeriodicFunction: "Function", TrigonometricFunction: ["PeriodicFunction", "TranscendentalFunction"], HyperbolicFunction: "TranscendentalFunction", MonotonicFunction: "Function", StrictMonotonicFunction: "MonotonicFunction", ContinuousFunction: "Function", DifferentiableFunction: "ContinuousFunction", InfinitelyDifferentiableFunction: "DifferentiableFunction", RationalFunction: ["AlgebraicFunction", "ContinuousFunction"], PolynomialFunction: ["AlgebraicFunction", "InfinitelyDifferentiableFunction"], QuadraticFunction: "PolynomialFunction", LinearFunction: ["QuadraticFunction", "MonotonicFunction"], ConstantFunction: "LinearFunction", Number: "Set", ImaginaryNumber: ["ComplexNumber", "InfiniteSet"], ComplexNumber: "ExtendedComplexNumber", ExtendedComplexNumber: "Number", ComplexInfinity: "ExtendedComplexNumber", NumberZero: ["CompositeNumber", "ImaginaryNumber", "FiniteSet"], NaturalNumber: "Integer", CompositeNumber: "NaturalNumber", PrimeNumber: "NaturalNumber", Integer: ["RationalNumber", "ExtendedInteger"], ExtendedInteger: "ExtendedRationalNumber", RationalNumber: ["AlgebraicNumber", "ExtendedRationalNumber"], IrrationalNumber: "RealNumber", TranscendentalNumber: ["IrrationalNumber", "ImaginaryNumber"], AlgebraicNumber: "IrrationalNumber", RealNumber: ["ComplexNumber", "ExtendedRealNumber"], ExtendedRealNumber: "ExtendedComplexNumber", ExtendedNaturalNumber: "ExtendedInteger", ExtendedRationalNumber: "ExtendedRealNumber", SignedInfinity: "ExtendedNaturalNumber", Tensor: "Expression", Scalar: "Tensor", Vector: "Matrix", Row: "Vector", Column: "Vector", Matrix: "Tensor", ComplexTensor: "Tensor", RealTensor: "ComplexTensor", IntegerTensor: "RealTensor", LogicalTensor: "IntegerTensor", SquareMatrix: "Matrix", MonomialMatrix: "SquareMatrix", TriangularMatrix: "SquareMatrix", UpperTriangularMatrix: "TriangularMatrix", LowerTriangularMatrix: "TriangularMatrix", PermutationMatrix: ["MonomialMatrix", "LogicalTensor", "OrthogonalMatrix"], OrthogonalMatrix: ["SquareMatrix", "RealTensor"], DiagonalMatrix: ["UpperTriangularMatrix", "LowerTriangularMatrix"], IdentityMatrix: ["DiagonalMatrix", "SymmetricMatrix", "PermutationMatrix"], ZeroMatrix: ["DiagonalMatrix", "SymmetricMatrix", "PermutationMatrix"], SymmetricMatrix: ["HermitianMatrix", "SquareMatrix", "RealTensor"], HermitianMatrix: "ComplexTensor", Quaternion: ["SquareMatrix", "ComplexTensor"] }, ni = { Function: "Q11348", ComplexNumber: "Q26851286", Integer: "Q47007735", ImaginaryNumber: "Q47310259", NaturalNumber: "Q28920052" }, ti = { MaybeBoolean: ["Union", "Boolean", ["Set", "Maybe"]], NaturalNumber: ["Union", "CompositeNumber", "PrimeNumber"], Scalar: ["Intersection", "Row", "Column"], TriangularMatrix: ["Union", "UpperTriangularMatrix", "LowerTriangularMatrix"], Vector: ["Union", "Row", "Column"] }, ri = { Boolean: 2, MaybeBoolean: 3, EmptySet: 0, IdentityMatrix: 1, ZeroMatrix: 1, NumberZero: 1 }, oi = { Range: { range: "ParametricDomain", evaluate: (e, i, n) => (i = Math.round(i), n = Math.round(n), Number.isNaN(i) || Number.isNaN(n) || i > n ? "EmptySet" : i === -1 / 0 && n === 1 / 0 ? "Integer" : 0 === i && n === 1 / 0 ? "NaturalNumber" : 0 === i && 0 === n ? "NumberZero" : ["Range", i, n]) }, Interval: { range: "ParametricDomain", evaluate: (e, i, n) => Number.isNaN(i) || Number.isNaN(n) || i > n ? "EmptySet" : i === -1 / 0 && n === 1 / 0 ? "RealNumber" : 0 === i && 0 === n ? "NumberZero" : ["Interval", i, n] } };
|
38895 | function si(e, i, n) { if (null === i)
|
38896 | return null; const t = ci(e); return "" === t ? n : n[t] ? null === li(i, n[t]) ? null : n : (n[t] = i, n); }
|
38897 | function ai(e, i, n, t) { var r; const o = G(i); if (null !== o)
|
38898 | return Math.abs(o - (null !== (r = G(e)) && void 0 !== r ? r : NaN)) <= t.numericalTolerance ? n : null; const s = J(i); if (null !== s)
|
38899 | return J(e) === s ? n : null; const a = ce(i); if (null !== a) {
|
38900 | const i = Object.keys(a), r = ce(e);
|
38901 | if (null === r)
|
38902 | return null;
|
38903 | if (Object.keys(r).length !== i.length)
|
38904 | return null;
|
38905 | for (const e of i) {
|
38906 | const i = ai(r[e], a[e], n, t);
|
38907 | if (null === i)
|
38908 | return null;
|
38909 | n = i;
|
38910 | }
|
38911 | return n;
|
38912 | } const l = re(i); if (null !== l)
|
38913 | return l.startsWith("_") ? si(l, e, n) : l === re(e) ? "object" == typeof i && "object" == typeof e && "wikidata" in i && "wikidata" in e && i.wikidata !== e.wikidata ? null : n : "object" == typeof i && "object" == typeof e && "wikidata" in i && "wikidata" in e && i.wikidata === e.wikidata ? n : null; const u = ie(i); if (null === u)
|
38914 | return null; if ("string" == typeof u && u.startsWith("_"))
|
38915 | return si(u, ie(e), n); {
|
38916 | const i = ie(e);
|
38917 | if (null === i)
|
38918 | return null;
|
38919 | if (null === li(u, i, t))
|
38920 | return null;
|
38921 | } const c = oe(i), m = oe(e), f = c.length; if (f !== m.length)
|
38922 | return null; let h = { ...n }, p = 0; for (; p < f;) {
|
38923 | const e = c[p], i = re(e);
|
38924 | if (null !== i)
|
38925 | if (i.startsWith("__")) {
|
38926 | let e = 0;
|
38927 | if (void 0 === c[p + 1])
|
38928 | e = m.length + 1;
|
38929 | else {
|
38930 | let i = !1;
|
38931 | for (; !i && e < m.length;)
|
38932 | i = null !== li(c[p + 1], m[e], t), e += 1;
|
38933 | if (!i)
|
38934 | return null;
|
38935 | }
|
38936 | if (!i.startsWith("___") && e <= 1)
|
38937 | return null;
|
38938 | h = si(i, ["Sequence", ...m.splice(0, e - 1)], h);
|
38939 | }
|
38940 | else if (i.startsWith("_"))
|
38941 | h = si(i, m.shift(), h);
|
38942 | else {
|
38943 | const i = li(e, m.shift(), t);
|
38944 | if (null === i)
|
38945 | return null;
|
38946 | h = { ...h, ...i };
|
38947 | }
|
38948 | else {
|
38949 | const i = li(e, m.shift(), t);
|
38950 | if (null === i)
|
38951 | return null;
|
38952 | h = { ...h, ...i };
|
38953 | }
|
38954 | if (null === h)
|
38955 | return null;
|
38956 | p += 1;
|
38957 | } return h; }
|
38958 | function li(e, i, n) { return ai(i, e, {}, null != n ? n : { numericalTolerance: E }); }
|
38959 | function ci(e) { const i = e.match(/^__?_?([a-zA-Z0-9]+)/); return null === i ? "" : i[1]; }
|
38960 | class mi {
|
38961 | constructor(e) { this._items = e ? new Map(e instanceof mi ? e._items : e) : new Map; }
|
38962 | has(e) { for (const i of this._items.keys())
|
38963 | if (li(e, i))
|
38964 | return !0; return !1; }
|
38965 | get(e) { for (const [i, n] of this._items)
|
38966 | if (li(e, i))
|
38967 | return n; }
|
38968 | set(e, i) { for (const n of this._items.keys())
|
38969 | if (li(e, n))
|
38970 | return void this._items.set(n, i); this._items.set(e, i); }
|
38971 | delete(e) { this._items.delete(e); }
|
38972 | [Symbol.iterator]() { return this._items.entries(); }
|
38973 | entries() { return this._items.entries(); }
|
38974 | }
|
38975 | const fi = ["Sqrt", 2], hi = ["Sqrt", 3], pi = ["Sqrt", 5], gi = ["Sqrt", 6], di = new mi([[["Divide", "Pi", 12], { Sin: ["Divide", ["Subtract", gi, fi], 4], Cos: ["Divide", ["Add", gi, fi], 4], Tan: ["Subtract", [2, hi]], Cot: ["Add", [2, hi]], Sec: ["Subtract", [gi, fi]], Csc: ["Add", [gi, fi]] }], [["Divide", "Pi", 10], { Sin: ["Divide", ["Subtract", pi, 1], 4], Cos: ["Divide", ["Sqrt", ["Add", 10, ["Multiply", 2, pi]]], 4], Tan: ["Divide", ["Sqrt", ["Subtract", 25, ["Multiply", 10, pi]]], 4], Cot: ["Sqrt", ["Add", 5, ["Multiply", 2, pi]]], Sec: ["Divide", ["Sqrt", ["Subtract", 50, ["Multiply", 10, pi]]], 5], Csc: ["Add", 1, pi] }], [["Divide", "Pi", 4], { Sin: ["Divide", fi, 2], Cos: ["Divide", fi, 2], Tan: 1, Cot: 1, Sec: fi, Csc: fi }], [["Divide", "Pi", 3], { Sin: ["Divide", hi, 2], Cos: "Half", Tan: hi, Cot: ["Divide", hi, 3], Sec: 2, Csc: ["Divide", ["Multiply", 2, hi], 3] }], [["Divide", "Pi", 2], { Sin: 1, Cos: 0, Tan: 1 / 0, Cot: 0, Sec: 1 / 0, Csc: 1 }]]), vi = { Degrees: { domain: "Real", constant: !0, value: .017453292519943295 }, MinusDoublePi: { domain: "TranscendentalNumber", constant: !0, hold: !1, value: [L, -2, "Pi"] }, MinusPi: { domain: "TranscendentalNumber", constant: !0, hold: !1, value: [_, "Pi"] }, MinusHalfPi: { domain: "TranscendentalNumber", constant: !0, hold: !1, value: [z, [_, "Pi"], 2] }, QuarterPi: { domain: "TranscendentalNumber", constant: !0, hold: !1, value: [z, "Pi", 4] }, ThirdPi: { domain: "TranscendentalNumber", constant: !0, hold: !1, value: [z, "Pi", 3] }, HalfPi: { domain: "TranscendentalNumber", constant: !0, hold: !1, value: [z, "Pi", 2] }, TwoThirdPi: { domain: "TranscendentalNumber", constant: !0, hold: !1, value: [L, 2, [z, "Pi", 3]] }, ThreeQuarterPi: { domain: "TranscendentalNumber", constant: !0, hold: !1, value: [L, 3, [z, "Pi", 4]] }, Pi: { domain: "TranscendentalNumber", constant: !0, wikidata: "Q167", value: e => "decimal" === e.numericFormat ? c.exports.Decimal.acos(-1) : "complex" === e.numericFormat ? m.exports.Complex.PI : Math.PI }, DoublePi: { domain: "TranscendentalNumber", constant: !0, hold: !1, value: [L, 2, "Pi"] }, Arccos: { domain: "TrigonometricFunction", range: ["Interval", 0, "Pi"], numeric: !0, value: ["Subtract", "HalfPi", ["Arcsin", "_"]], simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Arccos) && void 0 !== t ? t : ["Subtract", "HalfPi", ["Arcsin", i]]; }, evalNumber: (e, i) => Math.acos(i), evalDecimal: (e, i) => c.exports.Decimal.acos(i), evalComplex: (e, i) => m.exports.Complex.acos(i) }, Arcosh: { domain: "HyperbolicFunction", range: ["Interval", 0, 1 / 0], numeric: !0, value: ["Ln", ["Add", "_", ["Sqrt", ["Subtract", ["Square", "_"], 1]]]], simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Arccosh) && void 0 !== t ? t : ["Ln", ["Add", i, ["Sqrt", ["Subtract", ["Square", i], 1]]]]; }, evalNumber: (e, i) => Math.acosh(i), evalDecimal: (e, i) => c.exports.Decimal.acosh(i), evalComplex: (e, i) => m.exports.Complex.acosh(i) }, Arcsin: { domain: "TrigonometricFunction", range: ["Interval", "MinusHalfPi", "HalfPi"], numeric: !0, simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Arcsin) && void 0 !== t ? t : ["Multiply", 2, ["Arctan2", i, ["Add", 1, ["Sqrt", ["Subtract", 1, ["Square", i]]]]]]; }, value: ["Multiply", 2, ["Arctan2", "_", ["Add", 1, ["Sqrt", ["Subtract", 1, ["Square", "_"]]]]]], evalNumber: (e, i) => Math.asin(i), evalDecimal: (e, i) => c.exports.Decimal.asin(i), evalComplex: (e, i) => m.exports.Complex.asin(i) }, Arsinh: { domain: "HyperbolicFunction", range: ["Interval", -1 / 0, 1 / 0], numeric: !0, simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Arsinh) && void 0 !== t ? t : ["Ln", ["Add", i, ["Sqrt", ["Add", ["Square", i], 1]]]]; }, value: ["Ln", ["Add", "_", ["Sqrt", ["Add", ["Square", "_"], 1]]]], evalNumber: (e, i) => Math.asinh(i), evalDecimal: (e, i) => c.exports.Decimal.asinh(i), evalComplex: (e, i) => m.exports.Complex.asinh(i) }, Arctan: { wikidata: "Q2257242", domain: "TrigonometricFunction", range: ["Interval", "MinusHalfPi", "HalfPi"], numeric: !0, simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Arctan) && void 0 !== t ? t : i; }, evalNumber: (e, i) => Math.atan(i), evalDecimal: (e, i) => c.exports.Decimal.atan(i), evalComplex: (e, i) => m.exports.Complex.atan(i) }, Arctan2: { wikidata: "Q776598", range: ["Interval", "MinusPi", "Pi"], domain: "TrigonometricFunction", numeric: !0, evalNumber: (e, i, n) => Math.atan2(i, n), evalDecimal: (e, i, n) => c.exports.Decimal.atan2(i, n), evalComplex: (e, i, n) => m.exports.Complex.atan2(i, n) }, Artanh: { domain: "HyperbolicFunction", range: ["Interval", -1 / 0, 1 / 0], numeric: !0, simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Artanh) && void 0 !== t ? t : ["Multiply", "Half", ["Ln", ["Divide", ["Add", 1, i], ["Subtract", 1, i]]]]; }, value: ["Multiply", "Half", ["Ln", ["Divide", ["Add", 1, "_"], ["Subtract", 1, "_"]]]], evalNumber: (e, i) => Math.atanh(i), evalDecimal: (e, i) => c.exports.Decimal.atanh(i), evalComplex: (e, i) => m.exports.Complex.atanh(i) }, Cosh: { domain: "HyperbolicFunction", range: ["Interval", 1, 1 / 0], numeric: !0, simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Cosh) && void 0 !== t ? t : i; }, value: ["Multiply", "Half", ["Add", ["Exp", "_"], ["Exp", ["Negate", "_"]]]], evalNumber: (e, i) => Math.cosh(i), evalDecimal: (e, i) => c.exports.Decimal.cosh(i), evalComplex: (e, i) => m.exports.Complex.cosh(i) }, Cos: { domain: "TrigonometricFunction", range: ["Interval", -1, 1], numeric: !0, simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Cos) && void 0 !== t ? t : ["Sin", ["Add", i, "HalfPi"]]; }, value: ["Sin", ["Add", "_", "HalfPi"]], evalNumber: (e, i) => Math.cos(i), evalDecimal: (e, i) => c.exports.Decimal.cos(i), evalComplex: (e, i) => m.exports.Complex.cos(i) }, Cot: { domain: "TrigonometricFunction", range: "ComplexNumber", numeric: !0, simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Cot) && void 0 !== t ? t : ["Divide", ["Cos", i], ["Sin", i]]; }, value: ["Divide", ["Cos", "_"], ["Sin", "_"]], evalNumber: (e, i) => 1 / Math.tan(i), evalDecimal: (e, i) => h.div(c.exports.Decimal.tan(i)), evalComplex: (e, i) => m.exports.Complex.ONE.div(m.exports.Complex.tan(i)) }, Coth: { domain: "HyperbolicFunction", range: "ComplexNumber", numeric: !0, simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Coth) && void 0 !== t ? t : ["Divide", 1, ["Tanh", i]]; }, value: ["Divide", 1, ["Tanh", "_"]], evalNumber: (e, i) => 1 / Math.tanh(i), evalDecimal: (e, i) => h.div(c.exports.Decimal.tanh(i)), evalComplex: (e, i) => m.exports.Complex.ONE.div(m.exports.Complex.tanh(i)) }, Csc: { domain: "TrigonometricFunction", range: ["Interval", -1, 1], numeric: !0, simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Csc) && void 0 !== t ? t : ["Divide", 1, ["Sin", i]]; }, value: ["Divide", 1, ["Sin", "_"]], evalNumber: (e, i) => 1 / Math.tanh(i), evalDecimal: (e, i) => h.div(c.exports.Decimal.tanh(i)), evalComplex: (e, i) => m.exports.Complex.ONE.div(m.exports.Complex.tanh(i)) }, Csch: { domain: "HyperbolicFunction", range: ["Interval", -1, 1], numeric: !0, simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Csch) && void 0 !== t ? t : ["Divide", 1, ["Sinh", i]]; }, value: ["Divide", 1, ["Sinh", "_"]], evalNumber: (e, i) => 1 / Math.sinh(i), evalDecimal: (e, i) => h.div(c.exports.Decimal.sinh(i)), evalComplex: (e, i) => m.exports.Complex.ONE.div(m.exports.Complex.sinh(i)) }, FromPolarCoordinates: { domain: "Function", range: ["TupleOf", "RealNumber", "RealNumber"] }, Haversine: { wikidata: "Q2528380", domain: "TrigonometricFunction", range: ["Interval", 0, 1], value: ["Divide", ["Subtract", 1, ["Cos", "_"]], 2], numeric: !0 }, Hypot: { domain: "Function", range: ["Interval", 0, 1 / 0], value: ["Sqrt", ["Square", "_"], ["Square", "_2"]], evalNumber: (e, i, n) => Math.sqrt(i * i * +n * n), evalDecimal: (e, i, n) => c.exports.Decimal.sqrt(i.mul(i).add(n.mul(n))), evalComplex: (e, i, n) => m.exports.Complex.sqrt(i.mul(i).add(n.mul(n))) }, InverseFunction: { domain: "Function", range: "Function", simplify: (e, i) => { var n, t; const r = null !== (n = le(i, 1)) && void 0 !== n ? n : P; return "string" != typeof r ? i : null !== (t = { Sin: "Arcsin", Cos: "Arccos", Tan: "Arctan", Sec: "Arcsec", Csc: " Arccsc", Sinh: "Arsinh", Cosh: "Arcosh", Tanh: "Artanh", Sech: "Arcsech", Csch: "Arcsch", Arcosh: "Cosh", Arcos: "Cos", Arccsc: "Csc", Arcsch: "Csch", Arcsec: "Sec", Arcsin: "Sin", Arsinh: "Sinh", Arctan: "Tan", Artanh: "Tanh" }[r]) && void 0 !== t ? t : i; } }, InverseHaversine: { domain: "TrigonometricFunction", range: ["Interval", ["MinusPi"], "Pi"], numeric: !0, value: ["Multiply", 2, ["Arcsin", ["Sqrt", "_"]]] }, Sec: { domain: "TrigonometricFunction", range: ["Interval", -1, 1], numeric: !0, simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Sec) && void 0 !== t ? t : ["Divide", 1, ["Cos", i]]; }, value: ["Divide", 1, ["Cos", "_"]], evalNumber: (e, i) => 1 / Math.cos(i), evalDecimal: (e, i) => h.div(c.exports.Decimal.cos(i)), evalComplex: (e, i) => m.exports.Complex.ONE.div(m.exports.Complex.cos(i)) }, Sech: { domain: "HyperbolicFunction", range: ["Interval", -1, 1], numeric: !0, simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Sech) && void 0 !== t ? t : ["Divide", 1, ["Cosh", i]]; }, value: ["Divide", 1, ["Cosh", "_"]], evalNumber: (e, i) => 1 / Math.cosh(i), evalDecimal: (e, i) => h.div(c.exports.Decimal.cosh(i)), evalComplex: (e, i) => m.exports.Complex.ONE.div(m.exports.Complex.cosh(i)) }, Sinh: { domain: "HyperbolicFunction", range: ["Interval", -1 / 0, 1 / 0], numeric: !0, simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Sinh) && void 0 !== t ? t : ["Multiply", "Half", ["Subtract", ["Exp", i], ["Exp", ["Negate", i]]]]; }, value: ["Multiply", "Half", ["Subtract", ["Exp", "_"], ["Exp", ["Negate", "_"]]]] }, Sin: { domain: "TrigonometricFunction", range: ["Interval", -1, 1], numeric: !0, simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Sin) && void 0 !== t ? t : i; }, value: ["Divide", ["Subtract", ["Exp", ["Multiply", "ImaginaryUnit", "_"]], ["Exp", ["Multiply", "ImaginaryUnit", ["Negate", "_"]]]], ["Multiply", 2, "ImaginaryUnit"]], evalNumber: (e, i) => Math.sin(i), evalDecimal: (e, i) => i.sin(), evalComplex: (e, i) => i.sin() }, Tanh: { domain: "HyperbolicFunction", range: ["Interval", -1 / 0, 1 / 0], numeric: !0, simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Tanh) && void 0 !== t ? t : ["Divide", ["Sinh", i], ["Cosh", i]]; }, value: ["Divide", ["Sinh", "_"], ["Cosh", "_"]], evalNumber: (e, i) => Math.tanh(i), evalDecimal: (e, i) => i.tanh(), evalComplex: (e, i) => i.tanh() }, Tan: { domain: "TrigonometricFunction", range: "RealNumber", numeric: !0, simplify: (e, i) => { var n, t; return null !== (t = null === (n = di.get(i)) || void 0 === n ? void 0 : n.Tan) && void 0 !== t ? t : ["Divide", ["Sin", i], ["Cos", i]]; }, value: ["Divide", ["Sin", "_"], ["Cos", "_"]], evalNumber: (e, i) => Math.tan(i), evalDecimal: (e, i) => i.tan(), evalComplex: (e, i) => i.tan() }, ToPolarCoordinates: { domain: "Function", range: ["TupleOf", "RealNumber", "RealNumber"] } };
|
38976 | ({ arithmetic: Ee, algebra: {}, calculus: {}, combinatorics: {}, complex: {}, core: { Apply: { domain: "Function", range: "Anything" }, About: { domain: "Function", range: "Dictionary" }, BaseForm: { domain: "Function", range: "Integer" }, Block: { domain: "Function", range: "Anything" }, Domain: { domain: "ParametricDomain", range: "Domain" }, Evaluate: { domain: "Function", range: "Anything" }, Parentheses: { domain: "Function", threadable: !0, pure: !1, range: "Anything" }, Head: { domain: "Function", range: "Anything" }, Lambda: { domain: "Function", wikidata: "Q567612", hold: "all", range: "Anything" }, Latex: { domain: "Function", range: "String" }, String: { domain: "Function", threadable: !0, range: "String" }, Symbol: { domain: "Function", threadable: !0, range: "Symbol" }, Tail: { domain: "Function", range: "List" } }, collections: { EmptySet: { domain: "EmptySet", constant: !0, wikidata: "Q226183" }, CartesianProduct: { domain: "Function", wikidata: "Q173740", range: "Set", evaluate: function (e, i, n) { return "EmptySet"; } }, Intersection: { domain: "Function", wikidata: "Q185837", threadable: !0, associative: !0, commutative: !0, idempotent: !0, involution: !0, range: "Set", evaluate: function (e, ...i) { return "EmptySet"; } }, Complement: { domain: "Function", wikidata: "Q242767", range: "Set" }, Union: { domain: "Function", wikidata: "Q185359", threadable: !0, associative: !0, commutative: !0, idempotent: !0, involution: !0, range: "Set", evaluate: function (e, ...i) { return "EmptySet"; } }, SymmetricDifference: { domain: "Function", wikidata: "Q1147242", range: "Set" }, Subset: { domain: "Predicate", range: "MaybeBoolean", evaluate: function (e, i, n) { return "False"; } }, SubsetEqual: { domain: "Predicate", range: "MaybeBoolean", evaluate: function (e, i, n) { return "False"; } }, SetMinus: { domain: "Function", wikidata: "Q18192442", range: "MaybeBoolean", evaluate: function (e, i, n) { return "EmptySet"; } } }, domains: function () { var e; const i = { Nothing: { countable: !0, supersets: [], domain: "Domain" } }; for (const n of Object.keys(ii)) {
|
38977 | const t = Array.isArray(ii[n]) ? ii[n] : [ii[n]];
|
38978 | i[n] = null !== (e = oi[n]) && void 0 !== e ? e : {}, i[n] = { domain: oi[n] ? "ParametricDomain" : "Domain", wikidata: ni[n], supersets: t, value: ti, countable: void 0 !== ri[n], size: () => ri[n], ...i[n] };
|
38979 | for (const e of t)
|
38980 | if ("Anything" !== e && !ii[e])
|
38981 | throw new Error(`Unknown parent of domain "${n}": "${e}"`);
|
38982 | } const n = new Set; for (const e of Object.keys(i))
|
38983 | n.add(e); for (const e of Object.keys(i))
|
38984 | for (const t of i[e].supersets)
|
38985 | n.delete(t); n.delete("Nothing"), i.Nothing.supersets = [...n.values()]; for (const e of Object.keys(i)) {
|
38986 | let n = !1, t = 0, r = [e];
|
38987 | for (; t < 512 && !n;) {
|
38988 | const e = r.pop();
|
38989 | n = "Anything" === e, n || (r = [...e, ...i[e].supersets]), t++;
|
38990 | }
|
38991 | if (!n)
|
38992 | throw new Error(`The "${e}" domain cannot reach "Anything"`);
|
38993 | } return i; }(), dimensions: {}, logic: { True: { domain: "Boolean", constant: !0 }, False: { domain: "Boolean", constant: !0 }, Maybe: { domain: "MaybeBoolean", constant: !0 }, And: { domain: "LogicalFunction", threadable: !0, associative: !0, commutative: !0, idempotent: !0, range: "MaybeBoolean" }, Or: { domain: "LogicalFunction", threadable: !0, associative: !0, commutative: !0, idempotent: !0, range: "MaybeBoolean" }, Not: { domain: "LogicalFunction", involution: !0, range: "MaybeBoolean" }, Equivalent: { domain: "LogicalFunction", range: "MaybeBoolean" }, Implies: { domain: "LogicalFunction", range: "MaybeBoolean" }, Exists: { domain: "LogicalFunction", range: "MaybeBoolean" }, Equal: { domain: "LogicalFunction", range: "MaybeBoolean" }, NotEqual: { domain: "Function", wikidata: "Q28113351", commutative: !0, range: "MaybeBoolean" } }, inequalities: {}, intervals: {}, "linear-algebra": {}, numeric: {}, other: {}, polynomials: {}, physics: { "Mu-0": { constant: !0, wikidata: "Q1515261", domain: "RealNumber", value: 125663706212e-17, unit: [L, "H", [R, "m", -1]] } }, relations: {}, rounding: {}, statistics: {}, transcendentals: {}, trigonometry: vi, units: {} });
|
38994 | const Mn = "0.4.2";
|
38995 |
|
38996 | function makeSharedVirtualKeyboard(options) {
|
38997 | new RemoteVirtualKeyboard(options);
|
38998 | }
|
38999 | function convertLatexToMarkup(text, options) {
|
39000 | var _a, _b;
|
39001 | options = options !== null && options !== void 0 ? options : {};
|
39002 | options.mathstyle = (_a = options.mathstyle) !== null && _a !== void 0 ? _a : 'displaystyle';
|
39003 | let letterShapeStyle = (_b = options.letterShapeStyle) !== null && _b !== void 0 ? _b : 'auto';
|
39004 | if (letterShapeStyle === 'auto') {
|
39005 | letterShapeStyle = l10n.locale.startsWith('fr') ? 'french' : 'tex';
|
39006 | }
|
39007 | options.macros = getMacros(options === null || options === void 0 ? void 0 : options.macros);
|
39008 | //
|
39009 | // 1. Parse the formula and return a tree of atoms, e.g. 'genfrac'.
|
39010 | //
|
39011 | const root = new Atom('root', { mode: 'math' });
|
39012 | root.body = typeset(parseLatex(text, {
|
39013 | parseMode: 'math',
|
39014 | macros: options.macros,
|
39015 | registers: options.registers,
|
39016 | mathstyle: options.mathstyle,
|
39017 | onError: options.onError,
|
39018 | colorMap: options.colorMap,
|
39019 | backgroundColorMap: options.backgroundColorMap,
|
39020 | }), { registers: options.registers });
|
39021 | //
|
39022 | // 2. Transform the math atoms into elementary boxes
|
39023 | // for example from genfrac to VBox.
|
39024 | //
|
39025 | const box = root.render(new Context({
|
39026 | macros: options.macros,
|
39027 | registers: getDefaultRegisters(),
|
39028 | smartFence: false,
|
39029 | renderPlaceholder: () => new Box(0xa0, { maxFontSize: 1.0 }),
|
39030 | }, {
|
39031 | fontSize: DEFAULT_FONT_SIZE,
|
39032 | letterShapeStyle: letterShapeStyle,
|
39033 | }, options.mathstyle));
|
39034 | if (!box)
|
39035 | return '';
|
39036 | //
|
39037 | // 3. Adjust to `mord` according to TeX spacing rules
|
39038 | //
|
39039 | adjustInterAtomSpacing(box);
|
39040 | //
|
39041 | // 2. Simplify by coalescing adjacent boxes
|
39042 | // for example, from <span>1</span><span>2</span>
|
39043 | // to <span>12</span>
|
39044 | //
|
39045 | coalesce(box);
|
39046 | //
|
39047 | // 4. Wrap the expression with struts
|
39048 | //
|
39049 | const wrapper = makeStruts(box, { classes: 'ML__mathlive' });
|
39050 | //
|
39051 | // 5. Generate markup
|
39052 | //
|
39053 | return wrapper.toMarkup();
|
39054 | }
|
39055 | function convertLatexToMathMl(latex, options = {}) {
|
39056 | options.macros = getMacros(options === null || options === void 0 ? void 0 : options.macros);
|
39057 | return atomsToMathML(parseLatex(latex, {
|
39058 | parseMode: 'math',
|
39059 | args: () => '',
|
39060 | macros: options.macros,
|
39061 | registers: options.registers,
|
39062 | mathstyle: 'displaystyle',
|
39063 | onError: options.onError,
|
39064 | colorMap: options.colorMap,
|
39065 | backgroundColorMap: options.backgroundColorMap,
|
39066 | }), options);
|
39067 | }
|
39068 | function convertLatexToSpeakableText(latex, options = {}) {
|
39069 | options.macros = getMacros(options === null || options === void 0 ? void 0 : options.macros);
|
39070 | const atoms = parseLatex(latex, {
|
39071 | parseMode: 'math',
|
39072 | macros: options.macros,
|
39073 | registers: options.registers,
|
39074 | mathstyle: 'displaystyle',
|
39075 | onError: options.onError,
|
39076 | colorMap: options.colorMap,
|
39077 | backgroundColorMap: options.backgroundColorMap,
|
39078 | });
|
39079 | return atomToSpeakableText(atoms, options);
|
39080 | }
|
39081 | function renderMathInDocument(options) {
|
39082 | throwIfNotInBrowser();
|
39083 | renderMathInElement(document.body, options);
|
39084 | }
|
39085 | function getElement(element) {
|
39086 | if (typeof element === 'string' && isBrowser()) {
|
39087 | const result = document.getElementById(element);
|
39088 | if (result === null) {
|
39089 | throw new Error(`The element with ID "${element}" could not be found.`);
|
39090 | }
|
39091 | return result;
|
39092 | }
|
39093 | return typeof element === 'string' ? null : element;
|
39094 | }
|
39095 | function renderMathInElement(element, options) {
|
39096 | var _a, _b, _c;
|
39097 | const el = getElement(element);
|
39098 | if (!el)
|
39099 | return;
|
39100 | options = options !== null && options !== void 0 ? options : {};
|
39101 | options.renderToMarkup = (_a = options.renderToMarkup) !== null && _a !== void 0 ? _a : convertLatexToMarkup;
|
39102 | options.renderToMathML = (_b = options.renderToMathML) !== null && _b !== void 0 ? _b : convertLatexToMathMl;
|
39103 | options.renderToSpeakableText =
|
39104 | (_c = options.renderToSpeakableText) !== null && _c !== void 0 ? _c : convertLatexToSpeakableText;
|
39105 | autoRenderMathInElement(el, options);
|
39106 | }
|
39107 | // This SDK_VERSION variable will be replaced during the build process.
|
39108 | const version = {
|
39109 | mathlive: '0.69.8',
|
39110 | computeEngine: Mn,
|
39111 | };
|
39112 | const debug = {
|
39113 | latexToAsciiMath,
|
39114 | asciiMathToLatex,
|
39115 | FUNCTIONS: MathliveDebug.FUNCTIONS,
|
39116 | MATH_SYMBOLS: MathliveDebug.MATH_SYMBOLS,
|
39117 | TEXT_SYMBOLS: MathliveDebug.TEXT_SYMBOLS,
|
39118 | ENVIRONMENTS: MathliveDebug.ENVIRONMENTS,
|
39119 | DEFAULT_KEYBINDINGS: MathliveDebug.DEFAULT_KEYBINDINGS,
|
39120 | getKeybindingMarkup: MathliveDebug.getKeybindingMarkup,
|
39121 | };
|
39122 |
|
39123 | export { MathfieldElement, convertLatexToMarkup, convertLatexToMathMl, convertLatexToSpeakableText, debug, makeSharedVirtualKeyboard, We as parseMathJson, renderMathInDocument, renderMathInElement, Ve as serializeMathJson, version };
|