@baleada/logic 0.23.3 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/lib/index.cjs +2229 -1860
  2. package/lib/index.d.ts +934 -587
  3. package/lib/index.js +2158 -1828
  4. package/package.json +4 -3
package/lib/index.cjs CHANGED
@@ -1,26 +1,162 @@
1
1
  'use strict';
2
2
 
3
3
  var BezierEasing = require('bezier-easing');
4
- var color = require('@snigo.dev/color');
5
4
  var lazyCollections = require('lazy-collections');
6
- var perfectFreehand = require('perfect-freehand');
7
- var polygonClipping = require('polygon-clipping');
8
- var ky = require('ky');
9
- var createDOMPurify = require('dompurify');
10
5
  var fastFuzzy = require('fast-fuzzy');
6
+ var createDOMPurify = require('dompurify');
7
+ var slugify = require('@sindresorhus/slugify');
8
+ var arrayShuffle = require('array-shuffle');
11
9
  var klona = require('klona');
12
10
  var dequal = require('dequal');
13
- var slugify = require('@sindresorhus/slugify');
11
+ var merge = require('dset/merge');
12
+ var perfectFreehand = require('perfect-freehand');
13
+ var polygonClipping = require('polygon-clipping');
14
+ var ky = require('ky');
14
15
  var clsx = require('clsx');
15
16
 
