pimath 0.2.10 → 0.2.12

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.
Files changed (61) hide show
  1. package/dist/pimath.js +918 -924
  2. package/dist/pimath.js.map +1 -1
  3. package/package.json +13 -12
  4. package/src/algebra/equation.ts +3 -2
  5. package/src/algebra/equationSolver.ts +2 -1
  6. package/src/algebra/factor.ts +10 -9
  7. package/src/algebra/linearSystem.ts +10 -9
  8. package/src/algebra/logicalset.ts +8 -3
  9. package/src/algebra/matrix.ts +10 -9
  10. package/src/algebra/monom.ts +10 -4
  11. package/src/algebra/operations.ts +3 -2
  12. package/src/algebra/polyFactor.ts +11 -7
  13. package/src/algebra/polynom.ts +30 -30
  14. package/src/coefficients/fraction.ts +6 -5
  15. package/src/coefficients/root.ts +6 -5
  16. package/src/errors.ts +45 -0
  17. package/src/geometry/TupleN.ts +4 -3
  18. package/src/geometry/geomMath.ts +3 -2
  19. package/src/geometry/line.ts +4 -2
  20. package/src/geometry/line3.ts +7 -6
  21. package/src/geometry/plane3.ts +3 -2
  22. package/src/geometry/point.ts +5 -4
  23. package/src/geometry/sphere3.ts +6 -5
  24. package/src/geometry/triangle.ts +3 -2
  25. package/src/geometry/vector.ts +6 -5
  26. package/src/helpers.ts +3 -1
  27. package/src/index.ts +23 -0
  28. package/src/numeric.ts +2 -1
  29. package/src/randomization/geometry/rndPoint.ts +2 -2
  30. package/src/randomization/rndHelpers.ts +2 -1
  31. package/types/algebra/equation.d.ts.map +1 -1
  32. package/types/algebra/equationSolver.d.ts.map +1 -1
  33. package/types/algebra/factor.d.ts.map +1 -1
  34. package/types/algebra/linearSystem.d.ts.map +1 -1
  35. package/types/algebra/logicalset.d.ts.map +1 -1
  36. package/types/algebra/matrix.d.ts.map +1 -1
  37. package/types/algebra/monom.d.ts.map +1 -1
  38. package/types/algebra/operations.d.ts.map +1 -1
  39. package/types/algebra/polyFactor.d.ts +1 -1
  40. package/types/algebra/polyFactor.d.ts.map +1 -1
  41. package/types/algebra/polynom.d.ts.map +1 -1
  42. package/types/coefficients/fraction.d.ts.map +1 -1
  43. package/types/coefficients/root.d.ts.map +1 -1
  44. package/types/errors.d.ts +20 -0
  45. package/types/errors.d.ts.map +1 -0
  46. package/types/geometry/TupleN.d.ts.map +1 -1
  47. package/types/geometry/geomMath.d.ts.map +1 -1
  48. package/types/geometry/line.d.ts.map +1 -1
  49. package/types/geometry/line3.d.ts.map +1 -1
  50. package/types/geometry/plane3.d.ts.map +1 -1
  51. package/types/geometry/point.d.ts.map +1 -1
  52. package/types/geometry/sphere3.d.ts.map +1 -1
  53. package/types/geometry/triangle.d.ts.map +1 -1
  54. package/types/geometry/vector.d.ts.map +1 -1
  55. package/types/helpers.d.ts.map +1 -1
  56. package/types/index.d.ts +12 -0
  57. package/types/index.d.ts.map +1 -1
  58. package/types/numeric.d.ts.map +1 -1
  59. package/types/randomization/geometry/rndPoint.d.ts +1 -1
  60. package/types/randomization/geometry/rndPoint.d.ts.map +1 -1
  61. package/types/randomization/rndHelpers.d.ts.map +1 -1
package/dist/pimath.js CHANGED
@@ -1,21 +1,28 @@
1
+ //#region src/errors.ts
2
+ var e = class extends Error {
3
+ constructor(e, t) {
4
+ super(e, t), this.name = new.target.name;
5
+ }
6
+ }, t = class extends e {}, n = class extends e {}, r = class extends e {}, i = class extends e {}, a = class extends e {}, o = class extends e {}, s = class extends e {};
7
+ //#endregion
1
8
  //#region src/numeric.ts
