@redsift/charts 8.0.0 → 8.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { brush, select, scaleOrdinal, zoom, interpolateRound, interpolate, scaleLinear, sum, arc, pie, min, extent, descending, scaleSqrt, max } from 'd3';
2
- import { RedsiftDataVizColorBlueDefault, RedsiftDataVizColorGreyDark, RedsiftDataVizColorGreenDefault, RedsiftDataVizColorPinkDefault, RedsiftDataVizColorAquaDefault, RedsiftDataVizColorBrownDefault, RedsiftDataVizColorRedDefault, RedsiftDataVizColorYellowDefault, RedsiftDataVizColorPurpleDefault, RedsiftDataVizColorOrangeDefault, RedsiftDataVizColorGreyDefault, RedsiftDataVizColorGreenDark, RedsiftDataVizColorPinkDark, RedsiftDataVizColorAquaDark, RedsiftDataVizColorBrownDark, RedsiftDataVizColorRedDark, RedsiftDataVizColorYellowDark, RedsiftDataVizColorPurpleDark, RedsiftDataVizColorOrangeDark, RedsiftDataVizColorBlueDark, RedsiftDataVizColorGreenDarker, RedsiftDataVizColorPinkDarker, RedsiftDataVizColorAquaDarker, RedsiftDataVizColorBrownDarker, RedsiftDataVizColorRedDarker, RedsiftDataVizColorYellowDarker, RedsiftDataVizColorPurpleDarker, RedsiftDataVizColorOrangeDarker, RedsiftDataVizColorBlueDarker, RedsiftDataVizColorGreyDarker, RedsiftDataVizColorGreenDarkerer, RedsiftDataVizColorPinkDarkerer, RedsiftDataVizColorAquaDarkerer, RedsiftDataVizColorBrownDarkerer, RedsiftDataVizColorRedDarkerer, RedsiftDataVizColorYellowDarkerer, RedsiftDataVizColorPurpleDarkerer, RedsiftDataVizColorOrangeDarkerer, RedsiftDataVizColorBlueDarkerer, RedsiftDataVizColorGreyDarkerer, RedsiftDataVizColorGreenLight, RedsiftDataVizColorPinkLight, RedsiftDataVizColorAquaLight, RedsiftDataVizColorBrownLight, RedsiftDataVizColorRedLight, RedsiftDataVizColorYellowLight, RedsiftDataVizColorPurpleLight, RedsiftDataVizColorOrangeLight, RedsiftDataVizColorBlueLight, RedsiftDataVizColorGreyLight, RedsiftDataVizColorGreenLighter, RedsiftDataVizColorPinkLighter, RedsiftDataVizColorAquaLighter, RedsiftDataVizColorBrownLighter, RedsiftDataVizColorRedLighter, RedsiftDataVizColorYellowLighter, RedsiftDataVizColorPurpleLighter, RedsiftDataVizColorOrangeLighter, RedsiftDataVizColorBlueLighter, RedsiftDataVizColorGreyLighter, RedsiftDataVizColorGreenLighterer, RedsiftDataVizColorPinkLighterer, RedsiftDataVizColorAquaLighterer, RedsiftDataVizColorBrownLighterer, RedsiftDataVizColorRedLighterer, RedsiftDataVizColorYellowLighterer, RedsiftDataVizColorPurpleLighterer, RedsiftDataVizColorOrangeLighterer, RedsiftDataVizColorBlueLighterer, RedsiftDataVizColorGreyLighterer, Text, Number as Number$1, baseStyling, focusRing, Flexbox, warnIfNoAccessibleLabelFound, Heading, Button } from '@redsift/design-system';
1
+ import { brush, select, scaleOrdinal, zoom, interpolateRound, interpolate as interpolate$1, scaleLinear, sum, arc, pie, min, extent, descending, scaleSqrt, max } from 'd3';
2
+ import { RedsiftDataVizColorBlueDefault, RedsiftDataVizColorGreyDark, RedsiftDataVizColorGreenDefault, RedsiftDataVizColorPinkDefault, RedsiftDataVizColorAquaDefault, RedsiftDataVizColorBrownDefault, RedsiftDataVizColorRedDefault, RedsiftDataVizColorYellowDefault, RedsiftDataVizColorPurpleDefault, RedsiftDataVizColorOrangeDefault, RedsiftDataVizColorGreyDefault, RedsiftDataVizColorGreenDark, RedsiftDataVizColorPinkDark, RedsiftDataVizColorAquaDark, RedsiftDataVizColorBrownDark, RedsiftDataVizColorRedDark, RedsiftDataVizColorYellowDark, RedsiftDataVizColorPurpleDark, RedsiftDataVizColorOrangeDark, RedsiftDataVizColorBlueDark, RedsiftDataVizColorGreenDarker, RedsiftDataVizColorPinkDarker, RedsiftDataVizColorAquaDarker, RedsiftDataVizColorBrownDarker, RedsiftDataVizColorRedDarker, RedsiftDataVizColorYellowDarker, RedsiftDataVizColorPurpleDarker, RedsiftDataVizColorOrangeDarker, RedsiftDataVizColorBlueDarker, RedsiftDataVizColorGreyDarker, RedsiftDataVizColorGreenDarkerer, RedsiftDataVizColorPinkDarkerer, RedsiftDataVizColorAquaDarkerer, RedsiftDataVizColorBrownDarkerer, RedsiftDataVizColorRedDarkerer, RedsiftDataVizColorYellowDarkerer, RedsiftDataVizColorPurpleDarkerer, RedsiftDataVizColorOrangeDarkerer, RedsiftDataVizColorBlueDarkerer, RedsiftDataVizColorGreyDarkerer, RedsiftDataVizColorGreenLight, RedsiftDataVizColorPinkLight, RedsiftDataVizColorAquaLight, RedsiftDataVizColorBrownLight, RedsiftDataVizColorRedLight, RedsiftDataVizColorYellowLight, RedsiftDataVizColorPurpleLight, RedsiftDataVizColorOrangeLight, RedsiftDataVizColorBlueLight, RedsiftDataVizColorGreyLight, RedsiftDataVizColorGreenLighter, RedsiftDataVizColorPinkLighter, RedsiftDataVizColorAquaLighter, RedsiftDataVizColorBrownLighter, RedsiftDataVizColorRedLighter, RedsiftDataVizColorYellowLighter, RedsiftDataVizColorPurpleLighter, RedsiftDataVizColorOrangeLighter, RedsiftDataVizColorBlueLighter, RedsiftDataVizColorGreyLighter, RedsiftDataVizColorGreenLighterer, RedsiftDataVizColorPinkLighterer, RedsiftDataVizColorAquaLighterer, RedsiftDataVizColorBrownLighterer, RedsiftDataVizColorRedLighterer, RedsiftDataVizColorYellowLighterer, RedsiftDataVizColorPurpleLighterer, RedsiftDataVizColorOrangeLighterer, RedsiftDataVizColorBlueLighterer, RedsiftDataVizColorGreyLighterer, Text, Number as Number$1, baseStyling, focusRing, Flexbox, warnIfNoAccessibleLabelFound, Heading, Button, Icon } from '@redsift/design-system';
3
3
  import * as React from 'react';
4
4
  import React__default, { useRef, useEffect, useMemo, useState, useLayoutEffect, forwardRef, useCallback, useContext, useId } from 'react';
5
5
  import classNames from 'classnames';
6
6
  import { unstable_batchedUpdates } from 'react-dom';
7
7
  import styled, { css } from 'styled-components';
8
- import { Tooltip } from '@redsift/popovers';
8
+ import { Tooltip, Popover } from '@redsift/popovers';
9
9
  import { useLocalizedStringFormatter } from 'react-aria';
10
10
 
