pimath 0.2.11 → 0.2.13

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 (57) hide show
  1. package/dist/pimath.js +882 -907
  2. package/dist/pimath.js.map +1 -1
  3. package/package.json +3 -2
  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 +5 -4
  13. package/src/algebra/polynom.ts +30 -30
  14. package/src/coefficients/fraction.ts +6 -5
  15. package/src/coefficients/root.ts +5 -4
  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/rndHelpers.ts +2 -1
  30. package/types/algebra/equation.d.ts.map +1 -1
  31. package/types/algebra/equationSolver.d.ts.map +1 -1
  32. package/types/algebra/factor.d.ts.map +1 -1
  33. package/types/algebra/linearSystem.d.ts.map +1 -1
  34. package/types/algebra/logicalset.d.ts.map +1 -1
  35. package/types/algebra/matrix.d.ts.map +1 -1
  36. package/types/algebra/monom.d.ts.map +1 -1
  37. package/types/algebra/operations.d.ts.map +1 -1
  38. package/types/algebra/polyFactor.d.ts.map +1 -1
  39. package/types/algebra/polynom.d.ts.map +1 -1
  40. package/types/coefficients/fraction.d.ts.map +1 -1
  41. package/types/coefficients/root.d.ts.map +1 -1
  42. package/types/errors.d.ts +20 -0
  43. package/types/errors.d.ts.map +1 -0
  44. package/types/geometry/TupleN.d.ts.map +1 -1
  45. package/types/geometry/geomMath.d.ts.map +1 -1
  46. package/types/geometry/line.d.ts.map +1 -1
  47. package/types/geometry/line3.d.ts.map +1 -1
  48. package/types/geometry/plane3.d.ts.map +1 -1
  49. package/types/geometry/point.d.ts.map +1 -1
  50. package/types/geometry/sphere3.d.ts.map +1 -1
  51. package/types/geometry/triangle.d.ts.map +1 -1
  52. package/types/geometry/vector.d.ts.map +1 -1
  53. package/types/helpers.d.ts.map +1 -1
  54. package/types/index.d.ts +12 -0
  55. package/types/index.d.ts.map +1 -1
  56. package/types/numeric.d.ts.map +1 -1
  57. 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
- this.#e = e instanceof M || e instanceof A ? new M(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,23 +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);
1989
+ }
1990
+ }, le = class extends Error {
1991
+ constructor(e, t) {
1992
+ super(e, t), this.name = new.target.name;
1982
1993
  }
1983
- }, x = {
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__ */ function(e) {
1997
+ }, w = /* @__PURE__ */ function(e) {
1987
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;
1988
- }({}), C = /* @__PURE__ */ function(e) {
1999
+ }({}), T = /* @__PURE__ */ function(e) {
1989
2000
  return e.EXPRESSION = "expression", e.POLYNOM = "polynom", e.SET = "set", e.NUMERIC = "numeric", e;
1990
2001
  }({});
1991
- function te(e, t) {
1992
- if (e.length <= 1) return e;
1993
- let n = Object.keys(t).filter((e) => t[e].type === S.FUNCTION).map((e) => e);
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);
1994
2005
  n.sort((e, t) => t.length - e.length);
1995
- let r = RegExp(`^(${n.join("|")})\\(`), i = Object.keys(x);
2006
+ let r = RegExp(`^(${n.join("|")})\\(`), i = Object.keys(C);
1996
2007
  i.sort((e, t) => t.length - e.length);
1997
2008
  let a = RegExp(`^(${i.join("|")})`), o = /^(\d+(\.\d+)?)/, s = "", c, l, u;
1998
2009
  for (n.forEach((t) => {
@@ -2001,234 +2012,174 @@ function te(e, t) {
2001
2012
  e = e.replaceAll(n, `${t}($1)`);
2002
2013
  }
2003
2014
  }); e.length > 0;) {
2004
- 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)) {
2005
2019
  let t = n.find((t) => e.startsWith(t));
2006
- 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);
2007
2021
  } else if (i.length > 0 && a.exec(e)) {
2008
2022
  let t = i.find((t) => e.startsWith(t));
2009
- t && (u = t, e = e.slice(t.length), l = S.CONSTANT);
2023
+ t && (u = t, e = e.slice(t.length), l = w.CONSTANT);
2010
2024
  } else if (o.exec(e)) {
2011
2025
  let t = o.exec(e);
2012
- 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);
2013
2027
  } else switch (u = e[0], e = e.slice(1), u) {
2014
2028
  case "(":
2015
- l = S.LEFT_PARENTHESIS;
2029
+ l = w.LEFT_PARENTHESIS;
2016
2030
  break;
2017
2031
  case ")":
2018
- l = S.RIGHT_PARENTHESIS;
2032
+ l = w.RIGHT_PARENTHESIS;
2019
2033
  break;
2020
2034
  case ",":
2021
- l = S.FUNCTION_ARGUMENT;
2035
+ l = w.FUNCTION_ARGUMENT;
2022
2036
  break;
2023
2037
  case "+":
2024
2038
  case "-":
2025
2039
  case "*":
2026
2040
  case "/":
2027
2041
  case "^":
2028
- l = S.OPERATION;
2042
+ case "%":
2043
+ l = w.OPERATION;
2029
2044
  break;
2030
- default: l = S.VARIABLE;
2045
+ default: l = w.VARIABLE;
2031
2046
  }
2032
2047
  if (u === void 0 || l === void 0) throw Error("The token is undefined");
2033
- s += ne(c, l), s += u;
2048
+ s += fe(c, l), s += u;
2034
2049
  }
2035
2050
  return s;
2036
2051
  }
2037
- function ne(e, t) {
2038
- 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 ? "" : "*";
2039
2054
  }
2040
- var re = {
2055
+ var pe = {
2041
2056
  "^": {
2042
2057
  precedence: 4,
2043
2058
  associative: "right",
2044
- type: S.OPERATION
2059
+ type: w.OPERATION
2045
2060
  },
2046
2061
  "*": {
2047
2062
  precedence: 3,
2048
2063
  associative: "left",
2049
- type: S.OPERATION
2064
+ type: w.OPERATION
2050
2065
  },
2051
2066
  "/": {
2052
2067
  precedence: 3,
2053
2068
  associative: "left",
2054
- type: S.OPERATION
2069
+ type: w.OPERATION
2055
2070
  },
2056
2071
  "+": {
2057
2072
  precedence: 2,
2058
2073
  associative: "left",
2059
- type: S.OPERATION
2074
+ type: w.OPERATION
2060
2075
  },
2061
2076
  "-": {
2062
2077
  precedence: 2,
2063
2078
  associative: "left",
2064
- type: S.OPERATION
2065
- }
2066
- }, ie = {
2067
- "^": {
2068
- precedence: 4,
2069
- associative: "right",
2070
- type: S.OPERATION
2079
+ type: w.OPERATION
2071
2080
  },
2072
- "*": {
2081
+ "%": {
2073
2082
  precedence: 3,
2074
2083
  associative: "left",
2075
- type: S.OPERATION
2084
+ type: w.OPERATION
2076
2085
  },
2077
- "/": {
2086
+ "&": {
2078
2087
  precedence: 3,
2079
2088
  associative: "left",
2080
- type: S.OPERATION
2081
- },
2082
- "+": {
2083
- precedence: 2,
2084
- associative: "left",
2085
- type: S.OPERATION
2089
+ type: w.OPERATION
2086
2090
  },
2087
- "-": {
2088
- precedence: 2,
2091
+ "|": {
2092
+ precedence: 3,
2089
2093
  associative: "left",
2090
- type: S.OPERATION
2094
+ type: w.OPERATION
2091
2095
  },
2092
- "%": {
2093
- precedence: 3,
2096
+ "!": {
2097
+ precedence: 4,
2094
2098
  associative: "right",
2095
- type: S.OPERATION
2099
+ type: w.OPERATION
2096
2100
  },
2097
2101
  sin: {
2098
2102
  precedence: 4,
2099
2103
  associative: "right",
2100
- type: S.FUNCTION
2104
+ type: w.FUNCTION,
2105
+ arity: 1
2101
2106
  },
2102
2107
  cos: {
2103
2108
  precedence: 4,
2104
2109
  associative: "right",
2105
- type: S.FUNCTION
2110
+ type: w.FUNCTION,
2111
+ arity: 1
2106
2112
  },
2107
2113
  tan: {
2108
2114
  precedence: 4,
2109
2115
  associative: "right",
2110
- type: S.FUNCTION
2111
- },
2112
- sqrt: {
2113
- precedence: 4,
2114
- associative: "right",
2115
- type: S.FUNCTION
2116
- },
2117
- nthrt: {
2118
- precedence: 4,
2119
- associative: "right",
2120
- type: S.FUNCTION
2121
- },
2122
- logn: {
2123
- precedence: 4,
2124
- associative: "right",
2125
- type: S.FUNCTION
2126
- },
2127
- ",": {
2128
- precedence: 2,
2129
- associative: "left",
2130
- type: S.FUNCTION_ARGUMENT
2131
- }
2132
- }, ae = {
2133
- "^": {
2134
- precedence: 4,
2135
- associative: "right",
2136
- type: S.OPERATION
2137
- },
2138
- "*": {
2139
- precedence: 3,
2140
- associative: "left",
2141
- type: S.OPERATION
2142
- },
2143
- "/": {
2144
- precedence: 3,
2145
- associative: "left",
2146
- type: S.OPERATION
2147
- },
2148
- "+": {
2149
- precedence: 2,
2150
- associative: "left",
2151
- type: S.OPERATION
2152
- },
2153
- "-": {
2154
- precedence: 2,
2155
- associative: "left",
2156
- type: S.OPERATION
2157
- },
2158
- "%": {
2159
- precedence: 3,
2160
- associative: "right",
2161
- type: S.OPERATION
2116
+ type: w.FUNCTION,
2117
+ arity: 1
2162
2118
  },
2163
- sin: {
2119
+ asin: {
2164
2120
  precedence: 4,
2165
2121
  associative: "right",
2166
- type: S.FUNCTION
2122
+ type: w.FUNCTION,
2123
+ arity: 1
2167
2124
  },
2168
- cos: {
2125
+ acos: {
2169
2126
  precedence: 4,
2170
2127
  associative: "right",
2171
- type: S.FUNCTION
2128
+ type: w.FUNCTION,
2129
+ arity: 1
2172
2130
  },
2173
- tan: {
2131
+ atan: {
2174
2132
  precedence: 4,
2175
2133
  associative: "right",
2176
- type: S.FUNCTION
2134
+ type: w.FUNCTION,
2135
+ arity: 1
2177
2136
  },
2178
2137
  sqrt: {
2179
2138
  precedence: 4,
2180
2139
  associative: "right",
2181
- type: S.FUNCTION
2140
+ type: w.FUNCTION,
2141
+ arity: 1
2182
2142
  },
2183
2143
  nthrt: {
2184
2144
  precedence: 4,
2185
2145
  associative: "right",
2186
- type: S.FUNCTION
2146
+ type: w.FUNCTION,
2147
+ arity: 2
2187
2148
  },
2188
2149
  ln: {
2189
2150
  precedence: 4,
2190
2151
  associative: "right",
2191
- type: S.FUNCTION
2192
- },
2193
- logn: {
2194
- precedence: 4,
2195
- associative: "right",
2196
- type: S.FUNCTION
2152
+ type: w.FUNCTION,
2153
+ arity: 1
2197
2154
  },
2198
2155
  log: {
2199
2156
  precedence: 4,
2200
2157
  associative: "right",
2201
- type: S.FUNCTION
2202
- }
2203
- }, oe = {
2204
- "&": {
2205
- precedence: 3,
2206
- associative: "left",
2207
- type: S.OPERATION
2158
+ type: w.FUNCTION,
2159
+ arity: 1
2208
2160
  },
2209
- "|": {
2210
- precedence: 3,
2211
- associative: "left",
2212
- type: S.OPERATION
2213
- },
2214
- "!": {
2161
+ logn: {
2215
2162
  precedence: 4,
2216
2163
  associative: "right",
2217
- type: S.OPERATION
2218
- },
2219
- "-": {
2220
- precedence: 2,
2221
- associative: "left",
2222
- type: S.OPERATION
2164
+ type: w.FUNCTION,
2165
+ arity: 2
2223
2166
  }
2224
- }, 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 {
2225
2176
  #e;
2226
2177
  #t = [];
2227
2178
  #n = {};
2228
2179
  #r = [];
2229
2180
  #i;
2230
2181
  constructor(e) {
2231
- this.#e = e === void 0 ? C.POLYNOM : e, this.tokenConfigInitialization();
2182
+ this.#e = e === void 0 ? T.POLYNOM : e, this.tokenConfigInitialization();
2232
2183
  }
2233
2184
  get rpn() {
2234
2185
  return this.#t;
@@ -2237,217 +2188,216 @@ var re = {
2237
2188
  return this.#t.map((e) => e.token);
2238
2189
  }
2239
2190
  tokenConfigInitialization() {
2240
- 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;
2241
2192
  }
2242
2193
  NextToken(e, t) {
2243
2194
  let n, r;
2244
- if (n = "", r = void 0, e[t] === "(") n = "(", r = S.LEFT_PARENTHESIS;
2245
- else if (e[t] === ")") n = ")", r = S.RIGHT_PARENTHESIS;
2246
- 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;
2247
2198
  else {
2248
2199
  for (let i of this.#r) if (e.substring(t, t + i.length) === i) {
2249
2200
  n += i, r = this.#n[i].type;
2250
2201
  break;
2251
2202
  }
2252
- for (let i in x) if (e.substring(t, t + i.length) === i) {
2253
- 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;
2254
2205
  break;
2255
2206
  }
2256
2207
  if (n === "") if (/[0-9.]/.exec(e[t])) {
2257
2208
  let i = /^([0-9.]+)/.exec(e.substring(t));
2258
- n = i ? i[0] : "", r = S.COEFFICIENT;
2209
+ n = i ? i[0] : "", r = w.COEFFICIENT;
2259
2210
  } else if (/[a-zA-Z]/.exec(e[t])) {
2260
2211
  let i = /^([a-zA-Z])/.exec(e.substring(t));
2261
- n = i ? i[0] : "", r = S.VARIABLE;
2262
- } 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}"`);
2263
2214
  }
2264
- if (r === void 0) throw Error(`Token type is undefined for token ${n}`);
2265
- return [
2266
- n,
2267
- t + n.length,
2268
- r
2269
- ];
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
+ };
2270
2221
  }
2271
2222
  parse(e, t) {
2272
- let n = [], r = [], i = "", a = 0, o;
2273
- (t ?? this.#i) && (e = te(e, this.#n));
2274
- let s = 50, c;
2275
- for (; a < e.length;) {
2276
- if (s--, s === 0) {
2277
- console.log("SECURITY LEVEL 1 EXIT");
2278
- break;
2279
- }
2280
- switch ([i, a, o] = this.NextToken(e, a), o) {
2281
- case S.MONOM:
2282
- case S.COEFFICIENT:
2283
- case S.VARIABLE:
2284
- 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:
2285
2231
  n.push({
2286
- token: i,
2287
- tokenType: o
2232
+ token: a,
2233
+ tokenType: s
2288
2234
  });
2289
2235
  break;
2290
- case S.OPERATION:
2236
+ case w.OPERATION:
2291
2237
  if (r.length > 0) {
2292
2238
  let e = r[r.length - 1];
2293
- 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);) {
2294
- if (c--, c === 0) {
2295
- console.log("SECURITY LEVEL 2 OPERATION EXIT");
2296
- break;
2297
- }
2298
- if (n.push(r.pop() ?? {
2299
- token: "",
2300
- tokenType: S.OPERATION
2301
- }), r.length === 0) break;
2302
- e = r[r.length - 1];
2303
- }
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];
2304
2243
  }
2305
2244
  r.push({
2306
- token: i,
2307
- tokenType: o
2245
+ token: a,
2246
+ tokenType: s
2308
2247
  });
2309
2248
  break;
2310
- case S.FUNCTION_ARGUMENT:
2311
- for (c = 50; r[r.length - 1].token !== "(" && r.length > 0;) {
2312
- if (c--, c === 0) {
2313
- console.log("SECURITY LEVEL 2 FUNCTION ARGUMENT EXIT");
2314
- break;
2315
- }
2316
- n.push(r.pop() ?? {
2317
- token: i,
2318
- tokenType: o
2319
- });
2320
- }
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}"`);
2321
2255
  break;
2322
- case S.LEFT_PARENTHESIS:
2256
+ case w.LEFT_PARENTHESIS:
2323
2257
  r.push({
2324
- token: i,
2325
- tokenType: o
2326
- }), e[a] === "-" && n.push({
2258
+ token: a,
2259
+ tokenType: s
2260
+ }), e[i] === "-" && n.push({
2327
2261
  token: "0",
2328
- tokenType: S.COEFFICIENT
2262
+ tokenType: w.COEFFICIENT
2329
2263
  });
2330
2264
  break;
2331
- case S.RIGHT_PARENTHESIS:
2332
- for (c = 50; r[r.length - 1].token !== "(" && r.length > 1;) {
2333
- if (c--, c === 0) {
2334
- console.log("SECURITY LEVEL 2 CLOSING PARENTHESIS EXIT");
2335
- break;
2336
- }
2337
- n.push(r.pop() ?? {
2338
- token: i,
2339
- tokenType: o
2340
- });
2341
- }
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}"`);
2342
2271
  r.pop();
2343
2272
  break;
2344
- case S.FUNCTION:
2273
+ case w.FUNCTION:
2345
2274
  r.push({
2346
- token: i,
2347
- tokenType: o
2275
+ token: a,
2276
+ tokenType: s
2348
2277
  });
2349
2278
  break;
2350
- default: throw Error(`Token type ${i} is not handled`);
2279
+ default: throw new x(`Token type ${a} is not handled`);
2351
2280
  }
2352
2281
  }
2282
+ if (r.some((e) => e.token === "(")) throw new x(`Mismatched parentheses (unclosed '(') in "${e}"`);
2353
2283
  return this.#t = n.concat(r.reverse()), this;
2354
2284
  }
2355
- }, T = class {
2285
+ }, k = class {
2356
2286
  _rpn;
2357
2287
  _expression;
2358
- _isValid;
2359
2288
  constructor(e, t) {
2360
2289
  this._expression = e;
2361
2290
  try {
2362
- this._rpn = new w(C.NUMERIC).parse(e, t).rpn;
2291
+ this._rpn = new O(T.NUMERIC).parse(e, t).rpn;
2363
2292
  } catch (t) {
2364
- throw this._rpn = null, this._isValid = !1, console.warn(t), Error(`There was a problem parsing: ${e}`);
2293
+ throw new x(`There was a problem parsing: ${e}`, { cause: t });
2365
2294
  }
2366
2295
  }
2367
2296
  get rpn() {
2368
- return this._rpn ?? [];
2369
- }
2370
- get isValid() {
2371
- if (this._isValid === void 0) try {
2372
- this.evaluate({ x: 2 });
2373
- } catch (e) {
2374
- e instanceof Error, this._isValid = !1;
2375
- }
2376
- return this._isValid ?? !1;
2377
- }
2378
- set isValid(e) {
2379
- this._isValid = e;
2297
+ return this._rpn;
2380
2298
  }
2381
2299
  get expression() {
2382
2300
  return this._expression;
2383
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
+ }
2384
2332
  evaluate(e) {
2385
2333
  let t = [];
2386
- if (this._rpn === null) return this._isValid = !1, 0;
2387
- this._isValid = !0;
2388
- for (let n of this._rpn) if (n.tokenType === S.COEFFICIENT) if (!isNaN(+n.token)) t.push(+n.token);
2389
- else {
2390
- let e = n.token.split("/");
2391
- if (e.length !== 2) throw this._isValid = !1, Error("This coefficient is not a fraction");
2392
- t.push(e[0] / +e[1]);
2393
- }
2394
- else if (n.tokenType === S.VARIABLE && e !== void 0) Object.hasOwn(e, n.token) && t.push(+e[n.token]);
2395
- else if (n.tokenType === S.CONSTANT) t.push(x[n.token]);
2396
- 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) {
2397
2340
  if (n.token === "*") {
2398
2341
  let e = t.pop(), n = t.pop();
2399
- if (n === void 0 || e === void 0) throw this._isValid = !1, 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`);
2400
2343
  t.push(n * e);
2401
2344
  } else if (n.token === "/") {
2402
2345
  let e = t.pop(), n = t.pop();
2403
- if (n === void 0 || e === void 0) throw this._isValid = !1, 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`);
2404
2347
  t.push(n / e);
2405
2348
  } else if (n.token === "+") {
2406
2349
  let e = t.pop(), n = t.pop();
2407
- if (n === void 0 || e === void 0) throw this._isValid = !1, Error(`The addition values ${n ?? "a"} or ${e ?? "b"} are not defined`);
2408
- 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);
2409
2352
  } else if (n.token === "-") {
2410
2353
  let e = t.pop(), n = t.pop() ?? 0;
2411
- if (e === void 0) throw this._isValid = !1, Error("The subtraction value b is not defined");
2354
+ if (e === void 0) throw new S("The subtraction value b is not defined");
2412
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);
2413
2360
  } else if (n.token === "^") {
2414
2361
  let e = t.pop(), n = t.pop();
2415
- if (n === void 0 || e === void 0) throw this._isValid = !1, 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`);
2416
2363
  t.push(n ** +e);
2417
2364
  }
2418
- } else if (n.tokenType === S.FUNCTION) {
2365
+ } else if (n.tokenType === w.FUNCTION) {
2419
2366
  let e = t.pop();
2420
- if (e === void 0) throw this._isValid = !1, 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`);
2421
2368
  if (n.token === "sin") t.push(Math.sin(e));
2422
2369
  else if (n.token === "cos") t.push(Math.cos(e));
2423
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));
2424
2374
  else if (n.token === "sqrt") t.push(Math.sqrt(e));
2425
2375
  else if (n.token === "nthrt") {
2426
2376
  let n = t.pop();
2427
- if (n === void 0) throw this._isValid = !1, Error("The nthrt function requires two parameters");
2377
+ if (n === void 0) throw new S("The nthrt function requires two parameters");
2428
2378
  e % 2 == 0 && n < 0 ? t.push(NaN) : t.push((n < 0 ? -1 : 1) * Math.abs(n) ** (1 / e));
2429
2379
  } else if (n.token === "ln") t.push(Math.log(e));
2430
2380
  else if (n.token === "log") t.push(Math.log10(e));
2431
2381
  else if (n.token === "logn") {
2432
2382
  let n = t.pop();
2433
- if (n === void 0) throw this._isValid = !1, Error("The logn function requires two parameters");
2383
+ if (n === void 0) throw new S("The logn function requires two parameters");
2434
2384
  e <= 0 || e === 1 || n <= 0 ? t.push(NaN) : t.push(Math.log(n) / Math.log(e));
2435
2385
  }
2436
2386
  }
