securemark 0.261.1 → 0.262.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.js +1228 -665
  3. package/package.json +9 -9
  4. package/src/combinator/control/constraint/contract.ts +6 -8
  5. package/src/combinator/data/parser/context/memo.ts +1 -1
  6. package/src/combinator/data/parser/inits.ts +1 -1
  7. package/src/combinator/data/parser/sequence.ts +1 -1
  8. package/src/combinator/data/parser/union.ts +12 -7
  9. package/src/debug.test.ts +3 -3
  10. package/src/parser/api/bind.ts +2 -2
  11. package/src/parser/api/parse.test.ts +1 -1
  12. package/src/parser/api/parse.ts +1 -1
  13. package/src/parser/block/blockquote.test.ts +31 -31
  14. package/src/parser/block/blockquote.ts +1 -1
  15. package/src/parser/block/dlist.ts +1 -1
  16. package/src/parser/block/extension/aside.test.ts +3 -3
  17. package/src/parser/block/extension/aside.ts +1 -0
  18. package/src/parser/block/extension/example.test.ts +11 -11
  19. package/src/parser/block/extension/example.ts +1 -1
  20. package/src/parser/block/extension/fig.test.ts +5 -5
  21. package/src/parser/block/extension/figure.test.ts +2 -2
  22. package/src/parser/block/extension/figure.ts +1 -1
  23. package/src/parser/block/extension/message.ts +1 -1
  24. package/src/parser/block/extension/table.ts +1 -1
  25. package/src/parser/block/olist.ts +5 -7
  26. package/src/parser/block/reply.ts +1 -1
  27. package/src/parser/block/table.ts +8 -8
  28. package/src/parser/block/ulist.ts +1 -1
  29. package/src/parser/block.ts +1 -1
  30. package/src/parser/inline/bracket.ts +1 -1
  31. package/src/parser/inline/comment.ts +1 -1
  32. package/src/parser/inline/deletion.ts +1 -1
  33. package/src/parser/inline/emphasis.ts +1 -1
  34. package/src/parser/inline/extension/indexee.ts +9 -8
  35. package/src/parser/inline/extension/placeholder.ts +1 -1
  36. package/src/parser/inline/html.ts +1 -1
  37. package/src/parser/inline/insertion.ts +1 -1
  38. package/src/parser/inline/link.ts +1 -1
  39. package/src/parser/inline/mark.ts +1 -1
  40. package/src/parser/inline/media.ts +1 -1
  41. package/src/parser/inline/ruby.ts +1 -1
  42. package/src/parser/inline/strong.ts +1 -1
  43. package/src/parser/inline/template.ts +1 -1
  44. package/src/parser/locale.test.ts +1 -1
  45. package/src/parser/locale.ts +5 -4
  46. package/src/parser/processor/figure.test.ts +3 -3
  47. package/src/parser/processor/figure.ts +10 -8
  48. package/src/parser/processor/footnote.test.ts +2 -2
  49. package/src/parser/processor/footnote.ts +17 -12
  50. package/src/renderer/render.ts +3 -3
  51. package/src/util/info.ts +7 -5
  52. package/src/util/quote.ts +14 -12
  53. package/src/util/toc.ts +14 -8
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.261.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.262.1 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"));
@@ -92,6 +92,8 @@ exports.splice = exports.pop = exports.push = exports.shift = exports.unshift =
92
92
 
93
93
  const global_1 = __webpack_require__(4128);
94
94
 
