@funnycode/myclaude 0.1.156 → 0.1.158

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/myclaude.js +1464 -283
  2. package/dist/myclaude.mjs +1464 -283
  3. package/package.json +1 -1
package/dist/myclaude.js CHANGED
@@ -4,8 +4,8 @@
4
4
  // MACRO - build-time constants (injected by build.ts)
5
5
  // MACRO injected by build script
6
6
  globalThis.MACRO = {
7
- VERSION: "0.1.156",
8
- BUILD_TIME: "2026-07-29T08:07:27.596Z",
7
+ VERSION: "0.1.158",
8
+ BUILD_TIME: "2026-07-29T16:07:05.507Z",
9
9
  PACKAGE_URL: "@funnycode/myclaude",
10
10
  NATIVE_PACKAGE_URL: "@funnycode/myclaude",
11
11
  VERSION_CHANGELOG: '',
@@ -85149,9 +85149,6 @@ var require_schema = __commonJS((exports) => {
85149
85149
  }
85150
85150
  struct2[anno.it] = it;
85151
85151
  }
85152
- structIteratorCbor() {
85153
- throw new Error("@smithy/core/schema - structIteratorCbor not loaded.");
85154
- }
85155
85152
  }
85156
85153
  function member(memberSchema, memberName) {
85157
85154
  if (memberSchema instanceof NormalizedSchema) {
@@ -97310,23 +97307,23 @@ var require_cbor = __commonJS((exports) => {
97310
97307
  data2[tagSymbol] = true;
97311
97308
  return data2;
97312
97309
  }
97313
- var USE_BUFFER$1 = typeof Buffer !== "undefined";
97314
- var textDecoder2 = new TextDecoder;
97315
- var payload = alloc(0);
97316
- var isBuffer3 = false;
97317
- var dataView$1 = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
97310
+ var USE_BUFFER$3 = typeof Buffer !== "undefined";
97311
+ var textDecoder$1 = new TextDecoder;
97312
+ var payload$1 = alloc(0);
97313
+ var isBuffer$1 = false;
97314
+ var dataView$2 = new DataView(payload$1.buffer, payload$1.byteOffset, payload$1.byteLength);
97318
97315
  var _offset = 0;
97319
97316
  function setPayload(bytes) {
97320
- payload = bytes;
97321
- isBuffer3 = USE_BUFFER$1 && payload instanceof Buffer;
97322
- dataView$1 = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
97317
+ payload$1 = bytes;
97318
+ isBuffer$1 = USE_BUFFER$3 && payload$1 instanceof Buffer;
97319
+ dataView$2 = new DataView(payload$1.buffer, payload$1.byteOffset, payload$1.byteLength);
97323
97320
  }
97324
97321
  function decode3(at, to) {
97325
97322
  if (at >= to) {
97326
97323
  throw new Error("unexpected end of (decode) payload.");
97327
97324
  }
97328
- const major = (payload[at] & 224) >> 5;
97329
- const minor = payload[at] & 31;
97325
+ const major = (payload$1[at] & 224) >> 5;
97326
+ const minor = payload$1[at] & 31;
97330
97327
  if (minor === minorIndefinite && 2 <= major && major <= 5) {
97331
97328
  return decodeIndefinite(at, to);
97332
97329
  }
@@ -97343,35 +97340,35 @@ var require_cbor = __commonJS((exports) => {
97343
97340
  switch (minor) {
97344
97341
  case extendedOneByte:
97345
97342
  if (to - at < 2) {
97346
- overflow(1);
97343
+ overflow$1(1);
97347
97344
  }
97348
- unsignedInt = payload[at + 1];
97345
+ unsignedInt = payload$1[at + 1];
97349
97346
  offset = 2;
97350
97347
  break;
97351
97348
  case extendedFloat16:
97352
97349
  if (to - at < 3) {
97353
- overflow(2);
97350
+ overflow$1(2);
97354
97351
  }
97355
- unsignedInt = dataView$1.getUint16(at + 1);
97352
+ unsignedInt = dataView$2.getUint16(at + 1);
97356
97353
  offset = 3;
97357
97354
  break;
97358
97355
  case extendedFloat32:
97359
97356
  if (to - at < 5) {
97360
- overflow(4);
97357
+ overflow$1(4);
97361
97358
  }
97362
- unsignedInt = dataView$1.getUint32(at + 1);
97359
+ unsignedInt = dataView$2.getUint32(at + 1);
97363
97360
  offset = 5;
97364
97361
  break;
97365
97362
  case extendedFloat64:
97366
97363
  if (to - at < 9) {
97367
- overflow(8);
97364
+ overflow$1(8);
97368
97365
  }
97369
97366
  {
97370
- const hi = dataView$1.getUint32(at + 1);
97367
+ const hi = dataView$2.getUint32(at + 1);
97371
97368
  if (hi < 2097152) {
97372
- unsignedInt = hi * 4294967296 + dataView$1.getUint32(at + 5);
97369
+ unsignedInt = hi * 4294967296 + dataView$2.getUint32(at + 5);
97373
97370
  } else {
97374
- unsignedInt = dataView$1.getBigUint64(at + 1);
97371
+ unsignedInt = dataView$2.getBigUint64(at + 1);
97375
97372
  }
97376
97373
  }
97377
97374
  offset = 9;
@@ -97382,7 +97379,7 @@ var require_cbor = __commonJS((exports) => {
97382
97379
  }
97383
97380
  if (major === majorUint64) {
97384
97381
  _offset = offset;
97385
- return castBigInt(unsignedInt);
97382
+ return castBigInt$1(unsignedInt);
97386
97383
  } else if (major === majorNegativeInt64) {
97387
97384
  let negativeInt;
97388
97385
  if (typeof unsignedInt === "bigint") {
@@ -97391,7 +97388,7 @@ var require_cbor = __commonJS((exports) => {
97391
97388
  negativeInt = -1 - unsignedInt;
97392
97389
  }
97393
97390
  _offset = offset;
97394
- return castBigInt(negativeInt);
97391
+ return castBigInt$1(negativeInt);
97395
97392
  } else {
97396
97393
  return decodeTagValue(at, to, minor, unsignedInt, offset);
97397
97394
  }
@@ -97409,8 +97406,8 @@ var require_cbor = __commonJS((exports) => {
97409
97406
  }
97410
97407
  }
97411
97408
  function decodeIndefinite(at, to) {
97412
- const major = (payload[at] & 224) >> 5;
97413
- const minor = payload[at] & 31;
97409
+ const major = (payload$1[at] & 224) >> 5;
97410
+ const minor = payload$1[at] & 31;
97414
97411
  if (minor === minorIndefinite) {
97415
97412
  switch (major) {
97416
97413
  case majorUtf8String:
@@ -97424,7 +97421,7 @@ var require_cbor = __commonJS((exports) => {
97424
97421
  }
97425
97422
  }
97426
97423
  }
97427
- function bytesToFloat16(a2, b) {
97424
+ function bytesToFloat16$1(a2, b) {
97428
97425
  const sign = a2 >> 7;
97429
97426
  const exponent = (a2 & 124) >> 2;
97430
97427
  const fraction = (a2 & 3) << 8 | b;
@@ -97443,7 +97440,7 @@ var require_cbor = __commonJS((exports) => {
97443
97440
  return scalar * (Math.pow(2, exponent - 15) * (1 + fraction / 1024));
97444
97441
  }
97445
97442
  function decodeMap(at, to) {
97446
- const mapDataLength = decodeCount(at, to);
97443
+ const mapDataLength = decodeCount$1(at, to);
97447
97444
  if (mapDataLength < 25) {
97448
97445
  return decodeMapSmall(at, to, mapDataLength);
97449
97446
  }
@@ -97457,7 +97454,7 @@ var require_cbor = __commonJS((exports) => {
97457
97454
  for (let i2 = 0;i2 < mapDataLength; ++i2) {
97458
97455
  const key = decodeUtf8String(at, to);
97459
97456
  at += _offset;
97460
- const valMajor = (payload[at] & 224) >> 5;
97457
+ const valMajor = (payload$1[at] & 224) >> 5;
97461
97458
  if (valMajor === majorUtf8String) {
97462
97459
  map2[key] = decodeUtf8String(at, to);
97463
97460
  } else {
@@ -97484,7 +97481,7 @@ var require_cbor = __commonJS((exports) => {
97484
97481
  return map2;
97485
97482
  }
97486
97483
  function decodeList(at, to) {
97487
- const listDataLength = decodeCount(at, to);
97484
+ const listDataLength = decodeCount$1(at, to);
97488
97485
  const offset = _offset;
97489
97486
  at += offset;
97490
97487
  const base2 = at;
@@ -97497,74 +97494,74 @@ var require_cbor = __commonJS((exports) => {
97497
97494
  return list;
97498
97495
  }
97499
97496
  function decodeUtf8String(at, to) {
97500
- const length = decodeCount(at, to);
97497
+ const length = decodeCount$1(at, to);
97501
97498
  const offset = _offset;
97502
97499
  at += offset;
97503
97500
  if (to - at < length) {
97504
- overflow(length);
97501
+ overflow$1(length);
97505
97502
  }
97506
97503
  _offset = offset + length;
97507
97504
  if (length < 24) {
97508
97505
  return decodeUtf8StringCached(at, length);
97509
97506
  }
97510
- if (isBuffer3) {
97511
- return payload.toString("utf-8", at, at + length);
97507
+ if (isBuffer$1) {
97508
+ return payload$1.toString("utf-8", at, at + length);
97512
97509
  }
97513
- return textDecoder2.decode(payload.subarray(at, at + length));
97510
+ return textDecoder$1.decode(payload$1.subarray(at, at + length));
97514
97511
  }
97515
- var stringCache = new Array(2048);
97516
- var stringCacheEpochs = new Uint16Array(2048);
97517
- var cacheEpoch = 0;
97512
+ var stringCache$1 = new Array(2048);
97513
+ var stringCacheEpochs$1 = new Uint16Array(2048);
97514
+ var cacheEpoch$1 = 0;
97518
97515
  function advanceDecodingEpoch() {
97519
- cacheEpoch = cacheEpoch + 1 & 65535;
97516
+ cacheEpoch$1 = cacheEpoch$1 + 1 & 65535;
97520
97517
  }
97521
97518
  function decodeUtf8StringCached(at, length) {
97522
97519
  let h2 = length;
97523
97520
  for (let i2 = 0;i2 < length; ++i2) {
97524
- h2 = h2 * 31 + payload[at + i2] | 0;
97521
+ h2 = h2 * 31 + payload$1[at + i2] | 0;
97525
97522
  }
97526
97523
  const slot = h2 >>> 0 & 2047;
97527
- const cached2 = stringCache[slot];
97524
+ const cached2 = stringCache$1[slot];
97528
97525
  if (cached2 !== undefined) {
97529
97526
  if (cached2.length === length) {
97530
97527
  let match = true;
97531
97528
  for (let i2 = 0;i2 < length; ++i2) {
97532
- if (cached2.charCodeAt(i2) !== payload[at + i2]) {
97529
+ if (cached2.charCodeAt(i2) !== payload$1[at + i2]) {
97533
97530
  match = false;
97534
97531
  break;
97535
97532
  }
97536
97533
  }
97537
97534
  if (match) {
97538
- stringCacheEpochs[slot] = cacheEpoch;
97535
+ stringCacheEpochs$1[slot] = cacheEpoch$1;
97539
97536
  return cached2;
97540
97537
  }
97541
97538
  }
97542
97539
  }
97543
- const result = isBuffer3 ? payload.toString("utf-8", at, at + length) : textDecoder2.decode(payload.subarray(at, at + length));
97544
- if (stringCacheEpochs[slot] !== cacheEpoch) {
97545
- stringCache[slot] = result;
97546
- stringCacheEpochs[slot] = cacheEpoch;
97540
+ const result = isBuffer$1 ? payload$1.toString("utf-8", at, at + length) : textDecoder$1.decode(payload$1.subarray(at, at + length));
97541
+ if (stringCacheEpochs$1[slot] !== cacheEpoch$1) {
97542
+ stringCache$1[slot] = result;
97543
+ stringCacheEpochs$1[slot] = cacheEpoch$1;
97547
97544
  }
97548
97545
  return result;
97549
97546
  }
97550
97547
  function decodeUnstructuredByteString(at, to) {
97551
- const length = decodeCount(at, to);
97548
+ const length = decodeCount$1(at, to);
97552
97549
  const offset = _offset;
97553
97550
  at += offset;
97554
97551
  if (to - at < length) {
97555
- overflow(length);
97552
+ overflow$1(length);
97556
97553
  }
97557
- const value = payload.subarray(at, at + length);
97554
+ const value = payload$1.subarray(at, at + length);
97558
97555
  _offset = offset + length;
97559
97556
  return value;
97560
97557
  }
97561
97558
  function decodeTagValue(at, to, minor, unsignedInt, offset) {
97562
97559
  if (minor === 2 || minor === 3) {
97563
- const length = decodeCount(at + offset, to);
97560
+ const length = decodeCount$1(at + offset, to);
97564
97561
  let b = BigInt(0);
97565
97562
  const start = at + offset + _offset;
97566
97563
  for (let i2 = start;i2 < start + length; ++i2) {
97567
- b = b << BigInt(8) | BigInt(payload[i2]);
97564
+ b = b << BigInt(8) | BigInt(payload$1[i2]);
97568
97565
  }
97569
97566
  _offset = offset + _offset + length;
97570
97567
  return minor === 3 ? -b - BigInt(1) : b;
@@ -97590,11 +97587,11 @@ var require_cbor = __commonJS((exports) => {
97590
97587
  const value = decode3(at + offset, to);
97591
97588
  const valueOffset = _offset;
97592
97589
  _offset = offset + valueOffset;
97593
- return tag({ tag: castBigInt(unsignedInt), value });
97590
+ return tag({ tag: castBigInt$1(unsignedInt), value });
97594
97591
  }
97595
97592
  }
97596
97593
  function decodeSpecial(at, to) {
97597
- const minor = payload[at] & 31;
97594
+ const minor = payload$1[at] & 31;
97598
97595
  switch (minor) {
97599
97596
  case specialTrue:
97600
97597
  case specialFalse:
@@ -97611,25 +97608,25 @@ var require_cbor = __commonJS((exports) => {
97611
97608
  throw new Error("incomplete float16 at end of buf.");
97612
97609
  }
97613
97610
  _offset = 3;
97614
- return bytesToFloat16(payload[at + 1], payload[at + 2]);
97611
+ return bytesToFloat16$1(payload$1[at + 1], payload$1[at + 2]);
97615
97612
  case extendedFloat32:
97616
97613
  if (to - at < 5) {
97617
97614
  throw new Error("incomplete float32 at end of buf.");
97618
97615
  }
97619
97616
  _offset = 5;
97620
- return dataView$1.getFloat32(at + 1);
97617
+ return dataView$2.getFloat32(at + 1);
97621
97618
  case extendedFloat64:
97622
97619
  if (to - at < 9) {
97623
97620
  throw new Error("incomplete float64 at end of buf.");
97624
97621
  }
97625
97622
  _offset = 9;
97626
- return dataView$1.getFloat64(at + 1);
97623
+ return dataView$2.getFloat64(at + 1);
97627
97624
  default:
97628
97625
  unexpectedMinor(minor);
97629
97626
  }
97630
97627
  }
97631
- function decodeCount(at, to) {
97632
- const minor = payload[at] & 31;
97628
+ function decodeCount$1(at, to) {
97629
+ const minor = payload$1[at] & 31;
97633
97630
  if (minor < 24) {
97634
97631
  _offset = 1;
97635
97632
  return minor;
@@ -97637,28 +97634,28 @@ var require_cbor = __commonJS((exports) => {
97637
97634
  switch (minor) {
97638
97635
  case extendedOneByte:
97639
97636
  if (to - at < 2) {
97640
- overflow(1);
97637
+ overflow$1(1);
97641
97638
  }
97642
97639
  _offset = 2;
97643
- return payload[at + 1];
97640
+ return payload$1[at + 1];
97644
97641
  case extendedFloat16:
97645
97642
  if (to - at < 3) {
97646
- overflow(2);
97643
+ overflow$1(2);
97647
97644
  }
97648
97645
  _offset = 3;
97649
- return dataView$1.getUint16(at + 1);
97646
+ return dataView$2.getUint16(at + 1);
97650
97647
  case extendedFloat32:
97651
97648
  if (to - at < 5) {
97652
- overflow(4);
97649
+ overflow$1(4);
97653
97650
  }
97654
97651
  _offset = 5;
97655
- return dataView$1.getUint32(at + 1);
97652
+ return dataView$2.getUint32(at + 1);
97656
97653
  case extendedFloat64:
97657
97654
  if (to - at < 9) {
97658
- overflow(8);
97655
+ overflow$1(8);
97659
97656
  }
97660
97657
  _offset = 9;
97661
- return demote(dataView$1.getBigUint64(at + 1));
97658
+ return demote(dataView$2.getBigUint64(at + 1));
97662
97659
  default:
97663
97660
  unexpectedMinor(minor);
97664
97661
  }
@@ -97668,7 +97665,7 @@ var require_cbor = __commonJS((exports) => {
97668
97665
  const base2 = at;
97669
97666
  const map2 = {};
97670
97667
  for (;at < to; ) {
97671
- if (payload[at] === 255) {
97668
+ if (payload$1[at] === 255) {
97672
97669
  _offset = at - base2 + 2;
97673
97670
  return map2;
97674
97671
  }
@@ -97683,7 +97680,7 @@ var require_cbor = __commonJS((exports) => {
97683
97680
  at += 1;
97684
97681
  const list = [];
97685
97682
  for (const base2 = at;at < to; ) {
97686
- if (payload[at] === 255) {
97683
+ if (payload$1[at] === 255) {
97687
97684
  _offset = at - base2 + 2;
97688
97685
  return list;
97689
97686
  }
@@ -97696,17 +97693,17 @@ var require_cbor = __commonJS((exports) => {
97696
97693
  at += 1;
97697
97694
  const vector = [];
97698
97695
  for (const base2 = at;at < to; ) {
97699
- if (payload[at] === 255) {
97696
+ if (payload$1[at] === 255) {
97700
97697
  const data2 = alloc(vector.length);
97701
97698
  data2.set(vector, 0);
97702
97699
  _offset = at - base2 + 2;
97703
- if (USE_BUFFER$1) {
97700
+ if (USE_BUFFER$3) {
97704
97701
  return data2.toString("utf-8", 0, data2.length);
97705
97702
  }
97706
- return textDecoder2.decode(data2);
97703
+ return textDecoder$1.decode(data2);
97707
97704
  }
97708
- const major = (payload[at] & 224) >> 5;
97709
- const minor = payload[at] & 31;
97705
+ const major = (payload$1[at] & 224) >> 5;
97706
+ const minor = payload$1[at] & 31;
97710
97707
  if (major !== majorUtf8String) {
97711
97708
  unexpectedMajorInIndefiniteString(major);
97712
97709
  }
@@ -97726,14 +97723,14 @@ var require_cbor = __commonJS((exports) => {
97726
97723
  at += 1;
97727
97724
  const vector = [];
97728
97725
  for (const base2 = at;at < to; ) {
97729
- if (payload[at] === 255) {
97726
+ if (payload$1[at] === 255) {
97730
97727
  const data2 = alloc(vector.length);
97731
97728
  data2.set(vector, 0);
97732
97729
  _offset = at - base2 + 2;
97733
97730
  return data2;
97734
97731
  }
97735
- const major = (payload[at] & 224) >> 5;
97736
- const minor = payload[at] & 31;
97732
+ const major = (payload$1[at] & 224) >> 5;
97733
+ const minor = payload$1[at] & 31;
97737
97734
  if (major !== majorUnstructuredByteString) {
97738
97735
  unexpectedMajorInIndefiniteString(major);
97739
97736
  }
@@ -97749,7 +97746,7 @@ var require_cbor = __commonJS((exports) => {
97749
97746
  }
97750
97747
  throw new Error("expected break marker.");
97751
97748
  }
97752
- function castBigInt(bigInt) {
97749
+ function castBigInt$1(bigInt) {
97753
97750
  if (typeof bigInt === "number") {
97754
97751
  return bigInt;
97755
97752
  }
@@ -97766,7 +97763,7 @@ var require_cbor = __commonJS((exports) => {
97766
97763
  }
97767
97764
  return num;
97768
97765
  }
97769
- function overflow(n2) {
97766
+ function overflow$1(n2) {
97770
97767
  throw new Error(`length ${n2} greater than remaining buf len.`);
97771
97768
  }
97772
97769
  function unexpectedMinor(minor) {
@@ -97775,33 +97772,33 @@ var require_cbor = __commonJS((exports) => {
97775
97772
  function unexpectedMajorInIndefiniteString(major) {
97776
97773
  throw new Error(`unexpected major type ${major} in indefinite string.`);
97777
97774
  }
97778
- var USE_BUFFER = typeof Buffer !== "undefined";
97775
+ var USE_BUFFER$2 = typeof Buffer !== "undefined";
97779
97776
  var encodeStringCache = new Map;
97780
- var encodeCacheEpoch = 0;
97781
- var encodeCacheSaturated = false;
97777
+ var encodeCacheEpoch$1 = 0;
97778
+ var encodeCacheSaturated$1 = false;
97782
97779
  var initialSize = 2048;
97783
97780
  var data = alloc(initialSize);
97784
- var dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
97785
- var cursor = 0;
97781
+ var dataView$1 = new DataView(data.buffer, data.byteOffset, data.byteLength);
97782
+ var cursor$1 = 0;
97786
97783
  function encode6(_input) {
97787
97784
  const encodeStack = [_input];
97788
97785
  while (encodeStack.length) {
97789
97786
  const input = encodeStack.pop();
97790
97787
  if (typeof input === "string") {
97791
97788
  const len = input.length;
97792
- if (USE_BUFFER) {
97789
+ if (USE_BUFFER$2) {
97793
97790
  ensureSpace(len * 3 + 9);
97794
97791
  if (len > 23) {
97795
- encodeHeader(majorUtf8String, Buffer.byteLength(input));
97796
- cursor += data.write(input, cursor);
97792
+ encodeHeader$1(majorUtf8String, Buffer.byteLength(input));
97793
+ cursor$1 += data.write(input, cursor$1);
97797
97794
  } else {
97798
97795
  encodeStringCached(input);
97799
97796
  }
97800
97797
  } else {
97801
97798
  const maxBytes = len * 3;
97802
97799
  ensureSpace(maxBytes + 9);
97803
- const headerPos = cursor;
97804
- const result = new TextEncoder().encodeInto(input, data.subarray(cursor + 9));
97800
+ const headerPos = cursor$1;
97801
+ const result = new TextEncoder().encodeInto(input, data.subarray(cursor$1 + 9));
97805
97802
  const byteLen = result.written;
97806
97803
  let headerSize;
97807
97804
  if (byteLen < 24) {
@@ -97818,46 +97815,46 @@ var require_cbor = __commonJS((exports) => {
97818
97815
  if (headerSize < 9) {
97819
97816
  data.copyWithin(headerPos + headerSize, headerPos + 9, headerPos + 9 + byteLen);
97820
97817
  }
97821
- cursor = headerPos;
97818
+ cursor$1 = headerPos;
97822
97819
  encodeInteger(majorUtf8String, byteLen);
97823
- cursor += byteLen;
97820
+ cursor$1 += byteLen;
97824
97821
  }
97825
97822
  continue;
97826
97823
  }
97827
- if (data.byteLength - cursor < 9) {
97824
+ if (data.byteLength - cursor$1 < 9) {
97828
97825
  ensureSpace(64);
97829
97826
  }
97830
97827
  if (typeof input === "number") {
97831
- if (Number.isInteger(input)) {
97828
+ if (Number.isInteger(input) && input >= -9007199254740992 && input <= 9007199254740991) {
97832
97829
  const nonNegative = input >= 0;
97833
97830
  const major = nonNegative ? majorUint64 : majorNegativeInt64;
97834
97831
  const value = nonNegative ? input : -input - 1;
97835
97832
  if (value < 24) {
97836
- data[cursor++] = major << 5 | value;
97833
+ data[cursor$1++] = major << 5 | value;
97837
97834
  } else if (value < 256) {
97838
- data[cursor++] = major << 5 | 24;
97839
- data[cursor++] = value;
97835
+ data[cursor$1++] = major << 5 | 24;
97836
+ data[cursor$1++] = value;
97840
97837
  } else if (value < 65536) {
97841
- data[cursor++] = major << 5 | extendedFloat16;
97842
- data[cursor++] = value >> 8;
97843
- data[cursor++] = value & 255;
97838
+ data[cursor$1++] = major << 5 | extendedFloat16;
97839
+ data[cursor$1++] = value >> 8;
97840
+ data[cursor$1++] = value & 255;
97844
97841
  } else if (value < 4294967296) {
97845
- data[cursor++] = major << 5 | extendedFloat32;
97846
- dataView.setUint32(cursor, value);
97847
- cursor += 4;
97842
+ data[cursor$1++] = major << 5 | extendedFloat32;
97843
+ dataView$1.setUint32(cursor$1, value);
97844
+ cursor$1 += 4;
97848
97845
  } else {
97849
- data[cursor++] = major << 5 | extendedFloat64;
97846
+ data[cursor$1++] = major << 5 | extendedFloat64;
97850
97847
  const hi = value / 4294967296 | 0;
97851
97848
  const lo = value - hi * 4294967296 | 0;
97852
- dataView.setUint32(cursor, hi);
97853
- dataView.setUint32(cursor + 4, lo);
97854
- cursor += 8;
97849
+ dataView$1.setUint32(cursor$1, hi);
97850
+ dataView$1.setUint32(cursor$1 + 4, lo);
97851
+ cursor$1 += 8;
97855
97852
  }
97856
97853
  continue;
97857
97854
  }
97858
- data[cursor++] = majorSpecial << 5 | extendedFloat64;
97859
- dataView.setFloat64(cursor, input);
97860
- cursor += 8;
97855
+ data[cursor$1++] = majorSpecial << 5 | extendedFloat64;
97856
+ dataView$1.setFloat64(cursor$1, input);
97857
+ cursor$1 += 8;
97861
97858
  continue;
97862
97859
  } else if (typeof input === "bigint") {
97863
97860
  const nonNegative = input >= 0;
@@ -97868,9 +97865,9 @@ var require_cbor = __commonJS((exports) => {
97868
97865
  if (n2 < 4294967296) {
97869
97866
  encodeInteger(major, n2);
97870
97867
  } else {
97871
- data[cursor++] = major << 5 | extendedFloat64;
97872
- dataView.setBigUint64(cursor, value);
97873
- cursor += 8;
97868
+ data[cursor$1++] = major << 5 | extendedFloat64;
97869
+ dataView$1.setBigUint64(cursor$1, value);
97870
+ cursor$1 += 8;
97874
97871
  }
97875
97872
  } else {
97876
97873
  const binaryBigInt = value.toString(2);
@@ -97882,17 +97879,17 @@ var require_cbor = __commonJS((exports) => {
97882
97879
  b >>= BigInt(8);
97883
97880
  }
97884
97881
  ensureSpace(bigIntBytes.byteLength * 2 + 16);
97885
- data[cursor++] = nonNegative ? 194 : 195;
97886
- encodeHeader(majorUnstructuredByteString, bigIntBytes.byteLength);
97887
- data.set(bigIntBytes, cursor);
97888
- cursor += bigIntBytes.byteLength;
97882
+ data[cursor$1++] = nonNegative ? 194 : 195;
97883
+ encodeHeader$1(majorUnstructuredByteString, bigIntBytes.byteLength);
97884
+ data.set(bigIntBytes, cursor$1);
97885
+ cursor$1 += bigIntBytes.byteLength;
97889
97886
  }
97890
97887
  continue;
97891
97888
  } else if (input === null) {
97892
- data[cursor++] = majorSpecial << 5 | specialNull;
97889
+ data[cursor$1++] = majorSpecial << 5 | specialNull;
97893
97890
  continue;
97894
97891
  } else if (typeof input === "boolean") {
97895
- data[cursor++] = majorSpecial << 5 | (input ? specialTrue : specialFalse);
97892
+ data[cursor$1++] = majorSpecial << 5 | (input ? specialTrue : specialFalse);
97896
97893
  continue;
97897
97894
  } else if (typeof input === "undefined") {
97898
97895
  throw new Error("@smithy/core/cbor: client may not serialize undefined value.");
@@ -97906,15 +97903,15 @@ var require_cbor = __commonJS((exports) => {
97906
97903
  } else if (typeof input.byteLength === "number") {
97907
97904
  ensureSpace(input.length * 2 + 9);
97908
97905
  encodeInteger(majorUnstructuredByteString, input.length);
97909
- data.set(input, cursor);
97910
- cursor += input.byteLength;
97906
+ data.set(input, cursor$1);
97907
+ cursor$1 += input.byteLength;
97911
97908
  continue;
97912
97909
  } else if (typeof input === "object") {
97913
97910
  if (input instanceof NumericValue) {
97914
97911
  const decimalIndex = input.string.indexOf(".");
97915
97912
  const exponent = decimalIndex === -1 ? 0 : decimalIndex - input.string.length + 1;
97916
97913
  const mantissa = BigInt(input.string.replace(".", ""));
97917
- data[cursor++] = 196;
97914
+ data[cursor$1++] = 196;
97918
97915
  encodeInteger(majorList, 2);
97919
97916
  encodeStack.push(mantissa);
97920
97917
  encodeStack.push(exponent);
@@ -97923,7 +97920,7 @@ var require_cbor = __commonJS((exports) => {
97923
97920
  if (input[tagSymbol]) {
97924
97921
  if ("tag" in input && "value" in input) {
97925
97922
  encodeStack.push(input.value);
97926
- encodeHeader(majorTag, input.tag);
97923
+ encodeHeader$1(majorTag, input.tag);
97927
97924
  continue;
97928
97925
  } else {
97929
97926
  throw new Error("tag encountered with missing fields, need 'tag' and 'value', found: " + JSON.stringify(input));
@@ -97942,13 +97939,13 @@ var require_cbor = __commonJS((exports) => {
97942
97939
  }
97943
97940
  }
97944
97941
  function advanceEncodingEpoch() {
97945
- encodeCacheEpoch = encodeCacheEpoch + 1 & 65535;
97946
- encodeCacheSaturated = false;
97942
+ encodeCacheEpoch$1 = encodeCacheEpoch$1 + 1 & 65535;
97943
+ encodeCacheSaturated$1 = false;
97947
97944
  }
97948
97945
  function toUint8Array() {
97949
- const out = alloc(cursor);
97950
- out.set(data.subarray(0, cursor), 0);
97951
- cursor = 0;
97946
+ const out = alloc(cursor$1);
97947
+ out.set(data.subarray(0, cursor$1), 0);
97948
+ cursor$1 = 0;
97952
97949
  return out;
97953
97950
  }
97954
97951
  function resize(size) {
@@ -97961,23 +97958,23 @@ var require_cbor = __commonJS((exports) => {
97961
97958
  data.set(old, 0);
97962
97959
  }
97963
97960
  }
97964
- dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
97961
+ dataView$1 = new DataView(data.buffer, data.byteOffset, data.byteLength);
97965
97962
  }
97966
97963
  function encodeStringCached(input) {
97967
97964
  const cached2 = encodeStringCache.get(input);
97968
97965
  if (cached2 !== undefined) {
97969
- data.set(cached2.bytes, cursor);
97970
- cursor += cached2.bytes.length;
97971
- cached2.epoch = encodeCacheEpoch;
97966
+ data.set(cached2.bytes, cursor$1);
97967
+ cursor$1 += cached2.bytes.length;
97968
+ cached2.epoch = encodeCacheEpoch$1;
97972
97969
  return;
97973
97970
  }
97974
- const start = cursor;
97971
+ const start = cursor$1;
97975
97972
  const byteLen = Buffer.byteLength(input);
97976
97973
  encodeInteger(majorUtf8String, byteLen);
97977
- cursor += data.write(input, cursor);
97978
- const bytes = Uint8Array.prototype.slice.call(data, start, cursor);
97974
+ cursor$1 += data.write(input, cursor$1);
97975
+ const bytes = Uint8Array.prototype.slice.call(data, start, cursor$1);
97979
97976
  if (encodeStringCache.size >= 2048) {
97980
- if (encodeCacheSaturated) {
97977
+ if (encodeCacheSaturated$1) {
97981
97978
  return;
97982
97979
  }
97983
97980
  let evicted = 0;
@@ -97985,71 +97982,71 @@ var require_cbor = __commonJS((exports) => {
97985
97982
  if (evicted >= 1024) {
97986
97983
  break;
97987
97984
  }
97988
- if (entry.epoch !== encodeCacheEpoch) {
97985
+ if (entry.epoch !== encodeCacheEpoch$1) {
97989
97986
  encodeStringCache.delete(key);
97990
97987
  evicted++;
97991
97988
  }
97992
97989
  }
97993
97990
  if (evicted === 0) {
97994
- encodeCacheSaturated = true;
97991
+ encodeCacheSaturated$1 = true;
97995
97992
  return;
97996
97993
  }
97997
97994
  }
97998
97995
  if (encodeStringCache.size < 2048) {
97999
- encodeStringCache.set(input, { epoch: encodeCacheEpoch, bytes });
97996
+ encodeStringCache.set(input, { epoch: encodeCacheEpoch$1, bytes });
98000
97997
  }
98001
97998
  }
98002
97999
  function ensureSpace(bytes) {
98003
- const remaining = data.byteLength - cursor;
98000
+ const remaining = data.byteLength - cursor$1;
98004
98001
  if (remaining < bytes) {
98005
- if (cursor < 16000000) {
98002
+ if (cursor$1 < 16000000) {
98006
98003
  resize(Math.max(data.byteLength * 4, data.byteLength + bytes));
98007
98004
  } else {
98008
98005
  resize(data.byteLength + bytes + 16000000);
98009
98006
  }
98010
98007
  }
98011
98008
  }
98012
- function encodeHeader(major, value) {
98009
+ function encodeHeader$1(major, value) {
98013
98010
  if (value < 24) {
98014
- data[cursor++] = major << 5 | value;
98011
+ data[cursor$1++] = major << 5 | value;
98015
98012
  } else if (value < 256) {
98016
- data[cursor++] = major << 5 | 24;
98017
- data[cursor++] = value;
98013
+ data[cursor$1++] = major << 5 | 24;
98014
+ data[cursor$1++] = value;
98018
98015
  } else if (value < 65536) {
98019
- data[cursor++] = major << 5 | extendedFloat16;
98020
- dataView.setUint16(cursor, value);
98021
- cursor += 2;
98016
+ data[cursor$1++] = major << 5 | extendedFloat16;
98017
+ dataView$1.setUint16(cursor$1, value);
98018
+ cursor$1 += 2;
98022
98019
  } else if (value < 4294967296) {
98023
- data[cursor++] = major << 5 | extendedFloat32;
98024
- dataView.setUint32(cursor, value);
98025
- cursor += 4;
98020
+ data[cursor$1++] = major << 5 | extendedFloat32;
98021
+ dataView$1.setUint32(cursor$1, value);
98022
+ cursor$1 += 4;
98026
98023
  } else {
98027
- data[cursor++] = major << 5 | extendedFloat64;
98028
- dataView.setBigUint64(cursor, typeof value === "bigint" ? value : BigInt(value));
98029
- cursor += 8;
98024
+ data[cursor$1++] = major << 5 | extendedFloat64;
98025
+ dataView$1.setBigUint64(cursor$1, typeof value === "bigint" ? value : BigInt(value));
98026
+ cursor$1 += 8;
98030
98027
  }
98031
98028
  }
98032
98029
  function encodeInteger(major, value) {
98033
98030
  if (value < 24) {
98034
- data[cursor++] = major << 5 | value;
98031
+ data[cursor$1++] = major << 5 | value;
98035
98032
  } else if (value < 256) {
98036
- data[cursor++] = major << 5 | 24;
98037
- data[cursor++] = value;
98033
+ data[cursor$1++] = major << 5 | 24;
98034
+ data[cursor$1++] = value;
98038
98035
  } else if (value < 65536) {
98039
- data[cursor++] = major << 5 | extendedFloat16;
98040
- data[cursor++] = value >> 8;
98041
- data[cursor++] = value & 255;
98036
+ data[cursor$1++] = major << 5 | extendedFloat16;
98037
+ data[cursor$1++] = value >> 8;
98038
+ data[cursor$1++] = value & 255;
98042
98039
  } else if (value < 4294967296) {
98043
- data[cursor++] = major << 5 | extendedFloat32;
98044
- dataView.setUint32(cursor, value);
98045
- cursor += 4;
98040
+ data[cursor$1++] = major << 5 | extendedFloat32;
98041
+ dataView$1.setUint32(cursor$1, value);
98042
+ cursor$1 += 4;
98046
98043
  } else {
98047
- data[cursor++] = major << 5 | extendedFloat64;
98044
+ data[cursor$1++] = major << 5 | extendedFloat64;
98048
98045
  const hi = value / 4294967296 | 0;
98049
98046
  const lo = value - hi * 4294967296 | 0;
98050
- dataView.setUint32(cursor, hi);
98051
- dataView.setUint32(cursor + 4, lo);
98052
- cursor += 8;
98047
+ dataView$1.setUint32(cursor$1, hi);
98048
+ dataView$1.setUint32(cursor$1 + 4, lo);
98049
+ cursor$1 += 8;
98053
98050
  }
98054
98051
  }
98055
98052
  var cbor = {
@@ -98164,6 +98161,1278 @@ var require_cbor = __commonJS((exports) => {
98164
98161
  return new HttpRequest(contents);
98165
98162
  };
98166
98163
 
98164
+ class CborShapeSerializer2 extends SerdeContext {
98165
+ write(schema, value) {
98166
+ cursor = 0;
98167
+ const ns = NormalizedSchema.of(schema);
98168
+ writeValue(ns, value, undefined, this.serdeContext);
98169
+ }
98170
+ flush() {
98171
+ const result = buf.subarray(0, cursor);
98172
+ cursor = 0;
98173
+ buf = allocUnsafe2(INITIAL_BUFFER_SIZE);
98174
+ view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
98175
+ return result;
98176
+ }
98177
+ }
98178
+ var CBOR_STRUCT_CACHE = Symbol.for("@smithy/cbor-struct-cache");
98179
+ function loadCborStructIterator(ns) {
98180
+ const schema = ns.getSchema();
98181
+ const existing = schema[CBOR_STRUCT_CACHE];
98182
+ if (existing) {
98183
+ return existing;
98184
+ }
98185
+ const memberNames = [];
98186
+ const memberSchemas = [];
98187
+ for (const [name, memberSchema] of ns.structIterator()) {
98188
+ memberNames.push(name);
98189
+ memberSchemas.push(memberSchema);
98190
+ }
98191
+ const encodedKeys = new Array(memberNames.length);
98192
+ for (let i2 = 0;i2 < memberNames.length; ++i2) {
98193
+ encodedKeys[i2] = encodeCborStringKey(memberNames[i2]);
98194
+ }
98195
+ const cache = { memberNames, memberSchemas, encodedKeys };
98196
+ schema[CBOR_STRUCT_CACHE] = cache;
98197
+ return cache;
98198
+ }
98199
+ function encodeCborStringKey(s) {
98200
+ let utf8Bytes;
98201
+ if (USE_BUFFER$1) {
98202
+ utf8Bytes = Buffer.from(s, "utf-8");
98203
+ } else {
98204
+ utf8Bytes = new TextEncoder().encode(s);
98205
+ }
98206
+ const byteLen = utf8Bytes.length;
98207
+ let headerSize;
98208
+ if (byteLen < 24) {
98209
+ headerSize = 1;
98210
+ } else if (byteLen < 256) {
98211
+ headerSize = 2;
98212
+ } else {
98213
+ headerSize = 3;
98214
+ }
98215
+ const result = new Uint8Array(headerSize + byteLen);
98216
+ if (headerSize === 1) {
98217
+ result[0] = majorUtf8String << 5 | byteLen;
98218
+ } else if (headerSize === 2) {
98219
+ result[0] = majorUtf8String << 5 | 24;
98220
+ result[1] = byteLen;
98221
+ } else {
98222
+ result[0] = majorUtf8String << 5 | extendedFloat16;
98223
+ result[1] = byteLen >> 8;
98224
+ result[2] = byteLen & 255;
98225
+ }
98226
+ result.set(utf8Bytes, headerSize);
98227
+ return result;
98228
+ }
98229
+ var USE_BUFFER$1 = typeof Buffer !== "undefined";
98230
+ var textEncoder4 = new TextEncoder;
98231
+ var INITIAL_BUFFER_SIZE = 2048;
98232
+ var buf = USE_BUFFER$1 ? Buffer.allocUnsafe(INITIAL_BUFFER_SIZE) : new Uint8Array(INITIAL_BUFFER_SIZE);
98233
+ var view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
98234
+ var cursor = 0;
98235
+ var STRING_CACHE_MAX = 2048;
98236
+ var stringEncodeCache = new Map;
98237
+ var encodeCacheEpoch = 0;
98238
+ var encodeCacheSaturated = false;
98239
+ function allocUnsafe2(size) {
98240
+ return USE_BUFFER$1 ? Buffer.allocUnsafe(size) : new Uint8Array(size);
98241
+ }
98242
+ function writeValue(ns, value, container, serdeContext) {
98243
+ if (value == null) {
98244
+ if (value === undefined && ns.isIdempotencyToken()) {
98245
+ writeString(generateIdempotencyToken());
98246
+ return;
98247
+ }
98248
+ ensure(1);
98249
+ buf[cursor++] = majorSpecial << 5 | specialNull;
98250
+ return;
98251
+ }
98252
+ if (ns.isUnitSchema()) {
98253
+ ensure(1);
98254
+ encodeHeader(majorMap, 0);
98255
+ return;
98256
+ }
98257
+ const isObject5 = typeof value === "object";
98258
+ if (isObject5) {
98259
+ if (ns.isBlobSchema()) {
98260
+ if (value instanceof Uint8Array) {
98261
+ writeBytes(value);
98262
+ return;
98263
+ }
98264
+ }
98265
+ if (ns.isTimestampSchema()) {
98266
+ if (value instanceof Date) {
98267
+ writeTimestamp(value);
98268
+ return;
98269
+ }
98270
+ }
98271
+ if (ns.isStructSchema()) {
98272
+ writeStruct(ns, value, serdeContext);
98273
+ return;
98274
+ }
98275
+ if (Array.isArray(value) && (ns.isListSchema() || ns.isDocumentSchema())) {
98276
+ writeList(ns, value, ns.isDocumentSchema(), serdeContext);
98277
+ return;
98278
+ }
98279
+ if (ns.isMapSchema()) {
98280
+ writeMap(ns, value, false, serdeContext);
98281
+ return;
98282
+ }
98283
+ if (value instanceof Date) {
98284
+ writeTimestamp(value);
98285
+ return;
98286
+ }
98287
+ if (value instanceof Uint8Array) {
98288
+ writeBytes(value);
98289
+ return;
98290
+ }
98291
+ if (value instanceof NumericValue) {
98292
+ writeNumericValue(value);
98293
+ return;
98294
+ }
98295
+ if (value[tagSymbol]) {
98296
+ const tagged = value;
98297
+ writeTag(tagged.tag, tagged.value);
98298
+ return;
98299
+ }
98300
+ if (ns.isDocumentSchema()) {
98301
+ if (Array.isArray(value)) {
98302
+ writeList(ns, value, true, serdeContext);
98303
+ } else {
98304
+ writeMap(ns, value, true, serdeContext);
98305
+ }
98306
+ return;
98307
+ }
98308
+ if (ns.isBigDecimalSchema()) {
98309
+ writeUntypedValue(value);
98310
+ return;
98311
+ }
98312
+ writeMap(ns, value, true, serdeContext);
98313
+ return;
98314
+ }
98315
+ if (typeof value === "string") {
98316
+ if (ns.isBlobSchema()) {
98317
+ const bytes = (serdeContext?.base64Decoder ?? fromBase64)(value);
98318
+ writeBytes(bytes);
98319
+ return;
98320
+ }
98321
+ writeString(value);
98322
+ return;
98323
+ }
98324
+ if (typeof value === "number") {
98325
+ ensure(9);
98326
+ if (Number.isInteger(value) && value >= -9007199254740992 && value <= 9007199254740991) {
98327
+ writeInteger(value);
98328
+ } else {
98329
+ writeFloat64(value);
98330
+ }
98331
+ return;
98332
+ }
98333
+ if (typeof value === "boolean") {
98334
+ ensure(1);
98335
+ buf[cursor++] = majorSpecial << 5 | (value ? specialTrue : specialFalse);
98336
+ return;
98337
+ }
98338
+ if (typeof value === "bigint") {
98339
+ writeBigInt(value);
98340
+ return;
98341
+ }
98342
+ writeString(String(value));
98343
+ }
98344
+ function writeStruct(ns, value, serdeContext) {
98345
+ if (ns.isUnionSchema()) {
98346
+ let wrote = false;
98347
+ for (const [memberName, memberSchema] of ns.structIterator()) {
98348
+ const item = value[memberName];
98349
+ if (item != null) {
98350
+ ensure(9);
98351
+ encodeHeader(majorMap, 1);
98352
+ writeString(memberName);
98353
+ writeValue(memberSchema, item, ns, serdeContext);
98354
+ wrote = true;
98355
+ break;
98356
+ }
98357
+ }
98358
+ if (!wrote) {
98359
+ const { $unknown } = value;
98360
+ if (Array.isArray($unknown)) {
98361
+ ensure(9);
98362
+ encodeHeader(majorMap, 1);
98363
+ writeString($unknown[0]);
98364
+ writeUntypedValue($unknown[1]);
98365
+ } else {
98366
+ ensure(9);
98367
+ encodeHeader(majorMap, 0);
98368
+ }
98369
+ }
98370
+ return;
98371
+ }
98372
+ const cache = loadCborStructIterator(ns);
98373
+ const { memberNames, memberSchemas, encodedKeys } = cache;
98374
+ const z3 = memberNames.length;
98375
+ let headerSize;
98376
+ if (z3 < 24) {
98377
+ headerSize = 1;
98378
+ } else if (z3 < 256) {
98379
+ headerSize = 2;
98380
+ } else {
98381
+ headerSize = 3;
98382
+ }
98383
+ ensure(headerSize);
98384
+ const headerPos = cursor;
98385
+ cursor += headerSize;
98386
+ let count3 = 0;
98387
+ for (let i2 = 0;i2 < z3; ++i2) {
98388
+ const item = value[memberNames[i2]];
98389
+ if (item == null && !memberSchemas[i2].isIdempotencyToken()) {
98390
+ continue;
98391
+ }
98392
+ const key = encodedKeys[i2];
98393
+ ensure(key.length);
98394
+ buf.set(key, cursor);
98395
+ cursor += key.length;
98396
+ writeValue(memberSchemas[i2], item, ns, serdeContext);
98397
+ ++count3;
98398
+ }
98399
+ if (typeof value.__type === "string") {
98400
+ for (const k in value) {
98401
+ if (!memberNames.includes(k)) {
98402
+ writeString(k);
98403
+ writeUntypedValue(value[k]);
98404
+ ++count3;
98405
+ }
98406
+ }
98407
+ }
98408
+ if (headerSize === 1) {
98409
+ buf[headerPos] = majorMap << 5 | count3;
98410
+ } else if (headerSize === 2) {
98411
+ buf[headerPos] = majorMap << 5 | 24;
98412
+ buf[headerPos + 1] = count3;
98413
+ } else {
98414
+ buf[headerPos] = majorMap << 5 | extendedFloat16;
98415
+ buf[headerPos + 1] = count3 >> 8;
98416
+ buf[headerPos + 2] = count3 & 255;
98417
+ }
98418
+ }
98419
+ function writeList(ns, value, isDocument, serdeContext) {
98420
+ const sparse = !!ns.getMergedTraits().sparse;
98421
+ const valueSchema = ns.getValueSchema();
98422
+ if (isDocument || sparse) {
98423
+ const items = [];
98424
+ for (let i2 = 0;i2 < value.length; ++i2) {
98425
+ const item = value[i2];
98426
+ if (isDocument) {
98427
+ if (item !== undefined) {
98428
+ items.push(item);
98429
+ }
98430
+ } else {
98431
+ if (item != null || sparse) {
98432
+ items.push(item);
98433
+ }
98434
+ }
98435
+ }
98436
+ ensure(9);
98437
+ encodeHeader(majorList, items.length);
98438
+ for (let i2 = 0;i2 < items.length; ++i2) {
98439
+ writeValue(valueSchema, items[i2], undefined, serdeContext);
98440
+ }
98441
+ } else {
98442
+ let count3 = 0;
98443
+ for (let i2 = 0;i2 < value.length; ++i2) {
98444
+ if (value[i2] != null) {
98445
+ ++count3;
98446
+ }
98447
+ }
98448
+ ensure(9);
98449
+ encodeHeader(majorList, count3);
98450
+ for (let i2 = 0;i2 < value.length; ++i2) {
98451
+ if (value[i2] != null) {
98452
+ writeValue(valueSchema, value[i2], undefined, serdeContext);
98453
+ }
98454
+ }
98455
+ }
98456
+ }
98457
+ function writeMap(ns, value, isDocument, serdeContext) {
98458
+ const sparse = !!ns.getMergedTraits().sparse;
98459
+ const valueSchema = ns.getValueSchema();
98460
+ const keys2 = [];
98461
+ for (const k in value) {
98462
+ const v = value[k];
98463
+ if (isDocument ? v !== undefined : v != null || sparse) {
98464
+ keys2.push(k);
98465
+ }
98466
+ }
98467
+ ensure(9);
98468
+ encodeHeader(majorMap, keys2.length);
98469
+ for (let i2 = 0;i2 < keys2.length; ++i2) {
98470
+ const k = keys2[i2];
98471
+ writeString(k);
98472
+ writeValue(valueSchema, value[k], undefined, serdeContext);
98473
+ }
98474
+ }
98475
+ function writeUntypedValue(value) {
98476
+ if (value == null) {
98477
+ ensure(1);
98478
+ buf[cursor++] = majorSpecial << 5 | specialNull;
98479
+ return;
98480
+ }
98481
+ if (typeof value === "string") {
98482
+ writeString(value);
98483
+ return;
98484
+ }
98485
+ if (typeof value === "number") {
98486
+ ensure(9);
98487
+ if (Number.isInteger(value) && value >= -9007199254740992 && value <= 9007199254740991) {
98488
+ writeInteger(value);
98489
+ } else {
98490
+ writeFloat64(value);
98491
+ }
98492
+ return;
98493
+ }
98494
+ if (typeof value === "boolean") {
98495
+ ensure(1);
98496
+ buf[cursor++] = majorSpecial << 5 | (value ? specialTrue : specialFalse);
98497
+ return;
98498
+ }
98499
+ if (typeof value === "bigint") {
98500
+ writeBigInt(value);
98501
+ return;
98502
+ }
98503
+ if (value instanceof Uint8Array) {
98504
+ writeBytes(value);
98505
+ return;
98506
+ }
98507
+ if (value instanceof Date) {
98508
+ writeTimestamp(value);
98509
+ return;
98510
+ }
98511
+ if (value instanceof NumericValue) {
98512
+ writeNumericValue(value);
98513
+ return;
98514
+ }
98515
+ if (value[tagSymbol]) {
98516
+ const tagged = value;
98517
+ writeTag(tagged.tag, tagged.value);
98518
+ return;
98519
+ }
98520
+ if (Array.isArray(value)) {
98521
+ ensure(9);
98522
+ encodeHeader(majorList, value.length);
98523
+ for (let i2 = 0;i2 < value.length; ++i2) {
98524
+ writeUntypedValue(value[i2]);
98525
+ }
98526
+ return;
98527
+ }
98528
+ if (typeof value === "object") {
98529
+ const keys2 = Object.keys(value);
98530
+ ensure(9);
98531
+ encodeHeader(majorMap, keys2.length);
98532
+ for (let i2 = 0;i2 < keys2.length; ++i2) {
98533
+ writeString(keys2[i2]);
98534
+ writeUntypedValue(value[keys2[i2]]);
98535
+ }
98536
+ return;
98537
+ }
98538
+ writeString(String(value));
98539
+ }
98540
+ function ensure(n2) {
98541
+ if (cursor + n2 > buf.length) {
98542
+ let newSize = buf.length * 2;
98543
+ while (newSize < cursor + n2) {
98544
+ newSize *= 2;
98545
+ }
98546
+ const next = allocUnsafe2(newSize);
98547
+ next.set(buf.subarray(0, cursor));
98548
+ buf = next;
98549
+ view = new DataView(next.buffer, next.byteOffset, next.byteLength);
98550
+ }
98551
+ }
98552
+ function encodeHeader(major, value) {
98553
+ if (value < 24) {
98554
+ buf[cursor++] = major << 5 | value;
98555
+ } else if (value < 256) {
98556
+ buf[cursor++] = major << 5 | 24;
98557
+ buf[cursor++] = value;
98558
+ } else if (value < 65536) {
98559
+ buf[cursor++] = major << 5 | extendedFloat16;
98560
+ buf[cursor++] = value >> 8;
98561
+ buf[cursor++] = value & 255;
98562
+ } else if (value < 4294967296) {
98563
+ buf[cursor++] = major << 5 | extendedFloat32;
98564
+ view.setUint32(cursor, value);
98565
+ cursor += 4;
98566
+ } else {
98567
+ buf[cursor++] = major << 5 | extendedFloat64;
98568
+ const hi = value / 4294967296 | 0;
98569
+ const lo = value - hi * 4294967296 | 0;
98570
+ view.setUint32(cursor, hi);
98571
+ view.setUint32(cursor + 4, lo);
98572
+ cursor += 8;
98573
+ }
98574
+ }
98575
+ function encodeBigHeader(major, value) {
98576
+ const n2 = Number(value);
98577
+ if (n2 < 4294967296) {
98578
+ encodeHeader(major, n2);
98579
+ return;
98580
+ }
98581
+ buf[cursor++] = major << 5 | extendedFloat64;
98582
+ view.setBigUint64(cursor, value);
98583
+ cursor += 8;
98584
+ }
98585
+ function writeString(s) {
98586
+ const len = s.length;
98587
+ if (len <= 23) {
98588
+ const cached2 = stringEncodeCache.get(s);
98589
+ if (cached2) {
98590
+ ensure(cached2.bytes.length);
98591
+ buf.set(cached2.bytes, cursor);
98592
+ cursor += cached2.bytes.length;
98593
+ cached2.epoch = encodeCacheEpoch;
98594
+ return;
98595
+ }
98596
+ const start = cursor;
98597
+ writeStringUncached(s, len);
98598
+ const end2 = cursor;
98599
+ const bytes = Uint8Array.prototype.slice.call(buf, start, end2);
98600
+ if (stringEncodeCache.size >= STRING_CACHE_MAX) {
98601
+ if (encodeCacheSaturated) {
98602
+ return;
98603
+ }
98604
+ let evicted = 0;
98605
+ for (const [key, entry] of stringEncodeCache) {
98606
+ if (evicted >= 1024) {
98607
+ break;
98608
+ }
98609
+ if (entry.epoch !== encodeCacheEpoch) {
98610
+ stringEncodeCache.delete(key);
98611
+ ++evicted;
98612
+ }
98613
+ }
98614
+ if (evicted === 0) {
98615
+ encodeCacheSaturated = true;
98616
+ return;
98617
+ }
98618
+ }
98619
+ if (stringEncodeCache.size < STRING_CACHE_MAX) {
98620
+ stringEncodeCache.set(s, { epoch: encodeCacheEpoch, bytes });
98621
+ }
98622
+ return;
98623
+ }
98624
+ writeStringUncached(s, len);
98625
+ }
98626
+ function writeStringUncached(s, len) {
98627
+ if (USE_BUFFER$1) {
98628
+ const maxBytes = len * 3;
98629
+ ensure(maxBytes + 9);
98630
+ const byteLen = Buffer.byteLength(s);
98631
+ encodeHeader(majorUtf8String, byteLen);
98632
+ cursor += buf.write(s, cursor);
98633
+ } else {
98634
+ const maxBytes = len * 3;
98635
+ ensure(maxBytes + 9);
98636
+ const headerPos = cursor;
98637
+ const result = textEncoder4.encodeInto(s, buf.subarray(headerPos + 9));
98638
+ const byteLen = result.written;
98639
+ let headerSize;
98640
+ if (byteLen < 24) {
98641
+ headerSize = 1;
98642
+ } else if (byteLen < 256) {
98643
+ headerSize = 2;
98644
+ } else if (byteLen < 65536) {
98645
+ headerSize = 3;
98646
+ } else if (byteLen < 4294967296) {
98647
+ headerSize = 5;
98648
+ } else {
98649
+ headerSize = 9;
98650
+ }
98651
+ if (headerSize < 9) {
98652
+ buf.copyWithin(headerPos + headerSize, headerPos + 9, headerPos + 9 + byteLen);
98653
+ }
98654
+ cursor = headerPos;
98655
+ encodeHeader(majorUtf8String, byteLen);
98656
+ cursor += byteLen;
98657
+ }
98658
+ }
98659
+ function writeFloat64(value) {
98660
+ ensure(9);
98661
+ buf[cursor++] = majorSpecial << 5 | extendedFloat64;
98662
+ view.setFloat64(cursor, value);
98663
+ cursor += 8;
98664
+ }
98665
+ function writeInteger(value) {
98666
+ ensure(9);
98667
+ const nonNegative = value >= 0;
98668
+ const major = nonNegative ? majorUint64 : majorNegativeInt64;
98669
+ const abs = nonNegative ? value : -value - 1;
98670
+ encodeHeader(major, abs);
98671
+ }
98672
+ function writeBigInt(value) {
98673
+ const nonNegative = value >= 0;
98674
+ const major = nonNegative ? majorUint64 : majorNegativeInt64;
98675
+ const abs = nonNegative ? value : -value - BigInt(1);
98676
+ if (abs < BigInt("18446744073709551616")) {
98677
+ ensure(9);
98678
+ encodeBigHeader(major, abs);
98679
+ } else {
98680
+ const binaryStr = abs.toString(2);
98681
+ const byteLen = Math.ceil(binaryStr.length / 8);
98682
+ const bigIntBytes = new Uint8Array(byteLen);
98683
+ let b = abs;
98684
+ for (let i2 = byteLen - 1;i2 >= 0; --i2) {
98685
+ bigIntBytes[i2] = Number(b & BigInt(255));
98686
+ b >>= BigInt(8);
98687
+ }
98688
+ ensure(byteLen + 16);
98689
+ buf[cursor++] = nonNegative ? 194 : 195;
98690
+ encodeHeader(majorUnstructuredByteString, byteLen);
98691
+ buf.set(bigIntBytes, cursor);
98692
+ cursor += byteLen;
98693
+ }
98694
+ }
98695
+ function writeBytes(data2) {
98696
+ ensure(data2.length + 9);
98697
+ encodeHeader(majorUnstructuredByteString, data2.length);
98698
+ buf.set(data2, cursor);
98699
+ cursor += data2.length;
98700
+ }
98701
+ function writeTag(tagValue, innerValue) {
98702
+ ensure(9);
98703
+ if (typeof tagValue === "bigint") {
98704
+ encodeBigHeader(majorTag, tagValue);
98705
+ } else {
98706
+ encodeHeader(majorTag, tagValue);
98707
+ }
98708
+ writeUntypedValue(innerValue);
98709
+ }
98710
+ function writeNumericValue(nv2) {
98711
+ const decimalIndex = nv2.string.indexOf(".");
98712
+ const exponent = decimalIndex === -1 ? 0 : decimalIndex - nv2.string.length + 1;
98713
+ const mantissa = BigInt(nv2.string.replace(".", ""));
98714
+ ensure(9);
98715
+ buf[cursor++] = 196;
98716
+ encodeHeader(majorList, 2);
98717
+ ensure(9);
98718
+ writeInteger(exponent);
98719
+ writeBigInt(mantissa);
98720
+ }
98721
+ function writeTimestamp(date5) {
98722
+ ensure(18);
98723
+ encodeHeader(majorTag, 1);
98724
+ const epochSecs = date5.getTime() / 1000;
98725
+ if (Number.isInteger(epochSecs)) {
98726
+ writeInteger(epochSecs);
98727
+ } else {
98728
+ writeFloat64(epochSecs);
98729
+ }
98730
+ }
98731
+
98732
+ class CborShapeDeserializer2 extends SerdeContext {
98733
+ read(schema, bytes) {
98734
+ payload = bytes;
98735
+ isBuffer3 = USE_BUFFER && bytes instanceof Buffer;
98736
+ dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
98737
+ pos = 0;
98738
+ end = bytes.length;
98739
+ cacheEpoch = cacheEpoch + 1 & 65535;
98740
+ return readValue(NormalizedSchema.of(schema));
98741
+ }
98742
+ readValue(_schema, value) {
98743
+ return transformObject(NormalizedSchema.of(_schema), value);
98744
+ }
98745
+ }
98746
+ var USE_BUFFER = typeof Buffer !== "undefined";
98747
+ var textDecoder2 = new TextDecoder;
98748
+ var payload = new Uint8Array(0);
98749
+ var isBuffer3 = false;
98750
+ var dataView = new DataView(new ArrayBuffer(0));
98751
+ var pos = 0;
98752
+ var end = 0;
98753
+ var STRING_CACHE_SIZE = 2048;
98754
+ var stringCache = new Array(STRING_CACHE_SIZE);
98755
+ var stringCacheEpochs = new Uint16Array(STRING_CACHE_SIZE);
98756
+ var cacheEpoch = 0;
98757
+ function readValue(ns) {
98758
+ if (pos >= end) {
98759
+ throw new Error("unexpected end of CBOR payload.");
98760
+ }
98761
+ const major = (payload[pos] & 224) >> 5;
98762
+ const minor = payload[pos] & 31;
98763
+ if (minor === minorIndefinite && major >= 2 && major <= 5) {
98764
+ return readIndefinite(ns, major);
98765
+ }
98766
+ switch (major) {
98767
+ case majorUint64:
98768
+ return readUnsignedInt();
98769
+ case majorNegativeInt64:
98770
+ return readNegativeInt();
98771
+ case majorUnstructuredByteString:
98772
+ return readByteString();
98773
+ case majorUtf8String:
98774
+ return readUtf8String();
98775
+ case majorList:
98776
+ return readList(ns);
98777
+ case majorMap:
98778
+ return readMap(ns);
98779
+ case majorTag:
98780
+ return readTag();
98781
+ case majorSpecial:
98782
+ return readSpecial();
98783
+ default:
98784
+ throw new Error(`unexpected CBOR major type ${major}.`);
98785
+ }
98786
+ }
98787
+ function readList(ns) {
98788
+ const count3 = decodeCount();
98789
+ const memberSchema = ns.isListSchema() ? ns.getValueSchema() : ns;
98790
+ const list = Array(count3);
98791
+ for (let i2 = 0;i2 < count3; ++i2) {
98792
+ list[i2] = readValue(memberSchema);
98793
+ }
98794
+ return list;
98795
+ }
98796
+ function readMap(ns) {
98797
+ const count3 = decodeCount();
98798
+ if (ns.isStructSchema()) {
98799
+ const startPos = pos;
98800
+ return readStruct(ns, count3, startPos);
98801
+ }
98802
+ const valueSchema = ns.isMapSchema() ? ns.getValueSchema() : ns;
98803
+ const map2 = {};
98804
+ for (let i2 = 0;i2 < count3; ++i2) {
98805
+ const key = readUtf8String();
98806
+ map2[key] = readValue(valueSchema);
98807
+ }
98808
+ return map2;
98809
+ }
98810
+ function readStruct(ns, count3, startPos) {
98811
+ const isUnion = ns.isUnionSchema();
98812
+ const cache = loadCborStructIterator(ns);
98813
+ const { memberSchemas, encodedKeys, memberNames } = cache;
98814
+ const z3 = encodedKeys.length;
98815
+ const result = {};
98816
+ let unknownKey;
98817
+ let unknownValue;
98818
+ let unknownCount = 0;
98819
+ let hasType = false;
98820
+ let hint = 0;
98821
+ for (let i2 = 0;i2 < count3; ++i2) {
98822
+ const matchIdx = matchStructKey(encodedKeys, z3, hint);
98823
+ if (matchIdx >= 0) {
98824
+ hint = matchIdx + 1;
98825
+ if (hint >= z3) {
98826
+ hint = 0;
98827
+ }
98828
+ const val = readValue(memberSchemas[matchIdx]);
98829
+ if (val != null) {
98830
+ result[memberNames[matchIdx]] = val;
98831
+ }
98832
+ } else {
98833
+ const key = readUtf8String();
98834
+ const val = readValue(NormalizedSchema.of(15));
98835
+ if (key === "__type" && typeof val === "string") {
98836
+ hasType = true;
98837
+ } else {
98838
+ unknownKey = key;
98839
+ unknownValue = val;
98840
+ ++unknownCount;
98841
+ }
98842
+ }
98843
+ }
98844
+ if (isUnion) {
98845
+ let resultEmpty = true;
98846
+ for (const _ in result) {
98847
+ resultEmpty = false;
98848
+ break;
98849
+ }
98850
+ if (resultEmpty && unknownCount === 1) {
98851
+ result.$unknown = [unknownKey, unknownValue];
98852
+ }
98853
+ } else if (hasType) {
98854
+ pos = startPos;
98855
+ const docSchema = NormalizedSchema.of(15);
98856
+ for (let i2 = 0;i2 < count3; ++i2) {
98857
+ const key = readUtf8String();
98858
+ const val = readValue(docSchema);
98859
+ if (!(key in result)) {
98860
+ result[key] = val;
98861
+ }
98862
+ }
98863
+ }
98864
+ return result;
98865
+ }
98866
+ function readTag(ns) {
98867
+ const tagNum = decodeArgument();
98868
+ const tagNumber = typeof tagNum === "bigint" ? Number(tagNum) : tagNum;
98869
+ if (tagNumber === 1) {
98870
+ const docSchema2 = NormalizedSchema.of(15);
98871
+ const epochValue = readValue(docSchema2);
98872
+ return _parseEpochTimestamp(epochValue);
98873
+ }
98874
+ if (tagNumber === 2 || tagNumber === 3) {
98875
+ const byteStr = readByteString();
98876
+ let b = BigInt(0);
98877
+ for (let i2 = 0;i2 < byteStr.length; ++i2) {
98878
+ b = b << BigInt(8) | BigInt(byteStr[i2]);
98879
+ }
98880
+ return tagNumber === 3 ? -b - BigInt(1) : b;
98881
+ }
98882
+ if (tagNumber === 4) {
98883
+ const docSchema2 = NormalizedSchema.of(15);
98884
+ const pair = readValue(docSchema2);
98885
+ const [exponent, mantissa] = pair;
98886
+ const normalizer = mantissa < 0 ? -1 : 1;
98887
+ const mantissaStr = "0".repeat(Math.abs(exponent) + 1) + String(BigInt(normalizer) * BigInt(mantissa));
98888
+ let numericString;
98889
+ const sign = mantissa < 0 ? "-" : "";
98890
+ numericString = exponent === 0 ? mantissaStr : mantissaStr.slice(0, mantissaStr.length + exponent) + "." + mantissaStr.slice(exponent);
98891
+ numericString = numericString.replace(/^0+/g, "");
98892
+ if (numericString === "") {
98893
+ numericString = "0";
98894
+ }
98895
+ if (numericString[0] === ".") {
98896
+ numericString = "0" + numericString;
98897
+ }
98898
+ numericString = sign + numericString;
98899
+ return nv(numericString);
98900
+ }
98901
+ const docSchema = NormalizedSchema.of(15);
98902
+ const innerValue = readValue(docSchema);
98903
+ return { tag: castBigInt(tagNum), value: innerValue };
98904
+ }
98905
+ function readIndefinite(ns, major) {
98906
+ switch (major) {
98907
+ case majorUtf8String:
98908
+ return readUtf8StringIndefinite();
98909
+ case majorUnstructuredByteString:
98910
+ return readByteStringIndefinite();
98911
+ case majorList:
98912
+ return readListIndefinite(ns);
98913
+ case majorMap:
98914
+ return readMapIndefinite(ns);
98915
+ default:
98916
+ throw new Error(`unexpected indefinite length for major ${major}.`);
98917
+ }
98918
+ }
98919
+ function readUtf8StringIndefinite() {
98920
+ pos += 1;
98921
+ const chunks = [];
98922
+ let totalLen = 0;
98923
+ while (pos < end) {
98924
+ if (payload[pos] === 255) {
98925
+ pos += 1;
98926
+ const combined = new Uint8Array(totalLen);
98927
+ let offset = 0;
98928
+ for (let i2 = 0;i2 < chunks.length; ++i2) {
98929
+ combined.set(chunks[i2], offset);
98930
+ offset += chunks[i2].length;
98931
+ }
98932
+ if (USE_BUFFER) {
98933
+ return Buffer.from(combined.buffer, combined.byteOffset, combined.byteLength).toString("utf-8");
98934
+ }
98935
+ return textDecoder2.decode(combined);
98936
+ }
98937
+ const bytes = readByteString();
98938
+ chunks.push(bytes);
98939
+ totalLen += bytes.length;
98940
+ }
98941
+ throw new Error("expected break marker.");
98942
+ }
98943
+ function readByteStringIndefinite() {
98944
+ pos += 1;
98945
+ const chunks = [];
98946
+ let totalLen = 0;
98947
+ while (pos < end) {
98948
+ if (payload[pos] === 255) {
98949
+ pos += 1;
98950
+ const combined = new Uint8Array(totalLen);
98951
+ let offset = 0;
98952
+ for (let i2 = 0;i2 < chunks.length; ++i2) {
98953
+ combined.set(chunks[i2], offset);
98954
+ offset += chunks[i2].length;
98955
+ }
98956
+ return combined;
98957
+ }
98958
+ const bytes = readByteString();
98959
+ chunks.push(bytes);
98960
+ totalLen += bytes.length;
98961
+ }
98962
+ throw new Error("expected break marker.");
98963
+ }
98964
+ function readListIndefinite(ns) {
98965
+ pos += 1;
98966
+ const memberSchema = ns.isListSchema() ? ns.getValueSchema() : ns;
98967
+ const list = [];
98968
+ while (pos < end) {
98969
+ if (payload[pos] === 255) {
98970
+ pos += 1;
98971
+ return list;
98972
+ }
98973
+ list.push(readValue(memberSchema));
98974
+ }
98975
+ throw new Error("expected break marker.");
98976
+ }
98977
+ function readMapIndefinite(ns) {
98978
+ pos += 1;
98979
+ if (ns.isStructSchema()) {
98980
+ const cache = loadCborStructIterator(ns);
98981
+ const { memberSchemas, encodedKeys, memberNames } = cache;
98982
+ const z3 = encodedKeys.length;
98983
+ const isUnion = ns.isUnionSchema();
98984
+ const result = {};
98985
+ let unknownKey;
98986
+ let unknownValue;
98987
+ let unknownCount = 0;
98988
+ let hint = 0;
98989
+ while (pos < end) {
98990
+ if (payload[pos] === 255) {
98991
+ pos += 1;
98992
+ if (isUnion) {
98993
+ let resultEmpty = true;
98994
+ for (const _ in result) {
98995
+ resultEmpty = false;
98996
+ break;
98997
+ }
98998
+ if (resultEmpty && unknownCount === 1) {
98999
+ result.$unknown = [unknownKey, unknownValue];
99000
+ }
99001
+ }
99002
+ return result;
99003
+ }
99004
+ const matchIdx = matchStructKey(encodedKeys, z3, hint);
99005
+ if (matchIdx >= 0) {
99006
+ hint = matchIdx + 1;
99007
+ if (hint >= z3) {
99008
+ hint = 0;
99009
+ }
99010
+ const val = readValue(memberSchemas[matchIdx]);
99011
+ if (val != null) {
99012
+ result[memberNames[matchIdx]] = val;
99013
+ }
99014
+ } else {
99015
+ const key = readUtf8String();
99016
+ const val = readValue(NormalizedSchema.of(15));
99017
+ if (key !== "__type") {
99018
+ unknownKey = key;
99019
+ unknownValue = val;
99020
+ ++unknownCount;
99021
+ }
99022
+ }
99023
+ }
99024
+ throw new Error("expected break marker.");
99025
+ }
99026
+ const valueSchema = ns.isMapSchema() ? ns.getValueSchema() : ns;
99027
+ const map2 = {};
99028
+ while (pos < end) {
99029
+ if (payload[pos] === 255) {
99030
+ pos += 1;
99031
+ return map2;
99032
+ }
99033
+ const key = readUtf8String();
99034
+ map2[key] = readValue(valueSchema);
99035
+ }
99036
+ throw new Error("expected break marker.");
99037
+ }
99038
+ function matchStructKey(encodedKeys, z3, hint) {
99039
+ const hintKey = encodedKeys[hint];
99040
+ if (pos + hintKey.length <= end && bytesMatch(pos, hintKey)) {
99041
+ pos += hintKey.length;
99042
+ return hint;
99043
+ }
99044
+ for (let i2 = 0;i2 < z3; ++i2) {
99045
+ if (i2 === hint) {
99046
+ continue;
99047
+ }
99048
+ const ek = encodedKeys[i2];
99049
+ if (pos + ek.length <= end && bytesMatch(pos, ek)) {
99050
+ pos += ek.length;
99051
+ return i2;
99052
+ }
99053
+ }
99054
+ return -1;
99055
+ }
99056
+ function bytesMatch(at, expected) {
99057
+ const len = expected.length;
99058
+ if (payload[at] !== expected[0]) {
99059
+ return false;
99060
+ }
99061
+ for (let i2 = 1;i2 < len; ++i2) {
99062
+ if (payload[at + i2] !== expected[i2]) {
99063
+ return false;
99064
+ }
99065
+ }
99066
+ return true;
99067
+ }
99068
+ function decodeArgument() {
99069
+ const minor = payload[pos] & 31;
99070
+ if (minor < 24) {
99071
+ pos += 1;
99072
+ return minor;
99073
+ }
99074
+ switch (minor) {
99075
+ case extendedOneByte:
99076
+ if (end - pos < 2) {
99077
+ overflow(1);
99078
+ }
99079
+ pos += 2;
99080
+ return payload[pos - 1];
99081
+ case extendedFloat16:
99082
+ if (end - pos < 3) {
99083
+ overflow(2);
99084
+ }
99085
+ pos += 3;
99086
+ return dataView.getUint16(pos - 2);
99087
+ case extendedFloat32:
99088
+ if (end - pos < 5) {
99089
+ overflow(4);
99090
+ }
99091
+ pos += 5;
99092
+ return dataView.getUint32(pos - 4);
99093
+ case extendedFloat64: {
99094
+ if (end - pos < 9) {
99095
+ overflow(8);
99096
+ }
99097
+ pos += 9;
99098
+ const hi = dataView.getUint32(pos - 8);
99099
+ if (hi < 2097152) {
99100
+ return hi * 4294967296 + dataView.getUint32(pos - 4);
99101
+ }
99102
+ return dataView.getBigUint64(pos - 8);
99103
+ }
99104
+ default:
99105
+ throw new Error(`unexpected minor value ${minor}.`);
99106
+ }
99107
+ }
99108
+ function decodeCount() {
99109
+ const val = decodeArgument();
99110
+ return typeof val === "bigint" ? Number(val) : val;
99111
+ }
99112
+ function readUnsignedInt() {
99113
+ const val = decodeArgument();
99114
+ return castBigInt(val);
99115
+ }
99116
+ function readNegativeInt() {
99117
+ const val = decodeArgument();
99118
+ if (typeof val === "bigint") {
99119
+ return BigInt(-1) - val;
99120
+ }
99121
+ return -1 - val;
99122
+ }
99123
+ function readByteString() {
99124
+ const length = decodeCount();
99125
+ if (end - pos < length) {
99126
+ overflow(length);
99127
+ }
99128
+ const start = pos;
99129
+ pos += length;
99130
+ return payload.subarray(start, start + length);
99131
+ }
99132
+ function readUtf8String() {
99133
+ const length = decodeCount();
99134
+ if (end - pos < length) {
99135
+ overflow(length);
99136
+ }
99137
+ const start = pos;
99138
+ pos += length;
99139
+ if (length < 24) {
99140
+ return decodeUtf8Cached(start, length);
99141
+ }
99142
+ if (isBuffer3) {
99143
+ return payload.toString("utf-8", start, start + length);
99144
+ }
99145
+ return textDecoder2.decode(payload.subarray(start, start + length));
99146
+ }
99147
+ function decodeUtf8Cached(at, length) {
99148
+ let h2 = length;
99149
+ for (let i2 = 0;i2 < length; ++i2) {
99150
+ h2 = h2 * 31 + payload[at + i2] | 0;
99151
+ }
99152
+ const slot = h2 >>> 0 & STRING_CACHE_SIZE - 1;
99153
+ const cached2 = stringCache[slot];
99154
+ if (cached2 !== undefined && cached2.length === length) {
99155
+ let match = true;
99156
+ for (let i2 = 0;i2 < length; ++i2) {
99157
+ if (cached2.charCodeAt(i2) !== payload[at + i2]) {
99158
+ match = false;
99159
+ break;
99160
+ }
99161
+ }
99162
+ if (match) {
99163
+ stringCacheEpochs[slot] = cacheEpoch;
99164
+ return cached2;
99165
+ }
99166
+ }
99167
+ const result = isBuffer3 ? payload.toString("utf-8", at, at + length) : textDecoder2.decode(payload.subarray(at, at + length));
99168
+ if (stringCacheEpochs[slot] !== cacheEpoch) {
99169
+ stringCache[slot] = result;
99170
+ stringCacheEpochs[slot] = cacheEpoch;
99171
+ }
99172
+ return result;
99173
+ }
99174
+ function readSpecial() {
99175
+ const p = pos;
99176
+ const minor = payload[p] & 31;
99177
+ switch (minor) {
99178
+ case specialTrue:
99179
+ pos = p + 1;
99180
+ return true;
99181
+ case specialFalse:
99182
+ pos = p + 1;
99183
+ return false;
99184
+ case specialNull:
99185
+ pos = p + 1;
99186
+ return null;
99187
+ case specialUndefined:
99188
+ pos = p + 1;
99189
+ return null;
99190
+ case extendedFloat16: {
99191
+ if (end - p < 3) {
99192
+ overflow(2);
99193
+ }
99194
+ pos = p + 3;
99195
+ return bytesToFloat16(payload[p + 1], payload[p + 2]);
99196
+ }
99197
+ case extendedFloat32: {
99198
+ if (end - p < 5) {
99199
+ overflow(4);
99200
+ }
99201
+ pos = p + 5;
99202
+ return dataView.getFloat32(p + 1);
99203
+ }
99204
+ case extendedFloat64: {
99205
+ if (end - p < 9) {
99206
+ overflow(8);
99207
+ }
99208
+ pos = p + 9;
99209
+ return dataView.getFloat64(p + 1);
99210
+ }
99211
+ default:
99212
+ throw new Error(`unexpected minor value ${minor} for major 7.`);
99213
+ }
99214
+ }
99215
+ function bytesToFloat16(a2, b) {
99216
+ const sign = a2 >> 7;
99217
+ const exponent = (a2 & 124) >> 2;
99218
+ const fraction = (a2 & 3) << 8 | b;
99219
+ const scalar = sign === 0 ? 1 : -1;
99220
+ if (exponent === 0) {
99221
+ if (fraction === 0) {
99222
+ return 0;
99223
+ }
99224
+ return scalar * (Math.pow(2, 1 - 15) * (fraction / 1024));
99225
+ } else if (exponent === 31) {
99226
+ if (fraction === 0) {
99227
+ return scalar * Infinity;
99228
+ }
99229
+ return NaN;
99230
+ }
99231
+ return scalar * (Math.pow(2, exponent - 15) * (1 + fraction / 1024));
99232
+ }
99233
+ function castBigInt(value) {
99234
+ if (typeof value === "number") {
99235
+ return value;
99236
+ }
99237
+ const num = Number(value);
99238
+ if (Number.MIN_SAFE_INTEGER <= num && num <= Number.MAX_SAFE_INTEGER) {
99239
+ return num;
99240
+ }
99241
+ return value;
99242
+ }
99243
+ function overflow(n2) {
99244
+ throw new Error(`CBOR: length ${n2} greater than remaining buffer length.`);
99245
+ }
99246
+ function transformObject(ns, value) {
99247
+ if (ns.isTimestampSchema()) {
99248
+ if (typeof value === "number") {
99249
+ return _parseEpochTimestamp(value);
99250
+ }
99251
+ if (typeof value === "object" && value !== null) {
99252
+ if (value.tag === 1 && "value" in value) {
99253
+ return _parseEpochTimestamp(value.value);
99254
+ }
99255
+ }
99256
+ }
99257
+ if (ns.isBlobSchema()) {
99258
+ return value;
99259
+ }
99260
+ if (typeof value === "undefined" || typeof value === "boolean" || typeof value === "number" || typeof value === "string" || typeof value === "bigint" || typeof value === "symbol") {
99261
+ return value;
99262
+ }
99263
+ if (typeof value !== "object" || value === null) {
99264
+ return value;
99265
+ }
99266
+ if ("byteLength" in value) {
99267
+ return value;
99268
+ }
99269
+ if (value instanceof Date) {
99270
+ return value;
99271
+ }
99272
+ if (value instanceof NumericValue) {
99273
+ return value;
99274
+ }
99275
+ if (ns.isDocumentSchema()) {
99276
+ return value;
99277
+ }
99278
+ if (ns.isListSchema()) {
99279
+ const memberSchema = ns.getValueSchema();
99280
+ const out = [];
99281
+ for (const item of value) {
99282
+ out.push(transformObject(memberSchema, item));
99283
+ }
99284
+ return out;
99285
+ }
99286
+ const newObject = {};
99287
+ if (ns.isMapSchema()) {
99288
+ const targetSchema = ns.getValueSchema();
99289
+ for (const key in value) {
99290
+ newObject[key] = transformObject(targetSchema, value[key]);
99291
+ }
99292
+ } else if (ns.isStructSchema()) {
99293
+ const isUnion = ns.isUnionSchema();
99294
+ let keys2;
99295
+ if (isUnion) {
99296
+ keys2 = new Set;
99297
+ for (const k in value) {
99298
+ if (k !== "__type") {
99299
+ keys2.add(k);
99300
+ }
99301
+ }
99302
+ }
99303
+ for (const [key, memberSchema] of ns.structIterator()) {
99304
+ if (isUnion) {
99305
+ keys2.delete(key);
99306
+ }
99307
+ if (value[key] != null) {
99308
+ newObject[key] = transformObject(memberSchema, value[key]);
99309
+ }
99310
+ }
99311
+ if (isUnion && keys2?.size === 1) {
99312
+ let newObjectEmpty = true;
99313
+ for (const _ in newObject) {
99314
+ newObjectEmpty = false;
99315
+ break;
99316
+ }
99317
+ if (newObjectEmpty) {
99318
+ const k = keys2.values().next().value;
99319
+ newObject.$unknown = [k, value[k]];
99320
+ }
99321
+ } else if (typeof value.__type === "string") {
99322
+ for (const k in value) {
99323
+ if (!(k in newObject)) {
99324
+ newObject[k] = value[k];
99325
+ }
99326
+ }
99327
+ }
99328
+ }
99329
+ return newObject;
99330
+ }
99331
+
99332
+ class CborCodec extends SerdeContext {
99333
+ createSerializer() {
99334
+ const serializer = new CborShapeSerializer2;
99335
+ serializer.setSerdeContext(this.serdeContext);
99336
+ return serializer;
99337
+ }
99338
+ createDeserializer() {
99339
+ const deserializer = new CborShapeDeserializer2;
99340
+ deserializer.setSerdeContext(this.serdeContext);
99341
+ return deserializer;
99342
+ }
99343
+ }
99344
+
99345
+ class SmithyRpcV2CborProtocol extends RpcProtocol {
99346
+ codec = new CborCodec;
99347
+ serializer = this.codec.createSerializer();
99348
+ deserializer = this.codec.createDeserializer();
99349
+ constructor({ defaultNamespace, errorTypeRegistries }) {
99350
+ super({ defaultNamespace, errorTypeRegistries });
99351
+ }
99352
+ getShapeId() {
99353
+ return "smithy.protocols#rpcv2Cbor";
99354
+ }
99355
+ getPayloadCodec() {
99356
+ return this.codec;
99357
+ }
99358
+ async serializeRequest(operationSchema, input, context) {
99359
+ const request = await super.serializeRequest(operationSchema, input, context);
99360
+ Object.assign(request.headers, {
99361
+ "content-type": this.getDefaultContentType(),
99362
+ "smithy-protocol": "rpc-v2-cbor",
99363
+ accept: this.getDefaultContentType()
99364
+ });
99365
+ if (deref(operationSchema.input) === "unit") {
99366
+ delete request.body;
99367
+ delete request.headers["content-type"];
99368
+ } else {
99369
+ if (!request.body) {
99370
+ this.serializer.write(15, {});
99371
+ request.body = this.serializer.flush();
99372
+ }
99373
+ try {
99374
+ request.headers["content-length"] = String(request.body.byteLength);
99375
+ } catch (ignored) {}
99376
+ }
99377
+ const { service, operation } = getSmithyContext(context);
99378
+ const path12 = `/service/${service}/operation/${operation}`;
99379
+ if (request.path.endsWith("/")) {
99380
+ request.path += path12.slice(1);
99381
+ } else {
99382
+ request.path += path12;
99383
+ }
99384
+ return request;
99385
+ }
99386
+ async deserializeResponse(operationSchema, context, response) {
99387
+ return super.deserializeResponse(operationSchema, context, response);
99388
+ }
99389
+ async handleError(operationSchema, context, response, dataObject, metadata) {
99390
+ const errorName = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
99391
+ const errorMetadata = {
99392
+ $metadata: metadata,
99393
+ $fault: response.statusCode <= 500 ? "client" : "server"
99394
+ };
99395
+ let namespace = this.options.defaultNamespace;
99396
+ if (errorName.includes("#")) {
99397
+ [namespace] = errorName.split("#");
99398
+ }
99399
+ const registry2 = this.compositeErrorRegistry;
99400
+ const nsRegistry = TypeRegistry.for(namespace);
99401
+ registry2.copyFrom(nsRegistry);
99402
+ let errorSchema;
99403
+ try {
99404
+ errorSchema = registry2.getSchema(errorName);
99405
+ } catch (ignored) {
99406
+ if (dataObject.Message) {
99407
+ dataObject.message = dataObject.Message;
99408
+ }
99409
+ const syntheticRegistry = TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
99410
+ registry2.copyFrom(syntheticRegistry);
99411
+ const baseExceptionSchema = registry2.getBaseException();
99412
+ if (baseExceptionSchema) {
99413
+ const ErrorCtor2 = registry2.getErrorCtor(baseExceptionSchema);
99414
+ throw Object.assign(new ErrorCtor2({ name: errorName }), errorMetadata, dataObject);
99415
+ }
99416
+ throw Object.assign(new Error(errorName), errorMetadata, dataObject);
99417
+ }
99418
+ const ns = NormalizedSchema.of(errorSchema);
99419
+ const ErrorCtor = registry2.getErrorCtor(errorSchema);
99420
+ const message = dataObject.message ?? dataObject.Message ?? "Unknown";
99421
+ const exception = new ErrorCtor({});
99422
+ const output = {};
99423
+ for (const [name, member] of ns.structIterator()) {
99424
+ output[name] = this.deserializer.readValue(member, dataObject[name]);
99425
+ }
99426
+ throw Object.assign(exception, errorMetadata, {
99427
+ $fault: ns.getMergedTraits().error,
99428
+ message
99429
+ }, output);
99430
+ }
99431
+ getDefaultContentType() {
99432
+ return "application/cbor";
99433
+ }
99434
+ }
99435
+
98167
99436
  class CborShapeSerializer extends SerdeContext {
98168
99437
  value;
98169
99438
  write(schema, value) {
@@ -98234,6 +99503,14 @@ var require_cbor = __commonJS((exports) => {
98234
99503
  }
98235
99504
  }
98236
99505
  } else if (ns.isDocumentSchema()) {
99506
+ if (Array.isArray(sourceObject)) {
99507
+ const newArray = [];
99508
+ let i2 = 0;
99509
+ for (const item of sourceObject) {
99510
+ newArray[i2++] = this.serialize(ns.getValueSchema(), item);
99511
+ }
99512
+ return newArray;
99513
+ }
98237
99514
  for (const key in sourceObject) {
98238
99515
  newObject[key] = this.serialize(ns.getValueSchema(), sourceObject[key]);
98239
99516
  }
@@ -98350,113 +99627,11 @@ var require_cbor = __commonJS((exports) => {
98350
99627
  }
98351
99628
  }
98352
99629
  }
98353
-
98354
- class CborCodec extends SerdeContext {
98355
- createSerializer() {
98356
- const serializer = new CborShapeSerializer;
98357
- serializer.setSerdeContext(this.serdeContext);
98358
- return serializer;
98359
- }
98360
- createDeserializer() {
98361
- const deserializer = new CborShapeDeserializer;
98362
- deserializer.setSerdeContext(this.serdeContext);
98363
- return deserializer;
98364
- }
98365
- }
98366
-
98367
- class SmithyRpcV2CborProtocol extends RpcProtocol {
98368
- codec = new CborCodec;
98369
- serializer = this.codec.createSerializer();
98370
- deserializer = this.codec.createDeserializer();
98371
- constructor({ defaultNamespace, errorTypeRegistries }) {
98372
- super({ defaultNamespace, errorTypeRegistries });
98373
- }
98374
- getShapeId() {
98375
- return "smithy.protocols#rpcv2Cbor";
98376
- }
98377
- getPayloadCodec() {
98378
- return this.codec;
98379
- }
98380
- async serializeRequest(operationSchema, input, context) {
98381
- const request = await super.serializeRequest(operationSchema, input, context);
98382
- Object.assign(request.headers, {
98383
- "content-type": this.getDefaultContentType(),
98384
- "smithy-protocol": "rpc-v2-cbor",
98385
- accept: this.getDefaultContentType()
98386
- });
98387
- if (deref(operationSchema.input) === "unit") {
98388
- delete request.body;
98389
- delete request.headers["content-type"];
98390
- } else {
98391
- if (!request.body) {
98392
- this.serializer.write(15, {});
98393
- request.body = this.serializer.flush();
98394
- }
98395
- try {
98396
- request.headers["content-length"] = String(request.body.byteLength);
98397
- } catch (ignored) {}
98398
- }
98399
- const { service, operation } = getSmithyContext(context);
98400
- const path12 = `/service/${service}/operation/${operation}`;
98401
- if (request.path.endsWith("/")) {
98402
- request.path += path12.slice(1);
98403
- } else {
98404
- request.path += path12;
98405
- }
98406
- return request;
98407
- }
98408
- async deserializeResponse(operationSchema, context, response) {
98409
- return super.deserializeResponse(operationSchema, context, response);
98410
- }
98411
- async handleError(operationSchema, context, response, dataObject, metadata) {
98412
- const errorName = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
98413
- const errorMetadata = {
98414
- $metadata: metadata,
98415
- $fault: response.statusCode <= 500 ? "client" : "server"
98416
- };
98417
- let namespace = this.options.defaultNamespace;
98418
- if (errorName.includes("#")) {
98419
- [namespace] = errorName.split("#");
98420
- }
98421
- const registry2 = this.compositeErrorRegistry;
98422
- const nsRegistry = TypeRegistry.for(namespace);
98423
- registry2.copyFrom(nsRegistry);
98424
- let errorSchema;
98425
- try {
98426
- errorSchema = registry2.getSchema(errorName);
98427
- } catch (ignored) {
98428
- if (dataObject.Message) {
98429
- dataObject.message = dataObject.Message;
98430
- }
98431
- const syntheticRegistry = TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
98432
- registry2.copyFrom(syntheticRegistry);
98433
- const baseExceptionSchema = registry2.getBaseException();
98434
- if (baseExceptionSchema) {
98435
- const ErrorCtor2 = registry2.getErrorCtor(baseExceptionSchema);
98436
- throw Object.assign(new ErrorCtor2({ name: errorName }), errorMetadata, dataObject);
98437
- }
98438
- throw Object.assign(new Error(errorName), errorMetadata, dataObject);
98439
- }
98440
- const ns = NormalizedSchema.of(errorSchema);
98441
- const ErrorCtor = registry2.getErrorCtor(errorSchema);
98442
- const message = dataObject.message ?? dataObject.Message ?? "Unknown";
98443
- const exception = new ErrorCtor({});
98444
- const output = {};
98445
- for (const [name, member] of ns.structIterator()) {
98446
- output[name] = this.deserializer.readValue(member, dataObject[name]);
98447
- }
98448
- throw Object.assign(exception, errorMetadata, {
98449
- $fault: ns.getMergedTraits().error,
98450
- message
98451
- }, output);
98452
- }
98453
- getDefaultContentType() {
98454
- return "application/cbor";
98455
- }
98456
- }
98457
99630
  exports.CborCodec = CborCodec;
98458
99631
  exports.CborShapeDeserializer = CborShapeDeserializer;
99632
+ exports.CborShapeDeserializer2 = CborShapeDeserializer2;
98459
99633
  exports.CborShapeSerializer = CborShapeSerializer;
99634
+ exports.CborShapeSerializer2 = CborShapeSerializer2;
98460
99635
  exports.SmithyRpcV2CborProtocol = SmithyRpcV2CborProtocol;
98461
99636
  exports.buildHttpRpcRequest = buildHttpRpcRequest;
98462
99637
  exports.cbor = cbor;
@@ -117990,7 +119165,7 @@ var package_default;
117990
119165
  var init_package = __esm(() => {
117991
119166
  package_default = {
117992
119167
  name: "@funnycode/myclaude",
117993
- version: "0.1.156",
119168
+ version: "0.1.158",
117994
119169
  private: false,
117995
119170
  description: "An open-source AI coding assistant in your terminal - powered by Claude",
117996
119171
  license: "MIT",
@@ -408175,6 +409350,7 @@ import { join as join105 } from "path";
408175
409350
  function clearCachedSteps() {
408176
409351
  cachedSteps = null;
408177
409352
  cachedClaudeMdMtime = null;
409353
+ cachedDirMtime = null;
408178
409354
  cachedAt = null;
408179
409355
  }
408180
409356
  function isCacheValid() {
@@ -408190,6 +409366,13 @@ function isCacheValid() {
408190
409366
  } catch {
408191
409367
  return false;
408192
409368
  }
409369
+ try {
409370
+ const currentDirMtime = getFileModificationTime(cwd2);
409371
+ if (currentDirMtime !== cachedDirMtime)
409372
+ return false;
409373
+ } catch {
409374
+ return false;
409375
+ }
408193
409376
  if (cachedAt !== null && Date.now() - cachedAt > CACHE_MAX_AGE_MS) {
408194
409377
  return false;
408195
409378
  }
@@ -408209,6 +409392,11 @@ function getSteps() {
408209
409392
  } catch {
408210
409393
  cachedClaudeMdMtime = -1;
408211
409394
  }
409395
+ try {
409396
+ cachedDirMtime = getFileModificationTime(cwd2);
409397
+ } catch {
409398
+ cachedDirMtime = -1;
409399
+ }
408212
409400
  cachedAt = Date.now();
408213
409401
  cachedSteps = [
408214
409402
  {
@@ -408255,7 +409443,7 @@ function incrementProjectOnboardingSeenCount() {
408255
409443
  projectOnboardingSeenCount: current.projectOnboardingSeenCount + 1
408256
409444
  }));
408257
409445
  }
408258
- var cachedSteps = null, cachedClaudeMdMtime = null, cachedAt = null, CACHE_MAX_AGE_MS = 30000;
409446
+ var cachedSteps = null, cachedClaudeMdMtime = null, cachedDirMtime = null, cachedAt = null, CACHE_MAX_AGE_MS = 30000;
408259
409447
  var init_projectOnboardingState = __esm(() => {
408260
409448
  init_config();
408261
409449
  init_cwd2();
@@ -564590,7 +565778,6 @@ function migrateEnableAllProjectMcpServersToSettings() {
564590
565778
  });
564591
565779
  } catch (error49) {
564592
565780
  logError2("Failed to migrate MCP server settings, rolling back", error49);
564593
- const currentSettings = getSettingsForSource("localSettings") || {};
564594
565781
  let rollbackFailed = false;
564595
565782
  const rollbackUpdates = {};
564596
565783
  const migratedFields = [
@@ -564624,13 +565811,7 @@ function migrateEnableAllProjectMcpServersToSettings() {
564624
565811
  } catch (rollbackError) {
564625
565812
  logError2("Rollback of project config failed", rollbackError);
564626
565813
  rollbackFailed = true;
564627
- if (settingsRollbackSucceeded) {
564628
- try {
564629
- updateSettingsForSource("localSettings", currentSettings);
564630
- } catch (undoError) {
564631
- logError2("Failed to undo settings rollback after project config rollback failure", undoError);
564632
- }
564633
- }
565814
+ logError2("Settings rollback succeeded but project config rollback failed. " + "System is in an inconsistent state. Manual intervention may be required.", rollbackError);
564634
565815
  }
564635
565816
  if (rollbackFailed) {
564636
565817
  throw new Error("Migration failed and rollback was incomplete. The system may be in an inconsistent state. " + "Original error: " + (error49 instanceof Error ? error49.message : String(error49)));