@formatjs/intl-enumerator 1.8.5 → 1.8.6

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/polyfill.iife.js CHANGED
@@ -4,6 +4,2361 @@
4
4
  return !("supportedValuesOf" in Intl);
5
5
  }
6
6
 
7
+ // node_modules/.aspect_rules_js/decimal.js@10.4.3/node_modules/decimal.js/decimal.mjs
8
+ var EXP_LIMIT = 9e15;
9
+ var MAX_DIGITS = 1e9;
10
+ var NUMERALS = "0123456789abcdef";
11
+ var LN10 = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058";
12
+ var PI = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789";
13
+ var DEFAULTS = {
14
+ // These values must be integers within the stated ranges (inclusive).
15
+ // Most of these values can be changed at run-time using the `Decimal.config` method.
16
+ // The maximum number of significant digits of the result of a calculation or base conversion.
17
+ // E.g. `Decimal.config({ precision: 20 });`
18
+ precision: 20,
19
+ // 1 to MAX_DIGITS
20
+ // The rounding mode used when rounding to `precision`.
21
+ //
22
+ // ROUND_UP 0 Away from zero.
23
+ // ROUND_DOWN 1 Towards zero.
24
+ // ROUND_CEIL 2 Towards +Infinity.
25
+ // ROUND_FLOOR 3 Towards -Infinity.
26
+ // ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up.
27
+ // ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
28
+ // ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
29
+ // ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
30
+ // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
31
+ //
32
+ // E.g.
33
+ // `Decimal.rounding = 4;`
34
+ // `Decimal.rounding = Decimal.ROUND_HALF_UP;`
35
+ rounding: 4,
36
+ // 0 to 8
37
+ // The modulo mode used when calculating the modulus: a mod n.
38
+ // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
39
+ // The remainder (r) is calculated as: r = a - n * q.
40
+ //
41
+ // UP 0 The remainder is positive if the dividend is negative, else is negative.
42
+ // DOWN 1 The remainder has the same sign as the dividend (JavaScript %).
43
+ // FLOOR 3 The remainder has the same sign as the divisor (Python %).
44
+ // HALF_EVEN 6 The IEEE 754 remainder function.
45
+ // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive.
46
+ //
47
+ // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian
48
+ // division (9) are commonly used for the modulus operation. The other rounding modes can also
49
+ // be used, but they may not give useful results.
50
+ modulo: 1,
51
+ // 0 to 9
52
+ // The exponent value at and beneath which `toString` returns exponential notation.
53
+ // JavaScript numbers: -7
54
+ toExpNeg: -7,
55
+ // 0 to -EXP_LIMIT
56
+ // The exponent value at and above which `toString` returns exponential notation.
57
+ // JavaScript numbers: 21
58
+ toExpPos: 21,
59
+ // 0 to EXP_LIMIT
60
+ // The minimum exponent value, beneath which underflow to zero occurs.
61
+ // JavaScript numbers: -324 (5e-324)
62
+ minE: -EXP_LIMIT,
63
+ // -1 to -EXP_LIMIT
64
+ // The maximum exponent value, above which overflow to Infinity occurs.
65
+ // JavaScript numbers: 308 (1.7976931348623157e+308)
66
+ maxE: EXP_LIMIT,
67
+ // 1 to EXP_LIMIT
68
+ // Whether to use cryptographically-secure random number generation, if available.
69
+ crypto: false
70
+ // true/false
71
+ };
72
+ var inexact;
73
+ var quadrant;
74
+ var external = true;
75
+ var decimalError = "[DecimalError] ";
76
+ var invalidArgument = decimalError + "Invalid argument: ";
77
+ var precisionLimitExceeded = decimalError + "Precision limit exceeded";
78
+ var cryptoUnavailable = decimalError + "crypto unavailable";
79
+ var tag = "[object Decimal]";
80
+ var mathfloor = Math.floor;
81
+ var mathpow = Math.pow;
82
+ var isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i;
83
+ var isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i;
84
+ var isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i;
85
+ var isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
86
+ var BASE = 1e7;
87
+ var LOG_BASE = 7;
88
+ var MAX_SAFE_INTEGER = 9007199254740991;
89
+ var LN10_PRECISION = LN10.length - 1;
90
+ var PI_PRECISION = PI.length - 1;
91
+ var P = { toStringTag: tag };
92
+ P.absoluteValue = P.abs = function() {
93
+ var x = new this.constructor(this);
94
+ if (x.s < 0)
95
+ x.s = 1;
96
+ return finalise(x);
97
+ };
98
+ P.ceil = function() {
99
+ return finalise(new this.constructor(this), this.e + 1, 2);
100
+ };
101
+ P.clampedTo = P.clamp = function(min2, max2) {
102
+ var k, x = this, Ctor = x.constructor;
103
+ min2 = new Ctor(min2);
104
+ max2 = new Ctor(max2);
105
+ if (!min2.s || !max2.s)
106
+ return new Ctor(NaN);
107
+ if (min2.gt(max2))
108
+ throw Error(invalidArgument + max2);
109
+ k = x.cmp(min2);
110
+ return k < 0 ? min2 : x.cmp(max2) > 0 ? max2 : new Ctor(x);
111
+ };
112
+ P.comparedTo = P.cmp = function(y) {
113
+ var i, j, xdL, ydL, x = this, xd = x.d, yd = (y = new x.constructor(y)).d, xs = x.s, ys = y.s;
114
+ if (!xd || !yd) {
115
+ return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1;
116
+ }
117
+ if (!xd[0] || !yd[0])
118
+ return xd[0] ? xs : yd[0] ? -ys : 0;
119
+ if (xs !== ys)
120
+ return xs;
121
+ if (x.e !== y.e)
122
+ return x.e > y.e ^ xs < 0 ? 1 : -1;
123
+ xdL = xd.length;
124
+ ydL = yd.length;
125
+ for (i = 0, j = xdL < ydL ? xdL : ydL; i < j; ++i) {
126
+ if (xd[i] !== yd[i])
127
+ return xd[i] > yd[i] ^ xs < 0 ? 1 : -1;
128
+ }
129
+ return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1;
130
+ };
131
+ P.cosine = P.cos = function() {
132
+ var pr, rm, x = this, Ctor = x.constructor;
133
+ if (!x.d)
134
+ return new Ctor(NaN);
135
+ if (!x.d[0])
136
+ return new Ctor(1);
137
+ pr = Ctor.precision;
138
+ rm = Ctor.rounding;
139
+ Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
140
+ Ctor.rounding = 1;
141
+ x = cosine(Ctor, toLessThanHalfPi(Ctor, x));
142
+ Ctor.precision = pr;
143
+ Ctor.rounding = rm;
144
+ return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true);
145
+ };
146
+ P.cubeRoot = P.cbrt = function() {
147
+ var e, m, n, r, rep, s, sd, t, t3, t3plusx, x = this, Ctor = x.constructor;
148
+ if (!x.isFinite() || x.isZero())
149
+ return new Ctor(x);
150
+ external = false;
151
+ s = x.s * mathpow(x.s * x, 1 / 3);
152
+ if (!s || Math.abs(s) == 1 / 0) {
153
+ n = digitsToString(x.d);
154
+ e = x.e;
155
+ if (s = (e - n.length + 1) % 3)
156
+ n += s == 1 || s == -2 ? "0" : "00";
157
+ s = mathpow(n, 1 / 3);
158
+ e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2));
159
+ if (s == 1 / 0) {
160
+ n = "5e" + e;
161
+ } else {
162
+ n = s.toExponential();
163
+ n = n.slice(0, n.indexOf("e") + 1) + e;
164
+ }
165
+ r = new Ctor(n);
166
+ r.s = x.s;
167
+ } else {
168
+ r = new Ctor(s.toString());
169
+ }
170
+ sd = (e = Ctor.precision) + 3;
171
+ for (; ; ) {
172
+ t = r;
173
+ t3 = t.times(t).times(t);
174
+ t3plusx = t3.plus(x);
175
+ r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1);
176
+ if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
177
+ n = n.slice(sd - 3, sd + 1);
178
+ if (n == "9999" || !rep && n == "4999") {
179
+ if (!rep) {
180
+ finalise(t, e + 1, 0);
181
+ if (t.times(t).times(t).eq(x)) {
182
+ r = t;
183
+ break;
184
+ }
185
+ }
186
+ sd += 4;
187
+ rep = 1;
188
+ } else {
189
+ if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
190
+ finalise(r, e + 1, 1);
191
+ m = !r.times(r).times(r).eq(x);
192
+ }
193
+ break;
194
+ }
195
+ }
196
+ }
197
+ external = true;
198
+ return finalise(r, e, Ctor.rounding, m);
199
+ };
200
+ P.decimalPlaces = P.dp = function() {
201
+ var w, d = this.d, n = NaN;
202
+ if (d) {
203
+ w = d.length - 1;
204
+ n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
205
+ w = d[w];
206
+ if (w)
207
+ for (; w % 10 == 0; w /= 10)
208
+ n--;
209
+ if (n < 0)
210
+ n = 0;
211
+ }
212
+ return n;
213
+ };
214
+ P.dividedBy = P.div = function(y) {
215
+ return divide(this, new this.constructor(y));
216
+ };
217
+ P.dividedToIntegerBy = P.divToInt = function(y) {
218
+ var x = this, Ctor = x.constructor;
219
+ return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding);
220
+ };
221
+ P.equals = P.eq = function(y) {
222
+ return this.cmp(y) === 0;
223
+ };
224
+ P.floor = function() {
225
+ return finalise(new this.constructor(this), this.e + 1, 3);
226
+ };
227
+ P.greaterThan = P.gt = function(y) {
228
+ return this.cmp(y) > 0;
229
+ };
230
+ P.greaterThanOrEqualTo = P.gte = function(y) {
231
+ var k = this.cmp(y);
232
+ return k == 1 || k === 0;
233
+ };
234
+ P.hyperbolicCosine = P.cosh = function() {
235
+ var k, n, pr, rm, len, x = this, Ctor = x.constructor, one = new Ctor(1);
236
+ if (!x.isFinite())
237
+ return new Ctor(x.s ? 1 / 0 : NaN);
238
+ if (x.isZero())
239
+ return one;
240
+ pr = Ctor.precision;
241
+ rm = Ctor.rounding;
242
+ Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
243
+ Ctor.rounding = 1;
244
+ len = x.d.length;
245
+ if (len < 32) {
246
+ k = Math.ceil(len / 3);
247
+ n = (1 / tinyPow(4, k)).toString();
248
+ } else {
249
+ k = 16;
250
+ n = "2.3283064365386962890625e-10";
251
+ }
252
+ x = taylorSeries(Ctor, 1, x.times(n), new Ctor(1), true);
253
+ var cosh2_x, i = k, d8 = new Ctor(8);
254
+ for (; i--; ) {
255
+ cosh2_x = x.times(x);
256
+ x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8))));
257
+ }
258
+ return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true);
259
+ };
260
+ P.hyperbolicSine = P.sinh = function() {
261
+ var k, pr, rm, len, x = this, Ctor = x.constructor;
262
+ if (!x.isFinite() || x.isZero())
263
+ return new Ctor(x);
264
+ pr = Ctor.precision;
265
+ rm = Ctor.rounding;
266
+ Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
267
+ Ctor.rounding = 1;
268
+ len = x.d.length;
269
+ if (len < 3) {
270
+ x = taylorSeries(Ctor, 2, x, x, true);
271
+ } else {
272
+ k = 1.4 * Math.sqrt(len);
273
+ k = k > 16 ? 16 : k | 0;
274
+ x = x.times(1 / tinyPow(5, k));
275
+ x = taylorSeries(Ctor, 2, x, x, true);
276
+ var sinh2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
277
+ for (; k--; ) {
278
+ sinh2_x = x.times(x);
279
+ x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20))));
280
+ }
281
+ }
282
+ Ctor.precision = pr;
283
+ Ctor.rounding = rm;
284
+ return finalise(x, pr, rm, true);
285
+ };
286
+ P.hyperbolicTangent = P.tanh = function() {
287
+ var pr, rm, x = this, Ctor = x.constructor;
288
+ if (!x.isFinite())
289
+ return new Ctor(x.s);
290
+ if (x.isZero())
291
+ return new Ctor(x);
292
+ pr = Ctor.precision;
293
+ rm = Ctor.rounding;
294
+ Ctor.precision = pr + 7;
295
+ Ctor.rounding = 1;
296
+ return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm);
297
+ };
298
+ P.inverseCosine = P.acos = function() {
299
+ var halfPi, x = this, Ctor = x.constructor, k = x.abs().cmp(1), pr = Ctor.precision, rm = Ctor.rounding;
300
+ if (k !== -1) {
301
+ return k === 0 ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0) : new Ctor(NaN);
302
+ }
303
+ if (x.isZero())
304
+ return getPi(Ctor, pr + 4, rm).times(0.5);
305
+ Ctor.precision = pr + 6;
306
+ Ctor.rounding = 1;
307
+ x = x.asin();
308
+ halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
309
+ Ctor.precision = pr;
310
+ Ctor.rounding = rm;
311
+ return halfPi.minus(x);
312
+ };
313
+ P.inverseHyperbolicCosine = P.acosh = function() {
314
+ var pr, rm, x = this, Ctor = x.constructor;
315
+ if (x.lte(1))
316
+ return new Ctor(x.eq(1) ? 0 : NaN);
317
+ if (!x.isFinite())
318
+ return new Ctor(x);
319
+ pr = Ctor.precision;
320
+ rm = Ctor.rounding;
321
+ Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4;
322
+ Ctor.rounding = 1;
323
+ external = false;
324
+ x = x.times(x).minus(1).sqrt().plus(x);
325
+ external = true;
326
+ Ctor.precision = pr;
327
+ Ctor.rounding = rm;
328
+ return x.ln();
329
+ };
330
+ P.inverseHyperbolicSine = P.asinh = function() {
331
+ var pr, rm, x = this, Ctor = x.constructor;
332
+ if (!x.isFinite() || x.isZero())
333
+ return new Ctor(x);
334
+ pr = Ctor.precision;
335
+ rm = Ctor.rounding;
336
+ Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6;
337
+ Ctor.rounding = 1;
338
+ external = false;
339
+ x = x.times(x).plus(1).sqrt().plus(x);
340
+ external = true;
341
+ Ctor.precision = pr;
342
+ Ctor.rounding = rm;
343
+ return x.ln();
344
+ };
345
+ P.inverseHyperbolicTangent = P.atanh = function() {
346
+ var pr, rm, wpr, xsd, x = this, Ctor = x.constructor;
347
+ if (!x.isFinite())
348
+ return new Ctor(NaN);
349
+ if (x.e >= 0)
350
+ return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN);
351
+ pr = Ctor.precision;
352
+ rm = Ctor.rounding;
353
+ xsd = x.sd();
354
+ if (Math.max(xsd, pr) < 2 * -x.e - 1)
355
+ return finalise(new Ctor(x), pr, rm, true);
356
+ Ctor.precision = wpr = xsd - x.e;
357
+ x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1);
358
+ Ctor.precision = pr + 4;
359
+ Ctor.rounding = 1;
360
+ x = x.ln();
361
+ Ctor.precision = pr;
362
+ Ctor.rounding = rm;
363
+ return x.times(0.5);
364
+ };
365
+ P.inverseSine = P.asin = function() {
366
+ var halfPi, k, pr, rm, x = this, Ctor = x.constructor;
367
+ if (x.isZero())
368
+ return new Ctor(x);
369
+ k = x.abs().cmp(1);
370
+ pr = Ctor.precision;
371
+ rm = Ctor.rounding;
372
+ if (k !== -1) {
373
+ if (k === 0) {
374
+ halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
375
+ halfPi.s = x.s;
376
+ return halfPi;
377
+ }
378
+ return new Ctor(NaN);
379
+ }
380
+ Ctor.precision = pr + 6;
381
+ Ctor.rounding = 1;
382
+ x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan();
383
+ Ctor.precision = pr;
384
+ Ctor.rounding = rm;
385
+ return x.times(2);
386
+ };
387
+ P.inverseTangent = P.atan = function() {
388
+ var i, j, k, n, px, t, r, wpr, x2, x = this, Ctor = x.constructor, pr = Ctor.precision, rm = Ctor.rounding;
389
+ if (!x.isFinite()) {
390
+ if (!x.s)
391
+ return new Ctor(NaN);
392
+ if (pr + 4 <= PI_PRECISION) {
393
+ r = getPi(Ctor, pr + 4, rm).times(0.5);
394
+ r.s = x.s;
395
+ return r;
396
+ }
397
+ } else if (x.isZero()) {
398
+ return new Ctor(x);
399
+ } else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) {
400
+ r = getPi(Ctor, pr + 4, rm).times(0.25);
401
+ r.s = x.s;
402
+ return r;
403
+ }
404
+ Ctor.precision = wpr = pr + 10;
405
+ Ctor.rounding = 1;
406
+ k = Math.min(28, wpr / LOG_BASE + 2 | 0);
407
+ for (i = k; i; --i)
408
+ x = x.div(x.times(x).plus(1).sqrt().plus(1));
409
+ external = false;
410
+ j = Math.ceil(wpr / LOG_BASE);
411
+ n = 1;
412
+ x2 = x.times(x);
413
+ r = new Ctor(x);
414
+ px = x;
415
+ for (; i !== -1; ) {
416
+ px = px.times(x2);
417
+ t = r.minus(px.div(n += 2));
418
+ px = px.times(x2);
419
+ r = t.plus(px.div(n += 2));
420
+ if (r.d[j] !== void 0)
421
+ for (i = j; r.d[i] === t.d[i] && i--; )
422
+ ;
423
+ }
424
+ if (k)
425
+ r = r.times(2 << k - 1);
426
+ external = true;
427
+ return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true);
428
+ };
429
+ P.isFinite = function() {
430
+ return !!this.d;
431
+ };
432
+ P.isInteger = P.isInt = function() {
433
+ return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2;
434
+ };
435
+ P.isNaN = function() {
436
+ return !this.s;
437
+ };
438
+ P.isNegative = P.isNeg = function() {
439
+ return this.s < 0;
440
+ };
441
+ P.isPositive = P.isPos = function() {
442
+ return this.s > 0;
443
+ };
444
+ P.isZero = function() {
445
+ return !!this.d && this.d[0] === 0;
446
+ };
447
+ P.lessThan = P.lt = function(y) {
448
+ return this.cmp(y) < 0;
449
+ };
450
+ P.lessThanOrEqualTo = P.lte = function(y) {
451
+ return this.cmp(y) < 1;
452
+ };
453
+ P.logarithm = P.log = function(base) {
454
+ var isBase10, d, denominator, k, inf, num, sd, r, arg = this, Ctor = arg.constructor, pr = Ctor.precision, rm = Ctor.rounding, guard = 5;
455
+ if (base == null) {
456
+ base = new Ctor(10);
457
+ isBase10 = true;
458
+ } else {
459
+ base = new Ctor(base);
460
+ d = base.d;
461
+ if (base.s < 0 || !d || !d[0] || base.eq(1))
462
+ return new Ctor(NaN);
463
+ isBase10 = base.eq(10);
464
+ }
465
+ d = arg.d;
466
+ if (arg.s < 0 || !d || !d[0] || arg.eq(1)) {
467
+ return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0);
468
+ }
469
+ if (isBase10) {
470
+ if (d.length > 1) {
471
+ inf = true;
472
+ } else {
473
+ for (k = d[0]; k % 10 === 0; )
474
+ k /= 10;
475
+ inf = k !== 1;
476
+ }
477
+ }
478
+ external = false;
479
+ sd = pr + guard;
480
+ num = naturalLogarithm(arg, sd);
481
+ denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
482
+ r = divide(num, denominator, sd, 1);
483
+ if (checkRoundingDigits(r.d, k = pr, rm)) {
484
+ do {
485
+ sd += 10;
486
+ num = naturalLogarithm(arg, sd);
487
+ denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
488
+ r = divide(num, denominator, sd, 1);
489
+ if (!inf) {
490
+ if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 1e14) {
491
+ r = finalise(r, pr + 1, 0);
492
+ }
493
+ break;
494
+ }
495
+ } while (checkRoundingDigits(r.d, k += 10, rm));
496
+ }
497
+ external = true;
498
+ return finalise(r, pr, rm);
499
+ };
500
+ P.minus = P.sub = function(y) {
501
+ var d, e, i, j, k, len, pr, rm, xd, xe, xLTy, yd, x = this, Ctor = x.constructor;
502
+ y = new Ctor(y);
503
+ if (!x.d || !y.d) {
504
+ if (!x.s || !y.s)
505
+ y = new Ctor(NaN);
506
+ else if (x.d)
507
+ y.s = -y.s;
508
+ else
509
+ y = new Ctor(y.d || x.s !== y.s ? x : NaN);
510
+ return y;
511
+ }
512
+ if (x.s != y.s) {
513
+ y.s = -y.s;
514
+ return x.plus(y);
515
+ }
516
+ xd = x.d;
517
+ yd = y.d;
518
+ pr = Ctor.precision;
519
+ rm = Ctor.rounding;
520
+ if (!xd[0] || !yd[0]) {
521
+ if (yd[0])
522
+ y.s = -y.s;
523
+ else if (xd[0])
524
+ y = new Ctor(x);
525
+ else
526
+ return new Ctor(rm === 3 ? -0 : 0);
527
+ return external ? finalise(y, pr, rm) : y;
528
+ }
529
+ e = mathfloor(y.e / LOG_BASE);
530
+ xe = mathfloor(x.e / LOG_BASE);
531
+ xd = xd.slice();
532
+ k = xe - e;
533
+ if (k) {
534
+ xLTy = k < 0;
535
+ if (xLTy) {
536
+ d = xd;
537
+ k = -k;
538
+ len = yd.length;
539
+ } else {
540
+ d = yd;
541
+ e = xe;
542
+ len = xd.length;
543
+ }
544
+ i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
545
+ if (k > i) {
546
+ k = i;
547
+ d.length = 1;
548
+ }
549
+ d.reverse();
550
+ for (i = k; i--; )
551
+ d.push(0);
552
+ d.reverse();
553
+ } else {
554
+ i = xd.length;
555
+ len = yd.length;
556
+ xLTy = i < len;
557
+ if (xLTy)
558
+ len = i;
559
+ for (i = 0; i < len; i++) {
560
+ if (xd[i] != yd[i]) {
561
+ xLTy = xd[i] < yd[i];
562
+ break;
563
+ }
564
+ }
565
+ k = 0;
566
+ }
567
+ if (xLTy) {
568
+ d = xd;
569
+ xd = yd;
570
+ yd = d;
571
+ y.s = -y.s;
572
+ }
573
+ len = xd.length;
574
+ for (i = yd.length - len; i > 0; --i)
575
+ xd[len++] = 0;
576
+ for (i = yd.length; i > k; ) {
577
+ if (xd[--i] < yd[i]) {
578
+ for (j = i; j && xd[--j] === 0; )
579
+ xd[j] = BASE - 1;
580
+ --xd[j];
581
+ xd[i] += BASE;
582
+ }
583
+ xd[i] -= yd[i];
584
+ }
585
+ for (; xd[--len] === 0; )
586
+ xd.pop();
587
+ for (; xd[0] === 0; xd.shift())
588
+ --e;
589
+ if (!xd[0])
590
+ return new Ctor(rm === 3 ? -0 : 0);
591
+ y.d = xd;
592
+ y.e = getBase10Exponent(xd, e);
593
+ return external ? finalise(y, pr, rm) : y;
594
+ };
595
+ P.modulo = P.mod = function(y) {
596
+ var q, x = this, Ctor = x.constructor;
597
+ y = new Ctor(y);
598
+ if (!x.d || !y.s || y.d && !y.d[0])
599
+ return new Ctor(NaN);
600
+ if (!y.d || x.d && !x.d[0]) {
601
+ return finalise(new Ctor(x), Ctor.precision, Ctor.rounding);
602
+ }
603
+ external = false;
604
+ if (Ctor.modulo == 9) {
605
+ q = divide(x, y.abs(), 0, 3, 1);
606
+ q.s *= y.s;
607
+ } else {
608
+ q = divide(x, y, 0, Ctor.modulo, 1);
609
+ }
610
+ q = q.times(y);
611
+ external = true;
612
+ return x.minus(q);
613
+ };
614
+ P.naturalExponential = P.exp = function() {
615
+ return naturalExponential(this);
616
+ };
617
+ P.naturalLogarithm = P.ln = function() {
618
+ return naturalLogarithm(this);
619
+ };
620
+ P.negated = P.neg = function() {
621
+ var x = new this.constructor(this);
622
+ x.s = -x.s;
623
+ return finalise(x);
624
+ };
625
+ P.plus = P.add = function(y) {
626
+ var carry, d, e, i, k, len, pr, rm, xd, yd, x = this, Ctor = x.constructor;
627
+ y = new Ctor(y);
628
+ if (!x.d || !y.d) {
629
+ if (!x.s || !y.s)
630
+ y = new Ctor(NaN);
631
+ else if (!x.d)
632
+ y = new Ctor(y.d || x.s === y.s ? x : NaN);
633
+ return y;
634
+ }
635
+ if (x.s != y.s) {
636
+ y.s = -y.s;
637
+ return x.minus(y);
638
+ }
639
+ xd = x.d;
640
+ yd = y.d;
641
+ pr = Ctor.precision;
642
+ rm = Ctor.rounding;
643
+ if (!xd[0] || !yd[0]) {
644
+ if (!yd[0])
645
+ y = new Ctor(x);
646
+ return external ? finalise(y, pr, rm) : y;
647
+ }
648
+ k = mathfloor(x.e / LOG_BASE);
649
+ e = mathfloor(y.e / LOG_BASE);
650
+ xd = xd.slice();
651
+ i = k - e;
652
+ if (i) {
653
+ if (i < 0) {
654
+ d = xd;
655
+ i = -i;
656
+ len = yd.length;
657
+ } else {
658
+ d = yd;
659
+ e = k;
660
+ len = xd.length;
661
+ }
662
+ k = Math.ceil(pr / LOG_BASE);
663
+ len = k > len ? k + 1 : len + 1;
664
+ if (i > len) {
665
+ i = len;
666
+ d.length = 1;
667
+ }
668
+ d.reverse();
669
+ for (; i--; )
670
+ d.push(0);
671
+ d.reverse();
672
+ }
673
+ len = xd.length;
674
+ i = yd.length;
675
+ if (len - i < 0) {
676
+ i = len;
677
+ d = yd;
678
+ yd = xd;
679
+ xd = d;
680
+ }
681
+ for (carry = 0; i; ) {
682
+ carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
683
+ xd[i] %= BASE;
684
+ }
685
+ if (carry) {
686
+ xd.unshift(carry);
687
+ ++e;
688
+ }
689
+ for (len = xd.length; xd[--len] == 0; )
690
+ xd.pop();
691
+ y.d = xd;
692
+ y.e = getBase10Exponent(xd, e);
693
+ return external ? finalise(y, pr, rm) : y;
694
+ };
695
+ P.precision = P.sd = function(z) {
696
+ var k, x = this;
697
+ if (z !== void 0 && z !== !!z && z !== 1 && z !== 0)
698
+ throw Error(invalidArgument + z);
699
+ if (x.d) {
700
+ k = getPrecision(x.d);
701
+ if (z && x.e + 1 > k)
702
+ k = x.e + 1;
703
+ } else {
704
+ k = NaN;
705
+ }
706
+ return k;
707
+ };
708
+ P.round = function() {
709
+ var x = this, Ctor = x.constructor;
710
+ return finalise(new Ctor(x), x.e + 1, Ctor.rounding);
711
+ };
712
+ P.sine = P.sin = function() {
713
+ var pr, rm, x = this, Ctor = x.constructor;
714
+ if (!x.isFinite())
715
+ return new Ctor(NaN);
716
+ if (x.isZero())
717
+ return new Ctor(x);
718
+ pr = Ctor.precision;
719
+ rm = Ctor.rounding;
720
+ Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
721
+ Ctor.rounding = 1;
722
+ x = sine(Ctor, toLessThanHalfPi(Ctor, x));
723
+ Ctor.precision = pr;
724
+ Ctor.rounding = rm;
725
+ return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true);
726
+ };
727
+ P.squareRoot = P.sqrt = function() {
728
+ var m, n, sd, r, rep, t, x = this, d = x.d, e = x.e, s = x.s, Ctor = x.constructor;
729
+ if (s !== 1 || !d || !d[0]) {
730
+ return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0);
731
+ }
732
+ external = false;
733
+ s = Math.sqrt(+x);
734
+ if (s == 0 || s == 1 / 0) {
735
+ n = digitsToString(d);
736
+ if ((n.length + e) % 2 == 0)
737
+ n += "0";
738
+ s = Math.sqrt(n);
739
+ e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
740
+ if (s == 1 / 0) {
741
+ n = "5e" + e;
742
+ } else {
743
+ n = s.toExponential();
744
+ n = n.slice(0, n.indexOf("e") + 1) + e;
745
+ }
746
+ r = new Ctor(n);
747
+ } else {
748
+ r = new Ctor(s.toString());
749
+ }
750
+ sd = (e = Ctor.precision) + 3;
751
+ for (; ; ) {
752
+ t = r;
753
+ r = t.plus(divide(x, t, sd + 2, 1)).times(0.5);
754
+ if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
755
+ n = n.slice(sd - 3, sd + 1);
756
+ if (n == "9999" || !rep && n == "4999") {
757
+ if (!rep) {
758
+ finalise(t, e + 1, 0);
759
+ if (t.times(t).eq(x)) {
760
+ r = t;
761
+ break;
762
+ }
763
+ }
764
+ sd += 4;
765
+ rep = 1;
766
+ } else {
767
+ if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
768
+ finalise(r, e + 1, 1);
769
+ m = !r.times(r).eq(x);
770
+ }
771
+ break;
772
+ }
773
+ }
774
+ }
775
+ external = true;
776
+ return finalise(r, e, Ctor.rounding, m);
777
+ };
778
+ P.tangent = P.tan = function() {
779
+ var pr, rm, x = this, Ctor = x.constructor;
780
+ if (!x.isFinite())
781
+ return new Ctor(NaN);
782
+ if (x.isZero())
783
+ return new Ctor(x);
784
+ pr = Ctor.precision;
785
+ rm = Ctor.rounding;
786
+ Ctor.precision = pr + 10;
787
+ Ctor.rounding = 1;
788
+ x = x.sin();
789
+ x.s = 1;
790
+ x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0);
791
+ Ctor.precision = pr;
792
+ Ctor.rounding = rm;
793
+ return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true);
794
+ };
795
+ P.times = P.mul = function(y) {
796
+ var carry, e, i, k, r, rL, t, xdL, ydL, x = this, Ctor = x.constructor, xd = x.d, yd = (y = new Ctor(y)).d;
797
+ y.s *= x.s;
798
+ if (!xd || !xd[0] || !yd || !yd[0]) {
799
+ return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd ? NaN : !xd || !yd ? y.s / 0 : y.s * 0);
800
+ }
801
+ e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE);
802
+ xdL = xd.length;
803
+ ydL = yd.length;
804
+ if (xdL < ydL) {
805
+ r = xd;
806
+ xd = yd;
807
+ yd = r;
808
+ rL = xdL;
809
+ xdL = ydL;
810
+ ydL = rL;
811
+ }
812
+ r = [];
813
+ rL = xdL + ydL;
814
+ for (i = rL; i--; )
815
+ r.push(0);
816
+ for (i = ydL; --i >= 0; ) {
817
+ carry = 0;
818
+ for (k = xdL + i; k > i; ) {
819
+ t = r[k] + yd[i] * xd[k - i - 1] + carry;
820
+ r[k--] = t % BASE | 0;
821
+ carry = t / BASE | 0;
822
+ }
823
+ r[k] = (r[k] + carry) % BASE | 0;
824
+ }
825
+ for (; !r[--rL]; )
826
+ r.pop();
827
+ if (carry)
828
+ ++e;
829
+ else
830
+ r.shift();
831
+ y.d = r;
832
+ y.e = getBase10Exponent(r, e);
833
+ return external ? finalise(y, Ctor.precision, Ctor.rounding) : y;
834
+ };
835
+ P.toBinary = function(sd, rm) {
836
+ return toStringBinary(this, 2, sd, rm);
837
+ };
838
+ P.toDecimalPlaces = P.toDP = function(dp, rm) {
839
+ var x = this, Ctor = x.constructor;
840
+ x = new Ctor(x);
841
+ if (dp === void 0)
842
+ return x;
843
+ checkInt32(dp, 0, MAX_DIGITS);
844
+ if (rm === void 0)
845
+ rm = Ctor.rounding;
846
+ else
847
+ checkInt32(rm, 0, 8);
848
+ return finalise(x, dp + x.e + 1, rm);
849
+ };
850
+ P.toExponential = function(dp, rm) {
851
+ var str, x = this, Ctor = x.constructor;
852
+ if (dp === void 0) {
853
+ str = finiteToString(x, true);
854
+ } else {
855
+ checkInt32(dp, 0, MAX_DIGITS);
856
+ if (rm === void 0)
857
+ rm = Ctor.rounding;
858
+ else
859
+ checkInt32(rm, 0, 8);
860
+ x = finalise(new Ctor(x), dp + 1, rm);
861
+ str = finiteToString(x, true, dp + 1);
862
+ }
863
+ return x.isNeg() && !x.isZero() ? "-" + str : str;
864
+ };
865
+ P.toFixed = function(dp, rm) {
866
+ var str, y, x = this, Ctor = x.constructor;
867
+ if (dp === void 0) {
868
+ str = finiteToString(x);
869
+ } else {
870
+ checkInt32(dp, 0, MAX_DIGITS);
871
+ if (rm === void 0)
872
+ rm = Ctor.rounding;
873
+ else
874
+ checkInt32(rm, 0, 8);
875
+ y = finalise(new Ctor(x), dp + x.e + 1, rm);
876
+ str = finiteToString(y, false, dp + y.e + 1);
877
+ }
878
+ return x.isNeg() && !x.isZero() ? "-" + str : str;
879
+ };
880
+ P.toFraction = function(maxD) {
881
+ var d, d0, d1, d2, e, k, n, n0, n1, pr, q, r, x = this, xd = x.d, Ctor = x.constructor;
882
+ if (!xd)
883
+ return new Ctor(x);
884
+ n1 = d0 = new Ctor(1);
885
+ d1 = n0 = new Ctor(0);
886
+ d = new Ctor(d1);
887
+ e = d.e = getPrecision(xd) - x.e - 1;
888
+ k = e % LOG_BASE;
889
+ d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k);
890
+ if (maxD == null) {
891
+ maxD = e > 0 ? d : n1;
892
+ } else {
893
+ n = new Ctor(maxD);
894
+ if (!n.isInt() || n.lt(n1))
895
+ throw Error(invalidArgument + n);
896
+ maxD = n.gt(d) ? e > 0 ? d : n1 : n;
897
+ }
898
+ external = false;
899
+ n = new Ctor(digitsToString(xd));
900
+ pr = Ctor.precision;
901
+ Ctor.precision = e = xd.length * LOG_BASE * 2;
902
+ for (; ; ) {
903
+ q = divide(n, d, 0, 1, 1);
904
+ d2 = d0.plus(q.times(d1));
905
+ if (d2.cmp(maxD) == 1)
906
+ break;
907
+ d0 = d1;
908
+ d1 = d2;
909
+ d2 = n1;
910
+ n1 = n0.plus(q.times(d2));
911
+ n0 = d2;
912
+ d2 = d;
913
+ d = n.minus(q.times(d2));
914
+ n = d2;
915
+ }
916
+ d2 = divide(maxD.minus(d0), d1, 0, 1, 1);
917
+ n0 = n0.plus(d2.times(n1));
918
+ d0 = d0.plus(d2.times(d1));
919
+ n0.s = n1.s = x.s;
920
+ r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
921
+ Ctor.precision = pr;
922
+ external = true;
923
+ return r;
924
+ };
925
+ P.toHexadecimal = P.toHex = function(sd, rm) {
926
+ return toStringBinary(this, 16, sd, rm);
927
+ };
928
+ P.toNearest = function(y, rm) {
929
+ var x = this, Ctor = x.constructor;
930
+ x = new Ctor(x);
931
+ if (y == null) {
932
+ if (!x.d)
933
+ return x;
934
+ y = new Ctor(1);
935
+ rm = Ctor.rounding;
936
+ } else {
937
+ y = new Ctor(y);
938
+ if (rm === void 0) {
939
+ rm = Ctor.rounding;
940
+ } else {
941
+ checkInt32(rm, 0, 8);
942
+ }
943
+ if (!x.d)
944
+ return y.s ? x : y;
945
+ if (!y.d) {
946
+ if (y.s)
947
+ y.s = x.s;
948
+ return y;
949
+ }
950
+ }
951
+ if (y.d[0]) {
952
+ external = false;
953
+ x = divide(x, y, 0, rm, 1).times(y);
954
+ external = true;
955
+ finalise(x);
956
+ } else {
957
+ y.s = x.s;
958
+ x = y;
959
+ }
960
+ return x;
961
+ };
962
+ P.toNumber = function() {
963
+ return +this;
964
+ };
965
+ P.toOctal = function(sd, rm) {
966
+ return toStringBinary(this, 8, sd, rm);
967
+ };
968
+ P.toPower = P.pow = function(y) {
969
+ var e, k, pr, r, rm, s, x = this, Ctor = x.constructor, yn = +(y = new Ctor(y));
970
+ if (!x.d || !y.d || !x.d[0] || !y.d[0])
971
+ return new Ctor(mathpow(+x, yn));
972
+ x = new Ctor(x);
973
+ if (x.eq(1))
974
+ return x;
975
+ pr = Ctor.precision;
976
+ rm = Ctor.rounding;
977
+ if (y.eq(1))
978
+ return finalise(x, pr, rm);
979
+ e = mathfloor(y.e / LOG_BASE);
980
+ if (e >= y.d.length - 1 && (k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
981
+ r = intPow(Ctor, x, k, pr);
982
+ return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm);
983
+ }
984
+ s = x.s;
985
+ if (s < 0) {
986
+ if (e < y.d.length - 1)
987
+ return new Ctor(NaN);
988
+ if ((y.d[e] & 1) == 0)
989
+ s = 1;
990
+ if (x.e == 0 && x.d[0] == 1 && x.d.length == 1) {
991
+ x.s = s;
992
+ return x;
993
+ }
994
+ }
995
+ k = mathpow(+x, yn);
996
+ e = k == 0 || !isFinite(k) ? mathfloor(yn * (Math.log("0." + digitsToString(x.d)) / Math.LN10 + x.e + 1)) : new Ctor(k + "").e;
997
+ if (e > Ctor.maxE + 1 || e < Ctor.minE - 1)
998
+ return new Ctor(e > 0 ? s / 0 : 0);
999
+ external = false;
1000
+ Ctor.rounding = x.s = 1;
1001
+ k = Math.min(12, (e + "").length);
1002
+ r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr);
1003
+ if (r.d) {
1004
+ r = finalise(r, pr + 5, 1);
1005
+ if (checkRoundingDigits(r.d, pr, rm)) {
1006
+ e = pr + 10;
1007
+ r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1);
1008
+ if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 1e14) {
1009
+ r = finalise(r, pr + 1, 0);
1010
+ }
1011
+ }
1012
+ }
1013
+ r.s = s;
1014
+ external = true;
1015
+ Ctor.rounding = rm;
1016
+ return finalise(r, pr, rm);
1017
+ };
1018
+ P.toPrecision = function(sd, rm) {
1019
+ var str, x = this, Ctor = x.constructor;
1020
+ if (sd === void 0) {
1021
+ str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
1022
+ } else {
1023
+ checkInt32(sd, 1, MAX_DIGITS);
1024
+ if (rm === void 0)
1025
+ rm = Ctor.rounding;
1026
+ else
1027
+ checkInt32(rm, 0, 8);
1028
+ x = finalise(new Ctor(x), sd, rm);
1029
+ str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd);
1030
+ }
1031
+ return x.isNeg() && !x.isZero() ? "-" + str : str;
1032
+ };
1033
+ P.toSignificantDigits = P.toSD = function(sd, rm) {
1034
+ var x = this, Ctor = x.constructor;
1035
+ if (sd === void 0) {
1036
+ sd = Ctor.precision;
1037
+ rm = Ctor.rounding;
1038
+ } else {
1039
+ checkInt32(sd, 1, MAX_DIGITS);
1040
+ if (rm === void 0)
1041
+ rm = Ctor.rounding;
1042
+ else
1043
+ checkInt32(rm, 0, 8);
1044
+ }
1045
+ return finalise(new Ctor(x), sd, rm);
1046
+ };
1047
+ P.toString = function() {
1048
+ var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
1049
+ return x.isNeg() && !x.isZero() ? "-" + str : str;
1050
+ };
1051
+ P.truncated = P.trunc = function() {
1052
+ return finalise(new this.constructor(this), this.e + 1, 1);
1053
+ };
1054
+ P.valueOf = P.toJSON = function() {
1055
+ var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
1056
+ return x.isNeg() ? "-" + str : str;
1057
+ };
1058
+ function digitsToString(d) {
1059
+ var i, k, ws, indexOfLastWord = d.length - 1, str = "", w = d[0];
1060
+ if (indexOfLastWord > 0) {
1061
+ str += w;
1062
+ for (i = 1; i < indexOfLastWord; i++) {
1063
+ ws = d[i] + "";
1064
+ k = LOG_BASE - ws.length;
1065
+ if (k)
1066
+ str += getZeroString(k);
1067
+ str += ws;
1068
+ }
1069
+ w = d[i];
1070
+ ws = w + "";
1071
+ k = LOG_BASE - ws.length;
1072
+ if (k)
1073
+ str += getZeroString(k);
1074
+ } else if (w === 0) {
1075
+ return "0";
1076
+ }
1077
+ for (; w % 10 === 0; )
1078
+ w /= 10;
1079
+ return str + w;
1080
+ }
1081
+ function checkInt32(i, min2, max2) {
1082
+ if (i !== ~~i || i < min2 || i > max2) {
1083
+ throw Error(invalidArgument + i);
1084
+ }
1085
+ }
1086
+ function checkRoundingDigits(d, i, rm, repeating) {
1087
+ var di, k, r, rd;
1088
+ for (k = d[0]; k >= 10; k /= 10)
1089
+ --i;
1090
+ if (--i < 0) {
1091
+ i += LOG_BASE;
1092
+ di = 0;
1093
+ } else {
1094
+ di = Math.ceil((i + 1) / LOG_BASE);
1095
+ i %= LOG_BASE;
1096
+ }
1097
+ k = mathpow(10, LOG_BASE - i);
1098
+ rd = d[di] % k | 0;
1099
+ if (repeating == null) {
1100
+ if (i < 3) {
1101
+ if (i == 0)
1102
+ rd = rd / 100 | 0;
1103
+ else if (i == 1)
1104
+ rd = rd / 10 | 0;
1105
+ r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 5e4 || rd == 0;
1106
+ } else {
1107
+ r = (rm < 4 && rd + 1 == k || rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 100 | 0) == mathpow(10, i - 2) - 1 || (rd == k / 2 || rd == 0) && (d[di + 1] / k / 100 | 0) == 0;
1108
+ }
1109
+ } else {
1110
+ if (i < 4) {
1111
+ if (i == 0)
1112
+ rd = rd / 1e3 | 0;
1113
+ else if (i == 1)
1114
+ rd = rd / 100 | 0;
1115
+ else if (i == 2)
1116
+ rd = rd / 10 | 0;
1117
+ r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999;
1118
+ } else {
1119
+ r = ((repeating || rm < 4) && rd + 1 == k || !repeating && rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 1e3 | 0) == mathpow(10, i - 3) - 1;
1120
+ }
1121
+ }
1122
+ return r;
1123
+ }
1124
+ function convertBase(str, baseIn, baseOut) {
1125
+ var j, arr = [0], arrL, i = 0, strL = str.length;
1126
+ for (; i < strL; ) {
1127
+ for (arrL = arr.length; arrL--; )
1128
+ arr[arrL] *= baseIn;
1129
+ arr[0] += NUMERALS.indexOf(str.charAt(i++));
1130
+ for (j = 0; j < arr.length; j++) {
1131
+ if (arr[j] > baseOut - 1) {
1132
+ if (arr[j + 1] === void 0)
1133
+ arr[j + 1] = 0;
1134
+ arr[j + 1] += arr[j] / baseOut | 0;
1135
+ arr[j] %= baseOut;
1136
+ }
1137
+ }
1138
+ }
1139
+ return arr.reverse();
1140
+ }
1141
+ function cosine(Ctor, x) {
1142
+ var k, len, y;
1143
+ if (x.isZero())
1144
+ return x;
1145
+ len = x.d.length;
1146
+ if (len < 32) {
1147
+ k = Math.ceil(len / 3);
1148
+ y = (1 / tinyPow(4, k)).toString();
1149
+ } else {
1150
+ k = 16;
1151
+ y = "2.3283064365386962890625e-10";
1152
+ }
1153
+ Ctor.precision += k;
1154
+ x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1));
1155
+ for (var i = k; i--; ) {
1156
+ var cos2x = x.times(x);
1157
+ x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1);
1158
+ }
1159
+ Ctor.precision -= k;
1160
+ return x;
1161
+ }
1162
+ var divide = /* @__PURE__ */ function() {
1163
+ function multiplyInteger(x, k, base) {
1164
+ var temp, carry = 0, i = x.length;
1165
+ for (x = x.slice(); i--; ) {
1166
+ temp = x[i] * k + carry;
1167
+ x[i] = temp % base | 0;
1168
+ carry = temp / base | 0;
1169
+ }
1170
+ if (carry)
1171
+ x.unshift(carry);
1172
+ return x;
1173
+ }
1174
+ function compare(a, b, aL, bL) {
1175
+ var i, r;
1176
+ if (aL != bL) {
1177
+ r = aL > bL ? 1 : -1;
1178
+ } else {
1179
+ for (i = r = 0; i < aL; i++) {
1180
+ if (a[i] != b[i]) {
1181
+ r = a[i] > b[i] ? 1 : -1;
1182
+ break;
1183
+ }
1184
+ }
1185
+ }
1186
+ return r;
1187
+ }
1188
+ function subtract(a, b, aL, base) {
1189
+ var i = 0;
1190
+ for (; aL--; ) {
1191
+ a[aL] -= i;
1192
+ i = a[aL] < b[aL] ? 1 : 0;
1193
+ a[aL] = i * base + a[aL] - b[aL];
1194
+ }
1195
+ for (; !a[0] && a.length > 1; )
1196
+ a.shift();
1197
+ }
1198
+ return function(x, y, pr, rm, dp, base) {
1199
+ var cmp, e, i, k, logBase, more, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0, yL, yz, Ctor = x.constructor, sign2 = x.s == y.s ? 1 : -1, xd = x.d, yd = y.d;
1200
+ if (!xd || !xd[0] || !yd || !yd[0]) {
1201
+ return new Ctor(
1202
+ // Return NaN if either NaN, or both Infinity or 0.
1203
+ !x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN : (
1204
+ // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
1205
+ xd && xd[0] == 0 || !yd ? sign2 * 0 : sign2 / 0
1206
+ )
1207
+ );
1208
+ }
1209
+ if (base) {
1210
+ logBase = 1;
1211
+ e = x.e - y.e;
1212
+ } else {
1213
+ base = BASE;
1214
+ logBase = LOG_BASE;
1215
+ e = mathfloor(x.e / logBase) - mathfloor(y.e / logBase);
1216
+ }
1217
+ yL = yd.length;
1218
+ xL = xd.length;
1219
+ q = new Ctor(sign2);
1220
+ qd = q.d = [];
1221
+ for (i = 0; yd[i] == (xd[i] || 0); i++)
1222
+ ;
1223
+ if (yd[i] > (xd[i] || 0))
1224
+ e--;
1225
+ if (pr == null) {
1226
+ sd = pr = Ctor.precision;
1227
+ rm = Ctor.rounding;
1228
+ } else if (dp) {
1229
+ sd = pr + (x.e - y.e) + 1;
1230
+ } else {
1231
+ sd = pr;
1232
+ }
1233
+ if (sd < 0) {
1234
+ qd.push(1);
1235
+ more = true;
1236
+ } else {
1237
+ sd = sd / logBase + 2 | 0;
1238
+ i = 0;
1239
+ if (yL == 1) {
1240
+ k = 0;
1241
+ yd = yd[0];
1242
+ sd++;
1243
+ for (; (i < xL || k) && sd--; i++) {
1244
+ t = k * base + (xd[i] || 0);
1245
+ qd[i] = t / yd | 0;
1246
+ k = t % yd | 0;
1247
+ }
1248
+ more = k || i < xL;
1249
+ } else {
1250
+ k = base / (yd[0] + 1) | 0;
1251
+ if (k > 1) {
1252
+ yd = multiplyInteger(yd, k, base);
1253
+ xd = multiplyInteger(xd, k, base);
1254
+ yL = yd.length;
1255
+ xL = xd.length;
1256
+ }
1257
+ xi = yL;
1258
+ rem = xd.slice(0, yL);
1259
+ remL = rem.length;
1260
+ for (; remL < yL; )
1261
+ rem[remL++] = 0;
1262
+ yz = yd.slice();
1263
+ yz.unshift(0);
1264
+ yd0 = yd[0];
1265
+ if (yd[1] >= base / 2)
1266
+ ++yd0;
1267
+ do {
1268
+ k = 0;
1269
+ cmp = compare(yd, rem, yL, remL);
1270
+ if (cmp < 0) {
1271
+ rem0 = rem[0];
1272
+ if (yL != remL)
1273
+ rem0 = rem0 * base + (rem[1] || 0);
1274
+ k = rem0 / yd0 | 0;
1275
+ if (k > 1) {
1276
+ if (k >= base)
1277
+ k = base - 1;
1278
+ prod = multiplyInteger(yd, k, base);
1279
+ prodL = prod.length;
1280
+ remL = rem.length;
1281
+ cmp = compare(prod, rem, prodL, remL);
1282
+ if (cmp == 1) {
1283
+ k--;
1284
+ subtract(prod, yL < prodL ? yz : yd, prodL, base);
1285
+ }
1286
+ } else {
1287
+ if (k == 0)
1288
+ cmp = k = 1;
1289
+ prod = yd.slice();
1290
+ }
1291
+ prodL = prod.length;
1292
+ if (prodL < remL)
1293
+ prod.unshift(0);
1294
+ subtract(rem, prod, remL, base);
1295
+ if (cmp == -1) {
1296
+ remL = rem.length;
1297
+ cmp = compare(yd, rem, yL, remL);
1298
+ if (cmp < 1) {
1299
+ k++;
1300
+ subtract(rem, yL < remL ? yz : yd, remL, base);
1301
+ }
1302
+ }
1303
+ remL = rem.length;
1304
+ } else if (cmp === 0) {
1305
+ k++;
1306
+ rem = [0];
1307
+ }
1308
+ qd[i++] = k;
1309
+ if (cmp && rem[0]) {
1310
+ rem[remL++] = xd[xi] || 0;
1311
+ } else {
1312
+ rem = [xd[xi]];
1313
+ remL = 1;
1314
+ }
1315
+ } while ((xi++ < xL || rem[0] !== void 0) && sd--);
1316
+ more = rem[0] !== void 0;
1317
+ }
1318
+ if (!qd[0])
1319
+ qd.shift();
1320
+ }
1321
+ if (logBase == 1) {
1322
+ q.e = e;
1323
+ inexact = more;
1324
+ } else {
1325
+ for (i = 1, k = qd[0]; k >= 10; k /= 10)
1326
+ i++;
1327
+ q.e = i + e * logBase - 1;
1328
+ finalise(q, dp ? pr + q.e + 1 : pr, rm, more);
1329
+ }
1330
+ return q;
1331
+ };
1332
+ }();
1333
+ function finalise(x, sd, rm, isTruncated) {
1334
+ var digits, i, j, k, rd, roundUp, w, xd, xdi, Ctor = x.constructor;
1335
+ out:
1336
+ if (sd != null) {
1337
+ xd = x.d;
1338
+ if (!xd)
1339
+ return x;
1340
+ for (digits = 1, k = xd[0]; k >= 10; k /= 10)
1341
+ digits++;
1342
+ i = sd - digits;
1343
+ if (i < 0) {
1344
+ i += LOG_BASE;
1345
+ j = sd;
1346
+ w = xd[xdi = 0];
1347
+ rd = w / mathpow(10, digits - j - 1) % 10 | 0;
1348
+ } else {
1349
+ xdi = Math.ceil((i + 1) / LOG_BASE);
1350
+ k = xd.length;
1351
+ if (xdi >= k) {
1352
+ if (isTruncated) {
1353
+ for (; k++ <= xdi; )
1354
+ xd.push(0);
1355
+ w = rd = 0;
1356
+ digits = 1;
1357
+ i %= LOG_BASE;
1358
+ j = i - LOG_BASE + 1;
1359
+ } else {
1360
+ break out;
1361
+ }
1362
+ } else {
1363
+ w = k = xd[xdi];
1364
+ for (digits = 1; k >= 10; k /= 10)
1365
+ digits++;
1366
+ i %= LOG_BASE;
1367
+ j = i - LOG_BASE + digits;
1368
+ rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0;
1369
+ }
1370
+ }
1371
+ isTruncated = isTruncated || sd < 0 || xd[xdi + 1] !== void 0 || (j < 0 ? w : w % mathpow(10, digits - j - 1));
1372
+ roundUp = rm < 4 ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || isTruncated || rm == 6 && // Check whether the digit to the left of the rounding digit is odd.
1373
+ (i > 0 ? j > 0 ? w / mathpow(10, digits - j) : 0 : xd[xdi - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
1374
+ if (sd < 1 || !xd[0]) {
1375
+ xd.length = 0;
1376
+ if (roundUp) {
1377
+ sd -= x.e + 1;
1378
+ xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
1379
+ x.e = -sd || 0;
1380
+ } else {
1381
+ xd[0] = x.e = 0;
1382
+ }
1383
+ return x;
1384
+ }
1385
+ if (i == 0) {
1386
+ xd.length = xdi;
1387
+ k = 1;
1388
+ xdi--;
1389
+ } else {
1390
+ xd.length = xdi + 1;
1391
+ k = mathpow(10, LOG_BASE - i);
1392
+ xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0;
1393
+ }
1394
+ if (roundUp) {
1395
+ for (; ; ) {
1396
+ if (xdi == 0) {
1397
+ for (i = 1, j = xd[0]; j >= 10; j /= 10)
1398
+ i++;
1399
+ j = xd[0] += k;
1400
+ for (k = 1; j >= 10; j /= 10)
1401
+ k++;
1402
+ if (i != k) {
1403
+ x.e++;
1404
+ if (xd[0] == BASE)
1405
+ xd[0] = 1;
1406
+ }
1407
+ break;
1408
+ } else {
1409
+ xd[xdi] += k;
1410
+ if (xd[xdi] != BASE)
1411
+ break;
1412
+ xd[xdi--] = 0;
1413
+ k = 1;
1414
+ }
1415
+ }
1416
+ }
1417
+ for (i = xd.length; xd[--i] === 0; )
1418
+ xd.pop();
1419
+ }
1420
+ if (external) {
1421
+ if (x.e > Ctor.maxE) {
1422
+ x.d = null;
1423
+ x.e = NaN;
1424
+ } else if (x.e < Ctor.minE) {
1425
+ x.e = 0;
1426
+ x.d = [0];
1427
+ }
1428
+ }
1429
+ return x;
1430
+ }
1431
+ function finiteToString(x, isExp, sd) {
1432
+ if (!x.isFinite())
1433
+ return nonFiniteToString(x);
1434
+ var k, e = x.e, str = digitsToString(x.d), len = str.length;
1435
+ if (isExp) {
1436
+ if (sd && (k = sd - len) > 0) {
1437
+ str = str.charAt(0) + "." + str.slice(1) + getZeroString(k);
1438
+ } else if (len > 1) {
1439
+ str = str.charAt(0) + "." + str.slice(1);
1440
+ }
1441
+ str = str + (x.e < 0 ? "e" : "e+") + x.e;
1442
+ } else if (e < 0) {
1443
+ str = "0." + getZeroString(-e - 1) + str;
1444
+ if (sd && (k = sd - len) > 0)
1445
+ str += getZeroString(k);
1446
+ } else if (e >= len) {
1447
+ str += getZeroString(e + 1 - len);
1448
+ if (sd && (k = sd - e - 1) > 0)
1449
+ str = str + "." + getZeroString(k);
1450
+ } else {
1451
+ if ((k = e + 1) < len)
1452
+ str = str.slice(0, k) + "." + str.slice(k);
1453
+ if (sd && (k = sd - len) > 0) {
1454
+ if (e + 1 === len)
1455
+ str += ".";
1456
+ str += getZeroString(k);
1457
+ }
1458
+ }
1459
+ return str;
1460
+ }
1461
+ function getBase10Exponent(digits, e) {
1462
+ var w = digits[0];
1463
+ for (e *= LOG_BASE; w >= 10; w /= 10)
1464
+ e++;
1465
+ return e;
1466
+ }
1467
+ function getLn10(Ctor, sd, pr) {
1468
+ if (sd > LN10_PRECISION) {
1469
+ external = true;
1470
+ if (pr)
1471
+ Ctor.precision = pr;
1472
+ throw Error(precisionLimitExceeded);
1473
+ }
1474
+ return finalise(new Ctor(LN10), sd, 1, true);
1475
+ }
1476
+ function getPi(Ctor, sd, rm) {
1477
+ if (sd > PI_PRECISION)
1478
+ throw Error(precisionLimitExceeded);
1479
+ return finalise(new Ctor(PI), sd, rm, true);
1480
+ }
1481
+ function getPrecision(digits) {
1482
+ var w = digits.length - 1, len = w * LOG_BASE + 1;
1483
+ w = digits[w];
1484
+ if (w) {
1485
+ for (; w % 10 == 0; w /= 10)
1486
+ len--;
1487
+ for (w = digits[0]; w >= 10; w /= 10)
1488
+ len++;
1489
+ }
1490
+ return len;
1491
+ }
1492
+ function getZeroString(k) {
1493
+ var zs = "";
1494
+ for (; k--; )
1495
+ zs += "0";
1496
+ return zs;
1497
+ }
1498
+ function intPow(Ctor, x, n, pr) {
1499
+ var isTruncated, r = new Ctor(1), k = Math.ceil(pr / LOG_BASE + 4);
1500
+ external = false;
1501
+ for (; ; ) {
1502
+ if (n % 2) {
1503
+ r = r.times(x);
1504
+ if (truncate(r.d, k))
1505
+ isTruncated = true;
1506
+ }
1507
+ n = mathfloor(n / 2);
1508
+ if (n === 0) {
1509
+ n = r.d.length - 1;
1510
+ if (isTruncated && r.d[n] === 0)
1511
+ ++r.d[n];
1512
+ break;
1513
+ }
1514
+ x = x.times(x);
1515
+ truncate(x.d, k);
1516
+ }
1517
+ external = true;
1518
+ return r;
1519
+ }
1520
+ function isOdd(n) {
1521
+ return n.d[n.d.length - 1] & 1;
1522
+ }
1523
+ function maxOrMin(Ctor, args, ltgt) {
1524
+ var y, x = new Ctor(args[0]), i = 0;
1525
+ for (; ++i < args.length; ) {
1526
+ y = new Ctor(args[i]);
1527
+ if (!y.s) {
1528
+ x = y;
1529
+ break;
1530
+ } else if (x[ltgt](y)) {
1531
+ x = y;
1532
+ }
1533
+ }
1534
+ return x;
1535
+ }
1536
+ function naturalExponential(x, sd) {
1537
+ var denominator, guard, j, pow2, sum2, t, wpr, rep = 0, i = 0, k = 0, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
1538
+ if (!x.d || !x.d[0] || x.e > 17) {
1539
+ return new Ctor(x.d ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 : x.s ? x.s < 0 ? 0 : x : 0 / 0);
1540
+ }
1541
+ if (sd == null) {
1542
+ external = false;
1543
+ wpr = pr;
1544
+ } else {
1545
+ wpr = sd;
1546
+ }
1547
+ t = new Ctor(0.03125);
1548
+ while (x.e > -2) {
1549
+ x = x.times(t);
1550
+ k += 5;
1551
+ }
1552
+ guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
1553
+ wpr += guard;
1554
+ denominator = pow2 = sum2 = new Ctor(1);
1555
+ Ctor.precision = wpr;
1556
+ for (; ; ) {
1557
+ pow2 = finalise(pow2.times(x), wpr, 1);
1558
+ denominator = denominator.times(++i);
1559
+ t = sum2.plus(divide(pow2, denominator, wpr, 1));
1560
+ if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum2.d).slice(0, wpr)) {
1561
+ j = k;
1562
+ while (j--)
1563
+ sum2 = finalise(sum2.times(sum2), wpr, 1);
1564
+ if (sd == null) {
1565
+ if (rep < 3 && checkRoundingDigits(sum2.d, wpr - guard, rm, rep)) {
1566
+ Ctor.precision = wpr += 10;
1567
+ denominator = pow2 = t = new Ctor(1);
1568
+ i = 0;
1569
+ rep++;
1570
+ } else {
1571
+ return finalise(sum2, Ctor.precision = pr, rm, external = true);
1572
+ }
1573
+ } else {
1574
+ Ctor.precision = pr;
1575
+ return sum2;
1576
+ }
1577
+ }
1578
+ sum2 = t;
1579
+ }
1580
+ }
1581
+ function naturalLogarithm(y, sd) {
1582
+ var c, c0, denominator, e, numerator, rep, sum2, t, wpr, x1, x2, n = 1, guard = 10, x = y, xd = x.d, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
1583
+ if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) {
1584
+ return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x);
1585
+ }
1586
+ if (sd == null) {
1587
+ external = false;
1588
+ wpr = pr;
1589
+ } else {
1590
+ wpr = sd;
1591
+ }
1592
+ Ctor.precision = wpr += guard;
1593
+ c = digitsToString(xd);
1594
+ c0 = c.charAt(0);
1595
+ if (Math.abs(e = x.e) < 15e14) {
1596
+ while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
1597
+ x = x.times(y);
1598
+ c = digitsToString(x.d);
1599
+ c0 = c.charAt(0);
1600
+ n++;
1601
+ }
1602
+ e = x.e;
1603
+ if (c0 > 1) {
1604
+ x = new Ctor("0." + c);
1605
+ e++;
1606
+ } else {
1607
+ x = new Ctor(c0 + "." + c.slice(1));
1608
+ }
1609
+ } else {
1610
+ t = getLn10(Ctor, wpr + 2, pr).times(e + "");
1611
+ x = naturalLogarithm(new Ctor(c0 + "." + c.slice(1)), wpr - guard).plus(t);
1612
+ Ctor.precision = pr;
1613
+ return sd == null ? finalise(x, pr, rm, external = true) : x;
1614
+ }
1615
+ x1 = x;
1616
+ sum2 = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1);
1617
+ x2 = finalise(x.times(x), wpr, 1);
1618
+ denominator = 3;
1619
+ for (; ; ) {
1620
+ numerator = finalise(numerator.times(x2), wpr, 1);
1621
+ t = sum2.plus(divide(numerator, new Ctor(denominator), wpr, 1));
1622
+ if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum2.d).slice(0, wpr)) {
1623
+ sum2 = sum2.times(2);
1624
+ if (e !== 0)
1625
+ sum2 = sum2.plus(getLn10(Ctor, wpr + 2, pr).times(e + ""));
1626
+ sum2 = divide(sum2, new Ctor(n), wpr, 1);
1627
+ if (sd == null) {
1628
+ if (checkRoundingDigits(sum2.d, wpr - guard, rm, rep)) {
1629
+ Ctor.precision = wpr += guard;
1630
+ t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1);
1631
+ x2 = finalise(x.times(x), wpr, 1);
1632
+ denominator = rep = 1;
1633
+ } else {
1634
+ return finalise(sum2, Ctor.precision = pr, rm, external = true);
1635
+ }
1636
+ } else {
1637
+ Ctor.precision = pr;
1638
+ return sum2;
1639
+ }
1640
+ }
1641
+ sum2 = t;
1642
+ denominator += 2;
1643
+ }
1644
+ }
1645
+ function nonFiniteToString(x) {
1646
+ return String(x.s * x.s / 0);
1647
+ }
1648
+ function parseDecimal(x, str) {
1649
+ var e, i, len;
1650
+ if ((e = str.indexOf(".")) > -1)
1651
+ str = str.replace(".", "");
1652
+ if ((i = str.search(/e/i)) > 0) {
1653
+ if (e < 0)
1654
+ e = i;
1655
+ e += +str.slice(i + 1);
1656
+ str = str.substring(0, i);
1657
+ } else if (e < 0) {
1658
+ e = str.length;
1659
+ }
1660
+ for (i = 0; str.charCodeAt(i) === 48; i++)
1661
+ ;
1662
+ for (len = str.length; str.charCodeAt(len - 1) === 48; --len)
1663
+ ;
1664
+ str = str.slice(i, len);
1665
+ if (str) {
1666
+ len -= i;
1667
+ x.e = e = e - i - 1;
1668
+ x.d = [];
1669
+ i = (e + 1) % LOG_BASE;
1670
+ if (e < 0)
1671
+ i += LOG_BASE;
1672
+ if (i < len) {
1673
+ if (i)
1674
+ x.d.push(+str.slice(0, i));
1675
+ for (len -= LOG_BASE; i < len; )
1676
+ x.d.push(+str.slice(i, i += LOG_BASE));
1677
+ str = str.slice(i);
1678
+ i = LOG_BASE - str.length;
1679
+ } else {
1680
+ i -= len;
1681
+ }
1682
+ for (; i--; )
1683
+ str += "0";
1684
+ x.d.push(+str);
1685
+ if (external) {
1686
+ if (x.e > x.constructor.maxE) {
1687
+ x.d = null;
1688
+ x.e = NaN;
1689
+ } else if (x.e < x.constructor.minE) {
1690
+ x.e = 0;
1691
+ x.d = [0];
1692
+ }
1693
+ }
1694
+ } else {
1695
+ x.e = 0;
1696
+ x.d = [0];
1697
+ }
1698
+ return x;
1699
+ }
1700
+ function parseOther(x, str) {
1701
+ var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
1702
+ if (str.indexOf("_") > -1) {
1703
+ str = str.replace(/(\d)_(?=\d)/g, "$1");
1704
+ if (isDecimal.test(str))
1705
+ return parseDecimal(x, str);
1706
+ } else if (str === "Infinity" || str === "NaN") {
1707
+ if (!+str)
1708
+ x.s = NaN;
1709
+ x.e = NaN;
1710
+ x.d = null;
1711
+ return x;
1712
+ }
1713
+ if (isHex.test(str)) {
1714
+ base = 16;
1715
+ str = str.toLowerCase();
1716
+ } else if (isBinary.test(str)) {
1717
+ base = 2;
1718
+ } else if (isOctal.test(str)) {
1719
+ base = 8;
1720
+ } else {
1721
+ throw Error(invalidArgument + str);
1722
+ }
1723
+ i = str.search(/p/i);
1724
+ if (i > 0) {
1725
+ p = +str.slice(i + 1);
1726
+ str = str.substring(2, i);
1727
+ } else {
1728
+ str = str.slice(2);
1729
+ }
1730
+ i = str.indexOf(".");
1731
+ isFloat = i >= 0;
1732
+ Ctor = x.constructor;
1733
+ if (isFloat) {
1734
+ str = str.replace(".", "");
1735
+ len = str.length;
1736
+ i = len - i;
1737
+ divisor = intPow(Ctor, new Ctor(base), i, i * 2);
1738
+ }
1739
+ xd = convertBase(str, base, BASE);
1740
+ xe = xd.length - 1;
1741
+ for (i = xe; xd[i] === 0; --i)
1742
+ xd.pop();
1743
+ if (i < 0)
1744
+ return new Ctor(x.s * 0);
1745
+ x.e = getBase10Exponent(xd, xe);
1746
+ x.d = xd;
1747
+ external = false;
1748
+ if (isFloat)
1749
+ x = divide(x, divisor, len * 4);
1750
+ if (p)
1751
+ x = x.times(Math.abs(p) < 54 ? mathpow(2, p) : Decimal.pow(2, p));
1752
+ external = true;
1753
+ return x;
1754
+ }
1755
+ function sine(Ctor, x) {
1756
+ var k, len = x.d.length;
1757
+ if (len < 3) {
1758
+ return x.isZero() ? x : taylorSeries(Ctor, 2, x, x);
1759
+ }
1760
+ k = 1.4 * Math.sqrt(len);
1761
+ k = k > 16 ? 16 : k | 0;
1762
+ x = x.times(1 / tinyPow(5, k));
1763
+ x = taylorSeries(Ctor, 2, x, x);
1764
+ var sin2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
1765
+ for (; k--; ) {
1766
+ sin2_x = x.times(x);
1767
+ x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20))));
1768
+ }
1769
+ return x;
1770
+ }
1771
+ function taylorSeries(Ctor, n, x, y, isHyperbolic) {
1772
+ var j, t, u, x2, i = 1, pr = Ctor.precision, k = Math.ceil(pr / LOG_BASE);
1773
+ external = false;
1774
+ x2 = x.times(x);
1775
+ u = new Ctor(y);
1776
+ for (; ; ) {
1777
+ t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1);
1778
+ u = isHyperbolic ? y.plus(t) : y.minus(t);
1779
+ y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1);
1780
+ t = u.plus(y);
1781
+ if (t.d[k] !== void 0) {
1782
+ for (j = k; t.d[j] === u.d[j] && j--; )
1783
+ ;
1784
+ if (j == -1)
1785
+ break;
1786
+ }
1787
+ j = u;
1788
+ u = y;
1789
+ y = t;
1790
+ t = j;
1791
+ i++;
1792
+ }
1793
+ external = true;
1794
+ t.d.length = k + 1;
1795
+ return t;
1796
+ }
1797
+ function tinyPow(b, e) {
1798
+ var n = b;
1799
+ while (--e)
1800
+ n *= b;
1801
+ return n;
1802
+ }
1803
+ function toLessThanHalfPi(Ctor, x) {
1804
+ var t, isNeg = x.s < 0, pi = getPi(Ctor, Ctor.precision, 1), halfPi = pi.times(0.5);
1805
+ x = x.abs();
1806
+ if (x.lte(halfPi)) {
1807
+ quadrant = isNeg ? 4 : 1;
1808
+ return x;
1809
+ }
1810
+ t = x.divToInt(pi);
1811
+ if (t.isZero()) {
1812
+ quadrant = isNeg ? 3 : 2;
1813
+ } else {
1814
+ x = x.minus(t.times(pi));
1815
+ if (x.lte(halfPi)) {
1816
+ quadrant = isOdd(t) ? isNeg ? 2 : 3 : isNeg ? 4 : 1;
1817
+ return x;
1818
+ }
1819
+ quadrant = isOdd(t) ? isNeg ? 1 : 4 : isNeg ? 3 : 2;
1820
+ }
1821
+ return x.minus(pi).abs();
1822
+ }
1823
+ function toStringBinary(x, baseOut, sd, rm) {
1824
+ var base, e, i, k, len, roundUp, str, xd, y, Ctor = x.constructor, isExp = sd !== void 0;
1825
+ if (isExp) {
1826
+ checkInt32(sd, 1, MAX_DIGITS);
1827
+ if (rm === void 0)
1828
+ rm = Ctor.rounding;
1829
+ else
1830
+ checkInt32(rm, 0, 8);
1831
+ } else {
1832
+ sd = Ctor.precision;
1833
+ rm = Ctor.rounding;
1834
+ }
1835
+ if (!x.isFinite()) {
1836
+ str = nonFiniteToString(x);
1837
+ } else {
1838
+ str = finiteToString(x);
1839
+ i = str.indexOf(".");
1840
+ if (isExp) {
1841
+ base = 2;
1842
+ if (baseOut == 16) {
1843
+ sd = sd * 4 - 3;
1844
+ } else if (baseOut == 8) {
1845
+ sd = sd * 3 - 2;
1846
+ }
1847
+ } else {
1848
+ base = baseOut;
1849
+ }
1850
+ if (i >= 0) {
1851
+ str = str.replace(".", "");
1852
+ y = new Ctor(1);
1853
+ y.e = str.length - i;
1854
+ y.d = convertBase(finiteToString(y), 10, base);
1855
+ y.e = y.d.length;
1856
+ }
1857
+ xd = convertBase(str, 10, base);
1858
+ e = len = xd.length;
1859
+ for (; xd[--len] == 0; )
1860
+ xd.pop();
1861
+ if (!xd[0]) {
1862
+ str = isExp ? "0p+0" : "0";
1863
+ } else {
1864
+ if (i < 0) {
1865
+ e--;
1866
+ } else {
1867
+ x = new Ctor(x);
1868
+ x.d = xd;
1869
+ x.e = e;
1870
+ x = divide(x, y, sd, rm, 0, base);
1871
+ xd = x.d;
1872
+ e = x.e;
1873
+ roundUp = inexact;
1874
+ }
1875
+ i = xd[sd];
1876
+ k = base / 2;
1877
+ roundUp = roundUp || xd[sd + 1] !== void 0;
1878
+ roundUp = rm < 4 ? (i !== void 0 || roundUp) && (rm === 0 || rm === (x.s < 0 ? 3 : 2)) : i > k || i === k && (rm === 4 || roundUp || rm === 6 && xd[sd - 1] & 1 || rm === (x.s < 0 ? 8 : 7));
1879
+ xd.length = sd;
1880
+ if (roundUp) {
1881
+ for (; ++xd[--sd] > base - 1; ) {
1882
+ xd[sd] = 0;
1883
+ if (!sd) {
1884
+ ++e;
1885
+ xd.unshift(1);
1886
+ }
1887
+ }
1888
+ }
1889
+ for (len = xd.length; !xd[len - 1]; --len)
1890
+ ;
1891
+ for (i = 0, str = ""; i < len; i++)
1892
+ str += NUMERALS.charAt(xd[i]);
1893
+ if (isExp) {
1894
+ if (len > 1) {
1895
+ if (baseOut == 16 || baseOut == 8) {
1896
+ i = baseOut == 16 ? 4 : 3;
1897
+ for (--len; len % i; len++)
1898
+ str += "0";
1899
+ xd = convertBase(str, base, baseOut);
1900
+ for (len = xd.length; !xd[len - 1]; --len)
1901
+ ;
1902
+ for (i = 1, str = "1."; i < len; i++)
1903
+ str += NUMERALS.charAt(xd[i]);
1904
+ } else {
1905
+ str = str.charAt(0) + "." + str.slice(1);
1906
+ }
1907
+ }
1908
+ str = str + (e < 0 ? "p" : "p+") + e;
1909
+ } else if (e < 0) {
1910
+ for (; ++e; )
1911
+ str = "0" + str;
1912
+ str = "0." + str;
1913
+ } else {
1914
+ if (++e > len)
1915
+ for (e -= len; e--; )
1916
+ str += "0";
1917
+ else if (e < len)
1918
+ str = str.slice(0, e) + "." + str.slice(e);
1919
+ }
1920
+ }
1921
+ str = (baseOut == 16 ? "0x" : baseOut == 2 ? "0b" : baseOut == 8 ? "0o" : "") + str;
1922
+ }
1923
+ return x.s < 0 ? "-" + str : str;
1924
+ }
1925
+ function truncate(arr, len) {
1926
+ if (arr.length > len) {
1927
+ arr.length = len;
1928
+ return true;
1929
+ }
1930
+ }
1931
+ function abs(x) {
1932
+ return new this(x).abs();
1933
+ }
1934
+ function acos(x) {
1935
+ return new this(x).acos();
1936
+ }
1937
+ function acosh(x) {
1938
+ return new this(x).acosh();
1939
+ }
1940
+ function add(x, y) {
1941
+ return new this(x).plus(y);
1942
+ }
1943
+ function asin(x) {
1944
+ return new this(x).asin();
1945
+ }
1946
+ function asinh(x) {
1947
+ return new this(x).asinh();
1948
+ }
1949
+ function atan(x) {
1950
+ return new this(x).atan();
1951
+ }
1952
+ function atanh(x) {
1953
+ return new this(x).atanh();
1954
+ }
1955
+ function atan2(y, x) {
1956
+ y = new this(y);
1957
+ x = new this(x);
1958
+ var r, pr = this.precision, rm = this.rounding, wpr = pr + 4;
1959
+ if (!y.s || !x.s) {
1960
+ r = new this(NaN);
1961
+ } else if (!y.d && !x.d) {
1962
+ r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75);
1963
+ r.s = y.s;
1964
+ } else if (!x.d || y.isZero()) {
1965
+ r = x.s < 0 ? getPi(this, pr, rm) : new this(0);
1966
+ r.s = y.s;
1967
+ } else if (!y.d || x.isZero()) {
1968
+ r = getPi(this, wpr, 1).times(0.5);
1969
+ r.s = y.s;
1970
+ } else if (x.s < 0) {
1971
+ this.precision = wpr;
1972
+ this.rounding = 1;
1973
+ r = this.atan(divide(y, x, wpr, 1));
1974
+ x = getPi(this, wpr, 1);
1975
+ this.precision = pr;
1976
+ this.rounding = rm;
1977
+ r = y.s < 0 ? r.minus(x) : r.plus(x);
1978
+ } else {
1979
+ r = this.atan(divide(y, x, wpr, 1));
1980
+ }
1981
+ return r;
1982
+ }
1983
+ function cbrt(x) {
1984
+ return new this(x).cbrt();
1985
+ }
1986
+ function ceil(x) {
1987
+ return finalise(x = new this(x), x.e + 1, 2);
1988
+ }
1989
+ function clamp(x, min2, max2) {
1990
+ return new this(x).clamp(min2, max2);
1991
+ }
1992
+ function config(obj) {
1993
+ if (!obj || typeof obj !== "object")
1994
+ throw Error(decimalError + "Object expected");
1995
+ var i, p, v, useDefaults = obj.defaults === true, ps = [
1996
+ "precision",
1997
+ 1,
1998
+ MAX_DIGITS,
1999
+ "rounding",
2000
+ 0,
2001
+ 8,
2002
+ "toExpNeg",
2003
+ -EXP_LIMIT,
2004
+ 0,
2005
+ "toExpPos",
2006
+ 0,
2007
+ EXP_LIMIT,
2008
+ "maxE",
2009
+ 0,
2010
+ EXP_LIMIT,
2011
+ "minE",
2012
+ -EXP_LIMIT,
2013
+ 0,
2014
+ "modulo",
2015
+ 0,
2016
+ 9
2017
+ ];
2018
+ for (i = 0; i < ps.length; i += 3) {
2019
+ if (p = ps[i], useDefaults)
2020
+ this[p] = DEFAULTS[p];
2021
+ if ((v = obj[p]) !== void 0) {
2022
+ if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2])
2023
+ this[p] = v;
2024
+ else
2025
+ throw Error(invalidArgument + p + ": " + v);
2026
+ }
2027
+ }
2028
+ if (p = "crypto", useDefaults)
2029
+ this[p] = DEFAULTS[p];
2030
+ if ((v = obj[p]) !== void 0) {
2031
+ if (v === true || v === false || v === 0 || v === 1) {
2032
+ if (v) {
2033
+ if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
2034
+ this[p] = true;
2035
+ } else {
2036
+ throw Error(cryptoUnavailable);
2037
+ }
2038
+ } else {
2039
+ this[p] = false;
2040
+ }
2041
+ } else {
2042
+ throw Error(invalidArgument + p + ": " + v);
2043
+ }
2044
+ }
2045
+ return this;
2046
+ }
2047
+ function cos(x) {
2048
+ return new this(x).cos();
2049
+ }
2050
+ function cosh(x) {
2051
+ return new this(x).cosh();
2052
+ }
2053
+ function clone(obj) {
2054
+ var i, p, ps;
2055
+ function Decimal2(v) {
2056
+ var e, i2, t, x = this;
2057
+ if (!(x instanceof Decimal2))
2058
+ return new Decimal2(v);
2059
+ x.constructor = Decimal2;
2060
+ if (isDecimalInstance(v)) {
2061
+ x.s = v.s;
2062
+ if (external) {
2063
+ if (!v.d || v.e > Decimal2.maxE) {
2064
+ x.e = NaN;
2065
+ x.d = null;
2066
+ } else if (v.e < Decimal2.minE) {
2067
+ x.e = 0;
2068
+ x.d = [0];
2069
+ } else {
2070
+ x.e = v.e;
2071
+ x.d = v.d.slice();
2072
+ }
2073
+ } else {
2074
+ x.e = v.e;
2075
+ x.d = v.d ? v.d.slice() : v.d;
2076
+ }
2077
+ return;
2078
+ }
2079
+ t = typeof v;
2080
+ if (t === "number") {
2081
+ if (v === 0) {
2082
+ x.s = 1 / v < 0 ? -1 : 1;
2083
+ x.e = 0;
2084
+ x.d = [0];
2085
+ return;
2086
+ }
2087
+ if (v < 0) {
2088
+ v = -v;
2089
+ x.s = -1;
2090
+ } else {
2091
+ x.s = 1;
2092
+ }
2093
+ if (v === ~~v && v < 1e7) {
2094
+ for (e = 0, i2 = v; i2 >= 10; i2 /= 10)
2095
+ e++;
2096
+ if (external) {
2097
+ if (e > Decimal2.maxE) {
2098
+ x.e = NaN;
2099
+ x.d = null;
2100
+ } else if (e < Decimal2.minE) {
2101
+ x.e = 0;
2102
+ x.d = [0];
2103
+ } else {
2104
+ x.e = e;
2105
+ x.d = [v];
2106
+ }
2107
+ } else {
2108
+ x.e = e;
2109
+ x.d = [v];
2110
+ }
2111
+ return;
2112
+ } else if (v * 0 !== 0) {
2113
+ if (!v)
2114
+ x.s = NaN;
2115
+ x.e = NaN;
2116
+ x.d = null;
2117
+ return;
2118
+ }
2119
+ return parseDecimal(x, v.toString());
2120
+ } else if (t !== "string") {
2121
+ throw Error(invalidArgument + v);
2122
+ }
2123
+ if ((i2 = v.charCodeAt(0)) === 45) {
2124
+ v = v.slice(1);
2125
+ x.s = -1;
2126
+ } else {
2127
+ if (i2 === 43)
2128
+ v = v.slice(1);
2129
+ x.s = 1;
2130
+ }
2131
+ return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v);
2132
+ }
2133
+ Decimal2.prototype = P;
2134
+ Decimal2.ROUND_UP = 0;
2135
+ Decimal2.ROUND_DOWN = 1;
2136
+ Decimal2.ROUND_CEIL = 2;
2137
+ Decimal2.ROUND_FLOOR = 3;
2138
+ Decimal2.ROUND_HALF_UP = 4;
2139
+ Decimal2.ROUND_HALF_DOWN = 5;
2140
+ Decimal2.ROUND_HALF_EVEN = 6;
2141
+ Decimal2.ROUND_HALF_CEIL = 7;
2142
+ Decimal2.ROUND_HALF_FLOOR = 8;
2143
+ Decimal2.EUCLID = 9;
2144
+ Decimal2.config = Decimal2.set = config;
2145
+ Decimal2.clone = clone;
2146
+ Decimal2.isDecimal = isDecimalInstance;
2147
+ Decimal2.abs = abs;
2148
+ Decimal2.acos = acos;
2149
+ Decimal2.acosh = acosh;
2150
+ Decimal2.add = add;
2151
+ Decimal2.asin = asin;
2152
+ Decimal2.asinh = asinh;
2153
+ Decimal2.atan = atan;
2154
+ Decimal2.atanh = atanh;
2155
+ Decimal2.atan2 = atan2;
2156
+ Decimal2.cbrt = cbrt;
2157
+ Decimal2.ceil = ceil;
2158
+ Decimal2.clamp = clamp;
2159
+ Decimal2.cos = cos;
2160
+ Decimal2.cosh = cosh;
2161
+ Decimal2.div = div;
2162
+ Decimal2.exp = exp;
2163
+ Decimal2.floor = floor;
2164
+ Decimal2.hypot = hypot;
2165
+ Decimal2.ln = ln;
2166
+ Decimal2.log = log;
2167
+ Decimal2.log10 = log10;
2168
+ Decimal2.log2 = log2;
2169
+ Decimal2.max = max;
2170
+ Decimal2.min = min;
2171
+ Decimal2.mod = mod;
2172
+ Decimal2.mul = mul;
2173
+ Decimal2.pow = pow;
2174
+ Decimal2.random = random;
2175
+ Decimal2.round = round;
2176
+ Decimal2.sign = sign;
2177
+ Decimal2.sin = sin;
2178
+ Decimal2.sinh = sinh;
2179
+ Decimal2.sqrt = sqrt;
2180
+ Decimal2.sub = sub;
2181
+ Decimal2.sum = sum;
2182
+ Decimal2.tan = tan;
2183
+ Decimal2.tanh = tanh;
2184
+ Decimal2.trunc = trunc;
2185
+ if (obj === void 0)
2186
+ obj = {};
2187
+ if (obj) {
2188
+ if (obj.defaults !== true) {
2189
+ ps = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"];
2190
+ for (i = 0; i < ps.length; )
2191
+ if (!obj.hasOwnProperty(p = ps[i++]))
2192
+ obj[p] = this[p];
2193
+ }
2194
+ }
2195
+ Decimal2.config(obj);
2196
+ return Decimal2;
2197
+ }
2198
+ function div(x, y) {
2199
+ return new this(x).div(y);
2200
+ }
2201
+ function exp(x) {
2202
+ return new this(x).exp();
2203
+ }
2204
+ function floor(x) {
2205
+ return finalise(x = new this(x), x.e + 1, 3);
2206
+ }
2207
+ function hypot() {
2208
+ var i, n, t = new this(0);
2209
+ external = false;
2210
+ for (i = 0; i < arguments.length; ) {
2211
+ n = new this(arguments[i++]);
2212
+ if (!n.d) {
2213
+ if (n.s) {
2214
+ external = true;
2215
+ return new this(1 / 0);
2216
+ }
2217
+ t = n;
2218
+ } else if (t.d) {
2219
+ t = t.plus(n.times(n));
2220
+ }
2221
+ }
2222
+ external = true;
2223
+ return t.sqrt();
2224
+ }
2225
+ function isDecimalInstance(obj) {
2226
+ return obj instanceof Decimal || obj && obj.toStringTag === tag || false;
2227
+ }
2228
+ function ln(x) {
2229
+ return new this(x).ln();
2230
+ }
2231
+ function log(x, y) {
2232
+ return new this(x).log(y);
2233
+ }
2234
+ function log2(x) {
2235
+ return new this(x).log(2);
2236
+ }
2237
+ function log10(x) {
2238
+ return new this(x).log(10);
2239
+ }
2240
+ function max() {
2241
+ return maxOrMin(this, arguments, "lt");
2242
+ }
2243
+ function min() {
2244
+ return maxOrMin(this, arguments, "gt");
2245
+ }
2246
+ function mod(x, y) {
2247
+ return new this(x).mod(y);
2248
+ }
2249
+ function mul(x, y) {
2250
+ return new this(x).mul(y);
2251
+ }
2252
+ function pow(x, y) {
2253
+ return new this(x).pow(y);
2254
+ }
2255
+ function random(sd) {
2256
+ var d, e, k, n, i = 0, r = new this(1), rd = [];
2257
+ if (sd === void 0)
2258
+ sd = this.precision;
2259
+ else
2260
+ checkInt32(sd, 1, MAX_DIGITS);
2261
+ k = Math.ceil(sd / LOG_BASE);
2262
+ if (!this.crypto) {
2263
+ for (; i < k; )
2264
+ rd[i++] = Math.random() * 1e7 | 0;
2265
+ } else if (crypto.getRandomValues) {
2266
+ d = crypto.getRandomValues(new Uint32Array(k));
2267
+ for (; i < k; ) {
2268
+ n = d[i];
2269
+ if (n >= 429e7) {
2270
+ d[i] = crypto.getRandomValues(new Uint32Array(1))[0];
2271
+ } else {
2272
+ rd[i++] = n % 1e7;
2273
+ }
2274
+ }
2275
+ } else if (crypto.randomBytes) {
2276
+ d = crypto.randomBytes(k *= 4);
2277
+ for (; i < k; ) {
2278
+ n = d[i] + (d[i + 1] << 8) + (d[i + 2] << 16) + ((d[i + 3] & 127) << 24);
2279
+ if (n >= 214e7) {
2280
+ crypto.randomBytes(4).copy(d, i);
2281
+ } else {
2282
+ rd.push(n % 1e7);
2283
+ i += 4;
2284
+ }
2285
+ }
2286
+ i = k / 4;
2287
+ } else {
2288
+ throw Error(cryptoUnavailable);
2289
+ }
2290
+ k = rd[--i];
2291
+ sd %= LOG_BASE;
2292
+ if (k && sd) {
2293
+ n = mathpow(10, LOG_BASE - sd);
2294
+ rd[i] = (k / n | 0) * n;
2295
+ }
2296
+ for (; rd[i] === 0; i--)
2297
+ rd.pop();
2298
+ if (i < 0) {
2299
+ e = 0;
2300
+ rd = [0];
2301
+ } else {
2302
+ e = -1;
2303
+ for (; rd[0] === 0; e -= LOG_BASE)
2304
+ rd.shift();
2305
+ for (k = 1, n = rd[0]; n >= 10; n /= 10)
2306
+ k++;
2307
+ if (k < LOG_BASE)
2308
+ e -= LOG_BASE - k;
2309
+ }
2310
+ r.e = e;
2311
+ r.d = rd;
2312
+ return r;
2313
+ }
2314
+ function round(x) {
2315
+ return finalise(x = new this(x), x.e + 1, this.rounding);
2316
+ }
2317
+ function sign(x) {
2318
+ x = new this(x);
2319
+ return x.d ? x.d[0] ? x.s : 0 * x.s : x.s || NaN;
2320
+ }
2321
+ function sin(x) {
2322
+ return new this(x).sin();
2323
+ }
2324
+ function sinh(x) {
2325
+ return new this(x).sinh();
2326
+ }
2327
+ function sqrt(x) {
2328
+ return new this(x).sqrt();
2329
+ }
2330
+ function sub(x, y) {
2331
+ return new this(x).sub(y);
2332
+ }
2333
+ function sum() {
2334
+ var i = 0, args = arguments, x = new this(args[i]);
2335
+ external = false;
2336
+ for (; x.s && ++i < args.length; )
2337
+ x = x.plus(args[i]);
2338
+ external = true;
2339
+ return finalise(x, this.precision, this.rounding);
2340
+ }
2341
+ function tan(x) {
2342
+ return new this(x).tan();
2343
+ }
2344
+ function tanh(x) {
2345
+ return new this(x).tanh();
2346
+ }
2347
+ function trunc(x) {
2348
+ return finalise(x = new this(x), x.e + 1, 1);
2349
+ }
2350
+ P[Symbol.for("nodejs.util.inspect.custom")] = P.toString;
2351
+ P[Symbol.toStringTag] = "Decimal";
2352
+ var Decimal = P.constructor = clone(DEFAULTS);
2353
+ LN10 = new Decimal(LN10);
2354
+ PI = new Decimal(PI);
2355
+ var decimal_default = Decimal;
2356
+
2357
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/constants.js
2358
+ var TEN = new decimal_default(10);
2359
+ var ZERO = new decimal_default(0);
2360
+ var NEGATIVE_ZERO = new decimal_default(-0);
2361
+
7
2362
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/262.js
8
2363
  var MINUTES_PER_HOUR = 60;
