@baleada/logic 0.22.2 → 0.22.4

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 +392 -148
  2. package/lib/index.d.ts +265 -208
  3. package/lib/index.js +386 -136
  4. package/package.json +20 -20
package/lib/index.cjs CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var lazyCollections = require('lazy-collections');
6
4
  var slugify = require('@sindresorhus/slugify');
7
5
  var BezierEasing = require('bezier-easing');
@@ -11,19 +9,15 @@ var polygonClipping = require('polygon-clipping');
11
9
  var createDOMPurify = require('dompurify');
12
10
  var fastFuzzy = require('fast-fuzzy');
13
11
 
14
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
-
16
- var slugify__default = /*#__PURE__*/_interopDefaultLegacy(slugify);
17
- var BezierEasing__default = /*#__PURE__*/_interopDefaultLegacy(BezierEasing);
18
- var polygonClipping__default = /*#__PURE__*/_interopDefaultLegacy(polygonClipping);
19
- var createDOMPurify__default = /*#__PURE__*/_interopDefaultLegacy(createDOMPurify);
20
-
21
12
  function createReduceAsync(accumulate, initialValue) {
22
13
  return async (array) => {
23
- return await lazyCollections.reduce(async (accumulatorPromise, item, index) => {
24
- const accumulator = await accumulatorPromise;
25
- return accumulate(accumulator, item, index);
26
- }, Promise.resolve(initialValue))(array);
14
+ return await lazyCollections.reduce(
15
+ async (accumulatorPromise, item, index) => {
16
+ const accumulator = await accumulatorPromise;
17
+ return accumulate(accumulator, item, index);
18
+ },
19
+ Promise.resolve(initialValue)
20
+ )(array);
27
21
  };
28
22
  }