11
11
  const getRoundedIntermediaryPoint = (selection, scaleX, scaleY) => {
@@ -300,20 +300,3740 @@ const ColorTheme = {
300
300
  monochrome: 'monochrome'
301
301
  };
302
302
 
303
- var f$1=r(),n=e=>c$3(e,f$1),m$1=r();n.write=e=>c$3(e,m$1);var d$2=r();n.onStart=e=>c$3(e,d$2);var h$3=r();n.onFrame=e=>c$3(e,h$3);var p$1=r();n.onFinish=e=>c$3(e,p$1);var i=[];n.setTimeout=(e,t)=>{let a=n.now()+t,o=()=>{let F=i.findIndex(z=>z.cancel==o);~F&&i.splice(F,1),u$2-=~F?1:0;},s={time:a,handler:e,cancel:o};return i.splice(w(a),0,s),u$2+=1,v$2(),s};var w=e=>~(~i.findIndex(t=>t.time>e)||~i.length);n.cancel=e=>{d$2.delete(e),h$3.delete(e),p$1.delete(e),f$1.delete(e),m$1.delete(e);};n.sync=e=>{T=!0,n.batchedUpdates(e),T=!1;};n.throttle=e=>{let t;function a(){try{e(...t);}finally{t=null;}}function o(...s){t=s,n.onStart(a);}return o.handler=e,o.cancel=()=>{d$2.delete(a),t=null;},o};var y$3=typeof window<"u"?window.requestAnimationFrame:()=>{};n.use=e=>y$3=e;n.now=typeof performance<"u"?()=>performance.now():Date.now;n.batchedUpdates=e=>e();n.catch=console.error;n.frameLoop="always";n.advance=()=>{n.frameLoop!=="demand"?console.warn("Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"):x$2();};var l$2=-1,u$2=0,T=!1;function c$3(e,t){T?(t.delete(e),e(0)):(t.add(e),v$2());}function v$2(){l$2<0&&(l$2=0,n.frameLoop!=="demand"&&y$3(b$2));}function R(){l$2=-1;}function b$2(){~l$2&&(y$3(b$2),n.batchedUpdates(x$2));}function x$2(){let e=l$2;l$2=n.now();let t=w(l$2);if(t&&(Q$2(i.splice(0,t),a=>a.handler()),u$2-=t),!u$2){R();return}d$2.flush(),f$1.flush(e?Math.min(64,l$2-e):16.667),h$3.flush(),m$1.flush(),p$1.flush();}function r(){let e=new Set,t=e;return {add(a){u$2+=t==e&&!e.has(a)?1:0,e.add(a);},delete(a){return u$2-=t==e&&e.has(a)?1:0,e.delete(a)},flush(a){t.size&&(e=new Set,u$2-=t.size,Q$2(t,o=>o(a)&&e.add(o)),u$2+=e.size,t=e);}}}function Q$2(e,t){e.forEach(a=>{try{t(a);}catch(o){n.catch(o);}});}
303
+ var __defProp = Object.defineProperty;
304
+ var __export = (target, all) => {
305
+ for (var name in all)
306
+ __defProp(target, name, { get: all[name], enumerable: true });
307
+ };
308
+
309
+ // src/globals.ts
310
+ var globals_exports = {};
311
+ __export(globals_exports, {
312
+ assign: () => assign,
313
+ colors: () => colors,
314
+ createStringInterpolator: () => createStringInterpolator,
315
+ skipAnimation: () => skipAnimation,
316
+ to: () => to,
317
+ willAdvance: () => willAdvance
318
+ });
319
+
320
+ // ../rafz/dist/react-spring_rafz.modern.mjs
321
+ var updateQueue = makeQueue();
322
+ var raf = (fn) => schedule(fn, updateQueue);
323
+ var writeQueue = makeQueue();
324
+ raf.write = (fn) => schedule(fn, writeQueue);
325
+ var onStartQueue = makeQueue();
326
+ raf.onStart = (fn) => schedule(fn, onStartQueue);
327
+ var onFrameQueue = makeQueue();
328
+ raf.onFrame = (fn) => schedule(fn, onFrameQueue);
329
+ var onFinishQueue = makeQueue();
330
+ raf.onFinish = (fn) => schedule(fn, onFinishQueue);
331
+ var timeouts = [];
332
+ raf.setTimeout = (handler, ms) => {
333
+ const time = raf.now() + ms;
334
+ const cancel = () => {
335
+ const i = timeouts.findIndex((t) => t.cancel == cancel);
336
+ if (~i)
337
+ timeouts.splice(i, 1);
338
+ pendingCount -= ~i ? 1 : 0;
339
+ };
340
+ const timeout = { time, handler, cancel };
341
+ timeouts.splice(findTimeout(time), 0, timeout);
342
+ pendingCount += 1;
343
+ start();
344
+ return timeout;
345
+ };
346
+ var findTimeout = (time) => ~(~timeouts.findIndex((t) => t.time > time) || ~timeouts.length);
347
+ raf.cancel = (fn) => {
348
+ onStartQueue.delete(fn);
349
+ onFrameQueue.delete(fn);
350
+ onFinishQueue.delete(fn);
351
+ updateQueue.delete(fn);
352
+ writeQueue.delete(fn);
353
+ };
354
+ raf.sync = (fn) => {
355
+ sync = true;
356
+ raf.batchedUpdates(fn);
357
+ sync = false;
358
+ };
359
+ raf.throttle = (fn) => {
360
+ let lastArgs;
361
+ function queuedFn() {
362
+ try {
363
+ fn(...lastArgs);
364
+ } finally {
365
+ lastArgs = null;
366
+ }
367
+ }
368
+ function throttled(...args) {
369
+ lastArgs = args;
370
+ raf.onStart(queuedFn);
371
+ }
372
+ throttled.handler = fn;
373
+ throttled.cancel = () => {
374
+ onStartQueue.delete(queuedFn);
375
+ lastArgs = null;
376
+ };
377
+ return throttled;
378
+ };
379
+ var nativeRaf = typeof window != "undefined" ? window.requestAnimationFrame : (
380
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
381
+ () => {
382
+ }
383
+ );
384
+ raf.use = (impl) => nativeRaf = impl;
385
+ raf.now = typeof performance != "undefined" ? () => performance.now() : Date.now;
386
+ raf.batchedUpdates = (fn) => fn();
387
+ raf.catch = console.error;
388
+ raf.frameLoop = "always";
389
+ raf.advance = () => {
390
+ if (raf.frameLoop !== "demand") {
391
+ console.warn(
392
+ "Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"
393
+ );
394
+ } else {
395
+ update();
396
+ }
397
+ };
398
+ var ts = -1;
399
+ var pendingCount = 0;
400
+ var sync = false;
401
+ function schedule(fn, queue) {
402
+ if (sync) {
403
+ queue.delete(fn);
404
+ fn(0);
405
+ } else {
406
+ queue.add(fn);
407
+ start();
408
+ }
409
+ }
410
+ function start() {
411
+ if (ts < 0) {
412
+ ts = 0;
413
+ if (raf.frameLoop !== "demand") {
414
+ nativeRaf(loop);
415
+ }
416
+ }
417
+ }
418
+ function stop() {
419
+ ts = -1;
420
+ }
421
+ function loop() {
422
+ if (~ts) {
423
+ nativeRaf(loop);
424
+ raf.batchedUpdates(update);
425
+ }
426
+ }
427
+ function update() {
428
+ const prevTs = ts;
429
+ ts = raf.now();
430
+ const count = findTimeout(ts);
431
+ if (count) {
432
+ eachSafely(timeouts.splice(0, count), (t) => t.handler());
433
+ pendingCount -= count;
434
+ }
435
+ if (!pendingCount) {
436
+ stop();
437
+ return;
438
+ }
439
+ onStartQueue.flush();
440
+ updateQueue.flush(prevTs ? Math.min(64, ts - prevTs) : 16.667);
441
+ onFrameQueue.flush();
442
+ writeQueue.flush();
443
+ onFinishQueue.flush();
444
+ }
445
+ function makeQueue() {
446
+ let next = /* @__PURE__ */ new Set();
447
+ let current = next;
448
+ return {
449
+ add(fn) {
450
+ pendingCount += current == next && !next.has(fn) ? 1 : 0;
451
+ next.add(fn);
452
+ },
453
+ delete(fn) {
454
+ pendingCount -= current == next && next.has(fn) ? 1 : 0;
455
+ return next.delete(fn);
456
+ },
457
+ flush(arg) {
458
+ if (current.size) {
459
+ next = /* @__PURE__ */ new Set();
460
+ pendingCount -= current.size;
461
+ eachSafely(current, (fn) => fn(arg) && next.add(fn));
462
+ pendingCount += next.size;
463
+ current = next;
464
+ }
465
+ }
466
+ };
467
+ }
468
+ function eachSafely(values, each2) {
469
+ values.forEach((value) => {
470
+ try {
471
+ each2(value);
472
+ } catch (e) {
473
+ raf.catch(e);
474
+ }
475
+ });
476
+ }
477
+
478
+ // src/helpers.ts
479
+ function noop() {
480
+ }
481
+ var defineHidden = (obj, key, value) => Object.defineProperty(obj, key, { value, writable: true, configurable: true });
482
+ var is = {
483
+ arr: Array.isArray,
484
+ obj: (a) => !!a && a.constructor.name === "Object",
485
+ fun: (a) => typeof a === "function",
486
+ str: (a) => typeof a === "string",
487
+ num: (a) => typeof a === "number",
488
+ und: (a) => a === void 0
489
+ };
490
+ function isEqual(a, b) {
491
+ if (is.arr(a)) {
492
+ if (!is.arr(b) || a.length !== b.length)
493
+ return false;
494
+ for (let i = 0; i < a.length; i++) {
495
+ if (a[i] !== b[i])
496
+ return false;
497
+ }
498
+ return true;
499
+ }
500
+ return a === b;
501
+ }
502
+ var each = (obj, fn) => obj.forEach(fn);
503
+ function eachProp(obj, fn, ctx) {
504
+ if (is.arr(obj)) {
505
+ for (let i = 0; i < obj.length; i++) {
506
+ fn.call(ctx, obj[i], `${i}`);
507
+ }
508
+ return;
509
+ }
510
+ for (const key in obj) {
511
+ if (obj.hasOwnProperty(key)) {
512
+ fn.call(ctx, obj[key], key);
513
+ }
514
+ }
515
+ }
516
+ var toArray = (a) => is.und(a) ? [] : is.arr(a) ? a : [a];
517
+ function flush(queue, iterator) {
518
+ if (queue.size) {
519
+ const items = Array.from(queue);
520
+ queue.clear();
521
+ each(items, iterator);
522
+ }
523
+ }
524
+ var flushCalls = (queue, ...args) => flush(queue, (fn) => fn(...args));
525
+ var isSSR = () => typeof window === "undefined" || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
526
+
527
+ // src/globals.ts
528
+ var createStringInterpolator;
529
+ var to;
530
+ var colors = null;
531
+ var skipAnimation = false;
532
+ var willAdvance = noop;
533
+ var assign = (globals) => {
534
+ if (globals.to)
535
+ to = globals.to;
536
+ if (globals.now)
537
+ raf.now = globals.now;
538
+ if (globals.colors !== void 0)
539
+ colors = globals.colors;
540
+ if (globals.skipAnimation != null)
541
+ skipAnimation = globals.skipAnimation;
542
+ if (globals.createStringInterpolator)
543
+ createStringInterpolator = globals.createStringInterpolator;
544
+ if (globals.requestAnimationFrame)
545
+ raf.use(globals.requestAnimationFrame);
546
+ if (globals.batchedUpdates)
547
+ raf.batchedUpdates = globals.batchedUpdates;
548
+ if (globals.willAdvance)
549
+ willAdvance = globals.willAdvance;
550
+ if (globals.frameLoop)
551
+ raf.frameLoop = globals.frameLoop;
552
+ };
553
+
554
+ // src/FrameLoop.ts
555
+ var startQueue = /* @__PURE__ */ new Set();
556
+ var currentFrame = [];
557
+ var prevFrame = [];
558
+ var priority = 0;
559
+ var frameLoop = {
560
+ get idle() {
561
+ return !startQueue.size && !currentFrame.length;
562
+ },
563
+ /** Advance the given animation on every frame until idle. */
564
+ start(animation) {
565
+ if (priority > animation.priority) {
566
+ startQueue.add(animation);
567
+ raf.onStart(flushStartQueue);
568
+ } else {
569
+ startSafely(animation);
570
+ raf(advance);
571
+ }
572
+ },
573
+ /** Advance all animations by the given time. */
574
+ advance,
575
+ /** Call this when an animation's priority changes. */
576
+ sort(animation) {
577
+ if (priority) {
578
+ raf.onFrame(() => frameLoop.sort(animation));
579
+ } else {
580
+ const prevIndex = currentFrame.indexOf(animation);
581
+ if (~prevIndex) {
582
+ currentFrame.splice(prevIndex, 1);
583
+ startUnsafely(animation);
584
+ }
585
+ }
586
+ },
587
+ /**
588
+ * Clear all animations. For testing purposes.
589
+ *
590
+ * ☠️ Never call this from within the frameloop.
591
+ */
592
+ clear() {
593
+ currentFrame = [];
594
+ startQueue.clear();
595
+ }
596
+ };
597
+ function flushStartQueue() {
598
+ startQueue.forEach(startSafely);
599
+ startQueue.clear();
600
+ raf(advance);
601
+ }
602
+ function startSafely(animation) {
603
+ if (!currentFrame.includes(animation))
604
+ startUnsafely(animation);
605
+ }
606
+ function startUnsafely(animation) {
607
+ currentFrame.splice(
608
+ findIndex(currentFrame, (other) => other.priority > animation.priority),
609
+ 0,
610
+ animation
611
+ );
612
+ }
613
+ function advance(dt) {
614
+ const nextFrame = prevFrame;
615
+ for (let i = 0; i < currentFrame.length; i++) {
616
+ const animation = currentFrame[i];
617
+ priority = animation.priority;
618
+ if (!animation.idle) {
619
+ willAdvance(animation);
620
+ animation.advance(dt);
621
+ if (!animation.idle) {
622
+ nextFrame.push(animation);
623
+ }
624
+ }
625
+ }
626
+ priority = 0;
627
+ prevFrame = currentFrame;
628
+ prevFrame.length = 0;
629
+ currentFrame = nextFrame;
630
+ return currentFrame.length > 0;
631
+ }
632
+ function findIndex(arr, test) {
633
+ const index = arr.findIndex(test);
634
+ return index < 0 ? arr.length : index;
635
+ }
636
+
637
+ // src/clamp.ts
638
+ var clamp = (min, max, v) => Math.min(Math.max(v, min), max);
639
+
640
+ // src/colors.ts
641
+ var colors2 = {
642
+ transparent: 0,
643
+ aliceblue: 4042850303,
644
+ antiquewhite: 4209760255,
645
+ aqua: 16777215,
646
+ aquamarine: 2147472639,
647
+ azure: 4043309055,
648
+ beige: 4126530815,
649
+ bisque: 4293182719,
650
+ black: 255,
651
+ blanchedalmond: 4293643775,
652
+ blue: 65535,
653
+ blueviolet: 2318131967,
654
+ brown: 2771004159,
655
+ burlywood: 3736635391,
656
+ burntsienna: 3934150143,
657
+ cadetblue: 1604231423,
658
+ chartreuse: 2147418367,
659
+ chocolate: 3530104575,
660
+ coral: 4286533887,
661
+ cornflowerblue: 1687547391,
662
+ cornsilk: 4294499583,
663
+ crimson: 3692313855,
664
+ cyan: 16777215,
665
+ darkblue: 35839,
666
+ darkcyan: 9145343,
667
+ darkgoldenrod: 3095792639,
668
+ darkgray: 2846468607,
669
+ darkgreen: 6553855,
670
+ darkgrey: 2846468607,
671
+ darkkhaki: 3182914559,
672
+ darkmagenta: 2332068863,
673
+ darkolivegreen: 1433087999,
674
+ darkorange: 4287365375,
675
+ darkorchid: 2570243327,
676
+ darkred: 2332033279,
677
+ darksalmon: 3918953215,
678
+ darkseagreen: 2411499519,
679
+ darkslateblue: 1211993087,
680
+ darkslategray: 793726975,
681
+ darkslategrey: 793726975,
682
+ darkturquoise: 13554175,
683
+ darkviolet: 2483082239,
684
+ deeppink: 4279538687,
685
+ deepskyblue: 12582911,
686
+ dimgray: 1768516095,
687
+ dimgrey: 1768516095,
688
+ dodgerblue: 512819199,
689
+ firebrick: 2988581631,
690
+ floralwhite: 4294635775,
691
+ forestgreen: 579543807,
692
+ fuchsia: 4278255615,
693
+ gainsboro: 3705462015,
694
+ ghostwhite: 4177068031,
695
+ gold: 4292280575,
696
+ goldenrod: 3668254975,
697
+ gray: 2155905279,
698
+ green: 8388863,
699
+ greenyellow: 2919182335,
700
+ grey: 2155905279,
701
+ honeydew: 4043305215,
702
+ hotpink: 4285117695,
703
+ indianred: 3445382399,
704
+ indigo: 1258324735,
705
+ ivory: 4294963455,
706
+ khaki: 4041641215,
707
+ lavender: 3873897215,
708
+ lavenderblush: 4293981695,
709
+ lawngreen: 2096890111,
710
+ lemonchiffon: 4294626815,
711
+ lightblue: 2916673279,
712
+ lightcoral: 4034953471,
713
+ lightcyan: 3774873599,
714
+ lightgoldenrodyellow: 4210742015,
715
+ lightgray: 3553874943,
716
+ lightgreen: 2431553791,
717
+ lightgrey: 3553874943,
718
+ lightpink: 4290167295,
719
+ lightsalmon: 4288707327,
720
+ lightseagreen: 548580095,
721
+ lightskyblue: 2278488831,
722
+ lightslategray: 2005441023,
723
+ lightslategrey: 2005441023,
724
+ lightsteelblue: 2965692159,
725
+ lightyellow: 4294959359,
726
+ lime: 16711935,
727
+ limegreen: 852308735,
728
+ linen: 4210091775,
729
+ magenta: 4278255615,
730
+ maroon: 2147483903,
731
+ mediumaquamarine: 1724754687,
732
+ mediumblue: 52735,
733
+ mediumorchid: 3126187007,
734
+ mediumpurple: 2473647103,
735
+ mediumseagreen: 1018393087,
736
+ mediumslateblue: 2070474495,
737
+ mediumspringgreen: 16423679,
738
+ mediumturquoise: 1221709055,
739
+ mediumvioletred: 3340076543,
740
+ midnightblue: 421097727,
741
+ mintcream: 4127193855,
742
+ mistyrose: 4293190143,
743
+ moccasin: 4293178879,
744
+ navajowhite: 4292783615,
745
+ navy: 33023,
746
+ oldlace: 4260751103,
747
+ olive: 2155872511,
748
+ olivedrab: 1804477439,
749
+ orange: 4289003775,
750
+ orangered: 4282712319,
751
+ orchid: 3664828159,
752
+ palegoldenrod: 4008225535,
753
+ palegreen: 2566625535,
754
+ paleturquoise: 2951671551,
755
+ palevioletred: 3681588223,
756
+ papayawhip: 4293907967,
757
+ peachpuff: 4292524543,
758
+ peru: 3448061951,
759
+ pink: 4290825215,
760
+ plum: 3718307327,
761
+ powderblue: 2967529215,
762
+ purple: 2147516671,
763
+ rebeccapurple: 1714657791,
764
+ red: 4278190335,
765
+ rosybrown: 3163525119,
766
+ royalblue: 1097458175,
767
+ saddlebrown: 2336560127,
768
+ salmon: 4202722047,
769
+ sandybrown: 4104413439,
770
+ seagreen: 780883967,
771
+ seashell: 4294307583,
772
+ sienna: 2689740287,
773
+ silver: 3233857791,
774
+ skyblue: 2278484991,
775
+ slateblue: 1784335871,
776
+ slategray: 1887473919,
777
+ slategrey: 1887473919,
778
+ snow: 4294638335,
779
+ springgreen: 16744447,
780
+ steelblue: 1182971135,
781
+ tan: 3535047935,
782
+ teal: 8421631,
783
+ thistle: 3636451583,
784
+ tomato: 4284696575,
785
+ turquoise: 1088475391,
786
+ violet: 4001558271,
787
+ wheat: 4125012991,
788
+ white: 4294967295,
789
+ whitesmoke: 4126537215,
790
+ yellow: 4294902015,
791
+ yellowgreen: 2597139199
792
+ };
793
+
794
+ // src/colorMatchers.ts
795
+ var NUMBER = "[-+]?\\d*\\.?\\d+";
796
+ var PERCENTAGE = NUMBER + "%";
797
+ function call(...parts) {
798
+ return "\\(\\s*(" + parts.join(")\\s*,\\s*(") + ")\\s*\\)";
799
+ }
800
+ var rgb = new RegExp("rgb" + call(NUMBER, NUMBER, NUMBER));
801
+ var rgba = new RegExp("rgba" + call(NUMBER, NUMBER, NUMBER, NUMBER));
802
+ var hsl = new RegExp("hsl" + call(NUMBER, PERCENTAGE, PERCENTAGE));
803
+ var hsla = new RegExp(
804
+ "hsla" + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER)
805
+ );
806
+ var hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
807
+ var hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
808
+ var hex6 = /^#([0-9a-fA-F]{6})$/;
809
+ var hex8 = /^#([0-9a-fA-F]{8})$/;
810
+
811
+ // src/normalizeColor.ts
812
+ function normalizeColor(color) {
813
+ let match;
814
+ if (typeof color === "number") {
815
+ return color >>> 0 === color && color >= 0 && color <= 4294967295 ? color : null;
816
+ }
817
+ if (match = hex6.exec(color))
818
+ return parseInt(match[1] + "ff", 16) >>> 0;
819
+ if (colors && colors[color] !== void 0) {
820
+ return colors[color];
821
+ }
822
+ if (match = rgb.exec(color)) {
823
+ return (parse255(match[1]) << 24 | // r
824
+ parse255(match[2]) << 16 | // g
825
+ parse255(match[3]) << 8 | // b
826
+ 255) >>> // a
827
+ 0;
828
+ }
829
+ if (match = rgba.exec(color)) {
830
+ return (parse255(match[1]) << 24 | // r
831
+ parse255(match[2]) << 16 | // g
832
+ parse255(match[3]) << 8 | // b
833
+ parse1(match[4])) >>> // a
834
+ 0;
835
+ }
836
+ if (match = hex3.exec(color)) {
837
+ return parseInt(
838
+ match[1] + match[1] + // r
839
+ match[2] + match[2] + // g
840
+ match[3] + match[3] + // b
841
+ "ff",
842
+ // a
843
+ 16
844
+ ) >>> 0;
845
+ }
846
+ if (match = hex8.exec(color))
847
+ return parseInt(match[1], 16) >>> 0;
848
+ if (match = hex4.exec(color)) {
849
+ return parseInt(
850
+ match[1] + match[1] + // r
851
+ match[2] + match[2] + // g
852
+ match[3] + match[3] + // b
853
+ match[4] + match[4],
854
+ // a
855
+ 16
856
+ ) >>> 0;
857
+ }
858
+ if (match = hsl.exec(color)) {
859
+ return (hslToRgb(
860
+ parse360(match[1]),
861
+ // h
862
+ parsePercentage(match[2]),
863
+ // s
864
+ parsePercentage(match[3])
865
+ // l
866
+ ) | 255) >>> // a
867
+ 0;
868
+ }
869
+ if (match = hsla.exec(color)) {
870
+ return (hslToRgb(
871
+ parse360(match[1]),
872
+ // h
873
+ parsePercentage(match[2]),
874
+ // s
875
+ parsePercentage(match[3])
876
+ // l
877
+ ) | parse1(match[4])) >>> // a
878
+ 0;
879
+ }
880
+ return null;
881
+ }
882
+ function hue2rgb(p, q, t) {
883
+ if (t < 0)
884
+ t += 1;
885
+ if (t > 1)
886
+ t -= 1;
887
+ if (t < 1 / 6)
888
+ return p + (q - p) * 6 * t;
889
+ if (t < 1 / 2)
890
+ return q;
891
+ if (t < 2 / 3)
892
+ return p + (q - p) * (2 / 3 - t) * 6;
893
+ return p;
894
+ }
895
+ function hslToRgb(h, s, l) {
896
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
897
+ const p = 2 * l - q;
898
+ const r = hue2rgb(p, q, h + 1 / 3);
899
+ const g = hue2rgb(p, q, h);
900
+ const b = hue2rgb(p, q, h - 1 / 3);
901
+ return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b * 255) << 8;
902
+ }
903
+ function parse255(str) {
904
+ const int = parseInt(str, 10);
905
+ if (int < 0)
906
+ return 0;
907
+ if (int > 255)
908
+ return 255;
909
+ return int;
910
+ }
911
+ function parse360(str) {
912
+ const int = parseFloat(str);
913
+ return (int % 360 + 360) % 360 / 360;
914
+ }
915
+ function parse1(str) {
916
+ const num = parseFloat(str);
917
+ if (num < 0)
918
+ return 0;
919
+ if (num > 1)
920
+ return 255;
921
+ return Math.round(num * 255);
922
+ }
923
+ function parsePercentage(str) {
924
+ const int = parseFloat(str);
925
+ if (int < 0)
926
+ return 0;
927
+ if (int > 100)
928
+ return 1;
929
+ return int / 100;
930
+ }
931
+
932
+ // src/colorToRgba.ts
933
+ function colorToRgba(input) {
934
+ let int32Color = normalizeColor(input);
935
+ if (int32Color === null)
936
+ return input;
937
+ int32Color = int32Color || 0;
938
+ const r = (int32Color & 4278190080) >>> 24;
939
+ const g = (int32Color & 16711680) >>> 16;
940
+ const b = (int32Color & 65280) >>> 8;
941
+ const a = (int32Color & 255) / 255;
942
+ return `rgba(${r}, ${g}, ${b}, ${a})`;
943
+ }
944
+
945
+ // src/createInterpolator.ts
946
+ var createInterpolator = (range, output, extrapolate) => {
947
+ if (is.fun(range)) {
948
+ return range;
949
+ }
950
+ if (is.arr(range)) {
951
+ return createInterpolator({
952
+ range,
953
+ output,
954
+ extrapolate
955
+ });
956
+ }
957
+ if (is.str(range.output[0])) {
958
+ return createStringInterpolator(range);
959
+ }
960
+ const config = range;
961
+ const outputRange = config.output;
962
+ const inputRange = config.range || [0, 1];
963
+ const extrapolateLeft = config.extrapolateLeft || config.extrapolate || "extend";
964
+ const extrapolateRight = config.extrapolateRight || config.extrapolate || "extend";
965
+ const easing = config.easing || ((t) => t);
966
+ return (input) => {
967
+ const range2 = findRange(input, inputRange);
968
+ return interpolate(
969
+ input,
970
+ inputRange[range2],
971
+ inputRange[range2 + 1],
972
+ outputRange[range2],
973
+ outputRange[range2 + 1],
974
+ easing,
975
+ extrapolateLeft,
976
+ extrapolateRight,
977
+ config.map
978
+ );
979
+ };
980
+ };
981
+ function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) {
982
+ let result = map ? map(input) : input;
983
+ if (result < inputMin) {
984
+ if (extrapolateLeft === "identity")
985
+ return result;
986
+ else if (extrapolateLeft === "clamp")
987
+ result = inputMin;
988
+ }
989
+ if (result > inputMax) {
990
+ if (extrapolateRight === "identity")
991
+ return result;
992
+ else if (extrapolateRight === "clamp")
993
+ result = inputMax;
994
+ }
995
+ if (outputMin === outputMax)
996
+ return outputMin;
997
+ if (inputMin === inputMax)
998
+ return input <= inputMin ? outputMin : outputMax;
999
+ if (inputMin === -Infinity)
1000
+ result = -result;
1001
+ else if (inputMax === Infinity)
1002
+ result = result - inputMin;
1003
+ else
1004
+ result = (result - inputMin) / (inputMax - inputMin);
1005
+ result = easing(result);
1006
+ if (outputMin === -Infinity)
1007
+ result = -result;
1008
+ else if (outputMax === Infinity)
1009
+ result = result + outputMin;
1010
+ else
1011
+ result = result * (outputMax - outputMin) + outputMin;
1012
+ return result;
1013
+ }
1014
+ function findRange(input, inputRange) {
1015
+ for (var i = 1; i < inputRange.length - 1; ++i)
1016
+ if (inputRange[i] >= input)
1017
+ break;
1018
+ return i - 1;
1019
+ }
1020
+
1021
+ // src/easings.ts
1022
+ var steps = (steps2, direction = "end") => (progress2) => {
1023
+ progress2 = direction === "end" ? Math.min(progress2, 0.999) : Math.max(progress2, 1e-3);
1024
+ const expanded = progress2 * steps2;
1025
+ const rounded = direction === "end" ? Math.floor(expanded) : Math.ceil(expanded);
1026
+ return clamp(0, 1, rounded / steps2);
1027
+ };
1028
+ var c1 = 1.70158;
1029
+ var c2 = c1 * 1.525;
1030
+ var c3 = c1 + 1;
1031
+ var c4 = 2 * Math.PI / 3;
1032
+ var c5 = 2 * Math.PI / 4.5;
1033
+ var bounceOut = (x) => {
1034
+ const n1 = 7.5625;
1035
+ const d1 = 2.75;
1036
+ if (x < 1 / d1) {
1037
+ return n1 * x * x;
1038
+ } else if (x < 2 / d1) {
1039
+ return n1 * (x -= 1.5 / d1) * x + 0.75;
1040
+ } else if (x < 2.5 / d1) {
1041
+ return n1 * (x -= 2.25 / d1) * x + 0.9375;
1042
+ } else {
1043
+ return n1 * (x -= 2.625 / d1) * x + 0.984375;
1044
+ }
1045
+ };
1046
+ var easings = {
1047
+ linear: (x) => x,
1048
+ easeInQuad: (x) => x * x,
1049
+ easeOutQuad: (x) => 1 - (1 - x) * (1 - x),
1050
+ easeInOutQuad: (x) => x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2,
1051
+ easeInCubic: (x) => x * x * x,
1052
+ easeOutCubic: (x) => 1 - Math.pow(1 - x, 3),
1053
+ easeInOutCubic: (x) => x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2,
1054
+ easeInQuart: (x) => x * x * x * x,
1055
+ easeOutQuart: (x) => 1 - Math.pow(1 - x, 4),
1056
+ easeInOutQuart: (x) => x < 0.5 ? 8 * x * x * x * x : 1 - Math.pow(-2 * x + 2, 4) / 2,
1057
+ easeInQuint: (x) => x * x * x * x * x,
1058
+ easeOutQuint: (x) => 1 - Math.pow(1 - x, 5),
1059
+ easeInOutQuint: (x) => x < 0.5 ? 16 * x * x * x * x * x : 1 - Math.pow(-2 * x + 2, 5) / 2,
1060
+ easeInSine: (x) => 1 - Math.cos(x * Math.PI / 2),
1061
+ easeOutSine: (x) => Math.sin(x * Math.PI / 2),
1062
+ easeInOutSine: (x) => -(Math.cos(Math.PI * x) - 1) / 2,
1063
+ easeInExpo: (x) => x === 0 ? 0 : Math.pow(2, 10 * x - 10),
1064
+ easeOutExpo: (x) => x === 1 ? 1 : 1 - Math.pow(2, -10 * x),
1065
+ easeInOutExpo: (x) => x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? Math.pow(2, 20 * x - 10) / 2 : (2 - Math.pow(2, -20 * x + 10)) / 2,
1066
+ easeInCirc: (x) => 1 - Math.sqrt(1 - Math.pow(x, 2)),
1067
+ easeOutCirc: (x) => Math.sqrt(1 - Math.pow(x - 1, 2)),
1068
+ easeInOutCirc: (x) => x < 0.5 ? (1 - Math.sqrt(1 - Math.pow(2 * x, 2))) / 2 : (Math.sqrt(1 - Math.pow(-2 * x + 2, 2)) + 1) / 2,
1069
+ easeInBack: (x) => c3 * x * x * x - c1 * x * x,
1070
+ easeOutBack: (x) => 1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2),
1071
+ easeInOutBack: (x) => x < 0.5 ? Math.pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2) / 2 : (Math.pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2,
1072
+ easeInElastic: (x) => x === 0 ? 0 : x === 1 ? 1 : -Math.pow(2, 10 * x - 10) * Math.sin((x * 10 - 10.75) * c4),
1073
+ easeOutElastic: (x) => x === 0 ? 0 : x === 1 ? 1 : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1,
1074
+ easeInOutElastic: (x) => x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2 : Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5) / 2 + 1,
1075
+ easeInBounce: (x) => 1 - bounceOut(1 - x),
1076
+ easeOutBounce: bounceOut,
1077
+ easeInOutBounce: (x) => x < 0.5 ? (1 - bounceOut(1 - 2 * x)) / 2 : (1 + bounceOut(2 * x - 1)) / 2,
1078
+ steps
1079
+ };
1080
+
1081
+ // src/fluids.ts
1082
+ var $get = Symbol.for("FluidValue.get");
1083
+ var $observers = Symbol.for("FluidValue.observers");
1084
+ var hasFluidValue = (arg) => Boolean(arg && arg[$get]);
1085
+ var getFluidValue = (arg) => arg && arg[$get] ? arg[$get]() : arg;
1086
+ var getFluidObservers = (target) => target[$observers] || null;
1087
+ function callFluidObserver(observer2, event) {
1088
+ if (observer2.eventObserved) {
1089
+ observer2.eventObserved(event);
1090
+ } else {
1091
+ observer2(event);
1092
+ }
1093
+ }
1094
+ function callFluidObservers(target, event) {
1095
+ const observers = target[$observers];
1096
+ if (observers) {
1097
+ observers.forEach((observer2) => {
1098
+ callFluidObserver(observer2, event);
1099
+ });
1100
+ }
1101
+ }
1102
+ var FluidValue = class {
1103
+ constructor(get) {
1104
+ if (!get && !(get = this.get)) {
1105
+ throw Error("Unknown getter");
1106
+ }
1107
+ setFluidGetter(this, get);
1108
+ }
1109
+ };
1110
+ var setFluidGetter = (target, get) => setHidden(target, $get, get);
1111
+ function addFluidObserver(target, observer2) {
1112
+ if (target[$get]) {
1113
+ let observers = target[$observers];
1114
+ if (!observers) {
1115
+ setHidden(target, $observers, observers = /* @__PURE__ */ new Set());
1116
+ }
1117
+ if (!observers.has(observer2)) {
1118
+ observers.add(observer2);
1119
+ if (target.observerAdded) {
1120
+ target.observerAdded(observers.size, observer2);
1121
+ }
1122
+ }
1123
+ }
1124
+ return observer2;
1125
+ }
1126
+ function removeFluidObserver(target, observer2) {
1127
+ const observers = target[$observers];
1128
+ if (observers && observers.has(observer2)) {
1129
+ const count = observers.size - 1;
1130
+ if (count) {
1131
+ observers.delete(observer2);
1132
+ } else {
1133
+ target[$observers] = null;
1134
+ }
1135
+ if (target.observerRemoved) {
1136
+ target.observerRemoved(count, observer2);
1137
+ }
1138
+ }
1139
+ }
1140
+ var setHidden = (target, key, value) => Object.defineProperty(target, key, {
1141
+ value,
1142
+ writable: true,
1143
+ configurable: true
1144
+ });
1145
+
1146
+ // src/regexs.ts
1147
+ var numberRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
1148
+ var colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi;
1149
+ var unitRegex = new RegExp(`(${numberRegex.source})(%|[a-z]+)`, "i");
1150
+ var rgbaRegex = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi;
1151
+ var cssVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;
1152
+
1153
+ // src/variableToRgba.ts
1154
+ var variableToRgba = (input) => {
1155
+ const [token, fallback] = parseCSSVariable(input);
1156
+ if (!token || isSSR()) {
1157
+ return input;
1158
+ }
1159
+ const value = window.getComputedStyle(document.documentElement).getPropertyValue(token);
1160
+ if (value) {
1161
+ return value.trim();
1162
+ } else if (fallback && fallback.startsWith("--")) {
1163
+ const value2 = window.getComputedStyle(document.documentElement).getPropertyValue(fallback);
1164
+ if (value2) {
1165
+ return value2;
1166
+ } else {
1167
+ return input;
1168
+ }
1169
+ } else if (fallback && cssVariableRegex.test(fallback)) {
1170
+ return variableToRgba(fallback);
1171
+ } else if (fallback) {
1172
+ return fallback;
1173
+ }
1174
+ return input;
1175
+ };
1176
+ var parseCSSVariable = (current) => {
1177
+ const match = cssVariableRegex.exec(current);
1178
+ if (!match)
1179
+ return [,];
1180
+ const [, token, fallback] = match;
1181
+ return [token, fallback];
1182
+ };
1183
+
1184
+ // src/stringInterpolation.ts
1185
+ var namedColorRegex;
1186
+ var rgbaRound = (_, p1, p2, p3, p4) => `rgba(${Math.round(p1)}, ${Math.round(p2)}, ${Math.round(p3)}, ${p4})`;
1187
+ var createStringInterpolator2 = (config) => {
1188
+ if (!namedColorRegex)
1189
+ namedColorRegex = colors ? (
1190
+ // match color names, ignore partial matches
1191
+ new RegExp(`(${Object.keys(colors).join("|")})(?!\\w)`, "g")
1192
+ ) : (
1193
+ // never match
1194
+ /^\b$/
1195
+ );
1196
+ const output = config.output.map((value) => {
1197
+ return getFluidValue(value).replace(cssVariableRegex, variableToRgba).replace(colorRegex, colorToRgba).replace(namedColorRegex, colorToRgba);
1198
+ });
1199
+ const keyframes = output.map((value) => value.match(numberRegex).map(Number));
1200
+ const outputRanges = keyframes[0].map(
1201
+ (_, i) => keyframes.map((values) => {
1202
+ if (!(i in values)) {
1203
+ throw Error('The arity of each "output" value must be equal');
1204
+ }
1205
+ return values[i];
1206
+ })
1207
+ );
1208
+ const interpolators = outputRanges.map(
1209
+ (output2) => createInterpolator({ ...config, output: output2 })
1210
+ );
1211
+ return (input) => {
1212
+ const missingUnit = !unitRegex.test(output[0]) && output.find((value) => unitRegex.test(value))?.replace(numberRegex, "");
1213
+ let i = 0;
1214
+ return output[0].replace(
1215
+ numberRegex,
1216
+ () => `${interpolators[i++](input)}${missingUnit || ""}`
1217
+ ).replace(rgbaRegex, rgbaRound);
1218
+ };
1219
+ };
1220
+
1221
+ // src/deprecations.ts
1222
+ var prefix = "react-spring: ";
1223
+ var once = (fn) => {
1224
+ const func = fn;
1225
+ let called = false;
1226
+ if (typeof func != "function") {
1227
+ throw new TypeError(`${prefix}once requires a function parameter`);
1228
+ }
1229
+ return (...args) => {
1230
+ if (!called) {
1231
+ func(...args);
1232
+ called = true;
1233
+ }
1234
+ };
1235
+ };
1236
+ var warnInterpolate = once(console.warn);
1237
+ function deprecateInterpolate() {
1238
+ warnInterpolate(
1239
+ `${prefix}The "interpolate" function is deprecated in v9 (use "to" instead)`
1240
+ );
1241
+ }
1242
+ var warnDirectCall = once(console.warn);
1243
+ function deprecateDirectCall() {
1244
+ warnDirectCall(
1245
+ `${prefix}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`
1246
+ );
1247
+ }
1248
+
1249
+ // src/isAnimatedString.ts
1250
+ function isAnimatedString(value) {
1251
+ return is.str(value) && (value[0] == "#" || /\d/.test(value) || // Do not identify a CSS variable as an AnimatedString if its SSR
1252
+ !isSSR() && cssVariableRegex.test(value) || value in (colors || {}));
1253
+ }
1254
+ var useIsomorphicLayoutEffect = isSSR() ? useEffect : useLayoutEffect;
1255
+
1256
+ // src/hooks/useIsMounted.ts
1257
+ var useIsMounted = () => {
1258
+ const isMounted = useRef(false);
1259
+ useIsomorphicLayoutEffect(() => {
1260
+ isMounted.current = true;
1261
+ return () => {
1262
+ isMounted.current = false;
1263
+ };
1264
+ }, []);
1265
+ return isMounted;
1266
+ };
1267
+
1268
+ // src/hooks/useForceUpdate.ts
1269
+ function useForceUpdate() {
1270
+ const update2 = useState()[1];
1271
+ const isMounted = useIsMounted();
1272
+ return () => {
1273
+ if (isMounted.current) {
1274
+ update2(Math.random());
1275
+ }
1276
+ };
1277
+ }
1278
+ function useMemoOne(getResult, inputs) {
1279
+ const [initial] = useState(
1280
+ () => ({
1281
+ inputs,
1282
+ result: getResult()
1283
+ })
1284
+ );
1285
+ const committed = useRef();
1286
+ const prevCache = committed.current;
1287
+ let cache = prevCache;
1288
+ if (cache) {
1289
+ const useCache = Boolean(
1290
+ inputs && cache.inputs && areInputsEqual(inputs, cache.inputs)
1291
+ );
1292
+ if (!useCache) {
1293
+ cache = {
1294
+ inputs,
1295
+ result: getResult()
1296
+ };
1297
+ }
1298
+ } else {
1299
+ cache = initial;
1300
+ }
1301
+ useEffect(() => {
1302
+ committed.current = cache;
1303
+ if (prevCache == initial) {
1304
+ initial.inputs = initial.result = void 0;
1305
+ }
1306
+ }, [cache]);
1307
+ return cache.result;
1308
+ }
1309
+ function areInputsEqual(next, prev) {
1310
+ if (next.length !== prev.length) {
1311
+ return false;
1312
+ }
1313
+ for (let i = 0; i < next.length; i++) {
1314
+ if (next[i] !== prev[i]) {
1315
+ return false;
1316
+ }
1317
+ }
1318
+ return true;
1319
+ }
1320
+ var useOnce = (effect) => useEffect(effect, emptyDeps);
1321
+ var emptyDeps = [];
1322
+ function usePrev(value) {
1323
+ const prevRef = useRef();
1324
+ useEffect(() => {
1325
+ prevRef.current = value;
1326
+ });
1327
+ return prevRef.current;
1328
+ }
1329
+
1330
+ // src/Animated.ts
1331
+ var $node = Symbol.for("Animated:node");
1332
+ var isAnimated = (value) => !!value && value[$node] === value;
1333
+ var getAnimated = (owner) => owner && owner[$node];
1334
+ var setAnimated = (owner, node) => defineHidden(owner, $node, node);
1335
+ var getPayload = (owner) => owner && owner[$node] && owner[$node].getPayload();
1336
+ var Animated = class {
1337
+ constructor() {
1338
+ setAnimated(this, this);
1339
+ }
1340
+ /** Get every `AnimatedValue` used by this node. */
1341
+ getPayload() {
1342
+ return this.payload || [];
1343
+ }
1344
+ };
1345
+ var AnimatedValue = class extends Animated {
1346
+ constructor(_value) {
1347
+ super();
1348
+ this._value = _value;
1349
+ this.done = true;
1350
+ this.durationProgress = 0;
1351
+ if (is.num(this._value)) {
1352
+ this.lastPosition = this._value;
1353
+ }
1354
+ }
1355
+ /** @internal */
1356
+ static create(value) {
1357
+ return new AnimatedValue(value);
1358
+ }
1359
+ getPayload() {
1360
+ return [this];
1361
+ }
1362
+ getValue() {
1363
+ return this._value;
1364
+ }
1365
+ setValue(value, step) {
1366
+ if (is.num(value)) {
1367
+ this.lastPosition = value;
1368
+ if (step) {
1369
+ value = Math.round(value / step) * step;
1370
+ if (this.done) {
1371
+ this.lastPosition = value;
1372
+ }
1373
+ }
1374
+ }
1375
+ if (this._value === value) {
1376
+ return false;
1377
+ }
1378
+ this._value = value;
1379
+ return true;
1380
+ }
1381
+ reset() {
1382
+ const { done } = this;
1383
+ this.done = false;
1384
+ if (is.num(this._value)) {
1385
+ this.elapsedTime = 0;
1386
+ this.durationProgress = 0;
1387
+ this.lastPosition = this._value;
1388
+ if (done)
1389
+ this.lastVelocity = null;
1390
+ this.v0 = null;
1391
+ }
1392
+ }
1393
+ };
1394
+ var AnimatedString = class extends AnimatedValue {
1395
+ constructor(value) {
1396
+ super(0);
1397
+ this._string = null;
1398
+ this._toString = createInterpolator({
1399
+ output: [value, value]
1400
+ });
1401
+ }
1402
+ /** @internal */
1403
+ static create(value) {
1404
+ return new AnimatedString(value);
1405
+ }
1406
+ getValue() {
1407
+ const value = this._string;
1408
+ return value == null ? this._string = this._toString(this._value) : value;
1409
+ }
1410
+ setValue(value) {
1411
+ if (is.str(value)) {
1412
+ if (value == this._string) {
1413
+ return false;
1414
+ }
1415
+ this._string = value;
1416
+ this._value = 1;
1417
+ } else if (super.setValue(value)) {
1418
+ this._string = null;
1419
+ } else {
1420
+ return false;
1421
+ }
1422
+ return true;
1423
+ }
1424
+ reset(goal) {
1425
+ if (goal) {
1426
+ this._toString = createInterpolator({
1427
+ output: [this.getValue(), goal]
1428
+ });
1429
+ }
1430
+ this._value = 0;
1431
+ super.reset();
1432
+ }
1433
+ };
1434
+
1435
+ // src/context.ts
1436
+ var TreeContext = { dependencies: null };
1437
+
1438
+ // src/AnimatedObject.ts
1439
+ var AnimatedObject = class extends Animated {
1440
+ constructor(source) {
1441
+ super();
1442
+ this.source = source;
1443
+ this.setValue(source);
1444
+ }
1445
+ getValue(animated) {
1446
+ const values = {};
1447
+ eachProp(this.source, (source, key) => {
1448
+ if (isAnimated(source)) {
1449
+ values[key] = source.getValue(animated);
1450
+ } else if (hasFluidValue(source)) {
1451
+ values[key] = getFluidValue(source);
1452
+ } else if (!animated) {
1453
+ values[key] = source;
1454
+ }
1455
+ });
1456
+ return values;
1457
+ }
1458
+ /** Replace the raw object data */
1459
+ setValue(source) {
1460
+ this.source = source;
1461
+ this.payload = this._makePayload(source);
1462
+ }
1463
+ reset() {
1464
+ if (this.payload) {
1465
+ each(this.payload, (node) => node.reset());
1466
+ }
1467
+ }
1468
+ /** Create a payload set. */
1469
+ _makePayload(source) {
1470
+ if (source) {
1471
+ const payload = /* @__PURE__ */ new Set();
1472
+ eachProp(source, this._addToPayload, payload);
1473
+ return Array.from(payload);
1474
+ }
1475
+ }
1476
+ /** Add to a payload set. */
1477
+ _addToPayload(source) {
1478
+ if (TreeContext.dependencies && hasFluidValue(source)) {
1479
+ TreeContext.dependencies.add(source);
1480
+ }
1481
+ const payload = getPayload(source);
1482
+ if (payload) {
1483
+ each(payload, (node) => this.add(node));
1484
+ }
1485
+ }
1486
+ };
1487
+
1488
+ // src/AnimatedArray.ts
1489
+ var AnimatedArray = class extends AnimatedObject {
1490
+ constructor(source) {
1491
+ super(source);
1492
+ }
1493
+ /** @internal */
1494
+ static create(source) {
1495
+ return new AnimatedArray(source);
1496
+ }
1497
+ getValue() {
1498
+ return this.source.map((node) => node.getValue());
1499
+ }
1500
+ setValue(source) {
1501
+ const payload = this.getPayload();
1502
+ if (source.length == payload.length) {
1503
+ return payload.map((node, i) => node.setValue(source[i])).some(Boolean);
1504
+ }
1505
+ super.setValue(source.map(makeAnimated));
1506
+ return true;
1507
+ }
1508
+ };
1509
+ function makeAnimated(value) {
1510
+ const nodeType = isAnimatedString(value) ? AnimatedString : AnimatedValue;
1511
+ return nodeType.create(value);
1512
+ }
1513
+ function getAnimatedType(value) {
1514
+ const parentNode = getAnimated(value);
1515
+ return parentNode ? parentNode.constructor : is.arr(value) ? AnimatedArray : isAnimatedString(value) ? AnimatedString : AnimatedValue;
1516
+ }
1517
+ var withAnimated = (Component, host) => {
1518
+ const hasInstance = (
1519
+ // Function components must use "forwardRef" to avoid being
1520
+ // re-rendered on every animation frame.
1521
+ !is.fun(Component) || Component.prototype && Component.prototype.isReactComponent
1522
+ );
1523
+ return forwardRef((givenProps, givenRef) => {
1524
+ const instanceRef = useRef(null);
1525
+ const ref = hasInstance && // eslint-disable-next-line react-hooks/rules-of-hooks
1526
+ useCallback(
1527
+ (value) => {
1528
+ instanceRef.current = updateRef(givenRef, value);
1529
+ },
1530
+ [givenRef]
1531
+ );
1532
+ const [props, deps] = getAnimatedState(givenProps, host);
1533
+ const forceUpdate = useForceUpdate();
1534
+ const callback = () => {
1535
+ const instance = instanceRef.current;
1536
+ if (hasInstance && !instance) {
1537
+ return;
1538
+ }
1539
+ const didUpdate = instance ? host.applyAnimatedValues(instance, props.getValue(true)) : false;
1540
+ if (didUpdate === false) {
1541
+ forceUpdate();
1542
+ }
1543
+ };
1544
+ const observer = new PropsObserver(callback, deps);
1545
+ const observerRef = useRef();
1546
+ useIsomorphicLayoutEffect(() => {
1547
+ observerRef.current = observer;
1548
+ each(deps, (dep) => addFluidObserver(dep, observer));
1549
+ return () => {
1550
+ if (observerRef.current) {
1551
+ each(
1552
+ observerRef.current.deps,
1553
+ (dep) => removeFluidObserver(dep, observerRef.current)
1554
+ );
1555
+ raf.cancel(observerRef.current.update);
1556
+ }
1557
+ };
1558
+ });
1559
+ useEffect(callback, []);
1560
+ useOnce(() => () => {
1561
+ const observer2 = observerRef.current;
1562
+ each(observer2.deps, (dep) => removeFluidObserver(dep, observer2));
1563
+ });
1564
+ const usedProps = host.getComponentProps(props.getValue());
1565
+ return /* @__PURE__ */ React.createElement(Component, { ...usedProps, ref });
1566
+ });
1567
+ };
1568
+ var PropsObserver = class {
1569
+ constructor(update, deps) {
1570
+ this.update = update;
1571
+ this.deps = deps;
1572
+ }
1573
+ eventObserved(event) {
1574
+ if (event.type == "change") {
1575
+ raf.write(this.update);
1576
+ }
1577
+ }
1578
+ };
1579
+ function getAnimatedState(props, host) {
1580
+ const dependencies = /* @__PURE__ */ new Set();
1581
+ TreeContext.dependencies = dependencies;
1582
+ if (props.style)
1583
+ props = {
1584
+ ...props,
1585
+ style: host.createAnimatedStyle(props.style)
1586
+ };
1587
+ props = new AnimatedObject(props);
1588
+ TreeContext.dependencies = null;
1589
+ return [props, dependencies];
1590
+ }
1591
+ function updateRef(ref, value) {
1592
+ if (ref) {
1593
+ if (is.fun(ref))
1594
+ ref(value);
1595
+ else
1596
+ ref.current = value;
1597
+ }
1598
+ return value;
1599
+ }
1600
+
1601
+ // src/createHost.ts
1602
+ var cacheKey = Symbol.for("AnimatedComponent");
1603
+ var createHost = (components, {
1604
+ applyAnimatedValues = () => false,
1605
+ createAnimatedStyle = (style) => new AnimatedObject(style),
1606
+ getComponentProps = (props) => props
1607
+ } = {}) => {
1608
+ const hostConfig = {
1609
+ applyAnimatedValues,
1610
+ createAnimatedStyle,
1611
+ getComponentProps
1612
+ };
1613
+ const animated = (Component) => {
1614
+ const displayName = getDisplayName(Component) || "Anonymous";
1615
+ if (is.str(Component)) {
1616
+ Component = animated[Component] || (animated[Component] = withAnimated(Component, hostConfig));
1617
+ } else {
1618
+ Component = Component[cacheKey] || (Component[cacheKey] = withAnimated(Component, hostConfig));
1619
+ }
1620
+ Component.displayName = `Animated(${displayName})`;
1621
+ return Component;
1622
+ };
1623
+ eachProp(components, (Component, key) => {
1624
+ if (is.arr(components)) {
1625
+ key = getDisplayName(Component);
1626
+ }
1627
+ animated[key] = animated(Component);
1628
+ });
1629
+ return {
1630
+ animated
1631
+ };
1632
+ };
1633
+ var getDisplayName = (arg) => is.str(arg) ? arg : arg && is.str(arg.displayName) ? arg.displayName : is.fun(arg) && arg.name || null;
1634
+
1635
+ // src/hooks/useChain.ts
1636
+ function callProp(value, ...args) {
1637
+ return is.fun(value) ? value(...args) : value;
1638
+ }
1639
+ var matchProp = (value, key) => value === true || !!(key && value && (is.fun(value) ? value(key) : toArray(value).includes(key)));
1640
+ var resolveProp = (prop, key) => is.obj(prop) ? key && prop[key] : prop;
1641
+ var getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : void 0;
1642
+ var noopTransform = (value) => value;
1643
+ var getDefaultProps = (props, transform = noopTransform) => {
1644
+ let keys = DEFAULT_PROPS$b;
1645
+ if (props.default && props.default !== true) {
1646
+ props = props.default;
1647
+ keys = Object.keys(props);
1648
+ }
1649
+ const defaults2 = {};
1650
+ for (const key of keys) {
1651
+ const value = transform(props[key], key);
1652
+ if (!is.und(value)) {
1653
+ defaults2[key] = value;
1654
+ }
1655
+ }
1656
+ return defaults2;
1657
+ };
1658
+ var DEFAULT_PROPS$b = [
1659
+ "config",
1660
+ "onProps",
1661
+ "onStart",
1662
+ "onChange",
1663
+ "onPause",
1664
+ "onResume",
1665
+ "onRest"
1666
+ ];
1667
+ var RESERVED_PROPS = {
1668
+ config: 1,
1669
+ from: 1,
1670
+ to: 1,
1671
+ ref: 1,
1672
+ loop: 1,
1673
+ reset: 1,
1674
+ pause: 1,
1675
+ cancel: 1,
1676
+ reverse: 1,
1677
+ immediate: 1,
1678
+ default: 1,
1679
+ delay: 1,
1680
+ onProps: 1,
1681
+ onStart: 1,
1682
+ onChange: 1,
1683
+ onPause: 1,
1684
+ onResume: 1,
1685
+ onRest: 1,
1686
+ onResolve: 1,
1687
+ // Transition props
1688
+ items: 1,
1689
+ trail: 1,
1690
+ sort: 1,
1691
+ expires: 1,
1692
+ initial: 1,
1693
+ enter: 1,
1694
+ update: 1,
1695
+ leave: 1,
1696
+ children: 1,
1697
+ onDestroyed: 1,
1698
+ // Internal props
1699
+ keys: 1,
1700
+ callId: 1,
1701
+ parentId: 1
1702
+ };
1703
+ function getForwardProps(props) {
1704
+ const forward = {};
1705
+ let count = 0;
1706
+ eachProp(props, (value, prop) => {
1707
+ if (!RESERVED_PROPS[prop]) {
1708
+ forward[prop] = value;
1709
+ count++;
1710
+ }
1711
+ });
1712
+ if (count) {
1713
+ return forward;
1714
+ }
1715
+ }
1716
+ function inferTo(props) {
1717
+ const to2 = getForwardProps(props);
1718
+ if (to2) {
1719
+ const out = { to: to2 };
1720
+ eachProp(props, (val, key) => key in to2 || (out[key] = val));
1721
+ return out;
1722
+ }
1723
+ return { ...props };
1724
+ }
1725
+ function computeGoal(value) {
1726
+ value = getFluidValue(value);
1727
+ return is.arr(value) ? value.map(computeGoal) : isAnimatedString(value) ? globals_exports.createStringInterpolator({
1728
+ range: [0, 1],
1729
+ output: [value, value]
1730
+ })(1) : value;
1731
+ }
1732
+ function hasProps(props) {
1733
+ for (const _ in props)
1734
+ return true;
1735
+ return false;
1736
+ }
1737
+ function isAsyncTo(to2) {
1738
+ return is.fun(to2) || is.arr(to2) && is.obj(to2[0]);
1739
+ }
1740
+ function detachRefs(ctrl, ref) {
1741
+ ctrl.ref?.delete(ctrl);
1742
+ ref?.delete(ctrl);
1743
+ }
1744
+ function replaceRef(ctrl, ref) {
1745
+ if (ref && ctrl.ref !== ref) {
1746
+ ctrl.ref?.delete(ctrl);
1747
+ ref.add(ctrl);
1748
+ ctrl.ref = ref;
1749
+ }
1750
+ }
1751
+
1752
+ // src/constants.ts
1753
+ var config$1 = {
1754
+ default: { tension: 170, friction: 26 },
1755
+ gentle: { tension: 120, friction: 14 },
1756
+ wobbly: { tension: 180, friction: 12 },
1757
+ stiff: { tension: 210, friction: 20 },
1758
+ slow: { tension: 280, friction: 60 },
1759
+ molasses: { tension: 280, friction: 120 }
1760
+ };
1761
+
1762
+ // src/AnimationConfig.ts
1763
+ var defaults = {
1764
+ ...config$1.default,
1765
+ mass: 1,
1766
+ damping: 1,
1767
+ easing: easings.linear,
1768
+ clamp: false
1769
+ };
1770
+ var AnimationConfig = class {
1771
+ constructor() {
1772
+ /**
1773
+ * The initial velocity of one or more values.
1774
+ *
1775
+ * @default 0
1776
+ */
1777
+ this.velocity = 0;
1778
+ Object.assign(this, defaults);
1779
+ }
1780
+ };
1781
+ function mergeConfig(config2, newConfig, defaultConfig) {
1782
+ if (defaultConfig) {
1783
+ defaultConfig = { ...defaultConfig };
1784
+ sanitizeConfig(defaultConfig, newConfig);
1785
+ newConfig = { ...defaultConfig, ...newConfig };
1786
+ }
1787
+ sanitizeConfig(config2, newConfig);
1788
+ Object.assign(config2, newConfig);
1789
+ for (const key in defaults) {
1790
+ if (config2[key] == null) {
1791
+ config2[key] = defaults[key];
1792
+ }
1793
+ }
1794
+ let { frequency, damping } = config2;
1795
+ const { mass } = config2;
1796
+ if (!is.und(frequency)) {
1797
+ if (frequency < 0.01)
1798
+ frequency = 0.01;
1799
+ if (damping < 0)
1800
+ damping = 0;
1801
+ config2.tension = Math.pow(2 * Math.PI / frequency, 2) * mass;
1802
+ config2.friction = 4 * Math.PI * damping * mass / frequency;
1803
+ }
1804
+ return config2;
1805
+ }
1806
+ function sanitizeConfig(config2, props) {
1807
+ if (!is.und(props.decay)) {
1808
+ config2.duration = void 0;
1809
+ } else {
1810
+ const isTensionConfig = !is.und(props.tension) || !is.und(props.friction);
1811
+ if (isTensionConfig || !is.und(props.frequency) || !is.und(props.damping) || !is.und(props.mass)) {
1812
+ config2.duration = void 0;
1813
+ config2.decay = void 0;
1814
+ }
1815
+ if (isTensionConfig) {
1816
+ config2.frequency = void 0;
1817
+ }
1818
+ }
1819
+ }
1820
+
1821
+ // src/Animation.ts
1822
+ var emptyArray = [];
1823
+ var Animation = class {
1824
+ constructor() {
1825
+ this.changed = false;
1826
+ this.values = emptyArray;
1827
+ this.toValues = null;
1828
+ this.fromValues = emptyArray;
1829
+ this.config = new AnimationConfig();
1830
+ this.immediate = false;
1831
+ }
1832
+ };
1833
+ function scheduleProps(callId, { key, props, defaultProps, state, actions }) {
1834
+ return new Promise((resolve, reject) => {
1835
+ let delay;
1836
+ let timeout;
1837
+ let cancel = matchProp(props.cancel ?? defaultProps?.cancel, key);
1838
+ if (cancel) {
1839
+ onStart();
1840
+ } else {
1841
+ if (!is.und(props.pause)) {
1842
+ state.paused = matchProp(props.pause, key);
1843
+ }
1844
+ let pause = defaultProps?.pause;
1845
+ if (pause !== true) {
1846
+ pause = state.paused || matchProp(pause, key);
1847
+ }
1848
+ delay = callProp(props.delay || 0, key);
1849
+ if (pause) {
1850
+ state.resumeQueue.add(onResume);
1851
+ actions.pause();
1852
+ } else {
1853
+ actions.resume();
1854
+ onResume();
1855
+ }
1856
+ }
1857
+ function onPause() {
1858
+ state.resumeQueue.add(onResume);
1859
+ state.timeouts.delete(timeout);
1860
+ timeout.cancel();
1861
+ delay = timeout.time - raf.now();
1862
+ }
1863
+ function onResume() {
1864
+ if (delay > 0 && !globals_exports.skipAnimation) {
1865
+ state.delayed = true;
1866
+ timeout = raf.setTimeout(onStart, delay);
1867
+ state.pauseQueue.add(onPause);
1868
+ state.timeouts.add(timeout);
1869
+ } else {
1870
+ onStart();
1871
+ }
1872
+ }
1873
+ function onStart() {
1874
+ if (state.delayed) {
1875
+ state.delayed = false;
1876
+ }
1877
+ state.pauseQueue.delete(onPause);
1878
+ state.timeouts.delete(timeout);
1879
+ if (callId <= (state.cancelId || 0)) {
1880
+ cancel = true;
1881
+ }
1882
+ try {
1883
+ actions.start({ ...props, callId, cancel }, resolve);
1884
+ } catch (err) {
1885
+ reject(err);
1886
+ }
1887
+ }
1888
+ });
1889
+ }
1890
+
1891
+ // src/AnimationResult.ts
1892
+ var getCombinedResult = (target, results) => results.length == 1 ? results[0] : results.some((result) => result.cancelled) ? getCancelledResult(target.get()) : results.every((result) => result.noop) ? getNoopResult(target.get()) : getFinishedResult(
1893
+ target.get(),
1894
+ results.every((result) => result.finished)
1895
+ );
1896
+ var getNoopResult = (value) => ({
1897
+ value,
1898
+ noop: true,
1899
+ finished: true,
1900
+ cancelled: false
1901
+ });
1902
+ var getFinishedResult = (value, finished, cancelled = false) => ({
1903
+ value,
1904
+ finished,
1905
+ cancelled
1906
+ });
1907
+ var getCancelledResult = (value) => ({
1908
+ value,
1909
+ cancelled: true,
1910
+ finished: false
1911
+ });
1912
+
1913
+ // src/runAsync.ts
1914
+ function runAsync(to2, props, state, target) {
1915
+ const { callId, parentId, onRest } = props;
1916
+ const { asyncTo: prevTo, promise: prevPromise } = state;
1917
+ if (!parentId && to2 === prevTo && !props.reset) {
1918
+ return prevPromise;
1919
+ }
1920
+ return state.promise = (async () => {
1921
+ state.asyncId = callId;
1922
+ state.asyncTo = to2;
1923
+ const defaultProps = getDefaultProps(
1924
+ props,
1925
+ (value, key) => (
1926
+ // The `onRest` prop is only called when the `runAsync` promise is resolved.
1927
+ key === "onRest" ? void 0 : value
1928
+ )
1929
+ );
1930
+ let preventBail;
1931
+ let bail;
1932
+ const bailPromise = new Promise(
1933
+ (resolve, reject) => (preventBail = resolve, bail = reject)
1934
+ );
1935
+ const bailIfEnded = (bailSignal) => {
1936
+ const bailResult = (
1937
+ // The `cancel` prop or `stop` method was used.
1938
+ callId <= (state.cancelId || 0) && getCancelledResult(target) || // The async `to` prop was replaced.
1939
+ callId !== state.asyncId && getFinishedResult(target, false)
1940
+ );
1941
+ if (bailResult) {
1942
+ bailSignal.result = bailResult;
1943
+ bail(bailSignal);
1944
+ throw bailSignal;
1945
+ }
1946
+ };
1947
+ const animate = (arg1, arg2) => {
1948
+ const bailSignal = new BailSignal();
1949
+ const skipAnimationSignal = new SkipAnimationSignal();
1950
+ return (async () => {
1951
+ if (globals_exports.skipAnimation) {
1952
+ stopAsync(state);
1953
+ skipAnimationSignal.result = getFinishedResult(target, false);
1954
+ bail(skipAnimationSignal);
1955
+ throw skipAnimationSignal;
1956
+ }
1957
+ bailIfEnded(bailSignal);
1958
+ const props2 = is.obj(arg1) ? { ...arg1 } : { ...arg2, to: arg1 };
1959
+ props2.parentId = callId;
1960
+ eachProp(defaultProps, (value, key) => {
1961
+ if (is.und(props2[key])) {
1962
+ props2[key] = value;
1963
+ }
1964
+ });
1965
+ const result2 = await target.start(props2);
1966
+ bailIfEnded(bailSignal);
1967
+ if (state.paused) {
1968
+ await new Promise((resume) => {
1969
+ state.resumeQueue.add(resume);
1970
+ });
1971
+ }
1972
+ return result2;
1973
+ })();
1974
+ };
1975
+ let result;
1976
+ if (globals_exports.skipAnimation) {
1977
+ stopAsync(state);
1978
+ return getFinishedResult(target, false);
1979
+ }
1980
+ try {
1981
+ let animating;
1982
+ if (is.arr(to2)) {
1983
+ animating = (async (queue) => {
1984
+ for (const props2 of queue) {
1985
+ await animate(props2);
1986
+ }
1987
+ })(to2);
1988
+ } else {
1989
+ animating = Promise.resolve(to2(animate, target.stop.bind(target)));
1990
+ }
1991
+ await Promise.all([animating.then(preventBail), bailPromise]);
1992
+ result = getFinishedResult(target.get(), true, false);
1993
+ } catch (err) {
1994
+ if (err instanceof BailSignal) {
1995
+ result = err.result;
1996
+ } else if (err instanceof SkipAnimationSignal) {
1997
+ result = err.result;
1998
+ } else {
1999
+ throw err;
2000
+ }
2001
+ } finally {
2002
+ if (callId == state.asyncId) {
2003
+ state.asyncId = parentId;
2004
+ state.asyncTo = parentId ? prevTo : void 0;
2005
+ state.promise = parentId ? prevPromise : void 0;
2006
+ }
2007
+ }
2008
+ if (is.fun(onRest)) {
2009
+ raf.batchedUpdates(() => {
2010
+ onRest(result, target, target.item);
2011
+ });
2012
+ }
2013
+ return result;
2014
+ })();
2015
+ }
2016
+ function stopAsync(state, cancelId) {
2017
+ flush(state.timeouts, (t) => t.cancel());
2018
+ state.pauseQueue.clear();
2019
+ state.resumeQueue.clear();
2020
+ state.asyncId = state.asyncTo = state.promise = void 0;
2021
+ if (cancelId)
2022
+ state.cancelId = cancelId;
2023
+ }
2024
+ var BailSignal = class extends Error {
2025
+ constructor() {
2026
+ super(
2027
+ "An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise."
2028
+ );
2029
+ }
2030
+ };
2031
+ var SkipAnimationSignal = class extends Error {
2032
+ constructor() {
2033
+ super("SkipAnimationSignal");
2034
+ }
2035
+ };
2036
+ var isFrameValue = (value) => value instanceof FrameValue;
2037
+ var nextId = 1;
2038
+ var FrameValue = class extends FluidValue {
2039
+ constructor() {
2040
+ super(...arguments);
2041
+ this.id = nextId++;
2042
+ this._priority = 0;
2043
+ }
2044
+ get priority() {
2045
+ return this._priority;
2046
+ }
2047
+ set priority(priority) {
2048
+ if (this._priority != priority) {
2049
+ this._priority = priority;
2050
+ this._onPriorityChange(priority);
2051
+ }
2052
+ }
2053
+ /** Get the current value */
2054
+ get() {
2055
+ const node = getAnimated(this);
2056
+ return node && node.getValue();
2057
+ }
2058
+ /** Create a spring that maps our value to another value */
2059
+ to(...args) {
2060
+ return globals_exports.to(this, args);
2061
+ }
2062
+ /** @deprecated Use the `to` method instead. */
2063
+ interpolate(...args) {
2064
+ deprecateInterpolate();
2065
+ return globals_exports.to(this, args);
2066
+ }
2067
+ toJSON() {
2068
+ return this.get();
2069
+ }
2070
+ observerAdded(count) {
2071
+ if (count == 1)
2072
+ this._attach();
2073
+ }
2074
+ observerRemoved(count) {
2075
+ if (count == 0)
2076
+ this._detach();
2077
+ }
2078
+ /** Called when the first child is added. */
2079
+ _attach() {
2080
+ }
2081
+ /** Called when the last child is removed. */
2082
+ _detach() {
2083
+ }
2084
+ /** Tell our children about our new value */
2085
+ _onChange(value, idle = false) {
2086
+ callFluidObservers(this, {
2087
+ type: "change",
2088
+ parent: this,
2089
+ value,
2090
+ idle
2091
+ });
2092
+ }
2093
+ /** Tell our children about our new priority */
2094
+ _onPriorityChange(priority) {
2095
+ if (!this.idle) {
2096
+ frameLoop.sort(this);
2097
+ }
2098
+ callFluidObservers(this, {
2099
+ type: "priority",
2100
+ parent: this,
2101
+ priority
2102
+ });
2103
+ }
2104
+ };
2105
+
2106
+ // src/SpringPhase.ts
2107
+ var $P = Symbol.for("SpringPhase");
2108
+ var HAS_ANIMATED = 1;
2109
+ var IS_ANIMATING = 2;
2110
+ var IS_PAUSED = 4;
2111
+ var hasAnimated = (target) => (target[$P] & HAS_ANIMATED) > 0;
2112
+ var isAnimating = (target) => (target[$P] & IS_ANIMATING) > 0;
2113
+ var isPaused = (target) => (target[$P] & IS_PAUSED) > 0;
2114
+ var setActiveBit = (target, active) => active ? target[$P] |= IS_ANIMATING | HAS_ANIMATED : target[$P] &= ~IS_ANIMATING;
2115
+ var setPausedBit = (target, paused) => paused ? target[$P] |= IS_PAUSED : target[$P] &= ~IS_PAUSED;
2116
+
2117
+ // src/SpringValue.ts
2118
+ var SpringValue = class extends FrameValue {
2119
+ constructor(arg1, arg2) {
2120
+ super();
2121
+ /** The animation state */
2122
+ this.animation = new Animation();
2123
+ /** Some props have customizable default values */
2124
+ this.defaultProps = {};
2125
+ /** The state for `runAsync` calls */
2126
+ this._state = {
2127
+ paused: false,
2128
+ delayed: false,
2129
+ pauseQueue: /* @__PURE__ */ new Set(),
2130
+ resumeQueue: /* @__PURE__ */ new Set(),
2131
+ timeouts: /* @__PURE__ */ new Set()
2132
+ };
2133
+ /** The promise resolvers of pending `start` calls */
2134
+ this._pendingCalls = /* @__PURE__ */ new Set();
2135
+ /** The counter for tracking `scheduleProps` calls */
2136
+ this._lastCallId = 0;
2137
+ /** The last `scheduleProps` call that changed the `to` prop */
2138
+ this._lastToId = 0;
2139
+ this._memoizedDuration = 0;
2140
+ if (!is.und(arg1) || !is.und(arg2)) {
2141
+ const props = is.obj(arg1) ? { ...arg1 } : { ...arg2, from: arg1 };
2142
+ if (is.und(props.default)) {
2143
+ props.default = true;
2144
+ }
2145
+ this.start(props);
2146
+ }
2147
+ }
2148
+ /** Equals true when not advancing on each frame. */
2149
+ get idle() {
2150
+ return !(isAnimating(this) || this._state.asyncTo) || isPaused(this);
2151
+ }
2152
+ get goal() {
2153
+ return getFluidValue(this.animation.to);
2154
+ }
2155
+ get velocity() {
2156
+ const node = getAnimated(this);
2157
+ return node instanceof AnimatedValue ? node.lastVelocity || 0 : node.getPayload().map((node2) => node2.lastVelocity || 0);
2158
+ }
2159
+ /**
2160
+ * When true, this value has been animated at least once.
2161
+ */
2162
+ get hasAnimated() {
2163
+ return hasAnimated(this);
2164
+ }
2165
+ /**
2166
+ * When true, this value has an unfinished animation,
2167
+ * which is either active or paused.
2168
+ */
2169
+ get isAnimating() {
2170
+ return isAnimating(this);
2171
+ }
2172
+ /**
2173
+ * When true, all current and future animations are paused.
2174
+ */
2175
+ get isPaused() {
2176
+ return isPaused(this);
2177
+ }
2178
+ /**
2179
+ *
2180
+ *
2181
+ */
2182
+ get isDelayed() {
2183
+ return this._state.delayed;
2184
+ }
2185
+ /** Advance the current animation by a number of milliseconds */
2186
+ advance(dt) {
2187
+ let idle = true;
2188
+ let changed = false;
2189
+ const anim = this.animation;
2190
+ let { toValues } = anim;
2191
+ const { config: config2 } = anim;
2192
+ const payload = getPayload(anim.to);
2193
+ if (!payload && hasFluidValue(anim.to)) {
2194
+ toValues = toArray(getFluidValue(anim.to));
2195
+ }
2196
+ anim.values.forEach((node2, i) => {
2197
+ if (node2.done)
2198
+ return;
2199
+ const to2 = (
2200
+ // Animated strings always go from 0 to 1.
2201
+ node2.constructor == AnimatedString ? 1 : payload ? payload[i].lastPosition : toValues[i]
2202
+ );
2203
+ let finished = anim.immediate;
2204
+ let position = to2;
2205
+ if (!finished) {
2206
+ position = node2.lastPosition;
2207
+ if (config2.tension <= 0) {
2208
+ node2.done = true;
2209
+ return;
2210
+ }
2211
+ let elapsed = node2.elapsedTime += dt;
2212
+ const from = anim.fromValues[i];
2213
+ const v0 = node2.v0 != null ? node2.v0 : node2.v0 = is.arr(config2.velocity) ? config2.velocity[i] : config2.velocity;
2214
+ let velocity;
2215
+ const precision = config2.precision || (from == to2 ? 5e-3 : Math.min(1, Math.abs(to2 - from) * 1e-3));
2216
+ if (!is.und(config2.duration)) {
2217
+ let p = 1;
2218
+ if (config2.duration > 0) {
2219
+ if (this._memoizedDuration !== config2.duration) {
2220
+ this._memoizedDuration = config2.duration;
2221
+ if (node2.durationProgress > 0) {
2222
+ node2.elapsedTime = config2.duration * node2.durationProgress;
2223
+ elapsed = node2.elapsedTime += dt;
2224
+ }
2225
+ }
2226
+ p = (config2.progress || 0) + elapsed / this._memoizedDuration;
2227
+ p = p > 1 ? 1 : p < 0 ? 0 : p;
2228
+ node2.durationProgress = p;
2229
+ }
2230
+ position = from + config2.easing(p) * (to2 - from);
2231
+ velocity = (position - node2.lastPosition) / dt;
2232
+ finished = p == 1;
2233
+ } else if (config2.decay) {
2234
+ const decay = config2.decay === true ? 0.998 : config2.decay;
2235
+ const e = Math.exp(-(1 - decay) * elapsed);
2236
+ position = from + v0 / (1 - decay) * (1 - e);
2237
+ finished = Math.abs(node2.lastPosition - position) <= precision;
2238
+ velocity = v0 * e;
2239
+ } else {
2240
+ velocity = node2.lastVelocity == null ? v0 : node2.lastVelocity;
2241
+ const restVelocity = config2.restVelocity || precision / 10;
2242
+ const bounceFactor = config2.clamp ? 0 : config2.bounce;
2243
+ const canBounce = !is.und(bounceFactor);
2244
+ const isGrowing = from == to2 ? node2.v0 > 0 : from < to2;
2245
+ let isMoving;
2246
+ let isBouncing = false;
2247
+ const step = 1;
2248
+ const numSteps = Math.ceil(dt / step);
2249
+ for (let n = 0; n < numSteps; ++n) {
2250
+ isMoving = Math.abs(velocity) > restVelocity;
2251
+ if (!isMoving) {
2252
+ finished = Math.abs(to2 - position) <= precision;
2253
+ if (finished) {
2254
+ break;
2255
+ }
2256
+ }
2257
+ if (canBounce) {
2258
+ isBouncing = position == to2 || position > to2 == isGrowing;
2259
+ if (isBouncing) {
2260
+ velocity = -velocity * bounceFactor;
2261
+ position = to2;
2262
+ }
2263
+ }
2264
+ const springForce = -config2.tension * 1e-6 * (position - to2);
2265
+ const dampingForce = -config2.friction * 1e-3 * velocity;
2266
+ const acceleration = (springForce + dampingForce) / config2.mass;
2267
+ velocity = velocity + acceleration * step;
2268
+ position = position + velocity * step;
2269
+ }
2270
+ }
2271
+ node2.lastVelocity = velocity;
2272
+ if (Number.isNaN(position)) {
2273
+ console.warn(`Got NaN while animating:`, this);
2274
+ finished = true;
2275
+ }
2276
+ }
2277
+ if (payload && !payload[i].done) {
2278
+ finished = false;
2279
+ }
2280
+ if (finished) {
2281
+ node2.done = true;
2282
+ } else {
2283
+ idle = false;
2284
+ }
2285
+ if (node2.setValue(position, config2.round)) {
2286
+ changed = true;
2287
+ }
2288
+ });
2289
+ const node = getAnimated(this);
2290
+ const currVal = node.getValue();
2291
+ if (idle) {
2292
+ const finalVal = getFluidValue(anim.to);
2293
+ if ((currVal !== finalVal || changed) && !config2.decay) {
2294
+ node.setValue(finalVal);
2295
+ this._onChange(finalVal);
2296
+ } else if (changed && config2.decay) {
2297
+ this._onChange(currVal);
2298
+ }
2299
+ this._stop();
2300
+ } else if (changed) {
2301
+ this._onChange(currVal);
2302
+ }
2303
+ }
2304
+ /** Set the current value, while stopping the current animation */
2305
+ set(value) {
2306
+ raf.batchedUpdates(() => {
2307
+ this._stop();
2308
+ this._focus(value);
2309
+ this._set(value);
2310
+ });
2311
+ return this;
2312
+ }
2313
+ /**
2314
+ * Freeze the active animation in time, as well as any updates merged
2315
+ * before `resume` is called.
2316
+ */
2317
+ pause() {
2318
+ this._update({ pause: true });
2319
+ }
2320
+ /** Resume the animation if paused. */
2321
+ resume() {
2322
+ this._update({ pause: false });
2323
+ }
2324
+ /** Skip to the end of the current animation. */
2325
+ finish() {
2326
+ if (isAnimating(this)) {
2327
+ const { to: to2, config: config2 } = this.animation;
2328
+ raf.batchedUpdates(() => {
2329
+ this._onStart();
2330
+ if (!config2.decay) {
2331
+ this._set(to2, false);
2332
+ }
2333
+ this._stop();
2334
+ });
2335
+ }
2336
+ return this;
2337
+ }
2338
+ /** Push props into the pending queue. */
2339
+ update(props) {
2340
+ const queue = this.queue || (this.queue = []);
2341
+ queue.push(props);
2342
+ return this;
2343
+ }
2344
+ start(to2, arg2) {
2345
+ let queue;
2346
+ if (!is.und(to2)) {
2347
+ queue = [is.obj(to2) ? to2 : { ...arg2, to: to2 }];
2348
+ } else {
2349
+ queue = this.queue || [];
2350
+ this.queue = [];
2351
+ }
2352
+ return Promise.all(
2353
+ queue.map((props) => {
2354
+ const up = this._update(props);
2355
+ return up;
2356
+ })
2357
+ ).then((results) => getCombinedResult(this, results));
2358
+ }
2359
+ /**
2360
+ * Stop the current animation, and cancel any delayed updates.
2361
+ *
2362
+ * Pass `true` to call `onRest` with `cancelled: true`.
2363
+ */
2364
+ stop(cancel) {
2365
+ const { to: to2 } = this.animation;
2366
+ this._focus(this.get());
2367
+ stopAsync(this._state, cancel && this._lastCallId);
2368
+ raf.batchedUpdates(() => this._stop(to2, cancel));
2369
+ return this;
2370
+ }
2371
+ /** Restart the animation. */
2372
+ reset() {
2373
+ this._update({ reset: true });
2374
+ }
2375
+ /** @internal */
2376
+ eventObserved(event) {
2377
+ if (event.type == "change") {
2378
+ this._start();
2379
+ } else if (event.type == "priority") {
2380
+ this.priority = event.priority + 1;
2381
+ }
2382
+ }
2383
+ /**
2384
+ * Parse the `to` and `from` range from the given `props` object.
2385
+ *
2386
+ * This also ensures the initial value is available to animated components
2387
+ * during the render phase.
2388
+ */
2389
+ _prepareNode(props) {
2390
+ const key = this.key || "";
2391
+ let { to: to2, from } = props;
2392
+ to2 = is.obj(to2) ? to2[key] : to2;
2393
+ if (to2 == null || isAsyncTo(to2)) {
2394
+ to2 = void 0;
2395
+ }
2396
+ from = is.obj(from) ? from[key] : from;
2397
+ if (from == null) {
2398
+ from = void 0;
2399
+ }
2400
+ const range = { to: to2, from };
2401
+ if (!hasAnimated(this)) {
2402
+ if (props.reverse)
2403
+ [to2, from] = [from, to2];
2404
+ from = getFluidValue(from);
2405
+ if (!is.und(from)) {
2406
+ this._set(from);
2407
+ } else if (!getAnimated(this)) {
2408
+ this._set(to2);
2409
+ }
2410
+ }
2411
+ return range;
2412
+ }
2413
+ /** Every update is processed by this method before merging. */
2414
+ _update({ ...props }, isLoop) {
2415
+ const { key, defaultProps } = this;
2416
+ if (props.default)
2417
+ Object.assign(
2418
+ defaultProps,
2419
+ getDefaultProps(
2420
+ props,
2421
+ (value, prop) => /^on/.test(prop) ? resolveProp(value, key) : value
2422
+ )
2423
+ );
2424
+ mergeActiveFn(this, props, "onProps");
2425
+ sendEvent(this, "onProps", props, this);
2426
+ const range = this._prepareNode(props);
2427
+ if (Object.isFrozen(this)) {
2428
+ throw Error(
2429
+ "Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?"
2430
+ );
2431
+ }
2432
+ const state = this._state;
2433
+ return scheduleProps(++this._lastCallId, {
2434
+ key,
2435
+ props,
2436
+ defaultProps,
2437
+ state,
2438
+ actions: {
2439
+ pause: () => {
2440
+ if (!isPaused(this)) {
2441
+ setPausedBit(this, true);
2442
+ flushCalls(state.pauseQueue);
2443
+ sendEvent(
2444
+ this,
2445
+ "onPause",
2446
+ getFinishedResult(this, checkFinished(this, this.animation.to)),
2447
+ this
2448
+ );
2449
+ }
2450
+ },
2451
+ resume: () => {
2452
+ if (isPaused(this)) {
2453
+ setPausedBit(this, false);
2454
+ if (isAnimating(this)) {
2455
+ this._resume();
2456
+ }
2457
+ flushCalls(state.resumeQueue);
2458
+ sendEvent(
2459
+ this,
2460
+ "onResume",
2461
+ getFinishedResult(this, checkFinished(this, this.animation.to)),
2462
+ this
2463
+ );
2464
+ }
2465
+ },
2466
+ start: this._merge.bind(this, range)
2467
+ }
2468
+ }).then((result) => {
2469
+ if (props.loop && result.finished && !(isLoop && result.noop)) {
2470
+ const nextProps = createLoopUpdate(props);
2471
+ if (nextProps) {
2472
+ return this._update(nextProps, true);
2473
+ }
2474
+ }
2475
+ return result;
2476
+ });
2477
+ }
2478
+ /** Merge props into the current animation */
2479
+ _merge(range, props, resolve) {
2480
+ if (props.cancel) {
2481
+ this.stop(true);
2482
+ return resolve(getCancelledResult(this));
2483
+ }
2484
+ const hasToProp = !is.und(range.to);
2485
+ const hasFromProp = !is.und(range.from);
2486
+ if (hasToProp || hasFromProp) {
2487
+ if (props.callId > this._lastToId) {
2488
+ this._lastToId = props.callId;
2489
+ } else {
2490
+ return resolve(getCancelledResult(this));
2491
+ }
2492
+ }
2493
+ const { key, defaultProps, animation: anim } = this;
2494
+ const { to: prevTo, from: prevFrom } = anim;
2495
+ let { to: to2 = prevTo, from = prevFrom } = range;
2496
+ if (hasFromProp && !hasToProp && (!props.default || is.und(to2))) {
2497
+ to2 = from;
2498
+ }
2499
+ if (props.reverse)
2500
+ [to2, from] = [from, to2];
2501
+ const hasFromChanged = !isEqual(from, prevFrom);
2502
+ if (hasFromChanged) {
2503
+ anim.from = from;
2504
+ }
2505
+ from = getFluidValue(from);
2506
+ const hasToChanged = !isEqual(to2, prevTo);
2507
+ if (hasToChanged) {
2508
+ this._focus(to2);
2509
+ }
2510
+ const hasAsyncTo = isAsyncTo(props.to);
2511
+ const { config: config2 } = anim;
2512
+ const { decay, velocity } = config2;
2513
+ if (hasToProp || hasFromProp) {
2514
+ config2.velocity = 0;
2515
+ }
2516
+ if (props.config && !hasAsyncTo) {
2517
+ mergeConfig(
2518
+ config2,
2519
+ callProp(props.config, key),
2520
+ // Avoid calling the same "config" prop twice.
2521
+ props.config !== defaultProps.config ? callProp(defaultProps.config, key) : void 0
2522
+ );
2523
+ }
2524
+ let node = getAnimated(this);
2525
+ if (!node || is.und(to2)) {
2526
+ return resolve(getFinishedResult(this, true));
2527
+ }
2528
+ const reset = (
2529
+ // When `reset` is undefined, the `from` prop implies `reset: true`,
2530
+ // except for declarative updates. When `reset` is defined, there
2531
+ // must exist a value to animate from.
2532
+ is.und(props.reset) ? hasFromProp && !props.default : !is.und(from) && matchProp(props.reset, key)
2533
+ );
2534
+ const value = reset ? from : this.get();
2535
+ const goal = computeGoal(to2);
2536
+ const isAnimatable = is.num(goal) || is.arr(goal) || isAnimatedString(goal);
2537
+ const immediate = !hasAsyncTo && (!isAnimatable || matchProp(defaultProps.immediate || props.immediate, key));
2538
+ if (hasToChanged) {
2539
+ const nodeType = getAnimatedType(to2);
2540
+ if (nodeType !== node.constructor) {
2541
+ if (immediate) {
2542
+ node = this._set(goal);
2543
+ } else
2544
+ throw Error(
2545
+ `Cannot animate between ${node.constructor.name} and ${nodeType.name}, as the "to" prop suggests`
2546
+ );
2547
+ }
2548
+ }
2549
+ const goalType = node.constructor;
2550
+ let started = hasFluidValue(to2);
2551
+ let finished = false;
2552
+ if (!started) {
2553
+ const hasValueChanged = reset || !hasAnimated(this) && hasFromChanged;
2554
+ if (hasToChanged || hasValueChanged) {
2555
+ finished = isEqual(computeGoal(value), goal);
2556
+ started = !finished;
2557
+ }
2558
+ if (!isEqual(anim.immediate, immediate) && !immediate || !isEqual(config2.decay, decay) || !isEqual(config2.velocity, velocity)) {
2559
+ started = true;
2560
+ }
2561
+ }
2562
+ if (finished && isAnimating(this)) {
2563
+ if (anim.changed && !reset) {
2564
+ started = true;
2565
+ } else if (!started) {
2566
+ this._stop(prevTo);
2567
+ }
2568
+ }
2569
+ if (!hasAsyncTo) {
2570
+ if (started || hasFluidValue(prevTo)) {
2571
+ anim.values = node.getPayload();
2572
+ anim.toValues = hasFluidValue(to2) ? null : goalType == AnimatedString ? [1] : toArray(goal);
2573
+ }
2574
+ if (anim.immediate != immediate) {
2575
+ anim.immediate = immediate;
2576
+ if (!immediate && !reset) {
2577
+ this._set(prevTo);
2578
+ }
2579
+ }
2580
+ if (started) {
2581
+ const { onRest } = anim;
2582
+ each(ACTIVE_EVENTS, (type) => mergeActiveFn(this, props, type));
2583
+ const result = getFinishedResult(this, checkFinished(this, prevTo));
2584
+ flushCalls(this._pendingCalls, result);
2585
+ this._pendingCalls.add(resolve);
2586
+ if (anim.changed)
2587
+ raf.batchedUpdates(() => {
2588
+ anim.changed = !reset;
2589
+ onRest?.(result, this);
2590
+ if (reset) {
2591
+ callProp(defaultProps.onRest, result);
2592
+ } else {
2593
+ anim.onStart?.(result, this);
2594
+ }
2595
+ });
2596
+ }
2597
+ }
2598
+ if (reset) {
2599
+ this._set(value);
2600
+ }
2601
+ if (hasAsyncTo) {
2602
+ resolve(runAsync(props.to, props, this._state, this));
2603
+ } else if (started) {
2604
+ this._start();
2605
+ } else if (isAnimating(this) && !hasToChanged) {
2606
+ this._pendingCalls.add(resolve);
2607
+ } else {
2608
+ resolve(getNoopResult(value));
2609
+ }
2610
+ }
2611
+ /** Update the `animation.to` value, which might be a `FluidValue` */
2612
+ _focus(value) {
2613
+ const anim = this.animation;
2614
+ if (value !== anim.to) {
2615
+ if (getFluidObservers(this)) {
2616
+ this._detach();
2617
+ }
2618
+ anim.to = value;
2619
+ if (getFluidObservers(this)) {
2620
+ this._attach();
2621
+ }
2622
+ }
2623
+ }
2624
+ _attach() {
2625
+ let priority = 0;
2626
+ const { to: to2 } = this.animation;
2627
+ if (hasFluidValue(to2)) {
2628
+ addFluidObserver(to2, this);
2629
+ if (isFrameValue(to2)) {
2630
+ priority = to2.priority + 1;
2631
+ }
2632
+ }
2633
+ this.priority = priority;
2634
+ }
2635
+ _detach() {
2636
+ const { to: to2 } = this.animation;
2637
+ if (hasFluidValue(to2)) {
2638
+ removeFluidObserver(to2, this);
2639
+ }
2640
+ }
2641
+ /**
2642
+ * Update the current value from outside the frameloop,
2643
+ * and return the `Animated` node.
2644
+ */
2645
+ _set(arg, idle = true) {
2646
+ const value = getFluidValue(arg);
2647
+ if (!is.und(value)) {
2648
+ const oldNode = getAnimated(this);
2649
+ if (!oldNode || !isEqual(value, oldNode.getValue())) {
2650
+ const nodeType = getAnimatedType(value);
2651
+ if (!oldNode || oldNode.constructor != nodeType) {
2652
+ setAnimated(this, nodeType.create(value));
2653
+ } else {
2654
+ oldNode.setValue(value);
2655
+ }
2656
+ if (oldNode) {
2657
+ raf.batchedUpdates(() => {
2658
+ this._onChange(value, idle);
2659
+ });
2660
+ }
2661
+ }
2662
+ }
2663
+ return getAnimated(this);
2664
+ }
2665
+ _onStart() {
2666
+ const anim = this.animation;
2667
+ if (!anim.changed) {
2668
+ anim.changed = true;
2669
+ sendEvent(
2670
+ this,
2671
+ "onStart",
2672
+ getFinishedResult(this, checkFinished(this, anim.to)),
2673
+ this
2674
+ );
2675
+ }
2676
+ }
2677
+ _onChange(value, idle) {
2678
+ if (!idle) {
2679
+ this._onStart();
2680
+ callProp(this.animation.onChange, value, this);
2681
+ }
2682
+ callProp(this.defaultProps.onChange, value, this);
2683
+ super._onChange(value, idle);
2684
+ }
2685
+ // This method resets the animation state (even if already animating) to
2686
+ // ensure the latest from/to range is used, and it also ensures this spring
2687
+ // is added to the frameloop.
2688
+ _start() {
2689
+ const anim = this.animation;
2690
+ getAnimated(this).reset(getFluidValue(anim.to));
2691
+ if (!anim.immediate) {
2692
+ anim.fromValues = anim.values.map((node) => node.lastPosition);
2693
+ }
2694
+ if (!isAnimating(this)) {
2695
+ setActiveBit(this, true);
2696
+ if (!isPaused(this)) {
2697
+ this._resume();
2698
+ }
2699
+ }
2700
+ }
2701
+ _resume() {
2702
+ if (globals_exports.skipAnimation) {
2703
+ this.finish();
2704
+ } else {
2705
+ frameLoop.start(this);
2706
+ }
2707
+ }
2708
+ /**
2709
+ * Exit the frameloop and notify `onRest` listeners.
2710
+ *
2711
+ * Always wrap `_stop` calls with `batchedUpdates`.
2712
+ */
2713
+ _stop(goal, cancel) {
2714
+ if (isAnimating(this)) {
2715
+ setActiveBit(this, false);
2716
+ const anim = this.animation;
2717
+ each(anim.values, (node) => {
2718
+ node.done = true;
2719
+ });
2720
+ if (anim.toValues) {
2721
+ anim.onChange = anim.onPause = anim.onResume = void 0;
2722
+ }
2723
+ callFluidObservers(this, {
2724
+ type: "idle",
2725
+ parent: this
2726
+ });
2727
+ const result = cancel ? getCancelledResult(this.get()) : getFinishedResult(this.get(), checkFinished(this, goal ?? anim.to));
2728
+ flushCalls(this._pendingCalls, result);
2729
+ if (anim.changed) {
2730
+ anim.changed = false;
2731
+ sendEvent(this, "onRest", result, this);
2732
+ }
2733
+ }
2734
+ }
2735
+ };
2736
+ function checkFinished(target, to2) {
2737
+ const goal = computeGoal(to2);
2738
+ const value = computeGoal(target.get());
2739
+ return isEqual(value, goal);
2740
+ }
2741
+ function createLoopUpdate(props, loop = props.loop, to2 = props.to) {
2742
+ const loopRet = callProp(loop);
2743
+ if (loopRet) {
2744
+ const overrides = loopRet !== true && inferTo(loopRet);
2745
+ const reverse = (overrides || props).reverse;
2746
+ const reset = !overrides || overrides.reset;
2747
+ return createUpdate({
2748
+ ...props,
2749
+ loop,
2750
+ // Avoid updating default props when looping.
2751
+ default: false,
2752
+ // Never loop the `pause` prop.
2753
+ pause: void 0,
2754
+ // For the "reverse" prop to loop as expected, the "to" prop
2755
+ // must be undefined. The "reverse" prop is ignored when the
2756
+ // "to" prop is an array or function.
2757
+ to: !reverse || isAsyncTo(to2) ? to2 : void 0,
2758
+ // Ignore the "from" prop except on reset.
2759
+ from: reset ? props.from : void 0,
2760
+ reset,
2761
+ // The "loop" prop can return a "useSpring" props object to
2762
+ // override any of the original props.
2763
+ ...overrides
2764
+ });
2765
+ }
2766
+ }
2767
+ function createUpdate(props) {
2768
+ const { to: to2, from } = props = inferTo(props);
2769
+ const keys = /* @__PURE__ */ new Set();
2770
+ if (is.obj(to2))
2771
+ findDefined(to2, keys);
2772
+ if (is.obj(from))
2773
+ findDefined(from, keys);
2774
+ props.keys = keys.size ? Array.from(keys) : null;
2775
+ return props;
2776
+ }
2777
+ function declareUpdate(props) {
2778
+ const update2 = createUpdate(props);
2779
+ if (is.und(update2.default)) {
2780
+ update2.default = getDefaultProps(update2);
2781
+ }
2782
+ return update2;
2783
+ }
2784
+ function findDefined(values, keys) {
2785
+ eachProp(values, (value, key) => value != null && keys.add(key));
2786
+ }
2787
+ var ACTIVE_EVENTS = [
2788
+ "onStart",
2789
+ "onRest",
2790
+ "onChange",
2791
+ "onPause",
2792
+ "onResume"
2793
+ ];
2794
+ function mergeActiveFn(target, props, type) {
2795
+ target.animation[type] = props[type] !== getDefaultProp(props, type) ? resolveProp(props[type], target.key) : void 0;
2796
+ }
2797
+ function sendEvent(target, type, ...args) {
2798
+ target.animation[type]?.(...args);
2799
+ target.defaultProps[type]?.(...args);
2800
+ }
2801
+ var BATCHED_EVENTS = ["onStart", "onChange", "onRest"];
2802
+ var nextId2 = 1;
2803
+ var Controller = class {
2804
+ constructor(props, flush3) {
2805
+ this.id = nextId2++;
2806
+ /** The animated values */
2807
+ this.springs = {};
2808
+ /** The queue of props passed to the `update` method. */
2809
+ this.queue = [];
2810
+ /** The counter for tracking `scheduleProps` calls */
2811
+ this._lastAsyncId = 0;
2812
+ /** The values currently being animated */
2813
+ this._active = /* @__PURE__ */ new Set();
2814
+ /** The values that changed recently */
2815
+ this._changed = /* @__PURE__ */ new Set();
2816
+ /** Equals false when `onStart` listeners can be called */
2817
+ this._started = false;
2818
+ /** State used by the `runAsync` function */
2819
+ this._state = {
2820
+ paused: false,
2821
+ pauseQueue: /* @__PURE__ */ new Set(),
2822
+ resumeQueue: /* @__PURE__ */ new Set(),
2823
+ timeouts: /* @__PURE__ */ new Set()
2824
+ };
2825
+ /** The event queues that are flushed once per frame maximum */
2826
+ this._events = {
2827
+ onStart: /* @__PURE__ */ new Map(),
2828
+ onChange: /* @__PURE__ */ new Map(),
2829
+ onRest: /* @__PURE__ */ new Map()
2830
+ };
2831
+ this._onFrame = this._onFrame.bind(this);
2832
+ if (flush3) {
2833
+ this._flush = flush3;
2834
+ }
2835
+ if (props) {
2836
+ this.start({ default: true, ...props });
2837
+ }
2838
+ }
2839
+ /**
2840
+ * Equals `true` when no spring values are in the frameloop, and
2841
+ * no async animation is currently active.
2842
+ */
2843
+ get idle() {
2844
+ return !this._state.asyncTo && Object.values(this.springs).every((spring) => {
2845
+ return spring.idle && !spring.isDelayed && !spring.isPaused;
2846
+ });
2847
+ }
2848
+ get item() {
2849
+ return this._item;
2850
+ }
2851
+ set item(item) {
2852
+ this._item = item;
2853
+ }
2854
+ /** Get the current values of our springs */
2855
+ get() {
2856
+ const values = {};
2857
+ this.each((spring, key) => values[key] = spring.get());
2858
+ return values;
2859
+ }
2860
+ /** Set the current values without animating. */
2861
+ set(values) {
2862
+ for (const key in values) {
2863
+ const value = values[key];
2864
+ if (!is.und(value)) {
2865
+ this.springs[key].set(value);
2866
+ }
2867
+ }
2868
+ }
2869
+ /** Push an update onto the queue of each value. */
2870
+ update(props) {
2871
+ if (props) {
2872
+ this.queue.push(createUpdate(props));
2873
+ }
2874
+ return this;
2875
+ }
2876
+ /**
2877
+ * Start the queued animations for every spring, and resolve the returned
2878
+ * promise once all queued animations have finished or been cancelled.
2879
+ *
2880
+ * When you pass a queue (instead of nothing), that queue is used instead of
2881
+ * the queued animations added with the `update` method, which are left alone.
2882
+ */
2883
+ start(props) {
2884
+ let { queue } = this;
2885
+ if (props) {
2886
+ queue = toArray(props).map(createUpdate);
2887
+ } else {
2888
+ this.queue = [];
2889
+ }
2890
+ if (this._flush) {
2891
+ return this._flush(this, queue);
2892
+ }
2893
+ prepareKeys(this, queue);
2894
+ return flushUpdateQueue(this, queue);
2895
+ }
2896
+ /** @internal */
2897
+ stop(arg, keys) {
2898
+ if (arg !== !!arg) {
2899
+ keys = arg;
2900
+ }
2901
+ if (keys) {
2902
+ const springs = this.springs;
2903
+ each(toArray(keys), (key) => springs[key].stop(!!arg));
2904
+ } else {
2905
+ stopAsync(this._state, this._lastAsyncId);
2906
+ this.each((spring) => spring.stop(!!arg));
2907
+ }
2908
+ return this;
2909
+ }
2910
+ /** Freeze the active animation in time */
2911
+ pause(keys) {
2912
+ if (is.und(keys)) {
2913
+ this.start({ pause: true });
2914
+ } else {
2915
+ const springs = this.springs;
2916
+ each(toArray(keys), (key) => springs[key].pause());
2917
+ }
2918
+ return this;
2919
+ }
2920
+ /** Resume the animation if paused. */
2921
+ resume(keys) {
2922
+ if (is.und(keys)) {
2923
+ this.start({ pause: false });
2924
+ } else {
2925
+ const springs = this.springs;
2926
+ each(toArray(keys), (key) => springs[key].resume());
2927
+ }
2928
+ return this;
2929
+ }
2930
+ /** Call a function once per spring value */
2931
+ each(iterator) {
2932
+ eachProp(this.springs, iterator);
2933
+ }
2934
+ /** @internal Called at the end of every animation frame */
2935
+ _onFrame() {
2936
+ const { onStart, onChange, onRest } = this._events;
2937
+ const active = this._active.size > 0;
2938
+ const changed = this._changed.size > 0;
2939
+ if (active && !this._started || changed && !this._started) {
2940
+ this._started = true;
2941
+ flush(onStart, ([onStart2, result]) => {
2942
+ result.value = this.get();
2943
+ onStart2(result, this, this._item);
2944
+ });
2945
+ }
2946
+ const idle = !active && this._started;
2947
+ const values = changed || idle && onRest.size ? this.get() : null;
2948
+ if (changed && onChange.size) {
2949
+ flush(onChange, ([onChange2, result]) => {
2950
+ result.value = values;
2951
+ onChange2(result, this, this._item);
2952
+ });
2953
+ }
2954
+ if (idle) {
2955
+ this._started = false;
2956
+ flush(onRest, ([onRest2, result]) => {
2957
+ result.value = values;
2958
+ onRest2(result, this, this._item);
2959
+ });
2960
+ }
2961
+ }
2962
+ /** @internal */
2963
+ eventObserved(event) {
2964
+ if (event.type == "change") {
2965
+ this._changed.add(event.parent);
2966
+ if (!event.idle) {
2967
+ this._active.add(event.parent);
2968
+ }
2969
+ } else if (event.type == "idle") {
2970
+ this._active.delete(event.parent);
2971
+ } else
2972
+ return;
2973
+ raf.onFrame(this._onFrame);
2974
+ }
2975
+ };
2976
+ function flushUpdateQueue(ctrl, queue) {
2977
+ return Promise.all(queue.map((props) => flushUpdate(ctrl, props))).then(
2978
+ (results) => getCombinedResult(ctrl, results)
2979
+ );
2980
+ }
2981
+ async function flushUpdate(ctrl, props, isLoop) {
2982
+ const { keys, to: to2, from, loop, onRest, onResolve } = props;
2983
+ const defaults2 = is.obj(props.default) && props.default;
2984
+ if (loop) {
2985
+ props.loop = false;
2986
+ }
2987
+ if (to2 === false)
2988
+ props.to = null;
2989
+ if (from === false)
2990
+ props.from = null;
2991
+ const asyncTo = is.arr(to2) || is.fun(to2) ? to2 : void 0;
2992
+ if (asyncTo) {
2993
+ props.to = void 0;
2994
+ props.onRest = void 0;
2995
+ if (defaults2) {
2996
+ defaults2.onRest = void 0;
2997
+ }
2998
+ } else {
2999
+ each(BATCHED_EVENTS, (key) => {
3000
+ const handler = props[key];
3001
+ if (is.fun(handler)) {
3002
+ const queue = ctrl["_events"][key];
3003
+ props[key] = ({ finished, cancelled }) => {
3004
+ const result2 = queue.get(handler);
3005
+ if (result2) {
3006
+ if (!finished)
3007
+ result2.finished = false;
3008
+ if (cancelled)
3009
+ result2.cancelled = true;
3010
+ } else {
3011
+ queue.set(handler, {
3012
+ value: null,
3013
+ finished: finished || false,
3014
+ cancelled: cancelled || false
3015
+ });
3016
+ }
3017
+ };
3018
+ if (defaults2) {
3019
+ defaults2[key] = props[key];
3020
+ }
3021
+ }
3022
+ });
3023
+ }
3024
+ const state = ctrl["_state"];
3025
+ if (props.pause === !state.paused) {
3026
+ state.paused = props.pause;
3027
+ flushCalls(props.pause ? state.pauseQueue : state.resumeQueue);
3028
+ } else if (state.paused) {
3029
+ props.pause = true;
3030
+ }
3031
+ const promises = (keys || Object.keys(ctrl.springs)).map(
3032
+ (key) => ctrl.springs[key].start(props)
3033
+ );
3034
+ const cancel = props.cancel === true || getDefaultProp(props, "cancel") === true;
3035
+ if (asyncTo || cancel && state.asyncId) {
3036
+ promises.push(
3037
+ scheduleProps(++ctrl["_lastAsyncId"], {
3038
+ props,
3039
+ state,
3040
+ actions: {
3041
+ pause: noop,
3042
+ resume: noop,
3043
+ start(props2, resolve) {
3044
+ if (cancel) {
3045
+ stopAsync(state, ctrl["_lastAsyncId"]);
3046
+ resolve(getCancelledResult(ctrl));
3047
+ } else {
3048
+ props2.onRest = onRest;
3049
+ resolve(
3050
+ runAsync(
3051
+ asyncTo,
3052
+ props2,
3053
+ state,
3054
+ ctrl
3055
+ )
3056
+ );
3057
+ }
3058
+ }
3059
+ }
3060
+ })
3061
+ );
3062
+ }
3063
+ if (state.paused) {
3064
+ await new Promise((resume) => {
3065
+ state.resumeQueue.add(resume);
3066
+ });
3067
+ }
3068
+ const result = getCombinedResult(ctrl, await Promise.all(promises));
3069
+ if (loop && result.finished && !(isLoop && result.noop)) {
3070
+ const nextProps = createLoopUpdate(props, loop, to2);
3071
+ if (nextProps) {
3072
+ prepareKeys(ctrl, [nextProps]);
3073
+ return flushUpdate(ctrl, nextProps, true);
3074
+ }
3075
+ }
3076
+ if (onResolve) {
3077
+ raf.batchedUpdates(() => onResolve(result, ctrl, ctrl.item));
3078
+ }
3079
+ return result;
3080
+ }
3081
+ function getSprings(ctrl, props) {
3082
+ const springs = { ...ctrl.springs };
3083
+ if (props) {
3084
+ each(toArray(props), (props2) => {
3085
+ if (is.und(props2.keys)) {
3086
+ props2 = createUpdate(props2);
3087
+ }
3088
+ if (!is.obj(props2.to)) {
3089
+ props2 = { ...props2, to: void 0 };
3090
+ }
3091
+ prepareSprings(springs, props2, (key) => {
3092
+ return createSpring(key);
3093
+ });
3094
+ });
3095
+ }
3096
+ setSprings(ctrl, springs);
3097
+ return springs;
3098
+ }
3099
+ function setSprings(ctrl, springs) {
3100
+ eachProp(springs, (spring, key) => {
3101
+ if (!ctrl.springs[key]) {
3102
+ ctrl.springs[key] = spring;
3103
+ addFluidObserver(spring, ctrl);
3104
+ }
3105
+ });
3106
+ }
3107
+ function createSpring(key, observer) {
3108
+ const spring = new SpringValue();
3109
+ spring.key = key;
3110
+ if (observer) {
3111
+ addFluidObserver(spring, observer);
3112
+ }
3113
+ return spring;
3114
+ }
3115
+ function prepareSprings(springs, props, create) {
3116
+ if (props.keys) {
3117
+ each(props.keys, (key) => {
3118
+ const spring = springs[key] || (springs[key] = create(key));
3119
+ spring["_prepareNode"](props);
3120
+ });
3121
+ }
3122
+ }
3123
+ function prepareKeys(ctrl, queue) {
3124
+ each(queue, (props) => {
3125
+ prepareSprings(ctrl.springs, props, (key) => {
3126
+ return createSpring(key, ctrl);
3127
+ });
3128
+ });
3129
+ }
3130
+ var SpringContext = ({
3131
+ children,
3132
+ ...props
3133
+ }) => {
3134
+ const inherited = useContext(ctx);
3135
+ const pause = props.pause || !!inherited.pause, immediate = props.immediate || !!inherited.immediate;
3136
+ props = useMemoOne(() => ({ pause, immediate }), [pause, immediate]);
3137
+ const { Provider } = ctx;
3138
+ return /* @__PURE__ */ React.createElement(Provider, { value: props }, children);
3139
+ };
3140
+ var ctx = makeContext(SpringContext, {});
3141
+ SpringContext.Provider = ctx.Provider;
3142
+ SpringContext.Consumer = ctx.Consumer;
3143
+ function makeContext(target, init) {
3144
+ Object.assign(target, React.createContext(init));
3145
+ target.Provider._context = target;
3146
+ target.Consumer._context = target;
3147
+ return target;
3148
+ }
3149
+ var SpringRef = () => {
3150
+ const current = [];
3151
+ const SpringRef2 = function(props) {
3152
+ deprecateDirectCall();
3153
+ const results = [];
3154
+ each(current, (ctrl, i) => {
3155
+ if (is.und(props)) {
3156
+ results.push(ctrl.start());
3157
+ } else {
3158
+ const update2 = _getProps(props, ctrl, i);
3159
+ if (update2) {
3160
+ results.push(ctrl.start(update2));
3161
+ }
3162
+ }
3163
+ });
3164
+ return results;
3165
+ };
3166
+ SpringRef2.current = current;
3167
+ SpringRef2.add = function(ctrl) {
3168
+ if (!current.includes(ctrl)) {
3169
+ current.push(ctrl);
3170
+ }
3171
+ };
3172
+ SpringRef2.delete = function(ctrl) {
3173
+ const i = current.indexOf(ctrl);
3174
+ if (~i)
3175
+ current.splice(i, 1);
3176
+ };
3177
+ SpringRef2.pause = function() {
3178
+ each(current, (ctrl) => ctrl.pause(...arguments));
3179
+ return this;
3180
+ };
3181
+ SpringRef2.resume = function() {
3182
+ each(current, (ctrl) => ctrl.resume(...arguments));
3183
+ return this;
3184
+ };
3185
+ SpringRef2.set = function(values) {
3186
+ each(current, (ctrl, i) => {
3187
+ const update2 = is.fun(values) ? values(i, ctrl) : values;
3188
+ if (update2) {
3189
+ ctrl.set(update2);
3190
+ }
3191
+ });
3192
+ };
3193
+ SpringRef2.start = function(props) {
3194
+ const results = [];
3195
+ each(current, (ctrl, i) => {
3196
+ if (is.und(props)) {
3197
+ results.push(ctrl.start());
3198
+ } else {
3199
+ const update2 = this._getProps(props, ctrl, i);
3200
+ if (update2) {
3201
+ results.push(ctrl.start(update2));
3202
+ }
3203
+ }
3204
+ });
3205
+ return results;
3206
+ };
3207
+ SpringRef2.stop = function() {
3208
+ each(current, (ctrl) => ctrl.stop(...arguments));
3209
+ return this;
3210
+ };
3211
+ SpringRef2.update = function(props) {
3212
+ each(current, (ctrl, i) => ctrl.update(this._getProps(props, ctrl, i)));
3213
+ return this;
3214
+ };
3215
+ const _getProps = function(arg, ctrl, index) {
3216
+ return is.fun(arg) ? arg(index, ctrl) : arg;
3217
+ };
3218
+ SpringRef2._getProps = _getProps;
3219
+ return SpringRef2;
3220
+ };
3221
+
3222
+ // src/hooks/useSprings.ts
3223
+ function useSprings(length, props, deps) {
3224
+ const propsFn = is.fun(props) && props;
3225
+ if (propsFn && !deps)
3226
+ deps = [];
3227
+ const ref = useMemo(
3228
+ () => propsFn || arguments.length == 3 ? SpringRef() : void 0,
3229
+ []
3230
+ );
3231
+ const layoutId = useRef(0);
3232
+ const forceUpdate = useForceUpdate();
3233
+ const state = useMemo(
3234
+ () => ({
3235
+ ctrls: [],
3236
+ queue: [],
3237
+ flush(ctrl, updates2) {
3238
+ const springs2 = getSprings(ctrl, updates2);
3239
+ const canFlushSync = layoutId.current > 0 && !state.queue.length && !Object.keys(springs2).some((key) => !ctrl.springs[key]);
3240
+ return canFlushSync ? flushUpdateQueue(ctrl, updates2) : new Promise((resolve) => {
3241
+ setSprings(ctrl, springs2);
3242
+ state.queue.push(() => {
3243
+ resolve(flushUpdateQueue(ctrl, updates2));
3244
+ });
3245
+ forceUpdate();
3246
+ });
3247
+ }
3248
+ }),
3249
+ []
3250
+ );
3251
+ const ctrls = useRef([...state.ctrls]);
3252
+ const updates = [];
3253
+ const prevLength = usePrev(length) || 0;
3254
+ useMemo(() => {
3255
+ each(ctrls.current.slice(length, prevLength), (ctrl) => {
3256
+ detachRefs(ctrl, ref);
3257
+ ctrl.stop(true);
3258
+ });
3259
+ ctrls.current.length = length;
3260
+ declareUpdates(prevLength, length);
3261
+ }, [length]);
3262
+ useMemo(() => {
3263
+ declareUpdates(0, Math.min(prevLength, length));
3264
+ }, deps);
3265
+ function declareUpdates(startIndex, endIndex) {
3266
+ for (let i = startIndex; i < endIndex; i++) {
3267
+ const ctrl = ctrls.current[i] || (ctrls.current[i] = new Controller(null, state.flush));
3268
+ const update2 = propsFn ? propsFn(i, ctrl) : props[i];
3269
+ if (update2) {
3270
+ updates[i] = declareUpdate(update2);
3271
+ }
3272
+ }
3273
+ }
3274
+ const springs = ctrls.current.map((ctrl, i) => getSprings(ctrl, updates[i]));
3275
+ const context = useContext(SpringContext);
3276
+ const prevContext = usePrev(context);
3277
+ const hasContext = context !== prevContext && hasProps(context);
3278
+ useIsomorphicLayoutEffect(() => {
3279
+ layoutId.current++;
3280
+ state.ctrls = ctrls.current;
3281
+ const { queue } = state;
3282
+ if (queue.length) {
3283
+ state.queue = [];
3284
+ each(queue, (cb) => cb());
3285
+ }
3286
+ each(ctrls.current, (ctrl, i) => {
3287
+ ref?.add(ctrl);
3288
+ if (hasContext) {
3289
+ ctrl.start({ default: context });
3290
+ }
3291
+ const update2 = updates[i];
3292
+ if (update2) {
3293
+ replaceRef(ctrl, update2.ref);
3294
+ if (ctrl.ref) {
3295
+ ctrl.queue.push(update2);
3296
+ } else {
3297
+ ctrl.start(update2);
3298
+ }
3299
+ }
3300
+ });
3301
+ });
3302
+ useOnce(() => () => {
3303
+ each(state.ctrls, (ctrl) => ctrl.stop(true));
3304
+ });
3305
+ const values = springs.map((x) => ({ ...x }));
3306
+ return ref ? [values, ref] : values;
3307
+ }
304
3308
 
