@servicetitan/anvil2 1.43.3 → 1.44.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/{Breadcrumbs-B5bqrZ5D-BqK-Qfh9.js → Breadcrumbs-BMbkH9hL-BUjQksuj.js} +3 -3
  3. package/dist/{Breadcrumbs-B5bqrZ5D-BqK-Qfh9.js.map → Breadcrumbs-BMbkH9hL-BUjQksuj.js.map} +1 -1
  4. package/dist/{Breadcrumbs-De8uoLi8.js → Breadcrumbs-fthw3qaL.js} +2 -2
  5. package/dist/{Breadcrumbs-De8uoLi8.js.map → Breadcrumbs-fthw3qaL.js.map} +1 -1
  6. package/dist/Breadcrumbs.js +1 -1
  7. package/dist/{Calendar-DD5kmVd3-CBGTR11R.js → Calendar-BvftKznl-D4_xp9Rv.js} +3 -3
  8. package/dist/{Calendar-DD5kmVd3-CBGTR11R.js.map → Calendar-BvftKznl-D4_xp9Rv.js.map} +1 -1
  9. package/dist/{Calendar-Bgpz99F2.js → Calendar-DdOR9T_K.js} +2 -2
  10. package/dist/{Calendar-Bgpz99F2.js.map → Calendar-DdOR9T_K.js.map} +1 -1
  11. package/dist/Calendar.js +1 -1
  12. package/dist/{DateField-_TqCdcYv.js → DateField-Bqsnpt8S.js} +4 -4
  13. package/dist/{DateField-_TqCdcYv.js.map → DateField-Bqsnpt8S.js.map} +1 -1
  14. package/dist/DateField.js +1 -1
  15. package/dist/{DateFieldRange-Dk8WA52F.js → DateFieldRange-Cax7Kl9A.js} +2 -2
  16. package/dist/{DateFieldRange-Dk8WA52F.js.map → DateFieldRange-Cax7Kl9A.js.map} +1 -1
  17. package/dist/DateFieldRange.js +1 -1
  18. package/dist/{DateFieldSingle-D3xD8YZk.js → DateFieldSingle-bMX770gU.js} +2 -2
  19. package/dist/{DateFieldSingle-D3xD8YZk.js.map → DateFieldSingle-bMX770gU.js.map} +1 -1
  20. package/dist/DateFieldSingle.js +1 -1
  21. package/dist/{DateFieldYearless-BxkCSNk5.js → DateFieldYearless-ClNYTBK_.js} +2 -2
  22. package/dist/{DateFieldYearless-BxkCSNk5.js.map → DateFieldYearless-ClNYTBK_.js.map} +1 -1
  23. package/dist/{DateFieldYearless-CAUHW6Ow-EUWxJ0OY.js → DateFieldYearless-pejtv7-x-DBHpW83U.js} +7 -65
  24. package/dist/DateFieldYearless-pejtv7-x-DBHpW83U.js.map +1 -0
  25. package/dist/DateFieldYearless.js +1 -1
  26. package/dist/{InputMask-wUro4G2j.js → InputMask-BOUlnmiF.js} +2 -2
  27. package/dist/{InputMask-wUro4G2j.js.map → InputMask-BOUlnmiF.js.map} +1 -1
  28. package/dist/{InputMask-CE3pdXwL-B8XVrj36.js → InputMask-BuO8lNAB-DdxdO5Jw.js} +3 -3
  29. package/dist/{InputMask-CE3pdXwL-B8XVrj36.js.map → InputMask-BuO8lNAB-DdxdO5Jw.js.map} +1 -1
  30. package/dist/InputMask.js +1 -1
  31. package/dist/{Link-DZa0wmkA.js → Link-C4N_cV3i.js} +2 -2
  32. package/dist/{Link-DZa0wmkA.js.map → Link-C4N_cV3i.js.map} +1 -1
  33. package/dist/{Link-Dqp_XXl_-Bv20l_tY.js → Link-MiffPrW9-Cx1zYWSF.js} +3 -3
  34. package/dist/{Link-Dqp_XXl_-Bv20l_tY.js.map → Link-MiffPrW9-Cx1zYWSF.js.map} +1 -1
  35. package/dist/Link.js +1 -1
  36. package/dist/LinkButton.css +5 -0
  37. package/dist/LinkButton.d.ts +6 -0
  38. package/dist/LinkButton.js +76 -0
  39. package/dist/LinkButton.js.map +1 -0
  40. package/dist/{ListView-DdHpJHTc.js → ListView-DVPhWDCM.js} +24 -5
  41. package/dist/ListView-DVPhWDCM.js.map +1 -0
  42. package/dist/ListView.js +1 -1
  43. package/dist/NumberField-C9lMsPMD.js +1582 -0
  44. package/dist/NumberField-C9lMsPMD.js.map +1 -0
  45. package/dist/NumberField.css +49 -0
  46. package/dist/NumberField.d.ts +6 -0
  47. package/dist/NumberField.js +2 -0
  48. package/dist/NumberField.js.map +1 -0
  49. package/dist/{Page-CxB5N9dR.js → Page-CGAylFKz.js} +2 -2
  50. package/dist/{Page-CxB5N9dR.js.map → Page-CGAylFKz.js.map} +1 -1
  51. package/dist/Page.js +1 -1
  52. package/dist/{SegmentedControl-DKMQuf7s.js → SegmentedControl-DY1PSYmd.js} +2 -2
  53. package/dist/{SegmentedControl-DKMQuf7s.js.map → SegmentedControl-DY1PSYmd.js.map} +1 -1
  54. package/dist/SegmentedControl.js +1 -1
  55. package/dist/{SelectCard-DUNwYa5y-BSi21Aba.js → SelectCard-LSAl_7Lh-BYtfe9PC.js} +3 -3
  56. package/dist/{SelectCard-DUNwYa5y-BSi21Aba.js.map → SelectCard-LSAl_7Lh-BYtfe9PC.js.map} +1 -1
  57. package/dist/SelectCard.js +1 -1
  58. package/dist/{SelectCardGroup-YGYiBv5M.js → SelectCardGroup-u_QKdeRZ.js} +2 -2
  59. package/dist/{SelectCardGroup-YGYiBv5M.js.map → SelectCardGroup-u_QKdeRZ.js.map} +1 -1
  60. package/dist/{TextField-gYAqTpcX.js → TextField-B364hxo8.js} +2 -2
  61. package/dist/{TextField-gYAqTpcX.js.map → TextField-B364hxo8.js.map} +1 -1
  62. package/dist/{TextField-CRTh0gL_-D2CjcYXX.js → TextField-DoPP1CQ--UWAOTYiv.js} +2 -2
  63. package/dist/{TextField-CRTh0gL_-D2CjcYXX.js.map → TextField-DoPP1CQ--UWAOTYiv.js.map} +1 -1
  64. package/dist/TextField.js +1 -1
  65. package/dist/{Textarea-DohNOiIp.js → Textarea-D2AAZ1L3.js} +2 -2
  66. package/dist/{Textarea-DohNOiIp.js.map → Textarea-D2AAZ1L3.js.map} +1 -1
  67. package/dist/Textarea.js +1 -1
  68. package/dist/{TimeField-DRHLRqN3.js → TimeField-tA9uo4lK.js} +5 -4
  69. package/dist/{TimeField-DRHLRqN3.js.map → TimeField-tA9uo4lK.js.map} +1 -1
  70. package/dist/TimeField.js +1 -1
  71. package/dist/components/LinkButton/LinkButton.d.ts +57 -0
  72. package/dist/components/LinkButton/index.d.ts +2 -0
  73. package/dist/components/NumberField/NumberField.d.ts +11 -0
  74. package/dist/components/NumberField/index.d.ts +2 -0
  75. package/dist/components/index.d.ts +1 -0
  76. package/dist/{usePopoverSupport-B9Lsqryr-DhZHMoNb.js → index.esm-dyoPQhi6.js} +735 -13
  77. package/dist/index.esm-dyoPQhi6.js.map +1 -0
  78. package/dist/index.js +17 -16
  79. package/dist/index.js.map +1 -1
  80. package/dist/useFocusWithin-Cxz14Zyz-DEudRcSI.js +64 -0
  81. package/dist/useFocusWithin-Cxz14Zyz-DEudRcSI.js.map +1 -0
  82. package/dist/useLinkStyles.js +1 -1
  83. package/dist/{useOptionallyControlledState-DAv5LXXh-DAv5LXXh.js → useOptionallyControlledState-DbDuos5L-DbDuos5L.js} +9 -3
  84. package/dist/useOptionallyControlledState-DbDuos5L-DbDuos5L.js.map +1 -0
  85. package/dist/usePopoverSupport-B9Lsqryr-CYJxXiun.js +15 -0
  86. package/dist/usePopoverSupport-B9Lsqryr-CYJxXiun.js.map +1 -0
  87. package/package.json +2 -2
  88. package/dist/DateFieldYearless-CAUHW6Ow-EUWxJ0OY.js.map +0 -1
  89. package/dist/ListView-DdHpJHTc.js.map +0 -1
  90. package/dist/useOptionallyControlledState-DAv5LXXh-DAv5LXXh.js.map +0 -1
  91. package/dist/usePopoverSupport-B9Lsqryr-DhZHMoNb.js.map +0 -1
  92. /package/dist/{Breadcrumbs-B5bqrZ5D.css → Breadcrumbs-BMbkH9hL.css} +0 -0
  93. /package/dist/{Calendar-DD5kmVd3.css → Calendar-BvftKznl.css} +0 -0
  94. /package/dist/{Link-Dqp_XXl_.css → Link-MiffPrW9.css} +0 -0
  95. /package/dist/{SelectCard-DUNwYa5y.css → SelectCard-LSAl_7Lh.css} +0 -0