29
23
  function createReduce(accumulate, initialValue) {
@@ -37,11 +31,14 @@ function createForEachAsync(forEach) {
37
31
  }
38
32
  function createMapAsync(transform) {
39
33
  return async (array) => {
40
- return await createReduceAsync(async (resolvedMaps, item, index) => {
41
- const transformed = await transform(item, index);
42
- resolvedMaps.push(transformed);
43
- return resolvedMaps;
44
- }, [])(array);
34
+ return await createReduceAsync(
35
+ async (resolvedMaps, item, index) => {
36
+ const transformed = await transform(item, index);
37
+ resolvedMaps.push(transformed);
38
+ return resolvedMaps;
39
+ },
40
+ []
41
+ )(array);
45
42
  };
46
43
  }
47
44
  function createFilterAsync(condition) {
@@ -52,13 +49,19 @@ function createFilterAsync(condition) {
52
49
  }
53
50
  function createDelete(index) {
54
51
  return (array) => {
55
- return createConcat(createSlice(0, index)(array), createSlice(index + 1)(array))([]);
52
+ return createConcat(
53
+ createSlice(0, index)(array),
54
+ createSlice(index + 1)(array)
55
+ )([]);
56
56
  };
57
57
  }
58
58
  function createInsert(item, index) {
59
59
  return (array) => {
60
60
  const withItems = createConcat(array, [item])([]);
61
- return createReorder({ start: array.length, itemCount: 1 }, index)(withItems);
61
+ return createReorder(
62
+ { start: array.length, itemCount: 1 },
63
+ index
64
+ )(withItems);
62
65
  };
63
66
  }
64
67
  function createReorder(from, to) {
@@ -70,11 +73,21 @@ function createReorder(from, to) {
70
73
  const itemsToMove = createSlice(itemsToMoveStartIndex, itemsToMoveStartIndex + itemsToMoveCount)(array);
71
74
  if (itemsToMoveStartIndex < insertIndex) {
72
75
  const beforeItemsToMove = itemsToMoveStartIndex === 0 ? [] : createSlice(0, itemsToMoveStartIndex)(array), betweenItemsToMoveAndInsertIndex = createSlice(itemsToMoveStartIndex + itemsToMoveCount, insertIndex + 1)(array), afterInsertIndex = createSlice(insertIndex + 1)(array);
73
- return createConcat(beforeItemsToMove, betweenItemsToMoveAndInsertIndex, itemsToMove, afterInsertIndex)([]);
76
+ return createConcat(
77
+ beforeItemsToMove,
78
+ betweenItemsToMoveAndInsertIndex,
79
+ itemsToMove,
80
+ afterInsertIndex
81
+ )([]);
74
82
  }
75
83
  if (itemsToMoveStartIndex > insertIndex) {
76
84
  const beforeInsertion = insertIndex === 0 ? [] : createSlice(0, insertIndex)(array), betweenInsertionAndItemsToMove = createSlice(insertIndex, itemsToMoveStartIndex)(array), afterItemsToMove = createSlice(itemsToMoveStartIndex + itemsToMoveCount)(array);
77
- return createConcat(beforeInsertion, itemsToMove, betweenInsertionAndItemsToMove, afterItemsToMove)([]);
85
+ return createConcat(
86
+ beforeInsertion,
87
+ itemsToMove,
88
+ betweenInsertionAndItemsToMove,
89
+ afterItemsToMove
90
+ )([]);
78
91
  }
79
92
  return array;
80
93
  };
@@ -107,25 +120,44 @@ function createSwap(indices) {
107
120
  }
108
121
  function createReplace(index, item) {
109
122
  return (array) => {
110
- return createConcat(createSlice(0, index)(array), [item], createSlice(index + 1)(array))([]);
123
+ return createConcat(
124
+ createSlice(0, index)(array),
125
+ [item],
126
+ createSlice(index + 1)(array)
127
+ )([]);
111
128
  };
112
129
  }
113
130
  function createUnique() {
114
- return (array) => lazyCollections.pipe(lazyCollections.unique(), lazyCollections.toArray())(array);
131
+ return (array) => lazyCollections.pipe(
132
+ lazyCollections.unique(),
133
+ lazyCollections.toArray()
134
+ )(array);
115
135
  }
116
136
  function createSlice(from, to) {
117
137
  return (array) => {
118
- return from === to ? [] : lazyCollections.pipe(lazyCollections.slice(from, to - 1), lazyCollections.toArray())(array);
138
+ return from === to ? [] : lazyCollections.pipe(
139
+ lazyCollections.slice(from, to - 1),
140
+ lazyCollections.toArray()
141
+ )(array);
119
142
  };
120
143
  }
121
144
  function createFilter(condition) {
122
- return (array) => lazyCollections.pipe(lazyCollections.filter(condition), lazyCollections.toArray())(array);
145
+ return (array) => lazyCollections.pipe(
146
+ lazyCollections.filter(condition),
147
+ lazyCollections.toArray()
148
+ )(array);
123
149
  }
124
150
  function createMap(transform) {
125
- return (array) => lazyCollections.pipe(lazyCollections.map(transform), lazyCollections.toArray())(array);
151
+ return (array) => lazyCollections.pipe(
152
+ lazyCollections.map(transform),
153
+ lazyCollections.toArray()
154
+ )(array);
126
155
  }
127
156
  function createConcat(...arrays) {
128
- return (array) => lazyCollections.pipe(lazyCollections.concat(array, ...arrays), lazyCollections.toArray())();
157
+ return (array) => lazyCollections.pipe(
158
+ lazyCollections.concat(array, ...arrays),
159
+ lazyCollections.toArray()
160
+ )();
129
161
  }
130
162
  function createReverse() {
131
163
  return (array) => {
@@ -138,12 +170,15 @@ function createReverse() {
138
170
  }
139
171
  function createSort(compare) {
140
172
  return (array) => {
141
- return new Pipeable(array).pipe(createSlice(0), (sliced) => sliced.sort(compare));
173
+ return new Pipeable(array).pipe(
174
+ createSlice(0),
175
+ (sliced) => compare ? sliced.sort(compare) : sliced.sort()
176
+ );
142
177
  };
143
178
  }
144
179
  function createSlug(options) {
145
180
  return (string) => {
146
- return slugify__default["default"](string, options);
181
+ return slugify(string, options);
147
182
  };
148
183
  }
149
184
  function createClip(required) {
@@ -159,7 +194,10 @@ function createClamp(min, max) {
159
194
  }
160
195
  function createDetermine(potentialities) {
161
196
  const predicates = createMap(({ outcome, probability }, index) => {
162
- const lowerBound = index === 0 ? 0 : lazyCollections.pipe(lazyCollections.slice(0, index - 1), lazyCollections.reduce((lowerBound2, { probability: probability2 }) => lowerBound2 + probability2, 0))(potentialities), upperBound = lowerBound + probability;
197
+ const lowerBound = index === 0 ? 0 : lazyCollections.pipe(
198
+ lazyCollections.slice(0, index - 1),
199
+ lazyCollections.reduce((lowerBound2, { probability: probability2 }) => lowerBound2 + probability2, 0)
200
+ )(potentialities), upperBound = lowerBound + probability;
163
201
  return {
164
202
  outcome,
165
203
  predicate: (determinant) => determinant >= lowerBound && determinant < upperBound || determinant < 0 && index === 0 || index === predicates.length - 1
@@ -190,7 +228,10 @@ class Pipeable {
190
228
  return createReduce((piped, fn, index) => fn(piped, index), this.state)(fns);
191
229
  }
192
230
  async pipeAsync(...fns) {
193
- return await createReduceAsync(async (piped, fn, index) => await fn(piped, index), this.state)(fns);
231
+ return await createReduceAsync(
232
+ async (piped, fn, index) => await fn(piped, index),
233
+ this.state
234
+ )(fns);
194
235
  }
195
236
  }
196
237
 
@@ -247,7 +288,10 @@ const keysByName = {
247
288
  };
248
289
  const toListenableKeycomboItems = createMap((name) => ({ name, type: fromComboItemNameToType(name) }));
249
290
  function ensureKeycombo(type) {
250
- return new Pipeable(type).pipe(toCombo, toListenableKeycomboItems);
291
+ return new Pipeable(type).pipe(
292
+ toCombo,
293
+ toListenableKeycomboItems
294
+ );
251
295
  }
252
296
  function ensureClickcombo(type) {
253
297
  return toCombo(type);
@@ -259,7 +303,11 @@ const toUnique$1 = lazyCollections.unique();
259
303
  const toComboItems = lazyCollections.map((name) => name === "" ? delimiter : name);
260
304
  const delimiter = "+";
261
305
  function toCombo(type) {
262
- return lazyCollections.pipe(toUnique$1, toComboItems, lazyCollections.toArray())(type.split(delimiter));
306
+ return lazyCollections.pipe(
307
+ toUnique$1,
308
+ toComboItems,
309
+ lazyCollections.toArray()
310
+ )(type.split(delimiter));
263
311
  }
264
312
  function fromComboItemNameToType(name) {
265
313
  return lazyCollections.find((type) => predicatesByType[type](name))(listenableComboItemTypes) ?? "custom";
@@ -296,7 +344,7 @@ function createExceptAndOnlyEffect(type, effect, options) {
296
344
  if (type === "keydown" || type === "keyup") {
297
345
  return (event) => {
298
346
  const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true], api = {
299
- is: (keycombo) => eventMatchesKeycombo(event, ensureKeycombo(keycombo))
347
+ matches: (keycombo) => eventMatchesKeycombo(event, ensureKeycombo(keycombo))
300
348
  };
301
349
  if (matchesOnly) {
302
350
  effect(event, api);
@@ -308,10 +356,10 @@ function createExceptAndOnlyEffect(type, effect, options) {
308
356
  }
309
357
  };
310
358
  }
311
- if (type === "click" || type === "mousedown" || type === "mouseup" || type === "dblclick" || type === "contextmenu") {
359
+ if (type === "click" || type === "dblclick" || type === "contextmenu" || type.startsWith("mouse")) {
312
360
  return (event) => {
313
361
  const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true], api = {
314
- is: (clickcombo) => eventMatchesClickcombo(event, ensureClickcombo(clickcombo))
362
+ matches: (clickcombo) => eventMatchesClickcombo(event, ensureClickcombo(clickcombo))
315
363
  };
316
364
  if (matchesOnly) {
317
365
  effect(event, api);
@@ -323,10 +371,10 @@ function createExceptAndOnlyEffect(type, effect, options) {
323
371
  }
324
372
  };
325
373
  }
326
- if (type === "pointerdown" || type === "pointerup") {
374
+ if (type.startsWith("pointer")) {
327
375
  return (event) => {
328
376
  const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true], api = {
329
- is: (pointercombo) => eventMatchesPointercombo(event, ensurePointercombo(pointercombo))
377
+ matches: (pointercombo) => eventMatchesPointercombo(event, ensurePointercombo(pointercombo))
330
378
  };
331
379
  if (matchesOnly) {
332
380
  effect(event, api);
@@ -445,7 +493,10 @@ class Recognizeable {
445
493
  }
446
494
  recognize(sequenceItem, api, { onRecognized } = {}) {
447
495
  this.recognizing();
448
- 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])([]);
496
+ const type = this.toType(sequenceItem), excess = isNumber(this.maxSequenceLength) ? Math.max(0, this.sequence.length - this.maxSequenceLength) : 0, newSequence = createConcat(
497
+ createSlice(excess)(this.sequence),
498
+ [sequenceItem]
499
+ )([]);
449
500
  this.effectApi.getSequence = () => newSequence;
450
501
  this.effectApi.onRecognized = onRecognized || (() => {
451
502
  });
@@ -545,6 +596,9 @@ class Listenable {
545
596
  case "idle":
546
597
  this.idleListen(effect, options);
547
598
  break;
599
+ case "message":
600
+ this.messageListen(effect, options);
601
+ break;
548
602
  case "recognizeable":
549
603
  this.recognizeableListen(effect, options);
550
604
  break;
@@ -586,6 +640,11 @@ class Listenable {
586
640
  const { requestIdleCallback } = options, id = window.requestIdleCallback((deadline) => effect(deadline, {}), requestIdleCallback);
587
641
  this.active.add({ target: window, id });
588
642
  }
643
+ messageListen(effect, options) {
644
+ const { target = new BroadcastChannel("baleada") } = options;
645
+ target.addEventListener(this.type, (event) => effect(event, {}));
646
+ this.active.add({ target, id: [this.type, effect] });
647
+ }
589
648
  recognizeableListen(effect, options) {
590
649
  const guardedEffect = (sequenceItem, api) => {
591
650
  this.recognizeable.recognize(sequenceItem, api, { onRecognized: (sequenceItem2) => effect(sequenceItem2, api) });
@@ -653,7 +712,7 @@ function stop(stoppable) {
653
712
  id2.disconnect();
654
713
  return;
655
714
  }
656
- if (isArray(stoppable.id)) {
715
+ if ("target" in stoppable && stoppable.target instanceof MediaQueryList) {
657
716
  const { target: target2, id: id2 } = stoppable;
658
717
  target2.removeEventListener(id2[0], id2[1]);
659
718
  return;
@@ -663,6 +722,11 @@ function stop(stoppable) {
663
722
  target2.cancelIdleCallback(id2);
664
723
  return;
665
724
  }
725
+ if ("target" in stoppable && stoppable.target instanceof BroadcastChannel) {
726
+ const { target: target2, id: id2 } = stoppable;
727
+ target2.removeEventListener(id2[0], id2[1]);
728
+ return;
729
+ }
666
730
  const { target, id } = stoppable;
667
731
  target.removeEventListener(id[0], id[1], id[2]);
668
732
  }
@@ -694,6 +758,10 @@ const predicatesByImplementation = /* @__PURE__ */ new Map([
694
758
  "idle",
695
759
  (type) => type === "idle"
696
760
  ],
761
+ [
762
+ "message",
763
+ (type) => type === "message" || type === "messageerror"
764
+ ],
697
765
  [
698
766
  "documentevent",
699
767
  (type) => documentEvents.has(type)
@@ -814,7 +882,7 @@ const observerAssertionsByType = {
814
882
  resize: (observer) => observer instanceof ResizeObserver
815
883
  };
816
884
 
817
- const defaultOptions$6 = {
885
+ const defaultOptions$7 = {
818
886
  duration: 0,
819
887
  timing: [
820
888
  0,
@@ -842,10 +910,10 @@ class Animateable {
842
910
  getEaseables;
843
911
  getReversedEaseables;
844
912
  constructor(keyframes, options = {}) {
845
- this.initialDuration = options?.duration || defaultOptions$6.duration;
846
- this.controlPoints = fromTimingToControlPoints(options?.timing || defaultOptions$6.timing);
847
- this.iterationLimit = options?.iterations || defaultOptions$6.iterations;
848
- this.alternates = options?.alternates || defaultOptions$6.alternates;
913
+ this.initialDuration = options?.duration || defaultOptions$7.duration;
914
+ this.controlPoints = fromTimingToControlPoints(options?.timing || defaultOptions$7.timing);
915
+ this.iterationLimit = options?.iterations || defaultOptions$7.iterations;
916
+ this.alternates = options?.alternates || defaultOptions$7.alternates;
849
917
  this.reversedControlPoints = fromControlPointsToReversedControlPoints(this.controlPoints);
850
918
  this.toAnimationProgress = createToAnimationProgress(this.controlPoints);
851
919
  this.reversedToAnimationProgress = createToAnimationProgress(this.reversedControlPoints);
@@ -921,7 +989,10 @@ class Animateable {
921
989
  setKeyframes(keyframes) {
922
990
  this.stop();
923
991
  this.computedKeyframes = Array.from(keyframes).sort(({ progress: progressA }, { progress: progressB }) => progressA - progressB);
924
- this.reversedKeyframes = new Pipeable(this.keyframes).pipe(createReverse(), createMap(({ progress, properties }) => ({ progress: 1 - progress, properties })));
992
+ this.reversedKeyframes = new Pipeable(this.keyframes).pipe(
993
+ createReverse(),
994
+ createMap(({ progress, properties }) => ({ progress: 1 - progress, properties }))
995
+ );
925
996
  this.properties = toProperties(this.keyframes);
926
997
  this.easeables = this.getEaseables({ keyframes: this.keyframes, properties: this.properties });
927
998
  this.reversedEaseables = this.getReversedEaseables({ keyframes: this.reversedKeyframes, properties: this.properties });
@@ -1191,14 +1262,20 @@ class Animateable {
1191
1262
  return this.reversedEaseables;
1192
1263
  }
1193
1264
  })();
1194
- return lazyCollections.pipe(lazyCollections.filter(({ progress: { start, end } }) => start < naiveTimeProgress && end >= naiveTimeProgress), lazyCollections.reduce((frame, { property, progress, value: { previous, next }, toAnimationProgress }) => {
1195
- const timeProgress = (naiveTimeProgress - progress.start) / (progress.end - progress.start), animationProgress = toAnimationProgress(timeProgress);
1196
- frame.properties[property] = {
1197
- progress: { time: timeProgress, animation: animationProgress },
1198
- interpolated: toInterpolated({ previous, next, progress: animationProgress }, interpolateOptions)
1199
- };
1200
- return frame;
1201
- }, { properties: {}, timestamp }))(easeables);
1265
+ return lazyCollections.pipe(
1266
+ lazyCollections.filter(({ progress: { start, end } }) => start < naiveTimeProgress && end >= naiveTimeProgress),
1267
+ lazyCollections.reduce(
1268
+ (frame, { property, progress, value: { previous, next }, toAnimationProgress }) => {
1269
+ const timeProgress = (naiveTimeProgress - progress.start) / (progress.end - progress.start), animationProgress = toAnimationProgress(timeProgress);
1270
+ frame.properties[property] = {
1271
+ progress: { time: timeProgress, animation: animationProgress },
1272
+ interpolated: toInterpolated({ previous, next, progress: animationProgress }, interpolateOptions)
1273
+ };
1274
+ return frame;
1275
+ },
1276
+ { properties: {}, timestamp }
1277
+ )
1278
+ )(easeables);
1202
1279
  }
1203
1280
  recurse(type, timeRemaining, effect, options) {
1204
1281
  switch (type) {
@@ -1455,26 +1532,36 @@ class Animateable {
1455
1532
  }
1456
1533
  function createGetEaseables(fromKeyframeToControlPoints) {
1457
1534
  return ({ properties, keyframes }) => {
1458
- const fromPropertiesToEasables = createReduce((easeables, property) => {
1459
- const propertyKeyframes = createFilter(({ properties: properties2 }) => properties2.hasOwnProperty(property))(keyframes), fromKeyframesToEaseables = createReduce((propertyEaseables2, keyframe, index) => {
1460
- 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 }));
1461
- propertyEaseables2.push({
1535
+ const fromPropertiesToEasables = createReduce(
1536
+ (easeables, property) => {
1537
+ const propertyKeyframes = createFilter(({ properties: properties2 }) => properties2.hasOwnProperty(property))(keyframes), fromKeyframesToEaseables = createReduce(
1538
+ (propertyEaseables2, keyframe, index) => {
1539
+ 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 }));
1540
+ propertyEaseables2.push({
1541
+ property,
1542
+ value: { previous, next },
1543
+ progress: { start, end },
1544
+ hasCustomTiming,
1545
+ toAnimationProgress
1546
+ });
1547
+ return propertyEaseables2;
1548
+ },
1549
+ []
1550
+ ), propertyEaseables = fromKeyframesToEaseables(propertyKeyframes), firstEaseable = {
1462
1551
  property,
1463
- value: { previous, next },
1464
- progress: { start, end },
1465
- hasCustomTiming,
1466
- toAnimationProgress
1467
- });
1468
- return propertyEaseables2;
1469
- }, []), propertyEaseables = fromKeyframesToEaseables(propertyKeyframes), firstEaseable = {
1470
- property,
1471
- value: { previous: propertyEaseables[0].value.previous, next: propertyEaseables[0].value.previous },
1472
- progress: { start: -1, end: propertyEaseables[0].progress.start },
1473
- toAnimationProgress: (timeProgress) => 1,
1474
- hasCustomTiming: false
1475
- };
1476
- return createConcat(easeables, [firstEaseable], propertyEaseables)([]);
1477
- }, []);
1552
+ value: { previous: propertyEaseables[0].value.previous, next: propertyEaseables[0].value.previous },
1553
+ progress: { start: -1, end: propertyEaseables[0].progress.start },
1554
+ toAnimationProgress: (timeProgress) => 1,
1555
+ hasCustomTiming: false
1556
+ };
1557
+ return createConcat(
1558
+ easeables,
1559
+ [firstEaseable],
1560
+ propertyEaseables
1561
+ )([]);
1562
+ },
1563
+ []
1564
+ );
1478
1565
  return fromPropertiesToEasables(properties);
1479
1566
  };
1480
1567
  }
@@ -1504,7 +1591,7 @@ function fromControlPointsToReversedControlPoints(points) {
1504
1591
  }
1505
1592
  function createToAnimationProgress(points) {
1506
1593
  const { 0: { x: point1x, y: point1y }, 1: { x: point2x, y: point2y } } = points;
1507
- return BezierEasing__default["default"](point1x, point1y, point2x, point2y);
1594
+ return BezierEasing(point1x, point1y, point2x, point2y);
1508
1595
  }
1509
1596
  function toInterpolated({ previous, next, progress }, options = {}) {
1510
1597
  if (isUndefined(previous)) {
@@ -1514,11 +1601,14 @@ function toInterpolated({ previous, next, progress }, options = {}) {
1514
1601
  return (next - previous) * progress + previous;
1515
1602
  }
1516
1603
  if (isString(previous) && isString(next)) {
1517
- return color.mix(options.colorModel, {
1518
- start: previous,
1519
- end: next,
1520
- alpha: progress
1521
- }).toRgb().toRgbString();
1604
+ return color.mix(
1605
+ options.colorModel,
1606
+ {
1607
+ start: previous,
1608
+ end: next,
1609
+ alpha: progress
1610
+ }
1611
+ ).toRgb().toRgbString();
1522
1612
  }
1523
1613
  if (isArray(previous) && isArray(next)) {
1524
1614
  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;
@@ -1706,6 +1796,78 @@ const easingsNetInOutBack = [
1706
1796
  1.6
1707
1797
  ];
1708
1798
 
1799
+ const defaultOptions$6 = {
1800
+ name: "baleada"
1801
+ };
1802
+ class Broadcastable {
1803
+ name;
1804
+ constructor(state, options = {}) {
1805
+ this.setState(state);
1806
+ this.name = options.name ?? defaultOptions$6.name;
1807
+ this.ready();
1808
+ }
1809
+ computedStatus;
1810
+ ready() {
1811
+ this.computedStatus = "ready";
1812
+ }
1813
+ get state() {
1814
+ return this.computedState;
1815
+ }
1816
+ set state(state) {
1817
+ this.setState(state);
1818
+ }
1819
+ get status() {
1820
+ return this.computedStatus;
1821
+ }
1822
+ computedChannel;
1823
+ get channel() {
1824
+ return this.computedChannel || (this.computedChannel = new BroadcastChannel(this.name));
1825
+ }
1826
+ computedError;
1827
+ get error() {
1828
+ return this.computedError;
1829
+ }
1830
+ computedState;
1831
+ setState(state) {
1832
+ this.computedState = state;
1833
+ return this;
1834
+ }
1835
+ broadcast() {
1836
+ this.broadcasting();
1837
+ try {
1838
+ this.channel.postMessage(this.state);
1839
+ this.broadcasted();
1840
+ } catch (error) {
1841
+ this.computedError = error;
1842
+ this.errored();
1843
+ }
1844
+ return this;
1845
+ }
1846
+ broadcasting() {
1847
+ this.computedStatus = "broadcasting";
1848
+ }
1849
+ broadcasted() {
1850
+ this.computedStatus = "broadcasted";
1851
+ }
1852
+ errored() {
1853
+ this.computedStatus = "errored";
1854
+ }
1855
+ stop() {
1856
+ this.channel.close();
1857
+ this.stopped();
1858
+ return this;
1859
+ }
1860
+ stopped() {
1861
+ this.computedStatus = "stopped";
1862
+ }
1863
+ }
1864
+ function toMessageListenParams(instance, effect) {
1865
+ return [
1866
+ effect,
1867
+ { target: instance.channel }
1868
+ ];
1869
+ }
1870
+
1709
1871
  const defaultOptions$5 = {
1710
1872
  segment: {
1711
1873
  from: "start",
@@ -1754,7 +1916,10 @@ class Completeable {
1754
1916
  return this.computedStatus;
1755
1917
  }
1756
1918
  get segment() {
1757
- return this.string.slice(this.getSegmentStartIndex(), this.getSegmentEndIndex());
1919
+ return this.string.slice(
1920
+ this.getSegmentStartIndex(),
1921
+ this.getSegmentEndIndex()
1922
+ );
1758
1923
  }
1759
1924
  get dividerIndices() {
1760
1925
  return this.computedDividerIndices;
@@ -1867,7 +2032,12 @@ function toPreviousMatch({ string, re, from }) {
1867
2032
  if (!re.test(string.slice(0, from)) || from === 0) {
1868
2033
  indexOf = -1;
1869
2034
  } else {
1870
- const reversedStringBeforeFrom = new Pipeable(string).pipe((string2) => string2.slice(0, from), (sliced) => sliced.split(""), reverse, toString), toNextMatchIndex = toNextMatch({ string: reversedStringBeforeFrom, re, from: 0 });
2035
+ const reversedStringBeforeFrom = new Pipeable(string).pipe(
2036
+ (string2) => string2.slice(0, from),
2037
+ (sliced) => sliced.split(""),
2038
+ reverse,
2039
+ toString
2040
+ ), toNextMatchIndex = toNextMatch({ string: reversedStringBeforeFrom, re, from: 0 });
1871
2041
  indexOf = toNextMatchIndex === -1 ? -1 : reversedStringBeforeFrom.length - 1 - toNextMatchIndex;
1872
2042
  }
1873
2043
  return indexOf;
@@ -1959,7 +2129,7 @@ class Copyable {
1959
2129
  errored() {
1960
2130
  this.computedStatus = "errored";
1961
2131
  }
1962
- effectClipboardTextChanges() {
2132
+ listenForClipboardEvents() {
1963
2133
  this.copyListenable.listen(this.copyAndCutEffect);
1964
2134
  this.cutListenable.listen(this.copyAndCutEffect);
1965
2135
  }
@@ -1976,13 +2146,16 @@ const defaultOptions$4 = {
1976
2146
  class Delayable {
1977
2147
  animateable;
1978
2148
  constructor(effect, options = {}) {
1979
- this.animateable = new Animateable([
1980
- { progress: 0, properties: { progress: 0 } },
1981
- { progress: 1, properties: { progress: 1 } }
1982
- ], {
1983
- duration: options?.delay ?? defaultOptions$4.delay,
1984
- iterations: options?.executions ?? defaultOptions$4.executions
1985
- });
2149
+ this.animateable = new Animateable(
2150
+ [
2151
+ { progress: 0, properties: { progress: 0 } },
2152
+ { progress: 1, properties: { progress: 1 } }
2153
+ ],
2154
+ {
2155
+ duration: options?.delay ?? defaultOptions$4.delay,
2156
+ iterations: options?.executions ?? defaultOptions$4.executions
2157
+ }
2158
+ );
1986
2159
  this.setEffect(effect);
1987
2160
  this.ready();
1988
2161
  }
@@ -2169,7 +2342,7 @@ function toFlattenedD(stroke) {
2169
2342
  if (stroke.length === 0) {
2170
2343
  return "";
2171
2344
  }
2172
- const multiPolygon = polygonClipping__default["default"].union([stroke]);
2345
+ const multiPolygon = polygonClipping.union([stroke]);
2173
2346
  return createReduce((dFromMultiPolygon, polygon) => {
2174
2347
  return dFromMultiPolygon + createReduce((dFromRing, points) => {
2175
2348
  return dFromRing + toD(points);
@@ -2269,34 +2442,19 @@ class Fetchable {
2269
2442
  return this.computedError;
2270
2443
  }
2271
2444
  get arrayBuffer() {
2272
- return this.getUsedBody(this.computedArrayBuffer);
2445
+ return this.computedArrayBuffer;
2273
2446
  }
2274
2447
  get blob() {
2275
- return this.getUsedBody(this.computedBlob);
2448
+ return this.computedBlob;
2276
2449
  }
2277
2450
  get formData() {
2278
- return this.getUsedBody(this.computedFormData);
2451
+ return this.computedFormData;
2279
2452
  }
2280
2453
  get json() {
2281
- return this.getUsedBody(this.computedJson);
2454
+ return this.computedJson;
2282
2455
  }
2283
2456
  get text() {
2284
- return this.getUsedBody(this.computedText);
2285
- }
2286
- getUsedBody(resolveable) {
2287
- const bodyUsed = "bodyUsed" in this.response ? this.response.bodyUsed : false;
2288
- if (!bodyUsed) {
2289
- return resolveable.resolve();
2290
- }
2291
- switch (resolveable.status) {
2292
- case "ready":
2293
- break;
2294
- case "resolving":
2295
- break;
2296
- case "resolved":
2297
- case "errored":
2298
- return resolveable;
2299
- }
2457
+ return this.computedText;
2300
2458
  }
2301
2459
  computedResource;
2302
2460
  setResource(resource) {
@@ -2306,16 +2464,31 @@ class Fetchable {
2306
2464
  computedResponse;
2307
2465
  computedError;
2308
2466
  async fetch(options = {}) {
2309
- this.computedStatus = "fetching";
2467
+ this.fetching();
2310
2468
  try {
2311
2469
  this.computedResponse = await fetch(this.resource, { signal: this.abortController.signal, ...ensureOptions(options) });
2312
- this.computedStatus = "fetched";
2470
+ this.fetched();
2313
2471
  } catch (error) {
2314
2472
  this.computedError = error;
2315
- this.computedStatus = error.name === "AbortError" ? "aborted" : "errored";
2473
+ if (error.name === "AbortError")
2474
+ this.aborted();
2475
+ else
2476
+ this.errored();
2316
2477
  }
2317
2478
  return this;
2318
2479
  }
2480
+ fetching() {
2481
+ this.computedStatus = "fetching";
2482
+ }
2483
+ fetched() {
2484
+ this.computedStatus = "fetched";
2485
+ }
2486
+ aborted() {
2487
+ this.computedStatus = "aborted";
2488
+ }
2489
+ errored() {
2490
+ this.computedStatus = "errored";
2491
+ }
2319
2492
  async get(options = {}) {
2320
2493
  await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "get" });
2321
2494
  return this;
@@ -2679,38 +2852,50 @@ class Pickable {
2679
2852
  }
2680
2853
  pick(indexOrIndices, options = {}) {
2681
2854
  const { replace, allowsDuplicates } = { ...defaultPickOptions, ...options };
2682
- this.computedPicks = new Pipeable(indexOrIndices).pipe(ensureIndices, this.toPossiblePicks, (possiblePicks) => {
2683
- if (replace === "all") {
2684
- return allowsDuplicates ? possiblePicks : toUnique(possiblePicks);
2685
- }
2686
- const maybeWithoutDuplicates = allowsDuplicates ? possiblePicks : createFilter((possiblePick) => typeof lazyCollections.find((pick) => pick === possiblePick)(this.picks || []) !== "number")(possiblePicks);
2687
- switch (replace) {
2688
- case "none":
2689
- return createConcat(this.picks || [], maybeWithoutDuplicates)([]);
2690
- case "fifo":
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(maybeWithoutDuplicates.length - this.picks.length)(maybeWithoutDuplicates);
2699
- }
2700
- return new Pipeable(this.picks).pipe(createSlice(maybeWithoutDuplicates.length), createConcat(maybeWithoutDuplicates));
2701
- case "lifo":
2702
- if (maybeWithoutDuplicates.length === 0) {
2703
- return this.picks;
2704
- }
2705
- if (maybeWithoutDuplicates.length === this.picks.length) {
2706
- return maybeWithoutDuplicates;
2707
- }
2708
- if (maybeWithoutDuplicates.length > this.picks.length) {
2709
- return createSlice(0, maybeWithoutDuplicates.length - this.picks.length + 1)(maybeWithoutDuplicates);
2710
- }
2711
- return new Pipeable(this.picks).pipe(createSlice(0, this.picks.length - maybeWithoutDuplicates.length), createConcat(maybeWithoutDuplicates));
2855
+ this.computedPicks = new Pipeable(indexOrIndices).pipe(
2856
+ ensureIndices,
2857
+ this.toPossiblePicks,
2858
+ (possiblePicks) => {
2859
+ if (replace === "all") {
2860
+ return allowsDuplicates ? possiblePicks : toUnique(possiblePicks);
2861
+ }
2862
+ const maybeWithoutDuplicates = allowsDuplicates ? possiblePicks : createFilter(
2863
+ (possiblePick) => typeof lazyCollections.find((pick) => pick === possiblePick)(this.picks || []) !== "number"
2864
+ )(possiblePicks);
2865
+ switch (replace) {
2866
+ case "none":
2867
+ return createConcat(this.picks || [], maybeWithoutDuplicates)([]);
2868
+ case "fifo":
2869
+ if (maybeWithoutDuplicates.length === 0) {
2870
+ return this.picks;
2871
+ }
2872
+ if (maybeWithoutDuplicates.length === this.picks.length) {
2873
+ return maybeWithoutDuplicates;
2874
+ }
2875
+ if (maybeWithoutDuplicates.length > this.picks.length) {
2876
+ return createSlice(maybeWithoutDuplicates.length - this.picks.length)(maybeWithoutDuplicates);
2877
+ }
2878
+ return new Pipeable(this.picks).pipe(
2879
+ createSlice(maybeWithoutDuplicates.length),
2880
+ createConcat(maybeWithoutDuplicates)
2881
+ );
2882
+ case "lifo":
2883
+ if (maybeWithoutDuplicates.length === 0) {
2884
+ return this.picks;
2885
+ }
2886
+ if (maybeWithoutDuplicates.length === this.picks.length) {
2887
+ return maybeWithoutDuplicates;
2888
+ }
2889
+ if (maybeWithoutDuplicates.length > this.picks.length) {
2890
+ return createSlice(0, maybeWithoutDuplicates.length - this.picks.length + 1)(maybeWithoutDuplicates);
2891
+ }
2892
+ return new Pipeable(this.picks).pipe(
2893
+ createSlice(0, this.picks.length - maybeWithoutDuplicates.length),
2894
+ createConcat(maybeWithoutDuplicates)
2895
+ );
2896
+ }
2712
2897
  }
2713
- });
2898
+ );
2714
2899
  this.computedFirst = Math.min(...this.picks);
2715
2900
  this.computedLast = Math.max(...this.picks);
2716
2901
  this.computedMultiple = toUnique(this.picks).length > 1;
@@ -2730,7 +2915,9 @@ class Pickable {
2730
2915
  return this;
2731
2916
  }
2732
2917
  const omits = ensureIndices(indexOrIndices);
2733
- this.computedPicks = createFilter((pick, index) => options.reference === "array" ? isUndefined(lazyCollections.find((omit) => pick === omit)(omits)) : isUndefined(lazyCollections.find((omit) => index === omit)(omits)))(this.computedPicks);
2918
+ this.computedPicks = createFilter(
2919
+ (pick, index) => options.reference === "array" ? isUndefined(lazyCollections.find((omit) => pick === omit)(omits)) : isUndefined(lazyCollections.find((omit) => index === omit)(omits))
2920
+ )(this.computedPicks);
2734
2921
  this.computedFirst = Math.min(...this.picks);
2735
2922
  this.computedLast = Math.max(...this.picks);
2736
2923
  this.computedMultiple = toUnique(this.picks).length > 1;
@@ -2757,7 +2944,7 @@ class Sanitizeable {
2757
2944
  computedStatus;
2758
2945
  ready() {
2759
2946
  if (domIsAvailable()) {
2760
- this.computedDompurify = createDOMPurify__default["default"]();
2947
+ this.computedDompurify = createDOMPurify();
2761
2948
  this.computedDompurify.setConfig(this.domPurifyConfig);
2762
2949
  }
2763
2950
  this.computedStatus = "ready";
@@ -2770,7 +2957,7 @@ class Sanitizeable {
2770
2957
  }
2771
2958
  get dompurify() {
2772
2959
  if (!this.computedDompurify && domIsAvailable()) {
2773
- this.computedDompurify = createDOMPurify__default["default"]();
2960
+ this.computedDompurify = createDOMPurify();
2774
2961
  this.computedDompurify.setConfig(this.domPurifyConfig);
2775
2962
  }
2776
2963
  return this.computedDompurify;
@@ -2838,6 +3025,60 @@ class Searchable {
2838
3025
  }
2839
3026
  }
2840
3027
 
3028
+ class Shareable {
3029
+ constructor(state, options = {}) {
3030
+ this.setState(state);
3031
+ this.ready();
3032
+ }
3033
+ computedStatus;
3034
+ ready() {
3035
+ this.computedStatus = "ready";
3036
+ }
3037
+ get state() {
3038
+ return this.computedState;
3039
+ }
3040
+ set state(state) {
3041
+ this.setState(state);
3042
+ }
3043
+ get status() {
3044
+ return this.computedStatus;
3045
+ }
3046
+ computedCan;
3047
+ get can() {
3048
+ return this.computedCan;
3049
+ }
3050
+ computedError;
3051
+ get error() {
3052
+ return this.computedError;
3053
+ }
3054
+ computedState;
3055
+ setState(state) {
3056
+ this.computedState = state;
3057
+ this.computedCan = new Resolveable(async () => await navigator.canShare(state));
3058
+ return this;
3059
+ }
3060
+ async share() {
3061
+ this.sharing();
3062
+ try {
3063
+ await navigator.share(this.state);
3064
+ this.shared();
3065
+ } catch (error) {
3066
+ this.computedError = error;
3067
+ this.errored();
3068
+ }
3069
+ return this;
3070
+ }
3071
+ sharing() {
3072
+ this.computedStatus = "sharing";
3073
+ }
3074
+ shared() {
3075
+ this.computedStatus = "shared";
3076
+ }
3077
+ errored() {
3078
+ this.computedStatus = "errored";
3079
+ }
3080
+ }
3081
+
2841
3082
  const defaultOptions = {
2842
3083
  kind: "local",
2843
3084
  statusKeySuffix: " status"
@@ -2960,6 +3201,7 @@ class Storeable {
2960
3201
  }
2961
3202
 
2962
3203
  exports.Animateable = Animateable;
3204
+ exports.Broadcastable = Broadcastable;
2963
3205
  exports.Completeable = Completeable;
2964
3206
  exports.Copyable = Copyable;
2965
3207
  exports.Delayable = Delayable;
@@ -2975,6 +3217,7 @@ exports.Recognizeable = Recognizeable;
2975
3217
  exports.Resolveable = Resolveable;
2976
3218
  exports.Sanitizeable = Sanitizeable;
2977
3219
  exports.Searchable = Searchable;
3220
+ exports.Shareable = Shareable;
2978
3221
  exports.Storeable = Storeable;
2979
3222
  exports.createClamp = createClamp;
2980
3223
  exports.createClip = createClip;
@@ -3027,6 +3270,7 @@ exports.materialDecelerated = materialDecelerated;
3027
3270
  exports.materialStandard = materialStandard;
3028
3271
  exports.toD = toD;
3029
3272
  exports.toFlattenedD = toFlattenedD;
3273
+ exports.toMessageListenParams = toMessageListenParams;
3030
3274
  exports.verouEase = verouEase;
3031
3275
  exports.verouEaseIn = verouEaseIn;
3032
3276
  exports.verouEaseInOut = verouEaseInOut;