2437
2387
  if (t.length === 1) return this._numberCorrection(t[0]);
2438
- throw Error(`There was a problem parsing: ${this._expression}`);
2388
+ throw new S(`There was a problem parsing: ${this._expression}`);
2439
2389
  }
2440
2390
  _numberCorrection(e, t = 8) {
2441
2391
  return +e.toFixed(t);
2442
2392
  }
2443
- }, E = class e {
2393
+ }, A = class e {
2444
2394
  #e;
2445
2395
  #t;
2446
2396
  constructor(e) {
2447
- 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;
2448
2398
  }
2449
2399
  parse(t) {
2450
- 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);
2451
2401
  }
2452
2402
  clone = () => {
2453
2403
  let t = new e();
@@ -2464,10 +2414,10 @@ var re = {
2464
2414
  static gcd = (...t) => {
2465
2415
  for (let n of t) if (n.containsRationalPower()) return new e().zero();
2466
2416
  let n = new e();
2467
- 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();
2468
2418
  for (let e of t) {
2469
2419
  for (let t in n.literal) t in e.literal || n.removeVariable(t);
2470
- 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));
2471
2421
  }
2472
2422
  return n;
2473
2423
  };
@@ -2480,7 +2430,7 @@ var re = {
2480
2430
  for (let n of t) {
2481
2431
  let t = n instanceof e ? n : new e(n);
2482
2432
  if (this.isSameAs(t)) this.isZero() && this.#n(t), this.#e.add(t.coefficient);
2483
- 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);
2484
2434
  }
2485
2435
  return this;
2486
2436
  };
@@ -2488,14 +2438,14 @@ var re = {
2488
2438
  return this.#e;
2489
2439
  }
2490
2440
  set coefficient(e) {
2491
- this.#e = new p(e);
2441
+ this.#e = new m(e);
2492
2442
  }
2493
2443
  containsRationalPower = () => Object.values(this.#t).some((e) => e.isRational());
2494
- 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();
2495
2445
  derivative = (t = "x") => {
2496
2446
  if (this.hasVariable(t)) {
2497
2447
  let e = this.#t[t].clone(), n = this.clone();
2498
- return n.#t[t].subtract(1), n.#e.multiply(new p(e.clone())), n;
2448
+ return n.#t[t].subtract(1), n.#e.multiply(new m(e.clone())), n;
2499
2449
  }
2500
2450
  return new e().zero();
2501
2451
  };
@@ -2509,42 +2459,42 @@ var re = {
2509
2459
  };
2510
2460
  get dividers() {
2511
2461
  if (!this.coefficient.isRelative() || this.containsRationalPower() || this.coefficient.numerator > 1e6) return [this.clone()];
2512
- let t = d.dividers(Math.abs(this.coefficient.numerator)), n = [];
2462
+ let t = p.dividers(Math.abs(this.coefficient.numerator)), n = [];
2513
2463
  for (let e in this.literal) n = this.#a(n, e);
2514
2464
  let r = [];
2515
2465
  if (n.length > 0 && t.length > 0) for (let i of t) for (let t of n) {
2516
2466
  let n = new e();
2517
- n.coefficient = new p(i), n.literal = t, r.push(n);
2467
+ n.coefficient = new m(i), n.literal = t, r.push(n);
2518
2468
  }
2519
2469
  else if (t.length === 0) for (let t of n) {
2520
2470
  let n = new e();
2521
- n.coefficient = new p().one(), n.literal = t, r.push(n);
2471
+ n.coefficient = new m().one(), n.literal = t, r.push(n);
2522
2472
  }
2523
2473
  else for (let n of t) {
2524
2474
  let t = new e();
2525
- t.coefficient = new p(n), r.push(t);
2475
+ t.coefficient = new m(n), r.push(t);
2526
2476
  }
2527
2477
  return r.length === 0 ? [new e().one()] : r;
2528
2478
  }
2529
2479
  evaluate = (e, t) => {
2530
2480
  if (t === !0) {
2531
- if (e instanceof p) return this.#r(e.value);
2481
+ if (e instanceof m) return this.#r(e.value);
2532
2482
  if (typeof e == "number") return this.#r(e);
2533
2483
  if (typeof e == "object") {
2534
2484
  let t = {};
2535
- 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;
2536
2486
  return this.#r(t);
2537
2487
  }
2538
2488
  }
2539
2489
  let n = this.coefficient.clone();
2540
- if (typeof e == "number" || e instanceof p) {
2490
+ if (typeof e == "number" || e instanceof m) {
2541
2491
  let t = {};
2542
- return t[this.variables[0]] = new p(e), this.evaluate(t);
2492
+ return t[this.variables[0]] = new m(e), this.evaluate(t);
2543
2493
  }
2544
2494
  if (typeof e == "object") {
2545
2495
  if (this.variables.length === 0) return this.coefficient;
2546
2496
  for (let t in this.#t) {
2547
- let r = new p(e[t]);
2497
+ let r = new m(e[t]);
2548
2498
  n.multiply(r.pow(this.#t[t]));
2549
2499
  }
2550
2500
  }
@@ -2590,8 +2540,8 @@ var re = {
2590
2540
  this.#t = e;
2591
2541
  }
2592
2542
  set literalStr(e) {
2593
- 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]);
2594
- 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);
2595
2545
  }
2596
2546
  multiply = (...t) => {
2597
2547
  for (let n of t) {
@@ -2601,7 +2551,7 @@ var re = {
2601
2551
  }
2602
2552
  return this;
2603
2553
  };
2604
- one = () => (this.#e = new p().one(), this.#t = {}, this);
2554
+ one = () => (this.#e = new m().one(), this.#t = {}, this);
2605
2555
  opposite = () => (this.#e.opposite(), this);
2606
2556
  get plotFunction() {
2607
2557
  return this.#i("plot");
@@ -2613,7 +2563,7 @@ var re = {
2613
2563
  };
2614
2564
  primitive = (e = "x") => {
2615
2565
  let t = this.clone(), n;
2616
- 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;
2617
2567
  };
2618
2568
  reduce = () => {
2619
2569
  this.coefficient.reduce();
@@ -2624,9 +2574,9 @@ var re = {
2624
2574
  delete this.#t[e];
2625
2575
  }
2626
2576
  root = () => {
2627
- throw Error("Method not implemented.");
2577
+ throw new a("Method not implemented.");
2628
2578
  };
2629
- 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));
2630
2580
  sqrt = () => {
2631
2581
  if (this.isSquare()) {
2632
2582
  this.#e.sqrt();
@@ -2638,7 +2588,7 @@ var re = {
2638
2588
  for (let n of t) {
2639
2589
  let t = n instanceof e ? n : new e(n);
2640
2590
  if (this.isSameAs(t)) this.isZero() && this.#n(t), this.#e.add(t.clone().coefficient.opposite());
2641
- else throw Error("Subtract: Is not similar: " + t.display);
2591
+ else throw new r("Subtract: Is not similar: " + t.display);
2642
2592
  }
2643
2593
  return this;
2644
2594
  };
@@ -2648,7 +2598,7 @@ var re = {
2648
2598
  n.isZero() || e.push(t);
2649
2599
  }), e.sort(), e;
2650
2600
  }
2651
- zero = () => (this.#e = new p().zero(), this.#t = {}, this);
2601
+ zero = () => (this.#e = new m().zero(), this.#t = {}, this);
2652
2602
  #n(e) {
2653
2603
  for (let t in e.literal) this.#t[t] = e.literal[t].clone();
2654
2604
  }
@@ -2658,15 +2608,15 @@ var re = {
2658
2608
  let t = {}, n = this.variables[0];
2659
2609
  return t[n] = e, this.#r(t);
2660
2610
  }
2661
- if (e instanceof p) {
2611
+ if (e instanceof m) {
2662
2612
  let t = {};
2663
- 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);
2664
2614
  }
2665
2615
  if (typeof e == "object") {
2666
2616
  if (this.variables.length === 0) return this.coefficient.value;
2667
2617
  for (let n in this.#t) {
2668
2618
  let r = e[n];
2669
- 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;
2670
2620
  }
2671
2621
  }
2672
2622
  return t;
@@ -2681,21 +2631,21 @@ var re = {
2681
2631
  let n = [];
2682
2632
  for (let r = 0; r <= this.literal[t].value; r++) if (e.length === 0) {
2683
2633
  let e = {};
2684
- e[t] = new p(r), n.push(e);
2634
+ e[t] = new m(r), n.push(e);
2685
2635
  } else for (let i of e) {
2686
2636
  let e = {};
2687
2637
  for (let t in i) e[t] = i[t];
2688
- e[t] = new p(r), n.push(e);
2638
+ e[t] = new m(r), n.push(e);
2689
2639
  }
2690
2640
  return n;
2691
2641
  }
2692
2642
  #o = (t, n) => {
2693
2643
  let r, i, a, o, s;
2694
- if (n.tokenType === S.COEFFICIENT) t.push(new e(new p(n.token)));
2695
- 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) {
2696
2646
  let r = new e().one();
2697
2647
  r.setLetter(n.token, 1), t.push(r.clone());
2698
- } else if (n.tokenType === S.OPERATION) switch (n.token) {
2648
+ } else if (n.tokenType === w.OPERATION) switch (n.token) {
2699
2649
  case "-":
2700
2650
  i = t.pop() ?? new e().zero(), r = t.pop() ?? new e().zero(), t.push(r.subtract(i));
2701
2651
  break;
@@ -2705,25 +2655,31 @@ var re = {
2705
2655
  case "/":
2706
2656
  i = t.pop() ?? new e().one(), r = t.pop() ?? new e().one(), t.push(r.divide(i));
2707
2657
  break;
2708
- case "^": 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);
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);
2709
2659
  }
2710
2660
  };
2711
2661
  #s = (e) => {
2712
- let t = new w().parse(e).rpn, n = [];
2713
- if (t.length === 0) return this.zero(), this;
2714
- if (t.length === 1) {
2715
- let e = t[0];
2716
- return this.one(), e.tokenType === S.COEFFICIENT ? this.coefficient = new p(e.token) : e.tokenType === S.VARIABLE && this.setLetter(e.token, 1), 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 });
2717
2667
  }
2718
- for (let e of t) this.#o(n, e);
2719
- return this.one(), this.multiply(n[0]), this;
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;
2720
2676
  };
2721
2677
  };