305
- var ze$1=Object.defineProperty;var Le$2=(e,t)=>{for(var r in t)ze$1(e,r,{get:t[r],enumerable:!0});};var p={};Le$2(p,{assign:()=>U,colors:()=>c$2,createStringInterpolator:()=>k$2,skipAnimation:()=>ee,to:()=>J$1,willAdvance:()=>S});function Y(){}var mt$1=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,configurable:!0}),l$1={arr:Array.isArray,obj:e=>!!e&&e.constructor.name==="Object",fun:e=>typeof e=="function",str:e=>typeof e=="string",num:e=>typeof e=="number",und:e=>e===void 0};function bt$1(e,t){if(l$1.arr(e)){if(!l$1.arr(t)||e.length!==t.length)return !1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return !1;return !0}return e===t}var Ve=(e,t)=>e.forEach(t);function xt(e,t,r){if(l$1.arr(e)){for(let n=0;n<e.length;n++)t.call(r,e[n],`${n}`);return}for(let n in e)e.hasOwnProperty(n)&&t.call(r,e[n],n);}var ht$1=e=>l$1.und(e)?[]:l$1.arr(e)?e:[e];function Pe$1(e,t){if(e.size){let r=Array.from(e);e.clear(),Ve(r,t);}}var yt$1=(e,...t)=>Pe$1(e,r=>r(...t)),h$2=()=>typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent);var k$2,J$1,c$2=null,ee=!1,S=Y,U=e=>{e.to&&(J$1=e.to),e.now&&(n.now=e.now),e.colors!==void 0&&(c$2=e.colors),e.skipAnimation!=null&&(ee=e.skipAnimation),e.createStringInterpolator&&(k$2=e.createStringInterpolator),e.requestAnimationFrame&&n.use(e.requestAnimationFrame),e.batchedUpdates&&(n.batchedUpdates=e.batchedUpdates),e.willAdvance&&(S=e.willAdvance),e.frameLoop&&(n.frameLoop=e.frameLoop);};var E$1=new Set,u$1=[],H$1=[],A=0,qe$1={get idle(){return !E$1.size&&!u$1.length},start(e){A>e.priority?(E$1.add(e),n.onStart($e)):(te$1(e),n(B));},advance:B,sort(e){if(A)n.onFrame(()=>qe$1.sort(e));else {let t=u$1.indexOf(e);~t&&(u$1.splice(t,1),re(e));}},clear(){u$1=[],E$1.clear();}};function $e(){E$1.forEach(te$1),E$1.clear(),n(B);}function te$1(e){u$1.includes(e)||re(e);}function re(e){u$1.splice(Ge$1(u$1,t=>t.priority>e.priority),0,e);}function B(e){let t=H$1;for(let r=0;r<u$1.length;r++){let n=u$1[r];A=n.priority,n.idle||(S(n),n.advance(e),n.idle||t.push(n));}return A=0,H$1=u$1,H$1.length=0,u$1=t,u$1.length>0}function Ge$1(e,t){let r=e.findIndex(t);return r<0?e.length:r}var ne$2=(e,t,r)=>Math.min(Math.max(r,e),t);var It={transparent:0,aliceblue:4042850303,antiquewhite:4209760255,aqua:16777215,aquamarine:2147472639,azure:4043309055,beige:4126530815,bisque:4293182719,black:255,blanchedalmond:4293643775,blue:65535,blueviolet:2318131967,brown:2771004159,burlywood:3736635391,burntsienna:3934150143,cadetblue:1604231423,chartreuse:2147418367,chocolate:3530104575,coral:4286533887,cornflowerblue:1687547391,cornsilk:4294499583,crimson:3692313855,cyan:16777215,darkblue:35839,darkcyan:9145343,darkgoldenrod:3095792639,darkgray:2846468607,darkgreen:6553855,darkgrey:2846468607,darkkhaki:3182914559,darkmagenta:2332068863,darkolivegreen:1433087999,darkorange:4287365375,darkorchid:2570243327,darkred:2332033279,darksalmon:3918953215,darkseagreen:2411499519,darkslateblue:1211993087,darkslategray:793726975,darkslategrey:793726975,darkturquoise:13554175,darkviolet:2483082239,deeppink:4279538687,deepskyblue:12582911,dimgray:1768516095,dimgrey:1768516095,dodgerblue:512819199,firebrick:2988581631,floralwhite:4294635775,forestgreen:579543807,fuchsia:4278255615,gainsboro:3705462015,ghostwhite:4177068031,gold:4292280575,goldenrod:3668254975,gray:2155905279,green:8388863,greenyellow:2919182335,grey:2155905279,honeydew:4043305215,hotpink:4285117695,indianred:3445382399,indigo:1258324735,ivory:4294963455,khaki:4041641215,lavender:3873897215,lavenderblush:4293981695,lawngreen:2096890111,lemonchiffon:4294626815,lightblue:2916673279,lightcoral:4034953471,lightcyan:3774873599,lightgoldenrodyellow:4210742015,lightgray:3553874943,lightgreen:2431553791,lightgrey:3553874943,lightpink:4290167295,lightsalmon:4288707327,lightseagreen:548580095,lightskyblue:2278488831,lightslategray:2005441023,lightslategrey:2005441023,lightsteelblue:2965692159,lightyellow:4294959359,lime:16711935,limegreen:852308735,linen:4210091775,magenta:4278255615,maroon:2147483903,mediumaquamarine:1724754687,mediumblue:52735,mediumorchid:3126187007,mediumpurple:2473647103,mediumseagreen:1018393087,mediumslateblue:2070474495,mediumspringgreen:16423679,mediumturquoise:1221709055,mediumvioletred:3340076543,midnightblue:421097727,mintcream:4127193855,mistyrose:4293190143,moccasin:4293178879,navajowhite:4292783615,navy:33023,oldlace:4260751103,olive:2155872511,olivedrab:1804477439,orange:4289003775,orangered:4282712319,orchid:3664828159,palegoldenrod:4008225535,palegreen:2566625535,paleturquoise:2951671551,palevioletred:3681588223,papayawhip:4293907967,peachpuff:4292524543,peru:3448061951,pink:4290825215,plum:3718307327,powderblue:2967529215,purple:2147516671,rebeccapurple:1714657791,red:4278190335,rosybrown:3163525119,royalblue:1097458175,saddlebrown:2336560127,salmon:4202722047,sandybrown:4104413439,seagreen:780883967,seashell:4294307583,sienna:2689740287,silver:3233857791,skyblue:2278484991,slateblue:1784335871,slategray:1887473919,slategrey:1887473919,snow:4294638335,springgreen:16744447,steelblue:1182971135,tan:3535047935,teal:8421631,thistle:3636451583,tomato:4284696575,turquoise:1088475391,violet:4001558271,wheat:4125012991,white:4294967295,whitesmoke:4126537215,yellow:4294902015,yellowgreen:2597139199};var d$1="[-+]?\\d*\\.?\\d+",M=d$1+"%";function C$1(...e){return "\\(\\s*("+e.join(")\\s*,\\s*(")+")\\s*\\)"}var oe$1=new RegExp("rgb"+C$1(d$1,d$1,d$1)),fe$1=new RegExp("rgba"+C$1(d$1,d$1,d$1,d$1)),ae$1=new RegExp("hsl"+C$1(d$1,M,M)),ie=new RegExp("hsla"+C$1(d$1,M,M,d$1)),se$1=/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,ue$1=/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,le$1=/^#([0-9a-fA-F]{6})$/,ce=/^#([0-9a-fA-F]{8})$/;function be$1(e){let t;return typeof e=="number"?e>>>0===e&&e>=0&&e<=4294967295?e:null:(t=le$1.exec(e))?parseInt(t[1]+"ff",16)>>>0:c$2&&c$2[e]!==void 0?c$2[e]:(t=oe$1.exec(e))?(y$2(t[1])<<24|y$2(t[2])<<16|y$2(t[3])<<8|255)>>>0:(t=fe$1.exec(e))?(y$2(t[1])<<24|y$2(t[2])<<16|y$2(t[3])<<8|me$1(t[4]))>>>0:(t=se$1.exec(e))?parseInt(t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+"ff",16)>>>0:(t=ce.exec(e))?parseInt(t[1],16)>>>0:(t=ue$1.exec(e))?parseInt(t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+t[4]+t[4],16)>>>0:(t=ae$1.exec(e))?(de$1(pe(t[1]),z$1(t[2]),z$1(t[3]))|255)>>>0:(t=ie.exec(e))?(de$1(pe(t[1]),z$1(t[2]),z$1(t[3]))|me$1(t[4]))>>>0:null}function j$1(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+(t-e)*6*r:r<1/2?t:r<2/3?e+(t-e)*(2/3-r)*6:e}function de$1(e,t,r){let n=r<.5?r*(1+t):r+t-r*t,f=2*r-n,o=j$1(f,n,e+1/3),i=j$1(f,n,e),s=j$1(f,n,e-1/3);return Math.round(o*255)<<24|Math.round(i*255)<<16|Math.round(s*255)<<8}function y$2(e){let t=parseInt(e,10);return t<0?0:t>255?255:t}function pe(e){return (parseFloat(e)%360+360)%360/360}function me$1(e){let t=parseFloat(e);return t<0?0:t>1?255:Math.round(t*255)}function z$1(e){let t=parseFloat(e);return t<0?0:t>100?1:t/100}function D$1(e){let t=be$1(e);if(t===null)return e;t=t||0;let r=(t&4278190080)>>>24,n=(t&16711680)>>>16,f=(t&65280)>>>8,o=(t&255)/255;return `rgba(${r}, ${n}, ${f}, ${o})`}var W$1=(e,t,r)=>{if(l$1.fun(e))return e;if(l$1.arr(e))return W$1({range:e,output:t,extrapolate:r});if(l$1.str(e.output[0]))return k$2(e);let n=e,f=n.output,o=n.range||[0,1],i=n.extrapolateLeft||n.extrapolate||"extend",s=n.extrapolateRight||n.extrapolate||"extend",x=n.easing||(a=>a);return a=>{let F=He$1(a,o);return Ue$1(a,o[F],o[F+1],f[F],f[F+1],x,i,s,n.map)}};function Ue$1(e,t,r,n,f,o,i,s,x){let a=x?x(e):e;if(a<t){if(i==="identity")return a;i==="clamp"&&(a=t);}if(a>r){if(s==="identity")return a;s==="clamp"&&(a=r);}return n===f?n:t===r?e<=t?n:f:(t===-1/0?a=-a:r===1/0?a=a-t:a=(a-t)/(r-t),a=o(a),n===-1/0?a=-a:f===1/0?a=a+n:a=a*(f-n)+n,a)}function He$1(e,t){for(var r=1;r<t.length-1&&!(t[r]>=e);++r);return r-1}var Be=(e,t="end")=>r=>{r=t==="end"?Math.min(r,.999):Math.max(r,.001);let n=r*e,f=t==="end"?Math.floor(n):Math.ceil(n);return ne$2(0,1,f/e)},P=1.70158,L$1=P*1.525,xe$1=P+1,he$1=2*Math.PI/3,ye$1=2*Math.PI/4.5,V$1=e=>e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375,Lt$1={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>1-(1-e)*(1-e),easeInOutQuad:e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,easeInCubic:e=>e*e*e,easeOutCubic:e=>1-Math.pow(1-e,3),easeInOutCubic:e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,easeInQuart:e=>e*e*e*e,easeOutQuart:e=>1-Math.pow(1-e,4),easeInOutQuart:e=>e<.5?8*e*e*e*e:1-Math.pow(-2*e+2,4)/2,easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>1-Math.pow(1-e,5),easeInOutQuint:e=>e<.5?16*e*e*e*e*e:1-Math.pow(-2*e+2,5)/2,easeInSine:e=>1-Math.cos(e*Math.PI/2),easeOutSine:e=>Math.sin(e*Math.PI/2),easeInOutSine:e=>-(Math.cos(Math.PI*e)-1)/2,easeInExpo:e=>e===0?0:Math.pow(2,10*e-10),easeOutExpo:e=>e===1?1:1-Math.pow(2,-10*e),easeInOutExpo:e=>e===0?0:e===1?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2,easeInCirc:e=>1-Math.sqrt(1-Math.pow(e,2)),easeOutCirc:e=>Math.sqrt(1-Math.pow(e-1,2)),easeInOutCirc:e=>e<.5?(1-Math.sqrt(1-Math.pow(2*e,2)))/2:(Math.sqrt(1-Math.pow(-2*e+2,2))+1)/2,easeInBack:e=>xe$1*e*e*e-P*e*e,easeOutBack:e=>1+xe$1*Math.pow(e-1,3)+P*Math.pow(e-1,2),easeInOutBack:e=>e<.5?Math.pow(2*e,2)*((L$1+1)*2*e-L$1)/2:(Math.pow(2*e-2,2)*((L$1+1)*(e*2-2)+L$1)+2)/2,easeInElastic:e=>e===0?0:e===1?1:-Math.pow(2,10*e-10)*Math.sin((e*10-10.75)*he$1),easeOutElastic:e=>e===0?0:e===1?1:Math.pow(2,-10*e)*Math.sin((e*10-.75)*he$1)+1,easeInOutElastic:e=>e===0?0:e===1?1:e<.5?-(Math.pow(2,20*e-10)*Math.sin((20*e-11.125)*ye$1))/2:Math.pow(2,-20*e+10)*Math.sin((20*e-11.125)*ye$1)/2+1,easeInBounce:e=>1-V$1(1-e),easeOutBounce:V$1,easeInOutBounce:e=>e<.5?(1-V$1(1-2*e))/2:(1+V$1(2*e-1))/2,steps:Be};var g$1=Symbol.for("FluidValue.get"),m=Symbol.for("FluidValue.observers");var Pt=e=>!!(e&&e[g$1]),ve=e=>e&&e[g$1]?e[g$1]():e,qt=e=>e[m]||null;function je(e,t){e.eventObserved?e.eventObserved(t):e(t);}function $t(e,t){let r=e[m];r&&r.forEach(n=>{je(n,t);});}var ge=class{[g$1];[m];constructor(t){if(!t&&!(t=this.get))throw Error("Unknown getter");De$1(this,t);}},De$1=(e,t)=>Ee$1(e,g$1,t);function Gt$1(e,t){if(e[g$1]){let r=e[m];r||Ee$1(e,m,r=new Set),r.has(t)||(r.add(t),e.observerAdded&&e.observerAdded(r.size,t));}return t}function Qt(e,t){let r=e[m];if(r&&r.has(t)){let n=r.size-1;n?r.delete(t):e[m]=null,e.observerRemoved&&e.observerRemoved(n,t);}}var Ee$1=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,configurable:!0});var O=/[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,Oe=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi,K=new RegExp(`(${O.source})(%|[a-z]+)`,"i"),we$1=/rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi,b$1=/var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;var N=e=>{let[t,r]=We(e);if(!t||h$2())return e;let n=window.getComputedStyle(document.documentElement).getPropertyValue(t);if(n)return n.trim();if(r&&r.startsWith("--")){let f=window.getComputedStyle(document.documentElement).getPropertyValue(r);return f||e}else {if(r&&b$1.test(r))return N(r);if(r)return r}return e},We=e=>{let t=b$1.exec(e);if(!t)return [,];let[,r,n]=t;return [r,n]};var _$1,Ke$1=(e,t,r,n,f)=>`rgba(${Math.round(t)}, ${Math.round(r)}, ${Math.round(n)}, ${f})`,Xt=e=>{_$1||(_$1=c$2?new RegExp(`(${Object.keys(c$2).join("|")})(?!\\w)`,"g"):/^\b$/);let t=e.output.map(o=>ve(o).replace(b$1,N).replace(Oe,D$1).replace(_$1,D$1)),r=t.map(o=>o.match(O).map(Number)),f=r[0].map((o,i)=>r.map(s=>{if(!(i in s))throw Error('The arity of each "output" value must be equal');return s[i]})).map(o=>W$1({...e,output:o}));return o=>{let i=!K.test(t[0])&&t.find(x=>K.test(x))?.replace(O,""),s=0;return t[0].replace(O,()=>`${f[s++](o)}${i||""}`).replace(we$1,Ke$1)}};var Z="react-spring: ",Te=e=>{let t=e,r=!1;if(typeof t!="function")throw new TypeError(`${Z}once requires a function parameter`);return (...n)=>{r||(t(...n),r=!0);}},Ne$1=Te(console.warn);function Jt(){Ne$1(`${Z}The "interpolate" function is deprecated in v9 (use "to" instead)`);}var _e$1=Te(console.warn);function er$1(){_e$1(`${Z}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`);}function or(e){return l$1.str(e)&&(e[0]=="#"||/\d/.test(e)||!h$2()&&b$1.test(e)||e in(c$2||{}))}var Q$1=h$2()?useEffect:useLayoutEffect;var Ce$1=()=>{let e=useRef(!1);return Q$1(()=>(e.current=!0,()=>{e.current=!1;}),[]),e};function Mr(){let e=useState()[1],t=Ce$1();return ()=>{t.current&&e(Math.random());}}function Lr(e,t){let[r]=useState(()=>({inputs:t,result:e()})),n=useRef(),f=n.current,o=f;return o?t&&o.inputs&&it$2(t,o.inputs)||(o={inputs:t,result:e()}):o=r,useEffect(()=>{n.current=o,f==r&&(r.inputs=r.result=void 0);},[o]),o.result}function it$2(e,t){if(e.length!==t.length)return !1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return !1;return !0}var $r=e=>useEffect(e,ut),ut=[];function Ur(e){let t=useRef();return useEffect(()=>{t.current=e;}),t.current}
3309
+ // src/hooks/useSpring.ts
3310
+ function useSpring(props, deps) {
3311
+ const isFn = is.fun(props);
3312
+ const [[values], ref] = useSprings(
3313
+ 1,
3314
+ isFn ? props : [props],
3315
+ isFn ? deps || [] : deps
3316
+ );
3317
+ return isFn || arguments.length == 2 ? [values, ref] : values;
3318
+ }
3319
+ function useTransition(data, props, deps) {
3320
+ const propsFn = is.fun(props) && props;
3321
+ const {
3322
+ reset,
3323
+ sort,
3324
+ trail = 0,
3325
+ expires = true,
3326
+ exitBeforeEnter = false,
3327
+ onDestroyed,
3328
+ ref: propsRef,
3329
+ config: propsConfig
3330
+ } = propsFn ? propsFn() : props;
3331
+ const ref = useMemo(
3332
+ () => propsFn || arguments.length == 3 ? SpringRef() : void 0,
3333
+ []
3334
+ );
3335
+ const items = toArray(data);
3336
+ const transitions = [];
3337
+ const usedTransitions = useRef(null);
3338
+ const prevTransitions = reset ? null : usedTransitions.current;
3339
+ useIsomorphicLayoutEffect(() => {
3340
+ usedTransitions.current = transitions;
3341
+ });
3342
+ useOnce(() => {
3343
+ each(transitions, (t) => {
3344
+ ref?.add(t.ctrl);
3345
+ t.ctrl.ref = ref;
3346
+ });
3347
+ return () => {
3348
+ each(usedTransitions.current, (t) => {
3349
+ if (t.expired) {
3350
+ clearTimeout(t.expirationId);
3351
+ }
3352
+ detachRefs(t.ctrl, ref);
3353
+ t.ctrl.stop(true);
3354
+ });
3355
+ };
3356
+ });
3357
+ const keys = getKeys(items, propsFn ? propsFn() : props, prevTransitions);
3358
+ const expired = reset && usedTransitions.current || [];
3359
+ useIsomorphicLayoutEffect(
3360
+ () => each(expired, ({ ctrl, item, key }) => {
3361
+ detachRefs(ctrl, ref);
3362
+ callProp(onDestroyed, item, key);
3363
+ })
3364
+ );
3365
+ const reused = [];
3366
+ if (prevTransitions)
3367
+ each(prevTransitions, (t, i) => {
3368
+ if (t.expired) {
3369
+ clearTimeout(t.expirationId);
3370
+ expired.push(t);
3371
+ } else {
3372
+ i = reused[i] = keys.indexOf(t.key);
3373
+ if (~i)
3374
+ transitions[i] = t;
3375
+ }
3376
+ });
3377
+ each(items, (item, i) => {
3378
+ if (!transitions[i]) {
3379
+ transitions[i] = {
3380
+ key: keys[i],
3381
+ item,
3382
+ phase: "mount" /* MOUNT */,
3383
+ ctrl: new Controller()
3384
+ };
3385
+ transitions[i].ctrl.item = item;
3386
+ }
3387
+ });
3388
+ if (reused.length) {
3389
+ let i = -1;
3390
+ const { leave } = propsFn ? propsFn() : props;
3391
+ each(reused, (keyIndex, prevIndex) => {
3392
+ const t = prevTransitions[prevIndex];
3393
+ if (~keyIndex) {
3394
+ i = transitions.indexOf(t);
3395
+ transitions[i] = { ...t, item: items[keyIndex] };
3396
+ } else if (leave) {
3397
+ transitions.splice(++i, 0, t);
3398
+ }
3399
+ });
3400
+ }
3401
+ if (is.fun(sort)) {
3402
+ transitions.sort((a, b) => sort(a.item, b.item));
3403
+ }
3404
+ let delay = -trail;
3405
+ const forceUpdate = useForceUpdate();
3406
+ const defaultProps = getDefaultProps(props);
3407
+ const changes = /* @__PURE__ */ new Map();
3408
+ const exitingTransitions = useRef(/* @__PURE__ */ new Map());
3409
+ const forceChange = useRef(false);
3410
+ each(transitions, (t, i) => {
3411
+ const key = t.key;
3412
+ const prevPhase = t.phase;
3413
+ const p = propsFn ? propsFn() : props;
3414
+ let to2;
3415
+ let phase;
3416
+ const propsDelay = callProp(p.delay || 0, key);
3417
+ if (prevPhase == "mount" /* MOUNT */) {
3418
+ to2 = p.enter;
3419
+ phase = "enter" /* ENTER */;
3420
+ } else {
3421
+ const isLeave = keys.indexOf(key) < 0;
3422
+ if (prevPhase != "leave" /* LEAVE */) {
3423
+ if (isLeave) {
3424
+ to2 = p.leave;
3425
+ phase = "leave" /* LEAVE */;
3426
+ } else if (to2 = p.update) {
3427
+ phase = "update" /* UPDATE */;
3428
+ } else
3429
+ return;
3430
+ } else if (!isLeave) {
3431
+ to2 = p.enter;
3432
+ phase = "enter" /* ENTER */;
3433
+ } else
3434
+ return;
3435
+ }
3436
+ to2 = callProp(to2, t.item, i);
3437
+ to2 = is.obj(to2) ? inferTo(to2) : { to: to2 };
3438
+ if (!to2.config) {
3439
+ const config2 = propsConfig || defaultProps.config;
3440
+ to2.config = callProp(config2, t.item, i, phase);
3441
+ }
3442
+ delay += trail;
3443
+ const payload = {
3444
+ ...defaultProps,
3445
+ // we need to add our props.delay value you here.
3446
+ delay: propsDelay + delay,
3447
+ ref: propsRef,
3448
+ immediate: p.immediate,
3449
+ // This prevents implied resets.
3450
+ reset: false,
3451
+ // Merge any phase-specific props.
3452
+ ...to2
3453
+ };
3454
+ if (phase == "enter" /* ENTER */ && is.und(payload.from)) {
3455
+ const p2 = propsFn ? propsFn() : props;
3456
+ const from = is.und(p2.initial) || prevTransitions ? p2.from : p2.initial;
3457
+ payload.from = callProp(from, t.item, i);
3458
+ }
3459
+ const { onResolve } = payload;
3460
+ payload.onResolve = (result) => {
3461
+ callProp(onResolve, result);
3462
+ const transitions2 = usedTransitions.current;
3463
+ const t2 = transitions2.find((t3) => t3.key === key);
3464
+ if (!t2)
3465
+ return;
3466
+ if (result.cancelled && t2.phase != "update" /* UPDATE */) {
3467
+ return;
3468
+ }
3469
+ if (t2.ctrl.idle) {
3470
+ const idle = transitions2.every((t3) => t3.ctrl.idle);
3471
+ if (t2.phase == "leave" /* LEAVE */) {
3472
+ const expiry = callProp(expires, t2.item);
3473
+ if (expiry !== false) {
3474
+ const expiryMs = expiry === true ? 0 : expiry;
3475
+ t2.expired = true;
3476
+ if (!idle && expiryMs > 0) {
3477
+ if (expiryMs <= 2147483647)
3478
+ t2.expirationId = setTimeout(forceUpdate, expiryMs);
3479
+ return;
3480
+ }
3481
+ }
3482
+ }
3483
+ if (idle && transitions2.some((t3) => t3.expired)) {
3484
+ exitingTransitions.current.delete(t2);
3485
+ if (exitBeforeEnter) {
3486
+ forceChange.current = true;
3487
+ }
3488
+ forceUpdate();
3489
+ }
3490
+ }
3491
+ };
3492
+ const springs = getSprings(t.ctrl, payload);
3493
+ if (phase === "leave" /* LEAVE */ && exitBeforeEnter) {
3494
+ exitingTransitions.current.set(t, { phase, springs, payload });
3495
+ } else {
3496
+ changes.set(t, { phase, springs, payload });
3497
+ }
3498
+ });
3499
+ const context = useContext(SpringContext);
3500
+ const prevContext = usePrev(context);
3501
+ const hasContext = context !== prevContext && hasProps(context);
3502
+ useIsomorphicLayoutEffect(() => {
3503
+ if (hasContext) {
3504
+ each(transitions, (t) => {
3505
+ t.ctrl.start({ default: context });
3506
+ });
3507
+ }
3508
+ }, [context]);
3509
+ each(changes, (_, t) => {
3510
+ if (exitingTransitions.current.size) {
3511
+ const ind = transitions.findIndex((state) => state.key === t.key);
3512
+ transitions.splice(ind, 1);
3513
+ }
3514
+ });
3515
+ useIsomorphicLayoutEffect(
3516
+ () => {
3517
+ each(
3518
+ exitingTransitions.current.size ? exitingTransitions.current : changes,
3519
+ ({ phase, payload }, t) => {
3520
+ const { ctrl } = t;
3521
+ t.phase = phase;
3522
+ ref?.add(ctrl);
3523
+ if (hasContext && phase == "enter" /* ENTER */) {
3524
+ ctrl.start({ default: context });
3525
+ }
3526
+ if (payload) {
3527
+ replaceRef(ctrl, payload.ref);
3528
+ if ((ctrl.ref || ref) && !forceChange.current) {
3529
+ ctrl.update(payload);
3530
+ } else {
3531
+ ctrl.start(payload);
3532
+ if (forceChange.current) {
3533
+ forceChange.current = false;
3534
+ }
3535
+ }
3536
+ }
3537
+ }
3538
+ );
3539
+ },
3540
+ reset ? void 0 : deps
3541
+ );
3542
+ const renderTransitions = (render) => /* @__PURE__ */ React.createElement(React.Fragment, null, transitions.map((t, i) => {
3543
+ const { springs } = changes.get(t) || t.ctrl;
3544
+ const elem = render({ ...springs }, t.item, t, i);
3545
+ return elem && elem.type ? /* @__PURE__ */ React.createElement(
3546
+ elem.type,
3547
+ {
3548
+ ...elem.props,
3549
+ key: is.str(t.key) || is.num(t.key) ? t.key : t.ctrl.id,
3550
+ ref: elem.ref
3551
+ }
3552
+ ) : elem;
3553
+ }));
3554
+ return ref ? [renderTransitions, ref] : renderTransitions;
3555
+ }
3556
+ var nextKey = 1;
3557
+ function getKeys(items, { key, keys = key }, prevTransitions) {
3558
+ if (keys === null) {
3559
+ const reused = /* @__PURE__ */ new Set();
3560
+ return items.map((item) => {
3561
+ const t = prevTransitions && prevTransitions.find(
3562
+ (t2) => t2.item === item && t2.phase !== "leave" /* LEAVE */ && !reused.has(t2)
3563
+ );
3564
+ if (t) {
3565
+ reused.add(t);
3566
+ return t.key;
3567
+ }
3568
+ return nextKey++;
3569
+ });
3570
+ }
3571
+ return is.und(keys) ? items : is.fun(keys) ? items.map(keys) : toArray(keys);
3572
+ }
3573
+ var Interpolation = class extends FrameValue {
3574
+ constructor(source, args) {
3575
+ super();
3576
+ this.source = source;
3577
+ /** Equals false when in the frameloop */
3578
+ this.idle = true;
3579
+ /** The inputs which are currently animating */
3580
+ this._active = /* @__PURE__ */ new Set();
3581
+ this.calc = createInterpolator(...args);
3582
+ const value = this._get();
3583
+ const nodeType = getAnimatedType(value);
3584
+ setAnimated(this, nodeType.create(value));
3585
+ }
3586
+ advance(_dt) {
3587
+ const value = this._get();
3588
+ const oldValue = this.get();
3589
+ if (!isEqual(value, oldValue)) {
3590
+ getAnimated(this).setValue(value);
3591
+ this._onChange(value, this.idle);
3592
+ }
3593
+ if (!this.idle && checkIdle(this._active)) {
3594
+ becomeIdle(this);
3595
+ }
3596
+ }
3597
+ _get() {
3598
+ const inputs = is.arr(this.source) ? this.source.map(getFluidValue) : toArray(getFluidValue(this.source));
3599
+ return this.calc(...inputs);
3600
+ }
3601
+ _start() {
3602
+ if (this.idle && !checkIdle(this._active)) {
3603
+ this.idle = false;
3604
+ each(getPayload(this), (node) => {
3605
+ node.done = false;
3606
+ });
3607
+ if (globals_exports.skipAnimation) {
3608
+ raf.batchedUpdates(() => this.advance());
3609
+ becomeIdle(this);
3610
+ } else {
3611
+ frameLoop.start(this);
3612
+ }
3613
+ }
3614
+ }
3615
+ // Observe our sources only when we're observed.
3616
+ _attach() {
3617
+ let priority = 1;
3618
+ each(toArray(this.source), (source) => {
3619
+ if (hasFluidValue(source)) {
3620
+ addFluidObserver(source, this);
3621
+ }
3622
+ if (isFrameValue(source)) {
3623
+ if (!source.idle) {
3624
+ this._active.add(source);
3625
+ }
3626
+ priority = Math.max(priority, source.priority + 1);
3627
+ }
3628
+ });
3629
+ this.priority = priority;
3630
+ this._start();
3631
+ }
3632
+ // Stop observing our sources once we have no observers.
3633
+ _detach() {
3634
+ each(toArray(this.source), (source) => {
3635
+ if (hasFluidValue(source)) {
3636
+ removeFluidObserver(source, this);
3637
+ }
3638
+ });
3639
+ this._active.clear();
3640
+ becomeIdle(this);
3641
+ }
3642
+ /** @internal */
3643
+ eventObserved(event) {
3644
+ if (event.type == "change") {
3645
+ if (event.idle) {
3646
+ this.advance();
3647
+ } else {
3648
+ this._active.add(event.parent);
3649
+ this._start();
3650
+ }
3651
+ } else if (event.type == "idle") {
3652
+ this._active.delete(event.parent);
3653
+ } else if (event.type == "priority") {
3654
+ this.priority = toArray(this.source).reduce(
3655
+ (highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1),
3656
+ 0
3657
+ );
3658
+ }
3659
+ }
3660
+ };
3661
+ function isIdle(source) {
3662
+ return source.idle !== false;
3663
+ }
3664
+ function checkIdle(active) {
3665
+ return !active.size || Array.from(active).every(isIdle);
3666
+ }
3667
+ function becomeIdle(self) {
3668
+ if (!self.idle) {
3669
+ self.idle = true;
3670
+ each(getPayload(self), (node) => {
3671
+ node.done = true;
3672
+ });
3673
+ callFluidObservers(self, {
3674
+ type: "idle",
3675
+ parent: self
3676
+ });
3677
+ }
3678
+ }
3679
+ globals_exports.assign({
3680
+ createStringInterpolator: createStringInterpolator2,
3681
+ to: (source, args) => new Interpolation(source, args)
3682
+ });
306
3683
 
