nowbackup 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1388 @@
1
+ import {
2
+ fromHex,
3
+ fromUtf8,
4
+ toHex,
5
+ toUtf8
6
+ } from "./chunk-APZ4HNNC.js";
7
+
8
+ // ../../node_modules/tslib/tslib.es6.mjs
9
+ function __awaiter(thisArg, _arguments, P, generator) {
10
+ function adopt(value) {
11
+ return value instanceof P ? value : new P(function(resolve) {
12
+ resolve(value);
13
+ });
14
+ }
15
+ return new (P || (P = Promise))(function(resolve, reject) {
16
+ function fulfilled(value) {
17
+ try {
18
+ step(generator.next(value));
19
+ } catch (e) {
20
+ reject(e);
21
+ }
22
+ }
23
+ function rejected(value) {
24
+ try {
25
+ step(generator["throw"](value));
26
+ } catch (e) {
27
+ reject(e);
28
+ }
29
+ }
30
+ function step(result) {
31
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
32
+ }
33
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
34
+ });
35
+ }
36
+ function __generator(thisArg, body) {
37
+ var _ = { label: 0, sent: function() {
38
+ if (t[0] & 1) throw t[1];
39
+ return t[1];
40
+ }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
41
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
42
+ return this;
43
+ }), g;
44
+ function verb(n) {
45
+ return function(v) {
46
+ return step([n, v]);
47
+ };
48
+ }
49
+ function step(op) {
50
+ if (f) throw new TypeError("Generator is already executing.");
51
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
52
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
53
+ if (y = 0, t) op = [op[0] & 2, t.value];
54
+ switch (op[0]) {
55
+ case 0:
56
+ case 1:
57
+ t = op;
58
+ break;
59
+ case 4:
60
+ _.label++;
61
+ return { value: op[1], done: false };
62
+ case 5:
63
+ _.label++;
64
+ y = op[1];
65
+ op = [0];
66
+ continue;
67
+ case 7:
68
+ op = _.ops.pop();
69
+ _.trys.pop();
70
+ continue;
71
+ default:
72
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
73
+ _ = 0;
74
+ continue;
75
+ }
76
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
77
+ _.label = op[1];
78
+ break;
79
+ }
80
+ if (op[0] === 6 && _.label < t[1]) {
81
+ _.label = t[1];
82
+ t = op;
83
+ break;
84
+ }
85
+ if (t && _.label < t[2]) {
86
+ _.label = t[2];
87
+ _.ops.push(op);
88
+ break;
89
+ }
90
+ if (t[2]) _.ops.pop();
91
+ _.trys.pop();
92
+ continue;
93
+ }
94
+ op = body.call(thisArg, _);
95
+ } catch (e) {
96
+ op = [6, e];
97
+ y = 0;
98
+ } finally {
99
+ f = t = 0;
100
+ }
101
+ if (op[0] & 5) throw op[1];
102
+ return { value: op[0] ? op[1] : void 0, done: true };
103
+ }
104
+ }
105
+ function __values(o) {
106
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
107
+ if (m) return m.call(o);
108
+ if (o && typeof o.length === "number") return {
109
+ next: function() {
110
+ if (o && i >= o.length) o = void 0;
111
+ return { value: o && o[i++], done: !o };
112
+ }
113
+ };
114
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
115
+ }
116
+
117
+ // ../../node_modules/@smithy/util-buffer-from/dist-es/index.js
118
+ import { Buffer as Buffer2 } from "buffer";
119
+ var fromString = (input, encoding) => {
120
+ if (typeof input !== "string") {
121
+ throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
122
+ }
123
+ return encoding ? Buffer2.from(input, encoding) : Buffer2.from(input);
124
+ };
125
+
126
+ // ../../node_modules/@smithy/util-utf8/dist-es/fromUtf8.js
127
+ var fromUtf82 = (input) => {
128
+ const buf = fromString(input, "utf8");
129
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT);
130
+ };
131
+
132
+ // ../../node_modules/@aws-crypto/util/build/module/convertToBuffer.js
133
+ var fromUtf83 = typeof Buffer !== "undefined" && Buffer.from ? function(input) {
134
+ return Buffer.from(input, "utf8");
135
+ } : fromUtf82;
136
+ function convertToBuffer(data) {
137
+ if (data instanceof Uint8Array)
138
+ return data;
139
+ if (typeof data === "string") {
140
+ return fromUtf83(data);
141
+ }
142
+ if (ArrayBuffer.isView(data)) {
143
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
144
+ }
145
+ return new Uint8Array(data);
146
+ }
147
+
148
+ // ../../node_modules/@aws-crypto/util/build/module/isEmptyData.js
149
+ function isEmptyData(data) {
150
+ if (typeof data === "string") {
151
+ return data.length === 0;
152
+ }
153
+ return data.byteLength === 0;
154
+ }
155
+
156
+ // ../../node_modules/@aws-crypto/util/build/module/numToUint8.js
157
+ function numToUint8(num) {
158
+ return new Uint8Array([
159
+ (num & 4278190080) >> 24,
160
+ (num & 16711680) >> 16,
161
+ (num & 65280) >> 8,
162
+ num & 255
163
+ ]);
164
+ }
165
+
166
+ // ../../node_modules/@aws-crypto/util/build/module/uint32ArrayFrom.js
167
+ function uint32ArrayFrom(a_lookUpTable2) {
168
+ if (!Uint32Array.from) {
169
+ var return_array = new Uint32Array(a_lookUpTable2.length);
170
+ var a_index = 0;
171
+ while (a_index < a_lookUpTable2.length) {
172
+ return_array[a_index] = a_lookUpTable2[a_index];
173
+ a_index += 1;
174
+ }
175
+ return return_array;
176
+ }
177
+ return Uint32Array.from(a_lookUpTable2);
178
+ }
179
+
180
+ // ../../node_modules/@aws-crypto/crc32/build/module/aws_crc32.js
181
+ var AwsCrc32 = (
182
+ /** @class */
183
+ (function() {
184
+ function AwsCrc322() {
185
+ this.crc32 = new Crc32();
186
+ }
187
+ AwsCrc322.prototype.update = function(toHash) {
188
+ if (isEmptyData(toHash))
189
+ return;
190
+ this.crc32.update(convertToBuffer(toHash));
191
+ };
192
+ AwsCrc322.prototype.digest = function() {
193
+ return __awaiter(this, void 0, void 0, function() {
194
+ return __generator(this, function(_a) {
195
+ return [2, numToUint8(this.crc32.digest())];
196
+ });
197
+ });
198
+ };
199
+ AwsCrc322.prototype.reset = function() {
200
+ this.crc32 = new Crc32();
201
+ };
202
+ return AwsCrc322;
203
+ })()
204
+ );
205
+
206
+ // ../../node_modules/@aws-crypto/crc32/build/module/index.js
207
+ var Crc32 = (
208
+ /** @class */
209
+ (function() {
210
+ function Crc322() {
211
+ this.checksum = 4294967295;
212
+ }
213
+ Crc322.prototype.update = function(data) {
214
+ var e_1, _a;
215
+ try {
216
+ for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
217
+ var byte = data_1_1.value;
218
+ this.checksum = this.checksum >>> 8 ^ lookupTable[(this.checksum ^ byte) & 255];
219
+ }
220
+ } catch (e_1_1) {
221
+ e_1 = { error: e_1_1 };
222
+ } finally {
223
+ try {
224
+ if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);
225
+ } finally {
226
+ if (e_1) throw e_1.error;
227
+ }
228
+ }
229
+ return this;
230
+ };
231
+ Crc322.prototype.digest = function() {
232
+ return (this.checksum ^ 4294967295) >>> 0;
233
+ };
234
+ return Crc322;
235
+ })()
236
+ );
237
+ var a_lookUpTable = [
238
+ 0,
239
+ 1996959894,
240
+ 3993919788,
241
+ 2567524794,
242
+ 124634137,
243
+ 1886057615,
244
+ 3915621685,
245
+ 2657392035,
246
+ 249268274,
247
+ 2044508324,
248
+ 3772115230,
249
+ 2547177864,
250
+ 162941995,
251
+ 2125561021,
252
+ 3887607047,
253
+ 2428444049,
254
+ 498536548,
255
+ 1789927666,
256
+ 4089016648,
257
+ 2227061214,
258
+ 450548861,
259
+ 1843258603,
260
+ 4107580753,
261
+ 2211677639,
262
+ 325883990,
263
+ 1684777152,
264
+ 4251122042,
265
+ 2321926636,
266
+ 335633487,
267
+ 1661365465,
268
+ 4195302755,
269
+ 2366115317,
270
+ 997073096,
271
+ 1281953886,
272
+ 3579855332,
273
+ 2724688242,
274
+ 1006888145,
275
+ 1258607687,
276
+ 3524101629,
277
+ 2768942443,
278
+ 901097722,
279
+ 1119000684,
280
+ 3686517206,
281
+ 2898065728,
282
+ 853044451,
283
+ 1172266101,
284
+ 3705015759,
285
+ 2882616665,
286
+ 651767980,
287
+ 1373503546,
288
+ 3369554304,
289
+ 3218104598,
290
+ 565507253,
291
+ 1454621731,
292
+ 3485111705,
293
+ 3099436303,
294
+ 671266974,
295
+ 1594198024,
296
+ 3322730930,
297
+ 2970347812,
298
+ 795835527,
299
+ 1483230225,
300
+ 3244367275,
301
+ 3060149565,
302
+ 1994146192,
303
+ 31158534,
304
+ 2563907772,
305
+ 4023717930,
306
+ 1907459465,
307
+ 112637215,
308
+ 2680153253,
309
+ 3904427059,
310
+ 2013776290,
311
+ 251722036,
312
+ 2517215374,
313
+ 3775830040,
314
+ 2137656763,
315
+ 141376813,
316
+ 2439277719,
317
+ 3865271297,
318
+ 1802195444,
319
+ 476864866,
320
+ 2238001368,
321
+ 4066508878,
322
+ 1812370925,
323
+ 453092731,
324
+ 2181625025,
325
+ 4111451223,
326
+ 1706088902,
327
+ 314042704,
328
+ 2344532202,
329
+ 4240017532,
330
+ 1658658271,
331
+ 366619977,
332
+ 2362670323,
333
+ 4224994405,
334
+ 1303535960,
335
+ 984961486,
336
+ 2747007092,
337
+ 3569037538,
338
+ 1256170817,
339
+ 1037604311,
340
+ 2765210733,
341
+ 3554079995,
342
+ 1131014506,
343
+ 879679996,
344
+ 2909243462,
345
+ 3663771856,
346
+ 1141124467,
347
+ 855842277,
348
+ 2852801631,
349
+ 3708648649,
350
+ 1342533948,
351
+ 654459306,
352
+ 3188396048,
353
+ 3373015174,
354
+ 1466479909,
355
+ 544179635,
356
+ 3110523913,
357
+ 3462522015,
358
+ 1591671054,
359
+ 702138776,
360
+ 2966460450,
361
+ 3352799412,
362
+ 1504918807,
363
+ 783551873,
364
+ 3082640443,
365
+ 3233442989,
366
+ 3988292384,
367
+ 2596254646,
368
+ 62317068,
369
+ 1957810842,
370
+ 3939845945,
371
+ 2647816111,
372
+ 81470997,
373
+ 1943803523,
374
+ 3814918930,
375
+ 2489596804,
376
+ 225274430,
377
+ 2053790376,
378
+ 3826175755,
379
+ 2466906013,
380
+ 167816743,
381
+ 2097651377,
382
+ 4027552580,
383
+ 2265490386,
384
+ 503444072,
385
+ 1762050814,
386
+ 4150417245,
387
+ 2154129355,
388
+ 426522225,
389
+ 1852507879,
390
+ 4275313526,
391
+ 2312317920,
392
+ 282753626,
393
+ 1742555852,
394
+ 4189708143,
395
+ 2394877945,
396
+ 397917763,
397
+ 1622183637,
398
+ 3604390888,
399
+ 2714866558,
400
+ 953729732,
401
+ 1340076626,
402
+ 3518719985,
403
+ 2797360999,
404
+ 1068828381,
405
+ 1219638859,
406
+ 3624741850,
407
+ 2936675148,
408
+ 906185462,
409
+ 1090812512,
410
+ 3747672003,
411
+ 2825379669,
412
+ 829329135,
413
+ 1181335161,
414
+ 3412177804,
415
+ 3160834842,
416
+ 628085408,
417
+ 1382605366,
418
+ 3423369109,
419
+ 3138078467,
420
+ 570562233,
421
+ 1426400815,
422
+ 3317316542,
423
+ 2998733608,
424
+ 733239954,
425
+ 1555261956,
426
+ 3268935591,
427
+ 3050360625,
428
+ 752459403,
429
+ 1541320221,
430
+ 2607071920,
431
+ 3965973030,
432
+ 1969922972,
433
+ 40735498,
434
+ 2617837225,
435
+ 3943577151,
436
+ 1913087877,
437
+ 83908371,
438
+ 2512341634,
439
+ 3803740692,
440
+ 2075208622,
441
+ 213261112,
442
+ 2463272603,
443
+ 3855990285,
444
+ 2094854071,
445
+ 198958881,
446
+ 2262029012,
447
+ 4057260610,
448
+ 1759359992,
449
+ 534414190,
450
+ 2176718541,
451
+ 4139329115,
452
+ 1873836001,
453
+ 414664567,
454
+ 2282248934,
455
+ 4279200368,
456
+ 1711684554,
457
+ 285281116,
458
+ 2405801727,
459
+ 4167216745,
460
+ 1634467795,
461
+ 376229701,
462
+ 2685067896,
463
+ 3608007406,
464
+ 1308918612,
465
+ 956543938,
466
+ 2808555105,
467
+ 3495958263,
468
+ 1231636301,
469
+ 1047427035,
470
+ 2932959818,
471
+ 3654703836,
472
+ 1088359270,
473
+ 936918e3,
474
+ 2847714899,
475
+ 3736837829,
476
+ 1202900863,
477
+ 817233897,
478
+ 3183342108,
479
+ 3401237130,
480
+ 1404277552,
481
+ 615818150,
482
+ 3134207493,
483
+ 3453421203,
484
+ 1423857449,
485
+ 601450431,
486
+ 3009837614,
487
+ 3294710456,
488
+ 1567103746,
489
+ 711928724,
490
+ 3020668471,
491
+ 3272380065,
492
+ 1510334235,
493
+ 755167117
494
+ ];
495
+ var lookupTable = uint32ArrayFrom(a_lookUpTable);
496
+
497
+ // ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/Int64.js
498
+ var Int64 = class _Int64 {
499
+ bytes;
500
+ constructor(bytes) {
501
+ this.bytes = bytes;
502
+ if (bytes.byteLength !== 8) {
503
+ throw new Error("Int64 buffers must be exactly 8 bytes");
504
+ }
505
+ }
506
+ static fromNumber(number) {
507
+ if (number > 9223372036854776e3 || number < -9223372036854776e3) {
508
+ throw new Error(`${number} is too large (or, if negative, too small) to represent as an Int64`);
509
+ }
510
+ const bytes = new Uint8Array(8);
511
+ for (let i = 7, remaining = Math.abs(Math.round(number)); i > -1 && remaining > 0; i--, remaining /= 256) {
512
+ bytes[i] = remaining;
513
+ }
514
+ if (number < 0) {
515
+ negate(bytes);
516
+ }
517
+ return new _Int64(bytes);
518
+ }
519
+ valueOf() {
520
+ const bytes = this.bytes.slice(0);
521
+ const negative = bytes[0] & 128;
522
+ if (negative) {
523
+ negate(bytes);
524
+ }
525
+ return parseInt(toHex(bytes), 16) * (negative ? -1 : 1);
526
+ }
527
+ toString() {
528
+ return String(this.valueOf());
529
+ }
530
+ };
531
+ function negate(bytes) {
532
+ for (let i = 0; i < 8; i++) {
533
+ bytes[i] ^= 255;
534
+ }
535
+ for (let i = 7; i > -1; i--) {
536
+ bytes[i]++;
537
+ if (bytes[i] !== 0)
538
+ break;
539
+ }
540
+ }
541
+
542
+ // ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/HeaderMarshaller.js
543
+ var HeaderMarshaller = class {
544
+ toUtf8;
545
+ fromUtf8;
546
+ constructor(toUtf82, fromUtf84) {
547
+ this.toUtf8 = toUtf82;
548
+ this.fromUtf8 = fromUtf84;
549
+ }
550
+ format(headers) {
551
+ const chunks = [];
552
+ for (const headerName of Object.keys(headers)) {
553
+ const bytes = this.fromUtf8(headerName);
554
+ chunks.push(Uint8Array.from([bytes.byteLength]), bytes, this.formatHeaderValue(headers[headerName]));
555
+ }
556
+ const out = new Uint8Array(chunks.reduce((carry, bytes) => carry + bytes.byteLength, 0));
557
+ let position = 0;
558
+ for (const chunk of chunks) {
559
+ out.set(chunk, position);
560
+ position += chunk.byteLength;
561
+ }
562
+ return out;
563
+ }
564
+ formatHeaderValue(header) {
565
+ switch (header.type) {
566
+ case "boolean":
567
+ return Uint8Array.from([header.value ? 0 : 1]);
568
+ case "byte":
569
+ return Uint8Array.from([2, header.value]);
570
+ case "short":
571
+ const shortView = new DataView(new ArrayBuffer(3));
572
+ shortView.setUint8(0, 3);
573
+ shortView.setInt16(1, header.value, false);
574
+ return new Uint8Array(shortView.buffer);
575
+ case "integer":
576
+ const intView = new DataView(new ArrayBuffer(5));
577
+ intView.setUint8(0, 4);
578
+ intView.setInt32(1, header.value, false);
579
+ return new Uint8Array(intView.buffer);
580
+ case "long":
581
+ const longBytes = new Uint8Array(9);
582
+ longBytes[0] = 5;
583
+ longBytes.set(header.value.bytes, 1);
584
+ return longBytes;
585
+ case "binary":
586
+ const binView = new DataView(new ArrayBuffer(3 + header.value.byteLength));
587
+ binView.setUint8(0, 6);
588
+ binView.setUint16(1, header.value.byteLength, false);
589
+ const binBytes = new Uint8Array(binView.buffer);
590
+ binBytes.set(header.value, 3);
591
+ return binBytes;
592
+ case "string":
593
+ const utf8Bytes = this.fromUtf8(header.value);
594
+ const strView = new DataView(new ArrayBuffer(3 + utf8Bytes.byteLength));
595
+ strView.setUint8(0, 7);
596
+ strView.setUint16(1, utf8Bytes.byteLength, false);
597
+ const strBytes = new Uint8Array(strView.buffer);
598
+ strBytes.set(utf8Bytes, 3);
599
+ return strBytes;
600
+ case "timestamp":
601
+ const tsBytes = new Uint8Array(9);
602
+ tsBytes[0] = 8;
603
+ tsBytes.set(Int64.fromNumber(header.value.valueOf()).bytes, 1);
604
+ return tsBytes;
605
+ case "uuid":
606
+ if (!UUID_PATTERN.test(header.value)) {
607
+ throw new Error(`Invalid UUID received: ${header.value}`);
608
+ }
609
+ const uuidBytes = new Uint8Array(17);
610
+ uuidBytes[0] = 9;
611
+ uuidBytes.set(fromHex(header.value.replace(/\-/g, "")), 1);
612
+ return uuidBytes;
613
+ }
614
+ }
615
+ parse(headers) {
616
+ const out = {};
617
+ let position = 0;
618
+ while (position < headers.byteLength) {
619
+ const nameLength = headers.getUint8(position++);
620
+ const name = this.toUtf8(new Uint8Array(headers.buffer, headers.byteOffset + position, nameLength));
621
+ position += nameLength;
622
+ switch (headers.getUint8(position++)) {
623
+ case 0:
624
+ out[name] = {
625
+ type: BOOLEAN_TAG,
626
+ value: true
627
+ };
628
+ break;
629
+ case 1:
630
+ out[name] = {
631
+ type: BOOLEAN_TAG,
632
+ value: false
633
+ };
634
+ break;
635
+ case 2:
636
+ out[name] = {
637
+ type: BYTE_TAG,
638
+ value: headers.getInt8(position++)
639
+ };
640
+ break;
641
+ case 3:
642
+ out[name] = {
643
+ type: SHORT_TAG,
644
+ value: headers.getInt16(position, false)
645
+ };
646
+ position += 2;
647
+ break;
648
+ case 4:
649
+ out[name] = {
650
+ type: INT_TAG,
651
+ value: headers.getInt32(position, false)
652
+ };
653
+ position += 4;
654
+ break;
655
+ case 5:
656
+ out[name] = {
657
+ type: LONG_TAG,
658
+ value: new Int64(new Uint8Array(headers.buffer, headers.byteOffset + position, 8))
659
+ };
660
+ position += 8;
661
+ break;
662
+ case 6:
663
+ const binaryLength = headers.getUint16(position, false);
664
+ position += 2;
665
+ out[name] = {
666
+ type: BINARY_TAG,
667
+ value: new Uint8Array(headers.buffer, headers.byteOffset + position, binaryLength)
668
+ };
669
+ position += binaryLength;
670
+ break;
671
+ case 7:
672
+ const stringLength = headers.getUint16(position, false);
673
+ position += 2;
674
+ out[name] = {
675
+ type: STRING_TAG,
676
+ value: this.toUtf8(new Uint8Array(headers.buffer, headers.byteOffset + position, stringLength))
677
+ };
678
+ position += stringLength;
679
+ break;
680
+ case 8:
681
+ out[name] = {
682
+ type: TIMESTAMP_TAG,
683
+ value: new Date(new Int64(new Uint8Array(headers.buffer, headers.byteOffset + position, 8)).valueOf())
684
+ };
685
+ position += 8;
686
+ break;
687
+ case 9:
688
+ const uuidBytes = new Uint8Array(headers.buffer, headers.byteOffset + position, 16);
689
+ position += 16;
690
+ out[name] = {
691
+ type: UUID_TAG,
692
+ value: `${toHex(uuidBytes.subarray(0, 4))}-${toHex(uuidBytes.subarray(4, 6))}-${toHex(uuidBytes.subarray(6, 8))}-${toHex(uuidBytes.subarray(8, 10))}-${toHex(uuidBytes.subarray(10))}`
693
+ };
694
+ break;
695
+ default:
696
+ throw new Error(`Unrecognized header type tag`);
697
+ }
698
+ }
699
+ return out;
700
+ }
701
+ };
702
+ var HEADER_VALUE_TYPE;
703
+ (function(HEADER_VALUE_TYPE2) {
704
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["boolTrue"] = 0] = "boolTrue";
705
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["boolFalse"] = 1] = "boolFalse";
706
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["byte"] = 2] = "byte";
707
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["short"] = 3] = "short";
708
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["integer"] = 4] = "integer";
709
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["long"] = 5] = "long";
710
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["byteArray"] = 6] = "byteArray";
711
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["string"] = 7] = "string";
712
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["timestamp"] = 8] = "timestamp";
713
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["uuid"] = 9] = "uuid";
714
+ })(HEADER_VALUE_TYPE || (HEADER_VALUE_TYPE = {}));
715
+ var BOOLEAN_TAG = "boolean";
716
+ var BYTE_TAG = "byte";
717
+ var SHORT_TAG = "short";
718
+ var INT_TAG = "integer";
719
+ var LONG_TAG = "long";
720
+ var BINARY_TAG = "binary";
721
+ var STRING_TAG = "string";
722
+ var TIMESTAMP_TAG = "timestamp";
723
+ var UUID_TAG = "uuid";
724
+ var UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
725
+
726
+ // ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/splitMessage.js
727
+ var PRELUDE_MEMBER_LENGTH = 4;
728
+ var PRELUDE_LENGTH = PRELUDE_MEMBER_LENGTH * 2;
729
+ var CHECKSUM_LENGTH = 4;
730
+ var MINIMUM_MESSAGE_LENGTH = PRELUDE_LENGTH + CHECKSUM_LENGTH * 2;
731
+ function splitMessage({ byteLength, byteOffset, buffer }) {
732
+ if (byteLength < MINIMUM_MESSAGE_LENGTH) {
733
+ throw new Error("Provided message too short to accommodate event stream message overhead");
734
+ }
735
+ const view = new DataView(buffer, byteOffset, byteLength);
736
+ const messageLength = view.getUint32(0, false);
737
+ if (byteLength !== messageLength) {
738
+ throw new Error("Reported message length does not match received message length");
739
+ }
740
+ const headerLength = view.getUint32(PRELUDE_MEMBER_LENGTH, false);
741
+ const expectedPreludeChecksum = view.getUint32(PRELUDE_LENGTH, false);
742
+ const expectedMessageChecksum = view.getUint32(byteLength - CHECKSUM_LENGTH, false);
743
+ const checksummer = new Crc32().update(new Uint8Array(buffer, byteOffset, PRELUDE_LENGTH));
744
+ if (expectedPreludeChecksum !== checksummer.digest()) {
745
+ throw new Error(`The prelude checksum specified in the message (${expectedPreludeChecksum}) does not match the calculated CRC32 checksum (${checksummer.digest()})`);
746
+ }
747
+ checksummer.update(new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH, byteLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH)));
748
+ if (expectedMessageChecksum !== checksummer.digest()) {
749
+ throw new Error(`The message checksum (${checksummer.digest()}) did not match the expected value of ${expectedMessageChecksum}`);
750
+ }
751
+ return {
752
+ headers: new DataView(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH, headerLength),
753
+ body: new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH + headerLength, messageLength - headerLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH + CHECKSUM_LENGTH))
754
+ };
755
+ }
756
+
757
+ // ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/EventStreamCodec.js
758
+ var EventStreamCodec = class {
759
+ headerMarshaller;
760
+ messageBuffer;
761
+ isEndOfStream;
762
+ constructor(toUtf82, fromUtf84) {
763
+ this.headerMarshaller = new HeaderMarshaller(toUtf82, fromUtf84);
764
+ this.messageBuffer = [];
765
+ this.isEndOfStream = false;
766
+ }
767
+ feed(message) {
768
+ this.messageBuffer.push(this.decode(message));
769
+ }
770
+ endOfStream() {
771
+ this.isEndOfStream = true;
772
+ }
773
+ getMessage() {
774
+ const message = this.messageBuffer.pop();
775
+ const isEndOfStream = this.isEndOfStream;
776
+ return {
777
+ getMessage() {
778
+ return message;
779
+ },
780
+ isEndOfStream() {
781
+ return isEndOfStream;
782
+ }
783
+ };
784
+ }
785
+ getAvailableMessages() {
786
+ const messages = this.messageBuffer;
787
+ this.messageBuffer = [];
788
+ const isEndOfStream = this.isEndOfStream;
789
+ return {
790
+ getMessages() {
791
+ return messages;
792
+ },
793
+ isEndOfStream() {
794
+ return isEndOfStream;
795
+ }
796
+ };
797
+ }
798
+ encode({ headers: rawHeaders, body }) {
799
+ const headers = this.headerMarshaller.format(rawHeaders);
800
+ const length = headers.byteLength + body.byteLength + 16;
801
+ const out = new Uint8Array(length);
802
+ const view = new DataView(out.buffer, out.byteOffset, out.byteLength);
803
+ const checksum = new Crc32();
804
+ view.setUint32(0, length, false);
805
+ view.setUint32(4, headers.byteLength, false);
806
+ view.setUint32(8, checksum.update(out.subarray(0, 8)).digest(), false);
807
+ out.set(headers, 12);
808
+ out.set(body, headers.byteLength + 12);
809
+ view.setUint32(length - 4, checksum.update(out.subarray(8, length - 4)).digest(), false);
810
+ return out;
811
+ }
812
+ decode(message) {
813
+ const { headers, body } = splitMessage(message);
814
+ return { headers: this.headerMarshaller.parse(headers), body };
815
+ }
816
+ formatHeaders(rawHeaders) {
817
+ return this.headerMarshaller.format(rawHeaders);
818
+ }
819
+ };
820
+
821
+ // ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/MessageDecoderStream.js
822
+ var MessageDecoderStream = class {
823
+ options;
824
+ constructor(options) {
825
+ this.options = options;
826
+ }
827
+ [Symbol.asyncIterator]() {
828
+ return this.asyncIterator();
829
+ }
830
+ async *asyncIterator() {
831
+ for await (const bytes of this.options.inputStream) {
832
+ const decoded = this.options.decoder.decode(bytes);
833
+ yield decoded;
834
+ }
835
+ }
836
+ };
837
+
838
+ // ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/MessageEncoderStream.js
839
+ var MessageEncoderStream = class {
840
+ options;
841
+ constructor(options) {
842
+ this.options = options;
843
+ }
844
+ [Symbol.asyncIterator]() {
845
+ return this.asyncIterator();
846
+ }
847
+ async *asyncIterator() {
848
+ for await (const msg of this.options.messageStream) {
849
+ const encoded = this.options.encoder.encode(msg);
850
+ yield encoded;
851
+ }
852
+ if (this.options.includeEndFrame) {
853
+ yield new Uint8Array(0);
854
+ }
855
+ }
856
+ };
857
+
858
+ // ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageDecoderStream.js
859
+ var SmithyMessageDecoderStream = class {
860
+ options;
861
+ constructor(options) {
862
+ this.options = options;
863
+ }
864
+ [Symbol.asyncIterator]() {
865
+ return this.asyncIterator();
866
+ }
867
+ async *asyncIterator() {
868
+ for await (const message of this.options.messageStream) {
869
+ const deserialized = await this.options.deserializer(message);
870
+ if (deserialized === void 0)
871
+ continue;
872
+ yield deserialized;
873
+ }
874
+ }
875
+ };
876
+
877
+ // ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageEncoderStream.js
878
+ var SmithyMessageEncoderStream = class {
879
+ options;
880
+ constructor(options) {
881
+ this.options = options;
882
+ }
883
+ [Symbol.asyncIterator]() {
884
+ return this.asyncIterator();
885
+ }
886
+ async *asyncIterator() {
887
+ for await (const chunk of this.options.inputStream) {
888
+ const payloadBuf = this.options.serializer(chunk);
889
+ yield payloadBuf;
890
+ }
891
+ }
892
+ };
893
+
894
+ // ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/EventStreamMarshaller.js
895
+ import { Readable } from "stream";
896
+
897
+ // ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/getChunkedStream.js
898
+ function getChunkedStream(source) {
899
+ let currentMessageTotalLength = 0;
900
+ let currentMessagePendingLength = 0;
901
+ let currentMessage = null;
902
+ let messageLengthBuffer = null;
903
+ const allocateMessage = (size) => {
904
+ if (typeof size !== "number") {
905
+ throw new Error("Attempted to allocate an event message where size was not a number: " + size);
906
+ }
907
+ currentMessageTotalLength = size;
908
+ currentMessagePendingLength = 4;
909
+ currentMessage = new Uint8Array(size);
910
+ const currentMessageView = new DataView(currentMessage.buffer);
911
+ currentMessageView.setUint32(0, size, false);
912
+ };
913
+ const iterator = async function* () {
914
+ const sourceIterator = source[Symbol.asyncIterator]();
915
+ while (true) {
916
+ const { value, done } = await sourceIterator.next();
917
+ if (done) {
918
+ if (!currentMessageTotalLength) {
919
+ return;
920
+ } else if (currentMessageTotalLength === currentMessagePendingLength) {
921
+ yield currentMessage;
922
+ } else {
923
+ throw new Error("Truncated event message received.");
924
+ }
925
+ return;
926
+ }
927
+ const chunkLength = value.length;
928
+ let currentOffset = 0;
929
+ while (currentOffset < chunkLength) {
930
+ if (!currentMessage) {
931
+ const bytesRemaining = chunkLength - currentOffset;
932
+ if (!messageLengthBuffer) {
933
+ messageLengthBuffer = new Uint8Array(4);
934
+ }
935
+ const numBytesForTotal = Math.min(4 - currentMessagePendingLength, bytesRemaining);
936
+ messageLengthBuffer.set(value.slice(currentOffset, currentOffset + numBytesForTotal), currentMessagePendingLength);
937
+ currentMessagePendingLength += numBytesForTotal;
938
+ currentOffset += numBytesForTotal;
939
+ if (currentMessagePendingLength < 4) {
940
+ break;
941
+ }
942
+ allocateMessage(new DataView(messageLengthBuffer.buffer).getUint32(0, false));
943
+ messageLengthBuffer = null;
944
+ }
945
+ const numBytesToWrite = Math.min(currentMessageTotalLength - currentMessagePendingLength, chunkLength - currentOffset);
946
+ currentMessage.set(value.slice(currentOffset, currentOffset + numBytesToWrite), currentMessagePendingLength);
947
+ currentMessagePendingLength += numBytesToWrite;
948
+ currentOffset += numBytesToWrite;
949
+ if (currentMessageTotalLength && currentMessageTotalLength === currentMessagePendingLength) {
950
+ yield currentMessage;
951
+ currentMessage = null;
952
+ currentMessageTotalLength = 0;
953
+ currentMessagePendingLength = 0;
954
+ }
955
+ }
956
+ }
957
+ };
958
+ return {
959
+ [Symbol.asyncIterator]: iterator
960
+ };
961
+ }
962
+
963
+ // ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/getUnmarshalledStream.js
964
+ function getUnmarshalledStream(source, options) {
965
+ const messageUnmarshaller = getMessageUnmarshaller(options.deserializer, options.toUtf8);
966
+ return {
967
+ [Symbol.asyncIterator]: async function* () {
968
+ for await (const chunk of source) {
969
+ const message = options.eventStreamCodec.decode(chunk);
970
+ const type = await messageUnmarshaller(message);
971
+ if (type === void 0)
972
+ continue;
973
+ yield type;
974
+ }
975
+ }
976
+ };
977
+ }
978
+ function getMessageUnmarshaller(deserializer, toUtf82) {
979
+ return async function(message) {
980
+ const { value: messageType } = message.headers[":message-type"];
981
+ if (messageType === "error") {
982
+ const unmodeledError = new Error(message.headers[":error-message"].value || "UnknownError");
983
+ unmodeledError.name = message.headers[":error-code"].value;
984
+ throw unmodeledError;
985
+ } else if (messageType === "exception") {
986
+ const code = message.headers[":exception-type"].value;
987
+ const exception = { [code]: message };
988
+ const deserializedException = await deserializer(exception);
989
+ if (deserializedException.$unknown) {
990
+ const error = new Error(toUtf82(message.body));
991
+ error.name = code;
992
+ throw error;
993
+ }
994
+ throw deserializedException[code];
995
+ } else if (messageType === "event") {
996
+ const event = {
997
+ [message.headers[":event-type"].value]: message
998
+ };
999
+ const deserialized = await deserializer(event);
1000
+ if (deserialized.$unknown)
1001
+ return;
1002
+ return deserialized;
1003
+ } else {
1004
+ throw Error(`Unrecognizable event type: ${message.headers[":event-type"].value}`);
1005
+ }
1006
+ };
1007
+ }
1008
+
1009
+ // ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/EventStreamMarshaller.js
1010
+ var EventStreamMarshaller = class {
1011
+ eventStreamCodec;
1012
+ utfEncoder;
1013
+ constructor({ utf8Encoder, utf8Decoder }) {
1014
+ this.eventStreamCodec = new EventStreamCodec(utf8Encoder, utf8Decoder);
1015
+ this.utfEncoder = utf8Encoder;
1016
+ }
1017
+ deserialize(body, deserializer) {
1018
+ const inputStream = getChunkedStream(body);
1019
+ return new SmithyMessageDecoderStream({
1020
+ messageStream: new MessageDecoderStream({ inputStream, decoder: this.eventStreamCodec }),
1021
+ deserializer: getMessageUnmarshaller(deserializer, this.utfEncoder)
1022
+ });
1023
+ }
1024
+ serialize(inputStream, serializer) {
1025
+ return new MessageEncoderStream({
1026
+ messageStream: new SmithyMessageEncoderStream({ inputStream, serializer }),
1027
+ encoder: this.eventStreamCodec,
1028
+ includeEndFrame: true
1029
+ });
1030
+ }
1031
+ };
1032
+ var eventStreamSerdeProvider = (options) => new EventStreamMarshaller(options);
1033
+
1034
+ // ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/EventStreamMarshaller.js
1035
+ var EventStreamMarshaller2 = class {
1036
+ universalMarshaller;
1037
+ constructor({ utf8Encoder, utf8Decoder }) {
1038
+ this.universalMarshaller = new EventStreamMarshaller({
1039
+ utf8Decoder,
1040
+ utf8Encoder
1041
+ });
1042
+ }
1043
+ deserialize(body, deserializer) {
1044
+ const bodyIterable = typeof body[Symbol.asyncIterator] === "function" ? body : readableToIterable(body);
1045
+ return this.universalMarshaller.deserialize(bodyIterable, deserializer);
1046
+ }
1047
+ serialize(input, serializer) {
1048
+ return Readable.from(this.universalMarshaller.serialize(input, serializer));
1049
+ }
1050
+ };
1051
+ var eventStreamSerdeProvider2 = (options) => new EventStreamMarshaller2(options);
1052
+ async function* readableToIterable(readStream) {
1053
+ let streamEnded = false;
1054
+ let generationEnded = false;
1055
+ const records = new Array();
1056
+ readStream.on("error", (err) => {
1057
+ if (!streamEnded) {
1058
+ streamEnded = true;
1059
+ }
1060
+ if (err) {
1061
+ throw err;
1062
+ }
1063
+ });
1064
+ readStream.on("data", (data) => {
1065
+ records.push(data);
1066
+ });
1067
+ readStream.on("end", () => {
1068
+ streamEnded = true;
1069
+ });
1070
+ while (!generationEnded) {
1071
+ const value = await new Promise((resolve) => setTimeout(() => resolve(records.shift()), 0));
1072
+ if (value) {
1073
+ yield value;
1074
+ }
1075
+ generationEnded = streamEnded && records.length === 0;
1076
+ }
1077
+ }
1078
+
1079
+ // ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/utils.js
1080
+ var readableStreamToIterable = (readableStream) => ({
1081
+ [Symbol.asyncIterator]: async function* () {
1082
+ const reader = readableStream.getReader();
1083
+ try {
1084
+ while (true) {
1085
+ const { done, value } = await reader.read();
1086
+ if (done)
1087
+ return;
1088
+ yield value;
1089
+ }
1090
+ } finally {
1091
+ reader.releaseLock();
1092
+ }
1093
+ }
1094
+ });
1095
+ var iterableToReadableStream = (asyncIterable) => {
1096
+ const iterator = asyncIterable[Symbol.asyncIterator]();
1097
+ return new ReadableStream({
1098
+ async pull(controller) {
1099
+ const { done, value } = await iterator.next();
1100
+ if (done) {
1101
+ return controller.close();
1102
+ }
1103
+ controller.enqueue(value);
1104
+ }
1105
+ });
1106
+ };
1107
+
1108
+ // ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-config-resolver/EventStreamSerdeConfig.js
1109
+ var resolveEventStreamSerdeConfig = (input) => Object.assign(input, {
1110
+ eventStreamMarshaller: input.eventStreamSerdeProvider(input)
1111
+ });
1112
+
1113
+ // ../../node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js
1114
+ var EventStreamSerde = class {
1115
+ marshaller;
1116
+ serializer;
1117
+ deserializer;
1118
+ serdeContext;
1119
+ defaultContentType;
1120
+ constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType }) {
1121
+ this.marshaller = marshaller;
1122
+ this.serializer = serializer;
1123
+ this.deserializer = deserializer;
1124
+ this.serdeContext = serdeContext;
1125
+ this.defaultContentType = defaultContentType;
1126
+ }
1127
+ async serializeEventStream({ eventStream, requestSchema, initialRequest }) {
1128
+ const marshaller = this.marshaller;
1129
+ const eventStreamMember = requestSchema.getEventStreamMember();
1130
+ const unionSchema = requestSchema.getMemberSchema(eventStreamMember);
1131
+ const serializer = this.serializer;
1132
+ const defaultContentType = this.defaultContentType;
1133
+ const initialRequestMarker = /* @__PURE__ */ Symbol("initialRequestMarker");
1134
+ const eventStreamIterable = {
1135
+ async *[Symbol.asyncIterator]() {
1136
+ if (initialRequest) {
1137
+ const headers = {
1138
+ ":event-type": { type: "string", value: "initial-request" },
1139
+ ":message-type": { type: "string", value: "event" },
1140
+ ":content-type": { type: "string", value: defaultContentType }
1141
+ };
1142
+ serializer.write(requestSchema, initialRequest);
1143
+ const body = serializer.flush();
1144
+ yield {
1145
+ [initialRequestMarker]: true,
1146
+ headers,
1147
+ body
1148
+ };
1149
+ }
1150
+ for await (const page of eventStream) {
1151
+ yield page;
1152
+ }
1153
+ }
1154
+ };
1155
+ return marshaller.serialize(eventStreamIterable, (event) => {
1156
+ if (event[initialRequestMarker]) {
1157
+ return {
1158
+ headers: event.headers,
1159
+ body: event.body
1160
+ };
1161
+ }
1162
+ let unionMember = "";
1163
+ for (const key in event) {
1164
+ if (key !== "__type") {
1165
+ unionMember = key;
1166
+ break;
1167
+ }
1168
+ }
1169
+ const { additionalHeaders, body, eventType, explicitPayloadContentType } = this.writeEventBody(unionMember, unionSchema, event);
1170
+ const headers = {
1171
+ ":event-type": { type: "string", value: eventType },
1172
+ ":message-type": { type: "string", value: "event" },
1173
+ ":content-type": { type: "string", value: explicitPayloadContentType ?? defaultContentType },
1174
+ ...additionalHeaders
1175
+ };
1176
+ return {
1177
+ headers,
1178
+ body
1179
+ };
1180
+ });
1181
+ }
1182
+ async deserializeEventStream({ response, responseSchema, initialResponseContainer }) {
1183
+ var _a;
1184
+ const marshaller = this.marshaller;
1185
+ const eventStreamMember = responseSchema.getEventStreamMember();
1186
+ const unionSchema = responseSchema.getMemberSchema(eventStreamMember);
1187
+ const memberSchemas = unionSchema.getMemberSchemas();
1188
+ const initialResponseMarker = /* @__PURE__ */ Symbol("initialResponseMarker");
1189
+ const asyncIterable = marshaller.deserialize(response.body, async (event) => {
1190
+ var _a2, _b;
1191
+ let unionMember = "";
1192
+ for (const key in event) {
1193
+ if (key !== "__type") {
1194
+ unionMember = key;
1195
+ break;
1196
+ }
1197
+ }
1198
+ const body = event[unionMember].body;
1199
+ if (unionMember === "initial-response") {
1200
+ const dataObject = await this.deserializer.read(responseSchema, body);
1201
+ delete dataObject[eventStreamMember];
1202
+ return {
1203
+ [initialResponseMarker]: true,
1204
+ ...dataObject
1205
+ };
1206
+ } else if (unionMember in memberSchemas) {
1207
+ const eventStreamSchema = memberSchemas[unionMember];
1208
+ if (eventStreamSchema.isStructSchema()) {
1209
+ const out = {};
1210
+ let hasBindings = false;
1211
+ for (const [name, member] of eventStreamSchema.structIterator()) {
1212
+ const { eventHeader, eventPayload } = member.getMergedTraits();
1213
+ hasBindings = hasBindings || Boolean(eventHeader || eventPayload);
1214
+ if (eventPayload) {
1215
+ if (member.isBlobSchema()) {
1216
+ out[name] = body;
1217
+ } else if (member.isStringSchema()) {
1218
+ out[name] = (((_a2 = this.serdeContext) == null ? void 0 : _a2.utf8Encoder) ?? toUtf8)(body);
1219
+ } else if (member.isStructSchema()) {
1220
+ out[name] = await this.deserializer.read(member, body);
1221
+ }
1222
+ } else if (eventHeader) {
1223
+ const value = (_b = event[unionMember].headers[name]) == null ? void 0 : _b.value;
1224
+ if (value != null) {
1225
+ if (member.isNumericSchema()) {
1226
+ if (value && typeof value === "object" && "bytes" in value) {
1227
+ out[name] = BigInt(value.toString());
1228
+ } else {
1229
+ out[name] = Number(value);
1230
+ }
1231
+ } else {
1232
+ out[name] = value;
1233
+ }
1234
+ }
1235
+ }
1236
+ }
1237
+ if (hasBindings) {
1238
+ return {
1239
+ [unionMember]: out
1240
+ };
1241
+ }
1242
+ if (body.byteLength === 0) {
1243
+ return {
1244
+ [unionMember]: {}
1245
+ };
1246
+ }
1247
+ }
1248
+ return {
1249
+ [unionMember]: await this.deserializer.read(eventStreamSchema, body)
1250
+ };
1251
+ } else {
1252
+ return {
1253
+ $unknown: event
1254
+ };
1255
+ }
1256
+ });
1257
+ const asyncIterator = asyncIterable[Symbol.asyncIterator]();
1258
+ const firstEvent = await asyncIterator.next();
1259
+ if (firstEvent.done) {
1260
+ return asyncIterable;
1261
+ }
1262
+ if ((_a = firstEvent.value) == null ? void 0 : _a[initialResponseMarker]) {
1263
+ if (!responseSchema) {
1264
+ throw new Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");
1265
+ }
1266
+ for (const key in firstEvent.value) {
1267
+ initialResponseContainer[key] = firstEvent.value[key];
1268
+ }
1269
+ }
1270
+ return {
1271
+ async *[Symbol.asyncIterator]() {
1272
+ var _a2;
1273
+ if (!((_a2 = firstEvent == null ? void 0 : firstEvent.value) == null ? void 0 : _a2[initialResponseMarker])) {
1274
+ yield firstEvent.value;
1275
+ }
1276
+ while (true) {
1277
+ const { done, value } = await asyncIterator.next();
1278
+ if (done) {
1279
+ break;
1280
+ }
1281
+ yield value;
1282
+ }
1283
+ }
1284
+ };
1285
+ }
1286
+ writeEventBody(unionMember, unionSchema, event) {
1287
+ var _a;
1288
+ const serializer = this.serializer;
1289
+ let eventType = unionMember;
1290
+ let explicitPayloadMember = null;
1291
+ let explicitPayloadContentType;
1292
+ const isKnownSchema = (() => {
1293
+ const struct = unionSchema.getSchema();
1294
+ return struct[4].includes(unionMember);
1295
+ })();
1296
+ const additionalHeaders = {};
1297
+ if (!isKnownSchema) {
1298
+ const [type, value] = event[unionMember];
1299
+ eventType = type;
1300
+ serializer.write(15, value);
1301
+ } else {
1302
+ const eventSchema = unionSchema.getMemberSchema(unionMember);
1303
+ if (eventSchema.isStructSchema()) {
1304
+ for (const [memberName, memberSchema] of eventSchema.structIterator()) {
1305
+ const { eventHeader, eventPayload } = memberSchema.getMergedTraits();
1306
+ if (eventPayload) {
1307
+ explicitPayloadMember = memberName;
1308
+ } else if (eventHeader) {
1309
+ const value = event[unionMember][memberName];
1310
+ let type = "binary";
1311
+ if (memberSchema.isNumericSchema()) {
1312
+ if ((-2) ** 31 <= value && value <= 2 ** 31 - 1) {
1313
+ type = "integer";
1314
+ } else {
1315
+ type = "long";
1316
+ }
1317
+ } else if (memberSchema.isTimestampSchema()) {
1318
+ type = "timestamp";
1319
+ } else if (memberSchema.isStringSchema()) {
1320
+ type = "string";
1321
+ } else if (memberSchema.isBooleanSchema()) {
1322
+ type = "boolean";
1323
+ }
1324
+ if (value != null) {
1325
+ additionalHeaders[memberName] = {
1326
+ type,
1327
+ value
1328
+ };
1329
+ delete event[unionMember][memberName];
1330
+ }
1331
+ }
1332
+ }
1333
+ if (explicitPayloadMember !== null) {
1334
+ const payloadSchema = eventSchema.getMemberSchema(explicitPayloadMember);
1335
+ if (payloadSchema.isBlobSchema()) {
1336
+ explicitPayloadContentType = "application/octet-stream";
1337
+ } else if (payloadSchema.isStringSchema()) {
1338
+ explicitPayloadContentType = "text/plain";
1339
+ }
1340
+ serializer.write(payloadSchema, event[unionMember][explicitPayloadMember]);
1341
+ } else {
1342
+ serializer.write(eventSchema, event[unionMember]);
1343
+ }
1344
+ } else if (eventSchema.isUnitSchema()) {
1345
+ serializer.write(eventSchema, {});
1346
+ } else {
1347
+ throw new Error("@smithy/core/event-streams - non-struct member not supported in event stream union.");
1348
+ }
1349
+ }
1350
+ const messageSerialization = serializer.flush() ?? new Uint8Array();
1351
+ const body = typeof messageSerialization === "string" ? (((_a = this.serdeContext) == null ? void 0 : _a.utf8Decoder) ?? fromUtf8)(messageSerialization) : messageSerialization;
1352
+ return {
1353
+ body,
1354
+ eventType,
1355
+ explicitPayloadContentType,
1356
+ additionalHeaders
1357
+ };
1358
+ }
1359
+ };
1360
+
1361
+ export {
1362
+ __awaiter,
1363
+ __generator,
1364
+ __values,
1365
+ convertToBuffer,
1366
+ isEmptyData,
1367
+ numToUint8,
1368
+ uint32ArrayFrom,
1369
+ AwsCrc32,
1370
+ Int64,
1371
+ HeaderMarshaller,
1372
+ EventStreamCodec,
1373
+ MessageDecoderStream,
1374
+ MessageEncoderStream,
1375
+ SmithyMessageDecoderStream,
1376
+ SmithyMessageEncoderStream,
1377
+ getChunkedStream,
1378
+ getUnmarshalledStream,
1379
+ getMessageUnmarshaller,
1380
+ EventStreamMarshaller,
1381
+ eventStreamSerdeProvider,
1382
+ EventStreamMarshaller2,
1383
+ eventStreamSerdeProvider2,
1384
+ readableStreamToIterable,
1385
+ iterableToReadableStream,
1386
+ resolveEventStreamSerdeConfig,
1387
+ EventStreamSerde
1388
+ };