securemark 0.262.0 → 0.262.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.262.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.262.2 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory(require("DOMPurify"), require("Prism"));
@@ -130,7 +130,7 @@ function push(as, bs) {
130
130
  if (bs.length === 1) return as.push(bs[0]), as;
131
131
  if (global_1.Symbol.iterator in bs && bs.length > 50) return as.push(...bs), as;
132
132
 
133
- for (let i = 0, len = bs.length; i < len; ++i) {
133
+ for (let len = bs.length, i = 0; i < len; ++i) {
134
134
  as.push(bs[i]);
135
135
  }
136
136
  } else {
@@ -178,7 +178,28 @@ function splice(as, index, count, ...values) {
178
178
  return push(as, values), [];
179
179
  }
180
180
 
181
- return arguments.length > 2 ? as.splice(index, count, ...values) : as.splice(index);
181
+ switch (values.length) {
182
+ case 0:
183
+ return count !== undefined || arguments.length > 1 ? as.splice(index, count) : as.splice(index);
184
+
185
+ case 1:
186
+ return as.splice(index, count, values[0]);
187
+
188
+ case 2:
189
+ return as.splice(index, count, values[0], values[1]);
190
+
191
+ case 3:
192
+ return as.splice(index, count, values[0], values[1], values[2]);
193
+
194
+ case 4:
195
+ return as.splice(index, count, values[0], values[1], values[2], values[3]);
196
+
197
+ case 5:
198
+ return as.splice(index, count, values[0], values[1], values[2], values[3], values[4]);
199
+
200
+ default:
201
+ return count !== undefined || arguments.length > 1 ? as.splice(index, count, ...values) : as.splice(index);
202
+ }
182
203
  }
183
204
 
184
205
  exports.splice = splice;
@@ -406,6 +427,7 @@ class Cache {
406
427
  if (this.window * 1000 >= this.capacity === false) throw new Error(`Spica: Cache: Window must be 0.1% of capacity or more.`);
407
428
  this.block = settings.block;
408
429
  this.limit = settings.limit;
430
+ this.age = settings.age;
409
431
  this.earlyExpiring = settings.earlyExpiring;
410
432
  this.disposer = settings.disposer;
411
433
  this.stats = new Stats(this.window, settings.resolution, settings.offset);
@@ -424,7 +446,12 @@ class Cache {
424
446
  const index = node.value;
425
447
  callback &&= !!this.disposer;
426
448
  this.overlap -= +(index.region === 'LFU' && node.list === this.indexes.LRU);
427
- index.enode && this.expiries.delete(index.enode);
449
+
450
+ if (index.enode) {
451
+ this.expiries.delete(index.enode);
452
+ index.enode = void 0;
453
+ }
454
+
428
455
  node.delete();
429
456
  this.memory.delete(index.key);
430
457
  this.SIZE -= index.size;
@@ -486,14 +513,18 @@ class Cache {
486
513
 
487
514
  put(key, value, {
488
515
  size = 1,
489
- age = this.settings.age
516
+ age = this.age
490
517
  } = {}) {
491
518
  if (size < 1 || this.capacity < size || age <= 0) {
492
519
  this.disposer?.(value, key);
493
520
  return false;
494
521
  }
495
522
 
496
- const expiry = age === global_1.Infinity ? global_1.Infinity : (0, clock_1.now)() + age;
523
+ if (age === global_1.Infinity) {
524
+ age = 0;
525
+ }
526
+
527
+ const expiry = age ? (0, clock_1.now)() + age : global_1.Infinity;
497
528
  const node = this.memory.get(key);
498
529
 
499
530
  if (node && this.ensure(size, node)) {
@@ -503,7 +534,7 @@ class Cache {
503
534
  index.size = size;
504
535
  index.expiry = expiry;
505
536
 
506
- if (this.earlyExpiring && expiry !== global_1.Infinity) {
537
+ if (this.earlyExpiring && age) {
507
538
  index.enode ? this.expiries.update(index.enode, expiry) : index.enode = this.expiries.insert(node, expiry);
508
539
  } else if (index.enode) {
509
540
  this.expiries.delete(index.enode);
@@ -528,7 +559,7 @@ class Cache {
528
559
  region: 'LRU'
529
560
  }));
530
561
 
531
- if (this.earlyExpiring && expiry !== global_1.Infinity) {
562
+ if (this.earlyExpiring && age) {
532
563
  LRU.head.value.enode = this.expiries.insert(LRU.head, expiry);
533
564
  }
534
565
 
@@ -772,7 +803,7 @@ function rate(window, hits1, hits2, offset) {
772
803
  let hits = 0;
773
804
  let ratio = 100;
774
805
 
775
- for (let i = 0, len = hits1.length; i < len; ++i) {
806
+ for (let len = hits1.length, i = 0; i < len; ++i) {
776
807
  const subtotal = hits1[i] + hits2[i];
777
808
  if (subtotal === 0) continue;
778
809
  offset = i + 1 === len ? 0 : offset;
@@ -873,110 +904,6 @@ exports.equal = equal;
873
904
 
874
905
  /***/ }),
875
906
 
876
- /***/ 5084:
877
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
878
-
879
- "use strict";
880
-
881
-
882
- Object.defineProperty(exports, "__esModule", ({
883
- value: true
884
- }));
885
- exports.MultiMap = void 0;
886
-
887
- const global_1 = __webpack_require__(4128);
888
-
889
- const ring_1 = __webpack_require__(6395);
890
-
891
- class MultiMap {
892
- constructor(entries = [], memory = new global_1.Map()) {
893
- this.memory = memory;
894
-
895
- for (const {
896
- 0: k,
897
- 1: v
898
- } of entries) {
899
- this.set(k, v);
900
- }
901
- }
902
-
903
- get(key) {
904
- return this.memory.get(key)?.at(0);
905
- }
906
-
907
- getAll(key) {
908
- return this.memory.get(key);
909
- }
910
-
911
- set(key, val) {
912
- let vs = this.memory.get(key);
913
- if (vs) return vs.push(val), this;
914
- vs = new ring_1.Ring();
915
- vs.push(val);
916
- this.memory.set(key, vs);
917
- return this;
918
- }
919
-
920
- has(key, value) {
921
- const vs = this.memory.get(key);
922
- if (!vs?.length) return false;
923
- if (arguments.length < 2) return true;
924
- return vs.includes(value);
925
- }
926
-
927
- delete(key, value) {
928
- if (arguments.length < 2) return this.memory.delete(key);
929
- const vs = this.memory.get(key);
930
- if (!vs?.length) return false;
931
- const i = vs.indexOf(value);
932
- if (i === -1) return false;
933
- vs.splice(i, 1);
934
- return true;
935
- }
936
-
937
- clear() {
938
- this.memory.clear();
939
- }
940
-
941
- take(key, count) {
942
- const vs = this.memory.get(key);
943
- if (count === void 0) return vs?.shift();
944
- const acc = [];
945
-
946
- while (vs?.length && count--) {
947
- acc.push(vs.shift());
948
- }
949
-
950
- return acc;
951
- }
952
-
953
- ref(key) {
954
- let vs = this.memory.get(key);
955
- if (vs) return vs;
956
- vs = new ring_1.Ring();
957
- this.memory.set(key, vs);
958
- return vs;
959
- }
960
-
961
- *[Symbol.iterator]() {
962
- for (const {
963
- 0: k,
964
- 1: vs
965
- } of this.memory) {
966
- for (let i = 0; i < vs.length; ++i) {
967
- yield [k, vs.at(i)];
968
- }
969
- }
970
-
971
- return;
972
- }
973
-
974
- }
975
-
976
- exports.MultiMap = MultiMap;
977
-
978
- /***/ }),
979
-
980
907
  /***/ 8099:
981
908
  /***/ ((__unused_webpack_module, exports) => {
982
909
 
@@ -1282,6 +1209,10 @@ class Heap {
1282
1209
  sort(this.cmp, array, node[2], this.$length, this.stable);
1283
1210
  }
1284
1211
 
1212
+ find(order) {
1213
+ return this.array.find(node => node && node[0] === order);
1214
+ }
1215
+
1285
1216
  clear() {
1286
1217
  this.array = (0, global_1.Array)(size);
1287
1218
  this.$length = 0;
@@ -1300,7 +1231,7 @@ class MultiHeap {
1300
1231
  this.cmp = cmp;
1301
1232
  this.clean = clean;
1302
1233
  this.heap = new Heap(this.cmp);
1303
- this.dict = new Map();
1234
+ this.dict = new global_1.Map();
1304
1235
  this.list = (0, memoize_1.memoize)(order => {
1305
1236
  const list = new invlist_1.List();
1306
1237
  list[MultiHeap.order] = order;
@@ -1328,8 +1259,7 @@ class MultiHeap {
1328
1259
  }
1329
1260
 
1330
1261
  ++this.$length;
1331
- const list = this.list(order);
1332
- return [order, list.push(value)];
1262
+ return this.list(order).push(value);
1333
1263
  }
1334
1264
 
1335
1265
  extract() {
@@ -1347,35 +1277,37 @@ class MultiHeap {
1347
1277
  }
1348
1278
 
1349
1279
  delete(node) {
1350
- if (!node[1].list) throw new Error('Invalid node');
1351
- const {
1352
- 0: order,
1353
- 1: lnode
1354
- } = node;
1280
+ const list = node.list;
1281
+ if (!list) throw new Error('Invalid node');
1355
1282
  --this.$length;
1356
1283
 
1357
- if (lnode.list.length === 1) {
1358
- this.heap.delete(lnode[MultiHeap.heap]);
1359
- this.clean && this.dict.delete(order);
1284
+ if (list.length === 1) {
1285
+ this.heap.delete(list[MultiHeap.heap]);
1286
+ this.clean && this.dict.delete(list[MultiHeap.order]);
1360
1287
  }
1361
1288
 
1362
- return lnode.delete();
1289
+ return node.delete();
1363
1290
  }
1364
1291
 
1365
1292
  update(node, order, value) {
1366
- if (!node[1].list) throw new Error('Invalid node');
1293
+ const list = node.list;
1294
+ if (!list) throw new Error('Invalid node');
1367
1295
 
1368
1296
  if (arguments.length < 2) {
1369
- order = node[0];
1297
+ order = list[MultiHeap.order];
1370
1298
  }
1371
1299
 
1372
1300
  if (arguments.length > 2) {
1373
- node[1].value = value;
1301
+ node.value = value;
1374
1302
  }
1375
1303
 
1376
- if (this.cmp(node[0], order) === 0) return node;
1304
+ if (this.cmp(list[MultiHeap.order], order) === 0) return node;
1377
1305
  this.delete(node);
1378
- return this.insert(node[1].value, order);
1306
+ return this.insert(node.value, order);
1307
+ }
1308
+
1309
+ find(order) {
1310
+ return this.dict.get(order);
1379
1311
  }
1380
1312
 
1381
1313
  clear() {
@@ -1491,23 +1423,20 @@ __exportStar(__webpack_require__(2310), exports);
1491
1423
  "use strict";
1492
1424
  // Circular Inverse List
1493
1425
 
1494
- var _a;
1495
-
1496
1426
  Object.defineProperty(exports, "__esModule", ({
1497
1427
  value: true
1498
1428
  }));
1499
1429
  exports.List = void 0;
1500
1430
  const undefined = void 0;
1501
- const LENGTH = Symbol('length');
1502
1431
 
1503
1432
  class List {
1504
1433
  constructor() {
1505
- this[_a] = 0;
1434
+ this.$length = 0;
1506
1435
  this.head = undefined;
1507
1436
  }
1508
1437
 
1509
1438
  get length() {
1510
- return this[LENGTH];
1439
+ return this.$length;
1511
1440
  }
1512
1441
 
1513
1442
  get tail() {
@@ -1520,7 +1449,7 @@ class List {
1520
1449
 
1521
1450
  clear() {
1522
1451
  this.head = undefined;
1523
- this[LENGTH] = 0;
1452
+ this.$length = 0;
1524
1453
  }
1525
1454
 
1526
1455
  unshift(value) {
@@ -1566,7 +1495,7 @@ class List {
1566
1495
  insert(node, before = this.head) {
1567
1496
  if (node.list === this) return node.moveTo(before), node;
1568
1497
  node.delete();
1569
- ++this[LENGTH];
1498
+ ++this.$length;
1570
1499
  this.head ??= node; // @ts-expect-error
1571
1500
 
1572
1501
  node.list = this;
@@ -1576,11 +1505,43 @@ class List {
1576
1505
  return node;
1577
1506
  }
1578
1507
 
1579
- *[(_a = LENGTH, Symbol.iterator)]() {
1580
- for (let node = this.head; node;) {
1508
+ find(f) {
1509
+ for (let head = this.head, node = head; node;) {
1510
+ if (f(node.value)) return node;
1511
+ node = node.next;
1512
+ if (node === head) break;
1513
+ }
1514
+ }
1515
+
1516
+ toNodes() {
1517
+ const acc = [];
1518
+
1519
+ for (let head = this.head, node = head; node;) {
1520
+ acc.push(node);
1521
+ node = node.next;
1522
+ if (node === head) break;
1523
+ }
1524
+
1525
+ return acc;
1526
+ }
1527
+
1528
+ toArray() {
1529
+ const acc = [];
1530
+
1531
+ for (let head = this.head, node = head; node;) {
1532
+ acc.push(node.value);
1533
+ node = node.next;
1534
+ if (node === head) break;
1535
+ }
1536
+
1537
+ return acc;
1538
+ }
1539
+
1540
+ *[Symbol.iterator]() {
1541
+ for (let head = this.head, node = head; node;) {
1581
1542
  yield node.value;
1582
1543
  node = node.next;
1583
- if (node === this.head) return;
1544
+ if (node === head) return;
1584
1545
  }
1585
1546
  }
1586
1547
 
@@ -1594,14 +1555,14 @@ class Node {
1594
1555
  this.value = value;
1595
1556
  this.next = next;
1596
1557
  this.prev = prev;
1597
- ++list[LENGTH];
1558
+ ++list.$length;
1598
1559
  list.head ??= this;
1599
1560
  next && prev ? next.prev = prev.next = this : this.next = this.prev = this;
1600
1561
  }
1601
1562
 
1602
1563
  delete() {
1603
1564
  if (!this.list) return this.value;
1604
- --this.list[LENGTH];
1565
+ --this.list.$length;
1605
1566
  const {
1606
1567
  next,
1607
1568
  prev
@@ -1709,26 +1670,25 @@ const undefined = void 0;
1709
1670
 
1710
1671
  function memoize(f, identify = (...as) => as[0], memory) {
1711
1672
  if (typeof identify === 'object') return memoize(f, undefined, identify);
1712
- if (memory === undefined) return memoize(f, identify, new global_1.Map());
1713
- if ((0, alias_1.isArray)(memory)) return memoize(f, identify, {
1714
- has(key) {
1715
- return memory[key] !== undefined;
1716
- },
1717
-
1718
- get(key) {
1719
- return memory[key];
1720
- },
1673
+ return (0, alias_1.isArray)(memory) ? memoizeArray(f, identify, memory) : memoizeObject(f, identify, memory ?? new global_1.Map());
1674
+ }
1721
1675
 
1722
- set(key, value) {
1723
- memory[key] = value;
1724
- return this;
1725
- },
1676
+ exports.memoize = memoize;
1726
1677
 
1727
- delete() {
1728
- throw 0;
1729
- }
1678
+ function memoizeArray(f, identify, memory) {
1679
+ let nullish = false;
1680
+ return (...as) => {
1681
+ const b = identify(...as);
1682
+ let z = memory[b];
1683
+ if (z !== undefined || nullish && memory[b] !== undefined) return z;
1684
+ z = f(...as);
1685
+ nullish ||= z === undefined;
1686
+ memory[b] = z;
1687
+ return z;
1688
+ };
1689
+ }
1730
1690
 
1731
- });
1691
+ function memoizeObject(f, identify, memory) {
1732
1692
  let nullish = false;
1733
1693
  return (...as) => {
1734
1694
  const b = identify(...as);
@@ -1741,8 +1701,6 @@ function memoize(f, identify = (...as) => as[0], memory) {
1741
1701
  };
1742
1702
  }
1743
1703
 
1744
- exports.memoize = memoize;
1745
-
1746
1704
  function reduce(f, identify = (...as) => as[0]) {
1747
1705
  let key = {};
1748
1706
  let val;
@@ -1762,43 +1720,6 @@ exports.reduce = reduce;
1762
1720
 
1763
1721
  /***/ }),
1764
1722
 
1765
- /***/ 940:
1766
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1767
-
1768
- "use strict";
1769
-
1770
-
1771
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
1772
- if (k2 === undefined) k2 = k;
1773
- var desc = Object.getOwnPropertyDescriptor(m, k);
1774
-
1775
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1776
- desc = {
1777
- enumerable: true,
1778
- get: function () {
1779
- return m[k];
1780
- }
1781
- };
1782
- }
1783
-
1784
- Object.defineProperty(o, k2, desc);
1785
- } : function (o, m, k, k2) {
1786
- if (k2 === undefined) k2 = k;
1787
- o[k2] = m[k];
1788
- });
1789
-
1790
- var __exportStar = this && this.__exportStar || function (m, exports) {
1791
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1792
- };
1793
-
1794
- Object.defineProperty(exports, "__esModule", ({
1795
- value: true
1796
- }));
1797
-
1798
- __exportStar(__webpack_require__(5084), exports);
1799
-
1800
- /***/ }),
1801
-
1802
1723
  /***/ 4934:
1803
1724
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1804
1725
 
@@ -1808,7 +1729,7 @@ __exportStar(__webpack_require__(5084), exports);
1808
1729
  Object.defineProperty(exports, "__esModule", ({
1809
1730
  value: true
1810
1731
  }));
1811
- exports.PriorityQueue = exports.Queue = void 0;
1732
+ exports.MultiQueue = exports.PriorityQueue = exports.Queue = void 0;
1812
1733
 
1813
1734
  const global_1 = __webpack_require__(4128);
1814
1735
 
@@ -1938,7 +1859,7 @@ class FixedQueue {
1938
1859
  class PriorityQueue {
1939
1860
  constructor(cmp = PriorityQueue.max, clean = true) {
1940
1861
  this.clean = clean;
1941
- this.dict = new Map();
1862
+ this.dict = new global_1.Map();
1942
1863
  this.queue = (0, memoize_1.memoize)(priority => {
1943
1864
  const queue = new Queue();
1944
1865
  queue[PriorityQueue.priority] = priority;
@@ -1957,22 +1878,22 @@ class PriorityQueue {
1957
1878
  return this.$length === 0;
1958
1879
  }
1959
1880
 
1960
- peek() {
1961
- return this.heap.peek()?.peek();
1881
+ peek(priority) {
1882
+ return arguments.length === 0 ? this.heap.peek()?.peek() : this.dict.get(priority)?.peek();
1962
1883
  }
1963
1884
 
1964
- push(value, priority) {
1885
+ push(priority, value) {
1965
1886
  ++this.$length;
1966
1887
  this.queue(priority).push(value);
1967
1888
  }
1968
1889
 
1969
- pop() {
1890
+ pop(priority) {
1970
1891
  if (this.$length === 0) return;
1971
1892
  --this.$length;
1972
- const queue = this.heap.peek();
1973
- const value = queue.pop();
1893
+ const queue = arguments.length === 0 ? this.heap.peek() : this.dict.get(priority);
1894
+ const value = queue?.pop();
1974
1895
 
1975
- if (queue.isEmpty()) {
1896
+ if (queue?.isEmpty()) {
1976
1897
  this.heap.extract();
1977
1898
  this.clean && this.dict.delete(queue[PriorityQueue.priority]);
1978
1899
  }
@@ -2001,6 +1922,103 @@ PriorityQueue.priority = Symbol('priority');
2001
1922
  PriorityQueue.max = heap_1.Heap.max;
2002
1923
  PriorityQueue.min = heap_1.Heap.min;
2003
1924
 
1925
+ class MultiQueue {
1926
+ constructor(entries) {
1927
+ this.dict = new global_1.Map();
1928
+ if (entries) for (const {
1929
+ 0: k,
1930
+ 1: v
1931
+ } of entries) {
1932
+ this.set(k, v);
1933
+ }
1934
+ }
1935
+
1936
+ get length() {
1937
+ return this.dict.size;
1938
+ }
1939
+
1940
+ isEmpty() {
1941
+ return this.dict.size === 0;
1942
+ }
1943
+
1944
+ peek(key) {
1945
+ return this.dict.get(key)?.peek();
1946
+ }
1947
+
1948
+ push(key, value) {
1949
+ let vs = this.dict.get(key);
1950
+ if (vs) return void vs.push(value);
1951
+ vs = new Queue();
1952
+ vs.push(value);
1953
+ this.dict.set(key, vs);
1954
+ }
1955
+
1956
+ pop(key) {
1957
+ return this.dict.get(key)?.pop();
1958
+ }
1959
+
1960
+ clear() {
1961
+ this.dict = new global_1.Map();
1962
+ }
1963
+
1964
+ take(key, count) {
1965
+ if (count === void 0) return this.pop(key);
1966
+ const vs = this.dict.get(key);
1967
+ const acc = [];
1968
+
1969
+ while (vs && !vs.isEmpty() && count--) {
1970
+ acc.push(vs.pop());
1971
+ }
1972
+
1973
+ return acc;
1974
+ }
1975
+
1976
+ ref(key) {
1977
+ let vs = this.dict.get(key);
1978
+ if (vs) return vs;
1979
+ vs = new Queue();
1980
+ this.dict.set(key, vs);
1981
+ return vs;
1982
+ }
1983
+
1984
+ get size() {
1985
+ return this.length;
1986
+ }
1987
+
1988
+ get(key) {
1989
+ return this.peek(key);
1990
+ }
1991
+
1992
+ set(key, value) {
1993
+ this.push(key, value);
1994
+ return this;
1995
+ }
1996
+
1997
+ has(key) {
1998
+ return this.dict.has(key);
1999
+ }
2000
+
2001
+ delete(key) {
2002
+ return this.dict.delete(key);
2003
+ }
2004
+
2005
+ *[Symbol.iterator]() {
2006
+ for (const {
2007
+ 0: k,
2008
+ 1: vs
2009
+ } of this.dict) {
2010
+ while (!vs.isEmpty()) {
2011
+ yield [k, vs.pop()];
2012
+ }
2013
+ }
2014
+
2015
+ return;
2016
+ }
2017
+
2018
+ }
2019
+
2020
+ exports.MultiQueue = MultiQueue;
2021
+
2004
2022
  /***/ }),
2005
2023
 
2006
2024
  /***/ 7325:
@@ -2016,9 +2034,10 @@ exports.unique = exports.rndAf = exports.rndAP = exports.rnd0_ = exports.rnd0Z =
2016
2034
 
2017
2035
  const global_1 = __webpack_require__(4128);
2018
2036
 
2019
- const bases = [...Array(7)].map((_, i) => 1 << i);
2020
- const dict0_ = [...[...Array(36)].map((_, i) => i.toString(36)), ...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26), '-', '_'];
2021
- const dictAz = [...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26), ...[...Array(36)].map((_, i) => i.toString(36)).slice(-26)];
2037
+ const radixes = Object.freeze([...Array(7)].map((_, i) => 1 << i));
2038
+ const masks = Object.freeze(radixes.map(radix => radix - 1));
2039
+ const dict0_ = [...[...Array(36)].map((_, i) => i.toString(36)), ...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26), '-', '_'].join('');
2040
+ const dictAz = [...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26), ...[...Array(36)].map((_, i) => i.toString(36)).slice(-26)].join('');
2022
2041
  exports.rnd16 = cons(16);
2023
2042
  exports.rnd32 = cons(32);
2024
2043
  exports.rnd62 = cons(62);
@@ -2030,38 +2049,54 @@ exports.rnd0_ = conv(exports.rnd64, dict0_);
2030
2049
  exports.rndAP = conv(exports.rnd16, dictAz);
2031
2050
  exports.rndAf = conv(exports.rnd32, dictAz);
2032
2051
 
2033
- function unique(rnd, len, mem) {
2034
- const clear = !mem;
2052
+ function unique(rnd, len = 1, mem) {
2053
+ const independence = !mem;
2035
2054
  mem ??= new global_1.Set();
2036
- let limit = 5;
2037
- return () => {
2038
- while (true) {
2055
+ const trials = 3;
2056
+ let prefixes;
2057
+ let prefix = '';
2058
+ return function random() {
2059
+ for (let i = 0; i < trials; ++i) {
2060
+ const r = rnd(len);
2061
+ if (mem.has(r)) continue;
2062
+
2039
2063
  try {
2040
- for (let i = 0; i < limit; ++i) {
2041
- const r = rnd(len);
2042
- if (mem.has(r)) continue;
2043
- mem.add(r);
2044
- return r;
2064
+ mem.add(r);
2065
+ } catch (reason) {
2066
+ // ベンチマーク程度でもSetがパンクする場合がある。
2067
+ if (!independence) throw reason;
2068
+ prefixes ??= new global_1.Set();
2069
+ prefix ||= '?';
2070
+
2071
+ for (let i = 0; i < trials; ++i) {
2072
+ prefix = rnd(prefix.length);
2073
+ if (prefixes.has(prefix)) continue;
2074
+ prefixes.add(prefix);
2075
+ mem.clear();
2076
+ return random();
2045
2077
  }
2046
- } catch {}
2047
2078
 
2048
- clear && mem.clear();
2049
- ++len;
2050
- limit = len < 3 ? limit : 3;
2079
+ prefixes = new global_1.Set();
2080
+ prefix += '?';
2081
+ return random();
2082
+ }
2083
+
2084
+ return prefix + r;
2051
2085
  }
2086
+
2087
+ ++len;
2088
+ independence && mem.clear();
2089
+ return random();
2052
2090
  };
2053
2091
  }
2054
2092
 
2055
2093
  exports.unique = unique;
2056
2094
 
2057
- function cons(radix) {
2058
- const base = bases.find(base => base >= radix);
2059
- const len = bases.indexOf(base);
2060
- return () => {
2061
- while (true) {
2062
- const r = random(len);
2063
- if (r < radix) return r;
2064
- }
2095
+ function cons(size) {
2096
+ const len = radixes.findIndex(radix => radix >= size);
2097
+ return function rnd() {
2098
+ const r = random(len);
2099
+ return r < size ? r : rnd();
2065
2100
  };
2066
2101
  }
2067
2102
 
@@ -2079,7 +2114,6 @@ function conv(rnd, dict) {
2079
2114
 
2080
2115
  const buffer = new Uint16Array(512);
2081
2116
  const digit = 16;
2082
- const masks = bases.map((_, i) => +`0b${'1'.repeat(i) || 0}`);
2083
2117
  let index = buffer.length;
2084
2118
  let offset = digit;
2085
2119
 
@@ -2104,7 +2138,7 @@ function random(len) {
2104
2138
 
2105
2139
  /***/ }),
2106
2140
 
2107
- /***/ 6395:
2141
+ /***/ 5177:
2108
2142
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2109
2143
 
2110
2144
  "use strict";
@@ -2113,274 +2147,74 @@ function random(len) {
2113
2147
  Object.defineProperty(exports, "__esModule", ({
2114
2148
  value: true
2115
2149
  }));
2116
- exports.Ring = void 0;
2150
+ exports.isPrimitive = exports.is = exports.type = void 0;
2117
2151
 
2118
2152
  const global_1 = __webpack_require__(4128);
2119
2153
 
2120
2154
  const alias_1 = __webpack_require__(5406);
2121
2155
 
2122
- const array_1 = __webpack_require__(8112);
2123
-
2124
- const undefined = void 0;
2125
- const empty = Symbol('empty');
2126
-
2127
- const unempty = value => value === empty ? undefined : value;
2128
-
2129
- const space = Object.freeze((0, global_1.Array)(100).fill(empty));
2130
- let size = 16;
2131
-
2132
- class Ring {
2133
- constructor() {
2134
- this.array = (0, global_1.Array)(size);
2135
- this.head = 0;
2136
- this.tail = 0;
2137
- this.$length = 0;
2138
- this.excess = 0;
2139
- }
2140
-
2141
- get length() {
2142
- return this.$length;
2143
- }
2144
-
2145
- at(index) {
2146
- // Inline the code for optimization.
2147
- const array = this.array;
2148
-
2149
- if (index >= 0) {
2150
- if (index >= this.$length) return;
2151
- return unempty(array[(this.head - 1 + index) % array.length]);
2152
- } else {
2153
- if (-index > this.$length) return;
2154
- return this.tail + index >= 0 ? unempty(array[this.tail + index]) : unempty(array[array.length + this.tail + index]);
2155
- }
2156
- }
2157
-
2158
- replace(index, value, replacer) {
2159
- const array = this.array;
2160
-
2161
- if (index >= 0) {
2162
- if (index >= this.$length) throw new RangeError('Invalid index');
2163
- index = (this.head - 1 + index) % array.length;
2164
- } else {
2165
- if (-index > this.$length) throw new RangeError('Invalid index');
2166
- index = this.tail + index >= 0 ? this.tail + index : array.length + this.tail + index;
2167
- }
2168
-
2169
- const val = unempty(array[index]);
2170
- array[index] = replacer ? replacer(val, value) : value;
2171
- return val;
2172
- }
2173
-
2174
- push(value) {
2175
- const array = this.array;
2176
- let {
2177
- head,
2178
- tail
2179
- } = this;
2180
- tail = this.tail = next(head, tail, array.length);
2181
- head = this.head ||= tail;
2182
-
2183
- if (head === tail && this.$length !== 0) {
2184
- (0, array_1.splice)(array, tail - 1, 0, ...space);
2185
- head = this.head += space.length;
2186
- }
2187
-
2188
- array[tail - 1] = value;
2189
- ++this.$length;
2190
- }
2191
-
2192
- unshift(value) {
2193
- const array = this.array;
2194
- let {
2195
- head,
2196
- tail
2197
- } = this;
2198
- head = this.head = prev(head, tail, array.length);
2199
- tail = this.tail ||= head;
2200
-
2201
- if (head === tail && this.$length !== 0) {
2202
- (0, array_1.splice)(array, head, 0, ...space);
2203
- head = this.head += space.length;
2204
- }
2205
-
2206
- array[head - 1] = value;
2207
- ++this.$length;
2208
- }
2209
-
2210
- pop() {
2211
- if (this.$length === 0) return;
2212
- const array = this.array;
2213
- const i = this.tail - 1;
2214
- const value = unempty(array[i]);
2215
- array[i] = empty;
2216
- --this.$length === 0 ? this.head = this.tail = 0 : this.tail = this.tail === 1 ? array.length : this.tail - 1;
2217
- return value;
2218
- }
2219
-
2220
- shift() {
2221
- if (this.$length === 0) return;
2222
- const array = this.array;
2223
- const i = this.head - 1;
2224
- const value = unempty(array[i]);
2225
- array[i] = empty;
2226
- --this.$length === 0 ? this.head = this.tail = 0 : this.head = this.head === array.length ? 1 : this.head + 1;
2227
- return value;
2228
- }
2229
-
2230
- splice(index, count, ...values) {
2231
- const array = this.array;
2156
+ const ObjectPrototype = Object.prototype;
2157
+ const ArrayPrototype = Array.prototype;
2232
2158
 
2233
- if (this.excess > 100 && array.length - this.$length > 200) {
2234
- (0, array_1.splice)(array, 0, 100 - (0, array_1.splice)(array, this.tail, 100).length);
2235
- this.excess -= 100;
2236
- } else if (-this.excess > array.length * 2) {
2237
- this.excess = array.length;
2238
- }
2159
+ function type(value) {
2160
+ const type = typeof value;
2239
2161
 
2240
- index = index < 0 ? (0, alias_1.max)(0, this.$length + index) : index <= this.$length ? index : this.$length;
2241
- count = (0, alias_1.min)((0, alias_1.max)(count, 0), this.$length - index);
2162
+ switch (type) {
2163
+ case 'function':
2164
+ return 'Function';
2242
2165
 
2243
- if (values.length === 0) {
2244
- if (count === 0) return [];
2166
+ case 'object':
2167
+ if (value === null) return 'null';
2168
+ const tag = value[global_1.Symbol.toStringTag];
2169
+ if (tag) return tag;
2245
2170
 
2246
- switch (index) {
2247
- case 0:
2248
- if (count === 1) return [this.shift()];
2249
- break;
2171
+ switch ((0, alias_1.ObjectGetPrototypeOf)(value)) {
2172
+ case ArrayPrototype:
2173
+ return 'Array';
2250
2174
 
2251
- case this.$length - 1:
2252
- if (count === 1) return [this.pop()];
2253
- break;
2175
+ case ObjectPrototype:
2176
+ return 'Object';
2254
2177
 
2255
- case this.$length:
2256
- return [];
2178
+ default:
2179
+ return (0, alias_1.toString)(value).slice(8, -1);
2257
2180
  }
2258
- }
2259
-
2260
- index = (this.head || 1) - 1 + index;
2261
- index = index > array.length ? index % array.length : index;
2262
- this.excess += values.length - count;
2263
- this.$length += values.length - count; // |--H>*>T--|
2264
-
2265
- if (this.head <= this.tail) {
2266
- this.tail += values.length - count;
2267
- return (0, array_1.splice)(array, index, count, ...values);
2268
- } // |*>T---H>>|
2269
-
2270
-
2271
- if (index < this.tail) {
2272
- this.head += values.length - count;
2273
- this.tail += values.length - count;
2274
- return (0, array_1.splice)(array, index, count, ...values);
2275
- } // |>>T---H>*|
2276
-
2277
-
2278
- const cnt = (0, alias_1.min)(count, array.length - index);
2279
- const vs = (0, array_1.splice)(array, index, cnt, ...(0, array_1.splice)(values, 0, cnt));
2280
- vs.push(...(0, array_1.splice)(array, 0, count - vs.length, ...values));
2281
- return vs;
2282
- }
2283
-
2284
- clear() {
2285
- this.array = (0, global_1.Array)(size);
2286
- this.$length = this.head = this.tail = 0;
2287
- }
2288
-
2289
- includes(value) {
2290
- return this.array.includes(value);
2291
- }
2292
-
2293
- relational(index) {
2294
- if (index === -1) return -1;
2295
- return index + 1 >= this.head ? index + 1 - this.head : this.array.length - this.head + index;
2296
- }
2297
-
2298
- indexOf(value) {
2299
- return this.relational((0, array_1.indexOf)(this.array, value));
2300
- }
2301
-
2302
- findIndex(f) {
2303
- return this.relational(this.array.findIndex(value => value !== empty && f(value)));
2304
- }
2305
-
2306
- find(f) {
2307
- return unempty(this.array.find(value => value !== empty && f(value)));
2308
- }
2309
2181
 
2310
- toArray() {
2311
- return this.head <= this.tail ? this.array.slice((this.head || 1) - 1, this.tail) : this.array.slice((this.head || 1) - 1).concat(this.array.slice(0, this.tail));
2312
- }
2313
-
2314
- *[Symbol.iterator]() {
2315
- for (let i = 0; i < this.$length; ++i) {
2316
- yield this.at(i);
2317
- }
2318
-
2319
- return;
2182
+ default:
2183
+ return type;
2320
2184
  }
2321
-
2322
- }
2323
-
2324
- exports.Ring = Ring;
2325
-
2326
- function next(head, tail, length) {
2327
- return tail === length && head !== 1 ? 1 : tail + 1;
2328
2185
  }
2329
2186
 
2330
- function prev(head, tail, length) {
2331
- return head === 0 || head === 1 ? tail === length ? length + 1 : length : head - 1;
2332
- }
2333
-
2334
- /***/ }),
2335
-
2336
- /***/ 5177:
2337
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2338
-
2339
- "use strict";
2340
-
2341
-
2342
- Object.defineProperty(exports, "__esModule", ({
2343
- value: true
2344
- }));
2345
- exports.isPrimitive = exports.isType = exports.type = void 0;
2346
-
2347
- const global_1 = __webpack_require__(4128);
2187
+ exports.type = type;
2348
2188
 
2349
- const alias_1 = __webpack_require__(5406);
2189
+ function is(type, value) {
2190
+ switch (type) {
2191
+ case 'null':
2192
+ return value === null;
2350
2193
 
2351
- const ObjectPrototype = Object.prototype;
2352
- const ArrayPrototype = Array.prototype;
2194
+ case 'array':
2195
+ return (0, alias_1.isArray)(value);
2353
2196
 
2354
- function type(value) {
2355
- if (value === void 0) return 'undefined';
2356
- if (value === null) return 'null';
2357
- const type = typeof value;
2197
+ case 'object':
2198
+ return value !== null && typeof value === type;
2358
2199
 
2359
- if (type === 'object') {
2360
- if (value[global_1.Symbol.toStringTag]) return value[global_1.Symbol.toStringTag];
2361
- const proto = (0, alias_1.ObjectGetPrototypeOf)(value);
2362
- if (proto === ObjectPrototype) return 'Object';
2363
- if (proto === ArrayPrototype) return 'Array';
2364
- return (0, alias_1.toString)(value).slice(8, -1);
2200
+ default:
2201
+ return typeof value === type;
2365
2202
  }
2366
-
2367
- if (type === 'function') return 'Function';
2368
- return type;
2369
2203
  }
2370
2204
 
2371
- exports.type = type;
2205
+ exports.is = is;
2372
2206
 
2373
- function isType(value, name) {
2374
- if (name === 'object') return value !== null && typeof value === name;
2375
- if (name === 'function') return typeof value === name;
2376
- return type(value) === name;
2377
- }
2207
+ function isPrimitive(value) {
2208
+ switch (typeof value) {
2209
+ case 'function':
2210
+ return false;
2378
2211
 
2379
- exports.isType = isType;
2212
+ case 'object':
2213
+ return value === null;
2380
2214
 
2381
- function isPrimitive(value) {
2382
- const type = typeof value;
2383
- return type === 'object' || type === 'function' ? value === null : true;
2215
+ default:
2216
+ return true;
2217
+ }
2384
2218
  }
2385
2219
 
2386
2220
  exports.isPrimitive = isPrimitive;
@@ -2805,7 +2639,7 @@ const parser_1 = __webpack_require__(6728);
2805
2639
  function validate(patterns, has, parser) {
2806
2640
  if (typeof has === 'function') return validate(patterns, '', has);
2807
2641
  if (!(0, alias_1.isArray)(patterns)) return validate([patterns], has, parser);
2808
- const match = (0, global_1.Function)(['"use strict";', 'return source =>', '0', ...patterns.map(pattern => typeof pattern === 'string' ? `|| source.slice(0, ${pattern.length}) === '${pattern}'` : `|| /${pattern.source}/${pattern.flags}.test(source)`)].join(''))();
2642
+ const match = global_1.global.eval(['source =>', patterns.map(pattern => typeof pattern === 'string' ? `|| source.slice(0, ${pattern.length}) === '${pattern}'` : `|| /${pattern.source}/${pattern.flags}.test(source)`).join('').slice(2)].join(''));
2809
2643
  return ({
2810
2644
  source,
2811
2645
  context
@@ -4112,8 +3946,20 @@ function union(parsers) {
4112
3946
  case 1:
4113
3947
  return parsers[0];
4114
3948
 
3949
+ case 2:
3950
+ return input => parsers[0](input) ?? parsers[1](input);
3951
+
3952
+ case 3:
3953
+ return input => parsers[0](input) ?? parsers[1](input) ?? parsers[2](input);
3954
+
4115
3955
  default:
4116
- return (0, global_1.Function)('parsers', ['"use strict";', 'return (input, context) =>', '0', ...parsers.map((_, i) => `|| parsers[${i}](input, context)`)].join('\n'))(parsers);
3956
+ return input => {
3957
+ for (let i = 0; i < parsers.length; ++i) {
3958
+ const parser = parsers[i];
3959
+ const result = parser(input);
3960
+ if (result) return result;
3961
+ }
3962
+ };
4117
3963
  }
4118
3964
  }
4119
3965
 
@@ -7096,8 +6942,6 @@ const combinator_1 = __webpack_require__(2087);
7096
6942
 
7097
6943
  const dom_1 = __webpack_require__(3252);
7098
6944
 
7099
- const query_1 = __webpack_require__(6120);
7100
-
7101
6945
  function indexee(parser, optional) {
7102
6946
  return (0, combinator_1.fmap)(parser, ([el], _, {
7103
6947
  id
@@ -7122,7 +6966,7 @@ function text(source, optional = false) {
7122
6966
  if (index) return index;
7123
6967
  const target = source.cloneNode(true);
7124
6968
 
7125
- for (let es = (0, query_1.querySelectorAll)(target, 'code[data-src], .math[data-src], .comment, rt, rp, .reference, .checkbox, ul, ol'), i = 0; i < es.length; ++i) {
6969
+ for (let es = target.querySelectorAll('code[data-src], .math[data-src], .comment, rt, rp, .reference, .checkbox, ul, ol'), len = es.length, i = 0; i < len; ++i) {
7126
6970
  const el = es[i];
7127
6971
 
7128
6972
  switch (el.tagName) {
@@ -8093,14 +7937,12 @@ const ja_1 = __webpack_require__(1499);
8093
7937
 
8094
7938
  const dom_1 = __webpack_require__(3252);
8095
7939
 
8096
- const query_1 = __webpack_require__(6120);
8097
-
8098
7940
  function localize(parser) {
8099
7941
  return (0, combinator_1.fmap)(parser, ns => {
8100
7942
  if (ns.length === 0) return ns;
8101
7943
  const el = ns.length === 1 && typeof ns[0] === 'object' ? ns[0] : (0, dom_1.html)('div', ns);
8102
7944
 
8103
- for (let es = (0, query_1.querySelectorAll)(el, '.linebreak:not(:empty)'), i = 0; i < es.length; ++i) {
7945
+ for (let es = el.querySelectorAll('.linebreak:not(:empty)'), len = es.length, i = 0; i < len; ++i) {
8104
7946
  const el = es[i];
8105
7947
  if (!check(el)) continue;
8106
7948
  el.firstChild.remove();
@@ -8191,7 +8033,7 @@ const global_1 = __webpack_require__(4128);
8191
8033
 
8192
8034
  const label_1 = __webpack_require__(466);
8193
8035
 
8194
- const multimap_1 = __webpack_require__(940);
8036
+ const queue_1 = __webpack_require__(4934);
8195
8037
 
8196
8038
  const array_1 = __webpack_require__(8112);
8197
8039
 
@@ -8200,15 +8042,15 @@ const dom_1 = __webpack_require__(3252);
8200
8042
  const query_1 = __webpack_require__(6120);
8201
8043
 
8202
8044
  function* figure(target, footnotes, opts = {}) {
8203
- const refs = new multimap_1.MultiMap((0, array_1.push)((0, query_1.querySelectorAll)(target, 'a.label:not(.disabled)[data-label]'), footnotes && (0, query_1.querySelectorAll)(footnotes.references, 'a.label:not(.disabled)') || []).map(el => [el.getAttribute('data-label'), el]));
8045
+ const refs = new queue_1.MultiQueue((0, array_1.push)((0, query_1.querySelectorAll)(target, 'a.label:not(.disabled)[data-label]'), footnotes && (0, query_1.querySelectorAll)(footnotes.references, 'a.label:not(.disabled)') || []).map(el => [el.getAttribute('data-label'), el]));
8204
8046
  const labels = new global_1.Set();
8205
8047
  const numbers = new global_1.Map();
8206
8048
  let base = '0';
8207
8049
  let bases = base.split('.');
8208
8050
  let index = bases; // Bug: Firefox
8209
- //for (let defs = querySelectorAll(target, ':scope > figure[data-label], :scope > h1, :scope > h2'), len = defs.length, i = 0; i < len; ++i) {
8051
+ //for (let defs = target.querySelectorAll(':scope > figure[data-label], :scope > h1, :scope > h2'), len = defs.length, i = 0; i < len; ++i) {
8210
8052
 
8211
- for (let defs = (0, query_1.querySelectorAll)(target, 'figure[data-label], h1, h2'), len = defs.length, i = 0; i < len; ++i) {
8053
+ for (let defs = target.querySelectorAll('figure[data-label], h1, h2'), len = defs.length, i = 0; i < len; ++i) {
8212
8054
  yield;
8213
8055
  const def = defs[i];
8214
8056
  if (def.parentNode !== target) continue;
@@ -8390,16 +8232,14 @@ const global_1 = __webpack_require__(4128);
8390
8232
 
8391
8233
  const indexee_1 = __webpack_require__(1269);
8392
8234
 
8393
- const multimap_1 = __webpack_require__(940);
8235
+ const queue_1 = __webpack_require__(4934);
8394
8236
 
8395
8237
  const dom_1 = __webpack_require__(3252);
8396
8238
 
8397
- const query_1 = __webpack_require__(6120);
8398
-
8399
8239
  function* footnote(target, footnotes, opts = {}, bottom = null) {
8400
8240
  // Bug: Firefox
8401
- //querySelectorAll(target, `:scope > .annotations`).forEach(el => el.remove());
8402
- for (let es = (0, query_1.querySelectorAll)(target, `.annotations`), i = 0; i < es.length; ++i) {
8241
+ //target.querySelectorAll(`:scope > .annotations`).forEach(el => el.remove());
8242
+ for (let es = target.querySelectorAll(`.annotations`), len = es.length, i = 0; i < len; ++i) {
8403
8243
  const el = es[i];
8404
8244
  el.parentNode === target && el.remove();
8405
8245
  }
@@ -8418,13 +8258,13 @@ function build(syntax, marker, splitter) {
8418
8258
  // 構文ごとに各1回の処理では不可能
8419
8259
  return function* (target, footnote, opts = {}, bottom = null) {
8420
8260
  const defs = new global_1.Map();
8421
- const buffer = new multimap_1.MultiMap();
8261
+ const buffer = new queue_1.MultiQueue();
8422
8262
  const titles = new global_1.Map(); // Bug: Firefox
8423
- //const splitters = push([], querySelectorAll(target, `:scope > :is(${splitter ?? '_'})`));
8263
+ //const splitters = push([], target.querySelectorAll(`:scope > :is(${splitter ?? '_'})`));
8424
8264
 
8425
8265
  const splitters = [];
8426
8266
 
8427
- for (let es = (0, query_1.querySelectorAll)(target, splitter ?? '_'), i = 0; i < es.length; ++i) {
8267
+ for (let es = target.querySelectorAll(splitter ?? '_'), len = es.length, i = 0; i < len; ++i) {
8428
8268
  const el = es[i];
8429
8269
  el.parentNode === target && splitters.push(el);
8430
8270
  }
@@ -8433,7 +8273,7 @@ function build(syntax, marker, splitter) {
8433
8273
  let total = 0;
8434
8274
  let style;
8435
8275
 
8436
- for (let refs = (0, query_1.querySelectorAll)(target, `sup.${syntax}:not(.disabled)`), len = refs.length, i = 0; i < len; ++i) {
8276
+ for (let refs = target.querySelectorAll(`sup.${syntax}:not(.disabled)`), len = refs.length, i = 0; i < len; ++i) {
8437
8277
  yield;
8438
8278
  const ref = refs[i];
8439
8279
 
@@ -9784,8 +9624,6 @@ exports.info = void 0;
9784
9624
 
9785
9625
  const scope_1 = __webpack_require__(5202);
9786
9626
 
9787
- const query_1 = __webpack_require__(6120);
9788
-
9789
9627
  function info(source) {
9790
9628
  const match = (0, scope_1.scope)(source, '.invalid');
9791
9629
  return {
@@ -9804,7 +9642,7 @@ function info(source) {
9804
9642
  function find(selector) {
9805
9643
  const acc = [];
9806
9644
 
9807
- for (let es = (0, query_1.querySelectorAll)(source, selector), i = 0; i < es.length; ++i) {
9645
+ for (let es = source.querySelectorAll(selector), len = es.length, i = 0; i < len; ++i) {
9808
9646
  const el = es[i];
9809
9647
  match(el) && acc.push(el);
9810
9648
  }
@@ -9836,8 +9674,6 @@ const cite_1 = __webpack_require__(6315);
9836
9674
 
9837
9675
  const dom_1 = __webpack_require__(3252);
9838
9676
 
9839
- const query_1 = __webpack_require__(6120);
9840
-
9841
9677
  function quote(anchor, range) {
9842
9678
  if ((0, parser_1.exec)((0, cite_1.cite)({
9843
9679
  source: `>>${anchor}`,
@@ -9847,7 +9683,7 @@ function quote(anchor, range) {
9847
9683
  const node = trim(range.cloneContents());
9848
9684
  if (!node.firstChild) return '';
9849
9685
 
9850
- for (let es = (0, query_1.querySelectorAll)(node, 'code[data-src], .math[data-src], .media[data-src], rt, rp'), i = 0; i < es.length; ++i) {
9686
+ for (let es = node.querySelectorAll('code[data-src], .math[data-src], .media[data-src], rt, rp'), len = es.length, i = 0; i < len; ++i) {
9851
9687
  const el = es[i];
9852
9688
 
9853
9689
  switch (true) {
@@ -9873,7 +9709,7 @@ function quote(anchor, range) {
9873
9709
  anchor = '';
9874
9710
  }
9875
9711
 
9876
- for (let es = (0, query_1.querySelectorAll)(node, 'br'), i = 0; i < es.length; ++i) {
9712
+ for (let es = node.querySelectorAll('br'), len = es.length, i = 0; i < len; ++i) {
9877
9713
  const el = es[i];
9878
9714
 
9879
9715
  if (anchor && el.nextSibling instanceof global_1.Element && el.nextSibling.matches('.cite, .quote')) {
@@ -9983,10 +9819,8 @@ const global_1 = __webpack_require__(4128);
9983
9819
 
9984
9820
  const array_1 = __webpack_require__(8112);
9985
9821
 
9986
- const dom_1 = __webpack_require__(3252);
9987
-
9988
- const query_1 = __webpack_require__(6120); // Bug: Firefox
9989
- //const selector = 'h1 h2 h3 h4 h5 h6 aside.aside'.split(' ').map(s => `:scope > ${s}[id]`).join();
9822
+ const dom_1 = __webpack_require__(3252); // Bug: Firefox
9823
+ //const selector = `:scope > :is(h1, h2, h3, h4, h5, h6, aside.aside)[id]`;
9990
9824
 
9991
9825
 
9992
9826
  const selector = ':is(h1, h2, h3, h4, h5, h6, aside.aside)[id]';
@@ -9994,7 +9828,7 @@ const selector = ':is(h1, h2, h3, h4, h5, h6, aside.aside)[id]';
9994
9828
  function toc(source) {
9995
9829
  const hs = [];
9996
9830
 
9997
- for (let es = (0, query_1.querySelectorAll)(source, selector), i = 0; i < es.length; ++i) {
9831
+ for (let es = source.querySelectorAll(selector), len = es.length, i = 0; i < len; ++i) {
9998
9832
  const el = es[i];
9999
9833
 
10000
9834
  switch (el.tagName) {
@@ -10053,7 +9887,7 @@ function unlink(h) {
10053
9887
  /***/ 3252:
10054
9888
  /***/ (function(module) {
10055
9889
 
10056
- /*! typed-dom v0.0.305 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
9890
+ /*! typed-dom v0.0.309 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
10057
9891
  (function webpackUniversalModuleDefinition(root, factory) {
10058
9892
  if(true)
10059
9893
  module.exports = factory();
@@ -10145,45 +9979,44 @@ const alias_1 = __nested_webpack_require_3232__(406);
10145
9979
 
10146
9980
  const compare_1 = __nested_webpack_require_3232__(529);
10147
9981
 
10148
- function memoize(f, identify = (...as) => as[0], memory) {
10149
- if (typeof identify === 'object') return memoize(f, void 0, identify);
10150
- if (memory === void 0) return memoize(f, identify, new global_1.Map());
10151
- if ((0, alias_1.isArray)(memory)) return memoize(f, identify, {
10152
- has(key) {
10153
- return memory[key] !== void 0;
10154
- },
9982
+ const undefined = void 0;
10155
9983
 
10156
- get(key) {
10157
- return memory[key];
10158
- },
9984
+ function memoize(f, identify = (...as) => as[0], memory) {
9985
+ if (typeof identify === 'object') return memoize(f, undefined, identify);
9986
+ return (0, alias_1.isArray)(memory) ? memoizeArray(f, identify, memory) : memoizeObject(f, identify, memory ?? new global_1.Map());
9987
+ }
10159
9988
 
10160
- set(key, value) {
10161
- memory[key] = value;
10162
- return this;
10163
- },
9989
+ exports.memoize = memoize;
10164
9990
 
10165
- delete() {
10166
- throw 0;
10167
- }
9991
+ function memoizeArray(f, identify, memory) {
9992
+ let nullish = false;
9993
+ return (...as) => {
9994
+ const b = identify(...as);
9995
+ let z = memory[b];
9996
+ if (z !== undefined || nullish && memory[b] !== undefined) return z;
9997
+ z = f(...as);
9998
+ nullish ||= z === undefined;
9999
+ memory[b] = z;
10000
+ return z;
10001
+ };
10002
+ }
10168
10003
 
10169
- });
10004
+ function memoizeObject(f, identify, memory) {
10170
10005
  let nullish = false;
10171
10006
  return (...as) => {
10172
10007
  const b = identify(...as);
10173
10008
  let z = memory.get(b);
10174
- if (z !== void 0 || nullish && memory.has(b)) return z;
10009
+ if (z !== undefined || nullish && memory.has(b)) return z;
10175
10010
  z = f(...as);
10176
- nullish ||= z === void 0;
10011
+ nullish ||= z === undefined;
10177
10012
  memory.set(b, z);
10178
10013
  return z;
10179
10014
  };
10180
10015
  }
10181
10016
 
10182
- exports.memoize = memoize;
10183
-
10184
10017
  function reduce(f, identify = (...as) => as[0]) {
10185
- let key = [];
10186
- let val = [];
10018
+ let key = {};
10019
+ let val;
10187
10020
  return (...as) => {
10188
10021
  const b = identify(...as);
10189
10022
 
@@ -10201,7 +10034,7 @@ exports.reduce = reduce;
10201
10034
  /***/ }),
10202
10035
 
10203
10036
  /***/ 521:
10204
- /***/ ((__unused_webpack_module, exports, __nested_webpack_require_4622__) => {
10037
+ /***/ ((__unused_webpack_module, exports, __nested_webpack_require_4777__) => {
10205
10038
 
10206
10039
 
10207
10040
 
@@ -10210,11 +10043,11 @@ Object.defineProperty(exports, "__esModule", ({
10210
10043
  }));
10211
10044
  exports.defrag = exports.prepend = exports.append = exports.isChildren = exports.define = exports.element = exports.text = exports.svg = exports.html = exports.frag = exports.shadow = void 0;
10212
10045
 
10213
- const global_1 = __nested_webpack_require_4622__(128);
10046
+ const global_1 = __nested_webpack_require_4777__(128);
10214
10047
 
10215
- const alias_1 = __nested_webpack_require_4622__(406);
10048
+ const alias_1 = __nested_webpack_require_4777__(406);
10216
10049
 
10217
- const memoize_1 = __nested_webpack_require_4622__(808);
10050
+ const memoize_1 = __nested_webpack_require_4777__(808);
10218
10051
 
10219
10052
  var caches;
10220
10053
 
@@ -10449,7 +10282,7 @@ exports.defrag = defrag;
10449
10282
  /******/ var __webpack_module_cache__ = {};
10450
10283
  /******/
10451
10284
  /******/ // The require function
10452
- /******/ function __nested_webpack_require_11575__(moduleId) {
10285
+ /******/ function __nested_webpack_require_11730__(moduleId) {
10453
10286
  /******/ // Check if module is in cache
10454
10287
  /******/ var cachedModule = __webpack_module_cache__[moduleId];
10455
10288
  /******/ if (cachedModule !== undefined) {
@@ -10463,7 +10296,7 @@ exports.defrag = defrag;
10463
10296
  /******/ };
10464
10297
  /******/
10465
10298
  /******/ // Execute the module function
10466
- /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_11575__);
10299
+ /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_11730__);
10467
10300
  /******/
10468
10301
  /******/ // Return the exports of the module
10469
10302
  /******/ return module.exports;
@@ -10474,7 +10307,7 @@ exports.defrag = defrag;
10474
10307
  /******/ // startup
10475
10308
  /******/ // Load entry module and return exports
10476
10309
  /******/ // This entry module is referenced by other modules so it can't be inlined
10477
- /******/ var __webpack_exports__ = __nested_webpack_require_11575__(521);
10310
+ /******/ var __webpack_exports__ = __nested_webpack_require_11730__(521);
10478
10311
  /******/
10479
10312
  /******/ return __webpack_exports__;
10480
10313
  /******/ })()
@@ -10486,7 +10319,7 @@ exports.defrag = defrag;
10486
10319
  /***/ 6120:
10487
10320
  /***/ (function(module) {
10488
10321
 
10489
- /*! typed-dom v0.0.305 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
10322
+ /*! typed-dom v0.0.309 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
10490
10323
  (function webpackUniversalModuleDefinition(root, factory) {
10491
10324
  if(true)
10492
10325
  module.exports = factory();
@@ -10494,220 +10327,8 @@ exports.defrag = defrag;
10494
10327
  })(this, () => {
10495
10328
  return /******/ (() => { // webpackBootstrap
10496
10329
  /******/ "use strict";
10497
- /******/ var __webpack_modules__ = ({
10498
-
10499
- /***/ 99:
10500
- /***/ ((__unused_webpack_module, exports) => {
10501
-
10502
-
10503
-
10504
- Object.defineProperty(exports, "__esModule", ({
10505
- value: true
10506
- }));
10507
- exports.duffReduce = exports.duffEach = exports.duffbk = exports.duff = void 0;
10508
-
10509
- function duff(count, proc) {
10510
- if (count > 0) {
10511
- let i = 0,
10512
- m = count & 7,
10513
- d = (count - m) / 8;
10514
-
10515
- while (m--) {
10516
- proc(i++);
10517
- }
10518
-
10519
- while (d--) {
10520
- proc(i++);
10521
- proc(i++);
10522
- proc(i++);
10523
- proc(i++);
10524
- proc(i++);
10525
- proc(i++);
10526
- proc(i++);
10527
- proc(i++);
10528
- }
10529
- } else {
10530
- let i = -count,
10531
- m = i & 7,
10532
- d = (i - m) / 8;
10533
-
10534
- while (m--) {
10535
- proc(--i);
10536
- }
10537
-
10538
- while (d--) {
10539
- proc(--i);
10540
- proc(--i);
10541
- proc(--i);
10542
- proc(--i);
10543
- proc(--i);
10544
- proc(--i);
10545
- proc(--i);
10546
- proc(--i);
10547
- }
10548
- }
10549
- }
10550
-
10551
- exports.duff = duff;
10552
-
10553
- function duffbk(count, proc) {
10554
- if (count > 0) {
10555
- let i = 0,
10556
- m = count & 7,
10557
- d = (count - m) / 8;
10558
-
10559
- while (m--) {
10560
- if (proc(i++) === false) return;
10561
- }
10562
-
10563
- while (d--) {
10564
- switch (false) {
10565
- case proc(i++):
10566
- case proc(i++):
10567
- case proc(i++):
10568
- case proc(i++):
10569
- case proc(i++):
10570
- case proc(i++):
10571
- case proc(i++):
10572
- case proc(i++):
10573
- return;
10574
- }
10575
- }
10576
- } else {
10577
- let i = -count,
10578
- m = i & 7,
10579
- d = (i - m) / 8;
10580
-
10581
- while (m--) {
10582
- if (proc(--i) === false) return;
10583
- }
10584
-
10585
- while (d--) {
10586
- switch (false) {
10587
- case proc(--i):
10588
- case proc(--i):
10589
- case proc(--i):
10590
- case proc(--i):
10591
- case proc(--i):
10592
- case proc(--i):
10593
- case proc(--i):
10594
- case proc(--i):
10595
- return;
10596
- }
10597
- }
10598
- }
10599
- }
10600
-
10601
- exports.duffbk = duffbk;
10602
-
10603
- function duffEach(array, proc) {
10604
- let count = array.length;
10605
- let i = 0,
10606
- m = count & 7,
10607
- d = (count - m) / 8;
10608
-
10609
- while (m--) {
10610
- proc(array[i], i++, array);
10611
- }
10612
-
10613
- while (d--) {
10614
- proc(array[i], i++, array);
10615
- proc(array[i], i++, array);
10616
- proc(array[i], i++, array);
10617
- proc(array[i], i++, array);
10618
- proc(array[i], i++, array);
10619
- proc(array[i], i++, array);
10620
- proc(array[i], i++, array);
10621
- proc(array[i], i++, array);
10622
- }
10623
- }
10624
-
10625
- exports.duffEach = duffEach; // ベンチマークの10,000以上で急激な速度低下が見られるがNodeListなどでの
10626
- // 実際の使用では速度低下は見られない
10627
-
10628
- function duffReduce(array, proc, initial) {
10629
- let count = array.length;
10630
- let i = 0,
10631
- m = count & 7,
10632
- d = (count - m) / 8;
10633
- let acc = initial;
10634
-
10635
- while (m--) {
10636
- acc = proc(acc, array[i], i++, array);
10637
- }
10638
-
10639
- while (d--) {
10640
- acc = proc(acc, array[i], i++, array);
10641
- acc = proc(acc, array[i], i++, array);
10642
- acc = proc(acc, array[i], i++, array);
10643
- acc = proc(acc, array[i], i++, array);
10644
- acc = proc(acc, array[i], i++, array);
10645
- acc = proc(acc, array[i], i++, array);
10646
- acc = proc(acc, array[i], i++, array);
10647
- acc = proc(acc, array[i], i++, array);
10648
- }
10649
-
10650
- return acc;
10651
- }
10652
-
10653
- exports.duffReduce = duffReduce;
10654
-
10655
- /***/ }),
10656
-
10657
- /***/ 128:
10658
- /***/ ((module, __unused_webpack_exports, __nested_webpack_require_3560__) => {
10659
-
10660
-
10661
-
10662
- __nested_webpack_require_3560__(921);
10663
-
10664
- const global = void 0 || typeof globalThis !== 'undefined' && globalThis // @ts-ignore
10665
- || typeof self !== 'undefined' && self || Function('return this')();
10666
- global.global = global;
10667
- module.exports = global;
10668
-
10669
- /***/ }),
10670
-
10671
- /***/ 921:
10672
- /***/ (() => {
10673
-
10674
- // @ts-ignore
10675
-
10676
- var globalThis; // @ts-ignore
10677
-
10678
- var global = (/* unused pure expression or super */ null && (0));
10679
-
10680
- /***/ })
10681
-
10682
- /******/ });
10683
- /************************************************************************/
10684
- /******/ // The module cache
10685
- /******/ var __webpack_module_cache__ = {};
10686
- /******/
10687
- /******/ // The require function
10688
- /******/ function __nested_webpack_require_4212__(moduleId) {
10689
- /******/ // Check if module is in cache
10690
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
10691
- /******/ if (cachedModule !== undefined) {
10692
- /******/ return cachedModule.exports;
10693
- /******/ }
10694
- /******/ // Create a new module (and put it into the cache)
10695
- /******/ var module = __webpack_module_cache__[moduleId] = {
10696
- /******/ // no module.id needed
10697
- /******/ // no module.loaded needed
10698
- /******/ exports: {}
10699
- /******/ };
10700
- /******/
10701
- /******/ // Execute the module function
10702
- /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_4212__);
10703
- /******/
10704
- /******/ // Return the exports of the module
10705
- /******/ return module.exports;
10706
- /******/ }
10707
- /******/
10708
- /************************************************************************/
10709
10330
  var __webpack_exports__ = {};
10710
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
10331
+ // This entry need to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
10711
10332
  (() => {
10712
10333
  var exports = __webpack_exports__;
10713
10334
 
@@ -10717,10 +10338,6 @@ Object.defineProperty(exports, "__esModule", ({
10717
10338
  }));
10718
10339
  exports.querySelectorAll = exports.querySelectorAllWith = exports.querySelectorWith = void 0;
10719
10340
 
10720
- const global_1 = __nested_webpack_require_4212__(128);
10721
-
10722
- const duff_1 = __nested_webpack_require_4212__(99);
10723
-
10724
10341
  function querySelectorWith(node, selector) {
10725
10342
  return 'matches' in node && node.matches(selector) ? node : node.querySelector(selector);
10726
10343
  }
@@ -10734,13 +10351,23 @@ function querySelectorAllWith(node, selector) {
10734
10351
  acc.push(node);
10735
10352
  }
10736
10353
 
10737
- return (0, duff_1.duffReduce)(node.querySelectorAll(selector), (acc, el) => (acc.push(el), acc), acc);
10354
+ for (let es = node.querySelectorAll(selector), len = es.length, i = 0; i < len; ++i) {
10355
+ acc.push(es[i]);
10356
+ }
10357
+
10358
+ return acc;
10738
10359
  }
10739
10360
 
10740
10361
  exports.querySelectorAllWith = querySelectorAllWith;
10741
10362
 
10742
10363
  function querySelectorAll(node, selector) {
10743
- return (0, duff_1.duffReduce)(node.querySelectorAll(selector), (acc, el) => (acc.push(el), acc), (0, global_1.Array)());
10364
+ const acc = [];
10365
+
10366
+ for (let es = node.querySelectorAll(selector), len = es.length, i = 0; i < len; ++i) {
10367
+ acc.push(es[i]);
10368
+ }
10369
+
10370
+ return acc;
10744
10371
  }
10745
10372
 
10746
10373
  exports.querySelectorAll = querySelectorAll;