2722
2678
  //#endregion
2723
2679
  //#region src/algebra/operations.ts
2724
- function D(e, t) {
2725
- if (!Number.isSafeInteger(t)) throw Error("Can only raise item by an integer");
2726
- 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");
2727
2683
  if (t === 0) return e.one();
2728
2684
  let n = e.clone();
2729
2685
  for (let r = 1; r < t; r++) e.multiply(n);
@@ -2731,7 +2687,7 @@ function D(e, t) {
2731
2687
  }
2732
2688
  //#endregion
2733
2689
  //#region src/algebra/polynom.ts
2734
- var O = class e {
2690
+ var M = class e {
2735
2691
  #e = "x";
2736
2692
  #t;
2737
2693
  #n;
@@ -2742,9 +2698,9 @@ var O = class e {
2742
2698
  }
2743
2699
  parse(t, ...n) {
2744
2700
  if (this.#n = [], this.#t = [], this.#u(), typeof t == "string") return this.#h(t, ...n);
2745
- if ((typeof t == "number" || t instanceof p || t instanceof E) && n.length === 0) this.#n.push(new E(t));
2746
- else if (t instanceof E && n.length > 0) this.#n.push(new E(t)), n.forEach((e) => {
2747
- 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));
2748
2704
  });
2749
2705
  else if (t instanceof e) for (let e of t.monoms) this.#n.push(e.clone());
2750
2706
  return this;
@@ -2768,21 +2724,21 @@ var O = class e {
2768
2724
  }), n;
2769
2725
  }
2770
2726
  add(...t) {
2771
- 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));
2772
2728
  return this.reduce();
2773
2729
  }
2774
2730
  commonMonom() {
2775
- let e = new E().one();
2776
- e.coefficient = new p(this.gcdNumerator(), this.gcdDenominator());
2731
+ let e = new A().one();
2732
+ e.coefficient = new m(this.gcdNumerator(), this.gcdDenominator());
2777
2733
  for (let t of this.variables) {
2778
2734
  e.setLetter(t, this.degree(t));
2779
- 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;
2780
2736
  }
2781
2737
  return e;
2782
2738
  }
2783
2739
  degree(e) {
2784
- let t = new p().zero();
2785
- 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);
2786
2742
  return t;
2787
2743
  }
2788
2744
  derivative(t) {
@@ -2791,9 +2747,9 @@ var O = class e {
2791
2747
  return n.reduce();
2792
2748
  }
2793
2749
  divide(t) {
2794
- if (t instanceof p) return this.#o(t);
2750
+ if (t instanceof m) return this.#o(t);
2795
2751
  if (typeof t == "number" && Number.isSafeInteger(t)) return this.#s(t);
2796
- if (t instanceof E) return this.divide(new e(t));
2752
+ if (t instanceof A) return this.divide(new e(t));
2797
2753
  if (t instanceof e) {
2798
2754
  if (t.monoms.length === 1 && t.variables.length === 0) return this.#o(t.monoms[0].coefficient);
2799
2755
  {
@@ -2801,28 +2757,28 @@ var O = class e {
2801
2757
  if (n.isZero()) return this.#n = e.monoms, this.#u(), this;
2802
2758
  }
2803
2759
  } else if (typeof t == "string") return this.divide(new e(t));
2804
- throw Error(`Cannot divide by ${t}`);
2760
+ throw new r(`Cannot divide by ${t}`);
2805
2761
  }
2806
2762
  empty() {
2807
2763
  return this.#n = [], this.#u(), this;
2808
2764
  }
2809
2765
  euclidean(t) {
2810
- 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);
2811
2767
  if (t.variables.length === 0) return {
2812
2768
  quotient: this.clone().divide(t).reduce(),
2813
2769
  reminder: new e().zero()
2814
2770
  };
2815
- if (!this.degree(n).isNatural() || !t.degree(n).isNatural()) throw Error("Euclidean division requires integer degrees");
2816
- let a = t.monomByDegree(void 0, n), o = t.degree(n), s, c = this.degree(n).value - o.value + 1;
2817
- 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()))););
2818
- return r.reduce(), i.reduce(), {
2819
- quotient: r,
2820
- 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
2821
2777
  };
2822
2778
  }
2823
2779
  evaluate(e, t) {
2824
2780
  if (t) return this.#c(e);
2825
- let n = new p().zero();
2781
+ let n = new m().zero();
2826
2782
  return this.#n.forEach((r) => {
2827
2783
  n.add(r.evaluate(e, t));
2828
2784
  }), n;
@@ -2848,19 +2804,19 @@ var O = class e {
2848
2804
  this.#n = [];
2849
2805
  let t = this.#e ?? "x";
2850
2806
  return e.reverse().forEach((e, n) => {
2851
- let r = new E();
2852
- 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);
2853
2809
  }), this.#u(), this.reorder();
2854
2810
  }
2855
2811
  gcdDenominator() {
2856
- return d.gcd(...this.getDenominators());
2812
+ return p.gcd(...this.getDenominators());
2857
2813
  }
2858
2814
  gcdNumerator() {
2859
- return d.gcd(...this.getNumerators());
2815
+ return p.gcd(...this.getNumerators());
2860
2816
  }
2861
2817
  getCoefficients() {
2862
- if (!this.degree().isNatural()) throw Error("getCoefficients() requires a polynomial with integer degrees");
2863
- 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));
2864
2820
  return e.monoms.forEach((e) => {
2865
2821
  let r = t - e.degree().value - 1;
2866
2822
  n[r] = e.coefficient.clone();
@@ -2884,18 +2840,14 @@ var O = class e {
2884
2840
  }
2885
2841
  integrate(e, t, n = "x") {
2886
2842
  let r = this.primitive(n), i = {}, a = {};
2887
- 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));
2888
2844
  }
2889
2845
  inverse() {}
2890
2846
  isDeveloped(t) {
2891
- let n, r = t.replaceAll(/\^\(([-0-9/]+)\)/g, "$1");
2892
- if (r.includes("(") || r.includes(")")) return !1;
2893
- try {
2894
- n = new e(t);
2895
- } catch {
2896
- return !1;
2897
- }
2898
- 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);
2899
2851
  }
2900
2852
  isDividableBy(e) {
2901
2853
  if (e.degree().isOne()) {
@@ -2926,33 +2878,33 @@ var O = class e {
2926
2878
  return this.#n.length === 1 && this.#n[0].coefficient.isZero() || this.#n.length === 0;
2927
2879
  }
2928
2880
  lcmDenominator() {
2929
- return d.lcm(...this.getDenominators());
2881
+ return p.lcm(...this.getDenominators());
2930
2882
  }
2931
2883
  lcmNumerator() {
2932
- return d.lcm(...this.getNumerators());
2884
+ return p.lcm(...this.getNumerators());
2933
2885
  }
2934
2886
  get length() {
2935
2887
  return this.#n.length;
2936
2888
  }
2937
2889
  limitTo(e, t) {
2938
- let n = new p(e);
2890
+ let n = new m(e);
2939
2891
  if (n.isFinite()) {
2940
2892
  let e = t ?? this.variables[0] ?? "x";
2941
2893
  return this.evaluate({ [e]: n });
2942
2894
  }
2943
2895
  let r = this.monomByDegree(void 0, t), i = r.coefficient.sign(), a = r.degree(t);
2944
- 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();
2945
2897
  }
2946
2898
  monomByDegree(e, t) {
2947
2899
  if (e === void 0) return this.monomByDegree(this.degree(t), t);
2948
2900
  let n = this.clone().reduce();
2949
2901
  for (let r of n.#n) if (r.degree(t).isEqual(e)) return r.clone();
2950
- return new E().zero();
2902
+ return new A().zero();
2951
2903
  }
2952
2904
  monomByLetter(e) {
2953
2905
  let t = this.clone().reduce();
2954
2906
  for (let n of t.#n) if (n.hasVariable(e)) return n.clone();
2955
- return new E().zero();
2907
+ return new A().zero();
2956
2908
  }
2957
2909
  get monoms() {
2958
2910
  return this.#n;
@@ -2968,22 +2920,22 @@ var O = class e {
2968
2920
  }
2969
2921
  multiply(t) {
2970
2922
  if (t instanceof e) return this.#m(t);
2971
- if (t instanceof p) return this.#d(t);
2972
- 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);
2973
2925
  if (Number.isSafeInteger(t) && typeof t == "number") return this.#f(t);
2974
2926
  if (typeof t == "string") try {
2975
- let e = new p(t);
2927
+ let e = new m(t);
2976
2928
  return this.#d(e);
2977
- } catch {
2978
- throw Error("Cannot multiply by this value.");
2929
+ } catch (e) {
2930
+ throw new r("Cannot multiply by this value.", { cause: e });
2979
2931
  }
2980
- throw Error(`Cannot multiply by this value: ${t}`);
2932
+ throw new r(`Cannot multiply by this value: ${t}`);
2981
2933
  }
2982
2934
  get numberOfVars() {
2983
2935
  return this.variables.length;
2984
2936
  }
2985
2937
  one() {
2986
- 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;
2987
2939
  }
2988
2940
  opposite() {
2989
2941
  return this.#n = this.#n.map((e) => e.opposite()), this.#u(), this;
@@ -2992,7 +2944,7 @@ var O = class e {
2992
2944
  return this.#l("tex", !1, !1, !0);
2993
2945
  }
2994
2946
  pow(e) {
2995
- return D(this, e).reduce();
2947
+ return j(this, e).reduce();
2996
2948
  }
2997
2949
  primitive(t) {
2998
2950
  let n = new e();
@@ -3002,7 +2954,7 @@ var O = class e {
3002
2954
  reduce() {
3003
2955
  let e = 0;
3004
2956
  for (; e < this.#n.length;) {
3005
- 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--);
3006
2958
  e++;
3007
2959
  }
3008
2960
  this.#n = this.#n.filter((e) => !e.coefficient.isZero());
@@ -3022,16 +2974,16 @@ var O = class e {
3022
2974
  }), this;
3023
2975
  }
3024
2976
  replaceBy(t, n) {
3025
- let r, i = new e().zero();
3026
- 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());
3027
2979
  else {
3028
- if (r = e.literal[t].clone(), e.removeVariable(t), r.isStrictlyNegative()) throw Error(`Cannot replace variable "${t}" with negative power in a Polynom`);
3029
- 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));
3030
2982
  }
3031
- return this.#n = i.reduce().monoms, this.#u(), this;
2983
+ return this.#n = a.reduce().monoms, this.#u(), this;
3032
2984
  }
3033
2985
  root() {
3034
- throw Error("Cannot take the root from a polynom");
2986
+ throw new r("Cannot take the root from a polynom");
3035
2987
  }
3036
2988
  get roots() {
3037
2989
  return this.#i ? this.#r : this.getZeroes();
@@ -3043,10 +2995,10 @@ var O = class e {
3043
2995
  return this.#e = e, this;
3044
2996
  }
3045
2997
  sqrt() {
3046
- throw Error("Cannot take the square root from a polynom");
2998
+ throw new r("Cannot take the square root from a polynom");
3047
2999
  }
3048
3000
  subtract(...t) {
3049
- 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());
3050
3002
  return this.reduce();
3051
3003
  }
3052
3004
  tableOfSigns() {
@@ -3073,7 +3025,7 @@ var O = class e {
3073
3025
  return [...new Set(this.#n.flatMap((e) => e.variables))].sort();
3074
3026
  }
3075
3027
  zero() {
3076
- 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;
3077
3029
  }
3078
3030
  get zeroes() {
3079
3031
  return this.getZeroes();
@@ -3092,7 +3044,7 @@ var O = class e {
3092
3044
  return this.#u(), this;
3093
3045
  }
3094
3046
  #s(e) {
3095
- let t = new p(e);
3047
+ let t = new m(e);
3096
3048
  for (let e of this.#n) e.coefficient.divide(t);
3097
3049
  return this.#u(), this;
3098
3050
  }
@@ -3119,7 +3071,7 @@ var O = class e {
3119
3071
  return this.reduce();
3120
3072
  }
3121
3073
  #f(e) {
3122
- return this.#d(new p(e));
3074
+ return this.#d(new m(e));
3123
3075
  }
3124
3076
  #p(e) {
3125
3077
  for (let t of this.#n) t.multiply(e);
@@ -3127,33 +3079,33 @@ var O = class e {
3127
3079
  }
3128
3080
  #m(e) {
3129
3081
  let t = [];
3130
- 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));
3131
3083
  return this.#n = t, this.reduce();
3132
3084
  }
3133
3085
  #h(e, ...t) {
3134
3086
  if (t.length === 0) {
3135
3087
  if (e !== "" && !isNaN(Number(e))) {
3136
3088
  this.empty();
3137
- let t = new E(Number(e));
3089
+ let t = new A(Number(e));
3138
3090
  return this.add(t), this;
3139
3091
  }
3140
3092
  return this.#_(e);
3141
3093
  }
3142
3094
  if (/^[a-z]+$/.test(e)) {
3143
3095
  this.empty();
3144
- let n = t.map((e) => new p(e));
3096
+ let n = t.map((e) => new m(e));
3145
3097
  if (e.length > 1) {
3146
3098
  let t = e.split("");
3147
- 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`);
3148
3100
  let r = 0;
3149
3101
  for (let e of n) {
3150
- let n = new E();
3102
+ let n = new A();
3151
3103
  n.coefficient = e.clone(), n.literalStr = t[r] ?? "", this.add(n), r++;
3152
3104
  }
3153
3105
  } else {
3154
3106
  let t = n.length - 1;
3155
3107
  for (let r of n) {
3156
- let n = new E();
3108
+ let n = new A();
3157
3109
  n.coefficient = r.clone(), n.literalStr = `${e}^${t}`, this.add(n), t--;
3158
3110
  }
3159
3111
  }
@@ -3161,65 +3113,71 @@ var O = class e {
3161
3113
  }
3162
3114
  return this.zero();
3163
3115
  }
3164
- #g(t, n) {
3165
- switch (n.tokenType) {
3166
- case S.COEFFICIENT:
3167
- 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));
3168
3120
  break;
3169
- case S.VARIABLE:
3170
- t.push(new e().add(new E(n.token)));
3121
+ case w.VARIABLE:
3122
+ n.push(new e().add(new A(i.token)));
3171
3123
  break;
3172
- case S.CONSTANT: throw Error("Unsupported CONSTANT token in Polynom parser");
3173
- case S.OPERATION:
3174
- if (t.length >= 2) {
3175
- let e = t.pop(), r = t.pop();
3176
- if (r === void 0 || e === void 0) throw Error("Unexpected undefined operand in Polynom parser stack");
3177
- if (n.token === "+") t.push(r.add(e));
3178
- else if (n.token === "-") t.push(r.subtract(e));
3179
- else if (n.token === "*") t.push(r.multiply(e));
3180
- else if (n.token === "/") {
3181
- if (e.degree().isStrictlyPositive()) throw Error("Cannot divide a Polynom by another Polynom of degree > 0");
3182
- t.push(r.divide(e.monoms[0].coefficient));
3183
- } else if (n.token === "^") {
3184
- if (e.degree().isStrictlyPositive()) throw Error("Cannot elevate a polynom with another polynom !");
3185
- if (e.monoms[0].coefficient.isRelative()) t.push(r.pow(e.monoms[0].coefficient.value));
3186
- else if (r.monoms.length === 1 && r.monoms[0].coefficient.isOne()) {
3187
- for (let t in r.monoms[0].literal) r.monoms[0].literal[t].multiply(e.monoms[0].coefficient);
3188
- t.push(r);
3189
- } 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.isNatural()) 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");
3190
3142
  }
3191
- } else if (n.token === "-") {
3192
- let e = t.pop();
3193
- e && t.push(e.opposite());
3194
- } 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");
3195
3147
  break;
3196
- case S.MONOM: throw Error("Unexpected MONOM token in polynom parser");
3197
- 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`);
3198
3150
  }
3199
3151
  }
3200
3152
  #_(e) {
3201
- 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;
3202
3160
  this.zero();
3203
- let n = [];
3204
- for (let e of t) this.#g(n, e);
3205
- 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();
3206
3164
  }
3207
- }, k = class e {
3165
+ }, N = class e {
3208
3166
  #e;
3209
3167
  #t;
3210
3168
  #n;
3211
3169
  constructor(t, n, r) {
3212
- 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) {
3213
3171
  if (t instanceof e) return t.clone();
3214
3172
  typeof t == "string" && this.parse(t);
3215
- } 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));
3216
3174
  return r !== void 0 && (this.sign = r), this;