2
- function e(e) {
3
- let t = n(e), r = [], i, a;
4
- for (; t.length > 0;) i = t.shift() ?? 1, a = (t.length > 0 ? t.pop() : +i) ?? 1, r.push([i, a]);
5
- return r;
9
+ function c(e) {
10
+ let t = u(e), n = [], r, i;
11
+ for (; t.length > 0;) r = t.shift() ?? 1, i = (t.length > 0 ? t.pop() : +r) ?? 1, n.push([r, i]);
12
+ return n;
6
13
  }
7
- function t(...e) {
8
- let t = r(...e);
14
+ function l(...e) {
15
+ let t = d(...e);
9
16
  return e.map((e) => e / t);
10
17
  }
11
- function n(e) {
18
+ function u(e) {
12
19
  let t = Math.abs(e), n = Math.sqrt(t), r = [];
13
20
  for (let i = 1; i <= n; i++) e % i === 0 && (r.push(i), r.push(t / i));
14
21
  return r.sort(function(e, t) {
15
22
  return e - t;
16
23
  }), [...new Set(r)];
17
24
  }
18
- function r(...e) {
25
+ function d(...e) {
19
26
  let t = function(e, n) {
20
27
  return isNaN(e) || isNaN(n) ? NaN : n === 0 ? e : e === 0 ? n : t(n, e % n);
21
28
  }, n = 1, r = 2;
@@ -25,19 +32,19 @@ function r(...e) {
25
32
  for (r = 2; r < e.length && (n = t(n, e[r]), n !== 1); r++);
26
33
  return Math.abs(n);
27
34
  }
28
- function i(...e) {
35
+ function f(...e) {
29
36
  return e.reduce(function(e, t) {
30
- return Math.abs(e * t / r(e, t));
37
+ return Math.abs(e * t / d(e, t));
31
38
  });
32
39
  }
33
- function a(e, t = 3) {
40
+ function ee(e, t = 3) {
34
41
  return +e.toFixed(t);
35
42
  }
36
- function o(e) {
43
+ function te(e) {
37
44
  if (Number.isSafeInteger(e) || e.toString().split(".")[0].length < 10) return 0;
38
- throw Error("Periodic value: Not implemented yet");
45
+ throw new a("Periodic value: Not implemented yet");
39
46
  }
40
- function s(e) {
47
+ function ne(e) {
41
48
  let t = [
42
49
  2,
43
50
  3,
@@ -1271,7 +1278,7 @@ function s(e) {
1271
1278
  ];
1272
1279
  return e === void 0 ? t : t.slice(0, Math.min(t.length, e));
1273
1280
  }
1274
- function c(e, t) {
1281
+ function re(e, t) {
1275
1282
  let n = [], r = t === !0 ? +e : e ** 2;
1276
1283
  for (let t = 0; t <= e; t++) for (let i = 0; i <= e; i++) t ** 2 + i ** 2 === r && n.push([
1277
1284
  t,
@@ -1280,11 +1287,11 @@ function c(e, t) {
1280
1287
  ]);
1281
1288
  return n;
1282
1289
  }
1283
- function l(e, t = 2) {
1290
+ function ie(e, t = 2) {
1284
1291
  let n = Math.round(Number(`${e}e${t}`));
1285
1292
  return Number(`${n}e-${t}`);
1286
1293
  }
1287
- function u(e, t) {
1294
+ function ae(e, t) {
1288
1295
  let n = Math.floor(e ** (1 / t)), r = e;
1289
1296
  for (; n > 1;) {
1290
1297
  let e = n ** +t;
@@ -1293,21 +1300,21 @@ function u(e, t) {
1293
1300
  }
1294
1301
  return 1;
1295
1302
  }
1296
- var d = {
1297
- decompose: e,
1298
- dividers: n,
1299
- divideNumbersByGCD: t,
1300
- gcd: r,
1301
- lcm: i,
1302
- numberCorrection: a,
1303
- periodic: o,
1304
- primes: s,
1305
- pythagoreanTripletsWithTarget: c,
1306
- round: l,
1307
- greatestPower: u
1308
- }, f = /* @__PURE__ */ function(e) {
1303
+ var p = {
1304
+ decompose: c,
1305
+ dividers: u,
1306
+ divideNumbersByGCD: l,
1307
+ gcd: d,
1308
+ lcm: f,
1309
+ numberCorrection: ee,
1310
+ periodic: te,
1311
+ primes: ne,
1312
+ pythagoreanTripletsWithTarget: re,
1313
+ round: ie,
1314
+ greatestPower: ae
1315
+ }, oe = /* @__PURE__ */ function(e) {
1309
1316
  return e.frac = "frac", e.dfrac = "dfrac", e.tfrac = "tfrac", e;
1310
- }({}), p = class e {
1317
+ }({}), m = class e {
1311
1318
  #e = 1;
1312
1319
  #t = 3;
1313
1320
  #n = !0;
@@ -1370,7 +1377,7 @@ var d = {
1370
1377
  return n && r.reverse(), r;
1371
1378
  };
1372
1379
  static toSameDenominateur(...t) {
1373
- let n = t.map((t) => new e(t)), r = d.lcm(...n.map((e) => e.denominator));
1380
+ let n = t.map((t) => new e(t)), r = p.lcm(...n.map((e) => e.denominator));
1374
1381
  return n.forEach((e) => e.amplify(r / e.denominator)), n;
1375
1382
  }
1376
1383
  static unique = (t) => {
@@ -1392,7 +1399,7 @@ var d = {
1392
1399
  return this.reduce();
1393
1400
  };
1394
1401
  amplify = (e) => {
1395
- if (!Number.isSafeInteger(e)) throw Error("The amplification factor must be a safe integer.");
1402
+ if (!Number.isSafeInteger(e)) throw new i("The amplification factor must be a safe integer.");
1396
1403
  return this.#r *= e, this.#e *= e, this;
1397
1404
  };
1398
1405
  compare = (t, n) => {
@@ -1442,17 +1449,17 @@ var d = {
1442
1449
  fromNumber(e) {
1443
1450
  if (Number.isSafeInteger(e)) return this.#r = e, this.#e = 1, this.#n = !0, this;
1444
1451
  let [, t] = e.toString().split("."), n = t ? t.length : 0, r = 10 ** n;
1445
- return this.#r = e * r, this.#e = r, this.#r = d.numberCorrection(this.#r), this.#e = d.numberCorrection(this.#e), this.reduce(), this.#n = n < 10, this;
1452
+ return this.#r = e * r, this.#e = r, this.#r = p.numberCorrection(this.#r), this.#e = p.numberCorrection(this.#e), this.reduce(), this.#n = n < 10, this;
1446
1453
  }
1447
1454
  fromNumbers(e, t) {
1448
1455
  return Number.isSafeInteger(e) && Number.isSafeInteger(t) ? (this.#r = e, this.#e = t, this.#n = !0, this) : this.fromNumber(e / t);
1449
1456
  }
1450
1457
  fromPeriodic(e, t) {
1451
1458
  let [, n] = e.toString().split(/[.,]/), r = n ? n.length : 0;
1452
- if (!Number.isSafeInteger(t) || t <= 0) throw Error("The periodic length must be a positive integer.");
1453
- if (t > r) throw Error(`The periodic length (${t}) cannot exceed the number of decimal digits (${r}).`);
1454
- let i = 10 ** r;
1455
- return this.#r = +e * i - Math.floor(e * 10 ** (r - t)), this.#e = i - 10 ** (r - t), this.#n = !0, this;
1459
+ if (!Number.isSafeInteger(t) || t <= 0) throw new i("The periodic length must be a positive integer.");
1460
+ if (t > r) throw new i(`The periodic length (${t}) cannot exceed the number of decimal digits (${r}).`);
1461
+ let a = 10 ** r;
1462
+ return this.#r = +e * a - Math.floor(e * 10 ** (r - t)), this.#e = a - 10 ** (r - t), this.#n = !0, this;
1456
1463
  }
1457
1464
  fromString(e) {
1458
1465
  let t = e.split("/").map(Number);
@@ -1481,7 +1488,7 @@ var d = {
1481
1488
  isOne = () => this.#r === 1 && this.#e === 1;
1482
1489
  isPositive = () => this.sign() === 1;
1483
1490
  isRational = () => this.exact && !this.isRelative();
1484
- isReduced = () => Math.abs(d.gcd(this.#r, this.#e)) === 1;
1491
+ isReduced = () => Math.abs(p.gcd(this.#r, this.#e)) === 1;
1485
1492
  isRelative = () => this.exact && this.clone().reduce().denominator === 1;
1486
1493
  isSquare = () => Math.sqrt(this.#r) % 1 == 0 && Math.sqrt(this.#e) % 1 == 0;
1487
1494
  isStrictlyNegative = () => this.value < 0;
@@ -1509,17 +1516,17 @@ var d = {
1509
1516
  return a === r && o === i ? (this.#r = a, this.#e = o) : (this.#r = r / i, this.#e = 1, this.exact = !1), this;
1510
1517
  };
1511
1518
  reduce = () => {
1512
- let e = d.gcd(this.#r, this.#e);
1519
+ let e = p.gcd(this.#r, this.#e);
1513
1520
  return this.#r /= e, this.#e /= e, this.#e < 0 && (this.#e = -this.#e, this.#r = -this.#r), this;
1514
1521
  };
1515
1522
  root = (e) => {
1516
1523
  if (e === 0) return this;
1517
- if (!Number.isSafeInteger(e)) throw Error("The root must be an integer.");
1518
- if (e < 0 && this.inverse(), this.isNegative() && e % 2 == 0) throw Error("The root of a negative number must be odd.");
1524
+ if (!Number.isSafeInteger(e)) throw new i("The root must be an integer.");
1525
+ if (e < 0 && this.inverse(), this.isNegative() && e % 2 == 0) throw new r("The root of a negative number must be odd.");
1519
1526
  let t = this.sign();
1520
1527
  this.abs(), this.reduce();
1521
- let n = Math.floor(this.#r ** +Math.abs(1 / e)), r = Math.floor(this.#e ** +Math.abs(1 / e));
1522
- return this.#r **= +Math.abs(1 / e), this.#e **= +Math.abs(1 / e), (n !== this.#r || r !== this.#e) && (this.#r /= this.#e, this.#e = 1, this.exact = !1), this.multiply(t), this;
1528
+ let n = Math.floor(this.#r ** +Math.abs(1 / e)), a = Math.floor(this.#e ** +Math.abs(1 / e));
1529
+ return this.#r **= +Math.abs(1 / e), this.#e **= +Math.abs(1 / e), (n !== this.#r || a !== this.#e) && (this.#r /= this.#e, this.#e = 1, this.exact = !1), this.multiply(t), this;
1523
1530
  };
1524
1531
  sign = () => this.#r * this.#e >= 0 ? 1 : -1;
1525
1532
  sqrt = () => this.root(2);
@@ -1541,7 +1548,7 @@ var d = {
1541
1548
  };
1542
1549
  //#endregion
1543
1550
  //#region src/helpers.ts
1544
- function m(e, t = !0) {
1551
+ function se(e, t = !0) {
1545
1552
  return t ? `\\left( ${e} \\right)` : `(${e})`;
1546
1553
  }
1547
1554
  function h(e) {
@@ -1554,13 +1561,13 @@ function g(e, t, n, r, i) {
1554
1561
  return e.map((e, a) => r !== void 0 && a < r || i !== void 0 && a > i ? e : e === t ? n : e);
1555
1562
  }
1556
1563
  function _(e, t) {
1557
- if (t.length !== 1) throw Error(`splitChar must be a single character, got: "${t}"`);
1558
- let n = 0, r = 0, i = [];
1559
- for (let a = 0; a < e.length; a++) {
1560
- let o = e[a];
1561
- o === "(" ? n++ : o === ")" ? n-- : o === t && n === 0 && (i.push(e.substring(r, a)), r = a + 1);
1564
+ if (t.length !== 1) throw new i(`splitChar must be a single character, got: "${t}"`);
1565
+ let n = 0, r = 0, a = [];
1566
+ for (let i = 0; i < e.length; i++) {
1567
+ let o = e[i];
1568
+ o === "(" ? n++ : o === ")" ? n-- : o === t && n === 0 && (a.push(e.substring(r, i)), r = i + 1);
1562
1569
  }
1563
- return i.push(e.substring(r)), i;
1570
+ return a.push(e.substring(r)), a;
1564
1571
  }
1565
1572
  //#endregion
1566
1573
  //#region src/coefficients/root.ts
@@ -1570,16 +1577,16 @@ var v = class e {
1570
1577
  #n;
1571
1578
  #r = !1;
1572
1579
  constructor(e) {
1573
- return this.#t = 2, this.#e = new p().zero(), this.#n = new p().zero(), e && this.parse(e), this;
1580
+ return this.#t = 2, this.#e = new m().zero(), this.#n = new m().zero(), e && this.parse(e), this;
1574
1581
  }
1575
1582
  parse(t) {
1576
1583
  if (t instanceof e) return this.index = t.index, this.radical = t.radical.clone(), this.factor = t.factor.clone(), this;
1577
- if (t instanceof p) return this.index = 2, this.factor = t.clone(), this.radical.one(), this;
1584
+ if (t instanceof m) return this.index = 2, this.factor = t.clone(), this.radical.one(), this;
1578
1585
  if (typeof t == "string") {
1579
1586
  if (t.includes("sqrt")) return this.#s(t);
1580
1587
  if (t.includes("root")) return this.#o(t);
1581
1588
  }
1582
- return this.index = 2, this.factor = new p(t), this.radical.one(), this;
1589
+ return this.index = 2, this.factor = new m(t), this.radical.one(), this;
1583
1590
  }
1584
1591
  clone() {
1585
1592
  return new e().from(this.index, this.radical, this.factor);
@@ -1599,7 +1606,7 @@ var v = class e {
1599
1606
  add(t) {
1600
1607
  this.reduce();
1601
1608
  let n = new e(t).reduce();
1602
- if (this.index !== n.index || !this.radical.isEqual(n.radical)) throw Error("Add can only be done with two same index and radical");
1609
+ if (this.index !== n.index || !this.radical.isEqual(n.radical)) throw new r("Add can only be done with two same index and radical");
1603
1610
  return this.factor.add(n.factor), this;
1604
1611
  }
1605
1612
  divide(t) {
@@ -1612,7 +1619,7 @@ var v = class e {
1612
1619
  this.#e = e;
1613
1620
  }
1614
1621
  from(e, t, n) {
1615
- return this.index = e, this.radical = new p(t), this.factor = n ? new p(n) : new p().one(), this;
1622
+ return this.index = e, this.radical = new m(t), this.factor = n ? new m(n) : new m().one(), this;
1616
1623
  }
1617
1624
  group() {
1618
1625
  return this.radical.multiply(this.factor.pow(this.index)), this.factor.one(), this;
@@ -1621,11 +1628,11 @@ var v = class e {
1621
1628
  return this.#t;
1622
1629
  }
1623
1630
  set index(e) {
1624
- if (!Number.isSafeInteger(e) || e <= 0) throw Error("Index must be a strictly positive integer.");
1631
+ if (!Number.isSafeInteger(e) || e <= 0) throw new i("Index must be a strictly positive integer.");
1625
1632
  this.#t = e;
1626
1633
  }
1627
1634
  get indexAsPow() {
1628
- return new p(this.index).inverse();
1635
+ return new m(this.index).inverse();
1629
1636
  }
1630
1637
  inverse() {
1631
1638
  return this.factor.inverse(), this.radical.inverse(), this;
@@ -1650,7 +1657,7 @@ var v = class e {
1650
1657
  let e = this.indexAsPow.add(n.indexAsPow).reduce();
1651
1658
  return this.index = e.denominator, this.radical = this.radical.pow(e.numerator), this;
1652
1659
  }
1653
- throw Error("Multiply can only be done if radical or index as equals.");
1660
+ throw new r("Multiply can only be done if radical or index as equals.");
1654
1661
  }
1655
1662
  one() {
1656
1663
  return this.radical.one(), this.factor.one(), this;
@@ -1660,7 +1667,7 @@ var v = class e {
1660
1667
  }
1661
1668
  pow(e) {
1662
1669
  this.factor.pow(e);
1663
- let t = d.gcd(this.index, e);
1670
+ let t = p.gcd(this.index, e);
1664
1671
  return this.index /= t, this.radical.pow(e / t), this;
1665
1672
  }
1666
1673
  get radical() {
@@ -1674,7 +1681,7 @@ var v = class e {
1674
1681
  let e = this.radical.denominator;
1675
1682
  this.radical.denominator = 1, this.radical.numerator *= e, this.factor.divide(e);
1676
1683
  }
1677
- let e = d.greatestPower(this.radical.value, this.index);
1684
+ let e = p.greatestPower(this.radical.value, this.index);
1678
1685
  return this.factor.multiply(e ** (1 / this.index)), this.radical.divide(e), this;
1679
1686
  }
1680
1687
  root(e) {
@@ -1688,7 +1695,7 @@ var v = class e {
1688
1695
  return this.add(n.opposite());
1689
1696
  }
1690
1697
  get value() {
1691
- return d.numberCorrection(this.factor.value * this.radical.value ** (1 / this.index));
1698
+ return p.numberCorrection(this.factor.value * this.radical.value ** (1 / this.index));
1692
1699
  }
1693
1700
  get withSign() {
1694
1701
  return this.#r = !0, this;
@@ -1708,14 +1715,14 @@ var v = class e {
1708
1715
  return r.length === 0 ? null : r.join(" ");
1709
1716
  }
1710
1717
  #o(e) {
1711
- let t = /^(.*?)root\((\d+)\)\(?([^)]+)/.exec(e);
1712
- if (!t) throw Error(`Invalid root format: "${e}"`);
1713
- let [, n, r, i] = t;
1714
- return this.index = +r, this.radical = new p(i), this.factor = n === "" ? new p().one() : new p(n.trim()), this;
1718
+ let n = /^(.*?)root\((\d+)\)\(?([^)]+)/.exec(e);
1719
+ if (!n) throw new t(`Invalid root format: "${e}"`);
1720
+ let [, r, i, a] = n;
1721
+ return this.index = +i, this.radical = new m(a), this.factor = r === "" ? new m().one() : new m(r.trim()), this;
1715
1722
  }
1716
1723
  #s(e) {
1717
1724
  let [t, n] = e.split("sqrt");
1718
- return this.index = 2, this.radical = new p(h(n)), this.factor = t === "" ? new p().one() : new p(t), this;
1725
+ return this.index = 2, this.radical = new m(h(n)), this.factor = t === "" ? new m().one() : new m(t), this;
1719
1726
  }
1720
1727
  }, y = class e {
1721
1728
  #e;
@@ -1726,13 +1733,13 @@ var v = class e {
1726
1733
  #a;
1727
1734
  #o;
1728
1735
  constructor() {
1729
- this.#o = "x", this.#n = !1, this.#t = null, this.#a = null, this.#r = new p().zero(), this.#i = new v(), this.#e = 1;
1736
+ this.#o = "x", this.#n = !1, this.#t = null, this.#a = null, this.#r = new m().zero(), this.#i = new v(), this.#e = 1;
1730
1737
  }
1731
1738
  get tex() {
1732
1739
  if (this.#a) return this.#a;
1733
1740
  if (this.#i.isZero()) return this.#r.tex;
1734
1741
  if (this.#r.isZero()) return this.#i.tex;
1735
- let [e] = p.toSameDenominateur(this.#r, this.#i.factor), t = this.#i.clone().multiply(e.denominator).reduce(), n = `${e.numerator} ${t.withSign.tex}`;
1742
+ let [e] = m.toSameDenominateur(this.#r, this.#i.factor), t = this.#i.clone().multiply(e.denominator).reduce(), n = `${e.numerator} ${t.withSign.tex}`;
1736
1743
  return e.denominator === 1 ? n : `\\frac{ ${n} }{ ${e.denominator} }`;
1737
1744
  }
1738
1745
  set tex(e) {
@@ -1742,7 +1749,7 @@ var v = class e {
1742
1749
  if (this.#t) return this.#t;
1743
1750
  if (this.#i.isZero()) return this.#r.display;
1744
1751
  if (this.#r.isZero()) return this.#i.display;
1745
- let [e] = p.toSameDenominateur(this.#r, this.#i.factor), t = this.#i.clone().multiply(e.denominator).reduce(), n = `${e.numerator}${t.withSign.display}`;
1752
+ let [e] = m.toSameDenominateur(this.#r, this.#i.factor), t = this.#i.clone().multiply(e.denominator).reduce(), n = `${e.numerator}${t.withSign.display}`;
1746
1753
  return e.denominator === 1 ? n : `(${n})/${e.denominator}`;
1747
1754
  }
1748
1755
  set display(e) {
@@ -1751,7 +1758,7 @@ var v = class e {
1751
1758
  static fromFraction(t) {
1752
1759
  let n = new e();
1753
1760
  n.setExact();
1754
- let r = new p(t);
1761
+ let r = new m(t);
1755
1762
  return n.display = r.display, n.tex = r.tex, n.fraction = r, n.root = new v(), n;
1756
1763
  }
1757
1764
  static fromQuadratic(t, n, r) {
@@ -1759,7 +1766,7 @@ var v = class e {
1759
1766
  t,
1760
1767
  n,
1761
1768
  r
1762
- ].map((e) => new p(e)), s = a.clone().pow(2).subtract(i.clone().multiply(o).multiply(4));
1769
+ ].map((e) => new m(e)), s = a.clone().pow(2).subtract(i.clone().multiply(o).multiply(4));
1763
1770
  if (s.isNegative()) return [];
1764
1771
  if (s.isSquare()) {
1765
1772
  let t = s.sqrt(), n = a.clone().opposite().subtract(t).divide(i.clone().multiply(2)), r = a.clone().opposite().add(t).divide(i.clone().multiply(2));
@@ -1812,11 +1819,11 @@ var v = class e {
1812
1819
  set variable(e) {
1813
1820
  e !== void 0 && (this.#o = e);
1814
1821
  }
1815
- }, ee = class {
1822
+ }, ce = class {
1816
1823
  #e;
1817
1824
  #t;
1818
1825
  constructor(e) {
1819
- e instanceof M || e instanceof A ? this.#e = new M(e) : this.#e = new M().fromPolynom(e), this.#t = this.#e.getRoots();
1826
+ this.#e = e instanceof R || e instanceof P ? new R(e) : new R().fromPolynom(e), this.#t = this.#e.getRoots();
1820
1827
  }
1821
1828
  get fx() {
1822
1829
  return this.#e;
@@ -1854,15 +1861,15 @@ var v = class e {
1854
1861
  return r.degree().isZero() ? n : r.degree().value <= 2 ? n.concat(new e(r.clone()).solve()) : (this._ = 0, n.concat(this.#a(r)).sort((e, t) => e.value - t.value));
1855
1862
  }
1856
1863
  solveAsCardan() {
1857
- if (this.#t.degree().value !== 3) throw Error("The equation is not cubic.");
1864
+ if (this.#t.degree().value !== 3) throw new r("The equation is not cubic.");
1858
1865
  return this.#u();
1859
1866
  }
1860
1867
  #r(e, t) {
1861
1868
  let n = new y();
1862
- return n.exact = !1, n.tex = t?.tex ?? null, n.display = t?.display ?? null, n.fraction = new p(e), n.fraction.exact = !1, n.variable = this.#n, n;
1869
+ return n.exact = !1, n.tex = t?.tex ?? null, n.display = t?.display ?? null, n.fraction = new m(e), n.fraction.exact = !1, n.variable = this.#n, n;
1863
1870
  }
1864
1871
  #i(e) {
1865
- return e instanceof p && !e.exact ? this.#r(e.value) : y.fromFraction(e);
1872
+ return e instanceof m && !e.exact ? this.#r(e.value) : y.fromFraction(e);
1866
1873
  }
1867
1874
  #a(e) {
1868
1875
  let t = [], n = e.degree().value, [r, ...i] = e.getCoefficients(), a = 2 + Math.max(...i.map((e) => e.value / r.value)), o = this.#s(e, a, 100);
@@ -1890,7 +1897,7 @@ var v = class e {
1890
1897
  #s(e, t, n) {
1891
1898
  let r = [], i = 2 * t / n;
1892
1899
  for (let n = -t; n <= t; n += i) {
1893
- let t = d.numberCorrection(n);
1900
+ let t = p.numberCorrection(n);
1894
1901
  r.push({
1895
1902
  x: t,
1896
1903
  fx: e.evaluate(t, !0)
@@ -1915,9 +1922,9 @@ var v = class e {
1915
1922
  let e = t.monoms.reduce((e, t) => t.degree().value < e.degree().value ? t : e), r = e.coefficient;
1916
1923
  e.clone().divide(r), t.divide(e);
1917
1924
  }
1918
- let o = d.dividers(i.value), s = d.dividers(a.value), c = [];
1925
+ let o = p.dividers(i.value), s = p.dividers(a.value), c = [];
1919
1926
  for (let e of o) for (let t of s) {
1920
- let n = new p(t, e);
1927
+ let n = new m(t, e);
1921
1928
  c.find((e) => e.value === n.value) || (c.push(n.clone()), c.push(n.opposite().clone()));
1922
1929
  }
1923
1930
  c.forEach((e) => {
@@ -1976,19 +1983,27 @@ var v = class e {
1976
1983
  }
1977
1984
  #p(e, t, n) {
1978
1985
  let r = e.clone().multiply(2), i = new y();
1979
- i.fraction = t.clone().opposite().divide(r.clone()), i.root.radical = n.clone(), i.root.factor = new p().one().divide(r.clone()), i.exact = !0;
1986
+ i.fraction = t.clone().opposite().divide(r.clone()), i.root.radical = n.clone(), i.root.factor = new m().one().divide(r.clone()), i.exact = !0;
1980
1987
  let a = new y();
1981
- return a.fraction = t.clone().opposite().divide(r.clone()), a.root.radical = n.clone(), a.root.factor = new p().one().divide(r.clone()).opposite(), a.exact = !0, [i, a].sort((e, t) => e.value - t.value);
1988
+ return a.fraction = t.clone().opposite().divide(r.clone()), a.root.radical = n.clone(), a.root.factor = new m().one().divide(r.clone()).opposite(), a.exact = !0, [i, a].sort((e, t) => e.value - t.value);
1982
1989
  }
1983
- }, x = {
1990
+ }, le = class extends Error {
1991
+ constructor(e, t) {
1992
+ super(e, t), this.name = new.target.name;
1993
+ }
1994
+ }, x = class extends le {}, S = class extends le {}, ue = class extends S {}, C = {
1984
1995
  pi: Math.PI,
1985
1996
  e: Math.exp(1)
1986
- }, S = /* @__PURE__ */ ((e) => (e.VARIABLE = "variable", e.COEFFICIENT = "coefficient", e.OPERATION = "operation", e.CONSTANT = "constant", e.FUNCTION = "function", e.FUNCTION_ARGUMENT = "function-argument", e.MONOM = "monom", e.LEFT_PARENTHESIS = "(", e.RIGHT_PARENTHESIS = ")", e))(S || {}), C = /* @__PURE__ */ ((e) => (e.EXPRESSION = "expression", e.POLYNOM = "polynom", e.SET = "set", e.NUMERIC = "numeric", e))(C || {});
1987
- function te(e, t) {
1988
- if (e.length <= 1) return e;
1989
- let n = Object.keys(t).filter((e) => t[e].type === S.FUNCTION).map((e) => e);
1997
+ }, w = /* @__PURE__ */ function(e) {
1998
+ return e.VARIABLE = "variable", e.COEFFICIENT = "coefficient", e.OPERATION = "operation", e.CONSTANT = "constant", e.FUNCTION = "function", e.FUNCTION_ARGUMENT = "function-argument", e.MONOM = "monom", e.LEFT_PARENTHESIS = "(", e.RIGHT_PARENTHESIS = ")", e;
1999
+ }({}), T = /* @__PURE__ */ function(e) {
2000
+ return e.EXPRESSION = "expression", e.POLYNOM = "polynom", e.SET = "set", e.NUMERIC = "numeric", e;
2001
+ }({});
2002
+ function de(e, t) {
2003
+ if (e = e.replace(/\s+/g, ""), e.length <= 1) return e;
2004
+ let n = Object.keys(t).filter((e) => t[e].type === w.FUNCTION).map((e) => e);
1990
2005
  n.sort((e, t) => t.length - e.length);
1991
- let r = RegExp(`^(${n.join("|")})\\(`), i = Object.keys(x);
2006
+ let r = RegExp(`^(${n.join("|")})\\(`), i = Object.keys(C);
1992
2007
  i.sort((e, t) => t.length - e.length);
1993
2008
  let a = RegExp(`^(${i.join("|")})`), o = /^(\d+(\.\d+)?)/, s = "", c, l, u;
1994
2009
  for (n.forEach((t) => {
@@ -1997,224 +2012,174 @@ function te(e, t) {
1997
2012
  e = e.replaceAll(n, `${t}($1)`);
1998
2013
  }
1999
2014
  }); e.length > 0;) {
2000
- if (c = l, u = void 0, n.length > 0 && r.exec(e)) {
2015
+ c = l, u = void 0;
2016
+ let t = n.find((t) => e.startsWith(t));
2017
+ if (t !== void 0 && e[t.length] !== "(") throw new x(`Function "${t}" must be followed by parentheses`);
2018
+ if (n.length > 0 && r.exec(e)) {
2001
2019
  let t = n.find((t) => e.startsWith(t));
2002
- t && (u = t + "(", e = e.slice(t.length + 1), l = S.FUNCTION);
2020
+ t && (u = t + "(", e = e.slice(t.length + 1), l = w.FUNCTION);
2003
2021
  } else if (i.length > 0 && a.exec(e)) {
2004
2022
  let t = i.find((t) => e.startsWith(t));
2005
- t && (u = t, e = e.slice(t.length), l = S.CONSTANT);
2023
+ t && (u = t, e = e.slice(t.length), l = w.CONSTANT);
2006
2024
  } else if (o.exec(e)) {
2007
2025
  let t = o.exec(e);
2008
- t && (u = t[0], e = e.slice(t[0].length), l = S.COEFFICIENT);
2026
+ t && (u = t[0], e = e.slice(t[0].length), l = w.COEFFICIENT);
2009
2027
  } else switch (u = e[0], e = e.slice(1), u) {
2010
2028
  case "(":
2011
- l = S.LEFT_PARENTHESIS;
2029
+ l = w.LEFT_PARENTHESIS;
2012
2030
  break;
2013
2031
  case ")":
2014
- l = S.RIGHT_PARENTHESIS;
2032
+ l = w.RIGHT_PARENTHESIS;
2015
2033
  break;
2016
2034
  case ",":
2017
- l = S.FUNCTION_ARGUMENT;
2035
+ l = w.FUNCTION_ARGUMENT;
2018
2036
  break;
2019
2037
  case "+":
2020
2038
  case "-":
2021
2039
  case "*":
2022
2040
  case "/":
2023
2041
  case "^":
2024
- l = S.OPERATION;
2042
+ case "%":
2043
+ l = w.OPERATION;
2025
2044
  break;
2026
- default: l = S.VARIABLE;
2045
+ default: l = w.VARIABLE;
2027
2046
  }
2028
2047
  if (u === void 0 || l === void 0) throw Error("The token is undefined");
2029
- s += ne(c, l), s += u;
2048
+ s += fe(c, l), s += u;
2030
2049
  }
2031
2050
  return s;
2032
2051
  }
2033
- function ne(e, t) {
2034
- return e === void 0 || e === S.OPERATION || t === S.OPERATION || e === S.LEFT_PARENTHESIS || e === S.FUNCTION || e === S.FUNCTION_ARGUMENT || t === S.RIGHT_PARENTHESIS || t === S.FUNCTION_ARGUMENT ? "" : "*";
2052
+ function fe(e, t) {
2053
+ return e === void 0 || e === w.OPERATION || t === w.OPERATION || e === w.LEFT_PARENTHESIS || e === w.FUNCTION || e === w.FUNCTION_ARGUMENT || t === w.RIGHT_PARENTHESIS || t === w.FUNCTION_ARGUMENT ? "" : "*";
2035
2054
  }
2036
- var re = {
2055
+ var pe = {
2037
2056
  "^": {
2038
2057
  precedence: 4,
2039
2058
  associative: "right",
2040
- type: S.OPERATION
2059
+ type: w.OPERATION
2041
2060
  },
2042
2061
  "*": {
2043
2062
  precedence: 3,
2044
2063
  associative: "left",
2045
- type: S.OPERATION
2064
+ type: w.OPERATION
2046
2065
  },
2047
2066
  "/": {
2048
2067
  precedence: 3,
2049
2068
  associative: "left",
2050
- type: S.OPERATION
2069
+ type: w.OPERATION
2051
2070
  },
2052
2071
  "+": {
2053
2072
  precedence: 2,
2054
2073
  associative: "left",
2055
- type: S.OPERATION
2074
+ type: w.OPERATION
2056
2075
  },
2057
2076
  "-": {
2058
2077
  precedence: 2,
2059
2078
  associative: "left",
2060
- type: S.OPERATION
2061
- }
2062
- }, ie = {
2063
- "^": {
2064
- precedence: 4,
2065
- associative: "right",
2066
- type: S.OPERATION
2079
+ type: w.OPERATION
2067
2080
  },
2068
- "*": {
2081
+ "%": {
2069
2082
  precedence: 3,
2070
2083
  associative: "left",
2071
- type: S.OPERATION
2084
+ type: w.OPERATION
2072
2085
  },
2073
- "/": {
2086
+ "&": {
2074
2087
  precedence: 3,
2075
2088
  associative: "left",
2076
- type: S.OPERATION
2077
- },
2078
- "+": {
2079
- precedence: 2,
2080
- associative: "left",
2081
- type: S.OPERATION
2089
+ type: w.OPERATION
2082
2090
  },
2083
- "-": {
2084
- precedence: 2,
2091
+ "|": {
2092
+ precedence: 3,
2085
2093
  associative: "left",
2086
- type: S.OPERATION
2094
+ type: w.OPERATION
2087
2095
  },
2088
- "%": {
2089
- precedence: 3,
2096
+ "!": {
2097
+ precedence: 4,
2090
2098
  associative: "right",
2091
- type: S.OPERATION
2099
+ type: w.OPERATION
2092
2100
  },
2093
2101
  sin: {
2094
2102
  precedence: 4,
2095
2103
  associative: "right",
2096
- type: S.FUNCTION
2104
+ type: w.FUNCTION,
2105
+ arity: 1
2097
2106
  },
2098
2107
  cos: {
2099
2108
  precedence: 4,
2100
2109
  associative: "right",
2101
- type: S.FUNCTION
2110
+ type: w.FUNCTION,
2111
+ arity: 1
2102
2112
  },
2103
2113
  tan: {
2104
2114
  precedence: 4,
2105
2115
  associative: "right",
2106
- type: S.FUNCTION
2107
- },
2108
- sqrt: {
2109
- precedence: 4,
2110
- associative: "right",
2111
- type: S.FUNCTION
2112
- },
2113
- nthrt: {
2114
- precedence: 4,
2115
- associative: "right",
2116
- type: S.FUNCTION
2117
- },
2118
- ",": {
2119
- precedence: 2,
2120
- associative: "left",
2121
- type: S.FUNCTION_ARGUMENT
2122
- }
2123
- }, ae = {
2124
- "^": {
2125
- precedence: 4,
2126
- associative: "right",
2127
- type: S.OPERATION
2128
- },
2129
- "*": {
2130
- precedence: 3,
2131
- associative: "left",
2132
- type: S.OPERATION
2133
- },
2134
- "/": {
2135
- precedence: 3,
2136
- associative: "left",
2137
- type: S.OPERATION
2138
- },
2139
- "+": {
2140
- precedence: 2,
2141
- associative: "left",
2142
- type: S.OPERATION
2143
- },
2144
- "-": {
2145
- precedence: 2,
2146
- associative: "left",
2147
- type: S.OPERATION
2148
- },
2149
- "%": {
2150
- precedence: 3,
2151
- associative: "right",
2152
- type: S.OPERATION
2116
+ type: w.FUNCTION,
2117
+ arity: 1
2153
2118
  },
2154
- sin: {
2119
+ asin: {
2155
2120
  precedence: 4,
2156
2121
  associative: "right",
2157
- type: S.FUNCTION
2122
+ type: w.FUNCTION,
2123
+ arity: 1
2158
2124
  },
2159
- cos: {
2125
+ acos: {
2160
2126
  precedence: 4,
2161
2127
  associative: "right",
2162
- type: S.FUNCTION
2128
+ type: w.FUNCTION,
2129
+ arity: 1
2163
2130
  },
2164
- tan: {
2131
+ atan: {
2165
2132
  precedence: 4,
2166
2133
  associative: "right",
2167
- type: S.FUNCTION
2134
+ type: w.FUNCTION,
2135
+ arity: 1
2168
2136
  },
2169
2137
  sqrt: {
2170
2138
  precedence: 4,
2171
2139
  associative: "right",
2172
- type: S.FUNCTION
2140
+ type: w.FUNCTION,
2141
+ arity: 1
2173
2142
  },
2174
2143
  nthrt: {
2175
2144
  precedence: 4,
2176
2145
  associative: "right",
2177
- type: S.FUNCTION
2146
+ type: w.FUNCTION,
2147
+ arity: 2
2178
2148
  },
2179
2149
  ln: {
2180
2150
  precedence: 4,
2181
2151
  associative: "right",
2182
- type: S.FUNCTION
2152
+ type: w.FUNCTION,
2153
+ arity: 1
2183
2154
  },
2184
2155
  log: {
2185
2156
  precedence: 4,
2186
2157
  associative: "right",
2187
- type: S.FUNCTION
2188
- }
2189
- }, oe = {
2190
- "&": {
2191
- precedence: 3,
2192
- associative: "left",
2193
- type: S.OPERATION
2194
- },
2195
- "|": {
2196
- precedence: 3,
2197
- associative: "left",
2198
- type: S.OPERATION
2158
+ type: w.FUNCTION,
2159
+ arity: 1
2199
2160
  },
2200
- "!": {
2161
+ logn: {
2201
2162
  precedence: 4,
2202
2163
  associative: "right",
2203
- type: S.OPERATION
2204
- },
2205
- "-": {
2206
- precedence: 2,
2207
- associative: "left",
2208
- type: S.OPERATION
2164
+ type: w.FUNCTION,
2165
+ arity: 2
2209
2166
  }
2210
- }, w = class {
2167
+ };
2168
+ function E(...e) {
2169
+ let t = {};
2170
+ for (let n of e) t[n] = pe[n];
2171
+ return t;
2172
+ }
2173
+ var me = {};
2174
+ for (let [e, t] of Object.entries(pe)) t.type === w.FUNCTION && (me[e] = t.arity ?? 1);
2175
+ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin", "cos", "tan", "asin", "acos", "atan", "sqrt", "nthrt", "ln", "log", "logn"), ge = D, _e = E("&", "|", "!", "-"), O = class {
2211
2176
  #e;
2212
2177
  #t = [];
2213
2178
  #n = {};
2214
2179
  #r = [];
2215
2180
  #i;
2216
2181
  constructor(e) {
2217
- this.#e = typeof e > "u" ? C.POLYNOM : e, this.tokenConfigInitialization();
2182
+ this.#e = e === void 0 ? T.POLYNOM : e, this.tokenConfigInitialization();
2218
2183
  }
2219
2184
  get rpn() {
2220
2185
  return this.#t;
@@ -2223,211 +2188,216 @@ var re = {
2223
2188
  return this.#t.map((e) => e.token);
2224
2189
  }
2225
2190
  tokenConfigInitialization() {
2226
- return this.#e === C.SET ? (this.#n = oe, this.#i = !1) : this.#e === C.NUMERIC ? (this.#n = ae, this.#i = !0) : this.#e === C.EXPRESSION ? (this.#n = ie, this.#i = !0) : (this.#n = re, this.#i = !0), this.#r = Object.keys(this.#n).sort((e, t) => t.length - e.length), this.#n;
2191
+ return this.#e === T.SET ? (this.#n = _e, this.#i = !1) : this.#e === T.NUMERIC ? (this.#n = D, this.#i = !0) : this.#e === T.EXPRESSION ? (this.#n = ge, this.#i = !0) : (this.#n = he, this.#i = !0), this.#r = Object.keys(this.#n).sort((e, t) => t.length - e.length), this.#n;
2227
2192
  }
2228
2193
  NextToken(e, t) {
2229
2194
  let n, r;
2230
- if (n = "", r = void 0, e[t] === "(") n = "(", r = S.LEFT_PARENTHESIS;
2231
- else if (e[t] === ")") n = ")", r = S.RIGHT_PARENTHESIS;
2232
- else if (e[t] === ",") n = ",", r = S.FUNCTION_ARGUMENT;
2195
+ if (n = "", r = void 0, e[t] === "(") n = "(", r = w.LEFT_PARENTHESIS;
2196
+ else if (e[t] === ")") n = ")", r = w.RIGHT_PARENTHESIS;
2197
+ else if (e[t] === ",") n = ",", r = w.FUNCTION_ARGUMENT;
2233
2198
  else {
2234
2199
  for (let i of this.#r) if (e.substring(t, t + i.length) === i) {
2235
2200
  n += i, r = this.#n[i].type;
2236
2201
  break;
2237
2202
  }
2238
- for (let i in x) if (e.substring(t, t + i.length) === i) {
2239
- n += i, r = S.CONSTANT;
2203
+ for (let i in C) if (e.substring(t, t + i.length) === i) {
2204
+ n += i, r = w.CONSTANT;
2240
2205
  break;
2241
2206
  }
2242
2207
  if (n === "") if (/[0-9.]/.exec(e[t])) {
2243
2208
  let i = /^([0-9.]+)/.exec(e.substring(t));
2244
- n = i ? i[0] : "", r = S.COEFFICIENT;
2209
+ n = i ? i[0] : "", r = w.COEFFICIENT;
2245
2210
  } else if (/[a-zA-Z]/.exec(e[t])) {
2246
2211
  let i = /^([a-zA-Z])/.exec(e.substring(t));
2247
- n = i ? i[0] : "", r = S.VARIABLE;
2248
- } else console.log("Unidentified token", e[t], e, t), n = e[t], r = S.MONOM;
2212
+ n = i ? i[0] : "", r = w.VARIABLE;
2213
+ } else throw new x(`Unknown token "${e[t]}" at position ${t} in "${e}"`);
2249
2214
  }
2250
- if (r === void 0) throw Error(`Token type is undefined for token ${n}`);
2251
- return [
2252
- n,
2253
- t + n.length,
2254
- r
2255
- ];
2215
+ if (r === void 0) throw new x(`Token type is undefined for token ${n}`);
2216
+ return {
2217
+ token: n,
2218
+ nextPos: t + n.length,
2219
+ type: r
2220
+ };
2256
2221
  }
2257
2222
  parse(e, t) {
2258
- let n = [], r = [], i = "", a = 0, o;
2259
- (t ?? this.#i) && (e = te(e, this.#n));
2260
- let s = 50, c;
2261
- for (; a < e.length;) {
2262
- if (s--, s === 0) {
2263
- console.log("SECURITY LEVEL 1 EXIT");
2264
- break;
2265
- }
2266
- switch ([i, a, o] = this.NextToken(e, a), o) {
2267
- case S.MONOM:
2268
- case S.COEFFICIENT:
2269
- case S.VARIABLE:
2270
- case S.CONSTANT:
2223
+ let n = [], r = [], i = 0;
2224
+ for ((t ?? this.#i) && (e = de(e, this.#n)); i < e.length;) {
2225
+ let t = i, { token: a, nextPos: o, type: s } = this.NextToken(e, i);
2226
+ if (i = o, i <= t) throw new x(`Parser stalled at position ${t} in "${e}"`);
2227
+ switch (s) {
2228
+ case w.COEFFICIENT:
2229
+ case w.VARIABLE:
2230
+ case w.CONSTANT:
2271
2231
  n.push({
2272
- token: i,
2273
- tokenType: o
2232
+ token: a,
2233
+ tokenType: s
2274
2234
  });
2275
2235
  break;
2276
- case S.OPERATION:
2236
+ case w.OPERATION:
2277
2237
  if (r.length > 0) {
2278
2238
  let e = r[r.length - 1];
2279
- for (c = 50; e.token in this.#n && (this.#n[i].associative === "left" && this.#n[i].precedence <= this.#n[e.token].precedence || this.#n[i].associative === "right" && this.#n[i].precedence < this.#n[e.token].precedence);) {
2280
- if (c--, c === 0) {
2281
- console.log("SECURITY LEVEL 2 OPERATION EXIT");
2282
- break;
2283
- }
2284
- if (n.push(r.pop() ?? {
2285
- token: "",
2286
- tokenType: S.OPERATION
2287
- }), r.length === 0) break;
2288
- e = r[r.length - 1];
2289
- }
2239
+ for (; e.token in this.#n && (this.#n[a].associative === "left" && this.#n[a].precedence <= this.#n[e.token].precedence || this.#n[a].associative === "right" && this.#n[a].precedence < this.#n[e.token].precedence) && (n.push(r.pop() ?? {
2240
+ token: "",
2241
+ tokenType: w.OPERATION
2242
+ }), r.length !== 0);) e = r[r.length - 1];
2290
2243
  }
2291
2244
  r.push({
2292
- token: i,
2293
- tokenType: o
2245
+ token: a,
2246
+ tokenType: s
2294
2247
  });
2295
2248
  break;
2296
- case S.FUNCTION_ARGUMENT:
2297
- for (c = 50; r[r.length - 1].token !== "(" && r.length > 0;) {
2298
- if (c--, c === 0) {
2299
- console.log("SECURITY LEVEL 2 FUNCTION ARGUMENT EXIT");
2300
- break;
2301
- }
2302
- n.push(r.pop() ?? {
2303
- token: i,
2304
- tokenType: o
2305
- });
2306
- }
2249
+ case w.FUNCTION_ARGUMENT:
2250
+ for (; r.length > 0 && r[r.length - 1].token !== "(";) n.push(r.pop() ?? {
2251
+ token: a,
2252
+ tokenType: s
2253
+ });
2254
+ if (r.length === 0) throw new x(`Misplaced argument separator ',' in "${e}"`);
2307
2255
  break;
2308
- case S.LEFT_PARENTHESIS:
2256
+ case w.LEFT_PARENTHESIS:
2309
2257
  r.push({
2310
- token: i,
2311
- tokenType: o
2312
- }), e[a] === "-" && n.push({
2258
+ token: a,
2259
+ tokenType: s
2260
+ }), e[i] === "-" && n.push({
2313
2261
  token: "0",
2314
- tokenType: S.COEFFICIENT
2262
+ tokenType: w.COEFFICIENT
2315
2263
  });
2316
2264
  break;
2317
- case S.RIGHT_PARENTHESIS:
2318
- for (c = 50; r[r.length - 1].token !== "(" && r.length > 1;) {
2319
- if (c--, c === 0) {
2320
- console.log("SECURITY LEVEL 2 CLOSING PARENTHESIS EXIT");
2321
- break;
2322
- }
2323
- n.push(r.pop() ?? {
2324
- token: i,
2325
- tokenType: o
2326
- });
2327
- }
2265
+ case w.RIGHT_PARENTHESIS:
2266
+ for (; r.length > 0 && r[r.length - 1].token !== "(";) n.push(r.pop() ?? {
2267
+ token: a,
2268
+ tokenType: s
2269
+ });
2270
+ if (r.length === 0) throw new x(`Mismatched parentheses (unexpected ')') in "${e}"`);
2328
2271
  r.pop();
2329
2272
  break;
2330
- case S.FUNCTION:
2273
+ case w.FUNCTION:
2331
2274
  r.push({
2332
- token: i,
2333
- tokenType: o
2275
+ token: a,
2276
+ tokenType: s
2334
2277
  });
2335
2278
  break;
2336
- default: throw Error(`Token type ${i} is not handled`);
2279
+ default: throw new x(`Token type ${a} is not handled`);
2337
2280
  }
2338
2281
  }
2282
+ if (r.some((e) => e.token === "(")) throw new x(`Mismatched parentheses (unclosed '(') in "${e}"`);
2339
2283
  return this.#t = n.concat(r.reverse()), this;
2340
2284
  }
2341
- }, T = class {
2285
+ }, k = class {
2342
2286
  _rpn;
2343
2287
  _expression;
2344
- _isValid;
2345
2288
  constructor(e, t) {
2346
2289
  this._expression = e;
2347
2290
  try {
2348
- this._rpn = new w(C.NUMERIC).parse(e, t).rpn;
2291
+ this._rpn = new O(T.NUMERIC).parse(e, t).rpn;
2349
2292
  } catch (t) {
2350
- throw this._rpn = null, this._isValid = !1, console.warn(t), /* @__PURE__ */ Error(`There was a problem parsing: ${e}`);
2293
+ throw new x(`There was a problem parsing: ${e}`, { cause: t });
2351
2294
  }
2352
2295
  }
2353
2296
  get rpn() {
2354
- return this._rpn ?? [];
2355
- }
2356
- get isValid() {
2357
- if (this._isValid === void 0) try {
2358
- this.evaluate({ x: 2 });
2359
- } catch {
2360
- this._isValid = !1;
2361
- }
2362
- return this._isValid ?? !1;
2363
- }
2364
- set isValid(e) {
2365
- this._isValid = e;
2297
+ return this._rpn;
2366
2298
  }
2367
2299
  get expression() {
2368
2300
  return this._expression;
2369
2301
  }
2302
+ get variables() {
2303
+ let e = /* @__PURE__ */ new Set();
2304
+ for (let t of this._rpn) t.tokenType === w.VARIABLE && e.add(t.token);
2305
+ return [...e];
2306
+ }
2307
+ isValid(e) {
2308
+ return this._isStructurallyValid() ? this.variables.every((t) => e !== void 0 && Object.hasOwn(e, t)) : !1;
2309
+ }
2310
+ _isStructurallyValid() {
2311
+ let e = 0;
2312
+ for (let t of this._rpn) switch (t.tokenType) {
2313
+ case w.COEFFICIENT:
2314
+ case w.VARIABLE:
2315
+ case w.CONSTANT:
2316
+ e += 1;
2317
+ break;
2318
+ case w.OPERATION:
2319
+ if (e < 2) return !1;
2320
+ --e;
2321
+ break;
2322
+ case w.FUNCTION: {
2323
+ let n = me[t.token] ?? 1;
2324
+ if (e < n) return !1;
2325
+ e += 1 - n;
2326
+ break;
2327
+ }
2328
+ default: return !1;
2329
+ }
2330
+ return e === 1;
2331
+ }
2370
2332
  evaluate(e) {
2371
2333
  let t = [];
2372
- if (this._rpn === null) return this._isValid = !1, 0;
2373
- this._isValid = !0;
2374
- for (let n of this._rpn) if (n.tokenType === S.COEFFICIENT) if (!isNaN(+n.token)) t.push(+n.token);
2375
- else {
2376
- let e = n.token.split("/");
2377
- if (e.length !== 2) throw this._isValid = !1, /* @__PURE__ */ Error("This coefficient is not a fraction");
2378
- t.push(e[0] / +e[1]);
2379
- }
2380
- else if (n.tokenType === S.VARIABLE && e !== void 0) Object.hasOwn(e, n.token) && t.push(+e[n.token]);
2381
- else if (n.tokenType === S.CONSTANT) t.push(x[n.token]);
2382
- else if (n.tokenType === S.OPERATION) {
2334
+ for (let n of this._rpn) if (n.tokenType === w.COEFFICIENT) t.push(+n.token);
2335
+ else if (n.tokenType === w.VARIABLE) {
2336
+ if (e === void 0 || !Object.hasOwn(e, n.token)) throw new ue(`Missing value for variable "${n.token}"`);
2337
+ t.push(e[n.token]);
2338
+ } else if (n.tokenType === w.CONSTANT) t.push(C[n.token]);
2339
+ else if (n.tokenType === w.OPERATION) {
2383
2340
  if (n.token === "*") {
2384
2341
  let e = t.pop(), n = t.pop();
2385
- if (n === void 0 || e === void 0) throw this._isValid = !1, /* @__PURE__ */ Error(`The multiplication factors ${n ?? "a"} or ${e ?? "b"} are not defined`);
2342
+ if (n === void 0 || e === void 0) throw new S(`The multiplication factors ${n ?? "a"} or ${e ?? "b"} are not defined`);
2386
2343
  t.push(n * e);
2387
2344
  } else if (n.token === "/") {
2388
2345
  let e = t.pop(), n = t.pop();
2389
- if (n === void 0 || e === void 0) throw this._isValid = !1, /* @__PURE__ */ Error(`The division values ${n ?? "a"} or ${e ?? "b"} are not defined`);
2346
+ if (n === void 0 || e === void 0) throw new S(`The division values ${n ?? "a"} or ${e ?? "b"} are not defined`);
2390
2347
  t.push(n / e);
2391
2348
  } else if (n.token === "+") {
2392
2349
  let e = t.pop(), n = t.pop();
2393
- if (n === void 0 || e === void 0) throw this._isValid = !1, /* @__PURE__ */ Error(`The addition values ${n ?? "a"} or ${e ?? "b"} are not defined`);
2394
- t.push(+n + +e);
2350
+ if (n === void 0 || e === void 0) throw new S(`The addition values ${n ?? "a"} or ${e ?? "b"} are not defined`);
2351
+ t.push(n + e);
2395
2352
  } else if (n.token === "-") {
2396
2353
  let e = t.pop(), n = t.pop() ?? 0;
2397
- if (e === void 0) throw this._isValid = !1, /* @__PURE__ */ Error("The subtraction value b is not defined");
2354
+ if (e === void 0) throw new S("The subtraction value b is not defined");
2398
2355
  t.push(n - e);
2356
+ } else if (n.token === "%") {
2357
+ let e = t.pop(), n = t.pop();
2358
+ if (n === void 0 || e === void 0) throw new S(`The modulo values ${n ?? "a"} or ${e ?? "b"} are not defined`);
2359
+ t.push(n % e);
2399
2360
  } else if (n.token === "^") {
2400
2361
  let e = t.pop(), n = t.pop();
2401
- if (n === void 0 || e === void 0) throw this._isValid = !1, /* @__PURE__ */ Error(`The base value ${n ?? "a"} or exponent ${e ?? "b"} are not defined`);
2362
+ if (n === void 0 || e === void 0) throw new S(`The base value ${n ?? "a"} or exponent ${e ?? "b"} are not defined`);
2402
2363
  t.push(n ** +e);
2403
2364
  }
2404
- } else if (n.tokenType === S.FUNCTION) {
2365
+ } else if (n.tokenType === w.FUNCTION) {
2405
2366
  let e = t.pop();
2406
- if (e === void 0) throw this._isValid = !1, /* @__PURE__ */ Error(`The parameters for ${n.token} is not defined`);
2367
+ if (e === void 0) throw new S(`The parameters for ${n.token} is not defined`);
2407
2368
  if (n.token === "sin") t.push(Math.sin(e));
2408
2369
  else if (n.token === "cos") t.push(Math.cos(e));
2409
2370
  else if (n.token === "tan") t.push(Math.tan(e));
2371
+ else if (n.token === "asin") t.push(Math.asin(e));
2372
+ else if (n.token === "acos") t.push(Math.acos(e));
2373
+ else if (n.token === "atan") t.push(Math.atan(e));
2410
2374
  else if (n.token === "sqrt") t.push(Math.sqrt(e));
2411
2375
  else if (n.token === "nthrt") {
2412
2376
  let n = t.pop();
2413
- if (n === void 0) throw this._isValid = !1, /* @__PURE__ */ Error("The nthrt function requires two parameters");
2377
+ if (n === void 0) throw new S("The nthrt function requires two parameters");
2414
2378
  e % 2 == 0 && n < 0 ? t.push(NaN) : t.push((n < 0 ? -1 : 1) * Math.abs(n) ** (1 / e));
2415
- } else n.token === "ln" ? t.push(Math.log(e)) : n.token === "log" && t.push(Math.log10(e));
2379
+ } else if (n.token === "ln") t.push(Math.log(e));
2380
+ else if (n.token === "log") t.push(Math.log10(e));
2381
+ else if (n.token === "logn") {
2382
+ let n = t.pop();
2383
+ if (n === void 0) throw new S("The logn function requires two parameters");
2384
+ e <= 0 || e === 1 || n <= 0 ? t.push(NaN) : t.push(Math.log(n) / Math.log(e));
2385
+ }
2416
2386
  }
2417
2387
  if (t.length === 1) return this._numberCorrection(t[0]);
2418
- throw Error(`There was a problem parsing: ${this._expression}`);
2388
+ throw new S(`There was a problem parsing: ${this._expression}`);
2419
2389
  }
2420
2390
  _numberCorrection(e, t = 8) {
2421
2391
  return +e.toFixed(t);
2422
2392
  }
2423
- }, E = class e {
2393
+ }, A = class e {
2424
2394
  #e;
2425
2395
  #t;
2426
2396
  constructor(e) {
2427
- return this.#e = new p().zero(), this.#t = {}, e !== void 0 && this.parse(e), this;
2397
+ return this.#e = new m().zero(), this.#t = {}, e !== void 0 && this.parse(e), this;
2428
2398
  }
2429
2399
  parse(t) {
2430
- return this.#e = new p(), this.#t = {}, t instanceof e ? (this.#e = t.#e.clone(), this.#n(t), this) : t instanceof p ? (this.#e = t.clone(), this) : typeof t == "number" ? (this.#e = new p(t), this) : (isNaN(Number(t)) ? this.#s(t) : this.#e = new p(Number(t)), this);
2400
+ return this.#e = new m(), this.#t = {}, t instanceof e ? (this.#e = t.#e.clone(), this.#n(t), this) : t instanceof m ? (this.#e = t.clone(), this) : typeof t == "number" ? (this.#e = new m(t), this) : (isNaN(Number(t)) ? this.#s(t) : this.#e = new m(Number(t)), this);
2431
2401
  }
2432
2402
  clone = () => {
2433
2403
  let t = new e();
@@ -2444,10 +2414,10 @@ var re = {
2444
2414
  static gcd = (...t) => {
2445
2415
  for (let n of t) if (n.containsRationalPower()) return new e().zero();
2446
2416
  let n = new e();
2447
- n.coefficient = new p(d.gcd(...t.map((e) => e.coefficient.numerator)), d.lcm(...t.map((e) => e.coefficient.denominator))).reduce();
2417
+ n.coefficient = new m(p.gcd(...t.map((e) => e.coefficient.numerator)), p.lcm(...t.map((e) => e.coefficient.denominator))).reduce();
2448
2418
  for (let e of t) {
2449
2419
  for (let t in n.literal) t in e.literal || n.removeVariable(t);
2450
- for (let t in e.literal) !n.hasVariable(t) && e.literal[t].isStrictlyPositive() ? n.literal[t] = e.literal[t].clone() : n.literal[t] = new p(Math.min(e.literal[t].value, n.literal[t].value));
2420
+ for (let t in e.literal) !n.hasVariable(t) && e.literal[t].isStrictlyPositive() ? n.literal[t] = e.literal[t].clone() : n.literal[t] = new m(Math.min(e.literal[t].value, n.literal[t].value));
2451
2421
  }
2452
2422
  return n;
2453
2423
  };
@@ -2460,7 +2430,7 @@ var re = {
2460
2430
  for (let n of t) {
2461
2431
  let t = n instanceof e ? n : new e(n);
2462
2432
  if (this.isSameAs(t)) this.isZero() && this.#n(t), this.#e.add(t.coefficient);
2463
- else throw Error("Add monom: " + this.display + " is not similar with " + t.display);
2433
+ else throw new r("Add monom: " + this.display + " is not similar with " + t.display);
2464
2434
  }
2465
2435
  return this;
2466
2436
  };
@@ -2468,15 +2438,16 @@ var re = {
2468
2438
  return this.#e;
2469
2439
  }
2470
2440
  set coefficient(e) {
2471
- this.#e = new p(e);
2441
+ this.#e = new m(e);
2472
2442
  }
2473
2443
  containsRationalPower = () => Object.values(this.#t).some((e) => e.isRational());
2474
- degree = (e) => this.variables.length === 0 ? new p().zero() : e === void 0 ? Object.values(this.#t).reduce((e, t) => e.clone().add(t)) : this.hasVariable(e) ? this.#t[e].clone() : new p().zero();
2444
+ degree = (e) => this.variables.length === 0 ? new m().zero() : e === void 0 ? Object.values(this.#t).reduce((e, t) => e.clone().add(t)) : this.hasVariable(e) ? this.#t[e].clone() : new m().zero();
2475
2445
  derivative = (t = "x") => {
2476
2446
  if (this.hasVariable(t)) {
2477
2447
  let e = this.#t[t].clone(), n = this.clone();
2478
- return n.#t[t].subtract(1), n.#e.multiply(new p(e.clone())), n;
2479
- } else return new e().zero();
2448
+ return n.#t[t].subtract(1), n.#e.multiply(new m(e.clone())), n;
2449
+ }
2450
+ return new e().zero();
2480
2451
  };
2481
2452
  divide = (...t) => {
2482
2453
  for (let n of t) {
@@ -2488,42 +2459,42 @@ var re = {
2488
2459
  };
2489
2460
  get dividers() {
2490
2461
  if (!this.coefficient.isRelative() || this.containsRationalPower() || this.coefficient.numerator > 1e6) return [this.clone()];
2491
- let t = d.dividers(Math.abs(this.coefficient.numerator)), n = [];
2462
+ let t = p.dividers(Math.abs(this.coefficient.numerator)), n = [];
2492
2463
  for (let e in this.literal) n = this.#a(n, e);
2493
2464
  let r = [];
2494
2465
  if (n.length > 0 && t.length > 0) for (let i of t) for (let t of n) {
2495
2466
  let n = new e();
2496
- n.coefficient = new p(i), n.literal = t, r.push(n);
2467
+ n.coefficient = new m(i), n.literal = t, r.push(n);
2497
2468
  }
2498
2469
  else if (t.length === 0) for (let t of n) {
2499
2470
  let n = new e();
2500
- n.coefficient = new p().one(), n.literal = t, r.push(n);
2471
+ n.coefficient = new m().one(), n.literal = t, r.push(n);
2501
2472
  }
2502
2473
  else for (let n of t) {
2503
2474
  let t = new e();
2504
- t.coefficient = new p(n), r.push(t);
2475
+ t.coefficient = new m(n), r.push(t);
2505
2476
  }
2506
2477
  return r.length === 0 ? [new e().one()] : r;
2507
2478
  }
2508
2479
  evaluate = (e, t) => {
2509
2480
  if (t === !0) {
2510
- if (e instanceof p) return this.#r(e.value);
2481
+ if (e instanceof m) return this.#r(e.value);
2511
2482
  if (typeof e == "number") return this.#r(e);
2512
2483
  if (typeof e == "object") {
2513
2484
  let t = {};
2514
- for (let n in e) t[n] = new p(e[n]).value;
2485
+ for (let n in e) t[n] = new m(e[n]).value;
2515
2486
  return this.#r(t);
2516
2487
  }
2517
2488
  }
2518
2489
  let n = this.coefficient.clone();
2519
- if (typeof e == "number" || e instanceof p) {
2490
+ if (typeof e == "number" || e instanceof m) {
2520
2491
  let t = {};
2521
- return t[this.variables[0]] = new p(e), this.evaluate(t);
2492
+ return t[this.variables[0]] = new m(e), this.evaluate(t);
2522
2493
  }
2523
2494
  if (typeof e == "object") {
2524
2495
  if (this.variables.length === 0) return this.coefficient;
2525
2496
  for (let t in this.#t) {
2526
- let r = new p(e[t]);
2497
+ let r = new m(e[t]);
2527
2498
  n.multiply(r.pow(this.#t[t]));
2528
2499
  }
2529
2500
  }
@@ -2569,8 +2540,8 @@ var re = {
2569
2540
  this.#t = e;
2570
2541
  }
2571
2542
  set literalStr(e) {
2572
- for (let t of [...e.matchAll(/([a-z])\^([+-]?[0-9]+)/g)]) t[1] in this.#t || (this.#t[t[1]] = new p().zero()), this.#t[t[1]].add(+t[2]);
2573
- for (let t of [...e.matchAll(/([a-z](?!\^))/g)]) t[1] in this.#t || (this.#t[t[1]] = new p().zero()), this.#t[t[1]].add(1);
2543
+ for (let t of [...e.matchAll(/([a-z])\^([+-]?[0-9]+)/g)]) t[1] in this.#t || (this.#t[t[1]] = new m().zero()), this.#t[t[1]].add(+t[2]);
2544
+ for (let t of [...e.matchAll(/([a-z](?!\^))/g)]) t[1] in this.#t || (this.#t[t[1]] = new m().zero()), this.#t[t[1]].add(1);
2574
2545
  }
2575
2546
  multiply = (...t) => {
2576
2547
  for (let n of t) {
@@ -2580,7 +2551,7 @@ var re = {
2580
2551
  }
2581
2552
  return this;
2582
2553
  };
2583
- one = () => (this.#e = new p().one(), this.#t = {}, this);
2554
+ one = () => (this.#e = new m().one(), this.#t = {}, this);
2584
2555
  opposite = () => (this.#e.opposite(), this);
2585
2556
  get plotFunction() {
2586
2557
  return this.#i("plot");
@@ -2592,7 +2563,7 @@ var re = {
2592
2563
  };
2593
2564
  primitive = (e = "x") => {
2594
2565
  let t = this.clone(), n;
2595
- return t.hasVariable(e) ? (n = t.degree(e).clone().add(1), t.coefficient = t.coefficient.clone().divide(n), t.setLetter(e, n)) : (t.coefficient.isZero() && (t.coefficient = new p().one()), t.setLetter(e, 1)), t;
2566
+ return t.hasVariable(e) ? (n = t.degree(e).clone().add(1), t.coefficient = t.coefficient.clone().divide(n), t.setLetter(e, n)) : (t.coefficient.isZero() && (t.coefficient = new m().one()), t.setLetter(e, 1)), t;
2596
2567
  };
2597
2568
  reduce = () => {
2598
2569
  this.coefficient.reduce();
@@ -2603,9 +2574,9 @@ var re = {
2603
2574
  delete this.#t[e];
2604
2575
  }
2605
2576
  root = () => {
2606
- throw Error("Method not implemented.");
2577
+ throw new a("Method not implemented.");
2607
2578
  };
2608
- setLetter = (e, t) => t instanceof p ? this.hasVariable(e) && t.isZero() ? (this.removeVariable(e), this) : (this.#t[e] = t.clone(), this) : this.setLetter(e, new p(t));
2579
+ setLetter = (e, t) => t instanceof m ? this.hasVariable(e) && t.isZero() ? (this.removeVariable(e), this) : (this.#t[e] = t.clone(), this) : this.setLetter(e, new m(t));
2609
2580
  sqrt = () => {
2610
2581
  if (this.isSquare()) {
2611
2582
  this.#e.sqrt();
@@ -2617,7 +2588,7 @@ var re = {
2617
2588
  for (let n of t) {
2618
2589
  let t = n instanceof e ? n : new e(n);
2619
2590
  if (this.isSameAs(t)) this.isZero() && this.#n(t), this.#e.add(t.clone().coefficient.opposite());
2620
- else throw Error("Subtract: Is not similar: " + t.display);
2591
+ else throw new r("Subtract: Is not similar: " + t.display);
2621
2592
  }
2622
2593
  return this;
2623
2594
  };
@@ -2627,7 +2598,7 @@ var re = {
2627
2598
  n.isZero() || e.push(t);
2628
2599
  }), e.sort(), e;
2629
2600
  }
2630
- zero = () => (this.#e = new p().zero(), this.#t = {}, this);
2601
+ zero = () => (this.#e = new m().zero(), this.#t = {}, this);
2631
2602
  #n(e) {
2632
2603
  for (let t in e.literal) this.#t[t] = e.literal[t].clone();
2633
2604
  }
@@ -2637,15 +2608,15 @@ var re = {
2637
2608
  let t = {}, n = this.variables[0];
2638
2609
  return t[n] = e, this.#r(t);
2639
2610
  }
2640
- if (e instanceof p) {
2611
+ if (e instanceof m) {
2641
2612
  let t = {};
2642
- return t[this.variables[0]] = new p(e).value, this.#r(t);
2613
+ return t[this.variables[0]] = new m(e).value, this.#r(t);
2643
2614
  }
2644
2615
  if (typeof e == "object") {
2645
2616
  if (this.variables.length === 0) return this.coefficient.value;
2646
2617
  for (let n in this.#t) {
2647
2618
  let r = e[n];
2648
- r instanceof p ? t *= r.value ** this.#t[n].value : t *= r ** this.#t[n].value;
2619
+ r instanceof m ? t *= r.value ** this.#t[n].value : t *= r ** this.#t[n].value;
2649
2620
  }
2650
2621
  }
2651
2622
  return t;
@@ -2660,21 +2631,21 @@ var re = {
2660
2631
  let n = [];
2661
2632
  for (let r = 0; r <= this.literal[t].value; r++) if (e.length === 0) {
2662
2633
  let e = {};
2663
- e[t] = new p(r), n.push(e);
2634
+ e[t] = new m(r), n.push(e);
2664
2635
  } else for (let i of e) {
2665
2636
  let e = {};
2666
2637
  for (let t in i) e[t] = i[t];
2667
- e[t] = new p(r), n.push(e);
2638
+ e[t] = new m(r), n.push(e);
2668
2639
  }
2669
2640
  return n;
2670
2641
  }
2671
2642
  #o = (t, n) => {
2672
2643
  let r, i, a, o, s;
2673
- if (n.tokenType === S.COEFFICIENT) t.push(new e(new p(n.token)));
2674
- else if (n.tokenType === S.VARIABLE) {
2644
+ if (n.tokenType === w.COEFFICIENT) t.push(new e(new m(n.token)));
2645
+ else if (n.tokenType === w.VARIABLE) {
2675
2646
  let r = new e().one();
2676
2647
  r.setLetter(n.token, 1), t.push(r.clone());
2677
- } else if (n.tokenType === S.OPERATION) switch (n.token) {
2648
+ } else if (n.tokenType === w.OPERATION) switch (n.token) {
2678
2649
  case "-":
2679
2650
  i = t.pop() ?? new e().zero(), r = t.pop() ?? new e().zero(), t.push(r.subtract(i));
2680
2651
  break;
@@ -2684,26 +2655,31 @@ var re = {
2684
2655
  case "/":
2685
2656
  i = t.pop() ?? new e().one(), r = t.pop() ?? new e().one(), t.push(r.divide(i));
2686
2657
  break;
2687
- case "^":
2688
- s = t.pop()?.coefficient ?? new p().one(), a = t.pop() ?? new e().one(), o = a.variables[0], o && a.setLetter(o, s), t.push(a);
2689
- break;
2658
+ case "^": s = t.pop()?.coefficient ?? new m().one(), a = t.pop() ?? new e().one(), o = a.variables[0], o && a.setLetter(o, s), t.push(a);
2690
2659
  }
2691
2660
  };
2692
2661
  #s = (e) => {
2693
- let t = new w().parse(e).rpn, n = [];
2694
- if (t.length === 0) return this.zero(), this;
2695
- if (t.length === 1) {
2696
- let e = t[0];
2697
- return this.one(), e.tokenType === S.COEFFICIENT ? this.coefficient = new p(e.token) : e.tokenType === S.VARIABLE && this.setLetter(e.token, 1), this;
2698
- } else for (let e of t) this.#o(n, e);
2699
- return this.one(), this.multiply(n[0]), this;
2662
+ let n;
2663
+ try {
2664
+ n = new O().parse(e);
2665
+ } catch (n) {
2666
+ throw new t(`Cannot parse "${e}" as a Monom`, { cause: n });
2667
+ }
2668
+ let r = n.rpn, i = [];
2669
+ if (r.length === 0) return this.zero(), this;
2670
+ if (r.length === 1) {
2671
+ let e = r[0];
2672
+ return this.one(), e.tokenType === w.COEFFICIENT ? this.coefficient = new m(e.token) : e.tokenType === w.VARIABLE && this.setLetter(e.token, 1), this;
2673
+ }
2674
+ for (let e of r) this.#o(i, e);
2675
+ return this.one(), this.multiply(i[0]), this;
2700
2676
  };
2701
2677
  };
2702
2678
  //#endregion
2703
2679
  //#region src/algebra/operations.ts
2704
- function D(e, t) {
2705
- if (!Number.isSafeInteger(t)) throw Error("Can only raise item by an integer");
2706
- if (t < 0) throw Error("Can only raise item by a positive integer");
2680
+ function j(e, t) {
2681
+ if (!Number.isSafeInteger(t)) throw new i("Can only raise item by an integer");
2682
+ if (t < 0) throw new i("Can only raise item by a positive integer");
2707
2683
  if (t === 0) return e.one();
2708
2684
  let n = e.clone();
2709
2685
  for (let r = 1; r < t; r++) e.multiply(n);
@@ -2711,7 +2687,7 @@ function D(e, t) {
2711
2687
  }
2712
2688
  //#endregion
2713
2689
  //#region src/algebra/polynom.ts
2714
- var O = class e {
2690
+ var M = class e {
2715
2691
  #e = "x";
2716
2692
  #t;
2717
2693
  #n;
@@ -2722,9 +2698,9 @@ var O = class e {
2722
2698
  }
2723
2699
  parse(t, ...n) {
2724
2700
  if (this.#n = [], this.#t = [], this.#u(), typeof t == "string") return this.#h(t, ...n);
2725
- if ((typeof t == "number" || t instanceof p || t instanceof E) && n.length === 0) this.#n.push(new E(t));
2726
- else if (t instanceof E && n.length > 0) this.#n.push(new E(t)), n.forEach((e) => {
2727
- this.#n.push(new E(e));
2701
+ if ((typeof t == "number" || t instanceof m || t instanceof A) && n.length === 0) this.#n.push(new A(t));
2702
+ else if (t instanceof A && n.length > 0) this.#n.push(new A(t)), n.forEach((e) => {
2703
+ this.#n.push(new A(e));
2728
2704
  });
2729
2705
  else if (t instanceof e) for (let e of t.monoms) this.#n.push(e.clone());
2730
2706
  return this;
@@ -2748,21 +2724,21 @@ var O = class e {
2748
2724
  }), n;
2749
2725
  }
2750
2726
  add(...t) {
2751
- for (let n of t) n instanceof e ? this.#n = this.#n.concat(n.monoms.map((e) => e.clone())) : n instanceof E ? this.#n.push(n.clone()) : typeof n == "number" && Number.isSafeInteger(n) ? this.#n.push(new E(n.toString())) : this.#n.push(new E(n));
2727
+ for (let n of t) n instanceof e ? this.#n = this.#n.concat(n.monoms.map((e) => e.clone())) : n instanceof A ? this.#n.push(n.clone()) : typeof n == "number" && Number.isSafeInteger(n) ? this.#n.push(new A(n.toString())) : this.#n.push(new A(n));
2752
2728
  return this.reduce();
2753
2729
  }
2754
2730
  commonMonom() {
2755
- let e = new E().one();
2756
- e.coefficient = new p(this.gcdNumerator(), this.gcdDenominator());
2731
+ let e = new A().one();
2732
+ e.coefficient = new m(this.gcdNumerator(), this.gcdDenominator());
2757
2733
  for (let t of this.variables) {
2758
2734
  e.setLetter(t, this.degree(t));
2759
- for (let n of this.#n) if (e.setLetter(t, p.min(n.degree(t), e.degree(t))), e.degree(t).isZero()) break;
2735
+ for (let n of this.#n) if (e.setLetter(t, m.min(n.degree(t), e.degree(t))), e.degree(t).isZero()) break;
2760
2736
  }
2761
2737
  return e;
2762
2738
  }
2763
2739
  degree(e) {
2764
- let t = new p().zero();
2765
- for (let n of this.#n) t = p.max(n.degree(e).value, t);
2740
+ let t = new m().zero();
2741
+ for (let n of this.#n) t = m.max(n.degree(e).value, t);
2766
2742
  return t;
2767
2743
  }
2768
2744
  derivative(t) {
@@ -2771,9 +2747,9 @@ var O = class e {
2771
2747
  return n.reduce();
2772
2748
  }
2773
2749
  divide(t) {
2774
- if (t instanceof p) return this.#o(t);
2750
+ if (t instanceof m) return this.#o(t);
2775
2751
  if (typeof t == "number" && Number.isSafeInteger(t)) return this.#s(t);
2776
- if (t instanceof E) return this.divide(new e(t));
2752
+ if (t instanceof A) return this.divide(new e(t));
2777
2753
  if (t instanceof e) {
2778
2754
  if (t.monoms.length === 1 && t.variables.length === 0) return this.#o(t.monoms[0].coefficient);
2779
2755
  {
@@ -2781,28 +2757,28 @@ var O = class e {
2781
2757
  if (n.isZero()) return this.#n = e.monoms, this.#u(), this;
2782
2758
  }
2783
2759
  } else if (typeof t == "string") return this.divide(new e(t));
2784
- throw Error(`Cannot divide by ${t}`);
2760
+ throw new r(`Cannot divide by ${t}`);
2785
2761
  }
2786
2762
  empty() {
2787
2763
  return this.#n = [], this.#u(), this;
2788
2764
  }
2789
2765
  euclidean(t) {
2790
- let n = t.variables[0], r = new e().zero(), i = this.clone().reorder(n);
2766
+ let n = t.variables[0], i = new e().zero(), a = this.clone().reorder(n);
2791
2767
  if (t.variables.length === 0) return {
2792
2768
  quotient: this.clone().divide(t).reduce(),
2793
2769
  reminder: new e().zero()
2794
2770
  };
2795
- if (!this.degree(n).isNatural() || !t.degree(n).isNatural()) throw Error("Euclidean division requires integer degrees");
2796
- let a = t.monomByDegree(void 0, n), o = t.degree(n), s, c = this.degree(n).value - o.value + 1;
2797
- for (; i.degree(n).isGeq(o) && c > 0 && (c--, s = i.monomByDegree(void 0, n).clone().divide(a), !(!s.isZero() && (r.add(s), i.subtract(t.clone().multiply(s)).reduce(), s.degree(n).isZero()))););
2798
- return r.reduce(), i.reduce(), {
2799
- quotient: r,
2800
- reminder: i
2771
+ if (!this.degree(n).isNatural() || !t.degree(n).isNatural()) throw new r("Euclidean division requires integer degrees");
2772
+ let o = t.monomByDegree(void 0, n), s = t.degree(n), c, l = this.degree(n).value - s.value + 1;
2773
+ for (; a.degree(n).isGeq(s) && l > 0 && (l--, c = a.monomByDegree(void 0, n).clone().divide(o), !(!c.isZero() && (i.add(c), a.subtract(t.clone().multiply(c)).reduce(), c.degree(n).isZero()))););
2774
+ return i.reduce(), a.reduce(), {
2775
+ quotient: i,
2776
+ reminder: a
2801
2777
  };
2802
2778
  }
2803
2779
  evaluate(e, t) {
2804
2780
  if (t) return this.#c(e);
2805
- let n = new p().zero();
2781
+ let n = new m().zero();
2806
2782
  return this.#n.forEach((r) => {
2807
2783
  n.add(r.evaluate(e, t));
2808
2784
  }), n;
@@ -2828,19 +2804,19 @@ var O = class e {
2828
2804
  this.#n = [];
2829
2805
  let t = this.#e ?? "x";
2830
2806
  return e.reverse().forEach((e, n) => {
2831
- let r = new E();
2832
- r.coefficient = new p(e), r.setLetter(t, n), this.#n.push(r);
2807
+ let r = new A();
2808
+ r.coefficient = new m(e), r.setLetter(t, n), this.#n.push(r);
2833
2809
  }), this.#u(), this.reorder();
2834
2810
  }
2835
2811
  gcdDenominator() {
2836
- return d.gcd(...this.getDenominators());
2812
+ return p.gcd(...this.getDenominators());
2837
2813
  }
2838
2814
  gcdNumerator() {
2839
- return d.gcd(...this.getNumerators());
2815
+ return p.gcd(...this.getNumerators());
2840
2816
  }
2841
2817
  getCoefficients() {
2842
- if (!this.degree().isNatural()) throw Error("getCoefficients() requires a polynomial with integer degrees");
2843
- let e = this.clone().reorder(), t = this.degree().value + 1, n = Array.from({ length: t }, () => new p(0));
2818
+ if (!this.degree().isNatural()) throw new r("getCoefficients() requires a polynomial with integer degrees");
2819
+ let e = this.clone().reorder(), t = this.degree().value + 1, n = Array.from({ length: t }, () => new m(0));
2844
2820
  return e.monoms.forEach((e) => {
2845
2821
  let r = t - e.degree().value - 1;
2846
2822
  n[r] = e.coefficient.clone();
@@ -2864,24 +2840,21 @@ var O = class e {
2864
2840
  }
2865
2841
  integrate(e, t, n = "x") {
2866
2842
  let r = this.primitive(n), i = {}, a = {};
2867
- return i[n] = new p(e), a[n] = new p(t), r.evaluate(a).subtract(r.evaluate(i));
2843
+ return i[n] = new m(e), a[n] = new m(t), r.evaluate(a).subtract(r.evaluate(i));
2868
2844
  }
2869
2845
  inverse() {}
2870
2846
  isDeveloped(t) {
2871
- let n, r = t.replaceAll(/\^\(([-0-9/]+)\)/g, "$1");
2872
- if (r.includes("(") || r.includes(")")) return !1;
2873
- try {
2874
- n = new e(t);
2875
- } catch {
2876
- return !1;
2877
- }
2878
- return !!this.isEqual(n);
2847
+ let n = t.replaceAll(/\^\(([-0-9/]+)\)/g, "$1");
2848
+ if (n.includes("(") || n.includes(")")) return !1;
2849
+ let r = new e(t);
2850
+ return !!this.isEqual(r);
2879
2851
  }
2880
2852
  isDividableBy(e) {
2881
2853
  if (e.degree().isOne()) {
2882
2854
  let t = e.getZeroes()[0];
2883
2855
  return t.exact ? this.evaluate(t.fraction).isZero() : !1;
2884
- } else {
2856
+ }
2857
+ {
2885
2858
  let { reminder: t } = this.euclidean(e);
2886
2859
  return t.isZero();
2887
2860
  }
@@ -2905,33 +2878,33 @@ var O = class e {
2905
2878
  return this.#n.length === 1 && this.#n[0].coefficient.isZero() || this.#n.length === 0;
2906
2879
  }
2907
2880
  lcmDenominator() {
2908
- return d.lcm(...this.getDenominators());
2881
+ return p.lcm(...this.getDenominators());
2909
2882
  }
2910
2883
  lcmNumerator() {
2911
- return d.lcm(...this.getNumerators());
2884
+ return p.lcm(...this.getNumerators());
2912
2885
  }
2913
2886
  get length() {
2914
2887
  return this.#n.length;
2915
2888
  }
2916
2889
  limitTo(e, t) {
2917
- let n = new p(e);
2890
+ let n = new m(e);
2918
2891
  if (n.isFinite()) {
2919
2892
  let e = t ?? this.variables[0] ?? "x";
2920
2893
  return this.evaluate({ [e]: n });
2921
2894
  }
2922
2895
  let r = this.monomByDegree(void 0, t), i = r.coefficient.sign(), a = r.degree(t);
2923
- return a.isZero() ? r.coefficient.clone() : a.isStrictlyPositive() ? n.isPositive() ? i === 1 ? new p().infinite() : new p().infinite().opposite() : (a.value % 2 == 0 ? i : -i) === 1 ? new p().infinite() : new p().infinite().opposite() : new p().zero();
2896
+ return a.isZero() ? r.coefficient.clone() : a.isStrictlyPositive() ? n.isPositive() ? i === 1 ? new m().infinite() : new m().infinite().opposite() : (a.value % 2 == 0 ? i : -i) === 1 ? new m().infinite() : new m().infinite().opposite() : new m().zero();
2924
2897
  }
2925
2898
  monomByDegree(e, t) {
2926
2899
  if (e === void 0) return this.monomByDegree(this.degree(t), t);
2927
2900
  let n = this.clone().reduce();
2928
2901
  for (let r of n.#n) if (r.degree(t).isEqual(e)) return r.clone();
2929
- return new E().zero();
2902
+ return new A().zero();
2930
2903
  }
2931
2904
  monomByLetter(e) {
2932
2905
  let t = this.clone().reduce();
2933
2906
  for (let n of t.#n) if (n.hasVariable(e)) return n.clone();
2934
- return new E().zero();
2907
+ return new A().zero();
2935
2908
  }
2936
2909
  get monoms() {
2937
2910
  return this.#n;
@@ -2947,22 +2920,22 @@ var O = class e {
2947
2920
  }
2948
2921
  multiply(t) {
2949
2922
  if (t instanceof e) return this.#m(t);
2950
- if (t instanceof p) return this.#d(t);
2951
- if (t instanceof E) return this.#p(t);
2923
+ if (t instanceof m) return this.#d(t);
2924
+ if (t instanceof A) return this.#p(t);
2952
2925
  if (Number.isSafeInteger(t) && typeof t == "number") return this.#f(t);
2953
2926
  if (typeof t == "string") try {
2954
- let e = new p(t);
2927
+ let e = new m(t);
2955
2928
  return this.#d(e);
2956
- } catch {
2957
- throw Error("Cannot multiply by this value.");
2929
+ } catch (e) {
2930
+ throw new r("Cannot multiply by this value.", { cause: e });
2958
2931
  }
2959
- throw Error(`Cannot multiply by this value: ${t}`);
2932
+ throw new r(`Cannot multiply by this value: ${t}`);
2960
2933
  }
2961
2934
  get numberOfVars() {
2962
2935
  return this.variables.length;
2963
2936
  }
2964
2937
  one() {
2965
- return this.#n = [], this.#n.push(new E().one()), this.#u(), this;
2938
+ return this.#n = [], this.#n.push(new A().one()), this.#u(), this;
2966
2939
  }
2967
2940
  opposite() {
2968
2941
  return this.#n = this.#n.map((e) => e.opposite()), this.#u(), this;
@@ -2971,7 +2944,7 @@ var O = class e {
2971
2944
  return this.#l("tex", !1, !1, !0);
2972
2945
  }
2973
2946
  pow(e) {
2974
- return D(this, e).reduce();
2947
+ return j(this, e).reduce();
2975
2948
  }
2976
2949
  primitive(t) {
2977
2950
  let n = new e();
@@ -2981,7 +2954,7 @@ var O = class e {
2981
2954
  reduce() {
2982
2955
  let e = 0;
2983
2956
  for (; e < this.#n.length;) {
2984
- for (let t = e + 1; t < this.#n.length; t++) this.#n[e].isSameAs(this.#n[t]) && (this.#n[e].add(this.#n[t]), this.#n.splice(t, 1), this.#n[e].isZero() && (this.#n[e] = new E().zero()), t--);
2957
+ for (let t = e + 1; t < this.#n.length; t++) this.#n[e].isSameAs(this.#n[t]) && (this.#n[e].add(this.#n[t]), this.#n.splice(t, 1), this.#n[e].isZero() && (this.#n[e] = new A().zero()), t--);
2985
2958
  e++;
2986
2959
  }
2987
2960
  this.#n = this.#n.filter((e) => !e.coefficient.isZero());
@@ -3001,16 +2974,16 @@ var O = class e {
3001
2974
  }), this;
3002
2975
  }
3003
2976
  replaceBy(t, n) {
3004
- let r, i = new e().zero();
3005
- for (let e of this.monoms) if (!e.hasVariable(t) || e.literal[t].isZero()) i.add(e.clone());
2977
+ let i, a = new e().zero();
2978
+ for (let e of this.monoms) if (!e.hasVariable(t) || e.literal[t].isZero()) a.add(e.clone());
3006
2979
  else {
3007
- if (r = e.literal[t].clone(), e.removeVariable(t), r.isStrictlyNegative()) throw Error(`Cannot replace variable "${t}" with negative power in a Polynom`);
3008
- i.add(n.clone().pow(r.numerator).multiply(e));
2980
+ if (i = e.literal[t].clone(), e.removeVariable(t), i.isStrictlyNegative()) throw new r(`Cannot replace variable "${t}" with negative power in a Polynom`);
2981
+ a.add(n.clone().pow(i.numerator).multiply(e));
3009
2982
  }
3010
- return this.#n = i.reduce().monoms, this.#u(), this;
2983
+ return this.#n = a.reduce().monoms, this.#u(), this;
3011
2984
  }
3012
2985
  root() {
3013
- throw Error("Cannot take the root from a polynom");
2986
+ throw new r("Cannot take the root from a polynom");
3014
2987
  }
3015
2988
  get roots() {
3016
2989
  return this.#i ? this.#r : this.getZeroes();
@@ -3022,10 +2995,10 @@ var O = class e {
3022
2995
  return this.#e = e, this;
3023
2996
  }
3024
2997
  sqrt() {
3025
- throw Error("Cannot take the square root from a polynom");
2998
+ throw new r("Cannot take the square root from a polynom");
3026
2999
  }
3027
3000
  subtract(...t) {
3028
- for (let n of t) n instanceof e ? this.add(n.clone().opposite()) : n instanceof E ? this.#n.push(n.clone().opposite()) : this.#n.push(new E(n).opposite());
3001
+ for (let n of t) n instanceof e ? this.add(n.clone().opposite()) : n instanceof A ? this.#n.push(n.clone().opposite()) : this.#n.push(new A(n).opposite());
3029
3002
  return this.reduce();
3030
3003
  }
3031
3004
  tableOfSigns() {
@@ -3052,7 +3025,7 @@ var O = class e {
3052
3025
  return [...new Set(this.#n.flatMap((e) => e.variables))].sort();
3053
3026
  }
3054
3027
  zero() {
3055
- return this.#n = [], this.#n.push(new E().zero()), this.#u(), this;
3028
+ return this.#n = [], this.#n.push(new A().zero()), this.#u(), this;
3056
3029
  }
3057
3030
  get zeroes() {
3058
3031
  return this.getZeroes();
@@ -3071,7 +3044,7 @@ var O = class e {
3071
3044
  return this.#u(), this;
3072
3045
  }
3073
3046
  #s(e) {
3074
- let t = new p(e);
3047
+ let t = new m(e);
3075
3048
  for (let e of this.#n) e.coefficient.divide(t);
3076
3049
  return this.#u(), this;
3077
3050
  }
@@ -3098,7 +3071,7 @@ var O = class e {
3098
3071
  return this.reduce();
3099
3072
  }
3100
3073
  #f(e) {
3101
- return this.#d(new p(e));
3074
+ return this.#d(new m(e));
3102
3075
  }
3103
3076
  #p(e) {
3104
3077
  for (let t of this.#n) t.multiply(e);
@@ -3106,97 +3079,105 @@ var O = class e {
3106
3079
  }
3107
3080
  #m(e) {
3108
3081
  let t = [];
3109
- for (let n of this.#n) for (let r of e.monoms) t.push(E.xMultiply(n, r));
3082
+ for (let n of this.#n) for (let r of e.monoms) t.push(A.xMultiply(n, r));
3110
3083
  return this.#n = t, this.reduce();
3111
3084
  }
3112
3085
  #h(e, ...t) {
3113
3086
  if (t.length === 0) {
3114
3087
  if (e !== "" && !isNaN(Number(e))) {
3115
3088
  this.empty();
3116
- let t = new E(Number(e));
3089
+ let t = new A(Number(e));
3117
3090
  return this.add(t), this;
3118
3091
  }
3119
3092
  return this.#_(e);
3120
- } else if (/^[a-z]+$/.test(e)) {
3093
+ }
3094
+ if (/^[a-z]+$/.test(e)) {
3121
3095
  this.empty();
3122
- let n = t.map((e) => new p(e));
3096
+ let n = t.map((e) => new m(e));
3123
3097
  if (e.length > 1) {
3124
3098
  let t = e.split("");
3125
- if (n.length > t.length + 1) throw Error(`Too many values: ${t.length} letters but ${n.length} values provided`);
3099
+ if (n.length > t.length + 1) throw new i(`Too many values: ${t.length} letters but ${n.length} values provided`);
3126
3100
  let r = 0;
3127
3101
  for (let e of n) {
3128
- let n = new E();
3102
+ let n = new A();
3129
3103
  n.coefficient = e.clone(), n.literalStr = t[r] ?? "", this.add(n), r++;
3130
3104
  }
3131
3105
  } else {
3132
3106
  let t = n.length - 1;
3133
3107
  for (let r of n) {
3134
- let n = new E();
3108
+ let n = new A();
3135
3109
  n.coefficient = r.clone(), n.literalStr = `${e}^${t}`, this.add(n), t--;
3136
3110
  }
3137
3111
  }
3138
3112
  return this;
3139
- } else return this.zero();
3113
+ }
3114
+ return this.zero();
3140
3115
  }
3141
- #g(t, n) {
3142
- switch (n.tokenType) {
3143
- case S.COEFFICIENT:
3144
- t.push(new e(n.token));
3116
+ #g(n, i) {
3117
+ switch (i.tokenType) {
3118
+ case w.COEFFICIENT:
3119
+ n.push(new e(i.token));
3145
3120
  break;
3146
- case S.VARIABLE:
3147
- t.push(new e().add(new E(n.token)));
3121
+ case w.VARIABLE:
3122
+ n.push(new e().add(new A(i.token)));
3148
3123
  break;
3149
- case S.CONSTANT: throw Error("Unsupported CONSTANT token in Polynom parser");
3150
- case S.OPERATION:
3151
- if (t.length >= 2) {
3152
- let e = t.pop(), r = t.pop();
3153
- if (r === void 0 || e === void 0) throw Error("Unexpected undefined operand in Polynom parser stack");
3154
- if (n.token === "+") t.push(r.add(e));
3155
- else if (n.token === "-") t.push(r.subtract(e));
3156
- else if (n.token === "*") t.push(r.multiply(e));
3157
- else if (n.token === "/") {
3158
- if (e.degree().isStrictlyPositive()) throw Error("Cannot divide a Polynom by another Polynom of degree > 0");
3159
- t.push(r.divide(e.monoms[0].coefficient));
3160
- } else if (n.token === "^") {
3161
- if (e.degree().isStrictlyPositive()) throw Error("Cannot elevate a polynom with another polynom !");
3162
- if (e.monoms[0].coefficient.isRelative()) t.push(r.pow(e.monoms[0].coefficient.value));
3163
- else if (r.monoms.length === 1 && r.monoms[0].coefficient.isOne()) {
3164
- for (let t in r.monoms[0].literal) r.monoms[0].literal[t].multiply(e.monoms[0].coefficient);
3165
- t.push(r);
3166
- } else throw Error("Cannot raise a multi-monom Polynom to a fractional power");
3124
+ case w.CONSTANT: throw new t("Unsupported CONSTANT token in Polynom parser");
3125
+ case w.OPERATION:
3126
+ if (n.length >= 2) {
3127
+ let e = n.pop(), a = n.pop();
3128
+ if (a === void 0 || e === void 0) throw new t("Unexpected undefined operand in Polynom parser stack");
3129
+ if (i.token === "+") n.push(a.add(e));
3130
+ else if (i.token === "-") n.push(a.subtract(e));
3131
+ else if (i.token === "*") n.push(a.multiply(e));
3132
+ else if (i.token === "/") {
3133
+ if (e.degree().isStrictlyPositive()) throw new r("Cannot divide a Polynom by another Polynom of degree > 0");
3134
+ n.push(a.divide(e.monoms[0].coefficient));
3135
+ } else if (i.token === "^") {
3136
+ if (e.degree().isStrictlyPositive()) throw new r("Cannot elevate a polynom with another polynom !");
3137
+ if (e.monoms[0].coefficient.isRelative()) n.push(a.pow(e.monoms[0].coefficient.value));
3138
+ else if (a.monoms.length === 1 && a.monoms[0].coefficient.isOne()) {
3139
+ for (let t in a.monoms[0].literal) a.monoms[0].literal[t].multiply(e.monoms[0].coefficient);
3140
+ n.push(a);
3141
+ } else throw new r("Cannot raise a multi-monom Polynom to a fractional power");
3167
3142
  }
3168
- } else if (n.token === "-") {
3169
- let e = t.pop();
3170
- e && t.push(e.opposite());
3171
- } else throw Error("Error parsing the polynom");
3143
+ } else if (i.token === "-") {
3144
+ let e = n.pop();
3145
+ e && n.push(e.opposite());
3146
+ } else throw new t("Error parsing the polynom");
3172
3147
  break;
3173
- case S.MONOM: throw Error("Unexpected MONOM token in polynom parser");
3174
- case S.FUNCTION: throw Error(`Unsupported function token "${n.token}" in polynom parser`);
3148
+ case w.MONOM: throw new t("Unexpected MONOM token in polynom parser");
3149
+ case w.FUNCTION: throw new t(`Unsupported function token "${i.token}" in polynom parser`);
3175
3150
  }
3176
3151
  }
3177
3152
  #_(e) {
3178
- let t = new w().parse(e).rpn;
3153
+ let n;
3154
+ try {
3155
+ n = new O().parse(e);
3156
+ } catch (n) {
3157
+ throw new t(`Cannot parse "${e}" as a Polynom`, { cause: n });
3158
+ }
3159
+ let r = n.rpn;
3179
3160
  this.zero();
3180
- let n = [];
3181
- for (let e of t) this.#g(n, e);
3182
- return n.length === 1 && this.add(n[0]), this.reorder();
3161
+ let i = [];
3162
+ for (let e of r) this.#g(i, e);
3163
+ return i.length === 1 && this.add(i[0]), this.reorder();
3183
3164
  }
3184
- }, k = class e {
3165
+ }, N = class e {
3185
3166
  #e;
3186
3167
  #t;
3187
3168
  #n;
3188
3169
  constructor(t, n, r) {
3189
- if (this.#e = new O().zero(), this.#t = new O().zero(), this.#n = "=", t !== void 0 && n === void 0) {
3170
+ if (this.#e = new M().zero(), this.#t = new M().zero(), this.#n = "=", t !== void 0 && n === void 0) {
3190
3171
  if (t instanceof e) return t.clone();
3191
3172
  typeof t == "string" && this.parse(t);
3192
- } else t !== void 0 && n !== void 0 && (this.left = new O(t), this.right = new O(n));
3173
+ } else t !== void 0 && n !== void 0 && (this.left = new M(t), this.right = new M(n));
3193
3174
  return r !== void 0 && (this.sign = r), this;
3194
3175
  }
3195
3176
  parse = (e) => {
3196
- let t = this.#r(e);
3197
- if (t === !1) throw Error("The equation is not valid (no sign found)");
3198
- let n = e.split(t);
3199
- return this.create(new O(n[0]), new O(n[1]), this.#i(t));
3177
+ let n = this.#r(e);
3178
+ if (n === !1) throw new t("The equation is not valid (no sign found)");
3179
+ let r = e.split(n);
3180
+ return this.create(new M(r[0]), new M(r[1]), this.#i(n));
3200
3181
  };
3201
3182
  clone = () => new e(this.#e.clone(), this.#t.clone(), this.#n);
3202
3183
  get tex() {
@@ -3209,19 +3190,19 @@ var O = class e {
3209
3190
  return e.includes("=") || e.includes("<") || e.includes(">") || e.includes("<=") || e.includes(">=");
3210
3191
  }
3211
3192
  static makeSolutionsUnique(e, t) {
3212
- let n = [], r = e.filter((e) => n.includes(e.tex) ? !1 : (n.push(e.tex), !0));
3193
+ let n = [], r = e.filter((e) => !n.includes(e.tex) && (n.push(e.tex), !0));
3213
3194
  return t === !0 && r.sort((e, t) => e.value - t.value), r;
3214
3195
  }
3215
3196
  add(t) {
3216
3197
  if (t instanceof e) return this.#e.add(t.left), this.#t.add(t.right), this;
3217
3198
  if (typeof t == "string" && !e.isEquationString(t)) return this.add(new e(t));
3218
- let n = new O(t);
3199
+ let n = new M(t);
3219
3200
  return this.#e.add(n), this.#t.add(n), this;
3220
3201
  }
3221
3202
  create = (e, t, n) => (this.#e = e, this.#t = t, this.#n = this.#i(n ?? "="), this);
3222
- degree = (e) => p.max(this.#e.degree(e), this.#t.degree(e));
3203
+ degree = (e) => m.max(this.#e.degree(e), this.#t.degree(e));
3223
3204
  divide = (e) => {
3224
- let t = new p(e);
3205
+ let t = new m(e);
3225
3206
  return t.isZero() ? this : this.multiply(t.inverse());
3226
3207
  };
3227
3208
  evaluate(e, t) {
@@ -3261,7 +3242,7 @@ var O = class e {
3261
3242
  letters = () => [.../* @__PURE__ */ new Set([...this.#e.variables, ...this.#t.variables])];
3262
3243
  moveLeft = () => (this.#e.subtract(this.#t), this.#t.zero(), this);
3263
3244
  multiply = (e) => {
3264
- let t = new p(e);
3245
+ let t = new m(e);
3265
3246
  return this.#e.multiply(t), this.#t.multiply(t), this.#n !== "=" && t.sign() === -1 && this.#a(), this;
3266
3247
  };
3267
3248
  get numberOfVars() {
@@ -3294,7 +3275,7 @@ var O = class e {
3294
3275
  get signAsTex() {
3295
3276
  return this.#n === ">=" ? "\\geq" : this.#n === "<=" ? "\\leq" : this.#n;
3296
3277
  }
3297
- simplify = () => (this.multiply(d.lcm(...this.#e.getDenominators(), ...this.#t.getDenominators())), this.divide(d.gcd(...this.#e.getNumerators(), ...this.#t.getNumerators())), this);
3278
+ simplify = () => (this.multiply(p.lcm(...this.#e.getDenominators(), ...this.#t.getDenominators())), this.divide(p.gcd(...this.#e.getNumerators(), ...this.#t.getNumerators())), this);
3298
3279
  solve = () => new b(this.clone()).solve();
3299
3280
  split() {
3300
3281
  return [this.#e.clone(), this.#t.clone()];
@@ -3302,7 +3283,7 @@ var O = class e {
3302
3283
  subtract(t) {
3303
3284
  if (t instanceof e) return this.#e.subtract(t.left), this.#t.subtract(t.right), this;
3304
3285
  if (typeof t == "string" && !e.isEquationString(t)) return this.subtract(new e(t));
3305
- let n = new O(t);
3286
+ let n = new M(t);
3306
3287
  return this.#e.subtract(n), this.#t.subtract(n), this;
3307
3288
  }
3308
3289
  test = (e) => this.left.evaluate(e).isEqual(this.right.evaluate(e));
@@ -3319,34 +3300,34 @@ var O = class e {
3319
3300
  if (e.includes("=<")) return "=<";
3320
3301
  if (e.includes("<")) return "<";
3321
3302
  if (e.includes("=")) return "=";
3322
- throw Error("The equation is not valid (no sign found)");
3303
+ throw new t("The equation is not valid (no sign found)");
3323
3304
  };
3324
3305
  #i = (e) => e === void 0 ? "=" : e.includes("geq") || e.includes(">=") || e.includes("=>") ? ">=" : e.includes(">") ? ">" : e.includes("leq") || e.includes("<=") || e.includes("=<") ? "<=" : e.includes("<") ? "<" : "=";
3325
3306
  #a = () => this.#n === "=" ? this : this.#n.includes("<") ? (this.#n.replace("<", ">"), this) : (this.#n.includes(">") && this.#n.replace(">", "<"), this);
3326
- }, A = class e {
3307
+ }, P = class e {
3327
3308
  #e;
3328
3309
  #t;
3329
3310
  #n;
3330
3311
  #r = !1;
3331
3312
  constructor(t, n) {
3332
- return t instanceof e ? (this.#t = t.polynom.clone(), this.#n = t.power.clone(), n !== void 0 && this.#n.multiply(new p(n))) : t === void 0 ? (this.#t = new O(), this.#n = new p(1)) : (this.#t = new O(t), this.#n = new p(n ?? 1)), this.#e = 1, this;
3313
+ return t instanceof e ? (this.#t = t.polynom.clone(), this.#n = t.power.clone(), n !== void 0 && this.#n.multiply(new m(n))) : t === void 0 ? (this.#t = new M(), this.#n = new m(1)) : (this.#t = new M(t), this.#n = new m(n ?? 1)), this.#e = 1, this;
3333
3314
  }
3334
3315
  parse() {
3335
- throw Error("Method not implemented.");
3316
+ throw new a("Method not implemented.");
3336
3317
  }
3337
3318
  clone() {
3338
3319
  return new e(this);
3339
3320
  }
3340
3321
  get tex() {
3341
3322
  let e = this.power.numerator, t = this.power.denominator, n, r;
3342
- return this.#e === 0 && t > 1 ? (n = `\\sqrt${t === 2 ? "" : `[ ${t} ]`}{ ${this.polynom.tex} }`, r = e === 1 ? "" : `^{ ${e} }`) : (n = this.#r && this.power.isOne() ? this.polynom.tex : m(this.polynom.tex), r = t === 1 && e === 1 ? "" : `^{ ${this.power.tex} }`), n = `${n}${r}`, this.#e === 0 && e < 0 && (n = `\\frac{ 1 }{ ${n} }`), n;
3323
+ return this.#e === 0 && t > 1 ? (n = `\\sqrt${t === 2 ? "" : `[ ${t} ]`}{ ${this.polynom.tex} }`, r = e === 1 ? "" : `^{ ${e} }`) : (n = this.#r && this.power.isOne() ? this.polynom.tex : se(this.polynom.tex), r = t === 1 && e === 1 ? "" : `^{ ${this.power.tex} }`), n = `${n}${r}`, this.#e === 0 && e < 0 && (n = `\\frac{ 1 }{ ${n} }`), n;
3343
3324
  }
3344
3325
  get display() {
3345
3326
  let e = this.power.numerator, t = this.power.denominator, n, r;
3346
- return this.#e === 0 && t > 1 ? (n = `${t === 2 ? "sqrt" : `root(${t})`}(${this.polynom.display})`, r = e === 1 ? "" : `^(${e})`) : (n = this.#r && this.power.isOne() ? this.polynom.display : m(this.polynom.display, !1), r = t === 1 && e === 1 ? "" : `^(${this.power.display})`), n = `${n}${r}`, this.#e === 0 && e < 0 && (n = `1/(${n})`), n;
3327
+ return this.#e === 0 && t > 1 ? (n = `${t === 2 ? "sqrt" : `root(${t})`}(${this.polynom.display})`, r = e === 1 ? "" : `^(${e})`) : (n = this.#r && this.power.isOne() ? this.polynom.display : se(this.polynom.display, !1), r = t === 1 && e === 1 ? "" : `^(${this.power.display})`), n = `${n}${r}`, this.#e === 0 && e < 0 && (n = `1/(${n})`), n;
3347
3328
  }
3348
3329
  add() {
3349
- throw Error("Adding two factors is not possible");
3330
+ throw new r("Adding two factors is not possible");
3350
3331
  }
3351
3332
  get asSingle() {
3352
3333
  return this.#r = !0, this;
@@ -3363,19 +3344,19 @@ var O = class e {
3363
3344
  }
3364
3345
  develop() {
3365
3346
  if (this.power.isNatural()) return this.polynom.clone().pow(this.power.value);
3366
- throw Error("The power must be a natural number");
3347
+ throw new r("The power must be a natural number");
3367
3348
  }
3368
3349
  divide(t) {
3369
3350
  if (t instanceof e && this.isSameAs(t)) return this.power.subtract(t.power), this;
3370
- let n = new O(t);
3351
+ let n = new M(t);
3371
3352
  if (this.isSameAs(n)) return this.power.subtract(1), this;
3372
- throw Error("The two factors must be the same");
3353
+ throw new r("The two factors must be the same");
3373
3354
  }
3374
3355
  evaluate(e, t) {
3375
3356
  return t ? this.polynom.evaluate(e, !0) ** this.power.value : this.polynom.evaluate(e).pow(this.power);
3376
3357
  }
3377
3358
  fromPolynom(e) {
3378
- return this.#t = new O(e), this.#n = new p(1), this;
3359
+ return this.#t = new M(e), this.#n = new m(1), this;
3379
3360
  }
3380
3361
  hasVariable(e) {
3381
3362
  return this.polynom.hasVariable(e);
@@ -3391,7 +3372,7 @@ var O = class e {
3391
3372
  }
3392
3373
  isSameAs(t) {
3393
3374
  let n;
3394
- return n = t instanceof e ? t.polynom : t instanceof O ? t : new O(t), this.polynom.isEqual(n);
3375
+ return n = t instanceof e ? t.polynom : t instanceof M ? t : new M(t), this.polynom.isEqual(n);
3395
3376
  }
3396
3377
  isZero() {
3397
3378
  return this.polynom.isZero();
@@ -3400,15 +3381,15 @@ var O = class e {
3400
3381
  let n = new e(t);
3401
3382
  if (this.polynom.monoms.length === 1 && this.power.isOne() && n.polynom.monoms.length === 1 && this.power.isOne()) return this.polynom.multiply(n.polynom), this;
3402
3383
  if (t instanceof e && this.isSameAs(t)) return this.power.add(t.power), this;
3403
- let r = new O(t);
3404
- if (this.isSameAs(r)) return this.power.add(1), this;
3405
- throw Error("The two factors must be the same");
3384
+ let i = new M(t);
3385
+ if (this.isSameAs(i)) return this.power.add(1), this;
3386
+ throw new r("The two factors must be the same");
3406
3387
  }
3407
3388
  one() {
3408
3389
  return this.#t.one(), this.#n.one(), this;
3409
3390
  }
3410
3391
  opposite() {
3411
- throw Error("Method not implemented.");
3392
+ throw new a("Method not implemented.");
3412
3393
  }
3413
3394
  get polynom() {
3414
3395
  return this.#t;
@@ -3423,13 +3404,13 @@ var O = class e {
3423
3404
  return this.#n;
3424
3405
  }
3425
3406
  set power(e) {
3426
- this.#n = new p(e);
3407
+ this.#n = new m(e);
3427
3408
  }
3428
3409
  primitive() {
3429
- throw Error("Method not implemented.");
3410
+ throw new a("Method not implemented.");
3430
3411
  }
3431
3412
  reduce() {
3432
- throw Error("Method not implemented.");
3413
+ throw new a("Method not implemented.");
3433
3414
  }
3434
3415
  root(e) {
3435
3416
  return this.power.divide(e), this;
@@ -3438,7 +3419,7 @@ var O = class e {
3438
3419
  return this.root(2);
3439
3420
  }
3440
3421
  subtract() {
3441
- throw Error("Subtracting two factors is not possible");
3422
+ throw new r("Subtracting two factors is not possible");
3442
3423
  }
3443
3424
  tableOfSigns() {
3444
3425
  let e = this.power.clone().reduce(), t = this.polynom.tableOfSigns();
@@ -3470,19 +3451,19 @@ var O = class e {
3470
3451
  let r = n ? 1 : -1, i = [];
3471
3452
  for (let n of t.matchAll(/\(([^)]+)\)(?:\^(-?[0-9]+(?:\/[0-9]+)?|\(-?[0-9]+(?:\/[0-9]+)?\)))?|([^(]+)/g)) if (n[1] !== void 0) {
3472
3453
  let t = (n[2] ?? "1").replace(/[()]/g, "");
3473
- i.push(new e(new O(n[1]), new p(t).multiply(r)));
3474
- } else n[3]?.trim() && i.push(new e(new O(n[3].trim()), new p(r)));
3454
+ i.push(new e(new M(n[1]), new m(t).multiply(r)));
3455
+ } else n[3]?.trim() && i.push(new e(new M(n[3].trim()), new m(r)));
3475
3456
  return i;
3476
3457
  }
3477
- }, j = /* @__PURE__ */ function(e) {
3458
+ }, F = /* @__PURE__ */ function(e) {
3478
3459
  return e[e.ROOT = 0] = "ROOT", e[e.POWER = 1] = "POWER", e;
3479
- }({}), se = class e {
3460
+ }({}), I = class e {
3480
3461
  #e;
3481
3462
  #t;
3482
3463
  constructor(...e) {
3483
3464
  return this.#e = [], this.#t = [], e.length > 0 && this.parse(...e), this;
3484
3465
  }
3485
- parse = (...e) => (this.#e = e.map((e) => new k(e)), this.#n(), this);
3466
+ parse = (...e) => (this.#e = e.map((e) => new N(e)), this.#n(), this);
3486
3467
  clone = () => new e().parse(...this.#e.map((e) => e.clone()));
3487
3468
  get tex() {
3488
3469
  let e = this.clone().reorder();
@@ -3491,11 +3472,11 @@ var O = class e {
3491
3472
  get display() {
3492
3473
  return this.tex + "as display";
3493
3474
  }
3494
- static fromMatrix(t, n = "xyz") {
3495
- let r = t[0].length;
3496
- if (t.some((e) => e.length !== r)) throw Error("All rows must have the same number of columns");
3497
- let i = n.split("").splice(0, r - 1);
3498
- return new e(...t.map((e) => new k(new O(i.join(""), ...e), 0)));
3475
+ static fromMatrix(t, r = "xyz") {
3476
+ let i = t[0].length;
3477
+ if (t.some((e) => e.length !== i)) throw new n("All rows must have the same number of columns");
3478
+ let a = r.split("").splice(0, i - 1);
3479
+ return new e(...t.map((e) => new N(new M(a.join(""), ...e), 0)));
3499
3480
  }
3500
3481
  static solutionAsDisplay(e) {
3501
3482
  return `(${e.map((e) => e.display).join(";")})`;
@@ -3503,15 +3484,15 @@ var O = class e {
3503
3484
  static solutionAsTex(e) {
3504
3485
  return `\\left( ${e.map((e) => e.tex).join(" ; ")} \\right)`;
3505
3486
  }
3506
- add(t, n) {
3487
+ add(t, r) {
3507
3488
  if (t instanceof e) {
3508
3489
  let e = t.equations.length;
3509
- if (e !== this.#e.length) throw Error("The number of equations must be the same");
3490
+ if (e !== this.#e.length) throw new n("The number of equations must be the same");
3510
3491
  for (let n = 0; n < e; n++) this.#e[n].add(t.equations[n]);
3511
3492
  } else {
3512
- if (n === void 0 || n < 0 || n >= this.#e.length) throw Error("Index out of range");
3513
- let e = new k(t);
3514
- this.#e[n].add(e);
3493
+ if (r === void 0 || r < 0 || r >= this.#e.length) throw new o("Index out of range");
3494
+ let e = new N(t);
3495
+ this.#e[r].add(e);
3515
3496
  }
3516
3497
  return this;
3517
3498
  }
@@ -3533,7 +3514,7 @@ var O = class e {
3533
3514
  return t !== void 0 && t.length > 0 && (o = t[0].length), `\\left\\{\\begin{array}{${"r".repeat(i.length)}cl ${"|l".repeat(o)}}${a.join("\\\\ ")}\\end{array}\\right.`;
3534
3515
  };
3535
3516
  degree(e) {
3536
- return p.max(...this.#e.map((t) => t.degree(e)));
3517
+ return m.max(...this.#e.map((t) => t.degree(e)));
3537
3518
  }
3538
3519
  get equations() {
3539
3520
  return this.#e;
@@ -3542,7 +3523,7 @@ var O = class e {
3542
3523
  this.#e = e, this.#n();
3543
3524
  }
3544
3525
  evaluate(e, t) {
3545
- throw Error("Method not implemented.");
3526
+ throw new a("Method not implemented.");
3546
3527
  }
3547
3528
  hasVariable(e) {
3548
3529
  return this.#t.includes(e);
@@ -3562,11 +3543,11 @@ var O = class e {
3562
3543
  }
3563
3544
  multiply(e, t) {
3564
3545
  if (Array.isArray(e)) {
3565
- if (e.length !== this.#e.length) throw Error("The number of values must be the same as the number of equations");
3546
+ if (e.length !== this.#e.length) throw new n("The number of values must be the same as the number of equations");
3566
3547
  for (let t = 0; t < e.length; t++) this.#e[t].multiply(e[t]);
3567
3548
  return this;
3568
3549
  }
3569
- if (t === void 0 || t < 0 || t >= this.#e.length) throw Error("Index out of range");
3550
+ if (t === void 0 || t < 0 || t >= this.#e.length) throw new o("Index out of range");
3570
3551
  return this.#e[t].multiply(e), this;
3571
3552
  }
3572
3553
  reduce() {
@@ -3579,13 +3560,13 @@ var O = class e {
3579
3560
  solve() {
3580
3561
  let [e, t] = this.matrix, n = e.map((e, n) => [...e, t[n]]);
3581
3562
  for (let t = 0; t < e.length; t++) {
3582
- let r = n[t][t].clone();
3583
- if (r.isZero()) {
3563
+ let i = n[t][t].clone();
3564
+ if (i.isZero()) {
3584
3565
  let e = n.find((e, n) => n > t && !e[t].isZero());
3585
- if (e) n[t].forEach((t, n) => t.add(e[n])), r = n[t][t].clone();
3586
- else throw Error("Unsolvable...");
3566
+ if (e) n[t].forEach((t, n) => t.add(e[n])), i = n[t][t].clone();
3567
+ else throw new r("Unsolvable...");
3587
3568
  }
3588
- n[t] = n[t].map((e) => e.divide(r));
3569
+ n[t] = n[t].map((e) => e.divide(i));
3589
3570
  for (let r = 0; r < e.length; r++) {
3590
3571
  if (r === t) continue;
3591
3572
  let e = n[r][t].clone().opposite();
@@ -3599,7 +3580,7 @@ var O = class e {
3599
3580
  let t = [], n = this.equations.map((t) => t.left.monomByLetter(e).coefficient.value);
3600
3581
  return n.forEach((e, r) => {
3601
3582
  for (let i = r + 1; i < n.length; i++) {
3602
- let a = d.lcm(e, n[i]), o = e < 0 ? -1 : 1;
3583
+ let a = p.lcm(e, n[i]), o = e < 0 ? -1 : 1;
3603
3584
  t.push([{
3604
3585
  id: r,
3605
3586
  factor: o * a / e
@@ -3610,15 +3591,15 @@ var O = class e {
3610
3591
  }
3611
3592
  }), t.sort((e, t) => Math.abs(e[0].factor) + Math.abs(e[1].factor) - (Math.abs(t[0].factor) + Math.abs(t[1].factor)));
3612
3593
  }
3613
- subtract(t, n) {
3594
+ subtract(t, r) {
3614
3595
  if (t instanceof e) {
3615
3596
  let e = t.equations.length;
3616
- if (e !== this.#e.length) throw Error("The number of equations must be the same");
3597
+ if (e !== this.#e.length) throw new n("The number of equations must be the same");
3617
3598
  for (let n = 0; n < e; n++) this.#e[n].subtract(t.equations[n]);
3618
3599
  } else {
3619
- if (n === void 0 || n < 0 || n >= this.#e.length) throw Error("Index out of range");
3620
- let e = new k(t);
3621
- this.#e[n].subtract(e);
3600
+ if (r === void 0 || r < 0 || r >= this.#e.length) throw new o("Index out of range");
3601
+ let e = new N(t);
3602
+ this.#e[r].subtract(e);
3622
3603
  }
3623
3604
  return this;
3624
3605
  }
@@ -3652,12 +3633,19 @@ var O = class e {
3652
3633
  n.variable = e, t.push(n);
3653
3634
  }), t);
3654
3635
  }
3655
- }, ce = class {
3636
+ }, L = class {
3656
3637
  #e;
3657
3638
  constructor(e) {
3658
3639
  return this.#e = [], e !== void 0 && this.parse(e), this;
3659
3640
  }
3660
- parse = (e) => (this.#e = new w(C.SET).parse(e).rpn, this);
3641
+ parse = (e) => {
3642
+ try {
3643
+ this.#e = new O(T.SET).parse(e).rpn;
3644
+ } catch (n) {
3645
+ throw new t(`Cannot parse "${e}" as a LogicalSet`, { cause: n });
3646
+ }
3647
+ return this;
3648
+ };
3661
3649
  get tex() {
3662
3650
  let e = [];
3663
3651
  for (let t of this.#e) if (t.tokenType === "variable") e.push(t);
@@ -3689,15 +3677,13 @@ var O = class e {
3689
3677
  }));
3690
3678
  }
3691
3679
  break;
3692
- case "!":
3693
- if (e.length >= 1) {
3694
- let t = e.pop();
3695
- t && e.push({
3696
- token: `\\overline{ ${t.token} }`,
3697
- tokenType: "variable"
3698
- });
3699
- }
3700
- break;
3680
+ case "!": if (e.length >= 1) {
3681
+ let t = e.pop();
3682
+ t && e.push({
3683
+ token: `\\overline{ ${t.token} }`,
3684
+ tokenType: "variable"
3685
+ });
3686
+ }
3701
3687
  }
3702
3688
  return e[0].token;
3703
3689
  }
@@ -3800,24 +3786,23 @@ var O = class e {
3800
3786
  t && e && n.push(new Set([...t].filter((t) => !e.has(t))));
3801
3787
  }
3802
3788
  break;
3803
- case "!":
3804
- if (n.length >= 1) {
3805
- let e = n.pop();
3806
- e && n.push(new Set([...r].filter((t) => !e.has(t))));
3807
- }
3808
- break;
3789
+ case "!": if (n.length >= 1) {
3790
+ let e = n.pop();
3791
+ e && n.push(new Set([...r].filter((t) => !e.has(t))));
3792
+ }
3809
3793
  }
3810
3794
  return [...n[0]].sort();
3811
3795
  }
3812
- }, M = class e {
3813
- #e = j.POWER;
3796
+ }, R = class e {
3797
+ #e = F.POWER;
3814
3798
  #t = [];
3815
3799
  constructor(...e) {
3816
3800
  return this.parse(...e), this;
3817
3801
  }
3818
3802
  parse(...t) {
3819
3803
  return this.#t = [], t.length === 0 || t.forEach((t) => {
3820
- t instanceof e ? this.#t.push(...t.factors.map((e) => e.clone())) : this.#t.push(new A(t));
3804
+ if (typeof t == "string") return this.fromString(t);
3805
+ t instanceof e ? this.#t.push(...t.factors.map((e) => e.clone())) : this.#t.push(new P(t));
3821
3806
  }), this;
3822
3807
  }
3823
3808
  clone() {
@@ -3832,16 +3817,16 @@ var O = class e {
3832
3817
  return t.length === 0 ? e.length === 1 ? e[0].asSingle.display : e.map((e, t) => t === 0 && e.polynom.monoms.length === 1 ? e.asSingle.display : e.display).join("") : `(${e.length === 1 ? e[0].asSingle.display : e.map((e) => e.display).join("")})/(${t.length === 1 ? t[0].asSingle.display : t.map((e) => e.display).join("")})`;
3833
3818
  }
3834
3819
  static #n(t, n) {
3835
- let r = N(t), i = N(n), a = Object.keys(r).filter((e) => Object.hasOwn(i, e)).map((e) => {
3836
- let t = r[e].reduce((e, t) => e.add(t.power), new p("0")), n = i[e].reduce((e, t) => e.add(t.power), new p("0"));
3837
- return new A(e, p.min(t, n));
3820
+ let r = z(t), i = z(n), a = Object.keys(r).filter((e) => Object.hasOwn(i, e)).map((e) => {
3821
+ let t = r[e].reduce((e, t) => e.add(t.power), new m("0")), n = i[e].reduce((e, t) => e.add(t.power), new m("0"));
3822
+ return new P(e, m.min(t, n));
3838
3823
  });
3839
3824
  return new e(...a);
3840
3825
  }
3841
3826
  static #r(t, n) {
3842
- let r = N(t), i = N(n), a = [.../* @__PURE__ */ new Set([...Object.keys(r), ...Object.keys(i)])].map((e) => {
3843
- let t = Object.hasOwn(r, e) ? r[e].reduce((e, t) => e.add(t.power), new p("0")) : new p(0), n = Object.hasOwn(i, e) ? i[e].reduce((e, t) => e.add(t.power), new p("0")) : new p(0);
3844
- return new A(e, p.max(t, n));
3827
+ let r = z(t), i = z(n), a = [.../* @__PURE__ */ new Set([...Object.keys(r), ...Object.keys(i)])].map((e) => {
3828
+ let t = Object.hasOwn(r, e) ? r[e].reduce((e, t) => e.add(t.power), new m("0")) : new m(0), n = Object.hasOwn(i, e) ? i[e].reduce((e, t) => e.add(t.power), new m("0")) : new m(0);
3829
+ return new P(e, m.max(t, n));
3845
3830
  });
3846
3831
  return new e(...a);
3847
3832
  }
@@ -3866,17 +3851,17 @@ var O = class e {
3866
3851
  e.multiply(t.clone().divide(r[n]));
3867
3852
  }), i = t;
3868
3853
  }
3869
- let a = e.gcd(...n), o = new O(0).add(...n.map((e) => e.divide(a).reduce().develop().factors[0].polynom)).reduce();
3870
- return this.#t = [...a.factors, new A(o)], i && this.divide(i), this.#t = this.#t.filter((e) => !e.power.isZero()), this;
3854
+ let a = e.gcd(...n), o = new M(0).add(...n.map((e) => e.divide(a).reduce().develop().factors[0].polynom)).reduce();
3855
+ return this.#t = [...a.factors, new P(o)], i && this.divide(i), this.#t = this.#t.filter((e) => !e.power.isZero()), this;
3871
3856
  }
3872
3857
  get asPower() {
3873
- return this.#e = j.POWER, this;
3858
+ return this.#e = F.POWER, this;
3874
3859
  }
3875
3860
  get asRoot() {
3876
- return this.#e = j.ROOT, this;
3861
+ return this.#e = F.ROOT, this;
3877
3862
  }
3878
3863
  degree(e) {
3879
- return this.#t.reduce((t, n) => t.add(n.degree(e)), new p("0"));
3864
+ return this.#t.reduce((t, n) => t.add(n.degree(e)), new m("0"));
3880
3865
  }
3881
3866
  get denominator() {
3882
3867
  return new e(...this.#t.filter((e) => e.power.isNegative()).map((e) => e.clone().inverse()));
@@ -3892,7 +3877,7 @@ var O = class e {
3892
3877
  return r !== void 0 && (this.#t = r.factors), this.add(...t);
3893
3878
  }
3894
3879
  develop() {
3895
- let t = new O("1"), n = new O("1");
3880
+ let t = new M("1"), n = new M("1");
3896
3881
  return this.numerator.factors.forEach((e) => {
3897
3882
  t.multiply(e.develop());
3898
3883
  }), this.denominator.factors.forEach((e) => {
@@ -3903,7 +3888,7 @@ var O = class e {
3903
3888
  return this.#t = this.#t.concat(e.clone().factors.map((e) => e.inverse())), this;
3904
3889
  }
3905
3890
  evaluate(e, t) {
3906
- return t ? this.#t.reduce((n, r) => n * r.evaluate(e, t), 1) : this.#t.reduce((t, n) => t.multiply(n.evaluate(e)), new p("1"));
3891
+ return t ? this.#t.reduce((n, r) => n * r.evaluate(e, t), 1) : this.#t.reduce((t, n) => t.multiply(n.evaluate(e)), new m("1"));
3907
3892
  }
3908
3893
  factorize(t) {
3909
3894
  let n = [];
@@ -3911,7 +3896,7 @@ var O = class e {
3911
3896
  let r = e.polynom.factorize(t);
3912
3897
  if (r.length > 1) {
3913
3898
  let t = e.power.clone();
3914
- n.push(...r.map((e) => new A(e, t)));
3899
+ n.push(...r.map((e) => new P(e, t)));
3915
3900
  } else n.push(e.clone());
3916
3901
  });
3917
3902
  let r = new e(...n), i = r.numerator.reduce(), a = r.denominator.reduce();
@@ -3924,20 +3909,20 @@ var O = class e {
3924
3909
  this.#t = e;
3925
3910
  }
3926
3911
  fromPolynom(e, t) {
3927
- if (this.#t = [new A(new O(e))], t) {
3928
- let e = new O(t);
3912
+ if (this.#t = [new P(new M(e))], t) {
3913
+ let e = new M(t);
3929
3914
  if (e.isOne()) return this;
3930
- if (e.isZero()) throw Error("Cannot divide by zero");
3931
- this.#t.push(new A(e, -1));
3915
+ if (e.isZero()) throw new r("Cannot divide by zero");
3916
+ this.#t.push(new P(e, -1));
3932
3917
  }
3933
3918
  return this;
3934
3919
  }
3935
3920
  fromString(e) {
3936
3921
  this.#t = [];
3937
- let [t, ...n] = _(e, "/");
3938
- if (t === "") throw Error("Parsing a PolyFactor from a string requires a numerator");
3939
- if (n.length > 1) throw Error("Parsing a PolyFactor from a string only allows max one signe \"/\"");
3940
- return n.length === 0 ? this.#t = A.factorsFromString(h(t), !0) : this.#t = [...A.factorsFromString(h(t), !0), ...A.factorsFromString(h(n[0]), !1)], this;
3922
+ let [n, ...r] = _(e, "/");
3923
+ if (n === "") throw new t("Parsing a PolyFactor from a string requires a numerator");
3924
+ if (r.length > 1) throw new t("Parsing a PolyFactor from a string only allows max one signe \"/\"");
3925
+ return this.#t = r.length === 0 ? P.factorsFromString(h(n), !0) : [...P.factorsFromString(h(n), !0), ...P.factorsFromString(h(r[0]), !1)], this;
3941
3926
  }
3942
3927
  getRoots() {
3943
3928
  return [];
@@ -3962,36 +3947,37 @@ var O = class e {
3962
3947
  isZero() {
3963
3948
  return this.#t.every((e) => e.isZero());
3964
3949
  }
3965
- multiply(...e) {
3966
- return e.forEach((e) => {
3967
- this.#t = this.#t.concat(e.clone().factors);
3950
+ multiply(...t) {
3951
+ return t.forEach((t) => {
3952
+ let n = new e(t);
3953
+ this.#t = this.#t.concat(n.factors);
3968
3954
  }), this;
3969
3955
  }
3970
3956
  get numerator() {
3971
3957
  return new e(...this.#t.filter((e) => e.power.isPositive()));
3972
3958
  }
3973
3959
  one() {
3974
- return this.#t = [new A("1", "1")], this;
3960
+ return this.#t = [new P("1", "1")], this;
3975
3961
  }
3976
3962
  opposite() {
3977
3963
  let e = this.#t.findIndex((e) => e.display === "(-1)");
3978
- return e >= 0 ? this.#t.splice(e, 1) : this.#t.push(new A("-1", "1")), this;
3964
+ return e >= 0 ? this.#t.splice(e, 1) : this.#t.push(new P("-1", "1")), this;
3979
3965
  }
3980
3966
  pow(e) {
3981
3967
  return this.#t = this.#t.map((t) => t.pow(e)), this;
3982
3968
  }
3983
3969
  primitive() {
3984
- throw Error("Method not implemented.");
3970
+ throw new a("Method not implemented.");
3985
3971
  }
3986
3972
  reduce() {
3987
- let e = N(this);
3973
+ let e = z(this);
3988
3974
  this.#t = Object.values(e).map((e) => {
3989
3975
  let t = e[0].polynom;
3990
- return new A(t, e.reduce((e, t) => e.add(t.power), new p("0")).reduce());
3976
+ return new P(t, e.reduce((e, t) => e.add(t.power), new m("0")).reduce());
3991
3977
  }).filter((e) => !e.power.isZero());
3992
- let t = new A(1), n = new A(1), r = this.#t.filter((e) => e.polynom.monoms.length === 1 && e.power.isRelative());
3978
+ let t = new P(1), n = new P(1), r = this.#t.filter((e) => e.polynom.monoms.length === 1 && e.power.isRelative());
3993
3979
  return r.length > 0 && (r.forEach((e) => {
3994
- e.power.isPositive() ? t.multiply(new A(e.polynom.clone().pow(e.power.value))) : n.multiply(new A(e.polynom.clone().pow(-e.power.value)));
3980
+ e.power.isPositive() ? t.multiply(new P(e.polynom.clone().pow(e.power.value))) : n.multiply(new P(e.polynom.clone().pow(-e.power.value)));
3995
3981
  }), this.#t = this.#t.filter((e) => !(e.polynom.monoms.length === 1 && e.power.isRelative())), n.polynom.isOne() || this.#t.push(n.inverse()), t.polynom.isOne() || this.#t.push(t)), this;
3996
3982
  }
3997
3983
  root(e) {
@@ -4015,7 +4001,7 @@ var O = class e {
4015
4001
  }
4016
4002
  tableOfSigns() {
4017
4003
  let e = this.getZeroes(), t = e.map((e) => e.value), n = this.factorize().factors.map((e) => ({
4018
- factor: new A(e),
4004
+ factor: new P(e),
4019
4005
  ...e.tableOfSigns()
4020
4006
  }));
4021
4007
  return n.forEach((n) => {
@@ -4038,9 +4024,7 @@ var O = class e {
4038
4024
  case "h":
4039
4025
  e[n] = "h";
4040
4026
  break;
4041
- case "-":
4042
- e[n] = e[n] === "h" ? "h" : e[n] === "-" ? "+" : "-";
4043
- break;
4027
+ case "-": e[n] = e[n] === "h" ? "h" : e[n] === "-" ? "+" : "-";
4044
4028
  }
4045
4029
  }), e), []),
4046
4030
  roots: e,
@@ -4051,18 +4035,18 @@ var O = class e {
4051
4035
  return this.#t.reduce((e, t) => e.concat(t.variables), []);
4052
4036
  }
4053
4037
  zero() {
4054
- return this.#t = [new A("0", "1")], this;
4038
+ return this.#t = [new P("0", "1")], this;
4055
4039
  }
4056
4040
  #i() {
4057
4041
  let e, t = [];
4058
- return this.#e === j.ROOT ? (e = this.numerator.factors, t = this.denominator.factors) : e = this.#t, e.length === 0 && (e = [new A("1")]), {
4042
+ return this.#e === F.ROOT ? (e = this.numerator.factors, t = this.denominator.factors) : e = this.#t, e.length === 0 && (e = [new P("1")]), {
4059
4043
  num: e,
4060
4044
  den: t
4061
4045
  };
4062
4046
  }
4063
4047
  };
4064
- function N(e) {
4065
- let t = new p().one(), n = new p().one(), r = e.factors.reduce((e, r) => {
4048
+ function z(e) {
4049
+ let t = new m().one(), n = new m().one(), r = e.factors.reduce((e, r) => {
4066
4050
  if (r.polynom.degree().isZero() && r.power.isRelative()) {
4067
4051
  let i = r.polynom.monoms[0].coefficient.pow(r.power.clone().abs());
4068
4052
  return r.power.isPositive() ? t.multiply(i) : n.multiply(i), e;
@@ -4070,11 +4054,11 @@ function N(e) {
4070
4054
  let i = r.polynom.display;
4071
4055
  return Object.hasOwn(e, i) ? e[i].push(r) : e[i] = [r], e;
4072
4056
  }, {}), { numerator: i, denominator: a } = t.divide(n).reduce();
4073
- return i !== 1 && (r[i.toString()] = [new A(i, 1)]), a !== 1 && (r[a.toString()] = [new A(a, -1)]), r;
4057
+ return i !== 1 && (r[i.toString()] = [new P(i, 1)]), a !== 1 && (r[a.toString()] = [new P(a, -1)]), r;
4074
4058
  }
4075
4059
  //#endregion
4076
4060
  //#region src/algebra/matrix.ts
4077
- var le = class e {
4061
+ var ve = class e {
4078
4062
  #e = null;
4079
4063
  #t = 0;
4080
4064
  #n = [];
@@ -4114,7 +4098,7 @@ var le = class e {
4114
4098
  return this.#e = null, t;
4115
4099
  }
4116
4100
  add(e) {
4117
- if (!this.canBeAdded(e)) throw Error("Cannot add a matrix with different dimensions.");
4101
+ if (!this.canBeAdded(e)) throw new n("Cannot add a matrix with different dimensions.");
4118
4102
  return this.forEach((t, n, r) => {
4119
4103
  t.add(e.values[n][r]);
4120
4104
  }), this;
@@ -4139,7 +4123,7 @@ var le = class e {
4139
4123
  return this.dimension.cols === e.dimension.rows;
4140
4124
  }
4141
4125
  characteristic_polynom(t) {
4142
- return t ??= "k", this.clone().subtract(new e(this.dimension.rows).one().multiply(new O(t))).determinant();
4126
+ return t ??= "k", this.clone().subtract(new e(this.dimension.rows).one().multiply(new M(t))).determinant();
4143
4127
  }
4144
4128
  cofactor(e, t) {
4145
4129
  let n = this.clone();
@@ -4148,14 +4132,14 @@ var le = class e {
4148
4132
  }), n.determinant().multiply((-1) ** (e + t));
4149
4133
  }
4150
4134
  get cols() {
4151
- let e = Array.from({ length: this.dimension.cols }, () => Array.from({ length: this.dimension.rows }, () => new O()));
4135
+ let e = Array.from({ length: this.dimension.cols }, () => Array.from({ length: this.dimension.rows }, () => new M()));
4152
4136
  return this.forEach((t, n, r) => {
4153
4137
  e[r][n] = t;
4154
4138
  }), e;
4155
4139
  }
4156
4140
  determinant() {
4157
- if (!this.isSquare()) throw Error("Matrix is not square");
4158
- let e = new O();
4141
+ if (!this.isSquare()) throw new n("Matrix is not square");
4142
+ let e = new M();
4159
4143
  return this.#n.length === 1 ? this.#n[0][0].clone() : (this.values[0].forEach((t, n) => {
4160
4144
  let r = this.cofactor(0, n);
4161
4145
  e.add(t.clone().multiply(r));
@@ -4178,36 +4162,36 @@ var le = class e {
4178
4162
  });
4179
4163
  }
4180
4164
  fromDimensions(e, t) {
4181
- return this.#n = Array.from({ length: e }, () => Array.from({ length: t }, () => new O())), this;
4165
+ return this.#n = Array.from({ length: e }, () => Array.from({ length: t }, () => new M())), this;
4182
4166
  }
4183
4167
  fromString(e) {
4184
4168
  if (e.startsWith("((") && e.endsWith("))")) return this.fromString(e.substring(1, e.length - 1));
4185
4169
  let t = e.split("),(");
4186
- return this.#n = t.map((e, n) => n === 0 ? e.substring(1).split(",") : n === t.length - 1 ? e.substring(0, e.length - 1).split(",") : e.split(",")).map((e) => e.map((e) => new O(e))), this;
4170
+ return this.#n = t.map((e, n) => n === 0 ? e.substring(1).split(",") : n === t.length - 1 ? e.substring(0, e.length - 1).split(",") : e.split(",")).map((e) => e.map((e) => new M(e))), this;
4187
4171
  }
4188
4172
  fromValues(e) {
4189
4173
  this.#n = [];
4190
4174
  let t = e[0].length;
4191
- if (e.some((e) => e.length !== t)) throw Error("Each line must be the same length");
4175
+ if (e.some((e) => e.length !== t)) throw new n("Each line must be the same length");
4192
4176
  return e.forEach((e) => {
4193
4177
  let t = [];
4194
4178
  e.forEach((e) => {
4195
- t.push(new O(e));
4179
+ t.push(new M(e));
4196
4180
  }), this.#n.push(t);
4197
4181
  }), this;
4198
4182
  }
4199
4183
  fromVectors(...e) {
4200
4184
  this.#n = [];
4201
4185
  let t = e[0].dimension;
4202
- if (e.some((e) => e.dimension !== t)) throw Error("Each vectors must be the same dimension");
4186
+ if (e.some((e) => e.dimension !== t)) throw new n("Each vectors must be the same dimension");
4203
4187
  return this.fromDimensions(e[0].dimension, e.length), e.forEach((e, t) => {
4204
4188
  e.array.forEach((e, n) => {
4205
- this.#n[n][t] = new O(e);
4189
+ this.#n[n][t] = new M(e);
4206
4190
  });
4207
4191
  }), this;
4208
4192
  }
4209
4193
  inverse() {
4210
- if (!this.canBeInverted()) throw Error("The matrix cannot be inverted.");
4194
+ if (!this.canBeInverted()) throw new r("The matrix cannot be inverted.");
4211
4195
  let t = new e().fromDimensions(this.dimension.rows, this.dimension.cols);
4212
4196
  t.forEach((e, n, r) => {
4213
4197
  t.setValue(n, r, this.cofactor(n, r));
@@ -4242,14 +4226,14 @@ var le = class e {
4242
4226
  }
4243
4227
  multiply(t) {
4244
4228
  if (t instanceof e) {
4245
- if (!this.canBeMultiplied(t)) throw Error("Cannot multiply a matrix with incompatibles dimensions");
4246
- let n = new e(this.dimension.rows, t.dimension.cols);
4247
- return n.forEach((e, r, i) => {
4248
- let a = this.rows[r], o = t.cols[i], s = new O();
4229
+ if (!this.canBeMultiplied(t)) throw new n("Cannot multiply a matrix with incompatibles dimensions");
4230
+ let r = new e(this.dimension.rows, t.dimension.cols);
4231
+ return r.forEach((e, n, i) => {
4232
+ let a = this.rows[n], o = t.cols[i], s = new M();
4249
4233
  a.forEach((e, t) => {
4250
4234
  s.add(e.clone().multiply(o[t]));
4251
- }), n.setValue(r, i, s);
4252
- }), this.#n = n.values, this;
4235
+ }), r.setValue(n, i, s);
4236
+ }), this.#n = r.values, this;
4253
4237
  }
4254
4238
  return this.forEach((e, n, r) => {
4255
4239
  this.setValue(n, r, e.multiply(t));
@@ -4275,21 +4259,21 @@ var le = class e {
4275
4259
  return this.#t = 4, this;
4276
4260
  }
4277
4261
  pow(e) {
4278
- return D(this, e);
4262
+ return j(this, e);
4279
4263
  }
4280
4264
  reduce() {
4281
- throw Error("Not yet implemented");
4265
+ throw new a("Not yet implemented");
4282
4266
  }
4283
4267
  get rows() {
4284
4268
  return this.#n;
4285
4269
  }
4286
4270
  setValue(e, t, n) {
4287
4271
  let { rows: r, cols: i } = this.dimension;
4288
- if (e < 0 || e >= r || t < 0 || t >= i) throw Error(`${e}x${t} is out of range (${r}x${i})`);
4289
- return this.#n[e][t] = new O(n), this;
4272
+ if (e < 0 || e >= r || t < 0 || t >= i) throw new o(`${e}x${t} is out of range (${r}x${i})`);
4273
+ return this.#n[e][t] = new M(n), this;
4290
4274
  }
4291
4275
  subtract(e) {
4292
- if (!this.canBeAdded(e)) throw Error("Cannot subtract a matrix with different dimensions.");
4276
+ if (!this.canBeAdded(e)) throw new n("Cannot subtract a matrix with different dimensions.");
4293
4277
  return this.forEach((t, n, r) => {
4294
4278
  t.subtract(e.values[n][r]);
4295
4279
  }), this;
@@ -4311,29 +4295,29 @@ var le = class e {
4311
4295
  };
4312
4296
  //#endregion
4313
4297
  //#region src/geometry/geomMath.ts
4314
- function ue(e, t) {
4298
+ function ye(e, t) {
4315
4299
  return e.dimension === t.dimension && e.array.every((e, n) => t.array[n].isEqual(e));
4316
4300
  }
4317
- function de(e, t) {
4301
+ function be(e, t) {
4318
4302
  if (e.dimension !== t.dimension) return !1;
4319
4303
  let n = t.array[0].value / e.array[0].value;
4320
4304
  return e.array.every((e, r) => t.array[r].value === e.value * n);
4321
4305
  }
4322
- function P(e, t) {
4323
- return e.dimension === t.dimension ? e.array.reduce((e, n, r) => e.add(n.clone().multiply(t.array[r])), new p(0)) : new p().invalid();
4306
+ function xe(e, t) {
4307
+ return e.dimension === t.dimension ? e.array.reduce((e, n, r) => e.add(n.clone().multiply(t.array[r])), new m(0)) : new m().invalid();
4324
4308
  }
4325
- function fe(...e) {
4326
- if (e.some((t) => t.dimension !== e[0].dimension)) throw Error("All vectors must have the same dimension");
4327
- if (e[0].dimension !== e.length) throw Error(`The determinant of dimension ${e[0].dimension} must have the same number of vectors (${e.length} given)`);
4309
+ function Se(...e) {
4310
+ if (e.some((t) => t.dimension !== e[0].dimension)) throw new n("All vectors must have the same dimension");
4311
+ if (e[0].dimension !== e.length) throw new n(`The determinant of dimension ${e[0].dimension} must have the same number of vectors (${e.length} given)`);
4328
4312
  return e[0].dimension === 2 ? e[0].array[0].clone().multiply(e[1].array[1]).subtract(e[0].array[1].clone().multiply(e[1].array[0])) : e[0].array[0].clone().multiply(e[1].array[1].clone().multiply(e[2].array[2]).subtract(e[1].array[2].clone().multiply(e[2].array[1]))).subtract(e[0].array[1].clone().multiply(e[1].array[0].clone().multiply(e[2].array[2]).subtract(e[1].array[2].clone().multiply(e[2].array[0])))).add(e[0].array[2].clone().multiply(e[1].array[0].clone().multiply(e[2].array[1]).subtract(e[1].array[1].clone().multiply(e[2].array[0]))));
4329
4313
  }
4330
4314
  //#endregion
4331
4315
  //#region src/geometry/TupleN.ts
4332
- var F = class {
4316
+ var B = class {
4333
4317
  #e = [];
4334
4318
  #t;
4335
4319
  constructor(...e) {
4336
- this.#e = e.map((e) => new p(e));
4320
+ this.#e = e.map((e) => new m(e));
4337
4321
  }
4338
4322
  copy() {
4339
4323
  return this.#e.map((e) => e.clone());
@@ -4350,7 +4334,7 @@ var F = class {
4350
4334
  fromString(e) {
4351
4335
  e.startsWith("(") && (e = e.substring(1)), e.endsWith(")") && (e = e.substring(0, e.length - 1));
4352
4336
  let t = e.split(/[,;\s]/g).filter((e) => e.trim() !== "");
4353
- return t.length < 2 || (this.#e = t.map((e) => new p(e))), this;
4337
+ return t.length < 2 || (this.#e = t.map((e) => new m(e))), this;
4354
4338
  }
4355
4339
  get onChange() {
4356
4340
  return this.#t;
@@ -4359,46 +4343,46 @@ var F = class {
4359
4343
  this.#t = e;
4360
4344
  }
4361
4345
  setDimension(e = 2) {
4362
- if (e < 2) throw Error("Dimension must be at least 2");
4346
+ if (e < 2) throw new n("Dimension must be at least 2");
4363
4347
  if (e < this.dimension) this.#e = this.#e.slice(0, e);
4364
- else if (e > this.dimension) for (let t = this.dimension; t < e; t++) this.#e.push(new p(0));
4348
+ else if (e > this.dimension) for (let t = this.dimension; t < e; t++) this.#e.push(new m(0));
4365
4349
  return this;
4366
4350
  }
4367
4351
  get x() {
4368
4352
  return this.#e[0];
4369
4353
  }
4370
4354
  set x(e) {
4371
- this.#e[0] = new p(e), this.#t?.();
4355
+ this.#e[0] = new m(e), this.#t?.();
4372
4356
  }
4373
4357
  get y() {
4374
4358
  return this.#e[1];
4375
4359
  }
4376
4360
  set y(e) {
4377
- this.#e[1] = new p(e), this.#t?.();
4361
+ this.#e[1] = new m(e), this.#t?.();
4378
4362
  }
4379
4363
  get z() {
4380
- if (this.dimension < 3) throw Error("Vector is not 3D");
4364
+ if (this.dimension < 3) throw new n("Vector is not 3D");
4381
4365
  return this.#e[2];
4382
4366
  }
4383
4367
  set z(e) {
4384
- if (this.dimension < 3) throw Error("Vector is not 3D");
4385
- this.#e[2] = new p(e), this.#t?.();
4368
+ if (this.dimension < 3) throw new n("Vector is not 3D");
4369
+ this.#e[2] = new m(e), this.#t?.();
4386
4370
  }
4387
4371
  zero = () => (this.#e.forEach((e) => e.zero()), this.#t?.(), this);
4388
- }, I = class e extends F {
4372
+ }, V = class e extends B {
4389
4373
  constructor(...e) {
4390
4374
  super(), e.length > 0 && this.parse(...e);
4391
4375
  }
4392
- parse(...t) {
4393
- if (t.length === 1) {
4394
- if (t[0] instanceof F) return this.array = t[0].copy(), this;
4395
- if (typeof t[0] == "string") return this.fromString(t[0]), this;
4376
+ parse(...n) {
4377
+ if (n.length === 1) {
4378
+ if (n[0] instanceof B) return this.array = n[0].copy(), this;
4379
+ if (typeof n[0] == "string") return this.fromString(n[0]), this;
4396
4380
  }
4397
- if (t.length > 1) {
4398
- if (t.some((t) => t instanceof e)) throw Error("Creating a point with multiple argument requires an input fraction");
4399
- let n = t.map((e) => new p(e));
4400
- if (n.some((e) => e.isNaN())) throw Error("The given values are not a valid point string (a,b): ");
4401
- this.array = n;
4381
+ if (n.length > 1) {
4382
+ if (n.some((t) => t instanceof e)) throw new i("Creating a point with multiple argument requires an input fraction");
4383
+ let r = n.map((e) => new m(e));
4384
+ if (r.some((e) => e.isNaN())) throw new t("The given values are not a valid point string (a,b): ");
4385
+ this.array = r;
4402
4386
  }
4403
4387
  return this;
4404
4388
  }
@@ -4412,8 +4396,8 @@ var F = class {
4412
4396
  return `(${this.array.map((e) => e.display).join(";")})`;
4413
4397
  }
4414
4398
  distanceTo(e) {
4415
- if (this.dimension !== e.dimension) throw Error("The two points must have the same dimensions.");
4416
- let t = this.array.map((t, n) => e.array[n].clone().subtract(t)).reduce((e, t) => e.add(t.clone().pow(2)), new p(0));
4399
+ if (this.dimension !== e.dimension) throw new n("The two points must have the same dimensions.");
4400
+ let t = this.array.map((t, n) => e.array[n].clone().subtract(t)).reduce((e, t) => e.add(t.clone().pow(2)), new m(0));
4417
4401
  return new v().from(2, t).reduce();
4418
4402
  }
4419
4403
  isEqual(e) {
@@ -4423,30 +4407,30 @@ var F = class {
4423
4407
  return this.isEqual(new e(t, n));
4424
4408
  }
4425
4409
  middleOf(e, t) {
4426
- if (e.dimension !== t.dimension) throw Error("Vectors must be the same dimension");
4410
+ if (e.dimension !== t.dimension) throw new n("Vectors must be the same dimension");
4427
4411
  return this.array = [], e.array.forEach((e, n) => {
4428
4412
  this.array.push(e.clone().add(t.array[n]).divide(2));
4429
4413
  }), this;
4430
4414
  }
4431
- }, L = class e extends F {
4415
+ }, H = class e extends B {
4432
4416
  constructor(...e) {
4433
4417
  return super(), e.length > 0 && this.parse(...e), this;
4434
4418
  }
4435
4419
  parse(...e) {
4436
- if (e.length === 0) throw Error("Invalid value");
4420
+ if (e.length === 0) throw new i("Invalid value");
4437
4421
  if (e.length === 1) {
4438
- if (e[0] instanceof F) return this.array = e[0].copy(), this;
4422
+ if (e[0] instanceof B) return this.array = e[0].copy(), this;
4439
4423
  if (typeof e[0] == "string") return this.fromString(e[0]);
4440
- throw Error("Invalid value");
4424
+ throw new i("Invalid value");
4441
4425
  }
4442
4426
  if (e.length === 2) {
4443
- let [t, n] = e;
4444
- if (t instanceof F && n instanceof F) {
4445
- if (t.dimension !== n.dimension) throw Error("Vectors must have the same dimension");
4446
- return this.array = n.array.map((e, n) => e.clone().subtract(t.array[n])), this;
4427
+ let [t, r] = e;
4428
+ if (t instanceof B && r instanceof B) {
4429
+ if (t.dimension !== r.dimension) throw new n("Vectors must have the same dimension");
4430
+ return this.array = r.array.map((e, n) => e.clone().subtract(t.array[n])), this;
4447
4431
  }
4448
4432
  }
4449
- return this.array = e.map((e) => new p(e)), this;
4433
+ return this.array = e.map((e) => new m(e)), this;
4450
4434
  }
4451
4435
  clone() {
4452
4436
  return new e(...this.copy());
@@ -4469,16 +4453,16 @@ var F = class {
4469
4453
  return t && (r = Math.abs(r)), (n ? 1 : 180 / Math.PI) * Math.acos(r / (this.norm * e.norm));
4470
4454
  };
4471
4455
  cross(t) {
4472
- if (this.dimension !== 3 || t.dimension !== 3) throw Error("Cross product can only be determined in 3D");
4456
+ if (this.dimension !== 3 || t.dimension !== 3) throw new n("Cross product can only be determined in 3D");
4473
4457
  return new e(this.y.clone().multiply(t.z).subtract(this.z.clone().multiply(t.y)), this.z.clone().multiply(t.x).subtract(this.x.clone().multiply(t.z)), this.x.clone().multiply(t.y).subtract(this.y.clone().multiply(t.x)));
4474
4458
  }
4475
- divideByScalar = (e) => this.multiplyByScalar(new p(e).inverse());
4476
- dot = (e) => P(this, e);
4459
+ divideByScalar = (e) => this.multiplyByScalar(new m(e).inverse());
4460
+ dot = (e) => xe(this, e);
4477
4461
  fromString(e) {
4478
4462
  return e.startsWith("((") && e.endsWith("))") ? super.fromString(e.slice(1, -1)) : super.fromString(e);
4479
4463
  }
4480
- isColinearTo = (e) => de(this, e);
4481
- isEqual = (e) => ue(this, e);
4464
+ isColinearTo = (e) => be(this, e);
4465
+ isEqual = (e) => ye(this, e);
4482
4466
  isNormalTo = (e) => this.dot(e).isZero();
4483
4467
  get isNull() {
4484
4468
  return this.array.every((e) => e.isZero());
@@ -4490,25 +4474,25 @@ var F = class {
4490
4474
  return this.array.every((e) => e.isZero());
4491
4475
  }
4492
4476
  multiplyByScalar = (e) => {
4493
- let t = new p(e);
4477
+ let t = new m(e);
4494
4478
  return this.array.forEach((e) => e.multiply(t)), this;
4495
4479
  };
4496
4480
  get norm() {
4497
4481
  return Math.sqrt(this.normSquare.value);
4498
4482
  }
4499
4483
  get normSquare() {
4500
- return this.array.reduce((e, t) => e.add(t.clone().pow(2)), new p(0));
4484
+ return this.array.reduce((e, t) => e.add(t.clone().pow(2)), new m(0));
4501
4485
  }
4502
4486
  normal = () => {
4503
- if (this.dimension >= 3) throw Error("Normal vector can only be determined in 2D");
4487
+ if (this.dimension >= 3) throw new n("Normal vector can only be determined in 2D");
4504
4488
  let e = this.x.clone().opposite(), t = this.y.clone();
4505
4489
  return this.array[0] = t, this.array[1] = e, this;
4506
4490
  };
4507
4491
  one = () => (this.zero(), this.x.one(), this);
4508
4492
  opposite = () => (this.array.forEach((e) => e.opposite()), this);
4509
4493
  simplify = () => {
4510
- let e = d.lcm(...this.array.map((e) => e.denominator)), t = d.gcd(...this.array.map((e) => e.numerator));
4511
- return this.multiplyByScalar(new p(e, t)), this.x.isNegative() && this.opposite(), this;
4494
+ let e = p.lcm(...this.array.map((e) => e.denominator)), t = p.gcd(...this.array.map((e) => e.numerator));
4495
+ return this.multiplyByScalar(new m(e, t)), this.x.isNegative() && this.opposite(), this;
4512
4496
  };
4513
4497
  subtract = (e) => this.add(e.clone().opposite());
4514
4498
  translate(...e) {
@@ -4518,43 +4502,43 @@ var F = class {
4518
4502
  let e = this.norm;
4519
4503
  return e === 0 ? this : this.divideByScalar(e);
4520
4504
  };
4521
- }, R = /* @__PURE__ */ function(e) {
4505
+ }, U = /* @__PURE__ */ function(e) {
4522
4506
  return e.None = "none", e.Parallel = "parallel", e.Perpendicular = "perpendicular", e.Tangent = "tangent", e;
4523
- }({}), z = /* @__PURE__ */ function(e) {
4507
+ }({}), Ce = /* @__PURE__ */ function(e) {
4524
4508
  return e.None = "none", e.Parallel = "parallel", e.Perpendicular = "perpendicular", e.Tangent = "tangent", e;
4525
4509
  }({});
4526
4510
  //#endregion
4527
4511
  //#region src/randomization/rndHelpers.ts
4528
- function B(e = .5) {
4512
+ function we(e = .5) {
4529
4513
  return Math.random() < e;
4530
4514
  }
4531
- function V(e, t, n) {
4532
- if (t === void 0) return e >= 0 ? V(0, e) : V(e, 0);
4515
+ function W(e, t, n) {
4516
+ if (t === void 0) return e >= 0 ? W(0, e) : W(e, 0);
4533
4517
  if (e === t) return e;
4534
4518
  if (n === void 0) return Math.floor(Math.random() * (t - e + 1) + e);
4535
- if (Math.abs(t - e) <= n.length) throw Error("The number of excluded values is too high.");
4536
- let r = V(e, t);
4537
- for (; n.includes(r);) r = V(e, t);
4519
+ if (Math.abs(t - e) <= n.length) throw new i("The number of excluded values is too high.");
4520
+ let r = W(e, t);
4521
+ for (; n.includes(r);) r = W(e, t);
4538
4522
  return r;
4539
4523
  }
4540
- function H(e, t) {
4541
- return t === !1 ? B() ? V(1, e) : -V(1, e) : V(-e, e);
4524
+ function G(e, t) {
4525
+ return t === !1 ? we() ? W(1, e) : -W(1, e) : W(-e, e);
4542
4526
  }
4543
- function pe(e, t) {
4544
- let n = d.pythagoreanTripletsWithTarget(e).filter((e) => t === !0 || !e.includes(0));
4545
- return n.length === 0 ? null : U(n);
4527
+ function Te(e, t) {
4528
+ let n = p.pythagoreanTripletsWithTarget(e).filter((e) => t === !0 || !e.includes(0));
4529
+ return n.length === 0 ? null : K(n);
4546
4530
  }
4547
- function me(e) {
4548
- let t = d.primes();
4549
- return e !== void 0 && (t = t.filter((t) => t < e)), U(t);
4531
+ function Ee(e) {
4532
+ let t = p.primes();
4533
+ return e !== void 0 && (t = t.filter((t) => t < e)), K(t);
4550
4534
  }
4551
- function he(e, t) {
4552
- return t === void 0 && (t = 1), e.length <= 0 ? Object.values(e) : W(e).slice(0, t);
4535
+ function De(e, t) {
4536
+ return t === void 0 && (t = 1), e.length <= 0 ? Object.values(e) : Oe(e).slice(0, t);
4553
4537
  }
4554
- function U(e) {
4555
- return e.length === 0 ? null : e[V(0, e.length - 1)];
4538
+ function K(e) {
4539
+ return e.length === 0 ? null : e[W(0, e.length - 1)];
4556
4540
  }
4557
- function W(e) {
4541
+ function Oe(e) {
4558
4542
  let t = Object.values(e);
4559
4543
  for (let e = t.length - 1; e > 0; e--) {
4560
4544
  let n = Math.floor(Math.random() * (e + 1)), r = t[e];
@@ -4564,9 +4548,9 @@ function W(e) {
4564
4548
  }
4565
4549
  //#endregion
4566
4550
  //#region src/geometry/line.ts
4567
- var G = class e {
4568
- static PARALLEL = R.Parallel;
4569
- static PERPENDICULAR = R.Perpendicular;
4551
+ var q = class e {
4552
+ static PARALLEL = U.Parallel;
4553
+ static PERPENDICULAR = U.Perpendicular;
4570
4554
  #e;
4571
4555
  #t;
4572
4556
  #n;
@@ -4574,36 +4558,36 @@ var G = class e {
4574
4558
  #i;
4575
4559
  #a = 1;
4576
4560
  constructor(...e) {
4577
- return this.#t = new p().zero(), this.#n = new p().zero(), this.#r = new p().zero(), this.#e = new L(), this.#i = "lr", e.length > 0 && this.parse(...e), this;
4578
- }
4579
- parse = (...t) => {
4580
- if (t.length === 0) return this;
4581
- if (t.length === 1) {
4582
- if (t[0] instanceof e) return this.fromCoefficient(t[0].a, t[0].b, t[0].c);
4583
- if (t[0] instanceof k) return this.fromEquation(t[0]);
4584
- if (typeof t[0] == "string") try {
4585
- let e = new k(t[0]);
4561
+ return this.#t = new m().zero(), this.#n = new m().zero(), this.#r = new m().zero(), this.#e = new H(), this.#i = "lr", e.length > 0 && this.parse(...e), this;
4562
+ }
4563
+ parse = (...n) => {
4564
+ if (n.length === 0) return this;
4565
+ if (n.length === 1) {
4566
+ if (n[0] instanceof e) return this.fromCoefficient(n[0].a, n[0].b, n[0].c);
4567
+ if (n[0] instanceof N) return this.fromEquation(n[0]);
4568
+ if (typeof n[0] == "string") try {
4569
+ let e = new N(n[0]);
4586
4570
  return this.parse(e);
4587
4571
  } catch (e) {
4588
- return console.warn(e), this;
4572
+ throw new t(`Cannot parse "${n[0]}" as a Line`, { cause: e });
4589
4573
  }
4590
4574
  }
4591
- if (t.length === 2) {
4592
- if (t[0] instanceof I && t[1] instanceof I) return this.fromPoints(t[0], t[1]);
4593
- if (t[0] instanceof I && t[1] instanceof L) return this.fromPointAndDirection(t[0], t[1]);
4575
+ if (n.length === 2) {
4576
+ if (n[0] instanceof V && n[1] instanceof V) return this.fromPoints(n[0], n[1]);
4577
+ if (n[0] instanceof V && n[1] instanceof H) return this.fromPointAndDirection(n[0], n[1]);
4594
4578
  }
4595
- return t.length === 3 && t.every((e) => p.isFraction(e)) ? this.fromCoefficient(t[0], t[1], t[2]) : (console.warn("Something wrong happened while creating the line"), console.warn(t), this);
4579
+ return n.length === 3 && n.every((e) => m.isFraction(e)) ? this.fromCoefficient(n[0], n[1], n[2]) : (console.warn("Something wrong happened while creating the line"), console.warn(n), this);
4596
4580
  };
4597
4581
  clone = () => new e().fromCoefficient(this.#t, this.#n, this.#r);
4598
4582
  get tex() {
4599
4583
  let e = this.#a;
4600
4584
  switch (this.#a = 1, e) {
4601
4585
  case 0: return this.getEquation().reorder().tex;
4602
- case 2: return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new O().parse("x", this.slope, this.height).tex;
4586
+ case 2: return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new M().parse("x", this.slope, this.height).tex;
4603
4587
  case 3:
4604
4588
  case 4: {
4605
4589
  let t = this.d.clone().simplify();
4606
- return e === 3 ? `${L.asTex("x", "y")} = ${L.asTex(this.#e.x.tex, this.#e.y.tex)} + k\\cdot ${L.asTex(t.x.tex, t.y.tex)}` : `\\left\\{\\begin{aligned}\n\tx &= ${new O(this.#e.x).add(new E(t.x).multiply(new E("k"))).reorder("k", !0).tex}\\\\\n\ty &= ${new O(this.#e.y).add(new E(t.y).multiply(new E("k"))).reorder("k", !0).tex}\n\\end{aligned}\\right.`;
4590
+ return e === 3 ? `${H.asTex("x", "y")} = ${H.asTex(this.#e.x.tex, this.#e.y.tex)} + k\\cdot ${H.asTex(t.x.tex, t.y.tex)}` : `\\left\\{\\begin{aligned}\n\tx &= ${new M(this.#e.x).add(new A(t.x).multiply(new A("k"))).reorder("k", !0).tex}\\\\\n\ty &= ${new M(this.#e.y).add(new A(t.y).multiply(new A("k"))).reorder("k", !0).tex}\n\\end{aligned}\\right.`;
4607
4591
  }
4608
4592
  default: {
4609
4593
  let e = this.getEquation();
@@ -4615,13 +4599,13 @@ var G = class e {
4615
4599
  let e = this.#a;
4616
4600
  switch (this.#a = 1, e) {
4617
4601
  case 0: return this.getEquation().reorder().display;
4618
- case 2: return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new O().parse("x", this.slope, this.height).display;
4602
+ case 2: return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new M().parse("x", this.slope, this.height).display;
4619
4603
  case 3: {
4620
4604
  let e = this.d.clone().simplify();
4621
4605
  return `((x,y))=((${this.#e.x.display},${this.#e.y.display}))+k((${e.x.display},${e.y.display}))`;
4622
4606
  }
4623
4607
  case 4: {
4624
- let e = this.d.clone().simplify(), t = new O(this.#e.x).add(new E(e.x).multiply(new E("k"))).reorder("k", !0), n = new O(this.#e.y).add(new E(e.y).multiply(new E("k"))).reorder("k", !0);
4608
+ let e = this.d.clone().simplify(), t = new M(this.#e.x).add(new A(e.x).multiply(new A("k"))).reorder("k", !0), n = new M(this.#e.y).add(new A(e.y).multiply(new A("k"))).reorder("k", !0);
4625
4609
  return `{(x,=,${t.display}),(y,=,${n.display}):}`;
4626
4610
  }
4627
4611
  default: {
@@ -4674,7 +4658,7 @@ var G = class e {
4674
4658
  return this.#t.isZero() || (t = this.#t.isOne() ? "x" : this.#t.clone().opposite().isOne() ? "-x" : this.#t.value.toFixed(e) + "x"), this.#n.isZero() || (this.#n.isPositive() && (t += "+"), t += this.#n.value.toFixed(e) + "y"), this.#r.isZero() || (this.#r.isPositive() && (t += "+"), t += this.#r.value.toFixed(e)), t + "=0";
4675
4659
  }
4676
4660
  get d() {
4677
- let e = new L(this.#n.clone(), this.#t.clone().opposite());
4661
+ let e = new H(this.#n.clone(), this.#t.clone().opposite());
4678
4662
  return (this.#i === "lr" && e.x.isNegative() || this.#i === "rl" && e.x.isPositive()) && e.opposite(), e;
4679
4663
  }
4680
4664
  set d(e) {
@@ -4688,19 +4672,19 @@ var G = class e {
4688
4672
  return n.isZero() ? new v(0) : new v().from(2, n.inverse(), t).reduce();
4689
4673
  }
4690
4674
  fromCoefficient(e, t, n) {
4691
- this.#t = new p(e), this.#n = new p(t), this.#r = new p(n);
4675
+ this.#t = new m(e), this.#n = new m(t), this.#r = new m(n);
4692
4676
  let r = [
4693
4677
  this.#t,
4694
4678
  this.#n,
4695
4679
  this.#r
4696
- ].every((e) => e.exact) ? d.lcm(this.#t.denominator, this.#n.denominator, this.#r.denominator) : 1;
4697
- if (r > 1 && (this.#t.multiply(r).reduce(), this.#n.multiply(r).reduce(), this.#r.multiply(r).reduce()), this.#n.isZero()) return this.#e = new L(this.#r.clone().divide(this.#t).opposite(), 0), this;
4680
+ ].every((e) => e.exact) ? p.lcm(this.#t.denominator, this.#n.denominator, this.#r.denominator) : 1;
4681
+ if (r > 1 && (this.#t.multiply(r).reduce(), this.#n.multiply(r).reduce(), this.#r.multiply(r).reduce()), this.#n.isZero()) return this.#e = new H(this.#r.clone().divide(this.#t).opposite(), 0), this;
4698
4682
  for (let e = 0; e < this.#n.value; e++) {
4699
4683
  let t = this.#t.clone().divide(this.#n).multiply(e).subtract(this.#r.clone().divide(this.#n)).reduce();
4700
- if (this.#e = new L(e, t), t.isRelative()) return this;
4684
+ if (this.#e = new H(e, t), t.isRelative()) return this;
4701
4685
  }
4702
4686
  let i = this.#r.clone().divide(this.#n).opposite().reduce();
4703
- return this.#e = new L(0, i), this;
4687
+ return this.#e = new H(0, i), this;
4704
4688
  }
4705
4689
  fromEquation(e) {
4706
4690
  e.reorder(!0);
@@ -4718,23 +4702,23 @@ var G = class e {
4718
4702
  fromPointAndDirection(e, t) {
4719
4703
  return this.#i = t.x.isPositive() ? "lr" : "rl", this.fromPointAndNormal(e, t.clone().normal());
4720
4704
  }
4721
- fromPointAndLine(e, t, n = R.Parallel) {
4722
- return n === R.Perpendicular ? this.fromPointAndNormal(e, t.director) : this.fromPointAndNormal(e, t.normal);
4705
+ fromPointAndLine(e, t, n = U.Parallel) {
4706
+ return n === U.Perpendicular ? this.fromPointAndNormal(e, t.director) : this.fromPointAndNormal(e, t.normal);
4723
4707
  }
4724
- fromPointAndNormal = (e, t) => t.isZero() ? (console.warn("Normal vector is null."), this) : (this.fromCoefficient(t.x, t.y, e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposite()), this.#e = new L(e.clone()), this);
4708
+ fromPointAndNormal = (e, t) => t.isZero() ? (console.warn("Normal vector is null."), this) : (this.fromCoefficient(t.x, t.y, e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposite()), this.#e = new H(e.clone()), this);
4725
4709
  fromPoints(e, t) {
4726
- return this.fromPointAndNormal(e, new L(e, t).normal());
4710
+ return this.fromPointAndNormal(e, new H(e, t).normal());
4727
4711
  }
4728
4712
  getEquation() {
4729
- return new k(new O().parse("xy", this.#t, this.#n, this.#r), new O("0")).simplify();
4713
+ return new N(new M().parse("xy", this.#t, this.#n, this.#r), new M("0")).simplify();
4730
4714
  }
4731
4715
  getValueAtX = (e) => {
4732
- let t = this.getEquation().isolate("y"), n = new p(e);
4733
- return t instanceof k ? t.right.evaluate({ x: n }) : new p().invalid();
4716
+ let t = this.getEquation().isolate("y"), n = new m(e);
4717
+ return t instanceof N ? t.right.evaluate({ x: n }) : new m().invalid();
4734
4718
  };
4735
4719
  getValueAtY = (e) => {
4736
- let t = this.getEquation().isolate("x"), n = new p(e);
4737
- return t instanceof k ? t.right.evaluate({ y: n }) : new p().invalid();
4720
+ let t = this.getEquation().isolate("x"), n = new m(e);
4721
+ return t instanceof N ? t.right.evaluate({ y: n }) : new m().invalid();
4738
4722
  };
4739
4723
  get height() {
4740
4724
  return this.#r.clone().opposite().divide(this.#n);
@@ -4744,8 +4728,8 @@ var G = class e {
4744
4728
  return r.hasIntersection ? r.point.x.value >= Math.min(t.x.value, n.x.value) && r.point.x.value <= Math.max(t.x.value, n.x.value) && r.point.y.value >= Math.min(t.y.value, n.y.value) && r.point.y.value <= Math.max(t.y.value, n.y.value) : !1;
4745
4729
  }
4746
4730
  intersection = (e) => {
4747
- let t = new I(), n = !1, r = !1;
4748
- return this.#n.isZero() || e.b.isZero(), this.isParallelTo(e) ? (t.x = new p().invalid(), t.y = new p().invalid(), n = !0) : this.isSameAs(e) ? (t.x = new p().invalid(), t.y = new p().invalid(), r = !0) : (t.x = this.#n.clone().multiply(e.c).subtract(this.#r.clone().multiply(e.b)).divide(this.#t.clone().multiply(e.b).subtract(this.#n.clone().multiply(e.a))), t.y = this.#t.clone().multiply(e.c).subtract(this.#r.clone().multiply(e.a)).divide(this.#n.clone().multiply(e.a).subtract(this.#t.clone().multiply(e.b)))), {
4731
+ let t = new V(), n = !1, r = !1;
4732
+ return this.#n.isZero() || e.b.isZero(), this.isParallelTo(e) ? (t.x = new m().invalid(), t.y = new m().invalid(), n = !0) : this.isSameAs(e) ? (t.x = new m().invalid(), t.y = new m().invalid(), r = !0) : (t.x = this.#n.clone().multiply(e.c).subtract(this.#r.clone().multiply(e.b)).divide(this.#t.clone().multiply(e.b).subtract(this.#n.clone().multiply(e.a))), t.y = this.#t.clone().multiply(e.c).subtract(this.#r.clone().multiply(e.a)).divide(this.#n.clone().multiply(e.a).subtract(this.#t.clone().multiply(e.b)))), {
4749
4733
  point: t,
4750
4734
  hasIntersection: !(n || r),
4751
4735
  isParallel: n,
@@ -4766,25 +4750,25 @@ var G = class e {
4766
4750
  return this.d.normal();
4767
4751
  }
4768
4752
  get normal() {
4769
- return new L(this.#t, this.#n);
4753
+ return new H(this.#t, this.#n);
4770
4754
  }
4771
4755
  randomNearPoint = (e) => {
4772
4756
  let t = this.randomPoint(e), n = 10;
4773
- for (; this.isOnLine(t) && n > 0;) t.x.add(H(1, !1)), t.y.add(H(1, !1)), n--;
4757
+ for (; this.isOnLine(t) && n > 0;) t.x.add(G(1, !1)), t.y.add(G(1, !1)), n--;
4774
4758
  return t;
4775
4759
  };
4776
- randomPoint = (e) => new I(this.d.clone().multiplyByScalar(H(e === void 0 || e <= 1 ? 3 : e, !1)).add(this.#e));
4760
+ randomPoint = (e) => new V(this.d.clone().multiplyByScalar(G(e === void 0 || e <= 1 ? 3 : e, !1)).add(this.#e));
4777
4761
  simplify = () => {
4778
- let e = d.lcm(this.#t.denominator, this.#n.denominator, this.#r.denominator), t = d.gcd(this.#t.numerator, this.#n.numerator, this.#r.numerator);
4762
+ let e = p.lcm(this.#t.denominator, this.#n.denominator, this.#r.denominator), t = p.gcd(this.#t.numerator, this.#n.numerator, this.#r.numerator);
4779
4763
  return this.fromCoefficient(this.#t.clone().multiply(e).divide(t), this.#n.clone().multiply(e).divide(t), this.#r.clone().multiply(e).divide(t)), this;
4780
4764
  };
4781
4765
  get slope() {
4782
4766
  return this.#t.clone().opposite().divide(this.#n);
4783
4767
  }
4784
- }, K = class e {
4785
- #e = new I();
4786
- #t = new I();
4787
- #n = new I();
4768
+ }, J = class e {
4769
+ #e = new V();
4770
+ #t = new V();
4771
+ #n = new V();
4788
4772
  #r = !1;
4789
4773
  #i = null;
4790
4774
  #a = !0;
@@ -4805,12 +4789,12 @@ var G = class e {
4805
4789
  let [e, n, r] = t;
4806
4790
  return this.fromLines(e, n, r);
4807
4791
  }
4808
- if (t.every((e) => e instanceof G)) return this.fromLines(t[0], t[1], t[2]);
4809
- if (t.every((e) => e instanceof I)) return this.fromPoints(t[0], t[1], t[2]);
4792
+ if (t.every((e) => e instanceof q)) return this.fromLines(t[0], t[1], t[2]);
4793
+ if (t.every((e) => e instanceof V)) return this.fromPoints(t[0], t[1], t[2]);
4810
4794
  }
4811
4795
  if (t.length === 6) {
4812
- let e = t.map((e) => new p(e));
4813
- if (e.some((e) => e.isNaN())) throw Error("One of the values is not a valid number");
4796
+ let e = t.map((e) => new m(e));
4797
+ if (e.some((e) => e.isNaN())) throw new i("One of the values is not a valid number");
4814
4798
  return this.fromCoordinates(e[0], e[1], e[2], e[3], e[4], e[5]);
4815
4799
  }
4816
4800
  return this;
@@ -4862,10 +4846,10 @@ var G = class e {
4862
4846
  return this.#a = !0, this;
4863
4847
  }
4864
4848
  fromCoordinates(e, t, n, r, i, a) {
4865
- return this.fromPoints(new I(e, t), new I(n, r), new I(i, a));
4849
+ return this.fromPoints(new V(e, t), new V(n, r), new V(i, a));
4866
4850
  }
4867
4851
  fromLines(e, t, n) {
4868
- let r = new G(e).clone(), i = new G(t).clone(), a = new G(n).clone(), o = r.intersection(i);
4852
+ let r = new q(e).clone(), i = new q(t).clone(), a = new q(n).clone(), o = r.intersection(i);
4869
4853
  if (o.hasIntersection) this.#t = o.point;
4870
4854
  else return this.#r = !1, this;
4871
4855
  if (o = i.intersection(a), o.hasIntersection) this.#n = o.point;
@@ -4908,7 +4892,7 @@ var G = class e {
4908
4892
  }
4909
4893
  getHeights() {
4910
4894
  if (!this.#o.heights) {
4911
- let e = new G().fromPointAndNormal(this.#e, new L(this.#t, this.#n)), t = new G().fromPointAndNormal(this.#t, new L(this.#e, this.#n)), n = new G().fromPointAndNormal(this.#n, new L(this.#e, this.#t)), r = e.intersection(t).point;
4895
+ let e = new q().fromPointAndNormal(this.#e, new H(this.#t, this.#n)), t = new q().fromPointAndNormal(this.#t, new H(this.#e, this.#n)), n = new q().fromPointAndNormal(this.#n, new H(this.#e, this.#t)), r = e.intersection(t).point;
4912
4896
  this.#o.heights = {
4913
4897
  A: e,
4914
4898
  B: t,
@@ -4921,7 +4905,7 @@ var G = class e {
4921
4905
  getMedians() {
4922
4906
  let e = this.getMiddles();
4923
4907
  if (!this.#o.medians) {
4924
- let t = new G().fromPoints(this.#e, e.BC), n = new G().fromPoints(this.#t, e.AC), r = new G().fromPoints(this.#n, e.AB), i = t.intersection(n).point;
4908
+ let t = new q().fromPoints(this.#e, e.BC), n = new q().fromPoints(this.#t, e.AC), r = new q().fromPoints(this.#n, e.AB), i = t.intersection(n).point;
4925
4909
  this.#o.medians = {
4926
4910
  A: t,
4927
4911
  B: n,
@@ -4934,7 +4918,7 @@ var G = class e {
4934
4918
  getMediators() {
4935
4919
  let e = this.getMiddles();
4936
4920
  if (!this.#o.mediators) {
4937
- let t = new G().fromPointAndNormal(e.BC, new L(this.#t, this.#n)), n = new G().fromPointAndNormal(e.AC, new L(this.#e, this.#n)), r = new G().fromPointAndNormal(e.AB, new L(this.#e, this.#t)), i = t.intersection(n).point;
4921
+ let t = new q().fromPointAndNormal(e.BC, new H(this.#t, this.#n)), n = new q().fromPointAndNormal(e.AC, new H(this.#e, this.#n)), r = new q().fromPointAndNormal(e.AB, new H(this.#e, this.#t)), i = t.intersection(n).point;
4938
4922
  this.#o.mediators = {
4939
4923
  a: t,
4940
4924
  b: n,
@@ -4946,9 +4930,9 @@ var G = class e {
4946
4930
  }
4947
4931
  getMiddles() {
4948
4932
  return {
4949
- AB: new I().middleOf(this.#e, this.#t),
4950
- AC: new I().middleOf(this.#e, this.#n),
4951
- BC: new I().middleOf(this.#t, this.#n)
4933
+ AB: new V().middleOf(this.#e, this.#t),
4934
+ AC: new V().middleOf(this.#e, this.#n),
4935
+ BC: new V().middleOf(this.#t, this.#n)
4952
4936
  };
4953
4937
  }
4954
4938
  getPoints() {
@@ -4987,9 +4971,9 @@ var G = class e {
4987
4971
  }
4988
4972
  get lines() {
4989
4973
  return this.#i === null && (this.#i = {
4990
- AB: new G(this.#e, this.#t),
4991
- BC: new G(this.#t, this.#n),
4992
- AC: new G(this.#e, this.#n)
4974
+ AB: new q(this.#e, this.#t),
4975
+ BC: new q(this.#t, this.#n),
4976
+ AC: new q(this.#e, this.#n)
4993
4977
  }), this.#i;
4994
4978
  }
4995
4979
  medianA() {
@@ -5014,14 +4998,14 @@ var G = class e {
5014
4998
  }, this;
5015
4999
  }
5016
5000
  #s(e, t = !0) {
5017
- let n = this.lines, r = new L(), i = new L(), a = new I();
5018
- if (e === "A" ? (a = this.A.clone(), r = n.AB.clone().d, i = n.AC.clone().d) : e === "B" ? (a = this.B.clone(), r = n.AB.clone().d.opposite(), i = n.BC.clone().d) : e === "C" && (a = this.C.clone(), r = n.BC.clone().d.opposite(), i = n.AC.clone().d.opposite()), r === void 0 || i === void 0) throw Error(`The point ${e} does not exist`);
5019
- let o = t ? r.unit().add(i.unit()) : r.unit().subtract(i.unit());
5020
- return new G().fromPointAndDirection(a, o);
5001
+ let n = this.lines, r = new H(), i = new H(), a = new V();
5002
+ if (e === "A" ? (a = this.A.clone(), r = n.AB.clone().d, i = n.AC.clone().d) : e === "B" ? (a = this.B.clone(), r = n.AB.clone().d.opposite(), i = n.BC.clone().d) : e === "C" && (a = this.C.clone(), r = n.BC.clone().d.opposite(), i = n.AC.clone().d.opposite()), r === void 0 || i === void 0) throw new o(`The point ${e} does not exist`);
5003
+ let s = t ? r.unit().add(i.unit()) : r.unit().subtract(i.unit());
5004
+ return new q().fromPointAndDirection(a, s);
5021
5005
  }
5022
5006
  #c(e, t, n) {
5023
5007
  let r = (t ** 2 + n ** 2 - e ** 2) / (2 * t * n);
5024
- return this.#a ? Math.acos(r) : d.numberCorrection(Math.acos(r) * 180 / Math.PI);
5008
+ return this.#a ? Math.acos(r) : p.numberCorrection(Math.acos(r) * 180 / Math.PI);
5025
5009
  }
5026
5010
  #l = (e) => {
5027
5011
  switch (e.toUpperCase()) {
@@ -5031,8 +5015,8 @@ var G = class e {
5031
5015
  }
5032
5016
  return this.#e;
5033
5017
  };
5034
- #u = (e, t) => new L(this.#l(e), this.#l(t));
5035
- }, q = class e {
5018
+ #u = (e, t) => new H(this.#l(e), this.#l(t));
5019
+ }, Y = class e {
5036
5020
  #e = null;
5037
5021
  #t = null;
5038
5022
  #n = 1;
@@ -5041,7 +5025,7 @@ var G = class e {
5041
5025
  e.length > 0 && this.parse(...e);
5042
5026
  }
5043
5027
  parse(...t) {
5044
- return typeof t[0] == "string" ? this.fromString(t[0]) : t[0] instanceof k ? this.fromEquation(t[0]) : t[0] instanceof e ? this.copy(t[0]) : t.length === 2 && t[0] instanceof I && t[1] instanceof I ? this.fromCenterPoint(t[0], t[1]) : t.length >= 2 && t[0] instanceof I && (t[1] instanceof p || typeof t[1] == "number") ? this.fromCenterRadius(t[0], t[1], typeof t[2] == "boolean" && t[2]) : this;
5028
+ return typeof t[0] == "string" ? this.fromString(t[0]) : t[0] instanceof N ? this.fromEquation(t[0]) : t[0] instanceof e ? this.copy(t[0]) : t.length === 2 && t[0] instanceof V && t[1] instanceof V ? this.fromCenterPoint(t[0], t[1]) : t.length >= 2 && t[0] instanceof V && (t[1] instanceof m || typeof t[1] == "number") ? this.fromCenterRadius(t[0], t[1], typeof t[2] == "boolean" && t[2]) : this;
5045
5029
  }
5046
5030
  clone() {
5047
5031
  return new e().fromCenterRadius(this.center.clone(), this.squareRadius.clone(), !0);
@@ -5066,36 +5050,36 @@ var G = class e {
5066
5050
  return this.#n = 1, this;
5067
5051
  }
5068
5052
  get center() {
5069
- return this.#e ?? new I();
5053
+ return this.#e ?? new V();
5070
5054
  }
5071
5055
  get equation() {
5072
- return this.#t?.clone() ?? new k("0=0");
5056
+ return this.#t?.clone() ?? new N("0=0");
5073
5057
  }
5074
5058
  fromCenterPoint(e, t) {
5075
- return this.#e = e.clone(), this.#r = new L(this.#e, t).normSquare, this.#i(), this;
5059
+ return this.#e = e.clone(), this.#r = new H(this.#e, t).normSquare, this.#i(), this;
5076
5060
  }
5077
5061
  fromCenterRadius(e, t, n) {
5078
- return this.#e = e.clone(), n ? this.#r = new p(t) : this.#r = new p(t).pow(2), this.#i(), this;
5062
+ return this.#e = e.clone(), this.#r = n ? new m(t) : new m(t).pow(2), this.#i(), this;
5079
5063
  }
5080
5064
  fromEquation(e) {
5081
5065
  if (e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
5082
5066
  let t = e.left.monomByDegree(2, "x"), n = e.left.monomByDegree(2, "y"), r, i, a;
5083
- if (t.coefficient.isEqual(n.coefficient)) return e.divide(t.coefficient), r = e.left.monomByDegree(1, "x"), i = e.left.monomByDegree(1, "y"), a = e.left.monomByDegree(0), this.#e = new I(r.coefficient.clone().divide(2).opposite(), i.coefficient.clone().divide(2).opposite()), this.#r = a.coefficient.clone().opposite().add(this.#e.x.clone().pow(2)).add(this.#e.y.clone().pow(2)), this.#i(), this;
5067
+ if (t.coefficient.isEqual(n.coefficient)) return e.divide(t.coefficient), r = e.left.monomByDegree(1, "x"), i = e.left.monomByDegree(1, "y"), a = e.left.monomByDegree(0), this.#e = new V(r.coefficient.clone().divide(2).opposite(), i.coefficient.clone().divide(2).opposite()), this.#r = a.coefficient.clone().opposite().add(this.#e.x.clone().pow(2)).add(this.#e.y.clone().pow(2)), this.#i(), this;
5084
5068
  this.#a();
5085
5069
  }
5086
5070
  return this;
5087
5071
  }
5088
5072
  fromPoints(e, t, n) {
5089
- let r = new K(e, t, n);
5073
+ let r = new J(e, t, n);
5090
5074
  if (!r.isValid || !r.remarquables) return this.#a(), this;
5091
5075
  let i = r.getMediators().c.clone(), a = r.getMediators().b.clone();
5092
5076
  return this.fromCenterPoint(i.intersection(a).point, e);
5093
5077
  }
5094
5078
  fromString(e) {
5095
- return this.fromEquation(new k(e));
5079
+ return this.fromEquation(new N(e));
5096
5080
  }
5097
5081
  getPointsOnCircle() {
5098
- let e = d.pythagoreanTripletsWithTarget(this.squareRadius.value, !0), t = [];
5082
+ let e = p.pythagoreanTripletsWithTarget(this.squareRadius.value, !0), t = [];
5099
5083
  return e.forEach((e) => {
5100
5084
  for (let n of [
5101
5085
  [1, 1],
@@ -5104,7 +5088,7 @@ var G = class e {
5104
5088
  [1, -1]
5105
5089
  ]) {
5106
5090
  let r = this.center.x.clone().add(n[0] * e[0]), i = this.center.y.clone().add(n[1] * e[1]);
5107
- t.every((e) => !e.isEqualXY(r, i)) && t.push(new I(r, i));
5091
+ t.every((e) => !e.isEqualXY(r, i)) && t.push(new V(r, i));
5108
5092
  }
5109
5093
  }), t;
5110
5094
  }
@@ -5121,10 +5105,10 @@ var G = class e {
5121
5105
  if (s.length === 0) return [];
5122
5106
  if (s.length === 1) {
5123
5107
  let e = r.add(n.clone().multiplyByScalar(s[0].fraction));
5124
- return [new I(e.x, e.y)];
5108
+ return [new V(e.x, e.y)];
5125
5109
  }
5126
5110
  let c = s[0].exact ? r.clone().add(n.clone().multiplyByScalar(s[0].fraction)) : r.clone().add(n.clone().multiplyByScalar(s[0].value)), l = s[1].exact ? r.clone().add(n.clone().multiplyByScalar(s[1].fraction)) : r.clone().add(n.clone().multiplyByScalar(s[1].value));
5127
- return [new I(c.x, c.y), new I(l.x, l.y)].sort((e, t) => n.x.isZero() ? n.y.isPositive() ? e.y.value - t.y.value : t.y.value - e.y.value : n.x.isPositive() ? e.x.value - t.x.value : t.x.value - e.x.value);
5111
+ return [new V(c.x, c.y), new V(l.x, l.y)].sort((e, t) => n.x.isZero() ? n.y.isPositive() ? e.y.value - t.y.value : t.y.value - e.y.value : n.x.isPositive() ? e.x.value - t.x.value : t.x.value - e.x.value);
5128
5112
  }
5129
5113
  get radius() {
5130
5114
  return new v().from(2, this.#r ?? 0);
@@ -5135,57 +5119,57 @@ var G = class e {
5135
5119
  return t - n > 1e-10 ? 0 : Math.abs(t - n) < 1e-10 ? 1 : 2;
5136
5120
  }
5137
5121
  setRadius(e, t) {
5138
- return t ? this.#r = new p(e) : this.#r = new p(e).pow(2), this.#i(), this;
5122
+ return this.#r = t ? new m(e) : new m(e).pow(2), this.#i(), this;
5139
5123
  }
5140
5124
  get squareRadius() {
5141
- return this.#r?.clone() ?? new p(-1);
5125
+ return this.#r?.clone() ?? new m(-1);
5142
5126
  }
5143
- tangents = (e) => e instanceof p ? this.#c(e) : this.isPointOnCircle(e) ? this.#o(e) : this.#e !== null && this.#e.distanceTo(e).value > this.radius.value ? this.#s(e) : [];
5127
+ tangents = (e) => e instanceof m ? this.#c(e) : this.isPointOnCircle(e) ? this.#o(e) : this.#e !== null && this.#e.distanceTo(e).value > this.radius.value ? this.#s(e) : [];
5144
5128
  #i() {
5145
- this.#t = new k(new O(`(x-(${this.center.x.display}))^2+(y-(${this.center.y.display}))^2`), new O(this.squareRadius.display)).moveLeft();
5129
+ this.#t = new N(new M(`(x-(${this.center.x.display}))^2+(y-(${this.center.y.display}))^2`), new M(this.squareRadius.display)).moveLeft();
5146
5130
  }
5147
5131
  #a() {
5148
5132
  this.#e = null, this.#r = null, this.#t = null;
5149
5133
  }
5150
5134
  #o = (e) => {
5151
- let t = new L(this.center, e);
5152
- return [new G().fromPointAndNormal(e, t)];
5135
+ let t = new H(this.center, e);
5136
+ return [new q().fromPointAndNormal(e, t)];
5153
5137
  };
5154
5138
  #s = (e) => {
5155
- let t = this.center.x.clone().subtract(e.x), n = this.center.y.clone().subtract(e.y), r = new O("x"), i = new O("x^2+1");
5156
- return r.multiply(t).subtract(n).pow(2), i.multiply(this.squareRadius), new k(r, i).solve().map((t) => {
5157
- let n, r = new k("y", "x");
5158
- return t.exact ? (n = e.x.clone().opposite().multiply(t.fraction).add(e.y), r.right.multiply(t.fraction).add(n)) : (n = e.x.clone().opposite().multiply(t.value).add(e.y), r.right.multiply(t.value).add(n)), new G(r);
5139
+ let t = this.center.x.clone().subtract(e.x), n = this.center.y.clone().subtract(e.y), r = new M("x"), i = new M("x^2+1");
5140
+ return r.multiply(t).subtract(n).pow(2), i.multiply(this.squareRadius), new N(r, i).solve().map((t) => {
5141
+ let n, r = new N("y", "x");
5142
+ return t.exact ? (n = e.x.clone().opposite().multiply(t.fraction).add(e.y), r.right.multiply(t.fraction).add(n)) : (n = e.x.clone().opposite().multiply(t.value).add(e.y), r.right.multiply(t.value).add(n)), new q(r);
5159
5143
  });
5160
5144
  };
5161
5145
  #c = (e) => {
5162
5146
  let t = e.numerator, n = -e.denominator, r = this.center.x.clone(), i = this.center.y.clone(), a = this.squareRadius.clone().multiply(e.numerator ** 2 + e.denominator ** 2), o = r.clone().multiply(t).opposite().subtract(i.clone().multiply(n)).add(a.clone().sqrt()), s = r.clone().multiply(t).opposite().subtract(i.clone().multiply(n)).subtract(a.clone().sqrt());
5163
- return [new G(t, n, o), new G(t, n, s)];
5147
+ return [new q(t, n, o), new q(t, n, s)];
5164
5148
  };
5165
- }, J = class e {
5166
- static PARALLEL = z.Parallel;
5167
- static PERPENDICULAR = z.Perpendicular;
5168
- #e = new I();
5169
- #t = new L();
5149
+ }, X = class e {
5150
+ static PARALLEL = Ce.Parallel;
5151
+ static PERPENDICULAR = Ce.Perpendicular;
5152
+ #e = new V();
5153
+ #t = new H();
5170
5154
  constructor(e, t) {
5171
- return this.#e = e.clone(), this.#t = t instanceof I ? new L(e, t) : t.clone(), this;
5155
+ return this.#e = e.clone(), this.#t = t instanceof V ? new H(e, t) : t.clone(), this;
5172
5156
  }
5173
5157
  clone = () => (this.#t = this.#t.clone(), this.#e = this.#e.clone(), this);
5174
5158
  get tex() {
5175
5159
  return {
5176
- parametric: `${L.asTex("x", "y", "z")} = ${L.asTex(this.#e.x.tex, this.#e.y.tex, this.#e.z.tex)} + k\\cdot ${L.asTex(this.#t.x.tex, this.#t.y.tex, this.#t.z.tex)}`,
5160
+ parametric: `${H.asTex("x", "y", "z")} = ${H.asTex(this.#e.x.tex, this.#e.y.tex, this.#e.z.tex)} + k\\cdot ${H.asTex(this.#t.x.tex, this.#t.y.tex, this.#t.z.tex)}`,
5177
5161
  system: `\\left\\{\\begin{aligned}
5178
- x &= ${new O(this.#e.x).add(new E(this.#t.x).multiply(new E("k"))).reorder("k", !0).tex}\\\\
5179
- y &= ${new O(this.#e.y).add(new E(this.#t.y).multiply(new E("k"))).reorder("k", !0).tex}\\\\
5180
- z &= ${new O(this.#e.z).add(new E(this.#t.z).multiply(new E("k"))).reorder("k", !0).tex}
5162
+ x &= ${new M(this.#e.x).add(new A(this.#t.x).multiply(new A("k"))).reorder("k", !0).tex}\\\\
5163
+ y &= ${new M(this.#e.y).add(new A(this.#t.y).multiply(new A("k"))).reorder("k", !0).tex}\\\\
5164
+ z &= ${new M(this.#e.z).add(new A(this.#t.z).multiply(new A("k"))).reorder("k", !0).tex}
5181
5165
  \\end{aligned}\\right.`,
5182
- cartesian: `\\frac{ ${new O("x", 1, this.#e.x.clone().opposite()).tex} }{ ${this.direction.x.tex} } = \\frac{ ${new O("y", 1, this.#e.y.clone().opposite()).tex} }{ ${this.direction.y.tex} } = \\frac{ ${new O("z", 1, this.#e.z.clone().opposite()).tex} }{ ${this.direction.z.tex} }`
5166
+ cartesian: `\\frac{ ${new M("x", 1, this.#e.x.clone().opposite()).tex} }{ ${this.direction.x.tex} } = \\frac{ ${new M("y", 1, this.#e.y.clone().opposite()).tex} }{ ${this.direction.y.tex} } = \\frac{ ${new M("z", 1, this.#e.z.clone().opposite()).tex} }{ ${this.direction.z.tex} }`
5183
5167
  };
5184
5168
  }
5185
5169
  get display() {
5186
5170
  let e = this.#e.x.display, t = this.#e.y.display, n = this.#e.z.display, r = this.direction.simplify(), i = r.x.display, a = r.y.display, o = r.z.display;
5187
5171
  return {
5188
- parametric: `${L.asDisplay("x", "y", "z")} = ${L.asDisplay(this.#e.x.display, this.#e.y.display, this.#e.z.display)} + k\\cdot ${L.asDisplay(this.#t.x.display, this.#t.y.display, this.#t.z.display)}`,
5172
+ parametric: `${H.asDisplay("x", "y", "z")} = ${H.asDisplay(this.#e.x.display, this.#e.y.display, this.#e.z.display)} + k\\cdot ${H.asDisplay(this.#t.x.display, this.#t.y.display, this.#t.z.display)}`,
5189
5173
  system: "",
5190
5174
  cartesian: `(x-${e})/${i} = (y-${t})/${a} = (z-${n})/${o}`
5191
5175
  };
@@ -5206,7 +5190,7 @@ var G = class e {
5206
5190
  return this.#t.clone();
5207
5191
  }
5208
5192
  distanceTo(e) {
5209
- let t = new L(this.#e, e), n = this.direction, r = this.direction.normSquare, i = t.cross(n).normSquare.clone().divide(r), a = i.clone().sqrt();
5193
+ let t = new H(this.#e, e), n = this.direction, r = this.direction.normSquare, i = t.cross(n).normSquare.clone().divide(r), a = i.clone().sqrt();
5210
5194
  return {
5211
5195
  value: Math.sqrt(i.value),
5212
5196
  fraction: i.clone().sqrt(),
@@ -5218,34 +5202,34 @@ var G = class e {
5218
5202
  return r.hasIntersection ? r.point.x.value >= Math.min(t.x.value, n.x.value) && r.point.x.value <= Math.max(t.x.value, n.x.value) && r.point.y.value >= Math.min(t.y.value, n.y.value) && r.point.y.value <= Math.max(t.y.value, n.y.value) && r.point.z.value >= Math.min(t.z.value, n.z.value) && r.point.z.value <= Math.max(t.z.value, n.z.value) : !1;
5219
5203
  }
5220
5204
  intersection = (e) => {
5221
- throw Error("Method not implemented.");
5205
+ throw new a("Method not implemented.");
5222
5206
  };
5223
5207
  isOnLine = (e) => !1;
5224
5208
  isParallelTo = (e) => {
5225
- throw Error("Method not implemented.");
5209
+ throw new a("Method not implemented.");
5226
5210
  };
5227
5211
  isPerpendicularTo = (e) => {
5228
- throw Error("Method not implemented.");
5212
+ throw new a("Method not implemented.");
5229
5213
  };
5230
5214
  isSameAs = (e) => {
5231
- throw Error("Method not implemented.");
5215
+ throw new a("Method not implemented.");
5232
5216
  };
5233
5217
  isVertical = () => {
5234
- throw Error("Method not implemented.");
5218
+ throw new a("Method not implemented.");
5235
5219
  };
5236
5220
  get point() {
5237
5221
  return this.#e.clone();
5238
5222
  }
5239
5223
  randomPoint = (e = 5) => {
5240
- let t = this.#e.clone(), n = new p(H(e, !1));
5241
- return new I(t.x.clone().add(this.#t.x.clone().multiply(n)), t.y.clone().add(this.#t.y.clone().multiply(n)), t.z.clone().add(this.#t.z.clone().multiply(n)));
5224
+ let t = this.#e.clone(), n = new m(G(e, !1));
5225
+ return new V(t.x.clone().add(this.#t.x.clone().multiply(n)), t.y.clone().add(this.#t.y.clone().multiply(n)), t.z.clone().add(this.#t.z.clone().multiply(n)));
5242
5226
  };
5243
5227
  simplify = () => {
5244
- throw Error("Method not implemented.");
5228
+ throw new a("Method not implemented.");
5245
5229
  };
5246
- }, ge = class e {
5247
- #e = new L(0, 0, 1);
5248
- #t = new I(0, 0, 0);
5230
+ }, ke = class e {
5231
+ #e = new H(0, 0, 1);
5232
+ #t = new V(0, 0, 0);
5249
5233
  constructor(e) {
5250
5234
  return e && this.parse(e), this;
5251
5235
  }
@@ -5262,37 +5246,37 @@ var G = class e {
5262
5246
  }
5263
5247
  if (e.equation) {
5264
5248
  let t = e.equation.moveLeft().reduce().left, n = t.monomByLetter("x").coefficient, r = t.monomByLetter("y").coefficient, i = t.monomByLetter("z").coefficient, a = t.monomByDegree(0).coefficient;
5265
- this.normal = new L(n, r, i), n.isNotZero() ? this.point = new I(a.clone().divide(n).opposite(), 0, 0) : r.isNotZero() ? this.point = new I(0, a.clone().divide(r).opposite(), 0) : this.point = new I(0, 0, a.clone().divide(i).opposite());
5249
+ this.normal = new H(n, r, i), this.point = n.isNotZero() ? new V(a.clone().divide(n).opposite(), 0, 0) : r.isNotZero() ? new V(0, a.clone().divide(r).opposite(), 0) : new V(0, 0, a.clone().divide(i).opposite());
5266
5250
  return;
5267
5251
  }
5268
- if (e.points?.length === 3 && e.points.every((e) => e instanceof L)) {
5269
- let t = e.points[0], n = e.points[1], r = e.points[2], i = new L(t, n), a = new L(t, r);
5252
+ if (e.points?.length === 3 && e.points.every((e) => e instanceof H)) {
5253
+ let t = e.points[0], n = e.points[1], r = e.points[2], i = new H(t, n), a = new H(t, r);
5270
5254
  this.normal = i.cross(a), this.point = t;
5271
5255
  return;
5272
5256
  }
5273
5257
  if (e.coefficients?.length === 4) {
5274
5258
  let [t, n, r, i] = e.coefficients;
5275
- this.normal = new L(t, n, r), this.point = new I(0, 0, -i);
5259
+ this.normal = new H(t, n, r), this.point = new V(0, 0, -i);
5276
5260
  return;
5277
5261
  }
5278
5262
  }
5279
5263
  get tex() {
5280
- return new k(new O("xyz", this.a, this.b, this.c, this.d), new O(0)).reduce().tex;
5264
+ return new N(new M("xyz", this.a, this.b, this.c, this.d), new M(0)).reduce().tex;
5281
5265
  }
5282
5266
  get display() {
5283
- return new k(new O("xyz", this.a, this.b, this.c, this.d), new O(0)).reduce().display;
5267
+ return new N(new M("xyz", this.a, this.b, this.c, this.d), new M(0)).reduce().display;
5284
5268
  }
5285
5269
  get a() {
5286
5270
  return this.#e.x;
5287
5271
  }
5288
- angle(t, n, r) {
5289
- if (t instanceof e) return this.normal.angle(t.normal, n, r);
5290
- let i;
5291
- if (t instanceof L) {
5292
- if (t.dimension !== 3) throw Error("Vector is not 3D");
5293
- i = t;
5294
- } else i = t.direction;
5295
- return (r ? Math.PI / 2 : 90) - this.normal.angle(i, !0, r);
5272
+ angle(t, r, i) {
5273
+ if (t instanceof e) return this.normal.angle(t.normal, r, i);
5274
+ let a;
5275
+ if (t instanceof H) {
5276
+ if (t.dimension !== 3) throw new n("Vector is not 3D");
5277
+ a = t;
5278
+ } else a = t.direction;
5279
+ return (i ? Math.PI / 2 : 90) - this.normal.angle(a, !0, i);
5296
5280
  }
5297
5281
  get b() {
5298
5282
  return this.#e.y;
@@ -5308,10 +5292,10 @@ var G = class e {
5308
5292
  }
5309
5293
  intersectWithLine(e) {
5310
5294
  let { point: t, direction: n } = e, r = this.normal.dot(t).add(this.d).divide(this.normal.dot(n).opposite());
5311
- return new I(new L(t).add(n.clone().multiplyByScalar(r)));
5295
+ return new V(new H(t).add(n.clone().multiplyByScalar(r)));
5312
5296
  }
5313
5297
  intersectWithPlane(e) {
5314
- throw this.normal.cross(e.normal), new I(0, 0, 0), Error("Intersection with plane not yet implemented !");
5298
+ throw this.normal.cross(e.normal), new V(0, 0, 0), new a("Intersection with plane not yet implemented !");
5315
5299
  }
5316
5300
  isPointOnPlane(e) {
5317
5301
  return this.normal.dot(e).add(this.d).isZero();
@@ -5320,44 +5304,44 @@ var G = class e {
5320
5304
  return this.#e;
5321
5305
  }
5322
5306
  set normal(e) {
5323
- this.#e = new L(e);
5307
+ this.#e = new H(e);
5324
5308
  }
5325
5309
  get point() {
5326
5310
  return this.#t;
5327
5311
  }
5328
5312
  set point(e) {
5329
- this.#t = new I(e);
5313
+ this.#t = new V(e);
5330
5314
  }
5331
- }, _e = /* @__PURE__ */ function(e) {
5315
+ }, Ae = /* @__PURE__ */ function(e) {
5332
5316
  return e[e.INTERIOR = 0] = "INTERIOR", e[e.EXTERIOR = 1] = "EXTERIOR", e[e.SECANT = 2] = "SECANT", e[e.TANGENT_INSIDE = 3] = "TANGENT_INSIDE", e[e.TANGENT_OUTSIDE = 4] = "TANGENT_OUTSIDE", e[e.SUPERPOSED = 5] = "SUPERPOSED", e[e.CONCENTRIC = 6] = "CONCENTRIC", e;
5333
- }({}), ve = class {
5317
+ }({}), je = class {
5334
5318
  #e = void 0;
5335
5319
  #t = void 0;
5336
5320
  #n = void 0;
5337
5321
  #r = 1;
5338
5322
  constructor(e, t) {
5339
- return e && t && (this.#e = e, this.#t = new p(t).clone().pow(2), this.#a()), this;
5323
+ return e && t && (this.#e = e, this.#t = new m(t).clone().pow(2), this.#a()), this;
5340
5324
  }
5341
5325
  fromEquation(e) {
5342
- let t = new k(e).moveLeft().reduce(), n = [
5326
+ let t = new N(e).moveLeft().reduce(), n = [
5343
5327
  "x",
5344
5328
  "y",
5345
5329
  "z"
5346
5330
  ];
5347
5331
  if (n.some((e) => t.degree(e).value !== 2)) return this.makeUndefined();
5348
5332
  let r = t.left.monomByDegree(2, "x").coefficient;
5349
- return n.some((e) => t.left.monomByDegree(2, e).coefficient.isNotEqual(r)) ? this.makeUndefined() : (this.#e = new I(t.left.monomByDegree(1, "x").coefficient.clone().opposite().divide(2), t.left.monomByDegree(1, "y").coefficient.clone().opposite().divide(2), t.left.monomByDegree(1, "z").coefficient.clone().opposite().divide(2)), this.#t = t.left.monomByDegree(0).coefficient.clone().opposite().add(this.#e.x.clone().pow(2)).add(this.#e.y.clone().pow(2)).add(this.#e.z.clone().pow(2)), this.#a(), this);
5333
+ return n.some((e) => t.left.monomByDegree(2, e).coefficient.isNotEqual(r)) ? this.makeUndefined() : (this.#e = new V(t.left.monomByDegree(1, "x").coefficient.clone().opposite().divide(2), t.left.monomByDegree(1, "y").coefficient.clone().opposite().divide(2), t.left.monomByDegree(1, "z").coefficient.clone().opposite().divide(2)), this.#t = t.left.monomByDegree(0).coefficient.clone().opposite().add(this.#e.x.clone().pow(2)).add(this.#e.y.clone().pow(2)).add(this.#e.z.clone().pow(2)), this.#a(), this);
5350
5334
  }
5351
5335
  get center() {
5352
- if (this.#e === void 0) throw Error("Sphere3 is undefined");
5336
+ if (this.#e === void 0) throw new s("Sphere3 is undefined");
5353
5337
  return this.#e;
5354
5338
  }
5355
5339
  get squareRadius() {
5356
- if (this.#t === void 0) throw Error("Sphere3 is undefined");
5340
+ if (this.#t === void 0) throw new s("Sphere3 is undefined");
5357
5341
  return this.#t;
5358
5342
  }
5359
5343
  get radius() {
5360
- if (this.#t === void 0) throw Error("Sphere3 is undefined");
5344
+ if (this.#t === void 0) throw new s("Sphere3 is undefined");
5361
5345
  return this.#t.isSquare() ? {
5362
5346
  tex: this.#t.clone().sqrt().tex,
5363
5347
  display: this.#t.clone().sqrt().display,
@@ -5369,7 +5353,7 @@ var G = class e {
5369
5353
  };
5370
5354
  }
5371
5355
  get equation() {
5372
- if (this.#n === void 0) throw Error("Sphere3 is undefined");
5356
+ if (this.#n === void 0) throw new s("Sphere3 is undefined");
5373
5357
  return this.#n;
5374
5358
  }
5375
5359
  makeUndefined() {
@@ -5388,7 +5372,7 @@ var G = class e {
5388
5372
  return this.#i(!1);
5389
5373
  }
5390
5374
  #i = (e) => {
5391
- if (this.#n === void 0) throw Error("Sphere3 is undefined");
5375
+ if (this.#n === void 0) throw new s("Sphere3 is undefined");
5392
5376
  if (this.#r === 0) return e ? this.#n.tex : this.#n.display;
5393
5377
  let t = [];
5394
5378
  return [
@@ -5398,15 +5382,15 @@ var G = class e {
5398
5382
  ].forEach((n) => {
5399
5383
  if (this.center[n].isZero()) t.push(`${n}^2`);
5400
5384
  else {
5401
- let r = new O(n).subtract(this.center[n]);
5385
+ let r = new M(n).subtract(this.center[n]);
5402
5386
  t.push(e ? `\\(${r.tex}\\)^2` : `(${r.display})^2`);
5403
5387
  }
5404
5388
  }), t.join("+") + "=" + (e ? this.squareRadius.tex : this.squareRadius.display);
5405
5389
  };
5406
5390
  #a() {
5407
- this.#n = new k(new O("x").subtract(this.center.x).pow(2).add(new O("y").subtract(this.center.y).pow(2)).add(new O("z").subtract(this.center.z).pow(2)), new O(this.squareRadius)).reduce();
5391
+ this.#n = new N(new M("x").subtract(this.center.x).pow(2).add(new M("y").subtract(this.center.y).pow(2)).add(new M("z").subtract(this.center.z).pow(2)), new M(this.squareRadius)).reduce();
5408
5392
  }
5409
- static RELATIVE_POSITION = _e;
5393
+ static RELATIVE_POSITION = Ae;
5410
5394
  relativePosition = (e) => {
5411
5395
  let t = this.center.distanceTo(e.center).value, n = this.radius.value, r = e.radius.value;
5412
5396
  return t > n + r ? 1 : t === n + r ? 4 : t === 0 ? n === r ? 5 : 6 : t === Math.abs(n - r) ? 3 : t < Math.abs(n - r) ? 0 : 2;
@@ -5419,38 +5403,38 @@ var G = class e {
5419
5403
  };
5420
5404
  //#endregion
5421
5405
  //#region src/randomization/coefficient/rndFraction.ts
5422
- function Y(e) {
5406
+ function Z(e) {
5423
5407
  let t = Object.assign({
5424
5408
  negative: !0,
5425
5409
  max: 10,
5426
5410
  reduced: !0,
5427
5411
  zero: !0,
5428
5412
  natural: !1
5429
- }, e), n = new p();
5430
- if (t.negative ? n.numerator = H(t.max, t.zero) : n.numerator = V(+!t.zero, t.max), t.natural) n.denominator = 1;
5413
+ }, e), n = new m();
5414
+ if (n.numerator = t.negative ? G(t.max, t.zero) : W(+!t.zero, t.max), t.natural) n.denominator = 1;
5431
5415
  else {
5432
5416
  let e = 0;
5433
- for (; n.isRelative() && e < 10;) n.denominator = V(1, t.max), e++;
5417
+ for (; n.isRelative() && e < 10;) n.denominator = W(1, t.max), e++;
5434
5418
  }
5435
5419
  return t.reduced ? n.reduce() : n;
5436
5420
  }
5437
5421
  //#endregion
5438
5422
  //#region src/randomization/algebra/rndMonom.ts
5439
- function ye(e) {
5423
+ function Me(e) {
5440
5424
  let t = Object.assign({
5441
5425
  letters: "x",
5442
5426
  degree: 2,
5443
5427
  fraction: !0,
5444
5428
  zero: !1
5445
- }, e), n = new E();
5446
- if (n.coefficient = Y(Object.assign({}, {
5429
+ }, e), n = new A();
5430
+ if (n.coefficient = Z(Object.assign({}, {
5447
5431
  zero: t.zero,
5448
5432
  reduced: !0,
5449
5433
  natural: t.fraction === !1
5450
5434
  }, typeof t.fraction == "boolean" ? {} : t.fraction)), t.letters.length > 1) {
5451
5435
  for (let e of t.letters.split("")) n.setLetter(e, 0);
5452
5436
  for (let e = 0; e < t.degree; e++) {
5453
- let e = U(t.letters.split(""));
5437
+ let e = K(t.letters.split(""));
5454
5438
  n.setLetter(e, n.degree(e).clone().add(1));
5455
5439
  }
5456
5440
  } else n.setLetter(t.letters, t.degree);
@@ -5458,7 +5442,7 @@ function ye(e) {
5458
5442
  }
5459
5443
  //#endregion
5460
5444
  //#region src/randomization/algebra/rndPolynom.ts
5461
- var X = {
5445
+ var Ne = {
5462
5446
  letters: "x",
5463
5447
  degree: 2,
5464
5448
  fraction: !1,
@@ -5470,36 +5454,36 @@ var X = {
5470
5454
  commonConstant: !1,
5471
5455
  positive: !0
5472
5456
  };
5473
- function Z(e) {
5474
- let t = Object.assign({}, X, e);
5475
- if (t.factorable) return be(t);
5476
- let n = new O().empty(), r, i = t.degree ?? 2;
5477
- for (let e = i; e >= 0; e--) r = ye({
5457
+ function Q(e) {
5458
+ let t = Object.assign({}, Ne, e);
5459
+ if (t.factorable) return Pe(t);
5460
+ let n = new M().empty(), r, i = t.degree ?? 2;
5461
+ for (let e = i; e >= 0; e--) r = Me({
5478
5462
  letters: t.letters,
5479
5463
  degree: e,
5480
5464
  fraction: t.fraction,
5481
5465
  zero: e !== i && t.allowNullMonom
5482
5466
  }), t.unit && i === e && r.coefficient.one(), n.add(r);
5483
5467
  if (t.positive && n.monomByDegree().coefficient.isNegative() && n.opposite(), t.numberOfMonoms && t.numberOfMonoms > 0 && t.numberOfMonoms < n.length) for (; n.length > t.numberOfMonoms;) {
5484
- let e = V(1, n.length - 1);
5468
+ let e = W(1, n.length - 1);
5485
5469
  n.monoms.splice(e, 1);
5486
5470
  }
5487
5471
  return n.reduce();
5488
5472
  }
5489
- function be(e) {
5490
- let t = Object.assign(X, e), n = { ...t };
5473
+ function Pe(e) {
5474
+ let t = Object.assign(Ne, e), n = { ...t };
5491
5475
  n.degree = 1, n.factorable = !1;
5492
5476
  let r = [], i = t.degree ?? 2;
5493
- for (; r.length < i;) r.push(Z(n));
5477
+ for (; r.length < i;) r.push(Q(n));
5494
5478
  if (e?.commonConstant !== !1) {
5495
- let t = H(10, !1);
5496
- e?.commonConstant === !0 && (t === 1 || t === -1) && (t *= V(2, 5)), t !== 1 && t !== -1 && r.unshift(new O(t));
5479
+ let t = G(10, !1);
5480
+ e?.commonConstant === !0 && (t === 1 || t === -1) && (t *= W(2, 5)), t !== 1 && t !== -1 && r.unshift(new M(t));
5497
5481
  }
5498
- return O.xMultiply(...r);
5482
+ return M.xMultiply(...r);
5499
5483
  }
5500
5484
  //#endregion
5501
5485
  //#region src/randomization/algebra/rndEquation.ts
5502
- function xe(e) {
5486
+ function Fe(e) {
5503
5487
  let t = Object.assign({
5504
5488
  letters: "x",
5505
5489
  degree: 1,
@@ -5516,9 +5500,9 @@ function xe(e) {
5516
5500
  nothing: !1,
5517
5501
  everything: !1
5518
5502
  }
5519
- }, e), n = new O().one();
5503
+ }, e), n = new M().one();
5520
5504
  for (let e = 0; e < t.degree; e++) {
5521
- let e = Z({
5505
+ let e = Q({
5522
5506
  degree: 1,
5523
5507
  unit: t.unit,
5524
5508
  fraction: t.fraction,
@@ -5527,28 +5511,28 @@ function xe(e) {
5527
5511
  });
5528
5512
  n.multiply(e);
5529
5513
  }
5530
- return new k(n, 0);
5514
+ return new N(n, 0);
5531
5515
  }
5532
5516
  //#endregion
5533
5517
  //#region src/randomization/geometry/rndPoint.ts
5534
- function Q(e) {
5518
+ function $(e) {
5535
5519
  let t = Object.assign({
5536
5520
  axis: !0,
5537
5521
  fraction: !1,
5538
5522
  max: 10,
5539
5523
  quadrant: null
5540
- }, e), n = t.axis === "x", r = t.axis === "y", i = t.fraction ? Y({
5524
+ }, e), n = t.axis === "x", r = t.axis === "y", i = t.fraction ? Z({
5541
5525
  max: t.max,
5542
5526
  zero: n
5543
- }) : new p(H(t.max, n)), a = t.fraction ? Y({
5527
+ }) : new m(G(t.max, n)), a = t.fraction ? Z({
5544
5528
  max: t.max,
5545
5529
  zero: r
5546
- }) : new p(H(t.max, r));
5547
- return Number(t.quadrant) === 1 && (i.abs(), a.abs()), Number(t.quadrant) === 2 && (i.isPositive() && i.opposite(), a.isNegative() && a.opposite()), Number(t.quadrant) === 3 && (i.isPositive() && i.opposite(), a.isPositive() && a.opposite()), Number(t.quadrant) === 4 && (i.isNegative() && i.opposite(), a.isPositive() && a.opposite()), new I(i, a);
5530
+ }) : new m(G(t.max, r));
5531
+ return Number(t.quadrant) === 1 && (i.abs(), a.abs()), Number(t.quadrant) === 2 && (i.isPositive() && i.opposite(), a.isNegative() && a.opposite()), Number(t.quadrant) === 3 && (i.isPositive() && i.opposite(), a.isPositive() && a.opposite()), Number(t.quadrant) === 4 && (i.isNegative() && i.opposite(), a.isPositive() && a.opposite()), new V(i, a);
5548
5532
  }
5549
5533
  //#endregion
5550
5534
  //#region src/randomization/geometry/rndCircle.ts
5551
- function Se(e) {
5535
+ function Ie(e) {
5552
5536
  let t = Object.assign({
5553
5537
  center: {
5554
5538
  x: {
@@ -5561,82 +5545,92 @@ function Se(e) {
5561
5545
  }
5562
5546
  },
5563
5547
  pointsOnCircle: 8
5564
- }, e), n = Q(t.center), r, i;
5565
- return t.pointsOnCircle === 8 ? (r = V(1, 3), i = r ** 2 + (r + 1) ** 2) : i = V(1, 20), new q(n, i, !0);
5548
+ }, e), n = $(t.center), r, i;
5549
+ return t.pointsOnCircle === 8 ? (r = W(1, 3), i = r ** 2 + (r + 1) ** 2) : i = W(1, 20), new Y(n, i, !0);
5566
5550
  }
5567
5551
  //#endregion
5568
5552
  //#region src/randomization/geometry/rndLine.ts
5569
- function Ce(e) {
5553
+ function Le(e) {
5570
5554
  let t = Object.assign({ A: {
5571
- x: H(10),
5572
- y: H(10)
5573
- } }, e), n = new L(0, 0);
5574
- for (; n.isNull;) n.x = H(10, t.allow?.vertical ?? !0), n.y = H(10, t.allow?.horizontal ?? !0);
5575
- return t.slope === 1 ? n.x.sign() !== n.y.sign() && n.y.opposite() : t.slope === -1 && n.x.sign() !== n.y.sign() && n.y.opposite(), new G().fromPointAndDirection(new L(t.A.x, t.A.y), n);
5555
+ x: G(10),
5556
+ y: G(10)
5557
+ } }, e), n = new H(0, 0);
5558
+ for (; n.isNull;) n.x = G(10, t.allow?.vertical ?? !0), n.y = G(10, t.allow?.horizontal ?? !0);
5559
+ return t.slope === 1 ? n.x.sign() !== n.y.sign() && n.y.opposite() : t.slope === -1 && n.x.sign() !== n.y.sign() && n.y.opposite(), new q().fromPointAndDirection(new H(t.A.x, t.A.y), n);
5576
5560
  }
5577
5561
  //#endregion
5578
5562
  //#region src/randomization/geometry/rndLine3.ts
5579
- function we(e) {
5563
+ function Re(e) {
5580
5564
  let t = Object.assign({
5581
5565
  A: {
5582
- x: H(10),
5583
- y: H(10),
5584
- z: H(10)
5566
+ x: G(10),
5567
+ y: G(10),
5568
+ z: G(10)
5585
5569
  },
5586
5570
  direction: {
5587
- x: H(10),
5588
- y: H(10),
5589
- z: H(10)
5571
+ x: G(10),
5572
+ y: G(10),
5573
+ z: G(10)
5590
5574
  }
5591
5575
  }, e);
5592
- return new J(new I(t.A.x, t.A.y, t.A.z), new L(t.direction.x, t.direction.y, t.direction.z));
5576
+ return new X(new V(t.A.x, t.A.y, t.A.z), new H(t.direction.x, t.direction.y, t.direction.z));
5593
5577
  }
5594
5578
  //#endregion
5595
5579
  //#region src/randomization/random.ts
5596
- var $ = {
5597
- equation: (e) => xe(e),
5598
- polynom: (e) => Z(e),
5599
- monom: (e) => ye(e),
5600
- fraction: (e) => Y(e),
5601
- number: (e, t, n) => V(e, t, n),
5602
- numberSym: (e, t) => H(e, t),
5603
- prime: (e) => me(e),
5604
- triplet: (e, t) => pe(e, t),
5605
- bool: (e) => B(e),
5606
- array: (e, t) => he(e, t),
5607
- item: (e) => U(e),
5608
- shuffle: (e) => W(e),
5609
- line: (e) => Ce(e),
5610
- line3: (e) => we(e),
5611
- vector: (e) => new L(Q(e)),
5612
- point: (e) => Q(e),
5613
- circle: (e) => Se(e)
5614
- }, Te = {
5615
- Numeric: d,
5616
- Fraction: p,
5580
+ var ze = {
5581
+ equation: (e) => Fe(e),
5582
+ polynom: (e) => Q(e),
5583
+ monom: (e) => Me(e),
5584
+ fraction: (e) => Z(e),
5585
+ number: (e, t, n) => W(e, t, n),
5586
+ numberSym: (e, t) => G(e, t),
5587
+ prime: (e) => Ee(e),
5588
+ triplet: (e, t) => Te(e, t),
5589
+ bool: (e) => we(e),
5590
+ array: (e, t) => De(e, t),
5591
+ item: (e) => K(e),
5592
+ shuffle: (e) => Oe(e),
5593
+ line: (e) => Le(e),
5594
+ line3: (e) => Re(e),
5595
+ vector: (e) => new H($(e)),
5596
+ point: (e) => $(e),
5597
+ circle: (e) => Ie(e)
5598
+ }, Be = {
5599
+ Numeric: p,
5600
+ Fraction: m,
5617
5601
  Root: v,
5618
- Monom: E,
5619
- Polynom: O,
5620
- Equation: k,
5621
- Matrix: le,
5622
- LinearSystem: se,
5623
- Factor: A,
5624
- PolyFactor: M,
5625
- LogicalSet: ce,
5626
- Random: $,
5602
+ Monom: A,
5603
+ Polynom: M,
5604
+ Equation: N,
5605
+ Matrix: ve,
5606
+ LinearSystem: I,
5607
+ Factor: P,
5608
+ PolyFactor: R,
5609
+ LogicalSet: L,
5610
+ Random: ze,
5627
5611
  Geometry: {
5628
- Vector: L,
5629
- Point: I,
5630
- Line: G,
5631
- Triangle: K,
5632
- Circle: q,
5633
- Line3: J,
5634
- Plane3: ge,
5635
- Sphere3: ve
5612
+ Vector: H,
5613
+ Point: V,
5614
+ Line: q,
5615
+ Triangle: J,
5616
+ Circle: Y,
5617
+ Line3: X,
5618
+ Plane3: ke,
5619
+ Sphere3: je
5620
+ },
5621
+ Errors: {
5622
+ PiMathError: e,
5623
+ ParseError: t,
5624
+ DimensionError: n,
5625
+ MathError: r,
5626
+ InvalidArgumentError: i,
5627
+ NotImplementedError: a,
5628
+ IndexError: o,
5629
+ StateError: s
5636
5630
  },
5637
- NumExp: T
5631
+ NumExp: k
5638
5632
  };
5639
5633
  //#endregion
5640
- export { q as Circle, k as Equation, b as EquationSolver, j as FACTOR_DISPLAY, f as FRAC_TYPE, A as Factor, p as Fraction, G as Line, J as Line3, se as LinearSystem, ce as LogicalSet, le as Matrix, E as Monom, T as NumExp, d as Numeric, ge as Plane3, I as Point, M as PolyFactor, O as Polynom, $ as Random, v as Root, _e as SPHERE3_RELATIVE_POSITION, y as Solution, ve as Sphere3, ee as TableOfSigns, K as Triangle, L as Vector, de as areVectorsColinears, ue as areVectorsEquals, Te as default, fe as determinantFromVectors, P as dotProduct };
5634
+ export { Y as Circle, n as DimensionError, N as Equation, b as EquationSolver, F as FACTOR_DISPLAY, oe as FRAC_TYPE, P as Factor, m as Fraction, o as IndexError, i as InvalidArgumentError, q as Line, X as Line3, I as LinearSystem, L as LogicalSet, r as MathError, ve as Matrix, A as Monom, a as NotImplementedError, k as NumExp, p as Numeric, t as ParseError, e as PiMathError, ke as Plane3, V as Point, R as PolyFactor, M as Polynom, ze as Random, v as Root, Ae as SPHERE3_RELATIVE_POSITION, y as Solution, je as Sphere3, s as StateError, ce as TableOfSigns, J as Triangle, H as Vector, be as areVectorsColinears, ye as areVectorsEquals, Be as default, Se as determinantFromVectors, xe as dotProduct };
5641
5635
 
5642
5636
  //# sourceMappingURL=pimath.js.map