@baleada/logic 0.22.3 → 0.22.5

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 +524 -232
  2. package/lib/index.d.ts +269 -216
  3. package/lib/index.js +513 -219
  4. package/package.json +21 -21
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { reduce, pipe, filter, toArray, slice, concat, unique, map, find, findIndex, some, every, join } from 'lazy-collections';
1
+ import { reduce, pipe, unique, toArray, slice, filter, map, concat, find, findIndex, join, some, every } from 'lazy-collections';
2
2
  import slugify from '@sindresorhus/slugify';
3
3
  import BezierEasing from 'bezier-easing';
4
4
  import { mix } from '@snigo.dev/color';
@@ -9,10 +9,13 @@ import { Searcher } from 'fast-fuzzy';
9
9
 
10
10
  function createReduceAsync(accumulate, initialValue) {
11
11
  return async (array) => {
12
- return await reduce(async (accumulatorPromise, item, index) => {
13
- const accumulator = await accumulatorPromise;
14
- return accumulate(accumulator, item, index);
15
- }, Promise.resolve(initialValue))(array);
12
+ return await reduce(
13
+ async (accumulatorPromise, item, index) => {
14
+ const accumulator = await accumulatorPromise;
15
+ return accumulate(accumulator, item, index);
16
+ },
17
+ Promise.resolve(initialValue)
18
+ )(array);
16
19
  };
17
20
  }