307
- var h$1=Symbol.for("Animated:node"),v$1=e=>!!e&&e[h$1]===e,k$1=e=>e&&e[h$1],D=(e,t)=>mt$1(e,h$1,t),F$1=e=>e&&e[h$1]&&e[h$1].getPayload(),c$1=class{payload;constructor(){D(this,this);}getPayload(){return this.payload||[]}};var l=class extends c$1{constructor(r){super();this._value=r;l$1.num(this._value)&&(this.lastPosition=this._value);}done=!0;elapsedTime;lastPosition;lastVelocity;v0;durationProgress=0;static create(r){return new l(r)}getPayload(){return [this]}getValue(){return this._value}setValue(r,n){return l$1.num(r)&&(this.lastPosition=r,n&&(r=Math.round(r/n)*n,this.done&&(this.lastPosition=r))),this._value===r?!1:(this._value=r,!0)}reset(){let{done:r}=this;this.done=!1,l$1.num(this._value)&&(this.elapsedTime=0,this.durationProgress=0,this.lastPosition=this._value,r&&(this.lastVelocity=null),this.v0=null);}};var d=class extends l{_string=null;_toString;constructor(t){super(0),this._toString=W$1({output:[t,t]});}static create(t){return new d(t)}getValue(){let t=this._string;return t??(this._string=this._toString(this._value))}setValue(t){if(l$1.str(t)){if(t==this._string)return !1;this._string=t,this._value=1;}else if(super.setValue(t))this._string=null;else return !1;return !0}reset(t){t&&(this._toString=W$1({output:[this.getValue(),t]})),this._value=0,super.reset();}};var f={dependencies:null};var u=class extends c$1{constructor(r){super();this.source=r;this.setValue(r);}getValue(r){let n={};return xt(this.source,(a,i)=>{v$1(a)?n[i]=a.getValue(r):Pt(a)?n[i]=ve(a):r||(n[i]=a);}),n}setValue(r){this.source=r,this.payload=this._makePayload(r);}reset(){this.payload&&Ve(this.payload,r=>r.reset());}_makePayload(r){if(r){let n=new Set;return xt(r,this._addToPayload,n),Array.from(n)}}_addToPayload(r){f.dependencies&&Pt(r)&&f.dependencies.add(r);let n=F$1(r);n&&Ve(n,a=>this.add(a));}};var y$1=class extends u{constructor(t){super(t);}static create(t){return new y$1(t)}getValue(){return this.source.map(t=>t.getValue())}setValue(t){let r=this.getPayload();return t.length==r.length?r.map((n,a)=>n.setValue(t[a])).some(Boolean):(super.setValue(t.map(z)),!0)}};function z(e){return (or(e)?d:l).create(e)}function Le$1(e){let t=k$1(e);return t?t.constructor:l$1.arr(e)?y$1:or(e)?d:l}var x$1=(e,t)=>{let r=!l$1.fun(e)||e.prototype&&e.prototype.isReactComponent;return forwardRef((n$1,a)=>{let i=useRef(null),o=r&&useCallback(s=>{i.current=ae(a,s);},[a]),[m,T]=ne$1(n$1,t),W=Mr(),P=()=>{let s=i.current;if(r&&!s)return;(s?t.applyAnimatedValues(s,m.getValue(!0)):!1)===!1&&W();},_=new b(P,T),p=useRef();Q$1(()=>(p.current=_,Ve(T,s=>Gt$1(s,_)),()=>{p.current&&(Ve(p.current.deps,s=>Qt(s,p.current)),n.cancel(p.current.update));})),useEffect(P,[]),$r(()=>()=>{let s=p.current;Ve(s.deps,S=>Qt(S,s));});let $=t.getComponentProps(m.getValue());return React.createElement(e,{...$,ref:o})})},b=class{constructor(t,r){this.update=t;this.deps=r;}eventObserved(t){t.type=="change"&&n.write(this.update);}};function ne$1(e,t){let r=new Set;return f.dependencies=r,e.style&&(e={...e,style:t.createAnimatedStyle(e.style)}),e=new u(e),f.dependencies=null,[e,r]}function ae(e,t){return e&&(l$1.fun(e)?e(t):e.current=t),t}var j=Symbol.for("AnimatedComponent"),Ke=(e,{applyAnimatedValues:t=()=>!1,createAnimatedStyle:r=a=>new u(a),getComponentProps:n=a=>a}={})=>{let a={applyAnimatedValues:t,createAnimatedStyle:r,getComponentProps:n},i=o=>{let m=I$2(o)||"Anonymous";return l$1.str(o)?o=i[o]||(i[o]=x$1(o,a)):o=o[j]||(o[j]=x$1(o,a)),o.displayName=`Animated(${m})`,o};return xt(e,(o,m)=>{l$1.arr(e)&&(m=I$2(o)),i[m]=i(o);}),{animated:i}},I$2=e=>l$1.str(e)?e:e&&l$1.str(e.displayName)?e.displayName:l$1.fun(e)&&e.name||null;
3684
+ // src/index.ts
308
3685
 
