@kokimoki/app 1.4.7 → 1.6.0

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.
@@ -1,3 +1,6 @@
1
+ import require$$1 from 'path';
2
+ import require$$2 from 'fs';
3
+
1
4
  const defaultFieldOptions = {};
2
5
  class Field {
3
6
  options;
@@ -151,6 +154,8 @@ class FormArray extends Field {
151
154
  class Form extends FormGroup {
152
155
  }
153
156
 
157
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
158
+
154
159
  function getDefaultExportFromCjs (x) {
155
160
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
156
161
  }
@@ -634,7 +639,7 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
634
639
  var eventsExports = events.exports;
635
640
  var EventEmitter$1 = /*@__PURE__*/getDefaultExportFromCjs(eventsExports);
636
641
 
637
- const KOKIMOKI_APP_VERSION = "1.4.7";
642
+ const KOKIMOKI_APP_VERSION = "1.6.0";
638
643
 
639
644
  /**
640
645
  * Utility module to work with key-value stores.
@@ -862,8 +867,8 @@ class Observable {
862
867
  * @module math
863
868
  */
864
869
 
865
- const floor = Math.floor;
866
- const abs = Math.abs;
870
+ const floor$2 = Math.floor;
871
+ const abs$2 = Math.abs;
867
872
 
868
873
  /**
869
874
  * @function
@@ -871,7 +876,7 @@ const abs = Math.abs;
871
876
  * @param {number} b
872
877
  * @return {number} The smaller element of a and b
873
878
  */
874
- const min = (a, b) => a < b ? a : b;
879
+ const min$2 = (a, b) => a < b ? a : b;
875
880
 
876
881
  /**
877
882
  * @function
@@ -879,7 +884,7 @@ const min = (a, b) => a < b ? a : b;
879
884
  * @param {number} b
880
885
  * @return {number} The bigger element of a and b
881
886
  */
882
- const max = (a, b) => a > b ? a : b;
887
+ const max$3 = (a, b) => a > b ? a : b;
883
888
 
884
889
  /**
885
890
  * @param {number} n
@@ -1045,7 +1050,7 @@ const keys$1 = Object.keys;
1045
1050
  * @param {{[k:string]:V}} obj
1046
1051
  * @param {function(V,string):any} f
1047
1052
  */
1048
- const forEach = (obj, f) => {
1053
+ const forEach$2 = (obj, f) => {
1049
1054
  for (const key in obj) {
1050
1055
  f(obj[key], key);
1051
1056
  }
@@ -1278,7 +1283,7 @@ const BITS31 = 0x7FFFFFFF;
1278
1283
  const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;
1279
1284
 
1280
1285
  /* c8 ignore next */
1281
- const isInteger = Number.isInteger || (num => typeof num === 'number' && isFinite(num) && floor(num) === num);
1286
+ const isInteger = Number.isInteger || (num => typeof num === 'number' && isFinite(num) && floor$2(num) === num);
1282
1287
 
1283
1288
  /**
1284
1289
  * Error helpers.
@@ -1702,7 +1707,7 @@ class IntDiffOptRleDecoder extends Decoder {
1702
1707
  const diff = readVarInt(this);
1703
1708
  // if the first bit is set, we read more data
1704
1709
  const hasCount = diff & 1;
1705
- this.diff = floor(diff / 2); // shift >> 1
1710
+ this.diff = floor$2(diff / 2); // shift >> 1
1706
1711
  this.count = 1;
1707
1712
  if (hasCount) {
1708
1713
  this.count = readVarUint(this) + 2;
@@ -1865,7 +1870,7 @@ const verifyLen = (encoder, len) => {
1865
1870
  const bufferLen = encoder.cbuf.length;
1866
1871
  if (bufferLen - encoder.cpos < len) {
1867
1872
  encoder.bufs.push(createUint8ArrayViewFromArrayBuffer(encoder.cbuf.buffer, 0, encoder.cpos));
1868
- encoder.cbuf = new Uint8Array(max(bufferLen, len) * 2);
1873
+ encoder.cbuf = new Uint8Array(max$3(bufferLen, len) * 2);
1869
1874
  encoder.cpos = 0;
1870
1875
  }
1871
1876
  };
@@ -1906,7 +1911,7 @@ const writeUint8 = write;
1906
1911
  const writeVarUint = (encoder, num) => {
1907
1912
  while (num > BITS7) {
1908
1913
  write(encoder, BIT8 | (BITS7 & num));
1909
- num = floor(num / 128); // shift >>> 7
1914
+ num = floor$2(num / 128); // shift >>> 7
1910
1915
  }
1911
1916
  write(encoder, BITS7 & num);
1912
1917
  };
@@ -1927,12 +1932,12 @@ const writeVarInt = (encoder, num) => {
1927
1932
  }
1928
1933
  // |- whether to continue reading |- whether is negative |- number
1929
1934
  write(encoder, (num > BITS6 ? BIT8 : 0) | (isNegative ? BIT7 : 0) | (BITS6 & num));
1930
- num = floor(num / 64); // shift >>> 6
1935
+ num = floor$2(num / 64); // shift >>> 6
1931
1936
  // We don't need to consider the case of num === 0 so we can use a different
1932
1937
  // pattern here than above.
1933
1938
  while (num > 0) {
1934
1939
  write(encoder, (num > BITS7 ? BIT8 : 0) | (BITS7 & num));
1935
- num = floor(num / 128); // shift >>> 7
1940
+ num = floor$2(num / 128); // shift >>> 7
1936
1941
  }
1937
1942
  };
1938
1943
 
@@ -1999,7 +2004,7 @@ const writeVarString = (utf8TextEncoder && /** @type {any} */ (utf8TextEncoder).
1999
2004
  const writeUint8Array = (encoder, uint8Array) => {
2000
2005
  const bufferLen = encoder.cbuf.length;
2001
2006
  const cpos = encoder.cpos;
2002
- const leftCopyLen = min(bufferLen - cpos, uint8Array.length);
2007
+ const leftCopyLen = min$2(bufferLen - cpos, uint8Array.length);
2003
2008
  const rightCopyLen = uint8Array.length - leftCopyLen;
2004
2009
  encoder.cbuf.set(uint8Array.subarray(0, leftCopyLen), cpos);
2005
2010
  encoder.cpos += leftCopyLen;
@@ -2008,7 +2013,7 @@ const writeUint8Array = (encoder, uint8Array) => {
2008
2013
  // Append new buffer
2009
2014
  encoder.bufs.push(encoder.cbuf);
2010
2015
  // must have at least size of remaining buffer
2011
- encoder.cbuf = new Uint8Array(max(bufferLen * 2, rightCopyLen));
2016
+ encoder.cbuf = new Uint8Array(max$3(bufferLen * 2, rightCopyLen));
2012
2017
  // copy array
2013
2018
  encoder.cbuf.set(uint8Array.subarray(leftCopyLen));
2014
2019
  encoder.cpos = rightCopyLen;
@@ -2126,7 +2131,7 @@ const writeAny = (encoder, data) => {
2126
2131
  writeVarString(encoder, data);
2127
2132
  break
2128
2133
  case 'number':
2129
- if (isInteger(data) && abs(data) <= BITS31) {
2134
+ if (isInteger(data) && abs$2(data) <= BITS31) {
2130
2135
  // TYPE 125: INTEGER
2131
2136
  write(encoder, 125);
2132
2137
  writeVarInt(encoder, data);
@@ -2717,7 +2722,7 @@ const findIndexDS = (dis, clock) => {
2717
2722
  let left = 0;
2718
2723
  let right = dis.length - 1;
2719
2724
  while (left <= right) {
2720
- const midindex = floor((left + right) / 2);
2725
+ const midindex = floor$2((left + right) / 2);
2721
2726
  const mid = dis[midindex];
2722
2727
  const midclock = mid.clock;
2723
2728
  if (midclock <= clock) {
@@ -2763,7 +2768,7 @@ const sortAndMergeDeleteSet = ds => {
2763
2768
  const left = dels[j - 1];
2764
2769
  const right = dels[i];
2765
2770
  if (left.clock + left.len >= right.clock) {
2766
- left.len = max(left.len, right.clock + right.len - left.clock);
2771
+ left.len = max$3(left.len, right.clock + right.len - left.clock);
2767
2772
  } else {
2768
2773
  if (j < i) {
2769
2774
  dels[j] = right;
@@ -3889,7 +3894,7 @@ class UpdateEncoderV2 extends DSEncoderV2 {
3889
3894
  */
3890
3895
  const writeStructs = (encoder, structs, client, clock) => {
3891
3896
  // write first id
3892
- clock = max(clock, structs[0].id.clock); // make sure the first id exists
3897
+ clock = max$3(clock, structs[0].id.clock); // make sure the first id exists
3893
3898
  const startNewStructs = findIndexSS(structs, clock);
3894
3899
  // write # encoded structs
3895
3900
  writeVarUint(encoder.restEncoder, structs.length - startNewStructs);
@@ -4669,7 +4674,7 @@ const findIndexSS = (structs, clock) => {
4669
4674
  // @todo does it even make sense to pivot the search?
4670
4675
  // If a good split misses, it might actually increase the time to find the correct item.
4671
4676
  // Currently, the only advantage is that search with pivoting might find the item on the first try.
4672
- let midindex = floor((clock / (midclock + mid.length - 1)) * right); // pivoting the search
4677
+ let midindex = floor$2((clock / (midclock + mid.length - 1)) * right); // pivoting the search
4673
4678
  while (left <= right) {
4674
4679
  mid = structs[midindex];
4675
4680
  midclock = mid.id.clock;
@@ -4681,7 +4686,7 @@ const findIndexSS = (structs, clock) => {
4681
4686
  } else {
4682
4687
  right = midindex - 1;
4683
4688
  }
4684
- midindex = floor((left + right) / 2);
4689
+ midindex = floor$2((left + right) / 2);
4685
4690
  }
4686
4691
  // Always check state before looking for a struct in StructStore
4687
4692
  // Therefore the case of not finding a struct is unexpected
@@ -5009,7 +5014,7 @@ const tryMergeDeleteSet = (ds, store) => {
5009
5014
  for (let di = deleteItems.length - 1; di >= 0; di--) {
5010
5015
  const deleteItem = deleteItems[di];
5011
5016
  // start with merging the item next to the last deleted item
5012
- const mostRightIndexToCheck = min(structs.length - 1, 1 + findIndexSS(structs, deleteItem.clock + deleteItem.len - 1));
5017
+ const mostRightIndexToCheck = min$2(structs.length - 1, 1 + findIndexSS(structs, deleteItem.clock + deleteItem.len - 1));
5013
5018
  for (
5014
5019
  let si = mostRightIndexToCheck, struct = structs[si];
5015
5020
  si > 0 && struct.id.clock >= deleteItem.clock;
@@ -5096,7 +5101,7 @@ const cleanupTransactions = (transactionCleanups, i) => {
5096
5101
  if (beforeClock !== clock) {
5097
5102
  const structs = /** @type {Array<GC|Item>} */ (store.clients.get(client));
5098
5103
  // we iterate from right to left so we can safely remove entries
5099
- const firstChangePos = max(findIndexSS(structs, beforeClock), 1);
5104
+ const firstChangePos = max$3(findIndexSS(structs, beforeClock), 1);
5100
5105
  for (let i = structs.length - 1; i >= firstChangePos;) {
5101
5106
  i -= 1 + tryToMergeWithLefts(structs, i);
5102
5107
  }
@@ -5502,7 +5507,7 @@ const diffUpdateV2 = (update, sv, YDecoder = UpdateDecoderV2, YEncoder = UpdateE
5502
5507
  continue
5503
5508
  }
5504
5509
  if (curr.id.clock + curr.length > svClock) {
5505
- writeStructToLazyStructWriter(lazyStructWriter, curr, max(svClock - curr.id.clock, 0));
5510
+ writeStructToLazyStructWriter(lazyStructWriter, curr, max$3(svClock - curr.id.clock, 0));
5506
5511
  reader.next();
5507
5512
  while (reader.curr && reader.curr.id.client === currClient) {
5508
5513
  writeStructToLazyStructWriter(lazyStructWriter, reader.curr, 0);
@@ -5959,7 +5964,7 @@ const findMarker = (yarray, index) => {
5959
5964
  if (yarray._start === null || index === 0 || yarray._searchMarker === null) {
5960
5965
  return null
5961
5966
  }
5962
- const marker = yarray._searchMarker.length === 0 ? null : yarray._searchMarker.reduce((a, b) => abs(index - a.index) < abs(index - b.index) ? a : b);
5967
+ const marker = yarray._searchMarker.length === 0 ? null : yarray._searchMarker.reduce((a, b) => abs$2(index - a.index) < abs$2(index - b.index) ? a : b);
5963
5968
  let p = yarray._start;
5964
5969
  let pindex = 0;
5965
5970
  if (marker !== null) {
@@ -6018,7 +6023,7 @@ const findMarker = (yarray, index) => {
6018
6023
  // window.lengthes.push(marker.index - pindex)
6019
6024
  // console.log('distance', marker.index - pindex, 'len', p && p.parent.length)
6020
6025
  // }
6021
- if (marker !== null && abs(marker.index - pindex) < /** @type {YText|YArray<any>} */ (p.parent).length / maxSearchMarker) {
6026
+ if (marker !== null && abs$2(marker.index - pindex) < /** @type {YText|YArray<any>} */ (p.parent).length / maxSearchMarker) {
6022
6027
  // adjust existing marker
6023
6028
  overwriteMarker(marker, p, pindex);
6024
6029
  return marker
@@ -6065,7 +6070,7 @@ const updateMarkerChanges = (searchMarker, index, len) => {
6065
6070
  p.marker = true;
6066
6071
  }
6067
6072
  if (index < m.index || (len > 0 && index === m.index)) { // a simple index <= m.index check would actually suffice
6068
- m.index = max(index, m.index + len);
6073
+ m.index = max$3(index, m.index + len);
6069
6074
  }
6070
6075
  }
6071
6076
  };
@@ -8973,7 +8978,7 @@ class YXmlElement extends YXmlFragment {
8973
8978
  */
8974
8979
  const el = new YXmlElement(this.nodeName);
8975
8980
  const attrs = this.getAttributes();
8976
- forEach(attrs, (value, key) => {
8981
+ forEach$2(attrs, (value, key) => {
8977
8982
  if (typeof value === 'string') {
8978
8983
  el.setAttribute(key, value);
8979
8984
  }
@@ -12223,6 +12228,2572 @@ class KokimokiReqRes {
12223
12228
  }
12224
12229
  }
12225
12230
 
12231
+ var farmhash_modern = {exports: {}};
12232
+
12233
+ var util = {};
12234
+
12235
+ var types = {};
12236
+
12237
+ /** @type {import('./shams')} */
12238
+ /* eslint complexity: [2, 18], max-statements: [2, 33] */
12239
+ var shams$1 = function hasSymbols() {
12240
+ if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
12241
+ if (typeof Symbol.iterator === 'symbol') { return true; }
12242
+
12243
+ /** @type {{ [k in symbol]?: unknown }} */
12244
+ var obj = {};
12245
+ var sym = Symbol('test');
12246
+ var symObj = Object(sym);
12247
+ if (typeof sym === 'string') { return false; }
12248
+
12249
+ if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
12250
+ if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
12251
+
12252
+ // temp disabled per https://github.com/ljharb/object.assign/issues/17
12253
+ // if (sym instanceof Symbol) { return false; }
12254
+ // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
12255
+ // if (!(symObj instanceof Symbol)) { return false; }
12256
+
12257
+ // if (typeof Symbol.prototype.toString !== 'function') { return false; }
12258
+ // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
12259
+
12260
+ var symVal = 42;
12261
+ obj[sym] = symVal;
12262
+ for (var _ in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
12263
+ if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
12264
+
12265
+ if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
12266
+
12267
+ var syms = Object.getOwnPropertySymbols(obj);
12268
+ if (syms.length !== 1 || syms[0] !== sym) { return false; }
12269
+
12270
+ if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
12271
+
12272
+ if (typeof Object.getOwnPropertyDescriptor === 'function') {
12273
+ // eslint-disable-next-line no-extra-parens
12274
+ var descriptor = /** @type {PropertyDescriptor} */ (Object.getOwnPropertyDescriptor(obj, sym));
12275
+ if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
12276
+ }
12277
+
12278
+ return true;
12279
+ };
12280
+
12281
+ var hasSymbols$2 = shams$1;
12282
+
12283
+ var shams = function hasToStringTagShams() {
12284
+ return hasSymbols$2() && !!Symbol.toStringTag;
12285
+ };
12286
+
12287
+ /** @type {import('.')} */
12288
+ var esObjectAtoms = Object;
12289
+
12290
+ /** @type {import('.')} */
12291
+ var esErrors = Error;
12292
+
12293
+ /** @type {import('./eval')} */
12294
+ var _eval = EvalError;
12295
+
12296
+ /** @type {import('./range')} */
12297
+ var range = RangeError;
12298
+
12299
+ /** @type {import('./ref')} */
12300
+ var ref = ReferenceError;
12301
+
12302
+ /** @type {import('./syntax')} */
12303
+ var syntax = SyntaxError;
12304
+
12305
+ /** @type {import('./type')} */
12306
+ var type = TypeError;
12307
+
12308
+ /** @type {import('./uri')} */
12309
+ var uri = URIError;
12310
+
12311
+ /** @type {import('./abs')} */
12312
+ var abs$1 = Math.abs;
12313
+
12314
+ /** @type {import('./floor')} */
12315
+ var floor$1 = Math.floor;
12316
+
12317
+ /** @type {import('./max')} */
12318
+ var max$2 = Math.max;
12319
+
12320
+ /** @type {import('./min')} */
12321
+ var min$1 = Math.min;
12322
+
12323
+ /** @type {import('./pow')} */
12324
+ var pow$1 = Math.pow;
12325
+
12326
+ /** @type {import('./gOPD')} */
12327
+ var gOPD$1 = Object.getOwnPropertyDescriptor;
12328
+
12329
+ /** @type {import('.')} */
12330
+ var $gOPD$1 = gOPD$1;
12331
+
12332
+ if ($gOPD$1) {
12333
+ try {
12334
+ $gOPD$1([], 'length');
12335
+ } catch (e) {
12336
+ // IE 8 has a broken gOPD
12337
+ $gOPD$1 = null;
12338
+ }
12339
+ }
12340
+
12341
+ var gopd = $gOPD$1;
12342
+
12343
+ /** @type {import('.')} */
12344
+ var $defineProperty$1 = Object.defineProperty || false;
12345
+ if ($defineProperty$1) {
12346
+ try {
12347
+ $defineProperty$1({}, 'a', { value: 1 });
12348
+ } catch (e) {
12349
+ // IE 8 has a broken defineProperty
12350
+ $defineProperty$1 = false;
12351
+ }
12352
+ }
12353
+
12354
+ var esDefineProperty = $defineProperty$1;
12355
+
12356
+ var hasSymbols$1;
12357
+ var hasRequiredHasSymbols;
12358
+
12359
+ function requireHasSymbols () {
12360
+ if (hasRequiredHasSymbols) return hasSymbols$1;
12361
+ hasRequiredHasSymbols = 1;
12362
+
12363
+ var origSymbol = typeof Symbol !== 'undefined' && Symbol;
12364
+ var hasSymbolSham = shams$1;
12365
+
12366
+ /** @type {import('.')} */
12367
+ hasSymbols$1 = function hasNativeSymbols() {
12368
+ if (typeof origSymbol !== 'function') { return false; }
12369
+ if (typeof Symbol !== 'function') { return false; }
12370
+ if (typeof origSymbol('foo') !== 'symbol') { return false; }
12371
+ if (typeof Symbol('bar') !== 'symbol') { return false; }
12372
+
12373
+ return hasSymbolSham();
12374
+ };
12375
+ return hasSymbols$1;
12376
+ }
12377
+
12378
+ /* eslint no-invalid-this: 1 */
12379
+
12380
+ var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
12381
+ var toStr$3 = Object.prototype.toString;
12382
+ var max$1 = Math.max;
12383
+ var funcType = '[object Function]';
12384
+
12385
+ var concatty = function concatty(a, b) {
12386
+ var arr = [];
12387
+
12388
+ for (var i = 0; i < a.length; i += 1) {
12389
+ arr[i] = a[i];
12390
+ }
12391
+ for (var j = 0; j < b.length; j += 1) {
12392
+ arr[j + a.length] = b[j];
12393
+ }
12394
+
12395
+ return arr;
12396
+ };
12397
+
12398
+ var slicy = function slicy(arrLike, offset) {
12399
+ var arr = [];
12400
+ for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) {
12401
+ arr[j] = arrLike[i];
12402
+ }
12403
+ return arr;
12404
+ };
12405
+
12406
+ var joiny = function (arr, joiner) {
12407
+ var str = '';
12408
+ for (var i = 0; i < arr.length; i += 1) {
12409
+ str += arr[i];
12410
+ if (i + 1 < arr.length) {
12411
+ str += joiner;
12412
+ }
12413
+ }
12414
+ return str;
12415
+ };
12416
+
12417
+ var implementation$1 = function bind(that) {
12418
+ var target = this;
12419
+ if (typeof target !== 'function' || toStr$3.apply(target) !== funcType) {
12420
+ throw new TypeError(ERROR_MESSAGE + target);
12421
+ }
12422
+ var args = slicy(arguments, 1);
12423
+
12424
+ var bound;
12425
+ var binder = function () {
12426
+ if (this instanceof bound) {
12427
+ var result = target.apply(
12428
+ this,
12429
+ concatty(args, arguments)
12430
+ );
12431
+ if (Object(result) === result) {
12432
+ return result;
12433
+ }
12434
+ return this;
12435
+ }
12436
+ return target.apply(
12437
+ that,
12438
+ concatty(args, arguments)
12439
+ );
12440
+
12441
+ };
12442
+
12443
+ var boundLength = max$1(0, target.length - args.length);
12444
+ var boundArgs = [];
12445
+ for (var i = 0; i < boundLength; i++) {
12446
+ boundArgs[i] = '$' + i;
12447
+ }
12448
+
12449
+ bound = Function('binder', 'return function (' + joiny(boundArgs, ',') + '){ return binder.apply(this,arguments); }')(binder);
12450
+
12451
+ if (target.prototype) {
12452
+ var Empty = function Empty() {};
12453
+ Empty.prototype = target.prototype;
12454
+ bound.prototype = new Empty();
12455
+ Empty.prototype = null;
12456
+ }
12457
+
12458
+ return bound;
12459
+ };
12460
+
12461
+ var implementation = implementation$1;
12462
+
12463
+ var functionBind = Function.prototype.bind || implementation;
12464
+
12465
+ var functionCall;
12466
+ var hasRequiredFunctionCall;
12467
+
12468
+ function requireFunctionCall () {
12469
+ if (hasRequiredFunctionCall) return functionCall;
12470
+ hasRequiredFunctionCall = 1;
12471
+
12472
+ /** @type {import('./functionCall')} */
12473
+ functionCall = Function.prototype.call;
12474
+ return functionCall;
12475
+ }
12476
+
12477
+ var functionApply;
12478
+ var hasRequiredFunctionApply;
12479
+
12480
+ function requireFunctionApply () {
12481
+ if (hasRequiredFunctionApply) return functionApply;
12482
+ hasRequiredFunctionApply = 1;
12483
+
12484
+ /** @type {import('./functionApply')} */
12485
+ functionApply = Function.prototype.apply;
12486
+ return functionApply;
12487
+ }
12488
+
12489
+ var reflectApply$1;
12490
+ var hasRequiredReflectApply;
12491
+
12492
+ function requireReflectApply () {
12493
+ if (hasRequiredReflectApply) return reflectApply$1;
12494
+ hasRequiredReflectApply = 1;
12495
+
12496
+ /** @type {import('./reflectApply')} */
12497
+ reflectApply$1 = typeof Reflect !== 'undefined' && Reflect && Reflect.apply;
12498
+ return reflectApply$1;
12499
+ }
12500
+
12501
+ var actualApply;
12502
+ var hasRequiredActualApply;
12503
+
12504
+ function requireActualApply () {
12505
+ if (hasRequiredActualApply) return actualApply;
12506
+ hasRequiredActualApply = 1;
12507
+
12508
+ var bind = functionBind;
12509
+
12510
+ var $apply = requireFunctionApply();
12511
+ var $call = requireFunctionCall();
12512
+ var $reflectApply = requireReflectApply();
12513
+
12514
+ /** @type {import('./actualApply')} */
12515
+ actualApply = $reflectApply || bind.call($call, $apply);
12516
+ return actualApply;
12517
+ }
12518
+
12519
+ var callBindApplyHelpers;
12520
+ var hasRequiredCallBindApplyHelpers;
12521
+
12522
+ function requireCallBindApplyHelpers () {
12523
+ if (hasRequiredCallBindApplyHelpers) return callBindApplyHelpers;
12524
+ hasRequiredCallBindApplyHelpers = 1;
12525
+
12526
+ var bind = functionBind;
12527
+ var $TypeError = type;
12528
+
12529
+ var $call = requireFunctionCall();
12530
+ var $actualApply = requireActualApply();
12531
+
12532
+ /** @type {import('.')} */
12533
+ callBindApplyHelpers = function callBindBasic(args) {
12534
+ if (args.length < 1 || typeof args[0] !== 'function') {
12535
+ throw new $TypeError('a function is required');
12536
+ }
12537
+ return $actualApply(bind, $call, args);
12538
+ };
12539
+ return callBindApplyHelpers;
12540
+ }
12541
+
12542
+ var get;
12543
+ var hasRequiredGet;
12544
+
12545
+ function requireGet () {
12546
+ if (hasRequiredGet) return get;
12547
+ hasRequiredGet = 1;
12548
+
12549
+ var callBind = requireCallBindApplyHelpers();
12550
+ var gOPD = gopd;
12551
+
12552
+ var hasProtoAccessor;
12553
+ try {
12554
+ // eslint-disable-next-line no-extra-parens, no-proto
12555
+ hasProtoAccessor = /** @type {{ __proto__?: typeof Array.prototype }} */ ([]).__proto__ === Array.prototype;
12556
+ } catch (e) {
12557
+ if (!e || typeof e !== 'object' || !('code' in e) || e.code !== 'ERR_PROTO_ACCESS') {
12558
+ throw e;
12559
+ }
12560
+ }
12561
+
12562
+ // eslint-disable-next-line no-extra-parens
12563
+ var desc = !!hasProtoAccessor && gOPD && gOPD(Object.prototype, /** @type {keyof typeof Object.prototype} */ ('__proto__'));
12564
+
12565
+ var $Object = Object;
12566
+ var $getPrototypeOf = $Object.getPrototypeOf;
12567
+
12568
+ /** @type {import('./get')} */
12569
+ get = desc && typeof desc.get === 'function'
12570
+ ? callBind([desc.get])
12571
+ : typeof $getPrototypeOf === 'function'
12572
+ ? /** @type {import('./get')} */ function getDunder(value) {
12573
+ // eslint-disable-next-line eqeqeq
12574
+ return $getPrototypeOf(value == null ? value : $Object(value));
12575
+ }
12576
+ : false;
12577
+ return get;
12578
+ }
12579
+
12580
+ var hasown;
12581
+ var hasRequiredHasown;
12582
+
12583
+ function requireHasown () {
12584
+ if (hasRequiredHasown) return hasown;
12585
+ hasRequiredHasown = 1;
12586
+
12587
+ var call = Function.prototype.call;
12588
+ var $hasOwn = Object.prototype.hasOwnProperty;
12589
+ var bind = functionBind;
12590
+
12591
+ /** @type {import('.')} */
12592
+ hasown = bind.call(call, $hasOwn);
12593
+ return hasown;
12594
+ }
12595
+
12596
+ var undefined$1;
12597
+
12598
+ var $Object = esObjectAtoms;
12599
+
12600
+ var $Error = esErrors;
12601
+ var $EvalError = _eval;
12602
+ var $RangeError = range;
12603
+ var $ReferenceError = ref;
12604
+ var $SyntaxError = syntax;
12605
+ var $TypeError = type;
12606
+ var $URIError = uri;
12607
+
12608
+ var abs = abs$1;
12609
+ var floor = floor$1;
12610
+ var max = max$2;
12611
+ var min = min$1;
12612
+ var pow = pow$1;
12613
+
12614
+ var $Function = Function;
12615
+
12616
+ // eslint-disable-next-line consistent-return
12617
+ var getEvalledConstructor = function (expressionSyntax) {
12618
+ try {
12619
+ return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
12620
+ } catch (e) {}
12621
+ };
12622
+
12623
+ var $gOPD = gopd;
12624
+ var $defineProperty = esDefineProperty;
12625
+
12626
+ var throwTypeError = function () {
12627
+ throw new $TypeError();
12628
+ };
12629
+ var ThrowTypeError = $gOPD
12630
+ ? (function () {
12631
+ try {
12632
+ // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
12633
+ arguments.callee; // IE 8 does not throw here
12634
+ return throwTypeError;
12635
+ } catch (calleeThrows) {
12636
+ try {
12637
+ // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
12638
+ return $gOPD(arguments, 'callee').get;
12639
+ } catch (gOPDthrows) {
12640
+ return throwTypeError;
12641
+ }
12642
+ }
12643
+ }())
12644
+ : throwTypeError;
12645
+
12646
+ var hasSymbols = requireHasSymbols()();
12647
+ var getDunderProto = requireGet();
12648
+
12649
+ var getProto$1 = (typeof Reflect === 'function' && Reflect.getPrototypeOf)
12650
+ || $Object.getPrototypeOf
12651
+ || getDunderProto;
12652
+
12653
+ var $apply = requireFunctionApply();
12654
+ var $call = requireFunctionCall();
12655
+
12656
+ var needsEval = {};
12657
+
12658
+ var TypedArray = typeof Uint8Array === 'undefined' || !getProto$1 ? undefined$1 : getProto$1(Uint8Array);
12659
+
12660
+ var INTRINSICS = {
12661
+ __proto__: null,
12662
+ '%AggregateError%': typeof AggregateError === 'undefined' ? undefined$1 : AggregateError,
12663
+ '%Array%': Array,
12664
+ '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer,
12665
+ '%ArrayIteratorPrototype%': hasSymbols && getProto$1 ? getProto$1([][Symbol.iterator]()) : undefined$1,
12666
+ '%AsyncFromSyncIteratorPrototype%': undefined$1,
12667
+ '%AsyncFunction%': needsEval,
12668
+ '%AsyncGenerator%': needsEval,
12669
+ '%AsyncGeneratorFunction%': needsEval,
12670
+ '%AsyncIteratorPrototype%': needsEval,
12671
+ '%Atomics%': typeof Atomics === 'undefined' ? undefined$1 : Atomics,
12672
+ '%BigInt%': typeof BigInt === 'undefined' ? undefined$1 : BigInt,
12673
+ '%BigInt64Array%': typeof BigInt64Array === 'undefined' ? undefined$1 : BigInt64Array,
12674
+ '%BigUint64Array%': typeof BigUint64Array === 'undefined' ? undefined$1 : BigUint64Array,
12675
+ '%Boolean%': Boolean,
12676
+ '%DataView%': typeof DataView === 'undefined' ? undefined$1 : DataView,
12677
+ '%Date%': Date,
12678
+ '%decodeURI%': decodeURI,
12679
+ '%decodeURIComponent%': decodeURIComponent,
12680
+ '%encodeURI%': encodeURI,
12681
+ '%encodeURIComponent%': encodeURIComponent,
12682
+ '%Error%': $Error,
12683
+ '%eval%': eval, // eslint-disable-line no-eval
12684
+ '%EvalError%': $EvalError,
12685
+ '%Float32Array%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array,
12686
+ '%Float64Array%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array,
12687
+ '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined$1 : FinalizationRegistry,
12688
+ '%Function%': $Function,
12689
+ '%GeneratorFunction%': needsEval,
12690
+ '%Int8Array%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array,
12691
+ '%Int16Array%': typeof Int16Array === 'undefined' ? undefined$1 : Int16Array,
12692
+ '%Int32Array%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array,
12693
+ '%isFinite%': isFinite,
12694
+ '%isNaN%': isNaN,
12695
+ '%IteratorPrototype%': hasSymbols && getProto$1 ? getProto$1(getProto$1([][Symbol.iterator]())) : undefined$1,
12696
+ '%JSON%': typeof JSON === 'object' ? JSON : undefined$1,
12697
+ '%Map%': typeof Map === 'undefined' ? undefined$1 : Map,
12698
+ '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols || !getProto$1 ? undefined$1 : getProto$1(new Map()[Symbol.iterator]()),
12699
+ '%Math%': Math,
12700
+ '%Number%': Number,
12701
+ '%Object%': $Object,
12702
+ '%Object.getOwnPropertyDescriptor%': $gOPD,
12703
+ '%parseFloat%': parseFloat,
12704
+ '%parseInt%': parseInt,
12705
+ '%Promise%': typeof Promise === 'undefined' ? undefined$1 : Promise,
12706
+ '%Proxy%': typeof Proxy === 'undefined' ? undefined$1 : Proxy,
12707
+ '%RangeError%': $RangeError,
12708
+ '%ReferenceError%': $ReferenceError,
12709
+ '%Reflect%': typeof Reflect === 'undefined' ? undefined$1 : Reflect,
12710
+ '%RegExp%': RegExp,
12711
+ '%Set%': typeof Set === 'undefined' ? undefined$1 : Set,
12712
+ '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols || !getProto$1 ? undefined$1 : getProto$1(new Set()[Symbol.iterator]()),
12713
+ '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer,
12714
+ '%String%': String,
12715
+ '%StringIteratorPrototype%': hasSymbols && getProto$1 ? getProto$1(''[Symbol.iterator]()) : undefined$1,
12716
+ '%Symbol%': hasSymbols ? Symbol : undefined$1,
12717
+ '%SyntaxError%': $SyntaxError,
12718
+ '%ThrowTypeError%': ThrowTypeError,
12719
+ '%TypedArray%': TypedArray,
12720
+ '%TypeError%': $TypeError,
12721
+ '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array,
12722
+ '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray,
12723
+ '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array,
12724
+ '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array,
12725
+ '%URIError%': $URIError,
12726
+ '%WeakMap%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap,
12727
+ '%WeakRef%': typeof WeakRef === 'undefined' ? undefined$1 : WeakRef,
12728
+ '%WeakSet%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet,
12729
+
12730
+ '%Function.prototype.call%': $call,
12731
+ '%Function.prototype.apply%': $apply,
12732
+ '%Object.defineProperty%': $defineProperty,
12733
+ '%Math.abs%': abs,
12734
+ '%Math.floor%': floor,
12735
+ '%Math.max%': max,
12736
+ '%Math.min%': min,
12737
+ '%Math.pow%': pow
12738
+ };
12739
+
12740
+ if (getProto$1) {
12741
+ try {
12742
+ null.error; // eslint-disable-line no-unused-expressions
12743
+ } catch (e) {
12744
+ // https://github.com/tc39/proposal-shadowrealm/pull/384#issuecomment-1364264229
12745
+ var errorProto = getProto$1(getProto$1(e));
12746
+ INTRINSICS['%Error.prototype%'] = errorProto;
12747
+ }
12748
+ }
12749
+
12750
+ var doEval = function doEval(name) {
12751
+ var value;
12752
+ if (name === '%AsyncFunction%') {
12753
+ value = getEvalledConstructor('async function () {}');
12754
+ } else if (name === '%GeneratorFunction%') {
12755
+ value = getEvalledConstructor('function* () {}');
12756
+ } else if (name === '%AsyncGeneratorFunction%') {
12757
+ value = getEvalledConstructor('async function* () {}');
12758
+ } else if (name === '%AsyncGenerator%') {
12759
+ var fn = doEval('%AsyncGeneratorFunction%');
12760
+ if (fn) {
12761
+ value = fn.prototype;
12762
+ }
12763
+ } else if (name === '%AsyncIteratorPrototype%') {
12764
+ var gen = doEval('%AsyncGenerator%');
12765
+ if (gen && getProto$1) {
12766
+ value = getProto$1(gen.prototype);
12767
+ }
12768
+ }
12769
+
12770
+ INTRINSICS[name] = value;
12771
+
12772
+ return value;
12773
+ };
12774
+
12775
+ var LEGACY_ALIASES = {
12776
+ __proto__: null,
12777
+ '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
12778
+ '%ArrayPrototype%': ['Array', 'prototype'],
12779
+ '%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
12780
+ '%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
12781
+ '%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
12782
+ '%ArrayProto_values%': ['Array', 'prototype', 'values'],
12783
+ '%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
12784
+ '%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
12785
+ '%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
12786
+ '%BooleanPrototype%': ['Boolean', 'prototype'],
12787
+ '%DataViewPrototype%': ['DataView', 'prototype'],
12788
+ '%DatePrototype%': ['Date', 'prototype'],
12789
+ '%ErrorPrototype%': ['Error', 'prototype'],
12790
+ '%EvalErrorPrototype%': ['EvalError', 'prototype'],
12791
+ '%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
12792
+ '%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
12793
+ '%FunctionPrototype%': ['Function', 'prototype'],
12794
+ '%Generator%': ['GeneratorFunction', 'prototype'],
12795
+ '%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
12796
+ '%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
12797
+ '%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
12798
+ '%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
12799
+ '%JSONParse%': ['JSON', 'parse'],
12800
+ '%JSONStringify%': ['JSON', 'stringify'],
12801
+ '%MapPrototype%': ['Map', 'prototype'],
12802
+ '%NumberPrototype%': ['Number', 'prototype'],
12803
+ '%ObjectPrototype%': ['Object', 'prototype'],
12804
+ '%ObjProto_toString%': ['Object', 'prototype', 'toString'],
12805
+ '%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
12806
+ '%PromisePrototype%': ['Promise', 'prototype'],
12807
+ '%PromiseProto_then%': ['Promise', 'prototype', 'then'],
12808
+ '%Promise_all%': ['Promise', 'all'],
12809
+ '%Promise_reject%': ['Promise', 'reject'],
12810
+ '%Promise_resolve%': ['Promise', 'resolve'],
12811
+ '%RangeErrorPrototype%': ['RangeError', 'prototype'],
12812
+ '%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
12813
+ '%RegExpPrototype%': ['RegExp', 'prototype'],
12814
+ '%SetPrototype%': ['Set', 'prototype'],
12815
+ '%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
12816
+ '%StringPrototype%': ['String', 'prototype'],
12817
+ '%SymbolPrototype%': ['Symbol', 'prototype'],
12818
+ '%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
12819
+ '%TypedArrayPrototype%': ['TypedArray', 'prototype'],
12820
+ '%TypeErrorPrototype%': ['TypeError', 'prototype'],
12821
+ '%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
12822
+ '%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
12823
+ '%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
12824
+ '%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
12825
+ '%URIErrorPrototype%': ['URIError', 'prototype'],
12826
+ '%WeakMapPrototype%': ['WeakMap', 'prototype'],
12827
+ '%WeakSetPrototype%': ['WeakSet', 'prototype']
12828
+ };
12829
+
12830
+ var bind = functionBind;
12831
+ var hasOwn = requireHasown();
12832
+ var $concat = bind.call($call, Array.prototype.concat);
12833
+ var $spliceApply = bind.call($apply, Array.prototype.splice);
12834
+ var $replace = bind.call($call, String.prototype.replace);
12835
+ var $strSlice = bind.call($call, String.prototype.slice);
12836
+ var $exec = bind.call($call, RegExp.prototype.exec);
12837
+
12838
+ /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
12839
+ var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
12840
+ var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
12841
+ var stringToPath = function stringToPath(string) {
12842
+ var first = $strSlice(string, 0, 1);
12843
+ var last = $strSlice(string, -1);
12844
+ if (first === '%' && last !== '%') {
12845
+ throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
12846
+ } else if (last === '%' && first !== '%') {
12847
+ throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
12848
+ }
12849
+ var result = [];
12850
+ $replace(string, rePropName, function (match, number, quote, subString) {
12851
+ result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;
12852
+ });
12853
+ return result;
12854
+ };
12855
+ /* end adaptation */
12856
+
12857
+ var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
12858
+ var intrinsicName = name;
12859
+ var alias;
12860
+ if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
12861
+ alias = LEGACY_ALIASES[intrinsicName];
12862
+ intrinsicName = '%' + alias[0] + '%';
12863
+ }
12864
+
12865
+ if (hasOwn(INTRINSICS, intrinsicName)) {
12866
+ var value = INTRINSICS[intrinsicName];
12867
+ if (value === needsEval) {
12868
+ value = doEval(intrinsicName);
12869
+ }
12870
+ if (typeof value === 'undefined' && !allowMissing) {
12871
+ throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
12872
+ }
12873
+
12874
+ return {
12875
+ alias: alias,
12876
+ name: intrinsicName,
12877
+ value: value
12878
+ };
12879
+ }
12880
+
12881
+ throw new $SyntaxError('intrinsic ' + name + ' does not exist!');
12882
+ };
12883
+
12884
+ var getIntrinsic = function GetIntrinsic(name, allowMissing) {
12885
+ if (typeof name !== 'string' || name.length === 0) {
12886
+ throw new $TypeError('intrinsic name must be a non-empty string');
12887
+ }
12888
+ if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
12889
+ throw new $TypeError('"allowMissing" argument must be a boolean');
12890
+ }
12891
+
12892
+ if ($exec(/^%?[^%]*%?$/, name) === null) {
12893
+ throw new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name');
12894
+ }
12895
+ var parts = stringToPath(name);
12896
+ var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
12897
+
12898
+ var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
12899
+ var intrinsicRealName = intrinsic.name;
12900
+ var value = intrinsic.value;
12901
+ var skipFurtherCaching = false;
12902
+
12903
+ var alias = intrinsic.alias;
12904
+ if (alias) {
12905
+ intrinsicBaseName = alias[0];
12906
+ $spliceApply(parts, $concat([0, 1], alias));
12907
+ }
12908
+
12909
+ for (var i = 1, isOwn = true; i < parts.length; i += 1) {
12910
+ var part = parts[i];
12911
+ var first = $strSlice(part, 0, 1);
12912
+ var last = $strSlice(part, -1);
12913
+ if (
12914
+ (
12915
+ (first === '"' || first === "'" || first === '`')
12916
+ || (last === '"' || last === "'" || last === '`')
12917
+ )
12918
+ && first !== last
12919
+ ) {
12920
+ throw new $SyntaxError('property names with quotes must have matching quotes');
12921
+ }
12922
+ if (part === 'constructor' || !isOwn) {
12923
+ skipFurtherCaching = true;
12924
+ }
12925
+
12926
+ intrinsicBaseName += '.' + part;
12927
+ intrinsicRealName = '%' + intrinsicBaseName + '%';
12928
+
12929
+ if (hasOwn(INTRINSICS, intrinsicRealName)) {
12930
+ value = INTRINSICS[intrinsicRealName];
12931
+ } else if (value != null) {
12932
+ if (!(part in value)) {
12933
+ if (!allowMissing) {
12934
+ throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
12935
+ }
12936
+ return void undefined$1;
12937
+ }
12938
+ if ($gOPD && (i + 1) >= parts.length) {
12939
+ var desc = $gOPD(value, part);
12940
+ isOwn = !!desc;
12941
+
12942
+ // By convention, when a data property is converted to an accessor
12943
+ // property to emulate a data property that does not suffer from
12944
+ // the override mistake, that accessor's getter is marked with
12945
+ // an `originalValue` property. Here, when we detect this, we
12946
+ // uphold the illusion by pretending to see that original data
12947
+ // property, i.e., returning the value rather than the getter
12948
+ // itself.
12949
+ if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
12950
+ value = desc.get;
12951
+ } else {
12952
+ value = value[part];
12953
+ }
12954
+ } else {
12955
+ isOwn = hasOwn(value, part);
12956
+ value = value[part];
12957
+ }
12958
+
12959
+ if (isOwn && !skipFurtherCaching) {
12960
+ INTRINSICS[intrinsicRealName] = value;
12961
+ }
12962
+ }
12963
+ }
12964
+ return value;
12965
+ };
12966
+
12967
+ var callBind$2 = {exports: {}};
12968
+
12969
+ (function (module) {
12970
+
12971
+ var bind = functionBind;
12972
+ var GetIntrinsic = getIntrinsic;
12973
+
12974
+ var $apply = GetIntrinsic('%Function.prototype.apply%');
12975
+ var $call = GetIntrinsic('%Function.prototype.call%');
12976
+ var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
12977
+
12978
+ var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
12979
+ var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
12980
+ var $max = GetIntrinsic('%Math.max%');
12981
+
12982
+ if ($defineProperty) {
12983
+ try {
12984
+ $defineProperty({}, 'a', { value: 1 });
12985
+ } catch (e) {
12986
+ // IE 8 has a broken defineProperty
12987
+ $defineProperty = null;
12988
+ }
12989
+ }
12990
+
12991
+ module.exports = function callBind(originalFunction) {
12992
+ var func = $reflectApply(bind, $call, arguments);
12993
+ if ($gOPD && $defineProperty) {
12994
+ var desc = $gOPD(func, 'length');
12995
+ if (desc.configurable) {
12996
+ // original length, plus the receiver, minus any additional arguments (after the receiver)
12997
+ $defineProperty(
12998
+ func,
12999
+ 'length',
13000
+ { value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) }
13001
+ );
13002
+ }
13003
+ }
13004
+ return func;
13005
+ };
13006
+
13007
+ var applyBind = function applyBind() {
13008
+ return $reflectApply(bind, $apply, arguments);
13009
+ };
13010
+
13011
+ if ($defineProperty) {
13012
+ $defineProperty(module.exports, 'apply', { value: applyBind });
13013
+ } else {
13014
+ module.exports.apply = applyBind;
13015
+ }
13016
+ } (callBind$2));
13017
+
13018
+ var callBindExports = callBind$2.exports;
13019
+
13020
+ var GetIntrinsic = getIntrinsic;
13021
+
13022
+ var callBind$1 = callBindExports;
13023
+
13024
+ var $indexOf$1 = callBind$1(GetIntrinsic('String.prototype.indexOf'));
13025
+
13026
+ var callBound$2 = function callBoundIntrinsic(name, allowMissing) {
13027
+ var intrinsic = GetIntrinsic(name, !!allowMissing);
13028
+ if (typeof intrinsic === 'function' && $indexOf$1(name, '.prototype.') > -1) {
13029
+ return callBind$1(intrinsic);
13030
+ }
13031
+ return intrinsic;
13032
+ };
13033
+
13034
+ var hasToStringTag$3 = shams();
13035
+ var callBound$1 = callBound$2;
13036
+
13037
+ var $toString$1 = callBound$1('Object.prototype.toString');
13038
+
13039
+ var isStandardArguments = function isArguments(value) {
13040
+ if (hasToStringTag$3 && value && typeof value === 'object' && Symbol.toStringTag in value) {
13041
+ return false;
13042
+ }
13043
+ return $toString$1(value) === '[object Arguments]';
13044
+ };
13045
+
13046
+ var isLegacyArguments = function isArguments(value) {
13047
+ if (isStandardArguments(value)) {
13048
+ return true;
13049
+ }
13050
+ return value !== null &&
13051
+ typeof value === 'object' &&
13052
+ typeof value.length === 'number' &&
13053
+ value.length >= 0 &&
13054
+ $toString$1(value) !== '[object Array]' &&
13055
+ $toString$1(value.callee) === '[object Function]';
13056
+ };
13057
+
13058
+ var supportsStandardArguments = (function () {
13059
+ return isStandardArguments(arguments);
13060
+ }());
13061
+
13062
+ isStandardArguments.isLegacyArguments = isLegacyArguments; // for tests
13063
+
13064
+ var isArguments = supportsStandardArguments ? isStandardArguments : isLegacyArguments;
13065
+
13066
+ var toStr$2 = Object.prototype.toString;
13067
+ var fnToStr$1 = Function.prototype.toString;
13068
+ var isFnRegex = /^\s*(?:function)?\*/;
13069
+ var hasToStringTag$2 = shams();
13070
+ var getProto = Object.getPrototypeOf;
13071
+ var getGeneratorFunc = function () { // eslint-disable-line consistent-return
13072
+ if (!hasToStringTag$2) {
13073
+ return false;
13074
+ }
13075
+ try {
13076
+ return Function('return function*() {}')();
13077
+ } catch (e) {
13078
+ }
13079
+ };
13080
+ var GeneratorFunction;
13081
+
13082
+ var isGeneratorFunction = function isGeneratorFunction(fn) {
13083
+ if (typeof fn !== 'function') {
13084
+ return false;
13085
+ }
13086
+ if (isFnRegex.test(fnToStr$1.call(fn))) {
13087
+ return true;
13088
+ }
13089
+ if (!hasToStringTag$2) {
13090
+ var str = toStr$2.call(fn);
13091
+ return str === '[object GeneratorFunction]';
13092
+ }
13093
+ if (!getProto) {
13094
+ return false;
13095
+ }
13096
+ if (typeof GeneratorFunction === 'undefined') {
13097
+ var generatorFunc = getGeneratorFunc();
13098
+ GeneratorFunction = generatorFunc ? getProto(generatorFunc) : false;
13099
+ }
13100
+ return getProto(fn) === GeneratorFunction;
13101
+ };
13102
+
13103
+ var fnToStr = Function.prototype.toString;
13104
+ var reflectApply = typeof Reflect === 'object' && Reflect !== null && Reflect.apply;
13105
+ var badArrayLike;
13106
+ var isCallableMarker;
13107
+ if (typeof reflectApply === 'function' && typeof Object.defineProperty === 'function') {
13108
+ try {
13109
+ badArrayLike = Object.defineProperty({}, 'length', {
13110
+ get: function () {
13111
+ throw isCallableMarker;
13112
+ }
13113
+ });
13114
+ isCallableMarker = {};
13115
+ // eslint-disable-next-line no-throw-literal
13116
+ reflectApply(function () { throw 42; }, null, badArrayLike);
13117
+ } catch (_) {
13118
+ if (_ !== isCallableMarker) {
13119
+ reflectApply = null;
13120
+ }
13121
+ }
13122
+ } else {
13123
+ reflectApply = null;
13124
+ }
13125
+
13126
+ var constructorRegex = /^\s*class\b/;
13127
+ var isES6ClassFn = function isES6ClassFunction(value) {
13128
+ try {
13129
+ var fnStr = fnToStr.call(value);
13130
+ return constructorRegex.test(fnStr);
13131
+ } catch (e) {
13132
+ return false; // not a function
13133
+ }
13134
+ };
13135
+
13136
+ var tryFunctionObject = function tryFunctionToStr(value) {
13137
+ try {
13138
+ if (isES6ClassFn(value)) { return false; }
13139
+ fnToStr.call(value);
13140
+ return true;
13141
+ } catch (e) {
13142
+ return false;
13143
+ }
13144
+ };
13145
+ var toStr$1 = Object.prototype.toString;
13146
+ var objectClass = '[object Object]';
13147
+ var fnClass = '[object Function]';
13148
+ var genClass = '[object GeneratorFunction]';
13149
+ var ddaClass = '[object HTMLAllCollection]'; // IE 11
13150
+ var ddaClass2 = '[object HTML document.all class]';
13151
+ var ddaClass3 = '[object HTMLCollection]'; // IE 9-10
13152
+ var hasToStringTag$1 = typeof Symbol === 'function' && !!Symbol.toStringTag; // better: use `has-tostringtag`
13153
+
13154
+ var isIE68 = !(0 in [,]); // eslint-disable-line no-sparse-arrays, comma-spacing
13155
+
13156
+ var isDDA = function isDocumentDotAll() { return false; };
13157
+ if (typeof document === 'object') {
13158
+ // Firefox 3 canonicalizes DDA to undefined when it's not accessed directly
13159
+ var all = document.all;
13160
+ if (toStr$1.call(all) === toStr$1.call(document.all)) {
13161
+ isDDA = function isDocumentDotAll(value) {
13162
+ /* globals document: false */
13163
+ // in IE 6-8, typeof document.all is "object" and it's truthy
13164
+ if ((isIE68 || !value) && (typeof value === 'undefined' || typeof value === 'object')) {
13165
+ try {
13166
+ var str = toStr$1.call(value);
13167
+ return (
13168
+ str === ddaClass
13169
+ || str === ddaClass2
13170
+ || str === ddaClass3 // opera 12.16
13171
+ || str === objectClass // IE 6-8
13172
+ ) && value('') == null; // eslint-disable-line eqeqeq
13173
+ } catch (e) { /**/ }
13174
+ }
13175
+ return false;
13176
+ };
13177
+ }
13178
+ }
13179
+
13180
+ var isCallable$1 = reflectApply
13181
+ ? function isCallable(value) {
13182
+ if (isDDA(value)) { return true; }
13183
+ if (!value) { return false; }
13184
+ if (typeof value !== 'function' && typeof value !== 'object') { return false; }
13185
+ try {
13186
+ reflectApply(value, null, badArrayLike);
13187
+ } catch (e) {
13188
+ if (e !== isCallableMarker) { return false; }
13189
+ }
13190
+ return !isES6ClassFn(value) && tryFunctionObject(value);
13191
+ }
13192
+ : function isCallable(value) {
13193
+ if (isDDA(value)) { return true; }
13194
+ if (!value) { return false; }
13195
+ if (typeof value !== 'function' && typeof value !== 'object') { return false; }
13196
+ if (hasToStringTag$1) { return tryFunctionObject(value); }
13197
+ if (isES6ClassFn(value)) { return false; }
13198
+ var strClass = toStr$1.call(value);
13199
+ if (strClass !== fnClass && strClass !== genClass && !(/^\[object HTML/).test(strClass)) { return false; }
13200
+ return tryFunctionObject(value);
13201
+ };
13202
+
13203
+ var isCallable = isCallable$1;
13204
+
13205
+ var toStr = Object.prototype.toString;
13206
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
13207
+
13208
+ var forEachArray = function forEachArray(array, iterator, receiver) {
13209
+ for (var i = 0, len = array.length; i < len; i++) {
13210
+ if (hasOwnProperty.call(array, i)) {
13211
+ if (receiver == null) {
13212
+ iterator(array[i], i, array);
13213
+ } else {
13214
+ iterator.call(receiver, array[i], i, array);
13215
+ }
13216
+ }
13217
+ }
13218
+ };
13219
+
13220
+ var forEachString = function forEachString(string, iterator, receiver) {
13221
+ for (var i = 0, len = string.length; i < len; i++) {
13222
+ // no such thing as a sparse string.
13223
+ if (receiver == null) {
13224
+ iterator(string.charAt(i), i, string);
13225
+ } else {
13226
+ iterator.call(receiver, string.charAt(i), i, string);
13227
+ }
13228
+ }
13229
+ };
13230
+
13231
+ var forEachObject = function forEachObject(object, iterator, receiver) {
13232
+ for (var k in object) {
13233
+ if (hasOwnProperty.call(object, k)) {
13234
+ if (receiver == null) {
13235
+ iterator(object[k], k, object);
13236
+ } else {
13237
+ iterator.call(receiver, object[k], k, object);
13238
+ }
13239
+ }
13240
+ }
13241
+ };
13242
+
13243
+ var forEach$1 = function forEach(list, iterator, thisArg) {
13244
+ if (!isCallable(iterator)) {
13245
+ throw new TypeError('iterator must be a function');
13246
+ }
13247
+
13248
+ var receiver;
13249
+ if (arguments.length >= 3) {
13250
+ receiver = thisArg;
13251
+ }
13252
+
13253
+ if (toStr.call(list) === '[object Array]') {
13254
+ forEachArray(list, iterator, receiver);
13255
+ } else if (typeof list === 'string') {
13256
+ forEachString(list, iterator, receiver);
13257
+ } else {
13258
+ forEachObject(list, iterator, receiver);
13259
+ }
13260
+ };
13261
+
13262
+ var forEach_1 = forEach$1;
13263
+
13264
+ var possibleNames = [
13265
+ 'BigInt64Array',
13266
+ 'BigUint64Array',
13267
+ 'Float32Array',
13268
+ 'Float64Array',
13269
+ 'Int16Array',
13270
+ 'Int32Array',
13271
+ 'Int8Array',
13272
+ 'Uint16Array',
13273
+ 'Uint32Array',
13274
+ 'Uint8Array',
13275
+ 'Uint8ClampedArray'
13276
+ ];
13277
+
13278
+ var g$1 = typeof globalThis === 'undefined' ? commonjsGlobal : globalThis;
13279
+
13280
+ var availableTypedArrays$1 = function availableTypedArrays() {
13281
+ var out = [];
13282
+ for (var i = 0; i < possibleNames.length; i++) {
13283
+ if (typeof g$1[possibleNames[i]] === 'function') {
13284
+ out[out.length] = possibleNames[i];
13285
+ }
13286
+ }
13287
+ return out;
13288
+ };
13289
+
13290
+ var forEach = forEach_1;
13291
+ var availableTypedArrays = availableTypedArrays$1;
13292
+ var callBind = callBindExports;
13293
+ var callBound = callBound$2;
13294
+ var gOPD = gopd;
13295
+
13296
+ var $toString = callBound('Object.prototype.toString');
13297
+ var hasToStringTag = shams();
13298
+
13299
+ var g = typeof globalThis === 'undefined' ? commonjsGlobal : globalThis;
13300
+ var typedArrays = availableTypedArrays();
13301
+
13302
+ var $slice = callBound('String.prototype.slice');
13303
+ var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof');
13304
+
13305
+ var $indexOf = callBound('Array.prototype.indexOf', true) || function indexOf(array, value) {
13306
+ for (var i = 0; i < array.length; i += 1) {
13307
+ if (array[i] === value) {
13308
+ return i;
13309
+ }
13310
+ }
13311
+ return -1;
13312
+ };
13313
+ var cache = { __proto__: null };
13314
+ if (hasToStringTag && gOPD && getPrototypeOf) {
13315
+ forEach(typedArrays, function (typedArray) {
13316
+ var arr = new g[typedArray]();
13317
+ if (Symbol.toStringTag in arr) {
13318
+ var proto = getPrototypeOf(arr);
13319
+ var descriptor = gOPD(proto, Symbol.toStringTag);
13320
+ if (!descriptor) {
13321
+ var superProto = getPrototypeOf(proto);
13322
+ descriptor = gOPD(superProto, Symbol.toStringTag);
13323
+ }
13324
+ cache['$' + typedArray] = callBind(descriptor.get);
13325
+ }
13326
+ });
13327
+ } else {
13328
+ forEach(typedArrays, function (typedArray) {
13329
+ var arr = new g[typedArray]();
13330
+ cache['$' + typedArray] = callBind(arr.slice);
13331
+ });
13332
+ }
13333
+
13334
+ var tryTypedArrays = function tryAllTypedArrays(value) {
13335
+ var found = false;
13336
+ forEach(cache, function (getter, typedArray) {
13337
+ if (!found) {
13338
+ try {
13339
+ if ('$' + getter(value) === typedArray) {
13340
+ found = $slice(typedArray, 1);
13341
+ }
13342
+ } catch (e) { /**/ }
13343
+ }
13344
+ });
13345
+ return found;
13346
+ };
13347
+
13348
+ var trySlices = function tryAllSlices(value) {
13349
+ var found = false;
13350
+ forEach(cache, function (getter, name) {
13351
+ if (!found) {
13352
+ try {
13353
+ getter(value);
13354
+ found = $slice(name, 1);
13355
+ } catch (e) { /**/ }
13356
+ }
13357
+ });
13358
+ return found;
13359
+ };
13360
+
13361
+ var whichTypedArray$1 = function whichTypedArray(value) {
13362
+ if (!value || typeof value !== 'object') { return false; }
13363
+ if (!hasToStringTag) {
13364
+ var tag = $slice($toString(value), 8, -1);
13365
+ if ($indexOf(typedArrays, tag) > -1) {
13366
+ return tag;
13367
+ }
13368
+ if (tag !== 'Object') {
13369
+ return false;
13370
+ }
13371
+ // node < 0.6 hits here on real Typed Arrays
13372
+ return trySlices(value);
13373
+ }
13374
+ if (!gOPD) { return null; } // unknown engine
13375
+ return tryTypedArrays(value);
13376
+ };
13377
+
13378
+ var whichTypedArray = whichTypedArray$1;
13379
+
13380
+ var isTypedArray = function isTypedArray(value) {
13381
+ return !!whichTypedArray(value);
13382
+ };
13383
+
13384
+ (function (exports) {
13385
+
13386
+ var isArgumentsObject = isArguments;
13387
+ var isGeneratorFunction$1 = isGeneratorFunction;
13388
+ var whichTypedArray = whichTypedArray$1;
13389
+ var isTypedArray$1 = isTypedArray;
13390
+
13391
+ function uncurryThis(f) {
13392
+ return f.call.bind(f);
13393
+ }
13394
+
13395
+ var BigIntSupported = typeof BigInt !== 'undefined';
13396
+ var SymbolSupported = typeof Symbol !== 'undefined';
13397
+
13398
+ var ObjectToString = uncurryThis(Object.prototype.toString);
13399
+
13400
+ var numberValue = uncurryThis(Number.prototype.valueOf);
13401
+ var stringValue = uncurryThis(String.prototype.valueOf);
13402
+ var booleanValue = uncurryThis(Boolean.prototype.valueOf);
13403
+
13404
+ if (BigIntSupported) {
13405
+ var bigIntValue = uncurryThis(BigInt.prototype.valueOf);
13406
+ }
13407
+
13408
+ if (SymbolSupported) {
13409
+ var symbolValue = uncurryThis(Symbol.prototype.valueOf);
13410
+ }
13411
+
13412
+ function checkBoxedPrimitive(value, prototypeValueOf) {
13413
+ if (typeof value !== 'object') {
13414
+ return false;
13415
+ }
13416
+ try {
13417
+ prototypeValueOf(value);
13418
+ return true;
13419
+ } catch(e) {
13420
+ return false;
13421
+ }
13422
+ }
13423
+
13424
+ exports.isArgumentsObject = isArgumentsObject;
13425
+ exports.isGeneratorFunction = isGeneratorFunction$1;
13426
+ exports.isTypedArray = isTypedArray$1;
13427
+
13428
+ // Taken from here and modified for better browser support
13429
+ // https://github.com/sindresorhus/p-is-promise/blob/cda35a513bda03f977ad5cde3a079d237e82d7ef/index.js
13430
+ function isPromise(input) {
13431
+ return (
13432
+ (
13433
+ typeof Promise !== 'undefined' &&
13434
+ input instanceof Promise
13435
+ ) ||
13436
+ (
13437
+ input !== null &&
13438
+ typeof input === 'object' &&
13439
+ typeof input.then === 'function' &&
13440
+ typeof input.catch === 'function'
13441
+ )
13442
+ );
13443
+ }
13444
+ exports.isPromise = isPromise;
13445
+
13446
+ function isArrayBufferView(value) {
13447
+ if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
13448
+ return ArrayBuffer.isView(value);
13449
+ }
13450
+
13451
+ return (
13452
+ isTypedArray$1(value) ||
13453
+ isDataView(value)
13454
+ );
13455
+ }
13456
+ exports.isArrayBufferView = isArrayBufferView;
13457
+
13458
+
13459
+ function isUint8Array(value) {
13460
+ return whichTypedArray(value) === 'Uint8Array';
13461
+ }
13462
+ exports.isUint8Array = isUint8Array;
13463
+
13464
+ function isUint8ClampedArray(value) {
13465
+ return whichTypedArray(value) === 'Uint8ClampedArray';
13466
+ }
13467
+ exports.isUint8ClampedArray = isUint8ClampedArray;
13468
+
13469
+ function isUint16Array(value) {
13470
+ return whichTypedArray(value) === 'Uint16Array';
13471
+ }
13472
+ exports.isUint16Array = isUint16Array;
13473
+
13474
+ function isUint32Array(value) {
13475
+ return whichTypedArray(value) === 'Uint32Array';
13476
+ }
13477
+ exports.isUint32Array = isUint32Array;
13478
+
13479
+ function isInt8Array(value) {
13480
+ return whichTypedArray(value) === 'Int8Array';
13481
+ }
13482
+ exports.isInt8Array = isInt8Array;
13483
+
13484
+ function isInt16Array(value) {
13485
+ return whichTypedArray(value) === 'Int16Array';
13486
+ }
13487
+ exports.isInt16Array = isInt16Array;
13488
+
13489
+ function isInt32Array(value) {
13490
+ return whichTypedArray(value) === 'Int32Array';
13491
+ }
13492
+ exports.isInt32Array = isInt32Array;
13493
+
13494
+ function isFloat32Array(value) {
13495
+ return whichTypedArray(value) === 'Float32Array';
13496
+ }
13497
+ exports.isFloat32Array = isFloat32Array;
13498
+
13499
+ function isFloat64Array(value) {
13500
+ return whichTypedArray(value) === 'Float64Array';
13501
+ }
13502
+ exports.isFloat64Array = isFloat64Array;
13503
+
13504
+ function isBigInt64Array(value) {
13505
+ return whichTypedArray(value) === 'BigInt64Array';
13506
+ }
13507
+ exports.isBigInt64Array = isBigInt64Array;
13508
+
13509
+ function isBigUint64Array(value) {
13510
+ return whichTypedArray(value) === 'BigUint64Array';
13511
+ }
13512
+ exports.isBigUint64Array = isBigUint64Array;
13513
+
13514
+ function isMapToString(value) {
13515
+ return ObjectToString(value) === '[object Map]';
13516
+ }
13517
+ isMapToString.working = (
13518
+ typeof Map !== 'undefined' &&
13519
+ isMapToString(new Map())
13520
+ );
13521
+
13522
+ function isMap(value) {
13523
+ if (typeof Map === 'undefined') {
13524
+ return false;
13525
+ }
13526
+
13527
+ return isMapToString.working
13528
+ ? isMapToString(value)
13529
+ : value instanceof Map;
13530
+ }
13531
+ exports.isMap = isMap;
13532
+
13533
+ function isSetToString(value) {
13534
+ return ObjectToString(value) === '[object Set]';
13535
+ }
13536
+ isSetToString.working = (
13537
+ typeof Set !== 'undefined' &&
13538
+ isSetToString(new Set())
13539
+ );
13540
+ function isSet(value) {
13541
+ if (typeof Set === 'undefined') {
13542
+ return false;
13543
+ }
13544
+
13545
+ return isSetToString.working
13546
+ ? isSetToString(value)
13547
+ : value instanceof Set;
13548
+ }
13549
+ exports.isSet = isSet;
13550
+
13551
+ function isWeakMapToString(value) {
13552
+ return ObjectToString(value) === '[object WeakMap]';
13553
+ }
13554
+ isWeakMapToString.working = (
13555
+ typeof WeakMap !== 'undefined' &&
13556
+ isWeakMapToString(new WeakMap())
13557
+ );
13558
+ function isWeakMap(value) {
13559
+ if (typeof WeakMap === 'undefined') {
13560
+ return false;
13561
+ }
13562
+
13563
+ return isWeakMapToString.working
13564
+ ? isWeakMapToString(value)
13565
+ : value instanceof WeakMap;
13566
+ }
13567
+ exports.isWeakMap = isWeakMap;
13568
+
13569
+ function isWeakSetToString(value) {
13570
+ return ObjectToString(value) === '[object WeakSet]';
13571
+ }
13572
+ isWeakSetToString.working = (
13573
+ typeof WeakSet !== 'undefined' &&
13574
+ isWeakSetToString(new WeakSet())
13575
+ );
13576
+ function isWeakSet(value) {
13577
+ return isWeakSetToString(value);
13578
+ }
13579
+ exports.isWeakSet = isWeakSet;
13580
+
13581
+ function isArrayBufferToString(value) {
13582
+ return ObjectToString(value) === '[object ArrayBuffer]';
13583
+ }
13584
+ isArrayBufferToString.working = (
13585
+ typeof ArrayBuffer !== 'undefined' &&
13586
+ isArrayBufferToString(new ArrayBuffer())
13587
+ );
13588
+ function isArrayBuffer(value) {
13589
+ if (typeof ArrayBuffer === 'undefined') {
13590
+ return false;
13591
+ }
13592
+
13593
+ return isArrayBufferToString.working
13594
+ ? isArrayBufferToString(value)
13595
+ : value instanceof ArrayBuffer;
13596
+ }
13597
+ exports.isArrayBuffer = isArrayBuffer;
13598
+
13599
+ function isDataViewToString(value) {
13600
+ return ObjectToString(value) === '[object DataView]';
13601
+ }
13602
+ isDataViewToString.working = (
13603
+ typeof ArrayBuffer !== 'undefined' &&
13604
+ typeof DataView !== 'undefined' &&
13605
+ isDataViewToString(new DataView(new ArrayBuffer(1), 0, 1))
13606
+ );
13607
+ function isDataView(value) {
13608
+ if (typeof DataView === 'undefined') {
13609
+ return false;
13610
+ }
13611
+
13612
+ return isDataViewToString.working
13613
+ ? isDataViewToString(value)
13614
+ : value instanceof DataView;
13615
+ }
13616
+ exports.isDataView = isDataView;
13617
+
13618
+ // Store a copy of SharedArrayBuffer in case it's deleted elsewhere
13619
+ var SharedArrayBufferCopy = typeof SharedArrayBuffer !== 'undefined' ? SharedArrayBuffer : undefined;
13620
+ function isSharedArrayBufferToString(value) {
13621
+ return ObjectToString(value) === '[object SharedArrayBuffer]';
13622
+ }
13623
+ function isSharedArrayBuffer(value) {
13624
+ if (typeof SharedArrayBufferCopy === 'undefined') {
13625
+ return false;
13626
+ }
13627
+
13628
+ if (typeof isSharedArrayBufferToString.working === 'undefined') {
13629
+ isSharedArrayBufferToString.working = isSharedArrayBufferToString(new SharedArrayBufferCopy());
13630
+ }
13631
+
13632
+ return isSharedArrayBufferToString.working
13633
+ ? isSharedArrayBufferToString(value)
13634
+ : value instanceof SharedArrayBufferCopy;
13635
+ }
13636
+ exports.isSharedArrayBuffer = isSharedArrayBuffer;
13637
+
13638
+ function isAsyncFunction(value) {
13639
+ return ObjectToString(value) === '[object AsyncFunction]';
13640
+ }
13641
+ exports.isAsyncFunction = isAsyncFunction;
13642
+
13643
+ function isMapIterator(value) {
13644
+ return ObjectToString(value) === '[object Map Iterator]';
13645
+ }
13646
+ exports.isMapIterator = isMapIterator;
13647
+
13648
+ function isSetIterator(value) {
13649
+ return ObjectToString(value) === '[object Set Iterator]';
13650
+ }
13651
+ exports.isSetIterator = isSetIterator;
13652
+
13653
+ function isGeneratorObject(value) {
13654
+ return ObjectToString(value) === '[object Generator]';
13655
+ }
13656
+ exports.isGeneratorObject = isGeneratorObject;
13657
+
13658
+ function isWebAssemblyCompiledModule(value) {
13659
+ return ObjectToString(value) === '[object WebAssembly.Module]';
13660
+ }
13661
+ exports.isWebAssemblyCompiledModule = isWebAssemblyCompiledModule;
13662
+
13663
+ function isNumberObject(value) {
13664
+ return checkBoxedPrimitive(value, numberValue);
13665
+ }
13666
+ exports.isNumberObject = isNumberObject;
13667
+
13668
+ function isStringObject(value) {
13669
+ return checkBoxedPrimitive(value, stringValue);
13670
+ }
13671
+ exports.isStringObject = isStringObject;
13672
+
13673
+ function isBooleanObject(value) {
13674
+ return checkBoxedPrimitive(value, booleanValue);
13675
+ }
13676
+ exports.isBooleanObject = isBooleanObject;
13677
+
13678
+ function isBigIntObject(value) {
13679
+ return BigIntSupported && checkBoxedPrimitive(value, bigIntValue);
13680
+ }
13681
+ exports.isBigIntObject = isBigIntObject;
13682
+
13683
+ function isSymbolObject(value) {
13684
+ return SymbolSupported && checkBoxedPrimitive(value, symbolValue);
13685
+ }
13686
+ exports.isSymbolObject = isSymbolObject;
13687
+
13688
+ function isBoxedPrimitive(value) {
13689
+ return (
13690
+ isNumberObject(value) ||
13691
+ isStringObject(value) ||
13692
+ isBooleanObject(value) ||
13693
+ isBigIntObject(value) ||
13694
+ isSymbolObject(value)
13695
+ );
13696
+ }
13697
+ exports.isBoxedPrimitive = isBoxedPrimitive;
13698
+
13699
+ function isAnyArrayBuffer(value) {
13700
+ return typeof Uint8Array !== 'undefined' && (
13701
+ isArrayBuffer(value) ||
13702
+ isSharedArrayBuffer(value)
13703
+ );
13704
+ }
13705
+ exports.isAnyArrayBuffer = isAnyArrayBuffer;
13706
+
13707
+ ['isProxy', 'isExternal', 'isModuleNamespaceObject'].forEach(function(method) {
13708
+ Object.defineProperty(exports, method, {
13709
+ enumerable: false,
13710
+ value: function() {
13711
+ throw new Error(method + ' is not supported in userland');
13712
+ }
13713
+ });
13714
+ });
13715
+ } (types));
13716
+
13717
+ var isBuffer = function isBuffer(arg) {
13718
+ return arg instanceof Buffer;
13719
+ };
13720
+
13721
+ var inherits = {exports: {}};
13722
+
13723
+ var inherits_browser = {exports: {}};
13724
+
13725
+ var hasRequiredInherits_browser;
13726
+
13727
+ function requireInherits_browser () {
13728
+ if (hasRequiredInherits_browser) return inherits_browser.exports;
13729
+ hasRequiredInherits_browser = 1;
13730
+ if (typeof Object.create === 'function') {
13731
+ // implementation from standard node.js 'util' module
13732
+ inherits_browser.exports = function inherits(ctor, superCtor) {
13733
+ if (superCtor) {
13734
+ ctor.super_ = superCtor;
13735
+ ctor.prototype = Object.create(superCtor.prototype, {
13736
+ constructor: {
13737
+ value: ctor,
13738
+ enumerable: false,
13739
+ writable: true,
13740
+ configurable: true
13741
+ }
13742
+ });
13743
+ }
13744
+ };
13745
+ } else {
13746
+ // old school shim for old browsers
13747
+ inherits_browser.exports = function inherits(ctor, superCtor) {
13748
+ if (superCtor) {
13749
+ ctor.super_ = superCtor;
13750
+ var TempCtor = function () {};
13751
+ TempCtor.prototype = superCtor.prototype;
13752
+ ctor.prototype = new TempCtor();
13753
+ ctor.prototype.constructor = ctor;
13754
+ }
13755
+ };
13756
+ }
13757
+ return inherits_browser.exports;
13758
+ }
13759
+
13760
+ var hasRequiredInherits;
13761
+
13762
+ function requireInherits () {
13763
+ if (hasRequiredInherits) return inherits.exports;
13764
+ hasRequiredInherits = 1;
13765
+ try {
13766
+ var util = requireUtil();
13767
+ /* istanbul ignore next */
13768
+ if (typeof util.inherits !== 'function') throw '';
13769
+ inherits.exports = util.inherits;
13770
+ } catch (e) {
13771
+ /* istanbul ignore next */
13772
+ inherits.exports = requireInherits_browser();
13773
+ }
13774
+ return inherits.exports;
13775
+ }
13776
+
13777
+ var hasRequiredUtil;
13778
+
13779
+ function requireUtil () {
13780
+ if (hasRequiredUtil) return util;
13781
+ hasRequiredUtil = 1;
13782
+ (function (exports) {
13783
+ // Copyright Joyent, Inc. and other Node contributors.
13784
+ //
13785
+ // Permission is hereby granted, free of charge, to any person obtaining a
13786
+ // copy of this software and associated documentation files (the
13787
+ // "Software"), to deal in the Software without restriction, including
13788
+ // without limitation the rights to use, copy, modify, merge, publish,
13789
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
13790
+ // persons to whom the Software is furnished to do so, subject to the
13791
+ // following conditions:
13792
+ //
13793
+ // The above copyright notice and this permission notice shall be included
13794
+ // in all copies or substantial portions of the Software.
13795
+ //
13796
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
13797
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13798
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
13799
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
13800
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
13801
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
13802
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
13803
+
13804
+ var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||
13805
+ function getOwnPropertyDescriptors(obj) {
13806
+ var keys = Object.keys(obj);
13807
+ var descriptors = {};
13808
+ for (var i = 0; i < keys.length; i++) {
13809
+ descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
13810
+ }
13811
+ return descriptors;
13812
+ };
13813
+
13814
+ var formatRegExp = /%[sdj%]/g;
13815
+ exports.format = function(f) {
13816
+ if (!isString(f)) {
13817
+ var objects = [];
13818
+ for (var i = 0; i < arguments.length; i++) {
13819
+ objects.push(inspect(arguments[i]));
13820
+ }
13821
+ return objects.join(' ');
13822
+ }
13823
+
13824
+ var i = 1;
13825
+ var args = arguments;
13826
+ var len = args.length;
13827
+ var str = String(f).replace(formatRegExp, function(x) {
13828
+ if (x === '%%') return '%';
13829
+ if (i >= len) return x;
13830
+ switch (x) {
13831
+ case '%s': return String(args[i++]);
13832
+ case '%d': return Number(args[i++]);
13833
+ case '%j':
13834
+ try {
13835
+ return JSON.stringify(args[i++]);
13836
+ } catch (_) {
13837
+ return '[Circular]';
13838
+ }
13839
+ default:
13840
+ return x;
13841
+ }
13842
+ });
13843
+ for (var x = args[i]; i < len; x = args[++i]) {
13844
+ if (isNull(x) || !isObject(x)) {
13845
+ str += ' ' + x;
13846
+ } else {
13847
+ str += ' ' + inspect(x);
13848
+ }
13849
+ }
13850
+ return str;
13851
+ };
13852
+
13853
+
13854
+ // Mark that a method should not be used.
13855
+ // Returns a modified function which warns once by default.
13856
+ // If --no-deprecation is set, then it is a no-op.
13857
+ exports.deprecate = function(fn, msg) {
13858
+ if (typeof process !== 'undefined' && process.noDeprecation === true) {
13859
+ return fn;
13860
+ }
13861
+
13862
+ // Allow for deprecating things in the process of starting up.
13863
+ if (typeof process === 'undefined') {
13864
+ return function() {
13865
+ return exports.deprecate(fn, msg).apply(this, arguments);
13866
+ };
13867
+ }
13868
+
13869
+ var warned = false;
13870
+ function deprecated() {
13871
+ if (!warned) {
13872
+ if (process.throwDeprecation) {
13873
+ throw new Error(msg);
13874
+ } else if (process.traceDeprecation) {
13875
+ console.trace(msg);
13876
+ } else {
13877
+ console.error(msg);
13878
+ }
13879
+ warned = true;
13880
+ }
13881
+ return fn.apply(this, arguments);
13882
+ }
13883
+
13884
+ return deprecated;
13885
+ };
13886
+
13887
+
13888
+ var debugs = {};
13889
+ var debugEnvRegex = /^$/;
13890
+
13891
+ if (process.env.NODE_DEBUG) {
13892
+ var debugEnv = process.env.NODE_DEBUG;
13893
+ debugEnv = debugEnv.replace(/[|\\{}()[\]^$+?.]/g, '\\$&')
13894
+ .replace(/\*/g, '.*')
13895
+ .replace(/,/g, '$|^')
13896
+ .toUpperCase();
13897
+ debugEnvRegex = new RegExp('^' + debugEnv + '$', 'i');
13898
+ }
13899
+ exports.debuglog = function(set) {
13900
+ set = set.toUpperCase();
13901
+ if (!debugs[set]) {
13902
+ if (debugEnvRegex.test(set)) {
13903
+ var pid = process.pid;
13904
+ debugs[set] = function() {
13905
+ var msg = exports.format.apply(exports, arguments);
13906
+ console.error('%s %d: %s', set, pid, msg);
13907
+ };
13908
+ } else {
13909
+ debugs[set] = function() {};
13910
+ }
13911
+ }
13912
+ return debugs[set];
13913
+ };
13914
+
13915
+
13916
+ /**
13917
+ * Echos the value of a value. Trys to print the value out
13918
+ * in the best way possible given the different types.
13919
+ *
13920
+ * @param {Object} obj The object to print out.
13921
+ * @param {Object} opts Optional options object that alters the output.
13922
+ */
13923
+ /* legacy: obj, showHidden, depth, colors*/
13924
+ function inspect(obj, opts) {
13925
+ // default options
13926
+ var ctx = {
13927
+ seen: [],
13928
+ stylize: stylizeNoColor
13929
+ };
13930
+ // legacy...
13931
+ if (arguments.length >= 3) ctx.depth = arguments[2];
13932
+ if (arguments.length >= 4) ctx.colors = arguments[3];
13933
+ if (isBoolean(opts)) {
13934
+ // legacy...
13935
+ ctx.showHidden = opts;
13936
+ } else if (opts) {
13937
+ // got an "options" object
13938
+ exports._extend(ctx, opts);
13939
+ }
13940
+ // set default options
13941
+ if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
13942
+ if (isUndefined(ctx.depth)) ctx.depth = 2;
13943
+ if (isUndefined(ctx.colors)) ctx.colors = false;
13944
+ if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
13945
+ if (ctx.colors) ctx.stylize = stylizeWithColor;
13946
+ return formatValue(ctx, obj, ctx.depth);
13947
+ }
13948
+ exports.inspect = inspect;
13949
+
13950
+
13951
+ // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
13952
+ inspect.colors = {
13953
+ 'bold' : [1, 22],
13954
+ 'italic' : [3, 23],
13955
+ 'underline' : [4, 24],
13956
+ 'inverse' : [7, 27],
13957
+ 'white' : [37, 39],
13958
+ 'grey' : [90, 39],
13959
+ 'black' : [30, 39],
13960
+ 'blue' : [34, 39],
13961
+ 'cyan' : [36, 39],
13962
+ 'green' : [32, 39],
13963
+ 'magenta' : [35, 39],
13964
+ 'red' : [31, 39],
13965
+ 'yellow' : [33, 39]
13966
+ };
13967
+
13968
+ // Don't use 'blue' not visible on cmd.exe
13969
+ inspect.styles = {
13970
+ 'special': 'cyan',
13971
+ 'number': 'yellow',
13972
+ 'boolean': 'yellow',
13973
+ 'undefined': 'grey',
13974
+ 'null': 'bold',
13975
+ 'string': 'green',
13976
+ 'date': 'magenta',
13977
+ // "name": intentionally not styling
13978
+ 'regexp': 'red'
13979
+ };
13980
+
13981
+
13982
+ function stylizeWithColor(str, styleType) {
13983
+ var style = inspect.styles[styleType];
13984
+
13985
+ if (style) {
13986
+ return '\u001b[' + inspect.colors[style][0] + 'm' + str +
13987
+ '\u001b[' + inspect.colors[style][1] + 'm';
13988
+ } else {
13989
+ return str;
13990
+ }
13991
+ }
13992
+
13993
+
13994
+ function stylizeNoColor(str, styleType) {
13995
+ return str;
13996
+ }
13997
+
13998
+
13999
+ function arrayToHash(array) {
14000
+ var hash = {};
14001
+
14002
+ array.forEach(function(val, idx) {
14003
+ hash[val] = true;
14004
+ });
14005
+
14006
+ return hash;
14007
+ }
14008
+
14009
+
14010
+ function formatValue(ctx, value, recurseTimes) {
14011
+ // Provide a hook for user-specified inspect functions.
14012
+ // Check that value is an object with an inspect function on it
14013
+ if (ctx.customInspect &&
14014
+ value &&
14015
+ isFunction(value.inspect) &&
14016
+ // Filter out the util module, it's inspect function is special
14017
+ value.inspect !== exports.inspect &&
14018
+ // Also filter out any prototype objects using the circular check.
14019
+ !(value.constructor && value.constructor.prototype === value)) {
14020
+ var ret = value.inspect(recurseTimes, ctx);
14021
+ if (!isString(ret)) {
14022
+ ret = formatValue(ctx, ret, recurseTimes);
14023
+ }
14024
+ return ret;
14025
+ }
14026
+
14027
+ // Primitive types cannot have properties
14028
+ var primitive = formatPrimitive(ctx, value);
14029
+ if (primitive) {
14030
+ return primitive;
14031
+ }
14032
+
14033
+ // Look up the keys of the object.
14034
+ var keys = Object.keys(value);
14035
+ var visibleKeys = arrayToHash(keys);
14036
+
14037
+ if (ctx.showHidden) {
14038
+ keys = Object.getOwnPropertyNames(value);
14039
+ }
14040
+
14041
+ // IE doesn't make error fields non-enumerable
14042
+ // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
14043
+ if (isError(value)
14044
+ && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
14045
+ return formatError(value);
14046
+ }
14047
+
14048
+ // Some type of object without properties can be shortcutted.
14049
+ if (keys.length === 0) {
14050
+ if (isFunction(value)) {
14051
+ var name = value.name ? ': ' + value.name : '';
14052
+ return ctx.stylize('[Function' + name + ']', 'special');
14053
+ }
14054
+ if (isRegExp(value)) {
14055
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
14056
+ }
14057
+ if (isDate(value)) {
14058
+ return ctx.stylize(Date.prototype.toString.call(value), 'date');
14059
+ }
14060
+ if (isError(value)) {
14061
+ return formatError(value);
14062
+ }
14063
+ }
14064
+
14065
+ var base = '', array = false, braces = ['{', '}'];
14066
+
14067
+ // Make Array say that they are Array
14068
+ if (isArray(value)) {
14069
+ array = true;
14070
+ braces = ['[', ']'];
14071
+ }
14072
+
14073
+ // Make functions say that they are functions
14074
+ if (isFunction(value)) {
14075
+ var n = value.name ? ': ' + value.name : '';
14076
+ base = ' [Function' + n + ']';
14077
+ }
14078
+
14079
+ // Make RegExps say that they are RegExps
14080
+ if (isRegExp(value)) {
14081
+ base = ' ' + RegExp.prototype.toString.call(value);
14082
+ }
14083
+
14084
+ // Make dates with properties first say the date
14085
+ if (isDate(value)) {
14086
+ base = ' ' + Date.prototype.toUTCString.call(value);
14087
+ }
14088
+
14089
+ // Make error with message first say the error
14090
+ if (isError(value)) {
14091
+ base = ' ' + formatError(value);
14092
+ }
14093
+
14094
+ if (keys.length === 0 && (!array || value.length == 0)) {
14095
+ return braces[0] + base + braces[1];
14096
+ }
14097
+
14098
+ if (recurseTimes < 0) {
14099
+ if (isRegExp(value)) {
14100
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
14101
+ } else {
14102
+ return ctx.stylize('[Object]', 'special');
14103
+ }
14104
+ }
14105
+
14106
+ ctx.seen.push(value);
14107
+
14108
+ var output;
14109
+ if (array) {
14110
+ output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
14111
+ } else {
14112
+ output = keys.map(function(key) {
14113
+ return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
14114
+ });
14115
+ }
14116
+
14117
+ ctx.seen.pop();
14118
+
14119
+ return reduceToSingleString(output, base, braces);
14120
+ }
14121
+
14122
+
14123
+ function formatPrimitive(ctx, value) {
14124
+ if (isUndefined(value))
14125
+ return ctx.stylize('undefined', 'undefined');
14126
+ if (isString(value)) {
14127
+ var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
14128
+ .replace(/'/g, "\\'")
14129
+ .replace(/\\"/g, '"') + '\'';
14130
+ return ctx.stylize(simple, 'string');
14131
+ }
14132
+ if (isNumber(value))
14133
+ return ctx.stylize('' + value, 'number');
14134
+ if (isBoolean(value))
14135
+ return ctx.stylize('' + value, 'boolean');
14136
+ // For some reason typeof null is "object", so special case here.
14137
+ if (isNull(value))
14138
+ return ctx.stylize('null', 'null');
14139
+ }
14140
+
14141
+
14142
+ function formatError(value) {
14143
+ return '[' + Error.prototype.toString.call(value) + ']';
14144
+ }
14145
+
14146
+
14147
+ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
14148
+ var output = [];
14149
+ for (var i = 0, l = value.length; i < l; ++i) {
14150
+ if (hasOwnProperty(value, String(i))) {
14151
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
14152
+ String(i), true));
14153
+ } else {
14154
+ output.push('');
14155
+ }
14156
+ }
14157
+ keys.forEach(function(key) {
14158
+ if (!key.match(/^\d+$/)) {
14159
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
14160
+ key, true));
14161
+ }
14162
+ });
14163
+ return output;
14164
+ }
14165
+
14166
+
14167
+ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
14168
+ var name, str, desc;
14169
+ desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
14170
+ if (desc.get) {
14171
+ if (desc.set) {
14172
+ str = ctx.stylize('[Getter/Setter]', 'special');
14173
+ } else {
14174
+ str = ctx.stylize('[Getter]', 'special');
14175
+ }
14176
+ } else {
14177
+ if (desc.set) {
14178
+ str = ctx.stylize('[Setter]', 'special');
14179
+ }
14180
+ }
14181
+ if (!hasOwnProperty(visibleKeys, key)) {
14182
+ name = '[' + key + ']';
14183
+ }
14184
+ if (!str) {
14185
+ if (ctx.seen.indexOf(desc.value) < 0) {
14186
+ if (isNull(recurseTimes)) {
14187
+ str = formatValue(ctx, desc.value, null);
14188
+ } else {
14189
+ str = formatValue(ctx, desc.value, recurseTimes - 1);
14190
+ }
14191
+ if (str.indexOf('\n') > -1) {
14192
+ if (array) {
14193
+ str = str.split('\n').map(function(line) {
14194
+ return ' ' + line;
14195
+ }).join('\n').slice(2);
14196
+ } else {
14197
+ str = '\n' + str.split('\n').map(function(line) {
14198
+ return ' ' + line;
14199
+ }).join('\n');
14200
+ }
14201
+ }
14202
+ } else {
14203
+ str = ctx.stylize('[Circular]', 'special');
14204
+ }
14205
+ }
14206
+ if (isUndefined(name)) {
14207
+ if (array && key.match(/^\d+$/)) {
14208
+ return str;
14209
+ }
14210
+ name = JSON.stringify('' + key);
14211
+ if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
14212
+ name = name.slice(1, -1);
14213
+ name = ctx.stylize(name, 'name');
14214
+ } else {
14215
+ name = name.replace(/'/g, "\\'")
14216
+ .replace(/\\"/g, '"')
14217
+ .replace(/(^"|"$)/g, "'");
14218
+ name = ctx.stylize(name, 'string');
14219
+ }
14220
+ }
14221
+
14222
+ return name + ': ' + str;
14223
+ }
14224
+
14225
+
14226
+ function reduceToSingleString(output, base, braces) {
14227
+ var length = output.reduce(function(prev, cur) {
14228
+ if (cur.indexOf('\n') >= 0) ;
14229
+ return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
14230
+ }, 0);
14231
+
14232
+ if (length > 60) {
14233
+ return braces[0] +
14234
+ (base === '' ? '' : base + '\n ') +
14235
+ ' ' +
14236
+ output.join(',\n ') +
14237
+ ' ' +
14238
+ braces[1];
14239
+ }
14240
+
14241
+ return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
14242
+ }
14243
+
14244
+
14245
+ // NOTE: These type checking functions intentionally don't use `instanceof`
14246
+ // because it is fragile and can be easily faked with `Object.create()`.
14247
+ exports.types = types;
14248
+
14249
+ function isArray(ar) {
14250
+ return Array.isArray(ar);
14251
+ }
14252
+ exports.isArray = isArray;
14253
+
14254
+ function isBoolean(arg) {
14255
+ return typeof arg === 'boolean';
14256
+ }
14257
+ exports.isBoolean = isBoolean;
14258
+
14259
+ function isNull(arg) {
14260
+ return arg === null;
14261
+ }
14262
+ exports.isNull = isNull;
14263
+
14264
+ function isNullOrUndefined(arg) {
14265
+ return arg == null;
14266
+ }
14267
+ exports.isNullOrUndefined = isNullOrUndefined;
14268
+
14269
+ function isNumber(arg) {
14270
+ return typeof arg === 'number';
14271
+ }
14272
+ exports.isNumber = isNumber;
14273
+
14274
+ function isString(arg) {
14275
+ return typeof arg === 'string';
14276
+ }
14277
+ exports.isString = isString;
14278
+
14279
+ function isSymbol(arg) {
14280
+ return typeof arg === 'symbol';
14281
+ }
14282
+ exports.isSymbol = isSymbol;
14283
+
14284
+ function isUndefined(arg) {
14285
+ return arg === void 0;
14286
+ }
14287
+ exports.isUndefined = isUndefined;
14288
+
14289
+ function isRegExp(re) {
14290
+ return isObject(re) && objectToString(re) === '[object RegExp]';
14291
+ }
14292
+ exports.isRegExp = isRegExp;
14293
+ exports.types.isRegExp = isRegExp;
14294
+
14295
+ function isObject(arg) {
14296
+ return typeof arg === 'object' && arg !== null;
14297
+ }
14298
+ exports.isObject = isObject;
14299
+
14300
+ function isDate(d) {
14301
+ return isObject(d) && objectToString(d) === '[object Date]';
14302
+ }
14303
+ exports.isDate = isDate;
14304
+ exports.types.isDate = isDate;
14305
+
14306
+ function isError(e) {
14307
+ return isObject(e) &&
14308
+ (objectToString(e) === '[object Error]' || e instanceof Error);
14309
+ }
14310
+ exports.isError = isError;
14311
+ exports.types.isNativeError = isError;
14312
+
14313
+ function isFunction(arg) {
14314
+ return typeof arg === 'function';
14315
+ }
14316
+ exports.isFunction = isFunction;
14317
+
14318
+ function isPrimitive(arg) {
14319
+ return arg === null ||
14320
+ typeof arg === 'boolean' ||
14321
+ typeof arg === 'number' ||
14322
+ typeof arg === 'string' ||
14323
+ typeof arg === 'symbol' || // ES6 symbol
14324
+ typeof arg === 'undefined';
14325
+ }
14326
+ exports.isPrimitive = isPrimitive;
14327
+
14328
+ exports.isBuffer = isBuffer;
14329
+
14330
+ function objectToString(o) {
14331
+ return Object.prototype.toString.call(o);
14332
+ }
14333
+
14334
+
14335
+ function pad(n) {
14336
+ return n < 10 ? '0' + n.toString(10) : n.toString(10);
14337
+ }
14338
+
14339
+
14340
+ var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
14341
+ 'Oct', 'Nov', 'Dec'];
14342
+
14343
+ // 26 Feb 16:19:34
14344
+ function timestamp() {
14345
+ var d = new Date();
14346
+ var time = [pad(d.getHours()),
14347
+ pad(d.getMinutes()),
14348
+ pad(d.getSeconds())].join(':');
14349
+ return [d.getDate(), months[d.getMonth()], time].join(' ');
14350
+ }
14351
+
14352
+
14353
+ // log is just a thin wrapper to console.log that prepends a timestamp
14354
+ exports.log = function() {
14355
+ console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
14356
+ };
14357
+
14358
+
14359
+ /**
14360
+ * Inherit the prototype methods from one constructor into another.
14361
+ *
14362
+ * The Function.prototype.inherits from lang.js rewritten as a standalone
14363
+ * function (not on Function.prototype). NOTE: If this file is to be loaded
14364
+ * during bootstrapping this function needs to be rewritten using some native
14365
+ * functions as prototype setup using normal JavaScript does not work as
14366
+ * expected during bootstrapping (see mirror.js in r114903).
14367
+ *
14368
+ * @param {function} ctor Constructor function which needs to inherit the
14369
+ * prototype.
14370
+ * @param {function} superCtor Constructor function to inherit prototype from.
14371
+ */
14372
+ exports.inherits = requireInherits();
14373
+
14374
+ exports._extend = function(origin, add) {
14375
+ // Don't do anything if add isn't an object
14376
+ if (!add || !isObject(add)) return origin;
14377
+
14378
+ var keys = Object.keys(add);
14379
+ var i = keys.length;
14380
+ while (i--) {
14381
+ origin[keys[i]] = add[keys[i]];
14382
+ }
14383
+ return origin;
14384
+ };
14385
+
14386
+ function hasOwnProperty(obj, prop) {
14387
+ return Object.prototype.hasOwnProperty.call(obj, prop);
14388
+ }
14389
+
14390
+ var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;
14391
+
14392
+ exports.promisify = function promisify(original) {
14393
+ if (typeof original !== 'function')
14394
+ throw new TypeError('The "original" argument must be of type Function');
14395
+
14396
+ if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
14397
+ var fn = original[kCustomPromisifiedSymbol];
14398
+ if (typeof fn !== 'function') {
14399
+ throw new TypeError('The "util.promisify.custom" argument must be of type Function');
14400
+ }
14401
+ Object.defineProperty(fn, kCustomPromisifiedSymbol, {
14402
+ value: fn, enumerable: false, writable: false, configurable: true
14403
+ });
14404
+ return fn;
14405
+ }
14406
+
14407
+ function fn() {
14408
+ var promiseResolve, promiseReject;
14409
+ var promise = new Promise(function (resolve, reject) {
14410
+ promiseResolve = resolve;
14411
+ promiseReject = reject;
14412
+ });
14413
+
14414
+ var args = [];
14415
+ for (var i = 0; i < arguments.length; i++) {
14416
+ args.push(arguments[i]);
14417
+ }
14418
+ args.push(function (err, value) {
14419
+ if (err) {
14420
+ promiseReject(err);
14421
+ } else {
14422
+ promiseResolve(value);
14423
+ }
14424
+ });
14425
+
14426
+ try {
14427
+ original.apply(this, args);
14428
+ } catch (err) {
14429
+ promiseReject(err);
14430
+ }
14431
+
14432
+ return promise;
14433
+ }
14434
+
14435
+ Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
14436
+
14437
+ if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
14438
+ value: fn, enumerable: false, writable: false, configurable: true
14439
+ });
14440
+ return Object.defineProperties(
14441
+ fn,
14442
+ getOwnPropertyDescriptors(original)
14443
+ );
14444
+ };
14445
+
14446
+ exports.promisify.custom = kCustomPromisifiedSymbol;
14447
+
14448
+ function callbackifyOnRejected(reason, cb) {
14449
+ // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
14450
+ // Because `null` is a special error value in callbacks which means "no error
14451
+ // occurred", we error-wrap so the callback consumer can distinguish between
14452
+ // "the promise rejected with null" or "the promise fulfilled with undefined".
14453
+ if (!reason) {
14454
+ var newReason = new Error('Promise was rejected with a falsy value');
14455
+ newReason.reason = reason;
14456
+ reason = newReason;
14457
+ }
14458
+ return cb(reason);
14459
+ }
14460
+
14461
+ function callbackify(original) {
14462
+ if (typeof original !== 'function') {
14463
+ throw new TypeError('The "original" argument must be of type Function');
14464
+ }
14465
+
14466
+ // We DO NOT return the promise as it gives the user a false sense that
14467
+ // the promise is actually somehow related to the callback's execution
14468
+ // and that the callback throwing will reject the promise.
14469
+ function callbackified() {
14470
+ var args = [];
14471
+ for (var i = 0; i < arguments.length; i++) {
14472
+ args.push(arguments[i]);
14473
+ }
14474
+
14475
+ var maybeCb = args.pop();
14476
+ if (typeof maybeCb !== 'function') {
14477
+ throw new TypeError('The last argument must be of type Function');
14478
+ }
14479
+ var self = this;
14480
+ var cb = function() {
14481
+ return maybeCb.apply(self, arguments);
14482
+ };
14483
+ // In true node style we process the callback on `nextTick` with all the
14484
+ // implications (stack, `uncaughtException`, `async_hooks`)
14485
+ original.apply(this, args)
14486
+ .then(function(ret) { process.nextTick(cb.bind(null, null, ret)); },
14487
+ function(rej) { process.nextTick(callbackifyOnRejected.bind(null, rej, cb)); });
14488
+ }
14489
+
14490
+ Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
14491
+ Object.defineProperties(callbackified,
14492
+ getOwnPropertyDescriptors(original));
14493
+ return callbackified;
14494
+ }
14495
+ exports.callbackify = callbackify;
14496
+ } (util));
14497
+ return util;
14498
+ }
14499
+
14500
+ (function (module) {
14501
+ let imports = {};
14502
+ imports['__wbindgen_placeholder__'] = module.exports;
14503
+ let wasm;
14504
+ const { TextDecoder, TextEncoder } = requireUtil();
14505
+
14506
+ const heap = new Array(128).fill(undefined);
14507
+
14508
+ heap.push(undefined, null, true, false);
14509
+
14510
+ function getObject(idx) { return heap[idx]; }
14511
+
14512
+ let heap_next = heap.length;
14513
+
14514
+ function dropObject(idx) {
14515
+ if (idx < 132) return;
14516
+ heap[idx] = heap_next;
14517
+ heap_next = idx;
14518
+ }
14519
+
14520
+ function takeObject(idx) {
14521
+ const ret = getObject(idx);
14522
+ dropObject(idx);
14523
+ return ret;
14524
+ }
14525
+
14526
+ let cachedUint8Memory0 = null;
14527
+
14528
+ function getUint8Memory0() {
14529
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
14530
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
14531
+ }
14532
+ return cachedUint8Memory0;
14533
+ }
14534
+
14535
+ let WASM_VECTOR_LEN = 0;
14536
+
14537
+ function passArray8ToWasm0(arg, malloc) {
14538
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
14539
+ getUint8Memory0().set(arg, ptr / 1);
14540
+ WASM_VECTOR_LEN = arg.length;
14541
+ return ptr;
14542
+ }
14543
+ /**
14544
+ * @param {Uint8Array} input
14545
+ * @returns {number}
14546
+ */
14547
+ module.exports.fingerprint32 = function(input) {
14548
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
14549
+ const len0 = WASM_VECTOR_LEN;
14550
+ const ret = wasm.fingerprint32(ptr0, len0);
14551
+ return ret >>> 0;
14552
+ };
14553
+
14554
+ /**
14555
+ * @param {Uint8Array} input
14556
+ * @returns {bigint}
14557
+ */
14558
+ module.exports.fingerprint64 = function(input) {
14559
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
14560
+ const len0 = WASM_VECTOR_LEN;
14561
+ const ret = wasm.bigquery_fingerprint(ptr0, len0);
14562
+ return BigInt.asUintN(64, ret);
14563
+ };
14564
+
14565
+ /**
14566
+ * @param {Uint8Array} input
14567
+ * @returns {bigint}
14568
+ */
14569
+ module.exports.bigquery_fingerprint = function(input) {
14570
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
14571
+ const len0 = WASM_VECTOR_LEN;
14572
+ const ret = wasm.bigquery_fingerprint(ptr0, len0);
14573
+ return ret;
14574
+ };
14575
+
14576
+ /**
14577
+ * @param {Uint8Array} input
14578
+ * @returns {number}
14579
+ */
14580
+ module.exports.hash32 = function(input) {
14581
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
14582
+ const len0 = WASM_VECTOR_LEN;
14583
+ const ret = wasm.hash32(ptr0, len0);
14584
+ return ret >>> 0;
14585
+ };
14586
+
14587
+ /**
14588
+ * @param {Uint8Array} input
14589
+ * @param {number} seed
14590
+ * @returns {number}
14591
+ */
14592
+ module.exports.hash32_with_seed = function(input, seed) {
14593
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
14594
+ const len0 = WASM_VECTOR_LEN;
14595
+ const ret = wasm.hash32_with_seed(ptr0, len0, seed);
14596
+ return ret >>> 0;
14597
+ };
14598
+
14599
+ /**
14600
+ * @param {Uint8Array} input
14601
+ * @returns {bigint}
14602
+ */
14603
+ module.exports.hash64 = function(input) {
14604
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
14605
+ const len0 = WASM_VECTOR_LEN;
14606
+ const ret = wasm.hash64(ptr0, len0);
14607
+ return BigInt.asUintN(64, ret);
14608
+ };
14609
+
14610
+ /**
14611
+ * @param {Uint8Array} input
14612
+ * @param {bigint} seed
14613
+ * @returns {bigint}
14614
+ */
14615
+ module.exports.hash64_with_seed = function(input, seed) {
14616
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
14617
+ const len0 = WASM_VECTOR_LEN;
14618
+ const ret = wasm.hash64_with_seed(ptr0, len0, seed);
14619
+ return BigInt.asUintN(64, ret);
14620
+ };
14621
+
14622
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
14623
+
14624
+ cachedTextDecoder.decode();
14625
+
14626
+ function getStringFromWasm0(ptr, len) {
14627
+ ptr = ptr >>> 0;
14628
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
14629
+ }
14630
+
14631
+ function addHeapObject(obj) {
14632
+ if (heap_next === heap.length) heap.push(heap.length + 1);
14633
+ const idx = heap_next;
14634
+ heap_next = heap[idx];
14635
+
14636
+ heap[idx] = obj;
14637
+ return idx;
14638
+ }
14639
+
14640
+ let cachedTextEncoder = new TextEncoder('utf-8');
14641
+
14642
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
14643
+ ? function (arg, view) {
14644
+ return cachedTextEncoder.encodeInto(arg, view);
14645
+ }
14646
+ : function (arg, view) {
14647
+ const buf = cachedTextEncoder.encode(arg);
14648
+ view.set(buf);
14649
+ return {
14650
+ read: arg.length,
14651
+ written: buf.length
14652
+ };
14653
+ });
14654
+
14655
+ function passStringToWasm0(arg, malloc, realloc) {
14656
+
14657
+ if (realloc === undefined) {
14658
+ const buf = cachedTextEncoder.encode(arg);
14659
+ const ptr = malloc(buf.length, 1) >>> 0;
14660
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
14661
+ WASM_VECTOR_LEN = buf.length;
14662
+ return ptr;
14663
+ }
14664
+
14665
+ let len = arg.length;
14666
+ let ptr = malloc(len, 1) >>> 0;
14667
+
14668
+ const mem = getUint8Memory0();
14669
+
14670
+ let offset = 0;
14671
+
14672
+ for (; offset < len; offset++) {
14673
+ const code = arg.charCodeAt(offset);
14674
+ if (code > 0x7F) break;
14675
+ mem[ptr + offset] = code;
14676
+ }
14677
+
14678
+ if (offset !== len) {
14679
+ if (offset !== 0) {
14680
+ arg = arg.slice(offset);
14681
+ }
14682
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
14683
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
14684
+ const ret = encodeString(arg, view);
14685
+
14686
+ offset += ret.written;
14687
+ }
14688
+
14689
+ WASM_VECTOR_LEN = offset;
14690
+ return ptr;
14691
+ }
14692
+
14693
+ let cachedInt32Memory0 = null;
14694
+
14695
+ function getInt32Memory0() {
14696
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
14697
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
14698
+ }
14699
+ return cachedInt32Memory0;
14700
+ }
14701
+
14702
+ module.exports.__wbg_new_abda76e883ba8a5f = function() {
14703
+ const ret = new Error();
14704
+ return addHeapObject(ret);
14705
+ };
14706
+
14707
+ module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
14708
+ const ret = getObject(arg1).stack;
14709
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
14710
+ const len1 = WASM_VECTOR_LEN;
14711
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
14712
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
14713
+ };
14714
+
14715
+ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
14716
+ let deferred0_0;
14717
+ let deferred0_1;
14718
+ try {
14719
+ deferred0_0 = arg0;
14720
+ deferred0_1 = arg1;
14721
+ console.error(getStringFromWasm0(arg0, arg1));
14722
+ } finally {
14723
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
14724
+ }
14725
+ };
14726
+
14727
+ module.exports.__wbindgen_object_drop_ref = function(arg0) {
14728
+ takeObject(arg0);
14729
+ };
14730
+
14731
+ const path = require$$1.join(__dirname, 'farmhash_modern_bg.wasm');
14732
+ const bytes = require$$2.readFileSync(path);
14733
+
14734
+ const wasmModule = new WebAssembly.Module(bytes);
14735
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
14736
+ wasm = wasmInstance.exports;
14737
+ module.exports.__wasm = wasm;
14738
+ } (farmhash_modern));
14739
+
14740
+ var farmhash_modernExports = farmhash_modern.exports;
14741
+
14742
+ function asBuffer(input) {
14743
+ if (typeof input === 'string') {
14744
+ return new TextEncoder().encode(input);
14745
+ }
14746
+ if (input instanceof Uint8Array) {
14747
+ return input;
14748
+ }
14749
+ throw new Error('Expected input to be a string or Uint8Array');
14750
+ }
14751
+ /**
14752
+ * Create a new farmhash based u32 for a string or an array of bytes.
14753
+ * Fingerprint value should be portable and stable across library versions
14754
+ * and platforms.
14755
+ */
14756
+ function fingerprint32(input) {
14757
+ return farmhash_modernExports.fingerprint32(asBuffer(input));
14758
+ }
14759
+
14760
+ class KokimokiLocalStore extends KokimokiStore {
14761
+ localRoomName;
14762
+ _stateKey;
14763
+ get stateKey() {
14764
+ if (!this._stateKey) {
14765
+ throw new Error("Not initialized");
14766
+ }
14767
+ return this._stateKey;
14768
+ }
14769
+ constructor(localRoomName, schema) {
14770
+ super(`/l/${localRoomName}`, schema, RoomSubscriptionMode.ReadWrite);
14771
+ this.localRoomName = localRoomName;
14772
+ // Synchronize doc changes to local storage
14773
+ // TODO: maybe do not serialize full state every time
14774
+ this.doc.on("update", () => {
14775
+ const value = encodeStateAsUpdate(this.doc);
14776
+ const valueString = String.fromCharCode(...value);
14777
+ const valueBase64 = btoa(valueString);
14778
+ localStorage.setItem(this.stateKey, valueBase64);
14779
+ });
14780
+ }
14781
+ getInitialUpdate(appId, clientId) {
14782
+ this._stateKey = `${appId}/${clientId}/${this.localRoomName}`;
14783
+ // get initial update from local storage
14784
+ let initialUpdate = undefined;
14785
+ const state = localStorage.getItem(this.stateKey);
14786
+ if (state) {
14787
+ const valueString = atob(state);
14788
+ initialUpdate = Uint8Array.from(valueString, (c) => c.charCodeAt(0));
14789
+ }
14790
+ return {
14791
+ roomHash: fingerprint32(this.roomName),
14792
+ initialUpdate,
14793
+ };
14794
+ }
14795
+ }
14796
+
12226
14797
  class KokimokiClient extends EventEmitter$1 {
12227
14798
  host;
12228
14799
  appId;
@@ -12663,7 +15234,13 @@ class KokimokiClient extends EventEmitter$1 {
12663
15234
  }
12664
15235
  // Send subscription request if connected to server
12665
15236
  if (!subscription.joined) {
12666
- const res = await this.sendSubscribeReq(store.roomName, store.mode);
15237
+ let res;
15238
+ if (store instanceof KokimokiLocalStore) {
15239
+ res = store.getInitialUpdate(this.appId, this.id);
15240
+ }
15241
+ else {
15242
+ res = await this.sendSubscribeReq(store.roomName, store.mode);
15243
+ }
12667
15244
  this._subscriptionsByHash.set(res.roomHash, subscription);
12668
15245
  await subscription.applyInitialResponse(res.roomHash, res.initialUpdate);
12669
15246
  // Trigger onJoin event
@@ -12683,55 +15260,76 @@ class KokimokiClient extends EventEmitter$1 {
12683
15260
  }
12684
15261
  }
12685
15262
  async transact(handler) {
12686
- if (!this._connected) {
12687
- throw new Error("Client not connected");
12688
- }
15263
+ // if (!this._connected) {
15264
+ // throw new Error("Client not connected");
15265
+ // }
12689
15266
  const transaction = new KokimokiTransaction(this);
12690
15267
  await handler(transaction);
12691
15268
  const { updates, consumedMessages } = await transaction.getUpdates();
12692
15269
  if (!updates.length) {
12693
15270
  return;
12694
15271
  }
12695
- // Construct buffer
12696
- const writer = new WsMessageWriter();
15272
+ // Construct buffers
15273
+ const remoteUpdateWriter = new WsMessageWriter();
15274
+ const localUpdateWriter = new WsMessageWriter();
12697
15275
  // Write message type
12698
- writer.writeInt32(WsMessageType.Transaction);
15276
+ remoteUpdateWriter.writeInt32(WsMessageType.Transaction);
12699
15277
  // Update and write transaction ID
12700
15278
  const transactionId = ++this._messageId;
12701
- writer.writeInt32(transactionId);
12702
- // Write room hashes where messages were consumed
12703
- writer.writeInt32(consumedMessages.size);
15279
+ remoteUpdateWriter.writeInt32(transactionId);
15280
+ localUpdateWriter.writeInt32(transactionId);
15281
+ // Write room hashes where messages were consumed (remote only)
15282
+ remoteUpdateWriter.writeInt32(consumedMessages.size);
12704
15283
  for (const roomName of consumedMessages) {
12705
15284
  const subscription = this._subscriptionsByName.get(roomName);
12706
15285
  if (!subscription) {
12707
15286
  throw new Error(`Cannot consume message in "${roomName}" because it hasn't been joined`);
12708
15287
  }
12709
- writer.writeUint32(subscription.roomHash);
15288
+ remoteUpdateWriter.writeUint32(subscription.roomHash);
12710
15289
  }
12711
15290
  // Write updates
15291
+ let localUpdates = 0, remoteUpdates = 0;
12712
15292
  for (const { roomName, update } of updates) {
12713
15293
  const subscription = this._subscriptionsByName.get(roomName);
12714
15294
  if (!subscription) {
12715
15295
  throw new Error(`Cannot send update to "${roomName}" because it hasn't been joined`);
12716
15296
  }
12717
- writer.writeUint32(subscription.roomHash);
12718
- writer.writeUint8Array(update);
12719
- }
12720
- const buffer = writer.getBuffer();
12721
- // Wait for server to apply transaction
12722
- await new Promise((resolve, reject) => {
12723
- this._transactionPromises.set(transactionId, { resolve, reject });
12724
- // Send update to server
12725
- try {
12726
- this.ws.send(buffer);
15297
+ if (subscription.store instanceof KokimokiLocalStore) {
15298
+ localUpdates++;
15299
+ localUpdateWriter.writeUint32(subscription.roomHash);
15300
+ localUpdateWriter.writeUint8Array(update);
12727
15301
  }
12728
- catch (e) {
12729
- // Not connected
12730
- console.log("Failed to send update to server:", e);
12731
- // TODO: merge updates or something
12732
- throw e;
15302
+ else {
15303
+ remoteUpdates++;
15304
+ remoteUpdateWriter.writeUint32(subscription.roomHash);
15305
+ remoteUpdateWriter.writeUint8Array(update);
12733
15306
  }
12734
- });
15307
+ }
15308
+ // Wait for server to apply transaction
15309
+ if (remoteUpdates) {
15310
+ const remoteBuffer = remoteUpdateWriter.getBuffer();
15311
+ await new Promise((resolve, reject) => {
15312
+ this._transactionPromises.set(transactionId, { resolve, reject });
15313
+ // Send update to server
15314
+ try {
15315
+ this.ws.send(remoteBuffer);
15316
+ }
15317
+ catch (e) {
15318
+ // Not connected
15319
+ console.log("Failed to send update to server:", e);
15320
+ // Delete transaction promise
15321
+ this._transactionPromises.delete(transactionId);
15322
+ // TODO: merge updates or something
15323
+ reject(e);
15324
+ }
15325
+ });
15326
+ }
15327
+ // Apply local updates
15328
+ if (localUpdates) {
15329
+ const localBuffer = localUpdateWriter.getBuffer();
15330
+ const reader = new WsMessageReader(localBuffer);
15331
+ this.handleRoomUpdateMessage(reader);
15332
+ }
12735
15333
  }
12736
15334
  async close() {
12737
15335
  this._autoReconnect = false;
@@ -12761,6 +15359,14 @@ class KokimokiClient extends EventEmitter$1 {
12761
15359
  }
12762
15360
  return store;
12763
15361
  }
15362
+ // local store
15363
+ localStore(name, schema) {
15364
+ const store = new KokimokiLocalStore(name, schema);
15365
+ this.join(store)
15366
+ .then(() => { })
15367
+ .catch(() => { });
15368
+ return store;
15369
+ }
12764
15370
  // queue
12765
15371
  queue(name, schema, mode, autoJoin = true) {
12766
15372
  const queue = new KokimokiQueue(name, schema, mode);