3217
3175
  }
3218
3176
  parse = (e) => {
3219
- let t = this.#r(e);
3220
- if (t === !1) throw Error("The equation is not valid (no sign found)");
3221
- let n = e.split(t);
3222
- 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));
3223
3181
  };
3224
3182
  clone = () => new e(this.#e.clone(), this.#t.clone(), this.#n);
3225
3183
  get tex() {
@@ -3238,13 +3196,13 @@ var O = class e {
3238
3196
  add(t) {
3239
3197
  if (t instanceof e) return this.#e.add(t.left), this.#t.add(t.right), this;
3240
3198
  if (typeof t == "string" && !e.isEquationString(t)) return this.add(new e(t));
3241
- let n = new O(t);
3199
+ let n = new M(t);
3242
3200
  return this.#e.add(n), this.#t.add(n), this;
3243
3201
  }
3244
3202
  create = (e, t, n) => (this.#e = e, this.#t = t, this.#n = this.#i(n ?? "="), this);
3245
- 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));
3246
3204
  divide = (e) => {
3247
- let t = new p(e);
3205
+ let t = new m(e);
3248
3206
  return t.isZero() ? this : this.multiply(t.inverse());
3249
3207
  };
3250
3208
  evaluate(e, t) {
@@ -3284,7 +3242,7 @@ var O = class e {
3284
3242
  letters = () => [.../* @__PURE__ */ new Set([...this.#e.variables, ...this.#t.variables])];
3285
3243
  moveLeft = () => (this.#e.subtract(this.#t), this.#t.zero(), this);
3286
3244
  multiply = (e) => {
3287
- let t = new p(e);
3245
+ let t = new m(e);
3288
3246
  return this.#e.multiply(t), this.#t.multiply(t), this.#n !== "=" && t.sign() === -1 && this.#a(), this;
3289
3247
  };
3290
3248
  get numberOfVars() {
@@ -3317,7 +3275,7 @@ var O = class e {
3317
3275
  get signAsTex() {
3318
3276
  return this.#n === ">=" ? "\\geq" : this.#n === "<=" ? "\\leq" : this.#n;
3319
3277
  }
3320
- 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);
3321
3279
  solve = () => new b(this.clone()).solve();
3322
3280
  split() {
3323
3281
  return [this.#e.clone(), this.#t.clone()];
@@ -3325,7 +3283,7 @@ var O = class e {
3325
3283
  subtract(t) {
3326
3284
  if (t instanceof e) return this.#e.subtract(t.left), this.#t.subtract(t.right), this;
3327
3285
  if (typeof t == "string" && !e.isEquationString(t)) return this.subtract(new e(t));
3328
- let n = new O(t);
3286
+ let n = new M(t);
3329
3287
  return this.#e.subtract(n), this.#t.subtract(n), this;
3330
3288
  }
3331
3289
  test = (e) => this.left.evaluate(e).isEqual(this.right.evaluate(e));
@@ -3342,34 +3300,34 @@ var O = class e {
3342
3300
  if (e.includes("=<")) return "=<";
3343
3301
  if (e.includes("<")) return "<";
3344
3302
  if (e.includes("=")) return "=";
3345
- throw Error("The equation is not valid (no sign found)");
3303
+ throw new t("The equation is not valid (no sign found)");
3346
3304
  };
3347
3305
  #i = (e) => e === void 0 ? "=" : e.includes("geq") || e.includes(">=") || e.includes("=>") ? ">=" : e.includes(">") ? ">" : e.includes("leq") || e.includes("<=") || e.includes("=<") ? "<=" : e.includes("<") ? "<" : "=";
3348
3306
  #a = () => this.#n === "=" ? this : this.#n.includes("<") ? (this.#n.replace("<", ">"), this) : (this.#n.includes(">") && this.#n.replace(">", "<"), this);
3349
- }, A = class e {
3307
+ }, P = class e {
3350
3308
  #e;
3351
3309
  #t;
3352
3310
  #n;
3353
3311
  #r = !1;
3354
3312
  constructor(t, n) {
3355
- 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;
3356
3314
  }
3357
3315
  parse() {
3358
- throw Error("Method not implemented.");
3316
+ throw new a("Method not implemented.");
3359
3317
  }
3360
3318
  clone() {
3361
3319
  return new e(this);
3362
3320
  }
3363
3321
  get tex() {
3364
3322
  let e = this.power.numerator, t = this.power.denominator, n, r;
3365
- 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;
3366
3324
  }
3367
3325
  get display() {
3368
3326
  let e = this.power.numerator, t = this.power.denominator, n, r;
3369
- 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;
3370
3328
  }
3371
3329
  add() {
3372
- throw Error("Adding two factors is not possible");
3330
+ throw new r("Adding two factors is not possible");
3373
3331
  }
3374
3332
  get asSingle() {
3375
3333
  return this.#r = !0, this;
@@ -3386,19 +3344,19 @@ var O = class e {
3386
3344
  }
3387
3345
  develop() {
3388
3346
  if (this.power.isNatural()) return this.polynom.clone().pow(this.power.value);
3389
- throw Error("The power must be a natural number");
3347
+ throw new r("The power must be a natural number");
3390
3348
  }
3391
3349
  divide(t) {
3392
3350
  if (t instanceof e && this.isSameAs(t)) return this.power.subtract(t.power), this;
3393
- let n = new O(t);
3351
+ let n = new M(t);
3394
3352
  if (this.isSameAs(n)) return this.power.subtract(1), this;
3395
- throw Error("The two factors must be the same");
3353
+ throw new r("The two factors must be the same");
3396
3354
  }
3397
3355
  evaluate(e, t) {
3398
3356
  return t ? this.polynom.evaluate(e, !0) ** this.power.value : this.polynom.evaluate(e).pow(this.power);
3399
3357
  }
3400
3358
  fromPolynom(e) {
3401
- 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;
3402
3360
  }
3403
3361
  hasVariable(e) {
3404
3362
  return this.polynom.hasVariable(e);
@@ -3414,7 +3372,7 @@ var O = class e {
3414
3372
  }
3415
3373
  isSameAs(t) {
3416
3374
  let n;
3417
- 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);
3418
3376
  }
3419
3377
  isZero() {
3420
3378
  return this.polynom.isZero();
@@ -3423,15 +3381,15 @@ var O = class e {
3423
3381
  let n = new e(t);
3424
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;
3425
3383
  if (t instanceof e && this.isSameAs(t)) return this.power.add(t.power), this;
3426
- let r = new O(t);
3427
- if (this.isSameAs(r)) return this.power.add(1), this;
3428
- 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");
3429
3387
  }
3430
3388
  one() {
3431
3389
  return this.#t.one(), this.#n.one(), this;
3432
3390
  }
3433
3391
  opposite() {
3434
- throw Error("Method not implemented.");
3392
+ throw new a("Method not implemented.");
3435
3393
  }
3436
3394
  get polynom() {
3437
3395
  return this.#t;
@@ -3446,13 +3404,13 @@ var O = class e {
3446
3404
  return this.#n;
3447
3405
  }
3448
3406
  set power(e) {
3449
- this.#n = new p(e);
3407
+ this.#n = new m(e);
3450
3408
  }
3451
3409
  primitive() {
3452
- throw Error("Method not implemented.");
3410
+ throw new a("Method not implemented.");
3453
3411
  }
3454
3412
  reduce() {
3455
- throw Error("Method not implemented.");
3413
+ throw new a("Method not implemented.");
3456
3414
  }
3457
3415
  root(e) {
3458
3416
  return this.power.divide(e), this;
@@ -3461,7 +3419,7 @@ var O = class e {
3461
3419
  return this.root(2);
3462
3420
  }
3463
3421
  subtract() {
3464
- throw Error("Subtracting two factors is not possible");
3422
+ throw new r("Subtracting two factors is not possible");
3465
3423
  }
3466
3424
  tableOfSigns() {
3467
3425
  let e = this.power.clone().reduce(), t = this.polynom.tableOfSigns();
@@ -3493,19 +3451,19 @@ var O = class e {
3493
3451
  let r = n ? 1 : -1, i = [];
3494
3452
  for (let n of t.matchAll(/\(([^)]+)\)(?:\^(-?[0-9]+(?:\/[0-9]+)?|\(-?[0-9]+(?:\/[0-9]+)?\)))?|([^(]+)/g)) if (n[1] !== void 0) {
3495
3453
  let t = (n[2] ?? "1").replace(/[()]/g, "");
3496
- i.push(new e(new O(n[1]), new p(t).multiply(r)));
3497
- } 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)));
3498
3456
  return i;
3499
3457
  }
3500
- }, j = /* @__PURE__ */ function(e) {
3458
+ }, F = /* @__PURE__ */ function(e) {
3501
3459
  return e[e.ROOT = 0] = "ROOT", e[e.POWER = 1] = "POWER", e;
3502
- }({}), se = class e {
3460
+ }({}), I = class e {
3503
3461
  #e;
3504
3462
  #t;
3505
3463
  constructor(...e) {
3506
3464
  return this.#e = [], this.#t = [], e.length > 0 && this.parse(...e), this;
3507
3465
  }
3508
- 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);
3509
3467
  clone = () => new e().parse(...this.#e.map((e) => e.clone()));
3510
3468
  get tex() {
3511
3469
  let e = this.clone().reorder();
@@ -3514,11 +3472,11 @@ var O = class e {
3514
3472
  get display() {
3515
3473
  return this.tex + "as display";
3516
3474
  }
3517
- static fromMatrix(t, n = "xyz") {
3518
- let r = t[0].length;
3519
- if (t.some((e) => e.length !== r)) throw Error("All rows must have the same number of columns");
3520
- let i = n.split("").splice(0, r - 1);
3521
- 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)));
3522
3480
  }
3523
3481
  static solutionAsDisplay(e) {
3524
3482
  return `(${e.map((e) => e.display).join(";")})`;
@@ -3526,15 +3484,15 @@ var O = class e {
3526
3484
  static solutionAsTex(e) {
3527
3485
  return `\\left( ${e.map((e) => e.tex).join(" ; ")} \\right)`;
3528
3486
  }
3529
- add(t, n) {
3487
+ add(t, r) {
3530
3488
  if (t instanceof e) {
3531
3489
  let e = t.equations.length;
3532
- 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");
3533
3491
  for (let n = 0; n < e; n++) this.#e[n].add(t.equations[n]);
3534
3492
  } else {
3535
- if (n === void 0 || n < 0 || n >= this.#e.length) throw Error("Index out of range");
3536
- let e = new k(t);
3537
- 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);
3538
3496
  }
3539
3497
  return this;
3540
3498
  }
@@ -3556,7 +3514,7 @@ var O = class e {
3556
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.`;
3557
3515
  };
3558
3516
  degree(e) {
3559
- return p.max(...this.#e.map((t) => t.degree(e)));
3517
+ return m.max(...this.#e.map((t) => t.degree(e)));
3560
3518
  }
3561
3519
  get equations() {
3562
3520
  return this.#e;
@@ -3565,7 +3523,7 @@ var O = class e {
3565
3523
  this.#e = e, this.#n();
3566
3524
  }
3567
3525
  evaluate(e, t) {
3568
- throw Error("Method not implemented.");
3526
+ throw new a("Method not implemented.");
3569
3527
  }
3570
3528
  hasVariable(e) {
3571
3529
  return this.#t.includes(e);
@@ -3585,11 +3543,11 @@ var O = class e {
3585
3543
  }
3586
3544
  multiply(e, t) {
3587
3545
  if (Array.isArray(e)) {
3588
- 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");
3589
3547
  for (let t = 0; t < e.length; t++) this.#e[t].multiply(e[t]);
3590
3548
  return this;
3591
3549
  }
3592
- 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");
3593
3551
  return this.#e[t].multiply(e), this;
3594
3552
  }
3595
3553
  reduce() {
@@ -3602,13 +3560,13 @@ var O = class e {
3602
3560
  solve() {
3603
3561
  let [e, t] = this.matrix, n = e.map((e, n) => [...e, t[n]]);
3604
3562
  for (let t = 0; t < e.length; t++) {
3605
- let r = n[t][t].clone();
3606
- if (r.isZero()) {
3563
+ let i = n[t][t].clone();
3564
+ if (i.isZero()) {
3607
3565
  let e = n.find((e, n) => n > t && !e[t].isZero());
3608
- if (e) n[t].forEach((t, n) => t.add(e[n])), r = n[t][t].clone();
3609
- 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...");
3610
3568
  }
3611
- n[t] = n[t].map((e) => e.divide(r));
3569
+ n[t] = n[t].map((e) => e.divide(i));
3612
3570
  for (let r = 0; r < e.length; r++) {
3613
3571
  if (r === t) continue;
3614
3572
  let e = n[r][t].clone().opposite();
@@ -3622,7 +3580,7 @@ var O = class e {
3622
3580
  let t = [], n = this.equations.map((t) => t.left.monomByLetter(e).coefficient.value);
3623
3581
  return n.forEach((e, r) => {
3624
3582
  for (let i = r + 1; i < n.length; i++) {
3625
- 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;
3626
3584
  t.push([{
3627
3585
  id: r,
3628
3586
  factor: o * a / e
@@ -3633,15 +3591,15 @@ var O = class e {
3633
3591
  }
3634
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)));
3635
3593
  }
3636
- subtract(t, n) {
3594
+ subtract(t, r) {
3637
3595
  if (t instanceof e) {
3638
3596
  let e = t.equations.length;
3639
- 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");
3640
3598
  for (let n = 0; n < e; n++) this.#e[n].subtract(t.equations[n]);
3641
3599
  } else {
3642
- if (n === void 0 || n < 0 || n >= this.#e.length) throw Error("Index out of range");
3643
- let e = new k(t);
3644
- 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);
3645
3603
  }
3646
3604
  return this;
3647
3605
  }
@@ -3675,12 +3633,19 @@ var O = class e {
3675
3633
  n.variable = e, t.push(n);
3676
3634
  }), t);
3677
3635
  }
3678
- }, ce = class {
3636
+ }, L = class {
3679
3637
  #e;
3680
3638
  constructor(e) {
3681
3639
  return this.#e = [], e !== void 0 && this.parse(e), this;
3682
3640
  }
3683
- 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
+ };
3684
3649
  get tex() {
3685
3650
  let e = [];
3686
3651
  for (let t of this.#e) if (t.tokenType === "variable") e.push(t);
@@ -3828,8 +3793,8 @@ var O = class e {
3828
3793
  }
3829
3794
  return [...n[0]].sort();
3830
3795
  }
3831
- }, M = class e {
3832
- #e = j.POWER;
3796
+ }, R = class e {
3797
+ #e = F.POWER;
3833
3798
  #t = [];
3834
3799
  constructor(...e) {
3835
3800
  return this.parse(...e), this;
@@ -3837,7 +3802,7 @@ var O = class e {
3837
3802
  parse(...t) {
3838
3803
  return this.#t = [], t.length === 0 || t.forEach((t) => {
3839
3804
  if (typeof t == "string") return this.fromString(t);
3840
- t instanceof e ? this.#t.push(...t.factors.map((e) => e.clone())) : this.#t.push(new A(t));
3805
+ t instanceof e ? this.#t.push(...t.factors.map((e) => e.clone())) : this.#t.push(new P(t));
3841
3806
  }), this;
3842
3807
  }
3843
3808
  clone() {
@@ -3852,16 +3817,16 @@ var O = class e {
3852
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("")})`;
3853
3818
  }
3854
3819
  static #n(t, n) {
3855
- let r = N(t), i = N(n), a = Object.keys(r).filter((e) => Object.hasOwn(i, e)).map((e) => {
3856
- 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"));
3857
- 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));
3858
3823
  });
3859
3824
  return new e(...a);
3860
3825
  }
3861
3826
  static #r(t, n) {
3862
- let r = N(t), i = N(n), a = [.../* @__PURE__ */ new Set([...Object.keys(r), ...Object.keys(i)])].map((e) => {
3863
- 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);
3864
- 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));
3865
3830
  });
3866
3831
  return new e(...a);
3867
3832
  }
@@ -3886,17 +3851,17 @@ var O = class e {
3886
3851
  e.multiply(t.clone().divide(r[n]));
3887
3852
  }), i = t;
3888
3853
  }
3889
- let a = e.gcd(...n), o = new O(0).add(...n.map((e) => e.divide(a).reduce().develop().factors[0].polynom)).reduce();
3890
- 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;
3891
3856
  }
3892
3857
  get asPower() {
3893
- return this.#e = j.POWER, this;
3858
+ return this.#e = F.POWER, this;
3894
3859
  }
3895
3860
  get asRoot() {
3896
- return this.#e = j.ROOT, this;
3861
+ return this.#e = F.ROOT, this;
3897
3862
  }
3898
3863
  degree(e) {
3899
- 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"));
3900
3865
  }
3901
3866
  get denominator() {
3902
3867
  return new e(...this.#t.filter((e) => e.power.isNegative()).map((e) => e.clone().inverse()));
@@ -3912,7 +3877,7 @@ var O = class e {
3912
3877
  return r !== void 0 && (this.#t = r.factors), this.add(...t);
3913
3878
  }
3914
3879
  develop() {
3915
- let t = new O("1"), n = new O("1");
3880
+ let t = new M("1"), n = new M("1");
3916
3881
  return this.numerator.factors.forEach((e) => {
3917
3882
  t.multiply(e.develop());
3918
3883
  }), this.denominator.factors.forEach((e) => {
@@ -3923,7 +3888,7 @@ var O = class e {
3923
3888
  return this.#t = this.#t.concat(e.clone().factors.map((e) => e.inverse())), this;
3924
3889
  }
3925
3890
  evaluate(e, t) {
3926
- 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"));
3927
3892
  }
3928
3893
  factorize(t) {
3929
3894
  let n = [];
@@ -3931,7 +3896,7 @@ var O = class e {
3931
3896
  let r = e.polynom.factorize(t);
3932
3897
  if (r.length > 1) {
3933
3898
  let t = e.power.clone();
3934
- n.push(...r.map((e) => new A(e, t)));
3899
+ n.push(...r.map((e) => new P(e, t)));
3935
3900
  } else n.push(e.clone());
3936
3901
  });
3937
3902
  let r = new e(...n), i = r.numerator.reduce(), a = r.denominator.reduce();
@@ -3944,20 +3909,20 @@ var O = class e {
3944
3909
  this.#t = e;
3945
3910
  }
3946
3911
  fromPolynom(e, t) {
3947
- if (this.#t = [new A(new O(e))], t) {
3948
- let e = new O(t);
3912
+ if (this.#t = [new P(new M(e))], t) {
3913
+ let e = new M(t);
3949
3914
  if (e.isOne()) return this;
3950
- if (e.isZero()) throw Error("Cannot divide by zero");
3951
- 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));
3952
3917
  }
3953
3918
  return this;
3954
3919
  }
3955
3920
  fromString(e) {
3956
3921
  this.#t = [];
3957
- let [t, ...n] = _(e, "/");
3958
- if (t === "") throw Error("Parsing a PolyFactor from a string requires a numerator");
3959
- if (n.length > 1) throw Error("Parsing a PolyFactor from a string only allows max one signe \"/\"");
3960
- return this.#t = n.length === 0 ? A.factorsFromString(h(t), !0) : [...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;
3961
3926
  }
3962
3927
  getRoots() {
3963
3928
  return [];
@@ -3992,27 +3957,27 @@ var O = class e {
3992
3957
  return new e(...this.#t.filter((e) => e.power.isPositive()));
3993
3958
  }
3994
3959
  one() {
3995
- return this.#t = [new A("1", "1")], this;
3960
+ return this.#t = [new P("1", "1")], this;
3996
3961
  }
3997
3962
  opposite() {
3998
3963
  let e = this.#t.findIndex((e) => e.display === "(-1)");
3999
- 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;
4000
3965
  }
4001
3966
  pow(e) {
4002
3967
  return this.#t = this.#t.map((t) => t.pow(e)), this;
4003
3968
  }
4004
3969
  primitive() {
4005
- throw Error("Method not implemented.");
3970
+ throw new a("Method not implemented.");
4006
3971
  }
4007
3972
  reduce() {
4008
- let e = N(this);
3973
+ let e = z(this);
4009
3974
  this.#t = Object.values(e).map((e) => {
4010
3975
  let t = e[0].polynom;
4011
- 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());
4012
3977
  }).filter((e) => !e.power.isZero());
4013
- 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());
4014
3979
  return r.length > 0 && (r.forEach((e) => {
4015
- 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)));
4016
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;
4017
3982
  }
4018
3983
  root(e) {
@@ -4036,7 +4001,7 @@ var O = class e {
4036
4001
  }
4037
4002
  tableOfSigns() {
4038
4003
  let e = this.getZeroes(), t = e.map((e) => e.value), n = this.factorize().factors.map((e) => ({
4039
- factor: new A(e),
4004
+ factor: new P(e),
4040
4005
  ...e.tableOfSigns()
4041
4006
  }));
4042
4007
  return n.forEach((n) => {
@@ -4070,18 +4035,18 @@ var O = class e {
4070
4035
  return this.#t.reduce((e, t) => e.concat(t.variables), []);
4071
4036
  }
4072
4037
  zero() {
4073
- return this.#t = [new A("0", "1")], this;
4038
+ return this.#t = [new P("0", "1")], this;
4074
4039
  }
4075
4040
  #i() {
4076
4041
  let e, t = [];
4077
- 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")]), {
4078
4043
  num: e,
4079
4044
  den: t
4080
4045
  };
4081
4046
  }
4082
4047
  };
4083
- function N(e) {
4084
- 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) => {
4085
4050
  if (r.polynom.degree().isZero() && r.power.isRelative()) {
4086
4051
  let i = r.polynom.monoms[0].coefficient.pow(r.power.clone().abs());
4087
4052
  return r.power.isPositive() ? t.multiply(i) : n.multiply(i), e;
@@ -4089,11 +4054,11 @@ function N(e) {
4089
4054
  let i = r.polynom.display;
4090
4055
  return Object.hasOwn(e, i) ? e[i].push(r) : e[i] = [r], e;
4091
4056
  }, {}), { numerator: i, denominator: a } = t.divide(n).reduce();
4092
- 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;
4093
4058
  }
4094
4059
  //#endregion
4095
4060
  //#region src/algebra/matrix.ts
4096
- var le = class e {
4061
+ var ve = class e {
4097
4062
  #e = null;
4098
4063
  #t = 0;
4099
4064
  #n = [];
@@ -4133,7 +4098,7 @@ var le = class e {
4133
4098
  return this.#e = null, t;
4134
4099
  }
4135
4100
  add(e) {
4136
- 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.");
4137
4102
  return this.forEach((t, n, r) => {
4138
4103
  t.add(e.values[n][r]);
4139
4104
  }), this;
@@ -4158,7 +4123,7 @@ var le = class e {
4158
4123
  return this.dimension.cols === e.dimension.rows;
4159
4124
  }
4160
4125
  characteristic_polynom(t) {
4161
- 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();
4162
4127
  }
4163
4128
  cofactor(e, t) {
4164
4129
  let n = this.clone();
@@ -4167,14 +4132,14 @@ var le = class e {
4167
4132
  }), n.determinant().multiply((-1) ** (e + t));
4168
4133
  }
4169
4134
  get cols() {
4170
- 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()));
4171
4136
  return this.forEach((t, n, r) => {
4172
4137
  e[r][n] = t;
4173
4138
  }), e;
4174
4139
  }
4175
4140
  determinant() {
4176
- if (!this.isSquare()) throw Error("Matrix is not square");
4177
- let e = new O();
4141
+ if (!this.isSquare()) throw new n("Matrix is not square");
4142
+ let e = new M();
4178
4143
  return this.#n.length === 1 ? this.#n[0][0].clone() : (this.values[0].forEach((t, n) => {
4179
4144
  let r = this.cofactor(0, n);
4180
4145
  e.add(t.clone().multiply(r));
@@ -4197,36 +4162,36 @@ var le = class e {
4197
4162
  });
4198
4163
  }
4199
4164
  fromDimensions(e, t) {
4200
- 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;
4201
4166
  }
4202
4167
  fromString(e) {
4203
4168
  if (e.startsWith("((") && e.endsWith("))")) return this.fromString(e.substring(1, e.length - 1));
4204
4169
  let t = e.split("),(");
4205
- 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;
4206
4171
  }
4207
4172
  fromValues(e) {
4208
4173
  this.#n = [];
4209
4174
  let t = e[0].length;
4210
- 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");
4211
4176
  return e.forEach((e) => {
4212
4177
  let t = [];
4213
4178
  e.forEach((e) => {
4214
- t.push(new O(e));
4179
+ t.push(new M(e));
4215
4180
  }), this.#n.push(t);
4216
4181
  }), this;
4217
4182
  }
4218
4183
  fromVectors(...e) {
4219
4184
  this.#n = [];
4220
4185
  let t = e[0].dimension;
4221
- 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");
4222
4187
  return this.fromDimensions(e[0].dimension, e.length), e.forEach((e, t) => {
4223
4188
  e.array.forEach((e, n) => {
4224
- this.#n[n][t] = new O(e);
4189
+ this.#n[n][t] = new M(e);
4225
4190
  });
4226
4191
  }), this;
4227
4192
  }
4228
4193
  inverse() {
4229
- if (!this.canBeInverted()) throw Error("The matrix cannot be inverted.");
4194
+ if (!this.canBeInverted()) throw new r("The matrix cannot be inverted.");
4230
4195
  let t = new e().fromDimensions(this.dimension.rows, this.dimension.cols);
4231
4196
  t.forEach((e, n, r) => {
4232
4197
  t.setValue(n, r, this.cofactor(n, r));
@@ -4261,14 +4226,14 @@ var le = class e {
4261
4226
  }
4262
4227
  multiply(t) {
4263
4228
  if (t instanceof e) {
4264
- if (!this.canBeMultiplied(t)) throw Error("Cannot multiply a matrix with incompatibles dimensions");
4265
- let n = new e(this.dimension.rows, t.dimension.cols);
4266
- return n.forEach((e, r, i) => {
4267
- 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();
4268
4233
  a.forEach((e, t) => {
4269
4234
  s.add(e.clone().multiply(o[t]));
4270
- }), n.setValue(r, i, s);
4271
- }), this.#n = n.values, this;
4235
+ }), r.setValue(n, i, s);
4236
+ }), this.#n = r.values, this;
4272
4237
  }
4273
4238
  return this.forEach((e, n, r) => {
4274
4239
  this.setValue(n, r, e.multiply(t));
@@ -4294,21 +4259,21 @@ var le = class e {
4294
4259
  return this.#t = 4, this;
4295
4260
  }
4296
4261
  pow(e) {
4297
- return D(this, e);
4262
+ return j(this, e);
4298
4263
  }
4299
4264
  reduce() {
4300
- throw Error("Not yet implemented");
4265
+ throw new a("Not yet implemented");
4301
4266
  }
4302
4267
  get rows() {
4303
4268
  return this.#n;
4304
4269
  }
4305
4270
  setValue(e, t, n) {
4306
4271
  let { rows: r, cols: i } = this.dimension;
4307
- if (e < 0 || e >= r || t < 0 || t >= i) throw Error(`${e}x${t} is out of range (${r}x${i})`);
4308
- 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;
4309
4274
  }
4310
4275
  subtract(e) {
4311
- 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.");
4312
4277
  return this.forEach((t, n, r) => {
4313
4278
  t.subtract(e.values[n][r]);
4314
4279
  }), this;
@@ -4330,29 +4295,29 @@ var le = class e {
4330
4295
  };
4331
4296
  //#endregion
4332
4297
  //#region src/geometry/geomMath.ts
4333
- function ue(e, t) {
4298
+ function ye(e, t) {
4334
4299
  return e.dimension === t.dimension && e.array.every((e, n) => t.array[n].isEqual(e));
4335
4300
  }
4336
- function de(e, t) {
4301
+ function be(e, t) {
4337
4302
  if (e.dimension !== t.dimension) return !1;
4338
4303
  let n = t.array[0].value / e.array[0].value;
4339
4304
  return e.array.every((e, r) => t.array[r].value === e.value * n);
4340
4305
  }
4341
- function P(e, t) {
4342
- 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();
4343
4308
  }
4344
- function fe(...e) {
4345
- if (e.some((t) => t.dimension !== e[0].dimension)) throw Error("All vectors must have the same dimension");
4346
- 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)`);
4347
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]))));
4348
4313
  }
4349
4314
  //#endregion
4350
4315
  //#region src/geometry/TupleN.ts
4351
- var F = class {
4316
+ var B = class {
4352
4317
  #e = [];
4353
4318
  #t;
4354
4319
  constructor(...e) {
4355
- this.#e = e.map((e) => new p(e));
4320
+ this.#e = e.map((e) => new m(e));
4356
4321
  }
4357
4322
  copy() {
4358
4323
  return this.#e.map((e) => e.clone());
@@ -4369,7 +4334,7 @@ var F = class {
4369
4334
  fromString(e) {
4370
4335
  e.startsWith("(") && (e = e.substring(1)), e.endsWith(")") && (e = e.substring(0, e.length - 1));
4371
4336
  let t = e.split(/[,;\s]/g).filter((e) => e.trim() !== "");
4372
- 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;
4373
4338
  }
4374
4339
  get onChange() {
4375
4340
  return this.#t;
@@ -4378,46 +4343,46 @@ var F = class {
4378
4343
  this.#t = e;
4379
4344
  }
4380
4345
  setDimension(e = 2) {
4381
- if (e < 2) throw Error("Dimension must be at least 2");
4346
+ if (e < 2) throw new n("Dimension must be at least 2");
4382
4347
  if (e < this.dimension) this.#e = this.#e.slice(0, e);
4383
- 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));
4384
4349
  return this;
4385
4350
  }
4386
4351
  get x() {
4387
4352
  return this.#e[0];
4388
4353
  }
4389
4354
  set x(e) {
4390
- this.#e[0] = new p(e), this.#t?.();
4355
+ this.#e[0] = new m(e), this.#t?.();
4391
4356
  }
4392
4357
  get y() {
4393
4358
  return this.#e[1];
4394
4359
  }
4395
4360
  set y(e) {
4396
- this.#e[1] = new p(e), this.#t?.();
4361
+ this.#e[1] = new m(e), this.#t?.();
4397
4362
  }
4398
4363
  get z() {
4399
- if (this.dimension < 3) throw Error("Vector is not 3D");
4364
+ if (this.dimension < 3) throw new n("Vector is not 3D");
4400
4365
  return this.#e[2];
4401
4366
  }
4402
4367
  set z(e) {
4403
- if (this.dimension < 3) throw Error("Vector is not 3D");
4404
- 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?.();
4405
4370
  }
4406
4371
  zero = () => (this.#e.forEach((e) => e.zero()), this.#t?.(), this);
4407
- }, I = class e extends F {
4372
+ }, V = class e extends B {
4408
4373
  constructor(...e) {
4409
4374
  super(), e.length > 0 && this.parse(...e);
4410
4375
  }
4411
- parse(...t) {
4412
- if (t.length === 1) {
4413
- if (t[0] instanceof F) return this.array = t[0].copy(), this;
4414
- 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;
4415
4380
  }
4416
- if (t.length > 1) {
4417
- if (t.some((t) => t instanceof e)) throw Error("Creating a point with multiple argument requires an input fraction");
4418
- let n = t.map((e) => new p(e));
4419
- if (n.some((e) => e.isNaN())) throw Error("The given values are not a valid point string (a,b): ");
4420
- 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;
4421
4386
  }
4422
4387
  return this;
4423
4388
  }
@@ -4431,8 +4396,8 @@ var F = class {
4431
4396
  return `(${this.array.map((e) => e.display).join(";")})`;
4432
4397
  }
4433
4398
  distanceTo(e) {
4434
- if (this.dimension !== e.dimension) throw Error("The two points must have the same dimensions.");
4435
- 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));
4436
4401
  return new v().from(2, t).reduce();
4437
4402
  }
4438
4403
  isEqual(e) {
@@ -4442,30 +4407,30 @@ var F = class {
4442
4407
  return this.isEqual(new e(t, n));
4443
4408
  }
4444
4409
  middleOf(e, t) {
4445
- 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");
4446
4411
  return this.array = [], e.array.forEach((e, n) => {
4447
4412
  this.array.push(e.clone().add(t.array[n]).divide(2));
4448
4413
  }), this;
4449
4414
  }
4450
- }, L = class e extends F {
4415
+ }, H = class e extends B {
4451
4416
  constructor(...e) {
4452
4417
  return super(), e.length > 0 && this.parse(...e), this;
4453
4418
  }
4454
4419
  parse(...e) {
4455
- if (e.length === 0) throw Error("Invalid value");
4420
+ if (e.length === 0) throw new i("Invalid value");
4456
4421
  if (e.length === 1) {
4457
- 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;
4458
4423
  if (typeof e[0] == "string") return this.fromString(e[0]);
4459
- throw Error("Invalid value");
4424
+ throw new i("Invalid value");
4460
4425
  }
4461
4426
  if (e.length === 2) {
4462
- let [t, n] = e;
4463
- if (t instanceof F && n instanceof F) {
4464
- if (t.dimension !== n.dimension) throw Error("Vectors must have the same dimension");
4465
- 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;
4466
4431
  }
4467
4432
  }
4468
- return this.array = e.map((e) => new p(e)), this;
4433
+ return this.array = e.map((e) => new m(e)), this;
4469
4434
  }
4470
4435
  clone() {
4471
4436
  return new e(...this.copy());
@@ -4488,16 +4453,16 @@ var F = class {
4488
4453
  return t && (r = Math.abs(r)), (n ? 1 : 180 / Math.PI) * Math.acos(r / (this.norm * e.norm));
4489
4454
  };
4490
4455
  cross(t) {
4491
- 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");
4492
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)));
4493
4458
  }
4494
- divideByScalar = (e) => this.multiplyByScalar(new p(e).inverse());
4495
- dot = (e) => P(this, e);
4459
+ divideByScalar = (e) => this.multiplyByScalar(new m(e).inverse());
4460
+ dot = (e) => xe(this, e);
4496
4461
  fromString(e) {
4497
4462
  return e.startsWith("((") && e.endsWith("))") ? super.fromString(e.slice(1, -1)) : super.fromString(e);
4498
4463
  }
4499
- isColinearTo = (e) => de(this, e);
4500
- isEqual = (e) => ue(this, e);
4464
+ isColinearTo = (e) => be(this, e);
4465
+ isEqual = (e) => ye(this, e);
4501
4466
  isNormalTo = (e) => this.dot(e).isZero();
4502
4467
  get isNull() {
4503
4468
  return this.array.every((e) => e.isZero());
@@ -4509,25 +4474,25 @@ var F = class {
4509
4474
  return this.array.every((e) => e.isZero());
4510
4475
  }
4511
4476
  multiplyByScalar = (e) => {
4512
- let t = new p(e);
4477
+ let t = new m(e);
4513
4478
  return this.array.forEach((e) => e.multiply(t)), this;
4514
4479
  };
4515
4480
  get norm() {
4516
4481
  return Math.sqrt(this.normSquare.value);
4517
4482
  }
4518
4483
  get normSquare() {
4519
- 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));
4520
4485
  }
4521
4486
  normal = () => {
4522
- 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");
4523
4488
  let e = this.x.clone().opposite(), t = this.y.clone();
4524
4489
  return this.array[0] = t, this.array[1] = e, this;
4525
4490
  };
4526
4491
  one = () => (this.zero(), this.x.one(), this);
4527
4492
  opposite = () => (this.array.forEach((e) => e.opposite()), this);
4528
4493
  simplify = () => {
4529
- let e = d.lcm(...this.array.map((e) => e.denominator)), t = d.gcd(...this.array.map((e) => e.numerator));
4530
- 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;
4531
4496
  };
4532
4497
  subtract = (e) => this.add(e.clone().opposite());
4533
4498
  translate(...e) {
@@ -4537,43 +4502,43 @@ var F = class {
4537
4502
  let e = this.norm;
4538
4503
  return e === 0 ? this : this.divideByScalar(e);
4539
4504
  };
4540
- }, R = /* @__PURE__ */ function(e) {
4505
+ }, U = /* @__PURE__ */ function(e) {
4541
4506
  return e.None = "none", e.Parallel = "parallel", e.Perpendicular = "perpendicular", e.Tangent = "tangent", e;
4542
- }({}), z = /* @__PURE__ */ function(e) {
4507
+ }({}), Ce = /* @__PURE__ */ function(e) {
4543
4508
  return e.None = "none", e.Parallel = "parallel", e.Perpendicular = "perpendicular", e.Tangent = "tangent", e;
4544
4509
  }({});
4545
4510
  //#endregion
4546
4511
  //#region src/randomization/rndHelpers.ts
4547
- function B(e = .5) {
4512
+ function we(e = .5) {
4548
4513
  return Math.random() < e;
4549
4514
  }
4550
- function V(e, t, n) {
4551
- 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);
4552
4517
  if (e === t) return e;
4553
4518
  if (n === void 0) return Math.floor(Math.random() * (t - e + 1) + e);
4554
- if (Math.abs(t - e) <= n.length) throw Error("The number of excluded values is too high.");
4555
- let r = V(e, t);
4556
- 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);
4557
4522
  return r;
4558
4523
  }
4559
- function H(e, t) {
4560
- 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);
4561
4526
  }
4562
- function pe(e, t) {
4563
- let n = d.pythagoreanTripletsWithTarget(e).filter((e) => t === !0 || !e.includes(0));
4564
- 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);
4565
4530
  }
4566
- function me(e) {
4567
- let t = d.primes();
4568
- 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);
4569
4534
  }
4570
- function he(e, t) {
4571
- 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);
4572
4537
  }
4573
- function U(e) {
4574
- 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)];
4575
4540
  }
4576
- function W(e) {
4541
+ function Oe(e) {
4577
4542
  let t = Object.values(e);
4578
4543
  for (let e = t.length - 1; e > 0; e--) {
4579
4544
  let n = Math.floor(Math.random() * (e + 1)), r = t[e];
@@ -4583,9 +4548,9 @@ function W(e) {
4583
4548
  }
4584
4549
  //#endregion
4585
4550
  //#region src/geometry/line.ts
4586
- var G = class e {
4587
- static PARALLEL = R.Parallel;
4588
- static PERPENDICULAR = R.Perpendicular;
4551
+ var q = class e {
4552
+ static PARALLEL = U.Parallel;
4553
+ static PERPENDICULAR = U.Perpendicular;
4589
4554
  #e;
4590
4555
  #t;
4591
4556
  #n;
@@ -4593,36 +4558,36 @@ var G = class e {
4593
4558
  #i;
4594
4559
  #a = 1;
4595
4560
  constructor(...e) {
4596
- 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;
4597
- }
4598
- parse = (...t) => {
4599
- if (t.length === 0) return this;
4600
- if (t.length === 1) {
4601
- if (t[0] instanceof e) return this.fromCoefficient(t[0].a, t[0].b, t[0].c);
4602
- if (t[0] instanceof k) return this.fromEquation(t[0]);
4603
- if (typeof t[0] == "string") try {
4604
- 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]);
4605
4570
  return this.parse(e);
4606
4571
  } catch (e) {
4607
- return console.warn(e), this;
4572
+ throw new t(`Cannot parse "${n[0]}" as a Line`, { cause: e });
4608
4573
  }
4609
4574
  }
4610
- if (t.length === 2) {
4611
- if (t[0] instanceof I && t[1] instanceof I) return this.fromPoints(t[0], t[1]);
4612
- 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]);
4613
4578
  }
4614
- 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);
4615
4580
  };
4616
4581
  clone = () => new e().fromCoefficient(this.#t, this.#n, this.#r);
4617
4582
  get tex() {
4618
4583
  let e = this.#a;
4619
4584
  switch (this.#a = 1, e) {
4620
4585
  case 0: return this.getEquation().reorder().tex;
4621
- 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;
4622
4587
  case 3:
4623
4588
  case 4: {
4624
4589
  let t = this.d.clone().simplify();
4625
- 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.`;
4626
4591
  }
4627
4592
  default: {
4628
4593
  let e = this.getEquation();
@@ -4634,13 +4599,13 @@ var G = class e {
4634
4599
  let e = this.#a;
4635
4600
  switch (this.#a = 1, e) {
4636
4601
  case 0: return this.getEquation().reorder().display;
4637
- 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;
4638
4603
  case 3: {
4639
4604
  let e = this.d.clone().simplify();
4640
4605
  return `((x,y))=((${this.#e.x.display},${this.#e.y.display}))+k((${e.x.display},${e.y.display}))`;
4641
4606
  }
4642
4607
  case 4: {
4643
- 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);
4644
4609
  return `{(x,=,${t.display}),(y,=,${n.display}):}`;
4645
4610
  }
4646
4611
  default: {
@@ -4693,7 +4658,7 @@ var G = class e {
4693
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";
4694
4659
  }
4695
4660
  get d() {
4696
- let e = new L(this.#n.clone(), this.#t.clone().opposite());
4661
+ let e = new H(this.#n.clone(), this.#t.clone().opposite());
4697
4662
  return (this.#i === "lr" && e.x.isNegative() || this.#i === "rl" && e.x.isPositive()) && e.opposite(), e;
4698
4663
  }
4699
4664
  set d(e) {
@@ -4707,19 +4672,19 @@ var G = class e {
4707
4672
  return n.isZero() ? new v(0) : new v().from(2, n.inverse(), t).reduce();
4708
4673
  }
4709
4674
  fromCoefficient(e, t, n) {
4710
- 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);
4711
4676
  let r = [
4712
4677
  this.#t,
4713
4678
  this.#n,
4714
4679
  this.#r
4715
- ].every((e) => e.exact) ? d.lcm(this.#t.denominator, this.#n.denominator, this.#r.denominator) : 1;
4716
- 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;
4717
4682
  for (let e = 0; e < this.#n.value; e++) {
4718
4683
  let t = this.#t.clone().divide(this.#n).multiply(e).subtract(this.#r.clone().divide(this.#n)).reduce();
4719
- if (this.#e = new L(e, t), t.isRelative()) return this;
4684
+ if (this.#e = new H(e, t), t.isRelative()) return this;
4720
4685
  }
4721
4686
  let i = this.#r.clone().divide(this.#n).opposite().reduce();
4722
- return this.#e = new L(0, i), this;
4687
+ return this.#e = new H(0, i), this;
4723
4688
  }
4724
4689
  fromEquation(e) {
4725
4690
  e.reorder(!0);
@@ -4737,23 +4702,23 @@ var G = class e {
4737
4702
  fromPointAndDirection(e, t) {
4738
4703
  return this.#i = t.x.isPositive() ? "lr" : "rl", this.fromPointAndNormal(e, t.clone().normal());
4739
4704
  }
4740
- fromPointAndLine(e, t, n = R.Parallel) {
4741
- 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);
4742
4707
  }
4743
- 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);
4744
4709
  fromPoints(e, t) {
4745
- return this.fromPointAndNormal(e, new L(e, t).normal());
4710
+ return this.fromPointAndNormal(e, new H(e, t).normal());
4746
4711
  }
4747
4712
  getEquation() {
4748
- 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();
4749
4714
  }
4750
4715
  getValueAtX = (e) => {
4751
- let t = this.getEquation().isolate("y"), n = new p(e);
4752
- 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();
4753
4718
  };
4754
4719
  getValueAtY = (e) => {
4755
- let t = this.getEquation().isolate("x"), n = new p(e);
4756
- 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();
4757
4722
  };
4758
4723
  get height() {
4759
4724
  return this.#r.clone().opposite().divide(this.#n);
@@ -4763,8 +4728,8 @@ var G = class e {
4763
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;
4764
4729
  }
4765
4730
  intersection = (e) => {
4766
- let t = new I(), n = !1, r = !1;
4767
- 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)))), {
4768
4733
  point: t,
4769
4734
  hasIntersection: !(n || r),
4770
4735
  isParallel: n,
@@ -4785,25 +4750,25 @@ var G = class e {
4785
4750
  return this.d.normal();
4786
4751
  }
4787
4752
  get normal() {
4788
- return new L(this.#t, this.#n);
4753
+ return new H(this.#t, this.#n);
4789
4754
  }
4790
4755
  randomNearPoint = (e) => {
4791
4756
  let t = this.randomPoint(e), n = 10;
4792
- 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--;
4793
4758
  return t;
4794
4759
  };
4795
- 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));
4796
4761
  simplify = () => {
4797
- 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);
4798
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;
4799
4764
  };
4800
4765
  get slope() {
4801
4766
  return this.#t.clone().opposite().divide(this.#n);
4802
4767
  }
4803
- }, K = class e {
4804
- #e = new I();
4805
- #t = new I();
4806
- #n = new I();
4768
+ }, J = class e {
4769
+ #e = new V();
4770
+ #t = new V();
4771
+ #n = new V();
4807
4772
  #r = !1;
4808
4773
  #i = null;
4809
4774
  #a = !0;
@@ -4824,12 +4789,12 @@ var G = class e {
4824
4789
  let [e, n, r] = t;
4825
4790
  return this.fromLines(e, n, r);
4826
4791
  }
4827
- if (t.every((e) => e instanceof G)) return this.fromLines(t[0], t[1], t[2]);
4828
- 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]);
4829
4794
  }
4830
4795
  if (t.length === 6) {
4831
- let e = t.map((e) => new p(e));
4832
- 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");
4833
4798
  return this.fromCoordinates(e[0], e[1], e[2], e[3], e[4], e[5]);
4834
4799
  }
4835
4800
  return this;
@@ -4881,10 +4846,10 @@ var G = class e {
4881
4846
  return this.#a = !0, this;
4882
4847
  }
4883
4848
  fromCoordinates(e, t, n, r, i, a) {
4884
- 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));
4885
4850
  }
4886
4851
  fromLines(e, t, n) {
4887
- 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);
4888
4853
  if (o.hasIntersection) this.#t = o.point;
4889
4854
  else return this.#r = !1, this;
4890
4855
  if (o = i.intersection(a), o.hasIntersection) this.#n = o.point;
@@ -4927,7 +4892,7 @@ var G = class e {
4927
4892
  }
4928
4893
  getHeights() {
4929
4894
  if (!this.#o.heights) {
4930
- 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;
4931
4896
  this.#o.heights = {
4932
4897
  A: e,
4933
4898
  B: t,
@@ -4940,7 +4905,7 @@ var G = class e {
4940
4905
  getMedians() {
4941
4906
  let e = this.getMiddles();
4942
4907
  if (!this.#o.medians) {
4943
- 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;
4944
4909
  this.#o.medians = {
4945
4910
  A: t,
4946
4911
  B: n,
@@ -4953,7 +4918,7 @@ var G = class e {
4953
4918
  getMediators() {
4954
4919
  let e = this.getMiddles();
4955
4920
  if (!this.#o.mediators) {
4956
- 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;
4957
4922
  this.#o.mediators = {
4958
4923
  a: t,
4959
4924
  b: n,
@@ -4965,9 +4930,9 @@ var G = class e {
4965
4930
  }
4966
4931
  getMiddles() {
4967
4932
  return {
4968
- AB: new I().middleOf(this.#e, this.#t),
4969
- AC: new I().middleOf(this.#e, this.#n),
4970
- 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)
4971
4936
  };
4972
4937
  }
4973
4938
  getPoints() {
@@ -5006,9 +4971,9 @@ var G = class e {
5006
4971
  }
5007
4972
  get lines() {
5008
4973
  return this.#i === null && (this.#i = {
5009
- AB: new G(this.#e, this.#t),
5010
- BC: new G(this.#t, this.#n),
5011
- 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)
5012
4977
  }), this.#i;
5013
4978
  }
5014
4979
  medianA() {
@@ -5033,14 +4998,14 @@ var G = class e {
5033
4998
  }, this;
5034
4999
  }
5035
5000
  #s(e, t = !0) {
5036
- let n = this.lines, r = new L(), i = new L(), a = new I();
5037
- 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`);
5038
- let o = t ? r.unit().add(i.unit()) : r.unit().subtract(i.unit());
5039
- 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);
5040
5005
  }
5041
5006
  #c(e, t, n) {
5042
5007
  let r = (t ** 2 + n ** 2 - e ** 2) / (2 * t * n);
5043
- 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);
5044
5009
  }
5045
5010
  #l = (e) => {
5046
5011
  switch (e.toUpperCase()) {
@@ -5050,8 +5015,8 @@ var G = class e {
5050
5015
  }
5051
5016
  return this.#e;
5052
5017
  };
5053
- #u = (e, t) => new L(this.#l(e), this.#l(t));
5054
- }, q = class e {
5018
+ #u = (e, t) => new H(this.#l(e), this.#l(t));
5019
+ }, Y = class e {
5055
5020
  #e = null;
5056
5021
  #t = null;
5057
5022
  #n = 1;
@@ -5060,7 +5025,7 @@ var G = class e {
5060
5025
  e.length > 0 && this.parse(...e);
5061
5026
  }
5062
5027
  parse(...t) {
5063
- 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;
5064
5029
  }
5065
5030
  clone() {
5066
5031
  return new e().fromCenterRadius(this.center.clone(), this.squareRadius.clone(), !0);
@@ -5085,36 +5050,36 @@ var G = class e {
5085
5050
  return this.#n = 1, this;
5086
5051
  }
5087
5052
  get center() {
5088
- return this.#e ?? new I();
5053
+ return this.#e ?? new V();
5089
5054
  }
5090
5055
  get equation() {
5091
- return this.#t?.clone() ?? new k("0=0");
5056
+ return this.#t?.clone() ?? new N("0=0");
5092
5057
  }
5093
5058
  fromCenterPoint(e, t) {
5094
- 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;
5095
5060
  }
5096
5061
  fromCenterRadius(e, t, n) {
5097
- return this.#e = e.clone(), this.#r = n ? new p(t) : 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;
5098
5063
  }
5099
5064
  fromEquation(e) {
5100
5065
  if (e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
5101
5066
  let t = e.left.monomByDegree(2, "x"), n = e.left.monomByDegree(2, "y"), r, i, a;
5102
- 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;
5103
5068
  this.#a();
5104
5069
  }
5105
5070
  return this;
5106
5071
  }
5107
5072
  fromPoints(e, t, n) {
5108
- let r = new K(e, t, n);
5073
+ let r = new J(e, t, n);
5109
5074
  if (!r.isValid || !r.remarquables) return this.#a(), this;
5110
5075
  let i = r.getMediators().c.clone(), a = r.getMediators().b.clone();
5111
5076
  return this.fromCenterPoint(i.intersection(a).point, e);
5112
5077
  }
5113
5078
  fromString(e) {
5114
- return this.fromEquation(new k(e));
5079
+ return this.fromEquation(new N(e));
5115
5080
  }
5116
5081
  getPointsOnCircle() {
5117
- let e = d.pythagoreanTripletsWithTarget(this.squareRadius.value, !0), t = [];
5082
+ let e = p.pythagoreanTripletsWithTarget(this.squareRadius.value, !0), t = [];
5118
5083
  return e.forEach((e) => {
5119
5084
  for (let n of [
5120
5085
  [1, 1],
@@ -5123,7 +5088,7 @@ var G = class e {
5123
5088
  [1, -1]
5124
5089
  ]) {
5125
5090
  let r = this.center.x.clone().add(n[0] * e[0]), i = this.center.y.clone().add(n[1] * e[1]);
5126
- 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));
5127
5092
  }
5128
5093
  }), t;
5129
5094
  }
@@ -5140,10 +5105,10 @@ var G = class e {
5140
5105
  if (s.length === 0) return [];
5141
5106
  if (s.length === 1) {
5142
5107
  let e = r.add(n.clone().multiplyByScalar(s[0].fraction));
5143
- return [new I(e.x, e.y)];
5108
+ return [new V(e.x, e.y)];
5144
5109
  }
5145
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));
5146
- 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);
5147
5112
  }
5148
5113
  get radius() {
5149
5114
  return new v().from(2, this.#r ?? 0);
@@ -5154,57 +5119,57 @@ var G = class e {
5154
5119
  return t - n > 1e-10 ? 0 : Math.abs(t - n) < 1e-10 ? 1 : 2;
5155
5120
  }
5156
5121
  setRadius(e, t) {
5157
- return this.#r = t ? new p(e) : new p(e).pow(2), this.#i(), this;
5122
+ return this.#r = t ? new m(e) : new m(e).pow(2), this.#i(), this;
5158
5123
  }
5159
5124
  get squareRadius() {
5160
- return this.#r?.clone() ?? new p(-1);
5125
+ return this.#r?.clone() ?? new m(-1);
5161
5126
  }
5162
- 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) : [];
5163
5128
  #i() {
5164
- 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();
5165
5130
  }
5166
5131
  #a() {
5167
5132
  this.#e = null, this.#r = null, this.#t = null;
5168
5133
  }
5169
5134
  #o = (e) => {
5170
- let t = new L(this.center, e);
5171
- return [new G().fromPointAndNormal(e, t)];
5135
+ let t = new H(this.center, e);
5136
+ return [new q().fromPointAndNormal(e, t)];
5172
5137
  };
5173
5138
  #s = (e) => {
5174
- 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");
5175
- return r.multiply(t).subtract(n).pow(2), i.multiply(this.squareRadius), new k(r, i).solve().map((t) => {
5176
- let n, r = new k("y", "x");
5177
- 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);
5178
5143
  });
5179
5144
  };
5180
5145
  #c = (e) => {
5181
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());
5182
- return [new G(t, n, o), new G(t, n, s)];
5147
+ return [new q(t, n, o), new q(t, n, s)];
5183
5148
  };
5184
- }, J = class e {
5185
- static PARALLEL = z.Parallel;
5186
- static PERPENDICULAR = z.Perpendicular;
5187
- #e = new I();
5188
- #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();
5189
5154
  constructor(e, t) {
5190
- 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;
5191
5156
  }
5192
5157
  clone = () => (this.#t = this.#t.clone(), this.#e = this.#e.clone(), this);
5193
5158
  get tex() {
5194
5159
  return {
5195
- 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)}`,
5196
5161
  system: `\\left\\{\\begin{aligned}
5197
- x &= ${new O(this.#e.x).add(new E(this.#t.x).multiply(new E("k"))).reorder("k", !0).tex}\\\\
5198
- y &= ${new O(this.#e.y).add(new E(this.#t.y).multiply(new E("k"))).reorder("k", !0).tex}\\\\
5199
- 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}
5200
5165
  \\end{aligned}\\right.`,
5201
- 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} }`
5202
5167
  };
5203
5168
  }
5204
5169
  get display() {
5205
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;
5206
5171
  return {
5207
- 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)}`,
5208
5173
  system: "",
5209
5174
  cartesian: `(x-${e})/${i} = (y-${t})/${a} = (z-${n})/${o}`
5210
5175
  };
@@ -5225,7 +5190,7 @@ var G = class e {
5225
5190
  return this.#t.clone();
5226
5191
  }
5227
5192
  distanceTo(e) {
5228
- 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();
5229
5194
  return {
5230
5195
  value: Math.sqrt(i.value),
5231
5196
  fraction: i.clone().sqrt(),
@@ -5237,34 +5202,34 @@ var G = class e {
5237
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;
5238
5203
  }
5239
5204
  intersection = (e) => {
5240
- throw Error("Method not implemented.");
5205
+ throw new a("Method not implemented.");
5241
5206
  };
5242
5207
  isOnLine = (e) => !1;
5243
5208
  isParallelTo = (e) => {
5244
- throw Error("Method not implemented.");
5209
+ throw new a("Method not implemented.");
5245
5210
  };
5246
5211
  isPerpendicularTo = (e) => {
5247
- throw Error("Method not implemented.");
5212
+ throw new a("Method not implemented.");
5248
5213
  };
5249
5214
  isSameAs = (e) => {
5250
- throw Error("Method not implemented.");
5215
+ throw new a("Method not implemented.");
5251
5216
  };
5252
5217
  isVertical = () => {
5253
- throw Error("Method not implemented.");
5218
+ throw new a("Method not implemented.");
5254
5219
  };
5255
5220
  get point() {
5256
5221
  return this.#e.clone();
5257
5222
  }
5258
5223
  randomPoint = (e = 5) => {
5259
- let t = this.#e.clone(), n = new p(H(e, !1));
5260
- 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)));
5261
5226
  };
5262
5227
  simplify = () => {
5263
- throw Error("Method not implemented.");
5228
+ throw new a("Method not implemented.");
5264
5229
  };
5265
- }, ge = class e {
5266
- #e = new L(0, 0, 1);
5267
- #t = new I(0, 0, 0);
5230
+ }, ke = class e {
5231
+ #e = new H(0, 0, 1);
5232
+ #t = new V(0, 0, 0);
5268
5233
  constructor(e) {
5269
5234
  return e && this.parse(e), this;
5270
5235
  }
@@ -5281,37 +5246,37 @@ var G = class e {
5281
5246
  }
5282
5247
  if (e.equation) {
5283
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;
5284
- this.normal = new L(n, r, i), this.point = n.isNotZero() ? new I(a.clone().divide(n).opposite(), 0, 0) : r.isNotZero() ? new I(0, a.clone().divide(r).opposite(), 0) : 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());
5285
5250
  return;
5286
5251
  }
5287
- if (e.points?.length === 3 && e.points.every((e) => e instanceof L)) {
5288
- 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);
5289
5254
  this.normal = i.cross(a), this.point = t;
5290
5255
  return;
5291
5256
  }
5292
5257
  if (e.coefficients?.length === 4) {
5293
5258
  let [t, n, r, i] = e.coefficients;
5294
- 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);
5295
5260
  return;
5296
5261
  }
5297
5262
  }
5298
5263
  get tex() {
5299
- 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;
5300
5265
  }
5301
5266
  get display() {
5302
- 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;
5303
5268
  }
5304
5269
  get a() {
5305
5270
  return this.#e.x;
5306
5271
  }
5307
- angle(t, n, r) {
5308
- if (t instanceof e) return this.normal.angle(t.normal, n, r);
5309
- let i;
5310
- if (t instanceof L) {
5311
- if (t.dimension !== 3) throw Error("Vector is not 3D");
5312
- i = t;
5313
- } else i = t.direction;
5314
- 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);
5315
5280
  }
5316
5281
  get b() {
5317
5282
  return this.#e.y;
@@ -5327,10 +5292,10 @@ var G = class e {
5327
5292
  }
5328
5293
  intersectWithLine(e) {
5329
5294
  let { point: t, direction: n } = e, r = this.normal.dot(t).add(this.d).divide(this.normal.dot(n).opposite());
5330
- return new I(new L(t).add(n.clone().multiplyByScalar(r)));
5295
+ return new V(new H(t).add(n.clone().multiplyByScalar(r)));
5331
5296
  }
5332
5297
  intersectWithPlane(e) {
5333
- 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 !");
5334
5299
  }
5335
5300
  isPointOnPlane(e) {
5336
5301
  return this.normal.dot(e).add(this.d).isZero();
@@ -5339,44 +5304,44 @@ var G = class e {
5339
5304
  return this.#e;
5340
5305
  }
5341
5306
  set normal(e) {
5342
- this.#e = new L(e);
5307
+ this.#e = new H(e);
5343
5308
  }
5344
5309
  get point() {
5345
5310
  return this.#t;
5346
5311
  }
5347
5312
  set point(e) {
5348
- this.#t = new I(e);
5313
+ this.#t = new V(e);
5349
5314
  }
5350
- }, _e = /* @__PURE__ */ function(e) {
5315
+ }, Ae = /* @__PURE__ */ function(e) {
5351
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;
5352
- }({}), ve = class {
5317
+ }({}), je = class {
5353
5318
  #e = void 0;
5354
5319
  #t = void 0;
5355
5320
  #n = void 0;
5356
5321
  #r = 1;
5357
5322
  constructor(e, t) {
5358
- 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;
5359
5324
  }
5360
5325
  fromEquation(e) {
5361
- let t = new k(e).moveLeft().reduce(), n = [
5326
+ let t = new N(e).moveLeft().reduce(), n = [
5362
5327
  "x",
5363
5328
  "y",
5364
5329
  "z"
5365
5330
  ];
5366
5331
  if (n.some((e) => t.degree(e).value !== 2)) return this.makeUndefined();
5367
5332
  let r = t.left.monomByDegree(2, "x").coefficient;
5368
- 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);
5369
5334
  }
5370
5335
  get center() {
5371
- if (this.#e === void 0) throw Error("Sphere3 is undefined");
5336
+ if (this.#e === void 0) throw new s("Sphere3 is undefined");
5372
5337
  return this.#e;
5373
5338
  }
5374
5339
  get squareRadius() {
5375
- if (this.#t === void 0) throw Error("Sphere3 is undefined");
5340
+ if (this.#t === void 0) throw new s("Sphere3 is undefined");
5376
5341
  return this.#t;
5377
5342
  }
5378
5343
  get radius() {
5379
- if (this.#t === void 0) throw Error("Sphere3 is undefined");
5344
+ if (this.#t === void 0) throw new s("Sphere3 is undefined");
5380
5345
  return this.#t.isSquare() ? {
5381
5346
  tex: this.#t.clone().sqrt().tex,
5382
5347
  display: this.#t.clone().sqrt().display,
@@ -5388,7 +5353,7 @@ var G = class e {
5388
5353
  };
5389
5354
  }
5390
5355
  get equation() {
5391
- if (this.#n === void 0) throw Error("Sphere3 is undefined");
5356
+ if (this.#n === void 0) throw new s("Sphere3 is undefined");
5392
5357
  return this.#n;
5393
5358
  }
5394
5359
  makeUndefined() {
@@ -5407,7 +5372,7 @@ var G = class e {
5407
5372
  return this.#i(!1);
5408
5373
  }
5409
5374
  #i = (e) => {
5410
- if (this.#n === void 0) throw Error("Sphere3 is undefined");
5375
+ if (this.#n === void 0) throw new s("Sphere3 is undefined");
5411
5376
  if (this.#r === 0) return e ? this.#n.tex : this.#n.display;
5412
5377
  let t = [];
5413
5378
  return [
@@ -5417,15 +5382,15 @@ var G = class e {
5417
5382
  ].forEach((n) => {
5418
5383
  if (this.center[n].isZero()) t.push(`${n}^2`);
5419
5384
  else {
5420
- let r = new O(n).subtract(this.center[n]);
5385
+ let r = new M(n).subtract(this.center[n]);
5421
5386
  t.push(e ? `\\(${r.tex}\\)^2` : `(${r.display})^2`);
5422
5387
  }
5423
5388
  }), t.join("+") + "=" + (e ? this.squareRadius.tex : this.squareRadius.display);
5424
5389
  };
5425
5390
  #a() {
5426
- 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();
5427
5392
  }
5428
- static RELATIVE_POSITION = _e;
5393
+ static RELATIVE_POSITION = Ae;
5429
5394
  relativePosition = (e) => {
5430
5395
  let t = this.center.distanceTo(e.center).value, n = this.radius.value, r = e.radius.value;
5431
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;
@@ -5438,38 +5403,38 @@ var G = class e {
5438
5403
  };
5439
5404
  //#endregion
5440
5405
  //#region src/randomization/coefficient/rndFraction.ts
5441
- function Y(e) {
5406
+ function Z(e) {
5442
5407
  let t = Object.assign({
5443
5408
  negative: !0,
5444
5409
  max: 10,
5445
5410
  reduced: !0,
5446
5411
  zero: !0,
5447
5412
  natural: !1
5448
- }, e), n = new p();
5449
- if (n.numerator = t.negative ? H(t.max, t.zero) : 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;
5450
5415
  else {
5451
5416
  let e = 0;
5452
- 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++;
5453
5418
  }
5454
5419
  return t.reduced ? n.reduce() : n;
5455
5420
  }
5456
5421
  //#endregion
5457
5422
  //#region src/randomization/algebra/rndMonom.ts
5458
- function ye(e) {
5423
+ function Me(e) {
5459
5424
  let t = Object.assign({
5460
5425
  letters: "x",
5461
5426
  degree: 2,
5462
5427
  fraction: !0,
5463
5428
  zero: !1
5464
- }, e), n = new E();
5465
- if (n.coefficient = Y(Object.assign({}, {
5429
+ }, e), n = new A();
5430
+ if (n.coefficient = Z(Object.assign({}, {
5466
5431
  zero: t.zero,
5467
5432
  reduced: !0,
5468
5433
  natural: t.fraction === !1
5469
5434
  }, typeof t.fraction == "boolean" ? {} : t.fraction)), t.letters.length > 1) {
5470
5435
  for (let e of t.letters.split("")) n.setLetter(e, 0);
5471
5436
  for (let e = 0; e < t.degree; e++) {
5472
- let e = U(t.letters.split(""));
5437
+ let e = K(t.letters.split(""));
5473
5438
  n.setLetter(e, n.degree(e).clone().add(1));
5474
5439
  }
5475
5440
  } else n.setLetter(t.letters, t.degree);
@@ -5477,7 +5442,7 @@ function ye(e) {
5477
5442
  }
5478
5443
  //#endregion
5479
5444
  //#region src/randomization/algebra/rndPolynom.ts
5480
- var X = {
5445
+ var Ne = {
5481
5446
  letters: "x",
5482
5447
  degree: 2,
5483
5448
  fraction: !1,
@@ -5489,36 +5454,36 @@ var X = {
5489
5454
  commonConstant: !1,
5490
5455
  positive: !0
5491
5456
  };
5492
- function Z(e) {
5493
- let t = Object.assign({}, X, e);
5494
- if (t.factorable) return be(t);
5495
- let n = new O().empty(), r, i = t.degree ?? 2;
5496
- 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({
5497
5462
  letters: t.letters,
5498
5463
  degree: e,
5499
5464
  fraction: t.fraction,
5500
5465
  zero: e !== i && t.allowNullMonom
5501
5466
  }), t.unit && i === e && r.coefficient.one(), n.add(r);
5502
5467
  if (t.positive && n.monomByDegree().coefficient.isNegative() && n.opposite(), t.numberOfMonoms && t.numberOfMonoms > 0 && t.numberOfMonoms < n.length) for (; n.length > t.numberOfMonoms;) {
5503
- let e = V(1, n.length - 1);
5468
+ let e = W(1, n.length - 1);
5504
5469
  n.monoms.splice(e, 1);
5505
5470
  }
5506
5471
  return n.reduce();
5507
5472
  }
5508
- function be(e) {
5509
- let t = Object.assign(X, e), n = { ...t };
5473
+ function Pe(e) {
5474
+ let t = Object.assign(Ne, e), n = { ...t };
5510
5475
  n.degree = 1, n.factorable = !1;
5511
5476
  let r = [], i = t.degree ?? 2;
5512
- for (; r.length < i;) r.push(Z(n));
5477
+ for (; r.length < i;) r.push(Q(n));
5513
5478
  if (e?.commonConstant !== !1) {
5514
- let t = H(10, !1);
5515
- 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));
5516
5481
  }
5517
- return O.xMultiply(...r);
5482
+ return M.xMultiply(...r);
5518
5483
  }
5519
5484
  //#endregion
5520
5485
  //#region src/randomization/algebra/rndEquation.ts
5521
- function xe(e) {
5486
+ function Fe(e) {
5522
5487
  let t = Object.assign({
5523
5488
  letters: "x",
5524
5489
  degree: 1,
@@ -5535,9 +5500,9 @@ function xe(e) {
5535
5500
  nothing: !1,
5536
5501
  everything: !1
5537
5502
  }
5538
- }, e), n = new O().one();
5503
+ }, e), n = new M().one();
5539
5504
  for (let e = 0; e < t.degree; e++) {
5540
- let e = Z({
5505
+ let e = Q({
5541
5506
  degree: 1,
5542
5507
  unit: t.unit,
5543
5508
  fraction: t.fraction,
@@ -5546,28 +5511,28 @@ function xe(e) {
5546
5511
  });
5547
5512
  n.multiply(e);
5548
5513
  }
5549
- return new k(n, 0);
5514
+ return new N(n, 0);
5550
5515
  }
5551
5516
  //#endregion
5552
5517
  //#region src/randomization/geometry/rndPoint.ts
5553
- function Q(e) {
5518
+ function $(e) {
5554
5519
  let t = Object.assign({
5555
5520
  axis: !0,
5556
5521
  fraction: !1,
5557
5522
  max: 10,
5558
5523
  quadrant: null
5559
- }, 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({
5560
5525
  max: t.max,
5561
5526
  zero: n
5562
- }) : new p(H(t.max, n)), a = t.fraction ? Y({
5527
+ }) : new m(G(t.max, n)), a = t.fraction ? Z({
5563
5528
  max: t.max,
5564
5529
  zero: r
5565
- }) : new p(H(t.max, r));
5566
- 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);
5567
5532
  }
5568
5533
  //#endregion
5569
5534
  //#region src/randomization/geometry/rndCircle.ts
5570
- function Se(e) {
5535
+ function Ie(e) {
5571
5536
  let t = Object.assign({
5572
5537
  center: {
5573
5538
  x: {
@@ -5580,82 +5545,92 @@ function Se(e) {
5580
5545
  }
5581
5546
  },
5582
5547
  pointsOnCircle: 8
5583
- }, e), n = Q(t.center), r, i;
5584
- 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);
5585
5550
  }
5586
5551
  //#endregion
5587
5552
  //#region src/randomization/geometry/rndLine.ts
5588
- function Ce(e) {
5553
+ function Le(e) {
5589
5554
  let t = Object.assign({ A: {
5590
- x: H(10),
5591
- y: H(10)
5592
- } }, e), n = new L(0, 0);
5593
- for (; n.isNull;) n.x = H(10, t.allow?.vertical ?? !0), n.y = H(10, t.allow?.horizontal ?? !0);
5594
- 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);
5595
5560
  }
5596
5561
  //#endregion
5597
5562
  //#region src/randomization/geometry/rndLine3.ts
5598
- function we(e) {
5563
+ function Re(e) {
5599
5564
  let t = Object.assign({
5600
5565
  A: {
5601
- x: H(10),
5602
- y: H(10),
5603
- z: H(10)
5566
+ x: G(10),
5567
+ y: G(10),
5568
+ z: G(10)
5604
5569
  },
5605
5570
  direction: {
5606
- x: H(10),
5607
- y: H(10),
5608
- z: H(10)
5571
+ x: G(10),
5572
+ y: G(10),
5573
+ z: G(10)
5609
5574
  }
5610
5575
  }, e);
5611
- 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));
5612
5577
  }
5613
5578
  //#endregion
5614
5579
  //#region src/randomization/random.ts
5615
- var $ = {
5616
- equation: (e) => xe(e),
5617
- polynom: (e) => Z(e),
5618
- monom: (e) => ye(e),
5619
- fraction: (e) => Y(e),
5620
- number: (e, t, n) => V(e, t, n),
5621
- numberSym: (e, t) => H(e, t),
5622
- prime: (e) => me(e),
5623
- triplet: (e, t) => pe(e, t),
5624
- bool: (e) => B(e),
5625
- array: (e, t) => he(e, t),
5626
- item: (e) => U(e),
5627
- shuffle: (e) => W(e),
5628
- line: (e) => Ce(e),
5629
- line3: (e) => we(e),
5630
- vector: (e) => new L(Q(e)),
5631
- point: (e) => Q(e),
5632
- circle: (e) => Se(e)
5633
- }, Te = {
5634
- Numeric: d,
5635
- 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,
5636
5601
  Root: v,
5637
- Monom: E,
5638
- Polynom: O,
5639
- Equation: k,
5640
- Matrix: le,
5641
- LinearSystem: se,
5642
- Factor: A,
5643
- PolyFactor: M,
5644
- LogicalSet: ce,
5645
- 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,
5646
5611
  Geometry: {
5647
- Vector: L,
5648
- Point: I,
5649
- Line: G,
5650
- Triangle: K,
5651
- Circle: q,
5652
- Line3: J,
5653
- Plane3: ge,
5654
- 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
5655
5630
  },
5656
- NumExp: T
5631
+ NumExp: k
5657
5632
  };
5658
5633
  //#endregion
5659
- 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 };
5660
5635
 
5661
5636
  //# sourceMappingURL=pimath.js.map