309
- function I$1(t,...e){return l$1.fun(t)?t(...e):t}var te=(t,e)=>t===!0||!!(e&&t&&(l$1.fun(t)?t(e):ht$1(t).includes(e))),et=(t,e)=>l$1.obj(t)?e&&t[e]:t;var ke=(t,e)=>t.default===!0?t[e]:t.default?t.default[e]:void 0,nn=t=>t,ne=(t,e=nn)=>{let n=rn;t.default&&t.default!==!0&&(t=t.default,n=Object.keys(t));let r={};for(let o of n){let s=e(t[o],o);l$1.und(s)||(r[o]=s);}return r},rn=["config","onProps","onStart","onChange","onPause","onResume","onRest"],on={config:1,from:1,to:1,ref:1,loop:1,reset:1,pause:1,cancel:1,reverse:1,immediate:1,default:1,delay:1,onProps:1,onStart:1,onChange:1,onPause:1,onResume:1,onRest:1,onResolve:1,items:1,trail:1,sort:1,expires:1,initial:1,enter:1,update:1,leave:1,children:1,onDestroyed:1,keys:1,callId:1,parentId:1};function sn(t){let e={},n=0;if(xt(t,(r,o)=>{on[o]||(e[o]=r,n++);}),n)return e}function de(t){let e=sn(t);if(e){let n={to:e};return xt(t,(r,o)=>o in e||(n[o]=r)),n}return {...t}}function me(t){return t=ve(t),l$1.arr(t)?t.map(me):or(t)?p.createStringInterpolator({range:[0,1],output:[t,t]})(1):t}function Ue(t){for(let e in t)return !0;return !1}function Ee(t){return l$1.fun(t)||l$1.arr(t)&&l$1.obj(t[0])}function xe(t,e){t.ref?.delete(t),e?.delete(t);}function he(t,e){e&&t.ref!==e&&(t.ref?.delete(t),e.add(t),t.ref=e);}var mt={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20},slow:{tension:280,friction:60},molasses:{tension:280,friction:120}};var tt={...mt.default,mass:1,damping:1,easing:Lt$1.linear,clamp:!1},we=class{tension;friction;frequency;damping;mass;velocity=0;restVelocity;precision;progress;duration;easing;clamp;bounce;decay;round;constructor(){Object.assign(this,tt);}};function gt(t,e,n){n&&(n={...n},ht(n,e),e={...n,...e}),ht(t,e),Object.assign(t,e);for(let i in tt)t[i]==null&&(t[i]=tt[i]);let{frequency:r,damping:o}=t,{mass:s}=t;return l$1.und(r)||(r<.01&&(r=.01),o<0&&(o=0),t.tension=Math.pow(2*Math.PI/r,2)*s,t.friction=4*Math.PI*o*s/r),t}function ht(t,e){if(!l$1.und(e.decay))t.duration=void 0;else {let n=!l$1.und(e.tension)||!l$1.und(e.friction);(n||!l$1.und(e.frequency)||!l$1.und(e.damping)||!l$1.und(e.mass))&&(t.duration=void 0,t.decay=void 0),n&&(t.frequency=void 0);}}var yt=[],Le=class{changed=!1;values=yt;toValues=null;fromValues=yt;to;from;config=new we;immediate=!1};function Me(t,{key:e,props:n$1,defaultProps:r,state:o,actions:s}){return new Promise((i,a)=>{let u,p$1,f=te(n$1.cancel??r?.cancel,e);if(f)b();else {l$1.und(n$1.pause)||(o.paused=te(n$1.pause,e));let c=r?.pause;c!==!0&&(c=o.paused||te(c,e)),u=I$1(n$1.delay||0,e),c?(o.resumeQueue.add(m),s.pause()):(s.resume(),m());}function d(){o.resumeQueue.add(m),o.timeouts.delete(p$1),p$1.cancel(),u=p$1.time-n.now();}function m(){u>0&&!p.skipAnimation?(o.delayed=!0,p$1=n.setTimeout(b,u),o.pauseQueue.add(d),o.timeouts.add(p$1)):b();}function b(){o.delayed&&(o.delayed=!1),o.pauseQueue.delete(d),o.timeouts.delete(p$1),t<=(o.cancelId||0)&&(f=!0);try{s.start({...n$1,callId:t,cancel:f},i);}catch(c){a(c);}}})}var be=(t,e)=>e.length==1?e[0]:e.some(n=>n.cancelled)?q$1(t.get()):e.every(n=>n.noop)?nt(t.get()):E(t.get(),e.every(n=>n.finished)),nt=t=>({value:t,noop:!0,finished:!0,cancelled:!1}),E=(t,e,n=!1)=>({value:t,finished:e,cancelled:n}),q$1=t=>({value:t,cancelled:!0,finished:!1});function De(t,e,n$1,r){let{callId:o,parentId:s,onRest:i}=e,{asyncTo:a,promise:u}=n$1;return !s&&t===a&&!e.reset?u:n$1.promise=(async()=>{n$1.asyncId=o,n$1.asyncTo=t;let p$1=ne(e,(l,h)=>h==="onRest"?void 0:l),f,d,m=new Promise((l,h)=>(f=l,d=h)),b=l=>{let h=o<=(n$1.cancelId||0)&&q$1(r)||o!==n$1.asyncId&&E(r,!1);if(h)throw l.result=h,d(l),l},c=(l,h)=>{let g=new Ae,x=new Ne;return (async()=>{if(p.skipAnimation)throw oe(n$1),x.result=E(r,!1),d(x),x;b(g);let S=l$1.obj(l)?{...l}:{...h,to:l};S.parentId=o,xt(p$1,(V,_)=>{l$1.und(S[_])&&(S[_]=V);});let A=await r.start(S);return b(g),n$1.paused&&await new Promise(V=>{n$1.resumeQueue.add(V);}),A})()},P;if(p.skipAnimation)return oe(n$1),E(r,!1);try{let l;l$1.arr(t)?l=(async h=>{for(let g of h)await c(g);})(t):l=Promise.resolve(t(c,r.stop.bind(r))),await Promise.all([l.then(f),m]),P=E(r.get(),!0,!1);}catch(l){if(l instanceof Ae)P=l.result;else if(l instanceof Ne)P=l.result;else throw l}finally{o==n$1.asyncId&&(n$1.asyncId=s,n$1.asyncTo=s?a:void 0,n$1.promise=s?u:void 0);}return l$1.fun(i)&&n.batchedUpdates(()=>{i(P,r,r.item);}),P})()}function oe(t,e){Pe$1(t.timeouts,n=>n.cancel()),t.pauseQueue.clear(),t.resumeQueue.clear(),t.asyncId=t.asyncTo=t.promise=void 0,e&&(t.cancelId=e);}var Ae=class extends Error{result;constructor(){super("An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise.");}},Ne=class extends Error{result;constructor(){super("SkipAnimationSignal");}};var Re=t=>t instanceof X,Sn=1,X=class extends ge{id=Sn++;_priority=0;get priority(){return this._priority}set priority(e){this._priority!=e&&(this._priority=e,this._onPriorityChange(e));}get(){let e=k$1(this);return e&&e.getValue()}to(...e){return p.to(this,e)}interpolate(...e){return Jt(),p.to(this,e)}toJSON(){return this.get()}observerAdded(e){e==1&&this._attach();}observerRemoved(e){e==0&&this._detach();}_attach(){}_detach(){}_onChange(e,n=!1){$t(this,{type:"change",parent:this,value:e,idle:n});}_onPriorityChange(e){this.idle||qe$1.sort(this),$t(this,{type:"priority",parent:this,priority:e});}};var se=Symbol.for("SpringPhase"),bt=1,rt=2,ot=4,qe=t=>(t[se]&bt)>0,Q=t=>(t[se]&rt)>0,ye=t=>(t[se]&ot)>0,st=(t,e)=>e?t[se]|=rt|bt:t[se]&=~rt,it$1=(t,e)=>e?t[se]|=ot:t[se]&=~ot;var ue=class extends X{key;animation=new Le;queue;defaultProps={};_state={paused:!1,delayed:!1,pauseQueue:new Set,resumeQueue:new Set,timeouts:new Set};_pendingCalls=new Set;_lastCallId=0;_lastToId=0;_memoizedDuration=0;constructor(e,n){if(super(),!l$1.und(e)||!l$1.und(n)){let r=l$1.obj(e)?{...e}:{...n,from:e};l$1.und(r.default)&&(r.default=!0),this.start(r);}}get idle(){return !(Q(this)||this._state.asyncTo)||ye(this)}get goal(){return ve(this.animation.to)}get velocity(){let e=k$1(this);return e instanceof l?e.lastVelocity||0:e.getPayload().map(n=>n.lastVelocity||0)}get hasAnimated(){return qe(this)}get isAnimating(){return Q(this)}get isPaused(){return ye(this)}get isDelayed(){return this._state.delayed}advance(e){let n=!0,r=!1,o=this.animation,{toValues:s}=o,{config:i}=o,a=F$1(o.to);!a&&Pt(o.to)&&(s=ht$1(ve(o.to))),o.values.forEach((f,d$1)=>{if(f.done)return;let m=f.constructor==d?1:a?a[d$1].lastPosition:s[d$1],b=o.immediate,c=m;if(!b){if(c=f.lastPosition,i.tension<=0){f.done=!0;return}let P=f.elapsedTime+=e,l=o.fromValues[d$1],h=f.v0!=null?f.v0:f.v0=l$1.arr(i.velocity)?i.velocity[d$1]:i.velocity,g,x=i.precision||(l==m?.005:Math.min(1,Math.abs(m-l)*.001));if(l$1.und(i.duration))if(i.decay){let S=i.decay===!0?.998:i.decay,A=Math.exp(-(1-S)*P);c=l+h/(1-S)*(1-A),b=Math.abs(f.lastPosition-c)<=x,g=h*A;}else {g=f.lastVelocity==null?h:f.lastVelocity;let S=i.restVelocity||x/10,A=i.clamp?0:i.bounce,V=!l$1.und(A),_=l==m?f.v0>0:l<m,v,w=!1,C=1,$=Math.ceil(e/C);for(let L=0;L<$&&(v=Math.abs(g)>S,!(!v&&(b=Math.abs(m-c)<=x,b)));++L){V&&(w=c==m||c>m==_,w&&(g=-g*A,c=m));let N=-i.tension*1e-6*(c-m),y=-i.friction*.001*g,T=(N+y)/i.mass;g=g+T*C,c=c+g*C;}}else {let S=1;i.duration>0&&(this._memoizedDuration!==i.duration&&(this._memoizedDuration=i.duration,f.durationProgress>0&&(f.elapsedTime=i.duration*f.durationProgress,P=f.elapsedTime+=e)),S=(i.progress||0)+P/this._memoizedDuration,S=S>1?1:S<0?0:S,f.durationProgress=S),c=l+i.easing(S)*(m-l),g=(c-f.lastPosition)/e,b=S==1;}f.lastVelocity=g,Number.isNaN(c)&&(console.warn("Got NaN while animating:",this),b=!0);}a&&!a[d$1].done&&(b=!1),b?f.done=!0:n=!1,f.setValue(c,i.round)&&(r=!0);});let u=k$1(this),p=u.getValue();if(n){let f=ve(o.to);(p!==f||r)&&!i.decay?(u.setValue(f),this._onChange(f)):r&&i.decay&&this._onChange(p),this._stop();}else r&&this._onChange(p);}set(e){return n.batchedUpdates(()=>{this._stop(),this._focus(e),this._set(e);}),this}pause(){this._update({pause:!0});}resume(){this._update({pause:!1});}finish(){if(Q(this)){let{to:e,config:n$1}=this.animation;n.batchedUpdates(()=>{this._onStart(),n$1.decay||this._set(e,!1),this._stop();});}return this}update(e){return (this.queue||(this.queue=[])).push(e),this}start(e,n){let r;return l$1.und(e)?(r=this.queue||[],this.queue=[]):r=[l$1.obj(e)?e:{...n,to:e}],Promise.all(r.map(o=>this._update(o))).then(o=>be(this,o))}stop(e){let{to:n$1}=this.animation;return this._focus(this.get()),oe(this._state,e&&this._lastCallId),n.batchedUpdates(()=>this._stop(n$1,e)),this}reset(){this._update({reset:!0});}eventObserved(e){e.type=="change"?this._start():e.type=="priority"&&(this.priority=e.priority+1);}_prepareNode(e){let n=this.key||"",{to:r,from:o}=e;r=l$1.obj(r)?r[n]:r,(r==null||Ee(r))&&(r=void 0),o=l$1.obj(o)?o[n]:o,o==null&&(o=void 0);let s={to:r,from:o};return qe(this)||(e.reverse&&([r,o]=[o,r]),o=ve(o),l$1.und(o)?k$1(this)||this._set(r):this._set(o)),s}_update({...e},n){let{key:r,defaultProps:o}=this;e.default&&Object.assign(o,ne(e,(a,u)=>/^on/.test(u)?et(a,r):a)),_t(this,e,"onProps"),Ie(this,"onProps",e,this);let s=this._prepareNode(e);if(Object.isFrozen(this))throw Error("Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?");let i=this._state;return Me(++this._lastCallId,{key:r,props:e,defaultProps:o,state:i,actions:{pause:()=>{ye(this)||(it$1(this,!0),yt$1(i.pauseQueue),Ie(this,"onPause",E(this,Ce(this,this.animation.to)),this));},resume:()=>{ye(this)&&(it$1(this,!1),Q(this)&&this._resume(),yt$1(i.resumeQueue),Ie(this,"onResume",E(this,Ce(this,this.animation.to)),this));},start:this._merge.bind(this,s)}}).then(a=>{if(e.loop&&a.finished&&!(n&&a.noop)){let u=at(e);if(u)return this._update(u,!0)}return a})}_merge(e,n$1,r){if(n$1.cancel)return this.stop(!0),r(q$1(this));let o=!l$1.und(e.to),s=!l$1.und(e.from);if(o||s)if(n$1.callId>this._lastToId)this._lastToId=n$1.callId;else return r(q$1(this));let{key:i,defaultProps:a,animation:u}=this,{to:p,from:f}=u,{to:d$1=p,from:m=f}=e;s&&!o&&(!n$1.default||l$1.und(d$1))&&(d$1=m),n$1.reverse&&([d$1,m]=[m,d$1]);let b=!bt$1(m,f);b&&(u.from=m),m=ve(m);let c=!bt$1(d$1,p);c&&this._focus(d$1);let P=Ee(n$1.to),{config:l}=u,{decay:h,velocity:g}=l;(o||s)&&(l.velocity=0),n$1.config&&!P&&gt(l,I$1(n$1.config,i),n$1.config!==a.config?I$1(a.config,i):void 0);let x=k$1(this);if(!x||l$1.und(d$1))return r(E(this,!0));let S=l$1.und(n$1.reset)?s&&!n$1.default:!l$1.und(m)&&te(n$1.reset,i),A=S?m:this.get(),V=me(d$1),_=l$1.num(V)||l$1.arr(V)||or(V),v=!P&&(!_||te(a.immediate||n$1.immediate,i));if(c){let L=Le$1(d$1);if(L!==x.constructor)if(v)x=this._set(V);else throw Error(`Cannot animate between ${x.constructor.name} and ${L.name}, as the "to" prop suggests`)}let w=x.constructor,C=Pt(d$1),$=!1;if(!C){let L=S||!qe(this)&&b;(c||L)&&($=bt$1(me(A),V),C=!$),(!bt$1(u.immediate,v)&&!v||!bt$1(l.decay,h)||!bt$1(l.velocity,g))&&(C=!0);}if($&&Q(this)&&(u.changed&&!S?C=!0:C||this._stop(p)),!P&&((C||Pt(p))&&(u.values=x.getPayload(),u.toValues=Pt(d$1)?null:w==d?[1]:ht$1(V)),u.immediate!=v&&(u.immediate=v,!v&&!S&&this._set(p)),C)){let{onRest:L}=u;Ve(_n,y=>_t(this,n$1,y));let N=E(this,Ce(this,p));yt$1(this._pendingCalls,N),this._pendingCalls.add(r),u.changed&&n.batchedUpdates(()=>{u.changed=!S,L?.(N,this),S?I$1(a.onRest,N):u.onStart?.(N,this);});}S&&this._set(A),P?r(De(n$1.to,n$1,this._state,this)):C?this._start():Q(this)&&!c?this._pendingCalls.add(r):r(nt(A));}_focus(e){let n=this.animation;e!==n.to&&(qt(this)&&this._detach(),n.to=e,qt(this)&&this._attach());}_attach(){let e=0,{to:n}=this.animation;Pt(n)&&(Gt$1(n,this),Re(n)&&(e=n.priority+1)),this.priority=e;}_detach(){let{to:e}=this.animation;Pt(e)&&Qt(e,this);}_set(e,n$1=!0){let r=ve(e);if(!l$1.und(r)){let o=k$1(this);if(!o||!bt$1(r,o.getValue())){let s=Le$1(r);!o||o.constructor!=s?D(this,s.create(r)):o.setValue(r),o&&n.batchedUpdates(()=>{this._onChange(r,n$1);});}}return k$1(this)}_onStart(){let e=this.animation;e.changed||(e.changed=!0,Ie(this,"onStart",E(this,Ce(this,e.to)),this));}_onChange(e,n){n||(this._onStart(),I$1(this.animation.onChange,e,this)),I$1(this.defaultProps.onChange,e,this),super._onChange(e,n);}_start(){let e=this.animation;k$1(this).reset(ve(e.to)),e.immediate||(e.fromValues=e.values.map(n=>n.lastPosition)),Q(this)||(st(this,!0),ye(this)||this._resume());}_resume(){p.skipAnimation?this.finish():qe$1.start(this);}_stop(e,n){if(Q(this)){st(this,!1);let r=this.animation;Ve(r.values,s=>{s.done=!0;}),r.toValues&&(r.onChange=r.onPause=r.onResume=void 0),$t(this,{type:"idle",parent:this});let o=n?q$1(this.get()):E(this.get(),Ce(this,e??r.to));yt$1(this._pendingCalls,o),r.changed&&(r.changed=!1,Ie(this,"onRest",o,this));}}};function Ce(t,e){let n=me(e),r=me(t.get());return bt$1(r,n)}function at(t,e=t.loop,n=t.to){let r=I$1(e);if(r){let o=r!==!0&&de(r),s=(o||t).reverse,i=!o||o.reset;return Pe({...t,loop:e,default:!1,pause:void 0,to:!s||Ee(n)?n:void 0,from:i?t.from:void 0,reset:i,...o})}}function Pe(t){let{to:e,from:n}=t=de(t),r=new Set;return l$1.obj(e)&&Vt(e,r),l$1.obj(n)&&Vt(n,r),t.keys=r.size?Array.from(r):null,t}function Ot(t){let e=Pe(t);return l$1.und(e.default)&&(e.default=ne(e)),e}function Vt(t,e){xt(t,(n,r)=>n!=null&&e.add(r));}var _n=["onStart","onRest","onChange","onPause","onResume"];function _t(t,e,n){t.animation[n]=e[n]!==ke(e,n)?et(e[n],t.key):void 0;}function Ie(t,e,...n){t.animation[e]?.(...n),t.defaultProps[e]?.(...n);}var Fn=["onStart","onChange","onRest"],kn=1,le=class{id=kn++;springs={};queue=[];ref;_flush;_initialProps;_lastAsyncId=0;_active=new Set;_changed=new Set;_started=!1;_item;_state={paused:!1,pauseQueue:new Set,resumeQueue:new Set,timeouts:new Set};_events={onStart:new Map,onChange:new Map,onRest:new Map};constructor(e,n){this._onFrame=this._onFrame.bind(this),n&&(this._flush=n),e&&this.start({default:!0,...e});}get idle(){return !this._state.asyncTo&&Object.values(this.springs).every(e=>e.idle&&!e.isDelayed&&!e.isPaused)}get item(){return this._item}set item(e){this._item=e;}get(){let e={};return this.each((n,r)=>e[r]=n.get()),e}set(e){for(let n in e){let r=e[n];l$1.und(r)||this.springs[n].set(r);}}update(e){return e&&this.queue.push(Pe(e)),this}start(e){let{queue:n}=this;return e?n=ht$1(e).map(Pe):this.queue=[],this._flush?this._flush(this,n):(jt(this,n),ze(this,n))}stop(e,n){if(e!==!!e&&(n=e),n){let r=this.springs;Ve(ht$1(n),o=>r[o].stop(!!e));}else oe(this._state,this._lastAsyncId),this.each(r=>r.stop(!!e));return this}pause(e){if(l$1.und(e))this.start({pause:!0});else {let n=this.springs;Ve(ht$1(e),r=>n[r].pause());}return this}resume(e){if(l$1.und(e))this.start({pause:!1});else {let n=this.springs;Ve(ht$1(e),r=>n[r].resume());}return this}each(e){xt(this.springs,e);}_onFrame(){let{onStart:e,onChange:n,onRest:r}=this._events,o=this._active.size>0,s=this._changed.size>0;(o&&!this._started||s&&!this._started)&&(this._started=!0,Pe$1(e,([u,p])=>{p.value=this.get(),u(p,this,this._item);}));let i=!o&&this._started,a=s||i&&r.size?this.get():null;s&&n.size&&Pe$1(n,([u,p])=>{p.value=a,u(p,this,this._item);}),i&&(this._started=!1,Pe$1(r,([u,p])=>{p.value=a,u(p,this,this._item);}));}eventObserved(e){if(e.type=="change")this._changed.add(e.parent),e.idle||this._active.add(e.parent);else if(e.type=="idle")this._active.delete(e.parent);else return;n.onFrame(this._onFrame);}};function ze(t,e){return Promise.all(e.map(n=>wt(t,n))).then(n=>be(t,n))}async function wt(t,e,n$1){let{keys:r,to:o,from:s,loop:i,onRest:a,onResolve:u}=e,p=l$1.obj(e.default)&&e.default;i&&(e.loop=!1),o===!1&&(e.to=null),s===!1&&(e.from=null);let f=l$1.arr(o)||l$1.fun(o)?o:void 0;f?(e.to=void 0,e.onRest=void 0,p&&(p.onRest=void 0)):Ve(Fn,P=>{let l=e[P];if(l$1.fun(l)){let h=t._events[P];e[P]=({finished:g,cancelled:x})=>{let S=h.get(l);S?(g||(S.finished=!1),x&&(S.cancelled=!0)):h.set(l,{value:null,finished:g||!1,cancelled:x||!1});},p&&(p[P]=e[P]);}});let d=t._state;e.pause===!d.paused?(d.paused=e.pause,yt$1(e.pause?d.pauseQueue:d.resumeQueue)):d.paused&&(e.pause=!0);let m=(r||Object.keys(t.springs)).map(P=>t.springs[P].start(e)),b=e.cancel===!0||ke(e,"cancel")===!0;(f||b&&d.asyncId)&&m.push(Me(++t._lastAsyncId,{props:e,state:d,actions:{pause:Y,resume:Y,start(P,l){b?(oe(d,t._lastAsyncId),l(q$1(t))):(P.onRest=a,l(De(f,P,d,t)));}}})),d.paused&&await new Promise(P=>{d.resumeQueue.add(P);});let c=be(t,await Promise.all(m));if(i&&c.finished&&!(n$1&&c.noop)){let P=at(e,i,o);if(P)return jt(t,[P]),wt(t,P,!0)}return u&&n.batchedUpdates(()=>u(c,t,t.item)),c}function _e(t,e){let n={...t.springs};return e&&Ve(ht$1(e),r=>{l$1.und(r.keys)&&(r=Pe(r)),l$1.obj(r.to)||(r={...r,to:void 0}),Mt(n,r,o=>Lt(o));}),pt(t,n),n}function pt(t,e){xt(e,(n,r)=>{t.springs[r]||(t.springs[r]=n,Gt$1(n,t));});}function Lt(t,e){let n=new ue;return n.key=t,e&&Gt$1(n,e),n}function Mt(t,e,n){e.keys&&Ve(e.keys,r=>{(t[r]||(t[r]=n(r)))._prepareNode(e);});}function jt(t,e){Ve(e,n=>{Mt(t.springs,n,r=>Lt(r,t));});}var H=({children:t,...e})=>{let n=useContext(Ge),r=e.pause||!!n.pause,o=e.immediate||!!n.immediate;e=Lr(()=>({pause:r,immediate:o}),[r,o]);let{Provider:s}=Ge;return React.createElement(s,{value:e},t)},Ge=wn(H,{});H.Provider=Ge.Provider;H.Consumer=Ge.Consumer;function wn(t,e){return Object.assign(t,React.createContext(e)),t.Provider._context=t,t.Consumer._context=t,t}var fe=()=>{let t=[],e=function(r){er$1();let o=[];return Ve(t,(s,i)=>{if(l$1.und(r))o.push(s.start());else {let a=n(r,s,i);a&&o.push(s.start(a));}}),o};e.current=t,e.add=function(r){t.includes(r)||t.push(r);},e.delete=function(r){let o=t.indexOf(r);~o&&t.splice(o,1);},e.pause=function(){return Ve(t,r=>r.pause(...arguments)),this},e.resume=function(){return Ve(t,r=>r.resume(...arguments)),this},e.set=function(r){Ve(t,(o,s)=>{let i=l$1.fun(r)?r(s,o):r;i&&o.set(i);});},e.start=function(r){let o=[];return Ve(t,(s,i)=>{if(l$1.und(r))o.push(s.start());else {let a=this._getProps(r,s,i);a&&o.push(s.start(a));}}),o},e.stop=function(){return Ve(t,r=>r.stop(...arguments)),this},e.update=function(r){return Ve(t,(o,s)=>o.update(this._getProps(r,o,s))),this};let n=function(r,o,s){return l$1.fun(r)?r(s,o):r};return e._getProps=n,e};function He(t,e,n){let r=l$1.fun(e)&&e;r&&!n&&(n=[]);let o=useMemo(()=>r||arguments.length==3?fe():void 0,[]),s=useRef(0),i=Mr(),a=useMemo(()=>({ctrls:[],queue:[],flush(h,g){let x=_e(h,g);return s.current>0&&!a.queue.length&&!Object.keys(x).some(A=>!h.springs[A])?ze(h,g):new Promise(A=>{pt(h,x),a.queue.push(()=>{A(ze(h,g));}),i();})}}),[]),u=useRef([...a.ctrls]),p=[],f=Ur(t)||0;useMemo(()=>{Ve(u.current.slice(t,f),h=>{xe(h,o),h.stop(!0);}),u.current.length=t,d(f,t);},[t]),useMemo(()=>{d(0,Math.min(f,t));},n);function d(h,g){for(let x=h;x<g;x++){let S=u.current[x]||(u.current[x]=new le(null,a.flush)),A=r?r(x,S):e[x];A&&(p[x]=Ot(A));}}let m=u.current.map((h,g)=>_e(h,p[g])),b=useContext(H),c=Ur(b),P=b!==c&&Ue(b);Q$1(()=>{s.current++,a.ctrls=u.current;let{queue:h}=a;h.length&&(a.queue=[],Ve(h,g=>g())),Ve(u.current,(g,x)=>{o?.add(g),P&&g.start({default:b});let S=p[x];S&&(he(g,S.ref),g.ref?g.queue.push(S):g.start(S));});}),$r(()=>()=>{Ve(a.ctrls,h=>h.stop(!0));});let l=m.map(h=>({...h}));return o?[l,o]:l}function J(t,e){let n=l$1.fun(t),[[r],o]=He(1,n?t:[t],n?e||[]:e);return n||arguments.length==2?[r,o]:r}function Gt(t,e,n){let r=l$1.fun(e)&&e,{reset:o,sort:s,trail:i=0,expires:a=!0,exitBeforeEnter:u=!1,onDestroyed:p,ref:f,config:d}=r?r():e,m=useMemo(()=>r||arguments.length==3?fe():void 0,[]),b=ht$1(t),c=[],P=useRef(null),l=o?null:P.current;Q$1(()=>{P.current=c;}),$r(()=>(Ve(c,y=>{m?.add(y.ctrl),y.ctrl.ref=m;}),()=>{Ve(P.current,y=>{y.expired&&clearTimeout(y.expirationId),xe(y.ctrl,m),y.ctrl.stop(!0);});}));let h=tr(b,r?r():e,l),g=o&&P.current||[];Q$1(()=>Ve(g,({ctrl:y,item:T,key:F})=>{xe(y,m),I$1(p,T,F);}));let x=[];if(l&&Ve(l,(y,T)=>{y.expired?(clearTimeout(y.expirationId),g.push(y)):(T=x[T]=h.indexOf(y.key),~T&&(c[T]=y));}),Ve(b,(y,T)=>{c[T]||(c[T]={key:h[T],item:y,phase:"mount",ctrl:new le},c[T].ctrl.item=y);}),x.length){let y=-1,{leave:T}=r?r():e;Ve(x,(F,k)=>{let O=l[k];~F?(y=c.indexOf(O),c[y]={...O,item:b[F]}):T&&c.splice(++y,0,O);});}l$1.fun(s)&&c.sort((y,T)=>s(y.item,T.item));let S=-i,A=Mr(),V=ne(e),_=new Map,v=useRef(new Map),w=useRef(!1);Ve(c,(y,T)=>{let F=y.key,k=y.phase,O=r?r():e,U,D,Jt=I$1(O.delay||0,F);if(k=="mount")U=O.enter,D="enter";else {let M=h.indexOf(F)<0;if(k!="leave")if(M)U=O.leave,D="leave";else if(U=O.update)D="update";else return;else if(!M)U=O.enter,D="enter";else return}if(U=I$1(U,y.item,T),U=l$1.obj(U)?de(U):{to:U},!U.config){let M=d||V.config;U.config=I$1(M,y.item,T,D);}S+=i;let Z={...V,delay:Jt+S,ref:f,immediate:O.immediate,reset:!1,...U};if(D=="enter"&&l$1.und(Z.from)){let M=r?r():e,Te=l$1.und(M.initial)||l?M.from:M.initial;Z.from=I$1(Te,y.item,T);}let{onResolve:Wt}=Z;Z.onResolve=M=>{I$1(Wt,M);let Te=P.current,B=Te.find(Fe=>Fe.key===F);if(B&&!(M.cancelled&&B.phase!="update")&&B.ctrl.idle){let Fe=Te.every(ee=>ee.ctrl.idle);if(B.phase=="leave"){let ee=I$1(a,B.item);if(ee!==!1){let Ze=ee===!0?0:ee;if(B.expired=!0,!Fe&&Ze>0){Ze<=2147483647&&(B.expirationId=setTimeout(A,Ze));return}}}Fe&&Te.some(ee=>ee.expired)&&(v.current.delete(B),u&&(w.current=!0),A());}};let ft=_e(y.ctrl,Z);D==="leave"&&u?v.current.set(y,{phase:D,springs:ft,payload:Z}):_.set(y,{phase:D,springs:ft,payload:Z});});let C=useContext(H),$=Ur(C),L=C!==$&&Ue(C);Q$1(()=>{L&&Ve(c,y=>{y.ctrl.start({default:C});});},[C]),Ve(_,(y,T)=>{if(v.current.size){let F=c.findIndex(k=>k.key===T.key);c.splice(F,1);}}),Q$1(()=>{Ve(v.current.size?v.current:_,({phase:y,payload:T},F)=>{let{ctrl:k}=F;F.phase=y,m?.add(k),L&&y=="enter"&&k.start({default:C}),T&&(he(k,T.ref),(k.ref||m)&&!w.current?k.update(T):(k.start(T),w.current&&(w.current=!1)));});},o?void 0:n);let N=y=>React.createElement(React.Fragment,null,c.map((T,F)=>{let{springs:k}=_.get(T)||T.ctrl,O=y({...k},T.item,T,F);return O&&O.type?React.createElement(O.type,{...O.props,key:l$1.str(T.key)||l$1.num(T.key)?T.key:T.ctrl.id,ref:O.ref}):O}));return m?[N,m]:N}var er=1;function tr(t,{key:e,keys:n=e},r){if(n===null){let o=new Set;return t.map(s=>{let i=r&&r.find(a=>a.item===s&&a.phase!=="leave"&&!o.has(a));return i?(o.add(i),i.key):er++})}return l$1.und(n)?t:l$1.fun(n)?t.map(n):ht$1(n)}var W=class extends X{constructor(n,r){super();this.source=n;this.calc=W$1(...r);let o=this._get(),s=Le$1(o);D(this,s.create(o));}key;idle=!0;calc;_active=new Set;advance(n){let r=this._get(),o=this.get();bt$1(r,o)||(k$1(this).setValue(r),this._onChange(r,this.idle)),!this.idle&&Yt(this._active)&&ct(this);}_get(){let n=l$1.arr(this.source)?this.source.map(ve):ht$1(ve(this.source));return this.calc(...n)}_start(){this.idle&&!Yt(this._active)&&(this.idle=!1,Ve(F$1(this),n=>{n.done=!1;}),p.skipAnimation?(n.batchedUpdates(()=>this.advance()),ct(this)):qe$1.start(this));}_attach(){let n=1;Ve(ht$1(this.source),r=>{Pt(r)&&Gt$1(r,this),Re(r)&&(r.idle||this._active.add(r),n=Math.max(n,r.priority+1));}),this.priority=n,this._start();}_detach(){Ve(ht$1(this.source),n=>{Pt(n)&&Qt(n,this);}),this._active.clear(),ct(this);}eventObserved(n){n.type=="change"?n.idle?this.advance():(this._active.add(n.parent),this._start()):n.type=="idle"?this._active.delete(n.parent):n.type=="priority"&&(this.priority=ht$1(this.source).reduce((r,o)=>Math.max(r,(Re(o)?o.priority:0)+1),0));}};function vr(t){return t.idle!==!1}function Yt(t){return !t.size||Array.from(t).every(vr)}function ct(t){t.idle||(t.idle=!0,Ve(F$1(t),e=>{e.done=!0;}),$t(t,{type:"idle",parent:t}));}p.assign({createStringInterpolator:Xt,to:(t,e)=>new W(t,e)});
3686
+ // src/applyAnimatedValues.ts
3687
+ var isCustomPropRE = /^--/;
3688
+ function dangerousStyleValue(name, value) {
3689
+ if (value == null || typeof value === "boolean" || value === "")
3690
+ return "";
3691
+ if (typeof value === "number" && value !== 0 && !isCustomPropRE.test(name) && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]))
3692
+ return value + "px";
3693
+ return ("" + value).trim();
3694
+ }
3695
+ var attributeCache = {};
3696
+ function applyAnimatedValues(instance, props) {
3697
+ if (!instance.nodeType || !instance.setAttribute) {
3698
+ return false;
3699
+ }
3700
+ const isFilterElement = instance.nodeName === "filter" || instance.parentNode && instance.parentNode.nodeName === "filter";
3701
+ const { style, children, scrollTop, scrollLeft, viewBox, ...attributes } = props;
3702
+ const values = Object.values(attributes);
3703
+ const names = Object.keys(attributes).map(
3704
+ (name) => isFilterElement || instance.hasAttribute(name) ? name : attributeCache[name] || (attributeCache[name] = name.replace(
3705
+ /([A-Z])/g,
3706
+ // Attributes are written in dash case
3707
+ (n) => "-" + n.toLowerCase()
3708
+ ))
3709
+ );
3710
+ if (children !== void 0) {
3711
+ instance.textContent = children;
3712
+ }
3713
+ for (const name in style) {
3714
+ if (style.hasOwnProperty(name)) {
3715
+ const value = dangerousStyleValue(name, style[name]);
3716
+ if (isCustomPropRE.test(name)) {
3717
+ instance.style.setProperty(name, value);
3718
+ } else {
3719
+ instance.style[name] = value;
3720
+ }
3721
+ }
3722
+ }
3723
+ names.forEach((name, i) => {
3724
+ instance.setAttribute(name, values[i]);
3725
+ });
3726
+ if (scrollTop !== void 0) {
3727
+ instance.scrollTop = scrollTop;
3728
+ }
3729
+ if (scrollLeft !== void 0) {
3730
+ instance.scrollLeft = scrollLeft;
3731
+ }
3732
+ if (viewBox !== void 0) {
3733
+ instance.setAttribute("viewBox", viewBox);
3734
+ }
3735
+ }
3736
+ var isUnitlessNumber = {
3737
+ animationIterationCount: true,
3738
+ borderImageOutset: true,
3739
+ borderImageSlice: true,
3740
+ borderImageWidth: true,
3741
+ boxFlex: true,
3742
+ boxFlexGroup: true,
3743
+ boxOrdinalGroup: true,
3744
+ columnCount: true,
3745
+ columns: true,
3746
+ flex: true,
3747
+ flexGrow: true,
3748
+ flexPositive: true,
3749
+ flexShrink: true,
3750
+ flexNegative: true,
3751
+ flexOrder: true,
3752
+ gridRow: true,
3753
+ gridRowEnd: true,
3754
+ gridRowSpan: true,
3755
+ gridRowStart: true,
3756
+ gridColumn: true,
3757
+ gridColumnEnd: true,
3758
+ gridColumnSpan: true,
3759
+ gridColumnStart: true,
3760
+ fontWeight: true,
3761
+ lineClamp: true,
3762
+ lineHeight: true,
3763
+ opacity: true,
3764
+ order: true,
3765
+ orphans: true,
3766
+ tabSize: true,
3767
+ widows: true,
3768
+ zIndex: true,
3769
+ zoom: true,
3770
+ // SVG-related properties
3771
+ fillOpacity: true,
3772
+ floodOpacity: true,
3773
+ stopOpacity: true,
3774
+ strokeDasharray: true,
3775
+ strokeDashoffset: true,
3776
+ strokeMiterlimit: true,
3777
+ strokeOpacity: true,
3778
+ strokeWidth: true
3779
+ };
3780
+ var prefixKey = (prefix, key) => prefix + key.charAt(0).toUpperCase() + key.substring(1);
3781
+ var prefixes = ["Webkit", "Ms", "Moz", "O"];
3782
+ isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => {
3783
+ prefixes.forEach((prefix) => acc[prefixKey(prefix, prop)] = acc[prop]);
3784
+ return acc;
3785
+ }, isUnitlessNumber);
3786
+ var domTransforms = /^(matrix|translate|scale|rotate|skew)/;
3787
+ var pxTransforms = /^(translate)/;
3788
+ var degTransforms = /^(rotate|skew)/;
3789
+ var addUnit = (value, unit) => is.num(value) && value !== 0 ? value + unit : value;
3790
+ var isValueIdentity = (value, id) => is.arr(value) ? value.every((v) => isValueIdentity(v, id)) : is.num(value) ? value === id : parseFloat(value) === id;
3791
+ var AnimatedStyle = class extends AnimatedObject {
3792
+ constructor({ x, y, z, ...style }) {
3793
+ const inputs = [];
3794
+ const transforms = [];
3795
+ if (x || y || z) {
3796
+ inputs.push([x || 0, y || 0, z || 0]);
3797
+ transforms.push((xyz) => [
3798
+ `translate3d(${xyz.map((v) => addUnit(v, "px")).join(",")})`,
3799
+ // prettier-ignore
3800
+ isValueIdentity(xyz, 0)
3801
+ ]);
3802
+ }
3803
+ eachProp(style, (value, key) => {
3804
+ if (key === "transform") {
3805
+ inputs.push([value || ""]);
3806
+ transforms.push((transform) => [transform, transform === ""]);
3807
+ } else if (domTransforms.test(key)) {
3808
+ delete style[key];
3809
+ if (is.und(value))
3810
+ return;
3811
+ const unit = pxTransforms.test(key) ? "px" : degTransforms.test(key) ? "deg" : "";
3812
+ inputs.push(toArray(value));
3813
+ transforms.push(
3814
+ key === "rotate3d" ? ([x2, y2, z2, deg]) => [
3815
+ `rotate3d(${x2},${y2},${z2},${addUnit(deg, unit)})`,
3816
+ isValueIdentity(deg, 0)
3817
+ ] : (input) => [
3818
+ `${key}(${input.map((v) => addUnit(v, unit)).join(",")})`,
3819
+ isValueIdentity(input, key.startsWith("scale") ? 1 : 0)
3820
+ ]
3821
+ );
3822
+ }
3823
+ });
3824
+ if (inputs.length) {
3825
+ style.transform = new FluidTransform(inputs, transforms);
3826
+ }
3827
+ super(style);
3828
+ }
3829
+ };
3830
+ var FluidTransform = class extends FluidValue {
3831
+ constructor(inputs, transforms) {
3832
+ super();
3833
+ this.inputs = inputs;
3834
+ this.transforms = transforms;
3835
+ this._value = null;
3836
+ }
3837
+ get() {
3838
+ return this._value || (this._value = this._get());
3839
+ }
3840
+ _get() {
3841
+ let transform = "";
3842
+ let identity = true;
3843
+ each(this.inputs, (input, i) => {
3844
+ const arg1 = getFluidValue(input[0]);
3845
+ const [t, id] = this.transforms[i](
3846
+ is.arr(arg1) ? arg1 : input.map(getFluidValue)
3847
+ );
3848
+ transform += " " + t;
3849
+ identity = identity && id;
3850
+ });
3851
+ return identity ? "none" : transform;
3852
+ }
3853
+ // Start observing our inputs once we have an observer.
3854
+ observerAdded(count) {
3855
+ if (count == 1)
3856
+ each(
3857
+ this.inputs,
3858
+ (input) => each(
3859
+ input,
3860
+ (value) => hasFluidValue(value) && addFluidObserver(value, this)
3861
+ )
3862
+ );
3863
+ }
3864
+ // Stop observing our inputs once we have no observers.
3865
+ observerRemoved(count) {
3866
+ if (count == 0)
3867
+ each(
3868
+ this.inputs,
3869
+ (input) => each(
3870
+ input,
3871
+ (value) => hasFluidValue(value) && removeFluidObserver(value, this)
3872
+ )
3873
+ );
3874
+ }
3875
+ eventObserved(event) {
3876
+ if (event.type == "change") {
3877
+ this._value = null;
3878
+ }
3879
+ callFluidObservers(this, event);
3880
+ }
3881
+ };
310
3882
 
