@lightsparkdev/core 1.4.2 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3111 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/react-native/index.ts
31
+ var react_native_exports = {};
32
+ __export(react_native_exports, {
33
+ ConfigKeys: () => ConfigKeys,
34
+ CurrencyUnit: () => CurrencyUnit,
35
+ DefaultCrypto: () => DefaultCrypto,
36
+ KeyOrAlias: () => KeyOrAlias,
37
+ LightsparkAuthException: () => LightsparkAuthException_default,
38
+ LightsparkException: () => LightsparkException_default,
39
+ LightsparkSigningException: () => LightsparkSigningException_default,
40
+ Logger: () => Logger,
41
+ LoggingLevel: () => LoggingLevel,
42
+ NodeKeyCache: () => NodeKeyCache_default,
43
+ RSASigningKey: () => RSASigningKey,
44
+ Requester: () => Requester_default,
45
+ Secp256k1SigningKey: () => Secp256k1SigningKey,
46
+ ServerEnvironment: () => ServerEnvironment_default,
47
+ SigningKey: () => SigningKey,
48
+ SigningKeyType: () => SigningKeyType,
49
+ StubAuthProvider: () => StubAuthProvider,
50
+ abbrCurrencyUnit: () => abbrCurrencyUnit,
51
+ apiDomainForEnvironment: () => apiDomainForEnvironment,
52
+ b64decode: () => b64decode,
53
+ b64encode: () => b64encode,
54
+ bytesToHex: () => bytesToHex,
55
+ clamp: () => clamp,
56
+ convertCurrencyAmount: () => convertCurrencyAmount,
57
+ convertCurrencyAmountValue: () => convertCurrencyAmountValue,
58
+ countryCodesToCurrencyCodes: () => countryCodesToCurrencyCodes,
59
+ createSha256Hash: () => createSha256Hash,
60
+ defaultCurrencyCode: () => defaultCurrencyCode,
61
+ deleteLocalStorageItem: () => deleteLocalStorageItem,
62
+ ensureArray: () => ensureArray,
63
+ errorToJSON: () => errorToJSON,
64
+ formatCurrencyStr: () => formatCurrencyStr,
65
+ formatInviteAmount: () => formatInviteAmount,
66
+ getCurrencyAmount: () => getCurrencyAmount,
67
+ getCurrentLocale: () => getCurrentLocale,
68
+ getErrorMsg: () => getErrorMsg,
69
+ getLocalStorageBoolean: () => getLocalStorageBoolean,
70
+ getLocalStorageConfigItem: () => getLocalStorageConfigItem,
71
+ hexToBytes: () => hexToBytes,
72
+ isBare: () => isBare,
73
+ isBrowser: () => isBrowser,
74
+ isCurrencyAmountInputObj: () => isCurrencyAmountInputObj,
75
+ isCurrencyAmountObj: () => isCurrencyAmountObj,
76
+ isCurrencyAmountPreferenceObj: () => isCurrencyAmountPreferenceObj,
77
+ isCurrencyMap: () => isCurrencyMap,
78
+ isDeprecatedCurrencyAmountObj: () => isDeprecatedCurrencyAmountObj,
79
+ isError: () => isError,
80
+ isErrorMsg: () => isErrorMsg,
81
+ isErrorWithMessage: () => isErrorWithMessage,
82
+ isNode: () => isNode,
83
+ isNumber: () => isNumber,
84
+ isObject: () => isObject,
85
+ isReactNative: () => isReactNative,
86
+ isRecord: () => isRecord,
87
+ isSDKCurrencyAmount: () => isSDKCurrencyAmount,
88
+ isTest: () => isTest,
89
+ isType: () => isType,
90
+ isUint8Array: () => isUint8Array,
91
+ isUmaCurrencyAmount: () => isUmaCurrencyAmount,
92
+ linearInterpolate: () => linearInterpolate,
93
+ localeToCurrencyCode: () => localeToCurrencyCode,
94
+ localeToCurrencySymbol: () => localeToCurrencySymbol,
95
+ logger: () => logger,
96
+ lsidToUUID: () => lsidToUUID,
97
+ mapCurrencyAmount: () => mapCurrencyAmount,
98
+ notNullUndefined: () => notNullUndefined,
99
+ pollUntil: () => pollUntil,
100
+ round: () => round,
101
+ separateCurrencyStrParts: () => separateCurrencyStrParts,
102
+ setLocalStorageBoolean: () => setLocalStorageBoolean,
103
+ sleep: () => sleep,
104
+ urlsafe_b64decode: () => urlsafe_b64decode,
105
+ zipcodeToState: () => zipcodeToState,
106
+ zipcodeToStateCode: () => zipcodeToStateCode
107
+ });
108
+ module.exports = __toCommonJS(react_native_exports);
109
+
110
+ // ../../node_modules/auto-bind/index.js
111
+ var getAllProperties = (object) => {
112
+ const properties = /* @__PURE__ */ new Set();
113
+ do {
114
+ for (const key of Reflect.ownKeys(object)) {
115
+ properties.add([object, key]);
116
+ }
117
+ } while ((object = Reflect.getPrototypeOf(object)) && object !== Object.prototype);
118
+ return properties;
119
+ };
120
+ function autoBind(self2, { include, exclude } = {}) {
121
+ const filter = (key) => {
122
+ const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
123
+ if (include) {
124
+ return include.some(match);
125
+ }
126
+ if (exclude) {
127
+ return !exclude.some(match);
128
+ }
129
+ return true;
130
+ };
131
+ for (const [object, key] of getAllProperties(self2.constructor.prototype)) {
132
+ if (key === "constructor" || !filter(key)) {
133
+ continue;
134
+ }
135
+ const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
136
+ if (descriptor && typeof descriptor.value === "function") {
137
+ self2[key] = self2[key].bind(self2);
138
+ }
139
+ }
140
+ return self2;
141
+ }
142
+
143
+ // src/requester/Requester.ts
144
+ var import_dayjs = __toESM(require("dayjs"), 1);
145
+ var import_utc = __toESM(require("dayjs/plugin/utc.js"), 1);
146
+ var import_zen_observable_ts = require("zen-observable-ts");
147
+
148
+ // src/auth/StubAuthProvider.ts
149
+ var StubAuthProvider = class {
150
+ addAuthHeaders(headers) {
151
+ return Promise.resolve(headers);
152
+ }
153
+ isAuthorized() {
154
+ return Promise.resolve(false);
155
+ }
156
+ addWsConnectionParams(params) {
157
+ return Promise.resolve(params);
158
+ }
159
+ };
160
+
161
+ // src/LightsparkException.ts
162
+ var LightsparkException = class extends Error {
163
+ code;
164
+ message;
165
+ extraInfo;
166
+ constructor(code, message, extraInfo) {
167
+ super(message);
168
+ this.code = code;
169
+ this.message = message;
170
+ this.extraInfo = extraInfo;
171
+ }
172
+ };
173
+ var LightsparkException_default = LightsparkException;
174
+
175
+ // src/utils/base64.ts
176
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
177
+ var Base64 = {
178
+ btoa: (input = "") => {
179
+ const str = input;
180
+ let output = "";
181
+ for (let block = 0, charCode, i = 0, map = chars; str.charAt(i | 0) || (map = "=", i % 1); output += map.charAt(63 & block >> 8 - i % 1 * 8)) {
182
+ charCode = str.charCodeAt(i += 3 / 4);
183
+ if (charCode > 255) {
184
+ throw new Error(
185
+ "'btoa' failed: The string to be encoded contains characters outside of the Latin1 range."
186
+ );
187
+ }
188
+ block = block << 8 | charCode;
189
+ }
190
+ return output;
191
+ },
192
+ atob: (input = "") => {
193
+ const str = input.replace(/=+$/, "");
194
+ let output = "";
195
+ if (str.length % 4 == 1) {
196
+ throw new Error(
197
+ "'atob' failed: The string to be decoded is not correctly encoded."
198
+ );
199
+ }
200
+ for (let bc = 0, bs = 0, buffer, i = 0; buffer = str.charAt(i++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
201
+ buffer = chars.indexOf(buffer);
202
+ }
203
+ return output;
204
+ }
205
+ };
206
+ var b64decode = (encoded) => {
207
+ return Uint8Array.from(Base64.atob(encoded), (c) => c.charCodeAt(0));
208
+ };
209
+ var urlsafe_b64decode = (encoded) => {
210
+ return b64decode(encoded.replace(/_/g, "/").replace(/-/g, "+"));
211
+ };
212
+ var b64encode = (data) => {
213
+ return Base64.btoa(
214
+ String.fromCharCode.apply(null, Array.from(new Uint8Array(data)))
215
+ );
216
+ };
217
+
218
+ // src/crypto/LightsparkSigningException.ts
219
+ var LightsparkSigningException = class extends LightsparkException_default {
220
+ constructor(message, extraInfo) {
221
+ super("SigningException", message, extraInfo);
222
+ }
223
+ };
224
+ var LightsparkSigningException_default = LightsparkSigningException;
225
+
226
+ // src/crypto/crypto.ts
227
+ var getCrypto = () => {
228
+ let cryptoImplPromise;
229
+ if (typeof crypto !== "undefined") {
230
+ cryptoImplPromise = Promise.resolve(crypto);
231
+ } else {
232
+ cryptoImplPromise = import("crypto").then((nodeCrypto) => {
233
+ let cryptoModule = nodeCrypto;
234
+ if (!nodeCrypto.subtle) {
235
+ cryptoModule = Object.assign({}, cryptoModule, {
236
+ subtle: nodeCrypto.webcrypto.subtle
237
+ });
238
+ }
239
+ if (!nodeCrypto.getRandomValues) {
240
+ cryptoModule = Object.assign({}, cryptoModule, {
241
+ getRandomValues: (array) => {
242
+ if (!array) {
243
+ return array;
244
+ }
245
+ const buffer = Buffer.from(array.buffer);
246
+ const view = new Uint8Array(buffer);
247
+ nodeCrypto.randomFillSync(view);
248
+ return array;
249
+ }
250
+ });
251
+ }
252
+ return cryptoModule;
253
+ });
254
+ }
255
+ return cryptoImplPromise;
256
+ };
257
+ var getRandomValues32 = async (arr) => {
258
+ if (typeof crypto !== "undefined") {
259
+ return crypto.getRandomValues(arr);
260
+ } else {
261
+ const cryptoImpl = await getCrypto();
262
+ return cryptoImpl.getRandomValues(arr);
263
+ }
264
+ };
265
+ var deriveKey = async (password, salt, iterations, algorithm, bit_len) => {
266
+ const enc = new TextEncoder();
267
+ const cryptoImpl = await getCrypto();
268
+ const password_key = await cryptoImpl.subtle.importKey(
269
+ "raw",
270
+ enc.encode(password),
271
+ "PBKDF2",
272
+ false,
273
+ ["deriveBits", "deriveKey"]
274
+ );
275
+ const derived = await cryptoImpl.subtle.deriveBits(
276
+ {
277
+ name: "PBKDF2",
278
+ salt,
279
+ iterations,
280
+ hash: "SHA-256"
281
+ },
282
+ password_key,
283
+ bit_len
284
+ );
285
+ const key = await cryptoImpl.subtle.importKey(
286
+ "raw",
287
+ derived.slice(0, 32),
288
+ { name: algorithm, length: 256 },
289
+ false,
290
+ ["encrypt", "decrypt"]
291
+ );
292
+ const iv = derived.slice(32);
293
+ return [key, iv];
294
+ };
295
+ var decrypt = async (header_json, ciphertext, password) => {
296
+ let decoded = b64decode(ciphertext);
297
+ let header;
298
+ if (header_json === "AES_256_CBC_PBKDF2_5000_SHA256") {
299
+ header = {
300
+ v: 0,
301
+ i: 5e3
302
+ };
303
+ decoded = decoded.slice(8);
304
+ } else {
305
+ header = JSON.parse(header_json);
306
+ }
307
+ if (header.v < 0 || header.v > 4) {
308
+ throw new LightsparkException_default(
309
+ "DecryptionError",
310
+ `Unknown version ${header.v}`
311
+ );
312
+ }
313
+ const cryptoImpl = await getCrypto();
314
+ const algorithm = header.v < 2 ? "AES-CBC" : "AES-GCM";
315
+ const bit_len = header.v < 4 ? 384 : 352;
316
+ const salt_len = header.v < 4 ? 8 : 16;
317
+ if (header.lsv === 2 || header.v === 3) {
318
+ const salt = decoded.slice(decoded.length - 8, decoded.length);
319
+ const nonce = decoded.slice(0, 12);
320
+ const cipherText = decoded.slice(12, decoded.length - 8);
321
+ const [
322
+ key
323
+ /* , _iv */
324
+ ] = await deriveKey(
325
+ password,
326
+ salt,
327
+ header.i,
328
+ algorithm,
329
+ 256
330
+ );
331
+ return await cryptoImpl.subtle.decrypt(
332
+ { name: algorithm, iv: nonce.buffer },
333
+ key,
334
+ cipherText
335
+ );
336
+ } else {
337
+ const salt = decoded.slice(0, salt_len);
338
+ const encrypted = decoded.slice(salt_len);
339
+ const [key, iv] = await deriveKey(
340
+ password,
341
+ salt,
342
+ header.i,
343
+ algorithm,
344
+ bit_len
345
+ );
346
+ return await cryptoImpl.subtle.decrypt(
347
+ { name: algorithm, iv },
348
+ key,
349
+ encrypted
350
+ );
351
+ }
352
+ };
353
+ async function decryptSecretWithNodePassword(cipher, encryptedSecret, nodePassword) {
354
+ let decryptedValue = null;
355
+ try {
356
+ decryptedValue = await decrypt(cipher, encryptedSecret, nodePassword);
357
+ } catch (ex) {
358
+ console.error(ex);
359
+ }
360
+ return decryptedValue;
361
+ }
362
+ var generateSigningKeyPair = async () => {
363
+ const cryptoImpl = await getCrypto();
364
+ return await cryptoImpl.subtle.generateKey(
365
+ /*algorithm:*/
366
+ {
367
+ name: "RSA-PSS",
368
+ modulusLength: 4096,
369
+ publicExponent: new Uint8Array([1, 0, 1]),
370
+ hash: "SHA-256"
371
+ },
372
+ /*extractable*/
373
+ true,
374
+ /*keyUsages*/
375
+ ["sign", "verify"]
376
+ );
377
+ };
378
+ var serializeSigningKey = async (key, format) => {
379
+ const cryptoImpl = await getCrypto();
380
+ return await cryptoImpl.subtle.exportKey(
381
+ /*format*/
382
+ format,
383
+ /*key*/
384
+ key
385
+ );
386
+ };
387
+ var getNonce = async () => {
388
+ const nonceSt = await getRandomValues32(new Uint32Array(2));
389
+ const [upper, lower] = nonceSt;
390
+ const nonce = BigInt(upper) << 32n | BigInt(lower);
391
+ return Number(nonce);
392
+ };
393
+ var sign = async (keyOrAlias, data) => {
394
+ if (typeof keyOrAlias === "string") {
395
+ throw new LightsparkSigningException_default(
396
+ "Key alias not supported for default crypto."
397
+ );
398
+ }
399
+ const cryptoImpl = await getCrypto();
400
+ return await cryptoImpl.subtle.sign(
401
+ {
402
+ name: "RSA-PSS",
403
+ saltLength: 32
404
+ },
405
+ keyOrAlias,
406
+ data
407
+ );
408
+ };
409
+ var importPrivateSigningKey = async (keyData) => {
410
+ const cryptoImpl = await getCrypto();
411
+ return await cryptoImpl.subtle.importKey(
412
+ /*format*/
413
+ "pkcs8",
414
+ /*keyData*/
415
+ keyData,
416
+ /*algorithm*/
417
+ {
418
+ name: "RSA-PSS",
419
+ hash: "SHA-256"
420
+ },
421
+ /*extractable*/
422
+ true,
423
+ /*keyUsages*/
424
+ ["sign"]
425
+ );
426
+ };
427
+ var DefaultCrypto = {
428
+ decryptSecretWithNodePassword,
429
+ generateSigningKeyPair,
430
+ serializeSigningKey,
431
+ getNonce,
432
+ sign,
433
+ importPrivateSigningKey
434
+ };
435
+
436
+ // src/constants/index.ts
437
+ var ConfigKeys = {
438
+ LoggingEnabled: "lightspark-logging-enabled",
439
+ ConsoleToolsEnabled: "lightspark-console-tools-enabled"
440
+ };
441
+
442
+ // src/utils/environment.ts
443
+ var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
444
+ var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
445
+ var isTest = isNode && process.env.NODE_ENV === "test";
446
+ var isBare = typeof Bare !== "undefined";
447
+ var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
448
+
449
+ // src/utils/localStorage.ts
450
+ function getLocalStorageConfigItem(key) {
451
+ const localStorageBoolean = getLocalStorageBoolean(key);
452
+ if (localStorageBoolean == null) {
453
+ return false;
454
+ }
455
+ return localStorageBoolean;
456
+ }
457
+ function getLocalStorageBoolean(key) {
458
+ try {
459
+ if (localStorage.getItem(key) === "1") {
460
+ return true;
461
+ } else if (localStorage.getItem(key) == null) {
462
+ return null;
463
+ } else {
464
+ return false;
465
+ }
466
+ } catch (e) {
467
+ return null;
468
+ }
469
+ }
470
+ function setLocalStorageBoolean(key, value) {
471
+ try {
472
+ localStorage.setItem(key, value ? "1" : "0");
473
+ } catch (e) {
474
+ }
475
+ }
476
+ var deleteLocalStorageItem = (key) => {
477
+ try {
478
+ localStorage.removeItem(key);
479
+ } catch (e) {
480
+ }
481
+ };
482
+
483
+ // src/Logger.ts
484
+ var LoggingLevel = /* @__PURE__ */ ((LoggingLevel2) => {
485
+ LoggingLevel2[LoggingLevel2["Trace"] = 0] = "Trace";
486
+ LoggingLevel2[LoggingLevel2["Info"] = 1] = "Info";
487
+ return LoggingLevel2;
488
+ })(LoggingLevel || {});
489
+ var Logger = class {
490
+ context;
491
+ loggingEnabled = false;
492
+ loggingLevel = 1 /* Info */;
493
+ constructor(loggerContext, getLoggingEnabled) {
494
+ this.context = loggerContext;
495
+ void this.updateLoggingEnabled(getLoggingEnabled);
496
+ }
497
+ setLevel(level) {
498
+ this.loggingLevel = level;
499
+ }
500
+ setEnabled(enabled, level = 1 /* Info */) {
501
+ this.loggingEnabled = enabled;
502
+ this.loggingLevel = level;
503
+ }
504
+ async updateLoggingEnabled(getLoggingEnabled) {
505
+ if (getLoggingEnabled) {
506
+ this.loggingEnabled = await getLoggingEnabled();
507
+ } else if (isTest) {
508
+ this.loggingEnabled = true;
509
+ } else if (isBrowser) {
510
+ try {
511
+ this.loggingEnabled = getLocalStorageConfigItem(
512
+ ConfigKeys.LoggingEnabled
513
+ );
514
+ } catch (e) {
515
+ }
516
+ }
517
+ if (this.loggingEnabled) {
518
+ console.log(`[${this.context}] Logging enabled`);
519
+ }
520
+ }
521
+ trace(message, ...rest) {
522
+ if (this.loggingEnabled && this.loggingLevel === 0 /* Trace */) {
523
+ console.log(`[${this.context}] ${message}`, ...rest);
524
+ }
525
+ }
526
+ info(message, ...rest) {
527
+ if (this.loggingEnabled && this.loggingLevel <= 1 /* Info */) {
528
+ console.log(`[${this.context}] ${message}`, ...rest);
529
+ }
530
+ }
531
+ };
532
+ var logger = new Logger("@lightsparkdev/core");
533
+
534
+ // src/requester/Requester.ts
535
+ var DEFAULT_BASE_URL = "api.lightspark.com";
536
+ import_dayjs.default.extend(import_utc.default);
537
+ var Requester = class {
538
+ constructor(nodeKeyCache, schemaEndpoint, sdkUserAgent, authProvider = new StubAuthProvider(), baseUrl = DEFAULT_BASE_URL, cryptoImpl = DefaultCrypto, signingKey, fetchImpl = fetch) {
539
+ this.nodeKeyCache = nodeKeyCache;
540
+ this.schemaEndpoint = schemaEndpoint;
541
+ this.sdkUserAgent = sdkUserAgent;
542
+ this.authProvider = authProvider;
543
+ this.baseUrl = baseUrl;
544
+ this.cryptoImpl = cryptoImpl;
545
+ this.signingKey = signingKey;
546
+ this.fetchImpl = fetchImpl;
547
+ this.wsClient = new Promise((resolve) => {
548
+ this.resolveWsClient = resolve;
549
+ });
550
+ void this.initWsClient(baseUrl, authProvider);
551
+ autoBind(this);
552
+ }
553
+ wsClient;
554
+ resolveWsClient = null;
555
+ initWsClient(baseUrl, authProvider) {
556
+ return Promise.resolve(null);
557
+ }
558
+ async executeQuery(query) {
559
+ const data = await this.makeRawRequest(
560
+ query.queryPayload,
561
+ query.variables || {},
562
+ query.signingNodeId,
563
+ !!query.skipAuth
564
+ );
565
+ return query.constructObject(data);
566
+ }
567
+ subscribe(queryPayload, variables = {}) {
568
+ logger.trace(`Requester.subscribe variables`, variables);
569
+ const operationNameRegex = /^\s*(query|mutation|subscription)\s+(\w+)/i;
570
+ const operationMatch = queryPayload.match(operationNameRegex);
571
+ if (!operationMatch || operationMatch.length < 3) {
572
+ throw new LightsparkException_default("InvalidQuery", "Invalid query payload");
573
+ }
574
+ const operationType = operationMatch[1];
575
+ logger.trace(`Requester.subscribe operationType`, operationType);
576
+ if (operationType == "mutation") {
577
+ throw new LightsparkException_default(
578
+ "InvalidQuery",
579
+ "Mutation queries should call makeRawRequest instead"
580
+ );
581
+ }
582
+ for (const key in variables) {
583
+ if (variables[key] === void 0) {
584
+ variables[key] = null;
585
+ }
586
+ }
587
+ const operation = operationMatch[2];
588
+ const bodyData = {
589
+ query: queryPayload,
590
+ variables,
591
+ operationName: operation
592
+ };
593
+ return new import_zen_observable_ts.Observable((observer) => {
594
+ logger.trace(`Requester.subscribe observer`, observer);
595
+ let cleanup = null;
596
+ let canceled = false;
597
+ void (async () => {
598
+ try {
599
+ const wsClient = await this.wsClient;
600
+ if (!wsClient) {
601
+ throw new LightsparkException_default(
602
+ "WebSocketNotInitialized",
603
+ "WebSocket client is not initialized or is not available in the current environment."
604
+ );
605
+ }
606
+ if (!canceled) {
607
+ cleanup = wsClient.subscribe(bodyData, {
608
+ next: (data) => observer.next(data),
609
+ error: (err) => observer.error(err),
610
+ complete: () => observer.complete()
611
+ });
612
+ }
613
+ } catch (err) {
614
+ observer.error(err);
615
+ }
616
+ })();
617
+ return () => {
618
+ canceled = true;
619
+ if (cleanup) {
620
+ cleanup();
621
+ }
622
+ };
623
+ });
624
+ }
625
+ async makeRawRequest(queryPayload, variables = {}, signingNodeId = void 0, skipAuth = false) {
626
+ logger.trace(`Requester.makeRawRequest args`, {
627
+ queryPayload,
628
+ variables,
629
+ signingNodeId,
630
+ skipAuth
631
+ });
632
+ const operationNameRegex = /^\s*(query|mutation|subscription)\s+(\w+)/i;
633
+ const operationMatch = queryPayload.match(operationNameRegex);
634
+ if (!operationMatch || operationMatch.length < 3) {
635
+ throw new LightsparkException_default("InvalidQuery", "Invalid query payload");
636
+ }
637
+ const operationType = operationMatch[1];
638
+ if (operationType == "subscription") {
639
+ throw new LightsparkException_default(
640
+ "InvalidQuery",
641
+ "Subscription queries should call subscribe instead"
642
+ );
643
+ }
644
+ for (const key in variables) {
645
+ if (variables[key] === void 0) {
646
+ variables[key] = null;
647
+ }
648
+ }
649
+ const operation = operationMatch[2];
650
+ const payload = {
651
+ query: queryPayload,
652
+ variables,
653
+ operationName: operation
654
+ };
655
+ const browserUserAgent = typeof navigator !== "undefined" ? navigator.userAgent : "";
656
+ const sdkUserAgent = this.getSdkUserAgent();
657
+ const baseHeaders = {
658
+ "Content-Type": "application/json",
659
+ "X-Lightspark-SDK": sdkUserAgent,
660
+ "User-Agent": browserUserAgent || sdkUserAgent,
661
+ "X-GraphQL-Operation": operation
662
+ };
663
+ const headers = skipAuth ? baseHeaders : await this.authProvider.addAuthHeaders(baseHeaders);
664
+ let bodyData = await this.addSigningDataIfNeeded(
665
+ payload,
666
+ headers,
667
+ signingNodeId
668
+ );
669
+ if (bodyData.length > 1024 && typeof CompressionStream != "undefined") {
670
+ bodyData = await compress(bodyData);
671
+ headers["Content-Encoding"] = "deflate";
672
+ }
673
+ let urlWithProtocol = this.baseUrl;
674
+ if (!urlWithProtocol.startsWith("https://") && !urlWithProtocol.startsWith("http://")) {
675
+ urlWithProtocol = `https://${urlWithProtocol}`;
676
+ }
677
+ const url = `${urlWithProtocol}/${this.schemaEndpoint}`;
678
+ logger.trace(`Requester.makeRawRequest`, {
679
+ url,
680
+ operationName: operation,
681
+ variables,
682
+ headers
683
+ });
684
+ const response = await this.fetchImpl(url, {
685
+ method: "POST",
686
+ headers,
687
+ body: bodyData
688
+ });
689
+ if (!response.ok) {
690
+ throw new LightsparkException_default(
691
+ "RequestFailed",
692
+ `Request ${operation} failed. ${response.statusText}`
693
+ );
694
+ }
695
+ const responseJson = await response.json();
696
+ const data = responseJson.data;
697
+ if (!data) {
698
+ let firstErrorName = void 0;
699
+ if (Array.isArray(responseJson.errors) && responseJson.errors.length > 0) {
700
+ const firstError = responseJson.errors[0];
701
+ firstErrorName = firstError["extensions"]?.["error_name"];
702
+ }
703
+ throw new LightsparkException_default(
704
+ "RequestFailed",
705
+ `Request ${operation} failed. ${JSON.stringify(responseJson.errors)}`,
706
+ { errorName: firstErrorName }
707
+ );
708
+ }
709
+ return data;
710
+ }
711
+ getSdkUserAgent() {
712
+ const platform = isNode ? "NodeJS" : "Browser";
713
+ const platformVersion = isNode ? process.version : "";
714
+ return `${this.sdkUserAgent} ${platform}/${platformVersion}`;
715
+ }
716
+ stripProtocol(url) {
717
+ return url.replace(/.*?:\/\//g, "");
718
+ }
719
+ async addSigningDataIfNeeded(queryPayload, headers, signingNodeId) {
720
+ if (!signingNodeId) {
721
+ return new TextEncoder().encode(JSON.stringify(queryPayload));
722
+ }
723
+ const query = queryPayload.query;
724
+ const variables = queryPayload.variables;
725
+ const operationName = queryPayload.operationName;
726
+ const nonce = await this.cryptoImpl.getNonce();
727
+ const expiration = import_dayjs.default.utc().add(1, "hour").format();
728
+ const payload = {
729
+ query,
730
+ variables,
731
+ operationName,
732
+ nonce,
733
+ expires_at: expiration
734
+ };
735
+ const key = this.signingKey ?? this.nodeKeyCache.getKey(signingNodeId);
736
+ if (!key) {
737
+ throw new LightsparkSigningException_default(
738
+ "Missing node of encrypted_signing_private_key"
739
+ );
740
+ }
741
+ const encodedPayload = new TextEncoder().encode(JSON.stringify(payload));
742
+ const signedPayload = await key.sign(encodedPayload);
743
+ const encodedSignedPayload = b64encode(signedPayload);
744
+ headers["X-Lightspark-Signing"] = JSON.stringify({
745
+ v: "1",
746
+ signature: encodedSignedPayload
747
+ });
748
+ return encodedPayload;
749
+ }
750
+ };
751
+ async function compress(data) {
752
+ const stream = new Blob([data]).stream();
753
+ const compressedStream = stream.pipeThrough(new CompressionStream("deflate"));
754
+ const reader = compressedStream.getReader();
755
+ const chunks = [];
756
+ let done, value;
757
+ while (!done) {
758
+ ({ done, value } = await reader.read());
759
+ chunks.push(value);
760
+ }
761
+ const blob = new Blob(chunks);
762
+ return new Uint8Array(await blob.arrayBuffer());
763
+ }
764
+ var Requester_default = Requester;
765
+
766
+ // src/auth/LightsparkAuthException.ts
767
+ var LightsparkAuthException = class extends LightsparkException_default {
768
+ constructor(message, extraInfo) {
769
+ super("AuthException", message, extraInfo);
770
+ }
771
+ };
772
+ var LightsparkAuthException_default = LightsparkAuthException;
773
+
774
+ // src/crypto/KeyOrAlias.ts
775
+ var KeyOrAlias = {
776
+ key: (key) => ({ key }),
777
+ alias: (alias) => ({ alias })
778
+ };
779
+
780
+ // src/crypto/SigningKey.ts
781
+ var import_secp256k1 = __toESM(require("secp256k1"), 1);
782
+
783
+ // src/utils/hex.ts
784
+ var bytesToHex = (bytes) => {
785
+ return bytes.reduce((acc, byte) => {
786
+ return acc += ("0" + byte.toString(16)).slice(-2);
787
+ }, "");
788
+ };
789
+ var hexToBytes = (hex) => {
790
+ const bytes = [];
791
+ for (let c = 0; c < hex.length; c += 2) {
792
+ bytes.push(parseInt(hex.substr(c, 2), 16));
793
+ }
794
+ return Uint8Array.from(bytes);
795
+ };
796
+
797
+ // src/utils/createHash.ts
798
+ async function createSha256Hash(data, asHex) {
799
+ if (isBrowser) {
800
+ const source = typeof data === "string" ? new TextEncoder().encode(data) : data;
801
+ const buffer = await window.crypto.subtle.digest("SHA-256", source);
802
+ const arr = new Uint8Array(buffer);
803
+ if (asHex) {
804
+ return bytesToHex(arr);
805
+ }
806
+ return arr;
807
+ } else {
808
+ const { createHash } = await import("crypto");
809
+ if (asHex) {
810
+ const hexStr = createHash("sha256").update(data).digest("hex");
811
+ return hexStr;
812
+ }
813
+ const buffer = createHash("sha256").update(data).digest();
814
+ return new Uint8Array(buffer);
815
+ }
816
+ }
817
+
818
+ // src/crypto/types.ts
819
+ var SigningKeyType = /* @__PURE__ */ ((SigningKeyType2) => {
820
+ SigningKeyType2["RSASigningKey"] = "RSASigningKey";
821
+ SigningKeyType2["Secp256k1SigningKey"] = "Secp256k1SigningKey";
822
+ return SigningKeyType2;
823
+ })(SigningKeyType || {});
824
+
825
+ // src/crypto/SigningKey.ts
826
+ function isAlias(key) {
827
+ return "alias" in key;
828
+ }
829
+ var SigningKey = class {
830
+ type;
831
+ constructor(type) {
832
+ this.type = type;
833
+ }
834
+ };
835
+ var RSASigningKey = class extends SigningKey {
836
+ constructor(privateKey, cryptoImpl) {
837
+ super("RSASigningKey" /* RSASigningKey */);
838
+ this.privateKey = privateKey;
839
+ this.cryptoImpl = cryptoImpl;
840
+ }
841
+ async sign(data) {
842
+ const key = isAlias(this.privateKey) ? this.privateKey.alias : this.privateKey;
843
+ return this.cryptoImpl.sign(key, data);
844
+ }
845
+ };
846
+ var Secp256k1SigningKey = class extends SigningKey {
847
+ constructor(privateKey) {
848
+ super("Secp256k1SigningKey" /* Secp256k1SigningKey */);
849
+ this.privateKey = privateKey;
850
+ }
851
+ async sign(data) {
852
+ const keyBytes = new Uint8Array(hexToBytes(this.privateKey));
853
+ const hash = await createSha256Hash(data);
854
+ const signResult = import_secp256k1.default.ecdsaSign(hash, keyBytes);
855
+ return import_secp256k1.default.signatureExport(signResult.signature);
856
+ }
857
+ };
858
+
859
+ // src/crypto/NodeKeyCache.ts
860
+ var NodeKeyCache = class {
861
+ constructor(cryptoImpl = DefaultCrypto) {
862
+ this.cryptoImpl = cryptoImpl;
863
+ this.idToKey = /* @__PURE__ */ new Map();
864
+ autoBind(this);
865
+ }
866
+ idToKey;
867
+ async loadKey(id, keyOrAlias, signingKeyType) {
868
+ let signingKey;
869
+ if (keyOrAlias.alias !== void 0) {
870
+ switch (signingKeyType) {
871
+ case "RSASigningKey" /* RSASigningKey */:
872
+ signingKey = new RSASigningKey(
873
+ { alias: keyOrAlias.alias },
874
+ this.cryptoImpl
875
+ );
876
+ break;
877
+ default:
878
+ throw new LightsparkSigningException_default(
879
+ `Aliases are not supported for signing key type ${signingKeyType}`
880
+ );
881
+ }
882
+ this.idToKey.set(id, signingKey);
883
+ return signingKey;
884
+ }
885
+ try {
886
+ if (signingKeyType === "Secp256k1SigningKey" /* Secp256k1SigningKey */) {
887
+ signingKey = new Secp256k1SigningKey(keyOrAlias.key);
888
+ } else {
889
+ const decoded = b64decode(this.stripPemTags(keyOrAlias.key));
890
+ const cryptoKeyOrAlias = await this.cryptoImpl.importPrivateSigningKey(decoded);
891
+ const key = typeof cryptoKeyOrAlias === "string" ? { alias: cryptoKeyOrAlias } : cryptoKeyOrAlias;
892
+ signingKey = new RSASigningKey(key, this.cryptoImpl);
893
+ }
894
+ this.idToKey.set(id, signingKey);
895
+ return signingKey;
896
+ } catch (e) {
897
+ console.log("Error importing key: ", e);
898
+ }
899
+ return null;
900
+ }
901
+ getKey(id) {
902
+ return this.idToKey.get(id);
903
+ }
904
+ hasKey(id) {
905
+ return this.idToKey.has(id);
906
+ }
907
+ stripPemTags(pem) {
908
+ return pem.replace(/-----BEGIN (.*)-----/, "").replace(/-----END (.*)----/, "");
909
+ }
910
+ };
911
+ var NodeKeyCache_default = NodeKeyCache;
912
+
913
+ // src/ServerEnvironment.ts
914
+ var ServerEnvironment = /* @__PURE__ */ ((ServerEnvironment2) => {
915
+ ServerEnvironment2["PRODUCTION"] = "production";
916
+ ServerEnvironment2["DEV"] = "dev";
917
+ return ServerEnvironment2;
918
+ })(ServerEnvironment || {});
919
+ var apiDomainForEnvironment = (environment) => {
920
+ switch (environment) {
921
+ case "dev" /* DEV */:
922
+ return "api.dev.dev.sparkinfra.net";
923
+ case "production" /* PRODUCTION */:
924
+ return "api.lightspark.com";
925
+ }
926
+ };
927
+ var ServerEnvironment_default = ServerEnvironment;
928
+
929
+ // src/utils/arrays.ts
930
+ function ensureArray(value) {
931
+ return Array.isArray(value) ? value : [value];
932
+ }
933
+
934
+ // src/utils/locale.ts
935
+ function getCurrentLocale() {
936
+ return Intl.NumberFormat().resolvedOptions().locale;
937
+ }
938
+
939
+ // src/utils/localeToCurrencyCodes.ts
940
+ var countryCodesToCurrencyCodes = {
941
+ AD: "EUR",
942
+ // AE: "AED",
943
+ // AF: "AFN",
944
+ // AG: "XCD",
945
+ // AI: "XCD",
946
+ // AL: "ALL",
947
+ // AM: "AMD",
948
+ // AO: "AOA",
949
+ AR: "ARS",
950
+ AS: "USD",
951
+ AT: "EUR",
952
+ AU: "AUD",
953
+ // AW: "AWG",
954
+ AX: "EUR",
955
+ // AZ: "AZN",
956
+ // BA: "BAM",
957
+ // BB: "BBD",
958
+ // BD: "BDT",
959
+ BE: "EUR",
960
+ // BF: "XOF",
961
+ // BG: "BGN",
962
+ // BH: "BHD",
963
+ // BI: "BIF",
964
+ // BJ: "XOF",
965
+ BL: "EUR",
966
+ // BM: "BMD",
967
+ // BN: "BND",
968
+ // BO: "BOB",
969
+ BQ: "USD",
970
+ BR: "BRL",
971
+ // BS: "BSD",
972
+ // BT: "BTN",
973
+ // BV: "NOK",
974
+ // BW: "BWP",
975
+ // BY: "BYN",
976
+ // BZ: "BZD",
977
+ CA: "CAD",
978
+ // CC: "AUD",
979
+ // CD: "CDF",
980
+ // CF: "XAF",
981
+ // CG: "XAF",
982
+ // CH: "CHF",
983
+ // CI: "XOF",
984
+ // CK: "NZD",
985
+ // CL: "CLP",
986
+ // CM: "XAF",
987
+ // CN: "CNY",
988
+ CO: "COP",
989
+ // CR: "CRC",
990
+ // CU: "CUP",
991
+ // CV: "CVE",
992
+ // CW: "ANG",
993
+ // CX: "AUD",
994
+ CY: "EUR",
995
+ // CZ: "CZK",
996
+ DE: "EUR",
997
+ // DJ: "DJF",
998
+ // DK: "DKK",
999
+ // DM: "XCD",
1000
+ // DO: "DOP",
1001
+ // DZ: "DZD",
1002
+ EC: "USD",
1003
+ EE: "EUR",
1004
+ // EG: "EGP",
1005
+ // EH: "MAD",
1006
+ // ER: "ERN",
1007
+ ES: "EUR",
1008
+ // ET: "ETB",
1009
+ FI: "EUR",
1010
+ // FJ: "FJD",
1011
+ // FK: "FKP",
1012
+ FM: "USD",
1013
+ // FO: "DKK",
1014
+ FR: "EUR",
1015
+ // GA: "XAF",
1016
+ GB: "GBP",
1017
+ // GD: "XCD",
1018
+ // GE: "GEL",
1019
+ GF: "EUR",
1020
+ GG: "GBP",
1021
+ // GH: "GHS",
1022
+ // GI: "GIP",
1023
+ // GL: "DKK",
1024
+ // GM: "GMD",
1025
+ // GN: "GNF",
1026
+ GP: "EUR",
1027
+ // GQ: "XAF",
1028
+ GR: "EUR",
1029
+ GS: "GBP",
1030
+ // GT: "GTQ",
1031
+ GU: "USD",
1032
+ // GW: "XOF",
1033
+ // GY: "GYD",
1034
+ // HK: "HKD",
1035
+ // HM: "AUD",
1036
+ // HN: "HNL",
1037
+ // HR: "HRK",
1038
+ // HT: "HTG",
1039
+ // HU: "HUF",
1040
+ // ID: "IDR",
1041
+ IE: "EUR",
1042
+ // IL: "ILS",
1043
+ IM: "GBP",
1044
+ IN: "INR",
1045
+ IO: "USD",
1046
+ // IQ: "IQD",
1047
+ // IR: "IRR",
1048
+ // IS: "ISK",
1049
+ IT: "EUR",
1050
+ JE: "GBP",
1051
+ // JM: "JMD",
1052
+ // JO: "JOD",
1053
+ // JP: "JPY",
1054
+ // KE: "KES",
1055
+ // KG: "KGS",
1056
+ // KH: "KHR",
1057
+ // KI: "AUD",
1058
+ // KM: "KMF",
1059
+ // KN: "XCD",
1060
+ // KP: "KPW",
1061
+ // KR: "KRW",
1062
+ // KW: "KWD",
1063
+ // KY: "KYD",
1064
+ // KZ: "KZT",
1065
+ // LA: "LAK",
1066
+ // LB: "LBP",
1067
+ // LC: "XCD",
1068
+ // LI: "CHF",
1069
+ // LK: "LKR",
1070
+ // LR: "LRD",
1071
+ // LS: "LSL",
1072
+ LT: "EUR",
1073
+ LU: "EUR",
1074
+ LV: "EUR",
1075
+ // LY: "LYD",
1076
+ // MA: "MAD",
1077
+ MC: "EUR",
1078
+ // MD: "MDL",
1079
+ ME: "EUR",
1080
+ MF: "EUR",
1081
+ // MG: "MGA",
1082
+ MH: "USD",
1083
+ // MK: "MKD",
1084
+ // ML: "XOF",
1085
+ // MM: "MMK",
1086
+ // MN: "MNT",
1087
+ // MO: "MOP",
1088
+ MP: "USD",
1089
+ MQ: "EUR",
1090
+ // MR: "MRO",
1091
+ // MS: "XCD",
1092
+ MT: "EUR",
1093
+ // MU: "MUR",
1094
+ // MV: "MVR",
1095
+ // MW: "MWK",
1096
+ MX: "MXN",
1097
+ // MY: "MYR",
1098
+ // MZ: "MZN",
1099
+ // NA: "NAD",
1100
+ // NC: "XPF",
1101
+ // NE: "XOF",
1102
+ NF: "AUD",
1103
+ // NG: "NGN",
1104
+ // NI: "NIO",
1105
+ NL: "EUR",
1106
+ // NO: "NOK",
1107
+ // NP: "NPR",
1108
+ NR: "AUD",
1109
+ // NU: "NZD",
1110
+ // NZ: "NZD",
1111
+ // OM: "OMR",
1112
+ // PA: "PAB",
1113
+ // PE: "PEN",
1114
+ // PF: "XPF",
1115
+ // PG: "PGK",
1116
+ // PH: "PHP",
1117
+ // PK: "PKR",
1118
+ // PL: "PLN",
1119
+ PM: "EUR",
1120
+ // PN: "NZD",
1121
+ PR: "USD",
1122
+ // PS: "ILS",
1123
+ PT: "EUR",
1124
+ PW: "USD",
1125
+ // PY: "PYG",
1126
+ // QA: "QAR",
1127
+ RE: "EUR",
1128
+ // RO: "RON",
1129
+ // RS: "RSD",
1130
+ // RU: "RUB",
1131
+ // RW: "RWF",
1132
+ // SA: "SAR",
1133
+ // SB: "SBD",
1134
+ // SC: "SCR",
1135
+ // SD: "SDG",
1136
+ // SE: "SEK",
1137
+ // SG: "SGD",
1138
+ // SH: "SHP",
1139
+ SI: "EUR",
1140
+ // SJ: "NOK",
1141
+ SK: "EUR",
1142
+ // SL: "SLL",
1143
+ SM: "EUR",
1144
+ // SN: "XOF",
1145
+ // SO: "SOS",
1146
+ // SR: "SRD",
1147
+ // ST: "STD",
1148
+ // SV: "SVC",
1149
+ // SX: "ANG",
1150
+ // SY: "SYP",
1151
+ // SZ: "SZL",
1152
+ TC: "USD",
1153
+ // TD: "XAF",
1154
+ TF: "EUR",
1155
+ // TG: "XOF",
1156
+ // TH: "THB",
1157
+ // TJ: "TJS",
1158
+ // TK: "NZD",
1159
+ TL: "USD",
1160
+ // TM: "TMT",
1161
+ // TN: "TND",
1162
+ // TO: "TOP",
1163
+ // TR: "TRY",
1164
+ // TT: "TTD",
1165
+ TV: "AUD",
1166
+ // TW: "TWD",
1167
+ // TZ: "TZS",
1168
+ // UA: "UAH",
1169
+ // UG: "UGX",
1170
+ UM: "USD",
1171
+ US: "USD",
1172
+ // UY: "UYU",
1173
+ // UZ: "UZS",
1174
+ VA: "EUR",
1175
+ // VC: "XCD",
1176
+ // VE: "VEF",
1177
+ VG: "USD",
1178
+ VI: "USD",
1179
+ // VN: "VND",
1180
+ // VU: "VUV",
1181
+ // WF: "XPF",
1182
+ // WS: "WST",
1183
+ // YE: "YER",
1184
+ YT: "EUR"
1185
+ // ZA: "ZAR",
1186
+ // ZM: "ZMW",
1187
+ // ZW: "ZWL",
1188
+ };
1189
+ function getCountryCode(localeString) {
1190
+ let components = localeString.split("_");
1191
+ if (components.length === 2) {
1192
+ return components.pop();
1193
+ }
1194
+ components = localeString.split("-");
1195
+ if (components.length === 2) {
1196
+ return components.pop();
1197
+ }
1198
+ return localeString;
1199
+ }
1200
+ function localeToCurrencyCode(locale) {
1201
+ const countryCode = getCountryCode(locale);
1202
+ return countryCodesToCurrencyCodes[countryCode];
1203
+ }
1204
+
1205
+ // src/utils/numbers.ts
1206
+ function clamp(val, min, max) {
1207
+ return val > max ? max : val < min ? min : val;
1208
+ }
1209
+ function linearInterpolate(value, fromRangeStart, fromRangeEnd, toRangeStart, toRangeEnd) {
1210
+ const fromRangeMax = fromRangeEnd - fromRangeStart;
1211
+ const fromRangeVal = value - fromRangeStart;
1212
+ const toRangeMax = toRangeEnd - toRangeStart;
1213
+ const val = fromRangeVal / fromRangeMax * toRangeMax + toRangeStart;
1214
+ return clamp(
1215
+ val,
1216
+ Math.min(toRangeStart, toRangeEnd),
1217
+ Math.max(toRangeStart, toRangeEnd)
1218
+ );
1219
+ }
1220
+ function round(num, decimalPlaces = 0) {
1221
+ const p = Math.pow(10, decimalPlaces);
1222
+ const n = num * p * (1 + Number.EPSILON);
1223
+ return Math.round(n) / p;
1224
+ }
1225
+ function isNumber(value) {
1226
+ return typeof value === "number";
1227
+ }
1228
+
1229
+ // src/utils/currency.ts
1230
+ var defaultCurrencyCode = "USD";
1231
+ var CurrencyUnit = {
1232
+ FUTURE_VALUE: "FUTURE_VALUE",
1233
+ BITCOIN: "BITCOIN",
1234
+ SATOSHI: "SATOSHI",
1235
+ MILLISATOSHI: "MILLISATOSHI",
1236
+ NANOBITCOIN: "NANOBITCOIN",
1237
+ MICROBITCOIN: "MICROBITCOIN",
1238
+ MILLIBITCOIN: "MILLIBITCOIN",
1239
+ USD: "USD",
1240
+ MXN: "MXN",
1241
+ PHP: "PHP",
1242
+ EUR: "EUR",
1243
+ GBP: "GBP",
1244
+ INR: "INR",
1245
+ Bitcoin: "BITCOIN",
1246
+ Microbitcoin: "MICROBITCOIN",
1247
+ Millibitcoin: "MILLIBITCOIN",
1248
+ Millisatoshi: "MILLISATOSHI",
1249
+ Nanobitcoin: "NANOBITCOIN",
1250
+ Satoshi: "SATOSHI",
1251
+ Usd: "USD",
1252
+ Mxn: "MXN",
1253
+ Php: "PHP",
1254
+ Gbp: "GBP",
1255
+ Inr: "INR"
1256
+ };
1257
+ var standardUnitConversionObj = {
1258
+ [CurrencyUnit.BITCOIN]: (v, unitsPerBtc = 1) => v / unitsPerBtc,
1259
+ [CurrencyUnit.MICROBITCOIN]: (v, unitsPerBtc = 1) => v / unitsPerBtc * 1e6,
1260
+ [CurrencyUnit.MILLIBITCOIN]: (v, unitsPerBtc = 1) => v / unitsPerBtc * 1e3,
1261
+ [CurrencyUnit.MILLISATOSHI]: (v, unitsPerBtc = 1) => v / unitsPerBtc * 1e11,
1262
+ [CurrencyUnit.NANOBITCOIN]: (v, unitsPerBtc = 1) => v / unitsPerBtc * 1e9,
1263
+ [CurrencyUnit.SATOSHI]: (v, unitsPerBtc = 1) => v / unitsPerBtc * 1e8,
1264
+ /* Converting between two different fiat types is not currently supported */
1265
+ [CurrencyUnit.USD]: (v) => v,
1266
+ [CurrencyUnit.MXN]: (v) => v,
1267
+ [CurrencyUnit.PHP]: (v) => v,
1268
+ [CurrencyUnit.EUR]: (v) => v,
1269
+ [CurrencyUnit.GBP]: (v) => v,
1270
+ [CurrencyUnit.INR]: (v) => v
1271
+ };
1272
+ var toBitcoinConversion = (v, unitsPerBtc = 1) => round(v * unitsPerBtc);
1273
+ var toMicrobitcoinConversion = (v, unitsPerBtc = 1) => round(v / 1e6 * unitsPerBtc);
1274
+ var toMillibitcoinConversion = (v, unitsPerBtc = 1) => round(v / 1e3 * unitsPerBtc);
1275
+ var toMillisatoshiConversion = (v, unitsPerBtc = 1) => round(v / 1e11 * unitsPerBtc);
1276
+ var toNanobitcoinConversion = (v, unitsPerBtc = 1) => round(v / 1e9 * unitsPerBtc);
1277
+ var toSatoshiConversion = (v, unitsPerBtc = 1) => round(v / 1e8 * unitsPerBtc);
1278
+ var CONVERSION_MAP = {
1279
+ [CurrencyUnit.BITCOIN]: {
1280
+ [CurrencyUnit.BITCOIN]: (v) => v,
1281
+ [CurrencyUnit.MICROBITCOIN]: (v) => v * 1e6,
1282
+ [CurrencyUnit.MILLIBITCOIN]: (v) => v * 1e3,
1283
+ [CurrencyUnit.MILLISATOSHI]: (v) => v * 1e11,
1284
+ [CurrencyUnit.NANOBITCOIN]: (v) => v * 1e9,
1285
+ [CurrencyUnit.SATOSHI]: (v) => v * 1e8,
1286
+ [CurrencyUnit.USD]: toBitcoinConversion,
1287
+ [CurrencyUnit.MXN]: toBitcoinConversion,
1288
+ [CurrencyUnit.PHP]: toBitcoinConversion,
1289
+ [CurrencyUnit.EUR]: toBitcoinConversion,
1290
+ [CurrencyUnit.GBP]: toBitcoinConversion,
1291
+ [CurrencyUnit.INR]: toBitcoinConversion
1292
+ },
1293
+ [CurrencyUnit.MICROBITCOIN]: {
1294
+ [CurrencyUnit.BITCOIN]: (v) => v / 1e6,
1295
+ [CurrencyUnit.MICROBITCOIN]: (v) => v,
1296
+ [CurrencyUnit.MILLIBITCOIN]: (v) => v / 1e3,
1297
+ [CurrencyUnit.MILLISATOSHI]: (v) => v * 1e5,
1298
+ [CurrencyUnit.NANOBITCOIN]: (v) => v * 1e3,
1299
+ [CurrencyUnit.SATOSHI]: (v) => v * 100,
1300
+ [CurrencyUnit.USD]: toMicrobitcoinConversion,
1301
+ [CurrencyUnit.MXN]: toMicrobitcoinConversion,
1302
+ [CurrencyUnit.PHP]: toMicrobitcoinConversion,
1303
+ [CurrencyUnit.EUR]: toMicrobitcoinConversion,
1304
+ [CurrencyUnit.GBP]: toMicrobitcoinConversion,
1305
+ [CurrencyUnit.INR]: toMicrobitcoinConversion
1306
+ },
1307
+ [CurrencyUnit.MILLIBITCOIN]: {
1308
+ [CurrencyUnit.BITCOIN]: (v) => v / 1e3,
1309
+ [CurrencyUnit.MICROBITCOIN]: (v) => v * 1e3,
1310
+ [CurrencyUnit.MILLIBITCOIN]: (v) => v,
1311
+ [CurrencyUnit.MILLISATOSHI]: (v) => v * 1e8,
1312
+ [CurrencyUnit.NANOBITCOIN]: (v) => v * 1e6,
1313
+ [CurrencyUnit.SATOSHI]: (v) => v * 1e5,
1314
+ [CurrencyUnit.USD]: toMillibitcoinConversion,
1315
+ [CurrencyUnit.MXN]: toMillibitcoinConversion,
1316
+ [CurrencyUnit.PHP]: toMillibitcoinConversion,
1317
+ [CurrencyUnit.EUR]: toMillibitcoinConversion,
1318
+ [CurrencyUnit.GBP]: toMillibitcoinConversion,
1319
+ [CurrencyUnit.INR]: toMillibitcoinConversion
1320
+ },
1321
+ [CurrencyUnit.MILLISATOSHI]: {
1322
+ [CurrencyUnit.BITCOIN]: (v) => v / 1e11,
1323
+ [CurrencyUnit.MICROBITCOIN]: (v) => v / 1e5,
1324
+ [CurrencyUnit.MILLIBITCOIN]: (v) => v / 1e8,
1325
+ [CurrencyUnit.MILLISATOSHI]: (v) => v,
1326
+ [CurrencyUnit.NANOBITCOIN]: (v) => v / 100,
1327
+ [CurrencyUnit.SATOSHI]: (v) => v / 1e3,
1328
+ [CurrencyUnit.USD]: toMillisatoshiConversion,
1329
+ [CurrencyUnit.MXN]: toMillisatoshiConversion,
1330
+ [CurrencyUnit.PHP]: toMillisatoshiConversion,
1331
+ [CurrencyUnit.EUR]: toMillisatoshiConversion,
1332
+ [CurrencyUnit.GBP]: toMillisatoshiConversion,
1333
+ [CurrencyUnit.INR]: toMillisatoshiConversion
1334
+ },
1335
+ [CurrencyUnit.NANOBITCOIN]: {
1336
+ [CurrencyUnit.BITCOIN]: (v) => v / 1e9,
1337
+ [CurrencyUnit.MICROBITCOIN]: (v) => v / 1e3,
1338
+ [CurrencyUnit.MILLIBITCOIN]: (v) => v / 1e6,
1339
+ [CurrencyUnit.MILLISATOSHI]: (v) => v * 100,
1340
+ [CurrencyUnit.NANOBITCOIN]: (v) => v,
1341
+ [CurrencyUnit.SATOSHI]: (v) => v / 10,
1342
+ [CurrencyUnit.USD]: toNanobitcoinConversion,
1343
+ [CurrencyUnit.MXN]: toNanobitcoinConversion,
1344
+ [CurrencyUnit.PHP]: toNanobitcoinConversion,
1345
+ [CurrencyUnit.EUR]: toNanobitcoinConversion,
1346
+ [CurrencyUnit.GBP]: toNanobitcoinConversion,
1347
+ [CurrencyUnit.INR]: toNanobitcoinConversion
1348
+ },
1349
+ [CurrencyUnit.SATOSHI]: {
1350
+ [CurrencyUnit.BITCOIN]: (v) => v / 1e8,
1351
+ [CurrencyUnit.MICROBITCOIN]: (v) => v / 100,
1352
+ [CurrencyUnit.MILLIBITCOIN]: (v) => v / 1e5,
1353
+ [CurrencyUnit.MILLISATOSHI]: (v) => v * 1e3,
1354
+ [CurrencyUnit.NANOBITCOIN]: (v) => v * 10,
1355
+ [CurrencyUnit.SATOSHI]: (v) => v,
1356
+ [CurrencyUnit.USD]: toSatoshiConversion,
1357
+ [CurrencyUnit.MXN]: toSatoshiConversion,
1358
+ [CurrencyUnit.PHP]: toSatoshiConversion,
1359
+ [CurrencyUnit.EUR]: toSatoshiConversion,
1360
+ [CurrencyUnit.GBP]: toSatoshiConversion,
1361
+ [CurrencyUnit.INR]: toSatoshiConversion
1362
+ },
1363
+ [CurrencyUnit.USD]: standardUnitConversionObj,
1364
+ [CurrencyUnit.MXN]: standardUnitConversionObj,
1365
+ [CurrencyUnit.PHP]: standardUnitConversionObj,
1366
+ [CurrencyUnit.EUR]: standardUnitConversionObj,
1367
+ [CurrencyUnit.GBP]: standardUnitConversionObj,
1368
+ [CurrencyUnit.INR]: standardUnitConversionObj
1369
+ };
1370
+ function convertCurrencyAmountValue(fromUnit, toUnit, amount, unitsPerBtc = 1) {
1371
+ if (fromUnit === CurrencyUnit.FUTURE_VALUE || toUnit === CurrencyUnit.FUTURE_VALUE) {
1372
+ throw new LightsparkException_default("CurrencyError", `Unsupported CurrencyUnit.`);
1373
+ }
1374
+ if (fromUnit === toUnit) {
1375
+ return amount;
1376
+ }
1377
+ const conversionFn = CONVERSION_MAP[fromUnit][toUnit];
1378
+ if (!conversionFn) {
1379
+ throw new LightsparkException_default(
1380
+ "CurrencyError",
1381
+ `Cannot convert from ${fromUnit} to ${toUnit}`
1382
+ );
1383
+ }
1384
+ return conversionFn(amount, unitsPerBtc);
1385
+ }
1386
+ var convertCurrencyAmount = (from, toUnit) => {
1387
+ const value = convertCurrencyAmountValue(
1388
+ from.originalUnit,
1389
+ toUnit,
1390
+ from.originalValue
1391
+ );
1392
+ return {
1393
+ ...from,
1394
+ preferredCurrencyUnit: toUnit,
1395
+ preferredCurrencyValueApprox: value,
1396
+ preferredCurrencyValueRounded: value
1397
+ };
1398
+ };
1399
+ function isCurrencyAmountInputObj(arg) {
1400
+ return typeof arg === "object" && arg !== null && "value" in arg && (typeof arg.value === "number" || typeof arg.value === "string" || arg.value === null) && "unit" in arg && typeof arg.unit === "string";
1401
+ }
1402
+ function isUmaCurrencyAmount(arg) {
1403
+ return typeof arg === "object" && arg !== null && "value" in arg && typeof arg.value === "number" && "currency" in arg && typeof arg.currency === "object" && typeof arg.currency.code === "string" && typeof arg.currency.symbol === "string" && typeof arg.currency.name === "string" && typeof arg.currency.decimals === "number";
1404
+ }
1405
+ function isDeprecatedCurrencyAmountObj(arg) {
1406
+ return typeof arg === "object" && arg !== null && "value" in arg && "unit" in arg;
1407
+ }
1408
+ function isCurrencyAmountObj(arg) {
1409
+ return typeof arg === "object" && arg !== null && "original_value" in arg && "original_unit" in arg;
1410
+ }
1411
+ function isCurrencyAmountPreferenceObj(arg) {
1412
+ return typeof arg === "object" && arg !== null && "original_unit" in arg && typeof arg.original_unit === "string" && "original_value" in arg && typeof arg.original_value === "number" && "preferred_currency_unit" in arg && typeof arg.preferred_currency_unit === "string" && "preferred_currency_value_approx" in arg && typeof arg.preferred_currency_value_approx === "number";
1413
+ }
1414
+ function isSDKCurrencyAmount(arg) {
1415
+ return typeof arg === "object" && arg !== null && /* We can expect all SDK CurrencyAmount types to always have these exact properties: */
1416
+ "originalValue" in arg && "originalUnit" in arg && "preferredCurrencyUnit" in arg && "preferredCurrencyValueRounded" in arg && "preferredCurrencyValueApprox" in arg;
1417
+ }
1418
+ function asNumber(value) {
1419
+ if (typeof value === "string") {
1420
+ return Number(value);
1421
+ }
1422
+ return value || 0;
1423
+ }
1424
+ function getCurrencyAmount(currencyAmountArg) {
1425
+ let value = 0;
1426
+ let unit = void 0;
1427
+ if (isSDKCurrencyAmount(currencyAmountArg)) {
1428
+ value = currencyAmountArg.originalValue;
1429
+ unit = currencyAmountArg.originalUnit;
1430
+ } else if (isCurrencyAmountObj(currencyAmountArg)) {
1431
+ value = asNumber(currencyAmountArg.original_value);
1432
+ unit = currencyAmountArg.original_unit;
1433
+ } else if (isCurrencyAmountInputObj(currencyAmountArg) || isDeprecatedCurrencyAmountObj(currencyAmountArg)) {
1434
+ value = asNumber(currencyAmountArg.value);
1435
+ unit = currencyAmountArg.unit;
1436
+ }
1437
+ return {
1438
+ value: asNumber(value),
1439
+ unit: unit || CurrencyUnit.SATOSHI
1440
+ };
1441
+ }
1442
+ function convertCurrencyAmountValues(fromUnit, amount, unitsPerBtc = 1, conversionOverride) {
1443
+ const convert = convertCurrencyAmountValue;
1444
+ const namesToUnits = {
1445
+ sats: CurrencyUnit.SATOSHI,
1446
+ btc: CurrencyUnit.BITCOIN,
1447
+ msats: CurrencyUnit.MILLISATOSHI,
1448
+ usd: CurrencyUnit.USD,
1449
+ mxn: CurrencyUnit.MXN,
1450
+ php: CurrencyUnit.PHP,
1451
+ eur: CurrencyUnit.EUR,
1452
+ gbp: CurrencyUnit.GBP,
1453
+ inr: CurrencyUnit.INR,
1454
+ mibtc: CurrencyUnit.MICROBITCOIN,
1455
+ mlbtc: CurrencyUnit.MILLIBITCOIN,
1456
+ nbtc: CurrencyUnit.NANOBITCOIN
1457
+ };
1458
+ return Object.entries(namesToUnits).reduce(
1459
+ (acc, [name, unit]) => {
1460
+ if (conversionOverride && unit === conversionOverride.unit) {
1461
+ acc[name] = conversionOverride.convertedValue;
1462
+ } else {
1463
+ acc[name] = convert(
1464
+ fromUnit,
1465
+ unit,
1466
+ amount,
1467
+ unitsPerBtc
1468
+ );
1469
+ }
1470
+ return acc;
1471
+ },
1472
+ {}
1473
+ );
1474
+ }
1475
+ function getPreferredConversionOverride(currencyAmountArg) {
1476
+ if (isCurrencyAmountPreferenceObj(currencyAmountArg)) {
1477
+ return {
1478
+ unit: currencyAmountArg.preferred_currency_unit,
1479
+ convertedValue: currencyAmountArg.preferred_currency_value_approx
1480
+ };
1481
+ } else if (isSDKCurrencyAmount(currencyAmountArg)) {
1482
+ return {
1483
+ unit: currencyAmountArg.preferredCurrencyUnit,
1484
+ convertedValue: currencyAmountArg.preferredCurrencyValueApprox
1485
+ };
1486
+ }
1487
+ return void 0;
1488
+ }
1489
+ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
1490
+ const { value, unit } = getCurrencyAmount(currencyAmountArg);
1491
+ const conversionOverride = getPreferredConversionOverride(currencyAmountArg);
1492
+ const { sats, msats, btc, usd, mxn, php, mibtc, mlbtc, nbtc, eur, gbp, inr } = convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);
1493
+ const mapWithCurrencyUnits = {
1494
+ [CurrencyUnit.BITCOIN]: btc,
1495
+ [CurrencyUnit.SATOSHI]: sats,
1496
+ [CurrencyUnit.MILLISATOSHI]: msats,
1497
+ [CurrencyUnit.USD]: usd,
1498
+ [CurrencyUnit.MXN]: mxn,
1499
+ [CurrencyUnit.PHP]: php,
1500
+ [CurrencyUnit.EUR]: eur,
1501
+ [CurrencyUnit.GBP]: gbp,
1502
+ [CurrencyUnit.INR]: inr,
1503
+ [CurrencyUnit.MICROBITCOIN]: mibtc,
1504
+ [CurrencyUnit.MILLIBITCOIN]: mlbtc,
1505
+ [CurrencyUnit.NANOBITCOIN]: nbtc,
1506
+ [CurrencyUnit.FUTURE_VALUE]: NaN,
1507
+ formatted: {
1508
+ [CurrencyUnit.BITCOIN]: formatCurrencyStr({
1509
+ value: btc,
1510
+ unit: CurrencyUnit.BITCOIN
1511
+ }),
1512
+ [CurrencyUnit.SATOSHI]: formatCurrencyStr({
1513
+ value: sats,
1514
+ unit: CurrencyUnit.SATOSHI
1515
+ }),
1516
+ [CurrencyUnit.MILLISATOSHI]: formatCurrencyStr({
1517
+ value: msats,
1518
+ unit: CurrencyUnit.MILLISATOSHI
1519
+ }),
1520
+ [CurrencyUnit.MICROBITCOIN]: formatCurrencyStr({
1521
+ value: mibtc,
1522
+ unit: CurrencyUnit.MICROBITCOIN
1523
+ }),
1524
+ [CurrencyUnit.MILLIBITCOIN]: formatCurrencyStr({
1525
+ value: mlbtc,
1526
+ unit: CurrencyUnit.MILLIBITCOIN
1527
+ }),
1528
+ [CurrencyUnit.NANOBITCOIN]: formatCurrencyStr({
1529
+ value: nbtc,
1530
+ unit: CurrencyUnit.NANOBITCOIN
1531
+ }),
1532
+ [CurrencyUnit.USD]: formatCurrencyStr({
1533
+ value: usd,
1534
+ unit: CurrencyUnit.USD
1535
+ }),
1536
+ [CurrencyUnit.MXN]: formatCurrencyStr({
1537
+ value: mxn,
1538
+ unit: CurrencyUnit.MXN
1539
+ }),
1540
+ [CurrencyUnit.PHP]: formatCurrencyStr({
1541
+ value: php,
1542
+ unit: CurrencyUnit.PHP
1543
+ }),
1544
+ [CurrencyUnit.EUR]: formatCurrencyStr({
1545
+ value: eur,
1546
+ unit: CurrencyUnit.EUR
1547
+ }),
1548
+ [CurrencyUnit.GBP]: formatCurrencyStr({
1549
+ value: gbp,
1550
+ unit: CurrencyUnit.GBP
1551
+ }),
1552
+ [CurrencyUnit.INR]: formatCurrencyStr({
1553
+ value: inr,
1554
+ unit: CurrencyUnit.INR
1555
+ }),
1556
+ [CurrencyUnit.FUTURE_VALUE]: "-"
1557
+ }
1558
+ };
1559
+ return {
1560
+ ...mapWithCurrencyUnits,
1561
+ btc,
1562
+ sats,
1563
+ msats,
1564
+ isZero: msats === 0,
1565
+ isLessThan: (other) => {
1566
+ if (isNumber(other)) {
1567
+ return msats < other;
1568
+ }
1569
+ if (isCurrencyAmountObj(other)) {
1570
+ other = mapCurrencyAmount(other);
1571
+ }
1572
+ return msats < other.msats;
1573
+ },
1574
+ isGreaterThan: (other) => {
1575
+ if (isNumber(other)) {
1576
+ return msats > other;
1577
+ }
1578
+ if (isCurrencyAmountObj(other)) {
1579
+ other = mapCurrencyAmount(other);
1580
+ }
1581
+ return msats > other.msats;
1582
+ },
1583
+ isEqualTo: (other) => {
1584
+ if (isNumber(other)) {
1585
+ return msats === other;
1586
+ }
1587
+ if (isCurrencyAmountObj(other)) {
1588
+ other = mapCurrencyAmount(other);
1589
+ }
1590
+ return msats === other.msats;
1591
+ },
1592
+ formatted: {
1593
+ ...mapWithCurrencyUnits.formatted,
1594
+ btc: mapWithCurrencyUnits.formatted[CurrencyUnit.BITCOIN],
1595
+ sats: mapWithCurrencyUnits.formatted[CurrencyUnit.SATOSHI],
1596
+ msats: mapWithCurrencyUnits.formatted[CurrencyUnit.MILLISATOSHI]
1597
+ },
1598
+ type: "CurrencyMap"
1599
+ };
1600
+ }
1601
+ var isCurrencyMap = (currencyMap) => typeof currencyMap === "object" && currencyMap !== null && "type" in currencyMap && typeof currencyMap.type === "string" && currencyMap.type === "CurrencyMap";
1602
+ var abbrCurrencyUnit = (unit) => {
1603
+ switch (unit) {
1604
+ case CurrencyUnit.BITCOIN:
1605
+ return "BTC";
1606
+ case CurrencyUnit.SATOSHI:
1607
+ return "SAT";
1608
+ case CurrencyUnit.MILLISATOSHI:
1609
+ return "MSAT";
1610
+ case CurrencyUnit.MILLIBITCOIN:
1611
+ return "mBTC";
1612
+ case CurrencyUnit.MICROBITCOIN:
1613
+ return "\u03BCBTC";
1614
+ case CurrencyUnit.USD:
1615
+ return "USD";
1616
+ case CurrencyUnit.MXN:
1617
+ return "MXN";
1618
+ case CurrencyUnit.PHP:
1619
+ return "PHP";
1620
+ case CurrencyUnit.EUR:
1621
+ return "EUR";
1622
+ case CurrencyUnit.GBP:
1623
+ return "GBP";
1624
+ case CurrencyUnit.INR:
1625
+ return "INR";
1626
+ }
1627
+ return "Unsupported CurrencyUnit";
1628
+ };
1629
+ var defaultOptions = {
1630
+ /* undefined indicates to use default precision for unit defined below */
1631
+ precision: void 0,
1632
+ compact: false,
1633
+ showBtcSymbol: false,
1634
+ append: void 0
1635
+ };
1636
+ function formatCurrencyStr(amount, options) {
1637
+ const { precision, compact, showBtcSymbol } = {
1638
+ ...defaultOptions,
1639
+ ...options
1640
+ };
1641
+ let num;
1642
+ let unit;
1643
+ if (isUmaCurrencyAmount(amount)) {
1644
+ num = amount.value;
1645
+ unit = amount.currency.code;
1646
+ if (amount.currency.decimals > 0) {
1647
+ num = amount.value / Math.pow(10, amount.currency.decimals);
1648
+ }
1649
+ } else {
1650
+ const currencyAmount = getCurrencyAmount(amount);
1651
+ num = currencyAmount.value;
1652
+ unit = currencyAmount.unit;
1653
+ const centCurrencies = [
1654
+ CurrencyUnit.USD,
1655
+ CurrencyUnit.MXN,
1656
+ CurrencyUnit.PHP,
1657
+ CurrencyUnit.EUR,
1658
+ CurrencyUnit.GBP
1659
+ ];
1660
+ if (centCurrencies.includes(unit)) {
1661
+ num = num / 100;
1662
+ }
1663
+ }
1664
+ function getDefaultMaxFractionDigits(defaultDigits, fullPrecisionDigits) {
1665
+ let digits = defaultDigits;
1666
+ if (precision === "full") {
1667
+ digits = fullPrecisionDigits;
1668
+ } else if (typeof precision === "number") {
1669
+ digits = precision;
1670
+ } else if (compact) {
1671
+ digits = 1;
1672
+ }
1673
+ return digits;
1674
+ }
1675
+ const symbol = !showBtcSymbol ? "" : unit === CurrencyUnit.BITCOIN ? "\uE903" : unit === CurrencyUnit.SATOSHI || unit === abbrCurrencyUnit(CurrencyUnit.SATOSHI) ? "\uE902" : "";
1676
+ const currentLocale = getCurrentLocale();
1677
+ function isFormattableFiatCurrencyCode(currencyCode) {
1678
+ try {
1679
+ new Intl.NumberFormat(currentLocale, {
1680
+ style: "currency",
1681
+ currency: currencyCode
1682
+ });
1683
+ return true;
1684
+ } catch (e) {
1685
+ return false;
1686
+ }
1687
+ }
1688
+ let formattedStr = "";
1689
+ let forceAppendUnits = false;
1690
+ switch (unit) {
1691
+ case CurrencyUnit.BITCOIN:
1692
+ formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
1693
+ notation: compact ? "compact" : void 0,
1694
+ maximumFractionDigits: getDefaultMaxFractionDigits(4, 8)
1695
+ })}`;
1696
+ break;
1697
+ case CurrencyUnit.SATOSHI:
1698
+ case abbrCurrencyUnit(CurrencyUnit.SATOSHI):
1699
+ formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
1700
+ notation: compact ? "compact" : void 0,
1701
+ maximumFractionDigits: getDefaultMaxFractionDigits(0, 3)
1702
+ })}`;
1703
+ break;
1704
+ case CurrencyUnit.MILLISATOSHI:
1705
+ case CurrencyUnit.MICROBITCOIN:
1706
+ case CurrencyUnit.MILLIBITCOIN:
1707
+ case CurrencyUnit.NANOBITCOIN:
1708
+ formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
1709
+ notation: compact ? "compact" : void 0,
1710
+ maximumFractionDigits: getDefaultMaxFractionDigits(0, 0)
1711
+ })}`;
1712
+ break;
1713
+ default:
1714
+ if (isFormattableFiatCurrencyCode(unit)) {
1715
+ formattedStr = num.toLocaleString(currentLocale, {
1716
+ style: "currency",
1717
+ currency: unit,
1718
+ currencyDisplay: "narrowSymbol",
1719
+ notation: compact ? "compact" : void 0,
1720
+ maximumFractionDigits: getDefaultMaxFractionDigits(2, 2)
1721
+ });
1722
+ } else {
1723
+ formattedStr = `${num}`;
1724
+ forceAppendUnits = true;
1725
+ }
1726
+ break;
1727
+ }
1728
+ if (options?.appendUnits || forceAppendUnits) {
1729
+ const localeCurrencyCode = localeToCurrencyCode(currentLocale);
1730
+ if (unit === localeCurrencyCode && options?.appendUnits && !options.appendUnits.showForCurrentLocaleUnit) {
1731
+ return formattedStr;
1732
+ }
1733
+ const unitStr = isUmaCurrencyAmount(amount) ? amount.currency.code : abbrCurrencyUnit(unit);
1734
+ const unitSuffix = options?.appendUnits?.plural && num > 1 ? "s" : "";
1735
+ const unitStrWithSuffix = `${unitStr}${unitSuffix}`;
1736
+ formattedStr += ` ${options?.appendUnits?.lowercase ? unitStrWithSuffix.toLowerCase() : unitStrWithSuffix}`;
1737
+ }
1738
+ return formattedStr;
1739
+ }
1740
+ function separateCurrencyStrParts(currencyStr) {
1741
+ const symbol = currencyStr.replace(/[0-9\s\u00a0.,]/g, "");
1742
+ const amount = currencyStr.replace(/[^\d.,-]/g, "");
1743
+ return { symbol, amount };
1744
+ }
1745
+ function localeToCurrencySymbol(locale) {
1746
+ const currencyCode = localeToCurrencyCode(locale);
1747
+ const formatted = new Intl.NumberFormat(locale, {
1748
+ style: "currency",
1749
+ currency: currencyCode,
1750
+ useGrouping: false,
1751
+ // to avoid thousands separators
1752
+ minimumFractionDigits: 0,
1753
+ maximumFractionDigits: 0
1754
+ }).format(0);
1755
+ const { symbol } = separateCurrencyStrParts(formatted);
1756
+ return symbol;
1757
+ }
1758
+ function formatInviteAmount(amount, currency) {
1759
+ if (!amount || !currency) {
1760
+ return "";
1761
+ }
1762
+ const displayAmount = (amount / Math.pow(10, currency.decimals)).toFixed(
1763
+ currency.decimals
1764
+ );
1765
+ return `${displayAmount} ${currency.code}`;
1766
+ }
1767
+
1768
+ // src/utils/typeGuards.ts
1769
+ function isUint8Array(value) {
1770
+ return value instanceof Uint8Array;
1771
+ }
1772
+ function isObject(value) {
1773
+ const type = typeof value;
1774
+ return value != null && (type == "object" || type == "function");
1775
+ }
1776
+ function isRecord(value) {
1777
+ return typeof value === "object" && value !== null && !Array.isArray(value) && Object.prototype.toString.call(value) === "[object Object]";
1778
+ }
1779
+
1780
+ // src/utils/errors.ts
1781
+ var isError = (e) => {
1782
+ return Boolean(
1783
+ typeof e === "object" && e !== null && "name" in e && typeof e.name === "string" && "message" in e && typeof e.message === "string"
1784
+ );
1785
+ };
1786
+ var isErrorWithMessage = (e) => {
1787
+ return Boolean(
1788
+ typeof e === "object" && e !== null && "message" in e && typeof e.message === "string"
1789
+ );
1790
+ };
1791
+ var getErrorMsg = (e) => {
1792
+ return isErrorWithMessage(e) ? e.message : "Unknown error";
1793
+ };
1794
+ var isErrorMsg = (e, msg) => {
1795
+ if (isError(e)) {
1796
+ return e.message === msg;
1797
+ }
1798
+ return false;
1799
+ };
1800
+ function normalizeObject(obj) {
1801
+ const normalized = {};
1802
+ if (isObject(obj)) {
1803
+ const props = Object.getOwnPropertyNames(obj);
1804
+ for (const prop of props) {
1805
+ const objRecord = obj;
1806
+ normalized[prop] = objRecord[prop];
1807
+ }
1808
+ }
1809
+ return normalized;
1810
+ }
1811
+ function errorToJSON(err, stringifyObjects = false) {
1812
+ if (!err) {
1813
+ return null;
1814
+ }
1815
+ if (isObject(err) && "toJSON" in err && typeof err.toJSON === "function") {
1816
+ if (stringifyObjects === true) {
1817
+ return objectToJSON(err.toJSON());
1818
+ }
1819
+ return err.toJSON();
1820
+ }
1821
+ if (typeof err === "object" && /* This happens for certain errors like DOMException: */
1822
+ Object.getOwnPropertyNames(err).length === 0 && "message" in err && typeof err.message === "string") {
1823
+ return { message: err.message };
1824
+ }
1825
+ return objectToJSON(err);
1826
+ }
1827
+ function objectToJSON(obj) {
1828
+ const normalizedObj = normalizeObject(obj);
1829
+ return JSON.parse(
1830
+ JSON.stringify(normalizedObj, (key, value) => {
1831
+ if (key === "") {
1832
+ return value;
1833
+ }
1834
+ const objProps = Object.getOwnPropertyNames(normalizedObj);
1835
+ if (!objProps.includes(key)) {
1836
+ return void 0;
1837
+ }
1838
+ if (isObject(value)) {
1839
+ return JSON.stringify(value);
1840
+ }
1841
+ return value;
1842
+ })
1843
+ );
1844
+ }
1845
+
1846
+ // ../../node_modules/lodash-es/_freeGlobal.js
1847
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
1848
+ var freeGlobal_default = freeGlobal;
1849
+
1850
+ // ../../node_modules/lodash-es/_root.js
1851
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
1852
+ var root = freeGlobal_default || freeSelf || Function("return this")();
1853
+ var root_default = root;
1854
+
1855
+ // ../../node_modules/lodash-es/_Symbol.js
1856
+ var Symbol2 = root_default.Symbol;
1857
+ var Symbol_default = Symbol2;
1858
+
1859
+ // ../../node_modules/lodash-es/_getRawTag.js
1860
+ var objectProto = Object.prototype;
1861
+ var hasOwnProperty = objectProto.hasOwnProperty;
1862
+ var nativeObjectToString = objectProto.toString;
1863
+ var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
1864
+ function getRawTag(value) {
1865
+ var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
1866
+ try {
1867
+ value[symToStringTag] = void 0;
1868
+ var unmasked = true;
1869
+ } catch (e) {
1870
+ }
1871
+ var result = nativeObjectToString.call(value);
1872
+ if (unmasked) {
1873
+ if (isOwn) {
1874
+ value[symToStringTag] = tag;
1875
+ } else {
1876
+ delete value[symToStringTag];
1877
+ }
1878
+ }
1879
+ return result;
1880
+ }
1881
+ var getRawTag_default = getRawTag;
1882
+
1883
+ // ../../node_modules/lodash-es/_objectToString.js
1884
+ var objectProto2 = Object.prototype;
1885
+ var nativeObjectToString2 = objectProto2.toString;
1886
+ function objectToString(value) {
1887
+ return nativeObjectToString2.call(value);
1888
+ }
1889
+ var objectToString_default = objectToString;
1890
+
1891
+ // ../../node_modules/lodash-es/_baseGetTag.js
1892
+ var nullTag = "[object Null]";
1893
+ var undefinedTag = "[object Undefined]";
1894
+ var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
1895
+ function baseGetTag(value) {
1896
+ if (value == null) {
1897
+ return value === void 0 ? undefinedTag : nullTag;
1898
+ }
1899
+ return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
1900
+ }
1901
+ var baseGetTag_default = baseGetTag;
1902
+
1903
+ // ../../node_modules/lodash-es/isObject.js
1904
+ function isObject2(value) {
1905
+ var type = typeof value;
1906
+ return value != null && (type == "object" || type == "function");
1907
+ }
1908
+ var isObject_default = isObject2;
1909
+
1910
+ // ../../node_modules/lodash-es/isFunction.js
1911
+ var asyncTag = "[object AsyncFunction]";
1912
+ var funcTag = "[object Function]";
1913
+ var genTag = "[object GeneratorFunction]";
1914
+ var proxyTag = "[object Proxy]";
1915
+ function isFunction(value) {
1916
+ if (!isObject_default(value)) {
1917
+ return false;
1918
+ }
1919
+ var tag = baseGetTag_default(value);
1920
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
1921
+ }
1922
+ var isFunction_default = isFunction;
1923
+
1924
+ // src/utils/sleep.ts
1925
+ function sleep(ms) {
1926
+ return new Promise((resolve) => setTimeout(resolve, ms));
1927
+ }
1928
+
1929
+ // src/utils/pollUntil.ts
1930
+ function getDefaultMaxPollsError() {
1931
+ return new Error("pollUntil: Max polls reached");
1932
+ }
1933
+ async function pollUntil(asyncFn, getValue, maxPolls = 60, pollIntervalMs = 500, ignoreErrors = false, getMaxPollsError = getDefaultMaxPollsError) {
1934
+ let polls = 0;
1935
+ let stopPolling = false;
1936
+ let result = {
1937
+ stopPolling: false,
1938
+ value: null
1939
+ };
1940
+ while (!stopPolling) {
1941
+ polls += 1;
1942
+ if (polls > maxPolls) {
1943
+ stopPolling = true;
1944
+ const maxPollsError = getMaxPollsError(maxPolls);
1945
+ throw maxPollsError;
1946
+ }
1947
+ try {
1948
+ const asyncResult = await asyncFn();
1949
+ result = getValue(asyncResult, {
1950
+ stopPolling: false,
1951
+ value: null
1952
+ });
1953
+ if (result.stopPolling) {
1954
+ stopPolling = true;
1955
+ }
1956
+ } catch (e) {
1957
+ if (!ignoreErrors || isFunction_default(ignoreErrors) && !ignoreErrors(e)) {
1958
+ stopPolling = true;
1959
+ throw e;
1960
+ }
1961
+ }
1962
+ await sleep(pollIntervalMs);
1963
+ }
1964
+ return result.value;
1965
+ }
1966
+
1967
+ // src/utils/strings.ts
1968
+ function lsidToUUID(lsid) {
1969
+ return lsid.replace(/^[^:]+:(.*)$/, "$1");
1970
+ }
1971
+
1972
+ // src/utils/types.ts
1973
+ var isType = (typename) => (node) => {
1974
+ return node?.__typename === typename;
1975
+ };
1976
+ function notNullUndefined(value) {
1977
+ return value !== null && value !== void 0;
1978
+ }
1979
+
1980
+ // src/utils/zipcodeToState.ts
1981
+ var zipcodeToStateCode = {
1982
+ "20500": "DC",
1983
+ "20501": "DC",
1984
+ "20502": "DC",
1985
+ "20503": "DC",
1986
+ "20504": "DC",
1987
+ "20505": "DC",
1988
+ "20506": "DC",
1989
+ "20507": "DC",
1990
+ "20508": "DC",
1991
+ "20509": "DC",
1992
+ "20510": "DC",
1993
+ "20511": "DC",
1994
+ "20515": "DC",
1995
+ "20520": "DC",
1996
+ "20521": "DC",
1997
+ "20522": "DC",
1998
+ "20523": "DC",
1999
+ "20524": "DC",
2000
+ "20525": "DC",
2001
+ "20526": "DC",
2002
+ "20527": "DC",
2003
+ "20528": "DC",
2004
+ "20529": "DC",
2005
+ "20530": "DC",
2006
+ "20531": "DC",
2007
+ "20532": "DC",
2008
+ "20533": "DC",
2009
+ "20534": "DC",
2010
+ "20535": "DC",
2011
+ "20536": "DC",
2012
+ "20537": "DC",
2013
+ "20538": "DC",
2014
+ "20539": "DC",
2015
+ "20540": "DC",
2016
+ "20541": "DC",
2017
+ "20542": "DC",
2018
+ "20543": "DC",
2019
+ "20544": "DC",
2020
+ "20546": "DC",
2021
+ "20547": "DC",
2022
+ "20548": "DC",
2023
+ "20549": "DC",
2024
+ "20551": "DC",
2025
+ "20552": "DC",
2026
+ "20553": "DC",
2027
+ "20554": "DC",
2028
+ "20555": "DC",
2029
+ "20557": "DC",
2030
+ "20558": "DC",
2031
+ "20559": "DC",
2032
+ "20560": "DC",
2033
+ "20565": "DC",
2034
+ "20566": "DC",
2035
+ "20570": "DC",
2036
+ "20571": "DC",
2037
+ "20572": "DC",
2038
+ "20573": "DC",
2039
+ "20575": "DC",
2040
+ "20576": "DC",
2041
+ "20577": "DC",
2042
+ "20578": "DC",
2043
+ "20579": "DC",
2044
+ "20580": "DC",
2045
+ "20581": "DC",
2046
+ "20585": "DC",
2047
+ "20586": "DC",
2048
+ "20590": "DC",
2049
+ "20591": "DC",
2050
+ "20593": "DC",
2051
+ "20594": "DC",
2052
+ "20597": "DC",
2053
+ "20598": "MD",
2054
+ "20599": "DC",
2055
+ "72643": "AR",
2056
+ "73960": "OK",
2057
+ "83414": "WY",
2058
+ "96799": "HI",
2059
+ "96939": "GU",
2060
+ "96940": "GU",
2061
+ "96941": "MP",
2062
+ "96942": "MP",
2063
+ "96943": "MP",
2064
+ "96944": "MP",
2065
+ "96950": "PW",
2066
+ "96951": "PW",
2067
+ "96952": "PW",
2068
+ "96960": "FM",
2069
+ "96970": "FM",
2070
+ "06390": "CT"
2071
+ };
2072
+ var prefixToState = {
2073
+ "005": "NY",
2074
+ "006": "PR",
2075
+ "007": "PR",
2076
+ "008": "VI",
2077
+ "009": "PR",
2078
+ "010": "MA",
2079
+ "011": "MA",
2080
+ "012": "MA",
2081
+ "013": "MA",
2082
+ "014": "MA",
2083
+ "015": "MA",
2084
+ "016": "MA",
2085
+ "017": "MA",
2086
+ "018": "MA",
2087
+ "019": "MA",
2088
+ "020": "MA",
2089
+ "021": "MA",
2090
+ "022": "MA",
2091
+ "023": "MA",
2092
+ "024": "MA",
2093
+ "025": "MA",
2094
+ "026": "MA",
2095
+ "027": "MA",
2096
+ "028": "RI",
2097
+ "029": "RI",
2098
+ "030": "NH",
2099
+ "031": "NH",
2100
+ "032": "NH",
2101
+ "033": "NH",
2102
+ "034": "NH",
2103
+ "035": "NH",
2104
+ "036": "NH",
2105
+ "037": "NH",
2106
+ "038": "NH",
2107
+ "039": "ME",
2108
+ "040": "ME",
2109
+ "041": "ME",
2110
+ "042": "ME",
2111
+ "043": "ME",
2112
+ "044": "ME",
2113
+ "045": "ME",
2114
+ "046": "ME",
2115
+ "047": "ME",
2116
+ "048": "ME",
2117
+ "049": "ME",
2118
+ "050": "VT",
2119
+ "051": "VT",
2120
+ "052": "VT",
2121
+ "053": "VT",
2122
+ "054": "VT",
2123
+ "055": "MA",
2124
+ "056": "VT",
2125
+ "057": "VT",
2126
+ "058": "VT",
2127
+ "059": "VT",
2128
+ "060": "CT",
2129
+ "061": "CT",
2130
+ "062": "CT",
2131
+ "063": "CT",
2132
+ "064": "CT",
2133
+ "065": "CT",
2134
+ "066": "CT",
2135
+ "067": "CT",
2136
+ "068": "CT",
2137
+ "069": "CT",
2138
+ "070": "NJ",
2139
+ "071": "NJ",
2140
+ "072": "NJ",
2141
+ "073": "NJ",
2142
+ "074": "NJ",
2143
+ "075": "NJ",
2144
+ "076": "NJ",
2145
+ "077": "NJ",
2146
+ "078": "NJ",
2147
+ "079": "NJ",
2148
+ "080": "NJ",
2149
+ "081": "NJ",
2150
+ "082": "NJ",
2151
+ "083": "NJ",
2152
+ "084": "NJ",
2153
+ "085": "NJ",
2154
+ "086": "NJ",
2155
+ "087": "NJ",
2156
+ "088": "NJ",
2157
+ "089": "NJ",
2158
+ "090": "AE",
2159
+ "091": "AE",
2160
+ "092": "AE",
2161
+ "093": "AE",
2162
+ "094": "AE",
2163
+ "095": "AE",
2164
+ "096": "AE",
2165
+ "097": "AE",
2166
+ "098": "AE",
2167
+ "099": "AE",
2168
+ "100": "NY",
2169
+ "101": "NY",
2170
+ "102": "NY",
2171
+ "103": "NY",
2172
+ "104": "NY",
2173
+ "105": "NY",
2174
+ "106": "NY",
2175
+ "107": "NY",
2176
+ "108": "NY",
2177
+ "109": "NY",
2178
+ "110": "NY",
2179
+ "111": "NY",
2180
+ "112": "NY",
2181
+ "113": "NY",
2182
+ "114": "NY",
2183
+ "115": "NY",
2184
+ "116": "NY",
2185
+ "117": "NY",
2186
+ "118": "NY",
2187
+ "119": "NY",
2188
+ "120": "NY",
2189
+ "121": "NY",
2190
+ "122": "NY",
2191
+ "123": "NY",
2192
+ "124": "NY",
2193
+ "125": "NY",
2194
+ "126": "NY",
2195
+ "127": "NY",
2196
+ "128": "NY",
2197
+ "129": "NY",
2198
+ "130": "NY",
2199
+ "131": "NY",
2200
+ "132": "NY",
2201
+ "133": "NY",
2202
+ "134": "NY",
2203
+ "135": "NY",
2204
+ "136": "NY",
2205
+ "137": "NY",
2206
+ "138": "NY",
2207
+ "139": "NY",
2208
+ "140": "NY",
2209
+ "141": "NY",
2210
+ "142": "NY",
2211
+ "143": "NY",
2212
+ "144": "NY",
2213
+ "145": "NY",
2214
+ "146": "NY",
2215
+ "147": "NY",
2216
+ "148": "NY",
2217
+ "149": "NY",
2218
+ "150": "PA",
2219
+ "151": "PA",
2220
+ "152": "PA",
2221
+ "153": "PA",
2222
+ "154": "PA",
2223
+ "155": "PA",
2224
+ "156": "PA",
2225
+ "157": "PA",
2226
+ "158": "PA",
2227
+ "159": "PA",
2228
+ "160": "PA",
2229
+ "161": "PA",
2230
+ "162": "PA",
2231
+ "163": "PA",
2232
+ "164": "PA",
2233
+ "165": "PA",
2234
+ "166": "PA",
2235
+ "167": "PA",
2236
+ "168": "PA",
2237
+ "169": "PA",
2238
+ "170": "PA",
2239
+ "171": "PA",
2240
+ "172": "PA",
2241
+ "173": "PA",
2242
+ "174": "PA",
2243
+ "175": "PA",
2244
+ "176": "PA",
2245
+ "177": "PA",
2246
+ "178": "PA",
2247
+ "179": "PA",
2248
+ "180": "PA",
2249
+ "181": "PA",
2250
+ "182": "PA",
2251
+ "183": "PA",
2252
+ "184": "PA",
2253
+ "185": "PA",
2254
+ "186": "PA",
2255
+ "187": "PA",
2256
+ "188": "PA",
2257
+ "189": "PA",
2258
+ "190": "PA",
2259
+ "191": "PA",
2260
+ "192": "PA",
2261
+ "193": "PA",
2262
+ "194": "PA",
2263
+ "195": "PA",
2264
+ "196": "PA",
2265
+ "197": "DE",
2266
+ "198": "DE",
2267
+ "199": "DE",
2268
+ "200": "DC",
2269
+ "201": "VA",
2270
+ "202": "DC",
2271
+ "203": "DC",
2272
+ "204": "DC",
2273
+ "205": "DC",
2274
+ "206": "MD",
2275
+ "207": "MD",
2276
+ "208": "MD",
2277
+ "209": "MD",
2278
+ "210": "MD",
2279
+ "211": "MD",
2280
+ "212": "MD",
2281
+ "213": "MD",
2282
+ "214": "MD",
2283
+ "215": "MD",
2284
+ "216": "MD",
2285
+ "217": "MD",
2286
+ "218": "MD",
2287
+ "219": "MD",
2288
+ "220": "VA",
2289
+ "221": "VA",
2290
+ "222": "VA",
2291
+ "223": "VA",
2292
+ "224": "VA",
2293
+ "225": "VA",
2294
+ "226": "VA",
2295
+ "227": "VA",
2296
+ "228": "VA",
2297
+ "229": "VA",
2298
+ "230": "VA",
2299
+ "231": "VA",
2300
+ "232": "VA",
2301
+ "233": "VA",
2302
+ "234": "VA",
2303
+ "235": "VA",
2304
+ "236": "VA",
2305
+ "237": "VA",
2306
+ "238": "VA",
2307
+ "239": "VA",
2308
+ "240": "VA",
2309
+ "241": "VA",
2310
+ "242": "VA",
2311
+ "243": "VA",
2312
+ "244": "VA",
2313
+ "245": "VA",
2314
+ "246": "VA",
2315
+ "247": "WV",
2316
+ "248": "WV",
2317
+ "249": "WV",
2318
+ "250": "WV",
2319
+ "251": "WV",
2320
+ "252": "WV",
2321
+ "253": "WV",
2322
+ "254": "WV",
2323
+ "255": "WV",
2324
+ "256": "WV",
2325
+ "257": "WV",
2326
+ "258": "WV",
2327
+ "259": "WV",
2328
+ "260": "WV",
2329
+ "261": "WV",
2330
+ "262": "WV",
2331
+ "263": "WV",
2332
+ "264": "WV",
2333
+ "265": "WV",
2334
+ "266": "WV",
2335
+ "267": "WV",
2336
+ "268": "WV",
2337
+ "269": "WV",
2338
+ "270": "NC",
2339
+ "271": "NC",
2340
+ "272": "NC",
2341
+ "273": "NC",
2342
+ "274": "NC",
2343
+ "275": "NC",
2344
+ "276": "NC",
2345
+ "277": "NC",
2346
+ "278": "NC",
2347
+ "279": "NC",
2348
+ "280": "NC",
2349
+ "281": "NC",
2350
+ "282": "NC",
2351
+ "283": "NC",
2352
+ "284": "NC",
2353
+ "285": "NC",
2354
+ "286": "NC",
2355
+ "287": "NC",
2356
+ "288": "NC",
2357
+ "289": "NC",
2358
+ "290": "SC",
2359
+ "291": "SC",
2360
+ "292": "SC",
2361
+ "293": "SC",
2362
+ "294": "SC",
2363
+ "295": "SC",
2364
+ "296": "SC",
2365
+ "297": "SC",
2366
+ "298": "SC",
2367
+ "299": "SC",
2368
+ "300": "GA",
2369
+ "301": "GA",
2370
+ "302": "GA",
2371
+ "303": "GA",
2372
+ "304": "GA",
2373
+ "305": "GA",
2374
+ "306": "GA",
2375
+ "307": "GA",
2376
+ "308": "GA",
2377
+ "309": "GA",
2378
+ "310": "GA",
2379
+ "311": "GA",
2380
+ "312": "GA",
2381
+ "313": "GA",
2382
+ "314": "GA",
2383
+ "315": "GA",
2384
+ "316": "GA",
2385
+ "317": "GA",
2386
+ "318": "GA",
2387
+ "319": "GA",
2388
+ "320": "FL",
2389
+ "321": "FL",
2390
+ "322": "FL",
2391
+ "323": "FL",
2392
+ "324": "FL",
2393
+ "325": "FL",
2394
+ "326": "FL",
2395
+ "327": "FL",
2396
+ "328": "FL",
2397
+ "329": "FL",
2398
+ "330": "FL",
2399
+ "331": "FL",
2400
+ "332": "FL",
2401
+ "333": "FL",
2402
+ "334": "FL",
2403
+ "335": "FL",
2404
+ "336": "FL",
2405
+ "337": "FL",
2406
+ "338": "FL",
2407
+ "339": "FL",
2408
+ "340": "AA",
2409
+ "341": "FL",
2410
+ "342": "FL",
2411
+ "344": "FL",
2412
+ "346": "FL",
2413
+ "347": "FL",
2414
+ "349": "FL",
2415
+ "350": "AL",
2416
+ "351": "AL",
2417
+ "352": "AL",
2418
+ "354": "AL",
2419
+ "355": "AL",
2420
+ "356": "AL",
2421
+ "357": "AL",
2422
+ "358": "AL",
2423
+ "359": "AL",
2424
+ "360": "AL",
2425
+ "361": "AL",
2426
+ "362": "AL",
2427
+ "363": "AL",
2428
+ "364": "AL",
2429
+ "365": "AL",
2430
+ "366": "AL",
2431
+ "367": "AL",
2432
+ "368": "AL",
2433
+ "369": "AL",
2434
+ "370": "TN",
2435
+ "371": "TN",
2436
+ "372": "TN",
2437
+ "373": "TN",
2438
+ "374": "TN",
2439
+ "375": "TN",
2440
+ "376": "TN",
2441
+ "377": "TN",
2442
+ "378": "TN",
2443
+ "379": "TN",
2444
+ "380": "TN",
2445
+ "381": "TN",
2446
+ "382": "TN",
2447
+ "383": "TN",
2448
+ "384": "TN",
2449
+ "385": "TN",
2450
+ "386": "MS",
2451
+ "387": "MS",
2452
+ "388": "MS",
2453
+ "389": "MS",
2454
+ "390": "MS",
2455
+ "391": "MS",
2456
+ "392": "MS",
2457
+ "393": "MS",
2458
+ "394": "MS",
2459
+ "395": "MS",
2460
+ "396": "MS",
2461
+ "397": "MS",
2462
+ "398": "GA",
2463
+ "399": "GA",
2464
+ "400": "KY",
2465
+ "401": "KY",
2466
+ "402": "KY",
2467
+ "403": "KY",
2468
+ "404": "KY",
2469
+ "405": "KY",
2470
+ "406": "KY",
2471
+ "407": "KY",
2472
+ "408": "KY",
2473
+ "409": "KY",
2474
+ "410": "KY",
2475
+ "411": "KY",
2476
+ "412": "KY",
2477
+ "413": "KY",
2478
+ "414": "KY",
2479
+ "415": "KY",
2480
+ "416": "KY",
2481
+ "417": "KY",
2482
+ "418": "KY",
2483
+ "420": "KY",
2484
+ "421": "KY",
2485
+ "422": "KY",
2486
+ "423": "KY",
2487
+ "424": "KY",
2488
+ "425": "KY",
2489
+ "426": "KY",
2490
+ "427": "KY",
2491
+ "430": "OH",
2492
+ "431": "OH",
2493
+ "432": "OH",
2494
+ "433": "OH",
2495
+ "434": "OH",
2496
+ "435": "OH",
2497
+ "436": "OH",
2498
+ "437": "OH",
2499
+ "438": "OH",
2500
+ "439": "OH",
2501
+ "440": "OH",
2502
+ "441": "OH",
2503
+ "442": "OH",
2504
+ "443": "OH",
2505
+ "444": "OH",
2506
+ "445": "OH",
2507
+ "446": "OH",
2508
+ "447": "OH",
2509
+ "448": "OH",
2510
+ "449": "OH",
2511
+ "450": "OH",
2512
+ "451": "OH",
2513
+ "452": "OH",
2514
+ "453": "OH",
2515
+ "454": "OH",
2516
+ "455": "OH",
2517
+ "456": "OH",
2518
+ "457": "OH",
2519
+ "458": "OH",
2520
+ "459": "OH",
2521
+ "460": "IN",
2522
+ "461": "IN",
2523
+ "462": "IN",
2524
+ "463": "IN",
2525
+ "464": "IN",
2526
+ "465": "IN",
2527
+ "466": "IN",
2528
+ "467": "IN",
2529
+ "468": "IN",
2530
+ "469": "IN",
2531
+ "470": "IN",
2532
+ "471": "IN",
2533
+ "472": "IN",
2534
+ "473": "IN",
2535
+ "474": "IN",
2536
+ "475": "IN",
2537
+ "476": "IN",
2538
+ "477": "IN",
2539
+ "478": "IN",
2540
+ "479": "IN",
2541
+ "480": "MI",
2542
+ "481": "MI",
2543
+ "482": "MI",
2544
+ "483": "MI",
2545
+ "484": "MI",
2546
+ "485": "MI",
2547
+ "486": "MI",
2548
+ "487": "MI",
2549
+ "488": "MI",
2550
+ "489": "MI",
2551
+ "490": "MI",
2552
+ "491": "MI",
2553
+ "492": "MI",
2554
+ "493": "MI",
2555
+ "494": "MI",
2556
+ "495": "MI",
2557
+ "496": "MI",
2558
+ "497": "MI",
2559
+ "498": "MI",
2560
+ "499": "MI",
2561
+ "500": "IA",
2562
+ "501": "IA",
2563
+ "502": "IA",
2564
+ "503": "IA",
2565
+ "504": "IA",
2566
+ "505": "IA",
2567
+ "506": "IA",
2568
+ "507": "IA",
2569
+ "508": "IA",
2570
+ "509": "IA",
2571
+ "510": "IA",
2572
+ "511": "IA",
2573
+ "512": "IA",
2574
+ "513": "IA",
2575
+ "514": "IA",
2576
+ "515": "IA",
2577
+ "516": "IA",
2578
+ "520": "IA",
2579
+ "521": "IA",
2580
+ "522": "IA",
2581
+ "523": "IA",
2582
+ "524": "IA",
2583
+ "525": "IA",
2584
+ "526": "IA",
2585
+ "527": "IA",
2586
+ "528": "IA",
2587
+ "530": "WI",
2588
+ "531": "WI",
2589
+ "532": "WI",
2590
+ "534": "WI",
2591
+ "535": "WI",
2592
+ "537": "WI",
2593
+ "538": "WI",
2594
+ "539": "WI",
2595
+ "540": "WI",
2596
+ "541": "WI",
2597
+ "542": "WI",
2598
+ "543": "WI",
2599
+ "544": "WI",
2600
+ "545": "WI",
2601
+ "546": "WI",
2602
+ "547": "WI",
2603
+ "548": "WI",
2604
+ "549": "WI",
2605
+ "550": "MN",
2606
+ "551": "MN",
2607
+ "553": "MN",
2608
+ "554": "MN",
2609
+ "555": "MN",
2610
+ "556": "MN",
2611
+ "557": "MN",
2612
+ "558": "MN",
2613
+ "559": "MN",
2614
+ "560": "MN",
2615
+ "561": "MN",
2616
+ "562": "MN",
2617
+ "563": "MN",
2618
+ "564": "MN",
2619
+ "565": "MN",
2620
+ "566": "MN",
2621
+ "567": "MN",
2622
+ "570": "SD",
2623
+ "571": "SD",
2624
+ "572": "SD",
2625
+ "573": "SD",
2626
+ "574": "SD",
2627
+ "575": "SD",
2628
+ "576": "SD",
2629
+ "577": "SD",
2630
+ "580": "ND",
2631
+ "581": "ND",
2632
+ "582": "ND",
2633
+ "583": "ND",
2634
+ "584": "ND",
2635
+ "585": "ND",
2636
+ "586": "ND",
2637
+ "587": "ND",
2638
+ "588": "ND",
2639
+ "590": "MT",
2640
+ "591": "MT",
2641
+ "592": "MT",
2642
+ "593": "MT",
2643
+ "594": "MT",
2644
+ "595": "MT",
2645
+ "596": "MT",
2646
+ "597": "MT",
2647
+ "598": "MT",
2648
+ "599": "MT",
2649
+ "600": "IL",
2650
+ "601": "IL",
2651
+ "602": "IL",
2652
+ "603": "IL",
2653
+ "604": "IL",
2654
+ "605": "IL",
2655
+ "606": "IL",
2656
+ "607": "IL",
2657
+ "608": "IL",
2658
+ "609": "IL",
2659
+ "610": "IL",
2660
+ "611": "IL",
2661
+ "612": "IL",
2662
+ "613": "IL",
2663
+ "614": "IL",
2664
+ "615": "IL",
2665
+ "616": "IL",
2666
+ "617": "IL",
2667
+ "618": "IL",
2668
+ "619": "IL",
2669
+ "620": "IL",
2670
+ "622": "IL",
2671
+ "623": "IL",
2672
+ "624": "IL",
2673
+ "625": "IL",
2674
+ "626": "IL",
2675
+ "627": "IL",
2676
+ "628": "IL",
2677
+ "629": "IL",
2678
+ "630": "MO",
2679
+ "631": "MO",
2680
+ "633": "MO",
2681
+ "634": "MO",
2682
+ "635": "MO",
2683
+ "636": "MO",
2684
+ "637": "MO",
2685
+ "638": "MO",
2686
+ "639": "MO",
2687
+ "640": "MO",
2688
+ "641": "MO",
2689
+ "644": "MO",
2690
+ "645": "MO",
2691
+ "646": "MO",
2692
+ "647": "MO",
2693
+ "648": "MO",
2694
+ "649": "MO",
2695
+ "650": "MO",
2696
+ "651": "MO",
2697
+ "652": "MO",
2698
+ "653": "MO",
2699
+ "654": "MO",
2700
+ "655": "MO",
2701
+ "656": "MO",
2702
+ "657": "MO",
2703
+ "658": "MO",
2704
+ "660": "KS",
2705
+ "661": "KS",
2706
+ "662": "KS",
2707
+ "664": "KS",
2708
+ "665": "KS",
2709
+ "666": "KS",
2710
+ "667": "KS",
2711
+ "668": "KS",
2712
+ "669": "KS",
2713
+ "670": "KS",
2714
+ "671": "KS",
2715
+ "672": "KS",
2716
+ "673": "KS",
2717
+ "674": "KS",
2718
+ "675": "KS",
2719
+ "676": "KS",
2720
+ "677": "KS",
2721
+ "678": "KS",
2722
+ "679": "KS",
2723
+ "680": "NE",
2724
+ "681": "NE",
2725
+ "683": "NE",
2726
+ "684": "NE",
2727
+ "685": "NE",
2728
+ "686": "NE",
2729
+ "687": "NE",
2730
+ "688": "NE",
2731
+ "689": "NE",
2732
+ "690": "NE",
2733
+ "691": "NE",
2734
+ "692": "NE",
2735
+ "693": "NE",
2736
+ "700": "LA",
2737
+ "701": "LA",
2738
+ "703": "LA",
2739
+ "704": "LA",
2740
+ "705": "LA",
2741
+ "706": "LA",
2742
+ "707": "LA",
2743
+ "708": "LA",
2744
+ "710": "LA",
2745
+ "711": "LA",
2746
+ "712": "LA",
2747
+ "713": "LA",
2748
+ "714": "LA",
2749
+ "716": "AR",
2750
+ "717": "AR",
2751
+ "718": "AR",
2752
+ "719": "AR",
2753
+ "720": "AR",
2754
+ "721": "AR",
2755
+ "722": "AR",
2756
+ "723": "AR",
2757
+ "724": "AR",
2758
+ "725": "AR",
2759
+ "726": "AR",
2760
+ "727": "AR",
2761
+ "728": "AR",
2762
+ "729": "AR",
2763
+ "730": "OK",
2764
+ "731": "OK",
2765
+ "733": "OK",
2766
+ "734": "OK",
2767
+ "735": "OK",
2768
+ "736": "OK",
2769
+ "737": "OK",
2770
+ "738": "OK",
2771
+ "739": "OK",
2772
+ "740": "OK",
2773
+ "741": "OK",
2774
+ "743": "OK",
2775
+ "744": "OK",
2776
+ "745": "OK",
2777
+ "746": "OK",
2778
+ "747": "OK",
2779
+ "748": "OK",
2780
+ "749": "OK",
2781
+ "750": "TX",
2782
+ "751": "TX",
2783
+ "752": "TX",
2784
+ "753": "TX",
2785
+ "754": "TX",
2786
+ "755": "TX",
2787
+ "756": "TX",
2788
+ "757": "TX",
2789
+ "758": "TX",
2790
+ "759": "TX",
2791
+ "760": "TX",
2792
+ "761": "TX",
2793
+ "762": "TX",
2794
+ "763": "TX",
2795
+ "764": "TX",
2796
+ "765": "TX",
2797
+ "766": "TX",
2798
+ "767": "TX",
2799
+ "768": "TX",
2800
+ "769": "TX",
2801
+ "770": "TX",
2802
+ "771": "TX",
2803
+ "772": "TX",
2804
+ "773": "TX",
2805
+ "774": "TX",
2806
+ "775": "TX",
2807
+ "776": "TX",
2808
+ "777": "TX",
2809
+ "778": "TX",
2810
+ "779": "TX",
2811
+ "780": "TX",
2812
+ "781": "TX",
2813
+ "782": "TX",
2814
+ "783": "TX",
2815
+ "784": "TX",
2816
+ "785": "TX",
2817
+ "786": "TX",
2818
+ "787": "TX",
2819
+ "788": "TX",
2820
+ "789": "TX",
2821
+ "790": "TX",
2822
+ "791": "TX",
2823
+ "792": "TX",
2824
+ "793": "TX",
2825
+ "794": "TX",
2826
+ "795": "TX",
2827
+ "796": "TX",
2828
+ "797": "TX",
2829
+ "798": "TX",
2830
+ "799": "TX",
2831
+ "800": "CO",
2832
+ "801": "CO",
2833
+ "802": "CO",
2834
+ "803": "CO",
2835
+ "804": "CO",
2836
+ "805": "CO",
2837
+ "806": "CO",
2838
+ "807": "CO",
2839
+ "808": "CO",
2840
+ "809": "CO",
2841
+ "810": "CO",
2842
+ "811": "CO",
2843
+ "812": "CO",
2844
+ "813": "CO",
2845
+ "814": "CO",
2846
+ "815": "CO",
2847
+ "816": "CO",
2848
+ "820": "WY",
2849
+ "821": "WY",
2850
+ "822": "WY",
2851
+ "823": "WY",
2852
+ "824": "WY",
2853
+ "825": "WY",
2854
+ "826": "WY",
2855
+ "827": "WY",
2856
+ "828": "WY",
2857
+ "829": "WY",
2858
+ "830": "WY",
2859
+ "831": "WY",
2860
+ "832": "ID",
2861
+ "833": "ID",
2862
+ "834": "ID",
2863
+ "835": "ID",
2864
+ "836": "ID",
2865
+ "837": "ID",
2866
+ "838": "ID",
2867
+ "839": "ID",
2868
+ "840": "UT",
2869
+ "841": "UT",
2870
+ "842": "UT",
2871
+ "843": "UT",
2872
+ "844": "UT",
2873
+ "845": "UT",
2874
+ "846": "UT",
2875
+ "847": "UT",
2876
+ "850": "AZ",
2877
+ "851": "AZ",
2878
+ "852": "AZ",
2879
+ "853": "AZ",
2880
+ "854": "AZ",
2881
+ "855": "AZ",
2882
+ "856": "AZ",
2883
+ "857": "AZ",
2884
+ "859": "AZ",
2885
+ "860": "AZ",
2886
+ "863": "AZ",
2887
+ "864": "AZ",
2888
+ "865": "AZ",
2889
+ "870": "NM",
2890
+ "871": "NM",
2891
+ "872": "NM",
2892
+ "873": "NM",
2893
+ "874": "NM",
2894
+ "875": "NM",
2895
+ "877": "NM",
2896
+ "878": "NM",
2897
+ "879": "NM",
2898
+ "880": "NM",
2899
+ "881": "NM",
2900
+ "882": "NM",
2901
+ "883": "NM",
2902
+ "884": "NM",
2903
+ "885": "TX",
2904
+ "889": "NV",
2905
+ "890": "NV",
2906
+ "891": "NV",
2907
+ "893": "NV",
2908
+ "894": "NV",
2909
+ "895": "NV",
2910
+ "897": "NV",
2911
+ "898": "NV",
2912
+ "899": "NV",
2913
+ "900": "CA",
2914
+ "901": "CA",
2915
+ "902": "CA",
2916
+ "903": "CA",
2917
+ "904": "CA",
2918
+ "905": "CA",
2919
+ "906": "CA",
2920
+ "907": "CA",
2921
+ "908": "CA",
2922
+ "909": "CA",
2923
+ "910": "CA",
2924
+ "911": "CA",
2925
+ "912": "CA",
2926
+ "913": "CA",
2927
+ "914": "CA",
2928
+ "915": "CA",
2929
+ "916": "CA",
2930
+ "917": "CA",
2931
+ "918": "CA",
2932
+ "919": "CA",
2933
+ "920": "CA",
2934
+ "921": "CA",
2935
+ "922": "CA",
2936
+ "923": "CA",
2937
+ "924": "CA",
2938
+ "925": "CA",
2939
+ "926": "CA",
2940
+ "927": "CA",
2941
+ "928": "CA",
2942
+ "929": "CA",
2943
+ "930": "CA",
2944
+ "931": "CA",
2945
+ "932": "CA",
2946
+ "933": "CA",
2947
+ "934": "CA",
2948
+ "935": "CA",
2949
+ "936": "CA",
2950
+ "937": "CA",
2951
+ "938": "CA",
2952
+ "939": "CA",
2953
+ "940": "CA",
2954
+ "941": "CA",
2955
+ "942": "CA",
2956
+ "943": "CA",
2957
+ "944": "CA",
2958
+ "945": "CA",
2959
+ "946": "CA",
2960
+ "947": "CA",
2961
+ "948": "CA",
2962
+ "949": "CA",
2963
+ "950": "CA",
2964
+ "951": "CA",
2965
+ "952": "CA",
2966
+ "953": "CA",
2967
+ "954": "CA",
2968
+ "955": "CA",
2969
+ "956": "CA",
2970
+ "957": "CA",
2971
+ "958": "CA",
2972
+ "959": "CA",
2973
+ "960": "CA",
2974
+ "961": "CA",
2975
+ "962": "AP",
2976
+ "963": "GU",
2977
+ "964": "AP",
2978
+ "965": "AP",
2979
+ "966": "AP",
2980
+ "967": "HI",
2981
+ "968": "HI",
2982
+ "969": "MP",
2983
+ "970": "OR",
2984
+ "971": "OR",
2985
+ "972": "OR",
2986
+ "973": "OR",
2987
+ "974": "OR",
2988
+ "975": "OR",
2989
+ "976": "OR",
2990
+ "977": "OR",
2991
+ "978": "OR",
2992
+ "979": "OR",
2993
+ "980": "WA",
2994
+ "981": "WA",
2995
+ "982": "WA",
2996
+ "983": "WA",
2997
+ "984": "WA",
2998
+ "985": "WA",
2999
+ "986": "WA",
3000
+ "987": "WA",
3001
+ "988": "WA",
3002
+ "989": "WA",
3003
+ "990": "WA",
3004
+ "991": "WA",
3005
+ "992": "WA",
3006
+ "993": "WA",
3007
+ "994": "WA",
3008
+ "995": "AK",
3009
+ "996": "AK",
3010
+ "997": "AK",
3011
+ "998": "AK",
3012
+ "999": "AK"
3013
+ };
3014
+ function zipcodeToState(zipcode) {
3015
+ const fullZip = zipcode.slice(0, 5);
3016
+ if (zipcodeToStateCode[fullZip]) {
3017
+ return zipcodeToStateCode[fullZip];
3018
+ }
3019
+ const prefix = zipcode.slice(0, 3);
3020
+ return prefixToState[prefix] || null;
3021
+ }
3022
+ // Annotate the CommonJS export names for ESM import in node:
3023
+ 0 && (module.exports = {
3024
+ ConfigKeys,
3025
+ CurrencyUnit,
3026
+ DefaultCrypto,
3027
+ KeyOrAlias,
3028
+ LightsparkAuthException,
3029
+ LightsparkException,
3030
+ LightsparkSigningException,
3031
+ Logger,
3032
+ LoggingLevel,
3033
+ NodeKeyCache,
3034
+ RSASigningKey,
3035
+ Requester,
3036
+ Secp256k1SigningKey,
3037
+ ServerEnvironment,
3038
+ SigningKey,
3039
+ SigningKeyType,
3040
+ StubAuthProvider,
3041
+ abbrCurrencyUnit,
3042
+ apiDomainForEnvironment,
3043
+ b64decode,
3044
+ b64encode,
3045
+ bytesToHex,
3046
+ clamp,
3047
+ convertCurrencyAmount,
3048
+ convertCurrencyAmountValue,
3049
+ countryCodesToCurrencyCodes,
3050
+ createSha256Hash,
3051
+ defaultCurrencyCode,
3052
+ deleteLocalStorageItem,
3053
+ ensureArray,
3054
+ errorToJSON,
3055
+ formatCurrencyStr,
3056
+ formatInviteAmount,
3057
+ getCurrencyAmount,
3058
+ getCurrentLocale,
3059
+ getErrorMsg,
3060
+ getLocalStorageBoolean,
3061
+ getLocalStorageConfigItem,
3062
+ hexToBytes,
3063
+ isBare,
3064
+ isBrowser,
3065
+ isCurrencyAmountInputObj,
3066
+ isCurrencyAmountObj,
3067
+ isCurrencyAmountPreferenceObj,
3068
+ isCurrencyMap,
3069
+ isDeprecatedCurrencyAmountObj,
3070
+ isError,
3071
+ isErrorMsg,
3072
+ isErrorWithMessage,
3073
+ isNode,
3074
+ isNumber,
3075
+ isObject,
3076
+ isReactNative,
3077
+ isRecord,
3078
+ isSDKCurrencyAmount,
3079
+ isTest,
3080
+ isType,
3081
+ isUint8Array,
3082
+ isUmaCurrencyAmount,
3083
+ linearInterpolate,
3084
+ localeToCurrencyCode,
3085
+ localeToCurrencySymbol,
3086
+ logger,
3087
+ lsidToUUID,
3088
+ mapCurrencyAmount,
3089
+ notNullUndefined,
3090
+ pollUntil,
3091
+ round,
3092
+ separateCurrencyStrParts,
3093
+ setLocalStorageBoolean,
3094
+ sleep,
3095
+ urlsafe_b64decode,
3096
+ zipcodeToState,
3097
+ zipcodeToStateCode
3098
+ });
3099
+ /*! Bundled license information:
3100
+
3101
+ lodash-es/lodash.js:
3102
+ (**
3103
+ * @license
3104
+ * Lodash (Custom Build) <https://lodash.com/>
3105
+ * Build: `lodash modularize exports="es" -o ./`
3106
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
3107
+ * Released under MIT license <https://lodash.com/license>
3108
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
3109
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
3110
+ *)
3111
+ */