16
- function createClone() {
17
- return (any) => {
18
- return klona.klona(any);
17
+ function createClip(content) {
18
+ return (string) => {
19
+ return string.replace(content, "");
19
20
  };
20
21
  }
21
- function createEqual(compared) {
22
- return (any) => dequal.dequal(any, compared);
22
+ function createSlug(options) {
23
+ return (string) => {
24
+ return slugify(string, options);
25
+ };
26
+ }
27
+ function createSanitize(options) {
28
+ const dompurify = createDOMPurify();
29
+ dompurify.setConfig(options);
30
+ return (string) => {
31
+ return dompurify.sanitize(string);
32
+ };
33
+ }
34
+ function createSplit(options) {
35
+ const { separator = "", limit } = options;
36
+ return (string) => {
37
+ return string.split(separator, limit);
38
+ };
39
+ }
40
+ function createNumber(options = {}) {
41
+ const { radix = 10 } = options;
42
+ return (string) => parseInt(string, radix);
43
+ }
44
+ function createResults(candidates, options = {}) {
45
+ const narrowedOptions = predicateFunction(options) ? options(fastFuzzy.sortKind) : options, searcher = new fastFuzzy.Searcher(candidates, narrowedOptions);
46
+ return (query) => searcher.search(query);
47
+ }
48
+
49
+ function fromShorthandAliasToLonghandAlias(shorthand) {
50
+ if (capitalLetterRE.test(shorthand))
51
+ return `shift+${shorthand.toLowerCase()}`;
52
+ if (shorthand in keycombosBySpecialCharacter)
53
+ return keycombosBySpecialCharacter[shorthand];
54
+ return shorthand;
55
+ }
56
+ const capitalLetterRE = /^[A-Z]$/;
57
+ const keycombosBySpecialCharacter = {
58
+ "~": "shift+`",
59
+ _: "shift+-",
60
+ "+": "shift+=",
61
+ "{": "shift+[",
62
+ "}": "shift+]",
63
+ "|": "shift+\\",
64
+ ":": "shift+;",
65
+ '"': "shift+'",
66
+ "<": "shift+,",
67
+ ">": "shift+.",
68
+ "?": "shift+/",
69
+ "!": "shift+1",
70
+ "@": "shift+2",
71
+ "#": "shift+3",
72
+ $: "shift+4",
73
+ "%": "shift+5",
74
+ "^": "shift+6",
75
+ "&": "shift+7",
76
+ "*": "shift+8",
77
+ "(": "shift+9",
78
+ ")": "shift+0"
79
+ };
80
+
81
+ function createAliases(options = {}) {
82
+ const { toLonghand = fromShorthandAliasToLonghandAlias } = options;
83
+ return (combo) => {
84
+ const separator = "+", splitByPlus = createSplit({ separator });
85
+ return lazyCollections.pipe(
86
+ splitByPlus,
87
+ lazyCollections.flatMap(
88
+ (alias) => lazyCollections.pipe(
89
+ toLonghand,
90
+ splitByPlus
91
+ )(alias)
92
+ ),
93
+ // If the separator is used as a character in the type,
94
+ // two empty strings will be produced by the split.
95
+ // unique() combines those two into one, and also removes
96
+ // duplicates in longhand transformations.
97
+ lazyCollections.unique(),
98
+ lazyCollections.map((name) => name === "" ? separator : name.toLowerCase()),
99
+ lazyCollections.toArray()
100
+ )(combo);
101
+ };
102
+ }
103
+
104
+ function fromAliasToCode(alias) {
105
+ if (alias in partialCodesByAlias)
106
+ return partialCodesByAlias[alias];
107
+ if (alias in keyStatusKeysByAlias)
108
+ return keyStatusKeysByAlias[alias];
109
+ if (letterRE.test(alias))
110
+ return `Key${alias.toUpperCase()}`;
111
+ if (digitRE.test(alias))
112
+ return `Digit${alias}`;
113
+ if (functionRE.test(alias))
114
+ return alias.toUpperCase();
115
+ return "unsupported";
23
116
  }
117
+ const digitRE = /^[0-9]$/;
118
+ const letterRE = /^[a-zA-Z]$/;
119
+ const functionRE = /^[fF][0-9]{1,2}$/;
120
+ const keyStatusKeysByAlias = {
121
+ "`": "Backquote",
122
+ "-": "Minus",
123
+ "=": "Equal",
124
+ "": "BracketLeft",
125
+ "]": "BracketRight",
126
+ "\\": "Backslash",
127
+ ";": "Semicolon",
128
+ "'": "Quote",
129
+ ",": "Comma",
130
+ ".": "Period",
131
+ "/": "Slash",
132
+ up: "ArrowUp",
133
+ down: "ArrowDown",
134
+ left: "ArrowLeft",
135
+ right: "ArrowRight",
136
+ enter: "Enter",
137
+ space: "Space",
138
+ tab: "Tab",
139
+ esc: "Escape",
140
+ backspace: "Backspace",
141
+ delete: "Delete",
142
+ home: "Home",
143
+ end: "End",
144
+ pagedown: "PageDown",
145
+ pageup: "PageUp",
146
+ capslock: "CapsLock",
147
+ camera: "Camera"
148
+ };
149
+ const partialCodesByAlias = {
150
+ alt: "Alt",
151
+ opt: "Alt",
152
+ option: "Alt",
153
+ ctrl: "Control",
154
+ control: "Control",
155
+ meta: "Meta",
156
+ cmd: "Meta",
157
+ command: "Meta",
158
+ shift: "Shift"
159
+ };
24
160
 
25
161
  function createConcat(...arrays) {
26
162
  return (array) => lazyCollections.pipe(
@@ -101,6 +237,8 @@ function createReverse() {
101
237
  };
102
238
  }
103
239
  function createSlice(from, to) {
240
+ if (from < 0 || to && to < 0)
241
+ return (array) => array.slice(from, to);
104
242
  const toSliced = to ? lazyCollections.slice(from, to - 1) : lazyCollections.slice(from);
105
243
  return (array) => {
106
244
  return from === to ? [] : lazyCollections.pipe(
@@ -109,6 +247,11 @@ function createSlice(from, to) {
109
247
  )(array);
110
248
  };
111
249
  }
250
+ function createShuffle() {
251
+ return (array) => {
252
+ return arrayShuffle(array);
253
+ };
254
+ }
112
255
  function createSort(compare) {
113
256
  return (array) => {
114
257
  return lazyCollections.pipe(
@@ -117,19 +260,19 @@ function createSort(compare) {
117
260
  )(array);
118
261
  };
119
262
  }
120
- function createSwap(indices) {
263
+ function createSwap(item1Index, item2Index) {
121
264
  return (array) => {
122
- const { 0: from, 1: to } = indices, { reorderFrom, reorderTo } = (() => {
123
- if (from < to) {
265
+ const { reorderFrom, reorderTo } = (() => {
266
+ if (item1Index < item2Index) {
124
267
  return {
125
- reorderFrom: createReorder(from, to),
126
- reorderTo: createReorder(to - 1, from)
268
+ reorderFrom: createReorder(item1Index, item2Index),
269
+ reorderTo: createReorder(item2Index - 1, item1Index)
127
270
  };
128
271
  }
129
- if (from > to) {
272
+ if (item1Index > item2Index) {
130
273
  return {
131
- reorderFrom: createReorder(from, to),
132
- reorderTo: createReorder(to + 1, from)
274
+ reorderFrom: createReorder(item1Index, item2Index),
275
+ reorderTo: createReorder(item2Index + 1, item1Index)
133
276
  };
134
277
  }
135
278
  return {
@@ -147,6 +290,55 @@ function createUnique() {
147
290
  )(array);
148
291
  }
149
292
 
293
+ function createClone() {
294
+ return (any) => {
295
+ return klona.klona(any);
296
+ };
297
+ }
298
+ function createDeepEqual(compared) {
299
+ return (any) => dequal.dequal(any, compared);
300
+ }
301
+ function createEqual(compared) {
302
+ return (any) => any === compared;
303
+ }
304
+
305
+ function createValue$2(key, options = {}) {
306
+ const { predicateKey = createEqual(key) } = options;
307
+ return (associativeArray) => {
308
+ return lazyCollections.find(
309
+ ([candidate]) => predicateKey(candidate)
310
+ )(associativeArray)?.[1];
311
+ };
312
+ }
313
+ function createHas$1(key, options = {}) {
314
+ const { predicateKey = createEqual(key) } = options;
315
+ return (associativeArray) => {
316
+ return lazyCollections.findIndex(
317
+ ([candidate]) => predicateKey(candidate)
318
+ )(associativeArray) !== -1;
319
+ };
320
+ }
321
+ function createKeys$1() {
322
+ return (associativeArray) => {
323
+ return createMap(([key]) => key)(associativeArray);
324
+ };
325
+ }
326
+ function createValues$1() {
327
+ return (associativeArray) => {
328
+ return createMap(([, value]) => value)(associativeArray);
329
+ };
330
+ }
331
+
332
+ function createForEachAsync(effect) {
333
+ return async (array) => {
334
+ for (let i = 0; i < array.length; i++) {
335
+ const item = array[i];
336
+ await effect(item, i);
337
+ }
338
+ return array;
339
+ };
340
+ }
341
+
150
342
  function createFilterAsync(predicate) {
151
343
  return async (array) => {
152
344
  const transformedAsync = await createMapAsync(predicate)(array);
@@ -171,15 +363,6 @@ function createFindIndexAsync(predicate) {
171
363
  }
172
364
  };
173
365
  }
174
- function createForEachAsync(forEach) {
175
- return async (array) => {
176
- for (let i = 0; i < array.length; i++) {
177
- const item = array[i];
178
- await forEach(item, i);
179
- }
180
- return array;
181
- };
182
- }
183
366
  function createMapAsync(transform) {
184
367
  return async (array) => {
185
368
  return await createReduceAsync(
@@ -204,689 +387,495 @@ function createReduceAsync(accumulate, initialValue) {
204
387
  };
205
388
  }
206
389
 
207
- function createClip(required) {
208
- return (string) => {
209
- return string.replace(required, "");
210
- };
211
- }
212
- function createSlug(options) {
213
- return (string) => {
214
- return slugify(string, options);
215
- };
216
- }
217
-
218
- function createClamp(min, max) {
219
- return (number) => {
220
- const maxed = Math.max(number, min);
221
- return Math.min(maxed, max);
222
- };
223
- }
224
- function createDetermine(potentialities) {
225
- const predicates = createMap(({ outcome, probability }, index) => {
226
- const lowerBound = index === 0 ? 0 : lazyCollections.pipe(
227
- lazyCollections.slice(0, index - 1),
228
- lazyCollections.reduce((lowerBound2, { probability: probability2 }) => lowerBound2 + probability2, 0)
229
- )(potentialities), upperBound = lowerBound + probability;
230
- return {
231
- outcome,
232
- predicate: (determinant) => determinant >= lowerBound && determinant < upperBound || determinant < 0 && index === 0 || index === predicates.length - 1
233
- };
234
- })(potentialities);
235
- return (determinant) => lazyCollections.find(({ predicate }) => predicate(determinant))(predicates).outcome;
236
- }
237
-
238
- function createEntries() {
239
- return (object) => {
240
- const entries = [];
241
- for (const key in object) {
242
- entries.push([key, object[key]]);
243
- }
244
- return entries;
245
- };
246
- }
247
- function createKeys() {
248
- return (object) => {
249
- const keys = [];
250
- for (const key in object) {
251
- keys.push(key);
252
- }
253
- return keys;
254
- };
255
- }
256
- function createEvery(predicate) {
257
- return (object) => {
258
- for (const key in object) {
259
- if (!predicate(key, object[key])) {
260
- return false;
261
- }
262
- }
263
- return true;
264
- };
265
- }
266
- function createSome(predicate) {
267
- return (object) => {
268
- for (const key in object) {
269
- if (predicate(key, object[key]))
270
- return true;
271
- }
272
- return false;
273
- };
274
- }
275
-
276
- function createRename(from, to) {
277
- return (map) => {
278
- const keys = [...map.keys()], keyToRenameIndex = lazyCollections.findIndex((k) => k === from)(keys), newKeys = createReplace(keyToRenameIndex, to)(keys), values = [...map.values()];
279
- return createReduce((renamed, key, index) => renamed.set(key, values[index]), /* @__PURE__ */ new Map())(newKeys);
280
- };
390
+ function createList() {
391
+ return (...classValues) => clsx(...classValues);
281
392
  }
282
393
 
283
- const defaultOptions$m = {
284
- elementIsCandidate: false,
285
- // Adapted from React Aria https://github.com/adobe/react-spectrum/blob/b6786da906973130a1746b2bee63215bba013ca4/packages/%40react-aria/focus/src/FocusScope.tsx#L256
286
- tabbableSelector: lazyCollections.join(':not([hidden]):not([tabindex="-1"]),')([
287
- "input:not([disabled]):not([type=hidden])",
288
- "select:not([disabled])",
289
- "textarea:not([disabled])",
290
- "button:not([disabled])",
291
- "a[href]",
292
- "area[href]",
293
- "summary",
294
- "iframe",
295
- "object",
296
- "embed",
297
- "audio[controls]",
298
- "video[controls]",
299
- "[contenteditable]",
300
- "[tabindex]:not([disabled])"
301
- ])
394
+ const defaultCreateMixOptions = {
395
+ method: "oklch",
396
+ tag: "div",
397
+ getParent: () => document.body
302
398
  };
303
- function createFocusable(order, options = {}) {
304
- const { elementIsCandidate, tabbableSelector } = { ...defaultOptions$m, ...options }, predicateFocusable = (element) => element.matches(tabbableSelector);
305
- return (element) => {
306
- if (elementIsCandidate && predicateFocusable(element))
307
- return element;
308
- switch (order) {
309
- case "first":
310
- for (let i = 0; i < element.children.length; i++) {
311
- const focusable = createFocusable(order, { elementIsCandidate: true })(element.children[i]);
312
- if (focusable)
313
- return focusable;
314
- }
315
- break;
316
- case "last":
317
- for (let i = element.children.length - 1; i > -1; i--) {
318
- const focusable = createFocusable(order, { elementIsCandidate: true })(element.children[i]);
319
- if (focusable)
320
- return focusable;
321
- }
322
- break;
323
- }
399
+ function createMix(color2, options = {}) {
400
+ const { method, tag, getParent } = { ...defaultCreateMixOptions, ...options };
401
+ return (color1) => {
402
+ const element = document.createElement(tag), parent = getParent();
403
+ element.style.color = `color-mix(in ${method}, ${color1}, ${color2})`;
404
+ parent.appendChild(element);
405
+ const mixed = getComputedStyle(element).color;
406
+ parent.removeChild(element);
407
+ return mixed;
324
408
  };
325
409
  }
326
410
 
327
- function createToIndegree(graph) {
328
- const toIncoming = createToIncoming(graph);
329
- return (node) => lazyCollections.pipe(
330
- toIncoming,
331
- toLength()
332
- )(node);
333
- }
334
- function createToOutdegree(graph) {
335
- const toOutgoing = createToOutgoing(graph);
336
- return (node) => lazyCollections.pipe(
337
- toOutgoing,
338
- toLength()
339
- )(node);
340
- }
341
- function createToIncoming(graph) {
342
- const { edges } = graph;
343
- return function* (node) {
344
- yield* lazyCollections.filter(
345
- ({ to }) => to === node
346
- )(edges);
347
- };
348
- }
349
- function createToOutgoing(graph) {
350
- const { edges } = graph;
351
- return function* (node) {
352
- yield* lazyCollections.filter(
353
- ({ from }) => from === node
354
- )(edges);
355
- };
356
- }
357
- function createPredicateRoot(graph) {
358
- const toIndegree = createToIndegree(graph);
359
- return (node) => toIndegree(node) === 0;
411
+ function createDepthPathConfig(directedAcyclic) {
412
+ const predicateTerminal = createTerminal(directedAcyclic), predicatePathable = (node) => !predicateTerminal(node), toTraversalCandidates = (path) => lazyCollections.pipe(
413
+ lazyCollections.at(-1),
414
+ createOutgoing(directedAcyclic)
415
+ )(path);
416
+ return { predicatePathable, toTraversalCandidates };
360
417
  }
361
418
 
362
- function createFind(node) {
363
- return (tree) => {
364
- for (const treeNode of tree) {
365
- if (treeNode.node === node)
366
- return treeNode;
367
- const found = createFind(node)(treeNode.children);
368
- if (found)
369
- return found;
370
- }
371
- };
419
+ function createBreadthPathConfig(directedAcyclic) {
420
+ const predicateOnlyChild = createOnlyChild(directedAcyclic), predicatePathable = (node) => !predicateOnlyChild(node), toTraversalCandidates = (path) => lazyCollections.pipe(
421
+ lazyCollections.at(-2),
422
+ createOutgoing(directedAcyclic)
423
+ )(path);
424
+ return { predicatePathable, toTraversalCandidates };
372
425
  }
373
426
 
374
- function createToLayers$1(options = {}) {
375
- const toSteps = createToSteps$2(options.createToSteps);
376
- return function toLayers(directedAcyclic) {
377
- const layers = [];
378
- for (const { path } of toSteps(directedAcyclic)) {
379
- const node = path.at(-1), depth = path.length - 1;
380
- (layers[depth] || (layers[depth] = [])).push(node);
381
- }
382
- return layers;
383
- };
384
- }
385
- function createToTree$2(options = {}) {
386
- const toSteps = createToSteps$2(options.createToSteps);
387
- return function toTree(directedAcyclic) {
388
- const firstRoot = lazyCollections.pipe(
389
- createToRoots(),
390
- lazyCollections.at(0)
391
- )(directedAcyclic), tree = [];
392
- tree.push({
393
- node: firstRoot,
394
- children: []
395
- });
396
- for (const { path } of toSteps(directedAcyclic)) {
397
- const node = path.at(-1), parent = path.at(-2);
398
- if (parent) {
399
- const parentTreeNode = createFind(parent)(tree);
400
- if (parentTreeNode) {
401
- parentTreeNode.children.push({
402
- node,
403
- children: []
404
- });
405
- }
406
- }
407
- }
408
- return tree;
409
- };
410
- }
411
- function createToCommonAncestors$2(directedAcyclic) {
412
- const toNodeSteps = createToNodeSteps$2(directedAcyclic);
413
- return function* (a, b) {
414
- for (const { path: aPath } of toNodeSteps(a)) {
415
- for (const { path: bPath } of toNodeSteps(b)) {
416
- for (let aPathIndex = aPath.length - 1; aPathIndex >= 0; aPathIndex--) {
417
- for (let bPathIndex = bPath.length - 1; bPathIndex >= 0; bPathIndex--) {
418
- if (aPath[aPathIndex] === bPath[bPathIndex] && !lazyCollections.includes(aPath[aPathIndex])([a, b])) {
419
- yield {
420
- node: aPath[aPathIndex],
421
- distances: {
422
- [a]: aPath.length - aPathIndex - 1,
423
- [b]: bPath.length - bPathIndex - 1
424
- }
425
- };
426
- }
427
- }
428
- }
429
- }
430
- }
431
- };
432
- }
433
- function createPredicateAncestor$2(directedAcyclic) {
434
- const toNodeSteps = createToNodeSteps$2(directedAcyclic);
435
- return function(descendant, ancestor) {
436
- return lazyCollections.pipe(
437
- toNodeSteps,
438
- lazyCollections.some(({ path }) => lazyCollections.includes(ancestor)(path))
439
- )(descendant);
440
- };
441
- }
442
- function createToNodeSteps$2(directedAcyclic, options = {}) {
443
- const toSteps = createToSteps$2(options.createToSteps);
444
- return function* (node) {
445
- yield* lazyCollections.pipe(
446
- toSteps,
447
- lazyCollections.filter(({ path }) => path.at(-1) === node)
448
- )(directedAcyclic);
449
- };
450
- }
451
- const defaultCreateToStepsOptions$1 = {
452
- toUnsetMetadata: () => 0,
453
- toMockMetadata: (node, totalConnectionsFollowed) => totalConnectionsFollowed,
454
- kind: "directed acyclic"
455
- };
456
- function createToSteps$2(options = {}) {
457
- const { toUnsetMetadata, toMockMetadata, root, kind } = { ...defaultCreateToStepsOptions$1, ...options };
458
- return function* (directedAcyclic) {
459
- const { nodes } = directedAcyclic, toOutdegree = createToOutdegree(directedAcyclic), toPath = createToPath$2(directedAcyclic), roots = lazyCollections.pipe(
460
- createToRoots({ kind }),
461
- lazyCollections.toArray()
462
- )(directedAcyclic), state = {}, totalConnectionsFollowedByNode = {}, predicateExhausted = (node) => {
463
- return totalConnectionsFollowedByNode[node] === toOutdegree(node);
427
+ class Recognizeable {
428
+ maxSequenceLength;
429
+ effects;
430
+ effectApi;
431
+ constructor(sequence, options = {}) {
432
+ const defaultOptions = {
433
+ maxSequenceLength: true,
434
+ effects: {}
464
435
  };
465
- for (const node of nodes) {
466
- state[node] = {
467
- status: "unset",
468
- metadata: toUnsetMetadata(node)
469
- };
470
- }
471
- let location = root || lazyCollections.at(0)(roots);
472
- const path = toPath(state);
473
- yield { path, state: JSON.parse(JSON.stringify(state)) };
474
- function* toStep() {
475
- if (predicateExhausted(location)) {
476
- if (lazyCollections.includes(location)(roots))
477
- return;
478
- state[location].status = "unset";
479
- state[location].metadata = toUnsetMetadata(location);
480
- const path3 = toPath(state);
481
- location = path3.at(-2);
482
- yield* toStep();
483
- return;
436
+ this.maxSequenceLength = options?.maxSequenceLength || defaultOptions.maxSequenceLength;
437
+ this.effects = options?.effects || defaultOptions.effects;
438
+ this.resetComputedMetadata();
439
+ this.setSequence(sequence);
440
+ this.effectApi = {
441
+ getStatus: () => this.status,
442
+ getMetadata: () => this.metadata,
443
+ setMetadata: (metadata) => this.computedMetadata = metadata,
444
+ recognized: () => this.recognized(),
445
+ denied: () => this.denied(),
446
+ ready: () => this.ready()
447
+ };
448
+ this.ready();
449
+ }
450
+ computedMetadata;
451
+ resetComputedMetadata() {
452
+ this.computedMetadata = {};
453
+ }
454
+ recognized() {
455
+ this.computedStatus = "recognized";
456
+ }
457
+ denied() {
458
+ this.computedStatus = "denied";
459
+ }
460
+ computedStatus;
461
+ ready() {
462
+ this.computedStatus = "ready";
463
+ }
464
+ get sequence() {
465
+ return this.computedSequence;
466
+ }
467
+ set sequence(sequence) {
468
+ this.setSequence(sequence);
469
+ }
470
+ get status() {
471
+ return this.computedStatus;
472
+ }
473
+ get metadata() {
474
+ return this.computedMetadata;
475
+ }
476
+ computedSequence;
477
+ setSequence(sequence) {
478
+ this.computedSequence = sequence;
479
+ return this;
480
+ }
481
+ recognize(sequenceItem, options = {}) {
482
+ this.recognizing();
483
+ const type = this.toType(sequenceItem), pushSequence = (sequenceItem2) => {
484
+ newSequence.push(sequenceItem2);
485
+ if (this.maxSequenceLength !== true && newSequence.length > this.maxSequenceLength) {
486
+ newSequence.shift();
484
487
  }
485
- if (!(location in totalConnectionsFollowedByNode))
486
- totalConnectionsFollowedByNode[location] = 0;
487
- state[location].status = "set";
488
- state[location].metadata = toMockMetadata(location, totalConnectionsFollowedByNode[location]);
489
- const path2 = toPath(state);
490
- yield { path: path2, state: JSON.parse(JSON.stringify(state)) };
491
- totalConnectionsFollowedByNode[location]++;
492
- const newLocation = path2.at(-1);
493
- if (toOutdegree(newLocation) > 0)
494
- location = newLocation;
495
- yield* toStep();
496
- }
497
- yield* toStep();
498
- };
499
- }
500
- function createToPath$2(directedAcyclic) {
501
- const toOutdegree = createToOutdegree(directedAcyclic), toOutgoing = createToOutgoing(directedAcyclic), firstRoot = lazyCollections.pipe(
502
- createToRoots(),
503
- lazyCollections.at(0)
504
- )(directedAcyclic);
505
- return (state) => {
506
- const path = [firstRoot], getLastOutdegree = () => toOutdegree(path.at(-1)), getLastStatus = () => state[path.at(-1)].status;
507
- while (getLastOutdegree() > 0 && getLastStatus() === "set") {
508
- const edge = lazyCollections.pipe(
509
- toOutgoing,
510
- lazyCollections.find(
511
- ({ predicateTraversable }) => predicateTraversable(state)
512
- )
513
- )(path.at(-1));
514
- path.push(edge.to);
488
+ }, newSequence = [];
489
+ for (const sequenceItem2 of this.sequence) {
490
+ pushSequence(sequenceItem2);
515
491
  }
516
- return path;
517
- };
518
- }
519
- function createToRoots(options = {}) {
520
- return function* (directedAcyclic) {
521
- const { nodes } = directedAcyclic;
522
- for (const node of nodes) {
523
- if (createPredicateRoot(directedAcyclic)(node))
524
- yield node;
525
- if (options.kind === "arborescence")
492
+ pushSequence(sequenceItem);
493
+ this.effectApi.getSequence = () => newSequence;
494
+ this.effectApi.pushSequence = pushSequence;
495
+ this.effectApi.listenInjection = {
496
+ effect: options.listenInjection?.effect || (() => {
497
+ }),
498
+ optionsByType: options.listenInjection?.optionsByType || {}
499
+ };
500
+ this.effects[type]?.(sequenceItem, { ...this.effectApi });
501
+ switch (this.status) {
502
+ case "ready":
503
+ case "denied":
504
+ this.resetComputedMetadata();
505
+ this.setSequence([]);
506
+ break;
507
+ case "recognizing":
508
+ case "recognized":
509
+ this.setSequence(newSequence);
526
510
  break;
527
511
  }
528
- };
529
- }
530
-
531
- function createToLayers(options = {}) {
532
- const toSteps = createToSteps$1(options.createToSteps);
533
- return async function toLayers(directedAcyclic) {
534
- const layers = [];
535
- for await (const { path } of toSteps(directedAcyclic)) {
536
- const node = path.at(-1), depth = path.length - 1;
537
- (layers[depth] || (layers[depth] = [])).push(node);
538
- }
539
- return layers;
540
- };
541
- }
542
- function createToTree$1(options = {}) {
543
- const toSteps = createToSteps$1(options.createToSteps);
544
- return async function toTree(directedAcyclic) {
545
- const firstRoot = lazyCollections.pipe(
546
- createToRoots(),
547
- lazyCollections.at(0)
548
- )(directedAcyclic), tree = [];
549
- tree.push({
550
- node: firstRoot,
551
- children: []
552
- });
553
- for await (const { path } of toSteps(directedAcyclic)) {
554
- const node = path.at(-1), parent = path.at(-2);
555
- if (parent) {
556
- const parentTreeNode = createFind(parent)(tree);
557
- if (parentTreeNode) {
558
- parentTreeNode.children.push({
559
- node,
560
- children: []
561
- });
562
- }
512
+ return this;
513
+ }
514
+ recognizing() {
515
+ this.computedStatus = "recognizing";
516
+ }
517
+ toType(sequenceItem) {
518
+ if (predicateArray(sequenceItem)) {
519
+ if (sequenceItem[0] instanceof IntersectionObserverEntry) {
520
+ return "intersect";
563
521
  }
564
- }
565
- return tree;
566
- };
567
- }
568
- function createToCommonAncestors$1(directedAcyclic) {
569
- const toNodeSteps = createToNodeSteps$1(directedAcyclic);
570
- return async function* (a, b) {
571
- for await (const { path: aPath } of toNodeSteps(a)) {
572
- for await (const { path: bPath } of toNodeSteps(b)) {
573
- for (let aPathIndex = aPath.length - 1; aPathIndex >= 0; aPathIndex--) {
574
- for (let bPathIndex = bPath.length - 1; bPathIndex >= 0; bPathIndex--) {
575
- if (aPath[aPathIndex] === bPath[bPathIndex] && !lazyCollections.includes(aPath[aPathIndex])([a, b])) {
576
- yield {
577
- node: aPath[aPathIndex],
578
- distances: {
579
- [a]: aPath.length - aPathIndex - 1,
580
- [b]: bPath.length - bPathIndex - 1
581
- }
582
- };
583
- }
584
- }
585
- }
522
+ if (sequenceItem[0] instanceof MutationRecord) {
523
+ return "mutate";
524
+ }
525
+ if (sequenceItem[0] instanceof ResizeObserverEntry) {
526
+ return "resize";
527
+ }
528
+ } else {
529
+ if (sequenceItem instanceof MediaQueryListEvent) {
530
+ return sequenceItem.media;
586
531
  }
532
+ if ("didTimeout" in sequenceItem) {
533
+ return "idle";
534
+ }
535
+ return sequenceItem.type;
587
536
  }
588
- };
589
- }
590
- function createPredicateAncestor$1(directedAcyclic) {
591
- const toNodeSteps = createToNodeSteps$1(directedAcyclic);
592
- return async function(descendant, ancestor) {
593
- return await lazyCollections.pipe(
594
- toNodeSteps,
595
- lazyCollections.some(({ path }) => lazyCollections.includes(ancestor)(path))
596
- )(descendant);
597
- };
598
- }
599
- function createToNodeSteps$1(directedAcyclic, options = {}) {
600
- const toSteps = createToSteps$1(options.createToSteps);
601
- return async function* (node) {
602
- yield* await lazyCollections.pipe(
603
- toSteps,
604
- lazyCollections.filter(({ path }) => path.at(-1) === node)
605
- )(directedAcyclic);
606
- };
537
+ }
607
538
  }
608
- function createToSteps$1(options = {}) {
609
- const { toUnsetMetadata, toMockMetadata, root, kind } = { ...defaultCreateToStepsOptions$1, ...options };
610
- return async function* (directedAcyclic) {
611
- const { nodes } = directedAcyclic, toOutdegree = createToOutdegree(directedAcyclic), toPath = createToPath$1(directedAcyclic), roots = lazyCollections.pipe(
612
- createToRoots({ kind }),
613
- lazyCollections.toArray()
614
- )(directedAcyclic), state = {}, totalConnectionsFollowedByNode = {}, predicateExhausted = (node) => {
615
- return totalConnectionsFollowedByNode[node] === toOutdegree(node);
616
- };
617
- for (const node of nodes) {
618
- state[node] = {
619
- status: "unset",
620
- metadata: toUnsetMetadata(node)
621
- };
539
+
540
+ class Listenable {
541
+ computedRecognizeable;
542
+ recognizeableEffectsKeys;
543
+ computedActive;
544
+ constructor(type, options) {
545
+ if (type === "recognizeable") {
546
+ this.computedRecognizeable = new Recognizeable([], options?.recognizeable);
547
+ this.recognizeableEffectsKeys = Object.keys(options?.recognizeable?.effects);
622
548
  }
623
- let location = root || lazyCollections.at(0)(roots);
624
- const path = await toPath(state);
625
- yield { path, state: JSON.parse(JSON.stringify(state)) };
626
- async function* toStep() {
627
- if (predicateExhausted(location)) {
628
- if (lazyCollections.includes(location)(roots))
629
- return;
630
- state[location].status = "unset";
631
- state[location].metadata = toUnsetMetadata(location);
632
- const path3 = await toPath(state);
633
- location = path3.at(-2);
634
- yield* await toStep();
635
- return;
636
- }
637
- if (!(location in totalConnectionsFollowedByNode))
638
- totalConnectionsFollowedByNode[location] = 0;
639
- state[location].status = "set";
640
- state[location].metadata = toMockMetadata(location, totalConnectionsFollowedByNode[location]);
641
- const path2 = await toPath(state);
642
- yield { path: path2, state: JSON.parse(JSON.stringify(state)) };
643
- totalConnectionsFollowedByNode[location]++;
644
- const newLocation = path2.at(-1);
645
- if (toOutdegree(newLocation) > 0)
646
- location = newLocation;
647
- yield* await toStep();
549
+ this.computedActive = /* @__PURE__ */ new Set();
550
+ this.setType(type);
551
+ this.ready();
552
+ }
553
+ computedStatus;
554
+ ready() {
555
+ this.computedStatus = "ready";
556
+ }
557
+ get type() {
558
+ return this.computedType;
559
+ }
560
+ set type(type) {
561
+ this.setType(type);
562
+ }
563
+ get status() {
564
+ return this.computedStatus;
565
+ }
566
+ get active() {
567
+ return this.computedActive;
568
+ }
569
+ get recognizeable() {
570
+ return this.computedRecognizeable;
571
+ }
572
+ computedType;
573
+ implementation;
574
+ setType(type) {
575
+ this.stop();
576
+ this.computedType = type;
577
+ this.implementation = toImplementation(type);
578
+ return this;
579
+ }
580
+ listen(effect, options = {}) {
581
+ switch (this.implementation) {
582
+ case "intersection":
583
+ this.intersectionListen(effect, options);
584
+ break;
585
+ case "mutation":
586
+ this.mutationListen(effect, options);
587
+ break;
588
+ case "resize":
589
+ this.resizeListen(effect, options);
590
+ break;
591
+ case "mediaquery":
592
+ this.mediaQueryListen(effect, options);
593
+ break;
594
+ case "idle":
595
+ this.idleListen(effect, options);
596
+ break;
597
+ case "message":
598
+ this.messageListen(effect, options);
599
+ break;
600
+ case "recognizeable":
601
+ this.recognizeableListen(effect, options);
602
+ break;
603
+ case "documentevent":
604
+ this.documentEventListen(effect, options);
605
+ break;
606
+ case "event":
607
+ this.eventListen(effect, options);
608
+ break;
648
609
  }
649
- yield* await toStep();
650
- };
651
- }
652
- function createToPath$1(directedAcyclic) {
653
- const toOutdegree = createToOutdegree(directedAcyclic), toOutgoing = createToOutgoing(directedAcyclic), firstRoot = lazyCollections.pipe(
654
- createToRoots(),
655
- lazyCollections.at(0)
656
- )(directedAcyclic);
657
- return async (state) => {
658
- const path = [firstRoot], getLastOutdegree = () => toOutdegree(path.at(-1)), getLastStatus = () => state[path.at(-1)].status;
659
- while (getLastOutdegree() > 0 && getLastStatus() === "set") {
660
- const edge = await lazyCollections.pipe(
661
- toOutgoing,
662
- lazyCollections.toArray(),
663
- createFindAsync(
664
- async ({ predicateTraversable }) => await predicateTraversable(state)
665
- )
666
- )(path.at(-1));
667
- path.push(edge.to);
610
+ this.listening();
611
+ return this;
612
+ }
613
+ intersectionListen(effect, options) {
614
+ const { target, observer } = { ...this.getDefaultListenOptions(), ...options }, id = new IntersectionObserver(effect, observer);
615
+ id.observe(target);
616
+ this.active.add({ target, id });
617
+ }
618
+ mutationListen(effect, options) {
619
+ const { target, observe } = { ...this.getDefaultListenOptions(), ...options }, id = new MutationObserver(effect);
620
+ id.observe(target, observe);
621
+ this.active.add({ target, id });
622
+ }
623
+ resizeListen(effect, options) {
624
+ const { target, observe } = { ...this.getDefaultListenOptions(), ...options }, id = new ResizeObserver(effect);
625
+ id.observe(target, observe);
626
+ this.active.add({ target, id });
627
+ }
628
+ mediaQueryListen(effect, options) {
629
+ const target = window.matchMedia(this.type), { instantEffect } = { ...this.getDefaultListenOptions(), ...options };
630
+ instantEffect(target);
631
+ const withApi = (event) => effect(event);
632
+ target.addEventListener("change", withApi);
633
+ this.active.add({ target, id: ["change", withApi] });
634
+ }
635
+ idleListen(effect, options) {
636
+ const { requestIdleCallback } = { ...this.getDefaultListenOptions(), ...options }, id = window.requestIdleCallback((deadline) => effect(deadline), requestIdleCallback);
637
+ this.active.add({ target: window, id });
638
+ }
639
+ messageListen(effect, options) {
640
+ const { target = new BroadcastChannel("baleada") } = options;
641
+ target.addEventListener(this.type, (event) => effect(event));
642
+ this.active.add({ target, id: [this.type, effect] });
643
+ }
644
+ recognizeableListen(effect, options) {
645
+ const guardedEffect = (sequenceItem) => {
646
+ this.recognizeable.recognize(
647
+ sequenceItem,
648
+ { listenInjection: { effect, optionsByType } }
649
+ );
650
+ if (this.recognizeable.status === "recognized")
651
+ effect(sequenceItem);
652
+ }, optionsByType = {};
653
+ for (const type of this.recognizeableEffectsKeys) {
654
+ optionsByType[type] = {
655
+ ...this.getDefaultListenOptions(toImplementation(type)),
656
+ ...options
657
+ };
668
658
  }
669
- return path;
670
- };
671
- }
672
-
673
- const defaultCreateToStepsOptions = {
674
- priorityBranch: false,
675
- kind: "directed acyclic"
676
- };
677
- function createToTree(options = {}) {
678
- const withDefaults = {
679
- ...options,
680
- createToSteps: {
681
- ...defaultCreateToStepsOptions,
682
- ...options.createToSteps
659
+ for (const type of this.recognizeableEffectsKeys) {
660
+ const listenable = new Listenable(type);
661
+ listenable.listen(guardedEffect, options);
662
+ this.active.add({ id: listenable });
683
663
  }
684
- };
685
- return createToTree$2({
686
- ...withDefaults,
687
- createToSteps: toCreateDirectedAcyclicToStepsOptions(withDefaults.createToSteps)
688
- });
689
- }
690
- function createToCommonAncestors(...params) {
691
- return createToCommonAncestors$2(...params);
692
- }
693
- function createPredicateAncestor(...params) {
694
- return createPredicateAncestor$2(...params);
695
- }
696
- function createToNodeSteps(decisionTree, options = {}) {
697
- const withDefaults = {
698
- ...options,
699
- createToSteps: {
700
- ...defaultCreateToStepsOptions,
701
- ...options.createToSteps
664
+ }
665
+ documentEventListen(effect, options) {
666
+ const narrowedOptions = {
667
+ ...this.getDefaultListenOptions(),
668
+ target: document
669
+ };
670
+ this.eventListen(effect, narrowedOptions);
671
+ }
672
+ eventListen(effect, options) {
673
+ const { exceptAndOnlyEffect, effectOptions } = toAddEventListenerParams(this.type, effect, options), eventListeners = [[this.type, exceptAndOnlyEffect, ...effectOptions]];
674
+ this.addEventListeners(eventListeners, options);
675
+ }
676
+ addEventListeners(eventListeners, options) {
677
+ const { target } = { ...this.getDefaultListenOptions(), ...options };
678
+ for (const eventListener of eventListeners) {
679
+ target.addEventListener(eventListener[0], eventListener[1], eventListener[2]);
680
+ this.active.add({ target, id: eventListener });
702
681
  }
703
- };
704
- return createToNodeSteps$2(
705
- decisionTree,
706
- {
707
- ...withDefaults,
708
- createToSteps: toCreateDirectedAcyclicToStepsOptions(withDefaults.createToSteps)
682
+ }
683
+ listening() {
684
+ this.computedStatus = "listening";
685
+ }
686
+ stop(options = {}) {
687
+ const { target } = options;
688
+ switch (this.status) {
689
+ case "ready":
690
+ case void 0:
691
+ break;
692
+ default:
693
+ const stoppables = [...this.active].filter((active) => !target || ("target" in active ? active.target === target : false)), shouldUpdateStatus = stoppables.length === this.active.size;
694
+ for (const stoppable of stoppables) {
695
+ stop(stoppable);
696
+ this.active.delete(stoppable);
697
+ }
698
+ if (shouldUpdateStatus) {
699
+ this.stopped();
700
+ }
701
+ break;
709
702
  }
710
- );
711
- }
712
- function createToSteps(options = {}) {
713
- const withDefaults = {
714
- ...defaultCreateToStepsOptions,
715
- ...options
716
- };
717
- return createToSteps$2(
718
- toCreateDirectedAcyclicToStepsOptions(withDefaults)
719
- );
720
- }
721
- function createToPath(...params) {
722
- return createToPath$2(...params);
723
- }
724
- function toCreateDirectedAcyclicToStepsOptions(options) {
725
- return {
726
- ...defaultCreateToStepsOptions,
727
- ...options,
728
- ...{
729
- toUnsetMetadata: () => false,
730
- toMockMetadata: (node, totalConnectionsFollowed) => options.priorityBranch ? !totalConnectionsFollowed : !!totalConnectionsFollowed
703
+ return this;
704
+ }
705
+ stopped() {
706
+ this.computedStatus = "stopped";
707
+ }
708
+ getDefaultListenOptions(implementation) {
709
+ switch (implementation || this.implementation) {
710
+ case "intersection":
711
+ return {
712
+ target: document.querySelector("html"),
713
+ observer: {}
714
+ };
715
+ case "mutation":
716
+ return {
717
+ target: document.querySelector("html"),
718
+ observe: {}
719
+ };
720
+ case "resize":
721
+ return {
722
+ target: document.querySelector("html"),
723
+ observe: {}
724
+ };
725
+ case "mediaquery":
726
+ return {
727
+ instantEffect: () => {
728
+ }
729
+ };
730
+ case "idle":
731
+ return {
732
+ requestIdleCallback: {}
733
+ };
734
+ case "message":
735
+ return {
736
+ target: new BroadcastChannel("baleada")
737
+ };
738
+ case "recognizeable":
739
+ return {};
740
+ case "documentevent":
741
+ return {};
742
+ case "event":
743
+ return { target: document };
731
744
  }
732
- };
745
+ }
733
746
  }
734
-
735
- function createList() {
736
- return (...classValues) => clsx(...classValues);
747
+ function stop(stoppable) {
748
+ if (stoppable.id instanceof Listenable) {
749
+ stoppable.id.stop();
750
+ return;
751
+ }
752
+ if (lazyCollections.some((type) => observerAssertionsByType[type](stoppable.id))(["intersect", "mutate", "resize"])) {
753
+ const { id: id2 } = stoppable;
754
+ id2.disconnect();
755
+ return;
756
+ }
757
+ if ("target" in stoppable && stoppable.target instanceof MediaQueryList) {
758
+ const { target: target2, id: id2 } = stoppable;
759
+ target2.removeEventListener(id2[0], id2[1]);
760
+ return;
761
+ }
762
+ if (predicateNumber(stoppable.id)) {
763
+ const { target: target2, id: id2 } = stoppable;
764
+ target2.cancelIdleCallback(id2);
765
+ return;
766
+ }
767
+ if ("target" in stoppable && stoppable.target instanceof BroadcastChannel) {
768
+ const { target: target2, id: id2 } = stoppable;
769
+ target2.removeEventListener(id2[0], id2[1]);
770
+ return;
771
+ }
772
+ const { target, id } = stoppable;
773
+ target.removeEventListener(id[0], id[1], id[2]);
737
774
  }
738
-
739
- const defaultOptions$l = {
740
- toId: (node) => node.id,
741
- toChildren: (node) => node.children
742
- };
743
- function createToGraph(options = {}) {
744
- const { toId, toChildren } = { ...defaultOptions$l, ...options };
745
- return function* (tree) {
746
- const root = tree[0], rootId = toId(root);
747
- function* toPair(node, id) {
748
- const children = toChildren(node) || [];
749
- for (const child of children) {
750
- const childId = toId(child);
751
- yield {
752
- node: childId,
753
- edge: { from: id, to: childId }
754
- };
755
- yield* toPair(child, childId);
756
- }
757
- }
758
- yield { node: rootId };
759
- yield* toPair(root, rootId);
760
- };
775
+ function toImplementation(type) {
776
+ return lazyCollections.find((implementation) => predicatesByImplementation.get(implementation)(type))(predicatesByImplementation.keys());
761
777
  }
762
-
763
- const defaultOptions$k = {
764
- toKey: (alias) => fromAliasToKeyStatusKey(alias),
765
- toAliases: (event) => fromEventToAliases(event)
766
- };
767
- const createPredicateKeycomboMatch$1 = (keycombo, options = {}) => {
768
- const { toKey, toAliases } = { ...defaultOptions$k, ...options }, aliases = fromComboToAliases(keycombo), keys = lazyCollections.map(toKey)(aliases);
769
- return (event) => {
770
- const { toValue, set, toEntries } = createKeyStatuses();
771
- set(fromEventToKeyStatusKey(event), "down");
772
- for (const modifier of modifiers) {
773
- if (event[`${modifier.toLowerCase()}Key`])
774
- set({ key: modifier }, "down");
775
- }
776
- return lazyCollections.every(lazyCollections.pipe(
777
- toValue,
778
- predicateDown
779
- ))(keys) && lazyCollections.every(
780
- ([key]) => lazyCollections.some(
781
- (alias) => lazyCollections.includes(alias)(aliases)
782
- )(toAliases(key))
783
- )(toEntries());
784
- };
785
- };
786
-
787
- const defaultOptions$j = {
788
- initial: [],
789
- createPredicateKey: (query) => (candidate) => query === candidate
778
+ const predicatesByImplementation = /* @__PURE__ */ new Map([
779
+ [
780
+ "recognizeable",
781
+ (type) => type === "recognizeable"
782
+ ],
783
+ [
784
+ "intersection",
785
+ (type) => type === "intersect"
786
+ ],
787
+ [
788
+ "mutation",
789
+ (type) => type === "mutate"
790
+ ],
791
+ [
792
+ "resize",
793
+ (type) => type === "resize"
794
+ ],
795
+ [
796
+ "mediaquery",
797
+ (type) => implementationREs.mediaquery.test(type)
798
+ ],
799
+ [
800
+ "idle",
801
+ (type) => type === "idle"
802
+ ],
803
+ [
804
+ "message",
805
+ (type) => type === "message" || type === "messageerror"
806
+ ],
807
+ [
808
+ "documentevent",
809
+ (type) => documentEvents.has(type)
810
+ ],
811
+ [
812
+ "event",
813
+ () => true
814
+ ]
815
+ ]);
816
+ const documentEvents = /* @__PURE__ */ new Set([
817
+ "fullscreenchange",
818
+ "fullscreenerror",
819
+ "pointerlockchange",
820
+ "pointerlockerror",
821
+ "readystatechange",
822
+ "visibilitychange"
823
+ ]);
824
+ const implementationREs = {
825
+ mediaquery: /^\(.+\)$/
790
826
  };
791
- function createAssociativeArray(options = {}) {
792
- const { initial, createPredicateKey } = { ...defaultOptions$j, ...options }, entries = [...initial];
793
- const toValue = (key) => {
794
- const predicateKey = createPredicateKey(key);
795
- return lazyCollections.find(
796
- ([candidate]) => predicateKey(candidate)
797
- )(entries)?.[1];
798
- };
799
- const set = (key, value) => {
800
- const predicateKey = createPredicateKey(key), index = lazyCollections.findIndex(
801
- ([candidate]) => predicateKey(candidate)
802
- )(entries);
803
- if (index === -1) {
804
- entries.push([key, value]);
805
- return;
806
- }
807
- entries[index][1] = value;
808
- };
809
- const predicateHas = (key) => {
810
- const predicateKey = createPredicateKey(key);
811
- return lazyCollections.findIndex(
812
- ([candidate]) => predicateKey(candidate)
813
- )(entries) !== -1;
814
- };
815
- const clear = () => {
816
- entries.length = 0;
817
- };
818
- const del = (key) => {
819
- const predicateKey = createPredicateKey(key), index = lazyCollections.findIndex(
820
- ([candidate]) => predicateKey(candidate)
821
- )(entries);
822
- if (index === -1) {
823
- return false;
824
- }
825
- entries.splice(index, 1);
826
- return true;
827
- };
828
- const toKeys = () => {
829
- return createMap(([key]) => key)(entries);
830
- };
831
- const toValues = () => {
832
- return createMap(([, value]) => value)(entries);
833
- };
834
- const toEntries = () => {
835
- return entries;
836
- };
837
- return {
838
- toValue,
839
- set,
840
- predicateHas,
841
- clear,
842
- delete: del,
843
- toKeys,
844
- toValues,
845
- toEntries
846
- // get: toValue,
847
- // has: predicateHas,
848
- // keys: toKeys,
849
- // values: toValues,
850
- };
827
+ function toAddEventListenerParams(type, effect, options) {
828
+ const { addEventListener, useCapture } = options, exceptAndOnlyEffect = createExceptAndOnlyEffect(type, effect, options), effectOptions = [addEventListener || useCapture];
829
+ return { exceptAndOnlyEffect, effectOptions };
851
830
  }
831
+ const observerAssertionsByType = {
832
+ intersect: (observer) => observer instanceof IntersectionObserver,
833
+ mutate: (observer) => observer instanceof MutationObserver,
834
+ resize: (observer) => observer instanceof ResizeObserver
835
+ };
852
836
 
853
- const defaultOptions$i = {
837
+ const defaultOptions$k = {
854
838
  minDuration: 0,
855
839
  preventsDefaultUnlessDenied: true,
856
- toKey: (alias) => fromAliasToKeyStatusKey(alias),
857
- toAliases: (event) => fromEventToAliases(event)
840
+ toCode: (alias) => fromAliasToCode(alias),
841
+ toAliases: (code) => fromCodeToAliases(code)
858
842
  };
859
843
  function createKeypress(keycomboOrKeycombos, options = {}) {
860
844
  const {
861
845
  minDuration,
862
846
  preventsDefaultUnlessDenied,
863
- toKey,
847
+ toLonghand,
848
+ toCode,
864
849
  toAliases,
865
850
  onDown,
866
851
  onUp,
867
852
  onVisibilitychange
868
- } = { ...defaultOptions$i, ...options }, {
853
+ } = { ...defaultOptions$k, ...options }, {
869
854
  matchPredicatesByKeycombo,
870
855
  getDownCombos,
871
856
  predicateValid,
872
857
  cleanup,
873
- statuses
858
+ statuses,
859
+ toStatus,
860
+ setStatus,
861
+ clearStatuses,
862
+ deleteStatus
874
863
  } = createKeyState({
875
864
  keycomboOrKeycombos,
876
- unsupportedAliases: unsupportedAliases$2,
877
- toKey,
865
+ toLonghand,
866
+ toCode,
878
867
  toAliases,
879
868
  getRequest: () => request
880
- });
869
+ }), fromComboToAliasesLength = createAliasesLength({ toLonghand });
881
870
  let request;
882
871
  let localStatus;
883
872
  const keydown = (event, api) => {
884
- const { denied, getStatus } = api, key = fromEventToKeyStatusKey(event);
885
- if (statuses.toValue(key) === "down") {
873
+ const { denied, getStatus } = api, key = fromEventToKeyStatusCode(event);
874
+ if (toStatus(key) === "down") {
886
875
  onDown?.(toHookApi(api));
887
876
  return;
888
877
  }
889
- statuses.set(key, "down");
878
+ setStatus(key, "down");
890
879
  if (localStatus === "denied") {
891
880
  denied();
892
881
  onDown?.(toHookApi(api));
@@ -899,15 +888,15 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
899
888
  ) {
900
889
  denied();
901
890
  localStatus = getStatus();
902
- if (lazyCollections.includes(event.key)(unsupportedKeys$2))
903
- statuses.clear();
891
+ if (lazyCollections.includes(event.key)(unsupportedKeys))
892
+ clearStatuses();
904
893
  onDown?.(toHookApi(api));
905
894
  return;
906
895
  }
907
896
  if (preventsDefaultUnlessDenied)
908
897
  event.preventDefault();
909
898
  const { getMetadata } = api, metadata = getMetadata();
910
- metadata.pressed = downCombos[0];
899
+ metadata.keycombo = downCombos[0];
911
900
  localStatus = "recognizing";
912
901
  cleanup();
913
902
  storeKeyboardTimeMetadata({
@@ -916,6 +905,7 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
916
905
  getTimeMetadata: getMetadata,
917
906
  getShouldStore: () => downCombos.length && getDownCombos()[0] === downCombos[0],
918
907
  setRequest: (newRequest) => request = newRequest,
908
+ // @ts-expect-error
919
909
  recognize
920
910
  });
921
911
  onDown?.(toHookApi(api));
@@ -929,23 +919,23 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
929
919
  }
930
920
  };
931
921
  const keyup = (event, api) => {
932
- const { denied } = api, key = fromEventToKeyStatusKey(event);
922
+ const { denied } = api, key = fromEventToKeyStatusCode(event);
933
923
  if (localStatus === "denied") {
934
924
  denied();
935
- if (lazyCollections.includes(event.key)(unsupportedKeys$2))
936
- statuses.clear();
925
+ if (lazyCollections.includes(event.key)(unsupportedKeys))
926
+ clearStatuses();
937
927
  else
938
- statuses.delete(key);
928
+ deleteStatus(key);
939
929
  if (!predicateSomeKeyDown(statuses))
940
930
  localStatus = "recognizing";
941
931
  onUp?.(toHookApi(api));
942
932
  return;
943
933
  }
944
- statuses.delete(key);
934
+ deleteStatus(key);
945
935
  const downCombos = getDownCombos(), matches = matchPredicatesByKeycombo[downCombos[0]]?.(statuses);
946
936
  if (downCombos.length && matches) {
947
937
  const { getMetadata } = api, metadata = getMetadata();
948
- metadata.pressed = downCombos[0];
938
+ metadata.keycombo = downCombos[0];
949
939
  if (preventsDefaultUnlessDenied)
950
940
  event.preventDefault();
951
941
  localStatus = "recognizing";
@@ -958,7 +948,7 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
958
948
  };
959
949
  const visibilitychange = (event, api) => {
960
950
  if (document.visibilityState === "hidden") {
961
- statuses.clear();
951
+ clearStatuses();
962
952
  localStatus = "recognizing";
963
953
  cleanup();
964
954
  }
@@ -970,45 +960,63 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
970
960
  visibilitychange
971
961
  };
972
962
  }
973
- const unsupportedAliases$2 = ["meta", "command", "cmd"];
974
- const unsupportedKeys$2 = ["Meta"];
963
+ class Keypress extends Listenable {
964
+ constructor(keycomboOrKeycombos, options) {
965
+ super(
966
+ "recognizeable",
967
+ {
968
+ recognizeable: {
969
+ effects: createKeypress(keycomboOrKeycombos, options)
970
+ }
971
+ }
972
+ );
973
+ }
974
+ get metadata() {
975
+ return this.recognizeable.metadata;
976
+ }
977
+ }
975
978
 
976
- const defaultOptions$h = {
979
+ const defaultOptions$j = {
977
980
  minDuration: 0,
978
981
  preventsDefaultUnlessDenied: true,
979
- toKey: (alias) => fromAliasToKeyStatusKey(alias),
980
- toAliases: (event) => fromEventToAliases(event)
982
+ toCode: (alias) => fromAliasToCode(alias),
983
+ toAliases: (code) => fromCodeToAliases(code)
981
984
  };
982
985
  function createKeyrelease(keycomboOrKeycombos, options = {}) {
983
986
  const {
984
987
  minDuration,
985
988
  preventsDefaultUnlessDenied,
986
- toKey,
989
+ toLonghand,
990
+ toCode,
987
991
  toAliases,
988
992
  onDown,
989
993
  onUp,
990
994
  onVisibilitychange
991
- } = { ...defaultOptions$h, ...options }, {
995
+ } = { ...defaultOptions$j, ...options }, {
992
996
  matchPredicatesByKeycombo,
993
997
  getDownCombos,
994
998
  predicateValid,
995
999
  cleanup,
996
- statuses
1000
+ statuses,
1001
+ toStatus,
1002
+ setStatus,
1003
+ clearStatuses,
1004
+ deleteStatus
997
1005
  } = createKeyState({
998
1006
  keycomboOrKeycombos,
999
- unsupportedAliases: unsupportedAliases$1,
1000
- toKey,
1007
+ toLonghand,
1008
+ toCode,
1001
1009
  toAliases,
1002
1010
  getRequest: () => request
1003
- });
1011
+ }), fromComboToAliasesLength = createAliasesLength({ toLonghand });
1004
1012
  let request, localStatus;
1005
1013
  const keydown = (event, api) => {
1006
- const { denied, getStatus } = api, key = fromEventToKeyStatusKey(event);
1007
- if (statuses.toValue(key) === "down") {
1014
+ const { denied, getStatus } = api, key = fromEventToKeyStatusCode(event);
1015
+ if (toStatus(key) === "down") {
1008
1016
  onDown?.(toHookApi(api));
1009
1017
  return;
1010
1018
  }
1011
- statuses.set(key, "down");
1019
+ setStatus(key, "down");
1012
1020
  if (localStatus === "denied") {
1013
1021
  denied();
1014
1022
  onDown?.(toHookApi(api));
@@ -1021,8 +1029,8 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
1021
1029
  ) {
1022
1030
  denied();
1023
1031
  localStatus = getStatus();
1024
- if (lazyCollections.includes(event.key)(unsupportedKeys$1))
1025
- statuses.clear();
1032
+ if (lazyCollections.includes(event.key)(unsupportedKeys))
1033
+ clearStatuses();
1026
1034
  onDown?.(toHookApi(api));
1027
1035
  return;
1028
1036
  }
@@ -1045,21 +1053,21 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
1045
1053
  getStatus,
1046
1054
  getMetadata,
1047
1055
  denied
1048
- } = api, metadata = getMetadata(), key = fromEventToKeyStatusKey(event);
1056
+ } = api, metadata = getMetadata(), key = fromEventToKeyStatusCode(event);
1049
1057
  if (["denied", "recognized"].includes(localStatus)) {
1050
1058
  if (localStatus === "denied")
1051
1059
  denied();
1052
- if (lazyCollections.includes(event.key)(unsupportedKeys$1))
1053
- statuses.clear();
1060
+ if (lazyCollections.includes(event.key)(unsupportedKeys))
1061
+ clearStatuses();
1054
1062
  else
1055
- statuses.delete(key);
1063
+ deleteStatus(key);
1056
1064
  if (!predicateSomeKeyDown(statuses))
1057
1065
  localStatus = "recognizing";
1058
1066
  onUp?.(toHookApi(api));
1059
1067
  return;
1060
1068
  }
1061
1069
  const downCombos = getDownCombos(), matches = matchPredicatesByKeycombo[downCombos[0]]?.(statuses);
1062
- statuses.delete(key);
1070
+ deleteStatus(key);
1063
1071
  if (!downCombos.length || !matches) {
1064
1072
  onUp?.(toHookApi(api));
1065
1073
  return;
@@ -1068,7 +1076,7 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
1068
1076
  const status = getStatus();
1069
1077
  if (status === "recognized") {
1070
1078
  localStatus = status;
1071
- metadata.released = downCombos[0];
1079
+ metadata.keycombo = downCombos[0];
1072
1080
  }
1073
1081
  if (preventsDefaultUnlessDenied)
1074
1082
  event.preventDefault();
@@ -1084,7 +1092,7 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
1084
1092
  };
1085
1093
  const visibilitychange = (event, api) => {
1086
1094
  if (document.visibilityState === "hidden") {
1087
- statuses.clear();
1095
+ clearStatuses();
1088
1096
  localStatus = "recognizing";
1089
1097
  cleanup();
1090
1098
  }
@@ -1096,50 +1104,64 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
1096
1104
  visibilitychange
1097
1105
  };
1098
1106
  }
1099
- const unsupportedAliases$1 = ["meta", "command", "cmd"];
1100
- const unsupportedKeys$1 = ["Meta"];
1107
+ class Keyrelease extends Listenable {
1108
+ constructor(keycomboOrKeycombos, options) {
1109
+ super(
1110
+ "recognizeable",
1111
+ {
1112
+ recognizeable: {
1113
+ effects: createKeyrelease(keycomboOrKeycombos, options)
1114
+ }
1115
+ }
1116
+ );
1117
+ }
1118
+ get metadata() {
1119
+ return this.recognizeable.metadata;
1120
+ }
1121
+ }
1101
1122
 
1102
- const defaultOptions$g = {
1123
+ const defaultOptions$i = {
1103
1124
  minDuration: 0,
1104
1125
  maxInterval: 5e3,
1105
1126
  // VS Code default
1106
1127
  preventsDefaultUnlessDenied: true,
1107
- toKey: (alias) => fromAliasToKeyStatusKey(alias),
1108
- toAliases: (event) => fromEventToAliases(event)
1128
+ toCode: (alias) => fromAliasToCode(alias),
1129
+ toAliases: (code) => fromCodeToAliases(code)
1109
1130
  };
1110
- function createKeychord(keychord, options = {}) {
1131
+ function createKeychord(keycombos, options = {}) {
1111
1132
  const {
1112
1133
  minDuration,
1113
1134
  maxInterval,
1114
1135
  preventsDefaultUnlessDenied,
1115
- toKey,
1136
+ toLonghand,
1137
+ toCode,
1116
1138
  toAliases,
1117
1139
  onDown,
1118
1140
  onUp,
1119
1141
  onVisibilitychange
1120
- } = { ...defaultOptions$g, ...options }, narrowedKeychord = keychord.split(" "), keyStates = createMap((keycombo) => createKeyState({
1142
+ } = { ...defaultOptions$i, ...options }, narrowedKeycombos = keycombos.split(" "), keyStates = createMap((keycombo) => createKeyState({
1121
1143
  keycomboOrKeycombos: keycombo,
1122
- unsupportedAliases,
1123
- toKey,
1144
+ toLonghand,
1145
+ toCode,
1124
1146
  toAliases,
1125
1147
  getRequest: () => request
1126
- }))(narrowedKeychord), localStatuses = createMap(
1148
+ }))(narrowedKeycombos), localStatuses = createMap(
1127
1149
  () => "recognizing"
1128
- )(keyStates);
1150
+ )(keyStates), fromComboToAliasesLength = createAliasesLength({ toLonghand });
1129
1151
  let request, playedIndex = 0;
1130
1152
  const keydown = (event, api) => {
1131
- const { denied, getStatus } = api, key = fromEventToKeyStatusKey(event);
1132
- if (keyStates[playedIndex].statuses.toValue(key) === "down") {
1153
+ const { denied, getStatus } = api, key = fromEventToKeyStatusCode(event);
1154
+ if (keyStates[playedIndex].toStatus(key) === "down") {
1133
1155
  onDown?.(toHookApi(api));
1134
1156
  return;
1135
1157
  }
1136
1158
  if (localStatuses[playedIndex] === "recognized") {
1137
1159
  playedIndex++;
1138
- for (const [key2, status] of keyStates[playedIndex - 1].statuses.toEntries()) {
1139
- keyStates[playedIndex].statuses.set(key2, status);
1160
+ for (const [key2, status] of keyStates[playedIndex - 1].statuses) {
1161
+ keyStates[playedIndex].setStatus(key2, status);
1140
1162
  }
1141
1163
  }
1142
- keyStates[playedIndex].statuses.set(key, "down");
1164
+ keyStates[playedIndex].setStatus(key, "down");
1143
1165
  if (localStatuses[playedIndex] === "denied") {
1144
1166
  denied();
1145
1167
  onDown?.(toHookApi(api));
@@ -1155,8 +1177,8 @@ function createKeychord(keychord, options = {}) {
1155
1177
  denied();
1156
1178
  localStatuses[playedIndex] = getStatus();
1157
1179
  if (lazyCollections.includes(event.key)(unsupportedKeys)) {
1158
- for (const { statuses } of keyStates)
1159
- statuses.clear();
1180
+ for (const { clearStatuses } of keyStates)
1181
+ clearStatuses();
1160
1182
  }
1161
1183
  onDown?.(toHookApi(api));
1162
1184
  return;
@@ -1182,30 +1204,30 @@ function createKeychord(keychord, options = {}) {
1182
1204
  getStatus,
1183
1205
  getMetadata,
1184
1206
  denied
1185
- } = api, metadata = getMetadata(), key = fromEventToKeyStatusKey(event);
1207
+ } = api, metadata = getMetadata(), key = fromEventToKeyStatusCode(event);
1186
1208
  if (["denied", "recognized"].includes(localStatuses[playedIndex])) {
1187
1209
  if (localStatuses[playedIndex] === "denied")
1188
1210
  denied();
1189
- for (const { statuses } of keyStates) {
1211
+ for (const { clearStatuses, deleteStatus } of keyStates) {
1190
1212
  if (lazyCollections.includes(event.key)(unsupportedKeys))
1191
- statuses.clear();
1213
+ clearStatuses();
1192
1214
  else
1193
- statuses.delete(key);
1215
+ deleteStatus(key);
1194
1216
  }
1195
1217
  if (!predicateSomeKeyDown(keyStates[playedIndex].statuses)) {
1196
- if (localStatuses[playedIndex] === "denied" || playedIndex === narrowedKeychord.length - 1 && localStatuses[playedIndex] === "recognized") {
1218
+ if (localStatuses[playedIndex] === "denied" || playedIndex === narrowedKeycombos.length - 1 && localStatuses[playedIndex] === "recognized") {
1197
1219
  playedIndex = 0;
1198
1220
  for (let i = 0; i < localStatuses.length; i++)
1199
1221
  localStatuses[i] = "recognizing";
1200
- for (const { statuses } of keyStates)
1201
- statuses.clear();
1222
+ for (const { clearStatuses } of keyStates)
1223
+ clearStatuses();
1202
1224
  }
1203
1225
  }
1204
1226
  onUp?.(toHookApi(api));
1205
1227
  return;
1206
1228
  }
1207
1229
  const downCombos = keyStates[playedIndex].getDownCombos(), matches = keyStates[playedIndex].matchPredicatesByKeycombo[downCombos[0]]?.(keyStates[playedIndex].statuses);
1208
- keyStates[playedIndex].statuses.delete(key);
1230
+ keyStates[playedIndex].deleteStatus(key);
1209
1231
  if (!downCombos.length || !matches) {
1210
1232
  onUp?.(toHookApi(api));
1211
1233
  return;
@@ -1215,17 +1237,17 @@ function createKeychord(keychord, options = {}) {
1215
1237
  if (status === "recognizing" && localStatuses[playedIndex] === "recognized" || status === "recognized") {
1216
1238
  metadata.played[playedIndex] = {
1217
1239
  ...metadata.played[playedIndex],
1218
- released: downCombos[0]
1240
+ keycombo: downCombos[0]
1219
1241
  };
1220
1242
  }
1221
1243
  if (preventsDefaultUnlessDenied)
1222
1244
  event.preventDefault();
1223
- if (playedIndex === narrowedKeychord.length - 1 && !predicateSomeKeyDown(keyStates[playedIndex].statuses)) {
1245
+ if (playedIndex === narrowedKeycombos.length - 1 && !predicateSomeKeyDown(keyStates[playedIndex].statuses)) {
1224
1246
  playedIndex = 0;
1225
1247
  for (let i = 0; i < localStatuses.length; i++)
1226
1248
  localStatuses[i] = "recognizing";
1227
- for (const { statuses } of keyStates)
1228
- statuses.clear();
1249
+ for (const { clearStatuses } of keyStates)
1250
+ clearStatuses();
1229
1251
  }
1230
1252
  onUp?.(toHookApi(api));
1231
1253
  };
@@ -1235,7 +1257,7 @@ function createKeychord(keychord, options = {}) {
1235
1257
  denied();
1236
1258
  return;
1237
1259
  }
1238
- if (playedIndex === narrowedKeychord.length - 1) {
1260
+ if (playedIndex === narrowedKeycombos.length - 1) {
1239
1261
  recognized();
1240
1262
  localStatuses[playedIndex] = "recognized";
1241
1263
  return;
@@ -1244,8 +1266,8 @@ function createKeychord(keychord, options = {}) {
1244
1266
  };
1245
1267
  const visibilitychange = (event, api) => {
1246
1268
  if (document.visibilityState === "hidden") {
1247
- for (const { statuses } of keyStates)
1248
- statuses.clear();
1269
+ for (const { clearStatuses } of keyStates)
1270
+ clearStatuses();
1249
1271
  localStatuses[playedIndex] = "recognizing";
1250
1272
  keyStates[playedIndex].cleanup();
1251
1273
  playedIndex = 0;
@@ -1258,30 +1280,56 @@ function createKeychord(keychord, options = {}) {
1258
1280
  visibilitychange
1259
1281
  };
1260
1282
  }
1261
- const unsupportedAliases = ["meta", "command", "cmd"];
1262
- const unsupportedKeys = ["Meta"];
1283
+ class Keychord extends Listenable {
1284
+ constructor(keycombos, options) {
1285
+ super(
1286
+ "recognizeable",
1287
+ {
1288
+ recognizeable: {
1289
+ effects: createKeychord(keycombos, options)
1290
+ }
1291
+ }
1292
+ );
1293
+ }
1294
+ get metadata() {
1295
+ return this.recognizeable.metadata;
1296
+ }
1297
+ }
1263
1298
 
1264
1299
  function createKonami(options = {}) {
1265
1300
  return createKeychord("up up down down left right left right b a enter", options);
1266
1301
  }
1302
+ class Konami extends Listenable {
1303
+ constructor(options) {
1304
+ super(
1305
+ "recognizeable",
1306
+ {
1307
+ recognizeable: {
1308
+ effects: createKonami(options)
1309
+ }
1310
+ }
1311
+ );
1312
+ }
1313
+ get metadata() {
1314
+ return this.recognizeable.metadata;
1315
+ }
1316
+ }
1267
1317
 
1268
- const defaultOptions$f = {
1318
+ const defaultOptions$h = {
1269
1319
  minDuration: 0,
1270
- minDistance: 0,
1271
- getMousemoveTarget: (event) => event.target
1320
+ minDistance: 0
1272
1321
  };
1273
1322
  function createMousepress(options = {}) {
1274
1323
  const {
1275
1324
  minDuration,
1276
1325
  minDistance,
1277
- getMousemoveTarget,
1278
1326
  onDown,
1279
1327
  onLeave,
1280
1328
  onMove,
1281
1329
  onUp
1282
- } = { ...defaultOptions$f, ...options }, cleanup = (event) => {
1330
+ } = { ...defaultOptions$h, ...options }, cleanup = (target) => {
1283
1331
  window.cancelAnimationFrame(request);
1284
- getMousemoveTarget(event).removeEventListener("mousemove", mousemoveEffect);
1332
+ target.removeEventListener("mousemove", mousemoveEffect);
1285
1333
  };
1286
1334
  let request;
1287
1335
  let mousemoveEffect;
@@ -1296,9 +1344,11 @@ function createMousepress(options = {}) {
1296
1344
  api,
1297
1345
  () => mouseStatus === "down",
1298
1346
  (newRequest) => request = newRequest,
1347
+ // @ts-expect-error
1299
1348
  recognize
1300
1349
  );
1301
- getMousemoveTarget(event).addEventListener("mousemove", mousemoveEffect);
1350
+ const { listenInjection: { optionsByType: { mousedown: { target } } } } = api;
1351
+ target.addEventListener("mousemove", mousemoveEffect);
1302
1352
  onDown?.(toHookApi(api));
1303
1353
  };
1304
1354
  const mousemove = (event, api) => {
@@ -1315,20 +1365,20 @@ function createMousepress(options = {}) {
1315
1365
  }
1316
1366
  };
1317
1367
  const mouseleave = (event, api) => {
1318
- const { denied } = api;
1368
+ const { denied, listenInjection: { optionsByType: { mouseleave: { target } } } } = api;
1319
1369
  if (mouseStatus === "down") {
1320
1370
  denied();
1321
- cleanup(event);
1371
+ cleanup(target);
1322
1372
  mouseStatus = "leave";
1323
1373
  }
1324
1374
  onLeave?.(toHookApi(api));
1325
1375
  };
1326
1376
  const mouseup = (event, api) => {
1327
- const { denied } = api;
1377
+ const { denied, listenInjection: { optionsByType: { mouseup: { target } } } } = api;
1328
1378
  if (mouseStatus !== "down")
1329
1379
  return;
1330
1380
  denied();
1331
- cleanup(event);
1381
+ cleanup(target);
1332
1382
  mouseStatus = "up";
1333
1383
  onUp?.(toHookApi(api));
1334
1384
  };
@@ -1338,26 +1388,39 @@ function createMousepress(options = {}) {
1338
1388
  mouseup
1339
1389
  };
1340
1390
  }
1391
+ class Mousepress extends Listenable {
1392
+ constructor(options) {
1393
+ super(
1394
+ "recognizeable",
1395
+ {
1396
+ recognizeable: {
1397
+ effects: createMousepress(options)
1398
+ }
1399
+ }
1400
+ );
1401
+ }
1402
+ get metadata() {
1403
+ return this.recognizeable.metadata;
1404
+ }
1405
+ }
1341
1406
 
1342
- const defaultOptions$e = {
1407
+ const defaultOptions$g = {
1343
1408
  minDuration: 0,
1344
1409
  minDistance: 0,
1345
- minVelocity: 0,
1346
- getMousemoveTarget: (event) => event.target
1410
+ minVelocity: 0
1347
1411
  };
1348
1412
  function createMouserelease(options = {}) {
1349
1413
  const {
1350
1414
  minDuration,
1351
1415
  minDistance,
1352
1416
  minVelocity,
1353
- getMousemoveTarget,
1354
1417
  onDown,
1355
1418
  onLeave,
1356
1419
  onMove,
1357
1420
  onUp
1358
- } = { ...defaultOptions$e, ...options }, cleanup = (event) => {
1421
+ } = { ...defaultOptions$g, ...options }, cleanup = (target) => {
1359
1422
  window.cancelAnimationFrame(request);
1360
- getMousemoveTarget(event).removeEventListener("mousemove", mousemoveEffect);
1423
+ target.removeEventListener("mousemove", mousemoveEffect);
1361
1424
  };
1362
1425
  let request;
1363
1426
  let mousemoveEffect;
@@ -1373,7 +1436,8 @@ function createMouserelease(options = {}) {
1373
1436
  () => mouseStatus === "down",
1374
1437
  (newRequest) => request = newRequest
1375
1438
  );
1376
- getMousemoveTarget(event).addEventListener("mousemove", mousemoveEffect);
1439
+ const { listenInjection: { optionsByType: { mousedown: { target } } } } = api;
1440
+ target.addEventListener("mousemove", mousemoveEffect);
1377
1441
  onDown?.(toHookApi(api));
1378
1442
  };
1379
1443
  const mousemove = (event, api) => {
@@ -1381,10 +1445,10 @@ function createMouserelease(options = {}) {
1381
1445
  onMove?.(toHookApi(api));
1382
1446
  };
1383
1447
  const mouseleave = (event, api) => {
1384
- const { denied } = api;
1448
+ const { denied, listenInjection: { optionsByType: { mouseleave: { target } } } } = api;
1385
1449
  if (mouseStatus === "down") {
1386
1450
  denied();
1387
- cleanup(event);
1451
+ cleanup(target);
1388
1452
  mouseStatus = "leave";
1389
1453
  }
1390
1454
  onLeave?.(toHookApi(api));
@@ -1393,7 +1457,8 @@ function createMouserelease(options = {}) {
1393
1457
  if (mouseStatus !== "down")
1394
1458
  return;
1395
1459
  storePointerMoveMetadata(event, api);
1396
- cleanup(event);
1460
+ const { listenInjection: { optionsByType: { mouseup: { target } } } } = api;
1461
+ cleanup(target);
1397
1462
  mouseStatus = "up";
1398
1463
  recognize(event, api);
1399
1464
  onUp?.(toHookApi(api));
@@ -1412,8 +1477,23 @@ function createMouserelease(options = {}) {
1412
1477
  mouseup
1413
1478
  };
1414
1479
  }
1480
+ class Mouserelease extends Listenable {
1481
+ constructor(options) {
1482
+ super(
1483
+ "recognizeable",
1484
+ {
1485
+ recognizeable: {
1486
+ effects: createMouserelease(options)
1487
+ }
1488
+ }
1489
+ );
1490
+ }
1491
+ get metadata() {
1492
+ return this.recognizeable.metadata;
1493
+ }
1494
+ }
1415
1495
 
1416
- const defaultOptions$d = {
1496
+ const defaultOptions$f = {
1417
1497
  minDuration: 0,
1418
1498
  minDistance: 0
1419
1499
  };
@@ -1425,7 +1505,7 @@ function createTouchpress(options = {}) {
1425
1505
  onCancel,
1426
1506
  onMove,
1427
1507
  onEnd
1428
- } = { ...defaultOptions$d, ...options }, cleanup = () => {
1508
+ } = { ...defaultOptions$f, ...options }, cleanup = () => {
1429
1509
  window.cancelAnimationFrame(request);
1430
1510
  };
1431
1511
  let request;
@@ -1446,6 +1526,7 @@ function createTouchpress(options = {}) {
1446
1526
  api,
1447
1527
  () => totalTouches === 1,
1448
1528
  (newRequest) => request = newRequest,
1529
+ // @ts-expect-error
1449
1530
  recognize
1450
1531
  );
1451
1532
  onStart?.(toHookApi(api));
@@ -1485,8 +1566,23 @@ function createTouchpress(options = {}) {
1485
1566
  touchend
1486
1567
  };
1487
1568
  }
1569
+ class Touchpress extends Listenable {
1570
+ constructor(options) {
1571
+ super(
1572
+ "recognizeable",
1573
+ {
1574
+ recognizeable: {
1575
+ effects: createTouchpress(options)
1576
+ }
1577
+ }
1578
+ );
1579
+ }
1580
+ get metadata() {
1581
+ return this.recognizeable.metadata;
1582
+ }
1583
+ }
1488
1584
 
1489
- const defaultOptions$c = {
1585
+ const defaultOptions$e = {
1490
1586
  minDuration: 0,
1491
1587
  minDistance: 0,
1492
1588
  minVelocity: 0
@@ -1500,7 +1596,7 @@ function createTouchrelease(options = {}) {
1500
1596
  onCancel,
1501
1597
  onMove,
1502
1598
  onEnd
1503
- } = { ...defaultOptions$c, ...options }, cleanup = () => {
1599
+ } = { ...defaultOptions$e, ...options }, cleanup = () => {
1504
1600
  window.cancelAnimationFrame(request);
1505
1601
  };
1506
1602
  let request;
@@ -1566,1015 +1662,1340 @@ function createTouchrelease(options = {}) {
1566
1662
  touchend
1567
1663
  };
1568
1664
  }
1569
-
1570
- const defaultOptions$b = {
1571
- initial: []
1572
- };
1573
- function createKeyStatuses(options = {}) {
1574
- return createAssociativeArray({
1575
- ...defaultOptions$b,
1576
- ...options,
1577
- createPredicateKey: (query) => (key) => {
1578
- for (const prop in query) {
1579
- if (query[prop] !== key[prop]) {
1580
- return false;
1665
+ class Touchrelease extends Listenable {
1666
+ constructor(options) {
1667
+ super(
1668
+ "recognizeable",
1669
+ {
1670
+ recognizeable: {
1671
+ effects: createTouchrelease(options)
1581
1672
  }
1582
1673
  }
1583
- return true;
1584
- }
1585
- });
1674
+ );
1675
+ }
1676
+ get metadata() {
1677
+ return this.recognizeable.metadata;
1678
+ }
1586
1679
  }
1587
- function predicateDown(status) {
1588
- return status === "down";
1680
+
1681
+ function createRoot(graph) {
1682
+ const toIndegree = createIndegree(graph);
1683
+ return (node) => toIndegree(node) === 0;
1589
1684
  }
1590
- function predicateSomeKeyDown(statuses) {
1591
- return lazyCollections.includes("down")(statuses.toValues());
1685
+ function createTerminal(graph) {
1686
+ const toOutdegree = createOutdegree(graph);
1687
+ return (node) => toOutdegree(node) === 0;
1592
1688
  }
1593
-
1594
- function fromComboToAliases(combo) {
1595
- const delimiter = "+";
1596
- return lazyCollections.pipe(
1597
- lazyCollections.unique(),
1598
- lazyCollections.map((name) => name === "" ? delimiter : name.toLowerCase()),
1599
- lazyCollections.toArray()
1600
- )(combo.split(delimiter));
1689
+ function createChildren(graph) {
1690
+ return function* (node) {
1691
+ const outgoing = createOutgoing(graph)(node);
1692
+ for (const edge of outgoing)
1693
+ yield edge.to;
1694
+ };
1601
1695
  }
1602
-
1603
- function fromAliasToKeyStatusKey(alias) {
1604
- if (alias in keysByAlias) {
1605
- return { key: keysByAlias[alias] };
1606
- }
1607
- return {
1608
- code: (() => {
1609
- if (alias in codesByAlias)
1610
- return codesByAlias[alias];
1611
- if (letterRE.test(alias))
1612
- return `Key${alias.toUpperCase()}`;
1613
- if (digitRE.test(alias))
1614
- return `Digit${alias}`;
1615
- if (functionRE.test(alias))
1616
- return alias.toUpperCase();
1617
- return "unsupported";
1618
- })()
1696
+ function createIndegree(graph) {
1697
+ const toIncoming = createIncoming(graph);
1698
+ return (node) => lazyCollections.pipe(
1699
+ toIncoming,
1700
+ lazyCollections.toLength()
1701
+ )(node);
1702
+ }
1703
+ function createOutdegree(graph) {
1704
+ const toOutgoing = createOutgoing(graph);
1705
+ return (node) => lazyCollections.pipe(
1706
+ toOutgoing,
1707
+ lazyCollections.toLength()
1708
+ )(node);
1709
+ }
1710
+ function createIncoming(graph) {
1711
+ const { edges } = graph;
1712
+ return function* (node) {
1713
+ yield* lazyCollections.filter(
1714
+ ({ to }) => to === node
1715
+ )(edges);
1716
+ };
1717
+ }
1718
+ function createOutgoing(graph) {
1719
+ const { edges } = graph;
1720
+ return function* (node) {
1721
+ yield* lazyCollections.filter(
1722
+ ({ from }) => from === node
1723
+ )(edges);
1724
+ };
1725
+ }
1726
+ function createOnlyChild(graph) {
1727
+ const toTotalSiblings = createTotalSiblings(graph);
1728
+ return (node) => toTotalSiblings(node) === 0;
1729
+ }
1730
+ function createTotalSiblings(graph) {
1731
+ const toSiblings = createSiblings(graph);
1732
+ return (node) => lazyCollections.pipe(
1733
+ toSiblings,
1734
+ lazyCollections.toLength()
1735
+ )(node);
1736
+ }
1737
+ function createSiblings(graph) {
1738
+ const { edges } = graph;
1739
+ return function* (node) {
1740
+ const parents = lazyCollections.pipe(
1741
+ lazyCollections.filter(
1742
+ ({ to }) => to === node
1743
+ ),
1744
+ lazyCollections.map(
1745
+ ({ from }) => from
1746
+ )
1747
+ )(edges);
1748
+ for (const parent of parents) {
1749
+ yield* lazyCollections.pipe(
1750
+ lazyCollections.filter(
1751
+ ({ from, to }) => from === parent && to !== node
1752
+ ),
1753
+ lazyCollections.map(
1754
+ ({ to }) => to
1755
+ )
1756
+ )(edges);
1757
+ }
1619
1758
  };
1620
1759
  }
1621
- const digitRE = /^[0-9]$/;
1622
- const letterRE = /^[a-zA-Z]$/;
1623
- const functionRE = /^[fF][0-9]{1,2}$/;
1624
- const codesByAlias = {
1625
- "`": "Backquote",
1626
- "~": "Backquote",
1627
- "-": "Minus",
1628
- _: "Minus",
1629
- "=": "Equal",
1630
- "+": "Equal",
1631
- "[": "BracketLeft",
1632
- "{": "BracketLeft",
1633
- "]": "BracketRight",
1634
- "}": "BracketRight",
1635
- "\\": "Backslash",
1636
- "|": "Backslash",
1637
- ";": "Semicolon",
1638
- ":": "Semicolon",
1639
- "'": "Quote",
1640
- '"': "Quote",
1641
- ",": "Comma",
1642
- "<": "Comma",
1643
- ".": "Period",
1644
- ">": "Period",
1645
- "/": "Slash",
1646
- "?": "Slash",
1647
- "!": "Digit1",
1648
- "@": "Digit2",
1649
- "#": "Digit3",
1650
- $: "Digit4",
1651
- "%": "Digit5",
1652
- "^": "Digit6",
1653
- "&": "Digit7",
1654
- "*": "Digit8",
1655
- "(": "Digit9",
1656
- ")": "Digit0",
1657
- up: "ArrowUp",
1658
- down: "ArrowDown",
1659
- left: "ArrowLeft",
1660
- right: "ArrowRight",
1661
- enter: "Enter",
1662
- space: "Space",
1663
- tab: "Tab",
1664
- esc: "Escape",
1665
- backspace: "Backspace",
1666
- delete: "Delete",
1667
- home: "Home",
1668
- end: "End",
1669
- pagedown: "PageDown",
1670
- pageup: "PageUp",
1671
- capslock: "CapsLock",
1672
- camera: "Camera"
1673
- };
1674
- const keysByAlias = {
1675
- alt: "Alt",
1676
- opt: "Alt",
1677
- option: "Alt",
1678
- ctrl: "Control",
1679
- control: "Control",
1680
- meta: "Meta",
1681
- cmd: "Meta",
1682
- command: "Meta",
1683
- shift: "Shift"
1684
- };
1685
1760
 
1686
- const defaultOptions$a = {
1687
- toKey: (alias) => fromAliasToKeyStatusKey(alias)
1688
- };
1689
- const createPredicateKeycomboDown = (keycombo, options = {}) => {
1690
- const { toKey } = { ...defaultOptions$a, ...options }, keys = lazyCollections.pipe(
1691
- fromComboToAliases,
1692
- lazyCollections.map(toKey)
1693
- )(keycombo);
1694
- return (statuses) => {
1695
- const { toValue } = statuses;
1696
- return lazyCollections.every(lazyCollections.pipe(
1697
- toValue,
1698
- predicateDown
1699
- ))(keys);
1761
+ function createFind(node) {
1762
+ return (tree) => {
1763
+ for (const treeNode of tree) {
1764
+ if (treeNode.node === node)
1765
+ return treeNode;
1766
+ const found = createFind(node)(treeNode.children);
1767
+ if (found)
1768
+ return found;
1769
+ }
1700
1770
  };
1701
- };
1771
+ }
1702
1772
 
1703
- function fromEventToAliases(event) {
1704
- if (event.shiftKey && event.code in aliasesByShiftCode) {
1705
- return [aliasesByShiftCode[event.code]];
1706
- }
1707
- if (event.key in aliasListsByModifier) {
1708
- return aliasListsByModifier[event.key];
1709
- }
1710
- return event.code in aliasesByCode ? [aliasesByCode[event.code]] : [event.code.match(aliasCaptureRE)?.[1].toLowerCase() || "unsupported"];
1773
+ function createPath$2(directedAcyclic, config) {
1774
+ const { predicatePathable, toTraversalCandidates } = config, firstRoot = lazyCollections.pipe(
1775
+ createRoots(),
1776
+ lazyCollections.at(0)
1777
+ )(directedAcyclic);
1778
+ return (state) => {
1779
+ const path = [firstRoot], getLastPathable = () => predicatePathable(path.at(-1)), getLastStatus = () => state[path.at(-1)].status;
1780
+ while (getLastPathable() && getLastStatus() === "set") {
1781
+ const edge = lazyCollections.pipe(
1782
+ toTraversalCandidates,
1783
+ lazyCollections.find(
1784
+ ({ predicateShouldTraverse }) => predicateShouldTraverse(state)
1785
+ )
1786
+ )(path);
1787
+ path.push(edge.to);
1788
+ }
1789
+ return path;
1790
+ };
1711
1791
  }
1712
- const aliasCaptureRE = /^(?:Digit|Key)?(F[0-9]{1,2}|[0-9]|[A-Z])$/;
1713
- const aliasesByCode = {
1714
- Backquote: "`",
1715
- Minus: "-",
1716
- Equal: "=",
1717
- BracketLeft: "[",
1718
- BracketRight: "]",
1719
- Backslash: "\\",
1720
- Semicolon: ";",
1721
- Quote: "'",
1722
- Comma: ",",
1723
- Period: ".",
1724
- Slash: "/",
1725
- ArrowUp: "up",
1726
- ArrowDown: "down",
1727
- ArrowLeft: "left",
1728
- ArrowRight: "right",
1729
- Enter: "enter",
1730
- Space: "space",
1731
- Tab: "tab",
1732
- Escape: "esc",
1733
- Backspace: "backspace",
1734
- Delete: "delete",
1735
- Home: "home",
1736
- End: "end",
1737
- PageDown: "pagedown",
1738
- PageUp: "pageup",
1739
- CapsLock: "capslock",
1740
- Camera: "camera"
1741
- };
1742
- const aliasesByShiftCode = {
1743
- Backquote: "~",
1744
- Minus: "_",
1745
- Equal: "+",
1746
- BracketLeft: "{",
1747
- BracketRight: "}",
1748
- Backslash: "|",
1749
- Semicolon: ":",
1750
- Quote: '"',
1751
- Comma: "<",
1752
- Period: ">",
1753
- Slash: "?",
1754
- Digit1: "!",
1755
- Digit2: "@",
1756
- Digit3: "#",
1757
- Digit4: "$",
1758
- Digit5: "%",
1759
- Digit6: "^",
1760
- Digit7: "&",
1761
- Digit8: "*",
1762
- Digit9: "(",
1763
- Digit0: ")"
1764
- };
1765
- const aliasListsByModifier = {
1766
- Alt: ["alt", "option", "opt"],
1767
- Control: ["control", "ctrl"],
1768
- Meta: ["meta", "command", "cmd"],
1769
- Shift: ["shift"]
1770
- };
1771
1792
 
1772
- const defaultOptions$9 = {
1773
- toKey: (alias) => fromAliasToKeyStatusKey(alias),
1774
- toAliases: (event) => fromEventToAliases(event)
1793
+ function createLayers$1(options = {}) {
1794
+ const toSteps = createDepthFirstSteps$2(options.createDepthFirstSteps);
1795
+ return function* toLayers(directedAcyclic) {
1796
+ const layers = [];
1797
+ for (const { path } of toSteps(directedAcyclic)) {
1798
+ const node = path.at(-1), depth = path.length - 1;
1799
+ if (!layers[depth] && depth > 0)
1800
+ yield layers[depth - 1];
1801
+ (layers[depth] || (layers[depth] = [])).push(node);
1802
+ }
1803
+ };
1804
+ }
1805
+ function createTree$2(options = {}) {
1806
+ const toSteps = createDepthFirstSteps$2(options.createDepthFirstSteps);
1807
+ return (directedAcyclic) => {
1808
+ const firstRoot = lazyCollections.pipe(
1809
+ createRoots(),
1810
+ lazyCollections.at(0)
1811
+ )(directedAcyclic), tree = [];
1812
+ tree.push({
1813
+ node: firstRoot,
1814
+ children: []
1815
+ });
1816
+ for (const { path } of toSteps(directedAcyclic)) {
1817
+ const node = path.at(-1), parent = path.at(-2);
1818
+ if (parent) {
1819
+ const parentTreeNode = createFind(parent)(tree);
1820
+ if (parentTreeNode) {
1821
+ parentTreeNode.children.push({
1822
+ node,
1823
+ children: []
1824
+ });
1825
+ }
1826
+ }
1827
+ }
1828
+ return tree;
1829
+ };
1830
+ }
1831
+ const defaultCreateDepthFirstStepsOptions = {
1832
+ getSetStateValue: ({ totalChildrenDiscovered }) => totalChildrenDiscovered
1775
1833
  };
1776
- const createPredicateKeycomboMatch = (keycombo, options = {}) => {
1777
- const { toKey, toAliases } = { ...defaultOptions$9, ...options }, aliases = fromComboToAliases(keycombo), keys = lazyCollections.map(toKey)(aliases);
1778
- return (statuses) => {
1779
- const { toValue } = statuses;
1780
- return lazyCollections.every(lazyCollections.pipe(
1781
- toValue,
1782
- predicateDown
1783
- ))(keys) && lazyCollections.every(
1784
- ([key, value]) => value === "up" || lazyCollections.some(
1785
- (alias) => lazyCollections.includes(alias)(aliases)
1786
- )(toAliases(key))
1787
- )(statuses.toEntries());
1834
+ function createDepthFirstSteps$2(options = {}) {
1835
+ return createSteps$1(
1836
+ createConfigureDepthFirstSteps(options),
1837
+ options
1838
+ );
1839
+ }
1840
+ function createConfigureDepthFirstSteps(options) {
1841
+ const { getSetStateValue: getSetStateValueOption } = {
1842
+ ...defaultCreateDepthFirstStepsOptions,
1843
+ ...options
1844
+ };
1845
+ return function(directedAcyclic) {
1846
+ const getSetStateValue = (node) => getSetStateValueOption({
1847
+ node,
1848
+ totalChildrenDiscovered: totalChildrenDiscoveredByNode[node]
1849
+ }), stepFromEffect = (node) => totalChildrenDiscoveredByNode[node]++, predicateSteppable = (node) => !predicateTerminal(node), predicateTerminal = createTerminal(directedAcyclic), predicateExhausted = (node) => totalChildrenDiscoveredByNode[node] === toTotalSiblings(node), toTotalSiblings = createOutdegree(directedAcyclic), totalChildrenDiscoveredByNode = createReduce(
1850
+ (totalChildrenDiscoveredByNode2, node) => {
1851
+ totalChildrenDiscoveredByNode2[node] = 0;
1852
+ return totalChildrenDiscoveredByNode2;
1853
+ },
1854
+ {}
1855
+ )(directedAcyclic.nodes);
1856
+ return {
1857
+ getSetStateValue,
1858
+ stepFromEffect,
1859
+ predicateSteppable,
1860
+ predicateExhausted,
1861
+ createPath: createDepthPathConfig(directedAcyclic)
1862
+ };
1788
1863
  };
1864
+ }
1865
+ const defaultCreateStepsOptions$1 = {
1866
+ kind: "directed acyclic"
1789
1867
  };
1790
-
1791
- function createKeyState({
1792
- keycomboOrKeycombos,
1793
- unsupportedAliases,
1794
- toKey,
1795
- toAliases,
1796
- getRequest
1797
- }) {
1798
- const narrowedKeycombos = createFilter(
1799
- (keycombo) => !lazyCollections.some(
1800
- (alias) => lazyCollections.includes(alias)(unsupportedAliases)
1801
- )(fromComboToAliases(keycombo))
1802
- )(Array.isArray(keycomboOrKeycombos) ? keycomboOrKeycombos : [keycomboOrKeycombos]), createPredicateKeycomboDownOptions = { toKey }, downPredicatesByKeycombo = (() => {
1803
- const predicates = [];
1804
- for (const keycombo of narrowedKeycombos) {
1805
- predicates.push([
1806
- keycombo,
1807
- createPredicateKeycomboDown(
1808
- keycombo,
1809
- createPredicateKeycomboDownOptions
1810
- )
1811
- ]);
1868
+ function createSteps$1(configure, options = {}) {
1869
+ return function* (directedAcyclic) {
1870
+ const {
1871
+ getSetStateValue,
1872
+ stepFromEffect,
1873
+ predicateSteppable,
1874
+ predicateExhausted,
1875
+ createPath: createPathConfig
1876
+ } = configure(directedAcyclic), { kind, root } = { ...defaultCreateStepsOptions$1, ...options }, { nodes } = directedAcyclic, toPath = createPath$2(directedAcyclic, createPathConfig), roots = lazyCollections.pipe(
1877
+ createRoots({ kind }),
1878
+ lazyCollections.toArray()
1879
+ )(directedAcyclic), state = {};
1880
+ for (const node of nodes) {
1881
+ state[node] = {
1882
+ status: "unset",
1883
+ value: void 0
1884
+ };
1812
1885
  }
1813
- return predicates;
1814
- })(), createPredicateKeycomboMatchOptions = { ...createPredicateKeycomboDownOptions, toAliases }, matchPredicatesByKeycombo = (() => {
1815
- const predicates = {};
1816
- for (const keycombo of narrowedKeycombos) {
1817
- predicates[keycombo] = createPredicateKeycomboMatch(
1818
- keycombo,
1819
- createPredicateKeycomboMatchOptions
1820
- );
1886
+ let location = root || lazyCollections.at(0)(roots);
1887
+ const path = toPath(state);
1888
+ yield { path, state: JSON.parse(JSON.stringify(state)) };
1889
+ function* toStep() {
1890
+ if (predicateExhausted(location)) {
1891
+ if (lazyCollections.includes(location)(roots))
1892
+ return;
1893
+ state[location].status = "unset";
1894
+ delete state[location].value;
1895
+ const path3 = toPath(state);
1896
+ location = path3.at(-2);
1897
+ yield* toStep();
1898
+ return;
1899
+ }
1900
+ state[location].status = "set";
1901
+ state[location].value = getSetStateValue(location);
1902
+ const path2 = toPath(state);
1903
+ yield { path: path2, state: JSON.parse(JSON.stringify(state)) };
1904
+ stepFromEffect(location);
1905
+ const newLocation = path2.at(-1);
1906
+ if (predicateSteppable(newLocation))
1907
+ location = newLocation;
1908
+ yield* toStep();
1821
1909
  }
1822
- return predicates;
1823
- })(), validAliases = lazyCollections.pipe(
1824
- lazyCollections.flatMap(fromComboToAliases),
1825
- lazyCollections.unique(),
1826
- lazyCollections.toArray()
1827
- )(narrowedKeycombos), getDownCombos = () => lazyCollections.pipe(
1828
- lazyCollections.filter(([, predicate]) => predicate(statuses)),
1829
- lazyCollections.map(([keycombo]) => [keycombo, fromComboToAliases(keycombo)]),
1830
- lazyCollections.sort(([, aliasesA], [, aliasesB]) => aliasesB.length - aliasesA.length),
1831
- lazyCollections.map(([keycombo]) => keycombo),
1832
- lazyCollections.toArray()
1833
- )(downPredicatesByKeycombo), predicateValid = (event) => {
1834
- const aliases = toAliases(event);
1835
- return lazyCollections.some(
1836
- (validAlias) => lazyCollections.includes(validAlias)(aliases)
1837
- )(validAliases);
1838
- }, cleanup = () => {
1839
- window.cancelAnimationFrame(getRequest());
1840
- }, statuses = createKeyStatuses();
1841
- return {
1842
- narrowedKeycombos,
1843
- createPredicateKeycomboDownOptions,
1844
- downPredicatesByKeycombo,
1845
- createPredicateKeycomboMatchOptions,
1846
- matchPredicatesByKeycombo,
1847
- validAliases,
1848
- getDownCombos,
1849
- predicateValid,
1850
- cleanup,
1851
- statuses
1910
+ yield* toStep();
1852
1911
  };
1853
1912
  }
1854
-
1855
- function toLength() {
1856
- return function toLengthFn(data) {
1857
- return [...data].length;
1913
+ function createRoots(options = {}) {
1914
+ return function* (directedAcyclic) {
1915
+ const { nodes } = directedAcyclic, predicateRoot = createRoot(directedAcyclic);
1916
+ for (const node of nodes) {
1917
+ if (predicateRoot(node))
1918
+ yield node;
1919
+ if (options.kind === "arborescence")
1920
+ break;
1921
+ }
1858
1922
  };
1859
1923
  }
1860
1924
 
1861
- const fromComboToAliasesLength = lazyCollections.pipe(
1862
- fromComboToAliases,
1863
- toLength()
1864
- );
1925
+ function createCommonAncestors$2(directedAcyclic) {
1926
+ const toNodeDepthFirstSteps = createNodeDepthFirstSteps$2(directedAcyclic);
1927
+ return function* (a, b) {
1928
+ for (const { path: aPath } of toNodeDepthFirstSteps(a)) {
1929
+ for (const { path: bPath } of toNodeDepthFirstSteps(b)) {
1930
+ for (let aPathIndex = aPath.length - 1; aPathIndex >= 0; aPathIndex--) {
1931
+ for (let bPathIndex = bPath.length - 1; bPathIndex >= 0; bPathIndex--) {
1932
+ if (aPath[aPathIndex] === bPath[bPathIndex] && !lazyCollections.includes(aPath[aPathIndex])([a, b])) {
1933
+ yield {
1934
+ node: aPath[aPathIndex],
1935
+ distances: {
1936
+ [a]: aPath.length - aPathIndex - 1,
1937
+ [b]: bPath.length - bPathIndex - 1
1938
+ }
1939
+ };
1940
+ }
1941
+ }
1942
+ }
1943
+ }
1944
+ }
1945
+ };
1946
+ }
1947
+ function createAncestor$2(directedAcyclic) {
1948
+ const toNodeDepthFirstSteps = createNodeDepthFirstSteps$2(directedAcyclic);
1949
+ return function(descendant, ancestor) {
1950
+ return lazyCollections.pipe(
1951
+ toNodeDepthFirstSteps,
1952
+ lazyCollections.some(({ path }) => lazyCollections.includes(ancestor)(path))
1953
+ )(descendant);
1954
+ };
1955
+ }
1956
+ function createNodeDepthFirstSteps$2(directedAcyclic, options = {}) {
1957
+ const toSteps = createDepthFirstSteps$2(options.createDepthFirstSteps);
1958
+ return function* (node) {
1959
+ yield* lazyCollections.pipe(
1960
+ toSteps,
1961
+ lazyCollections.filter(({ path }) => path.at(-1) === node)
1962
+ )(directedAcyclic);
1963
+ };
1964
+ }
1865
1965
 
1866
- function fromEventToKeyStatusKey({ key, code }) {
1867
- return lazyCollections.includes(key)(modifiers) ? { key } : { code };
1966
+ const defaultCreateStepsOptions = {
1967
+ priorityBranch: false,
1968
+ kind: "directed acyclic"
1969
+ };
1970
+ function createTree$1(options = {}) {
1971
+ const withDefaults = {
1972
+ ...options,
1973
+ createDepthFirstSteps: {
1974
+ ...defaultCreateStepsOptions,
1975
+ ...options.createDepthFirstSteps
1976
+ }
1977
+ };
1978
+ return createTree$2(withDefaults);
1979
+ }
1980
+ function createCommonAncestors$1(...params) {
1981
+ return createCommonAncestors$2(...params);
1982
+ }
1983
+ function createAncestor$1(...params) {
1984
+ return createAncestor$2(...params);
1985
+ }
1986
+ function createNodeDepthFirstSteps$1(decisionTree, options = {}) {
1987
+ const withDefaults = {
1988
+ ...options,
1989
+ createDepthFirstSteps: {
1990
+ ...defaultCreateStepsOptions,
1991
+ ...options.createDepthFirstSteps
1992
+ }
1993
+ };
1994
+ return createNodeDepthFirstSteps$2(
1995
+ decisionTree,
1996
+ withDefaults
1997
+ );
1998
+ }
1999
+ function createDepthFirstSteps$1(options) {
2000
+ const { priorityBranch } = { ...defaultCreateStepsOptions, ...options }, configureDepthFirstSteps = createConfigureDepthFirstSteps({
2001
+ getSetStateValue: ({ totalChildrenDiscovered }) => totalChildrenDiscovered === 0 ? priorityBranch : !priorityBranch
2002
+ });
2003
+ return createSteps$1(configureDepthFirstSteps, options);
2004
+ }
2005
+ function createPath$1(...params) {
2006
+ return createPath$2(...params);
1868
2007
  }
1869
- const modifiers = ["Alt", "Control", "Meta", "Shift"];
1870
2008
 
1871
- function toDirection(angle, unit = "degrees") {
1872
- return Object.keys(directions).find((direction) => directions[direction][unit](angle));
2009
+ function createPath(directedAcyclicAsync, config) {
2010
+ const { predicatePathable, toTraversalCandidates } = config, firstRoot = lazyCollections.pipe(
2011
+ createRoots(),
2012
+ lazyCollections.at(0)
2013
+ )(directedAcyclicAsync);
2014
+ return async (state) => {
2015
+ const path = [firstRoot], getLastPathable = () => predicatePathable(path.at(-1)), getLastStatus = () => state[path.at(-1)].status;
2016
+ while (getLastPathable() && getLastStatus() === "set") {
2017
+ const edge = await lazyCollections.pipe(
2018
+ toTraversalCandidates,
2019
+ lazyCollections.toArray(),
2020
+ createFindAsync(
2021
+ async ({ predicateShouldTraverse }) => await predicateShouldTraverse(state)
2022
+ )
2023
+ )(path);
2024
+ path.push(edge.to);
2025
+ }
2026
+ return path;
2027
+ };
1873
2028
  }
1874
- const directions = {
1875
- up: {
1876
- degrees: (degrees) => degrees >= 67.5 && degrees <= 112.5,
1877
- radians: (radians) => radians >= 0.375 * Math.PI && radians <= 0.625 * Math.PI
1878
- },
1879
- upRight: {
1880
- degrees: (degrees) => degrees >= 22.5 && degrees < 67.5,
1881
- radians: (radians) => radians >= 0.125 * Math.PI && radians < 0.375 * Math.PI
1882
- },
1883
- right: {
1884
- degrees: (degrees) => degrees > 337.5 && degrees <= 360 || degrees < 22.5 && degrees >= 0,
1885
- radians: (radians) => radians > 1.875 * Math.PI && radians <= 2 * Math.PI || radians < 0.125 * Math.PI && radians >= 0
1886
- },
1887
- downRight: {
1888
- degrees: (degrees) => degrees > 292.5 && degrees <= 337.5,
1889
- radians: (radians) => radians > 1.625 * Math.PI && radians <= 1.875 * Math.PI
1890
- },
1891
- down: {
1892
- degrees: (degrees) => degrees >= 247.5 && degrees <= 292.5,
1893
- radians: (radians) => radians >= 1.375 * Math.PI && radians <= 1.625 * Math.PI
1894
- },
1895
- downLeft: {
1896
- degrees: (degrees) => degrees >= 202.5 && degrees < 247.5,
1897
- radians: (radians) => radians >= 1.125 * Math.PI && radians < 1.375 * Math.PI
1898
- },
1899
- left: {
1900
- degrees: (degrees) => degrees > 157.5 && degrees < 202.5,
1901
- radians: (radians) => radians > 0.875 * Math.PI && radians < 1.125 * Math.PI
1902
- },
1903
- upLeft: {
1904
- degrees: (degrees) => degrees > 112.5 && degrees <= 157.5,
1905
- radians: (radians) => radians > 0.625 * Math.PI && radians <= 0.875 * Math.PI
1906
- }
1907
- };
1908
2029
 
1909
- function toHookApi({
1910
- getSequence,
1911
- getStatus,
1912
- getMetadata
1913
- }) {
1914
- return {
1915
- sequence: getSequence(),
1916
- status: getStatus(),
1917
- metadata: getMetadata()
2030
+ function createLayers(options = {}) {
2031
+ const toSteps = createDepthFirstSteps(options.createDepthFirstSteps);
2032
+ return async function toLayers(directedAcyclicAsync) {
2033
+ const layers = [];
2034
+ for await (const { path } of toSteps(directedAcyclicAsync)) {
2035
+ const node = path.at(-1), depth = path.length - 1;
2036
+ (layers[depth] || (layers[depth] = [])).push(node);
2037
+ }
2038
+ return layers;
2039
+ };
2040
+ }
2041
+ function createTree(options = {}) {
2042
+ const toSteps = createDepthFirstSteps(options.createDepthFirstSteps);
2043
+ return async function toTree(directedAcyclicAsync) {
2044
+ const firstRoot = lazyCollections.pipe(
2045
+ createRoots(),
2046
+ lazyCollections.at(0)
2047
+ )(directedAcyclicAsync), tree = [];
2048
+ tree.push({
2049
+ node: firstRoot,
2050
+ children: []
2051
+ });
2052
+ for await (const { path } of toSteps(directedAcyclicAsync)) {
2053
+ const node = path.at(-1), parent = path.at(-2);
2054
+ if (parent) {
2055
+ const parentTreeNode = createFind(parent)(tree);
2056
+ if (parentTreeNode) {
2057
+ parentTreeNode.children.push({
2058
+ node,
2059
+ children: []
2060
+ });
2061
+ }
2062
+ }
2063
+ }
2064
+ return tree;
2065
+ };
2066
+ }
2067
+ function createDepthFirstSteps(options = {}) {
2068
+ return createSteps(
2069
+ createConfigureDepthFirstSteps(options),
2070
+ options
2071
+ );
2072
+ }
2073
+ function createSteps(configure, options = {}) {
2074
+ return async function* (directedAcyclicAsync) {
2075
+ const {
2076
+ getSetStateValue,
2077
+ stepFromEffect,
2078
+ predicateSteppable,
2079
+ predicateExhausted,
2080
+ createPath: createPathConfig
2081
+ } = configure(directedAcyclicAsync), { kind, root } = { ...defaultCreateStepsOptions$1, ...options }, { nodes } = directedAcyclicAsync, toPath = createPath(directedAcyclicAsync, createPathConfig), roots = lazyCollections.pipe(
2082
+ createRoots({ kind }),
2083
+ lazyCollections.toArray()
2084
+ )(directedAcyclicAsync), state = {};
2085
+ for (const node of nodes) {
2086
+ state[node] = {
2087
+ status: "unset",
2088
+ value: void 0
2089
+ };
2090
+ }
2091
+ let location = root || lazyCollections.at(0)(roots);
2092
+ const path = await toPath(state);
2093
+ yield { path, state: JSON.parse(JSON.stringify(state)) };
2094
+ async function* toStep() {
2095
+ if (predicateExhausted(location)) {
2096
+ if (lazyCollections.includes(location)(roots))
2097
+ return;
2098
+ state[location].status = "unset";
2099
+ delete state[location].value;
2100
+ const path3 = await toPath(state);
2101
+ location = path3.at(-2);
2102
+ yield* await toStep();
2103
+ return;
2104
+ }
2105
+ state[location].status = "set";
2106
+ state[location].value = getSetStateValue(location);
2107
+ const path2 = await toPath(state);
2108
+ yield { path: path2, state: JSON.parse(JSON.stringify(state)) };
2109
+ stepFromEffect(location);
2110
+ const newLocation = path2.at(-1);
2111
+ if (predicateSteppable(newLocation))
2112
+ location = newLocation;
2113
+ yield* await toStep();
2114
+ }
2115
+ yield* await toStep();
1918
2116
  };
1919
2117
  }
1920
2118
 
1921
- function toMousePoint(event) {
1922
- return {
1923
- x: event.clientX,
1924
- y: event.clientY
2119
+ function createCommonAncestors(directedAcyclicAsync) {
2120
+ const toNodeDepthFirstSteps = createNodeDepthFirstSteps(directedAcyclicAsync);
2121
+ return async function* (a, b) {
2122
+ for await (const { path: aPath } of toNodeDepthFirstSteps(a)) {
2123
+ for await (const { path: bPath } of toNodeDepthFirstSteps(b)) {
2124
+ for (let aPathIndex = aPath.length - 1; aPathIndex >= 0; aPathIndex--) {
2125
+ for (let bPathIndex = bPath.length - 1; bPathIndex >= 0; bPathIndex--) {
2126
+ if (aPath[aPathIndex] === bPath[bPathIndex] && !lazyCollections.includes(aPath[aPathIndex])([a, b])) {
2127
+ yield {
2128
+ node: aPath[aPathIndex],
2129
+ distances: {
2130
+ [a]: aPath.length - aPathIndex - 1,
2131
+ [b]: bPath.length - bPathIndex - 1
2132
+ }
2133
+ };
2134
+ }
2135
+ }
2136
+ }
2137
+ }
2138
+ }
1925
2139
  };
1926
2140
  }
1927
- function toTouchMovePoint(event) {
1928
- return {
1929
- x: event.touches.item(0).clientX,
1930
- y: event.touches.item(0).clientY
2141
+ function createAncestor(directedAcyclicAsync) {
2142
+ const toNodeDepthFirstSteps = createNodeDepthFirstSteps(directedAcyclicAsync);
2143
+ return async function(descendant, ancestor) {
2144
+ return await lazyCollections.pipe(
2145
+ toNodeDepthFirstSteps,
2146
+ lazyCollections.some(({ path }) => lazyCollections.includes(ancestor)(path))
2147
+ )(descendant);
1931
2148
  };
1932
2149
  }
1933
- function toTouchEndPoint(event) {
1934
- return {
1935
- x: event.changedTouches.item(0).clientX,
1936
- y: event.changedTouches.item(0).clientY
2150
+ function createNodeDepthFirstSteps(directedAcyclicAsync, options = {}) {
2151
+ const toSteps = createDepthFirstSteps(options.createDepthFirstSteps);
2152
+ return async function* (node) {
2153
+ yield* await lazyCollections.pipe(
2154
+ toSteps,
2155
+ lazyCollections.filter(({ path }) => path.at(-1) === node)
2156
+ )(directedAcyclicAsync);
1937
2157
  };
1938
2158
  }
1939
2159
 
1940
- function toPolarCoordinates({ xA, xB, yA, yB }) {
1941
- const distance = Math.hypot(xB - xA, yB - yA), angle = Math.atan2(yA - yB, xB - xA), radians = angle >= 0 ? angle : 2 * Math.PI + angle, degrees = radians * 180 / Math.PI;
1942
- return {
1943
- distance,
1944
- angle: { radians, degrees }
2160
+ const defaultOptions$d = {
2161
+ predicatesElement: false,
2162
+ // Adapted from React Aria https://github.com/adobe/react-spectrum/blob/b6786da906973130a1746b2bee63215bba013ca4/packages/%40react-aria/focus/src/FocusScope.tsx#L256
2163
+ tabbableSelector: lazyCollections.join(':not([hidden]):not([tabindex="-1"]),')([
2164
+ "input:not([disabled]):not([type=hidden])",
2165
+ "select:not([disabled])",
2166
+ "textarea:not([disabled])",
2167
+ "button:not([disabled])",
2168
+ "a[href]",
2169
+ "area[href]",
2170
+ "summary",
2171
+ "iframe",
2172
+ "object",
2173
+ "embed",
2174
+ "audio[controls]",
2175
+ "video[controls]",
2176
+ "[contenteditable]",
2177
+ "[tabindex]:not([disabled])"
2178
+ ])
2179
+ };
2180
+ function createFocusable(order, options = {}) {
2181
+ const { predicatesElement, tabbableSelector } = { ...defaultOptions$d, ...options }, predicateFocusable = (element) => element.matches(tabbableSelector);
2182
+ return (element) => {
2183
+ if (predicatesElement && predicateFocusable(element))
2184
+ return element;
2185
+ switch (order) {
2186
+ case "first":
2187
+ for (let i = 0; i < element.children.length; i++) {
2188
+ const focusable = createFocusable(order, { predicatesElement: true })(element.children[i]);
2189
+ if (focusable)
2190
+ return focusable;
2191
+ }
2192
+ break;
2193
+ case "last":
2194
+ for (let i = element.children.length - 1; i > -1; i--) {
2195
+ const focusable = createFocusable(order, { predicatesElement: true })(element.children[i]);
2196
+ if (focusable)
2197
+ return focusable;
2198
+ }
2199
+ break;
2200
+ }
1945
2201
  };
1946
2202
  }
2203
+ function createComputedStyle(pseudoElement) {
2204
+ return (element) => getComputedStyle(element, pseudoElement);
2205
+ }
1947
2206
 
1948
- const initialMetadata$3 = {
1949
- times: {
1950
- start: 0,
1951
- end: 0
1952
- },
1953
- duration: 0
2207
+ const defaultOptions$c = {
2208
+ toCode: (alias) => fromAliasToCode(alias),
2209
+ toAliases: (descriptor) => fromKeyboardEventDescriptorToAliases(descriptor)
1954
2210
  };
1955
- function storeKeyboardTimeMetadata({
1956
- event,
1957
- api,
1958
- getTimeMetadata,
1959
- getShouldStore,
1960
- setRequest,
1961
- recognize
1962
- }) {
1963
- if (!getShouldStore())
1964
- return;
1965
- const { getStatus, onRecognized } = api, timeMetadata = getTimeMetadata();
1966
- if (!timeMetadata.times)
1967
- timeMetadata.times = createClone()(initialMetadata$3.times);
1968
- timeMetadata.times.start = Math.round(event.timeStamp);
1969
- timeMetadata.times.end = Math.round(event.timeStamp);
1970
- const storeDuration = () => {
1971
- const request = requestAnimationFrame((timestamp) => {
1972
- if (!getShouldStore())
1973
- return;
1974
- timeMetadata.times.end = Math.round(timestamp);
1975
- timeMetadata.duration = Math.max(0, timeMetadata.times.end - timeMetadata.times.start);
1976
- if (recognize) {
1977
- recognize(event, api);
1978
- if (getStatus() === "recognized")
1979
- onRecognized(event);
2211
+ const createKeycomboMatch$1 = (keycombo, options = {}) => {
2212
+ const { toLonghand, toCode, toAliases: fromDescriptorToAliases } = { ...defaultOptions$c, ...options }, fromComboToAliases = createAliases({ toLonghand }), aliases = fromComboToAliases(keycombo), codes = createMap(toCode)(aliases), implicitModifierAliases = (() => {
2213
+ const implicitModifierAliases2 = [];
2214
+ for (const code of codes) {
2215
+ const implicitModifier = lazyCollections.find(
2216
+ (modifier) => code.includes(modifier)
2217
+ )(modifiers);
2218
+ if (implicitModifier)
2219
+ implicitModifierAliases2.push(implicitModifier.toLowerCase());
2220
+ }
2221
+ return implicitModifierAliases2;
2222
+ })();
2223
+ return (event) => {
2224
+ const statuses = [];
2225
+ createSet(fromEventToKeyStatusCode(event), "down")(statuses);
2226
+ for (const modifier of modifiers) {
2227
+ if (event[`${modifier.toLowerCase()}Key`])
2228
+ createSet(modifier, "down")(statuses);
2229
+ }
2230
+ const events = createMap(
2231
+ ([code]) => {
2232
+ const e = { code };
2233
+ for (const modifier of modifiers) {
2234
+ e[`${modifier.toLowerCase()}Key`] = event[`${modifier.toLowerCase()}Key`];
2235
+ }
2236
+ return e;
1980
2237
  }
1981
- storeDuration();
1982
- });
1983
- setRequest(request);
2238
+ )(statuses);
2239
+ return lazyCollections.every(
2240
+ (code) => createValue(
2241
+ code,
2242
+ { predicateKey: createCode(code) }
2243
+ )(statuses) === "down"
2244
+ )(codes) && lazyCollections.every(
2245
+ (e) => lazyCollections.pipe(
2246
+ fromDescriptorToAliases,
2247
+ lazyCollections.map(fromComboToAliases),
2248
+ lazyCollections.some(
2249
+ (longhandAliases) => lazyCollections.every(
2250
+ (longhandAlias) => lazyCollections.includes(longhandAlias)(aliases) || lazyCollections.includes(longhandAlias)(implicitModifierAliases)
2251
+ )(longhandAliases)
2252
+ )
2253
+ )(e)
2254
+ )(events);
1984
2255
  };
1985
- storeDuration();
1986
- }
1987
-
1988
- const initialMetadata$2 = {
1989
- points: {
1990
- start: { x: 0, y: 0 },
1991
- end: { x: 0, y: 0 }
1992
- }
1993
2256
  };
1994
- function storePointerStartMetadata(event, api) {
1995
- const { getMetadata } = api, metadata = getMetadata();
1996
- const point = event instanceof MouseEvent ? toMousePoint(event) : toTouchMovePoint(event);
1997
- if (!metadata.points)
1998
- metadata.points = createClone()(initialMetadata$2.points);
1999
- metadata.points.start = point;
2000
- metadata.points.end = point;
2257
+
2258
+ function createClamp(min, max) {
2259
+ return (number) => {
2260
+ const maxed = Math.max(number, min);
2261
+ return Math.min(maxed, max);
2262
+ };
2263
+ }
2264
+ function createDetermine(potentialities) {
2265
+ const predicates = createMap(
2266
+ ({ outcome, probability }, index) => {
2267
+ const lowerBound = index === 0 ? 0 : lazyCollections.pipe(
2268
+ lazyCollections.slice(0, index - 1),
2269
+ lazyCollections.reduce(
2270
+ (lowerBound2, { probability: probability2 }) => lowerBound2 + probability2,
2271
+ 0
2272
+ )
2273
+ )(potentialities), upperBound = lowerBound + probability;
2274
+ return {
2275
+ outcome,
2276
+ predicate: (determinant) => determinant >= lowerBound && determinant < upperBound || determinant < 0 && index === 0 || index === predicates.length - 1
2277
+ };
2278
+ }
2279
+ )(potentialities);
2280
+ return (determinant) => lazyCollections.find(
2281
+ ({ predicate }) => predicate(determinant)
2282
+ )(predicates).outcome;
2283
+ }
2284
+ function createGreater(threshold) {
2285
+ return (number) => number > threshold;
2286
+ }
2287
+ function createGreaterOrEqual(threshold) {
2288
+ return (number) => number >= threshold;
2289
+ }
2290
+ function createLessOrEqual(threshold) {
2291
+ return (number) => number <= threshold;
2292
+ }
2293
+ function createLess(threshold) {
2294
+ return (number) => number < threshold;
2001
2295
  }
2002
2296
 
2003
- const initialMetadata$1 = {
2004
- distance: {
2005
- straight: {
2006
- fromStart: 0,
2007
- fromPrevious: 0
2008
- },
2009
- horizontal: {
2010
- fromStart: 0,
2011
- fromPrevious: 0
2012
- },
2013
- vertical: {
2014
- fromStart: 0,
2015
- fromPrevious: 0
2297
+ function createValue$1(key) {
2298
+ return (object) => object[key];
2299
+ }
2300
+ function createHas(key) {
2301
+ return (object) => key in object;
2302
+ }
2303
+ function createKeys() {
2304
+ return (object) => {
2305
+ const keys = [];
2306
+ for (const key in object) {
2307
+ keys.push(key);
2016
2308
  }
2017
- },
2018
- angle: {
2019
- fromPrevious: { radians: 0, degrees: 0 },
2020
- fromStart: { radians: 0, degrees: 0 }
2021
- },
2022
- direction: {
2023
- fromPrevious: "up",
2024
- fromStart: "up"
2025
- }
2026
- };
2027
- function storePointerMoveMetadata(event, api) {
2028
- const { getMetadata } = api, metadata = getMetadata();
2029
- if (!metadata.distance) {
2030
- metadata.distance = createClone()(initialMetadata$1.distance);
2031
- metadata.angle = createClone()(initialMetadata$1.angle);
2032
- metadata.direction = createClone()(initialMetadata$1.direction);
2033
- }
2034
- const { x: previousX, y: previousY } = metadata.points.end, { x: startX, y: startY } = metadata.points.start, { x: newX, y: newY } = (() => {
2035
- if (event instanceof MouseEvent) {
2036
- return toMousePoint(event);
2309
+ return keys;
2310
+ };
2311
+ }
2312
+ function createEntries() {
2313
+ return (object) => {
2314
+ const entries = [];
2315
+ for (const key in object) {
2316
+ entries.push([key, object[key]]);
2037
2317
  }
2038
- if (event instanceof TouchEvent) {
2039
- if (event.type === "touchmove") {
2040
- return toTouchMovePoint(event);
2318
+ return entries;
2319
+ };
2320
+ }
2321
+ function createEvery(predicate) {
2322
+ return (object) => {
2323
+ for (const key in object) {
2324
+ if (!predicate(key, object[key])) {
2325
+ return false;
2041
2326
  }
2042
- return toTouchEndPoint(event);
2043
2327
  }
2044
- })(), { distance: distanceFromPrevious, angle: angleFromPrevious } = toPolarCoordinates({
2045
- xA: previousX,
2046
- xB: newX,
2047
- yA: previousY,
2048
- yB: newY
2049
- }), { distance: distanceFromStart, angle: angleFromStart } = toPolarCoordinates({
2050
- xA: startX,
2051
- xB: newX,
2052
- yA: startY,
2053
- yB: newY
2054
- });
2055
- metadata.distance.straight.fromPrevious = distanceFromPrevious;
2056
- metadata.distance.horizontal.fromPrevious = newX - previousX;
2057
- metadata.distance.vertical.fromPrevious = newY - previousY;
2058
- metadata.angle.fromPrevious = angleFromPrevious;
2059
- metadata.direction.fromPrevious = toDirection(angleFromPrevious.degrees);
2060
- metadata.distance.straight.fromStart = distanceFromStart;
2061
- metadata.distance.horizontal.fromStart = newX - startX;
2062
- metadata.distance.vertical.fromStart = newY - startY;
2063
- metadata.angle.fromStart = angleFromStart;
2064
- metadata.direction.fromStart = toDirection(angleFromStart.degrees);
2065
- metadata.points.end = { x: newX, y: newY };
2328
+ return true;
2329
+ };
2330
+ }
2331
+ function createSome(predicate) {
2332
+ return (object) => {
2333
+ for (const key in object) {
2334
+ if (predicate(key, object[key]))
2335
+ return true;
2336
+ }
2337
+ return false;
2338
+ };
2339
+ }
2340
+ function createDeepMerge(override) {
2341
+ return (object) => {
2342
+ const merged = createClone()(object);
2343
+ return merge.merge(merged, override || {});
2344
+ };
2066
2345
  }
2067
2346
 
2068
- const initialMetadata = {
2069
- times: {
2070
- start: 0,
2071
- end: 0
2072
- },
2073
- duration: 0,
2074
- velocity: 0
2347
+ let totalGraphNodes = -1;
2348
+ const defaultOptions$b = {
2349
+ toId: () => `${totalGraphNodes++}`,
2350
+ toChildren: (node) => node.children
2075
2351
  };
2076
- function storePointerTimeMetadata(event, api, getShouldStore, setRequest, recognize) {
2077
- const { getSequence, getMetadata, getStatus, onRecognized } = api, metadata = getMetadata();
2078
- if (!metadata.times) {
2079
- metadata.times = createClone()(initialMetadata.times);
2080
- }
2081
- metadata.times.start = Math.round(event.timeStamp);
2082
- metadata.times.end = Math.round(event.timeStamp);
2083
- let previousTime = metadata.times.start;
2084
- const storeDuration = () => {
2085
- const request = requestAnimationFrame((timestamp) => {
2086
- if (getShouldStore()) {
2087
- previousTime = metadata.times.end;
2088
- metadata.times.end = Math.round(timestamp);
2089
- metadata.duration = Math.max(0, metadata.times.end - metadata.times.start);
2090
- const durationFromPrevious = Math.max(0, metadata.times.end - previousTime);
2091
- metadata.velocity = metadata.distance.straight.fromPrevious / durationFromPrevious;
2092
- const event2 = getSequence().at(-1);
2093
- recognize?.(event2, api);
2094
- if (getStatus() === "recognized")
2095
- onRecognized(event2);
2096
- storeDuration();
2352
+ function createGraph(options = {}) {
2353
+ const { toId, toChildren } = { ...defaultOptions$b, ...options };
2354
+ return function* (tree) {
2355
+ const root = tree[0], rootId = toId(root);
2356
+ function* toPair(node, id) {
2357
+ const children = toChildren(node) || [];
2358
+ for (const child of children) {
2359
+ const childId = toId(child);
2360
+ yield {
2361
+ node: childId,
2362
+ edge: { from: id, to: childId }
2363
+ };
2364
+ yield* toPair(child, childId);
2097
2365
  }
2098
- });
2099
- setRequest(request);
2366
+ }
2367
+ yield { node: rootId };
2368
+ yield* toPair(root, rootId);
2100
2369
  };
2101
- storeDuration();
2102
2370
  }
2103
2371
 
2104
- function defineGraph(nodes, edges) {
2105
- return { nodes, edges };
2372
+ function createSet$2(key, value, options = {}) {
2373
+ const { predicateKey = createEqual(key) } = options;
2374
+ return (associativeArray) => {
2375
+ const index = lazyCollections.findIndex(
2376
+ ([candidate]) => predicateKey(candidate)
2377
+ )(associativeArray);
2378
+ if (index === -1) {
2379
+ associativeArray.push([key, value]);
2380
+ return;
2381
+ }
2382
+ associativeArray[index][1] = value;
2383
+ return associativeArray;
2384
+ };
2106
2385
  }
2107
- function defineGraphNodes(nodes) {
2108
- return nodes;
2386
+ function createClear$2() {
2387
+ return (associativeArray) => {
2388
+ associativeArray.length = 0;
2389
+ return associativeArray;
2390
+ };
2109
2391
  }
2110
- function defineGraphEdges(edges) {
2111
- return edges;
2392
+ function createDelete$2(key, options = {}) {
2393
+ const { predicateKey = createEqual(key) } = options;
2394
+ return (associativeArray) => {
2395
+ const index = lazyCollections.findIndex(
2396
+ ([candidate]) => predicateKey(candidate)
2397
+ )(associativeArray);
2398
+ if (index === -1)
2399
+ return associativeArray;
2400
+ associativeArray.splice(index, 1);
2401
+ return associativeArray;
2402
+ };
2112
2403
  }
2113
- function defineGraphNode(node) {
2114
- return node;
2404
+
2405
+ function createSet$1(key, value) {
2406
+ return (object) => {
2407
+ object[key] = value;
2408
+ return object;
2409
+ };
2115
2410
  }
2116
- function defineGraphEdge(from, to, predicateTraversable) {
2117
- return { from, to, predicateTraversable };
2411
+ function createDelete$1(key) {
2412
+ return (object) => {
2413
+ delete object[key];
2414
+ return object;
2415
+ };
2118
2416
  }
2119
- function defineAsyncGraph(nodes, edges) {
2120
- return { nodes, edges };
2417
+ function createClear$1() {
2418
+ return (object) => {
2419
+ for (const key in object) {
2420
+ delete object[key];
2421
+ }
2422
+ return object;
2423
+ };
2121
2424
  }
2122
- function defineAsyncGraphEdges(edges) {
2123
- return edges;
2425
+
2426
+ function fromEventToKeyStatusCode({ code }) {
2427
+ const modifier = lazyCollections.find(
2428
+ (modifier2) => code.includes(modifier2)
2429
+ )(modifiers);
2430
+ return modifier || code;
2431
+ }
2432
+ const modifiers = ["Alt", "Control", "Meta", "Shift"];
2433
+
2434
+ const createValue = createValue$2;
2435
+ function createSet(code, value) {
2436
+ return createSet$2(code, value);
2437
+ }
2438
+ const createClear = createClear$2;
2439
+ function createDelete(code) {
2440
+ return createDelete$2(code);
2441
+ }
2442
+ function createCode(query) {
2443
+ return function(candidate) {
2444
+ return query === candidate || lazyCollections.includes(query)(modifiers) && candidate.includes(query) || lazyCollections.includes(candidate)(modifiers) && query.includes(candidate);
2445
+ };
2124
2446
  }
2125
- function defineAsyncGraphEdge(from, to, predicateTraversable) {
2126
- return { from, to, predicateTraversable };
2447
+ const createValues = createValues$1;
2448
+ function predicateSomeKeyDown(statuses) {
2449
+ return lazyCollections.includes("down")(createValues()(statuses));
2450
+ }
2451
+
2452
+ const defaultOptions$a = {
2453
+ toCode: (alias) => fromAliasToCode(alias)
2454
+ };
2455
+ const createKeycomboDown = (keycombo, options = {}) => {
2456
+ const { toLonghand, toCode } = { ...defaultOptions$a, ...options }, codes = lazyCollections.pipe(
2457
+ createAliases({ toLonghand }),
2458
+ lazyCollections.map(toCode)
2459
+ )(keycombo);
2460
+ return (statuses) => lazyCollections.every(
2461
+ (code) => createValue(
2462
+ code,
2463
+ { predicateKey: createCode(code) }
2464
+ )(statuses) === "down"
2465
+ )(codes);
2466
+ };
2467
+
2468
+ function fromKeyboardEventDescriptorToAliases(event) {
2469
+ if (event.shiftKey && event.code in aliasesByShiftCode)
2470
+ return [aliasesByShiftCode[event.code]];
2471
+ const withoutModifierSide = toWithoutModifierSide(event.code);
2472
+ if (withoutModifierSide in aliasListsByModifier)
2473
+ return aliasListsByModifier[withoutModifierSide];
2474
+ return event.code in aliasesByCode ? [aliasesByCode[event.code]] : [event.code.match(aliasCaptureRE)?.[1].toLowerCase() || "unsupported"];
2127
2475
  }
2476
+ const toWithoutModifierSide = createClip(/(?:Left|Right)$/);
2477
+ const aliasCaptureRE = /^(?:Digit|Key)?(F[0-9]{1,2}|[0-9]|[A-Z])$/;
2478
+ const aliasesByCode = {
2479
+ Backquote: "`",
2480
+ Minus: "-",
2481
+ Equal: "=",
2482
+ BracketLeft: "[",
2483
+ BracketRight: "]",
2484
+ Backslash: "\\",
2485
+ Semicolon: ";",
2486
+ Quote: "'",
2487
+ Comma: ",",
2488
+ Period: ".",
2489
+ Slash: "/",
2490
+ ArrowUp: "up",
2491
+ ArrowDown: "down",
2492
+ ArrowLeft: "left",
2493
+ ArrowRight: "right",
2494
+ Enter: "enter",
2495
+ Space: "space",
2496
+ Tab: "tab",
2497
+ Escape: "esc",
2498
+ Backspace: "backspace",
2499
+ Delete: "delete",
2500
+ Home: "home",
2501
+ End: "end",
2502
+ PageDown: "pagedown",
2503
+ PageUp: "pageup",
2504
+ CapsLock: "capslock",
2505
+ Camera: "camera"
2506
+ };
2507
+ const aliasesByShiftCode = {
2508
+ Backquote: "~",
2509
+ Minus: "_",
2510
+ Equal: "+",
2511
+ BracketLeft: "{",
2512
+ BracketRight: "}",
2513
+ Backslash: "|",
2514
+ Semicolon: ":",
2515
+ Quote: '"',
2516
+ Comma: "<",
2517
+ Period: ">",
2518
+ Slash: "?",
2519
+ Digit1: "!",
2520
+ Digit2: "@",
2521
+ Digit3: "#",
2522
+ Digit4: "$",
2523
+ Digit5: "%",
2524
+ Digit6: "^",
2525
+ Digit7: "&",
2526
+ Digit8: "*",
2527
+ Digit9: "(",
2528
+ Digit0: ")"
2529
+ };
2530
+ const aliasListsByModifier = {
2531
+ Alt: ["alt", "option", "opt"],
2532
+ Control: ["control", "ctrl"],
2533
+ Meta: ["meta", "command", "cmd"],
2534
+ Shift: ["shift"]
2535
+ };
2128
2536
 
2129
- function defineAssociativeArrayEntries(entries) {
2130
- return entries;
2537
+ function fromCodeToAliases(code) {
2538
+ return fromKeyboardEventDescriptorToAliases({ code });
2131
2539
  }
2132
2540
 
2133
- function createExceptAndOnlyEffect(type, effect, options) {
2134
- const { except = [], only = [] } = options;
2135
- if (type === "keydown" || type === "keyup") {
2136
- return (event) => {
2137
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
2138
- if (matchesOnly) {
2139
- effect(event);
2140
- return;
2141
- }
2142
- if (only.length === 0 && !matchesExcept) {
2143
- effect(event);
2144
- return;
2145
- }
2146
- };
2147
- }
2148
- if (type === "click" || type === "dblclick" || type === "contextmenu" || type.startsWith("mouse")) {
2149
- return (event) => {
2150
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
2151
- if (matchesOnly) {
2152
- effect(event);
2153
- return;
2154
- }
2155
- if (only.length === 0 && !matchesExcept) {
2156
- effect(event);
2157
- return;
2158
- }
2159
- };
2160
- }
2161
- if (type.startsWith("pointer")) {
2162
- return (event) => {
2163
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
2164
- if (matchesOnly) {
2165
- effect(event);
2166
- return;
2167
- }
2168
- if (only.length === 0 && !matchesExcept) {
2169
- effect(event);
2170
- return;
2171
- }
2172
- };
2173
- }
2174
- return (event) => {
2175
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
2176
- if (matchesOnly) {
2177
- effect(event, {});
2178
- return;
2541
+ const defaultOptions$9 = {
2542
+ toCode: (alias) => fromAliasToCode(alias),
2543
+ toAliases: (code) => fromCodeToAliases(code)
2544
+ };
2545
+ const createKeycomboMatch = (keycombo, options = {}) => {
2546
+ const { toLonghand, toCode, toAliases } = { ...defaultOptions$9, ...options }, aliases = createAliases({ toLonghand })(keycombo), codes = lazyCollections.map(toCode)(aliases);
2547
+ return (statuses) => lazyCollections.every(
2548
+ (code) => createValue(
2549
+ code,
2550
+ { predicateKey: createCode(code) }
2551
+ )(statuses) === "down"
2552
+ )(codes) && lazyCollections.every(
2553
+ ([code, value]) => value === "up" || lazyCollections.pipe(
2554
+ toAliases,
2555
+ lazyCollections.some((alias) => lazyCollections.includes(alias)(aliases))
2556
+ )(code)
2557
+ )(statuses);
2558
+ };
2559
+
2560
+ function createKeyState({
2561
+ keycomboOrKeycombos,
2562
+ toLonghand,
2563
+ toCode,
2564
+ toAliases,
2565
+ getRequest
2566
+ }) {
2567
+ const fromComboToAliases = createAliases({ toLonghand }), narrowedKeycombos = createFilter(
2568
+ (keycombo) => !lazyCollections.some(
2569
+ (alias) => lazyCollections.includes(alias)(unsupportedAliases)
2570
+ )(fromComboToAliases(keycombo))
2571
+ )(Array.isArray(keycomboOrKeycombos) ? keycomboOrKeycombos : [keycomboOrKeycombos]), createKeycomboDownOptions = { toLonghand, toCode }, downPredicatesByKeycombo = (() => {
2572
+ const predicates = [];
2573
+ for (const keycombo of narrowedKeycombos) {
2574
+ predicates.push([
2575
+ keycombo,
2576
+ createKeycomboDown(
2577
+ keycombo,
2578
+ createKeycomboDownOptions
2579
+ )
2580
+ ]);
2179
2581
  }
2180
- if (only.length === 0 && !matchesExcept) {
2181
- effect(event, {});
2182
- return;
2582
+ return predicates;
2583
+ })(), createKeycomboMatchOptions = { ...createKeycomboDownOptions, toAliases }, matchPredicatesByKeycombo = (() => {
2584
+ const predicates = {};
2585
+ for (const keycombo of narrowedKeycombos) {
2586
+ predicates[keycombo] = createKeycomboMatch(
2587
+ keycombo,
2588
+ createKeycomboMatchOptions
2589
+ );
2183
2590
  }
2591
+ return predicates;
2592
+ })(), validAliases = lazyCollections.pipe(
2593
+ lazyCollections.flatMap(fromComboToAliases),
2594
+ lazyCollections.unique(),
2595
+ lazyCollections.toArray()
2596
+ )(narrowedKeycombos), getDownCombos = () => lazyCollections.pipe(
2597
+ lazyCollections.filter(([, predicate]) => predicate(statuses)),
2598
+ lazyCollections.map(([keycombo]) => [keycombo, fromComboToAliases(keycombo)]),
2599
+ lazyCollections.sort(([, aliasesA], [, aliasesB]) => aliasesB.length - aliasesA.length),
2600
+ lazyCollections.map(([keycombo]) => keycombo),
2601
+ lazyCollections.toArray()
2602
+ )(downPredicatesByKeycombo), predicateValid = (event) => {
2603
+ const aliases = toAliases(event.code);
2604
+ return lazyCollections.some(
2605
+ (validAlias) => lazyCollections.includes(validAlias)(aliases)
2606
+ )(validAliases);
2607
+ }, cleanup = () => {
2608
+ window.cancelAnimationFrame(getRequest());
2609
+ }, statuses = [], toStatus = (...params) => createValue(...params)(statuses), setStatus = (...params) => createSet(...params)(statuses), clearStatuses = (...params) => createClear(...params)(statuses), deleteStatus = (...params) => createDelete(...params)(statuses);
2610
+ return {
2611
+ narrowedKeycombos,
2612
+ createKeycomboDownOptions,
2613
+ downPredicatesByKeycombo,
2614
+ createKeycomboMatchOptions,
2615
+ matchPredicatesByKeycombo,
2616
+ validAliases,
2617
+ getDownCombos,
2618
+ predicateValid,
2619
+ cleanup,
2620
+ statuses,
2621
+ toStatus,
2622
+ setStatus,
2623
+ clearStatuses,
2624
+ deleteStatus
2184
2625
  };
2185
2626
  }
2627
+ const unsupportedAliases = ["meta", "command", "cmd"];
2628
+ const unsupportedKeys = ["Meta"];
2186
2629
 
2187
- function getDomAvailability() {
2188
- try {
2189
- return !!window ? "available" : "unavailable";
2190
- } catch (error) {
2191
- return "unavailable";
2192
- }
2630
+ function createAliasesLength(options) {
2631
+ return lazyCollections.pipe(
2632
+ createAliases(options),
2633
+ lazyCollections.toLength()
2634
+ );
2193
2635
  }
2194
2636
 
2195
- function predicateArray(value) {
2196
- return Array.isArray(value);
2197
- }
2198
- function predicateUndefined(value) {
2199
- return value === void 0;
2200
- }
2201
- function predicateFunction(value) {
2202
- return typeof value === "function";
2637
+ function toDirection(angle, unit = "degrees") {
2638
+ return Object.keys(directions).find((direction) => directions[direction][unit](angle));
2203
2639
  }
2204
- function predicateNull(value) {
2205
- return value === null;
2640
+ const directions = {
2641
+ up: {
2642
+ degrees: (degrees) => degrees >= 67.5 && degrees <= 112.5,
2643
+ radians: (radians) => radians >= 0.375 * Math.PI && radians <= 0.625 * Math.PI
2644
+ },
2645
+ upRight: {
2646
+ degrees: (degrees) => degrees >= 22.5 && degrees < 67.5,
2647
+ radians: (radians) => radians >= 0.125 * Math.PI && radians < 0.375 * Math.PI
2648
+ },
2649
+ right: {
2650
+ degrees: (degrees) => degrees > 337.5 && degrees <= 360 || degrees < 22.5 && degrees >= 0,
2651
+ radians: (radians) => radians > 1.875 * Math.PI && radians <= 2 * Math.PI || radians < 0.125 * Math.PI && radians >= 0
2652
+ },
2653
+ downRight: {
2654
+ degrees: (degrees) => degrees > 292.5 && degrees <= 337.5,
2655
+ radians: (radians) => radians > 1.625 * Math.PI && radians <= 1.875 * Math.PI
2656
+ },
2657
+ down: {
2658
+ degrees: (degrees) => degrees >= 247.5 && degrees <= 292.5,
2659
+ radians: (radians) => radians >= 1.375 * Math.PI && radians <= 1.625 * Math.PI
2660
+ },
2661
+ downLeft: {
2662
+ degrees: (degrees) => degrees >= 202.5 && degrees < 247.5,
2663
+ radians: (radians) => radians >= 1.125 * Math.PI && radians < 1.375 * Math.PI
2664
+ },
2665
+ left: {
2666
+ degrees: (degrees) => degrees > 157.5 && degrees < 202.5,
2667
+ radians: (radians) => radians > 0.875 * Math.PI && radians < 1.125 * Math.PI
2668
+ },
2669
+ upLeft: {
2670
+ degrees: (degrees) => degrees > 112.5 && degrees <= 157.5,
2671
+ radians: (radians) => radians > 0.625 * Math.PI && radians <= 0.875 * Math.PI
2672
+ }
2673
+ };
2674
+
2675
+ function toHookApi({
2676
+ getSequence,
2677
+ getStatus,
2678
+ getMetadata
2679
+ }) {
2680
+ return {
2681
+ sequence: getSequence(),
2682
+ status: getStatus(),
2683
+ metadata: getMetadata()
2684
+ };
2206
2685
  }
2207
- function predicateNumber(value) {
2208
- return typeof value === "number";
2686
+
2687
+ function toMousePoint(event) {
2688
+ return {
2689
+ x: event.clientX,
2690
+ y: event.clientY
2691
+ };
2209
2692
  }
2210
- function predicateString(value) {
2211
- return typeof value === "string";
2693
+ function toTouchMovePoint(event) {
2694
+ return {
2695
+ x: event.touches.item(0).clientX,
2696
+ y: event.touches.item(0).clientY
2697
+ };
2212
2698
  }
2213
- function predicateObject(value) {
2214
- return typeof value === "object";
2699
+ function toTouchEndPoint(event) {
2700
+ return {
2701
+ x: event.changedTouches.item(0).clientX,
2702
+ y: event.changedTouches.item(0).clientY
2703
+ };
2215
2704
  }
2216
2705
 
2217
- class Recognizeable {
2218
- maxSequenceLength;
2219
- effects;
2220
- effectApi;
2221
- constructor(sequence, options = {}) {
2222
- const defaultOptions = {
2223
- maxSequenceLength: true,
2224
- effects: {}
2225
- };
2226
- this.maxSequenceLength = options?.maxSequenceLength || defaultOptions.maxSequenceLength;
2227
- this.effects = options?.effects || defaultOptions.effects;
2228
- this.resetComputedMetadata();
2229
- this.setSequence(sequence);
2230
- this.effectApi = {
2231
- getStatus: () => this.status,
2232
- getMetadata: () => this.metadata,
2233
- setMetadata: (metadata) => this.computedMetadata = metadata,
2234
- recognized: () => this.recognized(),
2235
- denied: () => this.denied(),
2236
- ready: () => this.ready()
2237
- };
2238
- this.ready();
2239
- }
2240
- computedMetadata;
2241
- resetComputedMetadata() {
2242
- this.computedMetadata = {};
2243
- }
2244
- recognized() {
2245
- this.computedStatus = "recognized";
2246
- }
2247
- denied() {
2248
- this.computedStatus = "denied";
2249
- }
2250
- computedStatus;
2251
- ready() {
2252
- this.computedStatus = "ready";
2253
- }
2254
- get sequence() {
2255
- return this.computedSequence;
2256
- }
2257
- set sequence(sequence) {
2258
- this.setSequence(sequence);
2259
- }
2260
- get status() {
2261
- return this.computedStatus;
2262
- }
2263
- get metadata() {
2264
- return this.computedMetadata;
2265
- }
2266
- computedSequence;
2267
- setSequence(sequence) {
2268
- this.computedSequence = sequence;
2269
- return this;
2270
- }
2271
- recognize(sequenceItem, { onRecognized } = {}) {
2272
- this.recognizing();
2273
- const type = this.toType(sequenceItem), pushSequence = (sequenceItem2) => {
2274
- newSequence.push(sequenceItem2);
2275
- if (this.maxSequenceLength !== true && newSequence.length > this.maxSequenceLength) {
2276
- newSequence.shift();
2277
- }
2278
- }, newSequence = [];
2279
- for (const sequenceItem2 of this.sequence) {
2280
- pushSequence(sequenceItem2);
2281
- }
2282
- pushSequence(sequenceItem);
2283
- this.effectApi.getSequence = () => newSequence;
2284
- this.effectApi.pushSequence = pushSequence;
2285
- this.effectApi.onRecognized = onRecognized || (() => {
2286
- });
2287
- this.effects[type]?.(sequenceItem, { ...this.effectApi });
2288
- switch (this.status) {
2289
- case "ready":
2290
- case "denied":
2291
- this.resetComputedMetadata();
2292
- this.setSequence([]);
2293
- break;
2294
- case "recognizing":
2295
- case "recognized":
2296
- this.setSequence(newSequence);
2297
- break;
2298
- }
2299
- return this;
2300
- }
2301
- recognizing() {
2302
- this.computedStatus = "recognizing";
2303
- }
2304
- toType(sequenceItem) {
2305
- if (predicateArray(sequenceItem)) {
2306
- if (sequenceItem[0] instanceof IntersectionObserverEntry) {
2307
- return "intersect";
2308
- }
2309
- if (sequenceItem[0] instanceof MutationRecord) {
2310
- return "mutate";
2311
- }
2312
- if (sequenceItem[0] instanceof ResizeObserverEntry) {
2313
- return "resize";
2314
- }
2315
- } else {
2316
- if (sequenceItem instanceof MediaQueryListEvent) {
2317
- return sequenceItem.media;
2318
- }
2319
- if ("didTimeout" in sequenceItem) {
2320
- return "idle";
2321
- }
2322
- return sequenceItem.type;
2323
- }
2324
- }
2706
+ function toPolarCoordinates({ xA, xB, yA, yB }) {
2707
+ const distance = Math.hypot(xB - xA, yB - yA), angle = Math.atan2(yA - yB, xB - xA), radians = angle >= 0 ? angle : 2 * Math.PI + angle, degrees = radians * 180 / Math.PI;
2708
+ return {
2709
+ distance,
2710
+ angle: { radians, degrees }
2711
+ };
2325
2712
  }
2326
2713
 
2327
- class Listenable {
2328
- computedRecognizeable;
2329
- recognizeableEffectsKeys;
2330
- computedActive;
2331
- constructor(type, options) {
2332
- if (type === "recognizeable") {
2333
- this.computedRecognizeable = new Recognizeable([], options?.recognizeable);
2334
- this.recognizeableEffectsKeys = Object.keys(options?.recognizeable?.effects);
2335
- }
2336
- this.computedActive = /* @__PURE__ */ new Set();
2337
- this.setType(type);
2338
- this.ready();
2339
- }
2340
- computedStatus;
2341
- ready() {
2342
- this.computedStatus = "ready";
2343
- }
2344
- get type() {
2345
- return this.computedType;
2346
- }
2347
- set type(type) {
2348
- this.setType(type);
2349
- }
2350
- get status() {
2351
- return this.computedStatus;
2352
- }
2353
- get active() {
2354
- return this.computedActive;
2355
- }
2356
- get recognizeable() {
2357
- return this.computedRecognizeable;
2358
- }
2359
- computedType;
2360
- implementation;
2361
- setType(type) {
2362
- this.stop();
2363
- this.computedType = type;
2364
- this.implementation = toImplementation(type);
2365
- return this;
2714
+ const initialMetadata$3 = {
2715
+ times: {
2716
+ start: 0,
2717
+ end: 0
2718
+ },
2719
+ duration: 0
2720
+ };
2721
+ function storeKeyboardTimeMetadata({
2722
+ event,
2723
+ api,
2724
+ getTimeMetadata,
2725
+ getShouldStore,
2726
+ setRequest,
2727
+ recognize
2728
+ }) {
2729
+ if (!getShouldStore())
2730
+ return;
2731
+ const { getStatus, listenInjection: { effect } } = api, timeMetadata = getTimeMetadata();
2732
+ if (!timeMetadata.times)
2733
+ timeMetadata.times = createClone()(initialMetadata$3.times);
2734
+ timeMetadata.times.start = Math.round(event.timeStamp);
2735
+ timeMetadata.times.end = Math.round(event.timeStamp);
2736
+ const storeDuration = () => {
2737
+ const request = requestAnimationFrame((timestamp) => {
2738
+ if (!getShouldStore())
2739
+ return;
2740
+ timeMetadata.times.end = Math.round(timestamp);
2741
+ timeMetadata.duration = Math.max(0, timeMetadata.times.end - timeMetadata.times.start);
2742
+ if (recognize) {
2743
+ recognize(event, api);
2744
+ if (getStatus() === "recognized")
2745
+ effect(event);
2746
+ }
2747
+ storeDuration();
2748
+ });
2749
+ setRequest(request);
2750
+ };
2751
+ storeDuration();
2752
+ }
2753
+
2754
+ const initialMetadata$2 = {
2755
+ points: {
2756
+ start: { x: 0, y: 0 },
2757
+ end: { x: 0, y: 0 }
2366
2758
  }
2367
- listen(effect, options = {}) {
2368
- switch (this.implementation) {
2369
- case "intersection":
2370
- this.intersectionListen(effect, options);
2371
- break;
2372
- case "mutation":
2373
- this.mutationListen(effect, options);
2374
- break;
2375
- case "resize":
2376
- this.resizeListen(effect, options);
2377
- break;
2378
- case "mediaquery":
2379
- this.mediaQueryListen(effect, options);
2380
- break;
2381
- case "idle":
2382
- this.idleListen(effect, options);
2383
- break;
2384
- case "message":
2385
- this.messageListen(effect, options);
2386
- break;
2387
- case "recognizeable":
2388
- this.recognizeableListen(effect, options);
2389
- break;
2390
- case "documentevent":
2391
- this.documentEventListen(effect, options);
2392
- break;
2393
- case "event":
2394
- this.eventListen(effect, options);
2395
- break;
2759
+ };
2760
+ function storePointerStartMetadata(event, api) {
2761
+ const { getMetadata } = api, metadata = getMetadata();
2762
+ const point = event instanceof MouseEvent ? toMousePoint(event) : toTouchMovePoint(event);
2763
+ if (!metadata.points)
2764
+ metadata.points = createClone()(initialMetadata$2.points);
2765
+ metadata.points.start = point;
2766
+ metadata.points.end = point;
2767
+ }
2768
+
2769
+ const initialMetadata$1 = {
2770
+ distance: {
2771
+ straight: {
2772
+ fromStart: 0,
2773
+ fromPrevious: 0
2774
+ },
2775
+ horizontal: {
2776
+ fromStart: 0,
2777
+ fromPrevious: 0
2778
+ },
2779
+ vertical: {
2780
+ fromStart: 0,
2781
+ fromPrevious: 0
2396
2782
  }
2397
- this.listening();
2398
- return this;
2399
- }
2400
- intersectionListen(effect, options) {
2401
- const { target = document.querySelector("html"), observer } = options, id = new IntersectionObserver(effect, observer);
2402
- id.observe(target);
2403
- this.active.add({ target, id });
2404
- }
2405
- mutationListen(effect, options) {
2406
- const { target = document.querySelector("html"), observe } = options, id = new MutationObserver(effect);
2407
- id.observe(target, observe);
2408
- this.active.add({ target, id });
2783
+ },
2784
+ angle: {
2785
+ fromPrevious: { radians: 0, degrees: 0 },
2786
+ fromStart: { radians: 0, degrees: 0 }
2787
+ },
2788
+ direction: {
2789
+ fromPrevious: "up",
2790
+ fromStart: "up"
2409
2791
  }
2410
- resizeListen(effect, options) {
2411
- const { target = document.querySelector("html"), observe } = options, id = new ResizeObserver(effect);
2412
- id.observe(target, observe);
2413
- this.active.add({ target, id });
2792
+ };
2793
+ function storePointerMoveMetadata(event, api) {
2794
+ const { getMetadata } = api, metadata = getMetadata();
2795
+ if (!metadata.distance) {
2796
+ metadata.distance = createClone()(initialMetadata$1.distance);
2797
+ metadata.angle = createClone()(initialMetadata$1.angle);
2798
+ metadata.direction = createClone()(initialMetadata$1.direction);
2414
2799
  }
2415
- mediaQueryListen(effect, options) {
2416
- const target = window.matchMedia(this.type);
2417
- if (predicateFunction(options.instantEffect)) {
2418
- options.instantEffect(target);
2800
+ const { x: previousX, y: previousY } = metadata.points.end, { x: startX, y: startY } = metadata.points.start, { x: newX, y: newY } = (() => {
2801
+ if (event instanceof MouseEvent) {
2802
+ return toMousePoint(event);
2419
2803
  }
2420
- const withApi = (event) => effect(event);
2421
- target.addEventListener("change", withApi);
2422
- this.active.add({ target, id: ["change", withApi] });
2423
- }
2424
- idleListen(effect, options) {
2425
- const { requestIdleCallback } = options, id = window.requestIdleCallback((deadline) => effect(deadline), requestIdleCallback);
2426
- this.active.add({ target: window, id });
2427
- }
2428
- messageListen(effect, options) {
2429
- const { target = new BroadcastChannel("baleada") } = options;
2430
- target.addEventListener(this.type, (event) => effect(event));
2431
- this.active.add({ target, id: [this.type, effect] });
2432
- }
2433
- recognizeableListen(effect, options) {
2434
- const guardedEffect = (sequenceItem) => {
2435
- this.recognizeable.recognize(sequenceItem, { onRecognized: (sequenceItem2) => effect(sequenceItem2) });
2436
- if (this.recognizeable.status === "recognized")
2437
- effect(sequenceItem);
2438
- };
2439
- for (const type of this.recognizeableEffectsKeys) {
2440
- const listenable = new Listenable(type);
2441
- listenable.listen(guardedEffect, options);
2442
- this.active.add({ id: listenable });
2804
+ if (event instanceof TouchEvent) {
2805
+ if (event.type === "touchmove") {
2806
+ return toTouchMovePoint(event);
2807
+ }
2808
+ return toTouchEndPoint(event);
2443
2809
  }
2810
+ })(), { distance: distanceFromPrevious, angle: angleFromPrevious } = toPolarCoordinates({
2811
+ xA: previousX,
2812
+ xB: newX,
2813
+ yA: previousY,
2814
+ yB: newY
2815
+ }), { distance: distanceFromStart, angle: angleFromStart } = toPolarCoordinates({
2816
+ xA: startX,
2817
+ xB: newX,
2818
+ yA: startY,
2819
+ yB: newY
2820
+ });
2821
+ metadata.distance.straight.fromPrevious = distanceFromPrevious;
2822
+ metadata.distance.horizontal.fromPrevious = newX - previousX;
2823
+ metadata.distance.vertical.fromPrevious = newY - previousY;
2824
+ metadata.angle.fromPrevious = angleFromPrevious;
2825
+ metadata.direction.fromPrevious = toDirection(angleFromPrevious.degrees);
2826
+ metadata.distance.straight.fromStart = distanceFromStart;
2827
+ metadata.distance.horizontal.fromStart = newX - startX;
2828
+ metadata.distance.vertical.fromStart = newY - startY;
2829
+ metadata.angle.fromStart = angleFromStart;
2830
+ metadata.direction.fromStart = toDirection(angleFromStart.degrees);
2831
+ metadata.points.end = { x: newX, y: newY };
2832
+ }
2833
+
2834
+ const initialMetadata = {
2835
+ times: {
2836
+ start: 0,
2837
+ end: 0
2838
+ },
2839
+ duration: 0,
2840
+ velocity: 0
2841
+ };
2842
+ function storePointerTimeMetadata(event, api, getShouldStore, setRequest, recognize) {
2843
+ const { getSequence, getMetadata, getStatus, listenInjection: { effect } } = api, metadata = getMetadata();
2844
+ if (!metadata.times) {
2845
+ metadata.times = createClone()(initialMetadata.times);
2444
2846
  }
2445
- documentEventListen(effect, options) {
2446
- const narrowedOptions = {
2447
- ...options,
2448
- target: document
2847
+ metadata.times.start = Math.round(event.timeStamp);
2848
+ metadata.times.end = Math.round(event.timeStamp);
2849
+ let previousTime = metadata.times.start;
2850
+ const storeDuration = () => {
2851
+ const request = requestAnimationFrame((timestamp) => {
2852
+ if (getShouldStore()) {
2853
+ previousTime = metadata.times.end;
2854
+ metadata.times.end = Math.round(timestamp);
2855
+ metadata.duration = Math.max(0, metadata.times.end - metadata.times.start);
2856
+ const durationFromPrevious = Math.max(0, metadata.times.end - previousTime);
2857
+ metadata.velocity = metadata.distance.straight.fromPrevious / durationFromPrevious;
2858
+ const event2 = getSequence().at(-1);
2859
+ recognize?.(event2, api);
2860
+ if (getStatus() === "recognized")
2861
+ effect(event2);
2862
+ storeDuration();
2863
+ }
2864
+ });
2865
+ setRequest(request);
2866
+ };
2867
+ storeDuration();
2868
+ }
2869
+
2870
+ function defineGraph(nodes, edges) {
2871
+ return { nodes, edges };
2872
+ }
2873
+ function defineGraphNodes(nodes) {
2874
+ return nodes;
2875
+ }
2876
+ function defineGraphEdges(edges) {
2877
+ return edges;
2878
+ }
2879
+ function defineGraphNode(node) {
2880
+ return node;
2881
+ }
2882
+ function defineGraphEdge(from, to, predicateShouldTraverse) {
2883
+ return { from, to, predicateShouldTraverse };
2884
+ }
2885
+ function defineGraphAsync(nodes, edges) {
2886
+ return { nodes, edges };
2887
+ }
2888
+ function defineGraphAsyncEdges(edges) {
2889
+ return edges;
2890
+ }
2891
+ function defineGraphAsyncEdge(from, to, predicateShouldTraverse) {
2892
+ return { from, to, predicateShouldTraverse };
2893
+ }
2894
+
2895
+ function defineAssociativeArray(associativeArray) {
2896
+ return associativeArray;
2897
+ }
2898
+
2899
+ function createExceptAndOnlyEffect(type, effect, options) {
2900
+ const { except = [], only = [] } = options;
2901
+ if (type === "keydown" || type === "keyup") {
2902
+ return (event) => {
2903
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
2904
+ if (matchesOnly) {
2905
+ effect(event);
2906
+ return;
2907
+ }
2908
+ if (only.length === 0 && !matchesExcept) {
2909
+ effect(event);
2910
+ return;
2911
+ }
2449
2912
  };
2450
- this.eventListen(effect, narrowedOptions);
2451
- }
2452
- eventListen(effect, options) {
2453
- const { exceptAndOnlyEffect, effectOptions } = toAddEventListenerParams(this.type, effect, options), eventListeners = [[this.type, exceptAndOnlyEffect, ...effectOptions]];
2454
- this.addEventListeners(eventListeners, options);
2455
- }
2456
- addEventListeners(eventListeners, options) {
2457
- const { target = document } = options;
2458
- for (const eventListener of eventListeners) {
2459
- target.addEventListener(eventListener[0], eventListener[1], eventListener[2]);
2460
- this.active.add({ target, id: eventListener });
2461
- }
2462
2913
  }
2463
- listening() {
2464
- this.computedStatus = "listening";
2465
- }
2466
- stop(options = {}) {
2467
- const { target } = options;
2468
- switch (this.status) {
2469
- case "ready":
2470
- case void 0:
2471
- break;
2472
- default:
2473
- const stoppables = [...this.active].filter((active) => !target || ("target" in active ? active.target === target : false)), shouldUpdateStatus = stoppables.length === this.active.size;
2474
- for (const stoppable of stoppables) {
2475
- stop(stoppable);
2476
- this.active.delete(stoppable);
2477
- }
2478
- if (shouldUpdateStatus) {
2479
- this.stopped();
2480
- }
2481
- break;
2482
- }
2483
- return this;
2914
+ if (type === "click" || type === "dblclick" || type === "contextmenu" || type.startsWith("mouse")) {
2915
+ return (event) => {
2916
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
2917
+ if (matchesOnly) {
2918
+ effect(event);
2919
+ return;
2920
+ }
2921
+ if (only.length === 0 && !matchesExcept) {
2922
+ effect(event);
2923
+ return;
2924
+ }
2925
+ };
2484
2926
  }
2485
- stopped() {
2486
- this.computedStatus = "stopped";
2927
+ if (type.startsWith("pointer")) {
2928
+ return (event) => {
2929
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
2930
+ if (matchesOnly) {
2931
+ effect(event);
2932
+ return;
2933
+ }
2934
+ if (only.length === 0 && !matchesExcept) {
2935
+ effect(event);
2936
+ return;
2937
+ }
2938
+ };
2487
2939
  }
2940
+ return (event) => {
2941
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
2942
+ if (matchesOnly) {
2943
+ effect(event, {});
2944
+ return;
2945
+ }
2946
+ if (only.length === 0 && !matchesExcept) {
2947
+ effect(event, {});
2948
+ return;
2949
+ }
2950
+ };
2488
2951
  }
2489
- function stop(stoppable) {
2490
- if (stoppable.id instanceof Listenable) {
2491
- stoppable.id.stop();
2492
- return;
2952
+
2953
+ function getDomAvailability() {
2954
+ try {
2955
+ return !!window ? "available" : "unavailable";
2956
+ } catch (error) {
2957
+ return "unavailable";
2493
2958
  }
2494
- if (lazyCollections.some((type) => observerAssertionsByType[type](stoppable.id))(["intersect", "mutate", "resize"])) {
2495
- const { id: id2 } = stoppable;
2496
- id2.disconnect();
2497
- return;
2959
+ }
2960
+
2961
+ function predicateArray(value) {
2962
+ return Array.isArray(value);
2963
+ }
2964
+ function predicateUndefined(value) {
2965
+ return value === void 0;
2966
+ }
2967
+ function predicateFunction(value) {
2968
+ return typeof value === "function";
2969
+ }
2970
+ function predicateNull(value) {
2971
+ return value === null;
2972
+ }
2973
+ function predicateNumber(value) {
2974
+ return typeof value === "number";
2975
+ }
2976
+ function predicateString(value) {
2977
+ return typeof value === "string";
2978
+ }
2979
+ function predicateObject(value) {
2980
+ return typeof value === "object";
2981
+ }
2982
+
2983
+ function toInterpolated({ previous, next, progress }, options = {}) {
2984
+ if (predicateUndefined(previous)) {
2985
+ return next;
2498
2986
  }
2499
- if ("target" in stoppable && stoppable.target instanceof MediaQueryList) {
2500
- const { target: target2, id: id2 } = stoppable;
2501
- target2.removeEventListener(id2[0], id2[1]);
2502
- return;
2987
+ if (predicateNumber(previous) && predicateNumber(next)) {
2988
+ return (next - previous) * progress + previous;
2503
2989
  }
2504
- if (predicateNumber(stoppable.id)) {
2505
- const { target: target2, id: id2 } = stoppable;
2506
- target2.cancelIdleCallback(id2);
2507
- return;
2990
+ if (predicateString(previous) && predicateString(next)) {
2991
+ const { color: createMixOptions } = options;
2992
+ return createMix(`${next} ${progress * 100}%`, createMixOptions)(previous);
2508
2993
  }
2509
- if ("target" in stoppable && stoppable.target instanceof BroadcastChannel) {
2510
- const { target: target2, id: id2 } = stoppable;
2511
- target2.removeEventListener(id2[0], id2[1]);
2512
- return;
2994
+ if (predicateArray(previous) && predicateArray(next)) {
2995
+ const exactSliceEnd = (next.length - previous.length) * progress + previous.length, nextIsLonger = next.length > previous.length, sliceEnd = nextIsLonger ? Math.floor(exactSliceEnd) : Math.ceil(exactSliceEnd), sliceTarget = nextIsLonger ? next : previous;
2996
+ return createSlice(0, sliceEnd)(sliceTarget);
2513
2997
  }
2514
- const { target, id } = stoppable;
2515
- target.removeEventListener(id[0], id[1], id[2]);
2516
- }
2517
- function toImplementation(type) {
2518
- return lazyCollections.find((implementation) => predicatesByImplementation.get(implementation)(type))(predicatesByImplementation.keys());
2519
- }
2520
- const predicatesByImplementation = /* @__PURE__ */ new Map([
2521
- [
2522
- "recognizeable",
2523
- (type) => type === "recognizeable"
2524
- ],
2525
- [
2526
- "intersection",
2527
- (type) => type === "intersect"
2528
- ],
2529
- [
2530
- "mutation",
2531
- (type) => type === "mutate"
2532
- ],
2533
- [
2534
- "resize",
2535
- (type) => type === "resize"
2536
- ],
2537
- [
2538
- "mediaquery",
2539
- (type) => implementationREs.mediaquery.test(type)
2540
- ],
2541
- [
2542
- "idle",
2543
- (type) => type === "idle"
2544
- ],
2545
- [
2546
- "message",
2547
- (type) => type === "message" || type === "messageerror"
2548
- ],
2549
- [
2550
- "documentevent",
2551
- (type) => documentEvents.has(type)
2552
- ],
2553
- [
2554
- "event",
2555
- () => true
2556
- ]
2557
- ]);
2558
- const documentEvents = /* @__PURE__ */ new Set([
2559
- "fullscreenchange",
2560
- "fullscreenerror",
2561
- "pointerlockchange",
2562
- "pointerlockerror",
2563
- "readystatechange",
2564
- "visibilitychange"
2565
- ]);
2566
- const implementationREs = {
2567
- mediaquery: /^\(.+\)$/
2568
- };
2569
- function toAddEventListenerParams(type, effect, options) {
2570
- const { addEventListener, useCapture } = options, exceptAndOnlyEffect = createExceptAndOnlyEffect(type, effect, options), effectOptions = [addEventListener || useCapture];
2571
- return { exceptAndOnlyEffect, effectOptions };
2572
2998
  }
2573
- const observerAssertionsByType = {
2574
- intersect: (observer) => observer instanceof IntersectionObserver,
2575
- mutate: (observer) => observer instanceof MutationObserver,
2576
- resize: (observer) => observer instanceof ResizeObserver
2577
- };
2578
2999
 
2579
3000
  const defaultOptions$8 = {
2580
3001
  duration: 0,
@@ -2589,6 +3010,14 @@ const defaultOptions$8 = {
2589
3010
  iterations: 1,
2590
3011
  alternates: false
2591
3012
  };
3013
+ const defaultAnimateOptions = {
3014
+ interpolate: {
3015
+ color: {
3016
+ method: "oklch",
3017
+ ...defaultCreateMixOptions
3018
+ }
3019
+ }
3020
+ };
2592
3021
  class Animateable {
2593
3022
  initialDuration;
2594
3023
  iterationLimit;
@@ -2611,8 +3040,8 @@ class Animateable {
2611
3040
  this.iterationLimit = options?.iterations || defaultOptions$8.iterations;
2612
3041
  this.alternates = options?.alternates || defaultOptions$8.alternates;
2613
3042
  this.reversedControlPoints = fromControlPointsToReversedControlPoints(this.controlPoints);
2614
- this.toAnimationProgress = createToAnimationProgress(this.controlPoints);
2615
- this.reversedToAnimationProgress = createToAnimationProgress(this.reversedControlPoints);
3043
+ this.toAnimationProgress = createAnimationProgress(this.controlPoints);
3044
+ this.reversedToAnimationProgress = createAnimationProgress(this.reversedControlPoints);
2616
3045
  this.playCache = {};
2617
3046
  this.reverseCache = {};
2618
3047
  this.pauseCache = {};
@@ -2862,7 +3291,7 @@ class Animateable {
2862
3291
  computedRequest;
2863
3292
  createAnimate(type) {
2864
3293
  return (effect, options = {}) => {
2865
- const { interpolate: interpolateOptions } = options;
3294
+ const { interpolate: interpolateOptions } = createDeepMerge(options)(defaultAnimateOptions);
2866
3295
  this.computedRequest = window.requestAnimationFrame((timestamp) => {
2867
3296
  this.setStartTimeAndStatus(type, timestamp);
2868
3297
  const timeElapsed = Math.min(timestamp - this.startTime - this.totalTimeInvisible, this.duration), timeRemaining = this.duration - timeElapsed, timeProgress = timeElapsed / this.duration, toAnimationProgress = this.getToAnimationProgress(type), animationProgress = toAnimationProgress(timeProgress);
@@ -3233,7 +3662,7 @@ function createGetEaseables(fromKeyframeToControlPoints) {
3233
3662
  (easeables, property) => {
3234
3663
  const propertyKeyframes = createFilter(({ properties: properties2 }) => properties2.hasOwnProperty(property))(keyframes), fromKeyframesToEaseables = createReduce(
3235
3664
  (propertyEaseables2, keyframe, index) => {
3236
- const previous = keyframe.properties[property], next = index === propertyKeyframes.length - 1 ? previous : propertyKeyframes[index + 1].properties[property], start = keyframe.progress, end = index === propertyKeyframes.length - 1 ? 2 : propertyKeyframes[index + 1].progress, hasCustomTiming = !!keyframe.timing, toAnimationProgress = index === propertyKeyframes.length - 1 ? () => 1 : createToAnimationProgress(fromKeyframeToControlPoints({ keyframe, index, propertyKeyframes }));
3665
+ const previous = keyframe.properties[property], next = index === propertyKeyframes.length - 1 ? previous : propertyKeyframes[index + 1].properties[property], start = keyframe.progress, end = index === propertyKeyframes.length - 1 ? 2 : propertyKeyframes[index + 1].progress, hasCustomTiming = !!keyframe.timing, toAnimationProgress = index === propertyKeyframes.length - 1 ? () => 1 : createAnimationProgress(fromKeyframeToControlPoints({ keyframe, index, propertyKeyframes }));
3237
3666
  propertyEaseables2.push({
3238
3667
  property,
3239
3668
  value: { previous, next },
@@ -3286,32 +3715,10 @@ function fromControlPointsToReversedControlPoints(points) {
3286
3715
  { x: 1 - points[0].x, y: 1 - points[0].y }
3287
3716
  ];
3288
3717
  }
3289
- function createToAnimationProgress(points) {
3718
+ function createAnimationProgress(points) {
3290
3719
  const { 0: { x: point1x, y: point1y }, 1: { x: point2x, y: point2y } } = points;
3291
3720
  return BezierEasing(point1x, point1y, point2x, point2y);
3292
3721
  }
3293
- function toInterpolated({ previous, next, progress }, options = {}) {
3294
- if (predicateUndefined(previous)) {
3295
- return next;
3296
- }
3297
- if (predicateNumber(previous) && predicateNumber(next)) {
3298
- return (next - previous) * progress + previous;
3299
- }
3300
- if (predicateString(previous) && predicateString(next)) {
3301
- return color.mix(
3302
- options.colorModel,
3303
- {
3304
- start: previous,
3305
- end: next,
3306
- alpha: progress
3307
- }
3308
- ).toRgb().toRgbString();
3309
- }
3310
- if (predicateArray(previous) && predicateArray(next)) {
3311
- const exactSliceEnd = (next.length - previous.length) * progress + previous.length, nextIsLonger = next.length > previous.length, sliceEnd = nextIsLonger ? Math.floor(exactSliceEnd) : Math.ceil(exactSliceEnd), sliceTarget = nextIsLonger ? next : previous;
3312
- return createSlice(0, sliceEnd)(sliceTarget);
3313
- }
3314
- }
3315
3722
  const linear = [
3316
3723
  0,
3317
3724
  0,
@@ -3710,7 +4117,6 @@ class Completeable {
3710
4117
  }
3711
4118
  return this;
3712
4119
  }
3713
- // TODO: Support array of selections for multi cursor editing
3714
4120
  computedSelection;
3715
4121
  setSelection(selection) {
3716
4122
  this.computedSelection = selection;
@@ -4088,22 +4494,32 @@ class Drawable {
4088
4494
  }
4089
4495
  }
4090
4496
  function toD(stroke) {
4091
- return createReduce((d, [x0, y0], index) => {
4092
- const [x1, y1] = stroke[(index + 1) % stroke.length];
4093
- return `${d} ${x0} ${y0} ${(x0 + x1) / 2} ${(y0 + y1) / 2}`;
4094
- }, `M ${stroke[0][0]} ${stroke[0][1]} Q`)(stroke) + "Z";
4497
+ if (stroke.length < 4)
4498
+ return "";
4499
+ let a = stroke[0];
4500
+ let b = stroke[1];
4501
+ const c = stroke[2];
4502
+ let result = `M${a[0].toFixed(2)},${a[1].toFixed(2)} Q${b[0].toFixed(2)},${b[1].toFixed(2)} ${lazyCollections.average()([b[0], c[0]]).toFixed(2)},${lazyCollections.average()([b[1], c[1]]).toFixed(2)} T`;
4503
+ for (let i = 2; i < stroke.length - 1; i++) {
4504
+ a = stroke[i];
4505
+ b = stroke[i + 1];
4506
+ result += `${lazyCollections.average()([a[0], b[0]]).toFixed(2)},${lazyCollections.average()([a[1], b[1]]).toFixed(2)} `;
4507
+ }
4508
+ return `${result}Z`;
4095
4509
  }
4096
4510
  function toFlattenedD(stroke) {
4097
- if (stroke.length === 0) {
4511
+ if (stroke.length === 0)
4098
4512
  return "";
4513
+ const faces = polygonClipping.union([stroke]);
4514
+ const flattenedD = [];
4515
+ for (const face of faces) {
4516
+ for (const ring of face) {
4517
+ flattenedD.push(toD(ring));
4518
+ }
4099
4519
  }
4100
- const multiPolygon = polygonClipping.union([stroke]);
4101
- return createReduce((dFromMultiPolygon, polygon) => {
4102
- return dFromMultiPolygon + createReduce((dFromRing, points) => {
4103
- return dFromRing + toD(points);
4104
- }, "")(polygon);
4105
- }, "")(multiPolygon);
4520
+ return toSpaceSeparated(flattenedD);
4106
4521
  }
4522
+ const toSpaceSeparated = lazyCollections.join(" ");
4107
4523
 
4108
4524
  class Resolveable {
4109
4525
  constructor(getPromise, options = {}) {
@@ -4126,20 +4542,23 @@ class Resolveable {
4126
4542
  get value() {
4127
4543
  return this.computedValue;
4128
4544
  }
4545
+ get error() {
4546
+ return this.computedError;
4547
+ }
4129
4548
  computedGetPromise;
4130
4549
  setGetPromise(getPromise) {
4131
4550
  this.computedGetPromise = getPromise;
4132
4551
  return this;
4133
4552
  }
4134
4553
  computedValue;
4135
- async resolve(...args) {
4554
+ computedError;
4555
+ async resolve() {
4136
4556
  this.resolving();
4137
4557
  try {
4138
- const promises = this.getPromise(...args);
4139
- this.computedValue = predicateArray(promises) ? await createMapAsync(async (promise) => await promise)(promises) : await promises;
4558
+ this.computedValue = await this.getPromise();
4140
4559
  this.resolved();
4141
4560
  } catch (error) {
4142
- this.computedValue = error;
4561
+ this.computedError = error;
4143
4562
  this.errored();
4144
4563
  }
4145
4564
  return this;
@@ -4181,27 +4600,26 @@ class Fetchable {
4181
4600
  set resource(resource) {
4182
4601
  this.setResource(resource);
4183
4602
  }
4603
+ get status() {
4604
+ return this.computedStatus;
4605
+ }
4184
4606
  computedKy;
4185
4607
  get ky() {
4186
4608
  return this.computedKy;
4187
4609
  }
4188
4610
  computedAbortController;
4189
4611
  get abortController() {
4190
- if (!this.computedAbortController) {
4612
+ if (!this.computedAbortController)
4191
4613
  this.computedAbortController = new AbortController();
4192
- }
4193
4614
  return this.computedAbortController;
4194
4615
  }
4195
- get status() {
4196
- return this.computedStatus;
4197
- }
4198
- get response() {
4199
- return this.computedResponse;
4200
- }
4201
4616
  computedRetryCount = 0;
4202
4617
  get retryCount() {
4203
4618
  return this.computedRetryCount;
4204
4619
  }
4620
+ get response() {
4621
+ return this.computedResponse;
4622
+ }
4205
4623
  get error() {
4206
4624
  return this.computedError;
4207
4625
  }
@@ -4273,27 +4691,27 @@ class Fetchable {
4273
4691
  this.computedStatus = "errored";
4274
4692
  }
4275
4693
  async get(options = {}) {
4276
- await this.fetch({ signal: this.abortController.signal, ...options, method: "get" });
4694
+ await this.fetch({ ...options, method: "get" });
4277
4695
  return this;
4278
4696
  }
4279
4697
  async patch(options = {}) {
4280
- await this.fetch({ signal: this.abortController.signal, ...options, method: "patch" });
4698
+ await this.fetch({ ...options, method: "patch" });
4281
4699
  return this;
4282
4700
  }
4283
4701
  async post(options = {}) {
4284
- await this.fetch({ signal: this.abortController.signal, ...options, method: "post" });
4702
+ await this.fetch({ ...options, method: "post" });
4285
4703
  return this;
4286
4704
  }
4287
4705
  async put(options = {}) {
4288
- await this.fetch({ signal: this.abortController.signal, ...options, method: "put" });
4706
+ await this.fetch({ ...options, method: "put" });
4289
4707
  return this;
4290
4708
  }
4291
4709
  async delete(options = {}) {
4292
- await this.fetch({ signal: this.abortController.signal, ...options, method: "delete" });
4710
+ await this.fetch({ ...options, method: "delete" });
4293
4711
  return this;
4294
4712
  }
4295
4713
  async head(options = {}) {
4296
- await this.fetch({ signal: this.abortController.signal, ...options, method: "head" });
4714
+ await this.fetch({ ...options, method: "head" });
4297
4715
  return this;
4298
4716
  }
4299
4717
  abort() {
@@ -4390,6 +4808,9 @@ class Grantable {
4390
4808
  get permission() {
4391
4809
  return this.computedPermission;
4392
4810
  }
4811
+ get error() {
4812
+ return this.computedError;
4813
+ }
4393
4814
  get status() {
4394
4815
  return this.computedStatus;
4395
4816
  }
@@ -4399,22 +4820,23 @@ class Grantable {
4399
4820
  return this;
4400
4821
  }
4401
4822
  computedPermission;
4402
- async query() {
4403
- this.querying();
4823
+ computedError;
4824
+ async grant() {
4825
+ this.granting();
4404
4826
  try {
4405
4827
  this.computedPermission = await navigator.permissions.query(this.descriptor);
4406
- this.queried();
4828
+ this.granted();
4407
4829
  } catch (error) {
4408
- this.computedPermission = error;
4830
+ this.computedError = error;
4409
4831
  this.errored();
4410
4832
  }
4411
4833
  return this;
4412
4834
  }
4413
- querying() {
4414
- this.computedStatus = "querying";
4835
+ granting() {
4836
+ this.computedStatus = "granting";
4415
4837
  }
4416
- queried() {
4417
- this.computedStatus = "queried";
4838
+ granted() {
4839
+ this.computedStatus = "granted";
4418
4840
  }
4419
4841
  errored() {
4420
4842
  this.computedStatus = "errored";
@@ -4610,9 +5032,6 @@ class Pickable {
4610
5032
  get newest() {
4611
5033
  return this.picks[this.picks.length - 1];
4612
5034
  }
4613
- get status() {
4614
- return this.computedStatus;
4615
- }
4616
5035
  get items() {
4617
5036
  return this.toItems(this.picks);
4618
5037
  }
@@ -4621,6 +5040,9 @@ class Pickable {
4621
5040
  get multiple() {
4622
5041
  return this.computedMultiple;
4623
5042
  }
5043
+ get status() {
5044
+ return this.computedStatus;
5045
+ }
4624
5046
  toPossiblePicks;
4625
5047
  setArray(array) {
4626
5048
  this.computedArray = array;
@@ -4714,112 +5136,20 @@ function narrowIndices(indexOrIndices) {
4714
5136
  }
4715
5137
  const toUnique = createUnique();
4716
5138
 
4717
- class Sanitizeable {
4718
- domPurifyConfig;
4719
- constructor(html, options) {
4720
- this.computedHtml = html;
4721
- this.domPurifyConfig = options;
4722
- this.ready();
4723
- }
4724
- computedDompurify;
4725
- computedStatus;
4726
- ready() {
4727
- if (getDomAvailability() === "available") {
4728
- this.computedDompurify = createDOMPurify();
4729
- this.computedDompurify.setConfig(this.domPurifyConfig);
4730
- }
4731
- this.computedStatus = "ready";
4732
- }
4733
- get html() {
4734
- return this.computedHtml;
4735
- }
4736
- set html(html) {
4737
- this.setHtml(html);
4738
- }
4739
- get dompurify() {
4740
- if (!this.computedDompurify && getDomAvailability() === "available") {
4741
- this.computedDompurify = createDOMPurify();
4742
- this.computedDompurify.setConfig(this.domPurifyConfig);
4743
- }
4744
- return this.computedDompurify;
4745
- }
4746
- get status() {
4747
- return this.computedStatus;
4748
- }
4749
- computedHtml;
4750
- setHtml(html) {
4751
- this.computedHtml = html;
4752
- return this;
4753
- }
4754
- sanitize() {
4755
- this.setHtml(this.dompurify.sanitize(this.html));
4756
- this.sanitized();
4757
- return this;
4758
- }
4759
- sanitized() {
4760
- this.computedStatus = "sanitized";
4761
- }
4762
- }
4763
-
4764
- class Searchable {
4765
- searcherOptions;
4766
- computedResults;
4767
- constructor(candidates, options = {}) {
4768
- this.searcherOptions = options;
4769
- this.setCandidates(candidates);
4770
- this.computedResults = [];
4771
- this.ready();
4772
- }
4773
- computedStatus;
4774
- ready() {
4775
- this.computedStatus = "ready";
4776
- }
4777
- computedCandidates;
4778
- get candidates() {
4779
- return this.computedCandidates;
4780
- }
4781
- set candidates(candidates) {
4782
- this.setCandidates(candidates);
4783
- }
4784
- get results() {
4785
- return this.computedResults;
4786
- }
4787
- get searcher() {
4788
- return this.computedSearcher;
4789
- }
4790
- get status() {
4791
- return this.computedStatus;
4792
- }
4793
- computedSearcher;
4794
- setCandidates(candidates) {
4795
- this.computedCandidates = Array.from(candidates);
4796
- this.computedSearcher = new fastFuzzy.Searcher(candidates, this.searcherOptions);
4797
- return this;
4798
- }
4799
- search(query, options) {
4800
- this.computedResults = this.searcher.search(query, options);
4801
- this.searched();
4802
- return this;
4803
- }
4804
- searched() {
4805
- this.computedStatus = "searched";
4806
- }
4807
- }
4808
-
4809
5139
  class Shareable {
4810
- constructor(state, options = {}) {
4811
- this.setState(state);
5140
+ constructor(shareData, options = {}) {
5141
+ this.setShareData(shareData);
4812
5142
  this.ready();
4813
5143
  }
4814
5144
  computedStatus;
4815
5145
  ready() {
4816
5146
  this.computedStatus = "ready";
4817
5147
  }
4818
- get state() {
5148
+ get shareData() {
4819
5149
  return this.computedState;
4820
5150
  }
4821
- set state(state) {
4822
- this.setState(state);
5151
+ set shareData(shareData) {
5152
+ this.setShareData(shareData);
4823
5153
  }
4824
5154
  get status() {
4825
5155
  return this.computedStatus;
@@ -4833,15 +5163,15 @@ class Shareable {
4833
5163
  return this.computedError;
4834
5164
  }
4835
5165
  computedState;
4836
- setState(state) {
4837
- this.computedState = state;
4838
- this.computedCan = new Resolveable(async () => await navigator.canShare(state));
5166
+ setShareData(shareData) {
5167
+ this.computedState = shareData;
5168
+ this.computedCan = new Resolveable(async () => await navigator.canShare(shareData));
4839
5169
  return this;
4840
5170
  }
4841
5171
  async share() {
4842
5172
  this.sharing();
4843
5173
  try {
4844
- await navigator.share(this.state);
5174
+ await navigator.share(this.shareData);
4845
5175
  this.shared();
4846
5176
  } catch (error) {
4847
5177
  this.computedError = error;
@@ -4991,42 +5321,62 @@ exports.Drawable = Drawable;
4991
5321
  exports.Fetchable = Fetchable;
4992
5322
  exports.Fullscreenable = Fullscreenable;
4993
5323
  exports.Grantable = Grantable;
5324
+ exports.Keychord = Keychord;
5325
+ exports.Keypress = Keypress;
5326
+ exports.Keyrelease = Keyrelease;
5327
+ exports.Konami = Konami;
4994
5328
  exports.Listenable = Listenable;
5329
+ exports.Mousepress = Mousepress;
5330
+ exports.Mouserelease = Mouserelease;
4995
5331
  exports.Navigateable = Navigateable;
4996
5332
  exports.Pickable = Pickable;
4997
5333
  exports.Recognizeable = Recognizeable;
4998
5334
  exports.Resolveable = Resolveable;
4999
- exports.Sanitizeable = Sanitizeable;
5000
- exports.Searchable = Searchable;
5001
5335
  exports.Shareable = Shareable;
5002
5336
  exports.Storeable = Storeable;
5003
- exports.createAssociativeArray = createAssociativeArray;
5004
- exports.createAsyncDirectedAcyclicPredicateAncestor = createPredicateAncestor$1;
5005
- exports.createAsyncDirectedAcyclicToCommonAncestors = createToCommonAncestors$1;
5006
- exports.createAsyncDirectedAcyclicToLayers = createToLayers;
5007
- exports.createAsyncDirectedAcyclicToNodeSteps = createToNodeSteps$1;
5008
- exports.createAsyncDirectedAcyclicToPath = createToPath$1;
5009
- exports.createAsyncDirectedAcyclicToSteps = createToSteps$1;
5010
- exports.createAsyncDirectedAcyclicToTree = createToTree$1;
5337
+ exports.Touchpress = Touchpress;
5338
+ exports.Touchrelease = Touchrelease;
5339
+ exports.createAssociativeArrayClear = createClear$2;
5340
+ exports.createAssociativeArrayDelete = createDelete$2;
5341
+ exports.createAssociativeArrayHas = createHas$1;
5342
+ exports.createAssociativeArrayKeys = createKeys$1;
5343
+ exports.createAssociativeArraySet = createSet$2;
5344
+ exports.createAssociativeArrayValue = createValue$2;
5345
+ exports.createAssociativeArrayValues = createValues$1;
5346
+ exports.createBreadthPathConfig = createBreadthPathConfig;
5347
+ exports.createChildren = createChildren;
5011
5348
  exports.createClamp = createClamp;
5349
+ exports.createClear = createClear$1;
5012
5350
  exports.createClip = createClip;
5013
5351
  exports.createClone = createClone;
5352
+ exports.createComputedStyle = createComputedStyle;
5014
5353
  exports.createConcat = createConcat;
5015
- exports.createDecisionTreePredicateAncestor = createPredicateAncestor;
5016
- exports.createDecisionTreeToCommonAncestors = createToCommonAncestors;
5017
- exports.createDecisionTreeToNodeSteps = createToNodeSteps;
5018
- exports.createDecisionTreeToPath = createToPath;
5019
- exports.createDecisionTreeToSteps = createToSteps;
5020
- exports.createDecisionTreeToTree = createToTree;
5354
+ exports.createDecisionTreeAncestor = createAncestor$1;
5355
+ exports.createDecisionTreeCommonAncestors = createCommonAncestors$1;
5356
+ exports.createDecisionTreeNodeDepthFirstSteps = createNodeDepthFirstSteps$1;
5357
+ exports.createDecisionTreePath = createPath$1;
5358
+ exports.createDecisionTreeSteps = createDepthFirstSteps$1;
5359
+ exports.createDecisionTreeTree = createTree$1;
5360
+ exports.createDeepEqual = createDeepEqual;
5361
+ exports.createDeepMerge = createDeepMerge;
5362
+ exports.createDelete = createDelete$1;
5363
+ exports.createDepthPathConfig = createDepthPathConfig;
5021
5364
  exports.createDetermine = createDetermine;
5022
- exports.createDirectedAcyclicPredicateAncestor = createPredicateAncestor$2;
5023
- exports.createDirectedAcyclicToCommonAncestors = createToCommonAncestors$2;
5024
- exports.createDirectedAcyclicToLayers = createToLayers$1;
5025
- exports.createDirectedAcyclicToNodeSteps = createToNodeSteps$2;
5026
- exports.createDirectedAcyclicToPath = createToPath$2;
5027
- exports.createDirectedAcyclicToRoots = createToRoots;
5028
- exports.createDirectedAcyclicToSteps = createToSteps$2;
5029
- exports.createDirectedAcyclicToTree = createToTree$2;
5365
+ exports.createDirectedAcyclicAncestor = createAncestor$2;
5366
+ exports.createDirectedAcyclicAsyncAncestor = createAncestor;
5367
+ exports.createDirectedAcyclicAsyncCommonAncestors = createCommonAncestors;
5368
+ exports.createDirectedAcyclicAsyncDepthFirstSteps = createDepthFirstSteps;
5369
+ exports.createDirectedAcyclicAsyncLayers = createLayers;
5370
+ exports.createDirectedAcyclicAsyncNodeDepthFirstSteps = createNodeDepthFirstSteps;
5371
+ exports.createDirectedAcyclicAsyncPath = createPath;
5372
+ exports.createDirectedAcyclicAsyncTree = createTree;
5373
+ exports.createDirectedAcyclicCommonAncestors = createCommonAncestors$2;
5374
+ exports.createDirectedAcyclicDepthFirstSteps = createDepthFirstSteps$2;
5375
+ exports.createDirectedAcyclicLayers = createLayers$1;
5376
+ exports.createDirectedAcyclicNodeDepthFirstSteps = createNodeDepthFirstSteps$2;
5377
+ exports.createDirectedAcyclicPath = createPath$2;
5378
+ exports.createDirectedAcyclicRoots = createRoots;
5379
+ exports.createDirectedAcyclicTree = createTree$2;
5030
5380
  exports.createEntries = createEntries;
5031
5381
  exports.createEqual = createEqual;
5032
5382
  exports.createEvery = createEvery;
@@ -5036,45 +5386,60 @@ exports.createFindAsync = createFindAsync;
5036
5386
  exports.createFindIndexAsync = createFindIndexAsync;
5037
5387
  exports.createFocusable = createFocusable;
5038
5388
  exports.createForEachAsync = createForEachAsync;
5389
+ exports.createGraph = createGraph;
5390
+ exports.createGreater = createGreater;
5391
+ exports.createGreaterOrEqual = createGreaterOrEqual;
5392
+ exports.createHas = createHas;
5393
+ exports.createIncoming = createIncoming;
5394
+ exports.createIndegree = createIndegree;
5039
5395
  exports.createInsert = createInsert;
5040
5396
  exports.createKeychord = createKeychord;
5397
+ exports.createKeycomboMatch = createKeycomboMatch$1;
5041
5398
  exports.createKeypress = createKeypress;
5042
5399
  exports.createKeyrelease = createKeyrelease;
5043
5400
  exports.createKeys = createKeys;
5044
5401
  exports.createKonami = createKonami;
5402
+ exports.createLess = createLess;
5403
+ exports.createLessOrEqual = createLessOrEqual;
5045
5404
  exports.createList = createList;
5046
5405
  exports.createMap = createMap;
5047
5406
  exports.createMapAsync = createMapAsync;
5407
+ exports.createMix = createMix;
5048
5408
  exports.createMousepress = createMousepress;
5049
5409
  exports.createMouserelease = createMouserelease;
5050
- exports.createPredicateKeycomboMatch = createPredicateKeycomboMatch$1;
5051
- exports.createPredicateRoot = createPredicateRoot;
5410
+ exports.createNumber = createNumber;
5411
+ exports.createOnlyChild = createOnlyChild;
5412
+ exports.createOutdegree = createOutdegree;
5413
+ exports.createOutgoing = createOutgoing;
5052
5414
  exports.createReduce = createReduce;
5053
5415
  exports.createReduceAsync = createReduceAsync;
5054
5416
  exports.createRemove = createRemove;
5055
- exports.createRename = createRename;
5056
5417
  exports.createReorder = createReorder;
5057
5418
  exports.createReplace = createReplace;
5419
+ exports.createResults = createResults;
5058
5420
  exports.createReverse = createReverse;
5421
+ exports.createRoot = createRoot;
5422
+ exports.createSanitize = createSanitize;
5423
+ exports.createSet = createSet$1;
5424
+ exports.createShuffle = createShuffle;
5425
+ exports.createSiblings = createSiblings;
5059
5426
  exports.createSlice = createSlice;
5060
5427
  exports.createSlug = createSlug;
5061
5428
  exports.createSome = createSome;
5062
5429
  exports.createSort = createSort;
5063
5430
  exports.createSwap = createSwap;
5064
- exports.createToGraph = createToGraph;
5065
- exports.createToIncoming = createToIncoming;
5066
- exports.createToIndegree = createToIndegree;
5067
- exports.createToOutdegree = createToOutdegree;
5068
- exports.createToOutgoing = createToOutgoing;
5431
+ exports.createTerminal = createTerminal;
5432
+ exports.createTotalSiblings = createTotalSiblings;
5069
5433
  exports.createTouchpress = createTouchpress;
5070
5434
  exports.createTouchrelease = createTouchrelease;
5071
5435
  exports.createTreeFind = createFind;
5072
5436
  exports.createUnique = createUnique;
5073
- exports.defineAssociativeArrayEntries = defineAssociativeArrayEntries;
5074
- exports.defineAsyncGraph = defineAsyncGraph;
5075
- exports.defineAsyncGraphEdge = defineAsyncGraphEdge;
5076
- exports.defineAsyncGraphEdges = defineAsyncGraphEdges;
5437
+ exports.createValue = createValue$1;
5438
+ exports.defineAssociativeArray = defineAssociativeArray;
5077
5439
  exports.defineGraph = defineGraph;
5440
+ exports.defineGraphAsync = defineGraphAsync;
5441
+ exports.defineGraphAsyncEdge = defineGraphAsyncEdge;
5442
+ exports.defineGraphAsyncEdges = defineGraphAsyncEdges;
5078
5443
  exports.defineGraphEdge = defineGraphEdge;
5079
5444
  exports.defineGraphEdges = defineGraphEdges;
5080
5445
  exports.defineGraphNode = defineGraphNode;
@@ -5101,6 +5466,10 @@ exports.easingsNetOutExpo = easingsNetOutExpo;
5101
5466
  exports.easingsNetOutQuad = easingsNetOutQuad;
5102
5467
  exports.easingsNetOutQuint = easingsNetOutQuint;
5103
5468
  exports.easingsNetOutSine = easingsNetOutSine;
5469
+ exports.fromAliasToCode = fromAliasToCode;
5470
+ exports.fromCodeToAliases = fromCodeToAliases;
5471
+ exports.fromKeyboardEventDescriptorToAliases = fromKeyboardEventDescriptorToAliases;
5472
+ exports.fromShorthandAliasToLonghandAlias = fromShorthandAliasToLonghandAlias;
5104
5473
  exports.linear = linear;
5105
5474
  exports.materialAccelerated = materialAccelerated;
5106
5475
  exports.materialDecelerated = materialDecelerated;