311
- var k=/^--/;function I(t,e){return e==null||typeof e=="boolean"||e===""?"":typeof e=="number"&&e!==0&&!k.test(t)&&!(c.hasOwnProperty(t)&&c[t])?e+"px":(""+e).trim()}var v={};function V(t,e){if(!t.nodeType||!t.setAttribute)return !1;let r=t.nodeName==="filter"||t.parentNode&&t.parentNode.nodeName==="filter",{style:i,children:s,scrollTop:u,scrollLeft:l,viewBox:a,...n}=e,d=Object.values(n),m=Object.keys(n).map(o=>r||t.hasAttribute(o)?o:v[o]||(v[o]=o.replace(/([A-Z])/g,p=>"-"+p.toLowerCase())));s!==void 0&&(t.textContent=s);for(let o in i)if(i.hasOwnProperty(o)){let p=I(o,i[o]);k.test(o)?t.style.setProperty(o,p):t.style[o]=p;}m.forEach((o,p)=>{t.setAttribute(o,d[p]);}),u!==void 0&&(t.scrollTop=u),l!==void 0&&(t.scrollLeft=l),a!==void 0&&t.setAttribute("viewBox",a);}var c={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},F=(t,e)=>t+e.charAt(0).toUpperCase()+e.substring(1),L=["Webkit","Ms","Moz","O"];c=Object.keys(c).reduce((t,e)=>(L.forEach(r=>t[F(r,e)]=t[e]),t),c);var _=/^(matrix|translate|scale|rotate|skew)/,$=/^(translate)/,G=/^(rotate|skew)/,y=(t,e)=>l$1.num(t)&&t!==0?t+e:t,h=(t,e)=>l$1.arr(t)?t.every(r=>h(r,e)):l$1.num(t)?t===e:parseFloat(t)===e,g=class extends u{constructor({x:e,y:r,z:i,...s}){let u=[],l=[];(e||r||i)&&(u.push([e||0,r||0,i||0]),l.push(a=>[`translate3d(${a.map(n=>y(n,"px")).join(",")})`,h(a,0)])),xt(s,(a,n)=>{if(n==="transform")u.push([a||""]),l.push(d=>[d,d===""]);else if(_.test(n)){if(delete s[n],l$1.und(a))return;let d=$.test(n)?"px":G.test(n)?"deg":"";u.push(ht$1(a)),l.push(n==="rotate3d"?([m,o,p,O])=>[`rotate3d(${m},${o},${p},${y(O,d)})`,h(O,0)]:m=>[`${n}(${m.map(o=>y(o,d)).join(",")})`,h(m,n.startsWith("scale")?1:0)]);}}),u.length&&(s.transform=new x(u,l)),super(s);}},x=class extends ge{constructor(r,i){super();this.inputs=r;this.transforms=i;}_value=null;get(){return this._value||(this._value=this._get())}_get(){let r="",i=!0;return Ve(this.inputs,(s,u)=>{let l=ve(s[0]),[a,n]=this.transforms[u](l$1.arr(l)?l:s.map(ve));r+=" "+a,i=i&&n;}),i?"none":r}observerAdded(r){r==1&&Ve(this.inputs,i=>Ve(i,s=>Pt(s)&&Gt$1(s,this)));}observerRemoved(r){r==0&&Ve(this.inputs,i=>Ve(i,s=>Pt(s)&&Qt(s,this)));}eventObserved(r){r.type=="change"&&(this._value=null),$t(this,r);}};var C=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"];p.assign({batchedUpdates:unstable_batchedUpdates,createStringInterpolator:Xt,colors:It});var q=Ke(C,{applyAnimatedValues:V,createAnimatedStyle:t=>new g(t),getComponentProps:({scrollTop:t,scrollLeft:e,...r})=>r}),it=q.animated;
3883
+ // src/primitives.ts
3884
+ var primitives = [
3885
+ "a",
3886
+ "abbr",
3887
+ "address",
3888
+ "area",
3889
+ "article",
3890
+ "aside",
3891
+ "audio",
3892
+ "b",
3893
+ "base",
3894
+ "bdi",
3895
+ "bdo",
3896
+ "big",
3897
+ "blockquote",
3898
+ "body",
3899
+ "br",
3900
+ "button",
3901
+ "canvas",
3902
+ "caption",
3903
+ "cite",
3904
+ "code",
3905
+ "col",
3906
+ "colgroup",
3907
+ "data",
3908
+ "datalist",
3909
+ "dd",
3910
+ "del",
3911
+ "details",
3912
+ "dfn",
3913
+ "dialog",
3914
+ "div",
3915
+ "dl",
3916
+ "dt",
3917
+ "em",
3918
+ "embed",
3919
+ "fieldset",
3920
+ "figcaption",
3921
+ "figure",
3922
+ "footer",
3923
+ "form",
3924
+ "h1",
3925
+ "h2",
3926
+ "h3",
3927
+ "h4",
3928
+ "h5",
3929
+ "h6",
3930
+ "head",
3931
+ "header",
3932
+ "hgroup",
3933
+ "hr",
3934
+ "html",
3935
+ "i",
3936
+ "iframe",
3937
+ "img",
3938
+ "input",
3939
+ "ins",
3940
+ "kbd",
3941
+ "keygen",
3942
+ "label",
3943
+ "legend",
3944
+ "li",
3945
+ "link",
3946
+ "main",
3947
+ "map",
3948
+ "mark",
3949
+ "menu",
3950
+ "menuitem",
3951
+ "meta",
3952
+ "meter",
3953
+ "nav",
3954
+ "noscript",
3955
+ "object",
3956
+ "ol",
3957
+ "optgroup",
3958
+ "option",
3959
+ "output",
3960
+ "p",
3961
+ "param",
3962
+ "picture",
3963
+ "pre",
3964
+ "progress",
3965
+ "q",
3966
+ "rp",
3967
+ "rt",
3968
+ "ruby",
3969
+ "s",
3970
+ "samp",
3971
+ "script",
3972
+ "section",
3973
+ "select",
3974
+ "small",
3975
+ "source",
3976
+ "span",
3977
+ "strong",
3978
+ "style",
3979
+ "sub",
3980
+ "summary",
3981
+ "sup",
3982
+ "table",
3983
+ "tbody",
3984
+ "td",
3985
+ "textarea",
3986
+ "tfoot",
3987
+ "th",
3988
+ "thead",
3989
+ "time",
3990
+ "title",
3991
+ "tr",
3992
+ "track",
3993
+ "u",
3994
+ "ul",
3995
+ "var",
3996
+ "video",
3997
+ "wbr",
3998
+ // SVG
3999
+ "circle",
4000
+ "clipPath",
4001
+ "defs",
4002
+ "ellipse",
4003
+ "foreignObject",
4004
+ "g",
4005
+ "image",
4006
+ "line",
4007
+ "linearGradient",
4008
+ "mask",
4009
+ "path",
4010
+ "pattern",
4011
+ "polygon",
4012
+ "polyline",
4013
+ "radialGradient",
4014
+ "rect",
4015
+ "stop",
4016
+ "svg",
4017
+ "text",
4018
+ "tspan"
4019
+ ];
4020
+ globals_exports.assign({
4021
+ batchedUpdates: unstable_batchedUpdates,
4022
+ createStringInterpolator: createStringInterpolator2,
4023
+ colors: colors2
4024
+ });
4025
+ var host = createHost(primitives, {
4026
+ applyAnimatedValues,
4027
+ createAnimatedStyle: (style) => new AnimatedStyle(style),
4028
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
4029
+ getComponentProps: ({ scrollTop, scrollLeft, ...props }) => props
4030
+ });
4031
+ var animated = host.animated;
312
4032
 