18
21
  function createReduce(accumulate, initialValue) {
@@ -26,11 +29,14 @@ function createForEachAsync(forEach) {
26
29
  }
27
30
  function createMapAsync(transform) {
28
31
  return async (array) => {
29
- return await createReduceAsync(async (resolvedMaps, item, index) => {
30
- const transformed = await transform(item, index);
31
- resolvedMaps.push(transformed);
32
- return resolvedMaps;
33
- }, [])(array);
32
+ return await createReduceAsync(
33
+ async (resolvedMaps, item, index) => {
34
+ const transformed = await transform(item, index);
35
+ resolvedMaps.push(transformed);
36
+ return resolvedMaps;
37
+ },
38
+ []
39
+ )(array);
34
40
  };
35
41
  }
36
42
  function createFilterAsync(condition) {
@@ -39,36 +45,52 @@ function createFilterAsync(condition) {
39
45
  return createFilter((_, index) => transformedAsync[index])(array);
40
46
  };
41
47
  }
42
- function createDelete(index) {
48
+ function createRemove(index) {
43
49
  return (array) => {
44
- return createConcat(createSlice(0, index)(array), createSlice(index + 1)(array))([]);
50
+ return createConcat(
51
+ createSlice(0, index)(array),
52
+ createSlice(index + 1)(array)
53
+ )([]);
45
54
  };
46
55
  }
47
56
  function createInsert(item, index) {
48
57
  return (array) => {
49
58
  const withItems = createConcat(array, [item])([]);
50
- return createReorder({ start: array.length, itemCount: 1 }, index)(withItems);
59
+ return createReorder(
60
+ { start: array.length, itemCount: 1 },
61
+ index
62
+ )(withItems);
51
63
  };
52
64
  }
53
65
  function createReorder(from, to) {
54
66
  return (array) => {
55
- const [itemsToMoveStartIndex, itemsToMoveCount] = isObject(from) ? [from.start, from.itemCount] : [from, 1], insertIndex = to;
67
+ const [itemsToMoveStartIndex, itemsToMoveCount] = predicateObject(from) ? [from.start, from.itemCount] : [from, 1], insertIndex = to;
56
68
  if (insertIndex > itemsToMoveStartIndex && insertIndex < itemsToMoveStartIndex + itemsToMoveCount) {
57
69
  return array;
58
70
  }
59
71
  const itemsToMove = createSlice(itemsToMoveStartIndex, itemsToMoveStartIndex + itemsToMoveCount)(array);
60
72
  if (itemsToMoveStartIndex < insertIndex) {
61
73
  const beforeItemsToMove = itemsToMoveStartIndex === 0 ? [] : createSlice(0, itemsToMoveStartIndex)(array), betweenItemsToMoveAndInsertIndex = createSlice(itemsToMoveStartIndex + itemsToMoveCount, insertIndex + 1)(array), afterInsertIndex = createSlice(insertIndex + 1)(array);
62
- return createConcat(beforeItemsToMove, betweenItemsToMoveAndInsertIndex, itemsToMove, afterInsertIndex)([]);
74
+ return createConcat(
75
+ beforeItemsToMove,
76
+ betweenItemsToMoveAndInsertIndex,
77
+ itemsToMove,
78
+ afterInsertIndex
79
+ )([]);
63
80
  }
64
81
  if (itemsToMoveStartIndex > insertIndex) {
65
82
  const beforeInsertion = insertIndex === 0 ? [] : createSlice(0, insertIndex)(array), betweenInsertionAndItemsToMove = createSlice(insertIndex, itemsToMoveStartIndex)(array), afterItemsToMove = createSlice(itemsToMoveStartIndex + itemsToMoveCount)(array);
66
- return createConcat(beforeInsertion, itemsToMove, betweenInsertionAndItemsToMove, afterItemsToMove)([]);
83
+ return createConcat(
84
+ beforeInsertion,
85
+ itemsToMove,
86
+ betweenInsertionAndItemsToMove,
87
+ afterItemsToMove
88
+ )([]);
67
89
  }
68
90
  return array;
69
91
  };
70
92
  }
71
- function isObject(value) {
93
+ function predicateObject(value) {
72
94
  return typeof value === "object";
73
95
  }
74
96
  function createSwap(indices) {
@@ -96,25 +118,44 @@ function createSwap(indices) {
96
118
  }
97
119
  function createReplace(index, item) {
98
120
  return (array) => {
99
- return createConcat(createSlice(0, index)(array), [item], createSlice(index + 1)(array))([]);
121
+ return createConcat(
122
+ createSlice(0, index)(array),
123
+ [item],
124
+ createSlice(index + 1)(array)
125
+ )([]);
100
126
  };
101
127
  }
102
128
  function createUnique() {
103
- return (array) => pipe(unique(), toArray())(array);
129
+ return (array) => pipe(
130
+ unique(),
131
+ toArray()
132
+ )(array);
104
133
  }
105
134
  function createSlice(from, to) {
106
135
  return (array) => {
107
- return from === to ? [] : pipe(slice(from, to - 1), toArray())(array);
136
+ return from === to ? [] : pipe(
137
+ slice(from, to - 1),
138
+ toArray()
139
+ )(array);
108
140
  };
109
141
  }
110
142
  function createFilter(condition) {
111
- return (array) => pipe(filter(condition), toArray())(array);
143
+ return (array) => pipe(
144
+ filter(condition),
145
+ toArray()
146
+ )(array);
112
147
  }
113
148
  function createMap(transform) {
114
- return (array) => pipe(map(transform), toArray())(array);
149
+ return (array) => pipe(
150
+ map(transform),
151
+ toArray()
152
+ )(array);
115
153
  }
116
154
  function createConcat(...arrays) {
117
- return (array) => pipe(concat(array, ...arrays), toArray())();
155
+ return (array) => pipe(
156
+ concat(array, ...arrays),
157
+ toArray()
158
+ )();
118
159
  }
119
160
  function createReverse() {
120
161
  return (array) => {
@@ -127,7 +168,10 @@ function createReverse() {
127
168
  }
128
169
  function createSort(compare) {
129
170
  return (array) => {
130
- return new Pipeable(array).pipe(createSlice(0), (sliced) => sliced.sort(compare));
171
+ return new Pipeable(array).pipe(
172
+ createSlice(0),
173
+ (sliced) => compare ? sliced.sort(compare) : sliced.sort()
174
+ );
131
175
  };
132
176
  }
133
177
  function createSlug(options) {
@@ -148,7 +192,10 @@ function createClamp(min, max) {
148
192
  }
149
193
  function createDetermine(potentialities) {
150
194
  const predicates = createMap(({ outcome, probability }, index) => {
151
- const lowerBound = index === 0 ? 0 : pipe(slice(0, index - 1), reduce((lowerBound2, { probability: probability2 }) => lowerBound2 + probability2, 0))(potentialities), upperBound = lowerBound + probability;
195
+ const lowerBound = index === 0 ? 0 : pipe(
196
+ slice(0, index - 1),
197
+ reduce((lowerBound2, { probability: probability2 }) => lowerBound2 + probability2, 0)
198
+ )(potentialities), upperBound = lowerBound + probability;
152
199
  return {
153
200
  outcome,
154
201
  predicate: (determinant) => determinant >= lowerBound && determinant < upperBound || determinant < 0 && index === 0 || index === predicates.length - 1
@@ -171,6 +218,37 @@ function createToEntries() {
171
218
  return entries;
172
219
  };
173
220
  }
221
+ function createMatchesKeycombo(keycombo) {
222
+ return (event) => eventMatchesKeycombo(event, narrowKeycombo(keycombo));
223
+ }
224
+ function createMatchesMousecombo(mousecombo) {
225
+ return (event) => eventMatchesMousecombo(event, narrowMousecombo(mousecombo));
226
+ }
227
+ function createMatchesPointercombo(pointercombo) {
228
+ return (event) => eventMatchesPointercombo(event, narrowPointercombo(pointercombo));
229
+ }
230
+ function createToFocusable(order, elementIsCandidate) {
231
+ return (element) => {
232
+ if (elementIsCandidate && predicateFocusable(element))
233
+ return element;
234
+ switch (order) {
235
+ case "first":
236
+ for (let i = 0; i < element.children.length; i++) {
237
+ const focusable = createToFocusable(order, true)(element.children[i]);
238
+ if (focusable)
239
+ return focusable;
240
+ }
241
+ break;
242
+ case "last":
243
+ for (let i = element.children.length - 1; i > -1; i--) {
244
+ const focusable = createToFocusable(order, true)(element.children[i]);
245
+ if (focusable)
246
+ return focusable;
247
+ }
248
+ break;
249
+ }
250
+ };
251
+ }
174
252
  class Pipeable {
175
253
  constructor(state) {
176
254
  this.state = state;
@@ -179,7 +257,10 @@ class Pipeable {
179
257
  return createReduce((piped, fn, index) => fn(piped, index), this.state)(fns);
180
258
  }
181
259
  async pipeAsync(...fns) {
182
- return await createReduceAsync(async (piped, fn, index) => await fn(piped, index), this.state)(fns);
260
+ return await createReduceAsync(
261
+ async (piped, fn, index) => await fn(piped, index),
262
+ this.state
263
+ )(fns);
183
264
  }
184
265
  }
185
266
 
@@ -235,20 +316,27 @@ const keysByName = {
235
316
  f20: "F20"
236
317
  };
237
318
  const toListenableKeycomboItems = createMap((name) => ({ name, type: fromComboItemNameToType(name) }));
238
- function ensureKeycombo(type) {
239
- return new Pipeable(type).pipe(toCombo, toListenableKeycomboItems);
319
+ function narrowKeycombo(type) {
320
+ return new Pipeable(type).pipe(
321
+ toCombo,
322
+ toListenableKeycomboItems
323
+ );
240
324
  }
241
- function ensureClickcombo(type) {
325
+ function narrowMousecombo(type) {
242
326
  return toCombo(type);
243
327
  }
244
- function ensurePointercombo(type) {
328
+ function narrowPointercombo(type) {
245
329
  return toCombo(type);
246
330
  }
247
331
  const toUnique$1 = unique();
248
332
  const toComboItems = map((name) => name === "" ? delimiter : name);
249
333
  const delimiter = "+";
250
334
  function toCombo(type) {
251
- return pipe(toUnique$1, toComboItems, toArray())(type.split(delimiter));
335
+ return pipe(
336
+ toUnique$1,
337
+ toComboItems,
338
+ toArray()
339
+ )(type.split(delimiter));
252
340
  }
253
341
  function fromComboItemNameToType(name) {
254
342
  return find((type) => predicatesByType[type](name))(listenableComboItemTypes) ?? "custom";
@@ -284,45 +372,39 @@ function createExceptAndOnlyEffect(type, effect, options) {
284
372
  const { except = [], only = [] } = options;
285
373
  if (type === "keydown" || type === "keyup") {
286
374
  return (event) => {
287
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true], api = {
288
- is: (keycombo) => eventMatchesKeycombo(event, ensureKeycombo(keycombo))
289
- };
375
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true];
290
376
  if (matchesOnly) {
291
- effect(event, api);
377
+ effect(event);
292
378
  return;
293
379
  }
294
380
  if (only.length === 0 && !matchesExcept) {
295
- effect(event, api);
381
+ effect(event);
296
382
  return;
297
383
  }
298
384
  };
299
385
  }
300
386
  if (type === "click" || type === "dblclick" || type === "contextmenu" || type.startsWith("mouse")) {
301
387
  return (event) => {
302
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true], api = {
303
- is: (clickcombo) => eventMatchesClickcombo(event, ensureClickcombo(clickcombo))
304
- };
388
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true];
305
389
  if (matchesOnly) {
306
- effect(event, api);
390
+ effect(event);
307
391
  return;
308
392
  }
309
393
  if (only.length === 0 && !matchesExcept) {
310
- effect(event, api);
394
+ effect(event);
311
395
  return;
312
396
  }
313
397
  };
314
398
  }
315
399
  if (type.startsWith("pointer")) {
316
400
  return (event) => {
317
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true], api = {
318
- is: (pointercombo) => eventMatchesPointercombo(event, ensurePointercombo(pointercombo))
319
- };
401
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true];
320
402
  if (matchesOnly) {
321
- effect(event, api);
403
+ effect(event);
322
404
  return;
323
405
  }
324
406
  if (only.length === 0 && !matchesExcept) {
325
- effect(event, api);
407
+ effect(event);
326
408
  return;
327
409
  }
328
410
  };
@@ -339,7 +421,7 @@ function createExceptAndOnlyEffect(type, effect, options) {
339
421
  }
340
422
  };
341
423
  }
342
- function isModified({ event, alias }) {
424
+ function predicateModified({ event, alias }) {
343
425
  return predicatesByModifier[alias]?.(event);
344
426
  }
345
427
  const predicatesByModifier = {
@@ -360,24 +442,43 @@ function domIsAvailable() {
360
442
  return false;
361
443
  }
362
444
  }
363
- function isArray(value) {
445
+ function predicateArray(value) {
364
446
  return Array.isArray(value);
365
447
  }
366
- function isUndefined(value) {
448
+ function predicateUndefined(value) {
367
449
  return value === void 0;
368
450
  }
369
- function isFunction(value) {
451
+ function predicateFunction(value) {
370
452
  return typeof value === "function";
371
453
  }
372
- function isNull(value) {
454
+ function predicateNull(value) {
373
455
  return value === null;
374
456
  }
375
- function isNumber(value) {
457
+ function predicateNumber(value) {
376
458
  return typeof value === "number";
377
459
  }
378
- function isString(value) {
460
+ function predicateString(value) {
379
461
  return typeof value === "string";
380
462
  }
463
+ const tabbableSelector = join(':not([hidden]):not([tabindex="-1"]),')([
464
+ "input:not([disabled]):not([type=hidden])",
465
+ "select:not([disabled])",
466
+ "textarea:not([disabled])",
467
+ "button:not([disabled])",
468
+ "a[href]",
469
+ "area[href]",
470
+ "summary",
471
+ "iframe",
472
+ "object",
473
+ "embed",
474
+ "audio[controls]",
475
+ "video[controls]",
476
+ "[contenteditable]",
477
+ "[tabindex]:not([disabled])"
478
+ ]);
479
+ function predicateFocusable(element) {
480
+ return element.matches(tabbableSelector);
481
+ }
381
482
 
382
483
  class Recognizeable {
383
484
  maxSequenceLength;
@@ -432,13 +533,16 @@ class Recognizeable {
432
533
  this.computedSequence = sequence;
433
534
  return this;
434
535
  }
435
- recognize(sequenceItem, api, { onRecognized } = {}) {
536
+ recognize(sequenceItem, { onRecognized } = {}) {
436
537
  this.recognizing();
437
- const type = this.toType(sequenceItem), excess = isNumber(this.maxSequenceLength) ? Math.max(0, this.sequence.length - this.maxSequenceLength) : 0, newSequence = createConcat(createSlice(excess)(this.sequence), [sequenceItem])([]);
538
+ const type = this.toType(sequenceItem), excess = predicateNumber(this.maxSequenceLength) ? Math.max(0, this.sequence.length - this.maxSequenceLength) : 0, newSequence = createConcat(
539
+ createSlice(excess)(this.sequence),
540
+ [sequenceItem]
541
+ )([]);
438
542
  this.effectApi.getSequence = () => newSequence;
439
543
  this.effectApi.onRecognized = onRecognized || (() => {
440
544
  });
441
- this.effects.get(type)?.(sequenceItem, { ...api, ...this.effectApi });
545
+ this.effects.get(type)?.(sequenceItem, { ...this.effectApi });
442
546
  switch (this.status) {
443
547
  case "denied":
444
548
  this.resetComputedMetadata();
@@ -455,7 +559,7 @@ class Recognizeable {
455
559
  this.computedStatus = "recognizing";
456
560
  }
457
561
  toType(sequenceItem) {
458
- if (isArray(sequenceItem)) {
562
+ if (predicateArray(sequenceItem)) {
459
563
  if (sequenceItem[0] instanceof IntersectionObserverEntry) {
460
564
  return "intersect";
461
565
  }
@@ -534,6 +638,9 @@ class Listenable {
534
638
  case "idle":
535
639
  this.idleListen(effect, options);
536
640
  break;
641
+ case "message":
642
+ this.messageListen(effect, options);
643
+ break;
537
644
  case "recognizeable":
538
645
  this.recognizeableListen(effect, options);
539
646
  break;
@@ -564,22 +671,27 @@ class Listenable {
564
671
  }
565
672
  mediaQueryListen(effect, options) {
566
673
  const target = window.matchMedia(this.type);
567
- if (isFunction(options.instantEffect)) {
674
+ if (predicateFunction(options.instantEffect)) {
568
675
  options.instantEffect(target);
569
676
  }
570
- const withApi = (event) => effect(event, {});
677
+ const withApi = (event) => effect(event);
571
678
  target.addEventListener("change", withApi);
572
679
  this.active.add({ target, id: ["change", withApi] });
573
680
  }
574
681
  idleListen(effect, options) {
575
- const { requestIdleCallback } = options, id = window.requestIdleCallback((deadline) => effect(deadline, {}), requestIdleCallback);
682
+ const { requestIdleCallback } = options, id = window.requestIdleCallback((deadline) => effect(deadline), requestIdleCallback);
576
683
  this.active.add({ target: window, id });
577
684
  }
685
+ messageListen(effect, options) {
686
+ const { target = new BroadcastChannel("baleada") } = options;
687
+ target.addEventListener(this.type, (event) => effect(event));
688
+ this.active.add({ target, id: [this.type, effect] });
689
+ }
578
690
  recognizeableListen(effect, options) {
579
- const guardedEffect = (sequenceItem, api) => {
580
- this.recognizeable.recognize(sequenceItem, api, { onRecognized: (sequenceItem2) => effect(sequenceItem2, api) });
691
+ const guardedEffect = (sequenceItem) => {
692
+ this.recognizeable.recognize(sequenceItem, { onRecognized: (sequenceItem2) => effect(sequenceItem2) });
581
693
  if (this.recognizeable.status === "recognized") {
582
- effect(sequenceItem, api);
694
+ effect(sequenceItem);
583
695
  }
584
696
  };
585
697
  for (const type of this.recognizeableEffectsKeys) {
@@ -589,11 +701,11 @@ class Listenable {
589
701
  }
590
702
  }
591
703
  documentEventListen(effect, options) {
592
- const ensuredOptions = {
704
+ const narrowedOptions = {
593
705
  ...options,
594
706
  target: document
595
707
  };
596
- this.eventListen(effect, ensuredOptions);
708
+ this.eventListen(effect, narrowedOptions);
597
709
  }
598
710
  eventListen(effect, options) {
599
711
  const { exceptAndOnlyEffect, effectOptions } = toAddEventListenerParams(this.type, effect, options), eventListeners = [[this.type, exceptAndOnlyEffect, ...effectOptions]];
@@ -642,16 +754,21 @@ function stop(stoppable) {
642
754
  id2.disconnect();
643
755
  return;
644
756
  }
645
- if (isArray(stoppable.id)) {
757
+ if ("target" in stoppable && stoppable.target instanceof MediaQueryList) {
646
758
  const { target: target2, id: id2 } = stoppable;
647
759
  target2.removeEventListener(id2[0], id2[1]);
648
760
  return;
649
761
  }
650
- if (isNumber(stoppable.id)) {
762
+ if (predicateNumber(stoppable.id)) {
651
763
  const { target: target2, id: id2 } = stoppable;
652
764
  target2.cancelIdleCallback(id2);
653
765
  return;
654
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
+ }
655
772
  const { target, id } = stoppable;
656
773
  target.removeEventListener(id[0], id[1], id[2]);
657
774
  }
@@ -683,6 +800,10 @@ const predicatesByImplementation = /* @__PURE__ */ new Map([
683
800
  "idle",
684
801
  (type) => type === "idle"
685
802
  ],
803
+ [
804
+ "message",
805
+ (type) => type === "message" || type === "messageerror"
806
+ ],
686
807
  [
687
808
  "documentevent",
688
809
  (type) => documentEvents.has(type)
@@ -727,7 +848,7 @@ function eventMatchesKeycombo(event, keycombo) {
727
848
  if (index === keycombo.length - 1) {
728
849
  return name.startsWith("!") ? event.key.toLowerCase() !== toModifier(name.slice(1)).toLowerCase() : event.key.toLowerCase() === toModifier(name).toLowerCase();
729
850
  }
730
- return name.startsWith("!") ? !isModified({ event, alias: name.slice(1) }) : isModified({ event, alias: name });
851
+ return name.startsWith("!") ? !predicateModified({ event, alias: name.slice(1) }) : predicateModified({ event, alias: name });
731
852
  }
732
853
  })(keycombo);
733
854
  }
@@ -791,11 +912,11 @@ const predicatesByArrow = /* @__PURE__ */ new Map([
791
912
  const arrows = /* @__PURE__ */ new Set(["arrowup", "arrowright", "arrowdown", "arrowleft"]);
792
913
  const verticalArrows = /* @__PURE__ */ new Set(["arrowup", "arrowdown"]);
793
914
  const horizontalArrows = /* @__PURE__ */ new Set(["arrowright", "arrowleft"]);
794
- function eventMatchesClickcombo(event, clickcombo) {
795
- return every((name) => fromComboItemNameToType(name) === "click" || name.startsWith("!") && !isModified({ alias: name.slice(1), event }) || !name.startsWith("!") && isModified({ alias: name, event }))(clickcombo);
915
+ function eventMatchesMousecombo(event, Mousecombo) {
916
+ return every((name) => fromComboItemNameToType(name) === "click" || name.startsWith("!") && !predicateModified({ alias: name.slice(1), event }) || !name.startsWith("!") && predicateModified({ alias: name, event }))(Mousecombo);
796
917
  }
797
918
  function eventMatchesPointercombo(event, pointercombo) {
798
- return every((name) => fromComboItemNameToType(name) === "pointer" || name.startsWith("!") && !isModified({ alias: name.slice(1), event }) || !name.startsWith("!") && isModified({ alias: name, event }))(pointercombo);
919
+ return every((name) => fromComboItemNameToType(name) === "pointer" || name.startsWith("!") && !predicateModified({ alias: name.slice(1), event }) || !name.startsWith("!") && predicateModified({ alias: name, event }))(pointercombo);
799
920
  }
800
921
  const observerAssertionsByType = {
801
922
  intersect: (observer) => observer instanceof IntersectionObserver,
@@ -803,7 +924,7 @@ const observerAssertionsByType = {
803
924
  resize: (observer) => observer instanceof ResizeObserver
804
925
  };
805
926
 
806
- const defaultOptions$6 = {
927
+ const defaultOptions$7 = {
807
928
  duration: 0,
808
929
  timing: [
809
930
  0,
@@ -831,10 +952,10 @@ class Animateable {
831
952
  getEaseables;
832
953
  getReversedEaseables;
833
954
  constructor(keyframes, options = {}) {
834
- this.initialDuration = options?.duration || defaultOptions$6.duration;
835
- this.controlPoints = fromTimingToControlPoints(options?.timing || defaultOptions$6.timing);
836
- this.iterationLimit = options?.iterations || defaultOptions$6.iterations;
837
- this.alternates = options?.alternates || defaultOptions$6.alternates;
955
+ this.initialDuration = options?.duration || defaultOptions$7.duration;
956
+ this.controlPoints = fromTimingToControlPoints(options?.timing || defaultOptions$7.timing);
957
+ this.iterationLimit = options?.iterations || defaultOptions$7.iterations;
958
+ this.alternates = options?.alternates || defaultOptions$7.alternates;
838
959
  this.reversedControlPoints = fromControlPointsToReversedControlPoints(this.controlPoints);
839
960
  this.toAnimationProgress = createToAnimationProgress(this.controlPoints);
840
961
  this.reversedToAnimationProgress = createToAnimationProgress(this.reversedControlPoints);
@@ -910,7 +1031,10 @@ class Animateable {
910
1031
  setKeyframes(keyframes) {
911
1032
  this.stop();
912
1033
  this.computedKeyframes = Array.from(keyframes).sort(({ progress: progressA }, { progress: progressB }) => progressA - progressB);
913
- this.reversedKeyframes = new Pipeable(this.keyframes).pipe(createReverse(), createMap(({ progress, properties }) => ({ progress: 1 - progress, properties })));
1034
+ this.reversedKeyframes = new Pipeable(this.keyframes).pipe(
1035
+ createReverse(),
1036
+ createMap(({ progress, properties }) => ({ progress: 1 - progress, properties }))
1037
+ );
914
1038
  this.properties = toProperties(this.keyframes);
915
1039
  this.easeables = this.getEaseables({ keyframes: this.keyframes, properties: this.properties });
916
1040
  this.reversedEaseables = this.getReversedEaseables({ keyframes: this.reversedKeyframes, properties: this.properties });
@@ -920,13 +1044,13 @@ class Animateable {
920
1044
  duration;
921
1045
  totalTimeInvisible;
922
1046
  setPlaybackRate(playbackRate) {
923
- const ensuredPlaybackRate = Math.max(0, playbackRate);
924
- this.computedPlaybackRate = ensuredPlaybackRate;
925
- this.duration = 1 / ensuredPlaybackRate * this.initialDuration;
1047
+ const narrowedPlaybackRate = Math.max(0, playbackRate);
1048
+ this.computedPlaybackRate = narrowedPlaybackRate;
1049
+ this.duration = 1 / narrowedPlaybackRate * this.initialDuration;
926
1050
  switch (this.status) {
927
1051
  case "playing":
928
1052
  case "reversing":
929
- this.totalTimeInvisible = 1 / ensuredPlaybackRate * this.totalTimeInvisible;
1053
+ this.totalTimeInvisible = 1 / narrowedPlaybackRate * this.totalTimeInvisible;
930
1054
  this.seek(this.progress.time);
931
1055
  break;
932
1056
  }
@@ -1180,14 +1304,20 @@ class Animateable {
1180
1304
  return this.reversedEaseables;
1181
1305
  }
1182
1306
  })();
1183
- return pipe(filter(({ progress: { start, end } }) => start < naiveTimeProgress && end >= naiveTimeProgress), reduce((frame, { property, progress, value: { previous, next }, toAnimationProgress }) => {
1184
- const timeProgress = (naiveTimeProgress - progress.start) / (progress.end - progress.start), animationProgress = toAnimationProgress(timeProgress);
1185
- frame.properties[property] = {
1186
- progress: { time: timeProgress, animation: animationProgress },
1187
- interpolated: toInterpolated({ previous, next, progress: animationProgress }, interpolateOptions)
1188
- };
1189
- return frame;
1190
- }, { properties: {}, timestamp }))(easeables);
1307
+ return pipe(
1308
+ filter(({ progress: { start, end } }) => start < naiveTimeProgress && end >= naiveTimeProgress),
1309
+ reduce(
1310
+ (frame, { property, progress, value: { previous, next }, toAnimationProgress }) => {
1311
+ const timeProgress = (naiveTimeProgress - progress.start) / (progress.end - progress.start), animationProgress = toAnimationProgress(timeProgress);
1312
+ frame.properties[property] = {
1313
+ progress: { time: timeProgress, animation: animationProgress },
1314
+ interpolated: toInterpolated({ previous, next, progress: animationProgress }, interpolateOptions)
1315
+ };
1316
+ return frame;
1317
+ },
1318
+ { properties: {}, timestamp }
1319
+ )
1320
+ )(easeables);
1191
1321
  }
1192
1322
  recurse(type, timeRemaining, effect, options) {
1193
1323
  switch (type) {
@@ -1309,51 +1439,51 @@ class Animateable {
1309
1439
  seek(timeProgress, options = {}) {
1310
1440
  const iterations = Math.floor(timeProgress), naiveIterationProgress = timeProgress - iterations, { effect: naiveEffect } = options;
1311
1441
  this.computedIterations = iterations;
1312
- let ensuredTimeProgress, effect;
1442
+ let narrowedTimeProgress, effect;
1313
1443
  if (this.alternates) {
1314
1444
  if (naiveIterationProgress <= 0.5) {
1315
- ensuredTimeProgress = naiveIterationProgress * 2;
1445
+ narrowedTimeProgress = naiveIterationProgress * 2;
1316
1446
  switch (this.alternateCache.status) {
1317
1447
  case "playing":
1318
1448
  this.cancelAnimate();
1319
- this.seekCache = { timeProgress: ensuredTimeProgress };
1449
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1320
1450
  this.sought();
1321
- effect = isFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1451
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1322
1452
  this.play(effect, this.playCache.options);
1323
1453
  break;
1324
1454
  case "reversing":
1325
1455
  this.cancelAnimate();
1326
- this.seekCache = { timeProgress: ensuredTimeProgress };
1456
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1327
1457
  this.sought();
1328
- effect = isFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1458
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1329
1459
  this.reverse(effect, this.reverseCache.options);
1330
1460
  break;
1331
1461
  default:
1332
- this.seekCache = { timeProgress: ensuredTimeProgress };
1462
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1333
1463
  this.sought();
1334
1464
  effect = naiveEffect;
1335
1465
  this.createAnimate("seek")(effect, options);
1336
1466
  break;
1337
1467
  }
1338
1468
  } else {
1339
- ensuredTimeProgress = (naiveIterationProgress - 0.5) * 2;
1469
+ narrowedTimeProgress = (naiveIterationProgress - 0.5) * 2;
1340
1470
  switch (this.alternateCache.status) {
1341
1471
  case "playing":
1342
1472
  this.cancelAnimate();
1343
- this.seekCache = { timeProgress: ensuredTimeProgress };
1473
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1344
1474
  this.sought();
1345
- effect = isFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1475
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1346
1476
  this.reverse(effect, this.reverseCache.options);
1347
1477
  break;
1348
1478
  case "reversing":
1349
1479
  this.cancelAnimate();
1350
- this.seekCache = { timeProgress: ensuredTimeProgress };
1480
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1351
1481
  this.sought();
1352
- effect = isFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1482
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1353
1483
  this.play(effect, this.playCache.options);
1354
1484
  break;
1355
1485
  default:
1356
- this.seekCache = { timeProgress: ensuredTimeProgress };
1486
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1357
1487
  this.sought();
1358
1488
  effect = naiveEffect;
1359
1489
  if (effect) {
@@ -1363,24 +1493,24 @@ class Animateable {
1363
1493
  }
1364
1494
  }
1365
1495
  } else {
1366
- ensuredTimeProgress = naiveIterationProgress;
1496
+ narrowedTimeProgress = naiveIterationProgress;
1367
1497
  switch (this.status) {
1368
1498
  case "playing":
1369
1499
  this.cancelAnimate();
1370
- this.seekCache = { timeProgress: ensuredTimeProgress };
1500
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1371
1501
  this.sought();
1372
- effect = isFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1502
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1373
1503
  this.play(effect, this.playCache.options);
1374
1504
  break;
1375
1505
  case "reversing":
1376
1506
  this.cancelAnimate();
1377
- this.seekCache = { timeProgress: ensuredTimeProgress };
1507
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1378
1508
  this.sought();
1379
- effect = isFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1509
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1380
1510
  this.reverse(effect, this.reverseCache.options);
1381
1511
  break;
1382
1512
  default:
1383
- this.seekCache = { timeProgress: ensuredTimeProgress };
1513
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1384
1514
  this.sought();
1385
1515
  effect = naiveEffect;
1386
1516
  if (effect) {
@@ -1444,26 +1574,36 @@ class Animateable {
1444
1574
  }
1445
1575
  function createGetEaseables(fromKeyframeToControlPoints) {
1446
1576
  return ({ properties, keyframes }) => {
1447
- const fromPropertiesToEasables = createReduce((easeables, property) => {
1448
- const propertyKeyframes = createFilter(({ properties: properties2 }) => properties2.hasOwnProperty(property))(keyframes), fromKeyframesToEaseables = createReduce((propertyEaseables2, keyframe, index) => {
1449
- 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 ? (timeProgress) => 1 : createToAnimationProgress(fromKeyframeToControlPoints({ keyframe, index, propertyKeyframes }));
1450
- propertyEaseables2.push({
1577
+ const fromPropertiesToEasables = createReduce(
1578
+ (easeables, property) => {
1579
+ const propertyKeyframes = createFilter(({ properties: properties2 }) => properties2.hasOwnProperty(property))(keyframes), fromKeyframesToEaseables = createReduce(
1580
+ (propertyEaseables2, keyframe, index) => {
1581
+ 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 ? (timeProgress) => 1 : createToAnimationProgress(fromKeyframeToControlPoints({ keyframe, index, propertyKeyframes }));
1582
+ propertyEaseables2.push({
1583
+ property,
1584
+ value: { previous, next },
1585
+ progress: { start, end },
1586
+ hasCustomTiming,
1587
+ toAnimationProgress
1588
+ });
1589
+ return propertyEaseables2;
1590
+ },
1591
+ []
1592
+ ), propertyEaseables = fromKeyframesToEaseables(propertyKeyframes), firstEaseable = {
1451
1593
  property,
1452
- value: { previous, next },
1453
- progress: { start, end },
1454
- hasCustomTiming,
1455
- toAnimationProgress
1456
- });
1457
- return propertyEaseables2;
1458
- }, []), propertyEaseables = fromKeyframesToEaseables(propertyKeyframes), firstEaseable = {
1459
- property,
1460
- value: { previous: propertyEaseables[0].value.previous, next: propertyEaseables[0].value.previous },
1461
- progress: { start: -1, end: propertyEaseables[0].progress.start },
1462
- toAnimationProgress: (timeProgress) => 1,
1463
- hasCustomTiming: false
1464
- };
1465
- return createConcat(easeables, [firstEaseable], propertyEaseables)([]);
1466
- }, []);
1594
+ value: { previous: propertyEaseables[0].value.previous, next: propertyEaseables[0].value.previous },
1595
+ progress: { start: -1, end: propertyEaseables[0].progress.start },
1596
+ toAnimationProgress: (timeProgress) => 1,
1597
+ hasCustomTiming: false
1598
+ };
1599
+ return createConcat(
1600
+ easeables,
1601
+ [firstEaseable],
1602
+ propertyEaseables
1603
+ )([]);
1604
+ },
1605
+ []
1606
+ );
1467
1607
  return fromPropertiesToEasables(properties);
1468
1608
  };
1469
1609
  }
@@ -1496,20 +1636,23 @@ function createToAnimationProgress(points) {
1496
1636
  return BezierEasing(point1x, point1y, point2x, point2y);
1497
1637
  }
1498
1638
  function toInterpolated({ previous, next, progress }, options = {}) {
1499
- if (isUndefined(previous)) {
1639
+ if (predicateUndefined(previous)) {
1500
1640
  return next;
1501
1641
  }
1502
- if (isNumber(previous) && isNumber(next)) {
1642
+ if (predicateNumber(previous) && predicateNumber(next)) {
1503
1643
  return (next - previous) * progress + previous;
1504
1644
  }
1505
- if (isString(previous) && isString(next)) {
1506
- return mix(options.colorModel, {
1507
- start: previous,
1508
- end: next,
1509
- alpha: progress
1510
- }).toRgb().toRgbString();
1645
+ if (predicateString(previous) && predicateString(next)) {
1646
+ return mix(
1647
+ options.colorModel,
1648
+ {
1649
+ start: previous,
1650
+ end: next,
1651
+ alpha: progress
1652
+ }
1653
+ ).toRgb().toRgbString();
1511
1654
  }
1512
- if (isArray(previous) && isArray(next)) {
1655
+ if (predicateArray(previous) && predicateArray(next)) {
1513
1656
  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;
1514
1657
  return createSlice(0, sliceEnd)(sliceTarget);
1515
1658
  }
@@ -1695,6 +1838,78 @@ const easingsNetInOutBack = [
1695
1838
  1.6
1696
1839
  ];
1697
1840
 
1841
+ const defaultOptions$6 = {
1842
+ name: "baleada"
1843
+ };
1844
+ class Broadcastable {
1845
+ name;
1846
+ constructor(state, options = {}) {
1847
+ this.setState(state);
1848
+ this.name = options.name ?? defaultOptions$6.name;
1849
+ this.ready();
1850
+ }
1851
+ computedStatus;
1852
+ ready() {
1853
+ this.computedStatus = "ready";
1854
+ }
1855
+ get state() {
1856
+ return this.computedState;
1857
+ }
1858
+ set state(state) {
1859
+ this.setState(state);
1860
+ }
1861
+ get status() {
1862
+ return this.computedStatus;
1863
+ }
1864
+ computedChannel;
1865
+ get channel() {
1866
+ return this.computedChannel || (this.computedChannel = new BroadcastChannel(this.name));
1867
+ }
1868
+ computedError;
1869
+ get error() {
1870
+ return this.computedError;
1871
+ }
1872
+ computedState;
1873
+ setState(state) {
1874
+ this.computedState = state;
1875
+ return this;
1876
+ }
1877
+ broadcast() {
1878
+ this.broadcasting();
1879
+ try {
1880
+ this.channel.postMessage(this.state);
1881
+ this.broadcasted();
1882
+ } catch (error) {
1883
+ this.computedError = error;
1884
+ this.errored();
1885
+ }
1886
+ return this;
1887
+ }
1888
+ broadcasting() {
1889
+ this.computedStatus = "broadcasting";
1890
+ }
1891
+ broadcasted() {
1892
+ this.computedStatus = "broadcasted";
1893
+ }
1894
+ errored() {
1895
+ this.computedStatus = "errored";
1896
+ }
1897
+ stop() {
1898
+ this.channel.close();
1899
+ this.stopped();
1900
+ return this;
1901
+ }
1902
+ stopped() {
1903
+ this.computedStatus = "stopped";
1904
+ }
1905
+ }
1906
+ function toMessageListenParams(instance, effect) {
1907
+ return [
1908
+ effect,
1909
+ { target: instance.channel }
1910
+ ];
1911
+ }
1912
+
1698
1913
  const defaultOptions$5 = {
1699
1914
  segment: {
1700
1915
  from: "start",
@@ -1743,7 +1958,10 @@ class Completeable {
1743
1958
  return this.computedStatus;
1744
1959
  }
1745
1960
  get segment() {
1746
- return this.string.slice(this.getSegmentStartIndex(), this.getSegmentEndIndex());
1961
+ return this.string.slice(
1962
+ this.getSegmentStartIndex(),
1963
+ this.getSegmentEndIndex()
1964
+ );
1747
1965
  }
1748
1966
  get dividerIndices() {
1749
1967
  return this.computedDividerIndices;
@@ -1800,7 +2018,7 @@ class Completeable {
1800
2018
  complete(completion, options = {}) {
1801
2019
  this.completing();
1802
2020
  const { select } = { ...defaultCompleteOptions, ...options }, before = this.getBefore(), after = this.getAfter(), completedString = before + completion + after, completedSelection = (() => {
1803
- if (isFunction(select)) {
2021
+ if (predicateFunction(select)) {
1804
2022
  return select({ before, completion, after });
1805
2023
  }
1806
2024
  switch (select) {
@@ -1856,7 +2074,12 @@ function toPreviousMatch({ string, re, from }) {
1856
2074
  if (!re.test(string.slice(0, from)) || from === 0) {
1857
2075
  indexOf = -1;
1858
2076
  } else {
1859
- const reversedStringBeforeFrom = new Pipeable(string).pipe((string2) => string2.slice(0, from), (sliced) => sliced.split(""), reverse, toString), toNextMatchIndex = toNextMatch({ string: reversedStringBeforeFrom, re, from: 0 });
2077
+ const reversedStringBeforeFrom = new Pipeable(string).pipe(
2078
+ (string2) => string2.slice(0, from),
2079
+ (sliced) => sliced.split(""),
2080
+ reverse,
2081
+ toString
2082
+ ), toNextMatchIndex = toNextMatch({ string: reversedStringBeforeFrom, re, from: 0 });
1860
2083
  indexOf = toNextMatchIndex === -1 ? -1 : reversedStringBeforeFrom.length - 1 - toNextMatchIndex;
1861
2084
  }
1862
2085
  return indexOf;
@@ -1948,7 +2171,7 @@ class Copyable {
1948
2171
  errored() {
1949
2172
  this.computedStatus = "errored";
1950
2173
  }
1951
- effectClipboardTextChanges() {
2174
+ listenForClipboardEvents() {
1952
2175
  this.copyListenable.listen(this.copyAndCutEffect);
1953
2176
  this.cutListenable.listen(this.copyAndCutEffect);
1954
2177
  }
@@ -1965,13 +2188,16 @@ const defaultOptions$4 = {
1965
2188
  class Delayable {
1966
2189
  animateable;
1967
2190
  constructor(effect, options = {}) {
1968
- this.animateable = new Animateable([
1969
- { progress: 0, properties: { progress: 0 } },
1970
- { progress: 1, properties: { progress: 1 } }
1971
- ], {
1972
- duration: options?.delay ?? defaultOptions$4.delay,
1973
- iterations: options?.executions ?? defaultOptions$4.executions
1974
- });
2191
+ this.animateable = new Animateable(
2192
+ [
2193
+ { progress: 0, properties: { progress: 0 } },
2194
+ { progress: 1, properties: { progress: 1 } }
2195
+ ],
2196
+ {
2197
+ duration: options?.delay ?? defaultOptions$4.delay,
2198
+ iterations: options?.executions ?? defaultOptions$4.executions
2199
+ }
2200
+ );
1975
2201
  this.setEffect(effect);
1976
2202
  this.ready();
1977
2203
  }
@@ -2197,7 +2423,7 @@ class Resolveable {
2197
2423
  this.resolving();
2198
2424
  try {
2199
2425
  const promises = this.getPromise(...args);
2200
- this.computedValue = isArray(promises) ? await createMapAsync(async (promise) => await promise)(promises) : await promises;
2426
+ this.computedValue = predicateArray(promises) ? await createMapAsync(async (promise) => await promise)(promises) : await promises;
2201
2427
  this.resolved();
2202
2428
  } catch (error) {
2203
2429
  this.computedValue = error;
@@ -2258,34 +2484,19 @@ class Fetchable {
2258
2484
  return this.computedError;
2259
2485
  }
2260
2486
  get arrayBuffer() {
2261
- return this.getUsedBody(this.computedArrayBuffer);
2487
+ return this.computedArrayBuffer;
2262
2488
  }
2263
2489
  get blob() {
2264
- return this.getUsedBody(this.computedBlob);
2490
+ return this.computedBlob;
2265
2491
  }
2266
2492
  get formData() {
2267
- return this.getUsedBody(this.computedFormData);
2493
+ return this.computedFormData;
2268
2494
  }
2269
2495
  get json() {
2270
- return this.getUsedBody(this.computedJson);
2496
+ return this.computedJson;
2271
2497
  }
2272
2498
  get text() {
2273
- return this.getUsedBody(this.computedText);
2274
- }
2275
- getUsedBody(resolveable) {
2276
- const bodyUsed = "bodyUsed" in this.response ? this.response.bodyUsed : false;
2277
- if (!bodyUsed) {
2278
- return resolveable.resolve();
2279
- }
2280
- switch (resolveable.status) {
2281
- case "ready":
2282
- break;
2283
- case "resolving":
2284
- break;
2285
- case "resolved":
2286
- case "errored":
2287
- return resolveable;
2288
- }
2499
+ return this.computedText;
2289
2500
  }
2290
2501
  computedResource;
2291
2502
  setResource(resource) {
@@ -2295,34 +2506,49 @@ class Fetchable {
2295
2506
  computedResponse;
2296
2507
  computedError;
2297
2508
  async fetch(options = {}) {
2298
- this.computedStatus = "fetching";
2509
+ this.fetching();
2299
2510
  try {
2300
- this.computedResponse = await fetch(this.resource, { signal: this.abortController.signal, ...ensureOptions(options) });
2301
- this.computedStatus = "fetched";
2511
+ this.computedResponse = await fetch(this.resource, { signal: this.abortController.signal, ...narrowOptions(options) });
2512
+ this.fetched();
2302
2513
  } catch (error) {
2303
2514
  this.computedError = error;
2304
- this.computedStatus = error.name === "AbortError" ? "aborted" : "errored";
2515
+ if (error.name === "AbortError")
2516
+ this.aborted();
2517
+ else
2518
+ this.errored();
2305
2519
  }
2306
2520
  return this;
2307
2521
  }
2522
+ fetching() {
2523
+ this.computedStatus = "fetching";
2524
+ }
2525
+ fetched() {
2526
+ this.computedStatus = "fetched";
2527
+ }
2528
+ aborted() {
2529
+ this.computedStatus = "aborted";
2530
+ }
2531
+ errored() {
2532
+ this.computedStatus = "errored";
2533
+ }
2308
2534
  async get(options = {}) {
2309
- await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "get" });
2535
+ await this.fetch({ signal: this.abortController.signal, ...narrowOptions(options), method: "get" });
2310
2536
  return this;
2311
2537
  }
2312
2538
  async patch(options = {}) {
2313
- await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "patch" });
2539
+ await this.fetch({ signal: this.abortController.signal, ...narrowOptions(options), method: "patch" });
2314
2540
  return this;
2315
2541
  }
2316
2542
  async post(options = {}) {
2317
- await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "post" });
2543
+ await this.fetch({ signal: this.abortController.signal, ...narrowOptions(options), method: "post" });
2318
2544
  return this;
2319
2545
  }
2320
2546
  async put(options = {}) {
2321
- await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "put" });
2547
+ await this.fetch({ signal: this.abortController.signal, ...narrowOptions(options), method: "put" });
2322
2548
  return this;
2323
2549
  }
2324
2550
  async delete(options = {}) {
2325
- await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "delete" });
2551
+ await this.fetch({ signal: this.abortController.signal, ...narrowOptions(options), method: "delete" });
2326
2552
  return this;
2327
2553
  }
2328
2554
  abort() {
@@ -2330,8 +2556,8 @@ class Fetchable {
2330
2556
  return this;
2331
2557
  }
2332
2558
  }
2333
- function ensureOptions(options) {
2334
- return isFunction(options) ? options({ withJson }) : options;
2559
+ function narrowOptions(options) {
2560
+ return predicateFunction(options) ? options({ withJson }) : options;
2335
2561
  }
2336
2562
  function withJson(data) {
2337
2563
  return {
@@ -2514,7 +2740,7 @@ class Navigateable {
2514
2740
  }
2515
2741
  _navigate(location, options = {}) {
2516
2742
  const { allow } = { ...defaultNavigateOptions, ...options };
2517
- const ensuredLocation = (() => {
2743
+ const narrowedLocation = (() => {
2518
2744
  if (allow === "possible") {
2519
2745
  if (location < 0 && allow === "possible") {
2520
2746
  return 0;
@@ -2525,7 +2751,7 @@ class Navigateable {
2525
2751
  }
2526
2752
  return location;
2527
2753
  })();
2528
- this.computedLocation = ensuredLocation;
2754
+ this.computedLocation = narrowedLocation;
2529
2755
  }
2530
2756
  next(options = {}) {
2531
2757
  const { distance, loops } = { ...defaultNextAndPreviousOptions, ...options }, newLocation = (() => {
@@ -2668,38 +2894,50 @@ class Pickable {
2668
2894
  }
2669
2895
  pick(indexOrIndices, options = {}) {
2670
2896
  const { replace, allowsDuplicates } = { ...defaultPickOptions, ...options };
2671
- this.computedPicks = new Pipeable(indexOrIndices).pipe(ensureIndices, this.toPossiblePicks, (possiblePicks) => {
2672
- if (replace === "all") {
2673
- return allowsDuplicates ? possiblePicks : toUnique(possiblePicks);
2674
- }
2675
- const maybeWithoutDuplicates = allowsDuplicates ? possiblePicks : createFilter((possiblePick) => typeof find((pick) => pick === possiblePick)(this.picks || []) !== "number")(possiblePicks);
2676
- switch (replace) {
2677
- case "none":
2678
- return createConcat(this.picks || [], maybeWithoutDuplicates)([]);
2679
- case "fifo":
2680
- if (maybeWithoutDuplicates.length === 0) {
2681
- return this.picks;
2682
- }
2683
- if (maybeWithoutDuplicates.length === this.picks.length) {
2684
- return maybeWithoutDuplicates;
2685
- }
2686
- if (maybeWithoutDuplicates.length > this.picks.length) {
2687
- return createSlice(maybeWithoutDuplicates.length - this.picks.length)(maybeWithoutDuplicates);
2688
- }
2689
- return new Pipeable(this.picks).pipe(createSlice(maybeWithoutDuplicates.length), createConcat(maybeWithoutDuplicates));
2690
- case "lifo":
2691
- if (maybeWithoutDuplicates.length === 0) {
2692
- return this.picks;
2693
- }
2694
- if (maybeWithoutDuplicates.length === this.picks.length) {
2695
- return maybeWithoutDuplicates;
2696
- }
2697
- if (maybeWithoutDuplicates.length > this.picks.length) {
2698
- return createSlice(0, maybeWithoutDuplicates.length - this.picks.length + 1)(maybeWithoutDuplicates);
2699
- }
2700
- return new Pipeable(this.picks).pipe(createSlice(0, this.picks.length - maybeWithoutDuplicates.length), createConcat(maybeWithoutDuplicates));
2897
+ this.computedPicks = new Pipeable(indexOrIndices).pipe(
2898
+ narrowIndices,
2899
+ this.toPossiblePicks,
2900
+ (possiblePicks) => {
2901
+ if (replace === "all") {
2902
+ return allowsDuplicates ? possiblePicks : toUnique(possiblePicks);
2903
+ }
2904
+ const maybeWithoutDuplicates = allowsDuplicates ? possiblePicks : createFilter(
2905
+ (possiblePick) => typeof find((pick) => pick === possiblePick)(this.picks || []) !== "number"
2906
+ )(possiblePicks);
2907
+ switch (replace) {
2908
+ case "none":
2909
+ return createConcat(this.picks || [], maybeWithoutDuplicates)([]);
2910
+ case "fifo":
2911
+ if (maybeWithoutDuplicates.length === 0) {
2912
+ return this.picks;
2913
+ }
2914
+ if (maybeWithoutDuplicates.length === this.picks.length) {
2915
+ return maybeWithoutDuplicates;
2916
+ }
2917
+ if (maybeWithoutDuplicates.length > this.picks.length) {
2918
+ return createSlice(maybeWithoutDuplicates.length - this.picks.length)(maybeWithoutDuplicates);
2919
+ }
2920
+ return new Pipeable(this.picks).pipe(
2921
+ createSlice(maybeWithoutDuplicates.length),
2922
+ createConcat(maybeWithoutDuplicates)
2923
+ );
2924
+ case "lifo":
2925
+ if (maybeWithoutDuplicates.length === 0) {
2926
+ return this.picks;
2927
+ }
2928
+ if (maybeWithoutDuplicates.length === this.picks.length) {
2929
+ return maybeWithoutDuplicates;
2930
+ }
2931
+ if (maybeWithoutDuplicates.length > this.picks.length) {
2932
+ return createSlice(0, maybeWithoutDuplicates.length - this.picks.length + 1)(maybeWithoutDuplicates);
2933
+ }
2934
+ return new Pipeable(this.picks).pipe(
2935
+ createSlice(0, this.picks.length - maybeWithoutDuplicates.length),
2936
+ createConcat(maybeWithoutDuplicates)
2937
+ );
2938
+ }
2701
2939
  }
2702
- });
2940
+ );
2703
2941
  this.computedFirst = Math.min(...this.picks);
2704
2942
  this.computedLast = Math.max(...this.picks);
2705
2943
  this.computedMultiple = toUnique(this.picks).length > 1;
@@ -2710,7 +2948,7 @@ class Pickable {
2710
2948
  this.computedStatus = "picked";
2711
2949
  }
2712
2950
  omit(indexOrIndices, options = { reference: "array" }) {
2713
- if (isUndefined(indexOrIndices)) {
2951
+ if (predicateUndefined(indexOrIndices)) {
2714
2952
  this.computedPicks = [];
2715
2953
  this.computedFirst = void 0;
2716
2954
  this.computedLast = void 0;
@@ -2718,8 +2956,10 @@ class Pickable {
2718
2956
  this.omitted();
2719
2957
  return this;
2720
2958
  }
2721
- const omits = ensureIndices(indexOrIndices);
2722
- this.computedPicks = createFilter((pick, index) => options.reference === "array" ? isUndefined(find((omit) => pick === omit)(omits)) : isUndefined(find((omit) => index === omit)(omits)))(this.computedPicks);
2959
+ const omits = narrowIndices(indexOrIndices);
2960
+ this.computedPicks = createFilter(
2961
+ (pick, index) => options.reference === "array" ? predicateUndefined(find((omit) => pick === omit)(omits)) : predicateUndefined(find((omit) => index === omit)(omits))
2962
+ )(this.computedPicks);
2723
2963
  this.computedFirst = Math.min(...this.picks);
2724
2964
  this.computedLast = Math.max(...this.picks);
2725
2965
  this.computedMultiple = toUnique(this.picks).length > 1;
@@ -2730,7 +2970,7 @@ class Pickable {
2730
2970
  this.computedStatus = "omitted";
2731
2971
  }
2732
2972
  }
2733
- function ensureIndices(indexOrIndices) {
2973
+ function narrowIndices(indexOrIndices) {
2734
2974
  return Array.isArray(indexOrIndices) ? indexOrIndices : [indexOrIndices];
2735
2975
  }
2736
2976
  const toUnique = createUnique();
@@ -2827,6 +3067,60 @@ class Searchable {
2827
3067
  }
2828
3068
  }
2829
3069
 
3070
+ class Shareable {
3071
+ constructor(state, options = {}) {
3072
+ this.setState(state);
3073
+ this.ready();
3074
+ }
3075
+ computedStatus;
3076
+ ready() {
3077
+ this.computedStatus = "ready";
3078
+ }
3079
+ get state() {
3080
+ return this.computedState;
3081
+ }
3082
+ set state(state) {
3083
+ this.setState(state);
3084
+ }
3085
+ get status() {
3086
+ return this.computedStatus;
3087
+ }
3088
+ computedCan;
3089
+ get can() {
3090
+ return this.computedCan;
3091
+ }
3092
+ computedError;
3093
+ get error() {
3094
+ return this.computedError;
3095
+ }
3096
+ computedState;
3097
+ setState(state) {
3098
+ this.computedState = state;
3099
+ this.computedCan = new Resolveable(async () => await navigator.canShare(state));
3100
+ return this;
3101
+ }
3102
+ async share() {
3103
+ this.sharing();
3104
+ try {
3105
+ await navigator.share(this.state);
3106
+ this.shared();
3107
+ } catch (error) {
3108
+ this.computedError = error;
3109
+ this.errored();
3110
+ }
3111
+ return this;
3112
+ }
3113
+ sharing() {
3114
+ this.computedStatus = "sharing";
3115
+ }
3116
+ shared() {
3117
+ this.computedStatus = "shared";
3118
+ }
3119
+ errored() {
3120
+ this.computedStatus = "errored";
3121
+ }
3122
+ }
3123
+
2830
3124
  const defaultOptions = {
2831
3125
  kind: "local",
2832
3126
  statusKeySuffix: " status"
@@ -2848,7 +3142,7 @@ class Storeable {
2848
3142
  ready() {
2849
3143
  this.computedStatus = "ready";
2850
3144
  if (domIsAvailable()) {
2851
- if (isNull(this.storage.getItem(this.computedStatusKey))) {
3145
+ if (predicateNull(this.storage.getItem(this.computedStatusKey))) {
2852
3146
  this.storeStatus();
2853
3147
  }
2854
3148
  }
@@ -2862,7 +3156,7 @@ class Storeable {
2862
3156
  get status() {
2863
3157
  if (domIsAvailable()) {
2864
3158
  const storedStatus = this.storage.getItem(this.computedStatusKey);
2865
- if (this.computedStatus !== storedStatus && isString(storedStatus)) {
3159
+ if (this.computedStatus !== storedStatus && predicateString(storedStatus)) {
2866
3160
  this.computedStatus = storedStatus;
2867
3161
  }
2868
3162
  }
@@ -2948,4 +3242,4 @@ class Storeable {
2948
3242
  }
2949
3243
  }
2950
3244
 
2951
- export { Animateable, Completeable, Copyable, Delayable, Drawable, Fetchable, Fullscreenable, Grantable, Listenable, Navigateable, Pickable, Pipeable, Recognizeable, Resolveable, Sanitizeable, Searchable, Storeable, createClamp, createClip, createConcat, createDelete, createDetermine, createFilter, createFilterAsync, createForEachAsync, createInsert, createMap, createMapAsync, createReduce, createReduceAsync, createRename, createReorder, createReplace, createReverse, createSlice, createSlug, createSort, createSwap, createToEntries, createUnique, easingsNetInBack, easingsNetInCirc, easingsNetInCubic, easingsNetInExpo, easingsNetInOutBack, easingsNetInOutCirc, easingsNetInOutCubic, easingsNetInOutExpo, easingsNetInOutQuad, easingsNetInOutQuint, easingsNetInOutSine, easingsNetInQuad, easingsNetInQuart, easingsNetInQuint, easingsNetInSine, easingsNetOutBack, easingsNetOutCirc, easingsNetOutCubic, easingsNetOutExpo, easingsNetOutQuad, easingsNetOutQuint, easingsNetOutSine, linear, materialAccelerated, materialDecelerated, materialStandard, toD, toFlattenedD, verouEase, verouEaseIn, verouEaseInOut, verouEaseOut };
3245
+ export { Animateable, Broadcastable, Completeable, Copyable, Delayable, Drawable, Fetchable, Fullscreenable, Grantable, Listenable, Navigateable, Pickable, Pipeable, Recognizeable, Resolveable, Sanitizeable, Searchable, Shareable, Storeable, createClamp, createClip, createConcat, createDetermine, createFilter, createFilterAsync, createForEachAsync, createInsert, createMap, createMapAsync, createMatchesKeycombo, createMatchesMousecombo, createMatchesPointercombo, createReduce, createReduceAsync, createRemove, createRename, createReorder, createReplace, createReverse, createSlice, createSlug, createSort, createSwap, createToEntries, createToFocusable, createUnique, easingsNetInBack, easingsNetInCirc, easingsNetInCubic, easingsNetInExpo, easingsNetInOutBack, easingsNetInOutCirc, easingsNetInOutCubic, easingsNetInOutExpo, easingsNetInOutQuad, easingsNetInOutQuint, easingsNetInOutSine, easingsNetInQuad, easingsNetInQuart, easingsNetInQuint, easingsNetInSine, easingsNetOutBack, easingsNetOutCirc, easingsNetOutCubic, easingsNetOutExpo, easingsNetOutQuad, easingsNetOutQuint, easingsNetOutSine, linear, materialAccelerated, materialDecelerated, materialStandard, toD, toFlattenedD, toMessageListenParams, verouEase, verouEaseIn, verouEaseInOut, verouEaseOut };