@nice2dev/ui-math 1.0.22 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -6
- package/dist/index.mjs +245 -245
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ var R = Object.defineProperty;
|
|
|
2
2
|
var T = (e, r, t) => r in e ? R(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
3
|
var S = (e, r, t) => T(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
4
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
|
-
import
|
|
5
|
+
import xe, { useContext, createContext, memo, useState, useEffect, useMemo, useRef, useCallback } from "react";
|
|
6
6
|
const _e = (e, r) => r, te = createContext(_e);
|
|
7
7
|
function Zt() {
|
|
8
8
|
return { t: useContext(te) };
|
|
@@ -15,7 +15,7 @@ createContext({
|
|
|
15
15
|
});
|
|
16
16
|
createContext(null);
|
|
17
17
|
createContext(null);
|
|
18
|
-
const
|
|
18
|
+
const Z = {
|
|
19
19
|
radius: "md",
|
|
20
20
|
shadow: "md",
|
|
21
21
|
fill: "solid",
|
|
@@ -34,7 +34,7 @@ const Q = {
|
|
|
34
34
|
};
|
|
35
35
|
createContext({
|
|
36
36
|
displayStyle: "default",
|
|
37
|
-
variantConfig:
|
|
37
|
+
variantConfig: Z,
|
|
38
38
|
setDisplayStyle: () => {
|
|
39
39
|
}
|
|
40
40
|
});
|
|
@@ -55,23 +55,23 @@ let O = {
|
|
|
55
55
|
enabled: Vt,
|
|
56
56
|
slowRenderThreshold: 16
|
|
57
57
|
};
|
|
58
|
-
const
|
|
58
|
+
const Ae = [], J = /* @__PURE__ */ new Map(), Ne = /* @__PURE__ */ new Map();
|
|
59
59
|
function jt() {
|
|
60
|
-
|
|
60
|
+
Ae.length = 0, J.clear(), Ne.clear();
|
|
61
61
|
}
|
|
62
62
|
function qt(e) {
|
|
63
63
|
const r = O.slowRenderThreshold;
|
|
64
|
-
return
|
|
64
|
+
return Ae.filter((t) => t.actualDuration > r);
|
|
65
65
|
}
|
|
66
66
|
function G(e) {
|
|
67
67
|
return e < 1 ? `${(e * 1e3).toFixed(0)}μs` : e < 1e3 ? `${e.toFixed(2)}ms` : `${(e / 1e3).toFixed(2)}s`;
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
const e = Array.from(J.values()), r = qt(), t = e.reduce((n, i) => n + i.renderCount, 0), a = e.length > 0 ? e.reduce((n, i) => n + i.avgRenderTime, 0) / e.length : 0, o = Array.from(
|
|
69
|
+
function ya() {
|
|
70
|
+
const e = Array.from(J.values()), r = qt(), t = e.reduce((n, i) => n + i.renderCount, 0), a = e.length > 0 ? e.reduce((n, i) => n + i.avgRenderTime, 0) / e.length : 0, o = Array.from(Ne.values());
|
|
71
71
|
return { stats: e, slowRenders: r, totalRenders: t, avgRenderTime: a, marks: o };
|
|
72
72
|
}
|
|
73
73
|
function Ut() {
|
|
74
|
-
const e =
|
|
74
|
+
const e = ya();
|
|
75
75
|
console.group(
|
|
76
76
|
"%c[Nice2Dev Performance Report]",
|
|
77
77
|
"color: var(--nice-info, #6366f1); font-weight: bold; font-size: 14px"
|
|
@@ -98,17 +98,17 @@ function Ut() {
|
|
|
98
98
|
}))
|
|
99
99
|
), console.groupEnd()), console.groupEnd();
|
|
100
100
|
}
|
|
101
|
-
const
|
|
101
|
+
const va = memo(
|
|
102
102
|
({ position: e = "bottom-right", defaultCollapsed: r = !0 }) => {
|
|
103
103
|
const [t, a] = useState(r), [o, n] = useState([]), [i, c] = useState({ used: 0, total: 0 });
|
|
104
104
|
if (useEffect(() => {
|
|
105
105
|
const s = () => {
|
|
106
|
-
const
|
|
107
|
-
n(
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
used:
|
|
111
|
-
total:
|
|
106
|
+
const m = Array.from(J.values());
|
|
107
|
+
n(m.sort((g, w) => w.totalRenderTime - g.totalRenderTime).slice(0, 10));
|
|
108
|
+
const u = window.performance;
|
|
109
|
+
u.memory && c({
|
|
110
|
+
used: u.memory.usedJSHeapSize / 1024 / 1024,
|
|
111
|
+
total: u.memory.totalJSHeapSize / 1024 / 1024
|
|
112
112
|
});
|
|
113
113
|
};
|
|
114
114
|
s();
|
|
@@ -238,19 +238,19 @@ const ba = memo(
|
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
240
|
);
|
|
241
|
-
|
|
241
|
+
va.displayName = "ProfilerOverlay";
|
|
242
242
|
process.env.NODE_ENV;
|
|
243
243
|
createContext(null);
|
|
244
|
-
const
|
|
244
|
+
const st = createContext({
|
|
245
245
|
enabled: !0,
|
|
246
246
|
active: !1,
|
|
247
247
|
run: () => {
|
|
248
248
|
}
|
|
249
249
|
});
|
|
250
|
-
function
|
|
251
|
-
return useContext(
|
|
250
|
+
function Fa() {
|
|
251
|
+
return useContext(st);
|
|
252
252
|
}
|
|
253
|
-
function
|
|
253
|
+
function xl(e, r) {
|
|
254
254
|
if (!e)
|
|
255
255
|
return null;
|
|
256
256
|
if (e === !0)
|
|
@@ -260,7 +260,7 @@ function hl(e, r) {
|
|
|
260
260
|
const t = e.steps ?? r;
|
|
261
261
|
return t && t.length > 0 ? t : null;
|
|
262
262
|
}
|
|
263
|
-
function
|
|
263
|
+
function $a(e, r) {
|
|
264
264
|
return e.map((t) => ({
|
|
265
265
|
target: t.target,
|
|
266
266
|
title: t.titleKey ? r(t.titleKey, t.title ?? "") : t.title ?? "",
|
|
@@ -272,7 +272,7 @@ function Fa(e, r) {
|
|
|
272
272
|
disableInteraction: t.disableInteraction
|
|
273
273
|
}));
|
|
274
274
|
}
|
|
275
|
-
const
|
|
275
|
+
const wl = ({
|
|
276
276
|
steps: e,
|
|
277
277
|
autoStart: r,
|
|
278
278
|
label: t,
|
|
@@ -281,7 +281,7 @@ const bl = ({
|
|
|
281
281
|
style: n,
|
|
282
282
|
"data-testid": i
|
|
283
283
|
}) => {
|
|
284
|
-
const { enabled: c, run: f } =
|
|
284
|
+
const { enabled: c, run: f } = Fa(), { t: s } = Zt();
|
|
285
285
|
if (!c || !e || e.length === 0)
|
|
286
286
|
return null;
|
|
287
287
|
const d = t ?? s("tutorial.startAria", "Start tutorial");
|
|
@@ -294,7 +294,7 @@ const bl = ({
|
|
|
294
294
|
"data-testid": i,
|
|
295
295
|
"aria-label": d,
|
|
296
296
|
title: d,
|
|
297
|
-
onClick: () => f(
|
|
297
|
+
onClick: () => f($a(e, s), { autoStart: r }),
|
|
298
298
|
children: "?"
|
|
299
299
|
}
|
|
300
300
|
);
|
|
@@ -332,7 +332,7 @@ if (typeof document < "u" && !document.getElementById(vt)) {
|
|
|
332
332
|
createContext(null);
|
|
333
333
|
createContext(null);
|
|
334
334
|
createContext(null);
|
|
335
|
-
const
|
|
335
|
+
const fe = {
|
|
336
336
|
space1: "4px",
|
|
337
337
|
space2: "8px",
|
|
338
338
|
space3: "12px",
|
|
@@ -340,7 +340,7 @@ const de = {
|
|
|
340
340
|
space5: "20px",
|
|
341
341
|
space6: "24px",
|
|
342
342
|
space8: "32px"
|
|
343
|
-
},
|
|
343
|
+
}, ue = {
|
|
344
344
|
fontFamily: "'Inter', system-ui, -apple-system, sans-serif",
|
|
345
345
|
fontSizeXs: "0.75rem",
|
|
346
346
|
fontSizeSm: "0.8125rem",
|
|
@@ -352,25 +352,25 @@ const de = {
|
|
|
352
352
|
fontWeightSemibold: 600,
|
|
353
353
|
fontWeightBold: 700,
|
|
354
354
|
lineHeight: 1.5
|
|
355
|
-
},
|
|
355
|
+
}, me = { fast: "120ms ease", normal: "200ms ease", slow: "300ms ease" }, lt = (e) => ({
|
|
356
356
|
color: e,
|
|
357
357
|
radiusSm: "4px",
|
|
358
358
|
radiusMd: "6px",
|
|
359
359
|
radiusLg: "8px",
|
|
360
360
|
radiusXl: "12px",
|
|
361
361
|
radiusFull: "9999px"
|
|
362
|
-
}),
|
|
362
|
+
}), mr = {
|
|
363
363
|
sm: "0 1px 2px rgba(0,0,0,0.05)",
|
|
364
364
|
md: "0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1)",
|
|
365
365
|
lg: "0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1)",
|
|
366
366
|
xl: "0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1)"
|
|
367
|
-
},
|
|
367
|
+
}, fn = {
|
|
368
368
|
sm: "0 1px 2px rgba(0,0,0,0.3)",
|
|
369
369
|
md: "0 4px 6px -1px rgba(0,0,0,0.4)",
|
|
370
370
|
lg: "0 10px 15px -3px rgba(0,0,0,0.4)",
|
|
371
371
|
xl: "0 20px 25px -5px rgba(0,0,0,0.4)"
|
|
372
372
|
};
|
|
373
|
-
function
|
|
373
|
+
function z(e, r, t, a, o) {
|
|
374
374
|
return {
|
|
375
375
|
name: e,
|
|
376
376
|
darkMode: "light",
|
|
@@ -386,11 +386,11 @@ function I(e, r, t, a, o) {
|
|
|
386
386
|
canvas: t.canvas ?? t.primary
|
|
387
387
|
},
|
|
388
388
|
text: { ...a, inverse: a.inverse ?? "#ffffff" },
|
|
389
|
-
borders:
|
|
390
|
-
shadows:
|
|
391
|
-
spacing:
|
|
392
|
-
typography:
|
|
393
|
-
transitions:
|
|
389
|
+
borders: lt(o),
|
|
390
|
+
shadows: mr,
|
|
391
|
+
spacing: fe,
|
|
392
|
+
typography: ue,
|
|
393
|
+
transitions: me
|
|
394
394
|
};
|
|
395
395
|
}
|
|
396
396
|
function V(e, r, t, a, o) {
|
|
@@ -409,14 +409,14 @@ function V(e, r, t, a, o) {
|
|
|
409
409
|
canvas: t.canvas ?? t.primary
|
|
410
410
|
},
|
|
411
411
|
text: { ...a, inverse: a.inverse ?? "#0f172a" },
|
|
412
|
-
borders:
|
|
413
|
-
shadows:
|
|
414
|
-
spacing:
|
|
415
|
-
typography:
|
|
416
|
-
transitions:
|
|
412
|
+
borders: lt(o),
|
|
413
|
+
shadows: fn,
|
|
414
|
+
spacing: fe,
|
|
415
|
+
typography: ue,
|
|
416
|
+
transitions: me
|
|
417
417
|
};
|
|
418
418
|
}
|
|
419
|
-
|
|
419
|
+
z(
|
|
420
420
|
"Slate",
|
|
421
421
|
{
|
|
422
422
|
primary: "#64748b",
|
|
@@ -430,7 +430,7 @@ I(
|
|
|
430
430
|
{ primary: "#1e293b", secondary: "#475569", muted: "#94a3b8" },
|
|
431
431
|
"#cbd5e1"
|
|
432
432
|
);
|
|
433
|
-
|
|
433
|
+
z(
|
|
434
434
|
"Zinc",
|
|
435
435
|
{
|
|
436
436
|
primary: "#71717a",
|
|
@@ -444,7 +444,7 @@ I(
|
|
|
444
444
|
{ primary: "#18181b", secondary: "#3f3f46", muted: "#a1a1aa" },
|
|
445
445
|
"#d4d4d8"
|
|
446
446
|
);
|
|
447
|
-
|
|
447
|
+
z(
|
|
448
448
|
"Stone",
|
|
449
449
|
{
|
|
450
450
|
primary: "#78716c",
|
|
@@ -458,7 +458,7 @@ I(
|
|
|
458
458
|
{ primary: "#1c1917", secondary: "#44403c", muted: "#a8a29e" },
|
|
459
459
|
"#d6d3d1"
|
|
460
460
|
);
|
|
461
|
-
|
|
461
|
+
z(
|
|
462
462
|
"Cool Gray",
|
|
463
463
|
{
|
|
464
464
|
primary: "#6b7280",
|
|
@@ -472,7 +472,7 @@ I(
|
|
|
472
472
|
{ primary: "#111827", secondary: "#374151", muted: "#9ca3af" },
|
|
473
473
|
"#d1d5db"
|
|
474
474
|
);
|
|
475
|
-
|
|
475
|
+
z(
|
|
476
476
|
"Warm Gray",
|
|
477
477
|
{
|
|
478
478
|
primary: "#7c7568",
|
|
@@ -486,7 +486,7 @@ I(
|
|
|
486
486
|
{ primary: "#1f1d19", secondary: "#4a463d", muted: "#a09888" },
|
|
487
487
|
"#d4d0c8"
|
|
488
488
|
);
|
|
489
|
-
|
|
489
|
+
z(
|
|
490
490
|
"Silver",
|
|
491
491
|
{
|
|
492
492
|
primary: "#94a3b8",
|
|
@@ -500,7 +500,7 @@ I(
|
|
|
500
500
|
{ primary: "#334155", secondary: "#64748b", muted: "#94a3b8" },
|
|
501
501
|
"#cbd5e1"
|
|
502
502
|
);
|
|
503
|
-
|
|
503
|
+
z(
|
|
504
504
|
"Charcoal",
|
|
505
505
|
{
|
|
506
506
|
primary: "#374151",
|
|
@@ -514,7 +514,7 @@ I(
|
|
|
514
514
|
{ primary: "#111827", secondary: "#374151", muted: "#6b7280" },
|
|
515
515
|
"#d1d5db"
|
|
516
516
|
);
|
|
517
|
-
|
|
517
|
+
z(
|
|
518
518
|
"Ivory",
|
|
519
519
|
{
|
|
520
520
|
primary: "#92876d",
|
|
@@ -528,7 +528,7 @@ I(
|
|
|
528
528
|
{ primary: "#2b2517", secondary: "#5c5340", muted: "#9c9280" },
|
|
529
529
|
"#ddd8c4"
|
|
530
530
|
);
|
|
531
|
-
|
|
531
|
+
z(
|
|
532
532
|
"Rose",
|
|
533
533
|
{
|
|
534
534
|
primary: "#e11d48",
|
|
@@ -542,7 +542,7 @@ I(
|
|
|
542
542
|
{ primary: "#4c0519", secondary: "#881337", muted: "#f43f5e" },
|
|
543
543
|
"#fda4af"
|
|
544
544
|
);
|
|
545
|
-
|
|
545
|
+
z(
|
|
546
546
|
"Emerald",
|
|
547
547
|
{
|
|
548
548
|
primary: "#059669",
|
|
@@ -556,7 +556,7 @@ I(
|
|
|
556
556
|
{ primary: "#064e3b", secondary: "#065f46", muted: "#34d399" },
|
|
557
557
|
"#6ee7b7"
|
|
558
558
|
);
|
|
559
|
-
|
|
559
|
+
z(
|
|
560
560
|
"Amber",
|
|
561
561
|
{
|
|
562
562
|
primary: "#d97706",
|
|
@@ -570,7 +570,7 @@ I(
|
|
|
570
570
|
{ primary: "#451a03", secondary: "#78350f", muted: "#f59e0b" },
|
|
571
571
|
"#fcd34d"
|
|
572
572
|
);
|
|
573
|
-
|
|
573
|
+
z(
|
|
574
574
|
"Violet",
|
|
575
575
|
{
|
|
576
576
|
primary: "#7c3aed",
|
|
@@ -584,7 +584,7 @@ I(
|
|
|
584
584
|
{ primary: "#2e1065", secondary: "#4c1d95", muted: "#a78bfa" },
|
|
585
585
|
"#c4b5fd"
|
|
586
586
|
);
|
|
587
|
-
|
|
587
|
+
z(
|
|
588
588
|
"Teal",
|
|
589
589
|
{
|
|
590
590
|
primary: "#0d9488",
|
|
@@ -598,7 +598,7 @@ I(
|
|
|
598
598
|
{ primary: "#134e4a", secondary: "#115e59", muted: "#2dd4bf" },
|
|
599
599
|
"#5eead4"
|
|
600
600
|
);
|
|
601
|
-
|
|
601
|
+
z(
|
|
602
602
|
"Indigo",
|
|
603
603
|
{
|
|
604
604
|
primary: "#4f46e5",
|
|
@@ -612,7 +612,7 @@ I(
|
|
|
612
612
|
{ primary: "#1e1b4b", secondary: "#312e81", muted: "#818cf8" },
|
|
613
613
|
"#a5b4fc"
|
|
614
614
|
);
|
|
615
|
-
|
|
615
|
+
z(
|
|
616
616
|
"Cyan",
|
|
617
617
|
{
|
|
618
618
|
primary: "#0891b2",
|
|
@@ -626,7 +626,7 @@ I(
|
|
|
626
626
|
{ primary: "#164e63", secondary: "#155e75", muted: "#22d3ee" },
|
|
627
627
|
"#67e8f9"
|
|
628
628
|
);
|
|
629
|
-
|
|
629
|
+
z(
|
|
630
630
|
"Lime",
|
|
631
631
|
{
|
|
632
632
|
primary: "#65a30d",
|
|
@@ -640,7 +640,7 @@ I(
|
|
|
640
640
|
{ primary: "#1a2e05", secondary: "#365314", muted: "#84cc16" },
|
|
641
641
|
"#bef264"
|
|
642
642
|
);
|
|
643
|
-
|
|
643
|
+
z(
|
|
644
644
|
"Pink",
|
|
645
645
|
{
|
|
646
646
|
primary: "#db2777",
|
|
@@ -654,7 +654,7 @@ I(
|
|
|
654
654
|
{ primary: "#500724", secondary: "#831843", muted: "#f472b6" },
|
|
655
655
|
"#f9a8d4"
|
|
656
656
|
);
|
|
657
|
-
|
|
657
|
+
z(
|
|
658
658
|
"Orange",
|
|
659
659
|
{
|
|
660
660
|
primary: "#ea580c",
|
|
@@ -668,7 +668,7 @@ I(
|
|
|
668
668
|
{ primary: "#431407", secondary: "#7c2d12", muted: "#fb923c" },
|
|
669
669
|
"#fdba74"
|
|
670
670
|
);
|
|
671
|
-
|
|
671
|
+
z(
|
|
672
672
|
"Fuchsia",
|
|
673
673
|
{
|
|
674
674
|
primary: "#c026d3",
|
|
@@ -682,7 +682,7 @@ I(
|
|
|
682
682
|
{ primary: "#4a044e", secondary: "#701a75", muted: "#d946ef" },
|
|
683
683
|
"#e879f9"
|
|
684
684
|
);
|
|
685
|
-
|
|
685
|
+
z(
|
|
686
686
|
"Sky",
|
|
687
687
|
{
|
|
688
688
|
primary: "#0284c7",
|
|
@@ -696,7 +696,7 @@ I(
|
|
|
696
696
|
{ primary: "#0c4a6e", secondary: "#075985", muted: "#38bdf8" },
|
|
697
697
|
"#7dd3fc"
|
|
698
698
|
);
|
|
699
|
-
|
|
699
|
+
z(
|
|
700
700
|
"Ruby",
|
|
701
701
|
{
|
|
702
702
|
primary: "#be123c",
|
|
@@ -710,7 +710,7 @@ I(
|
|
|
710
710
|
{ primary: "#4c0519", secondary: "#881337", muted: "#fb7185" },
|
|
711
711
|
"#fda4af"
|
|
712
712
|
);
|
|
713
|
-
|
|
713
|
+
z(
|
|
714
714
|
"Coral",
|
|
715
715
|
{
|
|
716
716
|
primary: "#f97316",
|
|
@@ -864,7 +864,7 @@ V(
|
|
|
864
864
|
{ primary: "#ecfdf5", secondary: "#6ee7b7", muted: "#047857" },
|
|
865
865
|
"#047857"
|
|
866
866
|
);
|
|
867
|
-
|
|
867
|
+
z(
|
|
868
868
|
"Forest",
|
|
869
869
|
{
|
|
870
870
|
primary: "#166534",
|
|
@@ -878,7 +878,7 @@ I(
|
|
|
878
878
|
{ primary: "#052e16", secondary: "#166534", muted: "#4ade80" },
|
|
879
879
|
"#86efac"
|
|
880
880
|
);
|
|
881
|
-
|
|
881
|
+
z(
|
|
882
882
|
"Ocean",
|
|
883
883
|
{
|
|
884
884
|
primary: "#0369a1",
|
|
@@ -892,7 +892,7 @@ I(
|
|
|
892
892
|
{ primary: "#0c4a6e", secondary: "#0369a1", muted: "#38bdf8" },
|
|
893
893
|
"#7dd3fc"
|
|
894
894
|
);
|
|
895
|
-
|
|
895
|
+
z(
|
|
896
896
|
"Desert",
|
|
897
897
|
{
|
|
898
898
|
primary: "#b45309",
|
|
@@ -906,7 +906,7 @@ I(
|
|
|
906
906
|
{ primary: "#422006", secondary: "#713f12", muted: "#ca8a04" },
|
|
907
907
|
"#fde047"
|
|
908
908
|
);
|
|
909
|
-
|
|
909
|
+
z(
|
|
910
910
|
"Sunset",
|
|
911
911
|
{
|
|
912
912
|
primary: "#ea580c",
|
|
@@ -920,7 +920,7 @@ I(
|
|
|
920
920
|
{ primary: "#431407", secondary: "#9a3412", muted: "#f97316" },
|
|
921
921
|
"#fdba74"
|
|
922
922
|
);
|
|
923
|
-
|
|
923
|
+
z(
|
|
924
924
|
"Aurora",
|
|
925
925
|
{
|
|
926
926
|
primary: "#0d9488",
|
|
@@ -934,7 +934,7 @@ I(
|
|
|
934
934
|
{ primary: "#134e4a", secondary: "#115e59", muted: "#2dd4bf" },
|
|
935
935
|
"#5eead4"
|
|
936
936
|
);
|
|
937
|
-
|
|
937
|
+
z(
|
|
938
938
|
"Lavender",
|
|
939
939
|
{
|
|
940
940
|
primary: "#7e22ce",
|
|
@@ -948,7 +948,7 @@ I(
|
|
|
948
948
|
{ primary: "#3b0764", secondary: "#581c87", muted: "#a855f7" },
|
|
949
949
|
"#d8b4fe"
|
|
950
950
|
);
|
|
951
|
-
|
|
951
|
+
z(
|
|
952
952
|
"Autumn",
|
|
953
953
|
{
|
|
954
954
|
primary: "#c2410c",
|
|
@@ -962,7 +962,7 @@ I(
|
|
|
962
962
|
{ primary: "#450a0a", secondary: "#7f1d1d", muted: "#f87171" },
|
|
963
963
|
"#fca5a5"
|
|
964
964
|
);
|
|
965
|
-
|
|
965
|
+
z(
|
|
966
966
|
"Spring",
|
|
967
967
|
{
|
|
968
968
|
primary: "#16a34a",
|
|
@@ -976,7 +976,7 @@ I(
|
|
|
976
976
|
{ primary: "#14532d", secondary: "#166534", muted: "#4ade80" },
|
|
977
977
|
"#86efac"
|
|
978
978
|
);
|
|
979
|
-
|
|
979
|
+
z(
|
|
980
980
|
"Arctic",
|
|
981
981
|
{
|
|
982
982
|
primary: "#0ea5e9",
|
|
@@ -990,7 +990,7 @@ I(
|
|
|
990
990
|
{ primary: "#0c4a6e", secondary: "#0369a1", muted: "#7dd3fc" },
|
|
991
991
|
"#bae6fd"
|
|
992
992
|
);
|
|
993
|
-
|
|
993
|
+
z(
|
|
994
994
|
"Tropical",
|
|
995
995
|
{
|
|
996
996
|
primary: "#0d9488",
|
|
@@ -1004,7 +1004,7 @@ I(
|
|
|
1004
1004
|
{ primary: "#064e3b", secondary: "#065f46", muted: "#6ee7b7" },
|
|
1005
1005
|
"#a7f3d0"
|
|
1006
1006
|
);
|
|
1007
|
-
|
|
1007
|
+
z(
|
|
1008
1008
|
"Pastel Rose",
|
|
1009
1009
|
{
|
|
1010
1010
|
primary: "#f472b6",
|
|
@@ -1018,7 +1018,7 @@ I(
|
|
|
1018
1018
|
{ primary: "#831843", secondary: "#9d174d", muted: "#f9a8d4" },
|
|
1019
1019
|
"#f9a8d4"
|
|
1020
1020
|
);
|
|
1021
|
-
|
|
1021
|
+
z(
|
|
1022
1022
|
"Pastel Sky",
|
|
1023
1023
|
{
|
|
1024
1024
|
primary: "#38bdf8",
|
|
@@ -1032,7 +1032,7 @@ I(
|
|
|
1032
1032
|
{ primary: "#075985", secondary: "#0369a1", muted: "#7dd3fc" },
|
|
1033
1033
|
"#bae6fd"
|
|
1034
1034
|
);
|
|
1035
|
-
|
|
1035
|
+
z(
|
|
1036
1036
|
"Pastel Mint",
|
|
1037
1037
|
{
|
|
1038
1038
|
primary: "#34d399",
|
|
@@ -1046,7 +1046,7 @@ I(
|
|
|
1046
1046
|
{ primary: "#065f46", secondary: "#047857", muted: "#6ee7b7" },
|
|
1047
1047
|
"#a7f3d0"
|
|
1048
1048
|
);
|
|
1049
|
-
|
|
1049
|
+
z(
|
|
1050
1050
|
"Pastel Peach",
|
|
1051
1051
|
{
|
|
1052
1052
|
primary: "#fb923c",
|
|
@@ -1060,7 +1060,7 @@ I(
|
|
|
1060
1060
|
{ primary: "#7c2d12", secondary: "#9a3412", muted: "#fdba74" },
|
|
1061
1061
|
"#fed7aa"
|
|
1062
1062
|
);
|
|
1063
|
-
|
|
1063
|
+
z(
|
|
1064
1064
|
"Pastel Lavender",
|
|
1065
1065
|
{
|
|
1066
1066
|
primary: "#a78bfa",
|
|
@@ -1074,7 +1074,7 @@ I(
|
|
|
1074
1074
|
{ primary: "#4c1d95", secondary: "#5b21b6", muted: "#c4b5fd" },
|
|
1075
1075
|
"#ddd6fe"
|
|
1076
1076
|
);
|
|
1077
|
-
|
|
1077
|
+
z(
|
|
1078
1078
|
"Pastel Lemon",
|
|
1079
1079
|
{
|
|
1080
1080
|
primary: "#facc15",
|
|
@@ -1088,7 +1088,7 @@ I(
|
|
|
1088
1088
|
{ primary: "#713f12", secondary: "#854d0e", muted: "#fde047" },
|
|
1089
1089
|
"#fef08a"
|
|
1090
1090
|
);
|
|
1091
|
-
|
|
1091
|
+
z(
|
|
1092
1092
|
"Pastel Sage",
|
|
1093
1093
|
{
|
|
1094
1094
|
primary: "#86efac",
|
|
@@ -1102,7 +1102,7 @@ I(
|
|
|
1102
1102
|
{ primary: "#166534", secondary: "#15803d", muted: "#86efac" },
|
|
1103
1103
|
"#bbf7d0"
|
|
1104
1104
|
);
|
|
1105
|
-
|
|
1105
|
+
z(
|
|
1106
1106
|
"Pastel Coral",
|
|
1107
1107
|
{
|
|
1108
1108
|
primary: "#fb7185",
|
|
@@ -1116,7 +1116,7 @@ I(
|
|
|
1116
1116
|
{ primary: "#881337", secondary: "#9f1239", muted: "#fda4af" },
|
|
1117
1117
|
"#fecdd3"
|
|
1118
1118
|
);
|
|
1119
|
-
|
|
1119
|
+
z(
|
|
1120
1120
|
"Banking",
|
|
1121
1121
|
{
|
|
1122
1122
|
primary: "#1e3a5f",
|
|
@@ -1130,7 +1130,7 @@ I(
|
|
|
1130
1130
|
{ primary: "#0f172a", secondary: "#334155", muted: "#94a3b8" },
|
|
1131
1131
|
"#cbd5e1"
|
|
1132
1132
|
);
|
|
1133
|
-
|
|
1133
|
+
z(
|
|
1134
1134
|
"Healthcare",
|
|
1135
1135
|
{
|
|
1136
1136
|
primary: "#0891b2",
|
|
@@ -1144,7 +1144,7 @@ I(
|
|
|
1144
1144
|
{ primary: "#134e4a", secondary: "#1a6b6a", muted: "#80cbc4" },
|
|
1145
1145
|
"#b2dfdb"
|
|
1146
1146
|
);
|
|
1147
|
-
|
|
1147
|
+
z(
|
|
1148
1148
|
"Legal",
|
|
1149
1149
|
{
|
|
1150
1150
|
primary: "#1e293b",
|
|
@@ -1158,7 +1158,7 @@ I(
|
|
|
1158
1158
|
{ primary: "#0f172a", secondary: "#44403c", muted: "#a8a29e" },
|
|
1159
1159
|
"#d6d3d1"
|
|
1160
1160
|
);
|
|
1161
|
-
|
|
1161
|
+
z(
|
|
1162
1162
|
"Tech Startup",
|
|
1163
1163
|
{
|
|
1164
1164
|
primary: "#7c3aed",
|
|
@@ -1172,7 +1172,7 @@ I(
|
|
|
1172
1172
|
{ primary: "#1e1b4b", secondary: "#4c1d95", muted: "#a78bfa" },
|
|
1173
1173
|
"#c4b5fd"
|
|
1174
1174
|
);
|
|
1175
|
-
|
|
1175
|
+
z(
|
|
1176
1176
|
"Enterprise",
|
|
1177
1177
|
{
|
|
1178
1178
|
primary: "#1e40af",
|
|
@@ -1186,7 +1186,7 @@ I(
|
|
|
1186
1186
|
{ primary: "#1e3a5f", secondary: "#1e40af", muted: "#60a5fa" },
|
|
1187
1187
|
"#93c5fd"
|
|
1188
1188
|
);
|
|
1189
|
-
|
|
1189
|
+
z(
|
|
1190
1190
|
"Government",
|
|
1191
1191
|
{
|
|
1192
1192
|
primary: "#1d4ed8",
|
|
@@ -1200,7 +1200,7 @@ I(
|
|
|
1200
1200
|
{ primary: "#0f172a", secondary: "#1e293b", muted: "#64748b" },
|
|
1201
1201
|
"#cbd5e1"
|
|
1202
1202
|
);
|
|
1203
|
-
|
|
1203
|
+
z(
|
|
1204
1204
|
"Education",
|
|
1205
1205
|
{
|
|
1206
1206
|
primary: "#059669",
|
|
@@ -1214,7 +1214,7 @@ I(
|
|
|
1214
1214
|
{ primary: "#064e3b", secondary: "#065f46", muted: "#6ee7b7" },
|
|
1215
1215
|
"#a7f3d0"
|
|
1216
1216
|
);
|
|
1217
|
-
|
|
1217
|
+
z(
|
|
1218
1218
|
"Real Estate",
|
|
1219
1219
|
{
|
|
1220
1220
|
primary: "#92400e",
|
|
@@ -1228,7 +1228,7 @@ I(
|
|
|
1228
1228
|
{ primary: "#422006", secondary: "#713f12", muted: "#d97706" },
|
|
1229
1229
|
"#fcd34d"
|
|
1230
1230
|
);
|
|
1231
|
-
|
|
1231
|
+
z(
|
|
1232
1232
|
"Nord",
|
|
1233
1233
|
{
|
|
1234
1234
|
primary: "#5e81ac",
|
|
@@ -1256,7 +1256,7 @@ V(
|
|
|
1256
1256
|
{ primary: "#f8f8f2", secondary: "#c0c0c0", muted: "#6272a4" },
|
|
1257
1257
|
"#44475a"
|
|
1258
1258
|
);
|
|
1259
|
-
|
|
1259
|
+
z(
|
|
1260
1260
|
"Solarized Light",
|
|
1261
1261
|
{
|
|
1262
1262
|
primary: "#268bd2",
|
|
@@ -1326,7 +1326,7 @@ V(
|
|
|
1326
1326
|
{ primary: "#f0e4fc", secondary: "#b4a0cc", muted: "#6c5c84" },
|
|
1327
1327
|
"#4a3866"
|
|
1328
1328
|
);
|
|
1329
|
-
|
|
1329
|
+
z(
|
|
1330
1330
|
"Vaporwave",
|
|
1331
1331
|
{
|
|
1332
1332
|
primary: "#ff71ce",
|
|
@@ -1354,7 +1354,7 @@ V(
|
|
|
1354
1354
|
{ primary: "#00ff41", secondary: "#00cc33", muted: "#008822" },
|
|
1355
1355
|
"#003300"
|
|
1356
1356
|
);
|
|
1357
|
-
|
|
1357
|
+
z(
|
|
1358
1358
|
"Sepia",
|
|
1359
1359
|
{
|
|
1360
1360
|
primary: "#8b6914",
|
|
@@ -1368,7 +1368,7 @@ I(
|
|
|
1368
1368
|
{ primary: "#3e2723", secondary: "#5d4037", muted: "#a1887f" },
|
|
1369
1369
|
"#d7ccc8"
|
|
1370
1370
|
);
|
|
1371
|
-
|
|
1371
|
+
z(
|
|
1372
1372
|
"Vintage",
|
|
1373
1373
|
{
|
|
1374
1374
|
primary: "#8d6e63",
|
|
@@ -1424,7 +1424,7 @@ V(
|
|
|
1424
1424
|
{ primary: "#ffe6f7", secondary: "#c9a0c9", muted: "#6b4c7a" },
|
|
1425
1425
|
"#4a2d66"
|
|
1426
1426
|
);
|
|
1427
|
-
|
|
1427
|
+
z(
|
|
1428
1428
|
"Christmas",
|
|
1429
1429
|
{
|
|
1430
1430
|
primary: "#c41e3a",
|
|
@@ -1452,7 +1452,7 @@ V(
|
|
|
1452
1452
|
{ primary: "#ffedd5", secondary: "#fdba74", muted: "#9a5c28" },
|
|
1453
1453
|
"#5c3400"
|
|
1454
1454
|
);
|
|
1455
|
-
|
|
1455
|
+
z(
|
|
1456
1456
|
"Valentine",
|
|
1457
1457
|
{
|
|
1458
1458
|
primary: "#e11d48",
|
|
@@ -1466,7 +1466,7 @@ I(
|
|
|
1466
1466
|
{ primary: "#4c0519", secondary: "#881337", muted: "#f9a8d4" },
|
|
1467
1467
|
"#fda4af"
|
|
1468
1468
|
);
|
|
1469
|
-
|
|
1469
|
+
z(
|
|
1470
1470
|
"Easter",
|
|
1471
1471
|
{
|
|
1472
1472
|
primary: "#a78bfa",
|
|
@@ -1480,7 +1480,7 @@ I(
|
|
|
1480
1480
|
{ primary: "#581c87", secondary: "#6d28d9", muted: "#c4b5fd" },
|
|
1481
1481
|
"#ddd6fe"
|
|
1482
1482
|
);
|
|
1483
|
-
|
|
1483
|
+
z(
|
|
1484
1484
|
"Summer Beach",
|
|
1485
1485
|
{
|
|
1486
1486
|
primary: "#0ea5e9",
|
|
@@ -1494,7 +1494,7 @@ I(
|
|
|
1494
1494
|
{ primary: "#0c4a6e", secondary: "#0369a1", muted: "#7dd3fc" },
|
|
1495
1495
|
"#fcd34d"
|
|
1496
1496
|
);
|
|
1497
|
-
|
|
1497
|
+
z(
|
|
1498
1498
|
"Winter Frost",
|
|
1499
1499
|
{
|
|
1500
1500
|
primary: "#3b82f6",
|
|
@@ -1508,7 +1508,7 @@ I(
|
|
|
1508
1508
|
{ primary: "#1e3a5f", secondary: "#1e40af", muted: "#93c5fd" },
|
|
1509
1509
|
"#bfdbfe"
|
|
1510
1510
|
);
|
|
1511
|
-
|
|
1511
|
+
z(
|
|
1512
1512
|
"Cherry Blossom",
|
|
1513
1513
|
{
|
|
1514
1514
|
primary: "#ec4899",
|
|
@@ -1522,7 +1522,7 @@ I(
|
|
|
1522
1522
|
{ primary: "#831843", secondary: "#9d174d", muted: "#f9a8d4" },
|
|
1523
1523
|
"#fbcfe8"
|
|
1524
1524
|
);
|
|
1525
|
-
|
|
1525
|
+
z(
|
|
1526
1526
|
"Harvest",
|
|
1527
1527
|
{
|
|
1528
1528
|
primary: "#b45309",
|
|
@@ -1536,7 +1536,7 @@ I(
|
|
|
1536
1536
|
{ primary: "#451a03", secondary: "#78350f", muted: "#d97706" },
|
|
1537
1537
|
"#fcd34d"
|
|
1538
1538
|
);
|
|
1539
|
-
|
|
1539
|
+
z(
|
|
1540
1540
|
"Japanese Zen",
|
|
1541
1541
|
{
|
|
1542
1542
|
primary: "#6b7280",
|
|
@@ -1550,7 +1550,7 @@ I(
|
|
|
1550
1550
|
{ primary: "#2c2c2c", secondary: "#5c5c5c", muted: "#a0998a" },
|
|
1551
1551
|
"#d5cec0"
|
|
1552
1552
|
);
|
|
1553
|
-
|
|
1553
|
+
z(
|
|
1554
1554
|
"Moroccan",
|
|
1555
1555
|
{
|
|
1556
1556
|
primary: "#c2410c",
|
|
@@ -1564,7 +1564,7 @@ I(
|
|
|
1564
1564
|
{ primary: "#3a1a00", secondary: "#7c2d12", muted: "#d97706" },
|
|
1565
1565
|
"#f5d0a0"
|
|
1566
1566
|
);
|
|
1567
|
-
|
|
1567
|
+
z(
|
|
1568
1568
|
"Scandinavian",
|
|
1569
1569
|
{
|
|
1570
1570
|
primary: "#4b5563",
|
|
@@ -1578,7 +1578,7 @@ I(
|
|
|
1578
1578
|
{ primary: "#111827", secondary: "#374151", muted: "#9ca3af" },
|
|
1579
1579
|
"#e5e7eb"
|
|
1580
1580
|
);
|
|
1581
|
-
|
|
1581
|
+
z(
|
|
1582
1582
|
"Mediterranean",
|
|
1583
1583
|
{
|
|
1584
1584
|
primary: "#1e40af",
|
|
@@ -1592,7 +1592,7 @@ I(
|
|
|
1592
1592
|
{ primary: "#1e3a5f", secondary: "#2563eb", muted: "#93c5fd" },
|
|
1593
1593
|
"#bfdbfe"
|
|
1594
1594
|
);
|
|
1595
|
-
|
|
1595
|
+
z(
|
|
1596
1596
|
"Chinese New Year",
|
|
1597
1597
|
{
|
|
1598
1598
|
primary: "#dc2626",
|
|
@@ -1606,7 +1606,7 @@ I(
|
|
|
1606
1606
|
{ primary: "#450a0a", secondary: "#991b1b", muted: "#f87171" },
|
|
1607
1607
|
"#fca5a5"
|
|
1608
1608
|
);
|
|
1609
|
-
|
|
1609
|
+
z(
|
|
1610
1610
|
"Indian Festive",
|
|
1611
1611
|
{
|
|
1612
1612
|
primary: "#d97706",
|
|
@@ -1620,7 +1620,7 @@ I(
|
|
|
1620
1620
|
{ primary: "#451a03", secondary: "#92400e", muted: "#f59e0b" },
|
|
1621
1621
|
"#fcd34d"
|
|
1622
1622
|
);
|
|
1623
|
-
|
|
1623
|
+
z(
|
|
1624
1624
|
"Brazilian Carnival",
|
|
1625
1625
|
{
|
|
1626
1626
|
primary: "#16a34a",
|
|
@@ -1634,7 +1634,7 @@ I(
|
|
|
1634
1634
|
{ primary: "#052e16", secondary: "#166534", muted: "#4ade80" },
|
|
1635
1635
|
"#86efac"
|
|
1636
1636
|
);
|
|
1637
|
-
|
|
1637
|
+
z(
|
|
1638
1638
|
"African Earth",
|
|
1639
1639
|
{
|
|
1640
1640
|
primary: "#92400e",
|
|
@@ -1662,7 +1662,7 @@ V(
|
|
|
1662
1662
|
{ primary: "#ffffff", secondary: "#ffffff", muted: "#cccccc" },
|
|
1663
1663
|
"#ffffff"
|
|
1664
1664
|
);
|
|
1665
|
-
|
|
1665
|
+
z(
|
|
1666
1666
|
"Monochrome",
|
|
1667
1667
|
{
|
|
1668
1668
|
primary: "#404040",
|
|
@@ -1676,7 +1676,7 @@ I(
|
|
|
1676
1676
|
{ primary: "#1a1a1a", secondary: "#404040", muted: "#808080" },
|
|
1677
1677
|
"#c0c0c0"
|
|
1678
1678
|
);
|
|
1679
|
-
|
|
1679
|
+
z(
|
|
1680
1680
|
"Enhanced Contrast",
|
|
1681
1681
|
{
|
|
1682
1682
|
primary: "#0050b3",
|
|
@@ -1690,7 +1690,7 @@ I(
|
|
|
1690
1690
|
{ primary: "#000000", secondary: "#1a1a1a", muted: "#595959" },
|
|
1691
1691
|
"#8c8c8c"
|
|
1692
1692
|
);
|
|
1693
|
-
|
|
1693
|
+
z(
|
|
1694
1694
|
"Minimalist",
|
|
1695
1695
|
{
|
|
1696
1696
|
primary: "#18181b",
|
|
@@ -1732,7 +1732,7 @@ V(
|
|
|
1732
1732
|
{ primary: "#e8e8f0", secondary: "#a0a0b8", muted: "#5c5c74" },
|
|
1733
1733
|
"#3e3e58"
|
|
1734
1734
|
);
|
|
1735
|
-
|
|
1735
|
+
z(
|
|
1736
1736
|
"Coffee",
|
|
1737
1737
|
{
|
|
1738
1738
|
primary: "#6f4e37",
|
|
@@ -1746,7 +1746,7 @@ I(
|
|
|
1746
1746
|
{ primary: "#2c1a0e", secondary: "#5c3d28", muted: "#a08868" },
|
|
1747
1747
|
"#d4c4a8"
|
|
1748
1748
|
);
|
|
1749
|
-
|
|
1749
|
+
z(
|
|
1750
1750
|
"Wine",
|
|
1751
1751
|
{
|
|
1752
1752
|
primary: "#7f1d1d",
|
|
@@ -1924,7 +1924,7 @@ function NiceI18nProvider({ locale: e = "en", overrides: r, children: t }) {
|
|
|
1924
1924
|
const o = { ...translations.en, ...translations[e], ...r };
|
|
1925
1925
|
return { locale: e, t: (i, c) => o[i] ?? c ?? i };
|
|
1926
1926
|
}, [e, r]);
|
|
1927
|
-
return
|
|
1927
|
+
return xe.createElement(I18nContext.Provider, { value: a }, t);
|
|
1928
1928
|
}
|
|
1929
1929
|
function useNiceTranslation() {
|
|
1930
1930
|
return useContext(I18nContext);
|
|
@@ -2379,24 +2379,24 @@ function NiceMathEditor({
|
|
|
2379
2379
|
style: o,
|
|
2380
2380
|
tutorial: n
|
|
2381
2381
|
}) {
|
|
2382
|
-
const { t: i } = useNiceTranslation(), [c, f] = useState(r), [s, d] = useState("input"),
|
|
2382
|
+
const { t: i } = useNiceTranslation(), [c, f] = useState(r), [s, d] = useState("input"), m = useRef(null), u = useCallback(
|
|
2383
2383
|
(b) => {
|
|
2384
2384
|
f(b), t == null || t(b);
|
|
2385
2385
|
},
|
|
2386
2386
|
[t]
|
|
2387
2387
|
), g = useCallback(
|
|
2388
2388
|
(b) => {
|
|
2389
|
-
const l =
|
|
2389
|
+
const l = m.current;
|
|
2390
2390
|
if (!l) {
|
|
2391
|
-
|
|
2391
|
+
u(c + b);
|
|
2392
2392
|
return;
|
|
2393
2393
|
}
|
|
2394
|
-
const p = l.selectionStart, h = l.selectionEnd,
|
|
2395
|
-
|
|
2394
|
+
const p = l.selectionStart, h = l.selectionEnd, k = c.slice(0, p) + b + c.slice(h);
|
|
2395
|
+
u(k), setTimeout(() => {
|
|
2396
2396
|
l.focus(), l.selectionStart = l.selectionEnd = p + b.length;
|
|
2397
2397
|
}, 0);
|
|
2398
2398
|
},
|
|
2399
|
-
[c,
|
|
2399
|
+
[c, u]
|
|
2400
2400
|
), w = useCallback(
|
|
2401
2401
|
(b) => {
|
|
2402
2402
|
g(b.latex);
|
|
@@ -2405,7 +2405,7 @@ function NiceMathEditor({
|
|
|
2405
2405
|
), y = {
|
|
2406
2406
|
service: e,
|
|
2407
2407
|
latex: c,
|
|
2408
|
-
setLatex:
|
|
2408
|
+
setLatex: u,
|
|
2409
2409
|
insertSymbol: g,
|
|
2410
2410
|
insertTemplate: w,
|
|
2411
2411
|
mode: s,
|
|
@@ -2417,7 +2417,7 @@ function NiceMathEditor({
|
|
|
2417
2417
|
className: `nice-math-editor ${a ?? ""}`,
|
|
2418
2418
|
style: { position: "relative", ...styles$3.container, ...o },
|
|
2419
2419
|
children: [
|
|
2420
|
-
/* @__PURE__ */ jsx("span", { style: { position: "absolute", top: 6, right: 6, zIndex: 30 }, children: /* @__PURE__ */ jsx(
|
|
2420
|
+
/* @__PURE__ */ jsx("span", { style: { position: "absolute", top: 6, right: 6, zIndex: 30 }, children: /* @__PURE__ */ jsx(wl, { steps: xl(n, MATH_EDITOR_TOUR) }) }),
|
|
2421
2421
|
/* @__PURE__ */ jsx(Toolbar$1, {}),
|
|
2422
2422
|
/* @__PURE__ */ jsxs("div", { style: styles$3.main, children: [
|
|
2423
2423
|
/* @__PURE__ */ jsx(SymbolPalette, {}),
|
|
@@ -2425,9 +2425,9 @@ function NiceMathEditor({
|
|
|
2425
2425
|
/* @__PURE__ */ jsx(
|
|
2426
2426
|
"textarea",
|
|
2427
2427
|
{
|
|
2428
|
-
ref:
|
|
2428
|
+
ref: m,
|
|
2429
2429
|
value: c,
|
|
2430
|
-
onChange: (b) =>
|
|
2430
|
+
onChange: (b) => u(b.target.value),
|
|
2431
2431
|
placeholder: i("editor.latexPlaceholder", "Enter LaTeX equation..."),
|
|
2432
2432
|
style: styles$3.input
|
|
2433
2433
|
}
|
|
@@ -2601,7 +2601,7 @@ function LatexPreview({ latex: e }) {
|
|
|
2601
2601
|
] });
|
|
2602
2602
|
}
|
|
2603
2603
|
function HandwritingCanvas() {
|
|
2604
|
-
const { t: e } = useNiceTranslation(), { setLatex: r, setMode: t } = useMathEditor(), a = useRef(null), [o, n] = useState([]), [i, c] = useState([]), [f, s] = useState(!1), [d,
|
|
2604
|
+
const { t: e } = useNiceTranslation(), { setLatex: r, setMode: t } = useMathEditor(), a = useRef(null), [o, n] = useState([]), [i, c] = useState([]), [f, s] = useState(!1), [d, m] = useState(!1), u = (l) => {
|
|
2605
2605
|
const p = a.current;
|
|
2606
2606
|
if (!p)
|
|
2607
2607
|
return;
|
|
@@ -2621,9 +2621,9 @@ function HandwritingCanvas() {
|
|
|
2621
2621
|
const p = a.current, h = p == null ? void 0 : p.getContext("2d");
|
|
2622
2622
|
if (!p || !h)
|
|
2623
2623
|
return;
|
|
2624
|
-
const
|
|
2625
|
-
x: l.clientX -
|
|
2626
|
-
y: l.clientY -
|
|
2624
|
+
const k = p.getBoundingClientRect(), x = {
|
|
2625
|
+
x: l.clientX - k.left,
|
|
2626
|
+
y: l.clientY - k.top,
|
|
2627
2627
|
pressure: l.pressure,
|
|
2628
2628
|
timestamp: Date.now()
|
|
2629
2629
|
};
|
|
@@ -2647,12 +2647,12 @@ function HandwritingCanvas() {
|
|
|
2647
2647
|
p && l && p.clearRect(0, 0, l.width, l.height), n([]);
|
|
2648
2648
|
}, b = async () => {
|
|
2649
2649
|
if (o.length !== 0) {
|
|
2650
|
-
|
|
2650
|
+
m(!0);
|
|
2651
2651
|
try {
|
|
2652
2652
|
const l = await recognizeHandwriting(o);
|
|
2653
2653
|
r(l.latex), t("input");
|
|
2654
2654
|
} finally {
|
|
2655
|
-
|
|
2655
|
+
m(!1);
|
|
2656
2656
|
}
|
|
2657
2657
|
}
|
|
2658
2658
|
};
|
|
@@ -2665,7 +2665,7 @@ function HandwritingCanvas() {
|
|
|
2665
2665
|
{
|
|
2666
2666
|
ref: a,
|
|
2667
2667
|
style: styles$3.canvas,
|
|
2668
|
-
onPointerDown:
|
|
2668
|
+
onPointerDown: u,
|
|
2669
2669
|
onPointerMove: g,
|
|
2670
2670
|
onPointerUp: w,
|
|
2671
2671
|
onPointerLeave: w
|
|
@@ -2908,10 +2908,10 @@ class GraphService {
|
|
|
2908
2908
|
compute2DParametric(r, t, a, o, n) {
|
|
2909
2909
|
const i = this.parser.parse(r), c = this.parser.parse(t), f = [], s = (a.max - a.min) / o;
|
|
2910
2910
|
for (let d = 0; d <= o; d++) {
|
|
2911
|
-
const
|
|
2911
|
+
const m = a.min + d * s;
|
|
2912
2912
|
try {
|
|
2913
|
-
const
|
|
2914
|
-
Number.isFinite(
|
|
2913
|
+
const u = i({ t: m, ...n }), g = c({ t: m, ...n });
|
|
2914
|
+
Number.isFinite(u) && Number.isFinite(g) && f.push({ x: u, y: g });
|
|
2915
2915
|
} catch {
|
|
2916
2916
|
}
|
|
2917
2917
|
}
|
|
@@ -2925,8 +2925,8 @@ class GraphService {
|
|
|
2925
2925
|
try {
|
|
2926
2926
|
const d = n({ theta: s, t: s, ...o });
|
|
2927
2927
|
if (Number.isFinite(d)) {
|
|
2928
|
-
const
|
|
2929
|
-
i.push({ x:
|
|
2928
|
+
const m = d * Math.cos(s), u = d * Math.sin(s);
|
|
2929
|
+
i.push({ x: m, y: u });
|
|
2930
2930
|
}
|
|
2931
2931
|
} catch {
|
|
2932
2932
|
}
|
|
@@ -2937,50 +2937,50 @@ class GraphService {
|
|
|
2937
2937
|
compute3DSurface(r, t, a, o, n) {
|
|
2938
2938
|
const i = this.parser.parse(r), c = [], f = (t.max - t.min) / o, s = (a.max - a.min) / o;
|
|
2939
2939
|
for (let d = 0; d <= o; d++) {
|
|
2940
|
-
const
|
|
2940
|
+
const m = [], u = t.min + d * f;
|
|
2941
2941
|
for (let g = 0; g <= o; g++) {
|
|
2942
2942
|
const w = a.min + g * s;
|
|
2943
2943
|
try {
|
|
2944
|
-
const y = i({ x:
|
|
2945
|
-
Number.isFinite(y) ?
|
|
2944
|
+
const y = i({ x: u, y: w, ...n });
|
|
2945
|
+
Number.isFinite(y) ? m.push({ x: u, y: w, z: y }) : m.push({ x: u, y: w, z: 0 });
|
|
2946
2946
|
} catch {
|
|
2947
|
-
|
|
2947
|
+
m.push({ x: u, y: w, z: 0 });
|
|
2948
2948
|
}
|
|
2949
2949
|
}
|
|
2950
|
-
c.push(
|
|
2950
|
+
c.push(m);
|
|
2951
2951
|
}
|
|
2952
2952
|
return c;
|
|
2953
2953
|
}
|
|
2954
2954
|
/** Export plot data as SVG */
|
|
2955
2955
|
exportSVG(r, t, a, o) {
|
|
2956
|
-
const i = a - 80, c = o - 40 * 2, f = (
|
|
2956
|
+
const i = a - 80, c = o - 40 * 2, f = (m) => 40 + (m - t.xRange.min) / (t.xRange.max - t.xRange.min) * i, s = (m) => o - 40 - (m - t.yRange.min) / (t.yRange.max - t.yRange.min) * c, d = [
|
|
2957
2957
|
`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${o}">`,
|
|
2958
2958
|
`<rect width="100%" height="100%" fill="rgb(${t.backgroundColor.r},${t.backgroundColor.g},${t.backgroundColor.b})"/>`
|
|
2959
2959
|
];
|
|
2960
2960
|
if (t.showGrid) {
|
|
2961
2961
|
d.push('<g stroke="var(--nice-border, #ddd)" stroke-width="0.5">');
|
|
2962
|
-
for (let
|
|
2963
|
-
const
|
|
2964
|
-
d.push(`<line x1="${
|
|
2962
|
+
for (let m = Math.ceil(t.xRange.min); m <= t.xRange.max; m++) {
|
|
2963
|
+
const u = f(m);
|
|
2964
|
+
d.push(`<line x1="${u}" y1="40" x2="${u}" y2="${o - 40}"/>`);
|
|
2965
2965
|
}
|
|
2966
|
-
for (let
|
|
2967
|
-
const
|
|
2968
|
-
d.push(`<line x1="40" y1="${
|
|
2966
|
+
for (let m = Math.ceil(t.yRange.min); m <= t.yRange.max; m++) {
|
|
2967
|
+
const u = s(m);
|
|
2968
|
+
d.push(`<line x1="40" y1="${u}" x2="${a - 40}" y2="${u}"/>`);
|
|
2969
2969
|
}
|
|
2970
2970
|
d.push("</g>");
|
|
2971
2971
|
}
|
|
2972
2972
|
if (t.showAxes) {
|
|
2973
2973
|
d.push('<g stroke="var(--nice-text, #333)" stroke-width="1">');
|
|
2974
|
-
const
|
|
2975
|
-
d.push(`<line x1="40" y1="${
|
|
2974
|
+
const m = s(0), u = f(0);
|
|
2975
|
+
d.push(`<line x1="40" y1="${m}" x2="${a - 40}" y2="${m}"/>`), d.push(`<line x1="${u}" y1="40" x2="${u}" y2="${o - 40}"/>`), d.push("</g>");
|
|
2976
2976
|
}
|
|
2977
|
-
for (const
|
|
2978
|
-
if (
|
|
2979
|
-
const
|
|
2980
|
-
if (
|
|
2981
|
-
const g =
|
|
2977
|
+
for (const m of r.filter((u) => u.visible))
|
|
2978
|
+
if (m.type === "2d-function") {
|
|
2979
|
+
const u = this.compute2DFunction(m.expression, t.xRange, m.resolution || 200);
|
|
2980
|
+
if (u.length > 0) {
|
|
2981
|
+
const g = u.map((w, y) => `${y === 0 ? "M" : "L"}${f(w.x)},${s(w.y)}`).join(" ");
|
|
2982
2982
|
d.push(
|
|
2983
|
-
`<path d="${g}" fill="none" stroke="rgb(${
|
|
2983
|
+
`<path d="${g}" fill="none" stroke="rgb(${m.color.r},${m.color.g},${m.color.b})" stroke-width="${m.lineWidth}"/>`
|
|
2984
2984
|
);
|
|
2985
2985
|
}
|
|
2986
2986
|
}
|
|
@@ -3189,38 +3189,38 @@ function NiceGraphPlotter({
|
|
|
3189
3189
|
minValue: -5,
|
|
3190
3190
|
maxValue: 5,
|
|
3191
3191
|
speed: 1
|
|
3192
|
-
}),
|
|
3192
|
+
}), m = useCallback(() => {
|
|
3193
3193
|
i(e.getPlots());
|
|
3194
|
-
}, [e]),
|
|
3194
|
+
}, [e]), u = useCallback((p) => {
|
|
3195
3195
|
f((h) => ({ ...h, ...p }));
|
|
3196
3196
|
}, []), g = useCallback((p) => {
|
|
3197
3197
|
d((h) => ({ ...h, ...p }));
|
|
3198
3198
|
}, []), w = useCallback(
|
|
3199
3199
|
(p) => {
|
|
3200
|
-
e.addPlot(p),
|
|
3200
|
+
e.addPlot(p), m();
|
|
3201
3201
|
},
|
|
3202
|
-
[e,
|
|
3202
|
+
[e, m]
|
|
3203
3203
|
), y = useCallback(
|
|
3204
3204
|
(p) => {
|
|
3205
|
-
e.removePlot(p),
|
|
3205
|
+
e.removePlot(p), m();
|
|
3206
3206
|
},
|
|
3207
|
-
[e,
|
|
3207
|
+
[e, m]
|
|
3208
3208
|
), b = useCallback(
|
|
3209
3209
|
(p, h) => {
|
|
3210
|
-
e.updatePlot(p, h),
|
|
3210
|
+
e.updatePlot(p, h), m();
|
|
3211
3211
|
},
|
|
3212
|
-
[e,
|
|
3212
|
+
[e, m]
|
|
3213
3213
|
), l = {
|
|
3214
3214
|
service: e,
|
|
3215
3215
|
plots: n,
|
|
3216
3216
|
view: c,
|
|
3217
|
-
setView:
|
|
3217
|
+
setView: u,
|
|
3218
3218
|
addPlot: w,
|
|
3219
3219
|
removePlot: y,
|
|
3220
3220
|
updatePlot: b,
|
|
3221
3221
|
animation: s,
|
|
3222
3222
|
setAnimation: g,
|
|
3223
|
-
refresh:
|
|
3223
|
+
refresh: m
|
|
3224
3224
|
};
|
|
3225
3225
|
return /* @__PURE__ */ jsx(GraphContext.Provider, { value: l, children: /* @__PURE__ */ jsxs("div", { className: a, style: { ...styles$2.container, ...o }, children: [
|
|
3226
3226
|
/* @__PURE__ */ jsxs("div", { style: styles$2.sidebar, children: [
|
|
@@ -3286,7 +3286,7 @@ function PlotControls() {
|
|
|
3286
3286
|
"select",
|
|
3287
3287
|
{
|
|
3288
3288
|
onChange: (s) => {
|
|
3289
|
-
const d = FUNCTION_PRESETS.find((
|
|
3289
|
+
const d = FUNCTION_PRESETS.find((m) => m.name === s.target.value);
|
|
3290
3290
|
d && r({
|
|
3291
3291
|
type: d.type,
|
|
3292
3292
|
expression: d.expression,
|
|
@@ -3388,8 +3388,8 @@ function PlotList() {
|
|
|
3388
3388
|
}
|
|
3389
3389
|
function GraphToolbar({ width: e, height: r }) {
|
|
3390
3390
|
const { t } = useNiceTranslation(), { service: a, plots: o, view: n, setView: i } = useGraph(), c = () => {
|
|
3391
|
-
const s = a.exportSVG(o, n, e, r), d = new Blob([s], { type: "image/svg+xml" }),
|
|
3392
|
-
|
|
3391
|
+
const s = a.exportSVG(o, n, e, r), d = new Blob([s], { type: "image/svg+xml" }), m = URL.createObjectURL(d), u = document.createElement("a");
|
|
3392
|
+
u.href = m, u.download = "graph.svg", u.click(), URL.revokeObjectURL(m);
|
|
3393
3393
|
}, f = async () => {
|
|
3394
3394
|
const s = await a.exportPNG(o, n, e, r), d = document.createElement("a");
|
|
3395
3395
|
d.href = s, d.download = "graph.png", d.click();
|
|
@@ -3493,11 +3493,11 @@ function Canvas2D({ width: e, height: r }) {
|
|
|
3493
3493
|
if (!f || !s)
|
|
3494
3494
|
return;
|
|
3495
3495
|
s.fillStyle = `rgb(${n.backgroundColor.r},${n.backgroundColor.g},${n.backgroundColor.b})`, s.fillRect(0, 0, e, r);
|
|
3496
|
-
const d = e - c * 2,
|
|
3496
|
+
const d = e - c * 2, m = r - c * 2, u = (y) => c + (y - n.xRange.min) / (n.xRange.max - n.xRange.min) * d, g = (y) => r - c - (y - n.yRange.min) / (n.yRange.max - n.yRange.min) * m;
|
|
3497
3497
|
if (n.showGrid) {
|
|
3498
3498
|
s.strokeStyle = "var(--nice-border, #e0e0e0)", s.lineWidth = 0.5;
|
|
3499
3499
|
for (let y = Math.ceil(n.xRange.min); y <= n.xRange.max; y++) {
|
|
3500
|
-
const b =
|
|
3500
|
+
const b = u(y);
|
|
3501
3501
|
s.beginPath(), s.moveTo(b, c), s.lineTo(b, r - c), s.stroke();
|
|
3502
3502
|
}
|
|
3503
3503
|
for (let y = Math.ceil(n.yRange.min); y <= n.yRange.max; y++) {
|
|
@@ -3509,11 +3509,11 @@ function Canvas2D({ width: e, height: r }) {
|
|
|
3509
3509
|
s.strokeStyle = "var(--nice-text, #333)", s.lineWidth = 1;
|
|
3510
3510
|
const y = g(0);
|
|
3511
3511
|
s.beginPath(), s.moveTo(c, y), s.lineTo(e - c, y), s.stroke();
|
|
3512
|
-
const b =
|
|
3512
|
+
const b = u(0);
|
|
3513
3513
|
if (s.beginPath(), s.moveTo(b, c), s.lineTo(b, r - c), s.stroke(), n.showLabels) {
|
|
3514
3514
|
s.fillStyle = "var(--nice-text, #333)", s.font = "12px sans-serif", s.textAlign = "center", s.fillText("x", e - c + 15, y + 4), s.fillText("y", b, c - 10), s.font = "10px sans-serif";
|
|
3515
3515
|
for (let l = Math.ceil(n.xRange.min); l <= n.xRange.max; l++)
|
|
3516
|
-
l !== 0 && s.fillText(String(l),
|
|
3516
|
+
l !== 0 && s.fillText(String(l), u(l), y + 15);
|
|
3517
3517
|
for (let l = Math.ceil(n.yRange.min); l <= n.yRange.max; l++)
|
|
3518
3518
|
l !== 0 && (s.textAlign = "right", s.fillText(String(l), b - 5, g(l) + 4));
|
|
3519
3519
|
}
|
|
@@ -3554,12 +3554,12 @@ function Canvas2D({ width: e, height: r }) {
|
|
|
3554
3554
|
s.beginPath();
|
|
3555
3555
|
let p = !1;
|
|
3556
3556
|
for (const h of l) {
|
|
3557
|
-
const
|
|
3557
|
+
const k = u(h.x), x = g(h.y);
|
|
3558
3558
|
if (x < 0 || x > r) {
|
|
3559
3559
|
p = !1;
|
|
3560
3560
|
continue;
|
|
3561
3561
|
}
|
|
3562
|
-
p ? s.lineTo(
|
|
3562
|
+
p ? s.lineTo(k, x) : (s.moveTo(k, x), p = !0);
|
|
3563
3563
|
}
|
|
3564
3564
|
s.stroke();
|
|
3565
3565
|
}
|
|
@@ -4195,12 +4195,12 @@ function NiceCalculator({
|
|
|
4195
4195
|
className: r,
|
|
4196
4196
|
style: t
|
|
4197
4197
|
}) {
|
|
4198
|
-
const [a, o] = useState("0"), [n, i] = useState("standard"), [c, f] = useState([]), [s, d] = useState(!1),
|
|
4198
|
+
const [a, o] = useState("0"), [n, i] = useState("standard"), [c, f] = useState([]), [s, d] = useState(!1), m = useCallback(
|
|
4199
4199
|
(y) => {
|
|
4200
4200
|
s && /[0-9.]/.test(y) ? (o(y), d(!1)) : (o((b) => b === "0" && y !== "." ? y : b + y), d(!1));
|
|
4201
4201
|
},
|
|
4202
4202
|
[s]
|
|
4203
|
-
),
|
|
4203
|
+
), u = useCallback(() => {
|
|
4204
4204
|
o("0"), d(!1);
|
|
4205
4205
|
}, []), g = useCallback(() => {
|
|
4206
4206
|
try {
|
|
@@ -4217,8 +4217,8 @@ function NiceCalculator({
|
|
|
4217
4217
|
setMode: i,
|
|
4218
4218
|
history: c,
|
|
4219
4219
|
calculate: g,
|
|
4220
|
-
appendDigit:
|
|
4221
|
-
clear:
|
|
4220
|
+
appendDigit: m,
|
|
4221
|
+
clear: u
|
|
4222
4222
|
};
|
|
4223
4223
|
return /* @__PURE__ */ jsx(CalculatorContext.Provider, { value: w, children: /* @__PURE__ */ jsxs("div", { className: r, style: { ...styles$1.container, ...t }, children: [
|
|
4224
4224
|
/* @__PURE__ */ jsx(ModeSelector, {}),
|
|
@@ -4405,9 +4405,9 @@ function ProgrammerKeypad() {
|
|
|
4405
4405
|
] });
|
|
4406
4406
|
}
|
|
4407
4407
|
function MatrixMode() {
|
|
4408
|
-
const { t: e } = useNiceTranslation(), [r, t] = useState(MatrixOps.create(2, 2)), [a, o] = useState(MatrixOps.create(2, 2)), [n, i] = useState(""), c = (s, d,
|
|
4408
|
+
const { t: e } = useNiceTranslation(), [r, t] = useState(MatrixOps.create(2, 2)), [a, o] = useState(MatrixOps.create(2, 2)), [n, i] = useState(""), c = (s, d, m, u, g) => {
|
|
4409
4409
|
const w = { ...s, data: s.data.map((y) => [...y]) };
|
|
4410
|
-
w.data[
|
|
4410
|
+
w.data[m][u] = parseFloat(g) || 0, d(w);
|
|
4411
4411
|
}, f = [
|
|
4412
4412
|
{ label: "A + B", fn: () => MatrixOps.toString(MatrixOps.add(r, a)) },
|
|
4413
4413
|
{ label: "A - B", fn: () => MatrixOps.toString(MatrixOps.subtract(r, a)) },
|
|
@@ -4424,7 +4424,7 @@ function MatrixMode() {
|
|
|
4424
4424
|
MatrixInput,
|
|
4425
4425
|
{
|
|
4426
4426
|
matrix: r,
|
|
4427
|
-
onChange: (s, d,
|
|
4427
|
+
onChange: (s, d, m) => c(r, t, s, d, m)
|
|
4428
4428
|
}
|
|
4429
4429
|
)
|
|
4430
4430
|
] }),
|
|
@@ -4434,7 +4434,7 @@ function MatrixMode() {
|
|
|
4434
4434
|
MatrixInput,
|
|
4435
4435
|
{
|
|
4436
4436
|
matrix: a,
|
|
4437
|
-
onChange: (s, d,
|
|
4437
|
+
onChange: (s, d, m) => c(a, o, s, d, m)
|
|
4438
4438
|
}
|
|
4439
4439
|
)
|
|
4440
4440
|
] })
|
|
@@ -4570,12 +4570,12 @@ function CalculusMode() {
|
|
|
4570
4570
|
] });
|
|
4571
4571
|
}
|
|
4572
4572
|
function UnitsMode() {
|
|
4573
|
-
const { t: e } = useNiceTranslation(), { service: r } = useCalculator(), [t, a] = useState("1"), [o, n] = useState("m"), [i, c] = useState("ft"), [f, s] = useState("Length"), [d,
|
|
4573
|
+
const { t: e } = useNiceTranslation(), { service: r } = useCalculator(), [t, a] = useState("1"), [o, n] = useState("m"), [i, c] = useState("ft"), [f, s] = useState("Length"), [d, m] = useState(""), u = r.getUnitCategories(), g = r.getUnitsByCategory(f), w = () => {
|
|
4574
4574
|
try {
|
|
4575
4575
|
const y = r.convertUnits(parseFloat(t), o, i);
|
|
4576
|
-
|
|
4576
|
+
m(`${t} ${o} = ${r.format(y)} ${i}`);
|
|
4577
4577
|
} catch (y) {
|
|
4578
|
-
|
|
4578
|
+
m(y.message);
|
|
4579
4579
|
}
|
|
4580
4580
|
};
|
|
4581
4581
|
return /* @__PURE__ */ jsxs("div", { style: { padding: "12px", backgroundColor: "var(--nice-bg-secondary, #252525)" }, children: [
|
|
@@ -4597,7 +4597,7 @@ function UnitsMode() {
|
|
|
4597
4597
|
border: "1px solid var(--nice-text-secondary, #555)",
|
|
4598
4598
|
borderRadius: "4px"
|
|
4599
4599
|
},
|
|
4600
|
-
children:
|
|
4600
|
+
children: u.map((y) => /* @__PURE__ */ jsx("option", { value: y, children: y }, y))
|
|
4601
4601
|
}
|
|
4602
4602
|
),
|
|
4603
4603
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px", alignItems: "center", marginBottom: "12px" }, children: [
|
|
@@ -4730,10 +4730,10 @@ const GeoMath = {
|
|
|
4730
4730
|
},
|
|
4731
4731
|
/** Circle-line intersection */
|
|
4732
4732
|
circleLineIntersection(e, r, t, a) {
|
|
4733
|
-
const o = a.x - t.x, n = a.y - t.y, i = t.x - e.x, c = t.y - e.y, f = o * o + n * n, s = 2 * (i * o + c * n), d = i * i + c * c - r * r,
|
|
4734
|
-
if (
|
|
4733
|
+
const o = a.x - t.x, n = a.y - t.y, i = t.x - e.x, c = t.y - e.y, f = o * o + n * n, s = 2 * (i * o + c * n), d = i * i + c * c - r * r, m = s * s - 4 * f * d;
|
|
4734
|
+
if (m < 0)
|
|
4735
4735
|
return [];
|
|
4736
|
-
const
|
|
4736
|
+
const u = Math.sqrt(m), g = (-s - u) / (2 * f), w = (-s + u) / (2 * f), y = [];
|
|
4737
4737
|
return g >= 0 && g <= 1 && y.push({ x: t.x + g * o, y: t.y + g * n }), w >= 0 && w <= 1 && Math.abs(w - g) > 1e-10 && y.push({ x: t.x + w * o, y: t.y + w * n }), y;
|
|
4738
4738
|
},
|
|
4739
4739
|
/** Circle-circle intersection */
|
|
@@ -5004,9 +5004,9 @@ class GeometryService {
|
|
|
5004
5004
|
return [];
|
|
5005
5005
|
const n = [], i = (s) => {
|
|
5006
5006
|
if (s.type === "line" || s.type === "segment" || s.type === "ray") {
|
|
5007
|
-
const d = s,
|
|
5008
|
-
if (
|
|
5009
|
-
return [
|
|
5007
|
+
const d = s, m = this.getPoint(d.point1Id ?? d.originId), u = this.getPoint(d.point2Id ?? d.throughId);
|
|
5008
|
+
if (m && u)
|
|
5009
|
+
return [m, u];
|
|
5010
5010
|
}
|
|
5011
5011
|
return null;
|
|
5012
5012
|
}, c = i(a), f = i(o);
|
|
@@ -5020,17 +5020,17 @@ class GeometryService {
|
|
|
5020
5020
|
if (a.type === "circle" && f) {
|
|
5021
5021
|
const s = a, d = this.getPoint(s.centerId);
|
|
5022
5022
|
if (d) {
|
|
5023
|
-
const
|
|
5024
|
-
for (const
|
|
5025
|
-
const g = this.createPoint(
|
|
5023
|
+
const m = GeoMath.circleLineIntersection(d, s.radius, f[0], f[1]);
|
|
5024
|
+
for (const u of m) {
|
|
5025
|
+
const g = this.createPoint(u.x, u.y);
|
|
5026
5026
|
g.dependencies = [r, t], g.color = { r: 255, g: 0, b: 0 }, n.push(g);
|
|
5027
5027
|
}
|
|
5028
5028
|
}
|
|
5029
5029
|
}
|
|
5030
5030
|
if (a.type === "circle" && o.type === "circle") {
|
|
5031
|
-
const s = a, d = o,
|
|
5032
|
-
if (
|
|
5033
|
-
const g = GeoMath.circleCircleIntersection(
|
|
5031
|
+
const s = a, d = o, m = this.getPoint(s.centerId), u = this.getPoint(d.centerId);
|
|
5032
|
+
if (m && u) {
|
|
5033
|
+
const g = GeoMath.circleCircleIntersection(m, s.radius, u, d.radius);
|
|
5034
5034
|
for (const w of g) {
|
|
5035
5035
|
const y = this.createPoint(w.x, w.y);
|
|
5036
5036
|
y.dependencies = [r, t], y.color = { r: 255, g: 0, b: 0 }, n.push(y);
|
|
@@ -5107,9 +5107,9 @@ class GeometryService {
|
|
|
5107
5107
|
case "segment": {
|
|
5108
5108
|
const f = this.getPoint(i.point1Id), s = this.getPoint(i.point2Id);
|
|
5109
5109
|
if (f && s) {
|
|
5110
|
-
const d = n(f.x, f.y),
|
|
5110
|
+
const d = n(f.x, f.y), m = n(s.x, s.y);
|
|
5111
5111
|
o.push(
|
|
5112
|
-
`<line x1="${d.x}" y1="${d.y}" x2="${
|
|
5112
|
+
`<line x1="${d.x}" y1="${d.y}" x2="${m.x}" y2="${m.y}" stroke="${c}" stroke-width="${i.width}"/>`
|
|
5113
5113
|
);
|
|
5114
5114
|
}
|
|
5115
5115
|
break;
|
|
@@ -5117,9 +5117,9 @@ class GeometryService {
|
|
|
5117
5117
|
case "circle": {
|
|
5118
5118
|
const f = this.getPoint(i.centerId);
|
|
5119
5119
|
if (f) {
|
|
5120
|
-
const s = n(f.x, f.y), d = i.radius * a.scale,
|
|
5120
|
+
const s = n(f.x, f.y), d = i.radius * a.scale, m = i.fill ? `rgba(${i.fill.r},${i.fill.g},${i.fill.b},${i.fill.a ?? 0.2})` : "none";
|
|
5121
5121
|
o.push(
|
|
5122
|
-
`<circle cx="${s.x}" cy="${s.y}" r="${d}" fill="${
|
|
5122
|
+
`<circle cx="${s.x}" cy="${s.y}" r="${d}" fill="${m}" stroke="${c}" stroke-width="${i.width}"/>`
|
|
5123
5123
|
);
|
|
5124
5124
|
}
|
|
5125
5125
|
break;
|
|
@@ -5127,9 +5127,9 @@ class GeometryService {
|
|
|
5127
5127
|
case "polygon": {
|
|
5128
5128
|
const f = i.pointIds.map((s) => this.getPoint(s)).filter(Boolean);
|
|
5129
5129
|
if (f.length > 0) {
|
|
5130
|
-
const d = f.map((
|
|
5130
|
+
const d = f.map((u) => n(u.x, u.y)).map((u, g) => `${g === 0 ? "M" : "L"}${u.x},${u.y}`).join(" ") + " Z", m = i.fill ? `rgba(${i.fill.r},${i.fill.g},${i.fill.b},${i.fill.a ?? 0.2})` : "none";
|
|
5131
5131
|
o.push(
|
|
5132
|
-
`<path d="${d}" fill="${
|
|
5132
|
+
`<path d="${d}" fill="${m}" stroke="${c}" stroke-width="${i.width}"/>`
|
|
5133
5133
|
);
|
|
5134
5134
|
}
|
|
5135
5135
|
break;
|
|
@@ -5213,7 +5213,7 @@ function NiceGeometry({
|
|
|
5213
5213
|
className: a,
|
|
5214
5214
|
style: o
|
|
5215
5215
|
}) {
|
|
5216
|
-
const [n, i] = useState([]), [c, f] = useState("point"), [s, d] = useState([]), [
|
|
5216
|
+
const [n, i] = useState([]), [c, f] = useState("point"), [s, d] = useState([]), [m, u] = useState({
|
|
5217
5217
|
centerX: 0,
|
|
5218
5218
|
centerY: 0,
|
|
5219
5219
|
scale: 40,
|
|
@@ -5226,7 +5226,7 @@ function NiceGeometry({
|
|
|
5226
5226
|
}), g = useCallback(() => {
|
|
5227
5227
|
i(e.getAllElements());
|
|
5228
5228
|
}, [e]), w = useCallback((b) => {
|
|
5229
|
-
|
|
5229
|
+
u((l) => ({ ...l, ...b }));
|
|
5230
5230
|
}, []);
|
|
5231
5231
|
useEffect(() => {
|
|
5232
5232
|
g();
|
|
@@ -5236,7 +5236,7 @@ function NiceGeometry({
|
|
|
5236
5236
|
elements: n,
|
|
5237
5237
|
tool: c,
|
|
5238
5238
|
setTool: f,
|
|
5239
|
-
view:
|
|
5239
|
+
view: m,
|
|
5240
5240
|
setView: w,
|
|
5241
5241
|
selectedIds: s,
|
|
5242
5242
|
setSelectedIds: d,
|
|
@@ -5284,7 +5284,7 @@ function Toolbar() {
|
|
|
5284
5284
|
)) });
|
|
5285
5285
|
}
|
|
5286
5286
|
function Canvas({ width: e, height: r }) {
|
|
5287
|
-
const t = useRef(null), { service: a, elements: o, tool: n, view: i, selectedIds: c, setSelectedIds: f, refresh: s } = useGeometry(), [d,
|
|
5287
|
+
const t = useRef(null), { service: a, elements: o, tool: n, view: i, selectedIds: c, setSelectedIds: f, refresh: s } = useGeometry(), [d, m] = useState([]), u = useCallback(
|
|
5288
5288
|
(b, l) => {
|
|
5289
5289
|
const p = (b - e / 2) / i.scale + i.centerX, h = -(l - r / 2) / i.scale + i.centerY;
|
|
5290
5290
|
return i.snapToGrid ? {
|
|
@@ -5305,7 +5305,7 @@ function Canvas({ width: e, height: r }) {
|
|
|
5305
5305
|
const l = (h = t.current) == null ? void 0 : h.getBoundingClientRect();
|
|
5306
5306
|
if (!l)
|
|
5307
5307
|
return;
|
|
5308
|
-
const p =
|
|
5308
|
+
const p = u(b.clientX - l.left, b.clientY - l.top);
|
|
5309
5309
|
switch (n) {
|
|
5310
5310
|
case "point": {
|
|
5311
5311
|
a.createPoint(p.x, p.y), s();
|
|
@@ -5314,31 +5314,31 @@ function Canvas({ width: e, height: r }) {
|
|
|
5314
5314
|
case "segment":
|
|
5315
5315
|
case "line":
|
|
5316
5316
|
case "ray": {
|
|
5317
|
-
const
|
|
5318
|
-
if (
|
|
5319
|
-
|
|
5320
|
-
const v = [...x,
|
|
5317
|
+
const k = y(p);
|
|
5318
|
+
if (k)
|
|
5319
|
+
m((x) => {
|
|
5320
|
+
const v = [...x, k.id];
|
|
5321
5321
|
return v.length === 2 ? (n === "segment" ? a.createSegment(v[0], v[1]) : n === "line" ? a.createLine(v[0], v[1]) : n === "ray" && a.createRay(v[0], v[1]), s(), []) : v;
|
|
5322
5322
|
});
|
|
5323
5323
|
else {
|
|
5324
5324
|
const x = a.createPoint(p.x, p.y);
|
|
5325
|
-
|
|
5326
|
-
const
|
|
5327
|
-
return
|
|
5325
|
+
m((v) => {
|
|
5326
|
+
const C = [...v, x.id];
|
|
5327
|
+
return C.length === 2 ? (n === "segment" ? a.createSegment(C[0], C[1]) : n === "line" ? a.createLine(C[0], C[1]) : n === "ray" && a.createRay(C[0], C[1]), s(), []) : C;
|
|
5328
5328
|
}), s();
|
|
5329
5329
|
}
|
|
5330
5330
|
break;
|
|
5331
5331
|
}
|
|
5332
5332
|
case "circle": {
|
|
5333
|
-
const
|
|
5334
|
-
if (
|
|
5335
|
-
|
|
5333
|
+
const k = y(p);
|
|
5334
|
+
if (k)
|
|
5335
|
+
m((x) => {
|
|
5336
5336
|
if (x.length === 0)
|
|
5337
|
-
return [
|
|
5337
|
+
return [k.id];
|
|
5338
5338
|
const v = a.getPoint(x[0]);
|
|
5339
5339
|
if (v) {
|
|
5340
|
-
const
|
|
5341
|
-
a.createCircle(x[0],
|
|
5340
|
+
const C = GeoMath.distance(v, p);
|
|
5341
|
+
a.createCircle(x[0], C), s();
|
|
5342
5342
|
}
|
|
5343
5343
|
return [];
|
|
5344
5344
|
});
|
|
@@ -5346,30 +5346,30 @@ function Canvas({ width: e, height: r }) {
|
|
|
5346
5346
|
const x = a.getPoint(d[0]);
|
|
5347
5347
|
if (x) {
|
|
5348
5348
|
const v = GeoMath.distance(x, p);
|
|
5349
|
-
a.createCircle(d[0], v), s(),
|
|
5349
|
+
a.createCircle(d[0], v), s(), m([]);
|
|
5350
5350
|
}
|
|
5351
5351
|
} else {
|
|
5352
5352
|
const x = a.createPoint(p.x, p.y);
|
|
5353
|
-
|
|
5353
|
+
m([x.id]), s();
|
|
5354
5354
|
}
|
|
5355
5355
|
break;
|
|
5356
5356
|
}
|
|
5357
5357
|
case "midpoint": {
|
|
5358
|
-
const
|
|
5359
|
-
|
|
5360
|
-
const v = [...x,
|
|
5358
|
+
const k = y(p);
|
|
5359
|
+
k && m((x) => {
|
|
5360
|
+
const v = [...x, k.id];
|
|
5361
5361
|
return v.length === 2 ? (a.createMidpoint(v[0], v[1]), s(), []) : v;
|
|
5362
5362
|
});
|
|
5363
5363
|
break;
|
|
5364
5364
|
}
|
|
5365
5365
|
case "select": {
|
|
5366
|
-
const
|
|
5367
|
-
f(
|
|
5366
|
+
const k = y(p);
|
|
5367
|
+
f(k ? [k.id] : []);
|
|
5368
5368
|
break;
|
|
5369
5369
|
}
|
|
5370
5370
|
}
|
|
5371
5371
|
},
|
|
5372
|
-
[n, a, s,
|
|
5372
|
+
[n, a, s, u, d, f]
|
|
5373
5373
|
), y = (b) => {
|
|
5374
5374
|
for (const p of o)
|
|
5375
5375
|
if (p.type === "point" && GeoMath.distance(p, b) < 0.5)
|
|
@@ -5380,10 +5380,10 @@ function Canvas({ width: e, height: r }) {
|
|
|
5380
5380
|
if (!(!b || !l)) {
|
|
5381
5381
|
if (l.fillStyle = `rgb(${i.backgroundColor.r},${i.backgroundColor.g},${i.backgroundColor.b})`, l.fillRect(0, 0, e, r), i.showGrid) {
|
|
5382
5382
|
l.strokeStyle = "var(--nice-border, #e0e0e0)", l.lineWidth = 0.5;
|
|
5383
|
-
const p = i.gridSpacing * i.scale, h = (e / 2 - i.centerX * i.scale) % p,
|
|
5383
|
+
const p = i.gridSpacing * i.scale, h = (e / 2 - i.centerX * i.scale) % p, k = (r / 2 + i.centerY * i.scale) % p;
|
|
5384
5384
|
for (let x = h; x < e; x += p)
|
|
5385
5385
|
l.beginPath(), l.moveTo(x, 0), l.lineTo(x, r), l.stroke();
|
|
5386
|
-
for (let x =
|
|
5386
|
+
for (let x = k; x < r; x += p)
|
|
5387
5387
|
l.beginPath(), l.moveTo(0, x), l.lineTo(e, x), l.stroke();
|
|
5388
5388
|
}
|
|
5389
5389
|
if (i.showAxes) {
|
|
@@ -5393,25 +5393,25 @@ function Canvas({ width: e, height: r }) {
|
|
|
5393
5393
|
for (const p of o) {
|
|
5394
5394
|
if (!p.visible)
|
|
5395
5395
|
continue;
|
|
5396
|
-
const h = `rgb(${p.color.r},${p.color.g},${p.color.b})`,
|
|
5396
|
+
const h = `rgb(${p.color.r},${p.color.g},${p.color.b})`, k = c.includes(p.id);
|
|
5397
5397
|
switch (p.type) {
|
|
5398
5398
|
case "point": {
|
|
5399
5399
|
const x = g(p.x, p.y);
|
|
5400
|
-
l.beginPath(), l.arc(x.x, x.y,
|
|
5400
|
+
l.beginPath(), l.arc(x.x, x.y, k ? p.size + 2 : p.size, 0, 2 * Math.PI), l.fillStyle = k ? "var(--nice-primary-hover, #1976d2)" : h, l.fill(), p.label && (l.fillStyle = "var(--nice-text, #333)", l.font = "12px sans-serif", l.fillText(p.label, x.x + 8, x.y - 8));
|
|
5401
5401
|
break;
|
|
5402
5402
|
}
|
|
5403
5403
|
case "segment": {
|
|
5404
5404
|
const x = a.getPoint(p.point1Id), v = a.getPoint(p.point2Id);
|
|
5405
5405
|
if (x && v) {
|
|
5406
|
-
const
|
|
5407
|
-
l.strokeStyle = h, l.lineWidth = p.width, l.beginPath(), l.moveTo(
|
|
5406
|
+
const C = g(x.x, x.y), M = g(v.x, v.y);
|
|
5407
|
+
l.strokeStyle = h, l.lineWidth = p.width, l.beginPath(), l.moveTo(C.x, C.y), l.lineTo(M.x, M.y), l.stroke();
|
|
5408
5408
|
}
|
|
5409
5409
|
break;
|
|
5410
5410
|
}
|
|
5411
5411
|
case "line": {
|
|
5412
5412
|
const x = a.getPoint(p.point1Id), v = a.getPoint(p.point2Id);
|
|
5413
5413
|
if (x && v) {
|
|
5414
|
-
const
|
|
5414
|
+
const C = v.x - x.x, M = v.y - x.y, P = -1e3, j = 1e3, $ = g(x.x + P * C, x.y + P * M), B = g(x.x + j * C, x.y + j * M);
|
|
5415
5415
|
l.strokeStyle = h, l.lineWidth = p.width, l.beginPath(), l.moveTo($.x, $.y), l.lineTo(B.x, B.y), l.stroke();
|
|
5416
5416
|
}
|
|
5417
5417
|
break;
|
|
@@ -5419,8 +5419,8 @@ function Canvas({ width: e, height: r }) {
|
|
|
5419
5419
|
case "circle": {
|
|
5420
5420
|
const x = a.getPoint(p.centerId);
|
|
5421
5421
|
if (x) {
|
|
5422
|
-
const v = g(x.x, x.y),
|
|
5423
|
-
l.beginPath(), l.arc(v.x, v.y,
|
|
5422
|
+
const v = g(x.x, x.y), C = p.radius * i.scale;
|
|
5423
|
+
l.beginPath(), l.arc(v.x, v.y, C, 0, 2 * Math.PI), p.fill && (l.fillStyle = `rgba(${p.fill.r},${p.fill.g},${p.fill.b},${p.fill.a ?? 0.2})`, l.fill()), l.strokeStyle = h, l.lineWidth = p.width, l.stroke();
|
|
5424
5424
|
}
|
|
5425
5425
|
break;
|
|
5426
5426
|
}
|
|
@@ -5430,8 +5430,8 @@ function Canvas({ width: e, height: r }) {
|
|
|
5430
5430
|
l.beginPath();
|
|
5431
5431
|
const v = g(x[0].x, x[0].y);
|
|
5432
5432
|
l.moveTo(v.x, v.y);
|
|
5433
|
-
for (let
|
|
5434
|
-
const M = g(x[
|
|
5433
|
+
for (let C = 1; C < x.length; C++) {
|
|
5434
|
+
const M = g(x[C].x, x[C].y);
|
|
5435
5435
|
l.lineTo(M.x, M.y);
|
|
5436
5436
|
}
|
|
5437
5437
|
l.closePath(), p.fill && (l.fillStyle = `rgba(${p.fill.r},${p.fill.g},${p.fill.b},${p.fill.a ?? 0.2})`, l.fill()), l.strokeStyle = h, l.lineWidth = p.width, l.stroke();
|
|
@@ -5445,8 +5445,8 @@ function Canvas({ width: e, height: r }) {
|
|
|
5445
5445
|
for (const p of d) {
|
|
5446
5446
|
const h = a.getPoint(p);
|
|
5447
5447
|
if (h) {
|
|
5448
|
-
const
|
|
5449
|
-
l.beginPath(), l.arc(
|
|
5448
|
+
const k = g(h.x, h.y);
|
|
5449
|
+
l.beginPath(), l.arc(k.x, k.y, 12, 0, 2 * Math.PI), l.fill();
|
|
5450
5450
|
}
|
|
5451
5451
|
}
|
|
5452
5452
|
}
|