pimath 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pimath.js CHANGED
@@ -1,15 +1,15 @@
1
1
  function ut(n) {
2
- const t = rt(n), e = [];
2
+ const t = st(n), e = [];
3
3
  let i, s;
4
4
  for (; t.length > 0; )
5
5
  i = t.shift() ?? 1, s = (t.length > 0 ? t.pop() : +i) ?? 1, e.push([i, s]);
6
6
  return e;
7
7
  }
8
8
  function ft(...n) {
9
- const t = _(...n);
9
+ const t = J(...n);
10
10
  return n.map((e) => e / t);
11
11
  }
12
- function rt(n) {
12
+ function st(n) {
13
13
  const t = Math.abs(n), e = Math.sqrt(t), i = [];
14
14
  for (let s = 1; s <= e; s++)
15
15
  n % s === 0 && (i.push(s), i.push(t / s));
@@ -17,9 +17,9 @@ function rt(n) {
17
17
  return s - r;
18
18
  }), [...new Set(i)];
19
19
  }
20
- function _(...n) {
20
+ function J(...n) {
21
21
  const t = function(s, r) {
22
- return r === 0 ? s : t(r, s % r);
22
+ return isNaN(s) || isNaN(r) ? NaN : r === 0 ? s : s === 0 ? r : t(r, s % r);
23
23
  };
24
24
  let e = 1, i = 2;
25
25
  if (n.length === 0)
@@ -34,7 +34,7 @@ function _(...n) {
34
34
  }
35
35
  function dt(...n) {
36
36
  return n.reduce(function(t, e) {
37
- return Math.abs(t * e / _(t, e));
37
+ return Math.abs(t * e / J(t, e));
38
38
  });
39
39
  }
40
40
  function pt(n, t = 3) {
@@ -72,9 +72,9 @@ function vt(n, t) {
72
72
  }
73
73
  const x = {
74
74
  decompose: ut,
75
- dividers: rt,
75
+ dividers: st,
76
76
  divideNumbersByGCD: ft,
77
- gcd: _,
77
+ gcd: J,
78
78
  lcm: dt,
79
79
  numberCorrection: pt,
80
80
  periodic: mt,
@@ -84,7 +84,7 @@ const x = {
84
84
  greatestPower: vt
85
85
  };
86
86
  var xt = /* @__PURE__ */ ((n) => (n.frac = "frac", n.dfrac = "dfrac", n.tfrac = "tfrac", n))(xt || {});
87
- class a {
87
+ class h {
88
88
  #t = 1;
89
89
  #e = 3;
90
90
  #i = !0;
@@ -99,10 +99,10 @@ class a {
99
99
  * Parse the value to get the numerator and denominator
100
100
  * @param value : number or string to parse to get the fraction
101
101
  */
102
- parse = (t, e) => t === "" ? (this.#s = 0, this.#t = 1, this) : typeof t == "string" ? this.fromString(t) : typeof t == "number" && e === void 0 ? this.fromNumber(t) : typeof t == "number" && typeof e == "number" ? this.fromNumbers(t, e) : t instanceof a ? this.copy(t) : this;
102
+ parse = (t, e) => t === "" ? (this.#s = 0, this.#t = 1, this) : typeof t == "number" && isNaN(t) ? this.invalid() : typeof t == "number" && !isFinite(t) ? (this.infinite(), t < 0 && this.opposite(), this) : typeof t == "string" ? this.fromString(t) : typeof t == "number" && e === void 0 ? this.fromNumber(t) : typeof t == "number" && typeof e == "number" ? this.fromNumbers(t, e) : t instanceof h ? this.copy(t) : this;
103
103
  clone = () => {
104
- const t = new a();
105
- return t.numerator = this.#s, t.denominator = this.#t, t.exact = this.exact, t;
104
+ const t = new h();
105
+ return t.numerator = this.#s, t.denominator = this.#t, t.exact = this.exact, t.#r = this.#r, t.#e = this.#e, t.#n = this.#n, t;
106
106
  };
107
107
  copy(t) {
108
108
  return this.#s = t.numerator, this.#t = t.denominator, this.#i = t.exact, this;
@@ -119,66 +119,70 @@ class a {
119
119
  const t = this.#n && this.isPositive() ? "+" : "";
120
120
  return this.exact ? this.#t === 1 ? `${t}${this.#s}` : `${t}${this.#s}/${this.#t}` : t + this.value.toFixed(this.#e);
121
121
  }
122
+ static areEquals = (...t) => t.every((e) => e.isEqual(t[0]));
122
123
  static average = (...t) => {
123
- const e = new a().zero();
124
+ const e = new h().zero();
124
125
  for (const i of t)
125
126
  e.add(i);
126
127
  return e.divide(t.length), e;
127
128
  };
128
129
  static isFraction(t) {
129
- if (t instanceof a || typeof t == "number" && !isNaN(t))
130
+ if (t instanceof h || typeof t == "number" && !isNaN(t))
130
131
  return !0;
131
132
  if (typeof t == "string") {
132
- const [e, i] = t.split("/");
133
- return !isNaN(+e) && !isNaN(+i);
133
+ const e = t.split("/");
134
+ return e.length <= 2 && e.every((i) => !isNaN(+i));
134
135
  }
135
136
  return !1;
136
137
  }
137
138
  static max = (...t) => {
138
- let e = new a(t[0]);
139
+ let e = new h(t[0]);
139
140
  for (const i of t) {
140
- const s = new a(i);
141
+ const s = new h(i);
141
142
  s.isGreater(e) && (e = s.clone());
142
143
  }
143
144
  return e;
144
145
  };
145
146
  static min = (...t) => {
146
- let e = new a(t[0]);
147
+ let e = new h(t[0]);
147
148
  for (const i of t) {
148
- const s = new a(i);
149
+ const s = new h(i);
149
150
  s.isLesser(e) && (e = s.clone());
150
151
  }
151
152
  return e;
152
153
  };
153
154
  static sort = (t, e) => {
154
- const s = t.map((r) => r instanceof a ? r : new a(r)).sort((r, o) => r.value - o.value);
155
+ const s = t.map((r) => r instanceof h ? r : new h(r)).sort((r, o) => r.value - o.value);
155
156
  return e && s.reverse(), s;
156
157
  };
157
158
  static toSameDenominateur(...t) {
158
- const e = t.map((s) => new a(s)), i = x.lcm(...e.map((s) => s.denominator));
159
+ const e = t.map((s) => new h(s)), i = x.lcm(...e.map((s) => s.denominator));
159
160
  return e.forEach((s) => s.amplify(i / s.denominator)), e;
160
161
  }
161
162
  static unique = (t) => {
162
163
  const e = {}, i = [];
163
164
  return t.forEach((s) => {
164
- s instanceof a || (s = new a(s)), e[s.clone().reduce().tex] || (i.push(s.clone()), e[s.tex] = !0);
165
+ s instanceof h || (s = new h(s)), e[s.clone().reduce().tex] || (i.push(s.clone()), e[s.clone().reduce().tex] = !0);
165
166
  }), i;
166
167
  };
167
168
  static xMultiply = (...t) => {
168
- const e = new a();
169
+ const e = new h();
169
170
  return t.forEach((i) => e.multiply(i, !1)), e;
170
171
  };
171
172
  abs = () => (this.#s = Math.abs(this.#s), this.#t = Math.abs(this.#t), this);
172
173
  add = (t) => {
173
- if (t instanceof a) {
174
+ if (t instanceof h) {
174
175
  const e = this.#s, i = this.#t;
175
176
  this.#s = e * t.denominator + t.numerator * i, this.#t = i * t.denominator, this.exact = this.exact && t.exact;
176
177
  } else
177
- return this.add(new a(t));
178
+ return this.add(new h(t));
178
179
  return this.reduce();
179
180
  };
180
- amplify = (t) => (Number.isSafeInteger(t) && (this.#s *= t, this.#t *= t), this);
181
- areEquals = (...t) => t.every((e) => e.isEqual(t[0]));
181
+ amplify = (t) => {
182
+ if (!Number.isSafeInteger(t))
183
+ throw new Error("The amplification factor must be a safe integer.");
184
+ return this.#s *= t, this.#t *= t, this;
185
+ };
182
186
  /**
183
187
  * Compare the current coefficient with another coefficient
184
188
  * @param F (Coefficient) The coefficient to _compare
@@ -187,7 +191,7 @@ class a {
187
191
  compare = (t, e) => {
188
192
  e ??= "=";
189
193
  let i;
190
- switch (t instanceof a ? i = t.clone() : i = new a(t), e) {
194
+ switch (t instanceof h ? i = t.clone() : i = new h(t), e) {
191
195
  case ">":
192
196
  return this.value > i.value;
193
197
  case ">=":
@@ -201,9 +205,9 @@ class a {
201
205
  case "leq":
202
206
  return this.value <= i.value;
203
207
  case "=":
204
- return this.value === i.value;
208
+ return this.#s * i.denominator === i.numerator * this.#t;
205
209
  case "<>":
206
- return this.value !== i.value;
210
+ return this.#s * i.denominator !== i.numerator * this.#t;
207
211
  default:
208
212
  return !1;
209
213
  }
@@ -221,9 +225,9 @@ class a {
221
225
  return this.#e = t, this;
222
226
  }
223
227
  divide = (t) => {
224
- const e = new a(t);
228
+ const e = new h(t);
225
229
  if (e.numerator === 0)
226
- return new a().infinite();
230
+ return this.infinite();
227
231
  const i = this.#s, s = this.#t;
228
232
  return this.#s = i * e.denominator, this.#t = s * e.numerator, this.exact = this.exact && e.exact, this.reduce();
229
233
  };
@@ -246,12 +250,17 @@ class a {
246
250
  return Number.isSafeInteger(t) && Number.isSafeInteger(e) ? (this.#s = t, this.#t = e, this.#i = !0, this) : this.fromNumber(t / e);
247
251
  }
248
252
  fromPeriodic(t, e) {
249
- const [, i] = t.toString().split(/[.,]/), s = i ? i.length : 0, r = Math.pow(10, s);
253
+ const [, i] = t.toString().split(/[.,]/), s = i ? i.length : 0;
254
+ if (!Number.isSafeInteger(e) || e <= 0)
255
+ throw new Error("The periodic length must be a positive integer.");
256
+ if (e > s)
257
+ throw new Error(`The periodic length (${e}) cannot exceed the number of decimal digits (${s}).`);
258
+ const r = Math.pow(10, s);
250
259
  return this.#s = +t * r - Math.floor(+t * Math.pow(10, s - e)), this.#t = r - Math.pow(10, s - e), this.#i = !0, this;
251
260
  }
252
261
  fromString(t) {
253
262
  const e = t.split("/").map(Number);
254
- return this.#i = !0, e.length > 2 ? (this.#s = NaN, this) : e.some((i) => isNaN(i)) ? (this.#s = NaN, this) : e.length === 1 ? this.fromNumber(+t) : e[1] === 0 ? (this.#s = NaN, this.#t = 1, this) : (this.#s = e[0], this.#t = e[1], this);
263
+ return this.#i = !0, e.length > 2 ? (this.#s = NaN, this) : e.some((i) => isNaN(i)) ? (this.#s = NaN, this) : e.length === 1 ? this.fromNumber(+t) : e[1] === 0 ? this.infinite() : (this.#s = e[0], this.#t = e[1], this);
255
264
  }
256
265
  infinite = () => (this.#s = 1 / 0, this.#t = 1, this.exact = !0, this);
257
266
  invalid = () => (this.#s = NaN, this.#t = 1, this.exact = !0, this);
@@ -272,7 +281,7 @@ class a {
272
281
  isNegative = () => this.sign() === -1;
273
282
  isNotEqual = (t) => this.compare(t, "<>");
274
283
  isNotZero = () => this.#s !== 0;
275
- isOdd = () => this.isRelative() && this.value % 2 === 1;
284
+ isOdd = () => this.isRelative() && Math.abs(this.value % 2) === 1;
276
285
  isOne = () => this.#s === 1 && this.#t === 1;
277
286
  isPositive = () => this.sign() === 1;
278
287
  isRational = () => this.exact && !this.isRelative();
@@ -287,7 +296,7 @@ class a {
287
296
  // Mathematical operations specific to fractions
288
297
  isZero = () => this.#s === 0;
289
298
  multiply = (t, e = !0) => {
290
- const i = new a(t);
299
+ const i = new h(t);
291
300
  return this.#s = this.#s * i.numerator, this.#t = this.#t * i.denominator, this.exact = this.exact && i.exact, e ? this.reduce() : this;
292
301
  };
293
302
  // ------------------------------------------
@@ -300,11 +309,11 @@ class a {
300
309
  one = () => this.fromNumber(1);
301
310
  opposite = () => (this.#s = -this.#s, this);
302
311
  pow = (t) => {
303
- if (t instanceof a)
312
+ if (t instanceof h)
304
313
  return this.pow(t.value);
305
314
  this.reduce(), t < 0 && this.inverse();
306
- const e = Math.floor(Math.pow(this.#s, Math.abs(t))), i = Math.floor(Math.pow(this.#t, Math.abs(t)));
307
- return e ** Math.abs(t) === this.#s && i ** Math.abs(t) === this.#t ? (this.#s = this.#s ** Math.abs(t), this.#t = this.#t ** Math.abs(t)) : (this.#s = this.#s ** Math.abs(t), this.#t = this.#t ** Math.abs(t)), this;
315
+ const e = Math.abs(t), i = Math.pow(this.#s, e), s = Math.pow(this.#t, e), r = Math.floor(i), o = Math.floor(s);
316
+ return r === i && o === s ? (this.#s = r, this.#t = o) : (this.#s = i / s, this.#t = 1, this.exact = !1), this;
308
317
  };
309
318
  reduce = () => {
310
319
  const t = x.gcd(this.#s, this.#t);
@@ -313,9 +322,9 @@ class a {
313
322
  root = (t) => {
314
323
  if (t === 0)
315
324
  return this;
316
- if (t < 0 && this.inverse(), !Number.isSafeInteger(t))
325
+ if (!Number.isSafeInteger(t))
317
326
  throw new Error("The root must be an integer.");
318
- if (this.isNegative() && t % 2 === 0)
327
+ if (t < 0 && this.inverse(), this.isNegative() && t % 2 === 0)
319
328
  throw new Error("The root of a negative number must be odd.");
320
329
  const e = this.sign();
321
330
  this.abs(), this.reduce();
@@ -324,10 +333,7 @@ class a {
324
333
  };
325
334
  sign = () => this.#s * this.#t >= 0 ? 1 : -1;
326
335
  sqrt = () => this.root(2);
327
- subtract = (t) => t instanceof a ? this.add(t.clone().opposite()) : this.add(-t);
328
- get texWithSign() {
329
- return this.isPositive() ? `+${this.tex}` : this.tex;
330
- }
336
+ subtract = (t) => t instanceof h ? this.add(t.clone().opposite()) : this.add(-t);
331
337
  get tfrac() {
332
338
  return this.#r = "tfrac", this;
333
339
  }
@@ -343,13 +349,13 @@ class a {
343
349
  }
344
350
  zero = () => this.fromNumber(0);
345
351
  }
346
- function st(n, t = !0) {
352
+ function it(n, t = !0) {
347
353
  return t ? `\\left( ${n} \\right)` : `(${n})`;
348
354
  }
349
355
  function Q(n) {
350
356
  return n.startsWith("(") && (n = n.substring(1)), n.endsWith(")") && (n = n.substring(0, n.length - 1)), n;
351
357
  }
352
- function U(n, t, e, i, s) {
358
+ function j(n, t, e, i, s) {
353
359
  return n.map((r, o) => r === t ? e : r);
354
360
  }
355
361
  class T {
@@ -358,29 +364,29 @@ class T {
358
364
  #i;
359
365
  #s = !1;
360
366
  constructor(t) {
361
- return this.#e = 2, this.#t = new a().zero(), this.#i = new a().zero(), t && this.parse(t), this;
367
+ return this.#e = 2, this.#t = new h().zero(), this.#i = new h().zero(), t && this.parse(t), this;
362
368
  }
363
369
  parse(t) {
364
370
  if (t instanceof T)
365
371
  return this.index = t.index, this.radical = t.radical.clone(), this.factor = t.factor.clone(), this;
366
- if (t instanceof a)
372
+ if (t instanceof h)
367
373
  return this.index = 2, this.factor = t.clone(), this.radical.one(), this;
368
374
  if (typeof t == "string") {
369
375
  if (t.includes("sqrt"))
370
- return this.#h(t);
376
+ return this.#a(t);
371
377
  if (t.includes("root"))
372
378
  return this.#o(t);
373
379
  }
374
- return this.index = 2, this.factor = new a(t), this.radical.one(), this;
380
+ return this.index = 2, this.factor = new h(t), this.radical.one(), this;
375
381
  }
376
382
  clone() {
377
383
  return new T().from(this.index, this.radical, this.factor);
378
384
  }
379
385
  get tex() {
380
- const t = this.#s && this.factor.isPositive() ? "+" : "";
386
+ const t = this.#s && this.factor.isPositive() ? "+" : "", e = t && this.#t.numerator === 1 ? " " : "";
381
387
  if (this.value === 0) return `${t}0`;
382
- const e = this.#n(this.#t.denominator, this.#i.denominator), i = this.#n(this.#t.numerator, this.#i.numerator) ?? "1";
383
- return e === null ? `${t}${i}` : `${t}\\frac{ ${i} }{ ${e} }`;
388
+ const i = this.#n(this.#t.denominator, this.#i.denominator), s = this.#n(this.#t.numerator, this.#i.numerator) ?? "1";
389
+ return i === null ? `${t}${e}${s}` : `${t}${e}\\frac{ ${s} }{ ${i} }`;
384
390
  }
385
391
  get display() {
386
392
  const t = this.#s && this.factor.isPositive() ? "+" : "";
@@ -405,7 +411,7 @@ class T {
405
411
  this.#t = t;
406
412
  }
407
413
  from(t, e, i) {
408
- return this.index = t, this.radical = new a(e), this.factor = i ? new a(i) : new a().one(), this;
414
+ return this.index = t, this.radical = new h(e), this.factor = i ? new h(i) : new h().one(), this;
409
415
  }
410
416
  /**
411
417
  * convert to root(index)(radical), without factor
@@ -422,7 +428,7 @@ class T {
422
428
  this.#e = t;
423
429
  }
424
430
  get indexAsPow() {
425
- return new a(this.index).inverse();
431
+ return new h(this.index).inverse();
426
432
  }
427
433
  inverse() {
428
434
  return this.factor.inverse(), this.radical.inverse(), this;
@@ -499,25 +505,25 @@ class T {
499
505
  }
500
506
  #r(t, e, i) {
501
507
  const s = this.#e === 2 ? "sqrt" : `root(${this.#e})`, r = [
502
- t !== 1 && t !== 0 ? t.toString() : null,
508
+ t === 1 || t === 0 ? null : t === -1 ? "-" : t.toString(),
503
509
  e !== 1 && e !== 0 ? `${s}(${e})` : null
504
510
  ].filter((o) => o !== null);
505
511
  return r.length === 0 ? null : i && r.length === 2 ? `(${r.join("")})` : r.join("");
506
512
  }
507
513
  #n(t, e) {
508
514
  const i = this.#e === 2 ? "\\sqrt" : `\\sqrt[ ${this.#e} ]`, s = [
509
- t !== 1 && t !== 0 ? t.toString() : null,
515
+ t === 1 || t === 0 ? null : t === -1 ? "-" : t.toString(),
510
516
  e !== 1 && e !== 0 ? `${i}{ ${e} }` : null
511
517
  ].filter((r) => r !== null);
512
518
  return s.length === 0 ? null : s.join(" ");
513
519
  }
514
520
  #o(t) {
515
521
  const [e, i] = t.split("root"), [s, r] = i.split(")");
516
- return this.index = +Q(s), this.radical = new a(Q(r)), this.factor = e === "" ? new a().one() : new a(e), this;
522
+ return this.index = +Q(s), this.radical = new h(Q(r)), this.factor = e === "" ? new h().one() : new h(e), this;
517
523
  }
518
- #h(t) {
524
+ #a(t) {
519
525
  const [e, i] = t.split("sqrt");
520
- return this.index = 2, this.radical = new a(Q(i)), this.factor = e === "" ? new a().one() : new a(e), this;
526
+ return this.index = 2, this.radical = new h(Q(i)), this.factor = e === "" ? new h().one() : new h(e), this;
521
527
  }
522
528
  }
523
529
  class C {
@@ -529,13 +535,13 @@ class C {
529
535
  #n;
530
536
  #o;
531
537
  constructor() {
532
- this.#o = "x", this.#i = !1, this.#e = null, this.#n = null, this.#s = new a().zero(), this.#r = new T(), this.#t = 1;
538
+ this.#o = "x", this.#i = !1, this.#e = null, this.#n = null, this.#s = new h().zero(), this.#r = new T(), this.#t = 1;
533
539
  }
534
540
  get tex() {
535
541
  if (this.#n) return this.#n;
536
542
  if (this.#r.isZero()) return this.#s.tex;
537
543
  if (this.#s.isZero()) return this.#r.tex;
538
- const [t] = a.toSameDenominateur(this.#s, this.#r.factor), e = this.#r.clone().multiply(t.denominator).reduce(), i = `${t.numerator} ${e.withSign.tex}`;
544
+ const [t] = h.toSameDenominateur(this.#s, this.#r.factor), e = this.#r.clone().multiply(t.denominator).reduce(), i = `${t.numerator} ${e.withSign.tex}`;
539
545
  return t.denominator === 1 ? i : `\\frac{ ${i} }{ ${t.denominator} }`;
540
546
  }
541
547
  set tex(t) {
@@ -545,7 +551,7 @@ class C {
545
551
  if (this.#e) return this.#e;
546
552
  if (this.#r.isZero()) return this.#s.display;
547
553
  if (this.#s.isZero()) return this.#r.display;
548
- const [t] = a.toSameDenominateur(this.#s, this.#r.factor), e = this.#r.clone().multiply(t.denominator).reduce(), i = `${t.numerator}${e.withSign.display}`;
554
+ const [t] = h.toSameDenominateur(this.#s, this.#r.factor), e = this.#r.clone().multiply(t.denominator).reduce(), i = `${t.numerator}${e.withSign.display}`;
549
555
  return t.denominator === 1 ? i : `(${i})/${t.denominator}`;
550
556
  }
551
557
  set display(t) {
@@ -554,21 +560,21 @@ class C {
554
560
  static fromFraction(t) {
555
561
  const e = new C();
556
562
  e.setExact();
557
- const i = new a(t);
563
+ const i = new h(t);
558
564
  return e.display = i.display, e.tex = i.tex, e.fraction = i, e.root = new T(), e;
559
565
  }
560
566
  static fromQuadratic(t, e, i) {
561
- const [s, r, o] = [t, e, i].map((m) => new a(m)), h = r.clone().pow(2).subtract(s.clone().multiply(o).multiply(4));
562
- if (h.isNegative())
567
+ const [s, r, o] = [t, e, i].map((m) => new h(m)), a = r.clone().pow(2).subtract(s.clone().multiply(o).multiply(4));
568
+ if (a.isNegative())
563
569
  return [];
564
- if (h.isSquare()) {
565
- const m = h.sqrt(), d = r.clone().opposite().subtract(m).divide(s.clone().multiply(2)), y = r.clone().opposite().add(m).divide(s.clone().multiply(2));
570
+ if (a.isSquare()) {
571
+ const m = a.sqrt(), d = r.clone().opposite().subtract(m).divide(s.clone().multiply(2)), y = r.clone().opposite().add(m).divide(s.clone().multiply(2));
566
572
  return m.isZero() ? [C.fromFraction(d)] : [C.fromFraction(d), C.fromFraction(y)];
567
573
  }
568
574
  const c = new C();
569
- c.fraction = r.clone().opposite().divide(s).divide(2), c.root = new T().from(2, h, s.clone().multiply(2).inverse().opposite()), c.setExact(!1);
575
+ c.fraction = r.clone().opposite().divide(s).divide(2), c.root = new T().from(2, a, s.clone().multiply(2).inverse().opposite()), c.setExact(!1);
570
576
  const f = new C();
571
- return f.fraction = r.clone().opposite().divide(s).divide(2), f.root = new T().from(2, h, s.clone().multiply(2).inverse()), f.setExact(!1), [c, f];
577
+ return f.fraction = r.clone().opposite().divide(s).divide(2), f.root = new T().from(2, a, s.clone().multiply(2).inverse()), f.setExact(!1), [c, f];
572
578
  }
573
579
  get count() {
574
580
  return this.#t;
@@ -613,7 +619,7 @@ class C {
613
619
  t !== void 0 && (this.#o = t);
614
620
  }
615
621
  }
616
- class jt {
622
+ class Ut {
617
623
  #t;
618
624
  #e;
619
625
  constructor(t) {
@@ -666,19 +672,19 @@ class R {
666
672
  solveAsCardan() {
667
673
  if (this.#e.degree().value !== 3)
668
674
  throw new Error("The equation is not cubic.");
669
- return this.#c();
675
+ return this.#h();
670
676
  }
671
677
  #s(t, e) {
672
678
  const i = new C();
673
- return i.exact = !1, i.tex = e?.tex ?? null, i.display = e?.display ?? null, i.fraction = new a(t), i.fraction.exact = !1, i.variable = this.#i, i;
679
+ return i.exact = !1, i.tex = e?.tex ?? null, i.display = e?.display ?? null, i.fraction = new h(t), i.fraction.exact = !1, i.variable = this.#i, i;
674
680
  }
675
681
  #r(t) {
676
- return t instanceof a && !t.exact ? this.#s(t.value) : C.fromFraction(t);
682
+ return t instanceof h && !t.exact ? this.#s(t.value) : C.fromFraction(t);
677
683
  }
678
684
  // Solve using bissection algorithm (approximative solution)
679
685
  #n(t) {
680
- const e = [], i = t.degree().value, [s, ...r] = t.getCoefficients(), o = 2 + Math.max(...r.map((f) => f.value / s.value)), h = this.#h(t, o, 100);
681
- return this.#a(h, i).forEach((f) => {
686
+ const e = [], i = t.degree().value, [s, ...r] = t.getCoefficients(), o = 2 + Math.max(...r.map((f) => f.value / s.value)), a = this.#a(t, o, 100);
687
+ return this.#c(a, i).forEach((f) => {
682
688
  const [m, d] = f;
683
689
  if (m === d)
684
690
  e.push(this.#r(m));
@@ -695,27 +701,27 @@ class R {
695
701
  let o;
696
702
  for (; (i - e) / 2 > this.#t; ) {
697
703
  this._++, o = (e + i) / 2;
698
- const h = t.evaluate(o, !0);
699
- if (h === 0)
704
+ const a = t.evaluate(o, !0);
705
+ if (a === 0)
700
706
  return o;
701
- s * h < 0 ? (i = o, r = h) : (e = o, s = h);
707
+ s * a < 0 ? (i = o, r = a) : (e = o, s = a);
702
708
  }
703
709
  return (e + i) / 2;
704
710
  }
705
- #h(t, e, i) {
711
+ #a(t, e, i) {
706
712
  const s = [], r = 2 * e / i;
707
713
  for (let o = -e; o <= e; o += r) {
708
- const h = x.numberCorrection(o);
714
+ const a = x.numberCorrection(o);
709
715
  s.push(
710
716
  {
711
- x: h,
712
- fx: t.evaluate(h, !0)
717
+ x: a,
718
+ fx: t.evaluate(a, !0)
713
719
  }
714
720
  );
715
721
  }
716
722
  return s;
717
723
  }
718
- #a(t, e) {
724
+ #c(t, e) {
719
725
  const i = [];
720
726
  for (let s = 1; s < t.length; s++) {
721
727
  const r = t[s], o = t[s - 1];
@@ -733,10 +739,10 @@ class R {
733
739
  const d = t.monoms.reduce((q, $) => $.degree().value < q.degree().value ? $ : q), y = d.coefficient;
734
740
  d.clone().divide(y), t.divide(d);
735
741
  }
736
- const o = x.dividers(s.value), h = x.dividers(r.value), c = [];
742
+ const o = x.dividers(s.value), a = x.dividers(r.value), c = [];
737
743
  for (const d of o)
738
- for (const y of h) {
739
- const q = new a(y, d);
744
+ for (const y of a) {
745
+ const q = new h(y, d);
740
746
  c.find(($) => $.value === q.value) || (c.push(q.clone()), c.push(q.opposite().clone()));
741
747
  }
742
748
  c.forEach((d) => {
@@ -757,8 +763,8 @@ class R {
757
763
  reminder: f
758
764
  };
759
765
  }
760
- #c() {
761
- const t = this.#e, e = t.monomByDegree(3).coefficient, i = t.monomByDegree(2).coefficient, s = t.monomByDegree(1).coefficient, r = t.monomByDegree(0).coefficient, o = i.clone().divide(e), h = s.clone().divide(e), c = r.clone().divide(e), f = h.clone().subtract(o.clone().pow(2).divide(3)), m = c.clone().subtract(o.clone().multiply(h).divide(3)).add(o.clone().pow(3).multiply(2).divide(27)), d = m.clone().opposite(), y = f.clone().opposite().pow(3).divide(27), q = d.clone().pow(2).subtract(y.clone().multiply(4)).opposite();
766
+ #h() {
767
+ const t = this.#e, e = t.monomByDegree(3).coefficient, i = t.monomByDegree(2).coefficient, s = t.monomByDegree(1).coefficient, r = t.monomByDegree(0).coefficient, o = i.clone().divide(e), a = s.clone().divide(e), c = r.clone().divide(e), f = a.clone().subtract(o.clone().pow(2).divide(3)), m = c.clone().subtract(o.clone().multiply(a).divide(3)).add(o.clone().pow(3).multiply(2).divide(27)), d = m.clone().opposite(), y = f.clone().opposite().pow(3).divide(27), q = d.clone().pow(2).subtract(y.clone().multiply(4)).opposite();
762
768
  if (q.isNegative()) {
763
769
  const $ = m.clone().opposite().add(q.clone().opposite().sqrt()).divide(2).root(3), k = m.clone().opposite().subtract(q.clone().opposite().sqrt()).divide(2).root(3), I = $.clone().add(k).subtract(o.clone().divide(3));
764
770
  return [this.#r(I)];
@@ -791,13 +797,13 @@ class R {
791
797
  if (r.isNegative())
792
798
  return [];
793
799
  if (r.isSquare()) {
794
- const o = r.sqrt(), h = i.clone().opposite().subtract(o).divide(e.clone().multiply(2)), c = i.clone().opposite().add(o).divide(e.clone().multiply(2));
800
+ const o = r.sqrt(), a = i.clone().opposite().subtract(o).divide(e.clone().multiply(2)), c = i.clone().opposite().add(o).divide(e.clone().multiply(2));
795
801
  if (o.isZero()) {
796
- const f = this.#r(h);
802
+ const f = this.#r(a);
797
803
  return f.count = 2, [f];
798
804
  }
799
805
  return [
800
- this.#r(h),
806
+ this.#r(a),
801
807
  this.#r(c)
802
808
  ].sort((f, m) => f.value - m.value);
803
809
  }
@@ -805,25 +811,25 @@ class R {
805
811
  }
806
812
  #d(t, e, i) {
807
813
  const s = t.clone().multiply(2), r = new C();
808
- r.fraction = e.clone().opposite().divide(s.clone()), r.root.radical = i.clone(), r.root.factor = new a().one().divide(s.clone()), r.exact = !0;
814
+ r.fraction = e.clone().opposite().divide(s.clone()), r.root.radical = i.clone(), r.root.factor = new h().one().divide(s.clone()), r.exact = !0;
809
815
  const o = new C();
810
- return o.fraction = e.clone().opposite().divide(s.clone()), o.root.radical = i.clone(), o.root.factor = new a().one().divide(s.clone()).opposite(), o.exact = !0, [r, o].sort((h, c) => h.value - c.value);
816
+ return o.fraction = e.clone().opposite().divide(s.clone()), o.root.radical = i.clone(), o.root.factor = new h().one().divide(s.clone()).opposite(), o.exact = !0, [r, o].sort((a, c) => a.value - c.value);
811
817
  }
812
818
  }
813
- const tt = {
819
+ const _ = {
814
820
  pi: Math.PI,
815
821
  e: Math.exp(1)
816
822
  };
817
- var u = /* @__PURE__ */ ((n) => (n.VARIABLE = "variable", n.COEFFICIENT = "coefficient", n.OPERATION = "operation", n.CONSTANT = "constant", n.FUNCTION = "function", n.FUNCTION_ARGUMENT = "function-argument", n.MONOM = "monom", n.LEFT_PARENTHESIS = "(", n.RIGHT_PARENTHESIS = ")", n))(u || {}), S = /* @__PURE__ */ ((n) => (n.EXPRESSION = "expression", n.POLYNOM = "polynom", n.SET = "set", n.NUMERIC = "numeric", n))(S || {});
823
+ var l = /* @__PURE__ */ ((n) => (n.VARIABLE = "variable", n.COEFFICIENT = "coefficient", n.OPERATION = "operation", n.CONSTANT = "constant", n.FUNCTION = "function", n.FUNCTION_ARGUMENT = "function-argument", n.MONOM = "monom", n.LEFT_PARENTHESIS = "(", n.RIGHT_PARENTHESIS = ")", n))(l || {}), S = /* @__PURE__ */ ((n) => (n.EXPRESSION = "expression", n.POLYNOM = "polynom", n.SET = "set", n.NUMERIC = "numeric", n))(S || {});
818
824
  function bt(n, t) {
819
825
  if (n.length <= 1)
820
826
  return n;
821
- const e = Object.keys(t).filter((d) => t[d].type === u.FUNCTION).map((d) => d);
827
+ const e = Object.keys(t).filter((d) => t[d].type === l.FUNCTION).map((d) => d);
822
828
  e.sort((d, y) => y.length - d.length);
823
- const i = new RegExp(`^(${e.join("|")})\\(`), s = Object.keys(tt);
829
+ const i = new RegExp(`^(${e.join("|")})\\(`), s = Object.keys(_);
824
830
  s.sort((d, y) => y.length - d.length);
825
831
  const r = new RegExp(`^(${s.join("|")})`), o = /^(\d+(\.\d+)?)/;
826
- let h = "", c, f, m;
832
+ let a = "", c, f, m;
827
833
  for (e.forEach((d) => {
828
834
  if (n.includes(d)) {
829
835
  const y = new RegExp(`${d}([0-9.]+)`, "g");
@@ -832,81 +838,81 @@ function bt(n, t) {
832
838
  }); n.length > 0; ) {
833
839
  if (c = f, m = void 0, e.length > 0 && i.exec(n)) {
834
840
  const d = e.find((y) => n.startsWith(y));
835
- d && (m = d + "(", n = n.slice(d.length + 1), f = u.FUNCTION);
841
+ d && (m = d + "(", n = n.slice(d.length + 1), f = l.FUNCTION);
836
842
  } else if (s.length > 0 && r.exec(n)) {
837
843
  const d = s.find((y) => n.startsWith(y));
838
- d && (m = d, n = n.slice(d.length), f = u.CONSTANT);
844
+ d && (m = d, n = n.slice(d.length), f = l.CONSTANT);
839
845
  } else if (o.exec(n)) {
840
846
  const d = o.exec(n);
841
- d && (m = d[0], n = n.slice(d[0].length), f = u.COEFFICIENT);
847
+ d && (m = d[0], n = n.slice(d[0].length), f = l.COEFFICIENT);
842
848
  } else
843
849
  switch (m = n[0], n = n.slice(1), m) {
844
850
  case "(":
845
- f = u.LEFT_PARENTHESIS;
851
+ f = l.LEFT_PARENTHESIS;
846
852
  break;
847
853
  case ")":
848
- f = u.RIGHT_PARENTHESIS;
854
+ f = l.RIGHT_PARENTHESIS;
849
855
  break;
850
856
  case ",":
851
- f = u.FUNCTION_ARGUMENT;
857
+ f = l.FUNCTION_ARGUMENT;
852
858
  break;
853
859
  case "+":
854
860
  case "-":
855
861
  case "*":
856
862
  case "/":
857
863
  case "^":
858
- f = u.OPERATION;
864
+ f = l.OPERATION;
859
865
  break;
860
866
  default:
861
- f = u.VARIABLE;
867
+ f = l.VARIABLE;
862
868
  }
863
869
  if (m === void 0 || f === void 0)
864
870
  throw new Error("The token is undefined");
865
- h += Et(c, f), h += m;
871
+ a += Et(c, f), a += m;
866
872
  }
867
- return h;
873
+ return a;
868
874
  }
869
875
  function Et(n, t) {
870
- return n === void 0 || n === u.OPERATION || t === u.OPERATION || n === u.LEFT_PARENTHESIS || n === u.FUNCTION || n === u.FUNCTION_ARGUMENT || t === u.RIGHT_PARENTHESIS || t === u.FUNCTION_ARGUMENT ? "" : "*";
876
+ return n === void 0 || n === l.OPERATION || t === l.OPERATION || n === l.LEFT_PARENTHESIS || n === l.FUNCTION || n === l.FUNCTION_ARGUMENT || t === l.RIGHT_PARENTHESIS || t === l.FUNCTION_ARGUMENT ? "" : "*";
871
877
  }
872
878
  const Nt = {
873
- "^": { precedence: 4, associative: "right", type: u.OPERATION },
874
- "*": { precedence: 3, associative: "left", type: u.OPERATION },
875
- "/": { precedence: 3, associative: "left", type: u.OPERATION },
876
- "+": { precedence: 2, associative: "left", type: u.OPERATION },
877
- "-": { precedence: 2, associative: "left", type: u.OPERATION }
879
+ "^": { precedence: 4, associative: "right", type: l.OPERATION },
880
+ "*": { precedence: 3, associative: "left", type: l.OPERATION },
881
+ "/": { precedence: 3, associative: "left", type: l.OPERATION },
882
+ "+": { precedence: 2, associative: "left", type: l.OPERATION },
883
+ "-": { precedence: 2, associative: "left", type: l.OPERATION }
878
884
  }, At = {
879
- "^": { precedence: 4, associative: "right", type: u.OPERATION },
880
- "*": { precedence: 3, associative: "left", type: u.OPERATION },
881
- "/": { precedence: 3, associative: "left", type: u.OPERATION },
882
- "+": { precedence: 2, associative: "left", type: u.OPERATION },
883
- "-": { precedence: 2, associative: "left", type: u.OPERATION },
884
- "%": { precedence: 3, associative: "right", type: u.OPERATION },
885
- sin: { precedence: 4, associative: "right", type: u.FUNCTION },
886
- cos: { precedence: 4, associative: "right", type: u.FUNCTION },
887
- tan: { precedence: 4, associative: "right", type: u.FUNCTION },
888
- sqrt: { precedence: 4, associative: "right", type: u.FUNCTION },
889
- nthrt: { precedence: 4, associative: "right", type: u.FUNCTION },
890
- ",": { precedence: 2, associative: "left", type: u.FUNCTION_ARGUMENT }
885
+ "^": { precedence: 4, associative: "right", type: l.OPERATION },
886
+ "*": { precedence: 3, associative: "left", type: l.OPERATION },
887
+ "/": { precedence: 3, associative: "left", type: l.OPERATION },
888
+ "+": { precedence: 2, associative: "left", type: l.OPERATION },
889
+ "-": { precedence: 2, associative: "left", type: l.OPERATION },
890
+ "%": { precedence: 3, associative: "right", type: l.OPERATION },
891
+ sin: { precedence: 4, associative: "right", type: l.FUNCTION },
892
+ cos: { precedence: 4, associative: "right", type: l.FUNCTION },
893
+ tan: { precedence: 4, associative: "right", type: l.FUNCTION },
894
+ sqrt: { precedence: 4, associative: "right", type: l.FUNCTION },
895
+ nthrt: { precedence: 4, associative: "right", type: l.FUNCTION },
896
+ ",": { precedence: 2, associative: "left", type: l.FUNCTION_ARGUMENT }
891
897
  }, Tt = {
892
- "^": { precedence: 4, associative: "right", type: u.OPERATION },
893
- "*": { precedence: 3, associative: "left", type: u.OPERATION },
894
- "/": { precedence: 3, associative: "left", type: u.OPERATION },
895
- "+": { precedence: 2, associative: "left", type: u.OPERATION },
896
- "-": { precedence: 2, associative: "left", type: u.OPERATION },
897
- "%": { precedence: 3, associative: "right", type: u.OPERATION },
898
- sin: { precedence: 4, associative: "right", type: u.FUNCTION },
899
- cos: { precedence: 4, associative: "right", type: u.FUNCTION },
900
- tan: { precedence: 4, associative: "right", type: u.FUNCTION },
901
- sqrt: { precedence: 4, associative: "right", type: u.FUNCTION },
902
- nthrt: { precedence: 4, associative: "right", type: u.FUNCTION },
903
- ln: { precedence: 4, associative: "right", type: u.FUNCTION },
904
- log: { precedence: 4, associative: "right", type: u.FUNCTION }
898
+ "^": { precedence: 4, associative: "right", type: l.OPERATION },
899
+ "*": { precedence: 3, associative: "left", type: l.OPERATION },
900
+ "/": { precedence: 3, associative: "left", type: l.OPERATION },
901
+ "+": { precedence: 2, associative: "left", type: l.OPERATION },
902
+ "-": { precedence: 2, associative: "left", type: l.OPERATION },
903
+ "%": { precedence: 3, associative: "right", type: l.OPERATION },
904
+ sin: { precedence: 4, associative: "right", type: l.FUNCTION },
905
+ cos: { precedence: 4, associative: "right", type: l.FUNCTION },
906
+ tan: { precedence: 4, associative: "right", type: l.FUNCTION },
907
+ sqrt: { precedence: 4, associative: "right", type: l.FUNCTION },
908
+ nthrt: { precedence: 4, associative: "right", type: l.FUNCTION },
909
+ ln: { precedence: 4, associative: "right", type: l.FUNCTION },
910
+ log: { precedence: 4, associative: "right", type: l.FUNCTION }
905
911
  }, Ot = {
906
- "&": { precedence: 3, associative: "left", type: u.OPERATION },
907
- "|": { precedence: 3, associative: "left", type: u.OPERATION },
908
- "!": { precedence: 4, associative: "right", type: u.OPERATION },
909
- "-": { precedence: 2, associative: "left", type: u.OPERATION }
912
+ "&": { precedence: 3, associative: "left", type: l.OPERATION },
913
+ "|": { precedence: 3, associative: "left", type: l.OPERATION },
914
+ "!": { precedence: 4, associative: "right", type: l.OPERATION },
915
+ "-": { precedence: 2, associative: "left", type: l.OPERATION }
910
916
  };
911
917
  class G {
912
918
  #t;
@@ -935,31 +941,31 @@ class G {
935
941
  NextToken(t, e) {
936
942
  let i, s;
937
943
  if (i = "", s = void 0, t[e] === "(")
938
- i = "(", s = u.LEFT_PARENTHESIS;
944
+ i = "(", s = l.LEFT_PARENTHESIS;
939
945
  else if (t[e] === ")")
940
- i = ")", s = u.RIGHT_PARENTHESIS;
946
+ i = ")", s = l.RIGHT_PARENTHESIS;
941
947
  else if (t[e] === ",")
942
- i = ",", s = u.FUNCTION_ARGUMENT;
948
+ i = ",", s = l.FUNCTION_ARGUMENT;
943
949
  else {
944
950
  for (const r of this.#s)
945
951
  if (t.substring(e, e + r.length) === r) {
946
952
  i += r, s = this.#i[r].type;
947
953
  break;
948
954
  }
949
- for (const r in tt)
955
+ for (const r in _)
950
956
  if (t.substring(e, e + r.length) === r) {
951
- i += r, s = u.CONSTANT;
957
+ i += r, s = l.CONSTANT;
952
958
  break;
953
959
  }
954
960
  if (i === "")
955
961
  if (/[0-9.]/.exec(t[e])) {
956
962
  const r = /^([0-9.]+)/.exec(t.substring(e));
957
- i = r ? r[0] : "", s = u.COEFFICIENT;
963
+ i = r ? r[0] : "", s = l.COEFFICIENT;
958
964
  } else if (/[a-zA-Z]/.exec(t[e])) {
959
965
  const r = /^([a-zA-Z])/.exec(t.substring(e));
960
- i = r ? r[0] : "", s = u.VARIABLE;
966
+ i = r ? r[0] : "", s = l.VARIABLE;
961
967
  } else
962
- console.log("Unidentified token", t[e], t, e), i = t[e], s = u.MONOM;
968
+ console.log("Unidentified token", t[e], t, e), i = t[e], s = l.MONOM;
963
969
  }
964
970
  if (s === void 0)
965
971
  throw new Error(`Token type is undefined for token ${i}`);
@@ -973,7 +979,7 @@ class G {
973
979
  */
974
980
  parse(t, e) {
975
981
  const i = [], s = [];
976
- let r = "", o = 0, h;
982
+ let r = "", o = 0, a;
977
983
  (e ?? this.#r) && (t = bt(t, this.#i));
978
984
  let c = 50, f;
979
985
  for (; o < t.length; ) {
@@ -981,17 +987,17 @@ class G {
981
987
  console.log("SECURITY LEVEL 1 EXIT");
982
988
  break;
983
989
  }
984
- switch ([r, o, h] = this.NextToken(t, o), h) {
985
- case u.MONOM:
986
- case u.COEFFICIENT:
987
- case u.VARIABLE:
988
- case u.CONSTANT:
990
+ switch ([r, o, a] = this.NextToken(t, o), a) {
991
+ case l.MONOM:
992
+ case l.COEFFICIENT:
993
+ case l.VARIABLE:
994
+ case l.CONSTANT:
989
995
  i.push({
990
996
  token: r,
991
- tokenType: h
997
+ tokenType: a
992
998
  });
993
999
  break;
994
- case u.OPERATION:
1000
+ case l.OPERATION:
995
1001
  if (s.length > 0) {
996
1002
  let m = s[s.length - 1];
997
1003
  for (f = 50; m.token in this.#i && //either o1 is left-associative and its precedence is less than or equal to that of o2,
@@ -1001,37 +1007,37 @@ class G {
1001
1007
  console.log("SECURITY LEVEL 2 OPERATION EXIT");
1002
1008
  break;
1003
1009
  }
1004
- if (i.push(s.pop() ?? { token: "", tokenType: u.OPERATION }), s.length === 0)
1010
+ if (i.push(s.pop() ?? { token: "", tokenType: l.OPERATION }), s.length === 0)
1005
1011
  break;
1006
1012
  m = s[s.length - 1];
1007
1013
  }
1008
1014
  }
1009
- s.push({ token: r, tokenType: h });
1015
+ s.push({ token: r, tokenType: a });
1010
1016
  break;
1011
- case u.FUNCTION_ARGUMENT:
1017
+ case l.FUNCTION_ARGUMENT:
1012
1018
  for (f = 50; s[s.length - 1].token !== "(" && s.length > 0; ) {
1013
1019
  if (f--, f === 0) {
1014
1020
  console.log("SECURITY LEVEL 2 FUNCTION ARGUMENT EXIT");
1015
1021
  break;
1016
1022
  }
1017
- i.push(s.pop() ?? { token: r, tokenType: h });
1023
+ i.push(s.pop() ?? { token: r, tokenType: a });
1018
1024
  }
1019
1025
  break;
1020
- case u.LEFT_PARENTHESIS:
1021
- s.push({ token: r, tokenType: h }), t[o] === "-" && i.push({ token: "0", tokenType: u.COEFFICIENT });
1026
+ case l.LEFT_PARENTHESIS:
1027
+ s.push({ token: r, tokenType: a }), t[o] === "-" && i.push({ token: "0", tokenType: l.COEFFICIENT });
1022
1028
  break;
1023
- case u.RIGHT_PARENTHESIS:
1029
+ case l.RIGHT_PARENTHESIS:
1024
1030
  for (f = 50; s[s.length - 1].token !== "(" && s.length > 1; ) {
1025
1031
  if (f--, f === 0) {
1026
1032
  console.log("SECURITY LEVEL 2 CLOSING PARENTHESIS EXIT");
1027
1033
  break;
1028
1034
  }
1029
- i.push(s.pop() ?? { token: r, tokenType: h });
1035
+ i.push(s.pop() ?? { token: r, tokenType: a });
1030
1036
  }
1031
1037
  s.pop();
1032
1038
  break;
1033
- case u.FUNCTION:
1034
- s.push({ token: r, tokenType: h });
1039
+ case l.FUNCTION:
1040
+ s.push({ token: r, tokenType: a });
1035
1041
  break;
1036
1042
  default:
1037
1043
  throw new Error(`Token type ${r} is not handled`);
@@ -1076,7 +1082,7 @@ class Ct {
1076
1082
  return this._isValid = !1, 0;
1077
1083
  this._isValid = !0;
1078
1084
  for (const i of this._rpn)
1079
- if (i.tokenType === u.COEFFICIENT)
1085
+ if (i.tokenType === l.COEFFICIENT)
1080
1086
  if (!isNaN(+i.token))
1081
1087
  e.push(+i.token);
1082
1088
  else {
@@ -1085,11 +1091,11 @@ class Ct {
1085
1091
  throw this._isValid = !1, new Error("This coefficient is not a fraction");
1086
1092
  e.push(+s[0] / +s[1]);
1087
1093
  }
1088
- else if (i.tokenType === u.VARIABLE && t !== void 0)
1094
+ else if (i.tokenType === l.VARIABLE && t !== void 0)
1089
1095
  Object.hasOwn(t, i.token) && e.push(+t[i.token]);
1090
- else if (i.tokenType === u.CONSTANT)
1091
- e.push(tt[i.token]);
1092
- else if (i.tokenType === u.OPERATION) {
1096
+ else if (i.tokenType === l.CONSTANT)
1097
+ e.push(_[i.token]);
1098
+ else if (i.tokenType === l.OPERATION) {
1093
1099
  if (i.token === "*") {
1094
1100
  const s = e.pop(), r = e.pop();
1095
1101
  if (r === void 0 || s === void 0)
@@ -1116,7 +1122,7 @@ class Ct {
1116
1122
  throw this._isValid = !1, new Error(`The base value ${r ?? "a"} or exponent ${s ?? "b"} are not defined`);
1117
1123
  e.push(Math.pow(r, s));
1118
1124
  }
1119
- } else if (i.tokenType === u.FUNCTION) {
1125
+ } else if (i.tokenType === l.FUNCTION) {
1120
1126
  const s = e.pop();
1121
1127
  if (s === void 0)
1122
1128
  throw this._isValid = !1, new Error(`The parameters for ${i.token} is not defined`);
@@ -1147,7 +1153,7 @@ class p {
1147
1153
  #t;
1148
1154
  #e;
1149
1155
  constructor(t) {
1150
- return this.#t = new a().zero(), this.#e = {}, t !== void 0 && this.parse(t), this;
1156
+ return this.#t = new h().zero(), this.#e = {}, t !== void 0 && this.parse(t), this;
1151
1157
  }
1152
1158
  // -----------------------------------------
1153
1159
  /**
@@ -1155,7 +1161,7 @@ class p {
1155
1161
  * @param inputStr
1156
1162
  */
1157
1163
  parse(t) {
1158
- return this.#t = new a(), this.#e = {}, t instanceof p ? (this.#t = t.#t.clone(), this.#i(t), this) : t instanceof a ? (this.#t = t.clone(), this) : typeof t == "number" ? (this.#t = new a(t), this) : (isNaN(Number(t)) ? this.#r(t) : this.#t = new a(Number(t)), this);
1164
+ return this.#t = new h(), this.#e = {}, t instanceof p ? (this.#t = t.#t.clone(), this.#i(t), this) : t instanceof h ? (this.#t = t.clone(), this) : typeof t == "number" ? (this.#t = new h(t), this) : (isNaN(Number(t)) ? this.#a(t) : this.#t = new h(Number(t)), this);
1159
1165
  }
1160
1166
  /**
1161
1167
  * Clone the current Monom.
@@ -1171,34 +1177,26 @@ class p {
1171
1177
  * Get the tex output of the monom
1172
1178
  */
1173
1179
  get tex() {
1174
- let t = "";
1175
- const e = Object.keys(this.#e).sort();
1176
- for (const i of e)
1177
- this.#e[i].isNotZero() && (t += i, this.#e[i].isNotEqual(1) && (t += `^{ ${this.#e[i].tfrac.tex} }`));
1178
- return t === "" ? this.#t.value != 0 ? this.#t.frac.tex : "0" : this.#t.value === 1 ? t : this.#t.value === -1 ? `-${t}` : this.#t.value === 0 ? "0" : `${this.#t.frac.tex}${t}`;
1180
+ return this.#r("tex");
1179
1181
  }
1180
1182
  // Display getter
1181
1183
  /**
1182
1184
  * This display getter is to be used in the polynom display getter
1183
1185
  */
1184
1186
  get display() {
1185
- let t = "";
1186
- const e = Object.keys(this.#e).sort();
1187
- for (const i of e)
1188
- this.#e[i].isNotZero() && (t += i, this.#e[i].isNotEqual(1) && (t += `^(${this.#e[i].display})`));
1189
- return t === "" ? this.#t.value != 0 ? this.#t.display : "" : this.#t.value === 1 ? t : this.#t.value === -1 ? `-${t}` : this.#t.value === 0 ? "0" : `${this.#t.display}${t}`;
1187
+ return this.#r("display");
1190
1188
  }
1191
1189
  static gcd = (...t) => {
1192
1190
  for (const r of t)
1193
1191
  if (r.containsRationalPower())
1194
1192
  return new p().zero();
1195
1193
  const e = new p(), i = x.gcd(...t.map((r) => r.coefficient.numerator)), s = x.lcm(...t.map((r) => r.coefficient.denominator));
1196
- e.coefficient = new a(i, s).reduce();
1194
+ e.coefficient = new h(i, s).reduce();
1197
1195
  for (const r of t) {
1198
1196
  for (const o in e.literal)
1199
- o in r.literal || e.literal[o].zero();
1197
+ o in r.literal || e.removeVariable(o);
1200
1198
  for (const o in r.literal)
1201
- !e.hasVariable(o) && r.literal[o].isStrictlyPositive() ? e.literal[o] = r.literal[o].clone() : e.literal[o] = new a(Math.min(r.literal[o].value, e.literal[o].value));
1199
+ !e.hasVariable(o) && r.literal[o].isStrictlyPositive() ? e.literal[o] = r.literal[o].clone() : e.literal[o] = new h(Math.min(r.literal[o].value, e.literal[o].value));
1202
1200
  }
1203
1201
  return e;
1204
1202
  };
@@ -1219,7 +1217,10 @@ class p {
1219
1217
  add = (...t) => {
1220
1218
  for (const e of t) {
1221
1219
  const i = e instanceof p ? e : new p(e);
1222
- this.isSameAs(i) ? (this.isZero() && this.#i(i), this.#t.add(i.coefficient)) : console.log("Add monom: " + this.display + " is not similar with ", i.display);
1220
+ if (this.isSameAs(i))
1221
+ this.isZero() && this.#i(i), this.#t.add(i.coefficient);
1222
+ else
1223
+ throw new Error("Add monom: " + this.display + " is not similar with " + i.display);
1223
1224
  }
1224
1225
  return this;
1225
1226
  };
@@ -1235,14 +1236,14 @@ class p {
1235
1236
  * @param {Fraction | number | string} F
1236
1237
  */
1237
1238
  set coefficient(t) {
1238
- this.#t = new a(t);
1239
+ this.#t = new h(t);
1239
1240
  }
1240
1241
  containsRationalPower = () => Object.values(this.#e).some((t) => t.isRational());
1241
1242
  /**
1242
1243
  * Get the degree of a monom. If no setLetter is given, the result will be the global degree.
1243
1244
  * @param letter (string) Letter to get to degree (power)
1244
1245
  */
1245
- degree = (t) => this.variables.length === 0 ? new a().zero() : t === void 0 ? Object.values(this.#e).reduce((e, i) => e.clone().add(i)) : this.hasVariable(t) ? this.#e[t].clone() : new a().zero();
1246
+ degree = (t) => this.variables.length === 0 ? new h().zero() : t === void 0 ? Object.values(this.#e).reduce((e, i) => e.clone().add(i)) : this.hasVariable(t) ? this.#e[t].clone() : new h().zero();
1246
1247
  /**
1247
1248
  * Derivative the monom
1248
1249
  * @param letter
@@ -1250,7 +1251,7 @@ class p {
1250
1251
  derivative = (t = "x") => {
1251
1252
  if (this.hasVariable(t)) {
1252
1253
  const e = this.#e[t].clone(), i = this.clone();
1253
- return i.#e[t].subtract(1), i.#t.multiply(new a(e.clone())), i;
1254
+ return i.#e[t].subtract(1), i.#t.multiply(new h(e.clone())), i;
1254
1255
  } else
1255
1256
  return new p().zero();
1256
1257
  };
@@ -1277,23 +1278,23 @@ class p {
1277
1278
  const t = x.dividers(Math.abs(this.coefficient.numerator));
1278
1279
  let e = [];
1279
1280
  for (const s in this.literal)
1280
- e = this._getLiteralDividers(e, s);
1281
+ e = this.#n(e, s);
1281
1282
  const i = [];
1282
1283
  if (e.length > 0 && t.length > 0)
1283
1284
  for (const s of t)
1284
1285
  for (const r of e) {
1285
1286
  const o = new p();
1286
- o.coefficient = new a(s), o.literal = r, i.push(o);
1287
+ o.coefficient = new h(s), o.literal = r, i.push(o);
1287
1288
  }
1288
1289
  else if (t.length === 0)
1289
1290
  for (const s of e) {
1290
1291
  const r = new p();
1291
- r.coefficient = new a().one(), r.literal = s, i.push(r);
1292
+ r.coefficient = new h().one(), r.literal = s, i.push(r);
1292
1293
  }
1293
1294
  else
1294
1295
  for (const s of t) {
1295
1296
  const r = new p();
1296
- r.coefficient = new a(s), i.push(r);
1297
+ r.coefficient = new h(s), i.push(r);
1297
1298
  }
1298
1299
  return i.length === 0 ? [new p().one()] : i;
1299
1300
  }
@@ -1304,27 +1305,27 @@ class p {
1304
1305
  */
1305
1306
  evaluate = (t, e) => {
1306
1307
  if (e === !0) {
1307
- if (t instanceof a)
1308
+ if (t instanceof h)
1308
1309
  return this.#s(t.value);
1309
1310
  if (typeof t == "number")
1310
1311
  return this.#s(t);
1311
1312
  if (typeof t == "object") {
1312
1313
  const s = {};
1313
1314
  for (const r in t)
1314
- s[r] = new a(t[r]).value;
1315
+ s[r] = new h(t[r]).value;
1315
1316
  return this.#s(s);
1316
1317
  }
1317
1318
  }
1318
1319
  const i = this.coefficient.clone();
1319
- if (typeof t == "number" || t instanceof a) {
1320
+ if (typeof t == "number" || t instanceof h) {
1320
1321
  const s = {};
1321
- return s[this.variables[0]] = new a(t), this.evaluate(s);
1322
+ return s[this.variables[0]] = new h(t), this.evaluate(s);
1322
1323
  }
1323
1324
  if (typeof t == "object") {
1324
1325
  if (this.variables.length === 0)
1325
1326
  return this.coefficient;
1326
1327
  for (const s in this.#e) {
1327
- const r = new a(t[s]);
1328
+ const r = new h(t[s]);
1328
1329
  i.multiply(r.pow(this.#e[s]));
1329
1330
  }
1330
1331
  }
@@ -1338,10 +1339,10 @@ class p {
1338
1339
  hasVariable = (t) => Object.hasOwn(this.#e, t ?? "x");
1339
1340
  integrate(t, e, i) {
1340
1341
  const s = this.primitive(i);
1341
- return s.evaluate(e).subtract(s.evaluate(t));
1342
+ return s.evaluate(e, !1).subtract(s.evaluate(t, !1));
1342
1343
  }
1343
1344
  inverse = () => {
1344
- this.#t.opposite();
1345
+ this.#t.inverse();
1345
1346
  for (const t in this.#e)
1346
1347
  this.#e[t].opposite();
1347
1348
  return this;
@@ -1361,7 +1362,7 @@ class p {
1361
1362
  isEqual = (t) => this.isSameAs(t) && this.#t.isEqual(t.coefficient);
1362
1363
  isLiteralSquare = () => {
1363
1364
  for (const t in this.literal)
1364
- if (this.literal[t].isRational() || this.literal[t].isEven())
1365
+ if (this.literal[t].isRational() || this.literal[t].isOdd())
1365
1366
  return !1;
1366
1367
  return !0;
1367
1368
  };
@@ -1411,9 +1412,9 @@ class p {
1411
1412
  */
1412
1413
  set literalStr(t) {
1413
1414
  for (const e of [...t.matchAll(/([a-z])\^([+-]?[0-9]+)/g)])
1414
- e[1] in this.#e || (this.#e[e[1]] = new a().zero()), this.#e[e[1]].add(+e[2]);
1415
+ e[1] in this.#e || (this.#e[e[1]] = new h().zero()), this.#e[e[1]].add(+e[2]);
1415
1416
  for (const e of [...t.matchAll(/([a-z](?!\^))/g)])
1416
- e[1] in this.#e || (this.#e[e[1]] = new a().zero()), this.#e[e[1]].add(1);
1417
+ e[1] in this.#e || (this.#e[e[1]] = new h().zero()), this.#e[e[1]].add(1);
1417
1418
  }
1418
1419
  /**
1419
1420
  * Multiple multiple monoms to the current monom
@@ -1431,18 +1432,14 @@ class p {
1431
1432
  /**
1432
1433
  * Create a one value monom
1433
1434
  */
1434
- one = () => (this.#t = new a().one(), this.#e = {}, this);
1435
+ one = () => (this.#t = new h().one(), this.#e = {}, this);
1435
1436
  /**
1436
1437
  * Get the opposite
1437
1438
  * Returns a monom.
1438
1439
  */
1439
1440
  opposite = () => (this.#t.opposite(), this);
1440
1441
  get plotFunction() {
1441
- let t = "";
1442
- const e = Object.keys(this.#e).sort();
1443
- for (const i of e)
1444
- this.#e[i].isNotZero() && (t += (t === "" ? "" : "*") + i, this.#e[i].isNotEqual(1) && (t += `^(${this.#e[i].display})`));
1445
- return t === "" ? this.#t.value != 0 ? this.#t.display : "" : this.#t.value === 1 ? t : this.#t.value === -1 ? `-${t}` : this.#t.value === 0 ? "0" : `${this.#t.display}*${t}`;
1442
+ return this.#r("plot");
1446
1443
  }
1447
1444
  /**
1448
1445
  * Get the pow of a monom.
@@ -1457,7 +1454,7 @@ class p {
1457
1454
  primitive = (t = "x") => {
1458
1455
  const e = this.clone();
1459
1456
  let i;
1460
- return e.hasVariable(t) ? (i = e.degree(t).clone().add(1), e.coefficient = e.coefficient.clone().divide(i), e.setLetter(t, i)) : (e.coefficient.isZero() && (e.coefficient = new a().one()), e.setLetter(t, 1)), e;
1457
+ return e.hasVariable(t) ? (i = e.degree(t).clone().add(1), e.coefficient = e.coefficient.clone().divide(i), e.setLetter(t, i)) : (e.coefficient.isZero() && (e.coefficient = new h().one()), e.setLetter(t, 1)), e;
1461
1458
  };
1462
1459
  reduce = () => {
1463
1460
  this.coefficient.reduce();
@@ -1470,6 +1467,7 @@ class p {
1470
1467
  }
1471
1468
  /**
1472
1469
  * Get the nth-root of the monom
1470
+ * @todo Not yet implemented
1473
1471
  */
1474
1472
  root = () => {
1475
1473
  throw new Error("Method not implemented.");
@@ -1479,7 +1477,7 @@ class p {
1479
1477
  * @param letter (string) Letter to change
1480
1478
  * @param pow (number) Power of the setLetter (must be positive integer.
1481
1479
  */
1482
- setLetter = (t, e) => e instanceof a ? (this.hasVariable(t) && e.isZero() && this.removeVariable(t), this.#e[t] = e.clone(), this) : this.setLetter(t, new a(e));
1480
+ setLetter = (t, e) => e instanceof h ? this.hasVariable(t) && e.isZero() ? (this.removeVariable(t), this) : (this.#e[t] = e.clone(), this) : this.setLetter(t, new h(e));
1483
1481
  /**
1484
1482
  * Return the square root of a monom
1485
1483
  */
@@ -1487,7 +1485,7 @@ class p {
1487
1485
  if (this.isSquare()) {
1488
1486
  this.#t.sqrt();
1489
1487
  for (const t in this.#e)
1490
- this.#e[t].clone().divide(2);
1488
+ this.#e[t].divide(2);
1491
1489
  }
1492
1490
  return this;
1493
1491
  };
@@ -1498,7 +1496,10 @@ class p {
1498
1496
  subtract = (...t) => {
1499
1497
  for (const e of t) {
1500
1498
  const i = e instanceof p ? e : new p(e);
1501
- this.isSameAs(i) ? (this.isZero() && this.#i(i), this.#t.add(i.clone().coefficient.opposite())) : console.log("Subtract: Is not similar: ", i.display);
1499
+ if (this.isSameAs(i))
1500
+ this.isZero() && this.#i(i), this.#t.add(i.clone().coefficient.opposite());
1501
+ else
1502
+ throw new Error("Subtract: Is not similar: " + i.display);
1502
1503
  }
1503
1504
  return this;
1504
1505
  };
@@ -1517,7 +1518,7 @@ class p {
1517
1518
  /**
1518
1519
  * Create a zero value monom
1519
1520
  */
1520
- zero = () => (this.#t = new a().zero(), this.#e = {}, this);
1521
+ zero = () => (this.#t = new h().zero(), this.#e = {}, this);
1521
1522
  #i(t) {
1522
1523
  for (const e in t.literal)
1523
1524
  this.#e[e] = t.literal[e].clone();
@@ -1528,40 +1529,51 @@ class p {
1528
1529
  const i = {}, s = this.variables[0];
1529
1530
  return i[s] = t, this.#s(i);
1530
1531
  }
1531
- if (t instanceof a) {
1532
+ if (t instanceof h) {
1532
1533
  const i = {};
1533
- return i[this.variables[0]] = new a(t).value, this.#s(i);
1534
+ return i[this.variables[0]] = new h(t).value, this.#s(i);
1534
1535
  }
1535
1536
  if (typeof t == "object") {
1536
1537
  if (this.variables.length === 0)
1537
1538
  return this.coefficient.value;
1538
1539
  for (const i in this.#e) {
1539
1540
  const s = t[i];
1540
- s instanceof a ? e *= s.value ** this.#e[i].value : e *= s ** this.#e[i].value;
1541
+ s instanceof h ? e *= s.value ** this.#e[i].value : e *= s ** this.#e[i].value;
1541
1542
  }
1542
1543
  }
1543
1544
  return e;
1544
1545
  };
1545
1546
  #r = (t) => {
1546
- const i = new G().parse(t).rpn, s = [];
1547
- if (i.length === 0)
1548
- return this.zero(), this;
1549
- if (i.length === 1) {
1550
- const r = i[0];
1551
- return this.one(), r.tokenType === u.COEFFICIENT ? this.coefficient = new a(r.token) : r.tokenType === u.VARIABLE && this.setLetter(r.token, 1), this;
1552
- } else
1553
- for (const r of i)
1554
- this.#n(s, r);
1555
- return this.one(), this.multiply(s[0]), this;
1547
+ let e = "";
1548
+ const i = Object.keys(this.#e).sort();
1549
+ for (const r of i)
1550
+ this.#e[r].isNotZero() && (t === "plot" && e !== "" && (e += "*"), e += r, this.#e[r].isNotEqual(1) && (e += t === "tex" ? `^{ ${this.#e[r].tfrac.tex} }` : `^(${this.#e[r].display})`));
1551
+ const s = t === "tex" ? this.#t.frac.tex : this.#t.display;
1552
+ return e === "" ? this.#t.value !== 0 ? s : "0" : this.#t.value === 1 ? e : this.#t.value === -1 ? `-${e}` : this.#t.value === 0 ? "0" : t === "plot" ? `${s}*${e}` : `${s}${e}`;
1556
1553
  };
1557
- #n = (t, e) => {
1558
- let i, s, r, o, h;
1559
- if (e.tokenType === u.COEFFICIENT)
1560
- t.push(new p(new a(e.token)));
1561
- else if (e.tokenType === u.VARIABLE) {
1554
+ #n(t, e) {
1555
+ const i = [];
1556
+ for (let s = 0; s <= this.literal[e].value; s++)
1557
+ if (t.length === 0) {
1558
+ const r = {};
1559
+ r[e] = new h(s), i.push(r);
1560
+ } else
1561
+ for (const r of t) {
1562
+ const o = {};
1563
+ for (const a in r)
1564
+ o[a] = r[a];
1565
+ o[e] = new h(s), i.push(o);
1566
+ }
1567
+ return i;
1568
+ }
1569
+ #o = (t, e) => {
1570
+ let i, s, r, o, a;
1571
+ if (e.tokenType === l.COEFFICIENT)
1572
+ t.push(new p(new h(e.token)));
1573
+ else if (e.tokenType === l.VARIABLE) {
1562
1574
  const c = new p().one();
1563
1575
  c.setLetter(e.token, 1), t.push(c.clone());
1564
- } else if (e.tokenType === u.OPERATION)
1576
+ } else if (e.tokenType === l.OPERATION)
1565
1577
  switch (e.token) {
1566
1578
  case "-":
1567
1579
  s = t.pop() ?? new p().zero(), i = t.pop() ?? new p().zero(), t.push(i.subtract(s));
@@ -1573,28 +1585,25 @@ class p {
1573
1585
  s = t.pop() ?? new p().one(), i = t.pop() ?? new p().one(), t.push(i.divide(s));
1574
1586
  break;
1575
1587
  case "^": {
1576
- h = t.pop()?.coefficient ?? new a().one(), r = t.pop() ?? new p().one(), o = r.variables[0], o && r.setLetter(o, h), t.push(r);
1588
+ a = t.pop()?.coefficient ?? new h().one(), r = t.pop() ?? new p().one(), o = r.variables[0], o && r.setLetter(o, a), t.push(r);
1577
1589
  break;
1578
1590
  }
1579
1591
  }
1580
1592
  };
1581
- _getLiteralDividers(t, e) {
1582
- const i = [];
1583
- for (let s = 0; s <= this.literal[e].value; s++)
1584
- if (t.length === 0) {
1585
- const r = {};
1586
- r[e] = new a(s), i.push(r);
1587
- } else
1588
- for (const r of t) {
1589
- const o = {};
1590
- for (const h in r)
1591
- o[h] = r[h];
1592
- o[e] = new a(s), i.push(o);
1593
- }
1594
- return i;
1595
- }
1593
+ #a = (t) => {
1594
+ const i = new G().parse(t).rpn, s = [];
1595
+ if (i.length === 0)
1596
+ return this.zero(), this;
1597
+ if (i.length === 1) {
1598
+ const r = i[0];
1599
+ return this.one(), r.tokenType === l.COEFFICIENT ? this.coefficient = new h(r.token) : r.tokenType === l.VARIABLE && this.setLetter(r.token, 1), this;
1600
+ } else
1601
+ for (const r of i)
1602
+ this.#o(s, r);
1603
+ return this.one(), this.multiply(s[0]), this;
1604
+ };
1596
1605
  }
1597
- function nt(n, t) {
1606
+ function rt(n, t) {
1598
1607
  if (!Number.isSafeInteger(t))
1599
1608
  throw new Error("Can only raise item by an integer");
1600
1609
  if (t < 0)
@@ -1606,7 +1615,7 @@ function nt(n, t) {
1606
1615
  n.multiply(e);
1607
1616
  return n;
1608
1617
  }
1609
- class l {
1618
+ class u {
1610
1619
  #t = "x";
1611
1620
  #e;
1612
1621
  #i;
@@ -1620,29 +1629,30 @@ class l {
1620
1629
  * @param inputStr
1621
1630
  * @param values
1622
1631
  */
1623
- parse = (t, ...e) => {
1624
- if (this.#i = [], this.#e = [], typeof t == "string")
1632
+ parse(t, ...e) {
1633
+ if (this.#i = [], this.#e = [], this.#h(), typeof t == "string")
1625
1634
  return this.#m(t, ...e);
1626
- if ((typeof t == "number" || t instanceof a || t instanceof p) && e.length === 0)
1635
+ if ((typeof t == "number" || t instanceof h || t instanceof p) && e.length === 0)
1627
1636
  this.#i.push(new p(t));
1628
1637
  else if (t instanceof p && e.length > 0)
1629
1638
  this.#i.push(new p(t)), e.forEach((i) => {
1630
1639
  this.#i.push(new p(i));
1631
1640
  });
1632
- else if (t instanceof l)
1641
+ else if (t instanceof u)
1633
1642
  for (const i of t.monoms)
1634
1643
  this.#i.push(i.clone());
1635
1644
  return this;
1636
- };
1645
+ }
1637
1646
  /**
1638
1647
  * Clone the polynom
1639
1648
  */
1640
- clone = () => {
1641
- const t = new l(), e = [];
1649
+ clone() {
1650
+ const t = new u(), e = [];
1651
+ t.#t = this.#t;
1642
1652
  for (const i of this.#i)
1643
1653
  e.push(i.clone());
1644
1654
  return t.monoms = e, t;
1645
- };
1655
+ }
1646
1656
  get tex() {
1647
1657
  return this.#l("tex");
1648
1658
  }
@@ -1650,105 +1660,109 @@ class l {
1650
1660
  return this.#l();
1651
1661
  }
1652
1662
  static xMultiply(...t) {
1653
- const e = new l().one();
1663
+ const e = new u().one();
1654
1664
  return t.forEach((i) => {
1655
1665
  e.multiply(i);
1656
1666
  }), e;
1657
1667
  }
1658
- add = (...t) => {
1668
+ add(...t) {
1659
1669
  for (const e of t)
1660
- e instanceof l ? this.#i = this.#i.concat(e.monoms) : e instanceof p ? this.#i.push(e.clone()) : typeof e == "number" && Number.isSafeInteger(e) ? this.#i.push(new p(e.toString())) : this.#i.push(new p(e));
1670
+ e instanceof u ? this.#i = this.#i.concat(e.monoms.map((i) => i.clone())) : e instanceof p ? this.#i.push(e.clone()) : typeof e == "number" && Number.isSafeInteger(e) ? this.#i.push(new p(e.toString())) : this.#i.push(new p(e));
1661
1671
  return this.reduce();
1662
- };
1663
- commonMonom = () => {
1664
- const t = new p().one(), e = this.gcdNumerator(), i = this.gcdDenominator(), s = this.degree();
1665
- t.coefficient = new a(e, i);
1666
- for (const r of this.variables) {
1667
- t.setLetter(r, s);
1668
- for (const o of this.#i)
1669
- if (t.setLetter(r, a.min(o.degree(r), t.degree(r))), t.degree(r).isZero())
1672
+ }
1673
+ commonMonom() {
1674
+ const t = new p().one(), e = this.gcdNumerator(), i = this.gcdDenominator();
1675
+ t.coefficient = new h(e, i);
1676
+ for (const s of this.variables) {
1677
+ t.setLetter(s, this.degree(s));
1678
+ for (const r of this.#i)
1679
+ if (t.setLetter(s, h.min(r.degree(s), t.degree(s))), t.degree(s).isZero())
1670
1680
  break;
1671
1681
  }
1672
1682
  return t;
1673
- };
1674
- degree = (t) => {
1675
- let e = new a().zero();
1683
+ }
1684
+ degree(t) {
1685
+ let e = new h().zero();
1676
1686
  for (const i of this.#i)
1677
- e = a.max(i.degree(t).value, e);
1687
+ e = h.max(i.degree(t).value, e);
1678
1688
  return e;
1679
- };
1680
- derivative = (t) => {
1681
- const e = new l();
1689
+ }
1690
+ derivative(t) {
1691
+ const e = new u();
1682
1692
  for (const i of this.#i)
1683
1693
  e.add(i.derivative(t));
1684
1694
  return e.reduce();
1685
- };
1686
- divide = (t) => {
1687
- if (t instanceof a)
1695
+ }
1696
+ divide(t) {
1697
+ if (t instanceof h)
1688
1698
  return this.#o(t);
1689
1699
  if (typeof t == "number" && Number.isSafeInteger(t))
1690
- return this.#h(t);
1700
+ return this.#a(t);
1691
1701
  if (t instanceof p)
1692
- return this.divide(new l(t));
1693
- if (t instanceof l) {
1702
+ return this.divide(new u(t));
1703
+ if (t instanceof u) {
1694
1704
  if (t.monoms.length === 1 && t.variables.length === 0)
1695
1705
  return this.#o(t.monoms[0].coefficient);
1696
1706
  {
1697
1707
  const { quotient: e, reminder: i } = this.euclidean(t);
1698
1708
  if (i.isZero())
1699
- return this.#i = e.monoms, this;
1709
+ return this.#i = e.monoms, this.#h(), this;
1700
1710
  }
1701
1711
  } else if (typeof t == "string")
1702
- return this.divide(new l(t));
1712
+ return this.divide(new u(t));
1703
1713
  throw new Error(`Cannot divide by ${t}`);
1704
- };
1705
- empty = () => (this.#i = [], this);
1714
+ }
1715
+ empty() {
1716
+ return this.#i = [], this.#h(), this;
1717
+ }
1706
1718
  /**
1707
1719
  * Divide the current polynom by another polynom.
1708
1720
  * @param P
1709
1721
  * returns {quotient: Polynom, reminder: Polynom}
1710
1722
  */
1711
- euclidean = (t) => {
1712
- const e = t.variables[0], i = new l().zero(), s = this.clone().reorder(e);
1723
+ euclidean(t) {
1724
+ const e = t.variables[0], i = new u().zero(), s = this.clone().reorder(e);
1713
1725
  if (t.variables.length === 0)
1714
1726
  return {
1715
1727
  quotient: this.clone().divide(t).reduce(),
1716
- reminder: new l().zero()
1728
+ reminder: new u().zero()
1717
1729
  };
1730
+ if (!this.degree(e).isNatural() || !t.degree(e).isNatural())
1731
+ throw new Error("Euclidean division requires integer degrees");
1718
1732
  const r = t.monomByDegree(void 0, e), o = t.degree(e);
1719
- let h, c = this.degree(e).value * 2;
1720
- for (; s.degree(e).isGeq(o) && c > 0 && (c--, h = s.monomByDegree(void 0, e).clone().divide(r), !(!h.isZero() && (i.add(h), s.subtract(t.clone().multiply(h)).reduce(), h.degree(e).isZero()))); )
1733
+ let a, c = this.degree(e).value - o.value + 1;
1734
+ for (; s.degree(e).isGeq(o) && c > 0 && (c--, a = s.monomByDegree(void 0, e).clone().divide(r), !(!a.isZero() && (i.add(a), s.subtract(t.clone().multiply(a)).reduce(), a.degree(e).isZero()))); )
1721
1735
  ;
1722
1736
  return i.reduce(), s.reduce(), { quotient: i, reminder: s };
1723
- };
1724
- evaluate = (t, e) => {
1737
+ }
1738
+ evaluate(t, e) {
1725
1739
  if (e)
1726
- return this.#a(t);
1727
- const i = new a().zero();
1740
+ return this.#c(t);
1741
+ const i = new h().zero();
1728
1742
  return this.#i.forEach((s) => {
1729
1743
  i.add(s.evaluate(t, e));
1730
1744
  }), i;
1731
- };
1745
+ }
1732
1746
  // -------------------------------------
1733
1747
  /**
1734
1748
  * Factorize a polynom and store the best results in factors.
1735
- * @param letter
1749
+ * @param _letter
1736
1750
  * TODO: Handle other letter than 'x'.
1737
1751
  */
1738
1752
  factorize(t) {
1739
1753
  this.#e = [];
1740
1754
  let e = this.clone().reorder();
1741
1755
  const i = e.commonMonom();
1742
- e.monomByDegree().coefficient.isStrictlyNegative() && i.opposite(), i.isOne() || (this.#e.push(new l(i)), e = e.euclidean(this.#e[0]).quotient);
1756
+ e.monomByDegree().coefficient.isStrictlyNegative() && i.opposite(), i.isOne() || (this.#e.push(new u(i)), e = e.euclidean(this.#e[0]).quotient);
1743
1757
  const s = new R(e).solve();
1744
1758
  if (s.length === 0)
1745
- return this.#e = [this.clone()], this.#e;
1759
+ return this.#e.length === 0 ? this.#e = [this.clone()] : this.#e.push(e), this.#e;
1746
1760
  if (s.forEach((o) => {
1747
1761
  if (o.exact && o.root.isZero())
1748
- for (let h = 0; h < o.count; h++)
1749
- o.fraction.isRational() ? this.#e.push(new l().fromCoefficients(o.fraction.denominator, -o.fraction.numerator)) : this.#e.push(new l().fromCoefficients(1, o.fraction.clone().opposite()));
1750
- }), this.#e.map((o) => o.degree().value).reduce((o, h) => o + h, 0) < this.degree().value) {
1751
- const o = l.xMultiply(...this.#e);
1762
+ for (let a = 0; a < o.count; a++)
1763
+ o.fraction.isRational() ? this.#e.push(new u().fromCoefficients(o.fraction.denominator, -o.fraction.numerator)) : this.#e.push(new u().fromCoefficients(1, o.fraction.clone().opposite()));
1764
+ }), this.#e.map((o) => o.degree().value).reduce((o, a) => o + a, 0) < this.degree().value) {
1765
+ const o = u.xMultiply(...this.#e);
1752
1766
  this.#e.push(this.clone().divide(o));
1753
1767
  }
1754
1768
  return this.#e;
@@ -1761,54 +1775,62 @@ class l {
1761
1775
  const e = this.#t ?? "x";
1762
1776
  return t.reverse().forEach((i, s) => {
1763
1777
  const r = new p();
1764
- r.coefficient = new a(i), r.setLetter(e, s), this.#i.push(r);
1765
- }), this.reorder();
1778
+ r.coefficient = new h(i), r.setLetter(e, s), this.#i.push(r);
1779
+ }), this.#h(), this.reorder();
1780
+ }
1781
+ gcdDenominator() {
1782
+ return x.gcd(...this.getDenominators());
1783
+ }
1784
+ gcdNumerator() {
1785
+ return x.gcd(...this.getNumerators());
1766
1786
  }
1767
- gcdDenominator = () => x.gcd(...this.getDenominators());
1768
- gcdNumerator = () => x.gcd(...this.getNumerators());
1769
1787
  getCoefficients() {
1770
- const t = this.clone().reorder(), e = this.degree().value + 1, i = new Array(e).fill(new a(0));
1788
+ if (!this.degree().isNatural())
1789
+ throw new Error("getCoefficients() requires a polynomial with integer degrees");
1790
+ const t = this.clone().reorder(), e = this.degree().value + 1, i = Array.from({ length: e }, () => new h(0));
1771
1791
  return t.monoms.forEach((s) => {
1772
1792
  const r = e - s.degree().value - 1;
1773
1793
  i[r] = s.coefficient.clone();
1774
1794
  }), i;
1775
1795
  }
1776
1796
  // Next functions are used for for commonMonom, which is used in the factorize method.
1777
- getDenominators = () => {
1797
+ getDenominators() {
1778
1798
  const t = [];
1779
1799
  for (const e of this.#i)
1780
1800
  t.push(e.coefficient.denominator);
1781
1801
  return t;
1782
- };
1783
- getNumerators = () => {
1802
+ }
1803
+ getNumerators() {
1784
1804
  const t = [];
1785
1805
  for (const e of this.#i)
1786
1806
  t.push(e.coefficient.numerator);
1787
1807
  return t;
1788
- };
1789
- getZeroes = () => this.degree().isZero() ? [] : (this.roots = new R(this.clone()).solve(), this.roots);
1808
+ }
1809
+ getZeroes() {
1810
+ return this.degree().isZero() ? [] : (this.roots = new R(this.clone()).solve(), this.roots);
1811
+ }
1790
1812
  hasVariable(t) {
1791
1813
  return this.variables.includes(t);
1792
1814
  }
1793
- integrate = (t, e, i = "x") => {
1815
+ integrate(t, e, i = "x") {
1794
1816
  const s = this.primitive(i), r = {}, o = {};
1795
- return r[i] = new a(t), o[i] = new a(e), s.evaluate(o).subtract(s.evaluate(r));
1796
- };
1817
+ return r[i] = new h(t), o[i] = new h(e), s.evaluate(o).subtract(s.evaluate(r));
1818
+ }
1797
1819
  inverse() {
1798
1820
  }
1799
- isDeveloped = (t) => {
1821
+ isDeveloped(t) {
1800
1822
  let e;
1801
1823
  const i = t.replaceAll(/\^\(([-0-9/]+)\)/g, "$1");
1802
1824
  if (i.includes("(") || i.includes(")"))
1803
1825
  return !1;
1804
1826
  try {
1805
- e = new l(t);
1827
+ e = new u(t);
1806
1828
  } catch {
1807
1829
  return !1;
1808
1830
  }
1809
1831
  return !!this.isEqual(e);
1810
- };
1811
- isDividableBy = (t) => {
1832
+ }
1833
+ isDividableBy(t) {
1812
1834
  if (t.degree().isOne()) {
1813
1835
  const e = t.getZeroes()[0];
1814
1836
  return e.exact ? this.evaluate(e.fraction).isZero() : !1;
@@ -1816,39 +1838,44 @@ class l {
1816
1838
  const { reminder: e } = this.euclidean(t);
1817
1839
  return e.isZero();
1818
1840
  }
1819
- };
1820
- isEqual = (t) => this.#n(t, "=");
1841
+ }
1842
+ isEqual(t) {
1843
+ return this.#n(t, "=");
1844
+ }
1821
1845
  get isMultiVariable() {
1822
1846
  return this.#i.some((t) => t.variables.length > 1);
1823
1847
  }
1824
1848
  isOne() {
1825
1849
  return this.#i.length === 1 && this.#i[0].coefficient.isOne() && this.degree().isZero();
1826
1850
  }
1827
- isOppositeAt = (t) => this.#n(t.clone().opposite(), "=");
1828
- isSameAs = (t) => this.#n(t, "same");
1851
+ isOppositeAt(t) {
1852
+ return this.#n(t.clone().opposite(), "=");
1853
+ }
1854
+ isSameAs(t) {
1855
+ return this.#n(t, "same");
1856
+ }
1829
1857
  isZero() {
1830
1858
  return this.#i.length === 1 && this.#i[0].coefficient.isZero() || this.#i.length === 0;
1831
1859
  }
1832
- lcmDenominator = () => x.lcm(...this.getDenominators());
1833
- lcmNumerator = () => x.lcm(...this.getNumerators());
1860
+ lcmDenominator() {
1861
+ return x.lcm(...this.getDenominators());
1862
+ }
1863
+ lcmNumerator() {
1864
+ return x.lcm(...this.getNumerators());
1865
+ }
1834
1866
  get length() {
1835
1867
  return this.#i.length;
1836
1868
  }
1837
- letters = () => {
1838
- let t = /* @__PURE__ */ new Set();
1839
- for (const e of this.#i)
1840
- t = /* @__PURE__ */ new Set([...t, ...e.variables]);
1841
- return [...t];
1842
- };
1843
- limitToInfinity = (t) => {
1844
- const e = this.monomByDegree(void 0, t), i = e.coefficient.sign(), s = e.degree(t);
1845
- return s.isStrictlyPositive() ? i === 1 ? new a().infinite() : new a().infinite().opposite() : s.isZero() ? e.coefficient : new a().zero();
1846
- };
1847
- limitToNegativeInfinity = (t) => {
1848
- const e = this.monomByDegree(void 0, t), i = e.coefficient.sign(), s = e.degree(t);
1849
- return s.isStrictlyPositive() ? i === -1 ? new a().infinite() : new a().infinite().opposite() : s.isZero() ? e.coefficient : new a().zero();
1850
- };
1851
- monomByDegree = (t, e) => {
1869
+ limitTo(t, e) {
1870
+ const i = new h(t);
1871
+ if (i.isFinite()) {
1872
+ const f = e ?? this.variables[0] ?? "x";
1873
+ return this.evaluate({ [f]: i });
1874
+ }
1875
+ const s = this.monomByDegree(void 0, e), r = s.coefficient.sign(), o = s.degree(e);
1876
+ return o.isZero() ? s.coefficient.clone() : o.isStrictlyPositive() ? i.isPositive() ? r === 1 ? new h().infinite() : new h().infinite().opposite() : (o.value % 2 === 0 ? r : -r) === 1 ? new h().infinite() : new h().infinite().opposite() : new h().zero();
1877
+ }
1878
+ monomByDegree(t, e) {
1852
1879
  if (t === void 0)
1853
1880
  return this.monomByDegree(this.degree(e), e);
1854
1881
  const i = this.clone().reduce();
@@ -1856,34 +1883,34 @@ class l {
1856
1883
  if (s.degree(e).isEqual(t))
1857
1884
  return s.clone();
1858
1885
  return new p().zero();
1859
- };
1886
+ }
1860
1887
  // Used in LinearSystem.tex
1861
- monomByLetter = (t) => {
1888
+ monomByLetter(t) {
1862
1889
  const e = this.clone().reduce();
1863
1890
  for (const i of e.#i)
1864
1891
  if (i.hasVariable(t))
1865
1892
  return i.clone();
1866
1893
  return new p().zero();
1867
- };
1894
+ }
1868
1895
  // ------------------------------------------
1869
1896
  get monoms() {
1870
1897
  return this.#i;
1871
1898
  }
1872
1899
  set monoms(t) {
1873
- this.#i = t;
1900
+ this.#i = t, this.#h();
1874
1901
  }
1875
- monomsByDegree = (t, e) => {
1902
+ monomsByDegree(t, e) {
1876
1903
  if (t === void 0)
1877
- return this.monomsByDegree(this.degree(e));
1904
+ return this.monomsByDegree(this.degree(e), e);
1878
1905
  const i = [], s = this.clone().reduce();
1879
1906
  for (const r of s.#i)
1880
1907
  r.degree(e).isEqual(t) && i.push(r.clone());
1881
1908
  return i;
1882
- };
1883
- multiply = (t) => {
1884
- if (t instanceof l)
1909
+ }
1910
+ multiply(t) {
1911
+ if (t instanceof u)
1885
1912
  return this.#p(t);
1886
- if (t instanceof a)
1913
+ if (t instanceof h)
1887
1914
  return this.#u(t);
1888
1915
  if (t instanceof p)
1889
1916
  return this.#d(t);
@@ -1891,30 +1918,36 @@ class l {
1891
1918
  return this.#f(t);
1892
1919
  if (typeof t == "string")
1893
1920
  try {
1894
- const e = new a(t);
1921
+ const e = new h(t);
1895
1922
  return this.#u(e);
1896
1923
  } catch {
1897
1924
  throw new Error("Cannot multiply by this value.");
1898
1925
  }
1899
1926
  throw new Error(`Cannot multiply by this value: ${t}`);
1900
- };
1927
+ }
1901
1928
  get numberOfVars() {
1902
1929
  return this.variables.length;
1903
1930
  }
1904
- one = () => (this.#i = [], this.#i.push(new p().one()), this);
1931
+ one() {
1932
+ return this.#i = [], this.#i.push(new p().one()), this.#h(), this;
1933
+ }
1905
1934
  // ------------------------------------------
1906
- opposite = () => (this.#i = this.#i.map((t) => t.opposite()), this);
1935
+ opposite() {
1936
+ return this.#i = this.#i.map((t) => t.opposite()), this.#h(), this;
1937
+ }
1907
1938
  get plotFunction() {
1908
1939
  return this.#l("tex", !1, !1, !0);
1909
1940
  }
1910
- pow = (t) => nt(this, t).reduce();
1911
- primitive = (t) => {
1912
- const e = new l();
1941
+ pow(t) {
1942
+ return rt(this, t).reduce();
1943
+ }
1944
+ primitive(t) {
1945
+ const e = new u();
1913
1946
  for (const i of this.#i)
1914
1947
  e.add(i.primitive(t));
1915
1948
  return e;
1916
- };
1917
- reduce = () => {
1949
+ }
1950
+ reduce() {
1918
1951
  let t = 0;
1919
1952
  for (; t < this.#i.length; ) {
1920
1953
  for (let e = t + 1; e < this.#i.length; e++)
@@ -1924,14 +1957,14 @@ class l {
1924
1957
  this.#i = this.#i.filter((e) => !e.coefficient.isZero());
1925
1958
  for (const e of this.#i)
1926
1959
  e.coefficient.reduce();
1927
- return this.length === 0 ? new l().zero() : this.reorder();
1928
- };
1929
- reorder = (t = "x", e = !1) => {
1960
+ return this.length === 0 ? this.zero() : (this.#h(), this.reorder());
1961
+ }
1962
+ reorder(t = "x", e = !1) {
1930
1963
  const i = this.variables.filter((s) => s !== t);
1931
1964
  return this.#i.sort(function(s, r) {
1932
- const o = s.degree(t).value, h = r.degree(t).value;
1933
- if (o !== h)
1934
- return e ? o - h : h - o;
1965
+ const o = s.degree(t).value, a = r.degree(t).value;
1966
+ if (o !== a)
1967
+ return e ? o - a : a - o;
1935
1968
  if (i.length > 0)
1936
1969
  for (const c of i) {
1937
1970
  const f = s.degree(c).value, m = r.degree(c).value;
@@ -1940,19 +1973,25 @@ class l {
1940
1973
  }
1941
1974
  return 0;
1942
1975
  }), this;
1943
- };
1976
+ }
1944
1977
  /**
1945
1978
  * Replace a variable (letter) by a polynom.
1946
1979
  * @param letter
1947
1980
  * @param P
1948
1981
  */
1949
- replaceBy = (t, e) => {
1982
+ replaceBy(t, e) {
1950
1983
  let i;
1951
- const s = new l().zero();
1984
+ const s = new u().zero();
1952
1985
  for (const r of this.monoms)
1953
- !r.hasVariable(t) || r.literal[t].isZero() ? s.add(r.clone()) : (i = r.literal[t].clone(), r.removeVariable(t), s.add(e.clone().pow(Math.abs(i.numerator)).multiply(r)));
1954
- return this.#i = s.reduce().monoms, this;
1955
- };
1986
+ if (!r.hasVariable(t) || r.literal[t].isZero())
1987
+ s.add(r.clone());
1988
+ else {
1989
+ if (i = r.literal[t].clone(), r.removeVariable(t), i.isStrictlyNegative())
1990
+ throw new Error(`Cannot replace variable "${t}" with negative power in a Polynom`);
1991
+ s.add(e.clone().pow(i.numerator).multiply(r));
1992
+ }
1993
+ return this.#i = s.reduce().monoms, this.#h(), this;
1994
+ }
1956
1995
  // ------------------------------------------
1957
1996
  root() {
1958
1997
  throw new Error("Cannot take the root from a polynom");
@@ -1969,17 +2008,17 @@ class l {
1969
2008
  sqrt() {
1970
2009
  throw new Error("Cannot take the square root from a polynom");
1971
2010
  }
1972
- subtract = (...t) => {
2011
+ subtract(...t) {
1973
2012
  for (const e of t)
1974
- e instanceof l ? this.add(e.clone().opposite()) : e instanceof p ? this.#i.push(e.clone().opposite()) : this.#i.push(new p(e).opposite());
2013
+ e instanceof u ? this.add(e.clone().opposite()) : e instanceof p ? this.#i.push(e.clone().opposite()) : this.#i.push(new p(e).opposite());
1975
2014
  return this.reduce();
1976
- };
2015
+ }
1977
2016
  tableOfSigns() {
1978
2017
  const t = this.roots;
1979
2018
  let e = new Array(2 * t.length + 1).fill("").map((i, s) => s % 2 === 0 ? "" : "z");
1980
2019
  if (e.length === 1) {
1981
2020
  const [i] = this.getCoefficients().map((s) => s.value);
1982
- e = U(e, "", i > 0 ? "+" : "-");
2021
+ e = j(e, "", i > 0 ? "+" : "-");
1983
2022
  } else if (this.degree().isOne()) {
1984
2023
  const [i] = this.getCoefficients().map((s) => s.value);
1985
2024
  e[0] = i > 0 ? "-" : "+", e[1] = "z", e[2] = i > 0 ? "+" : "-";
@@ -1988,7 +2027,7 @@ class l {
1988
2027
  t[0].value - 1,
1989
2028
  ...t.map((s, r) => r === t.length - 1 ? t[r].value + 1 : (t[r].value + t[r + 1].value) / 2)
1990
2029
  ].forEach((s, r) => {
1991
- const o = this.evaluate({ x: s }, !0);
2030
+ const o = this.evaluate({ [this.variables[0] ?? "x"]: s }, !0);
1992
2031
  e[r * 2] = o > 0 ? "+" : "-";
1993
2032
  });
1994
2033
  return { roots: t, signs: e };
@@ -1998,20 +2037,19 @@ class l {
1998
2037
  return this.monoms[0]?.coefficient.value ?? 0;
1999
2038
  }
2000
2039
  get variables() {
2001
- let t = [];
2002
- for (const e of this.#i)
2003
- t = t.concat(e.variables);
2004
- return t = [...new Set(t)], t.sort(), t;
2040
+ return [...new Set(this.#i.flatMap((t) => t.variables))].sort();
2005
2041
  }
2006
2042
  /**
2007
2043
  * Set the polynom to zero.
2008
2044
  * @returns {this}
2009
2045
  */
2010
- zero = () => (this.#i = [], this.#i.push(new p().zero()), this);
2046
+ zero() {
2047
+ return this.#i = [], this.#i.push(new p().zero()), this.#h(), this;
2048
+ }
2011
2049
  get zeroes() {
2012
2050
  return this.getZeroes();
2013
2051
  }
2014
- #n = (t, e) => {
2052
+ #n(t, e) {
2015
2053
  e ??= "=";
2016
2054
  const i = this.clone().reduce().reorder(), s = t.clone().reduce().reorder();
2017
2055
  switch (e) {
@@ -2022,60 +2060,57 @@ class l {
2022
2060
  default:
2023
2061
  return !1;
2024
2062
  }
2025
- };
2026
- #o = (t) => {
2063
+ }
2064
+ #o(t) {
2027
2065
  for (const e of this.#i)
2028
2066
  e.coefficient.divide(t);
2029
- return this;
2030
- };
2031
- #h = (t) => {
2032
- const e = new a(t);
2067
+ return this.#h(), this;
2068
+ }
2069
+ #a(t) {
2070
+ const e = new h(t);
2033
2071
  for (const i of this.#i)
2034
2072
  i.coefficient.divide(e);
2035
- return this;
2036
- };
2037
- #a = (t) => {
2073
+ return this.#h(), this;
2074
+ }
2075
+ #c(t) {
2038
2076
  let e = 0;
2039
2077
  return this.#i.forEach((i) => {
2040
2078
  e += i.evaluate(t, !0);
2041
2079
  }), e;
2042
- };
2043
- #l = (t, e, i, s) => {
2080
+ }
2081
+ #l(t, e, i, s) {
2044
2082
  let r = "";
2045
2083
  for (const o of this.#i) {
2046
2084
  if (o.coefficient.value === 0)
2047
2085
  continue;
2048
- let h;
2049
- s ? h = o.plotFunction : h = t === "tex" ? o.tex : o.display, r += `${o.coefficient.sign() === 1 && (r !== "" || e === !0) ? "+" : ""}${h}`;
2086
+ let a;
2087
+ s ? a = o.plotFunction : a = t === "tex" ? o.tex : o.display, r += `${o.coefficient.sign() === 1 && (r !== "" || e === !0) ? "+" : ""}${a}`;
2050
2088
  }
2051
2089
  return i === !0 && this.length > 1 && (t === "tex" ? r = `\\left( ${r} \\right)` : r = `(${r})`), r === "" && (r = "0"), r;
2052
- };
2053
- #c = (t, e, i) => {
2054
- const s = t.monoms[0].dividers, r = t.monoms[t.monoms.length - 1].dividers, o = [];
2055
- return s.forEach((h) => {
2056
- h.degree(i).isLeq(e) && r.forEach((c) => {
2057
- h.degree(i).isNotEqual(c.degree(i)) && (o.push(new l(h, c)), o.push(new l(h, c.clone().opposite())));
2058
- });
2059
- }), o;
2060
- };
2061
- #u = (t) => {
2090
+ }
2091
+ #h() {
2092
+ this.#r = !1, this.#e = [];
2093
+ }
2094
+ #u(t) {
2062
2095
  for (const e of this.#i)
2063
2096
  e.coefficient.multiply(t);
2064
2097
  return this.reduce();
2065
- };
2066
- #f = (t) => this.#u(new a(t));
2067
- #d = (t) => {
2098
+ }
2099
+ #f(t) {
2100
+ return this.#u(new h(t));
2101
+ }
2102
+ #d(t) {
2068
2103
  for (const e of this.#i)
2069
2104
  e.multiply(t);
2070
2105
  return this.reduce();
2071
- };
2072
- #p = (t) => {
2106
+ }
2107
+ #p(t) {
2073
2108
  const e = [];
2074
2109
  for (const i of this.#i)
2075
2110
  for (const s of t.monoms)
2076
2111
  e.push(p.xMultiply(i, s));
2077
2112
  return this.#i = e, this.reduce();
2078
- };
2113
+ }
2079
2114
  #m(t, ...e) {
2080
2115
  if (e.length === 0) {
2081
2116
  if (t !== "" && !isNaN(Number(t))) {
@@ -2083,18 +2118,18 @@ class l {
2083
2118
  const i = new p(Number(t));
2084
2119
  return this.add(i), this;
2085
2120
  }
2086
- return this.#g(t);
2087
- } else if (/^[a-z]+/.test(t)) {
2121
+ return this.#w(t);
2122
+ } else if (/^[a-z]+$/.test(t)) {
2088
2123
  this.empty();
2089
- const i = e.map((s) => new a(s));
2124
+ const i = e.map((s) => new h(s));
2090
2125
  if (t.length > 1) {
2091
2126
  const s = t.split("");
2092
- if (s.length < e.length - 2)
2093
- throw new Error("Too many factors for too few variables !");
2127
+ if (i.length > s.length + 1)
2128
+ throw new Error(`Too many values: ${s.length} letters but ${i.length} values provided`);
2094
2129
  let r = 0;
2095
2130
  for (const o of i) {
2096
- const h = new p();
2097
- h.coefficient = o.clone(), h.literalStr = s[r] || "", this.add(h), r++;
2131
+ const a = new p();
2132
+ a.coefficient = o.clone(), a.literalStr = s[r] ?? "", this.add(a), r++;
2098
2133
  }
2099
2134
  } else {
2100
2135
  let s = i.length - 1;
@@ -2107,43 +2142,32 @@ class l {
2107
2142
  } else
2108
2143
  return this.zero();
2109
2144
  }
2110
- /**
2111
- * Main parse using a shutting yard class
2112
- * @param inputStr
2113
- */
2114
- #g = (t) => {
2115
- const i = new G().parse(t).rpn;
2116
- this.zero();
2117
- const s = [];
2118
- for (const r of i)
2119
- this.#w(s, r);
2120
- return s.length === 1 && this.add(s[0]), this.reorder();
2121
- };
2122
- #w = (t, e) => {
2145
+ #g(t, e) {
2123
2146
  switch (e.tokenType) {
2124
- case u.COEFFICIENT:
2125
- t.push(new l(e.token));
2126
- break;
2127
- case u.VARIABLE:
2128
- t.push(new l().add(new p(e.token)));
2147
+ case l.COEFFICIENT:
2148
+ t.push(new u(e.token));
2129
2149
  break;
2130
- case u.CONSTANT:
2131
- console.log("Actually, not supported - will be added later !");
2150
+ case l.VARIABLE:
2151
+ t.push(new u().add(new p(e.token)));
2132
2152
  break;
2133
- case u.OPERATION:
2153
+ case l.CONSTANT:
2154
+ throw new Error("Unsupported CONSTANT token in Polynom parser");
2155
+ case l.OPERATION:
2134
2156
  if (t.length >= 2) {
2135
2157
  const i = t.pop(), s = t.pop();
2136
2158
  if (s === void 0 || i === void 0)
2137
- break;
2159
+ throw new Error("Unexpected undefined operand in Polynom parser stack");
2138
2160
  if (e.token === "+")
2139
2161
  t.push(s.add(i));
2140
2162
  else if (e.token === "-")
2141
2163
  t.push(s.subtract(i));
2142
2164
  else if (e.token === "*")
2143
2165
  t.push(s.multiply(i));
2144
- else if (e.token === "/")
2145
- i.degree().isStrictlyPositive() ? console.log("divide by a polynom -> should create a rational polynom !") : t.push(s.divide(i.monoms[0].coefficient));
2146
- else if (e.token === "^") {
2166
+ else if (e.token === "/") {
2167
+ if (i.degree().isStrictlyPositive())
2168
+ throw new Error("Cannot divide a Polynom by another Polynom of degree > 0");
2169
+ t.push(s.divide(i.monoms[0].coefficient));
2170
+ } else if (e.token === "^") {
2147
2171
  if (i.degree().isStrictlyPositive())
2148
2172
  throw new Error("Cannot elevate a polynom with another polynom !");
2149
2173
  if (i.monoms[0].coefficient.isRelative())
@@ -2153,7 +2177,7 @@ class l {
2153
2177
  s.monoms[0].literal[r].multiply(i.monoms[0].coefficient);
2154
2178
  t.push(s);
2155
2179
  } else
2156
- console.error("Cannot have power with fraction");
2180
+ throw new Error("Cannot raise a multi-monom Polynom to a fractional power");
2157
2181
  }
2158
2182
  } else if (e.token === "-") {
2159
2183
  const i = t.pop();
@@ -2161,14 +2185,24 @@ class l {
2161
2185
  } else
2162
2186
  throw new Error("Error parsing the polynom");
2163
2187
  break;
2164
- case u.MONOM:
2165
- console.error("The monom token should not appear here");
2166
- break;
2167
- case u.FUNCTION:
2168
- console.error("The function token should not appear here - might be introduced later.");
2169
- break;
2188
+ case l.MONOM:
2189
+ throw new Error("Unexpected MONOM token in polynom parser");
2190
+ case l.FUNCTION:
2191
+ throw new Error(`Unsupported function token "${e.token}" in polynom parser`);
2170
2192
  }
2171
- };
2193
+ }
2194
+ /**
2195
+ * Main parse using a shutting yard class
2196
+ * @param inputStr
2197
+ */
2198
+ #w(t) {
2199
+ const i = new G().parse(t).rpn;
2200
+ this.zero();
2201
+ const s = [];
2202
+ for (const r of i)
2203
+ this.#g(s, r);
2204
+ return s.length === 1 && this.add(s[0]), this.reorder();
2205
+ }
2172
2206
  }
2173
2207
  class v {
2174
2208
  // Left part of the equation
@@ -2178,11 +2212,11 @@ class v {
2178
2212
  // Signe of the equation
2179
2213
  #i;
2180
2214
  constructor(t, e, i) {
2181
- if (this.#t = new l().zero(), this.#e = new l().zero(), this.#i = "=", t !== void 0 && e === void 0) {
2215
+ if (this.#t = new u().zero(), this.#e = new u().zero(), this.#i = "=", t !== void 0 && e === void 0) {
2182
2216
  if (t instanceof v)
2183
2217
  return t.clone();
2184
2218
  typeof t == "string" && this.parse(t);
2185
- } else t !== void 0 && e !== void 0 && (this.left = new l(t), this.right = new l(e));
2219
+ } else t !== void 0 && e !== void 0 && (this.left = new u(t), this.right = new u(e));
2186
2220
  return i !== void 0 && (this.sign = i), this;
2187
2221
  }
2188
2222
  // ------------------------------------------
@@ -2191,7 +2225,7 @@ class v {
2191
2225
  if (e === !1)
2192
2226
  throw new Error("The equation is not valid (no sign found)");
2193
2227
  const i = t.split(e);
2194
- return this.create(new l(i[0]), new l(i[1]), this.#r(e));
2228
+ return this.create(new u(i[0]), new u(i[1]), this.#r(e));
2195
2229
  };
2196
2230
  clone = () => new v(this.#t.clone(), this.#e.clone(), this.#i);
2197
2231
  get tex() {
@@ -2220,7 +2254,7 @@ class v {
2220
2254
  return this.#t.add(t.left), this.#e.add(t.right), this;
2221
2255
  if (typeof t == "string" && !v.isEquationString(t))
2222
2256
  return this.add(new v(t));
2223
- const e = new l(t);
2257
+ const e = new u(t);
2224
2258
  return this.#t.add(e), this.#e.add(e), this;
2225
2259
  }
2226
2260
  create = (t, e, i) => (this.#t = t, this.#e = e, this.#i = this.#r(i ?? "="), this);
@@ -2228,7 +2262,7 @@ class v {
2228
2262
  * Get the degree of the equation
2229
2263
  * @param letter
2230
2264
  */
2231
- degree = (t) => a.max(this.#t.degree(t), this.#e.degree(t));
2265
+ degree = (t) => h.max(this.#t.degree(t), this.#e.degree(t));
2232
2266
  /**
2233
2267
  * divide an equation by a given value (transformed as a fraction)
2234
2268
  *
@@ -2244,7 +2278,7 @@ class v {
2244
2278
  * @returns {Equation}
2245
2279
  */
2246
2280
  divide = (t) => {
2247
- const e = new a(t);
2281
+ const e = new h(t);
2248
2282
  return e.isZero() ? this : this.multiply(e.inverse());
2249
2283
  };
2250
2284
  /**
@@ -2307,7 +2341,7 @@ class v {
2307
2341
  this.#t = t;
2308
2342
  }
2309
2343
  // -----------------------------------------------
2310
- letters = () => [.../* @__PURE__ */ new Set([...this.#t.letters(), ...this.#e.letters()])];
2344
+ letters = () => [.../* @__PURE__ */ new Set([...this.#t.variables, ...this.#e.variables])];
2311
2345
  // -----------------------------------------------
2312
2346
  /**
2313
2347
  * Reorder will move all monoms containing a letter on the left, all the other on the right.
@@ -2318,7 +2352,7 @@ class v {
2318
2352
  * @param value
2319
2353
  */
2320
2354
  multiply = (t) => {
2321
- const e = new a(t);
2355
+ const e = new h(t);
2322
2356
  return this.#t.multiply(e), this.#e.multiply(e), this.#i !== "=" && e.sign() === -1 && this.#n(), this;
2323
2357
  };
2324
2358
  get numberOfVars() {
@@ -2367,7 +2401,7 @@ class v {
2367
2401
  return this.#t.subtract(t.left), this.#e.subtract(t.right), this;
2368
2402
  if (typeof t == "string" && !v.isEquationString(t))
2369
2403
  return this.subtract(new v(t));
2370
- const e = new l(t);
2404
+ const e = new u(t);
2371
2405
  return this.#t.subtract(e), this.#e.subtract(e), this;
2372
2406
  }
2373
2407
  test = (t) => this.left.evaluate(t).isEqual(this.right.evaluate(t));
@@ -2406,7 +2440,7 @@ class b {
2406
2440
  #i;
2407
2441
  #s = !1;
2408
2442
  constructor(t, e) {
2409
- return t instanceof b ? (this.#e = t.polynom.clone(), this.#i = t.power.clone(), e !== void 0 && this.#i.multiply(new a(e))) : t !== void 0 ? (this.#e = new l(t), this.#i = new a(e ?? 1)) : (this.#e = new l(), this.#i = new a(1)), this.#t = 1, this;
2443
+ return t instanceof b ? (this.#e = t.polynom.clone(), this.#i = t.power.clone(), e !== void 0 && this.#i.multiply(new h(e))) : t !== void 0 ? (this.#e = new u(t), this.#i = new h(e ?? 1)) : (this.#e = new u(), this.#i = new h(1)), this.#t = 1, this;
2410
2444
  }
2411
2445
  parse() {
2412
2446
  throw new Error("Method not implemented.");
@@ -2417,12 +2451,12 @@ class b {
2417
2451
  get tex() {
2418
2452
  const t = this.power.numerator, e = this.power.denominator;
2419
2453
  let i, s;
2420
- return this.#t === 0 && e > 1 ? (i = `\\sqrt${e === 2 ? "" : `[ ${e} ]`}{ ${this.polynom.tex} }`, s = t === 1 ? "" : `^{ ${t} }`) : (i = this.#s && this.power.isOne() ? this.polynom.tex : st(this.polynom.tex), s = e === 1 && t === 1 ? "" : `^{ ${this.power.tex} }`), i = `${i}${s}`, this.#t === 0 && t < 0 && (i = `\\frac{ 1 }{ ${i} }`), i;
2454
+ return this.#t === 0 && e > 1 ? (i = `\\sqrt${e === 2 ? "" : `[ ${e} ]`}{ ${this.polynom.tex} }`, s = t === 1 ? "" : `^{ ${t} }`) : (i = this.#s && this.power.isOne() ? this.polynom.tex : it(this.polynom.tex), s = e === 1 && t === 1 ? "" : `^{ ${this.power.tex} }`), i = `${i}${s}`, this.#t === 0 && t < 0 && (i = `\\frac{ 1 }{ ${i} }`), i;
2421
2455
  }
2422
2456
  get display() {
2423
2457
  const t = this.power.numerator, e = this.power.denominator;
2424
2458
  let i, s;
2425
- return this.#t === 0 && e > 1 ? (i = `${e === 2 ? "sqrt" : `root(${e})`}(${this.polynom.display})`, s = t === 1 ? "" : `^(${t})`) : (i = this.#s && this.power.isOne() ? this.polynom.display : st(this.polynom.display, !1), s = e === 1 && t === 1 ? "" : `^(${this.power.display})`), i = `${i}${s}`, this.#t === 0 && t < 0 && (i = `1/(${i})`), i;
2459
+ return this.#t === 0 && e > 1 ? (i = `${e === 2 ? "sqrt" : `root(${e})`}(${this.polynom.display})`, s = t === 1 ? "" : `^(${t})`) : (i = this.#s && this.power.isOne() ? this.polynom.display : it(this.polynom.display, !1), s = e === 1 && t === 1 ? "" : `^(${this.power.display})`), i = `${i}${s}`, this.#t === 0 && t < 0 && (i = `1/(${i})`), i;
2426
2460
  }
2427
2461
  add() {
2428
2462
  throw new Error("Adding two factors is not possible");
@@ -2448,7 +2482,7 @@ class b {
2448
2482
  divide(t) {
2449
2483
  if (t instanceof b && this.isSameAs(t))
2450
2484
  return this.power.subtract(t.power), this;
2451
- const e = new l(t);
2485
+ const e = new u(t);
2452
2486
  if (this.isSameAs(e))
2453
2487
  return this.power.subtract(1), this;
2454
2488
  throw new Error("The two factors must be the same");
@@ -2457,7 +2491,7 @@ class b {
2457
2491
  return e ? this.polynom.evaluate(t, !0) ** this.power.value : this.polynom.evaluate(t).pow(this.power);
2458
2492
  }
2459
2493
  fromPolynom(t) {
2460
- return this.#e = new l(t), this.#i = new a(1), this;
2494
+ return this.#e = new u(t), this.#i = new h(1), this;
2461
2495
  }
2462
2496
  hasVariable(t) {
2463
2497
  return this.polynom.hasVariable(t);
@@ -2473,7 +2507,7 @@ class b {
2473
2507
  }
2474
2508
  isSameAs(t) {
2475
2509
  let e;
2476
- return t instanceof b ? e = t.polynom : t instanceof l ? e = t : e = new l(t), this.polynom.isEqual(e);
2510
+ return t instanceof b ? e = t.polynom : t instanceof u ? e = t : e = new u(t), this.polynom.isEqual(e);
2477
2511
  }
2478
2512
  isZero() {
2479
2513
  return this.polynom.isZero();
@@ -2481,7 +2515,7 @@ class b {
2481
2515
  multiply(t) {
2482
2516
  if (t instanceof b && this.isSameAs(t))
2483
2517
  return this.power.add(t.power), this;
2484
- const e = new l(t);
2518
+ const e = new u(t);
2485
2519
  if (this.isSameAs(e))
2486
2520
  return this.power.add(1), this;
2487
2521
  throw new Error("The two factors must be the same");
@@ -2505,7 +2539,7 @@ class b {
2505
2539
  return this.#i;
2506
2540
  }
2507
2541
  set power(t) {
2508
- this.#i = new a(t);
2542
+ this.#i = new h(t);
2509
2543
  }
2510
2544
  primitive() {
2511
2545
  throw new Error("Method not implemented.");
@@ -2524,7 +2558,7 @@ class b {
2524
2558
  }
2525
2559
  tableOfSigns() {
2526
2560
  const t = this.power.clone().reduce(), e = this.polynom.tableOfSigns();
2527
- return t.isStrictlyNegative() && (e.signs = U(e.signs, "z", "d")), t.denominator % 2 === 0 ? e.signs = U(e.signs, "-", "h") : t.numerator % 2 === 0 && (e.signs = U(e.signs, "-", "+")), { roots: e.roots, signs: e.signs };
2561
+ return t.isStrictlyNegative() && (e.signs = j(e.signs, "z", "d")), t.denominator % 2 === 0 ? e.signs = j(e.signs, "-", "h") : t.numerator % 2 === 0 && (e.signs = j(e.signs, "-", "+")), { roots: e.roots, signs: e.signs };
2528
2562
  }
2529
2563
  get variables() {
2530
2564
  return this.polynom.variables;
@@ -2563,7 +2597,7 @@ class z {
2563
2597
  const s = e.split("").splice(0, i - 1);
2564
2598
  return new z(
2565
2599
  ...t.map((r) => {
2566
- const o = new l(s.join(""), ...r);
2600
+ const o = new u(s.join(""), ...r);
2567
2601
  return new v(o, 0);
2568
2602
  })
2569
2603
  );
@@ -2607,11 +2641,11 @@ class z {
2607
2641
  }
2608
2642
  o.push(i.join("&"));
2609
2643
  }
2610
- let h = 0;
2611
- return e !== void 0 && e.length > 0 && (h = e[0].length), `\\left\\{\\begin{array}{${"r".repeat(r.length)}cl ${"|l".repeat(h)}}${o.join("\\\\ ")}\\end{array}\\right.`;
2644
+ let a = 0;
2645
+ return e !== void 0 && e.length > 0 && (a = e[0].length), `\\left\\{\\begin{array}{${"r".repeat(r.length)}cl ${"|l".repeat(a)}}${o.join("\\\\ ")}\\end{array}\\right.`;
2612
2646
  };
2613
2647
  degree(t) {
2614
- return a.max(...this.#t.map((e) => e.degree(t)));
2648
+ return h.max(...this.#t.map((e) => e.degree(t)));
2615
2649
  }
2616
2650
  // ------------------------------------------
2617
2651
  get equations() {
@@ -2665,9 +2699,9 @@ class z {
2665
2699
  for (let s = 0; s < t.length; s++) {
2666
2700
  let r = i[s][s].clone();
2667
2701
  if (r.isZero()) {
2668
- const o = i.find((h, c) => c > s && !h[s].isZero());
2702
+ const o = i.find((a, c) => c > s && !a[s].isZero());
2669
2703
  if (o)
2670
- i[s].forEach((h, c) => h.add(o[c])), r = i[s][s].clone();
2704
+ i[s].forEach((a, c) => a.add(o[c])), r = i[s][s].clone();
2671
2705
  else
2672
2706
  throw new Error("Unsolvable...");
2673
2707
  }
@@ -2675,9 +2709,9 @@ class z {
2675
2709
  for (let o = 0; o < t.length; o++) {
2676
2710
  if (o === s)
2677
2711
  continue;
2678
- const h = i[o][s].clone().opposite();
2712
+ const a = i[o][s].clone().opposite();
2679
2713
  for (let c = 0; c < i[o].length; c++)
2680
- i[o][c].add(i[s][c].clone().multiply(h));
2714
+ i[o][c].add(i[s][c].clone().multiply(a));
2681
2715
  if (i[o].slice(0, i[o].length - 1).every((c) => c.isZero()))
2682
2716
  return i[o][i[o].length - 1].isZero() ? this.#r() : [];
2683
2717
  }
@@ -2688,15 +2722,15 @@ class z {
2688
2722
  const e = [], i = this.equations.map((s) => s.left.monomByLetter(t).coefficient.value);
2689
2723
  return i.forEach((s, r) => {
2690
2724
  for (let o = r + 1; o < i.length; o++) {
2691
- const h = x.lcm(s, i[o]), c = s < 0 ? -1 : 1;
2725
+ const a = x.lcm(s, i[o]), c = s < 0 ? -1 : 1;
2692
2726
  e.push([
2693
2727
  {
2694
2728
  id: r,
2695
- factor: c * h / s
2729
+ factor: c * a / s
2696
2730
  },
2697
2731
  {
2698
2732
  id: o,
2699
- factor: -c * h / i[o]
2733
+ factor: -c * a / i[o]
2700
2734
  }
2701
2735
  ]);
2702
2736
  }
@@ -2730,8 +2764,8 @@ class z {
2730
2764
  for (const i of this.#t) {
2731
2765
  const s = [], r = i.clone().reorder();
2732
2766
  for (const o of this.variables) {
2733
- const h = r.left.monomByLetter(o);
2734
- s.push(h.coefficient);
2767
+ const a = r.left.monomByLetter(o);
2768
+ s.push(a.coefficient);
2735
2769
  }
2736
2770
  e.push(r.right.monoms[0].coefficient), t.push(s);
2737
2771
  }
@@ -2869,26 +2903,26 @@ class qt {
2869
2903
  switch (r.token) {
2870
2904
  case "&":
2871
2905
  if (i.length >= 2) {
2872
- const o = i.pop(), h = i.pop();
2873
- h && o && i.push(new Set([...h].filter((c) => o.has(c))));
2906
+ const o = i.pop(), a = i.pop();
2907
+ a && o && i.push(new Set([...a].filter((c) => o.has(c))));
2874
2908
  }
2875
2909
  break;
2876
2910
  case "|":
2877
2911
  if (i.length >= 2) {
2878
- const o = i.pop(), h = i.pop();
2879
- h && o && i.push(/* @__PURE__ */ new Set([...h, ...o]));
2912
+ const o = i.pop(), a = i.pop();
2913
+ a && o && i.push(/* @__PURE__ */ new Set([...a, ...o]));
2880
2914
  }
2881
2915
  break;
2882
2916
  case "-":
2883
2917
  if (i.length >= 2) {
2884
- const o = i.pop(), h = i.pop();
2885
- h && o && i.push(new Set([...h].filter((c) => !o.has(c))));
2918
+ const o = i.pop(), a = i.pop();
2919
+ a && o && i.push(new Set([...a].filter((c) => !o.has(c))));
2886
2920
  }
2887
2921
  break;
2888
2922
  case "!":
2889
2923
  if (i.length >= 1) {
2890
2924
  const o = i.pop();
2891
- o && i.push(new Set([...s].filter((h) => !o.has(h))));
2925
+ o && i.push(new Set([...s].filter((a) => !o.has(a))));
2892
2926
  }
2893
2927
  break;
2894
2928
  }
@@ -2926,16 +2960,16 @@ class N {
2926
2960
  return `(${i})/(${s})`;
2927
2961
  }
2928
2962
  static #i(t, e) {
2929
- const i = Z(t), s = Z(e), o = Object.keys(i).filter((h) => Object.hasOwn(s, h)).map((h) => {
2930
- const c = i[h].reduce((m, d) => m.add(d.power), new a("0")), f = s[h].reduce((m, d) => m.add(d.power), new a("0"));
2931
- return new b(h, a.min(c, f));
2963
+ const i = Z(t), s = Z(e), o = Object.keys(i).filter((a) => Object.hasOwn(s, a)).map((a) => {
2964
+ const c = i[a].reduce((m, d) => m.add(d.power), new h("0")), f = s[a].reduce((m, d) => m.add(d.power), new h("0"));
2965
+ return new b(a, h.min(c, f));
2932
2966
  });
2933
2967
  return new N(...o);
2934
2968
  }
2935
2969
  static #s(t, e) {
2936
- const i = Z(t), s = Z(e), o = [.../* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(s)])].map((h) => {
2937
- const c = Object.hasOwn(i, h) ? i[h].reduce((m, d) => m.add(d.power), new a("0")) : new a(0), f = Object.hasOwn(s, h) ? s[h].reduce((m, d) => m.add(d.power), new a("0")) : new a(0);
2938
- return new b(h, a.max(c, f));
2970
+ const i = Z(t), s = Z(e), o = [.../* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(s)])].map((a) => {
2971
+ const c = Object.hasOwn(i, a) ? i[a].reduce((m, d) => m.add(d.power), new h("0")) : new h(0), f = Object.hasOwn(s, a) ? s[a].reduce((m, d) => m.add(d.power), new h("0")) : new h(0);
2972
+ return new b(a, h.max(c, f));
2939
2973
  });
2940
2974
  return new N(...o);
2941
2975
  }
@@ -2958,21 +2992,21 @@ class N {
2958
2992
  return t.shift(), t.forEach((i) => e = N.#s(e, i)), e;
2959
2993
  }
2960
2994
  add(...t) {
2961
- const e = [this.numerator, ...t.map((h) => h.numerator)], i = [this.denominator, ...t.map((h) => h.denominator)];
2995
+ const e = [this.numerator, ...t.map((a) => a.numerator)], i = [this.denominator, ...t.map((a) => a.denominator)];
2962
2996
  let s;
2963
- if (i.some((h) => h.factors.length > 0)) {
2964
- const h = N.lcm(...i);
2997
+ if (i.some((a) => a.factors.length > 0)) {
2998
+ const a = N.lcm(...i);
2965
2999
  e.forEach((c, f) => {
2966
- c.multiply(h.clone().divide(i[f]));
2967
- }), s = h;
3000
+ c.multiply(a.clone().divide(i[f]));
3001
+ }), s = a;
2968
3002
  }
2969
- const r = N.gcd(...e), o = new l(0).add(
2970
- ...e.map((h) => h.divide(r).reduce().develop().factors[0].polynom)
3003
+ const r = N.gcd(...e), o = new u(0).add(
3004
+ ...e.map((a) => a.divide(r).reduce().develop().factors[0].polynom)
2971
3005
  ).reduce();
2972
3006
  return this.#e = [
2973
3007
  ...r.factors,
2974
3008
  new b(o)
2975
- ], s && this.divide(s), this.#e = this.#e.filter((h) => !h.power.isZero()), this;
3009
+ ], s && this.divide(s), this.#e = this.#e.filter((a) => !a.power.isZero()), this;
2976
3010
  }
2977
3011
  get asPower() {
2978
3012
  return this.#t = D.POWER, this;
@@ -2981,7 +3015,7 @@ class N {
2981
3015
  return this.#t = D.ROOT, this;
2982
3016
  }
2983
3017
  degree(t) {
2984
- return this.#e.reduce((e, i) => e.add(i.degree(t)), new a("0"));
3018
+ return this.#e.reduce((e, i) => e.add(i.degree(t)), new h("0"));
2985
3019
  }
2986
3020
  get denominator() {
2987
3021
  return new N(
@@ -3001,7 +3035,7 @@ class N {
3001
3035
  return i !== void 0 && (this.#e = i.factors), this.add(...t);
3002
3036
  }
3003
3037
  develop() {
3004
- const t = new l("1"), e = new l("1");
3038
+ const t = new u("1"), e = new u("1");
3005
3039
  return this.numerator.factors.forEach((i) => {
3006
3040
  t.multiply(i.develop());
3007
3041
  }), this.denominator.factors.forEach((i) => {
@@ -3012,15 +3046,15 @@ class N {
3012
3046
  return this.#e = this.#e.concat(t.clone().factors.map((e) => e.inverse())), this;
3013
3047
  }
3014
3048
  evaluate(t, e) {
3015
- return e ? this.#e.reduce((i, s) => i * s.evaluate(t, e), 1) : this.#e.reduce((i, s) => i.multiply(s.evaluate(t)), new a("1"));
3049
+ return e ? this.#e.reduce((i, s) => i * s.evaluate(t, e), 1) : this.#e.reduce((i, s) => i.multiply(s.evaluate(t)), new h("1"));
3016
3050
  }
3017
3051
  factorize(t) {
3018
3052
  const e = [];
3019
3053
  this.#e.forEach((o) => {
3020
- const h = o.polynom.factorize(t);
3021
- if (h.length > 1) {
3054
+ const a = o.polynom.factorize(t);
3055
+ if (a.length > 1) {
3022
3056
  const c = o.power.clone();
3023
- e.push(...h.map((f) => new b(f, c)));
3057
+ e.push(...a.map((f) => new b(f, c)));
3024
3058
  } else
3025
3059
  e.push(o.clone());
3026
3060
  });
@@ -3034,8 +3068,8 @@ class N {
3034
3068
  this.#e = t;
3035
3069
  }
3036
3070
  fromPolynom(t, e) {
3037
- if (this.#e = [new b(new l(t))], e) {
3038
- const i = new l(e);
3071
+ if (this.#e = [new b(new u(t))], e) {
3072
+ const i = new u(e);
3039
3073
  if (i.isOne())
3040
3074
  return this;
3041
3075
  if (i.isZero())
@@ -3098,7 +3132,7 @@ class N {
3098
3132
  reduce() {
3099
3133
  const t = Z(this);
3100
3134
  return this.#e = Object.values(t).map((e) => {
3101
- const i = e[0].polynom, s = e.reduce((r, o) => r.add(o.power), new a("0"));
3135
+ const i = e[0].polynom, s = e.reduce((r, o) => r.add(o.power), new h("0"));
3102
3136
  return new b(i, s.reduce());
3103
3137
  }).filter((e) => !e.power.isZero()), this;
3104
3138
  }
@@ -3116,9 +3150,9 @@ class N {
3116
3150
  const s = e.power.value, r = i.power.value;
3117
3151
  if (s * r < 0)
3118
3152
  return -s;
3119
- const o = e.polynom.monoms.length, h = i.polynom.monoms.length;
3120
- if (o !== h)
3121
- return o - h;
3153
+ const o = e.polynom.monoms.length, a = i.polynom.monoms.length;
3154
+ if (o !== a)
3155
+ return o - a;
3122
3156
  const c = e.polynom.degree(t).value, f = i.polynom.degree(t).value;
3123
3157
  return c !== f ? c - f : s !== r ? s - r : e.degree().isLeq(i.degree()) ? -1 : 1;
3124
3158
  }), this;
@@ -3133,18 +3167,18 @@ class N {
3133
3167
  const t = this.getZeroes(), e = t.map((r) => r.value), i = this.factorize().factors.map((r) => ({ factor: new b(r), ...r.tableOfSigns() }));
3134
3168
  return i.forEach((r) => {
3135
3169
  const o = new Array(2 * t.length + 1).fill("");
3136
- let h = r.signs.shift(), c = r.roots.shift();
3170
+ let a = r.signs.shift(), c = r.roots.shift();
3137
3171
  const f = o.map((m, d) => {
3138
3172
  if (d % 2 === 0)
3139
- return h;
3173
+ return a;
3140
3174
  if (c === void 0 || c.value !== e[(d - 1) / 2])
3141
3175
  return "t";
3142
3176
  const y = r.signs.shift();
3143
- return h = r.signs.shift(), c = r.roots.shift(), y;
3177
+ return a = r.signs.shift(), c = r.roots.shift(), y;
3144
3178
  });
3145
3179
  r.roots = t, r.signs = f;
3146
- }), { signs: i.map((r) => [...r.signs]).reduce((r, o) => r.length === 0 ? o : (o.forEach((h, c) => {
3147
- switch (h) {
3180
+ }), { signs: i.map((r) => [...r.signs]).reduce((r, o) => r.length === 0 ? o : (o.forEach((a, c) => {
3181
+ switch (a) {
3148
3182
  case "d":
3149
3183
  r[c] = "d";
3150
3184
  break;
@@ -3172,11 +3206,11 @@ class N {
3172
3206
  }
3173
3207
  }
3174
3208
  function Z(n) {
3175
- const t = new a().one(), e = new a().one(), i = n.factors.reduce((o, h) => {
3176
- if (h.polynom.degree().isZero())
3177
- return h.power.isPositive() ? t.multiply(h.polynom.monoms[0].coefficient) : e.multiply(h.polynom.monoms[0].coefficient), o;
3178
- const c = h.polynom.display;
3179
- return Object.hasOwn(o, c) ? o[c].push(h) : o[c] = [h], o;
3209
+ const t = new h().one(), e = new h().one(), i = n.factors.reduce((o, a) => {
3210
+ if (a.polynom.degree().isZero())
3211
+ return a.power.isPositive() ? t.multiply(a.polynom.monoms[0].coefficient) : e.multiply(a.polynom.monoms[0].coefficient), o;
3212
+ const c = a.polynom.display;
3213
+ return Object.hasOwn(o, c) ? o[c].push(a) : o[c] = [a], o;
3180
3214
  }, {}), { numerator: s, denominator: r } = t.divide(e).reduce();
3181
3215
  return s !== 1 && (i[s.toString()] = [new b(s, 1)]), r !== 1 && (i[r.toString()] = [new b(r, -1)]), i;
3182
3216
  }
@@ -3243,7 +3277,7 @@ class B {
3243
3277
  }
3244
3278
  characteristic_polynom(t) {
3245
3279
  return t ??= "k", this.clone().subtract(
3246
- new B(this.dimension.rows).one().multiply(new l(t))
3280
+ new B(this.dimension.rows).one().multiply(new u(t))
3247
3281
  ).determinant();
3248
3282
  }
3249
3283
  cofactor(t, e) {
@@ -3253,7 +3287,7 @@ class B {
3253
3287
  }), i.determinant().multiply((-1) ** (t + e));
3254
3288
  }
3255
3289
  get cols() {
3256
- const t = Array.from({ length: this.dimension.cols }, () => Array.from({ length: this.dimension.rows }, () => new l()));
3290
+ const t = Array.from({ length: this.dimension.cols }, () => Array.from({ length: this.dimension.rows }, () => new u()));
3257
3291
  return this.forEach((e, i, s) => {
3258
3292
  t[s][i] = e;
3259
3293
  }), t;
@@ -3261,7 +3295,7 @@ class B {
3261
3295
  determinant() {
3262
3296
  if (!this.isSquare())
3263
3297
  throw new Error("Matrix is not square");
3264
- const t = new l();
3298
+ const t = new u();
3265
3299
  return this.#i.length === 1 ? this.#i[0][0].clone() : (this.values[0].forEach((e, i) => {
3266
3300
  const s = this.cofactor(0, i);
3267
3301
  t.add(e.clone().multiply(s));
@@ -3284,14 +3318,14 @@ class B {
3284
3318
  });
3285
3319
  }
3286
3320
  fromDimensions(t, e) {
3287
- return this.#i = Array.from({ length: t }, () => Array.from({ length: e }, () => new l())), this;
3321
+ return this.#i = Array.from({ length: t }, () => Array.from({ length: e }, () => new u())), this;
3288
3322
  }
3289
3323
  fromString(t) {
3290
3324
  if (t.startsWith("((") && t.endsWith("))"))
3291
3325
  return this.fromString(t.substring(1, t.length - 1));
3292
3326
  const e = t.split("),(");
3293
3327
  return this.#i = e.map((i, s) => s === 0 ? i.substring(1).split(",") : s === e.length - 1 ? i.substring(0, i.length - 1).split(",") : i.split(",")).map(
3294
- (i) => i.map((s) => new l(s))
3328
+ (i) => i.map((s) => new u(s))
3295
3329
  ), this;
3296
3330
  }
3297
3331
  fromValues(t) {
@@ -3302,7 +3336,7 @@ class B {
3302
3336
  return t.forEach((i) => {
3303
3337
  const s = [];
3304
3338
  i.forEach((r) => {
3305
- s.push(new l(r));
3339
+ s.push(new u(r));
3306
3340
  }), this.#i.push(s);
3307
3341
  }), this;
3308
3342
  }
@@ -3313,7 +3347,7 @@ class B {
3313
3347
  throw new Error("Each vectors must be the same dimension");
3314
3348
  return this.fromDimensions(t[0].dimension, t.length), t.forEach((i, s) => {
3315
3349
  i.array.forEach((r, o) => {
3316
- this.#i[o][s] = new l(r);
3350
+ this.#i[o][s] = new u(r);
3317
3351
  });
3318
3352
  }), this;
3319
3353
  }
@@ -3352,8 +3386,8 @@ class B {
3352
3386
  const { rows: e, cols: i } = this.dimension, s = Array.from({ length: e }, () => Array.from({ length: i }, () => {
3353
3387
  }));
3354
3388
  return this.#i.forEach((r, o) => {
3355
- r.forEach((h, c) => {
3356
- s[o][c] = t(h, o, c);
3389
+ r.forEach((a, c) => {
3390
+ s[o][c] = t(a, o, c);
3357
3391
  });
3358
3392
  }), s;
3359
3393
  }
@@ -3363,9 +3397,9 @@ class B {
3363
3397
  throw new Error("Cannot multiply a matrix with incompatibles dimensions");
3364
3398
  const e = new B(this.dimension.rows, t.dimension.cols);
3365
3399
  return e.forEach((i, s, r) => {
3366
- const o = this.rows[s], h = t.cols[r], c = new l();
3400
+ const o = this.rows[s], a = t.cols[r], c = new u();
3367
3401
  o.forEach((f, m) => {
3368
- c.add(f.clone().multiply(h[m]));
3402
+ c.add(f.clone().multiply(a[m]));
3369
3403
  }), e.setValue(s, r, c);
3370
3404
  }), this.#i = e.values, this;
3371
3405
  }
@@ -3387,7 +3421,7 @@ class B {
3387
3421
  return this.#e = !0, this;
3388
3422
  }
3389
3423
  pow(t) {
3390
- return nt(this, t);
3424
+ return rt(this, t);
3391
3425
  }
3392
3426
  reduce() {
3393
3427
  throw new Error("Not yet implemented");
@@ -3399,7 +3433,7 @@ class B {
3399
3433
  const { rows: s, cols: r } = this.dimension;
3400
3434
  if (t < 0 || t >= s || e < 0 || e >= r)
3401
3435
  throw new Error(`${t}x${e} is out of range (${s}x${r})`);
3402
- return this.#i[t][e] = new l(i), this;
3436
+ return this.#i[t][e] = new u(i), this;
3403
3437
  }
3404
3438
  subtract(t) {
3405
3439
  if (!this.canBeAdded(t))
@@ -3437,12 +3471,12 @@ function kt(n, t) {
3437
3471
  );
3438
3472
  }
3439
3473
  function Mt(n, t) {
3440
- return n.dimension !== t.dimension ? new a().invalid() : n.array.reduce(
3474
+ return n.dimension !== t.dimension ? new h().invalid() : n.array.reduce(
3441
3475
  (e, i, s) => e.add(i.clone().multiply(t.array[s])),
3442
- new a(0)
3476
+ new h(0)
3443
3477
  );
3444
3478
  }
3445
- function Ut(...n) {
3479
+ function jt(...n) {
3446
3480
  if (n.some((t) => t.dimension !== n[0].dimension))
3447
3481
  throw new Error("All vectors must have the same dimension");
3448
3482
  if (n[0].dimension !== n.length)
@@ -3459,7 +3493,7 @@ class P {
3459
3493
  #t = [];
3460
3494
  #e;
3461
3495
  constructor(...t) {
3462
- this.#t = t.map((e) => new a(e));
3496
+ this.#t = t.map((e) => new h(e));
3463
3497
  }
3464
3498
  copy() {
3465
3499
  return this.#t.map((t) => t.clone());
@@ -3476,7 +3510,7 @@ class P {
3476
3510
  fromString(t) {
3477
3511
  t.startsWith("(") && (t = t.substring(1)), t.endsWith(")") && (t = t.substring(0, t.length - 1));
3478
3512
  const e = t.split(/[,;\s]/g).filter((i) => i.trim() !== "");
3479
- return e.length < 2 ? this : (this.#t = e.map((i) => new a(i)), this);
3513
+ return e.length < 2 ? this : (this.#t = e.map((i) => new h(i)), this);
3480
3514
  }
3481
3515
  get onChange() {
3482
3516
  return this.#e;
@@ -3491,20 +3525,20 @@ class P {
3491
3525
  this.#t = this.#t.slice(0, t);
3492
3526
  else if (t > this.dimension)
3493
3527
  for (let e = this.dimension; e < t; e++)
3494
- this.#t.push(new a(0));
3528
+ this.#t.push(new h(0));
3495
3529
  return this;
3496
3530
  }
3497
3531
  get x() {
3498
3532
  return this.#t[0];
3499
3533
  }
3500
3534
  set x(t) {
3501
- this.#t[0] = new a(t), this.#e?.();
3535
+ this.#t[0] = new h(t), this.#e?.();
3502
3536
  }
3503
3537
  get y() {
3504
3538
  return this.#t[1];
3505
3539
  }
3506
3540
  set y(t) {
3507
- this.#t[1] = new a(t), this.#e?.();
3541
+ this.#t[1] = new h(t), this.#e?.();
3508
3542
  }
3509
3543
  get z() {
3510
3544
  if (this.dimension < 3)
@@ -3514,7 +3548,7 @@ class P {
3514
3548
  set z(t) {
3515
3549
  if (this.dimension < 3)
3516
3550
  throw new Error("Vector is not 3D");
3517
- this.#t[2] = new a(t), this.#e?.();
3551
+ this.#t[2] = new h(t), this.#e?.();
3518
3552
  }
3519
3553
  zero = () => (this.#t.forEach((t) => t.zero()), this.#e?.(), this);
3520
3554
  }
@@ -3532,7 +3566,7 @@ class w extends P {
3532
3566
  if (t.length > 1) {
3533
3567
  if (t.some((i) => i instanceof w))
3534
3568
  throw new Error("Creating a point with multiple argument requires an input fraction");
3535
- const e = t.map((i) => new a(i));
3569
+ const e = t.map((i) => new h(i));
3536
3570
  if (e.some((i) => i.isNaN()))
3537
3571
  throw new Error("The given values are not a valid point string (a,b): ");
3538
3572
  this.array = e;
@@ -3553,7 +3587,7 @@ class w extends P {
3553
3587
  throw new Error("The two points must have the same dimensions.");
3554
3588
  const i = this.array.map((s, r) => t.array[r].clone().subtract(s)).reduce(
3555
3589
  (s, r) => s.add(r.clone().pow(2)),
3556
- new a(0)
3590
+ new h(0)
3557
3591
  );
3558
3592
  return new T().from(2, i).reduce();
3559
3593
  }
@@ -3595,7 +3629,7 @@ class g extends P {
3595
3629
  return this.array = i.array.map((s, r) => s.clone().subtract(e.array[r])), this;
3596
3630
  }
3597
3631
  }
3598
- return this.array = t.map((e) => new a(e)), this;
3632
+ return this.array = t.map((e) => new h(e)), this;
3599
3633
  }
3600
3634
  clone() {
3601
3635
  return new g(...this.copy());
@@ -3628,7 +3662,7 @@ class g extends P {
3628
3662
  }
3629
3663
  // ------------------------------------------
3630
3664
  // Creation / parsing functions
3631
- divideByScalar = (t) => this.multiplyByScalar(new a(t).inverse());
3665
+ divideByScalar = (t) => this.multiplyByScalar(new h(t).inverse());
3632
3666
  dot = (t) => Mt(this, t);
3633
3667
  fromString(t) {
3634
3668
  return t.startsWith("((") && t.endsWith("))") ? super.fromString(t.slice(1, -1)) : super.fromString(t);
@@ -3647,14 +3681,14 @@ class g extends P {
3647
3681
  return this.array.every((t) => t.isZero());
3648
3682
  }
3649
3683
  multiplyByScalar = (t) => {
3650
- const e = new a(t);
3684
+ const e = new h(t);
3651
3685
  return this.array.forEach((i) => i.multiply(e)), this;
3652
3686
  };
3653
3687
  get norm() {
3654
3688
  return Math.sqrt(this.normSquare.value);
3655
3689
  }
3656
3690
  get normSquare() {
3657
- return this.array.reduce((t, e) => t.add(e.clone().pow(2)), new a(0));
3691
+ return this.array.reduce((t, e) => t.add(e.clone().pow(2)), new h(0));
3658
3692
  }
3659
3693
  normal = () => {
3660
3694
  if (this.dimension >= 3)
@@ -3666,7 +3700,7 @@ class g extends P {
3666
3700
  opposite = () => (this.array.forEach((t) => t.opposite()), this);
3667
3701
  simplify = () => {
3668
3702
  const t = x.lcm(...this.array.map((i) => i.denominator)), e = x.gcd(...this.array.map((i) => i.numerator));
3669
- return this.multiplyByScalar(new a(t, e)), this.x.isNegative() && this.opposite(), this;
3703
+ return this.multiplyByScalar(new h(t, e)), this.x.isNegative() && this.opposite(), this;
3670
3704
  };
3671
3705
  subtract = (t) => this.add(t.clone().opposite());
3672
3706
  translate(...t) {
@@ -3677,8 +3711,8 @@ class g extends P {
3677
3711
  return t === 0 ? this : this.divideByScalar(t);
3678
3712
  };
3679
3713
  }
3680
- var L = /* @__PURE__ */ ((n) => (n.None = "none", n.Parallel = "parallel", n.Perpendicular = "perpendicular", n.Tangent = "tangent", n))(L || {}), H = /* @__PURE__ */ ((n) => (n.None = "none", n.Parallel = "parallel", n.Perpendicular = "perpendicular", n.Tangent = "tangent", n))(H || {});
3681
- function ot(n = 0.5) {
3714
+ var V = /* @__PURE__ */ ((n) => (n.None = "none", n.Parallel = "parallel", n.Perpendicular = "perpendicular", n.Tangent = "tangent", n))(V || {}), H = /* @__PURE__ */ ((n) => (n.None = "none", n.Parallel = "parallel", n.Perpendicular = "perpendicular", n.Tangent = "tangent", n))(H || {});
3715
+ function nt(n = 0.5) {
3682
3716
  return Math.random() < n;
3683
3717
  }
3684
3718
  function O(n, t, e) {
@@ -3696,7 +3730,7 @@ function O(n, t, e) {
3696
3730
  return i;
3697
3731
  }
3698
3732
  function A(n, t) {
3699
- return t === !1 ? ot() ? O(1, n) : -O(1, n) : O(-n, n);
3733
+ return t === !1 ? nt() ? O(1, n) : -O(1, n) : O(-n, n);
3700
3734
  }
3701
3735
  function Bt(n, t) {
3702
3736
  const e = x.pythagoreanTripletsWithTarget(n).filter((i) => t === !0 || !i.includes(0));
@@ -3707,12 +3741,12 @@ function St(n) {
3707
3741
  return n !== void 0 && (t = t.filter((e) => e < n)), W(t);
3708
3742
  }
3709
3743
  function It(n, t) {
3710
- return t === void 0 && (t = 1), n.length <= 0 ? Object.values(n) : ht(n).slice(0, t);
3744
+ return t === void 0 && (t = 1), n.length <= 0 ? Object.values(n) : ot(n).slice(0, t);
3711
3745
  }
3712
3746
  function W(n) {
3713
3747
  return n.length === 0 ? null : n[O(0, n.length - 1)];
3714
3748
  }
3715
- function ht(n) {
3749
+ function ot(n) {
3716
3750
  const t = Object.values(n);
3717
3751
  for (let e = t.length - 1; e > 0; e--) {
3718
3752
  const i = Math.floor(Math.random() * (e + 1)), s = t[e];
@@ -3721,8 +3755,8 @@ function ht(n) {
3721
3755
  return t;
3722
3756
  }
3723
3757
  class E {
3724
- static PARALLEL = L.Parallel;
3725
- static PERPENDICULAR = L.Perpendicular;
3758
+ static PARALLEL = V.Parallel;
3759
+ static PERPENDICULAR = V.Perpendicular;
3726
3760
  #t;
3727
3761
  // ax + by + c = 0
3728
3762
  #e;
@@ -3738,7 +3772,7 @@ class E {
3738
3772
  * @param values
3739
3773
  */
3740
3774
  constructor(...t) {
3741
- return this.#e = new a().zero(), this.#i = new a().zero(), this.#s = new a().zero(), this.#t = new g(), this.#r = "lr", t.length > 0 && this.parse(...t), this;
3775
+ return this.#e = new h().zero(), this.#i = new h().zero(), this.#s = new h().zero(), this.#t = new g(), this.#r = "lr", t.length > 0 && this.parse(...t), this;
3742
3776
  }
3743
3777
  // ------------------------------------------
3744
3778
  /**
@@ -3768,7 +3802,7 @@ class E {
3768
3802
  if (t[0] instanceof w && t[1] instanceof g)
3769
3803
  return this.fromPointAndDirection(t[0], t[1]);
3770
3804
  }
3771
- return t.length === 3 && t.every((e) => a.isFraction(e)) ? this.fromCoefficient(
3805
+ return t.length === 3 && t.every((e) => h.isFraction(e)) ? this.fromCoefficient(
3772
3806
  t[0],
3773
3807
  t[1],
3774
3808
  t[2]
@@ -3783,13 +3817,13 @@ class E {
3783
3817
  case 0:
3784
3818
  return this.getEquation().reorder().tex;
3785
3819
  case 2:
3786
- return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new l().parse("x", this.slope, this.height).tex;
3820
+ return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new u().parse("x", this.slope, this.height).tex;
3787
3821
  case 3:
3788
3822
  case 4: {
3789
3823
  const e = this.d.clone().simplify();
3790
3824
  return t === 3 ? `${g.asTex("x", "y")} = ${g.asTex(this.#t.x.tex, this.#t.y.tex)} + k\\cdot ${g.asTex(e.x.tex, e.y.tex)}` : `\\left\\{\\begin{aligned}
3791
- x &= ${new l(this.#t.x).add(new p(e.x).multiply(new p("k"))).reorder("k", !0).tex}\\\\
3792
- y &= ${new l(this.#t.y).add(new p(e.y).multiply(new p("k"))).reorder("k", !0).tex}
3825
+ x &= ${new u(this.#t.x).add(new p(e.x).multiply(new p("k"))).reorder("k", !0).tex}\\\\
3826
+ y &= ${new u(this.#t.y).add(new p(e.y).multiply(new p("k"))).reorder("k", !0).tex}
3793
3827
  \\end{aligned}\\right.`;
3794
3828
  }
3795
3829
  default: {
@@ -3804,13 +3838,13 @@ class E {
3804
3838
  case 0:
3805
3839
  return this.getEquation().reorder().display;
3806
3840
  case 2:
3807
- return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new l().parse("x", this.slope, this.height).display;
3841
+ return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new u().parse("x", this.slope, this.height).display;
3808
3842
  case 3: {
3809
3843
  const e = this.d.clone().simplify();
3810
3844
  return `((x,y))=((${this.#t.x.display},${this.#t.y.display}))+k((${e.x.display},${e.y.display}))`;
3811
3845
  }
3812
3846
  case 4: {
3813
- const e = this.d.clone().simplify(), i = new l(this.#t.x).add(new p(e.x).multiply(new p("k"))).reorder("k", !0), s = new l(this.#t.y).add(new p(e.y).multiply(new p("k"))).reorder("k", !0);
3847
+ const e = this.d.clone().simplify(), i = new u(this.#t.x).add(new p(e.x).multiply(new p("k"))).reorder("k", !0), s = new u(this.#t.y).add(new p(e.y).multiply(new p("k"))).reorder("k", !0);
3814
3848
  return `{(x,=,${i.display}),(y,=,${s.display}):}`;
3815
3849
  }
3816
3850
  default: {
@@ -3878,13 +3912,13 @@ class E {
3878
3912
  return i.isZero() ? new T(0) : new T().from(2, i.inverse(), e).reduce();
3879
3913
  }
3880
3914
  fromCoefficient(t, e, i) {
3881
- this.#e = new a(t), this.#i = new a(e), this.#s = new a(i);
3915
+ this.#e = new h(t), this.#i = new h(e), this.#s = new h(i);
3882
3916
  const s = [this.#e, this.#i, this.#s].every((o) => o.exact) ? x.lcm(this.#e.denominator, this.#i.denominator, this.#s.denominator) : 1;
3883
3917
  if (s > 1 && (this.#e.multiply(s).reduce(), this.#i.multiply(s).reduce(), this.#s.multiply(s).reduce()), this.#i.isZero())
3884
3918
  return this.#t = new g(this.#s.clone().divide(this.#e).opposite(), 0), this;
3885
3919
  for (let o = 0; o < this.#i.value; o++) {
3886
- const h = this.#e.clone().divide(this.#i).multiply(o).subtract(this.#s.clone().divide(this.#i)).reduce();
3887
- if (this.#t = new g(o, h), h.isRelative())
3920
+ const a = this.#e.clone().divide(this.#i).multiply(o).subtract(this.#s.clone().divide(this.#i)).reduce();
3921
+ if (this.#t = new g(o, a), a.isRelative())
3888
3922
  return this;
3889
3923
  }
3890
3924
  const r = this.#s.clone().divide(this.#i).opposite().reduce();
@@ -3912,8 +3946,8 @@ class E {
3912
3946
  fromPointAndDirection(t, e) {
3913
3947
  return this.#r = e.x.isPositive() ? "lr" : "rl", this.fromPointAndNormal(t, e.clone().normal());
3914
3948
  }
3915
- fromPointAndLine(t, e, i = L.Parallel) {
3916
- return i === L.Perpendicular ? this.fromPointAndNormal(t, e.director) : this.fromPointAndNormal(t, e.normal);
3949
+ fromPointAndLine(t, e, i = V.Parallel) {
3950
+ return i === V.Perpendicular ? this.fromPointAndNormal(t, e.director) : this.fromPointAndNormal(t, e.normal);
3917
3951
  }
3918
3952
  fromPointAndNormal = (t, e) => e.isZero() ? (console.warn("Normal vector is null."), this) : (this.fromCoefficient(
3919
3953
  e.x,
@@ -3927,15 +3961,15 @@ class E {
3927
3961
  }
3928
3962
  // ------------------------------------------
3929
3963
  getEquation() {
3930
- return new v(new l().parse("xy", this.#e, this.#i, this.#s), new l("0")).simplify();
3964
+ return new v(new u().parse("xy", this.#e, this.#i, this.#s), new u("0")).simplify();
3931
3965
  }
3932
3966
  getValueAtX = (t) => {
3933
- const e = this.getEquation().isolate("y"), i = new a(t);
3934
- return e instanceof v ? e.right.evaluate({ x: i }) : new a().invalid();
3967
+ const e = this.getEquation().isolate("y"), i = new h(t);
3968
+ return e instanceof v ? e.right.evaluate({ x: i }) : new h().invalid();
3935
3969
  };
3936
3970
  getValueAtY = (t) => {
3937
- const e = this.getEquation().isolate("x"), i = new a(t);
3938
- return e instanceof v ? e.right.evaluate({ y: i }) : new a().invalid();
3971
+ const e = this.getEquation().isolate("x"), i = new h(t);
3972
+ return e instanceof v ? e.right.evaluate({ y: i }) : new h().invalid();
3939
3973
  };
3940
3974
  get height() {
3941
3975
  return this.#s.clone().opposite().divide(this.#i);
@@ -3949,7 +3983,7 @@ class E {
3949
3983
  intersection = (t) => {
3950
3984
  const e = new w();
3951
3985
  let i = !1, s = !1;
3952
- return this.#i.isZero() || t.b.isZero(), this.isParallelTo(t) ? (e.x = new a().invalid(), e.y = new a().invalid(), i = !0) : this.isSameAs(t) ? (e.x = new a().invalid(), e.y = new a().invalid(), s = !0) : (e.x = this.#i.clone().multiply(t.c).subtract(this.#s.clone().multiply(t.b)).divide(this.#e.clone().multiply(t.b).subtract(this.#i.clone().multiply(t.a))), e.y = this.#e.clone().multiply(t.c).subtract(this.#s.clone().multiply(t.a)).divide(this.#i.clone().multiply(t.a).subtract(this.#e.clone().multiply(t.b)))), {
3986
+ return this.#i.isZero() || t.b.isZero(), this.isParallelTo(t) ? (e.x = new h().invalid(), e.y = new h().invalid(), i = !0) : this.isSameAs(t) ? (e.x = new h().invalid(), e.y = new h().invalid(), s = !0) : (e.x = this.#i.clone().multiply(t.c).subtract(this.#s.clone().multiply(t.b)).divide(this.#e.clone().multiply(t.b).subtract(this.#i.clone().multiply(t.a))), e.y = this.#e.clone().multiply(t.c).subtract(this.#s.clone().multiply(t.a)).divide(this.#i.clone().multiply(t.a).subtract(this.#e.clone().multiply(t.b)))), {
3953
3987
  point: e,
3954
3988
  hasIntersection: !(i || s),
3955
3989
  isParallel: i,
@@ -3998,7 +4032,7 @@ class E {
3998
4032
  return this.#e.clone().opposite().divide(this.#i);
3999
4033
  }
4000
4034
  }
4001
- class V {
4035
+ class L {
4002
4036
  // This defines the triangle
4003
4037
  #t = new w();
4004
4038
  #e = new w();
@@ -4018,7 +4052,7 @@ class V {
4018
4052
  return t.length > 0 && this.parse(...t), this;
4019
4053
  }
4020
4054
  parse = (...t) => {
4021
- if (t.length === 1 && t[0] instanceof V)
4055
+ if (t.length === 1 && t[0] instanceof L)
4022
4056
  return this.copy(t[0]);
4023
4057
  if (t.length === 3) {
4024
4058
  if (t.every((e) => typeof e == "string")) {
@@ -4031,7 +4065,7 @@ class V {
4031
4065
  return this.fromPoints(t[0], t[1], t[2]);
4032
4066
  }
4033
4067
  if (t.length === 6) {
4034
- const e = t.map((i) => new a(i));
4068
+ const e = t.map((i) => new h(i));
4035
4069
  if (e.some((i) => i.isNaN()))
4036
4070
  throw new Error("One of the values is not a valid number");
4037
4071
  return this.fromCoordinates(e[0], e[1], e[2], e[3], e[4], e[5]);
@@ -4041,7 +4075,7 @@ class V {
4041
4075
  /**
4042
4076
  * Clone the Triangle class
4043
4077
  */
4044
- clone = () => new V(
4078
+ clone = () => new L(
4045
4079
  this.#t.clone(),
4046
4080
  this.#e.clone(),
4047
4081
  this.#i.clone()
@@ -4060,10 +4094,10 @@ class V {
4060
4094
  this.#t = t, this.#t.onChange = () => this.reset(), this.reset();
4061
4095
  }
4062
4096
  get AB() {
4063
- return this.#c("A", "B");
4097
+ return this.#h("A", "B");
4064
4098
  }
4065
4099
  get AC() {
4066
- return this.#c("A", "C");
4100
+ return this.#h("A", "C");
4067
4101
  }
4068
4102
  get B() {
4069
4103
  return this.#e;
@@ -4072,10 +4106,10 @@ class V {
4072
4106
  this.#e = t, this.#e.onChange = () => this.reset(), this.reset();
4073
4107
  }
4074
4108
  get BA() {
4075
- return this.#c("B", "A");
4109
+ return this.#h("B", "A");
4076
4110
  }
4077
4111
  get BC() {
4078
- return this.#c("B", "C");
4112
+ return this.#h("B", "C");
4079
4113
  }
4080
4114
  get C() {
4081
4115
  return this.#i;
@@ -4084,10 +4118,10 @@ class V {
4084
4118
  this.#i = t, this.#i.onChange = () => this.reset(), this.reset();
4085
4119
  }
4086
4120
  get CA() {
4087
- return this.#c("C", "A");
4121
+ return this.#h("C", "A");
4088
4122
  }
4089
4123
  get CB() {
4090
- return this.#c("C", "B");
4124
+ return this.#h("C", "B");
4091
4125
  }
4092
4126
  get asDegree() {
4093
4127
  return this.#n = !1, this;
@@ -4104,17 +4138,17 @@ class V {
4104
4138
  }
4105
4139
  fromLines(t, e, i) {
4106
4140
  const s = new E(t).clone(), r = new E(e).clone(), o = new E(i).clone();
4107
- let h = s.intersection(r);
4108
- if (h.hasIntersection)
4109
- this.#e = h.point;
4141
+ let a = s.intersection(r);
4142
+ if (a.hasIntersection)
4143
+ this.#e = a.point;
4110
4144
  else
4111
4145
  return this.#s = !1, this;
4112
- if (h = r.intersection(o), h.hasIntersection)
4113
- this.#i = h.point;
4146
+ if (a = r.intersection(o), a.hasIntersection)
4147
+ this.#i = a.point;
4114
4148
  else
4115
4149
  return this.#s = !1, this;
4116
- if (h = o.intersection(s), h.hasIntersection)
4117
- this.#t = h.point;
4150
+ if (a = o.intersection(s), a.hasIntersection)
4151
+ this.#t = a.point;
4118
4152
  else
4119
4153
  return this.#s = !1, this;
4120
4154
  return this.reset(), this.#r = { AB: s, AC: o, BC: r }, this;
@@ -4124,12 +4158,12 @@ class V {
4124
4158
  }
4125
4159
  getAngle(t) {
4126
4160
  const e = this.BC.norm, i = this.AC.norm, s = this.AB.norm;
4127
- return t === "A" ? this.#a(e, i, s) : t === "C" ? this.#a(s, i, e) : this.#a(i, e, s);
4161
+ return t === "A" ? this.#c(e, i, s) : t === "C" ? this.#c(s, i, e) : this.#c(i, e, s);
4128
4162
  }
4129
4163
  getBisectors(t = !0) {
4130
4164
  if (t && this.#o.bisectors) return this.#o.bisectors;
4131
4165
  if (!t && this.#o.externalBisectors) return this.#o.externalBisectors;
4132
- const e = this.#h("A", t), i = this.#h("B", t), s = this.#h("C", t), r = e.intersection(i).point;
4166
+ const e = this.#a("A", t), i = this.#a("B", t), s = this.#a("C", t), r = e.intersection(i).point;
4133
4167
  return t ? this.#o.bisectors = { A: e, B: i, C: s, intersection: r } : this.#o.externalBisectors = { A: e, B: i, C: s, intersection: r }, { A: e, B: i, C: s, intersection: r };
4134
4168
  }
4135
4169
  getHeights() {
@@ -4220,15 +4254,15 @@ class V {
4220
4254
  bisectors: null
4221
4255
  }, this;
4222
4256
  }
4223
- #h(t, e = !0) {
4257
+ #a(t, e = !0) {
4224
4258
  const i = this.lines;
4225
4259
  let s = new g(), r = new g(), o = new w();
4226
4260
  if (t === "A" ? (o = this.A.clone(), s = i.AB.clone().d, r = i.AC.clone().d) : t === "B" ? (o = this.B.clone(), s = i.AB.clone().d.opposite(), r = i.BC.clone().d) : t === "C" && (o = this.C.clone(), s = i.BC.clone().d.opposite(), r = i.AC.clone().d.opposite()), s === void 0 || r === void 0)
4227
4261
  throw new Error(`The point ${t} does not exist`);
4228
- const h = e ? s.unit().add(r.unit()) : s.unit().subtract(r.unit());
4229
- return new E().fromPointAndDirection(o, h);
4262
+ const a = e ? s.unit().add(r.unit()) : s.unit().subtract(r.unit());
4263
+ return new E().fromPointAndDirection(o, a);
4230
4264
  }
4231
- #a(t, e, i) {
4265
+ #c(t, e, i) {
4232
4266
  const s = (e ** 2 + i ** 2 - t ** 2) / (2 * e * i);
4233
4267
  return this.#n ? Math.acos(s) : x.numberCorrection(Math.acos(s) * 180 / Math.PI);
4234
4268
  }
@@ -4252,12 +4286,12 @@ class V {
4252
4286
  * @param ptName1
4253
4287
  * @param ptName2
4254
4288
  */
4255
- #c = (t, e) => new g(
4289
+ #h = (t, e) => new g(
4256
4290
  this.#l(t),
4257
4291
  this.#l(e)
4258
4292
  );
4259
4293
  }
4260
- class j {
4294
+ class U {
4261
4295
  #t = null;
4262
4296
  #e = null;
4263
4297
  #i = 1;
@@ -4266,14 +4300,14 @@ class j {
4266
4300
  t.length > 0 && this.parse(...t);
4267
4301
  }
4268
4302
  parse(...t) {
4269
- return typeof t[0] == "string" ? this.fromString(t[0]) : t[0] instanceof v ? this.fromEquation(t[0]) : t[0] instanceof j ? this.copy(t[0]) : t.length === 2 && t[0] instanceof w && t[1] instanceof w ? this.fromCenterPoint(t[0], t[1]) : t.length >= 2 && t[0] instanceof w && (t[1] instanceof a || typeof t[1] == "number") ? this.fromCenterRadius(
4303
+ return typeof t[0] == "string" ? this.fromString(t[0]) : t[0] instanceof v ? this.fromEquation(t[0]) : t[0] instanceof U ? this.copy(t[0]) : t.length === 2 && t[0] instanceof w && t[1] instanceof w ? this.fromCenterPoint(t[0], t[1]) : t.length >= 2 && t[0] instanceof w && (t[1] instanceof h || typeof t[1] == "number") ? this.fromCenterRadius(
4270
4304
  t[0],
4271
4305
  t[1],
4272
4306
  typeof t[2] == "boolean" ? t[2] : !1
4273
4307
  ) : this;
4274
4308
  }
4275
4309
  clone() {
4276
- return new j().fromCenterRadius(
4310
+ return new U().fromCenterRadius(
4277
4311
  this.center.clone(),
4278
4312
  this.squareRadius.clone(),
4279
4313
  !0
@@ -4310,7 +4344,7 @@ class j {
4310
4344
  return this.#t = t.clone(), this.#s = new g(this.#t, e).normSquare, this.#r(), this;
4311
4345
  }
4312
4346
  fromCenterRadius(t, e, i) {
4313
- return this.#t = t.clone(), i ? this.#s = new a(e) : this.#s = new a(e).pow(2), this.#r(), this;
4347
+ return this.#t = t.clone(), i ? this.#s = new h(e) : this.#s = new h(e).pow(2), this.#r(), this;
4314
4348
  }
4315
4349
  fromEquation(t) {
4316
4350
  if (t.moveLeft(), t.degree("x").value === 2 && t.degree("y").value === 2) {
@@ -4323,7 +4357,7 @@ class j {
4323
4357
  return this;
4324
4358
  }
4325
4359
  fromPoints(t, e, i) {
4326
- const s = new V(t, e, i);
4360
+ const s = new L(t, e, i);
4327
4361
  if (!s.isValid || !s.remarquables)
4328
4362
  return this.#n(), this;
4329
4363
  const r = s.getMediators().c.clone(), o = s.getMediators().b.clone();
@@ -4340,7 +4374,7 @@ class j {
4340
4374
  return t.forEach((i) => {
4341
4375
  for (const s of [[1, 1], [-1, 1], [-1, -1], [1, -1]]) {
4342
4376
  const r = this.center.x.clone().add(s[0] * i[0]), o = this.center.y.clone().add(s[1] * i[1]);
4343
- e.every((h) => !h.isEqualXY(r, o)) && e.push(new w(r, o));
4377
+ e.every((a) => !a.isEqualXY(r, o)) && e.push(new w(r, o));
4344
4378
  }
4345
4379
  }), e;
4346
4380
  }
@@ -4355,7 +4389,7 @@ class j {
4355
4389
  */
4356
4390
  lineIntersection(t) {
4357
4391
  if (this.#e === null) return [];
4358
- const e = this.center, i = t.d, s = t.OA, r = i.normSquare, o = s.x.clone().subtract(e.x).multiply(i.x).add(s.y.clone().subtract(e.y).multiply(i.y)).multiply(2), h = s.x.clone().subtract(e.x).pow(2).add(s.y.clone().subtract(e.y).pow(2)).subtract(this.squareRadius), c = C.fromQuadratic(r, o, h);
4392
+ const e = this.center, i = t.d, s = t.OA, r = i.normSquare, o = s.x.clone().subtract(e.x).multiply(i.x).add(s.y.clone().subtract(e.y).multiply(i.y)).multiply(2), a = s.x.clone().subtract(e.x).pow(2).add(s.y.clone().subtract(e.y).pow(2)).subtract(this.squareRadius), c = C.fromQuadratic(r, o, a);
4359
4393
  if (c.length === 0) return [];
4360
4394
  if (c.length === 1) {
4361
4395
  const d = s.add(i.clone().multiplyByScalar(c[0].fraction));
@@ -4384,16 +4418,16 @@ class j {
4384
4418
  return e - i > 1e-10 ? 0 : Math.abs(e - i) < 1e-10 ? 1 : 2;
4385
4419
  }
4386
4420
  setRadius(t, e) {
4387
- return e ? this.#s = new a(t) : this.#s = new a(t).pow(2), this.#r(), this;
4421
+ return e ? this.#s = new h(t) : this.#s = new h(t).pow(2), this.#r(), this;
4388
4422
  }
4389
4423
  get squareRadius() {
4390
- return this.#s?.clone() ?? new a(-1);
4424
+ return this.#s?.clone() ?? new h(-1);
4391
4425
  }
4392
- tangents = (t) => t instanceof a ? this.#a(t) : this.isPointOnCircle(t) ? this.#o(t) : this.#t !== null && this.#t.distanceTo(t).value > this.radius.value ? this.#h(t) : [];
4426
+ tangents = (t) => t instanceof h ? this.#c(t) : this.isPointOnCircle(t) ? this.#o(t) : this.#t !== null && this.#t.distanceTo(t).value > this.radius.value ? this.#a(t) : [];
4393
4427
  #r() {
4394
4428
  this.#e = new v(
4395
- new l(`(x-(${this.center.x.display}))^2+(y-(${this.center.y.display}))^2`),
4396
- new l(this.squareRadius.display)
4429
+ new u(`(x-(${this.center.x.display}))^2+(y-(${this.center.y.display}))^2`),
4430
+ new u(this.squareRadius.display)
4397
4431
  ).moveLeft();
4398
4432
  }
4399
4433
  #n() {
@@ -4403,17 +4437,17 @@ class j {
4403
4437
  const e = new g(this.center, t);
4404
4438
  return [new E().fromPointAndNormal(t, e)];
4405
4439
  };
4406
- #h = (t) => {
4407
- const e = this.center.x.clone().subtract(t.x), i = this.center.y.clone().subtract(t.y), s = new l("x"), r = new l("x^2+1");
4440
+ #a = (t) => {
4441
+ const e = this.center.x.clone().subtract(t.x), i = this.center.y.clone().subtract(t.y), s = new u("x"), r = new u("x^2+1");
4408
4442
  return s.multiply(e).subtract(i).pow(2), r.multiply(this.squareRadius), new v(s, r).solve().map((c) => {
4409
4443
  let f;
4410
4444
  const m = new v("y", "x");
4411
4445
  return c.exact ? (f = t.x.clone().opposite().multiply(c.fraction).add(t.y), m.right.multiply(c.fraction).add(f)) : (f = t.x.clone().opposite().multiply(c.value).add(t.y), m.right.multiply(c.value).add(f)), new E(m);
4412
4446
  });
4413
4447
  };
4414
- #a = (t) => {
4415
- const e = t.numerator, i = -t.denominator, s = this.center.x.clone(), r = this.center.y.clone(), o = this.squareRadius.clone().multiply(t.numerator ** 2 + t.denominator ** 2), h = s.clone().multiply(e).opposite().subtract(r.clone().multiply(i)).add(o.clone().sqrt()), c = s.clone().multiply(e).opposite().subtract(r.clone().multiply(i)).subtract(o.clone().sqrt());
4416
- return [new E(e, i, h), new E(e, i, c)];
4448
+ #c = (t) => {
4449
+ const e = t.numerator, i = -t.denominator, s = this.center.x.clone(), r = this.center.y.clone(), o = this.squareRadius.clone().multiply(t.numerator ** 2 + t.denominator ** 2), a = s.clone().multiply(e).opposite().subtract(r.clone().multiply(i)).add(o.clone().sqrt()), c = s.clone().multiply(e).opposite().subtract(r.clone().multiply(i)).subtract(o.clone().sqrt());
4450
+ return [new E(e, i, a), new E(e, i, c)];
4417
4451
  };
4418
4452
  }
4419
4453
  class X {
@@ -4431,19 +4465,19 @@ class X {
4431
4465
  return {
4432
4466
  parametric: `${g.asTex("x", "y", "z")} = ${g.asTex(this.#t.x.tex, this.#t.y.tex, this.#t.z.tex)} + k\\cdot ${g.asTex(this.#e.x.tex, this.#e.y.tex, this.#e.z.tex)}`,
4433
4467
  system: `\\left\\{\\begin{aligned}
4434
- x &= ${new l(this.#t.x).add(new p(this.#e.x).multiply(new p("k"))).reorder("k", !0).tex}\\\\
4435
- y &= ${new l(this.#t.y).add(new p(this.#e.y).multiply(new p("k"))).reorder("k", !0).tex}\\\\
4436
- z &= ${new l(this.#t.z).add(new p(this.#e.z).multiply(new p("k"))).reorder("k", !0).tex}
4468
+ x &= ${new u(this.#t.x).add(new p(this.#e.x).multiply(new p("k"))).reorder("k", !0).tex}\\\\
4469
+ y &= ${new u(this.#t.y).add(new p(this.#e.y).multiply(new p("k"))).reorder("k", !0).tex}\\\\
4470
+ z &= ${new u(this.#t.z).add(new p(this.#e.z).multiply(new p("k"))).reorder("k", !0).tex}
4437
4471
  \\end{aligned}\\right.`,
4438
- cartesian: `\\frac{ ${new l("x", 1, this.#t.x.clone().opposite()).tex} }{ ${this.direction.x.tex} } = \\frac{ ${new l("y", 1, this.#t.y.clone().opposite()).tex} }{ ${this.direction.y.tex} } = \\frac{ ${new l("z", 1, this.#t.z.clone().opposite()).tex} }{ ${this.direction.z.tex} }`
4472
+ cartesian: `\\frac{ ${new u("x", 1, this.#t.x.clone().opposite()).tex} }{ ${this.direction.x.tex} } = \\frac{ ${new u("y", 1, this.#t.y.clone().opposite()).tex} }{ ${this.direction.y.tex} } = \\frac{ ${new u("z", 1, this.#t.z.clone().opposite()).tex} }{ ${this.direction.z.tex} }`
4439
4473
  };
4440
4474
  }
4441
4475
  get display() {
4442
- const t = this.#t.x.display, e = this.#t.y.display, i = this.#t.z.display, s = this.direction.simplify(), r = s.x.display, o = s.y.display, h = s.z.display;
4476
+ const t = this.#t.x.display, e = this.#t.y.display, i = this.#t.z.display, s = this.direction.simplify(), r = s.x.display, o = s.y.display, a = s.z.display;
4443
4477
  return {
4444
4478
  parametric: `${g.asDisplay("x", "y", "z")} = ${g.asDisplay(this.#t.x.display, this.#t.y.display, this.#t.z.display)} + k\\cdot ${g.asDisplay(this.#e.x.display, this.#e.y.display, this.#e.z.display)}`,
4445
4479
  system: "",
4446
- cartesian: `(x-${t})/${r} = (y-${e})/${o} = (z-${i})/${h}`
4480
+ cartesian: `(x-${t})/${r} = (y-${e})/${o} = (z-${i})/${a}`
4447
4481
  };
4448
4482
  }
4449
4483
  get OA() {
@@ -4462,11 +4496,11 @@ class X {
4462
4496
  return this.#e.clone();
4463
4497
  }
4464
4498
  distanceTo(t) {
4465
- const e = new g(this.#t, t), i = this.direction, s = this.direction.normSquare, r = e.cross(i).normSquare, o = r.clone().divide(s), h = o.clone().sqrt();
4499
+ const e = new g(this.#t, t), i = this.direction, s = this.direction.normSquare, r = e.cross(i).normSquare, o = r.clone().divide(s), a = o.clone().sqrt();
4466
4500
  return {
4467
4501
  value: Math.sqrt(o.value),
4468
4502
  fraction: o.clone().sqrt(),
4469
- tex: h.exact ? h.tex : `\\sqrt{${o.tex}}`
4503
+ tex: a.exact ? a.tex : `\\sqrt{${o.tex}}`
4470
4504
  };
4471
4505
  }
4472
4506
  // ------------------------------------------
@@ -4498,7 +4532,7 @@ class X {
4498
4532
  return this.#t.clone();
4499
4533
  }
4500
4534
  randomPoint = (t = 5) => {
4501
- const e = this.#t.clone(), i = new a(A(t, !1));
4535
+ const e = this.#t.clone(), i = new h(A(t, !1));
4502
4536
  return new w(
4503
4537
  e.x.clone().add(this.#e.x.clone().multiply(i)),
4504
4538
  e.y.clone().add(this.#e.y.clone().multiply(i)),
@@ -4525,7 +4559,7 @@ class X {
4525
4559
  throw new Error("Method not implemented.");
4526
4560
  };
4527
4561
  }
4528
- class et {
4562
+ class tt {
4529
4563
  #t = new g(0, 0, 1);
4530
4564
  #e = new w(0, 0, 0);
4531
4565
  constructor(t) {
@@ -4560,21 +4594,21 @@ class et {
4560
4594
  }
4561
4595
  get tex() {
4562
4596
  return new v(
4563
- new l("xyz", this.a, this.b, this.c, this.d),
4564
- new l(0)
4597
+ new u("xyz", this.a, this.b, this.c, this.d),
4598
+ new u(0)
4565
4599
  ).reduce().tex;
4566
4600
  }
4567
4601
  get display() {
4568
4602
  return new v(
4569
- new l("xyz", this.a, this.b, this.c, this.d),
4570
- new l(0)
4603
+ new u("xyz", this.a, this.b, this.c, this.d),
4604
+ new u(0)
4571
4605
  ).reduce().display;
4572
4606
  }
4573
4607
  get a() {
4574
4608
  return this.#t.x;
4575
4609
  }
4576
4610
  angle(t, e, i) {
4577
- if (t instanceof et)
4611
+ if (t instanceof tt)
4578
4612
  return this.normal.angle(t.normal, e, i);
4579
4613
  let s;
4580
4614
  if (t instanceof g) {
@@ -4622,14 +4656,14 @@ class et {
4622
4656
  this.#e = new w(t);
4623
4657
  }
4624
4658
  }
4625
- var at = /* @__PURE__ */ ((n) => (n[n.INTERIOR = 0] = "INTERIOR", n[n.EXTERIOR = 1] = "EXTERIOR", n[n.SECANT = 2] = "SECANT", n[n.TANGENT_INSIDE = 3] = "TANGENT_INSIDE", n[n.TANGENT_OUTSIDE = 4] = "TANGENT_OUTSIDE", n[n.SUPERPOSED = 5] = "SUPERPOSED", n[n.CONCENTRIC = 6] = "CONCENTRIC", n))(at || {});
4659
+ var ht = /* @__PURE__ */ ((n) => (n[n.INTERIOR = 0] = "INTERIOR", n[n.EXTERIOR = 1] = "EXTERIOR", n[n.SECANT = 2] = "SECANT", n[n.TANGENT_INSIDE = 3] = "TANGENT_INSIDE", n[n.TANGENT_OUTSIDE = 4] = "TANGENT_OUTSIDE", n[n.SUPERPOSED = 5] = "SUPERPOSED", n[n.CONCENTRIC = 6] = "CONCENTRIC", n))(ht || {});
4626
4660
  class zt {
4627
4661
  #t = void 0;
4628
4662
  #e = void 0;
4629
4663
  #i = void 0;
4630
4664
  #s = 1;
4631
4665
  constructor(t, e) {
4632
- return t && e && (this.#t = t, this.#e = new a(e).clone().pow(2), this.#n()), this;
4666
+ return t && e && (this.#t = t, this.#e = new h(e).clone().pow(2), this.#n()), this;
4633
4667
  }
4634
4668
  fromEquation(t) {
4635
4669
  const e = new v(t).moveLeft().reduce(), i = ["x", "y", "z"];
@@ -4695,7 +4729,7 @@ class zt {
4695
4729
  if (this.center[s].isZero())
4696
4730
  e.push(`${s}^2`);
4697
4731
  else {
4698
- const r = new l(s).subtract(this.center[s]);
4732
+ const r = new u(s).subtract(this.center[s]);
4699
4733
  e.push(
4700
4734
  t ? `\\(${r.tex}\\)^2` : `(${r.display})^2`
4701
4735
  );
@@ -4704,15 +4738,15 @@ class zt {
4704
4738
  };
4705
4739
  #n() {
4706
4740
  this.#i = new v(
4707
- new l("x").subtract(this.center.x).pow(2).add(
4708
- new l("y").subtract(this.center.y).pow(2)
4741
+ new u("x").subtract(this.center.x).pow(2).add(
4742
+ new u("y").subtract(this.center.y).pow(2)
4709
4743
  ).add(
4710
- new l("z").subtract(this.center.z).pow(2)
4744
+ new u("z").subtract(this.center.z).pow(2)
4711
4745
  ),
4712
- new l(this.squareRadius)
4746
+ new u(this.squareRadius)
4713
4747
  ).reduce();
4714
4748
  }
4715
- static RELATIVE_POSITION = at;
4749
+ static RELATIVE_POSITION = ht;
4716
4750
  relativePosition = (t) => {
4717
4751
  const e = this.center.distanceTo(t.center).value, i = this.radius.value, s = t.radius.value;
4718
4752
  return e > i + s ? 1 : e === i + s ? 4 : e === 0 ? i === s ? 5 : 6 : e === Math.abs(i - s) ? 3 : e < Math.abs(i - s) ? 0 : 2;
@@ -4733,7 +4767,7 @@ function F(n) {
4733
4767
  natural: !1
4734
4768
  },
4735
4769
  n
4736
- ), e = new a();
4770
+ ), e = new h();
4737
4771
  if (t.negative ? e.numerator = A(t.max, t.zero) : e.numerator = O(t.zero ? 0 : 1, t.max), t.natural)
4738
4772
  e.denominator = 1;
4739
4773
  else {
@@ -4743,7 +4777,7 @@ function F(n) {
4743
4777
  }
4744
4778
  return t.reduced ? e.reduce() : e;
4745
4779
  }
4746
- function ct(n) {
4780
+ function at(n) {
4747
4781
  const t = Object.assign(
4748
4782
  {
4749
4783
  letters: "x",
@@ -4768,7 +4802,7 @@ function ct(n) {
4768
4802
  e.setLetter(t.letters, t.degree);
4769
4803
  return e;
4770
4804
  }
4771
- const K = {
4805
+ const ct = {
4772
4806
  letters: "x",
4773
4807
  degree: 2,
4774
4808
  fraction: !1,
@@ -4780,17 +4814,18 @@ const K = {
4780
4814
  commonConstant: !1,
4781
4815
  positive: !0
4782
4816
  };
4783
- function it(n) {
4817
+ function et(n) {
4818
+ console.log(n);
4784
4819
  const t = Object.assign(
4785
- K,
4820
+ ct,
4786
4821
  n
4787
4822
  );
4788
- if (t.factorable) return Pt(K);
4789
- const e = new l().empty();
4823
+ if (console.log(">>>>"), console.log(t), t.factorable) return Pt(t);
4824
+ const e = new u().empty();
4790
4825
  let i;
4791
4826
  const s = t.degree ?? 2;
4792
4827
  for (let r = s; r >= 0; r--)
4793
- i = ct({
4828
+ i = at({
4794
4829
  letters: t.letters,
4795
4830
  degree: r,
4796
4831
  fraction: t.fraction,
@@ -4805,18 +4840,18 @@ function it(n) {
4805
4840
  }
4806
4841
  function Pt(n) {
4807
4842
  const t = Object.assign(
4808
- K,
4843
+ ct,
4809
4844
  n
4810
4845
  ), e = { ...t };
4811
4846
  e.degree = 1, e.factorable = !1;
4812
4847
  const i = [], s = t.degree ?? 2;
4813
4848
  for (; i.length < s; )
4814
- i.push(it(e));
4849
+ i.push(et(e));
4815
4850
  if (n?.commonConstant !== !1) {
4816
4851
  let r = A(10, !1);
4817
- n?.commonConstant === !0 && (r === 1 || r === -1) && (r *= O(2, 5)), r !== 1 && r !== -1 && i.unshift(new l(r));
4852
+ n?.commonConstant === !0 && (r === 1 || r === -1) && (r *= O(2, 5)), r !== 1 && r !== -1 && i.unshift(new u(r));
4818
4853
  }
4819
- return l.xMultiply(...i);
4854
+ return u.xMultiply(...i);
4820
4855
  }
4821
4856
  function Rt(n) {
4822
4857
  const t = Object.assign(
@@ -4838,9 +4873,9 @@ function Rt(n) {
4838
4873
  }
4839
4874
  },
4840
4875
  n
4841
- ), e = new l().one();
4876
+ ), e = new u().one();
4842
4877
  for (let i = 0; i < t.degree; i++) {
4843
- const s = it({
4878
+ const s = et({
4844
4879
  degree: 1,
4845
4880
  unit: t.unit,
4846
4881
  fraction: t.fraction,
@@ -4851,7 +4886,7 @@ function Rt(n) {
4851
4886
  }
4852
4887
  return new v(e, 0);
4853
4888
  }
4854
- function J(n) {
4889
+ function K(n) {
4855
4890
  const t = Object.assign(
4856
4891
  {
4857
4892
  axis: !0,
@@ -4860,7 +4895,7 @@ function J(n) {
4860
4895
  quadrant: null
4861
4896
  },
4862
4897
  n
4863
- ), e = t.axis === "x", i = t.axis === "y", s = t.fraction ? F({ max: t.max, zero: e }) : new a(A(t.max, e)), r = t.fraction ? F({ max: t.max, zero: i }) : new a(A(t.max, i));
4898
+ ), e = t.axis === "x", i = t.axis === "y", s = t.fraction ? F({ max: t.max, zero: e }) : new h(A(t.max, e)), r = t.fraction ? F({ max: t.max, zero: i }) : new h(A(t.max, i));
4864
4899
  return Number(t.quadrant) === 1 && (s.abs(), r.abs()), Number(t.quadrant) === 2 && (s.isPositive() && s.opposite(), r.isNegative() && r.opposite()), Number(t.quadrant) === 3 && (s.isPositive() && s.opposite(), r.isPositive() && r.opposite()), Number(t.quadrant) === 4 && (s.isNegative() && s.opposite(), r.isPositive() && r.opposite()), new w(s, r);
4865
4900
  }
4866
4901
  function Zt(n) {
@@ -4873,9 +4908,9 @@ function Zt(n) {
4873
4908
  pointsOnCircle: 8
4874
4909
  },
4875
4910
  n
4876
- ), e = J(t.center);
4911
+ ), e = K(t.center);
4877
4912
  let i, s;
4878
- return t.pointsOnCircle === 8 ? (i = O(1, 3), s = i ** 2 + (i + 1) ** 2) : s = O(1, 20), new j(e, s, !0);
4913
+ return t.pointsOnCircle === 8 ? (i = O(1, 3), s = i ** 2 + (i + 1) ** 2) : s = O(1, 20), new U(e, s, !0);
4879
4914
  }
4880
4915
  function Dt(n) {
4881
4916
  const t = Object.assign(
@@ -4891,7 +4926,7 @@ function Dt(n) {
4891
4926
  e.x = A(10, t.allow?.vertical ?? !0), e.y = A(10, t.allow?.horizontal ?? !0);
4892
4927
  return t.slope === 1 ? e.x.sign() !== e.y.sign() && e.y.opposite() : t.slope === -1 && e.x.sign() !== e.y.sign() && e.y.opposite(), new E().fromPointAndDirection(new g(t.A.x, t.A.y), e);
4893
4928
  }
4894
- function Lt(n) {
4929
+ function Vt(n) {
4895
4930
  const t = Object.assign(
4896
4931
  {
4897
4932
  A: {
@@ -4909,57 +4944,57 @@ function Lt(n) {
4909
4944
  ), e = new w(t.A.x, t.A.y, t.A.z), i = new g(t.direction.x, t.direction.y, t.direction.z);
4910
4945
  return new X(e, i);
4911
4946
  }
4912
- const Vt = {
4947
+ const Lt = {
4913
4948
  equation: (n) => Rt(n),
4914
- polynom: (n) => it(n),
4915
- monom: (n) => ct(n),
4949
+ polynom: (n) => et(n),
4950
+ monom: (n) => at(n),
4916
4951
  fraction: (n) => F(n),
4917
4952
  number: (n, t, e) => O(n, t, e),
4918
4953
  numberSym: (n, t) => A(n, t),
4919
4954
  prime: (n) => St(n),
4920
4955
  triplet: (n, t) => Bt(n, t),
4921
- bool: (n) => ot(n),
4956
+ bool: (n) => nt(n),
4922
4957
  array: (n, t) => It(n, t),
4923
4958
  item: (n) => W(n),
4924
- shuffle: (n) => ht(n),
4959
+ shuffle: (n) => ot(n),
4925
4960
  line: (n) => Dt(n),
4926
- line3: (n) => Lt(n),
4927
- vector: (n) => J(n),
4928
- point: (n) => new w(J(n)),
4961
+ line3: (n) => Vt(n),
4962
+ vector: (n) => K(n),
4963
+ point: (n) => new w(K(n)),
4929
4964
  circle: (n) => Zt(n)
4930
4965
  }, Ft = {
4931
4966
  Numeric: x,
4932
- Fraction: a,
4967
+ Fraction: h,
4933
4968
  Root: T,
4934
4969
  Monom: p,
4935
- Polynom: l,
4970
+ Polynom: u,
4936
4971
  Equation: v,
4937
4972
  Matrix: B,
4938
4973
  LinearSystem: z,
4939
4974
  Factor: b,
4940
4975
  PolyFactor: N,
4941
4976
  LogicalSet: qt,
4942
- Random: Vt,
4977
+ Random: Lt,
4943
4978
  Geometry: {
4944
4979
  Vector: g,
4945
4980
  Point: w,
4946
4981
  Line: E,
4947
- Triangle: V,
4948
- Circle: j,
4982
+ Triangle: L,
4983
+ Circle: U,
4949
4984
  Line3: X,
4950
- Plane3: et,
4985
+ Plane3: tt,
4951
4986
  Sphere3: zt
4952
4987
  },
4953
4988
  NumExp: Ct
4954
4989
  };
4955
4990
  export {
4956
- j as Circle,
4991
+ U as Circle,
4957
4992
  v as Equation,
4958
4993
  R as EquationSolver,
4959
4994
  D as FACTOR_DISPLAY,
4960
4995
  xt as FRAC_TYPE,
4961
4996
  b as Factor,
4962
- a as Fraction,
4997
+ h as Fraction,
4963
4998
  E as Line,
4964
4999
  X as Line3,
4965
5000
  z as LinearSystem,
@@ -4968,22 +5003,22 @@ export {
4968
5003
  p as Monom,
4969
5004
  Ct as NumExp,
4970
5005
  x as Numeric,
4971
- et as Plane3,
5006
+ tt as Plane3,
4972
5007
  w as Point,
4973
5008
  N as PolyFactor,
4974
- l as Polynom,
4975
- Vt as Random,
5009
+ u as Polynom,
5010
+ Lt as Random,
4976
5011
  T as Root,
4977
- at as SPHERE3_RELATIVE_POSITION,
5012
+ ht as SPHERE3_RELATIVE_POSITION,
4978
5013
  C as Solution,
4979
5014
  zt as Sphere3,
4980
- jt as TableOfSigns,
4981
- V as Triangle,
5015
+ Ut as TableOfSigns,
5016
+ L as Triangle,
4982
5017
  g as Vector,
4983
5018
  kt as areVectorsColinears,
4984
5019
  $t as areVectorsEquals,
4985
5020
  Ft as default,
4986
- Ut as determinantFromVectors,
5021
+ jt as determinantFromVectors,
4987
5022
  Mt as dotProduct
4988
5023
  };
4989
5024
  //# sourceMappingURL=pimath.js.map