@t2000/cli 0.22.10 → 0.22.12

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,2513 @@
1
+ import { createRequire as __createRequire } from 'module'; import { fileURLToPath as __fileURLToPath } from 'url'; import { dirname as __pathDirname } from 'path'; const require = __createRequire(import.meta.url); const __filename = __fileURLToPath(import.meta.url); const __dirname = __pathDirname(__filename);
2
+
3
+ // ../../node_modules/.pnpm/@mysten+utils@0.3.1/node_modules/@mysten/utils/dist/b64.mjs
4
+ function fromBase64(base64String) {
5
+ return Uint8Array.from(atob(base64String), (char) => char.charCodeAt(0));
6
+ }
7
+ var CHUNK_SIZE = 8192;
8
+ function toBase64(bytes) {
9
+ if (bytes.length < CHUNK_SIZE) return btoa(String.fromCharCode(...bytes));
10
+ let output = "";
11
+ for (var i = 0; i < bytes.length; i += CHUNK_SIZE) {
12
+ const chunk2 = bytes.slice(i, i + CHUNK_SIZE);
13
+ output += String.fromCharCode(...chunk2);
14
+ }
15
+ return btoa(output);
16
+ }
17
+
18
+ // ../../node_modules/.pnpm/@mysten+utils@0.3.1/node_modules/@mysten/utils/dist/hex.mjs
19
+ function fromHex(hexStr) {
20
+ const normalized = hexStr.startsWith("0x") ? hexStr.slice(2) : hexStr;
21
+ const padded = normalized.length % 2 === 0 ? normalized : `0${normalized}`;
22
+ const intArr = padded.match(/[0-9a-fA-F]{2}/g)?.map((byte) => parseInt(byte, 16)) ?? [];
23
+ if (intArr.length !== padded.length / 2) throw new Error(`Invalid hex string ${hexStr}`);
24
+ return Uint8Array.from(intArr);
25
+ }
26
+ function toHex(bytes) {
27
+ return bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
28
+ }
29
+
30
+ // ../../node_modules/.pnpm/@scure+base@2.0.0/node_modules/@scure/base/index.js
31
+ function isBytes(a) {
32
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
33
+ }
34
+ function isArrayOf(isString, arr) {
35
+ if (!Array.isArray(arr))
36
+ return false;
37
+ if (arr.length === 0)
38
+ return true;
39
+ if (isString) {
40
+ return arr.every((item) => typeof item === "string");
41
+ } else {
42
+ return arr.every((item) => Number.isSafeInteger(item));
43
+ }
44
+ }
45
+ function afn(input) {
46
+ if (typeof input !== "function")
47
+ throw new Error("function expected");
48
+ return true;
49
+ }
50
+ function astr(label, input) {
51
+ if (typeof input !== "string")
52
+ throw new Error(`${label}: string expected`);
53
+ return true;
54
+ }
55
+ function anumber(n) {
56
+ if (!Number.isSafeInteger(n))
57
+ throw new Error(`invalid integer: ${n}`);
58
+ }
59
+ function aArr(input) {
60
+ if (!Array.isArray(input))
61
+ throw new Error("array expected");
62
+ }
63
+ function astrArr(label, input) {
64
+ if (!isArrayOf(true, input))
65
+ throw new Error(`${label}: array of strings expected`);
66
+ }
67
+ function anumArr(label, input) {
68
+ if (!isArrayOf(false, input))
69
+ throw new Error(`${label}: array of numbers expected`);
70
+ }
71
+ // @__NO_SIDE_EFFECTS__
72
+ function chain(...args) {
73
+ const id = (a) => a;
74
+ const wrap = (a, b) => (c) => a(b(c));
75
+ const encode = args.map((x) => x.encode).reduceRight(wrap, id);
76
+ const decode = args.map((x) => x.decode).reduce(wrap, id);
77
+ return { encode, decode };
78
+ }
79
+ // @__NO_SIDE_EFFECTS__
80
+ function alphabet(letters) {
81
+ const lettersA = typeof letters === "string" ? letters.split("") : letters;
82
+ const len = lettersA.length;
83
+ astrArr("alphabet", lettersA);
84
+ const indexes = new Map(lettersA.map((l, i) => [l, i]));
85
+ return {
86
+ encode: (digits) => {
87
+ aArr(digits);
88
+ return digits.map((i) => {
89
+ if (!Number.isSafeInteger(i) || i < 0 || i >= len)
90
+ throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${letters}`);
91
+ return lettersA[i];
92
+ });
93
+ },
94
+ decode: (input) => {
95
+ aArr(input);
96
+ return input.map((letter) => {
97
+ astr("alphabet.decode", letter);
98
+ const i = indexes.get(letter);
99
+ if (i === void 0)
100
+ throw new Error(`Unknown letter: "${letter}". Allowed: ${letters}`);
101
+ return i;
102
+ });
103
+ }
104
+ };
105
+ }
106
+ // @__NO_SIDE_EFFECTS__
107
+ function join(separator = "") {
108
+ astr("join", separator);
109
+ return {
110
+ encode: (from) => {
111
+ astrArr("join.decode", from);
112
+ return from.join(separator);
113
+ },
114
+ decode: (to) => {
115
+ astr("join.decode", to);
116
+ return to.split(separator);
117
+ }
118
+ };
119
+ }
120
+ function convertRadix(data, from, to) {
121
+ if (from < 2)
122
+ throw new Error(`convertRadix: invalid from=${from}, base cannot be less than 2`);
123
+ if (to < 2)
124
+ throw new Error(`convertRadix: invalid to=${to}, base cannot be less than 2`);
125
+ aArr(data);
126
+ if (!data.length)
127
+ return [];
128
+ let pos = 0;
129
+ const res = [];
130
+ const digits = Array.from(data, (d) => {
131
+ anumber(d);
132
+ if (d < 0 || d >= from)
133
+ throw new Error(`invalid integer: ${d}`);
134
+ return d;
135
+ });
136
+ const dlen = digits.length;
137
+ while (true) {
138
+ let carry = 0;
139
+ let done = true;
140
+ for (let i = pos; i < dlen; i++) {
141
+ const digit = digits[i];
142
+ const fromCarry = from * carry;
143
+ const digitBase = fromCarry + digit;
144
+ if (!Number.isSafeInteger(digitBase) || fromCarry / from !== carry || digitBase - digit !== fromCarry) {
145
+ throw new Error("convertRadix: carry overflow");
146
+ }
147
+ const div = digitBase / to;
148
+ carry = digitBase % to;
149
+ const rounded = Math.floor(div);
150
+ digits[i] = rounded;
151
+ if (!Number.isSafeInteger(rounded) || rounded * to + carry !== digitBase)
152
+ throw new Error("convertRadix: carry overflow");
153
+ if (!done)
154
+ continue;
155
+ else if (!rounded)
156
+ pos = i;
157
+ else
158
+ done = false;
159
+ }
160
+ res.push(carry);
161
+ if (done)
162
+ break;
163
+ }
164
+ for (let i = 0; i < data.length - 1 && data[i] === 0; i++)
165
+ res.push(0);
166
+ return res.reverse();
167
+ }
168
+ var gcd = (a, b) => b === 0 ? a : gcd(b, a % b);
169
+ var radix2carry = /* @__NO_SIDE_EFFECTS__ */ (from, to) => from + (to - gcd(from, to));
170
+ var powers = /* @__PURE__ */ (() => {
171
+ let res = [];
172
+ for (let i = 0; i < 40; i++)
173
+ res.push(2 ** i);
174
+ return res;
175
+ })();
176
+ function convertRadix2(data, from, to, padding) {
177
+ aArr(data);
178
+ if (from <= 0 || from > 32)
179
+ throw new Error(`convertRadix2: wrong from=${from}`);
180
+ if (to <= 0 || to > 32)
181
+ throw new Error(`convertRadix2: wrong to=${to}`);
182
+ if (/* @__PURE__ */ radix2carry(from, to) > 32) {
183
+ throw new Error(`convertRadix2: carry overflow from=${from} to=${to} carryBits=${/* @__PURE__ */ radix2carry(from, to)}`);
184
+ }
185
+ let carry = 0;
186
+ let pos = 0;
187
+ const max = powers[from];
188
+ const mask = powers[to] - 1;
189
+ const res = [];
190
+ for (const n of data) {
191
+ anumber(n);
192
+ if (n >= max)
193
+ throw new Error(`convertRadix2: invalid data word=${n} from=${from}`);
194
+ carry = carry << from | n;
195
+ if (pos + from > 32)
196
+ throw new Error(`convertRadix2: carry overflow pos=${pos} from=${from}`);
197
+ pos += from;
198
+ for (; pos >= to; pos -= to)
199
+ res.push((carry >> pos - to & mask) >>> 0);
200
+ const pow = powers[pos];
201
+ if (pow === void 0)
202
+ throw new Error("invalid carry");
203
+ carry &= pow - 1;
204
+ }
205
+ carry = carry << to - pos & mask;
206
+ if (!padding && pos >= from)
207
+ throw new Error("Excess padding");
208
+ if (!padding && carry > 0)
209
+ throw new Error(`Non-zero padding: ${carry}`);
210
+ if (padding && pos > 0)
211
+ res.push(carry >>> 0);
212
+ return res;
213
+ }
214
+ // @__NO_SIDE_EFFECTS__
215
+ function radix(num) {
216
+ anumber(num);
217
+ const _256 = 2 ** 8;
218
+ return {
219
+ encode: (bytes) => {
220
+ if (!isBytes(bytes))
221
+ throw new Error("radix.encode input should be Uint8Array");
222
+ return convertRadix(Array.from(bytes), _256, num);
223
+ },
224
+ decode: (digits) => {
225
+ anumArr("radix.decode", digits);
226
+ return Uint8Array.from(convertRadix(digits, num, _256));
227
+ }
228
+ };
229
+ }
230
+ // @__NO_SIDE_EFFECTS__
231
+ function radix2(bits, revPadding = false) {
232
+ anumber(bits);
233
+ if (bits <= 0 || bits > 32)
234
+ throw new Error("radix2: bits should be in (0..32]");
235
+ if (/* @__PURE__ */ radix2carry(8, bits) > 32 || /* @__PURE__ */ radix2carry(bits, 8) > 32)
236
+ throw new Error("radix2: carry overflow");
237
+ return {
238
+ encode: (bytes) => {
239
+ if (!isBytes(bytes))
240
+ throw new Error("radix2.encode input should be Uint8Array");
241
+ return convertRadix2(Array.from(bytes), 8, bits, !revPadding);
242
+ },
243
+ decode: (digits) => {
244
+ anumArr("radix2.decode", digits);
245
+ return Uint8Array.from(convertRadix2(digits, bits, 8, revPadding));
246
+ }
247
+ };
248
+ }
249
+ function unsafeWrapper(fn) {
250
+ afn(fn);
251
+ return function(...args) {
252
+ try {
253
+ return fn.apply(null, args);
254
+ } catch (e) {
255
+ }
256
+ };
257
+ }
258
+ var base64urlnopad = /* @__PURE__ */ chain(/* @__PURE__ */ radix2(6), /* @__PURE__ */ alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), /* @__PURE__ */ join(""));
259
+ var genBase58 = /* @__NO_SIDE_EFFECTS__ */ (abc) => /* @__PURE__ */ chain(/* @__PURE__ */ radix(58), /* @__PURE__ */ alphabet(abc), /* @__PURE__ */ join(""));
260
+ var base58 = /* @__PURE__ */ genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
261
+ var BECH_ALPHABET = /* @__PURE__ */ chain(/* @__PURE__ */ alphabet("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), /* @__PURE__ */ join(""));
262
+ var POLYMOD_GENERATORS = [996825010, 642813549, 513874426, 1027748829, 705979059];
263
+ function bech32Polymod(pre) {
264
+ const b = pre >> 25;
265
+ let chk = (pre & 33554431) << 5;
266
+ for (let i = 0; i < POLYMOD_GENERATORS.length; i++) {
267
+ if ((b >> i & 1) === 1)
268
+ chk ^= POLYMOD_GENERATORS[i];
269
+ }
270
+ return chk;
271
+ }
272
+ function bechChecksum(prefix, words, encodingConst = 1) {
273
+ const len = prefix.length;
274
+ let chk = 1;
275
+ for (let i = 0; i < len; i++) {
276
+ const c = prefix.charCodeAt(i);
277
+ if (c < 33 || c > 126)
278
+ throw new Error(`Invalid prefix (${prefix})`);
279
+ chk = bech32Polymod(chk) ^ c >> 5;
280
+ }
281
+ chk = bech32Polymod(chk);
282
+ for (let i = 0; i < len; i++)
283
+ chk = bech32Polymod(chk) ^ prefix.charCodeAt(i) & 31;
284
+ for (let v of words)
285
+ chk = bech32Polymod(chk) ^ v;
286
+ for (let i = 0; i < 6; i++)
287
+ chk = bech32Polymod(chk);
288
+ chk ^= encodingConst;
289
+ return BECH_ALPHABET.encode(convertRadix2([chk % powers[30]], 30, 5, false));
290
+ }
291
+ // @__NO_SIDE_EFFECTS__
292
+ function genBech32(encoding) {
293
+ const ENCODING_CONST = encoding === "bech32" ? 1 : 734539939;
294
+ const _words = /* @__PURE__ */ radix2(5);
295
+ const fromWords = _words.decode;
296
+ const toWords = _words.encode;
297
+ const fromWordsUnsafe = unsafeWrapper(fromWords);
298
+ function encode(prefix, words, limit = 90) {
299
+ astr("bech32.encode prefix", prefix);
300
+ if (isBytes(words))
301
+ words = Array.from(words);
302
+ anumArr("bech32.encode", words);
303
+ const plen = prefix.length;
304
+ if (plen === 0)
305
+ throw new TypeError(`Invalid prefix length ${plen}`);
306
+ const actualLength = plen + 7 + words.length;
307
+ if (limit !== false && actualLength > limit)
308
+ throw new TypeError(`Length ${actualLength} exceeds limit ${limit}`);
309
+ const lowered = prefix.toLowerCase();
310
+ const sum = bechChecksum(lowered, words, ENCODING_CONST);
311
+ return `${lowered}1${BECH_ALPHABET.encode(words)}${sum}`;
312
+ }
313
+ function decode(str, limit = 90) {
314
+ astr("bech32.decode input", str);
315
+ const slen = str.length;
316
+ if (slen < 8 || limit !== false && slen > limit)
317
+ throw new TypeError(`invalid string length: ${slen} (${str}). Expected (8..${limit})`);
318
+ const lowered = str.toLowerCase();
319
+ if (str !== lowered && str !== str.toUpperCase())
320
+ throw new Error(`String must be lowercase or uppercase`);
321
+ const sepIndex = lowered.lastIndexOf("1");
322
+ if (sepIndex === 0 || sepIndex === -1)
323
+ throw new Error(`Letter "1" must be present between prefix and data only`);
324
+ const prefix = lowered.slice(0, sepIndex);
325
+ const data = lowered.slice(sepIndex + 1);
326
+ if (data.length < 6)
327
+ throw new Error("Data must be at least 6 characters long");
328
+ const words = BECH_ALPHABET.decode(data).slice(0, -6);
329
+ const sum = bechChecksum(prefix, words, ENCODING_CONST);
330
+ if (!data.endsWith(sum))
331
+ throw new Error(`Invalid checksum in ${str}: expected "${sum}"`);
332
+ return { prefix, words };
333
+ }
334
+ const decodeUnsafe = unsafeWrapper(decode);
335
+ function decodeToBytes(str) {
336
+ const { prefix, words } = decode(str, false);
337
+ return { prefix, words, bytes: fromWords(words) };
338
+ }
339
+ function encodeFromBytes(prefix, bytes) {
340
+ return encode(prefix, toWords(bytes));
341
+ }
342
+ return {
343
+ encode,
344
+ decode,
345
+ encodeFromBytes,
346
+ decodeToBytes,
347
+ decodeUnsafe,
348
+ fromWords,
349
+ fromWordsUnsafe,
350
+ toWords
351
+ };
352
+ }
353
+ var bech32 = /* @__PURE__ */ genBech32("bech32");
354
+
355
+ // ../../node_modules/.pnpm/@mysten+utils@0.3.1/node_modules/@mysten/utils/dist/b58.mjs
356
+ var toBase58 = (buffer) => base58.encode(buffer);
357
+ var fromBase58 = (str) => base58.decode(str);
358
+
359
+ // ../../node_modules/.pnpm/@mysten+utils@0.3.1/node_modules/@mysten/utils/dist/chunk.mjs
360
+ function chunk(array, size) {
361
+ return Array.from({ length: Math.ceil(array.length / size) }, (_, i) => {
362
+ return array.slice(i * size, (i + 1) * size);
363
+ });
364
+ }
365
+
366
+ // ../../node_modules/.pnpm/@mysten+utils@0.3.1/node_modules/@mysten/utils/dist/dataloader.mjs
367
+ var DataLoader = class {
368
+ constructor(batchLoadFn, options) {
369
+ if (typeof batchLoadFn !== "function") throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but got: ${batchLoadFn}.`);
370
+ this._batchLoadFn = batchLoadFn;
371
+ this._maxBatchSize = getValidMaxBatchSize(options);
372
+ this._batchScheduleFn = getValidBatchScheduleFn(options);
373
+ this._cacheKeyFn = getValidCacheKeyFn(options);
374
+ this._cacheMap = getValidCacheMap(options);
375
+ this._batch = null;
376
+ this.name = getValidName(options);
377
+ }
378
+ /**
379
+ * Loads a key, returning a `Promise` for the value represented by that key.
380
+ */
381
+ load(key) {
382
+ if (key === null || key === void 0) throw new TypeError(`The loader.load() function must be called with a value, but got: ${String(key)}.`);
383
+ const batch = getCurrentBatch(this);
384
+ const cacheMap = this._cacheMap;
385
+ let cacheKey;
386
+ if (cacheMap) {
387
+ cacheKey = this._cacheKeyFn(key);
388
+ const cachedPromise = cacheMap.get(cacheKey);
389
+ if (cachedPromise) {
390
+ const cacheHits = batch.cacheHits || (batch.cacheHits = []);
391
+ return new Promise((resolve) => {
392
+ cacheHits.push(() => {
393
+ resolve(cachedPromise);
394
+ });
395
+ });
396
+ }
397
+ }
398
+ batch.keys.push(key);
399
+ const promise = new Promise((resolve, reject) => {
400
+ batch.callbacks.push({
401
+ resolve,
402
+ reject
403
+ });
404
+ });
405
+ if (cacheMap) cacheMap.set(cacheKey, promise);
406
+ return promise;
407
+ }
408
+ /**
409
+ * Loads multiple keys, promising an array of values:
410
+ *
411
+ * var [ a, b ] = await myLoader.loadMany([ 'a', 'b' ]);
412
+ *
413
+ * This is similar to the more verbose:
414
+ *
415
+ * var [ a, b ] = await Promise.all([
416
+ * myLoader.load('a'),
417
+ * myLoader.load('b')
418
+ * ]);
419
+ *
420
+ * However it is different in the case where any load fails. Where
421
+ * Promise.all() would reject, loadMany() always resolves, however each result
422
+ * is either a value or an Error instance.
423
+ *
424
+ * var [ a, b, c ] = await myLoader.loadMany([ 'a', 'b', 'badkey' ]);
425
+ * // c instanceof Error
426
+ *
427
+ */
428
+ loadMany(keys) {
429
+ if (!isArrayLike(keys)) throw new TypeError(`The loader.loadMany() function must be called with Array<key>, but got: ${keys}.`);
430
+ const loadPromises = [];
431
+ for (let i = 0; i < keys.length; i++) loadPromises.push(this.load(keys[i]).catch((error) => error));
432
+ return Promise.all(loadPromises);
433
+ }
434
+ /**
435
+ * Clears the value at `key` from the cache, if it exists. Returns itself for
436
+ * method chaining.
437
+ */
438
+ clear(key) {
439
+ const cacheMap = this._cacheMap;
440
+ if (cacheMap) {
441
+ const cacheKey = this._cacheKeyFn(key);
442
+ cacheMap.delete(cacheKey);
443
+ }
444
+ return this;
445
+ }
446
+ /**
447
+ * Clears the entire cache. To be used when some event results in unknown
448
+ * invalidations across this particular `DataLoader`. Returns itself for
449
+ * method chaining.
450
+ */
451
+ clearAll() {
452
+ const cacheMap = this._cacheMap;
453
+ if (cacheMap) cacheMap.clear();
454
+ return this;
455
+ }
456
+ /**
457
+ * Adds the provided key and value to the cache. If the key already
458
+ * exists, no change is made. Returns itself for method chaining.
459
+ *
460
+ * To prime the cache with an error at a key, provide an Error instance.
461
+ */
462
+ prime(key, value) {
463
+ const cacheMap = this._cacheMap;
464
+ if (cacheMap) {
465
+ const cacheKey = this._cacheKeyFn(key);
466
+ if (cacheMap.get(cacheKey) === void 0) {
467
+ let promise;
468
+ if (value instanceof Error) {
469
+ promise = Promise.reject(value);
470
+ promise.catch(() => {
471
+ });
472
+ } else promise = Promise.resolve(value);
473
+ cacheMap.set(cacheKey, promise);
474
+ }
475
+ }
476
+ return this;
477
+ }
478
+ };
479
+ var enqueuePostPromiseJob = typeof process === "object" && typeof process.nextTick === "function" ? function(fn) {
480
+ if (!resolvedPromise) resolvedPromise = Promise.resolve();
481
+ resolvedPromise.then(() => {
482
+ process.nextTick(fn);
483
+ });
484
+ } : typeof setImmediate === "function" ? function(fn) {
485
+ setImmediate(fn);
486
+ } : function(fn) {
487
+ setTimeout(fn);
488
+ };
489
+ var resolvedPromise;
490
+ function getCurrentBatch(loader) {
491
+ const existingBatch = loader._batch;
492
+ if (existingBatch !== null && !existingBatch.hasDispatched && existingBatch.keys.length < loader._maxBatchSize) return existingBatch;
493
+ const newBatch = {
494
+ hasDispatched: false,
495
+ keys: [],
496
+ callbacks: []
497
+ };
498
+ loader._batch = newBatch;
499
+ loader._batchScheduleFn(() => {
500
+ dispatchBatch(loader, newBatch);
501
+ });
502
+ return newBatch;
503
+ }
504
+ function dispatchBatch(loader, batch) {
505
+ batch.hasDispatched = true;
506
+ if (batch.keys.length === 0) {
507
+ resolveCacheHits(batch);
508
+ return;
509
+ }
510
+ let batchPromise;
511
+ try {
512
+ batchPromise = loader._batchLoadFn(batch.keys);
513
+ } catch (e) {
514
+ return failedDispatch(loader, batch, /* @__PURE__ */ new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function errored synchronously: ${String(e)}.`));
515
+ }
516
+ if (!batchPromise || typeof batchPromise.then !== "function") return failedDispatch(loader, batch, /* @__PURE__ */ new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise: ${String(batchPromise)}.`));
517
+ Promise.resolve(batchPromise).then((values) => {
518
+ if (!isArrayLike(values)) throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array: ${String(values)}.`);
519
+ if (values.length !== batch.keys.length) throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys.
520
+
521
+ Keys:
522
+ ${String(batch.keys)}
523
+
524
+ Values:
525
+ ${String(values)}`);
526
+ resolveCacheHits(batch);
527
+ for (let i = 0; i < batch.callbacks.length; i++) {
528
+ const value = values[i];
529
+ if (value instanceof Error) batch.callbacks[i].reject(value);
530
+ else batch.callbacks[i].resolve(value);
531
+ }
532
+ }).catch((error) => {
533
+ failedDispatch(loader, batch, error);
534
+ });
535
+ }
536
+ function failedDispatch(loader, batch, error) {
537
+ resolveCacheHits(batch);
538
+ for (let i = 0; i < batch.keys.length; i++) {
539
+ loader.clear(batch.keys[i]);
540
+ batch.callbacks[i].reject(error);
541
+ }
542
+ }
543
+ function resolveCacheHits(batch) {
544
+ if (batch.cacheHits) for (let i = 0; i < batch.cacheHits.length; i++) batch.cacheHits[i]();
545
+ }
546
+ function getValidMaxBatchSize(options) {
547
+ if (!(!options || options.batch !== false)) return 1;
548
+ const maxBatchSize = options && options.maxBatchSize;
549
+ if (maxBatchSize === void 0) return Infinity;
550
+ if (typeof maxBatchSize !== "number" || maxBatchSize < 1) throw new TypeError(`maxBatchSize must be a positive number: ${maxBatchSize}`);
551
+ return maxBatchSize;
552
+ }
553
+ function getValidBatchScheduleFn(options) {
554
+ const batchScheduleFn = options && options.batchScheduleFn;
555
+ if (batchScheduleFn === void 0) return enqueuePostPromiseJob;
556
+ if (typeof batchScheduleFn !== "function") throw new TypeError(`batchScheduleFn must be a function: ${batchScheduleFn}`);
557
+ return batchScheduleFn;
558
+ }
559
+ function getValidCacheKeyFn(options) {
560
+ const cacheKeyFn = options && options.cacheKeyFn;
561
+ if (cacheKeyFn === void 0) return (key) => key;
562
+ if (typeof cacheKeyFn !== "function") throw new TypeError(`cacheKeyFn must be a function: ${cacheKeyFn}`);
563
+ return cacheKeyFn;
564
+ }
565
+ function getValidCacheMap(options) {
566
+ if (!(!options || options.cache !== false)) return null;
567
+ const cacheMap = options && options.cacheMap;
568
+ if (cacheMap === void 0) return /* @__PURE__ */ new Map();
569
+ if (cacheMap !== null) {
570
+ const missingFunctions = [
571
+ "get",
572
+ "set",
573
+ "delete",
574
+ "clear"
575
+ ].filter((fnName) => cacheMap && typeof cacheMap[fnName] !== "function");
576
+ if (missingFunctions.length !== 0) throw new TypeError("Custom cacheMap missing methods: " + missingFunctions.join(", "));
577
+ }
578
+ return cacheMap;
579
+ }
580
+ function getValidName(options) {
581
+ if (options && options.name) return options.name;
582
+ return null;
583
+ }
584
+ function isArrayLike(x) {
585
+ return typeof x === "object" && x !== null && "length" in x && typeof x.length === "number" && (x.length === 0 || x.length > 0 && Object.prototype.hasOwnProperty.call(x, x.length - 1));
586
+ }
587
+
588
+ // ../../node_modules/.pnpm/@mysten+bcs@2.0.2/node_modules/@mysten/bcs/dist/uleb.mjs
589
+ function ulebEncode(num) {
590
+ let bigNum = BigInt(num);
591
+ const arr = [];
592
+ let len = 0;
593
+ if (bigNum === 0n) return [0];
594
+ while (bigNum > 0) {
595
+ arr[len] = Number(bigNum & 127n);
596
+ bigNum >>= 7n;
597
+ if (bigNum > 0n) arr[len] |= 128;
598
+ len += 1;
599
+ }
600
+ return arr;
601
+ }
602
+ function ulebDecode(arr) {
603
+ let total = 0n;
604
+ let shift = 0n;
605
+ let len = 0;
606
+ while (true) {
607
+ if (len >= arr.length) throw new Error("ULEB decode error: buffer overflow");
608
+ const byte = arr[len];
609
+ len += 1;
610
+ total += BigInt(byte & 127) << shift;
611
+ if ((byte & 128) === 0) break;
612
+ shift += 7n;
613
+ }
614
+ if (total > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error("ULEB decode error: value exceeds MAX_SAFE_INTEGER");
615
+ return {
616
+ value: Number(total),
617
+ length: len
618
+ };
619
+ }
620
+
621
+ // ../../node_modules/.pnpm/@mysten+bcs@2.0.2/node_modules/@mysten/bcs/dist/reader.mjs
622
+ var BcsReader = class {
623
+ /**
624
+ * @param {Uint8Array} data Data to use as a buffer.
625
+ */
626
+ constructor(data) {
627
+ this.bytePosition = 0;
628
+ this.dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
629
+ }
630
+ /**
631
+ * Shift current cursor position by `bytes`.
632
+ *
633
+ * @param {Number} bytes Number of bytes to
634
+ * @returns {this} Self for possible chaining.
635
+ */
636
+ shift(bytes) {
637
+ this.bytePosition += bytes;
638
+ return this;
639
+ }
640
+ /**
641
+ * Read U8 value from the buffer and shift cursor by 1.
642
+ * @returns
643
+ */
644
+ read8() {
645
+ const value = this.dataView.getUint8(this.bytePosition);
646
+ this.shift(1);
647
+ return value;
648
+ }
649
+ /**
650
+ * Read U16 value from the buffer and shift cursor by 2.
651
+ * @returns
652
+ */
653
+ read16() {
654
+ const value = this.dataView.getUint16(this.bytePosition, true);
655
+ this.shift(2);
656
+ return value;
657
+ }
658
+ /**
659
+ * Read U32 value from the buffer and shift cursor by 4.
660
+ * @returns
661
+ */
662
+ read32() {
663
+ const value = this.dataView.getUint32(this.bytePosition, true);
664
+ this.shift(4);
665
+ return value;
666
+ }
667
+ /**
668
+ * Read U64 value from the buffer and shift cursor by 8.
669
+ * @returns
670
+ */
671
+ read64() {
672
+ const value1 = this.read32();
673
+ const result = this.read32().toString(16) + value1.toString(16).padStart(8, "0");
674
+ return BigInt("0x" + result).toString(10);
675
+ }
676
+ /**
677
+ * Read U128 value from the buffer and shift cursor by 16.
678
+ */
679
+ read128() {
680
+ const value1 = BigInt(this.read64());
681
+ const result = BigInt(this.read64()).toString(16) + value1.toString(16).padStart(16, "0");
682
+ return BigInt("0x" + result).toString(10);
683
+ }
684
+ /**
685
+ * Read U128 value from the buffer and shift cursor by 32.
686
+ * @returns
687
+ */
688
+ read256() {
689
+ const value1 = BigInt(this.read128());
690
+ const result = BigInt(this.read128()).toString(16) + value1.toString(16).padStart(32, "0");
691
+ return BigInt("0x" + result).toString(10);
692
+ }
693
+ /**
694
+ * Read `num` number of bytes from the buffer and shift cursor by `num`.
695
+ * @param num Number of bytes to read.
696
+ */
697
+ readBytes(num) {
698
+ const start = this.bytePosition + this.dataView.byteOffset;
699
+ const value = new Uint8Array(this.dataView.buffer, start, num);
700
+ this.shift(num);
701
+ return value;
702
+ }
703
+ /**
704
+ * Read ULEB value - an integer of varying size. Used for enum indexes and
705
+ * vector lengths.
706
+ * @returns {Number} The ULEB value.
707
+ */
708
+ readULEB() {
709
+ const start = this.bytePosition + this.dataView.byteOffset;
710
+ const { value, length } = ulebDecode(new Uint8Array(this.dataView.buffer, start));
711
+ this.shift(length);
712
+ return value;
713
+ }
714
+ /**
715
+ * Read a BCS vector: read a length and then apply function `cb` X times
716
+ * where X is the length of the vector, defined as ULEB in BCS bytes.
717
+ * @param cb Callback to process elements of vector.
718
+ * @returns {Array<Any>} Array of the resulting values, returned by callback.
719
+ */
720
+ readVec(cb) {
721
+ const length = this.readULEB();
722
+ const result = [];
723
+ for (let i = 0; i < length; i++) result.push(cb(this, i, length));
724
+ return result;
725
+ }
726
+ };
727
+
728
+ // ../../node_modules/.pnpm/@mysten+bcs@2.0.2/node_modules/@mysten/bcs/dist/utils.mjs
729
+ function encodeStr(data, encoding) {
730
+ switch (encoding) {
731
+ case "base58":
732
+ return toBase58(data);
733
+ case "base64":
734
+ return toBase64(data);
735
+ case "hex":
736
+ return toHex(data);
737
+ default:
738
+ throw new Error("Unsupported encoding, supported values are: base64, hex");
739
+ }
740
+ }
741
+ function splitGenericParameters(str, genericSeparators = ["<", ">"]) {
742
+ const [left, right] = genericSeparators;
743
+ const tok = [];
744
+ let word = "";
745
+ let nestedAngleBrackets = 0;
746
+ for (let i = 0; i < str.length; i++) {
747
+ const char = str[i];
748
+ if (char === left) nestedAngleBrackets++;
749
+ if (char === right) nestedAngleBrackets--;
750
+ if (nestedAngleBrackets === 0 && char === ",") {
751
+ tok.push(word.trim());
752
+ word = "";
753
+ continue;
754
+ }
755
+ word += char;
756
+ }
757
+ tok.push(word.trim());
758
+ return tok;
759
+ }
760
+
761
+ // ../../node_modules/.pnpm/@mysten+bcs@2.0.2/node_modules/@mysten/bcs/dist/writer.mjs
762
+ var BcsWriter = class {
763
+ constructor({ initialSize = 1024, maxSize = Infinity, allocateSize = 1024 } = {}) {
764
+ this.bytePosition = 0;
765
+ this.size = initialSize;
766
+ this.maxSize = maxSize;
767
+ this.allocateSize = allocateSize;
768
+ this.dataView = new DataView(new ArrayBuffer(initialSize));
769
+ }
770
+ ensureSizeOrGrow(bytes) {
771
+ const requiredSize = this.bytePosition + bytes;
772
+ if (requiredSize > this.size) {
773
+ const nextSize = Math.min(this.maxSize, Math.max(this.size + requiredSize, this.size + this.allocateSize));
774
+ if (requiredSize > nextSize) throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${requiredSize}`);
775
+ this.size = nextSize;
776
+ const nextBuffer = new ArrayBuffer(this.size);
777
+ new Uint8Array(nextBuffer).set(new Uint8Array(this.dataView.buffer));
778
+ this.dataView = new DataView(nextBuffer);
779
+ }
780
+ }
781
+ /**
782
+ * Shift current cursor position by `bytes`.
783
+ *
784
+ * @param {Number} bytes Number of bytes to
785
+ * @returns {this} Self for possible chaining.
786
+ */
787
+ shift(bytes) {
788
+ this.bytePosition += bytes;
789
+ return this;
790
+ }
791
+ /**
792
+ * Write a U8 value into a buffer and shift cursor position by 1.
793
+ * @param {Number} value Value to write.
794
+ * @returns {this}
795
+ */
796
+ write8(value) {
797
+ this.ensureSizeOrGrow(1);
798
+ this.dataView.setUint8(this.bytePosition, Number(value));
799
+ return this.shift(1);
800
+ }
801
+ /**
802
+ * Write a U8 value into a buffer and shift cursor position by 1.
803
+ * @param {Number} value Value to write.
804
+ * @returns {this}
805
+ */
806
+ writeBytes(bytes) {
807
+ this.ensureSizeOrGrow(bytes.length);
808
+ for (let i = 0; i < bytes.length; i++) this.dataView.setUint8(this.bytePosition + i, bytes[i]);
809
+ return this.shift(bytes.length);
810
+ }
811
+ /**
812
+ * Write a U16 value into a buffer and shift cursor position by 2.
813
+ * @param {Number} value Value to write.
814
+ * @returns {this}
815
+ */
816
+ write16(value) {
817
+ this.ensureSizeOrGrow(2);
818
+ this.dataView.setUint16(this.bytePosition, Number(value), true);
819
+ return this.shift(2);
820
+ }
821
+ /**
822
+ * Write a U32 value into a buffer and shift cursor position by 4.
823
+ * @param {Number} value Value to write.
824
+ * @returns {this}
825
+ */
826
+ write32(value) {
827
+ this.ensureSizeOrGrow(4);
828
+ this.dataView.setUint32(this.bytePosition, Number(value), true);
829
+ return this.shift(4);
830
+ }
831
+ /**
832
+ * Write a U64 value into a buffer and shift cursor position by 8.
833
+ * @param {bigint} value Value to write.
834
+ * @returns {this}
835
+ */
836
+ write64(value) {
837
+ toLittleEndian(BigInt(value), 8).forEach((el) => this.write8(el));
838
+ return this;
839
+ }
840
+ /**
841
+ * Write a U128 value into a buffer and shift cursor position by 16.
842
+ *
843
+ * @param {bigint} value Value to write.
844
+ * @returns {this}
845
+ */
846
+ write128(value) {
847
+ toLittleEndian(BigInt(value), 16).forEach((el) => this.write8(el));
848
+ return this;
849
+ }
850
+ /**
851
+ * Write a U256 value into a buffer and shift cursor position by 16.
852
+ *
853
+ * @param {bigint} value Value to write.
854
+ * @returns {this}
855
+ */
856
+ write256(value) {
857
+ toLittleEndian(BigInt(value), 32).forEach((el) => this.write8(el));
858
+ return this;
859
+ }
860
+ /**
861
+ * Write a ULEB value into a buffer and shift cursor position by number of bytes
862
+ * written.
863
+ * @param {Number} value Value to write.
864
+ * @returns {this}
865
+ */
866
+ writeULEB(value) {
867
+ ulebEncode(value).forEach((el) => this.write8(el));
868
+ return this;
869
+ }
870
+ /**
871
+ * Write a vector into a buffer by first writing the vector length and then calling
872
+ * a callback on each passed value.
873
+ *
874
+ * @param {Array<Any>} vector Array of elements to write.
875
+ * @param {WriteVecCb} cb Callback to call on each element of the vector.
876
+ * @returns {this}
877
+ */
878
+ writeVec(vector2, cb) {
879
+ this.writeULEB(vector2.length);
880
+ Array.from(vector2).forEach((el, i) => cb(this, el, i, vector2.length));
881
+ return this;
882
+ }
883
+ /**
884
+ * Adds support for iterations over the object.
885
+ * @returns {Uint8Array}
886
+ */
887
+ *[Symbol.iterator]() {
888
+ for (let i = 0; i < this.bytePosition; i++) yield this.dataView.getUint8(i);
889
+ return this.toBytes();
890
+ }
891
+ /**
892
+ * Get underlying buffer taking only value bytes (in case initial buffer size was bigger).
893
+ * @returns {Uint8Array} Resulting bcs.
894
+ */
895
+ toBytes() {
896
+ return new Uint8Array(this.dataView.buffer.slice(0, this.bytePosition));
897
+ }
898
+ /**
899
+ * Represent data as 'hex' or 'base64'
900
+ * @param encoding Encoding to use: 'base64' or 'hex'
901
+ */
902
+ toString(encoding) {
903
+ return encodeStr(this.toBytes(), encoding);
904
+ }
905
+ };
906
+ function toLittleEndian(bigint, size) {
907
+ const result = new Uint8Array(size);
908
+ let i = 0;
909
+ while (bigint > 0) {
910
+ result[i] = Number(bigint % BigInt(256));
911
+ bigint = bigint / BigInt(256);
912
+ i += 1;
913
+ }
914
+ return result;
915
+ }
916
+
917
+ // ../../node_modules/.pnpm/@mysten+bcs@2.0.2/node_modules/@mysten/bcs/dist/bcs-type.mjs
918
+ var BcsType = class BcsType2 {
919
+ #write;
920
+ #serialize;
921
+ constructor(options) {
922
+ this.name = options.name;
923
+ this.read = options.read;
924
+ this.serializedSize = options.serializedSize ?? (() => null);
925
+ this.#write = options.write;
926
+ this.#serialize = options.serialize ?? ((value, options$1) => {
927
+ const writer = new BcsWriter({
928
+ initialSize: this.serializedSize(value) ?? void 0,
929
+ ...options$1
930
+ });
931
+ this.#write(value, writer);
932
+ return writer.toBytes();
933
+ });
934
+ this.validate = options.validate ?? (() => {
935
+ });
936
+ }
937
+ write(value, writer) {
938
+ this.validate(value);
939
+ this.#write(value, writer);
940
+ }
941
+ serialize(value, options) {
942
+ this.validate(value);
943
+ return new SerializedBcs(this, this.#serialize(value, options));
944
+ }
945
+ parse(bytes) {
946
+ const reader = new BcsReader(bytes);
947
+ return this.read(reader);
948
+ }
949
+ fromHex(hex) {
950
+ return this.parse(fromHex(hex));
951
+ }
952
+ fromBase58(b64) {
953
+ return this.parse(fromBase58(b64));
954
+ }
955
+ fromBase64(b64) {
956
+ return this.parse(fromBase64(b64));
957
+ }
958
+ transform({ name, input, output, validate }) {
959
+ return new BcsType2({
960
+ name: name ?? this.name,
961
+ read: (reader) => output ? output(this.read(reader)) : this.read(reader),
962
+ write: (value, writer) => this.#write(input ? input(value) : value, writer),
963
+ serializedSize: (value) => this.serializedSize(input ? input(value) : value),
964
+ serialize: (value, options) => this.#serialize(input ? input(value) : value, options),
965
+ validate: (value) => {
966
+ validate?.(value);
967
+ this.validate(input ? input(value) : value);
968
+ }
969
+ });
970
+ }
971
+ };
972
+ var SERIALIZED_BCS_BRAND = /* @__PURE__ */ Symbol.for("@mysten/serialized-bcs");
973
+ function isSerializedBcs(obj) {
974
+ return !!obj && typeof obj === "object" && obj[SERIALIZED_BCS_BRAND] === true;
975
+ }
976
+ var SerializedBcs = class {
977
+ #schema;
978
+ #bytes;
979
+ get [SERIALIZED_BCS_BRAND]() {
980
+ return true;
981
+ }
982
+ constructor(schema, bytes) {
983
+ this.#schema = schema;
984
+ this.#bytes = bytes;
985
+ }
986
+ toBytes() {
987
+ return this.#bytes;
988
+ }
989
+ toHex() {
990
+ return toHex(this.#bytes);
991
+ }
992
+ toBase64() {
993
+ return toBase64(this.#bytes);
994
+ }
995
+ toBase58() {
996
+ return toBase58(this.#bytes);
997
+ }
998
+ parse() {
999
+ return this.#schema.parse(this.#bytes);
1000
+ }
1001
+ };
1002
+ function fixedSizeBcsType({ size, ...options }) {
1003
+ return new BcsType({
1004
+ ...options,
1005
+ serializedSize: () => size
1006
+ });
1007
+ }
1008
+ function uIntBcsType({ readMethod, writeMethod, ...options }) {
1009
+ return fixedSizeBcsType({
1010
+ ...options,
1011
+ read: (reader) => reader[readMethod](),
1012
+ write: (value, writer) => writer[writeMethod](value),
1013
+ validate: (value) => {
1014
+ if (value < 0 || value > options.maxValue) throw new TypeError(`Invalid ${options.name} value: ${value}. Expected value in range 0-${options.maxValue}`);
1015
+ options.validate?.(value);
1016
+ }
1017
+ });
1018
+ }
1019
+ function bigUIntBcsType({ readMethod, writeMethod, ...options }) {
1020
+ return fixedSizeBcsType({
1021
+ ...options,
1022
+ read: (reader) => reader[readMethod](),
1023
+ write: (value, writer) => writer[writeMethod](BigInt(value)),
1024
+ validate: (val) => {
1025
+ const value = BigInt(val);
1026
+ if (value < 0 || value > options.maxValue) throw new TypeError(`Invalid ${options.name} value: ${value}. Expected value in range 0-${options.maxValue}`);
1027
+ options.validate?.(value);
1028
+ }
1029
+ });
1030
+ }
1031
+ function dynamicSizeBcsType({ serialize, ...options }) {
1032
+ const type = new BcsType({
1033
+ ...options,
1034
+ serialize,
1035
+ write: (value, writer) => {
1036
+ for (const byte of type.serialize(value).toBytes()) writer.write8(byte);
1037
+ }
1038
+ });
1039
+ return type;
1040
+ }
1041
+ function stringLikeBcsType({ toBytes, fromBytes, ...options }) {
1042
+ return new BcsType({
1043
+ ...options,
1044
+ read: (reader) => {
1045
+ const length = reader.readULEB();
1046
+ return fromBytes(reader.readBytes(length));
1047
+ },
1048
+ write: (hex, writer) => {
1049
+ const bytes = toBytes(hex);
1050
+ writer.writeULEB(bytes.length);
1051
+ for (let i = 0; i < bytes.length; i++) writer.write8(bytes[i]);
1052
+ },
1053
+ serialize: (value) => {
1054
+ const bytes = toBytes(value);
1055
+ const size = ulebEncode(bytes.length);
1056
+ const result = new Uint8Array(size.length + bytes.length);
1057
+ result.set(size, 0);
1058
+ result.set(bytes, size.length);
1059
+ return result;
1060
+ },
1061
+ validate: (value) => {
1062
+ if (typeof value !== "string") throw new TypeError(`Invalid ${options.name} value: ${value}. Expected string`);
1063
+ options.validate?.(value);
1064
+ }
1065
+ });
1066
+ }
1067
+ function lazyBcsType(cb) {
1068
+ let lazyType = null;
1069
+ function getType() {
1070
+ if (!lazyType) lazyType = cb();
1071
+ return lazyType;
1072
+ }
1073
+ return new BcsType({
1074
+ name: "lazy",
1075
+ read: (data) => getType().read(data),
1076
+ serializedSize: (value) => getType().serializedSize(value),
1077
+ write: (value, writer) => getType().write(value, writer),
1078
+ serialize: (value, options) => getType().serialize(value, options).toBytes()
1079
+ });
1080
+ }
1081
+ var BcsStruct = class extends BcsType {
1082
+ constructor({ name, fields, ...options }) {
1083
+ const canonicalOrder = Object.entries(fields);
1084
+ super({
1085
+ name,
1086
+ serializedSize: (values) => {
1087
+ let total = 0;
1088
+ for (const [field, type] of canonicalOrder) {
1089
+ const size = type.serializedSize(values[field]);
1090
+ if (size == null) return null;
1091
+ total += size;
1092
+ }
1093
+ return total;
1094
+ },
1095
+ read: (reader) => {
1096
+ const result = {};
1097
+ for (const [field, type] of canonicalOrder) result[field] = type.read(reader);
1098
+ return result;
1099
+ },
1100
+ write: (value, writer) => {
1101
+ for (const [field, type] of canonicalOrder) type.write(value[field], writer);
1102
+ },
1103
+ ...options,
1104
+ validate: (value) => {
1105
+ options?.validate?.(value);
1106
+ if (typeof value !== "object" || value == null) throw new TypeError(`Expected object, found ${typeof value}`);
1107
+ }
1108
+ });
1109
+ }
1110
+ };
1111
+ var BcsEnum = class extends BcsType {
1112
+ constructor({ fields, ...options }) {
1113
+ const canonicalOrder = Object.entries(fields);
1114
+ super({
1115
+ read: (reader) => {
1116
+ const index = reader.readULEB();
1117
+ const enumEntry = canonicalOrder[index];
1118
+ if (!enumEntry) throw new TypeError(`Unknown value ${index} for enum ${options.name}`);
1119
+ const [kind, type] = enumEntry;
1120
+ return {
1121
+ [kind]: type?.read(reader) ?? true,
1122
+ $kind: kind
1123
+ };
1124
+ },
1125
+ write: (value, writer) => {
1126
+ const [name, val] = Object.entries(value).filter(([name$1]) => Object.hasOwn(fields, name$1))[0];
1127
+ for (let i = 0; i < canonicalOrder.length; i++) {
1128
+ const [optionName, optionType] = canonicalOrder[i];
1129
+ if (optionName === name) {
1130
+ writer.writeULEB(i);
1131
+ optionType?.write(val, writer);
1132
+ return;
1133
+ }
1134
+ }
1135
+ },
1136
+ ...options,
1137
+ validate: (value) => {
1138
+ options?.validate?.(value);
1139
+ if (typeof value !== "object" || value == null) throw new TypeError(`Expected object, found ${typeof value}`);
1140
+ const keys = Object.keys(value).filter((k) => value[k] !== void 0 && Object.hasOwn(fields, k));
1141
+ if (keys.length !== 1) throw new TypeError(`Expected object with one key, but found ${keys.length} for type ${options.name}}`);
1142
+ const [variant] = keys;
1143
+ if (!Object.hasOwn(fields, variant)) throw new TypeError(`Invalid enum variant ${variant}`);
1144
+ }
1145
+ });
1146
+ }
1147
+ };
1148
+ var BcsTuple = class extends BcsType {
1149
+ constructor({ fields, name, ...options }) {
1150
+ super({
1151
+ name: name ?? `(${fields.map((t) => t.name).join(", ")})`,
1152
+ serializedSize: (values) => {
1153
+ let total = 0;
1154
+ for (let i = 0; i < fields.length; i++) {
1155
+ const size = fields[i].serializedSize(values[i]);
1156
+ if (size == null) return null;
1157
+ total += size;
1158
+ }
1159
+ return total;
1160
+ },
1161
+ read: (reader) => {
1162
+ const result = [];
1163
+ for (const field of fields) result.push(field.read(reader));
1164
+ return result;
1165
+ },
1166
+ write: (value, writer) => {
1167
+ for (let i = 0; i < fields.length; i++) fields[i].write(value[i], writer);
1168
+ },
1169
+ ...options,
1170
+ validate: (value) => {
1171
+ options?.validate?.(value);
1172
+ if (!Array.isArray(value)) throw new TypeError(`Expected array, found ${typeof value}`);
1173
+ if (value.length !== fields.length) throw new TypeError(`Expected array of length ${fields.length}, found ${value.length}`);
1174
+ }
1175
+ });
1176
+ }
1177
+ };
1178
+
1179
+ // ../../node_modules/.pnpm/@mysten+bcs@2.0.2/node_modules/@mysten/bcs/dist/bcs.mjs
1180
+ function fixedArray(size, type, options) {
1181
+ return new BcsType({
1182
+ read: (reader) => {
1183
+ const result = new Array(size);
1184
+ for (let i = 0; i < size; i++) result[i] = type.read(reader);
1185
+ return result;
1186
+ },
1187
+ write: (value, writer) => {
1188
+ for (const item of value) type.write(item, writer);
1189
+ },
1190
+ ...options,
1191
+ name: options?.name ?? `${type.name}[${size}]`,
1192
+ validate: (value) => {
1193
+ options?.validate?.(value);
1194
+ if (!value || typeof value !== "object" || !("length" in value)) throw new TypeError(`Expected array, found ${typeof value}`);
1195
+ if (value.length !== size) throw new TypeError(`Expected array of length ${size}, found ${value.length}`);
1196
+ }
1197
+ });
1198
+ }
1199
+ function option(type) {
1200
+ return bcs.enum(`Option<${type.name}>`, {
1201
+ None: null,
1202
+ Some: type
1203
+ }).transform({
1204
+ input: (value) => {
1205
+ if (value == null) return { None: true };
1206
+ return { Some: value };
1207
+ },
1208
+ output: (value) => {
1209
+ if (value.$kind === "Some") return value.Some;
1210
+ return null;
1211
+ }
1212
+ });
1213
+ }
1214
+ function vector(type, options) {
1215
+ return new BcsType({
1216
+ read: (reader) => {
1217
+ const length = reader.readULEB();
1218
+ const result = new Array(length);
1219
+ for (let i = 0; i < length; i++) result[i] = type.read(reader);
1220
+ return result;
1221
+ },
1222
+ write: (value, writer) => {
1223
+ writer.writeULEB(value.length);
1224
+ for (const item of value) type.write(item, writer);
1225
+ },
1226
+ ...options,
1227
+ name: options?.name ?? `vector<${type.name}>`,
1228
+ validate: (value) => {
1229
+ options?.validate?.(value);
1230
+ if (!value || typeof value !== "object" || !("length" in value)) throw new TypeError(`Expected array, found ${typeof value}`);
1231
+ }
1232
+ });
1233
+ }
1234
+ function compareBcsBytes(a, b) {
1235
+ for (let i = 0; i < Math.min(a.length, b.length); i++) if (a[i] !== b[i]) return a[i] - b[i];
1236
+ return a.length - b.length;
1237
+ }
1238
+ function map(keyType, valueType) {
1239
+ return new BcsType({
1240
+ name: `Map<${keyType.name}, ${valueType.name}>`,
1241
+ read: (reader) => {
1242
+ const length = reader.readULEB();
1243
+ const result = /* @__PURE__ */ new Map();
1244
+ for (let i = 0; i < length; i++) result.set(keyType.read(reader), valueType.read(reader));
1245
+ return result;
1246
+ },
1247
+ write: (value, writer) => {
1248
+ const entries = [...value.entries()].map(([key, val]) => [keyType.serialize(key).toBytes(), val]);
1249
+ entries.sort(([a], [b]) => compareBcsBytes(a, b));
1250
+ writer.writeULEB(entries.length);
1251
+ for (const [keyBytes, val] of entries) {
1252
+ writer.writeBytes(keyBytes);
1253
+ valueType.write(val, writer);
1254
+ }
1255
+ }
1256
+ });
1257
+ }
1258
+ var bcs = {
1259
+ u8(options) {
1260
+ return uIntBcsType({
1261
+ readMethod: "read8",
1262
+ writeMethod: "write8",
1263
+ size: 1,
1264
+ maxValue: 2 ** 8 - 1,
1265
+ ...options,
1266
+ name: options?.name ?? "u8"
1267
+ });
1268
+ },
1269
+ u16(options) {
1270
+ return uIntBcsType({
1271
+ readMethod: "read16",
1272
+ writeMethod: "write16",
1273
+ size: 2,
1274
+ maxValue: 2 ** 16 - 1,
1275
+ ...options,
1276
+ name: options?.name ?? "u16"
1277
+ });
1278
+ },
1279
+ u32(options) {
1280
+ return uIntBcsType({
1281
+ readMethod: "read32",
1282
+ writeMethod: "write32",
1283
+ size: 4,
1284
+ maxValue: 2 ** 32 - 1,
1285
+ ...options,
1286
+ name: options?.name ?? "u32"
1287
+ });
1288
+ },
1289
+ u64(options) {
1290
+ return bigUIntBcsType({
1291
+ readMethod: "read64",
1292
+ writeMethod: "write64",
1293
+ size: 8,
1294
+ maxValue: 2n ** 64n - 1n,
1295
+ ...options,
1296
+ name: options?.name ?? "u64"
1297
+ });
1298
+ },
1299
+ u128(options) {
1300
+ return bigUIntBcsType({
1301
+ readMethod: "read128",
1302
+ writeMethod: "write128",
1303
+ size: 16,
1304
+ maxValue: 2n ** 128n - 1n,
1305
+ ...options,
1306
+ name: options?.name ?? "u128"
1307
+ });
1308
+ },
1309
+ u256(options) {
1310
+ return bigUIntBcsType({
1311
+ readMethod: "read256",
1312
+ writeMethod: "write256",
1313
+ size: 32,
1314
+ maxValue: 2n ** 256n - 1n,
1315
+ ...options,
1316
+ name: options?.name ?? "u256"
1317
+ });
1318
+ },
1319
+ bool(options) {
1320
+ return fixedSizeBcsType({
1321
+ size: 1,
1322
+ read: (reader) => reader.read8() === 1,
1323
+ write: (value, writer) => writer.write8(value ? 1 : 0),
1324
+ ...options,
1325
+ name: options?.name ?? "bool",
1326
+ validate: (value) => {
1327
+ options?.validate?.(value);
1328
+ if (typeof value !== "boolean") throw new TypeError(`Expected boolean, found ${typeof value}`);
1329
+ }
1330
+ });
1331
+ },
1332
+ uleb128(options) {
1333
+ return dynamicSizeBcsType({
1334
+ read: (reader) => reader.readULEB(),
1335
+ serialize: (value) => {
1336
+ return Uint8Array.from(ulebEncode(value));
1337
+ },
1338
+ ...options,
1339
+ name: options?.name ?? "uleb128"
1340
+ });
1341
+ },
1342
+ bytes(size, options) {
1343
+ return fixedSizeBcsType({
1344
+ size,
1345
+ read: (reader) => reader.readBytes(size),
1346
+ write: (value, writer) => {
1347
+ writer.writeBytes(new Uint8Array(value));
1348
+ },
1349
+ ...options,
1350
+ name: options?.name ?? `bytes[${size}]`,
1351
+ validate: (value) => {
1352
+ options?.validate?.(value);
1353
+ if (!value || typeof value !== "object" || !("length" in value)) throw new TypeError(`Expected array, found ${typeof value}`);
1354
+ if (value.length !== size) throw new TypeError(`Expected array of length ${size}, found ${value.length}`);
1355
+ }
1356
+ });
1357
+ },
1358
+ byteVector(options) {
1359
+ return new BcsType({
1360
+ read: (reader) => {
1361
+ const length = reader.readULEB();
1362
+ return reader.readBytes(length);
1363
+ },
1364
+ write: (value, writer) => {
1365
+ const array = new Uint8Array(value);
1366
+ writer.writeULEB(array.length);
1367
+ writer.writeBytes(array);
1368
+ },
1369
+ ...options,
1370
+ name: options?.name ?? "vector<u8>",
1371
+ serializedSize: (value) => {
1372
+ const length = "length" in value ? value.length : null;
1373
+ return length == null ? null : ulebEncode(length).length + length;
1374
+ },
1375
+ validate: (value) => {
1376
+ options?.validate?.(value);
1377
+ if (!value || typeof value !== "object" || !("length" in value)) throw new TypeError(`Expected array, found ${typeof value}`);
1378
+ }
1379
+ });
1380
+ },
1381
+ string(options) {
1382
+ return stringLikeBcsType({
1383
+ toBytes: (value) => new TextEncoder().encode(value),
1384
+ fromBytes: (bytes) => new TextDecoder().decode(bytes),
1385
+ ...options,
1386
+ name: options?.name ?? "string"
1387
+ });
1388
+ },
1389
+ fixedArray,
1390
+ option,
1391
+ vector,
1392
+ tuple(fields, options) {
1393
+ return new BcsTuple({
1394
+ fields,
1395
+ ...options
1396
+ });
1397
+ },
1398
+ struct(name, fields, options) {
1399
+ return new BcsStruct({
1400
+ name,
1401
+ fields,
1402
+ ...options
1403
+ });
1404
+ },
1405
+ enum(name, fields, options) {
1406
+ return new BcsEnum({
1407
+ name,
1408
+ fields,
1409
+ ...options
1410
+ });
1411
+ },
1412
+ map,
1413
+ lazy(cb) {
1414
+ return lazyBcsType(cb);
1415
+ }
1416
+ };
1417
+
1418
+ // ../../node_modules/.pnpm/@mysten+sui@2.6.0_typescript@5.9.3/node_modules/@mysten/sui/dist/utils/suins.mjs
1419
+ var SUI_NS_NAME_REGEX = /^(?!.*(^(?!@)|[-.@])($|[-.@]))(?:[a-z0-9-]{0,63}(?:\.[a-z0-9-]{0,63})*)?@[a-z0-9-]{0,63}$/i;
1420
+ var SUI_NS_DOMAIN_REGEX = /^(?!.*(^|[-.])($|[-.]))(?:[a-z0-9-]{0,63}\.)+sui$/i;
1421
+ var MAX_SUI_NS_NAME_LENGTH = 235;
1422
+ function isValidSuiNSName(name) {
1423
+ if (name.length > MAX_SUI_NS_NAME_LENGTH) return false;
1424
+ if (name.includes("@")) return SUI_NS_NAME_REGEX.test(name);
1425
+ return SUI_NS_DOMAIN_REGEX.test(name);
1426
+ }
1427
+ function normalizeSuiNSName(name, format = "at") {
1428
+ const lowerCase = name.toLowerCase();
1429
+ let parts;
1430
+ if (lowerCase.includes("@")) {
1431
+ if (!SUI_NS_NAME_REGEX.test(lowerCase)) throw new Error(`Invalid SuiNS name ${name}`);
1432
+ const [labels, domain] = lowerCase.split("@");
1433
+ parts = [...labels ? labels.split(".") : [], domain];
1434
+ } else {
1435
+ if (!SUI_NS_DOMAIN_REGEX.test(lowerCase)) throw new Error(`Invalid SuiNS name ${name}`);
1436
+ parts = lowerCase.split(".").slice(0, -1);
1437
+ }
1438
+ if (format === "dot") return `${parts.join(".")}.sui`;
1439
+ return `${parts.slice(0, -1).join(".")}@${parts[parts.length - 1]}`;
1440
+ }
1441
+
1442
+ // ../../node_modules/.pnpm/@mysten+sui@2.6.0_typescript@5.9.3/node_modules/@mysten/sui/dist/utils/move-registry.mjs
1443
+ var NAME_PATTERN = /^([a-z0-9]+(?:-[a-z0-9]+)*)$/;
1444
+ var VERSION_REGEX = /^\d+$/;
1445
+ var MAX_APP_SIZE = 64;
1446
+ var NAME_SEPARATOR = "/";
1447
+ var isValidNamedPackage = (name) => {
1448
+ const parts = name.split(NAME_SEPARATOR);
1449
+ if (parts.length < 2 || parts.length > 3) return false;
1450
+ const [org, app, version] = parts;
1451
+ if (version !== void 0 && !VERSION_REGEX.test(version)) return false;
1452
+ if (!isValidSuiNSName(org)) return false;
1453
+ return NAME_PATTERN.test(app) && app.length < MAX_APP_SIZE;
1454
+ };
1455
+ var isValidNamedType = (type) => {
1456
+ const splitType = type.split(/::|<|>|,/);
1457
+ for (const t of splitType) if (t.includes(NAME_SEPARATOR) && !isValidNamedPackage(t)) return false;
1458
+ return isValidStructTag(type);
1459
+ };
1460
+
1461
+ // ../../node_modules/.pnpm/@mysten+sui@2.6.0_typescript@5.9.3/node_modules/@mysten/sui/dist/utils/sui-types.mjs
1462
+ var TX_DIGEST_LENGTH = 32;
1463
+ function isValidTransactionDigest(value) {
1464
+ try {
1465
+ return fromBase58(value).length === TX_DIGEST_LENGTH;
1466
+ } catch {
1467
+ return false;
1468
+ }
1469
+ }
1470
+ var SUI_ADDRESS_LENGTH = 32;
1471
+ function isValidSuiAddress(value) {
1472
+ return isHex(value) && getHexByteLength(value) === SUI_ADDRESS_LENGTH;
1473
+ }
1474
+ function isValidSuiObjectId(value) {
1475
+ return isValidSuiAddress(value);
1476
+ }
1477
+ var MOVE_IDENTIFIER_REGEX = /^[a-zA-Z][a-zA-Z0-9_]*$/;
1478
+ function isValidMoveIdentifier(name) {
1479
+ return MOVE_IDENTIFIER_REGEX.test(name);
1480
+ }
1481
+ var PRIMITIVE_TYPE_TAGS = [
1482
+ "bool",
1483
+ "u8",
1484
+ "u16",
1485
+ "u32",
1486
+ "u64",
1487
+ "u128",
1488
+ "u256",
1489
+ "address",
1490
+ "signer"
1491
+ ];
1492
+ var VECTOR_TYPE_REGEX = /^vector<(.+)>$/;
1493
+ function isValidTypeTag(type) {
1494
+ if (PRIMITIVE_TYPE_TAGS.includes(type)) return true;
1495
+ const vectorMatch = type.match(VECTOR_TYPE_REGEX);
1496
+ if (vectorMatch) return isValidTypeTag(vectorMatch[1]);
1497
+ if (type.includes("::")) return isValidStructTag(type);
1498
+ return false;
1499
+ }
1500
+ function isValidParsedStructTag(tag) {
1501
+ if (!isValidSuiAddress(tag.address) && !isValidNamedPackage(tag.address)) return false;
1502
+ if (!isValidMoveIdentifier(tag.module) || !isValidMoveIdentifier(tag.name)) return false;
1503
+ return tag.typeParams.every((param) => {
1504
+ if (typeof param === "string") return isValidTypeTag(param);
1505
+ return isValidParsedStructTag(param);
1506
+ });
1507
+ }
1508
+ function isValidStructTag(type) {
1509
+ try {
1510
+ return isValidParsedStructTag(parseStructTag(type));
1511
+ } catch {
1512
+ return false;
1513
+ }
1514
+ }
1515
+ function parseTypeTag(type) {
1516
+ if (type.startsWith("vector<")) {
1517
+ if (!type.endsWith(">")) throw new Error(`Invalid type tag: ${type}`);
1518
+ const inner = type.slice(7, -1);
1519
+ if (!inner) throw new Error(`Invalid type tag: ${type}`);
1520
+ const parsed = parseTypeTag(inner);
1521
+ if (typeof parsed === "string") return `vector<${parsed}>`;
1522
+ return `vector<${normalizeStructTag(parsed)}>`;
1523
+ }
1524
+ if (!type.includes("::")) return type;
1525
+ return parseStructTag(type);
1526
+ }
1527
+ function parseStructTag(type) {
1528
+ const parts = type.split("::");
1529
+ if (parts.length < 3) throw new Error(`Invalid struct tag: ${type}`);
1530
+ const [address, module] = parts;
1531
+ const isMvrPackage = isValidNamedPackage(address);
1532
+ const rest = type.slice(address.length + module.length + 4);
1533
+ const name = rest.includes("<") ? rest.slice(0, rest.indexOf("<")) : rest;
1534
+ const typeParams = rest.includes("<") ? splitGenericParameters(rest.slice(rest.indexOf("<") + 1, rest.lastIndexOf(">"))).map((typeParam) => parseTypeTag(typeParam.trim())) : [];
1535
+ return {
1536
+ address: isMvrPackage ? address : normalizeSuiAddress(address),
1537
+ module,
1538
+ name,
1539
+ typeParams
1540
+ };
1541
+ }
1542
+ function normalizeStructTag(type) {
1543
+ const { address, module, name, typeParams } = typeof type === "string" ? parseStructTag(type) : type;
1544
+ return `${address}::${module}::${name}${typeParams?.length > 0 ? `<${typeParams.map((typeParam) => typeof typeParam === "string" ? typeParam : normalizeStructTag(typeParam)).join(",")}>` : ""}`;
1545
+ }
1546
+ function normalizeSuiAddress(value, forceAdd0x = false) {
1547
+ let address = value.toLowerCase();
1548
+ if (!forceAdd0x && address.startsWith("0x")) address = address.slice(2);
1549
+ return `0x${address.padStart(SUI_ADDRESS_LENGTH * 2, "0")}`;
1550
+ }
1551
+ function normalizeSuiObjectId(value, forceAdd0x = false) {
1552
+ return normalizeSuiAddress(value, forceAdd0x);
1553
+ }
1554
+ function isHex(value) {
1555
+ return /^(0x|0X)?[a-fA-F0-9]+$/.test(value) && value.length % 2 === 0;
1556
+ }
1557
+ function getHexByteLength(value) {
1558
+ return /^(0x|0X)/.test(value) ? (value.length - 2) / 2 : value.length / 2;
1559
+ }
1560
+
1561
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/utils.js
1562
+ function isBytes2(a) {
1563
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
1564
+ }
1565
+ function anumber2(n, title = "") {
1566
+ if (!Number.isSafeInteger(n) || n < 0) {
1567
+ const prefix = title && `"${title}" `;
1568
+ throw new Error(`${prefix}expected integer >= 0, got ${n}`);
1569
+ }
1570
+ }
1571
+ function abytes(value, length, title = "") {
1572
+ const bytes = isBytes2(value);
1573
+ const len = value?.length;
1574
+ const needsLen = length !== void 0;
1575
+ if (!bytes || needsLen && len !== length) {
1576
+ const prefix = title && `"${title}" `;
1577
+ const ofLen = needsLen ? ` of length ${length}` : "";
1578
+ const got = bytes ? `length=${len}` : `type=${typeof value}`;
1579
+ throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
1580
+ }
1581
+ return value;
1582
+ }
1583
+ function ahash(h) {
1584
+ if (typeof h !== "function" || typeof h.create !== "function")
1585
+ throw new Error("Hash must wrapped by utils.createHasher");
1586
+ anumber2(h.outputLen);
1587
+ anumber2(h.blockLen);
1588
+ }
1589
+ function aexists(instance, checkFinished = true) {
1590
+ if (instance.destroyed)
1591
+ throw new Error("Hash instance has been destroyed");
1592
+ if (checkFinished && instance.finished)
1593
+ throw new Error("Hash#digest() has already been called");
1594
+ }
1595
+ function aoutput(out, instance) {
1596
+ abytes(out, void 0, "digestInto() output");
1597
+ const min = instance.outputLen;
1598
+ if (out.length < min) {
1599
+ throw new Error('"digestInto() output" expected to be of length >=' + min);
1600
+ }
1601
+ }
1602
+ function u32(arr) {
1603
+ return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
1604
+ }
1605
+ function clean(...arrays) {
1606
+ for (let i = 0; i < arrays.length; i++) {
1607
+ arrays[i].fill(0);
1608
+ }
1609
+ }
1610
+ function createView(arr) {
1611
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
1612
+ }
1613
+ var isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
1614
+ function byteSwap(word) {
1615
+ return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
1616
+ }
1617
+ var swap8IfBE = isLE ? (n) => n : (n) => byteSwap(n);
1618
+ function byteSwap32(arr) {
1619
+ for (let i = 0; i < arr.length; i++) {
1620
+ arr[i] = byteSwap(arr[i]);
1621
+ }
1622
+ return arr;
1623
+ }
1624
+ var swap32IfBE = isLE ? (u) => u : byteSwap32;
1625
+ var hasHexBuiltin = /* @__PURE__ */ (() => (
1626
+ // @ts-ignore
1627
+ typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function"
1628
+ ))();
1629
+ var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
1630
+ function bytesToHex(bytes) {
1631
+ abytes(bytes);
1632
+ if (hasHexBuiltin)
1633
+ return bytes.toHex();
1634
+ let hex = "";
1635
+ for (let i = 0; i < bytes.length; i++) {
1636
+ hex += hexes[bytes[i]];
1637
+ }
1638
+ return hex;
1639
+ }
1640
+ var asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
1641
+ function asciiToBase16(ch) {
1642
+ if (ch >= asciis._0 && ch <= asciis._9)
1643
+ return ch - asciis._0;
1644
+ if (ch >= asciis.A && ch <= asciis.F)
1645
+ return ch - (asciis.A - 10);
1646
+ if (ch >= asciis.a && ch <= asciis.f)
1647
+ return ch - (asciis.a - 10);
1648
+ return;
1649
+ }
1650
+ function hexToBytes(hex) {
1651
+ if (typeof hex !== "string")
1652
+ throw new Error("hex string expected, got " + typeof hex);
1653
+ if (hasHexBuiltin)
1654
+ return Uint8Array.fromHex(hex);
1655
+ const hl = hex.length;
1656
+ const al = hl / 2;
1657
+ if (hl % 2)
1658
+ throw new Error("hex string expected, got unpadded hex of length " + hl);
1659
+ const array = new Uint8Array(al);
1660
+ for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
1661
+ const n1 = asciiToBase16(hex.charCodeAt(hi));
1662
+ const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
1663
+ if (n1 === void 0 || n2 === void 0) {
1664
+ const char = hex[hi] + hex[hi + 1];
1665
+ throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
1666
+ }
1667
+ array[ai] = n1 * 16 + n2;
1668
+ }
1669
+ return array;
1670
+ }
1671
+ function utf8ToBytes(str) {
1672
+ if (typeof str !== "string")
1673
+ throw new Error("string expected");
1674
+ return new Uint8Array(new TextEncoder().encode(str));
1675
+ }
1676
+ function kdfInputToBytes(data, errorTitle = "") {
1677
+ if (typeof data === "string")
1678
+ return utf8ToBytes(data);
1679
+ return abytes(data, void 0, errorTitle);
1680
+ }
1681
+ function concatBytes(...arrays) {
1682
+ let sum = 0;
1683
+ for (let i = 0; i < arrays.length; i++) {
1684
+ const a = arrays[i];
1685
+ abytes(a);
1686
+ sum += a.length;
1687
+ }
1688
+ const res = new Uint8Array(sum);
1689
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
1690
+ const a = arrays[i];
1691
+ res.set(a, pad);
1692
+ pad += a.length;
1693
+ }
1694
+ return res;
1695
+ }
1696
+ function checkOpts(defaults, opts) {
1697
+ if (opts !== void 0 && {}.toString.call(opts) !== "[object Object]")
1698
+ throw new Error("options must be object or undefined");
1699
+ const merged = Object.assign(defaults, opts);
1700
+ return merged;
1701
+ }
1702
+ function createHasher(hashCons, info = {}) {
1703
+ const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
1704
+ const tmp = hashCons(void 0);
1705
+ hashC.outputLen = tmp.outputLen;
1706
+ hashC.blockLen = tmp.blockLen;
1707
+ hashC.create = (opts) => hashCons(opts);
1708
+ Object.assign(hashC, info);
1709
+ return Object.freeze(hashC);
1710
+ }
1711
+ function randomBytes(bytesLength = 32) {
1712
+ const cr = typeof globalThis === "object" ? globalThis.crypto : null;
1713
+ if (typeof cr?.getRandomValues !== "function")
1714
+ throw new Error("crypto.getRandomValues must be defined");
1715
+ return cr.getRandomValues(new Uint8Array(bytesLength));
1716
+ }
1717
+ var oidNist = (suffix) => ({
1718
+ oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
1719
+ });
1720
+
1721
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/_blake.js
1722
+ var BSIGMA = /* @__PURE__ */ Uint8Array.from([
1723
+ 0,
1724
+ 1,
1725
+ 2,
1726
+ 3,
1727
+ 4,
1728
+ 5,
1729
+ 6,
1730
+ 7,
1731
+ 8,
1732
+ 9,
1733
+ 10,
1734
+ 11,
1735
+ 12,
1736
+ 13,
1737
+ 14,
1738
+ 15,
1739
+ 14,
1740
+ 10,
1741
+ 4,
1742
+ 8,
1743
+ 9,
1744
+ 15,
1745
+ 13,
1746
+ 6,
1747
+ 1,
1748
+ 12,
1749
+ 0,
1750
+ 2,
1751
+ 11,
1752
+ 7,
1753
+ 5,
1754
+ 3,
1755
+ 11,
1756
+ 8,
1757
+ 12,
1758
+ 0,
1759
+ 5,
1760
+ 2,
1761
+ 15,
1762
+ 13,
1763
+ 10,
1764
+ 14,
1765
+ 3,
1766
+ 6,
1767
+ 7,
1768
+ 1,
1769
+ 9,
1770
+ 4,
1771
+ 7,
1772
+ 9,
1773
+ 3,
1774
+ 1,
1775
+ 13,
1776
+ 12,
1777
+ 11,
1778
+ 14,
1779
+ 2,
1780
+ 6,
1781
+ 5,
1782
+ 10,
1783
+ 4,
1784
+ 0,
1785
+ 15,
1786
+ 8,
1787
+ 9,
1788
+ 0,
1789
+ 5,
1790
+ 7,
1791
+ 2,
1792
+ 4,
1793
+ 10,
1794
+ 15,
1795
+ 14,
1796
+ 1,
1797
+ 11,
1798
+ 12,
1799
+ 6,
1800
+ 8,
1801
+ 3,
1802
+ 13,
1803
+ 2,
1804
+ 12,
1805
+ 6,
1806
+ 10,
1807
+ 0,
1808
+ 11,
1809
+ 8,
1810
+ 3,
1811
+ 4,
1812
+ 13,
1813
+ 7,
1814
+ 5,
1815
+ 15,
1816
+ 14,
1817
+ 1,
1818
+ 9,
1819
+ 12,
1820
+ 5,
1821
+ 1,
1822
+ 15,
1823
+ 14,
1824
+ 13,
1825
+ 4,
1826
+ 10,
1827
+ 0,
1828
+ 7,
1829
+ 6,
1830
+ 3,
1831
+ 9,
1832
+ 2,
1833
+ 8,
1834
+ 11,
1835
+ 13,
1836
+ 11,
1837
+ 7,
1838
+ 14,
1839
+ 12,
1840
+ 1,
1841
+ 3,
1842
+ 9,
1843
+ 5,
1844
+ 0,
1845
+ 15,
1846
+ 4,
1847
+ 8,
1848
+ 6,
1849
+ 2,
1850
+ 10,
1851
+ 6,
1852
+ 15,
1853
+ 14,
1854
+ 9,
1855
+ 11,
1856
+ 3,
1857
+ 0,
1858
+ 8,
1859
+ 12,
1860
+ 2,
1861
+ 13,
1862
+ 7,
1863
+ 1,
1864
+ 4,
1865
+ 10,
1866
+ 5,
1867
+ 10,
1868
+ 2,
1869
+ 8,
1870
+ 4,
1871
+ 7,
1872
+ 6,
1873
+ 1,
1874
+ 5,
1875
+ 15,
1876
+ 11,
1877
+ 9,
1878
+ 14,
1879
+ 3,
1880
+ 12,
1881
+ 13,
1882
+ 0,
1883
+ 0,
1884
+ 1,
1885
+ 2,
1886
+ 3,
1887
+ 4,
1888
+ 5,
1889
+ 6,
1890
+ 7,
1891
+ 8,
1892
+ 9,
1893
+ 10,
1894
+ 11,
1895
+ 12,
1896
+ 13,
1897
+ 14,
1898
+ 15,
1899
+ 14,
1900
+ 10,
1901
+ 4,
1902
+ 8,
1903
+ 9,
1904
+ 15,
1905
+ 13,
1906
+ 6,
1907
+ 1,
1908
+ 12,
1909
+ 0,
1910
+ 2,
1911
+ 11,
1912
+ 7,
1913
+ 5,
1914
+ 3,
1915
+ // Blake1, unused in others
1916
+ 11,
1917
+ 8,
1918
+ 12,
1919
+ 0,
1920
+ 5,
1921
+ 2,
1922
+ 15,
1923
+ 13,
1924
+ 10,
1925
+ 14,
1926
+ 3,
1927
+ 6,
1928
+ 7,
1929
+ 1,
1930
+ 9,
1931
+ 4,
1932
+ 7,
1933
+ 9,
1934
+ 3,
1935
+ 1,
1936
+ 13,
1937
+ 12,
1938
+ 11,
1939
+ 14,
1940
+ 2,
1941
+ 6,
1942
+ 5,
1943
+ 10,
1944
+ 4,
1945
+ 0,
1946
+ 15,
1947
+ 8,
1948
+ 9,
1949
+ 0,
1950
+ 5,
1951
+ 7,
1952
+ 2,
1953
+ 4,
1954
+ 10,
1955
+ 15,
1956
+ 14,
1957
+ 1,
1958
+ 11,
1959
+ 12,
1960
+ 6,
1961
+ 8,
1962
+ 3,
1963
+ 13,
1964
+ 2,
1965
+ 12,
1966
+ 6,
1967
+ 10,
1968
+ 0,
1969
+ 11,
1970
+ 8,
1971
+ 3,
1972
+ 4,
1973
+ 13,
1974
+ 7,
1975
+ 5,
1976
+ 15,
1977
+ 14,
1978
+ 1,
1979
+ 9
1980
+ ]);
1981
+
1982
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/_md.js
1983
+ var HashMD = class {
1984
+ blockLen;
1985
+ outputLen;
1986
+ padOffset;
1987
+ isLE;
1988
+ // For partial updates less than block size
1989
+ buffer;
1990
+ view;
1991
+ finished = false;
1992
+ length = 0;
1993
+ pos = 0;
1994
+ destroyed = false;
1995
+ constructor(blockLen, outputLen, padOffset, isLE2) {
1996
+ this.blockLen = blockLen;
1997
+ this.outputLen = outputLen;
1998
+ this.padOffset = padOffset;
1999
+ this.isLE = isLE2;
2000
+ this.buffer = new Uint8Array(blockLen);
2001
+ this.view = createView(this.buffer);
2002
+ }
2003
+ update(data) {
2004
+ aexists(this);
2005
+ abytes(data);
2006
+ const { view, buffer, blockLen } = this;
2007
+ const len = data.length;
2008
+ for (let pos = 0; pos < len; ) {
2009
+ const take = Math.min(blockLen - this.pos, len - pos);
2010
+ if (take === blockLen) {
2011
+ const dataView = createView(data);
2012
+ for (; blockLen <= len - pos; pos += blockLen)
2013
+ this.process(dataView, pos);
2014
+ continue;
2015
+ }
2016
+ buffer.set(data.subarray(pos, pos + take), this.pos);
2017
+ this.pos += take;
2018
+ pos += take;
2019
+ if (this.pos === blockLen) {
2020
+ this.process(view, 0);
2021
+ this.pos = 0;
2022
+ }
2023
+ }
2024
+ this.length += data.length;
2025
+ this.roundClean();
2026
+ return this;
2027
+ }
2028
+ digestInto(out) {
2029
+ aexists(this);
2030
+ aoutput(out, this);
2031
+ this.finished = true;
2032
+ const { buffer, view, blockLen, isLE: isLE2 } = this;
2033
+ let { pos } = this;
2034
+ buffer[pos++] = 128;
2035
+ clean(this.buffer.subarray(pos));
2036
+ if (this.padOffset > blockLen - pos) {
2037
+ this.process(view, 0);
2038
+ pos = 0;
2039
+ }
2040
+ for (let i = pos; i < blockLen; i++)
2041
+ buffer[i] = 0;
2042
+ view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE2);
2043
+ this.process(view, 0);
2044
+ const oview = createView(out);
2045
+ const len = this.outputLen;
2046
+ if (len % 4)
2047
+ throw new Error("_sha2: outputLen must be aligned to 32bit");
2048
+ const outLen = len / 4;
2049
+ const state = this.get();
2050
+ if (outLen > state.length)
2051
+ throw new Error("_sha2: outputLen bigger than state");
2052
+ for (let i = 0; i < outLen; i++)
2053
+ oview.setUint32(4 * i, state[i], isLE2);
2054
+ }
2055
+ digest() {
2056
+ const { buffer, outputLen } = this;
2057
+ this.digestInto(buffer);
2058
+ const res = buffer.slice(0, outputLen);
2059
+ this.destroy();
2060
+ return res;
2061
+ }
2062
+ _cloneInto(to) {
2063
+ to ||= new this.constructor();
2064
+ to.set(...this.get());
2065
+ const { blockLen, buffer, length, finished, destroyed, pos } = this;
2066
+ to.destroyed = destroyed;
2067
+ to.finished = finished;
2068
+ to.length = length;
2069
+ to.pos = pos;
2070
+ if (length % blockLen)
2071
+ to.buffer.set(buffer);
2072
+ return to;
2073
+ }
2074
+ clone() {
2075
+ return this._cloneInto();
2076
+ }
2077
+ };
2078
+ var SHA512_IV = /* @__PURE__ */ Uint32Array.from([
2079
+ 1779033703,
2080
+ 4089235720,
2081
+ 3144134277,
2082
+ 2227873595,
2083
+ 1013904242,
2084
+ 4271175723,
2085
+ 2773480762,
2086
+ 1595750129,
2087
+ 1359893119,
2088
+ 2917565137,
2089
+ 2600822924,
2090
+ 725511199,
2091
+ 528734635,
2092
+ 4215389547,
2093
+ 1541459225,
2094
+ 327033209
2095
+ ]);
2096
+
2097
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/_u64.js
2098
+ var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
2099
+ var _32n = /* @__PURE__ */ BigInt(32);
2100
+ function fromBig(n, le = false) {
2101
+ if (le)
2102
+ return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
2103
+ return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
2104
+ }
2105
+ function split(lst, le = false) {
2106
+ const len = lst.length;
2107
+ let Ah = new Uint32Array(len);
2108
+ let Al = new Uint32Array(len);
2109
+ for (let i = 0; i < len; i++) {
2110
+ const { h, l } = fromBig(lst[i], le);
2111
+ [Ah[i], Al[i]] = [h, l];
2112
+ }
2113
+ return [Ah, Al];
2114
+ }
2115
+ var shrSH = (h, _l, s) => h >>> s;
2116
+ var shrSL = (h, l, s) => h << 32 - s | l >>> s;
2117
+ var rotrSH = (h, l, s) => h >>> s | l << 32 - s;
2118
+ var rotrSL = (h, l, s) => h << 32 - s | l >>> s;
2119
+ var rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
2120
+ var rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
2121
+ var rotr32H = (_h, l) => l;
2122
+ var rotr32L = (h, _l) => h;
2123
+ function add(Ah, Al, Bh, Bl) {
2124
+ const l = (Al >>> 0) + (Bl >>> 0);
2125
+ return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
2126
+ }
2127
+ var add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
2128
+ var add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
2129
+ var add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
2130
+ var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
2131
+ var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
2132
+ var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
2133
+
2134
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/blake2.js
2135
+ var B2B_IV = /* @__PURE__ */ Uint32Array.from([
2136
+ 4089235720,
2137
+ 1779033703,
2138
+ 2227873595,
2139
+ 3144134277,
2140
+ 4271175723,
2141
+ 1013904242,
2142
+ 1595750129,
2143
+ 2773480762,
2144
+ 2917565137,
2145
+ 1359893119,
2146
+ 725511199,
2147
+ 2600822924,
2148
+ 4215389547,
2149
+ 528734635,
2150
+ 327033209,
2151
+ 1541459225
2152
+ ]);
2153
+ var BBUF = /* @__PURE__ */ new Uint32Array(32);
2154
+ function G1b(a, b, c, d, msg, x) {
2155
+ const Xl = msg[x], Xh = msg[x + 1];
2156
+ let Al = BBUF[2 * a], Ah = BBUF[2 * a + 1];
2157
+ let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1];
2158
+ let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1];
2159
+ let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1];
2160
+ let ll = add3L(Al, Bl, Xl);
2161
+ Ah = add3H(ll, Ah, Bh, Xh);
2162
+ Al = ll | 0;
2163
+ ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al });
2164
+ ({ Dh, Dl } = { Dh: rotr32H(Dh, Dl), Dl: rotr32L(Dh, Dl) });
2165
+ ({ h: Ch, l: Cl } = add(Ch, Cl, Dh, Dl));
2166
+ ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl });
2167
+ ({ Bh, Bl } = { Bh: rotrSH(Bh, Bl, 24), Bl: rotrSL(Bh, Bl, 24) });
2168
+ BBUF[2 * a] = Al, BBUF[2 * a + 1] = Ah;
2169
+ BBUF[2 * b] = Bl, BBUF[2 * b + 1] = Bh;
2170
+ BBUF[2 * c] = Cl, BBUF[2 * c + 1] = Ch;
2171
+ BBUF[2 * d] = Dl, BBUF[2 * d + 1] = Dh;
2172
+ }
2173
+ function G2b(a, b, c, d, msg, x) {
2174
+ const Xl = msg[x], Xh = msg[x + 1];
2175
+ let Al = BBUF[2 * a], Ah = BBUF[2 * a + 1];
2176
+ let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1];
2177
+ let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1];
2178
+ let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1];
2179
+ let ll = add3L(Al, Bl, Xl);
2180
+ Ah = add3H(ll, Ah, Bh, Xh);
2181
+ Al = ll | 0;
2182
+ ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al });
2183
+ ({ Dh, Dl } = { Dh: rotrSH(Dh, Dl, 16), Dl: rotrSL(Dh, Dl, 16) });
2184
+ ({ h: Ch, l: Cl } = add(Ch, Cl, Dh, Dl));
2185
+ ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl });
2186
+ ({ Bh, Bl } = { Bh: rotrBH(Bh, Bl, 63), Bl: rotrBL(Bh, Bl, 63) });
2187
+ BBUF[2 * a] = Al, BBUF[2 * a + 1] = Ah;
2188
+ BBUF[2 * b] = Bl, BBUF[2 * b + 1] = Bh;
2189
+ BBUF[2 * c] = Cl, BBUF[2 * c + 1] = Ch;
2190
+ BBUF[2 * d] = Dl, BBUF[2 * d + 1] = Dh;
2191
+ }
2192
+ function checkBlake2Opts(outputLen, opts = {}, keyLen, saltLen, persLen) {
2193
+ anumber2(keyLen);
2194
+ if (outputLen < 0 || outputLen > keyLen)
2195
+ throw new Error("outputLen bigger than keyLen");
2196
+ const { key, salt, personalization } = opts;
2197
+ if (key !== void 0 && (key.length < 1 || key.length > keyLen))
2198
+ throw new Error('"key" expected to be undefined or of length=1..' + keyLen);
2199
+ if (salt !== void 0)
2200
+ abytes(salt, saltLen, "salt");
2201
+ if (personalization !== void 0)
2202
+ abytes(personalization, persLen, "personalization");
2203
+ }
2204
+ var _BLAKE2 = class {
2205
+ buffer;
2206
+ buffer32;
2207
+ finished = false;
2208
+ destroyed = false;
2209
+ length = 0;
2210
+ pos = 0;
2211
+ blockLen;
2212
+ outputLen;
2213
+ constructor(blockLen, outputLen) {
2214
+ anumber2(blockLen);
2215
+ anumber2(outputLen);
2216
+ this.blockLen = blockLen;
2217
+ this.outputLen = outputLen;
2218
+ this.buffer = new Uint8Array(blockLen);
2219
+ this.buffer32 = u32(this.buffer);
2220
+ }
2221
+ update(data) {
2222
+ aexists(this);
2223
+ abytes(data);
2224
+ const { blockLen, buffer, buffer32 } = this;
2225
+ const len = data.length;
2226
+ const offset = data.byteOffset;
2227
+ const buf = data.buffer;
2228
+ for (let pos = 0; pos < len; ) {
2229
+ if (this.pos === blockLen) {
2230
+ swap32IfBE(buffer32);
2231
+ this.compress(buffer32, 0, false);
2232
+ swap32IfBE(buffer32);
2233
+ this.pos = 0;
2234
+ }
2235
+ const take = Math.min(blockLen - this.pos, len - pos);
2236
+ const dataOffset = offset + pos;
2237
+ if (take === blockLen && !(dataOffset % 4) && pos + take < len) {
2238
+ const data32 = new Uint32Array(buf, dataOffset, Math.floor((len - pos) / 4));
2239
+ swap32IfBE(data32);
2240
+ for (let pos32 = 0; pos + blockLen < len; pos32 += buffer32.length, pos += blockLen) {
2241
+ this.length += blockLen;
2242
+ this.compress(data32, pos32, false);
2243
+ }
2244
+ swap32IfBE(data32);
2245
+ continue;
2246
+ }
2247
+ buffer.set(data.subarray(pos, pos + take), this.pos);
2248
+ this.pos += take;
2249
+ this.length += take;
2250
+ pos += take;
2251
+ }
2252
+ return this;
2253
+ }
2254
+ digestInto(out) {
2255
+ aexists(this);
2256
+ aoutput(out, this);
2257
+ const { pos, buffer32 } = this;
2258
+ this.finished = true;
2259
+ clean(this.buffer.subarray(pos));
2260
+ swap32IfBE(buffer32);
2261
+ this.compress(buffer32, 0, true);
2262
+ swap32IfBE(buffer32);
2263
+ const out32 = u32(out);
2264
+ this.get().forEach((v, i) => out32[i] = swap8IfBE(v));
2265
+ }
2266
+ digest() {
2267
+ const { buffer, outputLen } = this;
2268
+ this.digestInto(buffer);
2269
+ const res = buffer.slice(0, outputLen);
2270
+ this.destroy();
2271
+ return res;
2272
+ }
2273
+ _cloneInto(to) {
2274
+ const { buffer, length, finished, destroyed, outputLen, pos } = this;
2275
+ to ||= new this.constructor({ dkLen: outputLen });
2276
+ to.set(...this.get());
2277
+ to.buffer.set(buffer);
2278
+ to.destroyed = destroyed;
2279
+ to.finished = finished;
2280
+ to.length = length;
2281
+ to.pos = pos;
2282
+ to.outputLen = outputLen;
2283
+ return to;
2284
+ }
2285
+ clone() {
2286
+ return this._cloneInto();
2287
+ }
2288
+ };
2289
+ var _BLAKE2b = class extends _BLAKE2 {
2290
+ // Same as SHA-512, but LE
2291
+ v0l = B2B_IV[0] | 0;
2292
+ v0h = B2B_IV[1] | 0;
2293
+ v1l = B2B_IV[2] | 0;
2294
+ v1h = B2B_IV[3] | 0;
2295
+ v2l = B2B_IV[4] | 0;
2296
+ v2h = B2B_IV[5] | 0;
2297
+ v3l = B2B_IV[6] | 0;
2298
+ v3h = B2B_IV[7] | 0;
2299
+ v4l = B2B_IV[8] | 0;
2300
+ v4h = B2B_IV[9] | 0;
2301
+ v5l = B2B_IV[10] | 0;
2302
+ v5h = B2B_IV[11] | 0;
2303
+ v6l = B2B_IV[12] | 0;
2304
+ v6h = B2B_IV[13] | 0;
2305
+ v7l = B2B_IV[14] | 0;
2306
+ v7h = B2B_IV[15] | 0;
2307
+ constructor(opts = {}) {
2308
+ const olen = opts.dkLen === void 0 ? 64 : opts.dkLen;
2309
+ super(128, olen);
2310
+ checkBlake2Opts(olen, opts, 64, 16, 16);
2311
+ let { key, personalization, salt } = opts;
2312
+ let keyLength = 0;
2313
+ if (key !== void 0) {
2314
+ abytes(key, void 0, "key");
2315
+ keyLength = key.length;
2316
+ }
2317
+ this.v0l ^= this.outputLen | keyLength << 8 | 1 << 16 | 1 << 24;
2318
+ if (salt !== void 0) {
2319
+ abytes(salt, void 0, "salt");
2320
+ const slt = u32(salt);
2321
+ this.v4l ^= swap8IfBE(slt[0]);
2322
+ this.v4h ^= swap8IfBE(slt[1]);
2323
+ this.v5l ^= swap8IfBE(slt[2]);
2324
+ this.v5h ^= swap8IfBE(slt[3]);
2325
+ }
2326
+ if (personalization !== void 0) {
2327
+ abytes(personalization, void 0, "personalization");
2328
+ const pers = u32(personalization);
2329
+ this.v6l ^= swap8IfBE(pers[0]);
2330
+ this.v6h ^= swap8IfBE(pers[1]);
2331
+ this.v7l ^= swap8IfBE(pers[2]);
2332
+ this.v7h ^= swap8IfBE(pers[3]);
2333
+ }
2334
+ if (key !== void 0) {
2335
+ const tmp = new Uint8Array(this.blockLen);
2336
+ tmp.set(key);
2337
+ this.update(tmp);
2338
+ }
2339
+ }
2340
+ // prettier-ignore
2341
+ get() {
2342
+ let { v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h } = this;
2343
+ return [v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h];
2344
+ }
2345
+ // prettier-ignore
2346
+ set(v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h) {
2347
+ this.v0l = v0l | 0;
2348
+ this.v0h = v0h | 0;
2349
+ this.v1l = v1l | 0;
2350
+ this.v1h = v1h | 0;
2351
+ this.v2l = v2l | 0;
2352
+ this.v2h = v2h | 0;
2353
+ this.v3l = v3l | 0;
2354
+ this.v3h = v3h | 0;
2355
+ this.v4l = v4l | 0;
2356
+ this.v4h = v4h | 0;
2357
+ this.v5l = v5l | 0;
2358
+ this.v5h = v5h | 0;
2359
+ this.v6l = v6l | 0;
2360
+ this.v6h = v6h | 0;
2361
+ this.v7l = v7l | 0;
2362
+ this.v7h = v7h | 0;
2363
+ }
2364
+ compress(msg, offset, isLast) {
2365
+ this.get().forEach((v, i) => BBUF[i] = v);
2366
+ BBUF.set(B2B_IV, 16);
2367
+ let { h, l } = fromBig(BigInt(this.length));
2368
+ BBUF[24] = B2B_IV[8] ^ l;
2369
+ BBUF[25] = B2B_IV[9] ^ h;
2370
+ if (isLast) {
2371
+ BBUF[28] = ~BBUF[28];
2372
+ BBUF[29] = ~BBUF[29];
2373
+ }
2374
+ let j = 0;
2375
+ const s = BSIGMA;
2376
+ for (let i = 0; i < 12; i++) {
2377
+ G1b(0, 4, 8, 12, msg, offset + 2 * s[j++]);
2378
+ G2b(0, 4, 8, 12, msg, offset + 2 * s[j++]);
2379
+ G1b(1, 5, 9, 13, msg, offset + 2 * s[j++]);
2380
+ G2b(1, 5, 9, 13, msg, offset + 2 * s[j++]);
2381
+ G1b(2, 6, 10, 14, msg, offset + 2 * s[j++]);
2382
+ G2b(2, 6, 10, 14, msg, offset + 2 * s[j++]);
2383
+ G1b(3, 7, 11, 15, msg, offset + 2 * s[j++]);
2384
+ G2b(3, 7, 11, 15, msg, offset + 2 * s[j++]);
2385
+ G1b(0, 5, 10, 15, msg, offset + 2 * s[j++]);
2386
+ G2b(0, 5, 10, 15, msg, offset + 2 * s[j++]);
2387
+ G1b(1, 6, 11, 12, msg, offset + 2 * s[j++]);
2388
+ G2b(1, 6, 11, 12, msg, offset + 2 * s[j++]);
2389
+ G1b(2, 7, 8, 13, msg, offset + 2 * s[j++]);
2390
+ G2b(2, 7, 8, 13, msg, offset + 2 * s[j++]);
2391
+ G1b(3, 4, 9, 14, msg, offset + 2 * s[j++]);
2392
+ G2b(3, 4, 9, 14, msg, offset + 2 * s[j++]);
2393
+ }
2394
+ this.v0l ^= BBUF[0] ^ BBUF[16];
2395
+ this.v0h ^= BBUF[1] ^ BBUF[17];
2396
+ this.v1l ^= BBUF[2] ^ BBUF[18];
2397
+ this.v1h ^= BBUF[3] ^ BBUF[19];
2398
+ this.v2l ^= BBUF[4] ^ BBUF[20];
2399
+ this.v2h ^= BBUF[5] ^ BBUF[21];
2400
+ this.v3l ^= BBUF[6] ^ BBUF[22];
2401
+ this.v3h ^= BBUF[7] ^ BBUF[23];
2402
+ this.v4l ^= BBUF[8] ^ BBUF[24];
2403
+ this.v4h ^= BBUF[9] ^ BBUF[25];
2404
+ this.v5l ^= BBUF[10] ^ BBUF[26];
2405
+ this.v5h ^= BBUF[11] ^ BBUF[27];
2406
+ this.v6l ^= BBUF[12] ^ BBUF[28];
2407
+ this.v6h ^= BBUF[13] ^ BBUF[29];
2408
+ this.v7l ^= BBUF[14] ^ BBUF[30];
2409
+ this.v7h ^= BBUF[15] ^ BBUF[31];
2410
+ clean(BBUF);
2411
+ }
2412
+ destroy() {
2413
+ this.destroyed = true;
2414
+ clean(this.buffer32);
2415
+ this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
2416
+ }
2417
+ };
2418
+ var blake2b = /* @__PURE__ */ createHasher((opts) => new _BLAKE2b(opts));
2419
+
2420
+ // ../../node_modules/.pnpm/@mysten+sui@2.6.0_typescript@5.9.3/node_modules/@mysten/sui/dist/cryptography/signature-scheme.mjs
2421
+ var SIGNATURE_SCHEME_TO_FLAG = {
2422
+ ED25519: 0,
2423
+ Secp256k1: 1,
2424
+ Secp256r1: 2,
2425
+ MultiSig: 3,
2426
+ ZkLogin: 5,
2427
+ Passkey: 6
2428
+ };
2429
+ var SIGNATURE_SCHEME_TO_SIZE = {
2430
+ ED25519: 32,
2431
+ Secp256k1: 33,
2432
+ Secp256r1: 33,
2433
+ Passkey: 33
2434
+ };
2435
+ var SIGNATURE_FLAG_TO_SCHEME = {
2436
+ 0: "ED25519",
2437
+ 1: "Secp256k1",
2438
+ 2: "Secp256r1",
2439
+ 3: "MultiSig",
2440
+ 5: "ZkLogin",
2441
+ 6: "Passkey"
2442
+ };
2443
+
2444
+ export {
2445
+ normalizeSuiNSName,
2446
+ isValidNamedPackage,
2447
+ isValidNamedType,
2448
+ base64urlnopad,
2449
+ bech32,
2450
+ toBase58,
2451
+ fromBase58,
2452
+ fromBase64,
2453
+ toBase64,
2454
+ fromHex,
2455
+ toHex,
2456
+ chunk,
2457
+ DataLoader,
2458
+ splitGenericParameters,
2459
+ isSerializedBcs,
2460
+ bcs,
2461
+ isValidTransactionDigest,
2462
+ SUI_ADDRESS_LENGTH,
2463
+ isValidSuiAddress,
2464
+ isValidSuiObjectId,
2465
+ parseStructTag,
2466
+ normalizeStructTag,
2467
+ normalizeSuiAddress,
2468
+ normalizeSuiObjectId,
2469
+ isBytes2 as isBytes,
2470
+ anumber2 as anumber,
2471
+ abytes,
2472
+ ahash,
2473
+ aexists,
2474
+ clean,
2475
+ createView,
2476
+ bytesToHex,
2477
+ hexToBytes,
2478
+ kdfInputToBytes,
2479
+ concatBytes,
2480
+ checkOpts,
2481
+ createHasher,
2482
+ randomBytes,
2483
+ oidNist,
2484
+ HashMD,
2485
+ SHA512_IV,
2486
+ split,
2487
+ shrSH,
2488
+ shrSL,
2489
+ rotrSH,
2490
+ rotrSL,
2491
+ rotrBH,
2492
+ rotrBL,
2493
+ add,
2494
+ add3L,
2495
+ add3H,
2496
+ add4L,
2497
+ add4H,
2498
+ add5L,
2499
+ add5H,
2500
+ blake2b,
2501
+ SIGNATURE_SCHEME_TO_FLAG,
2502
+ SIGNATURE_SCHEME_TO_SIZE,
2503
+ SIGNATURE_FLAG_TO_SCHEME
2504
+ };
2505
+ /*! Bundled license information:
2506
+
2507
+ @scure/base/index.js:
2508
+ (*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2509
+
2510
+ @noble/hashes/utils.js:
2511
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2512
+ */
2513
+ //# sourceMappingURL=chunk-6SBIVUVA.js.map