313
4033
  /**
314
4034
  * Component style.
315
4035
  */
316
- const StyledDataPoint = styled(it.g)``;
4036
+ const StyledDataPoint = styled(animated.g)``;
317
4037
 
318
4038
  const _excluded$k = ["children", "className", "data", "id", "index", "isSelected", "labelDecorator", "onClick", "role", "tooltipVariant"];
319
4039
  const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
@@ -428,7 +4148,7 @@ const StyledArc = styled(DataPoint)`
428
4148
  const config = (() => ({
429
4149
  config: {
430
4150
  duration: 700,
431
- easing: Lt$1.easeInOutQuad
4151
+ easing: easings.easeInOutQuad
432
4152
  },
433
4153
  reset: true,
434
4154
  immediate: false
@@ -467,10 +4187,10 @@ const Arc = /*#__PURE__*/forwardRef((props, ref) => {
467
4187
  previousData
468
4188
  } = props,
469
4189
  forwardedProps = _objectWithoutProperties(props, _excluded$j);
470
- const interpolator = interpolate(previousData, data);
4190
+ const interpolator = interpolate$1(previousData, data);
471
4191
  const isSelectable = role === 'option';
472
4192
  const isDeselected = isSelectable && propsIsSelected === false;
473
- const animatedProps = J(_objectSpread2(_objectSpread2({}, config), {}, {
4193
+ const animatedProps = useSpring(_objectSpread2(_objectSpread2({}, config), {}, {
474
4194
  to: async next => {
475
4195
  await next({
476
4196
  t: 1
@@ -485,7 +4205,7 @@ const Arc = /*#__PURE__*/forwardRef((props, ref) => {
485
4205
  className: classNames(Arc.className, className),
486
4206
  $clickable: Boolean(onClick),
487
4207
  $hasStroke: Boolean(hasStroke)
488
- }), /*#__PURE__*/React__default.createElement(it.path, {
4208
+ }), /*#__PURE__*/React__default.createElement(animated.path, {
489
4209
  d: config.immediate ? createArc(data) : animatedProps.t.to(t => createArc(interpolator(t))),
490
4210
  fill: isDeselected ? 'var(--redsift-color-neutral-lightgrey)' : color
491
4211
  }));
@@ -519,7 +4239,7 @@ const Arcs = /*#__PURE__*/forwardRef((props, ref) => {
519
4239
  } = props,
520
4240
  forwardedProps = _objectWithoutProperties(props, _excluded$i);
521
4241
  const id = propsId !== null && propsId !== void 0 ? propsId : useId();
522
- const animatedProps = J(_objectSpread2(_objectSpread2({}, config), {}, {
4242
+ const animatedProps = useSpring(_objectSpread2(_objectSpread2({}, config), {}, {
523
4243
  to: async next => {
524
4244
  await next({
525
4245
  t: 1
@@ -561,8 +4281,8 @@ const Arcs = /*#__PURE__*/forwardRef((props, ref) => {
561
4281
  const arcIndex = (_arc$index2 = arc.index) !== null && _arc$index2 !== void 0 ? _arc$index2 : index;
562
4282
  const arcId = (_arc$id2 = arc.id) !== null && _arc$id2 !== void 0 ? _arc$id2 : `id${id}__arc-${arcIndex}`;
563
4283
  const arcLabelDecorator = (_arc$labelDecorator = arc.labelDecorator) !== null && _arc$labelDecorator !== void 0 ? _arc$labelDecorator : labelDecorator;
564
- const interpolator = interpolate(arc.from, arc.data);
565
- return /*#__PURE__*/React__default.createElement(it.text, {
4284
+ const interpolator = interpolate$1(arc.from, arc.data);
4285
+ return /*#__PURE__*/React__default.createElement(animated.text, {
566
4286
  alignmentBaseline: "middle",
567
4287
  className: `arc-label _${index}`,
568
4288
  key: `${arcId}-label`,
@@ -600,7 +4320,7 @@ const AxisPosition = {
600
4320
  /**
601
4321
  * Component style.
602
4322
  */
603
- const StyledAxis = styled(it.g)`
4323
+ const StyledAxis = styled(animated.g)`
604
4324
  .redsift-axis__line,
605
4325
  .redsift-axis-tick__line {
606
4326
  fill: none;
@@ -759,7 +4479,7 @@ const Axis = /*#__PURE__*/forwardRef((props, ref) => {
759
4479
  forwardedProps = _objectWithoutProperties(props, _excluded$h);
760
4480
  const axis = getAxisType(position);
761
4481
  const axisRef = ref || useRef();
762
- const animatedProps = J(_objectSpread2(_objectSpread2({}, config), {}, {
4482
+ const animatedProps = useSpring(_objectSpread2(_objectSpread2({}, config), {}, {
763
4483
  to: async next => {
764
4484
  await next({
765
4485
  lineX2: axis === 'x' ? length : 0,
@@ -823,7 +4543,7 @@ const Axis = /*#__PURE__*/forwardRef((props, ref) => {
823
4543
  tickPadding: tickPadding,
824
4544
  tickRotation: tickRotation
825
4545
  });
826
- const transition = Gt(ticks, _objectSpread2(_objectSpread2({}, config), {}, {
4546
+ const transition = useTransition(ticks, _objectSpread2(_objectSpread2({}, config), {}, {
827
4547
  keys: tick => tick.key,
828
4548
  initial: tick => ({
829
4549
  opacity: 1,
@@ -855,7 +4575,7 @@ const Axis = /*#__PURE__*/forwardRef((props, ref) => {
855
4575
  transform: `translate(${x},${y})`,
856
4576
  ref: axisRef
857
4577
  }), variant === AxisVariant.default || variant === AxisVariant.tick || variant === AxisVariant.lineTick || variant === AxisVariant.tickValue ? transition((transitionProps, tick, _state, tickIndex) => {
858
- return /*#__PURE__*/React__default.createElement(it.g, {
4578
+ return /*#__PURE__*/React__default.createElement(animated.g, {
859
4579
  className: `${Axis.className}__tick`,
860
4580
  key: tickIndex,
861
4581
  transform: transitionProps.transform,
@@ -868,12 +4588,12 @@ const Axis = /*#__PURE__*/forwardRef((props, ref) => {
868
4588
  x2: tick.lineX,
869
4589
  y1: 0,
870
4590
  y2: tick.lineY
871
- }), variant === AxisVariant.default || variant === AxisVariant.tickValue ? /*#__PURE__*/React__default.createElement(it.text, {
4591
+ }), variant === AxisVariant.default || variant === AxisVariant.tickValue ? /*#__PURE__*/React__default.createElement(animated.text, {
872
4592
  dominantBaseline: textBaseline,
873
4593
  textAnchor: textAlign,
874
4594
  transform: transitionProps.textTransform
875
4595
  }, `${tick.value}`) : null);
876
- }) : null, variant === AxisVariant.default || variant === AxisVariant.line || variant === AxisVariant.lineTick ? /*#__PURE__*/React__default.createElement(it.line, {
4596
+ }) : null, variant === AxisVariant.default || variant === AxisVariant.line || variant === AxisVariant.lineTick ? /*#__PURE__*/React__default.createElement(animated.line, {
877
4597
  className: `${Axis.className}__line`,
878
4598
  x1: 0,
879
4599
  x2: config.immediate ? axis === 'x' ? length : 0 : animatedProps.lineX2,
@@ -988,11 +4708,11 @@ const Bar = /*#__PURE__*/forwardRef((props, ref) => {
988
4708
  width
989
4709
  } = props,
990
4710
  forwardedProps = _objectWithoutProperties(props, _excluded$g);
991
- const interpolator = interpolate(((_data = previousData.data) === null || _data === void 0 ? void 0 : _data.value) || 0, data.data.value);
4711
+ const interpolator = interpolate$1(((_data = previousData.data) === null || _data === void 0 ? void 0 : _data.value) || 0, data.data.value);
992
4712
  const text = labelDecorator ? labelDecorator(data) : data.data.key;
993
4713
  const isSelectable = role === 'option';
994
4714
  const isDeselected = isSelectable && propsIsSelected === false;
995
- const animatedProps = J(_objectSpread2(_objectSpread2({}, config), {}, {
4715
+ const animatedProps = useSpring(_objectSpread2(_objectSpread2({}, config), {}, {
996
4716
  to: async next => {
997
4717
  await next({
998
4718
  t: 1
@@ -1007,11 +4727,11 @@ const Bar = /*#__PURE__*/forwardRef((props, ref) => {
1007
4727
  className: classNames(Bar.className, className),
1008
4728
  transform: orientation === BarOrientation.horizontal ? `translate(0, ${gap * (index + 1) + height * index})` : `translate(${gap * (index + 1) + width * index}, 0)`,
1009
4729
  $clickable: Boolean(onClick)
1010
- }), orientation === BarOrientation.horizontal ? /*#__PURE__*/React__default.createElement(it.rect, {
4730
+ }), orientation === BarOrientation.horizontal ? /*#__PURE__*/React__default.createElement(animated.rect, {
1011
4731
  height: height,
1012
4732
  fill: isDeselected ? 'var(--redsift-color-neutral-lightgrey)' : color,
1013
4733
  width: config.immediate ? scale(data.data.value) : animatedProps.t.to(t => scale(interpolator(t)))
1014
- }) : /*#__PURE__*/React__default.createElement(it.rect, {
4734
+ }) : /*#__PURE__*/React__default.createElement(animated.rect, {
1015
4735
  height: config.immediate ? scale(data.data.value) : animatedProps.t.to(t => scale(interpolator(t))),
1016
4736
  fill: isDeselected ? 'var(--redsift-color-neutral-lightgrey)' : color,
1017
4737
  width: width
@@ -1074,9 +4794,10 @@ const StyledChartContainerCaption = styled.p`
1074
4794
  font-size: var(--redsift-typography-caption-font-size);