@@ -0,0 +1,1582 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { forwardRef, useRef, useState, useId, useMemo, useEffect, useCallback } from 'react';
4
+ import { useTrackingId } from './useTrackingId.js';
5
+ import { c as childrenToString } from './childrenToString-Bz9MqbHb-Bz9MqbHb.js';
6
+ import { c as cx } from './index-tZvMCc77.js';
7
+ import { L as Label } from './ProgressBar-BRvB-bD4-DppwBrFg.js';
8
+ import { S as Spinner } from './Spinner-DliJVzdW-BQlZEj4V.js';
9
+ import { t as textfieldStyles } from './TextField.module-EkKlj66e-EkKlj66e.js';
10
+ import { B as Button } from './Button-BaHFf1AT-BQy-PFB5.js';
11
+ import { I as Icon } from './Icon-B6HmlQiR-BxQkO3X5.js';
12
+ import { u as useFocusWithin, a as usePrevious } from './useFocusWithin-Cxz14Zyz-DEudRcSI.js';
13
+ import { e as maskitoNumberOptionsGenerator, f as maskitoParseNumber, g as maskitoStringifyNumber, u as useMaskito } from './index.esm-dyoPQhi6.js';
14
+ import { u as useOptionallyControlledState } from './useOptionallyControlledState-DbDuos5L-DbDuos5L.js';
15
+ import { u as useMergeRefs } from './useMergeRefs-Bde85AWI-Bde85AWI.js';
16
+ import { u as useLayoutPropsUtil } from './useLayoutPropsUtil-DWACCL8v-CZNrcQT-.js';
17
+ import { H as Helper } from './Helper-h7k80qls-DHPFHTvI.js';
18
+
19
+ import './NumberField.css';const SvgAdd = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M18 13h-5v5c0 .55-.45 1-1 1s-1-.45-1-1v-5H6c-.55 0-1-.45-1-1s.45-1 1-1h5V6c0-.55.45-1 1-1s1 .45 1 1v5h5c.55 0 1 .45 1 1s-.45 1-1 1z" }));
20
+
21
+ const SvgRemove = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M18 13H6c-.55 0-1-.45-1-1s.45-1 1-1h12c.55 0 1 .45 1 1s-.45 1-1 1z" }));
22
+
23
+ /*
24
+ * big.js v7.0.1
25
+ * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
26
+ * Copyright (c) 2025 Michael Mclaughlin
27
+ * https://github.com/MikeMcl/big.js/LICENCE.md
28
+ */
29
+
30
+
31
+ /************************************** EDITABLE DEFAULTS *****************************************/
32
+
33
+
34
+ // The default values below must be integers within the stated ranges.
35
+
36
+ /*
37
+ * The maximum number of decimal places (DP) of the results of operations involving division:
38
+ * div and sqrt, and pow with negative exponents.
39
+ */
40
+ var DP = 20, // 0 to MAX_DP
41
+
42
+ /*
43
+ * The rounding mode (RM) used when rounding to the above decimal places.
44
+ *
45
+ * 0 Towards zero (i.e. truncate, no rounding). (ROUND_DOWN)
46
+ * 1 To nearest neighbour. If equidistant, round up. (ROUND_HALF_UP)
47
+ * 2 To nearest neighbour. If equidistant, to even. (ROUND_HALF_EVEN)
48
+ * 3 Away from zero. (ROUND_UP)
49
+ */
50
+ RM = 1, // 0, 1, 2 or 3
51
+
52
+ // The maximum value of DP and Big.DP.
53
+ MAX_DP = 1E6, // 0 to 1000000
54
+
55
+ // The maximum magnitude of the exponent argument to the pow method.
56
+ MAX_POWER = 1E6, // 1 to 1000000
57
+
58
+ /*
59
+ * The negative exponent (NE) at and beneath which toString returns exponential notation.
60
+ * (JavaScript numbers: -7)
61
+ * -1000000 is the minimum recommended exponent value of a Big.
62
+ */
63
+ NE = -7, // 0 to -1000000
64
+
65
+ /*
66
+ * The positive exponent (PE) at and above which toString returns exponential notation.
67
+ * (JavaScript numbers: 21)
68
+ * 1000000 is the maximum recommended exponent value of a Big, but this limit is not enforced.
69
+ */
70
+ PE = 21, // 0 to 1000000
71
+
72
+ /*
73
+ * When true, an error will be thrown if a primitive number is passed to the Big constructor,
74
+ * or if valueOf is called, or if toNumber is called on a Big which cannot be converted to a
75
+ * primitive number without a loss of precision.
76
+ */
77
+ STRICT = false, // true or false
78
+
79
+
80
+ /**************************************************************************************************/
81
+
82
+
83
+ // Error messages.
84
+ NAME = '[big.js] ',
85
+ INVALID = NAME + 'Invalid ',
86
+ INVALID_DP = INVALID + 'decimal places',
87
+ INVALID_RM = INVALID + 'rounding mode',
88
+ DIV_BY_ZERO = NAME + 'Division by zero',
89
+
90
+ // The shared prototype object.
91
+ P = {},
92
+ UNDEFINED = void 0,
93
+ NUMERIC = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
94
+
95
+
96
+ /*
97
+ * Create and return a Big constructor.
98
+ */
99
+ function _Big_() {
100
+
101
+ /*
102
+ * The Big constructor and exported function.
103
+ * Create and return a new instance of a Big number object.
104
+ *
105
+ * n {number|string|Big} A numeric value.
106
+ */
107
+ function Big(n) {
108
+ var x = this;
109
+
110
+ // Enable constructor usage without new.
111
+ if (!(x instanceof Big)) {
112
+ return n === UNDEFINED && arguments.length === 0 ? _Big_() : new Big(n);
113
+ }
114
+
115
+
116
+ // Duplicate.
117
+ if (n instanceof Big) {
118
+ x.s = n.s;
119
+ x.e = n.e;
120
+ x.c = n.c.slice();
121
+ } else {
122
+ if (typeof n !== 'string') {
123
+ if (Big.strict === true && typeof n !== 'bigint') {
124
+ throw TypeError(INVALID + 'value');
125
+ }
126
+
127
+ // Minus zero?
128
+ n = n === 0 && 1 / n < 0 ? '-0' : String(n);
129
+ }
130
+
131
+ parse(x, n);
132
+ }
133
+
134
+ // Retain a reference to this Big constructor.
135
+ // Shadow Big.prototype.constructor which points to Object.
136
+ x.constructor = Big;
137
+ }
138
+
139
+ Big.prototype = P;
140
+ Big.DP = DP;
141
+ Big.RM = RM;
142
+ Big.NE = NE;
143
+ Big.PE = PE;
144
+ Big.strict = STRICT;
145
+ Big.roundDown = 0;
146
+ Big.roundHalfUp = 1;
147
+ Big.roundHalfEven = 2;
148
+ Big.roundUp = 3;
149
+
150
+ return Big;
151
+ }
152
+
153
+
154
+ /*
155
+ * Parse the number or string value passed to a Big constructor.
156
+ *
157
+ * x {Big} A Big number instance.
158
+ * n {number|string} A numeric value.
159
+ */
160
+ function parse(x, n) {
161
+ var e, i, nl;
162
+
163
+ if (!NUMERIC.test(n)) {
164
+ throw Error(INVALID + 'number');
165
+ }
166
+
167
+ // Determine sign.
168
+ x.s = n.charAt(0) == '-' ? (n = n.slice(1), -1) : 1;
169
+
170
+ // Decimal point?
171
+ if ((e = n.indexOf('.')) > -1) n = n.replace('.', '');
172
+
173
+ // Exponential form?
174
+ if ((i = n.search(/e/i)) > 0) {
175
+
176
+ // Determine exponent.
177
+ if (e < 0) e = i;
178
+ e += +n.slice(i + 1);
179
+ n = n.substring(0, i);
180
+ } else if (e < 0) {
181
+
182
+ // Integer.
183
+ e = n.length;
184
+ }
185
+
186
+ nl = n.length;
187
+
188
+ // Determine leading zeros.
189
+ for (i = 0; i < nl && n.charAt(i) == '0';) ++i;
190
+
191
+ if (i == nl) {
192
+
193
+ // Zero.
194
+ x.c = [x.e = 0];
195
+ } else {
196
+
197
+ // Determine trailing zeros.
198
+ for (; nl > 0 && n.charAt(--nl) == '0';);
199
+ x.e = e - i - 1;
200
+ x.c = [];
201
+
202
+ // Convert string to array of digits without leading/trailing zeros.
203
+ for (e = 0; i <= nl;) x.c[e++] = +n.charAt(i++);
204
+ }
205
+
206
+ return x;
207
+ }
208
+
209
+
210
+ /*
211
+ * Round Big x to a maximum of sd significant digits using rounding mode rm.
212
+ *
213
+ * x {Big} The Big to round.
214
+ * sd {number} Significant digits: integer, 0 to MAX_DP inclusive.
215
+ * rm {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up).
216
+ * [more] {boolean} Whether the result of division was truncated.
217
+ */
218
+ function round(x, sd, rm, more) {
219
+ var xc = x.c;
220
+
221
+ if (rm === UNDEFINED) rm = x.constructor.RM;
222
+ if (rm !== 0 && rm !== 1 && rm !== 2 && rm !== 3) {
223
+ throw Error(INVALID_RM);
224
+ }
225
+
226
+ if (sd < 1) {
227
+ more =
228
+ rm === 3 && (more || !!xc[0]) || sd === 0 && (
229
+ rm === 1 && xc[0] >= 5 ||
230
+ rm === 2 && (xc[0] > 5 || xc[0] === 5 && (more || xc[1] !== UNDEFINED))
231
+ );
232
+
233
+ xc.length = 1;
234
+
235
+ if (more) {
236
+
237
+ // 1, 0.1, 0.01, 0.001, 0.0001 etc.
238
+ x.e = x.e - sd + 1;
239
+ xc[0] = 1;
240
+ } else {
241
+
242
+ // Zero.
243
+ xc[0] = x.e = 0;
244
+ }
245
+ } else if (sd < xc.length) {
246
+
247
+ // xc[sd] is the digit after the digit that may be rounded up.
248
+ more =
249
+ rm === 1 && xc[sd] >= 5 ||
250
+ rm === 2 && (xc[sd] > 5 || xc[sd] === 5 &&
251
+ (more || xc[sd + 1] !== UNDEFINED || xc[sd - 1] & 1)) ||
252
+ rm === 3 && (more || !!xc[0]);
253
+
254
+ // Remove any digits after the required precision.
255
+ xc.length = sd;
256
+
257
+ // Round up?
258
+ if (more) {
259
+
260
+ // Rounding up may mean the previous digit has to be rounded up.
261
+ for (; ++xc[--sd] > 9;) {
262
+ xc[sd] = 0;
263
+ if (sd === 0) {
264
+ ++x.e;
265
+ xc.unshift(1);
266
+ break;
267
+ }
268
+ }
269
+ }
270
+
271
+ // Remove trailing zeros.
272
+ for (sd = xc.length; !xc[--sd];) xc.pop();
273
+ }
274
+
275
+ return x;
276
+ }
277
+
278
+
279
+ /*
280
+ * Return a string representing the value of Big x in normal or exponential notation.
281
+ * Handles P.toExponential, P.toFixed, P.toJSON, P.toPrecision, P.toString and P.valueOf.
282
+ */
283
+ function stringify(x, doExponential, isNonzero) {
284
+ var e = x.e,
285
+ s = x.c.join(''),
286
+ n = s.length;
287
+
288
+ // Exponential notation?
289
+ if (doExponential) {
290
+ s = s.charAt(0) + (n > 1 ? '.' + s.slice(1) : '') + (e < 0 ? 'e' : 'e+') + e;
291
+
292
+ // Normal notation.
293
+ } else if (e < 0) {
294
+ for (; ++e;) s = '0' + s;
295
+ s = '0.' + s;
296
+ } else if (e > 0) {
297
+ if (++e > n) {
298
+ for (e -= n; e--;) s += '0';
299
+ } else if (e < n) {
300
+ s = s.slice(0, e) + '.' + s.slice(e);
301
+ }
302
+ } else if (n > 1) {
303
+ s = s.charAt(0) + '.' + s.slice(1);
304
+ }
305
+
306
+ return x.s < 0 && isNonzero ? '-' + s : s;
307
+ }
308
+
309
+
310
+ // Prototype/instance methods
311
+
312
+
313
+ /*
314
+ * Return a new Big whose value is the absolute value of this Big.
315
+ */
316
+ P.abs = function () {
317
+ var x = new this.constructor(this);
318
+ x.s = 1;
319
+ return x;
320
+ };
321
+
322
+
323
+ /*
324
+ * Return 1 if the value of this Big is greater than the value of Big y,
325
+ * -1 if the value of this Big is less than the value of Big y, or
326
+ * 0 if they have the same value.
327
+ */
328
+ P.cmp = function (y) {
329
+ var isneg,
330
+ x = this,
331
+ xc = x.c,
332
+ yc = (y = new x.constructor(y)).c,
333
+ i = x.s,
334
+ j = y.s,
335
+ k = x.e,
336
+ l = y.e;
337
+
338
+ // Either zero?
339
+ if (!xc[0] || !yc[0]) return !xc[0] ? !yc[0] ? 0 : -j : i;
340
+
341
+ // Signs differ?
342
+ if (i != j) return i;
343
+
344
+ isneg = i < 0;
345
+
346
+ // Compare exponents.
347
+ if (k != l) return k > l ^ isneg ? 1 : -1;
348
+
349
+ j = (k = xc.length) < (l = yc.length) ? k : l;
350
+
351
+ // Compare digit by digit.
352
+ for (i = -1; ++i < j;) {
353
+ if (xc[i] != yc[i]) return xc[i] > yc[i] ^ isneg ? 1 : -1;
354
+ }
355
+
356
+ // Compare lengths.
357
+ return k == l ? 0 : k > l ^ isneg ? 1 : -1;
358
+ };
359
+
360
+
361
+ /*
362
+ * Return a new Big whose value is the value of this Big divided by the value of Big y, rounded,
363
+ * if necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM.
364
+ */
365
+ P.div = function (y) {
366
+ var x = this,
367
+ Big = x.constructor,
368
+ a = x.c, // dividend
369
+ b = (y = new Big(y)).c, // divisor
370
+ k = x.s == y.s ? 1 : -1,
371
+ dp = Big.DP;
372
+
373
+ if (dp !== ~~dp || dp < 0 || dp > MAX_DP) {
374
+ throw Error(INVALID_DP);
375
+ }
376
+
377
+ // Divisor is zero?
378
+ if (!b[0]) {
379
+ throw Error(DIV_BY_ZERO);
380
+ }
381
+
382
+ // Dividend is 0? Return +-0.
383
+ if (!a[0]) {
384
+ y.s = k;
385
+ y.c = [y.e = 0];
386
+ return y;
387
+ }
388
+
389
+ var bl, bt, n, cmp, ri,
390
+ bz = b.slice(),
391
+ ai = bl = b.length,
392
+ al = a.length,
393
+ r = a.slice(0, bl), // remainder
394
+ rl = r.length,
395
+ q = y, // quotient
396
+ qc = q.c = [],
397
+ qi = 0,
398
+ p = dp + (q.e = x.e - y.e) + 1; // precision of the result
399
+
400
+ q.s = k;
401
+ k = p < 0 ? 0 : p;
402
+
403
+ // Create version of divisor with leading zero.
404
+ bz.unshift(0);
405
+
406
+ // Add zeros to make remainder as long as divisor.
407
+ for (; rl++ < bl;) r.push(0);
408
+
409
+ do {
410
+
411
+ // n is how many times the divisor goes into current remainder.
412
+ for (n = 0; n < 10; n++) {
413
+
414
+ // Compare divisor and remainder.
415
+ if (bl != (rl = r.length)) {
416
+ cmp = bl > rl ? 1 : -1;
417
+ } else {
418
+ for (ri = -1, cmp = 0; ++ri < bl;) {
419
+ if (b[ri] != r[ri]) {
420
+ cmp = b[ri] > r[ri] ? 1 : -1;
421
+ break;
422
+ }
423
+ }
424
+ }
425
+
426
+ // If divisor < remainder, subtract divisor from remainder.
427
+ if (cmp < 0) {
428
+
429
+ // Remainder can't be more than 1 digit longer than divisor.
430
+ // Equalise lengths using divisor with extra leading zero?
431
+ for (bt = rl == bl ? b : bz; rl;) {
432
+ if (r[--rl] < bt[rl]) {
433
+ ri = rl;
434
+ for (; ri && !r[--ri];) r[ri] = 9;
435
+ --r[ri];
436
+ r[rl] += 10;
437
+ }
438
+ r[rl] -= bt[rl];
439
+ }
440
+
441
+ for (; !r[0];) r.shift();
442
+ } else {
443
+ break;
444
+ }
445
+ }
446
+
447
+ // Add the digit n to the result array.
448
+ qc[qi++] = cmp ? n : ++n;
449
+
450
+ // Update the remainder.
451
+ if (r[0] && cmp) r[rl] = a[ai] || 0;
452
+ else r = [a[ai]];
453
+
454
+ } while ((ai++ < al || r[0] !== UNDEFINED) && k--);
455
+
456
+ // Leading zero? Do not remove if result is simply zero (qi == 1).
457
+ if (!qc[0] && qi != 1) {
458
+
459
+ // There can't be more than one zero.
460
+ qc.shift();
461
+ q.e--;
462
+ p--;
463
+ }
464
+
465
+ // Round?
466
+ if (qi > p) round(q, p, Big.RM, r[0] !== UNDEFINED);
467
+
468
+ return q;
469
+ };
470
+
471
+
472
+ /*
473
+ * Return true if the value of this Big is equal to the value of Big y, otherwise return false.
474
+ */
475
+ P.eq = function (y) {
476
+ return this.cmp(y) === 0;
477
+ };
478
+
479
+
480
+ /*
481
+ * Return true if the value of this Big is greater than the value of Big y, otherwise return
482
+ * false.
483
+ */
484
+ P.gt = function (y) {
485
+ return this.cmp(y) > 0;
486
+ };
487
+
488
+
489
+ /*
490
+ * Return true if the value of this Big is greater than or equal to the value of Big y, otherwise
491
+ * return false.
492
+ */
493
+ P.gte = function (y) {
494
+ return this.cmp(y) > -1;
495
+ };
496
+
497
+
498
+ /*
499
+ * Return true if the value of this Big is less than the value of Big y, otherwise return false.
500
+ */
501
+ P.lt = function (y) {
502
+ return this.cmp(y) < 0;
503
+ };
504
+
505
+
506
+ /*
507
+ * Return true if the value of this Big is less than or equal to the value of Big y, otherwise
508
+ * return false.
509
+ */
510
+ P.lte = function (y) {
511
+ return this.cmp(y) < 1;
512
+ };
513
+
514
+
515
+ /*
516
+ * Return a new Big whose value is the value of this Big minus the value of Big y.
517
+ */
518
+ P.minus = P.sub = function (y) {
519
+ var i, j, t, xlty,
520
+ x = this,
521
+ Big = x.constructor,
522
+ a = x.s,
523
+ b = (y = new Big(y)).s;
524
+
525
+ // Signs differ?
526
+ if (a != b) {
527
+ y.s = -b;
528
+ return x.plus(y);
529
+ }
530
+
531
+ var xc = x.c.slice(),
532
+ xe = x.e,
533
+ yc = y.c,
534
+ ye = y.e;
535
+
536
+ // Either zero?
537
+ if (!xc[0] || !yc[0]) {
538
+ if (yc[0]) {
539
+ y.s = -b;
540
+ } else if (xc[0]) {
541
+ y = new Big(x);
542
+ } else {
543
+ y.s = 1;
544
+ }
545
+ return y;
546
+ }
547
+
548
+ // Determine which is the bigger number. Prepend zeros to equalise exponents.
549
+ if (a = xe - ye) {
550
+
551
+ if (xlty = a < 0) {
552
+ a = -a;
553
+ t = xc;
554
+ } else {
555
+ ye = xe;
556
+ t = yc;
557
+ }
558
+
559
+ t.reverse();
560
+ for (b = a; b--;) t.push(0);
561
+ t.reverse();
562
+ } else {
563
+
564
+ // Exponents equal. Check digit by digit.
565
+ j = ((xlty = xc.length < yc.length) ? xc : yc).length;
566
+
567
+ for (a = b = 0; b < j; b++) {
568
+ if (xc[b] != yc[b]) {
569
+ xlty = xc[b] < yc[b];
570
+ break;
571
+ }
572
+ }
573
+ }
574
+
575
+ // x < y? Point xc to the array of the bigger number.
576
+ if (xlty) {
577
+ t = xc;
578
+ xc = yc;
579
+ yc = t;
580
+ y.s = -y.s;
581
+ }
582
+
583
+ /*
584
+ * Append zeros to xc if shorter. No need to add zeros to yc if shorter as subtraction only
585
+ * needs to start at yc.length.
586
+ */
587
+ if ((b = (j = yc.length) - (i = xc.length)) > 0) for (; b--;) xc[i++] = 0;
588
+
589
+ // Subtract yc from xc.
590
+ for (b = i; j > a;) {
591
+ if (xc[--j] < yc[j]) {
592
+ for (i = j; i && !xc[--i];) xc[i] = 9;
593
+ --xc[i];
594
+ xc[j] += 10;
595
+ }
596
+
597
+ xc[j] -= yc[j];
598
+ }
599
+
600
+ // Remove trailing zeros.
601
+ for (; xc[--b] === 0;) xc.pop();
602
+
603
+ // Remove leading zeros and adjust exponent accordingly.
604
+ for (; xc[0] === 0;) {
605
+ xc.shift();
606
+ --ye;
607
+ }
608
+
609
+ if (!xc[0]) {
610
+
611
+ // n - n = +0
612
+ y.s = 1;
613
+
614
+ // Result must be zero.
615
+ xc = [ye = 0];
616
+ }
617
+
618
+ y.c = xc;
619
+ y.e = ye;
620
+
621
+ return y;
622
+ };
623
+
624
+
625
+ /*
626
+ * Return a new Big whose value is the value of this Big modulo the value of Big y.
627
+ */
628
+ P.mod = function (y) {
629
+ var ygtx,
630
+ x = this,
631
+ Big = x.constructor,
632
+ a = x.s,
633
+ b = (y = new Big(y)).s;
634
+
635
+ if (!y.c[0]) {
636
+ throw Error(DIV_BY_ZERO);
637
+ }
638
+
639
+ x.s = y.s = 1;
640
+ ygtx = y.cmp(x) == 1;
641
+ x.s = a;
642
+ y.s = b;
643
+
644
+ if (ygtx) return new Big(x);
645
+
646
+ a = Big.DP;
647
+ b = Big.RM;
648
+ Big.DP = Big.RM = 0;
649
+ x = x.div(y);
650
+ Big.DP = a;
651
+ Big.RM = b;
652
+
653
+ return this.minus(x.times(y));
654
+ };
655
+
656
+
657
+ /*
658
+ * Return a new Big whose value is the value of this Big negated.
659
+ */
660
+ P.neg = function () {
661
+ var x = new this.constructor(this);
662
+ x.s = -x.s;
663
+ return x;
664
+ };
665
+
666
+
667
+ /*
668
+ * Return a new Big whose value is the value of this Big plus the value of Big y.
669
+ */
670
+ P.plus = P.add = function (y) {
671
+ var e, k, t,
672
+ x = this,
673
+ Big = x.constructor;
674
+
675
+ y = new Big(y);
676
+
677
+ // Signs differ?
678
+ if (x.s != y.s) {
679
+ y.s = -y.s;
680
+ return x.minus(y);
681
+ }
682
+
683
+ var xe = x.e,
684
+ xc = x.c,
685
+ ye = y.e,
686
+ yc = y.c;
687
+
688
+ // Either zero?
689
+ if (!xc[0] || !yc[0]) {
690
+ if (!yc[0]) {
691
+ if (xc[0]) {
692
+ y = new Big(x);
693
+ } else {
694
+ y.s = x.s;
695
+ }
696
+ }
697
+ return y;
698
+ }
699
+
700
+ xc = xc.slice();
701
+
702
+ // Prepend zeros to equalise exponents.
703
+ // Note: reverse faster than unshifts.
704
+ if (e = xe - ye) {
705
+ if (e > 0) {
706
+ ye = xe;
707
+ t = yc;
708
+ } else {
709
+ e = -e;
710
+ t = xc;
711
+ }
712
+
713
+ t.reverse();
714
+ for (; e--;) t.push(0);
715
+ t.reverse();
716
+ }
717
+
718
+ // Point xc to the longer array.
719
+ if (xc.length - yc.length < 0) {
720
+ t = yc;
721
+ yc = xc;
722
+ xc = t;
723
+ }
724
+
725
+ e = yc.length;
726
+
727
+ // Only start adding at yc.length - 1 as the further digits of xc can be left as they are.
728
+ for (k = 0; e; xc[e] %= 10) k = (xc[--e] = xc[e] + yc[e] + k) / 10 | 0;
729
+
730
+ // No need to check for zero, as +x + +y != 0 && -x + -y != 0
731
+
732
+ if (k) {
733
+ xc.unshift(k);
734
+ ++ye;
735
+ }
736
+
737
+ // Remove trailing zeros.
738
+ for (e = xc.length; xc[--e] === 0;) xc.pop();
739
+
740
+ y.c = xc;
741
+ y.e = ye;
742
+
743
+ return y;
744
+ };
745
+
746
+
747
+ /*
748
+ * Return a Big whose value is the value of this Big raised to the power n.
749
+ * If n is negative, round to a maximum of Big.DP decimal places using rounding
750
+ * mode Big.RM.
751
+ *
752
+ * n {number} Integer, -MAX_POWER to MAX_POWER inclusive.
753
+ */
754
+ P.pow = function (n) {
755
+ var x = this,
756
+ one = new x.constructor('1'),
757
+ y = one,
758
+ isneg = n < 0;
759
+
760
+ if (n !== ~~n || n < -1e6 || n > MAX_POWER) {
761
+ throw Error(INVALID + 'exponent');
762
+ }
763
+
764
+ if (isneg) n = -n;
765
+
766
+ for (;;) {
767
+ if (n & 1) y = y.times(x);
768
+ n >>= 1;
769
+ if (!n) break;
770
+ x = x.times(x);
771
+ }
772
+
773
+ return isneg ? one.div(y) : y;
774
+ };
775
+
776
+
777
+ /*
778
+ * Return a new Big whose value is the value of this Big rounded to a maximum precision of sd
779
+ * significant digits using rounding mode rm, or Big.RM if rm is not specified.
780
+ *
781
+ * sd {number} Significant digits: integer, 1 to MAX_DP inclusive.
782
+ * rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up).
783
+ */
784
+ P.prec = function (sd, rm) {
785
+ if (sd !== ~~sd || sd < 1 || sd > MAX_DP) {
786
+ throw Error(INVALID + 'precision');
787
+ }
788
+ return round(new this.constructor(this), sd, rm);
789
+ };
790
+
791
+
792
+ /*
793
+ * Return a new Big whose value is the value of this Big rounded to a maximum of dp decimal places
794
+ * using rounding mode rm, or Big.RM if rm is not specified.
795
+ * If dp is negative, round to an integer which is a multiple of 10**-dp.
796
+ * If dp is not specified, round to 0 decimal places.
797
+ *
798
+ * dp? {number} Integer, -MAX_DP to MAX_DP inclusive.
799
+ * rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up).
800
+ */
801
+ P.round = function (dp, rm) {
802
+ if (dp === UNDEFINED) dp = 0;
803
+ else if (dp !== ~~dp || dp < -1e6 || dp > MAX_DP) {
804
+ throw Error(INVALID_DP);
805
+ }
806
+ return round(new this.constructor(this), dp + this.e + 1, rm);
807
+ };
808
+
809
+
810
+ /*
811
+ * Return a new Big whose value is the square root of the value of this Big, rounded, if
812
+ * necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM.
813
+ */
814
+ P.sqrt = function () {
815
+ var r, c, t,
816
+ x = this,
817
+ Big = x.constructor,
818
+ s = x.s,
819
+ e = x.e,
820
+ half = new Big('0.5');
821
+
822
+ // Zero?
823
+ if (!x.c[0]) return new Big(x);
824
+
825
+ // Negative?
826
+ if (s < 0) {
827
+ throw Error(NAME + 'No square root');
828
+ }
829
+
830
+ // Estimate.
831
+ s = Math.sqrt(+stringify(x, true, true));
832
+
833
+ // Math.sqrt underflow/overflow?
834
+ // Re-estimate: pass x coefficient to Math.sqrt as integer, then adjust the result exponent.
835
+ if (s === 0 || s === 1 / 0) {
836
+ c = x.c.join('');
837
+ if (!(c.length + e & 1)) c += '0';
838
+ s = Math.sqrt(c);
839
+ e = ((e + 1) / 2 | 0) - (e < 0 || e & 1);
840
+ r = new Big((s == 1 / 0 ? '5e' : (s = s.toExponential()).slice(0, s.indexOf('e') + 1)) + e);
841
+ } else {
842
+ r = new Big(s + '');
843
+ }
844
+
845
+ e = r.e + (Big.DP += 4);
846
+
847
+ // Newton-Raphson iteration.
848
+ do {
849
+ t = r;
850
+ r = half.times(t.plus(x.div(t)));
851
+ } while (t.c.slice(0, e).join('') !== r.c.slice(0, e).join(''));
852
+
853
+ return round(r, (Big.DP -= 4) + r.e + 1, Big.RM);
854
+ };
855
+
856
+
857
+ /*
858
+ * Return a new Big whose value is the value of this Big times the value of Big y.
859
+ */
860
+ P.times = P.mul = function (y) {
861
+ var c,
862
+ x = this,
863
+ Big = x.constructor,
864
+ xc = x.c,
865
+ yc = (y = new Big(y)).c,
866
+ a = xc.length,
867
+ b = yc.length,
868
+ i = x.e,
869
+ j = y.e;
870
+
871
+ // Determine sign of result.
872
+ y.s = x.s == y.s ? 1 : -1;
873
+
874
+ // Return signed 0 if either 0.
875
+ if (!xc[0] || !yc[0]) {
876
+ y.c = [y.e = 0];
877
+ return y;
878
+ }
879
+
880
+ // Initialise exponent of result as x.e + y.e.
881
+ y.e = i + j;
882
+
883
+ // If array xc has fewer digits than yc, swap xc and yc, and lengths.
884
+ if (a < b) {
885
+ c = xc;
886
+ xc = yc;
887
+ yc = c;
888
+ j = a;
889
+ a = b;
890
+ b = j;
891
+ }
892
+
893
+ // Initialise coefficient array of result with zeros.
894
+ for (c = new Array(j = a + b); j--;) c[j] = 0;
895
+
896
+ // Multiply.
897
+
898
+ // i is initially xc.length.
899
+ for (i = b; i--;) {
900
+ b = 0;
901
+
902
+ // a is yc.length.
903
+ for (j = a + i; j > i;) {
904
+
905
+ // Current sum of products at this digit position, plus carry.
906
+ b = c[j] + yc[i] * xc[j - i - 1] + b;
907
+ c[j--] = b % 10;
908
+
909
+ // carry
910
+ b = b / 10 | 0;
911
+ }
912
+
913
+ c[j] = b;
914
+ }
915
+
916
+ // Increment result exponent if there is a final carry, otherwise remove leading zero.
917
+ if (b) ++y.e;
918
+ else c.shift();
919
+
920
+ // Remove trailing zeros.
921
+ for (i = c.length; !c[--i];) c.pop();
922
+ y.c = c;
923
+
924
+ return y;
925
+ };
926
+
927
+
928
+ /*
929
+ * Return a string representing the value of this Big in exponential notation rounded to dp fixed
930
+ * decimal places using rounding mode rm, or Big.RM if rm is not specified.
931
+ *
932
+ * dp? {number} Decimal places: integer, 0 to MAX_DP inclusive.
933
+ * rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up).
934
+ */
935
+ P.toExponential = function (dp, rm) {
936
+ var x = this,
937
+ n = x.c[0];
938
+
939
+ if (dp !== UNDEFINED) {
940
+ if (dp !== ~~dp || dp < 0 || dp > MAX_DP) {
941
+ throw Error(INVALID_DP);
942
+ }
943
+ x = round(new x.constructor(x), ++dp, rm);
944
+ for (; x.c.length < dp;) x.c.push(0);
945
+ }
946
+
947
+ return stringify(x, true, !!n);
948
+ };
949
+
950
+
951
+ /*
952
+ * Return a string representing the value of this Big in normal notation rounded to dp fixed
953
+ * decimal places using rounding mode rm, or Big.RM if rm is not specified.
954
+ *
955
+ * dp? {number} Decimal places: integer, 0 to MAX_DP inclusive.
956
+ * rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up).
957
+ *
958
+ * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'.
959
+ * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'.
960
+ */
961
+ P.toFixed = function (dp, rm) {
962
+ var x = this,
963
+ n = x.c[0];
964
+
965
+ if (dp !== UNDEFINED) {
966
+ if (dp !== ~~dp || dp < 0 || dp > MAX_DP) {
967
+ throw Error(INVALID_DP);
968
+ }
969
+ x = round(new x.constructor(x), dp + x.e + 1, rm);
970
+
971
+ // x.e may have changed if the value is rounded up.
972
+ for (dp = dp + x.e + 1; x.c.length < dp;) x.c.push(0);
973
+ }
974
+
975
+ return stringify(x, false, !!n);
976
+ };
977
+
978
+
979
+ /*
980
+ * Return a string representing the value of this Big.
981
+ * Return exponential notation if this Big has a positive exponent equal to or greater than
982
+ * Big.PE, or a negative exponent equal to or less than Big.NE.
983
+ * Omit the sign for negative zero.
984
+ */
985
+ P.toJSON = P.toString = function () {
986
+ var x = this,
987
+ Big = x.constructor;
988
+ return stringify(x, x.e <= Big.NE || x.e >= Big.PE, !!x.c[0]);
989
+ };
990
+
991
+ if (typeof Symbol !== "undefined") {
992
+ P[Symbol.for('nodejs.util.inspect.custom')] = P.toJSON;
993
+ }
994
+
995
+
996
+ /*
997
+ * Return the value of this Big as a primitive number.
998
+ */
999
+ P.toNumber = function () {
1000
+ var n = +stringify(this, true, true);
1001
+ if (this.constructor.strict === true && !this.eq(n.toString())) {
1002
+ throw Error(NAME + 'Imprecise conversion');
1003
+ }
1004
+ return n;
1005
+ };
1006
+
1007
+
1008
+ /*
1009
+ * Return a string representing the value of this Big rounded to sd significant digits using
1010
+ * rounding mode rm, or Big.RM if rm is not specified.
1011
+ * Use exponential notation if sd is less than the number of digits necessary to represent
1012
+ * the integer part of the value in normal notation.
1013
+ *
1014
+ * sd {number} Significant digits: integer, 1 to MAX_DP inclusive.
1015
+ * rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up).
1016
+ */
1017
+ P.toPrecision = function (sd, rm) {
1018
+ var x = this,
1019
+ Big = x.constructor,
1020
+ n = x.c[0];
1021
+
1022
+ if (sd !== UNDEFINED) {
1023
+ if (sd !== ~~sd || sd < 1 || sd > MAX_DP) {
1024
+ throw Error(INVALID + 'precision');
1025
+ }
1026
+ x = round(new Big(x), sd, rm);
1027
+ for (; x.c.length < sd;) x.c.push(0);
1028
+ }
1029
+
1030
+ return stringify(x, sd <= x.e || x.e <= Big.NE || x.e >= Big.PE, !!n);
1031
+ };
1032
+
1033
+
1034
+ /*
1035
+ * Return a string representing the value of this Big.
1036
+ * Return exponential notation if this Big has a positive exponent equal to or greater than
1037
+ * Big.PE, or a negative exponent equal to or less than Big.NE.
1038
+ * Include the sign for negative zero.
1039
+ */
1040
+ P.valueOf = function () {
1041
+ var x = this,
1042
+ Big = x.constructor;
1043
+ if (Big.strict === true) {
1044
+ throw Error(NAME + 'valueOf disallowed');
1045
+ }
1046
+ return stringify(x, x.e <= Big.NE || x.e >= Big.PE, true);
1047
+ };
1048
+
1049
+
1050
+ // Export
1051
+
1052
+
1053
+ var Big = _Big_();
1054
+
1055
+ function usePlatform() {
1056
+ const [platform, setPlatform] = useState(detectPlatform());
1057
+ useEffect(() => {
1058
+ setPlatform(detectPlatform());
1059
+ }, []);
1060
+ return platform;
1061
+ }
1062
+ function detectPlatform() {
1063
+ if (typeof window === "undefined" || typeof navigator === "undefined") {
1064
+ return {
1065
+ isIPhone: false,
1066
+ isIPad: false,
1067
+ isIOS: false,
1068
+ isMac: false,
1069
+ isAppleDevice: false,
1070
+ isWebKit: false,
1071
+ isChrome: false,
1072
+ isFirefox: false,
1073
+ isAndroid: false
1074
+ };
1075
+ }
1076
+ const userAgent = navigator.userAgent;
1077
+ const platform = navigator.platform;
1078
+ const isIPhone = /iPhone/.test(userAgent) && !window.MSStream;
1079
+ const isIPad = /iPad/.test(userAgent) || !!navigator.maxTouchPoints && navigator.maxTouchPoints > 2 && /MacIntel/.test(platform);
1080
+ const isIOS = isIPhone || isIPad;
1081
+ const isMac = /Mac/.test(platform) && !isIOS;
1082
+ const isAppleDevice = isIOS || isMac;
1083
+ const isWebKit = /WebKit/.test(userAgent) && !/Chrome/.test(userAgent);
1084
+ const isChrome = /Chrome/.test(userAgent) && !/Edge/.test(userAgent) && !/Edg/.test(userAgent);
1085
+ const isFirefox = /Firefox/.test(userAgent);
1086
+ const isAndroid = /Android/.test(userAgent);
1087
+ return {
1088
+ isIPhone,
1089
+ isIPad,
1090
+ isIOS,
1091
+ isMac,
1092
+ isAppleDevice,
1093
+ isWebKit,
1094
+ isChrome,
1095
+ isFirefox,
1096
+ isAndroid
1097
+ };
1098
+ }
1099
+
1100
+ const useNumberFieldInputMode = ({
1101
+ hasDecimals,
1102
+ hasNegative
1103
+ }) => {
1104
+ const platform = usePlatform();
1105
+ const inputMode = useMemo(() => {
1106
+ let value = "decimal";
1107
+ if (platform.isIPhone) {
1108
+ if (hasNegative) {
1109
+ value = "text";
1110
+ } else if (hasDecimals) {
1111
+ value = "decimal";
1112
+ }
1113
+ } else if (platform.isAndroid) {
1114
+ if (hasNegative) {
1115
+ value = "numeric";
1116
+ } else if (hasDecimals) {
1117
+ value = "decimal";
1118
+ }
1119
+ }
1120
+ return value;
1121
+ }, [hasDecimals, hasNegative, platform.isAndroid, platform.isIPhone]);
1122
+ return inputMode;
1123
+ };
1124
+
1125
+ function useNumberFieldKeys(config) {
1126
+ const inputRef = useRef(null);
1127
+ useEffect(() => {
1128
+ const handleKeyDown = (event) => {
1129
+ switch (event.key) {
1130
+ case "ArrowUp":
1131
+ event.preventDefault();
1132
+ config.increment(config.step);
1133
+ break;
1134
+ case "ArrowDown":
1135
+ event.preventDefault();
1136
+ config.decrement(config.step);
1137
+ break;
1138
+ case "PageUp":
1139
+ event.preventDefault();
1140
+ config.increment(config.step * config.largeStepMultiplier);
1141
+ break;
1142
+ case "PageDown":
1143
+ event.preventDefault();
1144
+ config.decrement(config.step * config.largeStepMultiplier);
1145
+ break;
1146
+ case "Home":
1147
+ event.preventDefault();
1148
+ config.setToMin();
1149
+ break;
1150
+ case "End":
1151
+ event.preventDefault();
1152
+ config.setToMax();
1153
+ break;
1154
+ }
1155
+ };
1156
+ const inputElement = inputRef.current;
1157
+ if (inputElement) {
1158
+ inputElement.addEventListener("keydown", handleKeyDown);
1159
+ }
1160
+ return () => {
1161
+ if (inputElement) {
1162
+ inputElement.removeEventListener("keydown", handleKeyDown);
1163
+ }
1164
+ };
1165
+ }, [config]);
1166
+ return {
1167
+ inputRef
1168
+ };
1169
+ }
1170
+
1171
+ const DEFAULT_MIN_VALUE = 0;
1172
+ const DEFAULT_MAX_VALUE = 1e14;
1173
+ const useNumberField = (config) => {
1174
+ const inputRef = useRef(null);
1175
+ const {
1176
+ minValue = DEFAULT_MIN_VALUE,
1177
+ maxValue = DEFAULT_MAX_VALUE,
1178
+ label = ""
1179
+ } = config;
1180
+ const step = config.step ? Math.abs(config.step) : 1;
1181
+ const minimumFractionDigits = Math.abs(config.minimumFractionDigits ?? 0);
1182
+ const maximumFractionDigits = Math.max(
1183
+ Math.abs(config.maximumFractionDigits ?? 0),
1184
+ minimumFractionDigits
1185
+ );
1186
+ const previousMinimumFractionDigits = usePrevious(
1187
+ minimumFractionDigits,
1188
+ minimumFractionDigits
1189
+ );
1190
+ const params = useMemo(
1191
+ () => ({
1192
+ decimalSeparator: ".",
1193
+ thousandSeparator: ",",
1194
+ minusSign: "-",
1195
+ minimumFractionDigits,
1196
+ maximumFractionDigits
1197
+ }),
1198
+ [minimumFractionDigits, maximumFractionDigits]
1199
+ );
1200
+ const options = maskitoNumberOptionsGenerator(params);
1201
+ const [inputValue, setInputValue] = useOptionallyControlledState({
1202
+ controlledValue: convertValueProp(config.value, { maskitoParams: params }),
1203
+ defaultValue: convertValueProp(config.defaultValue, { maskitoParams: params }) ?? null,
1204
+ onChange: (value) => {
1205
+ if (value === null) return config.onChange?.(null);
1206
+ const parsedValue = maskitoParseNumber(value, params);
1207
+ const nanSafeValue = isNaN(parsedValue) ? null : parsedValue;
1208
+ config.onChange?.(nanSafeValue);
1209
+ }
1210
+ });
1211
+ useEffect(() => {
1212
+ if (previousMinimumFractionDigits === minimumFractionDigits) return;
1213
+ setInputValue((previous) => {
1214
+ if (previous === null || previous === void 0) return null;
1215
+ const parsedValue = maskitoParseNumber(previous, params);
1216
+ const nanSafeValue = isNaN(parsedValue) ? 0 : parsedValue;
1217
+ return maskitoStringifyNumber(nanSafeValue, params);
1218
+ });
1219
+ }, [minimumFractionDigits, previousMinimumFractionDigits]);
1220
+ const maskedInputRef = useMaskito({
1221
+ options
1222
+ });
1223
+ const computedValue = useMemo(() => {
1224
+ if (inputValue === null) return null;
1225
+ const parsedValue = maskitoParseNumber(inputValue, params);
1226
+ if (isNaN(parsedValue)) {
1227
+ return null;
1228
+ }
1229
+ const bigValue = new Big(parsedValue);
1230
+ return bigValue;
1231
+ }, [inputValue, params]);
1232
+ const clamp = useCallback(
1233
+ (value) => {
1234
+ return Math.min(Math.max(value, minValue), maxValue);
1235
+ },
1236
+ [minValue, maxValue]
1237
+ );
1238
+ const increment = useCallback(
1239
+ (amount) => {
1240
+ setInputValue((prevValue) => {
1241
+ const parsedValue = maskitoParseNumber(prevValue ?? "0", params);
1242
+ const nanSafeValue = isNaN(parsedValue) ? 0 : parsedValue;
1243
+ const incrementedValue = new Big(nanSafeValue).plus(amount);
1244
+ const clampedValue = clamp(incrementedValue.toNumber());
1245
+ return maskitoStringifyNumber(clampedValue, params);
1246
+ });
1247
+ },
1248
+ [clamp, params, setInputValue]
1249
+ );
1250
+ const decrement = useCallback(
1251
+ (amount) => {
1252
+ setInputValue((prevValue) => {
1253
+ const parsedValue = maskitoParseNumber(prevValue ?? "0", params);
1254
+ const nanSafeValue = isNaN(parsedValue) ? 0 : parsedValue;
1255
+ const decrementedValue = new Big(nanSafeValue).minus(amount);
1256
+ const clampedValue = clamp(decrementedValue.toNumber());
1257
+ return maskitoStringifyNumber(clampedValue, params);
1258
+ });
1259
+ },
1260
+ [clamp, params, setInputValue]
1261
+ );
1262
+ const setToMin = useCallback(() => {
1263
+ setInputValue(maskitoStringifyNumber(minValue, params));
1264
+ }, [minValue, params, setInputValue]);
1265
+ const setToMax = useCallback(() => {
1266
+ setInputValue(maskitoStringifyNumber(maxValue, params));
1267
+ }, [maxValue, params, setInputValue]);
1268
+ const { inputRef: keysInputRef } = useNumberFieldKeys({
1269
+ increment,
1270
+ decrement,
1271
+ setToMin,
1272
+ setToMax,
1273
+ step,
1274
+ largeStepMultiplier: 10
1275
+ });
1276
+ const combinedInputRef = useMergeRefs([
1277
+ inputRef,
1278
+ maskedInputRef,
1279
+ keysInputRef
1280
+ ]);
1281
+ const hasDecimals = minimumFractionDigits > 0 || maximumFractionDigits > 0;
1282
+ const hasNegative = minValue < 0;
1283
+ const inputMode = useNumberFieldInputMode({
1284
+ hasDecimals,
1285
+ hasNegative
1286
+ });
1287
+ const pattern = useMemo(() => {
1288
+ if (hasNegative) {
1289
+ return `-?[0-9]*(.[0-9]{0,${maximumFractionDigits}})?`;
1290
+ }
1291
+ if (hasDecimals) {
1292
+ return `[0-9]*(.[0-9]{0,${maximumFractionDigits}})?`;
1293
+ }
1294
+ return "[0-9]*";
1295
+ }, [maximumFractionDigits, hasDecimals, hasNegative]);
1296
+ const handleInputChange = (e) => {
1297
+ if (e.target.value === "") {
1298
+ setInputValue(null);
1299
+ } else {
1300
+ setInputValue(e.target.value);
1301
+ }
1302
+ };
1303
+ return {
1304
+ value: computedValue?.toNumber() ?? null,
1305
+ inputRef: combinedInputRef,
1306
+ inputProps: {
1307
+ value: inputValue ?? "",
1308
+ onChange: handleInputChange,
1309
+ inputMode,
1310
+ "aria-valuenow": computedValue?.toNumber() ?? void 0,
1311
+ "aria-valuemin": minValue,
1312
+ "aria-valuemax": maxValue,
1313
+ min: minValue,
1314
+ max: maxValue,
1315
+ step,
1316
+ role: "spinbutton",
1317
+ pattern,
1318
+ type: "text",
1319
+ autoComplete: "off"
1320
+ },
1321
+ incrementButtonProps: {
1322
+ onClick: () => increment(step),
1323
+ disabled: computedValue?.gte(maxValue),
1324
+ tabIndex: -1,
1325
+ "aria-label": `Increment ${label ?? ""}`
1326
+ },
1327
+ decrementButtonProps: {
1328
+ onClick: () => decrement(step),
1329
+ disabled: computedValue?.lte(minValue),
1330
+ tabIndex: -1,
1331
+ "aria-label": `Decrement ${label ?? ""}`
1332
+ }
1333
+ };
1334
+ };
1335
+ function convertValueProp(v, { maskitoParams }) {
1336
+ if (v === void 0 || v === null) {
1337
+ return v;
1338
+ }
1339
+ let bigValue;
1340
+ try {
1341
+ bigValue = new Big(v);
1342
+ } catch (_) {
1343
+ bigValue = new Big(0);
1344
+ }
1345
+ return maskitoStringifyNumber(
1346
+ bigValue.round(maskitoParams.maximumFractionDigits).toNumber(),
1347
+ maskitoParams
1348
+ );
1349
+ }
1350
+
1351
+ const small = "_small_l8s5c_24";
1352
+ const large = "_large_l8s5c_40";
1353
+ const numberFieldStyles = {
1354
+ "stepper-buttons": "_stepper-buttons_l8s5c_2",
1355
+ small: small,
1356
+ large: large
1357
+ };
1358
+
1359
+ const NumberField$1 = forwardRef(
1360
+ (props, ref) => {
1361
+ const { layoutStyles, componentProps } = useLayoutPropsUtil(props);
1362
+ const {
1363
+ className,
1364
+ error,
1365
+ errorAriaLive: errorAriaLiveProp = "assertive",
1366
+ defaultValue: defaultValueProp,
1367
+ value: valueProp,
1368
+ label,
1369
+ moreInfo,
1370
+ prefix,
1371
+ suffix,
1372
+ size,
1373
+ required,
1374
+ onChange: onChangeProp,
1375
+ onFocus: onFocusProp,
1376
+ onBlur: onBlurProp,
1377
+ id: idProp,
1378
+ description,
1379
+ hint,
1380
+ loading,
1381
+ disabled,
1382
+ readOnly,
1383
+ labelProps,
1384
+ style,
1385
+ placeholder,
1386
+ minValue,
1387
+ maxValue,
1388
+ maximumFractionDigits = 0,
1389
+ minimumFractionDigits = 0,
1390
+ step = 1,
1391
+ hideControls = false,
1392
+ ...rest
1393
+ } = componentProps;
1394
+ const numberFieldRef = useRef(null);
1395
+ const [openInfo, setOpenInfo] = useState(false);
1396
+ const [errorAriaLive, setErrorAriaLive] = useState("off");
1397
+ const { ref: wrapperRef } = useFocusWithin({
1398
+ onFocus: (e) => {
1399
+ setOpenInfo(true);
1400
+ setErrorAriaLive(errorAriaLiveProp);
1401
+ onFocusProp?.(e);
1402
+ },
1403
+ onBlur: (e) => {
1404
+ setOpenInfo(false);
1405
+ setErrorAriaLive("off");
1406
+ onBlurProp?.(e);
1407
+ }
1408
+ });
1409
+ const { inputProps, inputRef, incrementButtonProps, decrementButtonProps } = useNumberField({
1410
+ minValue,
1411
+ maxValue,
1412
+ maximumFractionDigits,
1413
+ minimumFractionDigits,
1414
+ step,
1415
+ value: valueProp,
1416
+ defaultValue: defaultValueProp,
1417
+ onChange: onChangeProp,
1418
+ label
1419
+ });
1420
+ const combinedInputRef = useMergeRefs([numberFieldRef, inputRef, ref]);
1421
+ const labelUid = useId();
1422
+ const id = idProp ?? labelUid;
1423
+ const prefixUid = useId();
1424
+ const suffixUid = useId();
1425
+ const helperUid = useId();
1426
+ const errorMessage = typeof error !== "boolean" ? error : void 0;
1427
+ const styleCombined = { ...style, ...layoutStyles };
1428
+ return /* @__PURE__ */ jsxs(
1429
+ "div",
1430
+ {
1431
+ className: cx(textfieldStyles["textfield"], className),
1432
+ "data-anv": "number-field",
1433
+ style: styleCombined,
1434
+ ref: wrapperRef,
1435
+ children: [
1436
+ label && /* @__PURE__ */ jsx(
1437
+ Label,
1438
+ {
1439
+ moreInfo,
1440
+ openMoreInfo: openInfo,
1441
+ required,
1442
+ htmlFor: id,
1443
+ ...labelProps,
1444
+ children: label
1445
+ }
1446
+ ),
1447
+ /* @__PURE__ */ jsxs(
1448
+ "div",
1449
+ {
1450
+ className: cx(textfieldStyles["input-wrapper"], {
1451
+ [textfieldStyles["small"]]: size === "small",
1452
+ [textfieldStyles["large"]]: size === "large",
1453
+ [numberFieldStyles["small"]]: size === "small",
1454
+ [numberFieldStyles["large"]]: size === "large"
1455
+ }),
1456
+ role: "presentation",
1457
+ onClick: () => numberFieldRef.current?.focus(),
1458
+ children: [
1459
+ prefix ? /* @__PURE__ */ jsx(
1460
+ "div",
1461
+ {
1462
+ "aria-hidden": true,
1463
+ className: textfieldStyles["prefix"],
1464
+ id: `prefix${prefixUid}`,
1465
+ children: prefix
1466
+ }
1467
+ ) : null,
1468
+ /* @__PURE__ */ jsx(
1469
+ "input",
1470
+ {
1471
+ id,
1472
+ className: cx(textfieldStyles["input"], {
1473
+ [textfieldStyles["error"]]: error
1474
+ }),
1475
+ ...rest,
1476
+ ...inputProps,
1477
+ required,
1478
+ placeholder,
1479
+ readOnly,
1480
+ disabled,
1481
+ ref: combinedInputRef,
1482
+ "aria-label": label ? void 0 : placeholder,
1483
+ "aria-describedby": helperUid,
1484
+ "aria-invalid": error ? !!error : void 0
1485
+ }
1486
+ ),
1487
+ loading ? /* @__PURE__ */ jsx(
1488
+ "div",
1489
+ {
1490
+ className: textfieldStyles["loading-spinner-wrapper"],
1491
+ "data-testid": "spinner",
1492
+ children: /* @__PURE__ */ jsx(Spinner, {})
1493
+ }
1494
+ ) : null,
1495
+ suffix ? /* @__PURE__ */ jsx(
1496
+ "div",
1497
+ {
1498
+ className: textfieldStyles["suffix"],
1499
+ "aria-hidden": true,
1500
+ id: `suffix${suffixUid}`,
1501
+ children: suffix
1502
+ }
1503
+ ) : null,
1504
+ !hideControls && !disabled && !readOnly && /* @__PURE__ */ jsxs("div", { className: numberFieldStyles["stepper-buttons"], children: [
1505
+ /* @__PURE__ */ jsx(
1506
+ Button,
1507
+ {
1508
+ appearance: "secondary",
1509
+ size: "small",
1510
+ ...decrementButtonProps,
1511
+ children: /* @__PURE__ */ jsx(Icon, { svg: SvgRemove })
1512
+ }
1513
+ ),
1514
+ /* @__PURE__ */ jsx(
1515
+ Button,
1516
+ {
1517
+ appearance: "secondary",
1518
+ size: "small",
1519
+ ...incrementButtonProps,
1520
+ children: /* @__PURE__ */ jsx(Icon, { svg: SvgAdd })
1521
+ }
1522
+ )
1523
+ ] })
1524
+ ]
1525
+ }
1526
+ ),
1527
+ hint || errorMessage || description ? /* @__PURE__ */ jsx(
1528
+ Helper,
1529
+ {
1530
+ id: helperUid,
1531
+ hint,
1532
+ showCounter: false,
1533
+ errorMessage,
1534
+ errorAriaLive,
1535
+ description
1536
+ }
1537
+ ) : null
1538
+ ]
1539
+ }
1540
+ );
1541
+ }
1542
+ );
1543
+ NumberField$1.displayName = "NumberField";
1544
+
1545
+ const styles = {
1546
+
1547
+ };
1548
+
1549
+ const NumberField = forwardRef(
1550
+ (props, ref) => {
1551
+ const data = {
1552
+ label: childrenToString(props.label),
1553
+ prefix: childrenToString(props.prefix),
1554
+ suffix: childrenToString(props.suffix),
1555
+ description: childrenToString(props.description),
1556
+ size: props.size,
1557
+ minValue: props.minValue,
1558
+ maxValue: props.maxValue,
1559
+ step: props.step,
1560
+ maximumFractionDigits: props.maximumFractionDigits,
1561
+ minimumFractionDigits: props.minimumFractionDigits
1562
+ };
1563
+ const trackingId = useTrackingId({
1564
+ name: "NumberField",
1565
+ data,
1566
+ hasOverride: !!props["data-tracking-id"]
1567
+ });
1568
+ return /* @__PURE__ */ jsx(
1569
+ NumberField$1,
1570
+ {
1571
+ ref,
1572
+ "data-tracking-id": trackingId,
1573
+ className: styles["number-field"],
1574
+ ...props
1575
+ }
1576
+ );
1577
+ }
1578
+ );
1579
+ NumberField.displayName = NumberField$1.displayName;
1580
+
1581
+ export { NumberField as N };
1582
+ //# sourceMappingURL=NumberField-C9lMsPMD.js.map