@pump-fun/pump-sdk 1.18.5 → 1.18.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
8
11
  var __export = (target, all) => {
9
12
  for (var name in all)
10
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,13 +30,1795 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  ));
28
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
32
 
33
+ // node_modules/base64-js/index.js
34
+ var require_base64_js = __commonJS({
35
+ "node_modules/base64-js/index.js"(exports) {
36
+ "use strict";
37
+ exports.byteLength = byteLength;
38
+ exports.toByteArray = toByteArray;
39
+ exports.fromByteArray = fromByteArray;
40
+ var lookup = [];
41
+ var revLookup = [];
42
+ var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
43
+ var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
44
+ for (i = 0, len = code.length; i < len; ++i) {
45
+ lookup[i] = code[i];
46
+ revLookup[code.charCodeAt(i)] = i;
47
+ }
48
+ var i;
49
+ var len;
50
+ revLookup["-".charCodeAt(0)] = 62;
51
+ revLookup["_".charCodeAt(0)] = 63;
52
+ function getLens(b64) {
53
+ var len2 = b64.length;
54
+ if (len2 % 4 > 0) {
55
+ throw new Error("Invalid string. Length must be a multiple of 4");
56
+ }
57
+ var validLen = b64.indexOf("=");
58
+ if (validLen === -1) validLen = len2;
59
+ var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
60
+ return [validLen, placeHoldersLen];
61
+ }
62
+ function byteLength(b64) {
63
+ var lens = getLens(b64);
64
+ var validLen = lens[0];
65
+ var placeHoldersLen = lens[1];
66
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
67
+ }
68
+ function _byteLength(b64, validLen, placeHoldersLen) {
69
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
70
+ }
71
+ function toByteArray(b64) {
72
+ var tmp;
73
+ var lens = getLens(b64);
74
+ var validLen = lens[0];
75
+ var placeHoldersLen = lens[1];
76
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
77
+ var curByte = 0;
78
+ var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
79
+ var i2;
80
+ for (i2 = 0; i2 < len2; i2 += 4) {
81
+ tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
82
+ arr[curByte++] = tmp >> 16 & 255;
83
+ arr[curByte++] = tmp >> 8 & 255;
84
+ arr[curByte++] = tmp & 255;
85
+ }
86
+ if (placeHoldersLen === 2) {
87
+ tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
88
+ arr[curByte++] = tmp & 255;
89
+ }
90
+ if (placeHoldersLen === 1) {
91
+ tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
92
+ arr[curByte++] = tmp >> 8 & 255;
93
+ arr[curByte++] = tmp & 255;
94
+ }
95
+ return arr;
96
+ }
97
+ function tripletToBase64(num) {
98
+ return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
99
+ }
100
+ function encodeChunk(uint8, start, end) {
101
+ var tmp;
102
+ var output = [];
103
+ for (var i2 = start; i2 < end; i2 += 3) {
104
+ tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
105
+ output.push(tripletToBase64(tmp));
106
+ }
107
+ return output.join("");
108
+ }
109
+ function fromByteArray(uint8) {
110
+ var tmp;
111
+ var len2 = uint8.length;
112
+ var extraBytes = len2 % 3;
113
+ var parts = [];
114
+ var maxChunkLength = 16383;
115
+ for (var i2 = 0, len22 = len2 - extraBytes; i2 < len22; i2 += maxChunkLength) {
116
+ parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
117
+ }
118
+ if (extraBytes === 1) {
119
+ tmp = uint8[len2 - 1];
120
+ parts.push(
121
+ lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
122
+ );
123
+ } else if (extraBytes === 2) {
124
+ tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
125
+ parts.push(
126
+ lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
127
+ );
128
+ }
129
+ return parts.join("");
130
+ }
131
+ }
132
+ });
133
+
134
+ // node_modules/ieee754/index.js
135
+ var require_ieee754 = __commonJS({
136
+ "node_modules/ieee754/index.js"(exports) {
137
+ "use strict";
138
+ exports.read = function(buffer, offset, isLE, mLen, nBytes) {
139
+ var e, m;
140
+ var eLen = nBytes * 8 - mLen - 1;
141
+ var eMax = (1 << eLen) - 1;
142
+ var eBias = eMax >> 1;
143
+ var nBits = -7;
144
+ var i = isLE ? nBytes - 1 : 0;
145
+ var d = isLE ? -1 : 1;
146
+ var s = buffer[offset + i];
147
+ i += d;
148
+ e = s & (1 << -nBits) - 1;
149
+ s >>= -nBits;
150
+ nBits += eLen;
151
+ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
152
+ }
153
+ m = e & (1 << -nBits) - 1;
154
+ e >>= -nBits;
155
+ nBits += mLen;
156
+ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
157
+ }
158
+ if (e === 0) {
159
+ e = 1 - eBias;
160
+ } else if (e === eMax) {
161
+ return m ? NaN : (s ? -1 : 1) * Infinity;
162
+ } else {
163
+ m = m + Math.pow(2, mLen);
164
+ e = e - eBias;
165
+ }
166
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
167
+ };
168
+ exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
169
+ var e, m, c;
170
+ var eLen = nBytes * 8 - mLen - 1;
171
+ var eMax = (1 << eLen) - 1;
172
+ var eBias = eMax >> 1;
173
+ var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
174
+ var i = isLE ? 0 : nBytes - 1;
175
+ var d = isLE ? 1 : -1;
176
+ var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
177
+ value = Math.abs(value);
178
+ if (isNaN(value) || value === Infinity) {
179
+ m = isNaN(value) ? 1 : 0;
180
+ e = eMax;
181
+ } else {
182
+ e = Math.floor(Math.log(value) / Math.LN2);
183
+ if (value * (c = Math.pow(2, -e)) < 1) {
184
+ e--;
185
+ c *= 2;
186
+ }
187
+ if (e + eBias >= 1) {
188
+ value += rt / c;
189
+ } else {
190
+ value += rt * Math.pow(2, 1 - eBias);
191
+ }
192
+ if (value * c >= 2) {
193
+ e++;
194
+ c /= 2;
195
+ }
196
+ if (e + eBias >= eMax) {
197
+ m = 0;
198
+ e = eMax;
199
+ } else if (e + eBias >= 1) {
200
+ m = (value * c - 1) * Math.pow(2, mLen);
201
+ e = e + eBias;
202
+ } else {
203
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
204
+ e = 0;
205
+ }
206
+ }
207
+ for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
208
+ }
209
+ e = e << mLen | m;
210
+ eLen += mLen;
211
+ for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
212
+ }
213
+ buffer[offset + i - d] |= s * 128;
214
+ };
215
+ }
216
+ });
217
+
218
+ // node_modules/buffer/index.js
219
+ var require_buffer = __commonJS({
220
+ "node_modules/buffer/index.js"(exports) {
221
+ "use strict";
222
+ var base64 = require_base64_js();
223
+ var ieee754 = require_ieee754();
224
+ var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
225
+ exports.Buffer = Buffer3;
226
+ exports.SlowBuffer = SlowBuffer;
227
+ exports.INSPECT_MAX_BYTES = 50;
228
+ var K_MAX_LENGTH = 2147483647;
229
+ exports.kMaxLength = K_MAX_LENGTH;
230
+ Buffer3.TYPED_ARRAY_SUPPORT = typedArraySupport();
231
+ if (!Buffer3.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
232
+ console.error(
233
+ "This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
234
+ );
235
+ }
236
+ function typedArraySupport() {
237
+ try {
238
+ const arr = new Uint8Array(1);
239
+ const proto = { foo: function() {
240
+ return 42;
241
+ } };
242
+ Object.setPrototypeOf(proto, Uint8Array.prototype);
243
+ Object.setPrototypeOf(arr, proto);
244
+ return arr.foo() === 42;
245
+ } catch (e) {
246
+ return false;
247
+ }
248
+ }
249
+ Object.defineProperty(Buffer3.prototype, "parent", {
250
+ enumerable: true,
251
+ get: function() {
252
+ if (!Buffer3.isBuffer(this)) return void 0;
253
+ return this.buffer;
254
+ }
255
+ });
256
+ Object.defineProperty(Buffer3.prototype, "offset", {
257
+ enumerable: true,
258
+ get: function() {
259
+ if (!Buffer3.isBuffer(this)) return void 0;
260
+ return this.byteOffset;
261
+ }
262
+ });
263
+ function createBuffer(length) {
264
+ if (length > K_MAX_LENGTH) {
265
+ throw new RangeError('The value "' + length + '" is invalid for option "size"');
266
+ }
267
+ const buf = new Uint8Array(length);
268
+ Object.setPrototypeOf(buf, Buffer3.prototype);
269
+ return buf;
270
+ }
271
+ function Buffer3(arg, encodingOrOffset, length) {
272
+ if (typeof arg === "number") {
273
+ if (typeof encodingOrOffset === "string") {
274
+ throw new TypeError(
275
+ 'The "string" argument must be of type string. Received type number'
276
+ );
277
+ }
278
+ return allocUnsafe(arg);
279
+ }
280
+ return from(arg, encodingOrOffset, length);
281
+ }
282
+ Buffer3.poolSize = 8192;
283
+ function from(value, encodingOrOffset, length) {
284
+ if (typeof value === "string") {
285
+ return fromString(value, encodingOrOffset);
286
+ }
287
+ if (ArrayBuffer.isView(value)) {
288
+ return fromArrayView(value);
289
+ }
290
+ if (value == null) {
291
+ throw new TypeError(
292
+ "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
293
+ );
294
+ }
295
+ if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
296
+ return fromArrayBuffer(value, encodingOrOffset, length);
297
+ }
298
+ if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
299
+ return fromArrayBuffer(value, encodingOrOffset, length);
300
+ }
301
+ if (typeof value === "number") {
302
+ throw new TypeError(
303
+ 'The "value" argument must not be of type number. Received type number'
304
+ );
305
+ }
306
+ const valueOf = value.valueOf && value.valueOf();
307
+ if (valueOf != null && valueOf !== value) {
308
+ return Buffer3.from(valueOf, encodingOrOffset, length);
309
+ }
310
+ const b = fromObject(value);
311
+ if (b) return b;
312
+ if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
313
+ return Buffer3.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
314
+ }
315
+ throw new TypeError(
316
+ "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
317
+ );
318
+ }
319
+ Buffer3.from = function(value, encodingOrOffset, length) {
320
+ return from(value, encodingOrOffset, length);
321
+ };
322
+ Object.setPrototypeOf(Buffer3.prototype, Uint8Array.prototype);
323
+ Object.setPrototypeOf(Buffer3, Uint8Array);
324
+ function assertSize(size) {
325
+ if (typeof size !== "number") {
326
+ throw new TypeError('"size" argument must be of type number');
327
+ } else if (size < 0) {
328
+ throw new RangeError('The value "' + size + '" is invalid for option "size"');
329
+ }
330
+ }
331
+ function alloc(size, fill, encoding) {
332
+ assertSize(size);
333
+ if (size <= 0) {
334
+ return createBuffer(size);
335
+ }
336
+ if (fill !== void 0) {
337
+ return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
338
+ }
339
+ return createBuffer(size);
340
+ }
341
+ Buffer3.alloc = function(size, fill, encoding) {
342
+ return alloc(size, fill, encoding);
343
+ };
344
+ function allocUnsafe(size) {
345
+ assertSize(size);
346
+ return createBuffer(size < 0 ? 0 : checked(size) | 0);
347
+ }
348
+ Buffer3.allocUnsafe = function(size) {
349
+ return allocUnsafe(size);
350
+ };
351
+ Buffer3.allocUnsafeSlow = function(size) {
352
+ return allocUnsafe(size);
353
+ };
354
+ function fromString(string, encoding) {
355
+ if (typeof encoding !== "string" || encoding === "") {
356
+ encoding = "utf8";
357
+ }
358
+ if (!Buffer3.isEncoding(encoding)) {
359
+ throw new TypeError("Unknown encoding: " + encoding);
360
+ }
361
+ const length = byteLength(string, encoding) | 0;
362
+ let buf = createBuffer(length);
363
+ const actual = buf.write(string, encoding);
364
+ if (actual !== length) {
365
+ buf = buf.slice(0, actual);
366
+ }
367
+ return buf;
368
+ }
369
+ function fromArrayLike(array) {
370
+ const length = array.length < 0 ? 0 : checked(array.length) | 0;
371
+ const buf = createBuffer(length);
372
+ for (let i = 0; i < length; i += 1) {
373
+ buf[i] = array[i] & 255;
374
+ }
375
+ return buf;
376
+ }
377
+ function fromArrayView(arrayView) {
378
+ if (isInstance(arrayView, Uint8Array)) {
379
+ const copy = new Uint8Array(arrayView);
380
+ return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
381
+ }
382
+ return fromArrayLike(arrayView);
383
+ }
384
+ function fromArrayBuffer(array, byteOffset, length) {
385
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
386
+ throw new RangeError('"offset" is outside of buffer bounds');
387
+ }
388
+ if (array.byteLength < byteOffset + (length || 0)) {
389
+ throw new RangeError('"length" is outside of buffer bounds');
390
+ }
391
+ let buf;
392
+ if (byteOffset === void 0 && length === void 0) {
393
+ buf = new Uint8Array(array);
394
+ } else if (length === void 0) {
395
+ buf = new Uint8Array(array, byteOffset);
396
+ } else {
397
+ buf = new Uint8Array(array, byteOffset, length);
398
+ }
399
+ Object.setPrototypeOf(buf, Buffer3.prototype);
400
+ return buf;
401
+ }
402
+ function fromObject(obj) {
403
+ if (Buffer3.isBuffer(obj)) {
404
+ const len = checked(obj.length) | 0;
405
+ const buf = createBuffer(len);
406
+ if (buf.length === 0) {
407
+ return buf;
408
+ }
409
+ obj.copy(buf, 0, 0, len);
410
+ return buf;
411
+ }
412
+ if (obj.length !== void 0) {
413
+ if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
414
+ return createBuffer(0);
415
+ }
416
+ return fromArrayLike(obj);
417
+ }
418
+ if (obj.type === "Buffer" && Array.isArray(obj.data)) {
419
+ return fromArrayLike(obj.data);
420
+ }
421
+ }
422
+ function checked(length) {
423
+ if (length >= K_MAX_LENGTH) {
424
+ throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
425
+ }
426
+ return length | 0;
427
+ }
428
+ function SlowBuffer(length) {
429
+ if (+length != length) {
430
+ length = 0;
431
+ }
432
+ return Buffer3.alloc(+length);
433
+ }
434
+ Buffer3.isBuffer = function isBuffer(b) {
435
+ return b != null && b._isBuffer === true && b !== Buffer3.prototype;
436
+ };
437
+ Buffer3.compare = function compare(a, b) {
438
+ if (isInstance(a, Uint8Array)) a = Buffer3.from(a, a.offset, a.byteLength);
439
+ if (isInstance(b, Uint8Array)) b = Buffer3.from(b, b.offset, b.byteLength);
440
+ if (!Buffer3.isBuffer(a) || !Buffer3.isBuffer(b)) {
441
+ throw new TypeError(
442
+ 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
443
+ );
444
+ }
445
+ if (a === b) return 0;
446
+ let x = a.length;
447
+ let y = b.length;
448
+ for (let i = 0, len = Math.min(x, y); i < len; ++i) {
449
+ if (a[i] !== b[i]) {
450
+ x = a[i];
451
+ y = b[i];
452
+ break;
453
+ }
454
+ }
455
+ if (x < y) return -1;
456
+ if (y < x) return 1;
457
+ return 0;
458
+ };
459
+ Buffer3.isEncoding = function isEncoding(encoding) {
460
+ switch (String(encoding).toLowerCase()) {
461
+ case "hex":
462
+ case "utf8":
463
+ case "utf-8":
464
+ case "ascii":
465
+ case "latin1":
466
+ case "binary":
467
+ case "base64":
468
+ case "ucs2":
469
+ case "ucs-2":
470
+ case "utf16le":
471
+ case "utf-16le":
472
+ return true;
473
+ default:
474
+ return false;
475
+ }
476
+ };
477
+ Buffer3.concat = function concat(list, length) {
478
+ if (!Array.isArray(list)) {
479
+ throw new TypeError('"list" argument must be an Array of Buffers');
480
+ }
481
+ if (list.length === 0) {
482
+ return Buffer3.alloc(0);
483
+ }
484
+ let i;
485
+ if (length === void 0) {
486
+ length = 0;
487
+ for (i = 0; i < list.length; ++i) {
488
+ length += list[i].length;
489
+ }
490
+ }
491
+ const buffer = Buffer3.allocUnsafe(length);
492
+ let pos = 0;
493
+ for (i = 0; i < list.length; ++i) {
494
+ let buf = list[i];
495
+ if (isInstance(buf, Uint8Array)) {
496
+ if (pos + buf.length > buffer.length) {
497
+ if (!Buffer3.isBuffer(buf)) buf = Buffer3.from(buf);
498
+ buf.copy(buffer, pos);
499
+ } else {
500
+ Uint8Array.prototype.set.call(
501
+ buffer,
502
+ buf,
503
+ pos
504
+ );
505
+ }
506
+ } else if (!Buffer3.isBuffer(buf)) {
507
+ throw new TypeError('"list" argument must be an Array of Buffers');
508
+ } else {
509
+ buf.copy(buffer, pos);
510
+ }
511
+ pos += buf.length;
512
+ }
513
+ return buffer;
514
+ };
515
+ function byteLength(string, encoding) {
516
+ if (Buffer3.isBuffer(string)) {
517
+ return string.length;
518
+ }
519
+ if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
520
+ return string.byteLength;
521
+ }
522
+ if (typeof string !== "string") {
523
+ throw new TypeError(
524
+ 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string
525
+ );
526
+ }
527
+ const len = string.length;
528
+ const mustMatch = arguments.length > 2 && arguments[2] === true;
529
+ if (!mustMatch && len === 0) return 0;
530
+ let loweredCase = false;
531
+ for (; ; ) {
532
+ switch (encoding) {
533
+ case "ascii":
534
+ case "latin1":
535
+ case "binary":
536
+ return len;
537
+ case "utf8":
538
+ case "utf-8":
539
+ return utf8ToBytes(string).length;
540
+ case "ucs2":
541
+ case "ucs-2":
542
+ case "utf16le":
543
+ case "utf-16le":
544
+ return len * 2;
545
+ case "hex":
546
+ return len >>> 1;
547
+ case "base64":
548
+ return base64ToBytes(string).length;
549
+ default:
550
+ if (loweredCase) {
551
+ return mustMatch ? -1 : utf8ToBytes(string).length;
552
+ }
553
+ encoding = ("" + encoding).toLowerCase();
554
+ loweredCase = true;
555
+ }
556
+ }
557
+ }
558
+ Buffer3.byteLength = byteLength;
559
+ function slowToString(encoding, start, end) {
560
+ let loweredCase = false;
561
+ if (start === void 0 || start < 0) {
562
+ start = 0;
563
+ }
564
+ if (start > this.length) {
565
+ return "";
566
+ }
567
+ if (end === void 0 || end > this.length) {
568
+ end = this.length;
569
+ }
570
+ if (end <= 0) {
571
+ return "";
572
+ }
573
+ end >>>= 0;
574
+ start >>>= 0;
575
+ if (end <= start) {
576
+ return "";
577
+ }
578
+ if (!encoding) encoding = "utf8";
579
+ while (true) {
580
+ switch (encoding) {
581
+ case "hex":
582
+ return hexSlice(this, start, end);
583
+ case "utf8":
584
+ case "utf-8":
585
+ return utf8Slice(this, start, end);
586
+ case "ascii":
587
+ return asciiSlice(this, start, end);
588
+ case "latin1":
589
+ case "binary":
590
+ return latin1Slice(this, start, end);
591
+ case "base64":
592
+ return base64Slice(this, start, end);
593
+ case "ucs2":
594
+ case "ucs-2":
595
+ case "utf16le":
596
+ case "utf-16le":
597
+ return utf16leSlice(this, start, end);
598
+ default:
599
+ if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
600
+ encoding = (encoding + "").toLowerCase();
601
+ loweredCase = true;
602
+ }
603
+ }
604
+ }
605
+ Buffer3.prototype._isBuffer = true;
606
+ function swap(b, n, m) {
607
+ const i = b[n];
608
+ b[n] = b[m];
609
+ b[m] = i;
610
+ }
611
+ Buffer3.prototype.swap16 = function swap16() {
612
+ const len = this.length;
613
+ if (len % 2 !== 0) {
614
+ throw new RangeError("Buffer size must be a multiple of 16-bits");
615
+ }
616
+ for (let i = 0; i < len; i += 2) {
617
+ swap(this, i, i + 1);
618
+ }
619
+ return this;
620
+ };
621
+ Buffer3.prototype.swap32 = function swap32() {
622
+ const len = this.length;
623
+ if (len % 4 !== 0) {
624
+ throw new RangeError("Buffer size must be a multiple of 32-bits");
625
+ }
626
+ for (let i = 0; i < len; i += 4) {
627
+ swap(this, i, i + 3);
628
+ swap(this, i + 1, i + 2);
629
+ }
630
+ return this;
631
+ };
632
+ Buffer3.prototype.swap64 = function swap64() {
633
+ const len = this.length;
634
+ if (len % 8 !== 0) {
635
+ throw new RangeError("Buffer size must be a multiple of 64-bits");
636
+ }
637
+ for (let i = 0; i < len; i += 8) {
638
+ swap(this, i, i + 7);
639
+ swap(this, i + 1, i + 6);
640
+ swap(this, i + 2, i + 5);
641
+ swap(this, i + 3, i + 4);
642
+ }
643
+ return this;
644
+ };
645
+ Buffer3.prototype.toString = function toString() {
646
+ const length = this.length;
647
+ if (length === 0) return "";
648
+ if (arguments.length === 0) return utf8Slice(this, 0, length);
649
+ return slowToString.apply(this, arguments);
650
+ };
651
+ Buffer3.prototype.toLocaleString = Buffer3.prototype.toString;
652
+ Buffer3.prototype.equals = function equals(b) {
653
+ if (!Buffer3.isBuffer(b)) throw new TypeError("Argument must be a Buffer");
654
+ if (this === b) return true;
655
+ return Buffer3.compare(this, b) === 0;
656
+ };
657
+ Buffer3.prototype.inspect = function inspect() {
658
+ let str = "";
659
+ const max = exports.INSPECT_MAX_BYTES;
660
+ str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
661
+ if (this.length > max) str += " ... ";
662
+ return "<Buffer " + str + ">";
663
+ };
664
+ if (customInspectSymbol) {
665
+ Buffer3.prototype[customInspectSymbol] = Buffer3.prototype.inspect;
666
+ }
667
+ Buffer3.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
668
+ if (isInstance(target, Uint8Array)) {
669
+ target = Buffer3.from(target, target.offset, target.byteLength);
670
+ }
671
+ if (!Buffer3.isBuffer(target)) {
672
+ throw new TypeError(
673
+ 'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target
674
+ );
675
+ }
676
+ if (start === void 0) {
677
+ start = 0;
678
+ }
679
+ if (end === void 0) {
680
+ end = target ? target.length : 0;
681
+ }
682
+ if (thisStart === void 0) {
683
+ thisStart = 0;
684
+ }
685
+ if (thisEnd === void 0) {
686
+ thisEnd = this.length;
687
+ }
688
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
689
+ throw new RangeError("out of range index");
690
+ }
691
+ if (thisStart >= thisEnd && start >= end) {
692
+ return 0;
693
+ }
694
+ if (thisStart >= thisEnd) {
695
+ return -1;
696
+ }
697
+ if (start >= end) {
698
+ return 1;
699
+ }
700
+ start >>>= 0;
701
+ end >>>= 0;
702
+ thisStart >>>= 0;
703
+ thisEnd >>>= 0;
704
+ if (this === target) return 0;
705
+ let x = thisEnd - thisStart;
706
+ let y = end - start;
707
+ const len = Math.min(x, y);
708
+ const thisCopy = this.slice(thisStart, thisEnd);
709
+ const targetCopy = target.slice(start, end);
710
+ for (let i = 0; i < len; ++i) {
711
+ if (thisCopy[i] !== targetCopy[i]) {
712
+ x = thisCopy[i];
713
+ y = targetCopy[i];
714
+ break;
715
+ }
716
+ }
717
+ if (x < y) return -1;
718
+ if (y < x) return 1;
719
+ return 0;
720
+ };
721
+ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
722
+ if (buffer.length === 0) return -1;
723
+ if (typeof byteOffset === "string") {
724
+ encoding = byteOffset;
725
+ byteOffset = 0;
726
+ } else if (byteOffset > 2147483647) {
727
+ byteOffset = 2147483647;
728
+ } else if (byteOffset < -2147483648) {
729
+ byteOffset = -2147483648;
730
+ }
731
+ byteOffset = +byteOffset;
732
+ if (numberIsNaN(byteOffset)) {
733
+ byteOffset = dir ? 0 : buffer.length - 1;
734
+ }
735
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
736
+ if (byteOffset >= buffer.length) {
737
+ if (dir) return -1;
738
+ else byteOffset = buffer.length - 1;
739
+ } else if (byteOffset < 0) {
740
+ if (dir) byteOffset = 0;
741
+ else return -1;
742
+ }
743
+ if (typeof val === "string") {
744
+ val = Buffer3.from(val, encoding);
745
+ }
746
+ if (Buffer3.isBuffer(val)) {
747
+ if (val.length === 0) {
748
+ return -1;
749
+ }
750
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
751
+ } else if (typeof val === "number") {
752
+ val = val & 255;
753
+ if (typeof Uint8Array.prototype.indexOf === "function") {
754
+ if (dir) {
755
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
756
+ } else {
757
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
758
+ }
759
+ }
760
+ return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
761
+ }
762
+ throw new TypeError("val must be string, number or Buffer");
763
+ }
764
+ function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
765
+ let indexSize = 1;
766
+ let arrLength = arr.length;
767
+ let valLength = val.length;
768
+ if (encoding !== void 0) {
769
+ encoding = String(encoding).toLowerCase();
770
+ if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
771
+ if (arr.length < 2 || val.length < 2) {
772
+ return -1;
773
+ }
774
+ indexSize = 2;
775
+ arrLength /= 2;
776
+ valLength /= 2;
777
+ byteOffset /= 2;
778
+ }
779
+ }
780
+ function read(buf, i2) {
781
+ if (indexSize === 1) {
782
+ return buf[i2];
783
+ } else {
784
+ return buf.readUInt16BE(i2 * indexSize);
785
+ }
786
+ }
787
+ let i;
788
+ if (dir) {
789
+ let foundIndex = -1;
790
+ for (i = byteOffset; i < arrLength; i++) {
791
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
792
+ if (foundIndex === -1) foundIndex = i;
793
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
794
+ } else {
795
+ if (foundIndex !== -1) i -= i - foundIndex;
796
+ foundIndex = -1;
797
+ }
798
+ }
799
+ } else {
800
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
801
+ for (i = byteOffset; i >= 0; i--) {
802
+ let found = true;
803
+ for (let j = 0; j < valLength; j++) {
804
+ if (read(arr, i + j) !== read(val, j)) {
805
+ found = false;
806
+ break;
807
+ }
808
+ }
809
+ if (found) return i;
810
+ }
811
+ }
812
+ return -1;
813
+ }
814
+ Buffer3.prototype.includes = function includes(val, byteOffset, encoding) {
815
+ return this.indexOf(val, byteOffset, encoding) !== -1;
816
+ };
817
+ Buffer3.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
818
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
819
+ };
820
+ Buffer3.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
821
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
822
+ };
823
+ function hexWrite(buf, string, offset, length) {
824
+ offset = Number(offset) || 0;
825
+ const remaining = buf.length - offset;
826
+ if (!length) {
827
+ length = remaining;
828
+ } else {
829
+ length = Number(length);
830
+ if (length > remaining) {
831
+ length = remaining;
832
+ }
833
+ }
834
+ const strLen = string.length;
835
+ if (length > strLen / 2) {
836
+ length = strLen / 2;
837
+ }
838
+ let i;
839
+ for (i = 0; i < length; ++i) {
840
+ const parsed = parseInt(string.substr(i * 2, 2), 16);
841
+ if (numberIsNaN(parsed)) return i;
842
+ buf[offset + i] = parsed;
843
+ }
844
+ return i;
845
+ }
846
+ function utf8Write(buf, string, offset, length) {
847
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
848
+ }
849
+ function asciiWrite(buf, string, offset, length) {
850
+ return blitBuffer(asciiToBytes(string), buf, offset, length);
851
+ }
852
+ function base64Write(buf, string, offset, length) {
853
+ return blitBuffer(base64ToBytes(string), buf, offset, length);
854
+ }
855
+ function ucs2Write(buf, string, offset, length) {
856
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
857
+ }
858
+ Buffer3.prototype.write = function write(string, offset, length, encoding) {
859
+ if (offset === void 0) {
860
+ encoding = "utf8";
861
+ length = this.length;
862
+ offset = 0;
863
+ } else if (length === void 0 && typeof offset === "string") {
864
+ encoding = offset;
865
+ length = this.length;
866
+ offset = 0;
867
+ } else if (isFinite(offset)) {
868
+ offset = offset >>> 0;
869
+ if (isFinite(length)) {
870
+ length = length >>> 0;
871
+ if (encoding === void 0) encoding = "utf8";
872
+ } else {
873
+ encoding = length;
874
+ length = void 0;
875
+ }
876
+ } else {
877
+ throw new Error(
878
+ "Buffer.write(string, encoding, offset[, length]) is no longer supported"
879
+ );
880
+ }
881
+ const remaining = this.length - offset;
882
+ if (length === void 0 || length > remaining) length = remaining;
883
+ if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
884
+ throw new RangeError("Attempt to write outside buffer bounds");
885
+ }
886
+ if (!encoding) encoding = "utf8";
887
+ let loweredCase = false;
888
+ for (; ; ) {
889
+ switch (encoding) {
890
+ case "hex":
891
+ return hexWrite(this, string, offset, length);
892
+ case "utf8":
893
+ case "utf-8":
894
+ return utf8Write(this, string, offset, length);
895
+ case "ascii":
896
+ case "latin1":
897
+ case "binary":
898
+ return asciiWrite(this, string, offset, length);
899
+ case "base64":
900
+ return base64Write(this, string, offset, length);
901
+ case "ucs2":
902
+ case "ucs-2":
903
+ case "utf16le":
904
+ case "utf-16le":
905
+ return ucs2Write(this, string, offset, length);
906
+ default:
907
+ if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
908
+ encoding = ("" + encoding).toLowerCase();
909
+ loweredCase = true;
910
+ }
911
+ }
912
+ };
913
+ Buffer3.prototype.toJSON = function toJSON() {
914
+ return {
915
+ type: "Buffer",
916
+ data: Array.prototype.slice.call(this._arr || this, 0)
917
+ };
918
+ };
919
+ function base64Slice(buf, start, end) {
920
+ if (start === 0 && end === buf.length) {
921
+ return base64.fromByteArray(buf);
922
+ } else {
923
+ return base64.fromByteArray(buf.slice(start, end));
924
+ }
925
+ }
926
+ function utf8Slice(buf, start, end) {
927
+ end = Math.min(buf.length, end);
928
+ const res = [];
929
+ let i = start;
930
+ while (i < end) {
931
+ const firstByte = buf[i];
932
+ let codePoint = null;
933
+ let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
934
+ if (i + bytesPerSequence <= end) {
935
+ let secondByte, thirdByte, fourthByte, tempCodePoint;
936
+ switch (bytesPerSequence) {
937
+ case 1:
938
+ if (firstByte < 128) {
939
+ codePoint = firstByte;
940
+ }
941
+ break;
942
+ case 2:
943
+ secondByte = buf[i + 1];
944
+ if ((secondByte & 192) === 128) {
945
+ tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
946
+ if (tempCodePoint > 127) {
947
+ codePoint = tempCodePoint;
948
+ }
949
+ }
950
+ break;
951
+ case 3:
952
+ secondByte = buf[i + 1];
953
+ thirdByte = buf[i + 2];
954
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
955
+ tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
956
+ if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
957
+ codePoint = tempCodePoint;
958
+ }
959
+ }
960
+ break;
961
+ case 4:
962
+ secondByte = buf[i + 1];
963
+ thirdByte = buf[i + 2];
964
+ fourthByte = buf[i + 3];
965
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
966
+ tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
967
+ if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
968
+ codePoint = tempCodePoint;
969
+ }
970
+ }
971
+ }
972
+ }
973
+ if (codePoint === null) {
974
+ codePoint = 65533;
975
+ bytesPerSequence = 1;
976
+ } else if (codePoint > 65535) {
977
+ codePoint -= 65536;
978
+ res.push(codePoint >>> 10 & 1023 | 55296);
979
+ codePoint = 56320 | codePoint & 1023;
980
+ }
981
+ res.push(codePoint);
982
+ i += bytesPerSequence;
983
+ }
984
+ return decodeCodePointsArray(res);
985
+ }
986
+ var MAX_ARGUMENTS_LENGTH = 4096;
987
+ function decodeCodePointsArray(codePoints) {
988
+ const len = codePoints.length;
989
+ if (len <= MAX_ARGUMENTS_LENGTH) {
990
+ return String.fromCharCode.apply(String, codePoints);
991
+ }
992
+ let res = "";
993
+ let i = 0;
994
+ while (i < len) {
995
+ res += String.fromCharCode.apply(
996
+ String,
997
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
998
+ );
999
+ }
1000
+ return res;
1001
+ }
1002
+ function asciiSlice(buf, start, end) {
1003
+ let ret = "";
1004
+ end = Math.min(buf.length, end);
1005
+ for (let i = start; i < end; ++i) {
1006
+ ret += String.fromCharCode(buf[i] & 127);
1007
+ }
1008
+ return ret;
1009
+ }
1010
+ function latin1Slice(buf, start, end) {
1011
+ let ret = "";
1012
+ end = Math.min(buf.length, end);
1013
+ for (let i = start; i < end; ++i) {
1014
+ ret += String.fromCharCode(buf[i]);
1015
+ }
1016
+ return ret;
1017
+ }
1018
+ function hexSlice(buf, start, end) {
1019
+ const len = buf.length;
1020
+ if (!start || start < 0) start = 0;
1021
+ if (!end || end < 0 || end > len) end = len;
1022
+ let out = "";
1023
+ for (let i = start; i < end; ++i) {
1024
+ out += hexSliceLookupTable[buf[i]];
1025
+ }
1026
+ return out;
1027
+ }
1028
+ function utf16leSlice(buf, start, end) {
1029
+ const bytes = buf.slice(start, end);
1030
+ let res = "";
1031
+ for (let i = 0; i < bytes.length - 1; i += 2) {
1032
+ res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
1033
+ }
1034
+ return res;
1035
+ }
1036
+ Buffer3.prototype.slice = function slice(start, end) {
1037
+ const len = this.length;
1038
+ start = ~~start;
1039
+ end = end === void 0 ? len : ~~end;
1040
+ if (start < 0) {
1041
+ start += len;
1042
+ if (start < 0) start = 0;
1043
+ } else if (start > len) {
1044
+ start = len;
1045
+ }
1046
+ if (end < 0) {
1047
+ end += len;
1048
+ if (end < 0) end = 0;
1049
+ } else if (end > len) {
1050
+ end = len;
1051
+ }
1052
+ if (end < start) end = start;
1053
+ const newBuf = this.subarray(start, end);
1054
+ Object.setPrototypeOf(newBuf, Buffer3.prototype);
1055
+ return newBuf;
1056
+ };
1057
+ function checkOffset(offset, ext, length) {
1058
+ if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
1059
+ if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
1060
+ }
1061
+ Buffer3.prototype.readUintLE = Buffer3.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
1062
+ offset = offset >>> 0;
1063
+ byteLength2 = byteLength2 >>> 0;
1064
+ if (!noAssert) checkOffset(offset, byteLength2, this.length);
1065
+ let val = this[offset];
1066
+ let mul = 1;
1067
+ let i = 0;
1068
+ while (++i < byteLength2 && (mul *= 256)) {
1069
+ val += this[offset + i] * mul;
1070
+ }
1071
+ return val;
1072
+ };
1073
+ Buffer3.prototype.readUintBE = Buffer3.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
1074
+ offset = offset >>> 0;
1075
+ byteLength2 = byteLength2 >>> 0;
1076
+ if (!noAssert) {
1077
+ checkOffset(offset, byteLength2, this.length);
1078
+ }
1079
+ let val = this[offset + --byteLength2];
1080
+ let mul = 1;
1081
+ while (byteLength2 > 0 && (mul *= 256)) {
1082
+ val += this[offset + --byteLength2] * mul;
1083
+ }
1084
+ return val;
1085
+ };
1086
+ Buffer3.prototype.readUint8 = Buffer3.prototype.readUInt8 = function readUInt8(offset, noAssert) {
1087
+ offset = offset >>> 0;
1088
+ if (!noAssert) checkOffset(offset, 1, this.length);
1089
+ return this[offset];
1090
+ };
1091
+ Buffer3.prototype.readUint16LE = Buffer3.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
1092
+ offset = offset >>> 0;
1093
+ if (!noAssert) checkOffset(offset, 2, this.length);
1094
+ return this[offset] | this[offset + 1] << 8;
1095
+ };
1096
+ Buffer3.prototype.readUint16BE = Buffer3.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
1097
+ offset = offset >>> 0;
1098
+ if (!noAssert) checkOffset(offset, 2, this.length);
1099
+ return this[offset] << 8 | this[offset + 1];
1100
+ };
1101
+ Buffer3.prototype.readUint32LE = Buffer3.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
1102
+ offset = offset >>> 0;
1103
+ if (!noAssert) checkOffset(offset, 4, this.length);
1104
+ return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
1105
+ };
1106
+ Buffer3.prototype.readUint32BE = Buffer3.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
1107
+ offset = offset >>> 0;
1108
+ if (!noAssert) checkOffset(offset, 4, this.length);
1109
+ return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
1110
+ };
1111
+ Buffer3.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
1112
+ offset = offset >>> 0;
1113
+ validateNumber(offset, "offset");
1114
+ const first = this[offset];
1115
+ const last = this[offset + 7];
1116
+ if (first === void 0 || last === void 0) {
1117
+ boundsError(offset, this.length - 8);
1118
+ }
1119
+ const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
1120
+ const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
1121
+ return BigInt(lo) + (BigInt(hi) << BigInt(32));
1122
+ });
1123
+ Buffer3.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
1124
+ offset = offset >>> 0;
1125
+ validateNumber(offset, "offset");
1126
+ const first = this[offset];
1127
+ const last = this[offset + 7];
1128
+ if (first === void 0 || last === void 0) {
1129
+ boundsError(offset, this.length - 8);
1130
+ }
1131
+ const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
1132
+ const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
1133
+ return (BigInt(hi) << BigInt(32)) + BigInt(lo);
1134
+ });
1135
+ Buffer3.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
1136
+ offset = offset >>> 0;
1137
+ byteLength2 = byteLength2 >>> 0;
1138
+ if (!noAssert) checkOffset(offset, byteLength2, this.length);
1139
+ let val = this[offset];
1140
+ let mul = 1;
1141
+ let i = 0;
1142
+ while (++i < byteLength2 && (mul *= 256)) {
1143
+ val += this[offset + i] * mul;
1144
+ }
1145
+ mul *= 128;
1146
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
1147
+ return val;
1148
+ };
1149
+ Buffer3.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
1150
+ offset = offset >>> 0;
1151
+ byteLength2 = byteLength2 >>> 0;
1152
+ if (!noAssert) checkOffset(offset, byteLength2, this.length);
1153
+ let i = byteLength2;
1154
+ let mul = 1;
1155
+ let val = this[offset + --i];
1156
+ while (i > 0 && (mul *= 256)) {
1157
+ val += this[offset + --i] * mul;
1158
+ }
1159
+ mul *= 128;
1160
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
1161
+ return val;
1162
+ };
1163
+ Buffer3.prototype.readInt8 = function readInt8(offset, noAssert) {
1164
+ offset = offset >>> 0;
1165
+ if (!noAssert) checkOffset(offset, 1, this.length);
1166
+ if (!(this[offset] & 128)) return this[offset];
1167
+ return (255 - this[offset] + 1) * -1;
1168
+ };
1169
+ Buffer3.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
1170
+ offset = offset >>> 0;
1171
+ if (!noAssert) checkOffset(offset, 2, this.length);
1172
+ const val = this[offset] | this[offset + 1] << 8;
1173
+ return val & 32768 ? val | 4294901760 : val;
1174
+ };
1175
+ Buffer3.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
1176
+ offset = offset >>> 0;
1177
+ if (!noAssert) checkOffset(offset, 2, this.length);
1178
+ const val = this[offset + 1] | this[offset] << 8;
1179
+ return val & 32768 ? val | 4294901760 : val;
1180
+ };
1181
+ Buffer3.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
1182
+ offset = offset >>> 0;
1183
+ if (!noAssert) checkOffset(offset, 4, this.length);
1184
+ return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
1185
+ };
1186
+ Buffer3.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
1187
+ offset = offset >>> 0;
1188
+ if (!noAssert) checkOffset(offset, 4, this.length);
1189
+ return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
1190
+ };
1191
+ Buffer3.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
1192
+ offset = offset >>> 0;
1193
+ validateNumber(offset, "offset");
1194
+ const first = this[offset];
1195
+ const last = this[offset + 7];
1196
+ if (first === void 0 || last === void 0) {
1197
+ boundsError(offset, this.length - 8);
1198
+ }
1199
+ const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
1200
+ return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
1201
+ });
1202
+ Buffer3.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
1203
+ offset = offset >>> 0;
1204
+ validateNumber(offset, "offset");
1205
+ const first = this[offset];
1206
+ const last = this[offset + 7];
1207
+ if (first === void 0 || last === void 0) {
1208
+ boundsError(offset, this.length - 8);
1209
+ }
1210
+ const val = (first << 24) + // Overflow
1211
+ this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
1212
+ return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
1213
+ });
1214
+ Buffer3.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
1215
+ offset = offset >>> 0;
1216
+ if (!noAssert) checkOffset(offset, 4, this.length);
1217
+ return ieee754.read(this, offset, true, 23, 4);
1218
+ };
1219
+ Buffer3.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
1220
+ offset = offset >>> 0;
1221
+ if (!noAssert) checkOffset(offset, 4, this.length);
1222
+ return ieee754.read(this, offset, false, 23, 4);
1223
+ };
1224
+ Buffer3.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
1225
+ offset = offset >>> 0;
1226
+ if (!noAssert) checkOffset(offset, 8, this.length);
1227
+ return ieee754.read(this, offset, true, 52, 8);
1228
+ };
1229
+ Buffer3.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
1230
+ offset = offset >>> 0;
1231
+ if (!noAssert) checkOffset(offset, 8, this.length);
1232
+ return ieee754.read(this, offset, false, 52, 8);
1233
+ };
1234
+ function checkInt(buf, value, offset, ext, max, min) {
1235
+ if (!Buffer3.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
1236
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
1237
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
1238
+ }
1239
+ Buffer3.prototype.writeUintLE = Buffer3.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
1240
+ value = +value;
1241
+ offset = offset >>> 0;
1242
+ byteLength2 = byteLength2 >>> 0;
1243
+ if (!noAssert) {
1244
+ const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1245
+ checkInt(this, value, offset, byteLength2, maxBytes, 0);
1246
+ }
1247
+ let mul = 1;
1248
+ let i = 0;
1249
+ this[offset] = value & 255;
1250
+ while (++i < byteLength2 && (mul *= 256)) {
1251
+ this[offset + i] = value / mul & 255;
1252
+ }
1253
+ return offset + byteLength2;
1254
+ };
1255
+ Buffer3.prototype.writeUintBE = Buffer3.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
1256
+ value = +value;
1257
+ offset = offset >>> 0;
1258
+ byteLength2 = byteLength2 >>> 0;
1259
+ if (!noAssert) {
1260
+ const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1261
+ checkInt(this, value, offset, byteLength2, maxBytes, 0);
1262
+ }
1263
+ let i = byteLength2 - 1;
1264
+ let mul = 1;
1265
+ this[offset + i] = value & 255;
1266
+ while (--i >= 0 && (mul *= 256)) {
1267
+ this[offset + i] = value / mul & 255;
1268
+ }
1269
+ return offset + byteLength2;
1270
+ };
1271
+ Buffer3.prototype.writeUint8 = Buffer3.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
1272
+ value = +value;
1273
+ offset = offset >>> 0;
1274
+ if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
1275
+ this[offset] = value & 255;
1276
+ return offset + 1;
1277
+ };
1278
+ Buffer3.prototype.writeUint16LE = Buffer3.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
1279
+ value = +value;
1280
+ offset = offset >>> 0;
1281
+ if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
1282
+ this[offset] = value & 255;
1283
+ this[offset + 1] = value >>> 8;
1284
+ return offset + 2;
1285
+ };
1286
+ Buffer3.prototype.writeUint16BE = Buffer3.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
1287
+ value = +value;
1288
+ offset = offset >>> 0;
1289
+ if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
1290
+ this[offset] = value >>> 8;
1291
+ this[offset + 1] = value & 255;
1292
+ return offset + 2;
1293
+ };
1294
+ Buffer3.prototype.writeUint32LE = Buffer3.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
1295
+ value = +value;
1296
+ offset = offset >>> 0;
1297
+ if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
1298
+ this[offset + 3] = value >>> 24;
1299
+ this[offset + 2] = value >>> 16;
1300
+ this[offset + 1] = value >>> 8;
1301
+ this[offset] = value & 255;
1302
+ return offset + 4;
1303
+ };
1304
+ Buffer3.prototype.writeUint32BE = Buffer3.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
1305
+ value = +value;
1306
+ offset = offset >>> 0;
1307
+ if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
1308
+ this[offset] = value >>> 24;
1309
+ this[offset + 1] = value >>> 16;
1310
+ this[offset + 2] = value >>> 8;
1311
+ this[offset + 3] = value & 255;
1312
+ return offset + 4;
1313
+ };
1314
+ function wrtBigUInt64LE(buf, value, offset, min, max) {
1315
+ checkIntBI(value, min, max, buf, offset, 7);
1316
+ let lo = Number(value & BigInt(4294967295));
1317
+ buf[offset++] = lo;
1318
+ lo = lo >> 8;
1319
+ buf[offset++] = lo;
1320
+ lo = lo >> 8;
1321
+ buf[offset++] = lo;
1322
+ lo = lo >> 8;
1323
+ buf[offset++] = lo;
1324
+ let hi = Number(value >> BigInt(32) & BigInt(4294967295));
1325
+ buf[offset++] = hi;
1326
+ hi = hi >> 8;
1327
+ buf[offset++] = hi;
1328
+ hi = hi >> 8;
1329
+ buf[offset++] = hi;
1330
+ hi = hi >> 8;
1331
+ buf[offset++] = hi;
1332
+ return offset;
1333
+ }
1334
+ function wrtBigUInt64BE(buf, value, offset, min, max) {
1335
+ checkIntBI(value, min, max, buf, offset, 7);
1336
+ let lo = Number(value & BigInt(4294967295));
1337
+ buf[offset + 7] = lo;
1338
+ lo = lo >> 8;
1339
+ buf[offset + 6] = lo;
1340
+ lo = lo >> 8;
1341
+ buf[offset + 5] = lo;
1342
+ lo = lo >> 8;
1343
+ buf[offset + 4] = lo;
1344
+ let hi = Number(value >> BigInt(32) & BigInt(4294967295));
1345
+ buf[offset + 3] = hi;
1346
+ hi = hi >> 8;
1347
+ buf[offset + 2] = hi;
1348
+ hi = hi >> 8;
1349
+ buf[offset + 1] = hi;
1350
+ hi = hi >> 8;
1351
+ buf[offset] = hi;
1352
+ return offset + 8;
1353
+ }
1354
+ Buffer3.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
1355
+ return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1356
+ });
1357
+ Buffer3.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
1358
+ return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1359
+ });
1360
+ Buffer3.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
1361
+ value = +value;
1362
+ offset = offset >>> 0;
1363
+ if (!noAssert) {
1364
+ const limit = Math.pow(2, 8 * byteLength2 - 1);
1365
+ checkInt(this, value, offset, byteLength2, limit - 1, -limit);
1366
+ }
1367
+ let i = 0;
1368
+ let mul = 1;
1369
+ let sub = 0;
1370
+ this[offset] = value & 255;
1371
+ while (++i < byteLength2 && (mul *= 256)) {
1372
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1373
+ sub = 1;
1374
+ }
1375
+ this[offset + i] = (value / mul >> 0) - sub & 255;
1376
+ }
1377
+ return offset + byteLength2;
1378
+ };
1379
+ Buffer3.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
1380
+ value = +value;
1381
+ offset = offset >>> 0;
1382
+ if (!noAssert) {
1383
+ const limit = Math.pow(2, 8 * byteLength2 - 1);
1384
+ checkInt(this, value, offset, byteLength2, limit - 1, -limit);
1385
+ }
1386
+ let i = byteLength2 - 1;
1387
+ let mul = 1;
1388
+ let sub = 0;
1389
+ this[offset + i] = value & 255;
1390
+ while (--i >= 0 && (mul *= 256)) {
1391
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1392
+ sub = 1;
1393
+ }
1394
+ this[offset + i] = (value / mul >> 0) - sub & 255;
1395
+ }
1396
+ return offset + byteLength2;
1397
+ };
1398
+ Buffer3.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
1399
+ value = +value;
1400
+ offset = offset >>> 0;
1401
+ if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
1402
+ if (value < 0) value = 255 + value + 1;
1403
+ this[offset] = value & 255;
1404
+ return offset + 1;
1405
+ };
1406
+ Buffer3.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
1407
+ value = +value;
1408
+ offset = offset >>> 0;
1409
+ if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
1410
+ this[offset] = value & 255;
1411
+ this[offset + 1] = value >>> 8;
1412
+ return offset + 2;
1413
+ };
1414
+ Buffer3.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
1415
+ value = +value;
1416
+ offset = offset >>> 0;
1417
+ if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
1418
+ this[offset] = value >>> 8;
1419
+ this[offset + 1] = value & 255;
1420
+ return offset + 2;
1421
+ };
1422
+ Buffer3.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
1423
+ value = +value;
1424
+ offset = offset >>> 0;
1425
+ if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
1426
+ this[offset] = value & 255;
1427
+ this[offset + 1] = value >>> 8;
1428
+ this[offset + 2] = value >>> 16;
1429
+ this[offset + 3] = value >>> 24;
1430
+ return offset + 4;
1431
+ };
1432
+ Buffer3.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
1433
+ value = +value;
1434
+ offset = offset >>> 0;
1435
+ if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
1436
+ if (value < 0) value = 4294967295 + value + 1;
1437
+ this[offset] = value >>> 24;
1438
+ this[offset + 1] = value >>> 16;
1439
+ this[offset + 2] = value >>> 8;
1440
+ this[offset + 3] = value & 255;
1441
+ return offset + 4;
1442
+ };
1443
+ Buffer3.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
1444
+ return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1445
+ });
1446
+ Buffer3.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
1447
+ return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1448
+ });
1449
+ function checkIEEE754(buf, value, offset, ext, max, min) {
1450
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
1451
+ if (offset < 0) throw new RangeError("Index out of range");
1452
+ }
1453
+ function writeFloat(buf, value, offset, littleEndian, noAssert) {
1454
+ value = +value;
1455
+ offset = offset >>> 0;
1456
+ if (!noAssert) {
1457
+ checkIEEE754(buf, value, offset, 4, 34028234663852886e22, -34028234663852886e22);
1458
+ }
1459
+ ieee754.write(buf, value, offset, littleEndian, 23, 4);
1460
+ return offset + 4;
1461
+ }
1462
+ Buffer3.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
1463
+ return writeFloat(this, value, offset, true, noAssert);
1464
+ };
1465
+ Buffer3.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
1466
+ return writeFloat(this, value, offset, false, noAssert);
1467
+ };
1468
+ function writeDouble(buf, value, offset, littleEndian, noAssert) {
1469
+ value = +value;
1470
+ offset = offset >>> 0;
1471
+ if (!noAssert) {
1472
+ checkIEEE754(buf, value, offset, 8, 17976931348623157e292, -17976931348623157e292);
1473
+ }
1474
+ ieee754.write(buf, value, offset, littleEndian, 52, 8);
1475
+ return offset + 8;
1476
+ }
1477
+ Buffer3.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
1478
+ return writeDouble(this, value, offset, true, noAssert);
1479
+ };
1480
+ Buffer3.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
1481
+ return writeDouble(this, value, offset, false, noAssert);
1482
+ };
1483
+ Buffer3.prototype.copy = function copy(target, targetStart, start, end) {
1484
+ if (!Buffer3.isBuffer(target)) throw new TypeError("argument should be a Buffer");
1485
+ if (!start) start = 0;
1486
+ if (!end && end !== 0) end = this.length;
1487
+ if (targetStart >= target.length) targetStart = target.length;
1488
+ if (!targetStart) targetStart = 0;
1489
+ if (end > 0 && end < start) end = start;
1490
+ if (end === start) return 0;
1491
+ if (target.length === 0 || this.length === 0) return 0;
1492
+ if (targetStart < 0) {
1493
+ throw new RangeError("targetStart out of bounds");
1494
+ }
1495
+ if (start < 0 || start >= this.length) throw new RangeError("Index out of range");
1496
+ if (end < 0) throw new RangeError("sourceEnd out of bounds");
1497
+ if (end > this.length) end = this.length;
1498
+ if (target.length - targetStart < end - start) {
1499
+ end = target.length - targetStart + start;
1500
+ }
1501
+ const len = end - start;
1502
+ if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
1503
+ this.copyWithin(targetStart, start, end);
1504
+ } else {
1505
+ Uint8Array.prototype.set.call(
1506
+ target,
1507
+ this.subarray(start, end),
1508
+ targetStart
1509
+ );
1510
+ }
1511
+ return len;
1512
+ };
1513
+ Buffer3.prototype.fill = function fill(val, start, end, encoding) {
1514
+ if (typeof val === "string") {
1515
+ if (typeof start === "string") {
1516
+ encoding = start;
1517
+ start = 0;
1518
+ end = this.length;
1519
+ } else if (typeof end === "string") {
1520
+ encoding = end;
1521
+ end = this.length;
1522
+ }
1523
+ if (encoding !== void 0 && typeof encoding !== "string") {
1524
+ throw new TypeError("encoding must be a string");
1525
+ }
1526
+ if (typeof encoding === "string" && !Buffer3.isEncoding(encoding)) {
1527
+ throw new TypeError("Unknown encoding: " + encoding);
1528
+ }
1529
+ if (val.length === 1) {
1530
+ const code = val.charCodeAt(0);
1531
+ if (encoding === "utf8" && code < 128 || encoding === "latin1") {
1532
+ val = code;
1533
+ }
1534
+ }
1535
+ } else if (typeof val === "number") {
1536
+ val = val & 255;
1537
+ } else if (typeof val === "boolean") {
1538
+ val = Number(val);
1539
+ }
1540
+ if (start < 0 || this.length < start || this.length < end) {
1541
+ throw new RangeError("Out of range index");
1542
+ }
1543
+ if (end <= start) {
1544
+ return this;
1545
+ }
1546
+ start = start >>> 0;
1547
+ end = end === void 0 ? this.length : end >>> 0;
1548
+ if (!val) val = 0;
1549
+ let i;
1550
+ if (typeof val === "number") {
1551
+ for (i = start; i < end; ++i) {
1552
+ this[i] = val;
1553
+ }
1554
+ } else {
1555
+ const bytes = Buffer3.isBuffer(val) ? val : Buffer3.from(val, encoding);
1556
+ const len = bytes.length;
1557
+ if (len === 0) {
1558
+ throw new TypeError('The value "' + val + '" is invalid for argument "value"');
1559
+ }
1560
+ for (i = 0; i < end - start; ++i) {
1561
+ this[i + start] = bytes[i % len];
1562
+ }
1563
+ }
1564
+ return this;
1565
+ };
1566
+ var errors = {};
1567
+ function E(sym, getMessage, Base) {
1568
+ errors[sym] = class NodeError extends Base {
1569
+ constructor() {
1570
+ super();
1571
+ Object.defineProperty(this, "message", {
1572
+ value: getMessage.apply(this, arguments),
1573
+ writable: true,
1574
+ configurable: true
1575
+ });
1576
+ this.name = `${this.name} [${sym}]`;
1577
+ this.stack;
1578
+ delete this.name;
1579
+ }
1580
+ get code() {
1581
+ return sym;
1582
+ }
1583
+ set code(value) {
1584
+ Object.defineProperty(this, "code", {
1585
+ configurable: true,
1586
+ enumerable: true,
1587
+ value,
1588
+ writable: true
1589
+ });
1590
+ }
1591
+ toString() {
1592
+ return `${this.name} [${sym}]: ${this.message}`;
1593
+ }
1594
+ };
1595
+ }
1596
+ E(
1597
+ "ERR_BUFFER_OUT_OF_BOUNDS",
1598
+ function(name) {
1599
+ if (name) {
1600
+ return `${name} is outside of buffer bounds`;
1601
+ }
1602
+ return "Attempt to access memory outside buffer bounds";
1603
+ },
1604
+ RangeError
1605
+ );
1606
+ E(
1607
+ "ERR_INVALID_ARG_TYPE",
1608
+ function(name, actual) {
1609
+ return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
1610
+ },
1611
+ TypeError
1612
+ );
1613
+ E(
1614
+ "ERR_OUT_OF_RANGE",
1615
+ function(str, range, input) {
1616
+ let msg = `The value of "${str}" is out of range.`;
1617
+ let received = input;
1618
+ if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
1619
+ received = addNumericalSeparator(String(input));
1620
+ } else if (typeof input === "bigint") {
1621
+ received = String(input);
1622
+ if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
1623
+ received = addNumericalSeparator(received);
1624
+ }
1625
+ received += "n";
1626
+ }
1627
+ msg += ` It must be ${range}. Received ${received}`;
1628
+ return msg;
1629
+ },
1630
+ RangeError
1631
+ );
1632
+ function addNumericalSeparator(val) {
1633
+ let res = "";
1634
+ let i = val.length;
1635
+ const start = val[0] === "-" ? 1 : 0;
1636
+ for (; i >= start + 4; i -= 3) {
1637
+ res = `_${val.slice(i - 3, i)}${res}`;
1638
+ }
1639
+ return `${val.slice(0, i)}${res}`;
1640
+ }
1641
+ function checkBounds(buf, offset, byteLength2) {
1642
+ validateNumber(offset, "offset");
1643
+ if (buf[offset] === void 0 || buf[offset + byteLength2] === void 0) {
1644
+ boundsError(offset, buf.length - (byteLength2 + 1));
1645
+ }
1646
+ }
1647
+ function checkIntBI(value, min, max, buf, offset, byteLength2) {
1648
+ if (value > max || value < min) {
1649
+ const n = typeof min === "bigint" ? "n" : "";
1650
+ let range;
1651
+ if (byteLength2 > 3) {
1652
+ if (min === 0 || min === BigInt(0)) {
1653
+ range = `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}`;
1654
+ } else {
1655
+ range = `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n}`;
1656
+ }
1657
+ } else {
1658
+ range = `>= ${min}${n} and <= ${max}${n}`;
1659
+ }
1660
+ throw new errors.ERR_OUT_OF_RANGE("value", range, value);
1661
+ }
1662
+ checkBounds(buf, offset, byteLength2);
1663
+ }
1664
+ function validateNumber(value, name) {
1665
+ if (typeof value !== "number") {
1666
+ throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
1667
+ }
1668
+ }
1669
+ function boundsError(value, length, type) {
1670
+ if (Math.floor(value) !== value) {
1671
+ validateNumber(value, type);
1672
+ throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer", value);
1673
+ }
1674
+ if (length < 0) {
1675
+ throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
1676
+ }
1677
+ throw new errors.ERR_OUT_OF_RANGE(
1678
+ type || "offset",
1679
+ `>= ${type ? 1 : 0} and <= ${length}`,
1680
+ value
1681
+ );
1682
+ }
1683
+ var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
1684
+ function base64clean(str) {
1685
+ str = str.split("=")[0];
1686
+ str = str.trim().replace(INVALID_BASE64_RE, "");
1687
+ if (str.length < 2) return "";
1688
+ while (str.length % 4 !== 0) {
1689
+ str = str + "=";
1690
+ }
1691
+ return str;
1692
+ }
1693
+ function utf8ToBytes(string, units) {
1694
+ units = units || Infinity;
1695
+ let codePoint;
1696
+ const length = string.length;
1697
+ let leadSurrogate = null;
1698
+ const bytes = [];
1699
+ for (let i = 0; i < length; ++i) {
1700
+ codePoint = string.charCodeAt(i);
1701
+ if (codePoint > 55295 && codePoint < 57344) {
1702
+ if (!leadSurrogate) {
1703
+ if (codePoint > 56319) {
1704
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
1705
+ continue;
1706
+ } else if (i + 1 === length) {
1707
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
1708
+ continue;
1709
+ }
1710
+ leadSurrogate = codePoint;
1711
+ continue;
1712
+ }
1713
+ if (codePoint < 56320) {
1714
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
1715
+ leadSurrogate = codePoint;
1716
+ continue;
1717
+ }
1718
+ codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
1719
+ } else if (leadSurrogate) {
1720
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
1721
+ }
1722
+ leadSurrogate = null;
1723
+ if (codePoint < 128) {
1724
+ if ((units -= 1) < 0) break;
1725
+ bytes.push(codePoint);
1726
+ } else if (codePoint < 2048) {
1727
+ if ((units -= 2) < 0) break;
1728
+ bytes.push(
1729
+ codePoint >> 6 | 192,
1730
+ codePoint & 63 | 128
1731
+ );
1732
+ } else if (codePoint < 65536) {
1733
+ if ((units -= 3) < 0) break;
1734
+ bytes.push(
1735
+ codePoint >> 12 | 224,
1736
+ codePoint >> 6 & 63 | 128,
1737
+ codePoint & 63 | 128
1738
+ );
1739
+ } else if (codePoint < 1114112) {
1740
+ if ((units -= 4) < 0) break;
1741
+ bytes.push(
1742
+ codePoint >> 18 | 240,
1743
+ codePoint >> 12 & 63 | 128,
1744
+ codePoint >> 6 & 63 | 128,
1745
+ codePoint & 63 | 128
1746
+ );
1747
+ } else {
1748
+ throw new Error("Invalid code point");
1749
+ }
1750
+ }
1751
+ return bytes;
1752
+ }
1753
+ function asciiToBytes(str) {
1754
+ const byteArray = [];
1755
+ for (let i = 0; i < str.length; ++i) {
1756
+ byteArray.push(str.charCodeAt(i) & 255);
1757
+ }
1758
+ return byteArray;
1759
+ }
1760
+ function utf16leToBytes(str, units) {
1761
+ let c, hi, lo;
1762
+ const byteArray = [];
1763
+ for (let i = 0; i < str.length; ++i) {
1764
+ if ((units -= 2) < 0) break;
1765
+ c = str.charCodeAt(i);
1766
+ hi = c >> 8;
1767
+ lo = c % 256;
1768
+ byteArray.push(lo);
1769
+ byteArray.push(hi);
1770
+ }
1771
+ return byteArray;
1772
+ }
1773
+ function base64ToBytes(str) {
1774
+ return base64.toByteArray(base64clean(str));
1775
+ }
1776
+ function blitBuffer(src, dst, offset, length) {
1777
+ let i;
1778
+ for (i = 0; i < length; ++i) {
1779
+ if (i + offset >= dst.length || i >= src.length) break;
1780
+ dst[i + offset] = src[i];
1781
+ }
1782
+ return i;
1783
+ }
1784
+ function isInstance(obj, type) {
1785
+ return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
1786
+ }
1787
+ function numberIsNaN(obj) {
1788
+ return obj !== obj;
1789
+ }
1790
+ var hexSliceLookupTable = function() {
1791
+ const alphabet = "0123456789abcdef";
1792
+ const table = new Array(256);
1793
+ for (let i = 0; i < 16; ++i) {
1794
+ const i16 = i * 16;
1795
+ for (let j = 0; j < 16; ++j) {
1796
+ table[i16 + j] = alphabet[i] + alphabet[j];
1797
+ }
1798
+ }
1799
+ return table;
1800
+ }();
1801
+ function defineBigIntMethod(fn) {
1802
+ return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
1803
+ }
1804
+ function BufferBigIntNotDefined() {
1805
+ throw new Error("BigInt not supported");
1806
+ }
1807
+ }
1808
+ });
1809
+
30
1810
  // src/index.ts