1075
4795
  font-weight: var(--redsift-typography-caption-font-weight);
1076
4796
  line-height: var(--redsift-typography-caption-line-height);
4797
+ margin: 8px;
1077
4798
  `;
1078
4799
 
1079
- const _excluded$f = ["aria-label", "aria-labelledby", "caption", "chartProps", "chartRef", "children", "className", "id", "title", "onReset"];
4800
+ const _excluded$f = ["aria-label", "aria-labelledby", "description", "chartProps", "chartRef", "children", "className", "id", "title", "onReset"];
1080
4801
  const COMPONENT_NAME$6 = 'ChartContainer';
1081
4802
  const CLASSNAME$6 = 'redsift-chart-container';
1082
4803
  const DEFAULT_PROPS$6 = {};
@@ -1084,7 +4805,7 @@ const ChartContainer = /*#__PURE__*/forwardRef((props, ref) => {
1084
4805
  const {
1085
4806
  'aria-label': propsAriaLabel,
1086
4807
  'aria-labelledby': propsAriaLabelledby,
1087
- caption,
4808
+ description,
1088
4809
  chartProps,
1089
4810
  chartRef,
1090
4811
  children,
@@ -1115,14 +4836,16 @@ const ChartContainer = /*#__PURE__*/forwardRef((props, ref) => {
1115
4836
  color: "question",
1116
4837
  variant: "unstyled",
1117
4838
  onClick: onReset
1118
- }, stringFormatter.format('reset')) : null) : null, children ? /*#__PURE__*/React__default.createElement("div", _extends({}, chartProps, {
4839
+ }, stringFormatter.format('reset')) : null) : null, /*#__PURE__*/React__default.createElement(Flexbox, {
4840
+ flexDirection: "column"
4841
+ }, children ? /*#__PURE__*/React__default.createElement("div", _extends({}, chartProps, {
1119
4842
  ref: chartRef,
1120
4843
  className: `${ChartContainer.className}__content`,
1121
4844
  "aria-label": ariaLabel,
1122
4845
  "aria-labelledby": ariaLabelledby
1123
- }), children) : null, caption ? /*#__PURE__*/React__default.createElement(StyledChartContainerCaption, {
1124
- className: `${ChartContainer.className}__caption`
1125
- }, caption) : null);
4846
+ }), children) : null, description ? /*#__PURE__*/React__default.createElement(StyledChartContainerCaption, {
4847
+ className: `${ChartContainer.className}__description`
4848
+ }, description) : null));
1126
4849
  });
1127
4850
  ChartContainer.className = CLASSNAME$6;
1128
4851
  ChartContainer.defaultProps = DEFAULT_PROPS$6;
@@ -2348,13 +6071,20 @@ const EmptyScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
2348
6071
  })))));
2349
6072
  });
2350
6073
 
2351
- const _excluded$1 = ["isBrushable", "className", "data", "dotRole", "id", "isDotSelected", "labelDecorator", "labelVariant", "legendProps", "onBrush", "onBrushEnd", "onDotClick", "size", "theme", "tooltipVariant", "variant", "xAxisVariant", "yAxisVariant"];
6074
+ // Material Design Icons v7.2.96
6075
+ var mdiChevronDown = "M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z";
6076
+ var mdiChevronRight = "M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z";
6077
+ var mdiMouse = "M11,1.07C7.05,1.56 4,4.92 4,9H11M4,15A8,8 0 0,0 12,23A8,8 0 0,0 20,15V11H4M13,1.07V9H20C20,4.92 16.94,1.56 13,1.07Z";
6078
+
6079
+ const _excluded$1 = ["isBrushable", "caption", "className", "data", "dotRole", "hideControlKeyPanel", "id", "isDotSelected", "labelDecorator", "labelVariant", "legendProps", "onBrush", "onBrushEnd", "onDotClick", "size", "theme", "tooltipVariant", "variant", "xAxisVariant", "xAxisPlacement", "yAxisVariant", "yAxisPlacement"];
2352
6080
  const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
2353
6081
  const {
2354
6082
  isBrushable,
6083
+ caption,
2355
6084
  className,
2356
6085
  data: propsData,
2357
6086
  dotRole,
6087
+ hideControlKeyPanel,
2358
6088
  id,
2359
6089
  isDotSelected,
2360
6090
  labelDecorator,
@@ -2368,7 +6098,9 @@ const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
2368
6098
  tooltipVariant,
2369
6099
  variant,
2370
6100
  xAxisVariant,
2371
- yAxisVariant
6101
+ xAxisPlacement,
6102
+ yAxisVariant,
6103
+ yAxisPlacement
2372
6104
  } = props,
2373
6105
  forwardedProps = _objectWithoutProperties(props, _excluded$1);
2374
6106
  const cache = useRef();
@@ -2380,10 +6112,10 @@ const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
2380
6112
  const width = chartDimensions.width;
2381
6113
  const height = chartDimensions.height;
2382
6114
  const margins = {
2383
- top: 16,
2384
- left: 48,
2385
- right: 16,
2386
- bottom: 48
6115
+ top: xAxisVariant === AxisVariant.default || xAxisVariant === AxisVariant.tickValue ? 24 : 8,
6116
+ left: yAxisVariant === AxisVariant.default || yAxisVariant === AxisVariant.tickValue ? 48 : 8,
6117
+ right: yAxisVariant === AxisVariant.default || yAxisVariant === AxisVariant.tickValue ? 48 : 8,
6118
+ bottom: xAxisVariant === AxisVariant.default || xAxisVariant === AxisVariant.tickValue ? 24 : 8
2387
6119
  };
2388
6120
  const chartHeight = height - margins.top - margins.bottom;
2389
6121
  const chartWidth = width - margins.left - margins.right;
@@ -2454,11 +6186,50 @@ const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
2454
6186
  if (countsByCategory && !legendWidth.current) {
2455
6187
  legendWidth.current = `${Math.max(...countsByCategory.map(d => d.key.length + String(d.value).length)) * 8 + 32}px`;
2456
6188
  }
6189
+ const [isKeyPanelOpen, setIsKeyPanelOpen] = useState(false);
2457
6190
  return /*#__PURE__*/React__default.createElement(StyledScatterPlot, _extends({}, forwardedProps, {
2458
6191
  id: id,
2459
6192
  className: className,
2460
6193
  ref: ref
2461
- }), /*#__PURE__*/React__default.createElement("svg", {
6194
+ }), /*#__PURE__*/React__default.createElement(Flexbox, {
6195
+ flexDirection: "column",
6196
+ alignItems: "center",
6197
+ gap: "8"
6198
+ }, !hideControlKeyPanel ? /*#__PURE__*/React__default.createElement(Flexbox, {
6199
+ width: width,
6200
+ position: "absolute"
6201
+ }, /*#__PURE__*/React__default.createElement(Flexbox, {
6202
+ flexDirection: "column",
6203
+ alignItems: "flex-end",
6204
+ position: "absolute",
6205
+ top: `${margins.top + 16}px`,
6206
+ right: `${margins.right + 16}px`
6207
+ }, /*#__PURE__*/React__default.createElement(Popover, {
6208
+ placement: "bottom-end",
6209
+ isOpen: isKeyPanelOpen,
6210
+ onOpen: setIsKeyPanelOpen
6211
+ }, /*#__PURE__*/React__default.createElement(Popover.Trigger, null, /*#__PURE__*/React__default.createElement(Button, {
6212
+ variant: "secondary",
6213
+ rightIcon: isKeyPanelOpen ? mdiChevronDown : mdiChevronRight,
6214
+ color: "question",
6215
+ style: {
6216
+ border: '1px solid var(--redsift-color-neutral-midgrey)'
6217
+ }
6218
+ }, /*#__PURE__*/React__default.createElement(Icon, {
6219
+ icon: mdiMouse
6220
+ }))), /*#__PURE__*/React__default.createElement(Popover.Content, {
6221
+ flexDirection: "column",
6222
+ alignItems: "flex-start"
6223
+ }, /*#__PURE__*/React__default.createElement(Text, {
6224
+ margin: "8px 16px 0",
6225
+ fontSize: "13px"
6226
+ }, "Zoom - Mouse wheel"), /*#__PURE__*/React__default.createElement(Text, {
6227
+ margin: "0 16px",
6228
+ fontSize: "13px"
6229
+ }, "Pan - Left click and drag"), /*#__PURE__*/React__default.createElement(Text, {
6230
+ margin: "0 16px 8px",
6231
+ fontSize: "13px"
6232
+ }, "Select - Hold shift, left click and drag"))))) : null, /*#__PURE__*/React__default.createElement("svg", {
2462
6233
  ref: svgRef,
2463
6234
  width: width,
2464
6235
  height: height
@@ -2499,23 +6270,41 @@ const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
2499
6270
  });
2500
6271
  }))), /*#__PURE__*/React__default.createElement("g", {
2501
6272
  transform: `translate(${margins.left},${margins.top})`
2502
- }, /*#__PURE__*/React__default.createElement(Axis, {
2503
- position: "left",
2504
- length: chartHeight,
2505
- scale: scaleY,
6273
+ }, ['bottom', 'both'].includes(xAxisPlacement) ? /*#__PURE__*/React__default.createElement(Axis, {
6274
+ position: "bottom",
6275
+ length: chartWidth,
6276
+ scale: scaleX,
2506
6277
  x: 0,
2507
- y: 0,
6278
+ y: chartHeight,
2508
6279
  tickValues: 8,
2509
6280
  variant: xAxisVariant
2510
- }), /*#__PURE__*/React__default.createElement(Axis, {
2511
- position: "bottom",
6281
+ }) : null, ['top', 'both'].includes(xAxisPlacement) ? /*#__PURE__*/React__default.createElement(Axis, {
6282
+ position: "top",
2512
6283
  length: chartWidth,
2513
6284
  scale: scaleX,
2514
6285
  x: 0,
2515
- y: chartHeight,
6286
+ y: 0,
6287
+ tickValues: 8,
6288
+ variant: xAxisVariant
6289
+ }) : null, ['left', 'both'].includes(yAxisPlacement) ? /*#__PURE__*/React__default.createElement(Axis, {
6290
+ position: "left",
6291
+ length: chartHeight,
6292
+ scale: scaleY,
6293
+ x: 0,
6294
+ y: 0,
6295
+ tickValues: 8,
6296
+ variant: yAxisVariant
6297
+ }) : null, ['right', 'both'].includes(yAxisPlacement) ? /*#__PURE__*/React__default.createElement(Axis, {
6298
+ position: "right",
6299
+ length: chartHeight,
6300
+ scale: scaleY,
6301
+ x: chartWidth,
6302
+ y: 0,
2516
6303
  tickValues: 8,
2517
6304
  variant: yAxisVariant
2518
- }))), hasCategory && labelVariant !== ScatterPlotLabelVariant.none ? /*#__PURE__*/React__default.createElement(Legend, _extends({
6305
+ }) : null)), /*#__PURE__*/React__default.createElement(StyledChartContainerCaption, {
6306
+ width: chartWidth - 48
6307
+ }, caption)), hasCategory && labelVariant !== ScatterPlotLabelVariant.none ? /*#__PURE__*/React__default.createElement(Legend, _extends({
2519
6308
  data: countsByCategory.map(d => _objectSpread2(_objectSpread2({}, d), {}, {
2520
6309
  color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(d.key)
2521
6310
  })),
@@ -2528,6 +6317,7 @@ const _excluded = ["className", "data", "dotRole", "emptyComponent", "id", "isDo
2528
6317
  const COMPONENT_NAME = 'ScatterPlot';
2529
6318
  const CLASSNAME = 'redsift-scatterplot';
2530
6319
  const DEFAULT_PROPS = {
6320
+ hideControlKeyPanel: false,
2531
6321
  labelVariant: ScatterPlotLabelVariant.externalLabel,
2532
6322
  localeText: {
2533
6323
  emptyChartText: 'No Data'
@@ -2537,7 +6327,9 @@ const DEFAULT_PROPS = {
2537
6327
  tooltipVariant: TooltipVariant.none,
2538
6328
  variant: ScatterPlotVariant.default,
2539
6329
  xAxisVariant: AxisVariant.default,
2540
- yAxisVariant: AxisVariant.default
6330
+ xAxisPlacement: 'bottom',
6331
+ yAxisVariant: AxisVariant.default,
6332
+ yAxisPlacement: 'left'
2541
6333
  };
2542
6334
  const ScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
2543
6335
  const {