95
+ const undefined = void 0;
96
+
95
97
  function indexOf(as, a) {
96
98
  if (as.length === 0) return -1;
97
99
  return a === a ? as.indexOf(a) : as.findIndex(a => a !== a);
@@ -101,7 +103,10 @@ exports.indexOf = indexOf;
101
103
 
102
104
  function unshift(as, bs) {
103
105
  if ('length' in as) {
104
- for (let i = as.length - 1; i >= 0; --i) {
106
+ if (as.length === 1) return bs.unshift(as[0]), bs;
107
+ if (global_1.Symbol.iterator in as) return bs.unshift(...as), bs;
108
+
109
+ for (let i = as.length; i--;) {
105
110
  bs.unshift(as[i]);
106
111
  }
107
112
  } else {
@@ -115,14 +120,17 @@ exports.unshift = unshift;
115
120
 
116
121
  function shift(as, count) {
117
122
  if (count < 0) throw new Error('Unexpected negative number');
118
- return count === void 0 ? [as.shift(), as] : [splice(as, 0, count), as];
123
+ return count === undefined ? [as.shift(), as] : [splice(as, 0, count), as];
119
124
  }
120
125
 
121
126
  exports.shift = shift;
122
127
 
123
128
  function push(as, bs) {
124
129
  if ('length' in bs) {
125
- for (let i = 0, len = bs.length; i < len; ++i) {
130
+ if (bs.length === 1) return as.push(bs[0]), as;
131
+ if (global_1.Symbol.iterator in bs && bs.length > 50) return as.push(...bs), as;
132
+
133
+ for (let len = bs.length, i = 0; i < len; ++i) {
126
134
  as.push(bs[i]);
127
135
  }
128
136
  } else {
@@ -138,50 +146,39 @@ exports.push = push;
138
146
 
139
147
  function pop(as, count) {
140
148
  if (count < 0) throw new Error('Unexpected negative number');
141
- return count === void 0 ? [as, as.pop()] : [as, splice(as, as.length - count, count)];
149
+ return count === undefined ? [as, as.pop()] : [as, splice(as, as.length - count, count)];
142
150
  }
143
151
 
144
152
  exports.pop = pop;
145
153
 
146
- function splice(as, index, count, ...inserts) {
147
- if (count === 0 && inserts.length === 0) return [];
154
+ function splice(as, index, count, ...values) {
155
+ if (as.length === 0) return push(as, values), [];
156
+
157
+ if (index > as.length) {
158
+ index = as.length;
159
+ } else if (index < 0) {
160
+ index = -index > as.length ? 0 : as.length + index;
161
+ }
162
+
148
163
  count = count > as.length ? as.length : count;
164
+ if (count === 0 && values.length === 0) return [];
165
+ if (count === 1 && values.length === 1) return [[as[index], as[index] = values[0]][0]];
149
166
 
150
167
  switch (index) {
151
168
  case 0:
152
- switch (count) {
153
- case 0:
154
- return [[], unshift(inserts, as)][0];
155
-
156
- case 1:
157
- return as.length === 0 ? [[], unshift(inserts, as)][0] : [[as.shift()], unshift(inserts, as)][0];
158
-
159
- case void 0:
160
- if (as.length > 1 || arguments.length > 2) break;
161
- return as.length === 0 ? [] : splice(as, index, 1);
162
- }
163
-
169
+ if (count === 0) return unshift(values, as), [];
170
+ if (count === 1) return [[as.shift()], unshift(values, as)][0];
164
171
  break;
165
172
 
166
- case -1:
167
173
  case as.length - 1:
168
- switch (count) {
169
- case 1:
170
- return as.length === 0 ? [[], push(as, inserts)][0] : [[as.pop()], push(as, inserts)][0];
171
-
172
- case void 0:
173
- if (as.length > 1 || arguments.length > 2) break;
174
- return as.length === 0 ? [] : splice(as, index, 1);
175
- }
176
-
174
+ if (count === 1) return [[as.pop()], push(as, values)][0];
177
175
  break;
178
176
 
179
177
  case as.length:
180
- case global_1.Infinity:
181
- return [[], push(as, inserts)][0];
178
+ return push(as, values), [];
182
179
  }
183
180
 
184
- return arguments.length > 2 ? as.splice(index, count, ...inserts) : as.splice(index);
181
+ return arguments.length > 2 ? as.splice(index, count, ...values) : as.splice(index);
185
182
  }
186
183
 
187
184
  exports.splice = splice;
@@ -369,15 +366,14 @@ const assign_1 = __webpack_require__(4401);
369
366
  class Cache {
370
367
  constructor(capacity, opts = {}) {
371
368
  this.settings = {
372
- window: 0,
373
369
  capacity: 0,
374
- space: global_1.Infinity,
375
370
  age: global_1.Infinity,
376
371
  earlyExpiring: false,
377
372
  capture: {
378
373
  delete: true,
379
374
  clear: true
380
375
  },
376
+ window: 0,
381
377
  resolution: 1,
382
378
  offset: 0,
383
379
  block: 20,
@@ -391,7 +387,7 @@ class Cache {
391
387
  LRU: new invlist_1.List(),
392
388
  LFU: new invlist_1.List()
393
389
  };
394
- this.expiries = new heap_1.Heap((a, b) => a.value.expiry - b.value.expiry);
390
+ this.expiries = new heap_1.Heap(heap_1.Heap.min);
395
391
  this.misses = 0;
396
392
  this.sweep = 0;
397
393
  this.ratio = 500;
@@ -407,8 +403,7 @@ class Cache {
407
403
  this.capacity = settings.capacity;
408
404
  if (this.capacity >= 1 === false) throw new Error(`Spica: Cache: Capacity must be 1 or more.`);
409
405
  this.window = settings.window || this.capacity;
410
- if (this.window * 1000 < this.capacity) throw new Error(`Spica: Cache: Window must be 0.1% of capacity or more.`);
411
- this.space = settings.space;
406
+ if (this.window * 1000 >= this.capacity === false) throw new Error(`Spica: Cache: Window must be 0.1% of capacity or more.`);
412
407
  this.block = settings.block;
413
408
  this.limit = settings.limit;
414
409
  this.earlyExpiring = settings.earlyExpiring;
@@ -438,13 +433,12 @@ class Cache {
438
433
 
439
434
  ensure(margin, skip) {
440
435
  let size = skip?.value.size ?? 0;
441
- if (margin - size <= 0) return true;
442
436
  const {
443
437
  LRU,
444
438
  LFU
445
439
  } = this.indexes;
446
440
 
447
- while (this.length === this.capacity || this.size + margin - size > this.space) {
441
+ while (this.size + margin - size > this.capacity) {
448
442
  let target;
449
443
 
450
444
  switch (true) {
@@ -494,7 +488,7 @@ class Cache {
494
488
  size = 1,
495
489
  age = this.settings.age
496
490
  } = {}) {
497
- if (size > this.space || age <= 0) {
491
+ if (size < 1 || this.capacity < size || age <= 0) {
498
492
  this.disposer?.(value, key);
499
493
  return false;
500
494
  }
@@ -510,7 +504,7 @@ class Cache {
510
504
  index.expiry = expiry;
511
505
 
512
506
  if (this.earlyExpiring && expiry !== global_1.Infinity) {
513
- index.enode ? this.expiries.update(index.enode) : index.enode = this.expiries.insert(node);
507
+ index.enode ? this.expiries.update(index.enode, expiry) : index.enode = this.expiries.insert(node, expiry);
514
508
  } else if (index.enode) {
515
509
  this.expiries.delete(index.enode);
516
510
  index.enode = void 0;
@@ -535,7 +529,7 @@ class Cache {
535
529
  }));
536
530
 
537
531
  if (this.earlyExpiring && expiry !== global_1.Infinity) {
538
- LRU.head.value.enode = this.expiries.insert(LRU.head);
532
+ LRU.head.value.enode = this.expiries.insert(LRU.head, expiry);
539
533
  }
540
534
 
541
535
  return false;
@@ -560,14 +554,14 @@ class Cache {
560
554
  ++this.misses;
561
555
  this.evict(node, true);
562
556
  return;
563
- } // Optimization for memoize.
557
+ }
564
558
 
559
+ this.misses &&= 0;
560
+ this.sweep &&= 0; // Optimization for memoize.
565
561
 
566
562
  if (this.capacity > 3 && node === node.list.head) return node.value.value;
567
563
  this.access(node);
568
564
  this.adjust();
569
- this.misses &&= 0;
570
- this.sweep = 0;
571
565
  return node.value.value;
572
566
  }
573
567
 
@@ -607,21 +601,35 @@ class Cache {
607
601
  const memory = this.memory;
608
602
  this.memory = new global_1.Map();
609
603
 
610
- for (const [key, {
611
- value: {
612
- value
604
+ for (const {
605
+ 0: key,
606
+ 1: {
607
+ value: {
608
+ value
609
+ }
613
610
  }
614
- }] of memory) {
611
+ } of memory) {
615
612
  this.disposer(value, key);
616
613
  }
617
614
  }
618
615
 
616
+ resize(capacity) {
617
+ if (this.capacity >= 1 === false) throw new Error(`Spica: Cache: Capacity must be 1 or more.`);
618
+ this.capacity = capacity;
619
+ this.window = this.settings.window || this.capacity;
620
+ if (this.window * 1000 >= this.capacity === false) throw new Error(`Spica: Cache: Window must be 0.1% of capacity or more.`);
621
+ this.ensure(0);
622
+ }
623
+
619
624
  *[Symbol.iterator]() {
620
- for (const [key, {
621
- value: {
622
- value
625
+ for (const {
626
+ 0: key,
627
+ 1: {
628
+ value: {
629
+ value
630
+ }
623
631
  }
624
- }] of this.memory) {
632
+ } of this.memory) {
625
633
  yield [key, value];
626
634
  }
627
635
 
@@ -764,7 +772,7 @@ function rate(window, hits1, hits2, offset) {
764
772
  let hits = 0;
765
773
  let ratio = 100;
766
774
 
767
- for (let i = 0, len = hits1.length; i < len; ++i) {
775
+ for (let len = hits1.length, i = 0; i < len; ++i) {
768
776
  const subtotal = hits1[i] + hits2[i];
769
777
  if (subtotal === 0) continue;
770
778
  offset = i + 1 === len ? 0 : offset;
@@ -792,58 +800,56 @@ function rate(window, hits1, hits2, offset) {
792
800
  Object.defineProperty(exports, "__esModule", ({
793
801
  value: true
794
802
  }));
795
- exports.tick = exports.clock = exports.now = void 0;
803
+ exports.tick = exports.promise = exports.clock = exports.now = void 0;
796
804
 
797
805
  const global_1 = __webpack_require__(4128);
798
806
 
799
- const alias_1 = __webpack_require__(5406);
807
+ const queue_1 = __webpack_require__(4934);
800
808
 
801
809
  const exception_1 = __webpack_require__(7822);
802
810
 
803
- let mem;
811
+ const undefined = void 0;
812
+ let time;
804
813
  let count = 0;
805
814
 
806
- function now(nocache = false) {
807
- if (mem === void 0) {
808
- tick(() => mem = void 0);
809
- } else if (!nocache && ++count !== 100) {
810
- return mem;
815
+ function now(nocache) {
816
+ if (time === undefined) {
817
+ tick(() => time = undefined);
818
+ } else if (!nocache && count++ !== 20) {
819
+ return time;
811
820
  }
812
821
 
813
- count = 0;
814
- return mem = global_1.Date.now();
822
+ count = 1;
823
+ return time = global_1.Date.now();
815
824
  }
816
825
 
817
826
  exports.now = now;
818
- exports.clock = Promise.resolve(void 0);
819
- let queue = [];
820
- let jobs = [];
821
- let index = 0;
822
- const scheduler = Promise.resolve();
827
+ exports.clock = global_1.Promise.resolve(undefined);
828
+
829
+ function promise(cb) {
830
+ global_1.Promise.resolve().then(cb);
831
+ }
832
+
833
+ exports.promise = promise;
834
+ const queue = new queue_1.Queue();
835
+ const scheduler = global_1.Promise.resolve();
823
836
 
824
837
  function tick(cb) {
825
- index === 0 && scheduler.then(run);
826
- index++ === queue.length ? queue.push(cb) : queue[index - 1] = cb;
838
+ queue.isEmpty() && scheduler.then(run);
839
+ queue.push(cb);
827
840
  }
828
841
 
829
842
  exports.tick = tick;
830
843
 
831
844
  function run() {
832
- const count = index;
833
- [index, queue, jobs] = [0, jobs, queue];
834
-
835
- for (let i = 0; i < count; ++i) {
845
+ for (let count = queue.length; count--;) {
836
846
  try {
837
- (void 0, jobs[i])(); // Release the reference.
838
-
839
- jobs[i] = void 0;
847
+ // @ts-expect-error
848
+ (0, queue.pop())();
840
849
  } catch (reason) {
841
850
  (0, exception_1.causeAsyncException)(reason);
842
851
  }
843
- } // Gradually reduce the unused buffer space.
844
-
845
-
846
- jobs.length > 1000 && count < jobs.length * 0.5 && jobs.splice((0, alias_1.floor)(jobs.length * 0.9), jobs.length);
852
+ }
847
853
  }
848
854
 
849
855
  /***/ }),
@@ -880,62 +886,51 @@ exports.MultiMap = void 0;
880
886
 
881
887
  const global_1 = __webpack_require__(4128);
882
888
 
883
- const array_1 = __webpack_require__(8112);
889
+ const ring_1 = __webpack_require__(6395);
884
890
 
885
891
  class MultiMap {
886
892
  constructor(entries = [], memory = new global_1.Map()) {
887
893
  this.memory = memory;
888
894
 
889
- for (const [k, v] of entries) {
895
+ for (const {
896
+ 0: k,
897
+ 1: v
898
+ } of entries) {
890
899
  this.set(k, v);
891
900
  }
892
901
  }
893
902
 
894
903
  get(key) {
895
- return this.memory.get(key)?.[0];
904
+ return this.memory.get(key)?.at(0);
905
+ }
906
+
907
+ getAll(key) {
908
+ return this.memory.get(key);
896
909
  }
897
910
 
898
911
  set(key, val) {
899
- this.memory.get(key)?.push(val) ?? this.memory.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);
900
917
  return this;
901
918
  }
902
919
 
903
920
  has(key, value) {
904
921
  const vs = this.memory.get(key);
905
- if (!vs || vs.length === 0) return false;
922
+ if (!vs?.length) return false;
906
923
  if (arguments.length < 2) return true;
907
-
908
- switch (value) {
909
- case vs[0]:
910
- case vs[vs.length - 1]:
911
- return true;
912
-
913
- default:
914
- return (0, array_1.indexOf)(vs, value) > -1;
915
- }
924
+ return vs.includes(value);
916
925
  }
917
926
 
918
927
  delete(key, value) {
919
928
  if (arguments.length < 2) return this.memory.delete(key);
920
929
  const vs = this.memory.get(key);
921
- if (!vs || vs.length === 0) return false;
922
-
923
- switch (value) {
924
- case vs[0]:
925
- vs.shift();
926
- break;
927
-
928
- case vs[vs.length - 1]:
929
- vs.pop();
930
- break;
931
-
932
- default:
933
- const i = (0, array_1.indexOf)(vs, value);
934
- if (i === -1) return false;
935
- (0, array_1.splice)(vs, i, 1);
936
- }
937
-
938
- vs.length === 0 && this.memory.delete(key);
930
+ if (!vs?.length) return false;
931
+ const i = vs.indexOf(value);
932
+ if (i === -1) return false;
933
+ vs.splice(i, 1);
939
934
  return true;
940
935
  }
941
936
 
@@ -944,22 +939,32 @@ class MultiMap {
944
939
  }
945
940
 
946
941
  take(key, count) {
947
- const vs = this.memory.get(key) ?? [];
948
- return count === void 0 ? (0, array_1.splice)(vs, 0, 1)[0] : (0, array_1.splice)(vs, 0, 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;
949
951
  }
950
952
 
951
953
  ref(key) {
952
954
  let vs = this.memory.get(key);
953
955
  if (vs) return vs;
954
- vs = [];
956
+ vs = new ring_1.Ring();
955
957
  this.memory.set(key, vs);
956
958
  return vs;
957
959
  }
958
960
 
959
961
  *[Symbol.iterator]() {
960
- for (const [k, vs] of this.memory) {
962
+ for (const {
963
+ 0: k,
964
+ 1: vs
965
+ } of this.memory) {
961
966
  for (let i = 0; i < vs.length; ++i) {
962
- yield [k, vs[i]];
967
+ yield [k, vs.at(i)];
963
968
  }
964
969
  }
965
970
 
@@ -981,12 +986,12 @@ exports.MultiMap = MultiMap;
981
986
  Object.defineProperty(exports, "__esModule", ({
982
987
  value: true
983
988
  }));
984
- exports.duffReduce = exports.duffEach = exports.duffbk = exports.duff = void 0;
989
+ exports.duffReduce = exports.duffEach = exports.duffbk = exports.duff = void 0; // 100,000以上でforより大幅に低速となり実用不可
985
990
 
986
991
  function duff(count, proc) {
987
992
  if (count > 0) {
988
993
  let i = 0,
989
- m = count % 8,
994
+ m = count & 7,
990
995
  d = (count - m) / 8;
991
996
 
992
997
  while (m--) {
@@ -1005,7 +1010,7 @@ function duff(count, proc) {
1005
1010
  }
1006
1011
  } else {
1007
1012
  let i = -count,
1008
- m = i % 8,
1013
+ m = i & 7,
1009
1014
  d = (i - m) / 8;
1010
1015
 
1011
1016
  while (m--) {
@@ -1025,12 +1030,12 @@ function duff(count, proc) {
1025
1030
  }
1026
1031
  }
1027
1032
 
1028
- exports.duff = duff;
1033
+ exports.duff = duff; // 100,000以上でforより大幅に低速となり実用不可
1029
1034
 
1030
1035
  function duffbk(count, proc) {
1031
1036
  if (count > 0) {
1032
1037
  let i = 0,
1033
- m = count % 8,
1038
+ m = count & 7,
1034
1039
  d = (count - m) / 8;
1035
1040
 
1036
1041
  while (m--) {
@@ -1038,18 +1043,21 @@ function duffbk(count, proc) {
1038
1043
  }
1039
1044
 
1040
1045
  while (d--) {
1041
- if (proc(i++) === false) return;
1042
- if (proc(i++) === false) return;
1043
- if (proc(i++) === false) return;
1044
- if (proc(i++) === false) return;
1045
- if (proc(i++) === false) return;
1046
- if (proc(i++) === false) return;
1047
- if (proc(i++) === false) return;
1048
- if (proc(i++) === false) return;
1046
+ switch (false) {
1047
+ case proc(i++):
1048
+ case proc(i++):
1049
+ case proc(i++):
1050
+ case proc(i++):
1051
+ case proc(i++):
1052
+ case proc(i++):
1053
+ case proc(i++):
1054
+ case proc(i++):
1055
+ return;
1056
+ }
1049
1057
  }
1050
1058
  } else {
1051
1059
  let i = -count,
1052
- m = i % 8,
1060
+ m = i & 7,
1053
1061
  d = (i - m) / 8;
1054
1062
 
1055
1063
  while (m--) {
@@ -1057,14 +1065,17 @@ function duffbk(count, proc) {
1057
1065
  }
1058
1066
 
1059
1067
  while (d--) {
1060
- if (proc(--i) === false) return;
1061
- if (proc(--i) === false) return;
1062
- if (proc(--i) === false) return;
1063
- if (proc(--i) === false) return;
1064
- if (proc(--i) === false) return;
1065
- if (proc(--i) === false) return;
1066
- if (proc(--i) === false) return;
1067
- if (proc(--i) === false) return;
1068
+ switch (false) {
1069
+ case proc(--i):
1070
+ case proc(--i):
1071
+ case proc(--i):
1072
+ case proc(--i):
1073
+ case proc(--i):
1074
+ case proc(--i):
1075
+ case proc(--i):
1076
+ case proc(--i):
1077
+ return;
1078
+ }
1068
1079
  }
1069
1080
  }
1070
1081
  }
@@ -1074,7 +1085,7 @@ exports.duffbk = duffbk;
1074
1085
  function duffEach(array, proc) {
1075
1086
  let count = array.length;
1076
1087
  let i = 0,
1077
- m = count % 8,
1088
+ m = count & 7,
1078
1089
  d = (count - m) / 8;
1079
1090
 
1080
1091
  while (m--) {
@@ -1093,30 +1104,32 @@ function duffEach(array, proc) {
1093
1104
  }
1094
1105
  }
1095
1106
 
1096
- exports.duffEach = duffEach;
1107
+ exports.duffEach = duffEach; // ベンチマークの10,000以上で急激な速度低下が見られる場合があるがNodeListなどでの
1108
+ // 実際の使用では速度低下は見られない
1097
1109
 
1098
1110
  function duffReduce(array, proc, initial) {
1099
1111
  let count = array.length;
1100
1112
  let i = 0,
1101
- m = count % 8,
1113
+ m = count & 7,
1102
1114
  d = (count - m) / 8;
1115
+ let acc = initial;
1103
1116
 
1104
1117
  while (m--) {
1105
- initial = proc(initial, array[i], i++, array);
1118
+ acc = proc(acc, array[i], i++, array);
1106
1119
  }
1107
1120
 
1108
1121
  while (d--) {
1109
- initial = proc(initial, array[i], i++, array);
1110
- initial = proc(initial, array[i], i++, array);
1111
- initial = proc(initial, array[i], i++, array);
1112
- initial = proc(initial, array[i], i++, array);
1113
- initial = proc(initial, array[i], i++, array);
1114
- initial = proc(initial, array[i], i++, array);
1115
- initial = proc(initial, array[i], i++, array);
1116
- initial = proc(initial, array[i], i++, array);
1122
+ acc = proc(acc, array[i], i++, array);
1123
+ acc = proc(acc, array[i], i++, array);
1124
+ acc = proc(acc, array[i], i++, array);
1125
+ acc = proc(acc, array[i], i++, array);
1126
+ acc = proc(acc, array[i], i++, array);
1127
+ acc = proc(acc, array[i], i++, array);
1128
+ acc = proc(acc, array[i], i++, array);
1129
+ acc = proc(acc, array[i], i++, array);
1117
1130
  }
1118
1131
 
1119
- return initial;
1132
+ return acc;
1120
1133
  }
1121
1134
 
1122
1135
  exports.duffReduce = duffReduce;
@@ -1180,18 +1193,22 @@ var global = (/* unused pure expression or super */ null && (globalThis));
1180
1193
  Object.defineProperty(exports, "__esModule", ({
1181
1194
  value: true
1182
1195
  }));
1183
- exports.Heap = void 0;
1196
+ exports.MultiHeap = exports.Heap = void 0;
1184
1197
 
1185
- const alias_1 = __webpack_require__(5406); // Min heap
1198
+ const global_1 = __webpack_require__(4128);
1186
1199
 
1200
+ const invlist_1 = __webpack_require__(7452);
1201
+
1202
+ const memoize_1 = __webpack_require__(1808);
1187
1203
 
1188
1204
  const undefined = void 0;
1205
+ let size = 16;
1189
1206
 
1190
1207
  class Heap {
1191
- constructor(cmp = (a, b) => a > b ? 1 : a < b ? -1 : 0, stable = false) {
1208
+ constructor(cmp = Heap.max, stable = false) {
1192
1209
  this.cmp = cmp;
1193
1210
  this.stable = stable;
1194
- this.array = [];
1211
+ this.array = (0, global_1.Array)(size);
1195
1212
  this.$length = 0;
1196
1213
  }
1197
1214
 
@@ -1199,19 +1216,35 @@ class Heap {
1199
1216
  return this.$length;
1200
1217
  }
1201
1218
 
1202
- insert(value, order = value) {
1219
+ isEmpty() {
1220
+ return this.array[0] !== undefined;
1221
+ }
1222
+
1223
+ peek() {
1224
+ return this.array[0]?.[1];
1225
+ }
1226
+
1227
+ insert(value, order) {
1228
+ if (arguments.length < 2) {
1229
+ order = value;
1230
+ }
1231
+
1203
1232
  const array = this.array;
1204
1233
  const node = array[this.$length] = [order, value, this.$length++];
1205
- upHeapify(array, this.cmp, this.$length);
1234
+ upHeapify(this.cmp, array, this.$length);
1206
1235
  return node;
1207
1236
  }
1208
1237
 
1209
- replace(value, order = value) {
1210
- const array = this.array;
1238
+ replace(value, order) {
1239
+ if (arguments.length < 2) {
1240
+ order = value;
1241
+ }
1242
+
1211
1243
  if (this.$length === 0) return void this.insert(value, order);
1244
+ const array = this.array;
1212
1245
  const replaced = array[0][1];
1213
1246
  array[0] = [order, value, 0];
1214
- downHeapify(array, this.cmp, 1, this.$length, this.stable);
1247
+ downHeapify(this.cmp, array, 1, this.$length, this.stable);
1215
1248
  return replaced;
1216
1249
  }
1217
1250
 
@@ -1229,47 +1262,146 @@ class Heap {
1229
1262
  swap(array, index, --this.$length); // @ts-expect-error
1230
1263
 
1231
1264
  array[this.$length] = undefined;
1232
- index < this.$length && this.sort(array[index]);
1233
-
1234
- if (array.length >= 2 ** 16 && array.length >= this.$length * 2) {
1235
- array.splice(array.length / 2, array.length / 2);
1236
- }
1237
-
1265
+ index < this.$length && sort(this.cmp, array, index, this.$length, this.stable);
1238
1266
  return node[1];
1239
1267
  }
1240
1268
 
1241
- update(node, order = node[1], value = node[1]) {
1269
+ update(node, order, value) {
1270
+ if (arguments.length < 2) {
1271
+ order = node[0];
1272
+ }
1273
+
1242
1274
  const array = this.array;
1243
1275
  if (array[node[2]] !== node) throw new Error('Invalid node');
1244
- node[1] = value;
1276
+
1277
+ if (arguments.length > 2) {
1278
+ node[1] = value;
1279
+ }
1280
+
1245
1281
  if (this.cmp(node[0], node[0] = order) === 0) return;
1246
- this.sort(node);
1282
+ sort(this.cmp, array, node[2], this.$length, this.stable);
1247
1283
  }
1248
1284
 
1249
- sort(node) {
1250
- const array = this.array;
1251
- return upHeapify(array, this.cmp, node[2] + 1) || downHeapify(array, this.cmp, node[2] + 1, this.$length, this.stable);
1285
+ clear() {
1286
+ this.array = (0, global_1.Array)(size);
1287
+ this.$length = 0;
1288
+ }
1289
+
1290
+ }
1291
+
1292
+ exports.Heap = Heap;
1293
+
1294
+ Heap.max = (a, b) => a > b ? -1 : a < b ? 1 : 0;
1295
+
1296
+ Heap.min = (a, b) => a > b ? 1 : a < b ? -1 : 0;
1297
+
1298
+ class MultiHeap {
1299
+ constructor(cmp = MultiHeap.max, clean = true) {
1300
+ this.cmp = cmp;
1301
+ this.clean = clean;
1302
+ this.heap = new Heap(this.cmp);
1303
+ this.dict = new Map();
1304
+ this.list = (0, memoize_1.memoize)(order => {
1305
+ const list = new invlist_1.List();
1306
+ list[MultiHeap.order] = order;
1307
+ list[MultiHeap.heap] = this.heap.insert(list, order);
1308
+ return list;
1309
+ }, this.dict);
1310
+ this.$length = 0;
1311
+ }
1312
+
1313
+ get length() {
1314
+ return this.$length;
1315
+ }
1316
+
1317
+ isEmpty() {
1318
+ return this.heap.isEmpty();
1252
1319
  }
1253
1320
 
1254
1321
  peek() {
1255
- return this.array[0]?.[1];
1322
+ return this.heap.peek()?.head.value;
1323
+ }
1324
+
1325
+ insert(value, order) {
1326
+ if (arguments.length < 2) {
1327
+ order = value;
1328
+ }
1329
+
1330
+ ++this.$length;
1331
+ const list = this.list(order);
1332
+ return [order, list.push(value)];
1333
+ }
1334
+
1335
+ extract() {
1336
+ if (this.$length === 0) return;
1337
+ --this.$length;
1338
+ const list = this.heap.peek();
1339
+ const value = list.shift();
1340
+
1341
+ if (list.length === 0) {
1342
+ this.heap.extract();
1343
+ this.clean && this.dict.delete(list[MultiHeap.order]);
1344
+ }
1345
+
1346
+ return value;
1347
+ }
1348
+
1349
+ delete(node) {
1350
+ if (!node[1].list) throw new Error('Invalid node');
1351
+ const {
1352
+ 0: order,
1353
+ 1: lnode
1354
+ } = node;
1355
+ --this.$length;
1356
+
1357
+ if (lnode.list.length === 1) {
1358
+ this.heap.delete(lnode[MultiHeap.heap]);
1359
+ this.clean && this.dict.delete(order);
1360
+ }
1361
+
1362
+ return lnode.delete();
1363
+ }
1364
+
1365
+ update(node, order, value) {
1366
+ if (!node[1].list) throw new Error('Invalid node');
1367
+
1368
+ if (arguments.length < 2) {
1369
+ order = node[0];
1370
+ }
1371
+
1372
+ if (arguments.length > 2) {
1373
+ node[1].value = value;
1374
+ }
1375
+
1376
+ if (this.cmp(node[0], order) === 0) return node;
1377
+ this.delete(node);
1378
+ return this.insert(node[1].value, order);
1256
1379
  }
1257
1380
 
1258
1381
  clear() {
1259
- this.array = [];
1382
+ this.heap.clear();
1383
+ this.dict.clear();
1260
1384
  this.$length = 0;
1261
1385
  }
1262
1386
 
1263
1387
  }
1264
1388
 
1265
- exports.Heap = Heap;
1389
+ exports.MultiHeap = MultiHeap;
1390
+ MultiHeap.order = Symbol('order');
1391
+ MultiHeap.heap = Symbol('heap');
1392
+ MultiHeap.max = Heap.max;
1393
+ MultiHeap.min = Heap.min;
1394
+
1395
+ function sort(cmp, array, index, length, stable) {
1396
+ return upHeapify(cmp, array, index + 1) || downHeapify(cmp, array, index + 1, length, stable);
1397
+ }
1266
1398
 
1267
- function upHeapify(array, cmp, index) {
1399
+ function upHeapify(cmp, array, index) {
1268
1400
  const order = array[index - 1][0];
1269
1401
  let changed = false;
1270
1402
 
1271
1403
  while (index > 1) {
1272
- const parent = (0, alias_1.floor)(index / 2);
1404
+ const parent = index / 2 | 0;
1273
1405
  if (cmp(array[parent - 1][0], order) <= 0) break;
1274
1406
  swap(array, index - 1, parent - 1);
1275
1407
  index = parent;
@@ -1279,7 +1411,7 @@ function upHeapify(array, cmp, index) {
1279
1411
  return changed;
1280
1412
  }
1281
1413
 
1282
- function downHeapify(array, cmp, index, length, stable) {
1414
+ function downHeapify(cmp, array, index, length, stable) {
1283
1415
  let changed = false;
1284
1416
 
1285
1417
  while (index < length) {
@@ -1357,7 +1489,7 @@ __exportStar(__webpack_require__(2310), exports);
1357
1489
  /***/ ((__unused_webpack_module, exports) => {
1358
1490
 
1359
1491
  "use strict";
1360
- // Circular inverse list
1492
+ // Circular Inverse List
1361
1493
 
1362
1494
  var _a;
1363
1495
 
@@ -1395,10 +1527,18 @@ class List {
1395
1527
  return this.head = this.push(value);
1396
1528
  }
1397
1529
 
1530
+ push(value) {
1531
+ return new Node(this, value, this.head, this.head?.prev);
1532
+ }
1533
+
1398
1534
  unshiftNode(node) {
1399
1535
  return this.head = this.pushNode(node);
1400
1536
  }
1401
1537
 
1538
+ pushNode(node) {
1539
+ return this.insert(node, this.head);
1540
+ }
1541
+
1402
1542
  unshiftRotationally(value) {
1403
1543
  const node = this.last;
1404
1544
  if (!node) return this.unshift(value);
@@ -1407,18 +1547,6 @@ class List {
1407
1547
  return node;
1408
1548
  }
1409
1549
 
1410
- shift() {
1411
- return this.head?.delete();
1412
- }
1413
-
1414
- push(value) {
1415
- return new Node(value, this.head, this.head?.prev, this);
1416
- }
1417
-
1418
- pushNode(node) {
1419
- return this.insert(node, this.head);
1420
- }
1421
-
1422
1550
  pushRotationally(value) {
1423
1551
  const node = this.head;
1424
1552
  if (!node) return this.push(value);
@@ -1427,12 +1555,16 @@ class List {
1427
1555
  return node;
1428
1556
  }
1429
1557
 
1558
+ shift() {
1559
+ return this.head?.delete();
1560
+ }
1561
+
1430
1562
  pop() {
1431
1563
  return this.last?.delete();
1432
1564
  }
1433
1565
 
1434
1566
  insert(node, before = this.head) {
1435
- if (node.list === this) return before && node.move(before), node;
1567
+ if (node.list === this) return node.moveTo(before), node;
1436
1568
  node.delete();
1437
1569
  ++this[LENGTH];
1438
1570
  this.head ??= node; // @ts-expect-error
@@ -1457,11 +1589,11 @@ class List {
1457
1589
  exports.List = List;
1458
1590
 
1459
1591
  class Node {
1460
- constructor(value, next, prev, list = next?.list ?? new List()) {
1592
+ constructor(list, value, next, prev) {
1593
+ this.list = list;
1461
1594
  this.value = value;
1462
1595
  this.next = next;
1463
1596
  this.prev = prev;
1464
- this.list = list;
1465
1597
  ++list[LENGTH];
1466
1598
  list.head ??= this;
1467
1599
  next && prev ? next.prev = prev.next = this : this.next = this.prev = this;
@@ -1470,17 +1602,21 @@ class Node {
1470
1602
  delete() {
1471
1603
  if (!this.list) return this.value;
1472
1604
  --this.list[LENGTH];
1605
+ const {
1606
+ next,
1607
+ prev
1608
+ } = this;
1473
1609
 
1474
1610
  if (this.list.head === this) {
1475
- this.list.head = this.next === this ? undefined : this.next;
1611
+ this.list.head = next === this ? undefined : next;
1476
1612
  }
1477
1613
 
1478
- if (this.next) {
1479
- this.next.prev = this.prev;
1614
+ if (next) {
1615
+ next.prev = prev;
1480
1616
  }
1481
1617
 
1482
- if (this.prev) {
1483
- this.prev.next = this.next;
1618
+ if (prev) {
1619
+ prev.next = next;
1484
1620
  } // @ts-expect-error
1485
1621
 
1486
1622
 
@@ -1491,20 +1627,19 @@ class Node {
1491
1627
  }
1492
1628
 
1493
1629
  insertBefore(value) {
1494
- return new Node(value, this, this.prev, this.list);
1630
+ return new Node(this.list, value, this, this.prev);
1495
1631
  }
1496
1632
 
1497
1633
  insertAfter(value) {
1498
- return new Node(value, this.next, this, this.list);
1634
+ return new Node(this.list, value, this.next, this);
1499
1635
  }
1500
1636
 
1501
- move(before) {
1637
+ moveTo(before) {
1502
1638
  if (!before) return false;
1503
1639
  if (this === before) return false;
1504
1640
  if (before.list !== this.list) return before.list.insert(this, before), true;
1505
1641
  const a1 = this;
1506
1642
  const b1 = before;
1507
- if (!b1) return false;
1508
1643
  if (a1.next === b1) return false;
1509
1644
  const b0 = b1.prev;
1510
1645
  const a0 = a1.prev;
@@ -1519,12 +1654,12 @@ class Node {
1519
1654
  }
1520
1655
 
1521
1656
  moveToHead() {
1522
- this.move(this.list.head);
1657
+ this.moveTo(this.list.head);
1523
1658
  this.list.head = this;
1524
1659
  }
1525
1660
 
1526
1661
  moveToLast() {
1527
- this.move(this.list.head);
1662
+ this.moveTo(this.list.head);
1528
1663
  }
1529
1664
 
1530
1665
  swap(node) {
@@ -1533,8 +1668,8 @@ class Node {
1533
1668
  if (node1 === node2) return false;
1534
1669
  const node3 = node2.next;
1535
1670
  if (node1.list !== node2.list) throw new Error(`Spica: InvList: Cannot swap nodes across lists.`);
1536
- node2.move(node1);
1537
- node1.move(node3);
1671
+ node2.moveTo(node1);
1672
+ node1.moveTo(node3);
1538
1673
 
1539
1674
  switch (this.list.head) {
1540
1675
  case node1:
@@ -1570,45 +1705,44 @@ const alias_1 = __webpack_require__(5406);
1570
1705
 
1571
1706
  const compare_1 = __webpack_require__(5529);
1572
1707
 
1573
- function memoize(f, identify = (...as) => as[0], memory) {
1574
- if (typeof identify === 'object') return memoize(f, void 0, identify);
1575
- if (memory === void 0) return memoize(f, identify, new global_1.Map());
1576
- if ((0, alias_1.isArray)(memory)) return memoize(f, identify, {
1577
- has(key) {
1578
- return memory[key] !== void 0;
1579
- },
1708
+ const undefined = void 0;
1580
1709
 
1581
- get(key) {
1582
- return memory[key];
1583
- },
1710
+ function memoize(f, identify = (...as) => as[0], memory) {
1711
+ if (typeof identify === 'object') return memoize(f, undefined, identify);
1712
+ return (0, alias_1.isArray)(memory) ? memoizeArray(f, identify, memory) : memoizeObject(f, identify, memory ?? new global_1.Map());
1713
+ }
1584
1714
 
1585
- set(key, value) {
1586
- memory[key] = value;
1587
- return this;
1588
- },
1715
+ exports.memoize = memoize;
1589
1716
 
1590
- delete() {
1591
- throw 0;
1592
- }
1717
+ function memoizeArray(f, identify, memory) {
1718
+ let nullish = false;
1719
+ return (...as) => {
1720
+ const b = identify(...as);
1721
+ let z = memory[b];
1722
+ if (z !== undefined || nullish && memory[b] !== undefined) return z;
1723
+ z = f(...as);
1724
+ nullish ||= z === undefined;
1725
+ memory[b] = z;
1726
+ return z;
1727
+ };
1728
+ }
1593
1729
 
1594
- });
1730
+ function memoizeObject(f, identify, memory) {
1595
1731
  let nullish = false;
1596
1732
  return (...as) => {
1597
1733
  const b = identify(...as);
1598
1734
  let z = memory.get(b);
1599
- if (z !== void 0 || nullish && memory.has(b)) return z;
1735
+ if (z !== undefined || nullish && memory.has(b)) return z;
1600
1736
  z = f(...as);
1601
- nullish ||= z === void 0;
1737
+ nullish ||= z === undefined;
1602
1738
  memory.set(b, z);
1603
1739
  return z;
1604
1740
  };
1605
1741
  }
1606
1742
 
1607
- exports.memoize = memoize;
1608
-
1609
1743
  function reduce(f, identify = (...as) => as[0]) {
1610
- let key = [];
1611
- let val = [];
1744
+ let key = {};
1745
+ let val;
1612
1746
  return (...as) => {
1613
1747
  const b = identify(...as);
1614
1748
 
@@ -1631,34 +1765,238 @@ exports.reduce = reduce;
1631
1765
  "use strict";
1632
1766
 
1633
1767
 
1634
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
1635
- if (k2 === undefined) k2 = k;
1636
- var desc = Object.getOwnPropertyDescriptor(m, k);
1768
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
1769
+ if (k2 === undefined) k2 = k;
1770
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1771
+
1772
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1773
+ desc = {
1774
+ enumerable: true,
1775
+ get: function () {
1776
+ return m[k];
1777
+ }
1778
+ };
1779
+ }
1780
+
1781
+ Object.defineProperty(o, k2, desc);
1782
+ } : function (o, m, k, k2) {
1783
+ if (k2 === undefined) k2 = k;
1784
+ o[k2] = m[k];
1785
+ });
1786
+
1787
+ var __exportStar = this && this.__exportStar || function (m, exports) {
1788
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1789
+ };
1790
+
1791
+ Object.defineProperty(exports, "__esModule", ({
1792
+ value: true
1793
+ }));
1794
+
1795
+ __exportStar(__webpack_require__(5084), exports);
1796
+
1797
+ /***/ }),
1798
+
1799
+ /***/ 4934:
1800
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1801
+
1802
+ "use strict";
1803
+
1804
+
1805
+ Object.defineProperty(exports, "__esModule", ({
1806
+ value: true
1807
+ }));
1808
+ exports.PriorityQueue = exports.Queue = void 0;
1809
+
1810
+ const global_1 = __webpack_require__(4128);
1811
+
1812
+ const heap_1 = __webpack_require__(818);
1813
+
1814
+ const memoize_1 = __webpack_require__(1808);
1815
+
1816
+ const undefined = void 0;
1817
+ const size = 2048;
1818
+ const initsize = 16;
1819
+
1820
+ class Queue {
1821
+ constructor() {
1822
+ this.head = new FixedQueue(initsize);
1823
+ this.tail = this.head;
1824
+ this.count = 0;
1825
+ this.irregular = 0;
1826
+ }
1827
+
1828
+ get length() {
1829
+ return this.count === 0 ? this.head.length : this.head.length + this.tail.length + (size - 1) * (this.count - 2) + (this.irregular || size) - 1;
1830
+ }
1831
+
1832
+ isEmpty() {
1833
+ return this.head.isEmpty();
1834
+ }
1835
+
1836
+ peek(index = 0) {
1837
+ return index === 0 ? this.head.peek(0) : this.tail.peek(-1);
1838
+ }
1839
+
1840
+ push(value) {
1841
+ const tail = this.tail;
1842
+
1843
+ if (tail.isFull()) {
1844
+ if (tail.next.isEmpty()) {
1845
+ this.tail = tail.next;
1846
+ } else {
1847
+ this.tail = tail.next = new FixedQueue(size, tail.next);
1848
+ }
1849
+
1850
+ ++this.count;
1851
+
1852
+ if (tail.size !== size && tail !== this.head) {
1853
+ this.irregular = tail.size;
1854
+ }
1855
+ }
1856
+
1857
+ this.tail.push(value);
1858
+ }
1859
+
1860
+ pop() {
1861
+ const head = this.head;
1862
+ const value = head.pop();
1863
+
1864
+ if (head.isEmpty() && !head.next.isEmpty()) {
1865
+ --this.count;
1866
+ this.head = head.next;
1867
+
1868
+ if (this.head.size === this.irregular) {
1869
+ this.irregular = 0;
1870
+ }
1871
+ }
1872
+
1873
+ return value;
1874
+ }
1875
+
1876
+ clear() {
1877
+ this.head = this.tail = new FixedQueue(initsize);
1878
+ this.count = 0;
1879
+ this.irregular = 0;
1880
+ }
1881
+
1882
+ *[Symbol.iterator]() {
1883
+ while (!this.isEmpty()) {
1884
+ yield this.pop();
1885
+ }
1886
+
1887
+ return;
1888
+ }
1889
+
1890
+ }
1891
+
1892
+ exports.Queue = Queue;
1893
+
1894
+ class FixedQueue {
1895
+ constructor(size, next) {
1896
+ this.size = size;
1897
+ this.array = (0, global_1.Array)(this.size);
1898
+ this.mask = this.array.length - 1;
1899
+ this.head = 0;
1900
+ this.tail = 0;
1901
+ this.next = next ?? this;
1902
+ }
1903
+
1904
+ get length() {
1905
+ return this.tail >= this.head ? this.tail - this.head : this.array.length - this.head + this.tail;
1906
+ }
1907
+
1908
+ isEmpty() {
1909
+ return this.tail === this.head;
1910
+ }
1911
+
1912
+ isFull() {
1913
+ return (this.tail + 1 & this.mask) === this.head;
1914
+ }
1915
+
1916
+ peek(index = 0) {
1917
+ return index === 0 ? this.array[this.head] : this.array[this.tail - 1 & this.mask];
1918
+ }
1919
+
1920
+ push(value) {
1921
+ this.array[this.tail] = value;
1922
+ this.tail = this.tail + 1 & this.mask;
1923
+ }
1924
+
1925
+ pop() {
1926
+ if (this.isEmpty()) return;
1927
+ const value = this.array[this.head];
1928
+ this.array[this.head] = undefined;
1929
+ this.head = this.head + 1 & this.mask;
1930
+ return value;
1931
+ }
1932
+
1933
+ }
1934
+
1935
+ class PriorityQueue {
1936
+ constructor(cmp = PriorityQueue.max, clean = true) {
1937
+ this.clean = clean;
1938
+ this.dict = new Map();
1939
+ this.queue = (0, memoize_1.memoize)(priority => {
1940
+ const queue = new Queue();
1941
+ queue[PriorityQueue.priority] = priority;
1942
+ this.heap.insert(queue, priority);
1943
+ return queue;
1944
+ }, this.dict);
1945
+ this.$length = 0;
1946
+ this.heap = new heap_1.Heap(cmp);
1947
+ }
1948
+
1949
+ get length() {
1950
+ return this.$length;
1951
+ }
1952
+
1953
+ isEmpty() {
1954
+ return this.$length === 0;
1955
+ }
1956
+
1957
+ peek() {
1958
+ return this.heap.peek()?.peek();
1959
+ }
1960
+
1961
+ push(value, priority) {
1962
+ ++this.$length;
1963
+ this.queue(priority).push(value);
1964
+ }
1965
+
1966
+ pop() {
1967
+ if (this.$length === 0) return;
1968
+ --this.$length;
1969
+ const queue = this.heap.peek();
1970
+ const value = queue.pop();
1971
+
1972
+ if (queue.isEmpty()) {
1973
+ this.heap.extract();
1974
+ this.clean && this.dict.delete(queue[PriorityQueue.priority]);
1975
+ }
1976
+
1977
+ return value;
1978
+ }
1637
1979
 
1638
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1639
- desc = {
1640
- enumerable: true,
1641
- get: function () {
1642
- return m[k];
1643
- }
1644
- };
1980
+ clear() {
1981
+ this.heap.clear();
1982
+ this.dict.clear();
1983
+ this.$length = 0;
1645
1984
  }
1646
1985
 
1647
- Object.defineProperty(o, k2, desc);
1648
- } : function (o, m, k, k2) {
1649
- if (k2 === undefined) k2 = k;
1650
- o[k2] = m[k];
1651
- });
1986
+ *[Symbol.iterator]() {
1987
+ while (!this.isEmpty()) {
1988
+ yield this.pop();
1989
+ }
1652
1990
 
1653
- var __exportStar = this && this.__exportStar || function (m, exports) {
1654
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1655
- };
1991
+ return;
1992
+ }
1656
1993
 
1657
- Object.defineProperty(exports, "__esModule", ({
1658
- value: true
1659
- }));
1994
+ }
1660
1995
 
1661
- __exportStar(__webpack_require__(5084), exports);
1996
+ exports.PriorityQueue = PriorityQueue;
1997
+ PriorityQueue.priority = Symbol('priority');
1998
+ PriorityQueue.max = heap_1.Heap.max;
1999
+ PriorityQueue.min = heap_1.Heap.min;
1662
2000
 
1663
2001
  /***/ }),
1664
2002
 
@@ -1675,9 +2013,10 @@ exports.unique = exports.rndAf = exports.rndAP = exports.rnd0_ = exports.rnd0Z =
1675
2013
 
1676
2014
  const global_1 = __webpack_require__(4128);
1677
2015
 
1678
- const bases = [...Array(7)].map((_, i) => 1 << i);
1679
- const dict0_ = [...[...Array(36)].map((_, i) => i.toString(36)), ...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26), '-', '_'];
1680
- const dictAz = [...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26), ...[...Array(36)].map((_, i) => i.toString(36)).slice(-26)];
2016
+ const radixes = Object.freeze([...Array(7)].map((_, i) => 1 << i));
2017
+ const masks = Object.freeze(radixes.map(radix => radix - 1));
2018
+ const dict0_ = Object.freeze([...[...Array(36)].map((_, i) => i.toString(36)), ...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26), '-', '_']);
2019
+ const dictAz = Object.freeze([...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26), ...[...Array(36)].map((_, i) => i.toString(36)).slice(-26)]);
1681
2020
  exports.rnd16 = cons(16);
1682
2021
  exports.rnd32 = cons(32);
1683
2022
  exports.rnd62 = cons(62);
@@ -1689,36 +2028,54 @@ exports.rnd0_ = conv(exports.rnd64, dict0_);
1689
2028
  exports.rndAP = conv(exports.rnd16, dictAz);
1690
2029
  exports.rndAf = conv(exports.rnd32, dictAz);
1691
2030
 
1692
- function unique(rnd, len, mem) {
1693
- const clear = !mem;
2031
+ function unique(rnd, len = 1, mem) {
2032
+ const independence = !mem;
1694
2033
  mem ??= new global_1.Set();
1695
- let limit = 5;
1696
- return () => {
1697
- while (true) {
1698
- for (let i = 0; i < limit; ++i) {
1699
- const r = rnd(len);
1700
- if (mem.has(r)) continue;
2034
+ const trials = 3;
2035
+ let prefixes;
2036
+ let prefix = '';
2037
+ return function random() {
2038
+ for (let i = 0; i < trials; ++i) {
2039
+ const r = rnd(len);
2040
+ if (mem.has(r)) continue;
2041
+
2042
+ try {
1701
2043
  mem.add(r);
1702
- return r;
2044
+ } catch (reason) {
2045
+ // ベンチマーク程度でもSetがパンクする場合がある。
2046
+ if (!independence) throw reason;
2047
+ prefixes ??= new global_1.Set();
2048
+ prefix ||= '?';
2049
+
2050
+ for (let i = 0; i < trials; ++i) {
2051
+ prefix = rnd(prefix.length);
2052
+ if (prefixes.has(prefix)) continue;
2053
+ prefixes.add(prefix);
2054
+ mem.clear();
2055
+ return random();
2056
+ }
2057
+
2058
+ prefixes = new global_1.Set();
2059
+ prefix += '?';
2060
+ return random();
1703
2061
  }
1704
2062
 
1705
- clear && mem.clear();
1706
- ++len;
1707
- limit = len < 3 ? limit : 3;
2063
+ return prefix + r;
1708
2064
  }
2065
+
2066
+ ++len;
2067
+ independence && mem.clear();
2068
+ return random();
1709
2069
  };
1710
2070
  }
1711
2071
 
1712
2072
  exports.unique = unique;
1713
2073
 
1714
- function cons(radix) {
1715
- const base = bases.find(base => base >= radix);
1716
- const len = bases.indexOf(base);
1717
- return () => {
1718
- while (true) {
1719
- const r = random(len);
1720
- if (r < radix) return r;
1721
- }
2074
+ function cons(size) {
2075
+ const len = radixes.findIndex(radix => radix >= size);
2076
+ return function rnd() {
2077
+ const r = random(len);
2078
+ return r < size ? r : rnd();
1722
2079
  };
1723
2080
  }
1724
2081
 
@@ -1736,7 +2093,6 @@ function conv(rnd, dict) {
1736
2093
 
1737
2094
  const buffer = new Uint16Array(512);
1738
2095
  const digit = 16;
1739
- const masks = bases.map((_, i) => +`0b${'1'.repeat(i) || 0}`);
1740
2096
  let index = buffer.length;
1741
2097
  let offset = digit;
1742
2098
 
@@ -1761,6 +2117,235 @@ function random(len) {
1761
2117
 
1762
2118
  /***/ }),
1763
2119
 
2120
+ /***/ 6395:
2121
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2122
+
2123
+ "use strict";
2124
+
2125
+
2126
+ Object.defineProperty(exports, "__esModule", ({
2127
+ value: true
2128
+ }));
2129
+ exports.Ring = void 0;
2130
+
2131
+ const global_1 = __webpack_require__(4128);
2132
+
2133
+ const alias_1 = __webpack_require__(5406);
2134
+
2135
+ const array_1 = __webpack_require__(8112);
2136
+
2137
+ const undefined = void 0;
2138
+ const empty = Symbol('empty');
2139
+
2140
+ const unempty = value => value === empty ? undefined : value;
2141
+
2142
+ const space = Object.freeze((0, global_1.Array)(100).fill(empty));
2143
+ let size = 16;
2144
+
2145
+ class Ring {
2146
+ constructor() {
2147
+ this.array = (0, global_1.Array)(size);
2148
+ this.head = 0;
2149
+ this.tail = 0;
2150
+ this.$length = 0;
2151
+ this.excess = 0;
2152
+ }
2153
+
2154
+ get length() {
2155
+ return this.$length;
2156
+ }
2157
+
2158
+ at(index) {
2159
+ // Inline the code for optimization.
2160
+ const array = this.array;
2161
+
2162
+ if (index >= 0) {
2163
+ if (index >= this.$length) return;
2164
+ return unempty(array[(this.head - 1 + index) % array.length]);
2165
+ } else {
2166
+ if (-index > this.$length) return;
2167
+ return this.tail + index >= 0 ? unempty(array[this.tail + index]) : unempty(array[array.length + this.tail + index]);
2168
+ }
2169
+ }
2170
+
2171
+ replace(index, value, replacer) {
2172
+ const array = this.array;
2173
+
2174
+ if (index >= 0) {
2175
+ if (index >= this.$length) throw new RangeError('Invalid index');
2176
+ index = (this.head - 1 + index) % array.length;
2177
+ } else {
2178
+ if (-index > this.$length) throw new RangeError('Invalid index');
2179
+ index = this.tail + index >= 0 ? this.tail + index : array.length + this.tail + index;
2180
+ }
2181
+
2182
+ const val = unempty(array[index]);
2183
+ array[index] = replacer ? replacer(val, value) : value;
2184
+ return val;
2185
+ }
2186
+
2187
+ push(value) {
2188
+ const array = this.array;
2189
+ let {
2190
+ head,
2191
+ tail
2192
+ } = this;
2193
+ tail = this.tail = next(head, tail, array.length);
2194
+ head = this.head ||= tail;
2195
+
2196
+ if (head === tail && this.$length !== 0) {
2197
+ (0, array_1.splice)(array, tail - 1, 0, ...space);
2198
+ head = this.head += space.length;
2199
+ }
2200
+
2201
+ array[tail - 1] = value;
2202
+ ++this.$length;
2203
+ }
2204
+
2205
+ unshift(value) {
2206
+ const array = this.array;
2207
+ let {
2208
+ head,
2209
+ tail
2210
+ } = this;
2211
+ head = this.head = prev(head, tail, array.length);
2212
+ tail = this.tail ||= head;
2213
+
2214
+ if (head === tail && this.$length !== 0) {
2215
+ (0, array_1.splice)(array, head, 0, ...space);
2216
+ head = this.head += space.length;
2217
+ }
2218
+
2219
+ array[head - 1] = value;
2220
+ ++this.$length;
2221
+ }
2222
+
2223
+ pop() {
2224
+ if (this.$length === 0) return;
2225
+ const array = this.array;
2226
+ const i = this.tail - 1;
2227
+ const value = unempty(array[i]);
2228
+ array[i] = empty;
2229
+ --this.$length === 0 ? this.head = this.tail = 0 : this.tail = this.tail === 1 ? array.length : this.tail - 1;
2230
+ return value;
2231
+ }
2232
+
2233
+ shift() {
2234
+ if (this.$length === 0) return;
2235
+ const array = this.array;
2236
+ const i = this.head - 1;
2237
+ const value = unempty(array[i]);
2238
+ array[i] = empty;
2239
+ --this.$length === 0 ? this.head = this.tail = 0 : this.head = this.head === array.length ? 1 : this.head + 1;
2240
+ return value;
2241
+ }
2242
+
2243
+ splice(index, count, ...values) {
2244
+ const array = this.array;
2245
+
2246
+ if (this.excess > 100 && array.length - this.$length > 200) {
2247
+ (0, array_1.splice)(array, 0, 100 - (0, array_1.splice)(array, this.tail, 100).length);
2248
+ this.excess -= 100;
2249
+ } else if (-this.excess > array.length * 2) {
2250
+ this.excess = array.length;
2251
+ }
2252
+
2253
+ index = index < 0 ? (0, alias_1.max)(0, this.$length + index) : index <= this.$length ? index : this.$length;
2254
+ count = (0, alias_1.min)((0, alias_1.max)(count, 0), this.$length - index);
2255
+
2256
+ if (values.length === 0) {
2257
+ if (count === 0) return [];
2258
+
2259
+ switch (index) {
2260
+ case 0:
2261
+ if (count === 1) return [this.shift()];
2262
+ break;
2263
+
2264
+ case this.$length - 1:
2265
+ if (count === 1) return [this.pop()];
2266
+ break;
2267
+
2268
+ case this.$length:
2269
+ return [];
2270
+ }
2271
+ }
2272
+
2273
+ index = (this.head || 1) - 1 + index;
2274
+ index = index > array.length ? index % array.length : index;
2275
+ this.excess += values.length - count;
2276
+ this.$length += values.length - count; // |--H>*>T--|
2277
+
2278
+ if (this.head <= this.tail) {
2279
+ this.tail += values.length - count;
2280
+ return (0, array_1.splice)(array, index, count, ...values);
2281
+ } // |*>T---H>>|
2282
+
2283
+
2284
+ if (index < this.tail) {
2285
+ this.head += values.length - count;
2286
+ this.tail += values.length - count;
2287
+ return (0, array_1.splice)(array, index, count, ...values);
2288
+ } // |>>T---H>*|
2289
+
2290
+
2291
+ const cnt = (0, alias_1.min)(count, array.length - index);
2292
+ const vs = (0, array_1.splice)(array, index, cnt, ...(0, array_1.splice)(values, 0, cnt));
2293
+ vs.push(...(0, array_1.splice)(array, 0, count - vs.length, ...values));
2294
+ return vs;
2295
+ }
2296
+
2297
+ clear() {
2298
+ this.array = (0, global_1.Array)(size);
2299
+ this.$length = this.head = this.tail = 0;
2300
+ }
2301
+
2302
+ includes(value) {
2303
+ return this.array.includes(value);
2304
+ }
2305
+
2306
+ relational(index) {
2307
+ if (index === -1) return -1;
2308
+ return index + 1 >= this.head ? index + 1 - this.head : this.array.length - this.head + index;
2309
+ }
2310
+
2311
+ indexOf(value) {
2312
+ return this.relational((0, array_1.indexOf)(this.array, value));
2313
+ }
2314
+
2315
+ findIndex(f) {
2316
+ return this.relational(this.array.findIndex(value => value !== empty && f(value)));
2317
+ }
2318
+
2319
+ find(f) {
2320
+ return unempty(this.array.find(value => value !== empty && f(value)));
2321
+ }
2322
+
2323
+ toArray() {
2324
+ 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));
2325
+ }
2326
+
2327
+ *[Symbol.iterator]() {
2328
+ for (let i = 0; i < this.$length; ++i) {
2329
+ yield this.at(i);
2330
+ }
2331
+
2332
+ return;
2333
+ }
2334
+
2335
+ }
2336
+
2337
+ exports.Ring = Ring;
2338
+
2339
+ function next(head, tail, length) {
2340
+ return tail === length && head !== 1 ? 1 : tail + 1;
2341
+ }
2342
+
2343
+ function prev(head, tail, length) {
2344
+ return head === 0 || head === 1 ? tail === length ? length + 1 : length : head - 1;
2345
+ }
2346
+
2347
+ /***/ }),
2348
+
1764
2349
  /***/ 5177:
1765
2350
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1766
2351
 
@@ -1770,7 +2355,7 @@ function random(len) {
1770
2355
  Object.defineProperty(exports, "__esModule", ({
1771
2356
  value: true
1772
2357
  }));
1773
- exports.isPrimitive = exports.isType = exports.type = void 0;
2358
+ exports.isPrimitive = exports.is = exports.type = void 0;
1774
2359
 
1775
2360
  const global_1 = __webpack_require__(4128);
1776
2361
 
@@ -1780,35 +2365,64 @@ const ObjectPrototype = Object.prototype;
1780
2365
  const ArrayPrototype = Array.prototype;
1781
2366
 
1782
2367
  function type(value) {
1783
- if (value === void 0) return 'undefined';
1784
- if (value === null) return 'null';
1785
2368
  const type = typeof value;
1786
2369
 
1787
- if (type === 'object') {
1788
- if (value[global_1.Symbol.toStringTag]) return value[global_1.Symbol.toStringTag];
1789
- const proto = (0, alias_1.ObjectGetPrototypeOf)(value);
1790
- if (proto === ObjectPrototype) return 'Object';
1791
- if (proto === ArrayPrototype) return 'Array';
1792
- return (0, alias_1.toString)(value).slice(8, -1);
1793
- }
2370
+ switch (type) {
2371
+ case 'function':
2372
+ return 'Function';
1794
2373
 
1795
- if (type === 'function') return 'Function';
1796
- return type;
2374
+ case 'object':
2375
+ if (value === null) return 'null';
2376
+ const tag = value[global_1.Symbol.toStringTag];
2377
+ if (tag) return tag;
2378
+
2379
+ switch ((0, alias_1.ObjectGetPrototypeOf)(value)) {
2380
+ case ArrayPrototype:
2381
+ return 'Array';
2382
+
2383
+ case ObjectPrototype:
2384
+ return 'Object';
2385
+
2386
+ default:
2387
+ return (0, alias_1.toString)(value).slice(8, -1);
2388
+ }
2389
+
2390
+ default:
2391
+ return type;
2392
+ }
1797
2393
  }
1798
2394
 
1799
2395
  exports.type = type;
1800
2396
 
1801
- function isType(value, name) {
1802
- if (name === 'object') return value !== null && typeof value === name;
1803
- if (name === 'function') return typeof value === name;
1804
- return type(value) === name;
2397
+ function is(type, value) {
2398
+ switch (type) {
2399
+ case 'null':
2400
+ return value === null;
2401
+
2402
+ case 'array':
2403
+ return (0, alias_1.isArray)(value);
2404
+
2405
+ case 'object':
2406
+ return value !== null && typeof value === type;
2407
+
2408
+ default:
2409
+ return typeof value === type;
2410
+ }
1805
2411
  }
1806
2412
 
1807
- exports.isType = isType;
2413
+ exports.is = is;
1808
2414
 
1809
2415
  function isPrimitive(value) {
1810
- const type = typeof value;
1811
- return type === 'object' || type === 'function' ? value === null : true;
2416
+ switch (typeof value) {
2417
+ case 'function':
2418
+ return false;
2419
+
2420
+ case 'object':
2421
+ return value === null;
2422
+
2423
+ default:
2424
+ return true;
2425
+ }
1812
2426
  }
1813
2427
 
1814
2428
  exports.isPrimitive = isPrimitive;
@@ -1847,84 +2461,80 @@ Object.defineProperty(exports, "ReadonlyURL", ({
1847
2461
  return format_3.ReadonlyURL;
1848
2462
  }
1849
2463
  }));
1850
- const internal = Symbol.for('spica/url::internal');
1851
2464
 
1852
2465
  class URL {
1853
2466
  constructor(source, base) {
1854
2467
  this.source = source;
1855
2468
  this.base = base;
1856
- this[internal] = {
1857
- url: new format_1.ReadonlyURL(source, base),
1858
- searchParams: void 0
1859
- };
2469
+ this.url = new format_1.ReadonlyURL(source, base);
1860
2470
  }
1861
2471
 
1862
2472
  get href() {
1863
- return this[internal].searchParams?.toString().replace(/^(?=.)/, `${this[internal].url.href.slice(0, -this[internal].url.query.length - this[internal].url.fragment.length || this[internal].url.href.length)}?`).concat(this.fragment) ?? this[internal].url.href;
2473
+ return this.params?.toString().replace(/^(?=.)/, `${this.url.href.slice(0, -this.url.query.length - this.url.fragment.length || this.url.href.length)}?`).concat(this.fragment) ?? this.url.href;
1864
2474
  }
1865
2475
 
1866
2476
  get resource() {
1867
- return this[internal].searchParams?.toString().replace(/^(?=.)/, `${this[internal].url.href.slice(0, -this[internal].url.query.length - this[internal].url.fragment.length || this[internal].url.href.length)}?`) ?? this[internal].url.resource;
2477
+ return this.params?.toString().replace(/^(?=.)/, `${this.url.href.slice(0, -this.url.query.length - this.url.fragment.length || this.url.href.length)}?`) ?? this.url.resource;
1868
2478
  }
1869
2479
 
1870
2480
  get origin() {
1871
- return this[internal].url.origin;
2481
+ return this.url.origin;
1872
2482
  }
1873
2483
 
1874
2484
  get scheme() {
1875
- return this[internal].url.protocol.slice(0, -1);
2485
+ return this.url.protocol.slice(0, -1);
1876
2486
  }
1877
2487
 
1878
2488
  get protocol() {
1879
- return this[internal].url.protocol;
2489
+ return this.url.protocol;
1880
2490
  }
1881
2491
 
1882
2492
  get username() {
1883
- return this[internal].url.username;
2493
+ return this.url.username;
1884
2494
  }
1885
2495
 
1886
2496
  get password() {
1887
- return this[internal].url.password;
2497
+ return this.url.password;
1888
2498
  }
1889
2499
 
1890
2500
  get host() {
1891
- return this[internal].url.host;
2501
+ return this.url.host;
1892
2502
  }
1893
2503
 
1894
2504
  get hostname() {
1895
- return this[internal].url.hostname;
2505
+ return this.url.hostname;
1896
2506
  }
1897
2507
 
1898
2508
  get port() {
1899
- return this[internal].url.port;
2509
+ return this.url.port;
1900
2510
  }
1901
2511
 
1902
2512
  get path() {
1903
- return this[internal].searchParams?.toString().replace(/^(?=.)/, `${this.pathname}?`) ?? this[internal].url.path;
2513
+ return this.params?.toString().replace(/^(?=.)/, `${this.pathname}?`) ?? this.url.path;
1904
2514
  }
1905
2515
 
1906
2516
  get pathname() {
1907
- return this[internal].url.pathname;
2517
+ return this.url.pathname;
1908
2518
  }
1909
2519
 
1910
2520
  get search() {
1911
- return this[internal].searchParams?.toString().replace(/^(?=.)/, '?') ?? this[internal].url.search;
2521
+ return this.params?.toString().replace(/^(?=.)/, '?') ?? this.url.search;
1912
2522
  }
1913
2523
 
1914
2524
  get query() {
1915
- return this[internal].searchParams?.toString().replace(/^(?=.)/, '?') ?? this[internal].url.query;
2525
+ return this.params?.toString().replace(/^(?=.)/, '?') ?? this.url.query;
1916
2526
  }
1917
2527
 
1918
2528
  get hash() {
1919
- return this[internal].url.hash;
2529
+ return this.url.hash;
1920
2530
  }
1921
2531
 
1922
2532
  get fragment() {
1923
- return this[internal].url.fragment;
2533
+ return this.url.fragment;
1924
2534
  }
1925
2535
 
1926
2536
  get searchParams() {
1927
- return this[internal].searchParams ??= new global_1.URLSearchParams(this.search);
2537
+ return this.params ??= new global_1.URLSearchParams(this.search);
1928
2538
  }
1929
2539
 
1930
2540
  toString() {
@@ -1973,7 +2583,6 @@ function encode(url) {
1973
2583
  }
1974
2584
 
1975
2585
  exports._encode = encode;
1976
- const internal = Symbol.for('spica/url::internal');
1977
2586
 
1978
2587
  class ReadonlyURL {
1979
2588
  constructor(source, base) {
@@ -2006,74 +2615,71 @@ class ReadonlyURL {
2006
2615
 
2007
2616
  }
2008
2617
 
2009
- this[internal] = {
2010
- share: ReadonlyURL.get(source, base),
2011
- searchParams: void 0
2012
- };
2618
+ this.share = ReadonlyURL.get(source, base);
2013
2619
  }
2014
2620
 
2015
2621
  get href() {
2016
- return this[internal].share.href ??= this[internal].share.url.href;
2622
+ return this.share.href ??= this.share.url.href;
2017
2623
  }
2018
2624
 
2019
2625
  get resource() {
2020
- return this[internal].share.resource ??= this.href.slice(0, -this.fragment.length - this.query.length || this.href.length) + this.search;
2626
+ return this.share.resource ??= this.href.slice(0, -this.fragment.length - this.query.length || this.href.length) + this.search;
2021
2627
  }
2022
2628
 
2023
2629
  get origin() {
2024
- return this[internal].share.origin ??= this[internal].share.url.origin;
2630
+ return this.share.origin ??= this.share.url.origin;
2025
2631
  }
2026
2632
 
2027
2633
  get protocol() {
2028
- return this[internal].share.protocol ??= this[internal].share.url.protocol;
2634
+ return this.share.protocol ??= this.share.url.protocol;
2029
2635
  }
2030
2636
 
2031
2637
  get username() {
2032
- return this[internal].share.username ??= this[internal].share.url.username;
2638
+ return this.share.username ??= this.share.url.username;
2033
2639
  }
2034
2640
 
2035
2641
  get password() {
2036
- return this[internal].share.password ??= this[internal].share.url.password;
2642
+ return this.share.password ??= this.share.url.password;
2037
2643
  }
2038
2644
 
2039
2645
  get host() {
2040
- return this[internal].share.host ??= this[internal].share.url.host;
2646
+ return this.share.host ??= this.share.url.host;
2041
2647
  }
2042
2648
 
2043
2649
  get hostname() {
2044
- return this[internal].share.hostname ??= this[internal].share.url.hostname;
2650
+ return this.share.hostname ??= this.share.url.hostname;
2045
2651
  }
2046
2652
 
2047
2653
  get port() {
2048
- return this[internal].share.port ??= this[internal].share.url.port;
2654
+ return this.share.port ??= this.share.url.port;
2049
2655
  }
2050
2656
 
2051
2657
  get path() {
2052
- return this[internal].share.path ??= `${this.pathname}${this.search}`;
2658
+ return this.share.path ??= `${this.pathname}${this.search}`;
2053
2659
  }
2054
2660
 
2055
2661
  get pathname() {
2056
- return this[internal].share.pathname ??= this[internal].share.url.pathname;
2662
+ return this.share.pathname ??= this.share.url.pathname;
2057
2663
  }
2058
2664
 
2059
2665
  get search() {
2060
- return this[internal].share.search ??= this[internal].share.url.search;
2666
+ return this.share.search ??= this.share.url.search;
2061
2667
  }
2062
2668
 
2063
2669
  get query() {
2064
- return this[internal].share.query ??= this.search || this.href[this.href.length - this.fragment.length - 1] === '?' && '?' || '';
2670
+ return this.share.query ??= this.search || this.href[this.href.length - this.fragment.length - 1] === '?' && '?' || '';
2065
2671
  }
2066
2672
 
2067
2673
  get hash() {
2068
- return this[internal].share.hash ??= this[internal].share.url.hash;
2674
+ return this.share.hash ??= this.share.url.hash;
2069
2675
  }
2070
2676
 
2071
2677
  get fragment() {
2072
- return this[internal].share.fragment ??= this.hash || this.href[this.href.length - 1] === '#' && '#' || '';
2678
+ return this.share.fragment ??= this.hash || this.href[this.href.length - 1] === '#' && '#' || '';
2073
2679
  }
2074
2680
 
2075
2681
  get searchParams() {
2076
- return this[internal].searchParams ??= new global_1.URLSearchParams(this.search);
2682
+ return this.params ??= new global_1.URLSearchParams(this.search);
2077
2683
  }
2078
2684
 
2079
2685
  toString() {
@@ -2241,7 +2847,7 @@ const parser_1 = __webpack_require__(6728);
2241
2847
  function validate(patterns, has, parser) {
2242
2848
  if (typeof has === 'function') return validate(patterns, '', has);
2243
2849
  if (!(0, alias_1.isArray)(patterns)) return validate([patterns], has, parser);
2244
- 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(''))();
2850
+ 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(''));
2245
2851
  return ({
2246
2852
  source,
2247
2853
  context
@@ -3309,7 +3915,7 @@ class Memo {
3309
3915
  clear(position) {
3310
3916
  const memory = this.memory;
3311
3917
 
3312
- for (let i = position, len = memory.length; i < len; ++i) {
3918
+ for (let len = memory.length, i = position; i < len; ++i) {
3313
3919
  memory.pop();
3314
3920
  } //console.log('clear', position + 1);
3315
3921
 
@@ -3347,7 +3953,7 @@ function inits(parsers, resume) {
3347
3953
  let rest = source;
3348
3954
  let nodes;
3349
3955
 
3350
- for (let i = 0, len = parsers.length; i < len; ++i) {
3956
+ for (let len = parsers.length, i = 0; i < len; ++i) {
3351
3957
  if (rest === '') break;
3352
3958
  if (context.delimiters?.match(rest, context.precedence)) break;
3353
3959
  const result = parsers[i]({
@@ -3394,7 +4000,7 @@ function sequence(parsers, resume) {
3394
4000
  let rest = source;
3395
4001
  let nodes;
3396
4002
 
3397
- for (let i = 0, len = parsers.length; i < len; ++i) {
4003
+ for (let len = parsers.length, i = 0; i < len; ++i) {
3398
4004
  if (rest === '') return;
3399
4005
  if (context.delimiters?.match(rest, context.precedence)) return;
3400
4006
  const result = parsers[i]({
@@ -3548,8 +4154,20 @@ function union(parsers) {
3548
4154
  case 1:
3549
4155
  return parsers[0];
3550
4156
 
4157
+ case 2:
4158
+ return input => parsers[0](input) ?? parsers[1](input);
4159
+
4160
+ case 3:
4161
+ return input => parsers[0](input) ?? parsers[1](input) ?? parsers[2](input);
4162
+
3551
4163
  default:
3552
- return (0, global_1.Function)('parsers', ['"use strict";', 'return (input, context) =>', '0', ...parsers.map((_, i) => `|| parsers[${i}](input, context)`)].join('\n'))(parsers);
4164
+ return input => {
4165
+ for (let i = 0; i < parsers.length; ++i) {
4166
+ const parser = parsers[i];
4167
+ const result = parser(input);
4168
+ if (result) return result;
4169
+ }
4170
+ };
3553
4171
  }
3554
4172
  }
3555
4173
 
@@ -3858,7 +4476,7 @@ function bind(target, settings) {
3858
4476
  function nearest(index) {
3859
4477
  let el;
3860
4478
 
3861
- for (let i = 0, len = 0; i < blocks.length; ++i) {
4479
+ for (let len = 0, i = 0; i < blocks.length; ++i) {
3862
4480
  const block = blocks[i];
3863
4481
  len += block[0].length;
3864
4482
  el = block[1][0] ?? el;
@@ -3869,7 +4487,7 @@ function bind(target, settings) {
3869
4487
  }
3870
4488
 
3871
4489
  function index(source) {
3872
- for (let i = 0, len = 0; i < blocks.length; ++i) {
4490
+ for (let len = 0, i = 0; i < blocks.length; ++i) {
3873
4491
  const block = blocks[i];
3874
4492
  if (block[1].includes(source)) return len;
3875
4493
  len += block[0].length;
@@ -4065,10 +4683,10 @@ const figure_1 = __webpack_require__(9123);
4065
4683
 
4066
4684
  const footnote_1 = __webpack_require__(7529);
4067
4685
 
4068
- const dom_1 = __webpack_require__(3252);
4069
-
4070
4686
  const url_1 = __webpack_require__(2261);
4071
4687
 
4688
+ const dom_1 = __webpack_require__(3252);
4689
+
4072
4690
  function parse(source, opts = {}, context) {
4073
4691
  if (!(0, segment_1.validate)(source, segment_1.MAX_SEGMENT_SIZE)) throw new Error(`Too large input over ${segment_1.MAX_SEGMENT_SIZE.toLocaleString('en')} bytes.`);
4074
4692
  const url = (0, header_2.headers)(source).find(field => field.toLowerCase().startsWith('url:'))?.slice(4).trim() ?? '';
@@ -4207,10 +4825,10 @@ const reply_1 = __webpack_require__(9978);
4207
4825
 
4208
4826
  const paragraph_1 = __webpack_require__(6457);
4209
4827
 
4210
- const dom_1 = __webpack_require__(3252);
4211
-
4212
4828
  const random_1 = __webpack_require__(7325);
4213
4829
 
4830
+ const dom_1 = __webpack_require__(3252);
4831
+
4214
4832
  exports.block = (0, combinator_1.creation)(1, false, error((0, combinator_1.reset)({
4215
4833
  resources: {
4216
4834
  clock: 50 * 1000,
@@ -4281,7 +4899,7 @@ const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combina
4281
4899
  references
4282
4900
  }
4283
4901
  }, context);
4284
- return [[(0, dom_1.html)('section', [document, references])], ''];
4902
+ return [[(0, dom_1.html)('section', [document, (0, dom_1.html)('h2', 'References'), references])], ''];
4285
4903
  })))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
4286
4904
 
4287
4905
  /***/ }),
@@ -4382,10 +5000,10 @@ const locale_1 = __webpack_require__(5485);
4382
5000
 
4383
5001
  const visibility_1 = __webpack_require__(7618);
4384
5002
 
4385
- const dom_1 = __webpack_require__(3252);
4386
-
4387
5003
  const array_1 = __webpack_require__(8112);
4388
5004
 
5005
+ const dom_1 = __webpack_require__(3252);
5006
+
4389
5007
  exports.dlist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, locale_1.localize)((0, combinator_1.fmap)((0, combinator_1.validate)(/^~[^\S\n]+(?=\S)/, (0, combinator_1.some)((0, combinator_1.inits)([(0, combinator_1.state)(128
4390
5008
  /* State.annotation */
4391
5009
  | 64
@@ -4492,7 +5110,7 @@ exports.aside = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, co
4492
5110
  return [(0, dom_1.html)('aside', {
4493
5111
  id: (0, indexee_1.identity)((0, indexee_1.text)(heading)),
4494
5112
  class: 'aside'
4495
- }, [document, references])];
5113
+ }, [document, (0, dom_1.html)('h2', 'References'), references])];
4496
5114
  })));
4497
5115
 
4498
5116
  /***/ }),
@@ -4546,7 +5164,7 @@ exports.example = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0,
4546
5164
  'data-type': 'markdown'
4547
5165
  }, [(0, dom_1.html)('pre', {
4548
5166
  translate: 'no'
4549
- }, body.slice(0, -1)), (0, dom_1.html)('hr'), (0, dom_1.html)('section', [document, references])])];
5167
+ }, body.slice(0, -1)), (0, dom_1.html)('hr'), (0, dom_1.html)('section', [document, (0, dom_1.html)('h2', 'References'), references])])];
4550
5168
  }
4551
5169
 
4552
5170
  case 'math':
@@ -4682,10 +5300,10 @@ const locale_1 = __webpack_require__(5485);
4682
5300
 
4683
5301
  const visibility_1 = __webpack_require__(7618);
4684
5302
 
4685
- const dom_1 = __webpack_require__(3252);
4686
-
4687
5303
  const memoize_1 = __webpack_require__(1808);
4688
5304
 
5305
+ const dom_1 = __webpack_require__(3252);
5306
+
4689
5307
  exports.segment = (0, combinator_1.block)((0, combinator_1.match)(/^(~{3,})(?:figure[^\S\n])?(?=\[?\$)/, (0, memoize_1.memoize)(([, fence], closer = new RegExp(String.raw`^${fence}[^\S\n]*(?:$|\n)`)) => (0, combinator_1.close)((0, combinator_1.sequence)([source_1.contentline, (0, combinator_1.inits)([// All parsers which can include closing terms.
4690
5308
  (0, combinator_1.union)([codeblock_1.segment_, mathblock_1.segment_, table_2.segment_, blockquote_1.segment, placeholder_1.segment_, (0, combinator_1.some)(source_1.contentline, closer)]), source_1.emptyline, (0, combinator_1.union)([source_1.emptyline, (0, combinator_1.some)(source_1.contentline, closer)])])]), closer), ([, fence]) => fence.length, [])));
4691
5309
  exports.figure = (0, combinator_1.block)((0, combinator_1.fallback)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.fmap)((0, combinator_1.convert)(source => source.slice(source.match(/^~+(?:\w+\s+)?/)[0].length, source.trimEnd().lastIndexOf('\n')), (0, combinator_1.sequence)([(0, combinator_1.line)((0, combinator_1.sequence)([label_1.label, (0, source_1.str)(/^(?=\s).*\n/)])), (0, combinator_1.inits)([(0, combinator_1.block)((0, combinator_1.union)([ulist_1.ulist, olist_1.olist, table_1.table, codeblock_1.codeblock, mathblock_1.mathblock, example_1.example, table_2.table, blockquote_1.blockquote, placeholder_1.placeholder, (0, combinator_1.line)(inline_1.media), (0, combinator_1.line)(inline_1.shortmedia)])), source_1.emptyline, (0, combinator_1.block)((0, locale_1.localize)((0, combinator_1.state)(4
@@ -4834,10 +5452,10 @@ const blockquote_1 = __webpack_require__(7859);
4834
5452
 
4835
5453
  const paragraph_1 = __webpack_require__(6457);
4836
5454
 
4837
- const dom_1 = __webpack_require__(3252);
4838
-
4839
5455
  const array_1 = __webpack_require__(8112);
4840
5456
 
5457
+ const dom_1 = __webpack_require__(3252);
5458
+
4841
5459
  exports.message = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.fmap)((0, combinator_1.fence)(/^(~{3,})message\/(\S+)([^\n]*)(?:$|\n)/, 300), // Bug: Type mismatch between outer and inner.
4842
5460
  ([body, overflow, closer, opener, delim, type, param], _, context) => {
4843
5461
  if (!closer || overflow || param.trimStart()) return [(0, dom_1.html)('pre', {
@@ -4944,10 +5562,10 @@ const locale_1 = __webpack_require__(5485);
4944
5562
 
4945
5563
  const visibility_1 = __webpack_require__(7618);
4946
5564
 
4947
- const dom_1 = __webpack_require__(3252);
4948
-
4949
5565
  const array_1 = __webpack_require__(8112);
4950
5566
 
5567
+ const dom_1 = __webpack_require__(3252);
5568
+
4951
5569
  const opener = /^(~{3,})table(?:\/(\S+))?(?!\S)([^\n]*)(?:$|\n)/;
4952
5570
  exports.segment = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.clear)((0, combinator_1.fence)(opener, 10000))));
4953
5571
  exports.segment_ = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.clear)((0, combinator_1.fence)(opener, 10000, false))), false);
@@ -5363,14 +5981,12 @@ const source_1 = __webpack_require__(6743);
5363
5981
 
5364
5982
  const visibility_1 = __webpack_require__(7618);
5365
5983
 
5366
- const dom_1 = __webpack_require__(3252);
5367
-
5368
5984
  const memoize_1 = __webpack_require__(1808);
5369
5985
 
5370
- const duff_1 = __webpack_require__(8099);
5371
-
5372
5986
  const array_1 = __webpack_require__(8112);
5373
5987
 
5988
+ const dom_1 = __webpack_require__(3252);
5989
+
5374
5990
  const openers = {
5375
5991
  '.': /^([0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*(?![^\S\n])\.?(?:$|\s)/,
5376
5992
  '(': /^\(([0-9]*|[a-z]*)(?![^)\n])\)?(?:-(?!-)[0-9]*)*(?:$|\s)/
@@ -5471,19 +6087,20 @@ function format(el, type, form) {
5471
6087
  'data-type': style(type) || global_1.undefined
5472
6088
  });
5473
6089
  const marker = el.firstElementChild?.getAttribute('data-marker').match(initial(type))?.[0] ?? '';
5474
- const es = el.children;
5475
- (0, duff_1.duffbk)(es.length, i => {
6090
+
6091
+ for (let es = el.children, len = es.length, i = 0; i < len; ++i) {
5476
6092
  const el = es[i];
5477
6093
 
5478
6094
  switch (el.getAttribute('data-marker')) {
5479
6095
  case '':
5480
6096
  case marker:
5481
6097
  el.removeAttribute('data-marker');
5482
- return;
6098
+ continue;
5483
6099
  }
5484
6100
 
5485
- return false;
5486
- });
6101
+ break;
6102
+ }
6103
+
5487
6104
  return el;
5488
6105
  }
5489
6106
 
@@ -5539,9 +6156,9 @@ const locale_1 = __webpack_require__(5485);
5539
6156
 
5540
6157
  const visibility_1 = __webpack_require__(7618);
5541
6158
 
5542
- const dom_1 = __webpack_require__(3252);
5543
-
5544
6159
  const array_1 = __webpack_require__(8112);
6160
+
6161
+ const dom_1 = __webpack_require__(3252);
5545
6162
  /*
5546
6163
  必ず対象指定から始まる
5547
6164
  対象がページである場合>>.を表現方法とする
@@ -5726,12 +6343,12 @@ const source_1 = __webpack_require__(6743);
5726
6343
 
5727
6344
  const visibility_1 = __webpack_require__(7618);
5728
6345
 
5729
- const dom_1 = __webpack_require__(3252);
5730
-
5731
6346
  const duff_1 = __webpack_require__(8099);
5732
6347
 
5733
6348
  const array_1 = __webpack_require__(8112);
5734
6349
 
6350
+ const dom_1 = __webpack_require__(3252);
6351
+
5735
6352
  exports.table = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^\|[^\n]*(?:\n\|[^\n]*){2}/, (0, combinator_1.sequence)([row((0, combinator_1.some)(head), true), row((0, combinator_1.some)(align), false), (0, combinator_1.some)(row((0, combinator_1.some)(data), true))])), rows => [(0, dom_1.html)('table', [(0, dom_1.html)('thead', [rows.shift()]), (0, dom_1.html)('tbody', format(rows))])])));
5736
6353
 
5737
6354
  const row = (parser, optional) => (0, combinator_1.creation)(1, false, (0, combinator_1.fallback)((0, combinator_1.fmap)((0, combinator_1.line)((0, combinator_1.surround)(/^(?=\|)/, (0, combinator_1.some)((0, combinator_1.union)([parser])), /^[|\\]?\s*$/, optional)), es => [(0, dom_1.html)('tr', es)]), (0, combinator_1.rewrite)(source_1.contentline, ({
@@ -5752,14 +6369,14 @@ function format(rows) {
5752
6369
  const aligns = rows[0].className === 'invalid' ? [] : (0, duff_1.duffReduce)(rows.shift().children, (acc, el) => (0, array_1.push)(acc, [el.textContent]), []);
5753
6370
 
5754
6371
  for (let i = 0; i < rows.length; ++i) {
5755
- (0, duff_1.duffEach)(rows[i].children, (col, i) => {
5756
- if (i > 0 && !aligns[i]) {
5757
- aligns[i] = aligns[i - 1];
6372
+ for (let cols = rows[i].children, len = cols.length, j = 0; j < len; ++j) {
6373
+ if (j > 0 && !aligns[j]) {
6374
+ aligns[j] = aligns[j - 1];
5758
6375
  }
5759
6376
 
5760
- if (!aligns[i]) return;
5761
- col.setAttribute('align', aligns[i]);
5762
- });
6377
+ if (!aligns[j]) continue;
6378
+ cols[j].setAttribute('align', aligns[j]);
6379
+ }
5763
6380
  }
5764
6381
 
5765
6382
  return rows;
@@ -5788,10 +6405,10 @@ const inline_1 = __webpack_require__(1160);
5788
6405
 
5789
6406
  const visibility_1 = __webpack_require__(7618);
5790
6407
 
5791
- const dom_1 = __webpack_require__(3252);
5792
-
5793
6408
  const array_1 = __webpack_require__(8112);
5794
6409
 
6410
+ const dom_1 = __webpack_require__(3252);
6411
+
5795
6412
  exports.ulist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^-(?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.state)(4
5796
6413
  /* State.media */
5797
6414
  , exports.ulist_))));
@@ -6281,10 +6898,10 @@ const inline_1 = __webpack_require__(1160);
6281
6898
 
6282
6899
  const source_1 = __webpack_require__(6743);
6283
6900
 
6284
- const dom_1 = __webpack_require__(3252);
6285
-
6286
6901
  const array_1 = __webpack_require__(8112);
6287
6902
 
6903
+ const dom_1 = __webpack_require__(3252);
6904
+
6288
6905
  const index = /^[0-9A-Za-z]+(?:(?:[.-]|, )[0-9A-Za-z]+)*/;
6289
6906
  exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.syntax)(0
6290
6907
  /* Syntax.none */
@@ -6367,12 +6984,12 @@ const inline_1 = __webpack_require__(1160);
6367
6984
 
6368
6985
  const source_1 = __webpack_require__(6743);
6369
6986
 
6370
- const dom_1 = __webpack_require__(3252);
6371
-
6372
6987
  const memoize_1 = __webpack_require__(1808);
6373
6988
 
6374
6989
  const array_1 = __webpack_require__(8112);
6375
6990
 
6991
+ const dom_1 = __webpack_require__(3252);
6992
+
6376
6993
  exports.comment = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[%', (0, combinator_1.syntax)(0
6377
6994
  /* Syntax.none */
6378
6995
  , 4, 1, 0
@@ -6404,10 +7021,10 @@ const source_1 = __webpack_require__(6743);
6404
7021
 
6405
7022
  const visibility_1 = __webpack_require__(7618);
6406
7023
 
6407
- const dom_1 = __webpack_require__(3252);
6408
-
6409
7024
  const array_1 = __webpack_require__(8112);
6410
7025
 
7026
+ const dom_1 = __webpack_require__(3252);
7027
+
6411
7028
  exports.deletion = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('~~', '~'), (0, combinator_1.syntax)(0
6412
7029
  /* Syntax.none */
6413
7030
  , 1, 1, 0
@@ -6435,10 +7052,10 @@ const source_1 = __webpack_require__(6743);
6435
7052
 
6436
7053
  const visibility_1 = __webpack_require__(7618);
6437
7054
 
6438
- const dom_1 = __webpack_require__(3252);
6439
-
6440
7055
  const array_1 = __webpack_require__(8112);
6441
7056
 
7057
+ const dom_1 = __webpack_require__(3252);
7058
+
6442
7059
  exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('_', '_'), (0, combinator_1.syntax)(0
6443
7060
  /* Syntax.none */
6444
7061
  , 1, 1, 0
@@ -6533,7 +7150,7 @@ const combinator_1 = __webpack_require__(2087);
6533
7150
 
6534
7151
  const dom_1 = __webpack_require__(3252);
6535
7152
 
6536
- const duff_1 = __webpack_require__(8099);
7153
+ const query_1 = __webpack_require__(6120);
6537
7154
 
6538
7155
  function indexee(parser, optional) {
6539
7156
  return (0, combinator_1.fmap)(parser, ([el], _, {
@@ -6558,37 +7175,41 @@ function text(source, optional = false) {
6558
7175
  const index = indexer?.getAttribute('data-index');
6559
7176
  if (index) return index;
6560
7177
  const target = source.cloneNode(true);
6561
- (0, duff_1.duffEach)(target.querySelectorAll('code[data-src], .math[data-src], .comment, rt, rp, .reference, .checkbox, ul, ol'), el => {
7178
+
7179
+ 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) {
7180
+ const el = es[i];
7181
+
6562
7182
  switch (el.tagName) {
6563
7183
  case 'CODE':
6564
7184
  (0, dom_1.define)(el, el.getAttribute('data-src'));
6565
- return;
7185
+ continue;
6566
7186
 
6567
7187
  case 'RT':
6568
7188
  case 'RP':
6569
7189
  case 'UL':
6570
7190
  case 'OL':
6571
7191
  el.remove();
6572
- return;
7192
+ continue;
6573
7193
  }
6574
7194
 
6575
7195
  switch (el.className) {
6576
7196
  case 'math':
6577
7197
  (0, dom_1.define)(el, el.getAttribute('data-src'));
6578
- return;
7198
+ continue;
6579
7199
 
6580
7200
  case 'comment':
6581
7201
  case 'checkbox':
6582
7202
  el.remove();
6583
- return;
7203
+ continue;
6584
7204
 
6585
7205
  case 'reference':
6586
7206
  el.firstChild.remove();
6587
- return;
7207
+ continue;
6588
7208
  }
6589
- }); // Better:
7209
+ } // Better:
6590
7210
  //return target.innerText;
6591
7211
 
7212
+
6592
7213
  return target.textContent;
6593
7214
  }
6594
7215
 
@@ -6698,9 +7319,9 @@ const source_1 = __webpack_require__(6743);
6698
7319
 
6699
7320
  const visibility_1 = __webpack_require__(7618);
6700
7321
 
6701
- const dom_1 = __webpack_require__(3252);
7322
+ const array_1 = __webpack_require__(8112);
6702
7323
 
6703
- const array_1 = __webpack_require__(8112); // Don't use the symbols already used: !#$%@&*+~=
7324
+ const dom_1 = __webpack_require__(3252); // Don't use the symbols already used: !#$%@&*+~=
6704
7325
  // All syntax surrounded by square brackets shouldn't contain line breaks.
6705
7326
 
6706
7327
 
@@ -6738,14 +7359,14 @@ const source_1 = __webpack_require__(6743);
6738
7359
 
6739
7360
  const visibility_1 = __webpack_require__(7618);
6740
7361
 
6741
- const dom_1 = __webpack_require__(3252);
6742
-
6743
7362
  const memoize_1 = __webpack_require__(1808);
6744
7363
 
6745
7364
  const cache_1 = __webpack_require__(9210);
6746
7365
 
6747
7366
  const array_1 = __webpack_require__(8112);
6748
7367
 
7368
+ const dom_1 = __webpack_require__(3252);
7369
+
6749
7370
  const tags = global_1.Object.freeze(['bdo', 'bdi']);
6750
7371
  const attrspecs = {
6751
7372
  bdo: {
@@ -6871,10 +7492,10 @@ const source_1 = __webpack_require__(6743);
6871
7492
 
6872
7493
  const visibility_1 = __webpack_require__(7618);
6873
7494
 
6874
- const dom_1 = __webpack_require__(3252);
6875
-
6876
7495
  const array_1 = __webpack_require__(8112);
6877
7496
 
7497
+ const dom_1 = __webpack_require__(3252);
7498
+
6878
7499
  exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('++', '+'), (0, combinator_1.syntax)(0
6879
7500
  /* Syntax.none */
6880
7501
  , 1, 1, 0
@@ -6912,10 +7533,10 @@ const visibility_1 = __webpack_require__(7618);
6912
7533
 
6913
7534
  const util_1 = __webpack_require__(9437);
6914
7535
 
6915
- const dom_1 = __webpack_require__(3252);
6916
-
6917
7536
  const url_1 = __webpack_require__(2261);
6918
7537
 
7538
+ const dom_1 = __webpack_require__(3252);
7539
+
6919
7540
  const optspec = {
6920
7541
  rel: ['nofollow']
6921
7542
  };
@@ -7077,10 +7698,10 @@ const source_1 = __webpack_require__(6743);
7077
7698
 
7078
7699
  const visibility_1 = __webpack_require__(7618);
7079
7700
 
7080
- const dom_1 = __webpack_require__(3252);
7081
-
7082
7701
  const array_1 = __webpack_require__(8112);
7083
7702
 
7703
+ const dom_1 = __webpack_require__(3252);
7704
+
7084
7705
  exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('==', '='), (0, combinator_1.syntax)(0
7085
7706
  /* Syntax.none */
7086
7707
  , 1, 1, 0
@@ -7152,12 +7773,12 @@ const htmlentity_1 = __webpack_require__(1562);
7152
7773
 
7153
7774
  const source_1 = __webpack_require__(6743);
7154
7775
 
7155
- const dom_1 = __webpack_require__(3252);
7156
-
7157
7776
  const url_1 = __webpack_require__(2261);
7158
7777
 
7159
7778
  const array_1 = __webpack_require__(8112);
7160
7779
 
7780
+ const dom_1 = __webpack_require__(3252);
7781
+
7161
7782
  const optspec = {
7162
7783
  'width': [],
7163
7784
  'height': [],
@@ -7328,10 +7949,10 @@ const source_1 = __webpack_require__(6743);
7328
7949
 
7329
7950
  const visibility_1 = __webpack_require__(7618);
7330
7951
 
7331
- const dom_1 = __webpack_require__(3252);
7332
-
7333
7952
  const array_1 = __webpack_require__(8112);
7334
7953
 
7954
+ const dom_1 = __webpack_require__(3252);
7955
+
7335
7956
  exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.syntax)(512
7336
7957
  /* Syntax.ruby */
7337
7958
  , 2, 1, -1
@@ -7465,10 +8086,10 @@ const source_1 = __webpack_require__(6743);
7465
8086
 
7466
8087
  const visibility_1 = __webpack_require__(7618);
7467
8088
 
7468
- const dom_1 = __webpack_require__(3252);
7469
-
7470
8089
  const array_1 = __webpack_require__(8112);
7471
8090
 
8091
+ const dom_1 = __webpack_require__(3252);
8092
+
7472
8093
  exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('*', '*'), (0, combinator_1.syntax)(0
7473
8094
  /* Syntax.none */
7474
8095
  , 1, 1, 0
@@ -7494,10 +8115,10 @@ const combinator_1 = __webpack_require__(2087);
7494
8115
 
7495
8116
  const source_1 = __webpack_require__(6743);
7496
8117
 
7497
- const dom_1 = __webpack_require__(3252);
7498
-
7499
8118
  const array_1 = __webpack_require__(8112);
7500
8119
 
8120
+ const dom_1 = __webpack_require__(3252);
8121
+
7501
8122
  exports.template = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('{{', (0, combinator_1.syntax)(0
7502
8123
  /* Syntax.none */
7503
8124
  , 2, 1, -1
@@ -7526,16 +8147,19 @@ const ja_1 = __webpack_require__(1499);
7526
8147
 
7527
8148
  const dom_1 = __webpack_require__(3252);
7528
8149
 
7529
- const duff_1 = __webpack_require__(8099);
8150
+ const query_1 = __webpack_require__(6120);
7530
8151
 
7531
8152
  function localize(parser) {
7532
8153
  return (0, combinator_1.fmap)(parser, ns => {
7533
8154
  if (ns.length === 0) return ns;
7534
8155
  const el = ns.length === 1 && typeof ns[0] === 'object' ? ns[0] : (0, dom_1.html)('div', ns);
7535
- (0, duff_1.duffEach)(el.querySelectorAll('.linebreak:not(:empty)'), el => {
7536
- if (!check(el)) return;
8156
+
8157
+ for (let es = (0, query_1.querySelectorAll)(el, '.linebreak:not(:empty)'), i = 0; i < es.length; ++i) {
8158
+ const el = es[i];
8159
+ if (!check(el)) continue;
7537
8160
  el.firstChild.remove();
7538
- });
8161
+ }
8162
+
7539
8163
  return ns;
7540
8164
  });
7541
8165
  }
@@ -7621,22 +8245,24 @@ const global_1 = __webpack_require__(4128);
7621
8245
 
7622
8246
  const label_1 = __webpack_require__(466);
7623
8247
 
7624
- const dom_1 = __webpack_require__(3252);
7625
-
7626
8248
  const multimap_1 = __webpack_require__(940);
7627
8249
 
7628
8250
  const array_1 = __webpack_require__(8112);
7629
8251
 
8252
+ const dom_1 = __webpack_require__(3252);
8253
+
8254
+ const query_1 = __webpack_require__(6120);
8255
+
7630
8256
  function* figure(target, footnotes, opts = {}) {
7631
- const refs = new multimap_1.MultiMap((0, array_1.push)((0, array_1.push)([], target.querySelectorAll('a.label:not(.disabled)[data-label]')), footnotes?.references.querySelectorAll('a.label:not(.disabled)') ?? []).map(el => [el.getAttribute('data-label'), el]));
8257
+ 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]));
7632
8258
  const labels = new global_1.Set();
7633
8259
  const numbers = new global_1.Map();
7634
8260
  let base = '0';
7635
8261
  let bases = base.split('.');
7636
8262
  let index = bases; // Bug: Firefox
7637
- //for (let defs = target.querySelectorAll(':scope > figure[data-label], :scope > h1, :scope > h2'), i = 0, len = defs.length; i < len; ++i) {
8263
+ //for (let defs = querySelectorAll(target, ':scope > figure[data-label], :scope > h1, :scope > h2'), len = defs.length, i = 0; i < len; ++i) {
7638
8264
 
7639
- for (let defs = target.querySelectorAll('figure[data-label], h1, h2'), i = 0, len = defs.length; i < len; ++i) {
8265
+ for (let defs = (0, query_1.querySelectorAll)(target, 'figure[data-label], h1, h2'), len = defs.length, i = 0; i < len; ++i) {
7640
8266
  yield;
7641
8267
  const def = defs[i];
7642
8268
  if (def.parentNode !== target) continue;
@@ -7737,7 +8363,9 @@ function* figure(target, footnotes, opts = {}) {
7737
8363
  labels.add(label);
7738
8364
  opts.id !== '' && def.setAttribute('id', `label:${opts.id ? `${opts.id}:` : ''}${label}`);
7739
8365
 
7740
- for (const ref of refs.take(label, global_1.Infinity)) {
8366
+ for (let rs = refs.take(label, global_1.Infinity), i = 0; i < rs.length; ++i) {
8367
+ const ref = rs[i];
8368
+
7741
8369
  if (ref.getAttribute('data-invalid-message') === messages.reference) {
7742
8370
  (0, dom_1.define)(ref, {
7743
8371
  class: void ref.classList.remove('invalid'),
@@ -7816,18 +8444,20 @@ const global_1 = __webpack_require__(4128);
7816
8444
 
7817
8445
  const indexee_1 = __webpack_require__(1269);
7818
8446
 
7819
- const dom_1 = __webpack_require__(3252);
7820
-
7821
8447
  const multimap_1 = __webpack_require__(940);
7822
8448
 
7823
- const duff_1 = __webpack_require__(8099);
8449
+ const dom_1 = __webpack_require__(3252);
7824
8450
 
7825
- const array_1 = __webpack_require__(8112);
8451
+ const query_1 = __webpack_require__(6120);
7826
8452
 
7827
8453
  function* footnote(target, footnotes, opts = {}, bottom = null) {
7828
8454
  // Bug: Firefox
7829
- //target.querySelectorAll(`:scope > .annotations`).forEach(el => el.remove());
7830
- (0, duff_1.duffEach)(target.querySelectorAll(`.annotations`), el => el.parentNode === target && el.remove());
8455
+ //querySelectorAll(target, `:scope > .annotations`).forEach(el => el.remove());
8456
+ for (let es = (0, query_1.querySelectorAll)(target, `.annotations`), i = 0; i < es.length; ++i) {
8457
+ const el = es[i];
8458
+ el.parentNode === target && el.remove();
8459
+ }
8460
+
7831
8461
  yield* (0, exports.reference)(target, footnotes?.references, opts, bottom);
7832
8462
  yield* (0, exports.annotation)(target, footnotes?.annotations, opts, bottom);
7833
8463
  return;
@@ -7844,14 +8474,20 @@ function build(syntax, marker, splitter) {
7844
8474
  const defs = new global_1.Map();
7845
8475
  const buffer = new multimap_1.MultiMap();
7846
8476
  const titles = new global_1.Map(); // Bug: Firefox
7847
- //const splitters = push([], target.querySelectorAll(`:scope > :is(${splitter ?? '_'})`));
8477
+ //const splitters = push([], querySelectorAll(target, `:scope > :is(${splitter ?? '_'})`));
8478
+
8479
+ const splitters = [];
8480
+
8481
+ for (let es = (0, query_1.querySelectorAll)(target, splitter ?? '_'), i = 0; i < es.length; ++i) {
8482
+ const el = es[i];
8483
+ el.parentNode === target && splitters.push(el);
8484
+ }
7848
8485
 
7849
- const splitters = (0, duff_1.duffReduce)(target.querySelectorAll(splitter ?? '_'), (acc, el) => el.parentNode === target ? (0, array_1.push)(acc, [el]) : acc, []);
7850
8486
  let count = 0;
7851
8487
  let total = 0;
7852
8488
  let style;
7853
8489
 
7854
- for (let refs = target.querySelectorAll(`sup.${syntax}:not(.disabled)`), i = 0, len = refs.length; i < len; ++i) {
8490
+ for (let refs = (0, query_1.querySelectorAll)(target, `sup.${syntax}:not(.disabled)`), len = refs.length, i = 0; i < len; ++i) {
7855
8491
  yield;
7856
8492
  const ref = refs[i];
7857
8493
 
@@ -7906,7 +8542,8 @@ function build(syntax, marker, splitter) {
7906
8542
  if (title && !blank && def.childNodes.length === 1) {
7907
8543
  def.insertBefore(content.cloneNode(true), def.lastChild);
7908
8544
 
7909
- for (const ref of buffer.take(identifier, global_1.Infinity)) {
8545
+ for (let refs = buffer.take(identifier, global_1.Infinity), i = 0; i < refs.length; ++i) {
8546
+ const ref = refs[i];
7910
8547
  if (ref.getAttribute('data-invalid-type') !== 'content') continue;
7911
8548
  (0, dom_1.define)(ref, {
7912
8549
  title,
@@ -8730,10 +9367,10 @@ const math_1 = __webpack_require__(611);
8730
9367
 
8731
9368
  const media_1 = __webpack_require__(2233);
8732
9369
 
8733
- const query_1 = __webpack_require__(6120);
8734
-
8735
9370
  const memoize_1 = __webpack_require__(1808);
8736
9371
 
9372
+ const query_1 = __webpack_require__(6120);
9373
+
8737
9374
  const selector = 'img.media:not(.invalid):not([src])[data-src], a > :not(img).media:not(.invalid), pre.code:not(.invalid), .math:not(.invalid)';
8738
9375
  const extend = (0, memoize_1.reduce)(opts => ({
8739
9376
  code: code_1.code,
@@ -8746,8 +9383,8 @@ function render(source, opts = {}) {
8746
9383
  opts = extend(opts);
8747
9384
  const base = global_1.location.href;
8748
9385
 
8749
- for (const el of (0, query_1.querySelectorAll)(source, selector)) {
8750
- render_(base, el, opts);
9386
+ for (let es = (0, query_1.querySelectorAllWith)(source, selector), i = 0; i < es.length; ++i) {
9387
+ render_(base, es[i], opts);
8751
9388
  }
8752
9389
  }
8753
9390
 
@@ -9201,9 +9838,7 @@ exports.info = void 0;
9201
9838
 
9202
9839
  const scope_1 = __webpack_require__(5202);
9203
9840
 
9204
- const duff_1 = __webpack_require__(8099);
9205
-
9206
- const array_1 = __webpack_require__(8112);
9841
+ const query_1 = __webpack_require__(6120);
9207
9842
 
9208
9843
  function info(source) {
9209
9844
  const match = (0, scope_1.scope)(source, '.invalid');
@@ -9221,7 +9856,14 @@ function info(source) {
9221
9856
  };
9222
9857
 
9223
9858
  function find(selector) {
9224
- return (0, duff_1.duffReduce)(source.querySelectorAll(selector), (acc, el) => match(el) ? (0, array_1.push)(acc, [el]) : acc, []);
9859
+ const acc = [];
9860
+
9861
+ for (let es = (0, query_1.querySelectorAll)(source, selector), i = 0; i < es.length; ++i) {
9862
+ const el = es[i];
9863
+ match(el) && acc.push(el);
9864
+ }
9865
+
9866
+ return acc;
9225
9867
  }
9226
9868
  }
9227
9869
 
@@ -9248,7 +9890,7 @@ const cite_1 = __webpack_require__(6315);
9248
9890
 
9249
9891
  const dom_1 = __webpack_require__(3252);
9250
9892
 
9251
- const duff_1 = __webpack_require__(8099);
9893
+ const query_1 = __webpack_require__(6120);
9252
9894
 
9253
9895
  function quote(anchor, range) {
9254
9896
  if ((0, parser_1.exec)((0, cite_1.cite)({
@@ -9258,22 +9900,25 @@ function quote(anchor, range) {
9258
9900
  fit(range);
9259
9901
  const node = trim(range.cloneContents());
9260
9902
  if (!node.firstChild) return '';
9261
- (0, duff_1.duffEach)(node.querySelectorAll('code[data-src], .math[data-src], .media[data-src], rt, rp'), el => {
9903
+
9904
+ 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) {
9905
+ const el = es[i];
9906
+
9262
9907
  switch (true) {
9263
9908
  case el.matches('code'):
9264
9909
  case el.matches('.math'):
9265
9910
  (0, dom_1.define)(el, el.getAttribute('data-src'));
9266
- return;
9911
+ continue;
9267
9912
 
9268
9913
  case el.matches('.media'):
9269
9914
  el.replaceWith(/[\s{}]/.test(el.getAttribute('data-src')) ? `!{ ${el.getAttribute('data-src')} }` : `!{${el.getAttribute('data-src')}}`);
9270
- return;
9915
+ continue;
9271
9916
 
9272
9917
  case el.matches('rt, rp'):
9273
9918
  el.remove();
9274
- return;
9919
+ continue;
9275
9920
  }
9276
- });
9921
+ }
9277
9922
 
9278
9923
  if (range.startOffset === 0 && range.startContainer.parentElement?.matches('.cite, .quote') && (!range.startContainer.previousSibling || range.startContainer.previousSibling.nodeName === 'BR')) {
9279
9924
  node.prepend(`>${range.startContainer.parentElement.matches('.quote.invalid') ? ' ' : ''}`);
@@ -9282,26 +9927,29 @@ function quote(anchor, range) {
9282
9927
  anchor = '';
9283
9928
  }
9284
9929
 
9285
- (0, duff_1.duffEach)(node.querySelectorAll('br'), el => {
9930
+ for (let es = (0, query_1.querySelectorAll)(node, 'br'), i = 0; i < es.length; ++i) {
9931
+ const el = es[i];
9932
+
9286
9933
  if (anchor && el.nextSibling instanceof global_1.Element && el.nextSibling.matches('.cite, .quote')) {
9287
9934
  el.replaceWith(`\n>${el.nextSibling.matches('.quote.invalid') ? ' ' : ''}`);
9288
- return;
9935
+ continue;
9289
9936
  }
9290
9937
 
9291
9938
  if (anchor && el.parentElement?.closest('.cite, .quote')) {
9292
9939
  el.replaceWith(`\n>${el.parentElement.closest('.quote.invalid') ? ' ' : ''}`);
9293
- return;
9940
+ continue;
9294
9941
  }
9295
9942
 
9296
9943
  if (anchor) {
9297
9944
  el.replaceWith(`\n>>${anchor}\n> `);
9298
9945
  anchor = '';
9299
- return;
9946
+ continue;
9300
9947
  } else {
9301
9948
  el.replaceWith(`\n> `);
9302
- return;
9949
+ continue;
9303
9950
  }
9304
- });
9951
+ }
9952
+
9305
9953
  anchor && node.append(`\n>>${anchor}`);
9306
9954
  return node.textContent;
9307
9955
  }
@@ -9387,29 +10035,36 @@ exports.toc = void 0;
9387
10035
 
9388
10036
  const global_1 = __webpack_require__(4128);
9389
10037
 
9390
- const dom_1 = __webpack_require__(3252);
10038
+ const array_1 = __webpack_require__(8112);
9391
10039
 
9392
- const duff_1 = __webpack_require__(8099);
10040
+ const dom_1 = __webpack_require__(3252);
9393
10041
 
9394
- const array_1 = __webpack_require__(8112); // Bug: Firefox
10042
+ const query_1 = __webpack_require__(6120); // Bug: Firefox
9395
10043
  //const selector = 'h1 h2 h3 h4 h5 h6 aside.aside'.split(' ').map(s => `:scope > ${s}[id]`).join();
9396
10044
 
9397
10045
 
9398
10046
  const selector = ':is(h1, h2, h3, h4, h5, h6, aside.aside)[id]';
9399
10047
 
9400
10048
  function toc(source) {
9401
- const hs = (0, duff_1.duffReduce)(source.querySelectorAll(selector), (acc, el) => {
10049
+ const hs = [];
10050
+
10051
+ for (let es = (0, query_1.querySelectorAll)(source, selector), i = 0; i < es.length; ++i) {
10052
+ const el = es[i];
10053
+
9402
10054
  switch (el.tagName) {
9403
10055
  case 'ASIDE':
9404
- return (0, array_1.push)(acc, [(0, dom_1.html)(el.firstElementChild.tagName.toLowerCase(), {
10056
+ hs.push((0, dom_1.html)(el.firstElementChild.tagName.toLowerCase(), {
9405
10057
  id: el.id,
9406
10058
  class: 'aside'
9407
- }, el.firstElementChild.cloneNode(true).childNodes)]);
10059
+ }, el.firstElementChild.cloneNode(true).childNodes));
10060
+ continue;
9408
10061
 
9409
10062
  default:
9410
- return (0, array_1.push)(acc, [el]);
10063
+ hs.push(el);
10064
+ continue;
9411
10065
  }
9412
- }, []);
10066
+ }
10067
+
9413
10068
  return parse(cons(hs));
9414
10069
  }
9415
10070
 
@@ -9439,7 +10094,11 @@ function level(h) {
9439
10094
  }
9440
10095
 
9441
10096
  function unlink(h) {
9442
- (0, duff_1.duffEach)(h.getElementsByTagName('a'), el => void el.replaceWith(...el.childNodes));
10097
+ for (let es = h.getElementsByTagName('a'), len = es.length, i = 0; i < len; ++i) {
10098
+ const el = es[i];
10099
+ el.replaceWith(...el.childNodes);
10100
+ }
10101
+
9443
10102
  return h.childNodes;
9444
10103
  }
9445
10104
 
@@ -9448,7 +10107,7 @@ function unlink(h) {
9448
10107
  /***/ 3252:
9449
10108
  /***/ (function(module) {
9450
10109
 
9451
- /*! typed-dom v0.0.301 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
10110
+ /*! typed-dom v0.0.307 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
9452
10111
  (function webpackUniversalModuleDefinition(root, factory) {
9453
10112
  if(true)
9454
10113
  module.exports = factory();
@@ -9466,9 +10125,9 @@ return /******/ (() => { // webpackBootstrap
9466
10125
  Object.defineProperty(exports, "__esModule", ({
9467
10126
  value: true
9468
10127
  }));
9469
- exports.ObjectSetPrototypeOf = exports.ObjectGetPrototypeOf = exports.ObjectCreate = exports.ObjectAssign = exports.toString = exports.isEnumerable = exports.isPrototypeOf = exports.hasOwnProperty = exports.isArray = exports.sign = exports.round = exports.random = exports.min = exports.max = exports.floor = exports.ceil = exports.abs = exports.parseInt = exports.parseFloat = exports.isSafeInteger = exports.isNaN = exports.isInteger = exports.isFinite = exports[NaN] = void 0;
10128
+ exports.ObjectSetPrototypeOf = exports.ObjectGetPrototypeOf = exports.ObjectCreate = exports.ObjectAssign = exports.toString = exports.isEnumerable = exports.isPrototypeOf = exports.hasOwnProperty = exports.isArray = exports.sqrt = exports.log = exports.tan = exports.cos = exports.sign = exports.round = exports.random = exports.min = exports.max = exports.floor = exports.ceil = exports.abs = exports.parseInt = exports.parseFloat = exports.isSafeInteger = exports.isNaN = exports.isInteger = exports.isFinite = exports[NaN] = void 0;
9470
10129
  exports[NaN] = Number.NaN, exports.isFinite = Number.isFinite, exports.isInteger = Number.isInteger, exports.isNaN = Number.isNaN, exports.isSafeInteger = Number.isSafeInteger, exports.parseFloat = Number.parseFloat, exports.parseInt = Number.parseInt;
9471
- exports.abs = Math.abs, exports.ceil = Math.ceil, exports.floor = Math.floor, exports.max = Math.max, exports.min = Math.min, exports.random = Math.random, exports.round = Math.round, exports.sign = Math.sign;
10130
+ exports.abs = Math.abs, exports.ceil = Math.ceil, exports.floor = Math.floor, exports.max = Math.max, exports.min = Math.min, exports.random = Math.random, exports.round = Math.round, exports.sign = Math.sign, exports.cos = Math.cos, exports.tan = Math.tan, exports.log = Math.log, exports.sqrt = Math.sqrt;
9472
10131
  exports.isArray = Array.isArray;
9473
10132
  exports.hasOwnProperty = Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);
9474
10133
  exports.isPrototypeOf = Object.prototype.isPrototypeOf.call.bind(Object.prototype.isPrototypeOf);
@@ -9500,11 +10159,11 @@ exports.equal = equal;
9500
10159
  /***/ }),
9501
10160
 
9502
10161
  /***/ 128:
9503
- /***/ ((module, __unused_webpack_exports, __nested_webpack_require_2590__) => {
10162
+ /***/ ((module, __unused_webpack_exports, __nested_webpack_require_2745__) => {
9504
10163
 
9505
10164
 
9506
10165
 
9507
- __nested_webpack_require_2590__(921);
10166
+ __nested_webpack_require_2745__(921);
9508
10167
 
9509
10168
  const global = void 0 || typeof globalThis !== 'undefined' && globalThis // @ts-ignore
9510
10169
  || typeof self !== 'undefined' && self || Function('return this')();
@@ -9525,7 +10184,7 @@ var global = (/* unused pure expression or super */ null && (0));
9525
10184
  /***/ }),
9526
10185
 
9527
10186
  /***/ 808:
9528
- /***/ ((__unused_webpack_module, exports, __nested_webpack_require_3077__) => {
10187
+ /***/ ((__unused_webpack_module, exports, __nested_webpack_require_3232__) => {
9529
10188
 
9530
10189
 
9531
10190
 
@@ -9534,51 +10193,50 @@ Object.defineProperty(exports, "__esModule", ({
9534
10193
  }));
9535
10194
  exports.reduce = exports.memoize = void 0;
9536
10195
 
9537
- const global_1 = __nested_webpack_require_3077__(128);
10196
+ const global_1 = __nested_webpack_require_3232__(128);
9538
10197
 
9539
- const alias_1 = __nested_webpack_require_3077__(406);
10198
+ const alias_1 = __nested_webpack_require_3232__(406);
9540
10199
 
9541
- const compare_1 = __nested_webpack_require_3077__(529);
10200
+ const compare_1 = __nested_webpack_require_3232__(529);
9542
10201
 
9543
- function memoize(f, identify = (...as) => as[0], memory) {
9544
- if (typeof identify === 'object') return memoize(f, void 0, identify);
9545
- if (memory === void 0) return memoize(f, identify, new global_1.Map());
9546
- if ((0, alias_1.isArray)(memory)) return memoize(f, identify, {
9547
- has(key) {
9548
- return memory[key] !== void 0;
9549
- },
10202
+ const undefined = void 0;
9550
10203
 
9551
- get(key) {
9552
- return memory[key];
9553
- },
10204
+ function memoize(f, identify = (...as) => as[0], memory) {
10205
+ if (typeof identify === 'object') return memoize(f, undefined, identify);
10206
+ return (0, alias_1.isArray)(memory) ? memoizeArray(f, identify, memory) : memoizeObject(f, identify, memory ?? new global_1.Map());
10207
+ }
9554
10208
 
9555
- set(key, value) {
9556
- memory[key] = value;
9557
- return this;
9558
- },
10209
+ exports.memoize = memoize;
9559
10210
 
9560
- delete() {
9561
- throw 0;
9562
- }
10211
+ function memoizeArray(f, identify, memory) {
10212
+ let nullish = false;
10213
+ return (...as) => {
10214
+ const b = identify(...as);
10215
+ let z = memory[b];
10216
+ if (z !== undefined || nullish && memory[b] !== undefined) return z;
10217
+ z = f(...as);
10218
+ nullish ||= z === undefined;
10219
+ memory[b] = z;
10220
+ return z;
10221
+ };
10222
+ }
9563
10223
 
9564
- });
10224
+ function memoizeObject(f, identify, memory) {
9565
10225
  let nullish = false;
9566
10226
  return (...as) => {
9567
10227
  const b = identify(...as);
9568
10228
  let z = memory.get(b);
9569
- if (z !== void 0 || nullish && memory.has(b)) return z;
10229
+ if (z !== undefined || nullish && memory.has(b)) return z;
9570
10230
  z = f(...as);
9571
- nullish ||= z === void 0;
10231
+ nullish ||= z === undefined;
9572
10232
  memory.set(b, z);
9573
10233
  return z;
9574
10234
  };
9575
10235
  }
9576
10236
 
9577
- exports.memoize = memoize;
9578
-
9579
10237
  function reduce(f, identify = (...as) => as[0]) {
9580
- let key = [];
9581
- let val = [];
10238
+ let key = {};
10239
+ let val;
9582
10240
  return (...as) => {
9583
10241
  const b = identify(...as);
9584
10242
 
@@ -9596,7 +10254,7 @@ exports.reduce = reduce;
9596
10254
  /***/ }),
9597
10255
 
9598
10256
  /***/ 521:
9599
- /***/ ((__unused_webpack_module, exports, __nested_webpack_require_4467__) => {
10257
+ /***/ ((__unused_webpack_module, exports, __nested_webpack_require_4777__) => {
9600
10258
 
9601
10259
 
9602
10260
 
@@ -9605,11 +10263,11 @@ Object.defineProperty(exports, "__esModule", ({
9605
10263
  }));
9606
10264
  exports.defrag = exports.prepend = exports.append = exports.isChildren = exports.define = exports.element = exports.text = exports.svg = exports.html = exports.frag = exports.shadow = void 0;
9607
10265
 
9608
- const global_1 = __nested_webpack_require_4467__(128);
10266
+ const global_1 = __nested_webpack_require_4777__(128);
9609
10267
 
9610
- const alias_1 = __nested_webpack_require_4467__(406);
10268
+ const alias_1 = __nested_webpack_require_4777__(406);
9611
10269
 
9612
- const memoize_1 = __nested_webpack_require_4467__(808);
10270
+ const memoize_1 = __nested_webpack_require_4777__(808);
9613
10271
 
9614
10272
  var caches;
9615
10273
 
@@ -9650,9 +10308,8 @@ function text(source) {
9650
10308
  exports.text = text;
9651
10309
 
9652
10310
  function element(context, ns) {
9653
- const cache = (0, memoize_1.memoize)(elem, (_, ns, tag) => `${ns}:${tag}`);
9654
10311
  return (tag, attrs, children) => {
9655
- const el = tag.includes('-') ? elem(context, ns, tag) : cache(context, ns, tag).cloneNode(true);
10312
+ const el = elem(context, ns, tag);
9656
10313
  return !attrs || isChildren(attrs) ? defineChildren(el, attrs ?? children) : defineChildren(defineAttrs(el, attrs), children);
9657
10314
  };
9658
10315
  }
@@ -9845,7 +10502,7 @@ exports.defrag = defrag;
9845
10502
  /******/ var __webpack_module_cache__ = {};
9846
10503
  /******/
9847
10504
  /******/ // The require function
9848
- /******/ function __nested_webpack_require_11560__(moduleId) {
10505
+ /******/ function __nested_webpack_require_11730__(moduleId) {
9849
10506
  /******/ // Check if module is in cache
9850
10507
  /******/ var cachedModule = __webpack_module_cache__[moduleId];
9851
10508
  /******/ if (cachedModule !== undefined) {
@@ -9859,7 +10516,7 @@ exports.defrag = defrag;
9859
10516
  /******/ };
9860
10517
  /******/
9861
10518
  /******/ // Execute the module function
9862
- /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_11560__);
10519
+ /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_11730__);
9863
10520
  /******/
9864
10521
  /******/ // Return the exports of the module
9865
10522
  /******/ return module.exports;
@@ -9870,7 +10527,7 @@ exports.defrag = defrag;
9870
10527
  /******/ // startup
9871
10528
  /******/ // Load entry module and return exports
9872
10529
  /******/ // This entry module is referenced by other modules so it can't be inlined
9873
- /******/ var __webpack_exports__ = __nested_webpack_require_11560__(521);
10530
+ /******/ var __webpack_exports__ = __nested_webpack_require_11730__(521);
9874
10531
  /******/
9875
10532
  /******/ return __webpack_exports__;
9876
10533
  /******/ })()
@@ -9882,7 +10539,7 @@ exports.defrag = defrag;
9882
10539
  /***/ 6120:
9883
10540
  /***/ (function(module) {
9884
10541
 
9885
- /*! typed-dom v0.0.301 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
10542
+ /*! typed-dom v0.0.307 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
9886
10543
  (function webpackUniversalModuleDefinition(root, factory) {
9887
10544
  if(true)
9888
10545
  module.exports = factory();
@@ -9892,114 +10549,6 @@ return /******/ (() => { // webpackBootstrap
9892
10549
  /******/ "use strict";
9893
10550
  /******/ var __webpack_modules__ = ({
9894
10551
 
9895
- /***/ 112:
9896
- /***/ ((__unused_webpack_module, exports, __nested_webpack_require_645__) => {
9897
-
9898
-
9899
-
9900
- Object.defineProperty(exports, "__esModule", ({
9901
- value: true
9902
- }));
9903
- exports.splice = exports.pop = exports.push = exports.shift = exports.unshift = exports.indexOf = void 0;
9904
-
9905
- const global_1 = __nested_webpack_require_645__(128);
9906
-
9907
- function indexOf(as, a) {
9908
- if (as.length === 0) return -1;
9909
- return a === a ? as.indexOf(a) : as.findIndex(a => a !== a);
9910
- }
9911
-
9912
- exports.indexOf = indexOf;
9913
-
9914
- function unshift(as, bs) {
9915
- if ('length' in as) {
9916
- for (let i = as.length - 1; i >= 0; --i) {
9917
- bs.unshift(as[i]);
9918
- }
9919
- } else {
9920
- bs.unshift(...as);
9921
- }
9922
-
9923
- return bs;
9924
- }
9925
-
9926
- exports.unshift = unshift;
9927
-
9928
- function shift(as, count) {
9929
- if (count < 0) throw new Error('Unexpected negative number');
9930
- return count === void 0 ? [as.shift(), as] : [splice(as, 0, count), as];
9931
- }
9932
-
9933
- exports.shift = shift;
9934
-
9935
- function push(as, bs) {
9936
- if ('length' in bs) {
9937
- for (let i = 0, len = bs.length; i < len; ++i) {
9938
- as.push(bs[i]);
9939
- }
9940
- } else {
9941
- for (const b of bs) {
9942
- as.push(b);
9943
- }
9944
- }
9945
-
9946
- return as;
9947
- }
9948
-
9949
- exports.push = push;
9950
-
9951
- function pop(as, count) {
9952
- if (count < 0) throw new Error('Unexpected negative number');
9953
- return count === void 0 ? [as, as.pop()] : [as, splice(as, as.length - count, count)];
9954
- }
9955
-
9956
- exports.pop = pop;
9957
-
9958
- function splice(as, index, count, ...inserts) {
9959
- if (count === 0 && inserts.length === 0) return [];
9960
- count = count > as.length ? as.length : count;
9961
-
9962
- switch (index) {
9963
- case 0:
9964
- switch (count) {
9965
- case 0:
9966
- return [[], unshift(inserts, as)][0];
9967
-
9968
- case 1:
9969
- return as.length === 0 ? [[], unshift(inserts, as)][0] : [[as.shift()], unshift(inserts, as)][0];
9970
-
9971
- case void 0:
9972
- if (as.length > 1 || arguments.length > 2) break;
9973
- return as.length === 0 ? [] : splice(as, index, 1);
9974
- }
9975
-
9976
- break;
9977
-
9978
- case -1:
9979
- case as.length - 1:
9980
- switch (count) {
9981
- case 1:
9982
- return as.length === 0 ? [[], push(as, inserts)][0] : [[as.pop()], push(as, inserts)][0];
9983
-
9984
- case void 0:
9985
- if (as.length > 1 || arguments.length > 2) break;
9986
- return as.length === 0 ? [] : splice(as, index, 1);
9987
- }
9988
-
9989
- break;
9990
-
9991
- case as.length:
9992
- case global_1.Infinity:
9993
- return [[], push(as, inserts)][0];
9994
- }
9995
-
9996
- return arguments.length > 2 ? as.splice(index, count, ...inserts) : as.splice(index);
9997
- }
9998
-
9999
- exports.splice = splice;
10000
-
10001
- /***/ }),
10002
-
10003
10552
  /***/ 99:
10004
10553
  /***/ ((__unused_webpack_module, exports) => {
10005
10554
 
@@ -10008,12 +10557,12 @@ exports.splice = splice;
10008
10557
  Object.defineProperty(exports, "__esModule", ({
10009
10558
  value: true
10010
10559
  }));
10011
- exports.duffReduce = exports.duffEach = exports.duffbk = exports.duff = void 0;
10560
+ exports.duffReduce = exports.duffEach = exports.duffbk = exports.duff = void 0; // 100,000以上でforより大幅に低速となり実用不可
10012
10561
 
10013
10562
  function duff(count, proc) {
10014
10563
  if (count > 0) {
10015
10564
  let i = 0,
10016
- m = count % 8,
10565
+ m = count & 7,
10017
10566
  d = (count - m) / 8;
10018
10567
 
10019
10568
  while (m--) {
@@ -10032,7 +10581,7 @@ function duff(count, proc) {
10032
10581
  }
10033
10582
  } else {
10034
10583
  let i = -count,
10035
- m = i % 8,
10584
+ m = i & 7,
10036
10585
  d = (i - m) / 8;
10037
10586
 
10038
10587
  while (m--) {
@@ -10052,12 +10601,12 @@ function duff(count, proc) {
10052
10601
  }
10053
10602
  }
10054
10603
 
10055
- exports.duff = duff;
10604
+ exports.duff = duff; // 100,000以上でforより大幅に低速となり実用不可
10056
10605
 
10057
10606
  function duffbk(count, proc) {
10058
10607
  if (count > 0) {
10059
10608
  let i = 0,
10060
- m = count % 8,
10609
+ m = count & 7,
10061
10610
  d = (count - m) / 8;
10062
10611
 
10063
10612
  while (m--) {
@@ -10065,18 +10614,21 @@ function duffbk(count, proc) {
10065
10614
  }
10066
10615
 
10067
10616
  while (d--) {
10068
- if (proc(i++) === false) return;
10069
- if (proc(i++) === false) return;
10070
- if (proc(i++) === false) return;
10071
- if (proc(i++) === false) return;
10072
- if (proc(i++) === false) return;
10073
- if (proc(i++) === false) return;
10074
- if (proc(i++) === false) return;
10075
- if (proc(i++) === false) return;
10617
+ switch (false) {
10618
+ case proc(i++):
10619
+ case proc(i++):
10620
+ case proc(i++):
10621
+ case proc(i++):
10622
+ case proc(i++):
10623
+ case proc(i++):
10624
+ case proc(i++):
10625
+ case proc(i++):
10626
+ return;
10627
+ }
10076
10628
  }
10077
10629
  } else {
10078
10630
  let i = -count,
10079
- m = i % 8,
10631
+ m = i & 7,
10080
10632
  d = (i - m) / 8;
10081
10633
 
10082
10634
  while (m--) {
@@ -10084,14 +10636,17 @@ function duffbk(count, proc) {
10084
10636
  }
10085
10637
 
10086
10638
  while (d--) {
10087
- if (proc(--i) === false) return;
10088
- if (proc(--i) === false) return;
10089
- if (proc(--i) === false) return;
10090
- if (proc(--i) === false) return;
10091
- if (proc(--i) === false) return;
10092
- if (proc(--i) === false) return;
10093
- if (proc(--i) === false) return;
10094
- if (proc(--i) === false) return;
10639
+ switch (false) {
10640
+ case proc(--i):
10641
+ case proc(--i):
10642
+ case proc(--i):
10643
+ case proc(--i):
10644
+ case proc(--i):
10645
+ case proc(--i):
10646
+ case proc(--i):
10647
+ case proc(--i):
10648
+ return;
10649
+ }
10095
10650
  }
10096
10651
  }
10097
10652
  }
@@ -10101,7 +10656,7 @@ exports.duffbk = duffbk;
10101
10656
  function duffEach(array, proc) {
10102
10657
  let count = array.length;
10103
10658
  let i = 0,
10104
- m = count % 8,
10659
+ m = count & 7,
10105
10660
  d = (count - m) / 8;
10106
10661
 
10107
10662
  while (m--) {
@@ -10120,30 +10675,32 @@ function duffEach(array, proc) {
10120
10675
  }
10121
10676
  }
10122
10677
 
10123
- exports.duffEach = duffEach;
10678
+ exports.duffEach = duffEach; // ベンチマークの10,000以上で急激な速度低下が見られる場合があるがNodeListなどでの
10679
+ // 実際の使用では速度低下は見られない
10124
10680
 
10125
10681
  function duffReduce(array, proc, initial) {
10126
10682
  let count = array.length;
10127
10683
  let i = 0,
10128
- m = count % 8,
10684
+ m = count & 7,
10129
10685
  d = (count - m) / 8;
10686
+ let acc = initial;
10130
10687
 
10131
10688
  while (m--) {
10132
- initial = proc(initial, array[i], i++, array);
10689
+ acc = proc(acc, array[i], i++, array);
10133
10690
  }
10134
10691
 
10135
10692
  while (d--) {
10136
- initial = proc(initial, array[i], i++, array);
10137
- initial = proc(initial, array[i], i++, array);
10138
- initial = proc(initial, array[i], i++, array);
10139
- initial = proc(initial, array[i], i++, array);
10140
- initial = proc(initial, array[i], i++, array);
10141
- initial = proc(initial, array[i], i++, array);
10142
- initial = proc(initial, array[i], i++, array);
10143
- initial = proc(initial, array[i], i++, array);
10693
+ acc = proc(acc, array[i], i++, array);
10694
+ acc = proc(acc, array[i], i++, array);
10695
+ acc = proc(acc, array[i], i++, array);
10696
+ acc = proc(acc, array[i], i++, array);
10697
+ acc = proc(acc, array[i], i++, array);
10698
+ acc = proc(acc, array[i], i++, array);
10699
+ acc = proc(acc, array[i], i++, array);
10700
+ acc = proc(acc, array[i], i++, array);
10144
10701
  }
10145
10702
 
10146
- return initial;
10703
+ return acc;
10147
10704
  }
10148
10705
 
10149
10706
  exports.duffReduce = duffReduce;
@@ -10151,11 +10708,11 @@ exports.duffReduce = duffReduce;
10151
10708
  /***/ }),
10152
10709
 
10153
10710
  /***/ 128:
10154
- /***/ ((module, __unused_webpack_exports, __nested_webpack_require_6113__) => {
10711
+ /***/ ((module, __unused_webpack_exports, __nested_webpack_require_3627__) => {
10155
10712
 
10156
10713
 
10157
10714
 
10158
- __nested_webpack_require_6113__(921);
10715
+ __nested_webpack_require_3627__(921);
10159
10716
 
10160
10717
  const global = void 0 || typeof globalThis !== 'undefined' && globalThis // @ts-ignore
10161
10718
  || typeof self !== 'undefined' && self || Function('return this')();
@@ -10181,7 +10738,7 @@ var global = (/* unused pure expression or super */ null && (0));
10181
10738
  /******/ var __webpack_module_cache__ = {};
10182
10739
  /******/
10183
10740
  /******/ // The require function
10184
- /******/ function __nested_webpack_require_6765__(moduleId) {
10741
+ /******/ function __nested_webpack_require_4279__(moduleId) {
10185
10742
  /******/ // Check if module is in cache
10186
10743
  /******/ var cachedModule = __webpack_module_cache__[moduleId];
10187
10744
  /******/ if (cachedModule !== undefined) {
@@ -10195,7 +10752,7 @@ var global = (/* unused pure expression or super */ null && (0));
10195
10752
  /******/ };
10196
10753
  /******/
10197
10754
  /******/ // Execute the module function
10198
- /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_6765__);
10755
+ /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_4279__);
10199
10756
  /******/
10200
10757
  /******/ // Return the exports of the module
10201
10758
  /******/ return module.exports;
@@ -10211,26 +10768,32 @@ var exports = __webpack_exports__;
10211
10768
  Object.defineProperty(exports, "__esModule", ({
10212
10769
  value: true
10213
10770
  }));
10214
- exports.querySelectorAll = exports.querySelector = void 0;
10771
+ exports.querySelectorAll = exports.querySelectorAllWith = exports.querySelectorWith = void 0;
10215
10772
 
10216
- const duff_1 = __nested_webpack_require_6765__(99);
10773
+ const global_1 = __nested_webpack_require_4279__(128);
10217
10774
 
10218
- const array_1 = __nested_webpack_require_6765__(112);
10775
+ const duff_1 = __nested_webpack_require_4279__(99);
10219
10776
 
10220
- function querySelector(node, selector) {
10777
+ function querySelectorWith(node, selector) {
10221
10778
  return 'matches' in node && node.matches(selector) ? node : node.querySelector(selector);
10222
10779
  }
10223
10780
 
10224
- exports.querySelector = querySelector;
10781
+ exports.querySelectorWith = querySelectorWith;
10225
10782
 
10226
- function querySelectorAll(node, selector) {
10783
+ function querySelectorAllWith(node, selector) {
10227
10784
  const acc = [];
10228
10785
 
10229
10786
  if ('matches' in node && node.matches(selector)) {
10230
10787
  acc.push(node);
10231
10788
  }
10232
10789
 
10233
- return (0, duff_1.duffReduce)(node.querySelectorAll(selector), (acc, node) => (0, array_1.push)(acc, [node]), acc);
10790
+ return (0, duff_1.duffReduce)(node.querySelectorAll(selector), (acc, el) => (acc.push(el), acc), acc);
10791
+ }
10792
+
10793
+ exports.querySelectorAllWith = querySelectorAllWith;
10794
+
10795
+ function querySelectorAll(node, selector) {
10796
+ return (0, duff_1.duffReduce)(node.querySelectorAll(selector), (acc, el) => (acc.push(el), acc), (0, global_1.Array)());
10234
10797
  }
10235
10798
 
10236
10799
  exports.querySelectorAll = querySelectorAll;