9
2364
  var SECONDS_PER_MINUTE = 60;
@@ -219,6 +2574,21 @@
219
2574
  strategy: strategies.variadic
220
2575
  });
221
2576
 
2577
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/ComputeExponentForMagnitude.js
2578
+ decimal_default.set({
2579
+ toExpPos: 100
2580
+ });
2581
+
2582
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/ToRawFixed.js
2583
+ decimal_default.set({
2584
+ toExpPos: 100
2585
+ });
2586
+
2587
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/ToRawPrecision.js
2588
+ decimal_default.set({
2589
+ toExpPos: 100
2590
+ });
2591
+
222
2592
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/regex.generated.js
223
2593
  var S_UNICODE_REGEX = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20BF\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC1\uFDFC\uFDFD\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDE8\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEE0-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF73\uDF80-\uDFD8\uDFE0-\uDFEB]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDD78\uDD7A-\uDDCB\uDDCD-\uDE53\uDE60-\uDE6D\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6\uDF00-\uDF92\uDF94-\uDFCA]/;
224
2594
 
@@ -409,4 +2779,15 @@
409
2779
  });
410
2780
  }
411
2781
  })();
2782
+ /*! Bundled license information:
2783
+
2784
+ decimal.js/decimal.mjs:
2785
+ (*!
2786
+ * decimal.js v10.4.3
2787
+ * An arbitrary-precision Decimal type for JavaScript.
2788
+ * https://github.com/MikeMcl/decimal.js
2789
+ * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
2790
+ * MIT Licence
2791
+ *)
2792
+ */
412
2793
  //# sourceMappingURL=polyfill.iife.js.map