31
1811
  var index_exports = {};
32
1812
  __export(index_exports, {
33
1813
  BONDING_CURVE_NEW_SIZE: () => BONDING_CURVE_NEW_SIZE,
34
1814
  CANONICAL_POOL_INDEX: () => CANONICAL_POOL_INDEX,
1815
+ GLOBAL_PDA: () => GLOBAL_PDA,
1816
+ GLOBAL_VOLUME_ACCUMULATOR_PDA: () => GLOBAL_VOLUME_ACCUMULATOR_PDA,
1817
+ OnlinePumpSdk: () => OnlinePumpSdk,
35
1818
  PUMP_AMM_PROGRAM_ID: () => PUMP_AMM_PROGRAM_ID,
1819
+ PUMP_FEE_CONFIG_PDA: () => PUMP_FEE_CONFIG_PDA,
36
1820
  PUMP_PROGRAM_ID: () => PUMP_PROGRAM_ID,
1821
+ PUMP_SDK: () => PUMP_SDK,
37
1822
  PumpSdk: () => PumpSdk,
38
1823
  bondingCurveMarketCap: () => bondingCurveMarketCap,
39
1824
  bondingCurvePda: () => bondingCurvePda,
@@ -48,10 +1833,7 @@ __export(index_exports, {
48
1833
  getPumpProgram: () => getPumpProgram,
49
1834
  getSellSolAmountFromTokenAmount: () => getSellSolAmountFromTokenAmount,
50
1835
  getSellSolAmountFromTokenAmountQuote: () => getSellSolAmountFromTokenAmountQuote,
51
- globalPda: () => globalPda,
52
- globalVolumeAccumulatorPda: () => globalVolumeAccumulatorPda,
53
1836
  newBondingCurve: () => newBondingCurve,
54
- pumpFeeConfigPda: () => pumpFeeConfigPda,
55
1837
  pumpIdl: () => pump_default,
56
1838
  pumpPoolAuthorityPda: () => pumpPoolAuthorityPda,
57
1839
  totalUnclaimedTokens: () => totalUnclaimedTokens,
@@ -5037,12 +6819,18 @@ function ceilDiv(a, b) {
5037
6819
  }
5038
6820
 
5039
6821
  // src/pda.ts
5040
- var import_web34 = require("@solana/web3.js");
5041
- var import_spl_token2 = require("@solana/spl-token");
5042
- var import_pump_swap_sdk2 = require("@pump-fun/pump-swap-sdk");
6822
+ var import_web35 = require("@solana/web3.js");
6823
+ var import_spl_token3 = require("@solana/spl-token");
6824
+ var import_pump_swap_sdk3 = require("@pump-fun/pump-swap-sdk");
5043
6825
 
5044
6826
  // src/sdk.ts
5045
6827
  var import_anchor = require("@coral-xyz/anchor");
6828
+ var import_pump_swap_sdk2 = require("@pump-fun/pump-swap-sdk");
6829
+ var import_spl_token2 = require("@solana/spl-token");
6830
+ var import_web34 = require("@solana/web3.js");
6831
+ var import_bn5 = __toESM(require("bn.js"));
6832
+
6833
+ // src/onlineSdk.ts
5046
6834
  var import_pump_swap_sdk = require("@pump-fun/pump-swap-sdk");
5047
6835
  var import_spl_token = require("@solana/spl-token");
5048
6836
  var import_web33 = require("@solana/web3.js");
@@ -5108,8 +6896,281 @@ function currentDayTokens(globalVolumeAccumulator, userVolumeAccumulator, curren
5108
6896
  if (currentDaySolVolume.eqn(0)) {
5109
6897
  return new import_bn3.default(0);
5110
6898
  }
5111
- return currentSolVolume.mul(currentDayTokenSupply).div(currentDaySolVolume);
5112
- }
6899
+ return currentSolVolume.mul(currentDayTokenSupply).div(currentDaySolVolume);
6900
+ }
6901
+
6902
+ // src/onlineSdk.ts
6903
+ var OFFLINE_PUMP_PROGRAM = getPumpProgram(null);
6904
+ var OnlinePumpSdk = class {
6905
+ constructor(connection) {
6906
+ this.connection = connection;
6907
+ this.pumpProgram = getPumpProgram(connection);
6908
+ this.offlinePumpProgram = OFFLINE_PUMP_PROGRAM;
6909
+ this.pumpAmmSdk = new import_pump_swap_sdk.OnlinePumpAmmSdk(connection);
6910
+ this.pumpAmmAdminSdk = new import_pump_swap_sdk.PumpAmmAdminSdk(connection);
6911
+ }
6912
+ async fetchGlobal() {
6913
+ return await this.pumpProgram.account.global.fetch(GLOBAL_PDA);
6914
+ }
6915
+ async fetchFeeConfig() {
6916
+ return await this.pumpProgram.account.feeConfig.fetch(PUMP_FEE_CONFIG_PDA);
6917
+ }
6918
+ async fetchBondingCurve(mint) {
6919
+ return await this.pumpProgram.account.bondingCurve.fetch(
6920
+ bondingCurvePda(mint)
6921
+ );
6922
+ }
6923
+ async fetchBuyState(mint, user) {
6924
+ const [bondingCurveAccountInfo, associatedUserAccountInfo] = await this.connection.getMultipleAccountsInfo([
6925
+ bondingCurvePda(mint),
6926
+ (0, import_spl_token.getAssociatedTokenAddressSync)(mint, user, true)
6927
+ ]);
6928
+ if (!bondingCurveAccountInfo) {
6929
+ throw new Error(
6930
+ `Bonding curve account not found for mint: ${mint.toBase58()}`
6931
+ );
6932
+ }
6933
+ const bondingCurve = PUMP_SDK.decodeBondingCurve(bondingCurveAccountInfo);
6934
+ return { bondingCurveAccountInfo, bondingCurve, associatedUserAccountInfo };
6935
+ }
6936
+ async fetchSellState(mint, user) {
6937
+ const [bondingCurveAccountInfo, associatedUserAccountInfo] = await this.connection.getMultipleAccountsInfo([
6938
+ bondingCurvePda(mint),
6939
+ (0, import_spl_token.getAssociatedTokenAddressSync)(mint, user, true)
6940
+ ]);
6941
+ if (!bondingCurveAccountInfo) {
6942
+ throw new Error(
6943
+ `Bonding curve account not found for mint: ${mint.toBase58()}`
6944
+ );
6945
+ }
6946
+ if (!associatedUserAccountInfo) {
6947
+ throw new Error(
6948
+ `Associated token account not found for mint: ${mint.toBase58()} and user: ${user.toBase58()}`
6949
+ );
6950
+ }
6951
+ const bondingCurve = PUMP_SDK.decodeBondingCurve(bondingCurveAccountInfo);
6952
+ return { bondingCurveAccountInfo, bondingCurve };
6953
+ }
6954
+ async fetchGlobalVolumeAccumulator() {
6955
+ return await this.pumpProgram.account.globalVolumeAccumulator.fetch(
6956
+ GLOBAL_VOLUME_ACCUMULATOR_PDA
6957
+ );
6958
+ }
6959
+ async fetchUserVolumeAccumulator(user) {
6960
+ return await this.pumpProgram.account.userVolumeAccumulator.fetchNullable(
6961
+ userVolumeAccumulatorPda(user)
6962
+ );
6963
+ }
6964
+ async fetchUserVolumeAccumulatorTotalStats(user) {
6965
+ const userVolumeAccumulator = await this.fetchUserVolumeAccumulator(
6966
+ user
6967
+ ) ?? {
6968
+ totalUnclaimedTokens: new import_bn4.default(0),
6969
+ totalClaimedTokens: new import_bn4.default(0),
6970
+ currentSolVolume: new import_bn4.default(0)
6971
+ };
6972
+ const userVolumeAccumulatorAmm = await this.pumpAmmSdk.fetchUserVolumeAccumulator(user) ?? {
6973
+ totalUnclaimedTokens: new import_bn4.default(0),
6974
+ totalClaimedTokens: new import_bn4.default(0),
6975
+ currentSolVolume: new import_bn4.default(0)
6976
+ };
6977
+ return {
6978
+ totalUnclaimedTokens: userVolumeAccumulator.totalUnclaimedTokens.add(
6979
+ userVolumeAccumulatorAmm.totalUnclaimedTokens
6980
+ ),
6981
+ totalClaimedTokens: userVolumeAccumulator.totalClaimedTokens.add(
6982
+ userVolumeAccumulatorAmm.totalClaimedTokens
6983
+ ),
6984
+ currentSolVolume: userVolumeAccumulator.currentSolVolume.add(
6985
+ userVolumeAccumulatorAmm.currentSolVolume
6986
+ )
6987
+ };
6988
+ }
6989
+ async collectCoinCreatorFeeInstructions(coinCreator) {
6990
+ let quoteMint = import_spl_token.NATIVE_MINT;
6991
+ let quoteTokenProgram = import_spl_token.TOKEN_PROGRAM_ID;
6992
+ let coinCreatorVaultAuthority = (0, import_pump_swap_sdk.coinCreatorVaultAuthorityPda)(coinCreator);
6993
+ let coinCreatorVaultAta = (0, import_pump_swap_sdk.coinCreatorVaultAtaPda)(
6994
+ coinCreatorVaultAuthority,
6995
+ quoteMint,
6996
+ quoteTokenProgram
6997
+ );
6998
+ let coinCreatorTokenAccount = (0, import_spl_token.getAssociatedTokenAddressSync)(
6999
+ quoteMint,
7000
+ coinCreator,
7001
+ true,
7002
+ quoteTokenProgram
7003
+ );
7004
+ const [coinCreatorVaultAtaAccountInfo, coinCreatorTokenAccountInfo] = await this.connection.getMultipleAccountsInfo([
7005
+ coinCreatorVaultAta,
7006
+ coinCreatorTokenAccount
7007
+ ]);
7008
+ return [
7009
+ await this.offlinePumpProgram.methods.collectCreatorFee().accountsPartial({
7010
+ creator: coinCreator
7011
+ }).instruction(),
7012
+ ...await import_pump_swap_sdk.PUMP_AMM_SDK.collectCoinCreatorFee({
7013
+ coinCreator,
7014
+ quoteMint,
7015
+ quoteTokenProgram,
7016
+ coinCreatorVaultAuthority,
7017
+ coinCreatorVaultAta,
7018
+ coinCreatorTokenAccount,
7019
+ coinCreatorVaultAtaAccountInfo,
7020
+ coinCreatorTokenAccountInfo
7021
+ })
7022
+ ];
7023
+ }
7024
+ async adminSetCoinCreatorInstructions(newCoinCreator, mint) {
7025
+ const global = await this.fetchGlobal();
7026
+ return [
7027
+ await this.offlinePumpProgram.methods.adminSetCreator(newCoinCreator).accountsPartial({
7028
+ adminSetCreatorAuthority: global.adminSetCreatorAuthority,
7029
+ mint
7030
+ }).instruction(),
7031
+ await this.pumpAmmAdminSdk.adminSetCoinCreator(mint, newCoinCreator)
7032
+ ];
7033
+ }
7034
+ async getCreatorVaultBalance(creator) {
7035
+ const creatorVault = creatorVaultPda(creator);
7036
+ const accountInfo = await this.connection.getAccountInfo(creatorVault);
7037
+ if (accountInfo === null) {
7038
+ return new import_bn4.default(0);
7039
+ }
7040
+ const rentExemptionLamports = await this.connection.getMinimumBalanceForRentExemption(
7041
+ accountInfo.data.length
7042
+ );
7043
+ if (accountInfo.lamports < rentExemptionLamports) {
7044
+ return new import_bn4.default(0);
7045
+ }
7046
+ return new import_bn4.default(accountInfo.lamports - rentExemptionLamports);
7047
+ }
7048
+ async getCreatorVaultBalanceBothPrograms(creator) {
7049
+ const balance = await this.getCreatorVaultBalance(creator);
7050
+ const ammBalance = await this.pumpAmmSdk.getCoinCreatorVaultBalance(creator);
7051
+ return balance.add(ammBalance);
7052
+ }
7053
+ async adminUpdateTokenIncentives(startTime, endTime, dayNumber, tokenSupplyPerDay, secondsInADay = new import_bn4.default(86400), mint = PUMP_TOKEN_MINT, tokenProgram = import_spl_token.TOKEN_2022_PROGRAM_ID) {
7054
+ const { authority } = await this.fetchGlobal();
7055
+ return await this.offlinePumpProgram.methods.adminUpdateTokenIncentives(
7056
+ startTime,
7057
+ endTime,
7058
+ secondsInADay,
7059
+ dayNumber,
7060
+ tokenSupplyPerDay
7061
+ ).accountsPartial({
7062
+ authority,
7063
+ mint,
7064
+ tokenProgram
7065
+ }).instruction();
7066
+ }
7067
+ async adminUpdateTokenIncentivesBothPrograms(startTime, endTime, dayNumber, tokenSupplyPerDay, secondsInADay = new import_bn4.default(86400), mint = PUMP_TOKEN_MINT, tokenProgram = import_spl_token.TOKEN_2022_PROGRAM_ID) {
7068
+ return [
7069
+ await this.adminUpdateTokenIncentives(
7070
+ startTime,
7071
+ endTime,
7072
+ dayNumber,
7073
+ tokenSupplyPerDay,
7074
+ secondsInADay,
7075
+ mint,
7076
+ tokenProgram
7077
+ ),
7078
+ await this.pumpAmmAdminSdk.adminUpdateTokenIncentives(
7079
+ startTime,
7080
+ endTime,
7081
+ dayNumber,
7082
+ tokenSupplyPerDay,
7083
+ secondsInADay,
7084
+ mint,
7085
+ tokenProgram
7086
+ )
7087
+ ];
7088
+ }
7089
+ async claimTokenIncentives(user, payer) {
7090
+ const { mint } = await this.fetchGlobalVolumeAccumulator();
7091
+ if (mint.equals(import_web33.PublicKey.default)) {
7092
+ return [];
7093
+ }
7094
+ const [mintAccountInfo, userAccumulatorAccountInfo] = await this.connection.getMultipleAccountsInfo([
7095
+ mint,
7096
+ userVolumeAccumulatorPda(user)
7097
+ ]);
7098
+ if (!mintAccountInfo) {
7099
+ return [];
7100
+ }
7101
+ if (!userAccumulatorAccountInfo) {
7102
+ return [];
7103
+ }
7104
+ return [
7105
+ await this.offlinePumpProgram.methods.claimTokenIncentives().accountsPartial({
7106
+ user,
7107
+ payer,
7108
+ mint,
7109
+ tokenProgram: mintAccountInfo.owner
7110
+ }).instruction()
7111
+ ];
7112
+ }
7113
+ async claimTokenIncentivesBothPrograms(user, payer) {
7114
+ return [
7115
+ ...await this.claimTokenIncentives(user, payer),
7116
+ ...await this.pumpAmmSdk.claimTokenIncentives(user, payer)
7117
+ ];
7118
+ }
7119
+ async getTotalUnclaimedTokens(user) {
7120
+ const [
7121
+ globalVolumeAccumulatorAccountInfo,
7122
+ userVolumeAccumulatorAccountInfo
7123
+ ] = await this.connection.getMultipleAccountsInfo([
7124
+ GLOBAL_VOLUME_ACCUMULATOR_PDA,
7125
+ userVolumeAccumulatorPda(user)
7126
+ ]);
7127
+ if (!globalVolumeAccumulatorAccountInfo || !userVolumeAccumulatorAccountInfo) {
7128
+ return new import_bn4.default(0);
7129
+ }
7130
+ const globalVolumeAccumulator = PUMP_SDK.decodeGlobalVolumeAccumulator(
7131
+ globalVolumeAccumulatorAccountInfo
7132
+ );
7133
+ const userVolumeAccumulator = PUMP_SDK.decodeUserVolumeAccumulator(
7134
+ userVolumeAccumulatorAccountInfo
7135
+ );
7136
+ return totalUnclaimedTokens(globalVolumeAccumulator, userVolumeAccumulator);
7137
+ }
7138
+ async getTotalUnclaimedTokensBothPrograms(user) {
7139
+ return (await this.getTotalUnclaimedTokens(user)).add(
7140
+ await this.pumpAmmSdk.getTotalUnclaimedTokens(user)
7141
+ );
7142
+ }
7143
+ async getCurrentDayTokens(user) {
7144
+ const [
7145
+ globalVolumeAccumulatorAccountInfo,
7146
+ userVolumeAccumulatorAccountInfo
7147
+ ] = await this.connection.getMultipleAccountsInfo([
7148
+ GLOBAL_VOLUME_ACCUMULATOR_PDA,
7149
+ userVolumeAccumulatorPda(user)
7150
+ ]);
7151
+ if (!globalVolumeAccumulatorAccountInfo || !userVolumeAccumulatorAccountInfo) {
7152
+ return new import_bn4.default(0);
7153
+ }
7154
+ const globalVolumeAccumulator = PUMP_SDK.decodeGlobalVolumeAccumulator(
7155
+ globalVolumeAccumulatorAccountInfo
7156
+ );
7157
+ const userVolumeAccumulator = PUMP_SDK.decodeUserVolumeAccumulator(
7158
+ userVolumeAccumulatorAccountInfo
7159
+ );
7160
+ return currentDayTokens(globalVolumeAccumulator, userVolumeAccumulator);
7161
+ }
7162
+ async getCurrentDayTokensBothPrograms(user) {
7163
+ return (await this.getCurrentDayTokens(user)).add(
7164
+ await this.pumpAmmSdk.getCurrentDayTokens(user)
7165
+ );
7166
+ }
7167
+ async syncUserVolumeAccumulatorBothPrograms(user) {
7168
+ return [
7169
+ await PUMP_SDK.syncUserVolumeAccumulator(user),
7170
+ await import_pump_swap_sdk.PUMP_AMM_SDK.syncUserVolumeAccumulator(user)
7171
+ ];
7172
+ }
7173
+ };
5113
7174
 
5114
7175
  // src/sdk.ts
5115
7176
  function getPumpProgram(connection) {
@@ -5118,29 +7179,22 @@ function getPumpProgram(connection) {
5118
7179
  new import_anchor.AnchorProvider(connection, null, {})
5119
7180
  );
5120
7181
  }
5121
- var PUMP_PROGRAM_ID = new import_web33.PublicKey(
7182
+ var PUMP_PROGRAM_ID = new import_web34.PublicKey(
5122
7183
  "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"
5123
7184
  );
5124
- var PUMP_AMM_PROGRAM_ID = new import_web33.PublicKey(
7185
+ var PUMP_AMM_PROGRAM_ID = new import_web34.PublicKey(
5125
7186
  "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA"
5126
7187
  );
5127
- var PUMP_FEE_PROGRAM_ID = new import_web33.PublicKey(
7188
+ var PUMP_FEE_PROGRAM_ID = new import_web34.PublicKey(
5128
7189
  "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
5129
7190
  );
5130
7191
  var BONDING_CURVE_NEW_SIZE = 150;
5131
- var PUMP_TOKEN_MINT = new import_web33.PublicKey(
7192
+ var PUMP_TOKEN_MINT = new import_web34.PublicKey(
5132
7193
  "pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn"
5133
7194
  );
5134
7195
  var PumpSdk = class {
5135
- constructor(connection) {
5136
- this.connection = connection;
5137
- this.pumpProgram = getPumpProgram(connection);
5138
- this.offlinePumpProgram = getPumpProgram(null);
5139
- this.pumpAmmSdk = new import_pump_swap_sdk.PumpAmmSdk(connection);
5140
- this.pumpAmmAdminSdk = new import_pump_swap_sdk.PumpAmmAdminSdk(connection);
5141
- }
5142
- programId() {
5143
- return this.offlinePumpProgram.programId;
7196
+ constructor() {
7197
+ this.offlinePumpProgram = OFFLINE_PUMP_PROGRAM;
5144
7198
  }
5145
7199
  decodeGlobal(accountInfo) {
5146
7200
  return this.offlinePumpProgram.coder.accounts.decode(
@@ -5188,83 +7242,6 @@ var PumpSdk = class {
5188
7242
  return null;
5189
7243
  }
5190
7244
  }
5191
- async fetchGlobal() {
5192
- return await this.pumpProgram.account.global.fetch(globalPda());
5193
- }
5194
- async fetchFeeConfig() {
5195
- return await this.pumpProgram.account.feeConfig.fetch(pumpFeeConfigPda());
5196
- }
5197
- async fetchBondingCurve(mint) {
5198
- return await this.pumpProgram.account.bondingCurve.fetch(
5199
- bondingCurvePda(mint)
5200
- );
5201
- }
5202
- async fetchBuyState(mint, user) {
5203
- const [bondingCurveAccountInfo, associatedUserAccountInfo] = await this.connection.getMultipleAccountsInfo([
5204
- bondingCurvePda(mint),
5205
- (0, import_spl_token.getAssociatedTokenAddressSync)(mint, user, true)
5206
- ]);
5207
- if (!bondingCurveAccountInfo) {
5208
- throw new Error(
5209
- `Bonding curve account not found for mint: ${mint.toBase58()}`
5210
- );
5211
- }
5212
- const bondingCurve = this.decodeBondingCurve(bondingCurveAccountInfo);
5213
- return { bondingCurveAccountInfo, bondingCurve, associatedUserAccountInfo };
5214
- }
5215
- async fetchSellState(mint, user) {
5216
- const [bondingCurveAccountInfo, associatedUserAccountInfo] = await this.connection.getMultipleAccountsInfo([
5217
- bondingCurvePda(mint),
5218
- (0, import_spl_token.getAssociatedTokenAddressSync)(mint, user, true)
5219
- ]);
5220
- if (!bondingCurveAccountInfo) {
5221
- throw new Error(
5222
- `Bonding curve account not found for mint: ${mint.toBase58()}`
5223
- );
5224
- }
5225
- if (!associatedUserAccountInfo) {
5226
- throw new Error(
5227
- `Associated token account not found for mint: ${mint.toBase58()} and user: ${user.toBase58()}`
5228
- );
5229
- }
5230
- const bondingCurve = this.decodeBondingCurve(bondingCurveAccountInfo);
5231
- return { bondingCurveAccountInfo, bondingCurve };
5232
- }
5233
- async fetchGlobalVolumeAccumulator() {
5234
- return await this.pumpProgram.account.globalVolumeAccumulator.fetch(
5235
- globalVolumeAccumulatorPda()[0]
5236
- );
5237
- }
5238
- async fetchUserVolumeAccumulator(user) {
5239
- return await this.pumpProgram.account.userVolumeAccumulator.fetchNullable(
5240
- userVolumeAccumulatorPda(user)[0]
5241
- );
5242
- }
5243
- async fetchUserVolumeAccumulatorTotalStats(user) {
5244
- const userVolumeAccumulator = await this.fetchUserVolumeAccumulator(
5245
- user
5246
- ) ?? {
5247
- totalUnclaimedTokens: new import_bn4.default(0),
5248
- totalClaimedTokens: new import_bn4.default(0),
5249
- currentSolVolume: new import_bn4.default(0)
5250
- };
5251
- const userVolumeAccumulatorAmm = await this.pumpAmmSdk.fetchUserVolumeAccumulator(user) ?? {
5252
- totalUnclaimedTokens: new import_bn4.default(0),
5253
- totalClaimedTokens: new import_bn4.default(0),
5254
- currentSolVolume: new import_bn4.default(0)
5255
- };
5256
- return {
5257
- totalUnclaimedTokens: userVolumeAccumulator.totalUnclaimedTokens.add(
5258
- userVolumeAccumulatorAmm.totalUnclaimedTokens
5259
- ),
5260
- totalClaimedTokens: userVolumeAccumulator.totalClaimedTokens.add(
5261
- userVolumeAccumulatorAmm.totalClaimedTokens
5262
- ),
5263
- currentSolVolume: userVolumeAccumulator.currentSolVolume.add(
5264
- userVolumeAccumulatorAmm.currentSolVolume
5265
- )
5266
- };
5267
- }
5268
7245
  async createInstruction({
5269
7246
  mint,
5270
7247
  name,
@@ -5298,10 +7275,10 @@ var PumpSdk = class {
5298
7275
  })
5299
7276
  );
5300
7277
  }
5301
- const associatedUser = (0, import_spl_token.getAssociatedTokenAddressSync)(mint, user, true);
7278
+ const associatedUser = (0, import_spl_token2.getAssociatedTokenAddressSync)(mint, user, true);
5302
7279
  if (!associatedUserAccountInfo) {
5303
7280
  instructions.push(
5304
- (0, import_spl_token.createAssociatedTokenAccountIdempotentInstruction)(
7281
+ (0, import_spl_token2.createAssociatedTokenAccountIdempotentInstruction)(
5305
7282
  user,
5306
7283
  associatedUser,
5307
7284
  user,
@@ -5334,14 +7311,14 @@ var PumpSdk = class {
5334
7311
  amount,
5335
7312
  solAmount
5336
7313
  }) {
5337
- const associatedUser = (0, import_spl_token.getAssociatedTokenAddressSync)(mint, user, true);
7314
+ const associatedUser = (0, import_spl_token2.getAssociatedTokenAddressSync)(mint, user, true);
5338
7315
  return [
5339
7316
  await this.createInstruction({ mint, name, symbol, uri, creator, user }),
5340
7317
  await this.extendAccountInstruction({
5341
7318
  account: bondingCurvePda(mint),
5342
7319
  user
5343
7320
  }),
5344
- (0, import_spl_token.createAssociatedTokenAccountIdempotentInstruction)(
7321
+ (0, import_spl_token2.createAssociatedTokenAccountIdempotentInstruction)(
5345
7322
  user,
5346
7323
  associatedUser,
5347
7324
  user,
@@ -5377,7 +7354,7 @@ var PumpSdk = class {
5377
7354
  feeRecipient: getFeeRecipient(global),
5378
7355
  amount,
5379
7356
  solAmount: solAmount.add(
5380
- solAmount.mul(new import_bn4.default(Math.floor(slippage * 10))).div(new import_bn4.default(1e3))
7357
+ solAmount.mul(new import_bn5.default(Math.floor(slippage * 10))).div(new import_bn5.default(1e3))
5381
7358
  )
5382
7359
  });
5383
7360
  }
@@ -5408,7 +7385,7 @@ var PumpSdk = class {
5408
7385
  feeRecipient: getFeeRecipient(global),
5409
7386
  amount,
5410
7387
  solAmount: solAmount.sub(
5411
- solAmount.mul(new import_bn4.default(Math.floor(slippage * 10))).div(new import_bn4.default(1e3))
7388
+ solAmount.mul(new import_bn5.default(Math.floor(slippage * 10))).div(new import_bn5.default(1e3))
5412
7389
  )
5413
7390
  })
5414
7391
  );
@@ -5434,191 +7411,13 @@ var PumpSdk = class {
5434
7411
  withdrawAuthority
5435
7412
  }).instruction();
5436
7413
  }
5437
- async collectCoinCreatorFeeInstructions(coinCreator) {
5438
- let quoteMint = import_spl_token.NATIVE_MINT;
5439
- let quoteTokenProgram = import_spl_token.TOKEN_PROGRAM_ID;
5440
- let coinCreatorVaultAuthority = this.pumpAmmSdk.coinCreatorVaultAuthorityPda(coinCreator);
5441
- let coinCreatorVaultAta = this.pumpAmmSdk.coinCreatorVaultAta(
5442
- coinCreatorVaultAuthority,
5443
- quoteMint,
5444
- quoteTokenProgram
5445
- );
5446
- let coinCreatorTokenAccount = (0, import_spl_token.getAssociatedTokenAddressSync)(
5447
- quoteMint,
5448
- coinCreator,
5449
- true,
5450
- quoteTokenProgram
5451
- );
5452
- const [coinCreatorVaultAtaAccountInfo, coinCreatorTokenAccountInfo] = await this.connection.getMultipleAccountsInfo([
5453
- coinCreatorVaultAta,
5454
- coinCreatorTokenAccount
5455
- ]);
5456
- return [
5457
- await this.offlinePumpProgram.methods.collectCreatorFee().accountsPartial({
5458
- creator: coinCreator
5459
- }).instruction(),
5460
- ...await this.pumpAmmSdk.collectCoinCreatorFee({
5461
- coinCreator,
5462
- quoteMint,
5463
- quoteTokenProgram,
5464
- coinCreatorVaultAuthority,
5465
- coinCreatorVaultAta,
5466
- coinCreatorTokenAccount,
5467
- coinCreatorVaultAtaAccountInfo,
5468
- coinCreatorTokenAccountInfo
5469
- })
5470
- ];
5471
- }
5472
- async adminSetCoinCreatorInstructions(newCoinCreator, mint) {
5473
- const global = await this.fetchGlobal();
5474
- return [
5475
- await this.offlinePumpProgram.methods.adminSetCreator(newCoinCreator).accountsPartial({
5476
- adminSetCreatorAuthority: global.adminSetCreatorAuthority,
5477
- mint
5478
- }).instruction(),
5479
- await this.pumpAmmAdminSdk.adminSetCoinCreator(mint, newCoinCreator)
5480
- ];
5481
- }
5482
- async getCreatorVaultBalance(creator) {
5483
- const creatorVault = creatorVaultPda(creator);
5484
- const accountInfo = await this.connection.getAccountInfo(creatorVault);
5485
- if (accountInfo === null) {
5486
- return new import_bn4.default(0);
5487
- }
5488
- const rentExemptionLamports = await this.connection.getMinimumBalanceForRentExemption(
5489
- accountInfo.data.length
5490
- );
5491
- if (accountInfo.lamports < rentExemptionLamports) {
5492
- return new import_bn4.default(0);
5493
- }
5494
- return new import_bn4.default(accountInfo.lamports - rentExemptionLamports);
5495
- }
5496
- async getCreatorVaultBalanceBothPrograms(creator) {
5497
- const balance = await this.getCreatorVaultBalance(creator);
5498
- const ammBalance = await this.pumpAmmSdk.getCoinCreatorVaultBalance(creator);
5499
- return balance.add(ammBalance);
5500
- }
5501
- async adminUpdateTokenIncentives(startTime, endTime, dayNumber, tokenSupplyPerDay, secondsInADay = new import_bn4.default(86400), mint = PUMP_TOKEN_MINT, tokenProgram = import_spl_token.TOKEN_2022_PROGRAM_ID) {
5502
- const { authority } = await this.fetchGlobal();
5503
- return await this.offlinePumpProgram.methods.adminUpdateTokenIncentives(
5504
- startTime,
5505
- endTime,
5506
- secondsInADay,
5507
- dayNumber,
5508
- tokenSupplyPerDay
5509
- ).accountsPartial({
5510
- authority,
5511
- mint,
5512
- tokenProgram
5513
- }).instruction();
5514
- }
5515
- async adminUpdateTokenIncentivesBothPrograms(startTime, endTime, dayNumber, tokenSupplyPerDay, secondsInADay = new import_bn4.default(86400), mint = PUMP_TOKEN_MINT, tokenProgram = import_spl_token.TOKEN_2022_PROGRAM_ID) {
5516
- return [
5517
- await this.adminUpdateTokenIncentives(
5518
- startTime,
5519
- endTime,
5520
- dayNumber,
5521
- tokenSupplyPerDay,
5522
- secondsInADay,
5523
- mint,
5524
- tokenProgram
5525
- ),
5526
- await this.pumpAmmAdminSdk.adminUpdateTokenIncentives(
5527
- startTime,
5528
- endTime,
5529
- dayNumber,
5530
- tokenSupplyPerDay,
5531
- secondsInADay,
5532
- mint,
5533
- tokenProgram
5534
- )
5535
- ];
5536
- }
5537
- async claimTokenIncentives(user, payer) {
5538
- const { mint } = await this.fetchGlobalVolumeAccumulator();
5539
- if (mint.equals(import_web33.PublicKey.default)) {
5540
- return [];
5541
- }
5542
- const [mintAccountInfo, userAccumulatorAccountInfo] = await this.connection.getMultipleAccountsInfo([
5543
- mint,
5544
- userVolumeAccumulatorPda(user)[0]
5545
- ]);
5546
- if (!mintAccountInfo) {
5547
- return [];
5548
- }
5549
- if (!userAccumulatorAccountInfo) {
5550
- return [];
5551
- }
5552
- return [
5553
- await this.offlinePumpProgram.methods.claimTokenIncentives().accountsPartial({
5554
- user,
5555
- payer,
5556
- mint,
5557
- tokenProgram: mintAccountInfo.owner
5558
- }).instruction()
5559
- ];
5560
- }
5561
- async claimTokenIncentivesBothPrograms(user, payer) {
5562
- return [
5563
- ...await this.claimTokenIncentives(user, payer),
5564
- ...await this.pumpAmmSdk.claimTokenIncentives(user, payer)
5565
- ];
5566
- }
5567
- async getTotalUnclaimedTokens(user) {
5568
- const [
5569
- globalVolumeAccumulatorAccountInfo,
5570
- userVolumeAccumulatorAccountInfo
5571
- ] = await this.connection.getMultipleAccountsInfo([
5572
- globalVolumeAccumulatorPda()[0],
5573
- userVolumeAccumulatorPda(user)[0]
5574
- ]);
5575
- if (!globalVolumeAccumulatorAccountInfo || !userVolumeAccumulatorAccountInfo) {
5576
- return new import_bn4.default(0);
5577
- }
5578
- const globalVolumeAccumulator = this.decodeGlobalVolumeAccumulator(
5579
- globalVolumeAccumulatorAccountInfo
5580
- );
5581
- const userVolumeAccumulator = this.decodeUserVolumeAccumulator(
5582
- userVolumeAccumulatorAccountInfo
5583
- );
5584
- return totalUnclaimedTokens(globalVolumeAccumulator, userVolumeAccumulator);
5585
- }
5586
- async getTotalUnclaimedTokensBothPrograms(user) {
5587
- return (await this.getTotalUnclaimedTokens(user)).add(
5588
- await this.pumpAmmSdk.getTotalUnclaimedTokens(user)
5589
- );
5590
- }
5591
- async getCurrentDayTokens(user) {
5592
- const [
5593
- globalVolumeAccumulatorAccountInfo,
5594
- userVolumeAccumulatorAccountInfo
5595
- ] = await this.connection.getMultipleAccountsInfo([
5596
- globalVolumeAccumulatorPda()[0],
5597
- userVolumeAccumulatorPda(user)[0]
5598
- ]);
5599
- if (!globalVolumeAccumulatorAccountInfo || !userVolumeAccumulatorAccountInfo) {
5600
- return new import_bn4.default(0);
5601
- }
5602
- const globalVolumeAccumulator = this.decodeGlobalVolumeAccumulator(
5603
- globalVolumeAccumulatorAccountInfo
5604
- );
5605
- const userVolumeAccumulator = this.decodeUserVolumeAccumulator(
5606
- userVolumeAccumulatorAccountInfo
5607
- );
5608
- return currentDayTokens(globalVolumeAccumulator, userVolumeAccumulator);
5609
- }
5610
- async getCurrentDayTokensBothPrograms(user) {
5611
- return (await this.getCurrentDayTokens(user)).add(
5612
- await this.pumpAmmSdk.getCurrentDayTokens(user)
5613
- );
5614
- }
5615
7414
  async syncUserVolumeAccumulator(user) {
5616
7415
  return await this.offlinePumpProgram.methods.syncUserVolumeAccumulator().accountsPartial({ user }).instruction();
5617
7416
  }
5618
7417
  async syncUserVolumeAccumulatorBothPrograms(user) {
5619
7418
  return [
5620
7419
  await this.syncUserVolumeAccumulator(user),
5621
- await this.pumpAmmSdk.syncUserVolumeAccumulator(user)
7420
+ await import_pump_swap_sdk2.PUMP_AMM_SDK.syncUserVolumeAccumulator(user)
5622
7421
  ];
5623
7422
  }
5624
7423
  async setCreator({
@@ -5650,7 +7449,7 @@ var PumpSdk = class {
5650
7449
  }) {
5651
7450
  return await this.getBuyInstructionInternal({
5652
7451
  user,
5653
- associatedUser: (0, import_spl_token.getAssociatedTokenAddressSync)(mint, user, true),
7452
+ associatedUser: (0, import_spl_token2.getAssociatedTokenAddressSync)(mint, user, true),
5654
7453
  mint,
5655
7454
  creator,
5656
7455
  feeRecipient,
@@ -5703,71 +7502,62 @@ var PumpSdk = class {
5703
7502
  return await this.offlinePumpProgram.methods.sell(amount, solAmount).accountsPartial({
5704
7503
  feeRecipient,
5705
7504
  mint,
5706
- associatedUser: (0, import_spl_token.getAssociatedTokenAddressSync)(mint, user, true),
7505
+ associatedUser: (0, import_spl_token2.getAssociatedTokenAddressSync)(mint, user, true),
5707
7506
  user,
5708
7507
  creatorVault: creatorVaultPda(creator)
5709
7508
  }).instruction();
5710
7509
  }
5711
7510
  };
7511
+ var PUMP_SDK = new PumpSdk();
5712
7512
  function getFeeRecipient(global) {
5713
7513
  const feeRecipients = [global.feeRecipient, ...global.feeRecipients];
5714
7514
  return feeRecipients[Math.floor(Math.random() * feeRecipients.length)];
5715
7515
  }
5716
7516
 
5717
7517
  // src/pda.ts
5718
- function globalPda() {
5719
- const [globalPda2] = import_web34.PublicKey.findProgramAddressSync(
5720
- [Buffer.from("global")],
5721
- PUMP_PROGRAM_ID
5722
- );
5723
- return globalPda2;
5724
- }
5725
- function pumpFeeConfigPda() {
5726
- return import_web34.PublicKey.findProgramAddressSync(
5727
- [Buffer.from("fee_config"), PUMP_PROGRAM_ID.toBuffer()],
5728
- PUMP_FEE_PROGRAM_ID
5729
- )[0];
5730
- }
7518
+ var import_buffer = __toESM(require_buffer());
7519
+ var GLOBAL_PDA = (0, import_pump_swap_sdk3.pumpPda)([import_buffer.Buffer.from("global")]);
7520
+ var PUMP_FEE_CONFIG_PDA = (0, import_pump_swap_sdk3.pumpFeePda)([
7521
+ import_buffer.Buffer.from("fee_config"),
7522
+ PUMP_PROGRAM_ID.toBuffer()
7523
+ ]);
7524
+ var GLOBAL_VOLUME_ACCUMULATOR_PDA = (0, import_pump_swap_sdk3.pumpPda)([
7525
+ import_buffer.Buffer.from("global_volume_accumulator")
7526
+ ]);
5731
7527
  function bondingCurvePda(mint) {
5732
- const [bondingCurvePda2] = import_web34.PublicKey.findProgramAddressSync(
5733
- [Buffer.from("bonding-curve"), new import_web34.PublicKey(mint).toBuffer()],
5734
- PUMP_PROGRAM_ID
5735
- );
5736
- return bondingCurvePda2;
7528
+ return (0, import_pump_swap_sdk3.pumpPda)([
7529
+ import_buffer.Buffer.from("bonding-curve"),
7530
+ new import_web35.PublicKey(mint).toBuffer()
7531
+ ]);
5737
7532
  }
5738
7533
  function creatorVaultPda(creator) {
5739
- const [creatorVault] = import_web34.PublicKey.findProgramAddressSync(
5740
- [Buffer.from("creator-vault"), creator.toBuffer()],
5741
- PUMP_PROGRAM_ID
5742
- );
5743
- return creatorVault;
7534
+ return (0, import_pump_swap_sdk3.pumpPda)([import_buffer.Buffer.from("creator-vault"), creator.toBuffer()]);
5744
7535
  }
5745
7536
  function pumpPoolAuthorityPda(mint) {
5746
- return import_web34.PublicKey.findProgramAddressSync(
5747
- [Buffer.from("pool-authority"), mint.toBuffer()],
5748
- PUMP_PROGRAM_ID
5749
- );
7537
+ return (0, import_pump_swap_sdk3.pumpPda)([import_buffer.Buffer.from("pool-authority"), mint.toBuffer()]);
5750
7538
  }
5751
7539
  var CANONICAL_POOL_INDEX = 0;
5752
7540
  function canonicalPumpPoolPda(mint) {
5753
- const [pumpPoolAuthority] = pumpPoolAuthorityPda(mint);
5754
- return (0, import_pump_swap_sdk2.poolPda)(
7541
+ return (0, import_pump_swap_sdk3.poolPda)(
5755
7542
  CANONICAL_POOL_INDEX,
5756
- pumpPoolAuthority,
7543
+ pumpPoolAuthorityPda(mint),
5757
7544
  mint,
5758
- import_spl_token2.NATIVE_MINT,
5759
- PUMP_AMM_PROGRAM_ID
5760
- );
5761
- }
5762
- function globalVolumeAccumulatorPda() {
5763
- return import_web34.PublicKey.findProgramAddressSync(
5764
- [Buffer.from("global_volume_accumulator")],
5765
- PUMP_PROGRAM_ID
7545
+ import_spl_token3.NATIVE_MINT
5766
7546
  );
5767
7547
  }
5768
7548
  function userVolumeAccumulatorPda(user) {
5769
- return import_web34.PublicKey.findProgramAddressSync(
5770
- [Buffer.from("user_volume_accumulator"), user.toBuffer()],
5771
- PUMP_PROGRAM_ID
5772
- );
7549
+ return (0, import_pump_swap_sdk3.pumpPda)([import_buffer.Buffer.from("user_volume_accumulator"), user.toBuffer()]);
5773
7550
  }
7551
+ /*! Bundled license information:
7552
+
7553
+ ieee754/index.js:
7554
+ (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
7555
+
7556
+ buffer/index.js:
7557
+ (*!
7558
+ * The buffer module from node.js, for the browser.
7559
+ *
7560
+ * @author Feross Aboukhadijeh <https://feross.org>
7561
+ * @license MIT
7562
+ *)
7563
+ */