@formatjs/intl-listformat 7.7.5 → 7.7.7

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