@seeqdev/qomponents 0.0.116 → 0.0.118

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/dist/Accordion/Accordion.js +9 -0
  2. package/dist/Accordion/Accordion.js.map +1 -0
  3. package/dist/Accordion/Accordion.stories.js +115 -0
  4. package/dist/Accordion/Accordion.stories.js.map +1 -0
  5. package/dist/Accordion/Accordion.test.js +55 -0
  6. package/dist/Accordion/Accordion.test.js.map +1 -0
  7. package/dist/Accordion/Accordion.types.js +2 -0
  8. package/dist/Accordion/Accordion.types.js.map +1 -0
  9. package/dist/Accordion/index.js +2 -0
  10. package/dist/Accordion/index.js.map +1 -0
  11. package/dist/Alert/Alert.js +34 -0
  12. package/dist/Alert/Alert.js.map +1 -0
  13. package/dist/Alert/Alert.stories.js +52 -0
  14. package/dist/Alert/Alert.stories.js.map +1 -0
  15. package/dist/Alert/Alert.test.js +51 -0
  16. package/dist/Alert/Alert.test.js.map +1 -0
  17. package/dist/Alert/Alert.types.js +2 -0
  18. package/dist/Alert/Alert.types.js.map +1 -0
  19. package/dist/Alert/index.js +2 -0
  20. package/dist/Alert/index.js.map +1 -0
  21. package/dist/Button/Button.js +92 -0
  22. package/dist/Button/Button.js.map +1 -0
  23. package/dist/Button/Button.stories.js +100 -0
  24. package/dist/Button/Button.stories.js.map +1 -0
  25. package/dist/Button/Button.test.js +49 -0
  26. package/dist/Button/Button.test.js.map +1 -0
  27. package/dist/Button/Button.types.js +5 -0
  28. package/dist/Button/Button.types.js.map +1 -0
  29. package/dist/Button/index.js +2 -0
  30. package/dist/Button/index.js.map +1 -0
  31. package/dist/ButtonWithDropdown/ButtonWithDropdown.js +67 -0
  32. package/dist/ButtonWithDropdown/ButtonWithDropdown.js.map +1 -0
  33. package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js +98 -0
  34. package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js.map +1 -0
  35. package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js +85 -0
  36. package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js.map +1 -0
  37. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js +2 -0
  38. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js.map +1 -0
  39. package/dist/ButtonWithDropdown/index.js +2 -0
  40. package/dist/ButtonWithDropdown/index.js.map +1 -0
  41. package/dist/ButtonWithPopover/ButtonWithPopover.js +53 -0
  42. package/dist/ButtonWithPopover/ButtonWithPopover.js.map +1 -0
  43. package/dist/ButtonWithPopover/ButtonWithPopover.stories.js +75 -0
  44. package/dist/ButtonWithPopover/ButtonWithPopover.stories.js.map +1 -0
  45. package/dist/ButtonWithPopover/ButtonWithPopover.test.js +82 -0
  46. package/dist/ButtonWithPopover/ButtonWithPopover.test.js.map +1 -0
  47. package/dist/ButtonWithPopover/ButtonWithPopover.types.js +2 -0
  48. package/dist/ButtonWithPopover/ButtonWithPopover.types.js.map +1 -0
  49. package/dist/ButtonWithPopover/index.js +2 -0
  50. package/dist/ButtonWithPopover/index.js.map +1 -0
  51. package/dist/Checkbox/Checkbox.js +26 -0
  52. package/dist/Checkbox/Checkbox.js.map +1 -0
  53. package/dist/Checkbox/Checkbox.stories.js +34 -0
  54. package/dist/Checkbox/Checkbox.stories.js.map +1 -0
  55. package/dist/Checkbox/Checkbox.test.js +94 -0
  56. package/dist/Checkbox/Checkbox.test.js.map +1 -0
  57. package/dist/Checkbox/Checkbox.types.js +2 -0
  58. package/dist/Checkbox/Checkbox.types.js.map +1 -0
  59. package/dist/Checkbox/index.js +2 -0
  60. package/dist/Checkbox/index.js.map +1 -0
  61. package/dist/Collapse/Collapse.d.ts +4 -0
  62. package/dist/Collapse/Collapse.js +3 -5
  63. package/dist/Collapse/Collapse.js.map +1 -1
  64. package/dist/Collapse/Collapse.stories.d.ts +5 -0
  65. package/dist/Collapse/Collapse.stories.js +1 -1
  66. package/dist/Collapse/Collapse.test.d.ts +1 -0
  67. package/dist/Collapse/Collapse.test.js +7 -12
  68. package/dist/Collapse/Collapse.test.js.map +1 -1
  69. package/dist/Collapse/Collapse.types.d.ts +4 -0
  70. package/dist/Collapse/index.d.ts +1 -0
  71. package/dist/FontCustom.woff +0 -0
  72. package/dist/FontCustom.woff2 +0 -0
  73. package/dist/Icon/Icon.js +55 -0
  74. package/dist/Icon/Icon.js.map +1 -0
  75. package/dist/Icon/Icon.stories.js +50 -0
  76. package/dist/Icon/Icon.stories.js.map +1 -0
  77. package/dist/Icon/Icon.test.js +55 -0
  78. package/dist/Icon/Icon.test.js.map +1 -0
  79. package/dist/Icon/Icon.types.js +16 -0
  80. package/dist/Icon/Icon.types.js.map +1 -0
  81. package/dist/Icon/index.js +2 -0
  82. package/dist/Icon/index.js.map +1 -0
  83. package/dist/InputGroup/InputGroup.js +32 -0
  84. package/dist/InputGroup/InputGroup.js.map +1 -0
  85. package/dist/InputGroup/InputGroup.stories.js +168 -0
  86. package/dist/InputGroup/InputGroup.stories.js.map +1 -0
  87. package/dist/InputGroup/InputGroup.test.js +43 -0
  88. package/dist/InputGroup/InputGroup.test.js.map +1 -0
  89. package/dist/InputGroup/InputGroup.types.js +2 -0
  90. package/dist/InputGroup/InputGroup.types.js.map +1 -0
  91. package/dist/InputGroup/index.js +2 -0
  92. package/dist/InputGroup/index.js.map +1 -0
  93. package/dist/Modal/Modal.js +100 -0
  94. package/dist/Modal/Modal.js.map +1 -0
  95. package/dist/Modal/Modal.stories.js +127 -0
  96. package/dist/Modal/Modal.stories.js.map +1 -0
  97. package/dist/Modal/Modal.test.js +108 -0
  98. package/dist/Modal/Modal.test.js.map +1 -0
  99. package/dist/Modal/Modal.types.js +2 -0
  100. package/dist/Modal/Modal.types.js.map +1 -0
  101. package/dist/Modal/index.js +2 -0
  102. package/dist/Modal/index.js.map +1 -0
  103. package/dist/ProgressBar/ProgressBar.js +30 -0
  104. package/dist/ProgressBar/ProgressBar.js.map +1 -0
  105. package/dist/ProgressBar/ProgressBar.stories.js +73 -0
  106. package/dist/ProgressBar/ProgressBar.stories.js.map +1 -0
  107. package/dist/ProgressBar/ProgressBar.test.js +38 -0
  108. package/dist/ProgressBar/ProgressBar.test.js.map +1 -0
  109. package/dist/ProgressBar/ProgressBar.types.d.ts +1 -2
  110. package/dist/ProgressBar/ProgressBar.types.js +2 -0
  111. package/dist/ProgressBar/ProgressBar.types.js.map +1 -0
  112. package/dist/ProgressBar/index.js +2 -0
  113. package/dist/ProgressBar/index.js.map +1 -0
  114. package/dist/SeeqActionDropdown/SeeqActionDropdown.js +48 -0
  115. package/dist/SeeqActionDropdown/SeeqActionDropdown.js.map +1 -0
  116. package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js +80 -0
  117. package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js.map +1 -0
  118. package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js +73 -0
  119. package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js.map +1 -0
  120. package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js +2 -0
  121. package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js.map +1 -0
  122. package/dist/SeeqActionDropdown/index.js +2 -0
  123. package/dist/SeeqActionDropdown/index.js.map +1 -0
  124. package/dist/SeeqActionDropdown/variants.js +23 -0
  125. package/dist/SeeqActionDropdown/variants.js.map +1 -0
  126. package/dist/Select/Select.js +174 -0
  127. package/dist/Select/Select.js.map +1 -0
  128. package/dist/Select/Select.stories.js +80 -0
  129. package/dist/Select/Select.stories.js.map +1 -0
  130. package/dist/Select/Select.test.js +182 -0
  131. package/dist/Select/Select.test.js.map +1 -0
  132. package/dist/Select/Select.types.js +2 -0
  133. package/dist/Select/Select.types.js.map +1 -0
  134. package/dist/Select/index.js +3 -0
  135. package/dist/Select/index.js.map +1 -0
  136. package/dist/Slider/Slider.js +13 -0
  137. package/dist/Slider/Slider.js.map +1 -0
  138. package/dist/Slider/Slider.stories.js +58 -0
  139. package/dist/Slider/Slider.stories.js.map +1 -0
  140. package/dist/Slider/Slider.test.js +33 -0
  141. package/dist/Slider/Slider.test.js.map +1 -0
  142. package/dist/Slider/Slider.types.js +2 -0
  143. package/dist/Slider/Slider.types.js.map +1 -0
  144. package/dist/Slider/index.js +2 -0
  145. package/dist/Slider/index.js.map +1 -0
  146. package/dist/Tabs/Tabs.js +22 -0
  147. package/dist/Tabs/Tabs.js.map +1 -0
  148. package/dist/Tabs/Tabs.stories.js +91 -0
  149. package/dist/Tabs/Tabs.stories.js.map +1 -0
  150. package/dist/Tabs/Tabs.test.js +91 -0
  151. package/dist/Tabs/Tabs.test.js.map +1 -0
  152. package/dist/Tabs/Tabs.types.js +2 -0
  153. package/dist/Tabs/Tabs.types.js.map +1 -0
  154. package/dist/Tabs/index.js +2 -0
  155. package/dist/Tabs/index.js.map +1 -0
  156. package/dist/TextArea/TextArea.js +25 -0
  157. package/dist/TextArea/TextArea.js.map +1 -0
  158. package/dist/TextArea/TextArea.stories.js +46 -0
  159. package/dist/TextArea/TextArea.stories.js.map +1 -0
  160. package/dist/TextArea/TextArea.test.js +68 -0
  161. package/dist/TextArea/TextArea.test.js.map +1 -0
  162. package/dist/TextArea/TextArea.types.js +2 -0
  163. package/dist/TextArea/TextArea.types.js.map +1 -0
  164. package/dist/TextArea/index.js +2 -0
  165. package/dist/TextArea/index.js.map +1 -0
  166. package/dist/TextField/TextField.js +79 -0
  167. package/dist/TextField/TextField.js.map +1 -0
  168. package/dist/TextField/TextField.stories.js +70 -0
  169. package/dist/TextField/TextField.stories.js.map +1 -0
  170. package/dist/TextField/TextField.test.js +39 -0
  171. package/dist/TextField/TextField.test.js.map +1 -0
  172. package/dist/TextField/TextField.types.js +2 -0
  173. package/dist/TextField/TextField.types.js.map +1 -0
  174. package/dist/TextField/index.js +2 -0
  175. package/dist/TextField/index.js.map +1 -0
  176. package/dist/ToolbarButton/ToolbarButton.js +75 -0
  177. package/dist/ToolbarButton/ToolbarButton.js.map +1 -0
  178. package/dist/ToolbarButton/ToolbarButton.stories.js +94 -0
  179. package/dist/ToolbarButton/ToolbarButton.stories.js.map +1 -0
  180. package/dist/ToolbarButton/ToolbarButton.test.js +93 -0
  181. package/dist/ToolbarButton/ToolbarButton.test.js.map +1 -0
  182. package/dist/ToolbarButton/ToolbarButton.types.js +2 -0
  183. package/dist/ToolbarButton/ToolbarButton.types.js.map +1 -0
  184. package/dist/ToolbarButton/index.js +2 -0
  185. package/dist/ToolbarButton/index.js.map +1 -0
  186. package/dist/Tooltip/QTip.stories.js +45 -0
  187. package/dist/Tooltip/QTip.stories.js.map +1 -0
  188. package/dist/Tooltip/QTip.types.js +2 -0
  189. package/dist/Tooltip/QTip.types.js.map +1 -0
  190. package/dist/Tooltip/QTipPerformance.stories.js +30 -0
  191. package/dist/Tooltip/QTipPerformance.stories.js.map +1 -0
  192. package/dist/Tooltip/Qtip.js +168 -0
  193. package/dist/Tooltip/Qtip.js.map +1 -0
  194. package/dist/Tooltip/Tooltip.js +36 -0
  195. package/dist/Tooltip/Tooltip.js.map +1 -0
  196. package/dist/Tooltip/Tooltip.stories.js +32 -0
  197. package/dist/Tooltip/Tooltip.stories.js.map +1 -0
  198. package/dist/Tooltip/Tooltip.types.js +3 -0
  199. package/dist/Tooltip/Tooltip.types.js.map +1 -0
  200. package/dist/Tooltip/TooltipPerformance.stories.js +30 -0
  201. package/dist/Tooltip/TooltipPerformance.stories.js.map +1 -0
  202. package/dist/Tooltip/index.js +3 -0
  203. package/dist/Tooltip/index.js.map +1 -0
  204. package/dist/Tooltip/qTip.utilities.js +11 -0
  205. package/dist/Tooltip/qTip.utilities.js.map +1 -0
  206. package/dist/index.d.ts +2 -0
  207. package/dist/index.esm.js +3550 -35
  208. package/dist/index.esm.js.map +1 -1
  209. package/dist/index.js +3549 -33
  210. package/dist/index.js.map +1 -1
  211. package/dist/styles.css +24 -8
  212. package/dist/types.js +2 -0
  213. package/dist/types.js.map +1 -0
  214. package/dist/utils/browserId.js +29 -0
  215. package/dist/utils/browserId.js.map +1 -0
  216. package/dist/utils/svg.js +20 -0
  217. package/dist/utils/svg.js.map +1 -0
  218. package/dist/utils/validateStyleDimension.js +14 -0
  219. package/dist/utils/validateStyleDimension.js.map +1 -0
  220. package/dist/utils/validateStyleDimension.test.js +20 -0
  221. package/dist/utils/validateStyleDimension.test.js.map +1 -0
  222. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -1097,7 +1097,7 @@ const oppositeAlignmentMap = {
1097
1097
  start: 'end',
1098
1098
  end: 'start'
1099
1099
  };
1100
- function clamp$1(start, value, end) {
1100
+ function clamp$2(start, value, end) {
1101
1101
  return max$1(start, min$1(value, end));
1102
1102
  }
1103
1103
  function evaluate(value, param) {
@@ -1470,7 +1470,7 @@ const arrow$1 = options => ({
1470
1470
  const min$1$1 = minPadding;
1471
1471
  const max = clientSize - arrowDimensions[length] - maxPadding;
1472
1472
  const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
1473
- const offset = clamp$1(min$1$1, center, max);
1473
+ const offset = clamp$2(min$1$1, center, max);
1474
1474
 
1475
1475
  // If the reference is small enough that the arrow's padding causes it to
1476
1476
  // to point to nothing for an aligned placement, adjust the offset of the
@@ -1810,14 +1810,14 @@ const shift = function (options) {
1810
1810
  const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
1811
1811
  const min = mainAxisCoord + overflow[minSide];
1812
1812
  const max = mainAxisCoord - overflow[maxSide];
1813
- mainAxisCoord = clamp$1(min, mainAxisCoord, max);
1813
+ mainAxisCoord = clamp$2(min, mainAxisCoord, max);
1814
1814
  }
1815
1815
  if (checkCrossAxis) {
1816
1816
  const minSide = crossAxis === 'y' ? 'top' : 'left';
1817
1817
  const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
1818
1818
  const min = crossAxisCoord + overflow[minSide];
1819
1819
  const max = crossAxisCoord - overflow[maxSide];
1820
- crossAxisCoord = clamp$1(min, crossAxisCoord, max);
1820
+ crossAxisCoord = clamp$2(min, crossAxisCoord, max);
1821
1821
  }
1822
1822
  const limitedCoords = limiter.fn({
1823
1823
  ...state,
@@ -6127,7 +6127,7 @@ function createDOMPurify() {
6127
6127
  }
6128
6128
  var purify = createDOMPurify();
6129
6129
 
6130
- const noop$1 = () => { };
6130
+ const noop$2 = () => { };
6131
6131
 
6132
6132
  /**
6133
6133
  * A setInterval hook that calls a callback after a interval duration
@@ -6158,7 +6158,7 @@ function useIntervalWhen(callback, intervalDurationMs = 0, when = true, startImm
6158
6158
  window.clearInterval(interval);
6159
6159
  };
6160
6160
  }
6161
- return noop$1;
6161
+ return noop$2;
6162
6162
  }, [when, intervalDurationMs, startImmediate]);
6163
6163
  }
6164
6164
 
@@ -6834,7 +6834,7 @@ var from = String.fromCharCode;
6834
6834
  * @param {object}
6835
6835
  * @return {object}
6836
6836
  */
6837
- var assign = Object.assign;
6837
+ var assign$1 = Object.assign;
6838
6838
 
6839
6839
  /**
6840
6840
  * @param {string} value
@@ -6960,7 +6960,7 @@ function node (value, root, parent, type, props, children, length) {
6960
6960
  * @return {object}
6961
6961
  */
6962
6962
  function copy (root, props) {
6963
- return assign(node('', null, null, '', null, null, 0), root, {length: -root.length}, props)
6963
+ return assign$1(node('', null, null, '', null, null, 0), root, {length: -root.length}, props)
6964
6964
  }
6965
6965
 
6966
6966
  /**
@@ -7648,7 +7648,7 @@ var incorrectImportAlarm = function incorrectImportAlarm(element, index, childre
7648
7648
 
7649
7649
  /* eslint-disable no-fallthrough */
7650
7650
 
7651
- function prefix(value, length) {
7651
+ function prefix$1(value, length) {
7652
7652
  switch (hash(value, length)) {
7653
7653
  // color-adjust
7654
7654
  case 5103:
@@ -7776,7 +7776,7 @@ function prefix(value, length) {
7776
7776
  // (s)tretch
7777
7777
 
7778
7778
  case 115:
7779
- return ~indexof(value, 'stretch') ? prefix(replace(value, 'stretch', 'fill-available'), length) + value : value;
7779
+ return ~indexof(value, 'stretch') ? prefix$1(replace(value, 'stretch', 'fill-available'), length) + value : value;
7780
7780
  }
7781
7781
  break;
7782
7782
  // position: sticky
@@ -7824,7 +7824,7 @@ function prefix(value, length) {
7824
7824
  var prefixer = function prefixer(element, index, children, callback) {
7825
7825
  if (element.length > -1) if (!element["return"]) switch (element.type) {
7826
7826
  case DECLARATION:
7827
- element["return"] = prefix(element.value, element.length);
7827
+ element["return"] = prefix$1(element.value, element.length);
7828
7828
  break;
7829
7829
 
7830
7830
  case KEYFRAMES:
@@ -9292,7 +9292,7 @@ var _excluded$3 = ["className", "clearValue", "cx", "getStyles", "getClassNames"
9292
9292
  // NO OP
9293
9293
  // ==============================
9294
9294
 
9295
- var noop = function noop() {};
9295
+ var noop$1 = function noop() {};
9296
9296
 
9297
9297
  // ==============================
9298
9298
  // Class Name Prefixer
@@ -9453,7 +9453,7 @@ function easeOutCubic(t, b, c, d) {
9453
9453
  }
9454
9454
  function animatedScrollTo(element, to) {
9455
9455
  var duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 200;
9456
- var callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : noop;
9456
+ var callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : noop$1;
9457
9457
  var start = getScrollTop(element);
9458
9458
  var change = to - start;
9459
9459
  var increment = 10;
@@ -9541,8 +9541,8 @@ var options = {
9541
9541
  // check for SSR
9542
9542
  var w = typeof window !== 'undefined' ? window : {};
9543
9543
  if (w.addEventListener && w.removeEventListener) {
9544
- w.addEventListener('p', noop, options);
9545
- w.removeEventListener('p', noop, false);
9544
+ w.addEventListener('p', noop$1, options);
9545
+ w.removeEventListener('p', noop$1, false);
9546
9546
  }
9547
9547
  var supportsPassiveEvents = passiveOptionAccessed;
9548
9548
  function notNullish(item) {
@@ -10647,7 +10647,7 @@ var safeIsNaN = Number.isNaN ||
10647
10647
  function ponyfill(value) {
10648
10648
  return typeof value === 'number' && value !== value;
10649
10649
  };
10650
- function isEqual(first, second) {
10650
+ function isEqual$1(first, second) {
10651
10651
  if (first === second) {
10652
10652
  return true;
10653
10653
  }
@@ -10656,12 +10656,12 @@ function isEqual(first, second) {
10656
10656
  }
10657
10657
  return false;
10658
10658
  }
10659
- function areInputsEqual(newInputs, lastInputs) {
10659
+ function areInputsEqual$1(newInputs, lastInputs) {
10660
10660
  if (newInputs.length !== lastInputs.length) {
10661
10661
  return false;
10662
10662
  }
10663
10663
  for (var i = 0; i < newInputs.length; i++) {
10664
- if (!isEqual(newInputs[i], lastInputs[i])) {
10664
+ if (!isEqual$1(newInputs[i], lastInputs[i])) {
10665
10665
  return false;
10666
10666
  }
10667
10667
  }
@@ -10669,7 +10669,7 @@ function areInputsEqual(newInputs, lastInputs) {
10669
10669
  }
10670
10670
 
10671
10671
  function memoizeOne(resultFn, isEqual) {
10672
- if (isEqual === void 0) { isEqual = areInputsEqual; }
10672
+ if (isEqual === void 0) { isEqual = areInputsEqual$1; }
10673
10673
  var cache = null;
10674
10674
  function memoized() {
10675
10675
  var newArgs = [];
@@ -11574,7 +11574,7 @@ var defaultStyles = {
11574
11574
  valueContainer: valueContainerCSS
11575
11575
  };
11576
11576
 
11577
- var colors = {
11577
+ var colors$1 = {
11578
11578
  primary: '#2684FF',
11579
11579
  primary75: '#4C9AFF',
11580
11580
  primary50: '#B2D4FF',
@@ -11607,7 +11607,7 @@ var spacing = {
11607
11607
  };
11608
11608
  var defaultTheme = {
11609
11609
  borderRadius: borderRadius$1,
11610
- colors: colors,
11610
+ colors: colors$1,
11611
11611
  spacing: spacing
11612
11612
  };
11613
11613
 
@@ -12726,7 +12726,7 @@ var Select$1 = /*#__PURE__*/function (_Component) {
12726
12726
  id: id,
12727
12727
  innerRef: this.getInputRef,
12728
12728
  onBlur: this.onInputBlur,
12729
- onChange: noop,
12729
+ onChange: noop$1,
12730
12730
  onFocus: this.onInputFocus,
12731
12731
  disabled: isDisabled,
12732
12732
  tabIndex: tabIndex,
@@ -15966,11 +15966,3511 @@ const InputGroup = React.forwardRef((props, ref) => {
15966
15966
  const tooltipData = getQTipData(tooltipProps);
15967
15967
  const appliedClasses = `${baseClasses} ${extraClassNames}`;
15968
15968
  const fieldAppliedClasses = `${fieldClasses} ${extraClassNames} ${lightTheme} ${darkTheme} ${borderRadius} ${showError ? errorClasses : borderColorClasses} `;
15969
- return (React.createElement("div", { id: id, className: appliedClasses },
15969
+ return (React.createElement("div", { id: `input-group-${id}`, className: appliedClasses },
15970
15970
  field ? (React.createElement("div", { "data-testid": testId, className: `tw-flex tw-flex-1 tw-cursor-pointer active:tw-z-50 ${fieldAppliedClasses}` }, field)) : (React.createElement(TextField, { testId: testId, readonly: readonly, onChange: onChange, onKeyUp: onKeyUp, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, name: name, ref: ref, showError: showError, value: value, required: required, placeholder: placeholder, autoComplete: autoComplete, autoFocus: autoFocus, id: id, type: type, disabled: disabled, step: step, min: min, max: max, maxLength: maxLength, minLength: minLength, extraClassNames: `tw-flex tw-flex-1 tw-w-full tw-rounded-r-none focus:tw-z-30 ${extraClassNames}`, ...tooltipData })),
15971
15971
  append.filter(Boolean).map((item, index) => item?.variant === 'button' ? (React.createElement(Button, { key: index, extraClassNames: "tw-ml-[-1px] focus:tw-z-40 focus:tw-border tw-rounded-l-none tw-rounded-r-none last:tw-rounded-r-sm", ...item.buttonProps })) : (React.createElement("div", { key: index, className: `${borderColorClasses} tw-flex tw-items-center tw-justify-center tw-rounded-none tw-ml-[-1px] active:tw-z-30 active:tw-border tw-border last:tw-rounded-r-sm` }, item?.element)))));
15972
15972
  });
15973
15973
 
15974
+ // src/index.ts
15975
+ var updateQueue = makeQueue();
15976
+ var raf = (fn) => schedule(fn, updateQueue);
15977
+ var writeQueue = makeQueue();
15978
+ raf.write = (fn) => schedule(fn, writeQueue);
15979
+ var onStartQueue = makeQueue();
15980
+ raf.onStart = (fn) => schedule(fn, onStartQueue);
15981
+ var onFrameQueue = makeQueue();
15982
+ raf.onFrame = (fn) => schedule(fn, onFrameQueue);
15983
+ var onFinishQueue = makeQueue();
15984
+ raf.onFinish = (fn) => schedule(fn, onFinishQueue);
15985
+ var timeouts = [];
15986
+ raf.setTimeout = (handler, ms) => {
15987
+ const time = raf.now() + ms;
15988
+ const cancel = () => {
15989
+ const i = timeouts.findIndex((t) => t.cancel == cancel);
15990
+ if (~i)
15991
+ timeouts.splice(i, 1);
15992
+ pendingCount -= ~i ? 1 : 0;
15993
+ };
15994
+ const timeout = { time, handler, cancel };
15995
+ timeouts.splice(findTimeout(time), 0, timeout);
15996
+ pendingCount += 1;
15997
+ start();
15998
+ return timeout;
15999
+ };
16000
+ var findTimeout = (time) => ~(~timeouts.findIndex((t) => t.time > time) || ~timeouts.length);
16001
+ raf.cancel = (fn) => {
16002
+ onStartQueue.delete(fn);
16003
+ onFrameQueue.delete(fn);
16004
+ onFinishQueue.delete(fn);
16005
+ updateQueue.delete(fn);
16006
+ writeQueue.delete(fn);
16007
+ };
16008
+ raf.sync = (fn) => {
16009
+ sync = true;
16010
+ raf.batchedUpdates(fn);
16011
+ sync = false;
16012
+ };
16013
+ raf.throttle = (fn) => {
16014
+ let lastArgs;
16015
+ function queuedFn() {
16016
+ try {
16017
+ fn(...lastArgs);
16018
+ } finally {
16019
+ lastArgs = null;
16020
+ }
16021
+ }
16022
+ function throttled(...args) {
16023
+ lastArgs = args;
16024
+ raf.onStart(queuedFn);
16025
+ }
16026
+ throttled.handler = fn;
16027
+ throttled.cancel = () => {
16028
+ onStartQueue.delete(queuedFn);
16029
+ lastArgs = null;
16030
+ };
16031
+ return throttled;
16032
+ };
16033
+ var nativeRaf = typeof window != "undefined" ? window.requestAnimationFrame : (
16034
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
16035
+ () => {
16036
+ }
16037
+ );
16038
+ raf.use = (impl) => nativeRaf = impl;
16039
+ raf.now = typeof performance != "undefined" ? () => performance.now() : Date.now;
16040
+ raf.batchedUpdates = (fn) => fn();
16041
+ raf.catch = console.error;
16042
+ raf.frameLoop = "always";
16043
+ raf.advance = () => {
16044
+ if (raf.frameLoop !== "demand") {
16045
+ console.warn(
16046
+ "Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"
16047
+ );
16048
+ } else {
16049
+ update();
16050
+ }
16051
+ };
16052
+ var ts = -1;
16053
+ var pendingCount = 0;
16054
+ var sync = false;
16055
+ function schedule(fn, queue) {
16056
+ if (sync) {
16057
+ queue.delete(fn);
16058
+ fn(0);
16059
+ } else {
16060
+ queue.add(fn);
16061
+ start();
16062
+ }
16063
+ }
16064
+ function start() {
16065
+ if (ts < 0) {
16066
+ ts = 0;
16067
+ if (raf.frameLoop !== "demand") {
16068
+ nativeRaf(loop);
16069
+ }
16070
+ }
16071
+ }
16072
+ function stop() {
16073
+ ts = -1;
16074
+ }
16075
+ function loop() {
16076
+ if (~ts) {
16077
+ nativeRaf(loop);
16078
+ raf.batchedUpdates(update);
16079
+ }
16080
+ }
16081
+ function update() {
16082
+ const prevTs = ts;
16083
+ ts = raf.now();
16084
+ const count = findTimeout(ts);
16085
+ if (count) {
16086
+ eachSafely(timeouts.splice(0, count), (t) => t.handler());
16087
+ pendingCount -= count;
16088
+ }
16089
+ if (!pendingCount) {
16090
+ stop();
16091
+ return;
16092
+ }
16093
+ onStartQueue.flush();
16094
+ updateQueue.flush(prevTs ? Math.min(64, ts - prevTs) : 16.667);
16095
+ onFrameQueue.flush();
16096
+ writeQueue.flush();
16097
+ onFinishQueue.flush();
16098
+ }
16099
+ function makeQueue() {
16100
+ let next = /* @__PURE__ */ new Set();
16101
+ let current = next;
16102
+ return {
16103
+ add(fn) {
16104
+ pendingCount += current == next && !next.has(fn) ? 1 : 0;
16105
+ next.add(fn);
16106
+ },
16107
+ delete(fn) {
16108
+ pendingCount -= current == next && next.has(fn) ? 1 : 0;
16109
+ return next.delete(fn);
16110
+ },
16111
+ flush(arg) {
16112
+ if (current.size) {
16113
+ next = /* @__PURE__ */ new Set();
16114
+ pendingCount -= current.size;
16115
+ eachSafely(current, (fn) => fn(arg) && next.add(fn));
16116
+ pendingCount += next.size;
16117
+ current = next;
16118
+ }
16119
+ }
16120
+ };
16121
+ }
16122
+ function eachSafely(values, each) {
16123
+ values.forEach((value) => {
16124
+ try {
16125
+ each(value);
16126
+ } catch (e) {
16127
+ raf.catch(e);
16128
+ }
16129
+ });
16130
+ }
16131
+
16132
+ var __defProp = Object.defineProperty;
16133
+ var __export = (target, all) => {
16134
+ for (var name in all)
16135
+ __defProp(target, name, { get: all[name], enumerable: true });
16136
+ };
16137
+
16138
+ // src/globals.ts
16139
+ var globals_exports = {};
16140
+ __export(globals_exports, {
16141
+ assign: () => assign,
16142
+ colors: () => colors,
16143
+ createStringInterpolator: () => createStringInterpolator,
16144
+ skipAnimation: () => skipAnimation,
16145
+ to: () => to,
16146
+ willAdvance: () => willAdvance
16147
+ });
16148
+
16149
+ // src/helpers.ts
16150
+ function noop() {
16151
+ }
16152
+ var defineHidden = (obj, key, value) => Object.defineProperty(obj, key, { value, writable: true, configurable: true });
16153
+ var is = {
16154
+ arr: Array.isArray,
16155
+ obj: (a) => !!a && a.constructor.name === "Object",
16156
+ fun: (a) => typeof a === "function",
16157
+ str: (a) => typeof a === "string",
16158
+ num: (a) => typeof a === "number",
16159
+ und: (a) => a === void 0
16160
+ };
16161
+ function isEqual(a, b) {
16162
+ if (is.arr(a)) {
16163
+ if (!is.arr(b) || a.length !== b.length)
16164
+ return false;
16165
+ for (let i = 0; i < a.length; i++) {
16166
+ if (a[i] !== b[i])
16167
+ return false;
16168
+ }
16169
+ return true;
16170
+ }
16171
+ return a === b;
16172
+ }
16173
+ var each = (obj, fn) => obj.forEach(fn);
16174
+ function eachProp(obj, fn, ctx) {
16175
+ if (is.arr(obj)) {
16176
+ for (let i = 0; i < obj.length; i++) {
16177
+ fn.call(ctx, obj[i], `${i}`);
16178
+ }
16179
+ return;
16180
+ }
16181
+ for (const key in obj) {
16182
+ if (obj.hasOwnProperty(key)) {
16183
+ fn.call(ctx, obj[key], key);
16184
+ }
16185
+ }
16186
+ }
16187
+ var toArray = (a) => is.und(a) ? [] : is.arr(a) ? a : [a];
16188
+ function flush(queue, iterator) {
16189
+ if (queue.size) {
16190
+ const items = Array.from(queue);
16191
+ queue.clear();
16192
+ each(items, iterator);
16193
+ }
16194
+ }
16195
+ var flushCalls = (queue, ...args) => flush(queue, (fn) => fn(...args));
16196
+ var isSSR = () => typeof window === "undefined" || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
16197
+
16198
+ // src/globals.ts
16199
+ var createStringInterpolator;
16200
+ var to;
16201
+ var colors = null;
16202
+ var skipAnimation = false;
16203
+ var willAdvance = noop;
16204
+ var assign = (globals) => {
16205
+ if (globals.to)
16206
+ to = globals.to;
16207
+ if (globals.now)
16208
+ raf.now = globals.now;
16209
+ if (globals.colors !== void 0)
16210
+ colors = globals.colors;
16211
+ if (globals.skipAnimation != null)
16212
+ skipAnimation = globals.skipAnimation;
16213
+ if (globals.createStringInterpolator)
16214
+ createStringInterpolator = globals.createStringInterpolator;
16215
+ if (globals.requestAnimationFrame)
16216
+ raf.use(globals.requestAnimationFrame);
16217
+ if (globals.batchedUpdates)
16218
+ raf.batchedUpdates = globals.batchedUpdates;
16219
+ if (globals.willAdvance)
16220
+ willAdvance = globals.willAdvance;
16221
+ if (globals.frameLoop)
16222
+ raf.frameLoop = globals.frameLoop;
16223
+ };
16224
+ var startQueue = /* @__PURE__ */ new Set();
16225
+ var currentFrame = [];
16226
+ var prevFrame = [];
16227
+ var priority = 0;
16228
+ var frameLoop = {
16229
+ get idle() {
16230
+ return !startQueue.size && !currentFrame.length;
16231
+ },
16232
+ /** Advance the given animation on every frame until idle. */
16233
+ start(animation) {
16234
+ if (priority > animation.priority) {
16235
+ startQueue.add(animation);
16236
+ raf.onStart(flushStartQueue);
16237
+ } else {
16238
+ startSafely(animation);
16239
+ raf(advance);
16240
+ }
16241
+ },
16242
+ /** Advance all animations by the given time. */
16243
+ advance,
16244
+ /** Call this when an animation's priority changes. */
16245
+ sort(animation) {
16246
+ if (priority) {
16247
+ raf.onFrame(() => frameLoop.sort(animation));
16248
+ } else {
16249
+ const prevIndex = currentFrame.indexOf(animation);
16250
+ if (~prevIndex) {
16251
+ currentFrame.splice(prevIndex, 1);
16252
+ startUnsafely(animation);
16253
+ }
16254
+ }
16255
+ },
16256
+ /**
16257
+ * Clear all animations. For testing purposes.
16258
+ *
16259
+ * ☠️ Never call this from within the frameloop.
16260
+ */
16261
+ clear() {
16262
+ currentFrame = [];
16263
+ startQueue.clear();
16264
+ }
16265
+ };
16266
+ function flushStartQueue() {
16267
+ startQueue.forEach(startSafely);
16268
+ startQueue.clear();
16269
+ raf(advance);
16270
+ }
16271
+ function startSafely(animation) {
16272
+ if (!currentFrame.includes(animation))
16273
+ startUnsafely(animation);
16274
+ }
16275
+ function startUnsafely(animation) {
16276
+ currentFrame.splice(
16277
+ findIndex(currentFrame, (other) => other.priority > animation.priority),
16278
+ 0,
16279
+ animation
16280
+ );
16281
+ }
16282
+ function advance(dt) {
16283
+ const nextFrame = prevFrame;
16284
+ for (let i = 0; i < currentFrame.length; i++) {
16285
+ const animation = currentFrame[i];
16286
+ priority = animation.priority;
16287
+ if (!animation.idle) {
16288
+ willAdvance(animation);
16289
+ animation.advance(dt);
16290
+ if (!animation.idle) {
16291
+ nextFrame.push(animation);
16292
+ }
16293
+ }
16294
+ }
16295
+ priority = 0;
16296
+ prevFrame = currentFrame;
16297
+ prevFrame.length = 0;
16298
+ currentFrame = nextFrame;
16299
+ return currentFrame.length > 0;
16300
+ }
16301
+ function findIndex(arr, test) {
16302
+ const index = arr.findIndex(test);
16303
+ return index < 0 ? arr.length : index;
16304
+ }
16305
+
16306
+ // src/clamp.ts
16307
+ var clamp$1 = (min, max, v) => Math.min(Math.max(v, min), max);
16308
+
16309
+ // src/colors.ts
16310
+ var colors2 = {
16311
+ transparent: 0,
16312
+ aliceblue: 4042850303,
16313
+ antiquewhite: 4209760255,
16314
+ aqua: 16777215,
16315
+ aquamarine: 2147472639,
16316
+ azure: 4043309055,
16317
+ beige: 4126530815,
16318
+ bisque: 4293182719,
16319
+ black: 255,
16320
+ blanchedalmond: 4293643775,
16321
+ blue: 65535,
16322
+ blueviolet: 2318131967,
16323
+ brown: 2771004159,
16324
+ burlywood: 3736635391,
16325
+ burntsienna: 3934150143,
16326
+ cadetblue: 1604231423,
16327
+ chartreuse: 2147418367,
16328
+ chocolate: 3530104575,
16329
+ coral: 4286533887,
16330
+ cornflowerblue: 1687547391,
16331
+ cornsilk: 4294499583,
16332
+ crimson: 3692313855,
16333
+ cyan: 16777215,
16334
+ darkblue: 35839,
16335
+ darkcyan: 9145343,
16336
+ darkgoldenrod: 3095792639,
16337
+ darkgray: 2846468607,
16338
+ darkgreen: 6553855,
16339
+ darkgrey: 2846468607,
16340
+ darkkhaki: 3182914559,
16341
+ darkmagenta: 2332068863,
16342
+ darkolivegreen: 1433087999,
16343
+ darkorange: 4287365375,
16344
+ darkorchid: 2570243327,
16345
+ darkred: 2332033279,
16346
+ darksalmon: 3918953215,
16347
+ darkseagreen: 2411499519,
16348
+ darkslateblue: 1211993087,
16349
+ darkslategray: 793726975,
16350
+ darkslategrey: 793726975,
16351
+ darkturquoise: 13554175,
16352
+ darkviolet: 2483082239,
16353
+ deeppink: 4279538687,
16354
+ deepskyblue: 12582911,
16355
+ dimgray: 1768516095,
16356
+ dimgrey: 1768516095,
16357
+ dodgerblue: 512819199,
16358
+ firebrick: 2988581631,
16359
+ floralwhite: 4294635775,
16360
+ forestgreen: 579543807,
16361
+ fuchsia: 4278255615,
16362
+ gainsboro: 3705462015,
16363
+ ghostwhite: 4177068031,
16364
+ gold: 4292280575,
16365
+ goldenrod: 3668254975,
16366
+ gray: 2155905279,
16367
+ green: 8388863,
16368
+ greenyellow: 2919182335,
16369
+ grey: 2155905279,
16370
+ honeydew: 4043305215,
16371
+ hotpink: 4285117695,
16372
+ indianred: 3445382399,
16373
+ indigo: 1258324735,
16374
+ ivory: 4294963455,
16375
+ khaki: 4041641215,
16376
+ lavender: 3873897215,
16377
+ lavenderblush: 4293981695,
16378
+ lawngreen: 2096890111,
16379
+ lemonchiffon: 4294626815,
16380
+ lightblue: 2916673279,
16381
+ lightcoral: 4034953471,
16382
+ lightcyan: 3774873599,
16383
+ lightgoldenrodyellow: 4210742015,
16384
+ lightgray: 3553874943,
16385
+ lightgreen: 2431553791,
16386
+ lightgrey: 3553874943,
16387
+ lightpink: 4290167295,
16388
+ lightsalmon: 4288707327,
16389
+ lightseagreen: 548580095,
16390
+ lightskyblue: 2278488831,
16391
+ lightslategray: 2005441023,
16392
+ lightslategrey: 2005441023,
16393
+ lightsteelblue: 2965692159,
16394
+ lightyellow: 4294959359,
16395
+ lime: 16711935,
16396
+ limegreen: 852308735,
16397
+ linen: 4210091775,
16398
+ magenta: 4278255615,
16399
+ maroon: 2147483903,
16400
+ mediumaquamarine: 1724754687,
16401
+ mediumblue: 52735,
16402
+ mediumorchid: 3126187007,
16403
+ mediumpurple: 2473647103,
16404
+ mediumseagreen: 1018393087,
16405
+ mediumslateblue: 2070474495,
16406
+ mediumspringgreen: 16423679,
16407
+ mediumturquoise: 1221709055,
16408
+ mediumvioletred: 3340076543,
16409
+ midnightblue: 421097727,
16410
+ mintcream: 4127193855,
16411
+ mistyrose: 4293190143,
16412
+ moccasin: 4293178879,
16413
+ navajowhite: 4292783615,
16414
+ navy: 33023,
16415
+ oldlace: 4260751103,
16416
+ olive: 2155872511,
16417
+ olivedrab: 1804477439,
16418
+ orange: 4289003775,
16419
+ orangered: 4282712319,
16420
+ orchid: 3664828159,
16421
+ palegoldenrod: 4008225535,
16422
+ palegreen: 2566625535,
16423
+ paleturquoise: 2951671551,
16424
+ palevioletred: 3681588223,
16425
+ papayawhip: 4293907967,
16426
+ peachpuff: 4292524543,
16427
+ peru: 3448061951,
16428
+ pink: 4290825215,
16429
+ plum: 3718307327,
16430
+ powderblue: 2967529215,
16431
+ purple: 2147516671,
16432
+ rebeccapurple: 1714657791,
16433
+ red: 4278190335,
16434
+ rosybrown: 3163525119,
16435
+ royalblue: 1097458175,
16436
+ saddlebrown: 2336560127,
16437
+ salmon: 4202722047,
16438
+ sandybrown: 4104413439,
16439
+ seagreen: 780883967,
16440
+ seashell: 4294307583,
16441
+ sienna: 2689740287,
16442
+ silver: 3233857791,
16443
+ skyblue: 2278484991,
16444
+ slateblue: 1784335871,
16445
+ slategray: 1887473919,
16446
+ slategrey: 1887473919,
16447
+ snow: 4294638335,
16448
+ springgreen: 16744447,
16449
+ steelblue: 1182971135,
16450
+ tan: 3535047935,
16451
+ teal: 8421631,
16452
+ thistle: 3636451583,
16453
+ tomato: 4284696575,
16454
+ turquoise: 1088475391,
16455
+ violet: 4001558271,
16456
+ wheat: 4125012991,
16457
+ white: 4294967295,
16458
+ whitesmoke: 4126537215,
16459
+ yellow: 4294902015,
16460
+ yellowgreen: 2597139199
16461
+ };
16462
+
16463
+ // src/colorMatchers.ts
16464
+ var NUMBER = "[-+]?\\d*\\.?\\d+";
16465
+ var PERCENTAGE = NUMBER + "%";
16466
+ function call(...parts) {
16467
+ return "\\(\\s*(" + parts.join(")\\s*,\\s*(") + ")\\s*\\)";
16468
+ }
16469
+ var rgb = new RegExp("rgb" + call(NUMBER, NUMBER, NUMBER));
16470
+ var rgba = new RegExp("rgba" + call(NUMBER, NUMBER, NUMBER, NUMBER));
16471
+ var hsl = new RegExp("hsl" + call(NUMBER, PERCENTAGE, PERCENTAGE));
16472
+ var hsla = new RegExp(
16473
+ "hsla" + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER)
16474
+ );
16475
+ var hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
16476
+ var hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
16477
+ var hex6 = /^#([0-9a-fA-F]{6})$/;
16478
+ var hex8 = /^#([0-9a-fA-F]{8})$/;
16479
+
16480
+ // src/normalizeColor.ts
16481
+ function normalizeColor(color) {
16482
+ let match;
16483
+ if (typeof color === "number") {
16484
+ return color >>> 0 === color && color >= 0 && color <= 4294967295 ? color : null;
16485
+ }
16486
+ if (match = hex6.exec(color))
16487
+ return parseInt(match[1] + "ff", 16) >>> 0;
16488
+ if (colors && colors[color] !== void 0) {
16489
+ return colors[color];
16490
+ }
16491
+ if (match = rgb.exec(color)) {
16492
+ return (parse255(match[1]) << 24 | // r
16493
+ parse255(match[2]) << 16 | // g
16494
+ parse255(match[3]) << 8 | // b
16495
+ 255) >>> // a
16496
+ 0;
16497
+ }
16498
+ if (match = rgba.exec(color)) {
16499
+ return (parse255(match[1]) << 24 | // r
16500
+ parse255(match[2]) << 16 | // g
16501
+ parse255(match[3]) << 8 | // b
16502
+ parse1(match[4])) >>> // a
16503
+ 0;
16504
+ }
16505
+ if (match = hex3.exec(color)) {
16506
+ return parseInt(
16507
+ match[1] + match[1] + // r
16508
+ match[2] + match[2] + // g
16509
+ match[3] + match[3] + // b
16510
+ "ff",
16511
+ // a
16512
+ 16
16513
+ ) >>> 0;
16514
+ }
16515
+ if (match = hex8.exec(color))
16516
+ return parseInt(match[1], 16) >>> 0;
16517
+ if (match = hex4.exec(color)) {
16518
+ return parseInt(
16519
+ match[1] + match[1] + // r
16520
+ match[2] + match[2] + // g
16521
+ match[3] + match[3] + // b
16522
+ match[4] + match[4],
16523
+ // a
16524
+ 16
16525
+ ) >>> 0;
16526
+ }
16527
+ if (match = hsl.exec(color)) {
16528
+ return (hslToRgb(
16529
+ parse360(match[1]),
16530
+ // h
16531
+ parsePercentage(match[2]),
16532
+ // s
16533
+ parsePercentage(match[3])
16534
+ // l
16535
+ ) | 255) >>> // a
16536
+ 0;
16537
+ }
16538
+ if (match = hsla.exec(color)) {
16539
+ return (hslToRgb(
16540
+ parse360(match[1]),
16541
+ // h
16542
+ parsePercentage(match[2]),
16543
+ // s
16544
+ parsePercentage(match[3])
16545
+ // l
16546
+ ) | parse1(match[4])) >>> // a
16547
+ 0;
16548
+ }
16549
+ return null;
16550
+ }
16551
+ function hue2rgb(p, q, t) {
16552
+ if (t < 0)
16553
+ t += 1;
16554
+ if (t > 1)
16555
+ t -= 1;
16556
+ if (t < 1 / 6)
16557
+ return p + (q - p) * 6 * t;
16558
+ if (t < 1 / 2)
16559
+ return q;
16560
+ if (t < 2 / 3)
16561
+ return p + (q - p) * (2 / 3 - t) * 6;
16562
+ return p;
16563
+ }
16564
+ function hslToRgb(h, s, l) {
16565
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
16566
+ const p = 2 * l - q;
16567
+ const r = hue2rgb(p, q, h + 1 / 3);
16568
+ const g = hue2rgb(p, q, h);
16569
+ const b = hue2rgb(p, q, h - 1 / 3);
16570
+ return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b * 255) << 8;
16571
+ }
16572
+ function parse255(str) {
16573
+ const int = parseInt(str, 10);
16574
+ if (int < 0)
16575
+ return 0;
16576
+ if (int > 255)
16577
+ return 255;
16578
+ return int;
16579
+ }
16580
+ function parse360(str) {
16581
+ const int = parseFloat(str);
16582
+ return (int % 360 + 360) % 360 / 360;
16583
+ }
16584
+ function parse1(str) {
16585
+ const num = parseFloat(str);
16586
+ if (num < 0)
16587
+ return 0;
16588
+ if (num > 1)
16589
+ return 255;
16590
+ return Math.round(num * 255);
16591
+ }
16592
+ function parsePercentage(str) {
16593
+ const int = parseFloat(str);
16594
+ if (int < 0)
16595
+ return 0;
16596
+ if (int > 100)
16597
+ return 1;
16598
+ return int / 100;
16599
+ }
16600
+
16601
+ // src/colorToRgba.ts
16602
+ function colorToRgba(input) {
16603
+ let int32Color = normalizeColor(input);
16604
+ if (int32Color === null)
16605
+ return input;
16606
+ int32Color = int32Color || 0;
16607
+ const r = (int32Color & 4278190080) >>> 24;
16608
+ const g = (int32Color & 16711680) >>> 16;
16609
+ const b = (int32Color & 65280) >>> 8;
16610
+ const a = (int32Color & 255) / 255;
16611
+ return `rgba(${r}, ${g}, ${b}, ${a})`;
16612
+ }
16613
+
16614
+ // src/createInterpolator.ts
16615
+ var createInterpolator = (range, output, extrapolate) => {
16616
+ if (is.fun(range)) {
16617
+ return range;
16618
+ }
16619
+ if (is.arr(range)) {
16620
+ return createInterpolator({
16621
+ range,
16622
+ output,
16623
+ extrapolate
16624
+ });
16625
+ }
16626
+ if (is.str(range.output[0])) {
16627
+ return createStringInterpolator(range);
16628
+ }
16629
+ const config = range;
16630
+ const outputRange = config.output;
16631
+ const inputRange = config.range || [0, 1];
16632
+ const extrapolateLeft = config.extrapolateLeft || config.extrapolate || "extend";
16633
+ const extrapolateRight = config.extrapolateRight || config.extrapolate || "extend";
16634
+ const easing = config.easing || ((t) => t);
16635
+ return (input) => {
16636
+ const range2 = findRange(input, inputRange);
16637
+ return interpolate(
16638
+ input,
16639
+ inputRange[range2],
16640
+ inputRange[range2 + 1],
16641
+ outputRange[range2],
16642
+ outputRange[range2 + 1],
16643
+ easing,
16644
+ extrapolateLeft,
16645
+ extrapolateRight,
16646
+ config.map
16647
+ );
16648
+ };
16649
+ };
16650
+ function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) {
16651
+ let result = map ? map(input) : input;
16652
+ if (result < inputMin) {
16653
+ if (extrapolateLeft === "identity")
16654
+ return result;
16655
+ else if (extrapolateLeft === "clamp")
16656
+ result = inputMin;
16657
+ }
16658
+ if (result > inputMax) {
16659
+ if (extrapolateRight === "identity")
16660
+ return result;
16661
+ else if (extrapolateRight === "clamp")
16662
+ result = inputMax;
16663
+ }
16664
+ if (outputMin === outputMax)
16665
+ return outputMin;
16666
+ if (inputMin === inputMax)
16667
+ return input <= inputMin ? outputMin : outputMax;
16668
+ if (inputMin === -Infinity)
16669
+ result = -result;
16670
+ else if (inputMax === Infinity)
16671
+ result = result - inputMin;
16672
+ else
16673
+ result = (result - inputMin) / (inputMax - inputMin);
16674
+ result = easing(result);
16675
+ if (outputMin === -Infinity)
16676
+ result = -result;
16677
+ else if (outputMax === Infinity)
16678
+ result = result + outputMin;
16679
+ else
16680
+ result = result * (outputMax - outputMin) + outputMin;
16681
+ return result;
16682
+ }
16683
+ function findRange(input, inputRange) {
16684
+ for (var i = 1; i < inputRange.length - 1; ++i)
16685
+ if (inputRange[i] >= input)
16686
+ break;
16687
+ return i - 1;
16688
+ }
16689
+
16690
+ // src/easings.ts
16691
+ var steps = (steps2, direction = "end") => (progress2) => {
16692
+ progress2 = direction === "end" ? Math.min(progress2, 0.999) : Math.max(progress2, 1e-3);
16693
+ const expanded = progress2 * steps2;
16694
+ const rounded = direction === "end" ? Math.floor(expanded) : Math.ceil(expanded);
16695
+ return clamp$1(0, 1, rounded / steps2);
16696
+ };
16697
+ var c1 = 1.70158;
16698
+ var c2 = c1 * 1.525;
16699
+ var c3 = c1 + 1;
16700
+ var c4 = 2 * Math.PI / 3;
16701
+ var c5 = 2 * Math.PI / 4.5;
16702
+ var bounceOut = (x) => {
16703
+ const n1 = 7.5625;
16704
+ const d1 = 2.75;
16705
+ if (x < 1 / d1) {
16706
+ return n1 * x * x;
16707
+ } else if (x < 2 / d1) {
16708
+ return n1 * (x -= 1.5 / d1) * x + 0.75;
16709
+ } else if (x < 2.5 / d1) {
16710
+ return n1 * (x -= 2.25 / d1) * x + 0.9375;
16711
+ } else {
16712
+ return n1 * (x -= 2.625 / d1) * x + 0.984375;
16713
+ }
16714
+ };
16715
+ var easings = {
16716
+ linear: (x) => x,
16717
+ easeInQuad: (x) => x * x,
16718
+ easeOutQuad: (x) => 1 - (1 - x) * (1 - x),
16719
+ easeInOutQuad: (x) => x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2,
16720
+ easeInCubic: (x) => x * x * x,
16721
+ easeOutCubic: (x) => 1 - Math.pow(1 - x, 3),
16722
+ easeInOutCubic: (x) => x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2,
16723
+ easeInQuart: (x) => x * x * x * x,
16724
+ easeOutQuart: (x) => 1 - Math.pow(1 - x, 4),
16725
+ easeInOutQuart: (x) => x < 0.5 ? 8 * x * x * x * x : 1 - Math.pow(-2 * x + 2, 4) / 2,
16726
+ easeInQuint: (x) => x * x * x * x * x,
16727
+ easeOutQuint: (x) => 1 - Math.pow(1 - x, 5),
16728
+ easeInOutQuint: (x) => x < 0.5 ? 16 * x * x * x * x * x : 1 - Math.pow(-2 * x + 2, 5) / 2,
16729
+ easeInSine: (x) => 1 - Math.cos(x * Math.PI / 2),
16730
+ easeOutSine: (x) => Math.sin(x * Math.PI / 2),
16731
+ easeInOutSine: (x) => -(Math.cos(Math.PI * x) - 1) / 2,
16732
+ easeInExpo: (x) => x === 0 ? 0 : Math.pow(2, 10 * x - 10),
16733
+ easeOutExpo: (x) => x === 1 ? 1 : 1 - Math.pow(2, -10 * x),
16734
+ 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,
16735
+ easeInCirc: (x) => 1 - Math.sqrt(1 - Math.pow(x, 2)),
16736
+ easeOutCirc: (x) => Math.sqrt(1 - Math.pow(x - 1, 2)),
16737
+ 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,
16738
+ easeInBack: (x) => c3 * x * x * x - c1 * x * x,
16739
+ easeOutBack: (x) => 1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2),
16740
+ 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,
16741
+ easeInElastic: (x) => x === 0 ? 0 : x === 1 ? 1 : -Math.pow(2, 10 * x - 10) * Math.sin((x * 10 - 10.75) * c4),
16742
+ easeOutElastic: (x) => x === 0 ? 0 : x === 1 ? 1 : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1,
16743
+ 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,
16744
+ easeInBounce: (x) => 1 - bounceOut(1 - x),
16745
+ easeOutBounce: bounceOut,
16746
+ easeInOutBounce: (x) => x < 0.5 ? (1 - bounceOut(1 - 2 * x)) / 2 : (1 + bounceOut(2 * x - 1)) / 2,
16747
+ steps
16748
+ };
16749
+
16750
+ // src/fluids.ts
16751
+ var $get = Symbol.for("FluidValue.get");
16752
+ var $observers = Symbol.for("FluidValue.observers");
16753
+ var hasFluidValue = (arg) => Boolean(arg && arg[$get]);
16754
+ var getFluidValue = (arg) => arg && arg[$get] ? arg[$get]() : arg;
16755
+ var getFluidObservers = (target) => target[$observers] || null;
16756
+ function callFluidObserver(observer2, event) {
16757
+ if (observer2.eventObserved) {
16758
+ observer2.eventObserved(event);
16759
+ } else {
16760
+ observer2(event);
16761
+ }
16762
+ }
16763
+ function callFluidObservers(target, event) {
16764
+ const observers = target[$observers];
16765
+ if (observers) {
16766
+ observers.forEach((observer2) => {
16767
+ callFluidObserver(observer2, event);
16768
+ });
16769
+ }
16770
+ }
16771
+ var FluidValue = class {
16772
+ constructor(get) {
16773
+ if (!get && !(get = this.get)) {
16774
+ throw Error("Unknown getter");
16775
+ }
16776
+ setFluidGetter(this, get);
16777
+ }
16778
+ };
16779
+ var setFluidGetter = (target, get) => setHidden(target, $get, get);
16780
+ function addFluidObserver(target, observer2) {
16781
+ if (target[$get]) {
16782
+ let observers = target[$observers];
16783
+ if (!observers) {
16784
+ setHidden(target, $observers, observers = /* @__PURE__ */ new Set());
16785
+ }
16786
+ if (!observers.has(observer2)) {
16787
+ observers.add(observer2);
16788
+ if (target.observerAdded) {
16789
+ target.observerAdded(observers.size, observer2);
16790
+ }
16791
+ }
16792
+ }
16793
+ return observer2;
16794
+ }
16795
+ function removeFluidObserver(target, observer2) {
16796
+ const observers = target[$observers];
16797
+ if (observers && observers.has(observer2)) {
16798
+ const count = observers.size - 1;
16799
+ if (count) {
16800
+ observers.delete(observer2);
16801
+ } else {
16802
+ target[$observers] = null;
16803
+ }
16804
+ if (target.observerRemoved) {
16805
+ target.observerRemoved(count, observer2);
16806
+ }
16807
+ }
16808
+ }
16809
+ var setHidden = (target, key, value) => Object.defineProperty(target, key, {
16810
+ value,
16811
+ writable: true,
16812
+ configurable: true
16813
+ });
16814
+
16815
+ // src/regexs.ts
16816
+ var numberRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
16817
+ var colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi;
16818
+ var unitRegex = new RegExp(`(${numberRegex.source})(%|[a-z]+)`, "i");
16819
+ var rgbaRegex = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi;
16820
+ var cssVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;
16821
+
16822
+ // src/variableToRgba.ts
16823
+ var variableToRgba = (input) => {
16824
+ const [token, fallback] = parseCSSVariable(input);
16825
+ if (!token || isSSR()) {
16826
+ return input;
16827
+ }
16828
+ const value = window.getComputedStyle(document.documentElement).getPropertyValue(token);
16829
+ if (value) {
16830
+ return value.trim();
16831
+ } else if (fallback && fallback.startsWith("--")) {
16832
+ const value2 = window.getComputedStyle(document.documentElement).getPropertyValue(fallback);
16833
+ if (value2) {
16834
+ return value2;
16835
+ } else {
16836
+ return input;
16837
+ }
16838
+ } else if (fallback && cssVariableRegex.test(fallback)) {
16839
+ return variableToRgba(fallback);
16840
+ } else if (fallback) {
16841
+ return fallback;
16842
+ }
16843
+ return input;
16844
+ };
16845
+ var parseCSSVariable = (current) => {
16846
+ const match = cssVariableRegex.exec(current);
16847
+ if (!match)
16848
+ return [,];
16849
+ const [, token, fallback] = match;
16850
+ return [token, fallback];
16851
+ };
16852
+
16853
+ // src/stringInterpolation.ts
16854
+ var namedColorRegex;
16855
+ var rgbaRound = (_, p1, p2, p3, p4) => `rgba(${Math.round(p1)}, ${Math.round(p2)}, ${Math.round(p3)}, ${p4})`;
16856
+ var createStringInterpolator2 = (config) => {
16857
+ if (!namedColorRegex)
16858
+ namedColorRegex = colors ? (
16859
+ // match color names, ignore partial matches
16860
+ new RegExp(`(${Object.keys(colors).join("|")})(?!\\w)`, "g")
16861
+ ) : (
16862
+ // never match
16863
+ /^\b$/
16864
+ );
16865
+ const output = config.output.map((value) => {
16866
+ return getFluidValue(value).replace(cssVariableRegex, variableToRgba).replace(colorRegex, colorToRgba).replace(namedColorRegex, colorToRgba);
16867
+ });
16868
+ const keyframes = output.map((value) => value.match(numberRegex).map(Number));
16869
+ const outputRanges = keyframes[0].map(
16870
+ (_, i) => keyframes.map((values) => {
16871
+ if (!(i in values)) {
16872
+ throw Error('The arity of each "output" value must be equal');
16873
+ }
16874
+ return values[i];
16875
+ })
16876
+ );
16877
+ const interpolators = outputRanges.map(
16878
+ (output2) => createInterpolator({ ...config, output: output2 })
16879
+ );
16880
+ return (input) => {
16881
+ const missingUnit = !unitRegex.test(output[0]) && output.find((value) => unitRegex.test(value))?.replace(numberRegex, "");
16882
+ let i = 0;
16883
+ return output[0].replace(
16884
+ numberRegex,
16885
+ () => `${interpolators[i++](input)}${missingUnit || ""}`
16886
+ ).replace(rgbaRegex, rgbaRound);
16887
+ };
16888
+ };
16889
+
16890
+ // src/deprecations.ts
16891
+ var prefix = "react-spring: ";
16892
+ var once = (fn) => {
16893
+ const func = fn;
16894
+ let called = false;
16895
+ if (typeof func != "function") {
16896
+ throw new TypeError(`${prefix}once requires a function parameter`);
16897
+ }
16898
+ return (...args) => {
16899
+ if (!called) {
16900
+ func(...args);
16901
+ called = true;
16902
+ }
16903
+ };
16904
+ };
16905
+ var warnInterpolate = once(console.warn);
16906
+ function deprecateInterpolate() {
16907
+ warnInterpolate(
16908
+ `${prefix}The "interpolate" function is deprecated in v9 (use "to" instead)`
16909
+ );
16910
+ }
16911
+ var warnDirectCall = once(console.warn);
16912
+ function deprecateDirectCall() {
16913
+ warnDirectCall(
16914
+ `${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`
16915
+ );
16916
+ }
16917
+
16918
+ // src/isAnimatedString.ts
16919
+ function isAnimatedString(value) {
16920
+ return is.str(value) && (value[0] == "#" || /\d/.test(value) || // Do not identify a CSS variable as an AnimatedString if its SSR
16921
+ !isSSR() && cssVariableRegex.test(value) || value in (colors || {}));
16922
+ }
16923
+ var useIsomorphicLayoutEffect = isSSR() ? React.useEffect : React.useLayoutEffect;
16924
+
16925
+ // src/hooks/useIsMounted.ts
16926
+ var useIsMounted = () => {
16927
+ const isMounted = React.useRef(false);
16928
+ useIsomorphicLayoutEffect(() => {
16929
+ isMounted.current = true;
16930
+ return () => {
16931
+ isMounted.current = false;
16932
+ };
16933
+ }, []);
16934
+ return isMounted;
16935
+ };
16936
+
16937
+ // src/hooks/useForceUpdate.ts
16938
+ function useForceUpdate() {
16939
+ const update = React.useState()[1];
16940
+ const isMounted = useIsMounted();
16941
+ return () => {
16942
+ if (isMounted.current) {
16943
+ update(Math.random());
16944
+ }
16945
+ };
16946
+ }
16947
+ function useMemoOne(getResult, inputs) {
16948
+ const [initial] = React.useState(
16949
+ () => ({
16950
+ inputs,
16951
+ result: getResult()
16952
+ })
16953
+ );
16954
+ const committed = React.useRef();
16955
+ const prevCache = committed.current;
16956
+ let cache = prevCache;
16957
+ if (cache) {
16958
+ const useCache = Boolean(
16959
+ inputs && cache.inputs && areInputsEqual(inputs, cache.inputs)
16960
+ );
16961
+ if (!useCache) {
16962
+ cache = {
16963
+ inputs,
16964
+ result: getResult()
16965
+ };
16966
+ }
16967
+ } else {
16968
+ cache = initial;
16969
+ }
16970
+ React.useEffect(() => {
16971
+ committed.current = cache;
16972
+ if (prevCache == initial) {
16973
+ initial.inputs = initial.result = void 0;
16974
+ }
16975
+ }, [cache]);
16976
+ return cache.result;
16977
+ }
16978
+ function areInputsEqual(next, prev) {
16979
+ if (next.length !== prev.length) {
16980
+ return false;
16981
+ }
16982
+ for (let i = 0; i < next.length; i++) {
16983
+ if (next[i] !== prev[i]) {
16984
+ return false;
16985
+ }
16986
+ }
16987
+ return true;
16988
+ }
16989
+ var useOnce = (effect) => React.useEffect(effect, emptyDeps);
16990
+ var emptyDeps = [];
16991
+ function usePrev(value) {
16992
+ const prevRef = React.useRef();
16993
+ React.useEffect(() => {
16994
+ prevRef.current = value;
16995
+ });
16996
+ return prevRef.current;
16997
+ }
16998
+
16999
+ // src/Animated.ts
17000
+ var $node = Symbol.for("Animated:node");
17001
+ var isAnimated = (value) => !!value && value[$node] === value;
17002
+ var getAnimated = (owner) => owner && owner[$node];
17003
+ var setAnimated = (owner, node) => defineHidden(owner, $node, node);
17004
+ var getPayload = (owner) => owner && owner[$node] && owner[$node].getPayload();
17005
+ var Animated = class {
17006
+ constructor() {
17007
+ setAnimated(this, this);
17008
+ }
17009
+ /** Get every `AnimatedValue` used by this node. */
17010
+ getPayload() {
17011
+ return this.payload || [];
17012
+ }
17013
+ };
17014
+ var AnimatedValue = class extends Animated {
17015
+ constructor(_value) {
17016
+ super();
17017
+ this._value = _value;
17018
+ this.done = true;
17019
+ this.durationProgress = 0;
17020
+ if (is.num(this._value)) {
17021
+ this.lastPosition = this._value;
17022
+ }
17023
+ }
17024
+ /** @internal */
17025
+ static create(value) {
17026
+ return new AnimatedValue(value);
17027
+ }
17028
+ getPayload() {
17029
+ return [this];
17030
+ }
17031
+ getValue() {
17032
+ return this._value;
17033
+ }
17034
+ setValue(value, step) {
17035
+ if (is.num(value)) {
17036
+ this.lastPosition = value;
17037
+ if (step) {
17038
+ value = Math.round(value / step) * step;
17039
+ if (this.done) {
17040
+ this.lastPosition = value;
17041
+ }
17042
+ }
17043
+ }
17044
+ if (this._value === value) {
17045
+ return false;
17046
+ }
17047
+ this._value = value;
17048
+ return true;
17049
+ }
17050
+ reset() {
17051
+ const { done } = this;
17052
+ this.done = false;
17053
+ if (is.num(this._value)) {
17054
+ this.elapsedTime = 0;
17055
+ this.durationProgress = 0;
17056
+ this.lastPosition = this._value;
17057
+ if (done)
17058
+ this.lastVelocity = null;
17059
+ this.v0 = null;
17060
+ }
17061
+ }
17062
+ };
17063
+ var AnimatedString = class extends AnimatedValue {
17064
+ constructor(value) {
17065
+ super(0);
17066
+ this._string = null;
17067
+ this._toString = createInterpolator({
17068
+ output: [value, value]
17069
+ });
17070
+ }
17071
+ /** @internal */
17072
+ static create(value) {
17073
+ return new AnimatedString(value);
17074
+ }
17075
+ getValue() {
17076
+ const value = this._string;
17077
+ return value == null ? this._string = this._toString(this._value) : value;
17078
+ }
17079
+ setValue(value) {
17080
+ if (is.str(value)) {
17081
+ if (value == this._string) {
17082
+ return false;
17083
+ }
17084
+ this._string = value;
17085
+ this._value = 1;
17086
+ } else if (super.setValue(value)) {
17087
+ this._string = null;
17088
+ } else {
17089
+ return false;
17090
+ }
17091
+ return true;
17092
+ }
17093
+ reset(goal) {
17094
+ if (goal) {
17095
+ this._toString = createInterpolator({
17096
+ output: [this.getValue(), goal]
17097
+ });
17098
+ }
17099
+ this._value = 0;
17100
+ super.reset();
17101
+ }
17102
+ };
17103
+
17104
+ // src/context.ts
17105
+ var TreeContext = { dependencies: null };
17106
+
17107
+ // src/AnimatedObject.ts
17108
+ var AnimatedObject = class extends Animated {
17109
+ constructor(source) {
17110
+ super();
17111
+ this.source = source;
17112
+ this.setValue(source);
17113
+ }
17114
+ getValue(animated) {
17115
+ const values = {};
17116
+ eachProp(this.source, (source, key) => {
17117
+ if (isAnimated(source)) {
17118
+ values[key] = source.getValue(animated);
17119
+ } else if (hasFluidValue(source)) {
17120
+ values[key] = getFluidValue(source);
17121
+ } else if (!animated) {
17122
+ values[key] = source;
17123
+ }
17124
+ });
17125
+ return values;
17126
+ }
17127
+ /** Replace the raw object data */
17128
+ setValue(source) {
17129
+ this.source = source;
17130
+ this.payload = this._makePayload(source);
17131
+ }
17132
+ reset() {
17133
+ if (this.payload) {
17134
+ each(this.payload, (node) => node.reset());
17135
+ }
17136
+ }
17137
+ /** Create a payload set. */
17138
+ _makePayload(source) {
17139
+ if (source) {
17140
+ const payload = /* @__PURE__ */ new Set();
17141
+ eachProp(source, this._addToPayload, payload);
17142
+ return Array.from(payload);
17143
+ }
17144
+ }
17145
+ /** Add to a payload set. */
17146
+ _addToPayload(source) {
17147
+ if (TreeContext.dependencies && hasFluidValue(source)) {
17148
+ TreeContext.dependencies.add(source);
17149
+ }
17150
+ const payload = getPayload(source);
17151
+ if (payload) {
17152
+ each(payload, (node) => this.add(node));
17153
+ }
17154
+ }
17155
+ };
17156
+
17157
+ // src/AnimatedArray.ts
17158
+ var AnimatedArray = class extends AnimatedObject {
17159
+ constructor(source) {
17160
+ super(source);
17161
+ }
17162
+ /** @internal */
17163
+ static create(source) {
17164
+ return new AnimatedArray(source);
17165
+ }
17166
+ getValue() {
17167
+ return this.source.map((node) => node.getValue());
17168
+ }
17169
+ setValue(source) {
17170
+ const payload = this.getPayload();
17171
+ if (source.length == payload.length) {
17172
+ return payload.map((node, i) => node.setValue(source[i])).some(Boolean);
17173
+ }
17174
+ super.setValue(source.map(makeAnimated));
17175
+ return true;
17176
+ }
17177
+ };
17178
+ function makeAnimated(value) {
17179
+ const nodeType = isAnimatedString(value) ? AnimatedString : AnimatedValue;
17180
+ return nodeType.create(value);
17181
+ }
17182
+ function getAnimatedType(value) {
17183
+ const parentNode = getAnimated(value);
17184
+ return parentNode ? parentNode.constructor : is.arr(value) ? AnimatedArray : isAnimatedString(value) ? AnimatedString : AnimatedValue;
17185
+ }
17186
+ var withAnimated = (Component, host) => {
17187
+ const hasInstance = (
17188
+ // Function components must use "forwardRef" to avoid being
17189
+ // re-rendered on every animation frame.
17190
+ !is.fun(Component) || Component.prototype && Component.prototype.isReactComponent
17191
+ );
17192
+ return React.forwardRef((givenProps, givenRef) => {
17193
+ const instanceRef = React.useRef(null);
17194
+ const ref = hasInstance && // eslint-disable-next-line react-hooks/rules-of-hooks
17195
+ React.useCallback(
17196
+ (value) => {
17197
+ instanceRef.current = updateRef(givenRef, value);
17198
+ },
17199
+ [givenRef]
17200
+ );
17201
+ const [props, deps] = getAnimatedState(givenProps, host);
17202
+ const forceUpdate = useForceUpdate();
17203
+ const callback = () => {
17204
+ const instance = instanceRef.current;
17205
+ if (hasInstance && !instance) {
17206
+ return;
17207
+ }
17208
+ const didUpdate = instance ? host.applyAnimatedValues(instance, props.getValue(true)) : false;
17209
+ if (didUpdate === false) {
17210
+ forceUpdate();
17211
+ }
17212
+ };
17213
+ const observer = new PropsObserver(callback, deps);
17214
+ const observerRef = React.useRef();
17215
+ useIsomorphicLayoutEffect(() => {
17216
+ observerRef.current = observer;
17217
+ each(deps, (dep) => addFluidObserver(dep, observer));
17218
+ return () => {
17219
+ if (observerRef.current) {
17220
+ each(
17221
+ observerRef.current.deps,
17222
+ (dep) => removeFluidObserver(dep, observerRef.current)
17223
+ );
17224
+ raf.cancel(observerRef.current.update);
17225
+ }
17226
+ };
17227
+ });
17228
+ React.useEffect(callback, []);
17229
+ useOnce(() => () => {
17230
+ const observer2 = observerRef.current;
17231
+ each(observer2.deps, (dep) => removeFluidObserver(dep, observer2));
17232
+ });
17233
+ const usedProps = host.getComponentProps(props.getValue());
17234
+ return /* @__PURE__ */ React__namespace.createElement(Component, { ...usedProps, ref });
17235
+ });
17236
+ };
17237
+ var PropsObserver = class {
17238
+ constructor(update, deps) {
17239
+ this.update = update;
17240
+ this.deps = deps;
17241
+ }
17242
+ eventObserved(event) {
17243
+ if (event.type == "change") {
17244
+ raf.write(this.update);
17245
+ }
17246
+ }
17247
+ };
17248
+ function getAnimatedState(props, host) {
17249
+ const dependencies = /* @__PURE__ */ new Set();
17250
+ TreeContext.dependencies = dependencies;
17251
+ if (props.style)
17252
+ props = {
17253
+ ...props,
17254
+ style: host.createAnimatedStyle(props.style)
17255
+ };
17256
+ props = new AnimatedObject(props);
17257
+ TreeContext.dependencies = null;
17258
+ return [props, dependencies];
17259
+ }
17260
+ function updateRef(ref, value) {
17261
+ if (ref) {
17262
+ if (is.fun(ref))
17263
+ ref(value);
17264
+ else
17265
+ ref.current = value;
17266
+ }
17267
+ return value;
17268
+ }
17269
+
17270
+ // src/createHost.ts
17271
+ var cacheKey = Symbol.for("AnimatedComponent");
17272
+ var createHost = (components, {
17273
+ applyAnimatedValues = () => false,
17274
+ createAnimatedStyle = (style) => new AnimatedObject(style),
17275
+ getComponentProps = (props) => props
17276
+ } = {}) => {
17277
+ const hostConfig = {
17278
+ applyAnimatedValues,
17279
+ createAnimatedStyle,
17280
+ getComponentProps
17281
+ };
17282
+ const animated = (Component) => {
17283
+ const displayName = getDisplayName(Component) || "Anonymous";
17284
+ if (is.str(Component)) {
17285
+ Component = animated[Component] || (animated[Component] = withAnimated(Component, hostConfig));
17286
+ } else {
17287
+ Component = Component[cacheKey] || (Component[cacheKey] = withAnimated(Component, hostConfig));
17288
+ }
17289
+ Component.displayName = `Animated(${displayName})`;
17290
+ return Component;
17291
+ };
17292
+ eachProp(components, (Component, key) => {
17293
+ if (is.arr(components)) {
17294
+ key = getDisplayName(Component);
17295
+ }
17296
+ animated[key] = animated(Component);
17297
+ });
17298
+ return {
17299
+ animated
17300
+ };
17301
+ };
17302
+ var getDisplayName = (arg) => is.str(arg) ? arg : arg && is.str(arg.displayName) ? arg.displayName : is.fun(arg) && arg.name || null;
17303
+
17304
+ // src/hooks/useChain.ts
17305
+ function callProp(value, ...args) {
17306
+ return is.fun(value) ? value(...args) : value;
17307
+ }
17308
+ var matchProp = (value, key) => value === true || !!(key && value && (is.fun(value) ? value(key) : toArray(value).includes(key)));
17309
+ var resolveProp = (prop, key) => is.obj(prop) ? key && prop[key] : prop;
17310
+ var getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : void 0;
17311
+ var noopTransform = (value) => value;
17312
+ var getDefaultProps = (props, transform = noopTransform) => {
17313
+ let keys = DEFAULT_PROPS;
17314
+ if (props.default && props.default !== true) {
17315
+ props = props.default;
17316
+ keys = Object.keys(props);
17317
+ }
17318
+ const defaults2 = {};
17319
+ for (const key of keys) {
17320
+ const value = transform(props[key], key);
17321
+ if (!is.und(value)) {
17322
+ defaults2[key] = value;
17323
+ }
17324
+ }
17325
+ return defaults2;
17326
+ };
17327
+ var DEFAULT_PROPS = [
17328
+ "config",
17329
+ "onProps",
17330
+ "onStart",
17331
+ "onChange",
17332
+ "onPause",
17333
+ "onResume",
17334
+ "onRest"
17335
+ ];
17336
+ var RESERVED_PROPS = {
17337
+ config: 1,
17338
+ from: 1,
17339
+ to: 1,
17340
+ ref: 1,
17341
+ loop: 1,
17342
+ reset: 1,
17343
+ pause: 1,
17344
+ cancel: 1,
17345
+ reverse: 1,
17346
+ immediate: 1,
17347
+ default: 1,
17348
+ delay: 1,
17349
+ onProps: 1,
17350
+ onStart: 1,
17351
+ onChange: 1,
17352
+ onPause: 1,
17353
+ onResume: 1,
17354
+ onRest: 1,
17355
+ onResolve: 1,
17356
+ // Transition props
17357
+ items: 1,
17358
+ trail: 1,
17359
+ sort: 1,
17360
+ expires: 1,
17361
+ initial: 1,
17362
+ enter: 1,
17363
+ update: 1,
17364
+ leave: 1,
17365
+ children: 1,
17366
+ onDestroyed: 1,
17367
+ // Internal props
17368
+ keys: 1,
17369
+ callId: 1,
17370
+ parentId: 1
17371
+ };
17372
+ function getForwardProps(props) {
17373
+ const forward = {};
17374
+ let count = 0;
17375
+ eachProp(props, (value, prop) => {
17376
+ if (!RESERVED_PROPS[prop]) {
17377
+ forward[prop] = value;
17378
+ count++;
17379
+ }
17380
+ });
17381
+ if (count) {
17382
+ return forward;
17383
+ }
17384
+ }
17385
+ function inferTo(props) {
17386
+ const to2 = getForwardProps(props);
17387
+ if (to2) {
17388
+ const out = { to: to2 };
17389
+ eachProp(props, (val, key) => key in to2 || (out[key] = val));
17390
+ return out;
17391
+ }
17392
+ return { ...props };
17393
+ }
17394
+ function computeGoal(value) {
17395
+ value = getFluidValue(value);
17396
+ return is.arr(value) ? value.map(computeGoal) : isAnimatedString(value) ? globals_exports.createStringInterpolator({
17397
+ range: [0, 1],
17398
+ output: [value, value]
17399
+ })(1) : value;
17400
+ }
17401
+ function hasProps(props) {
17402
+ for (const _ in props)
17403
+ return true;
17404
+ return false;
17405
+ }
17406
+ function isAsyncTo(to2) {
17407
+ return is.fun(to2) || is.arr(to2) && is.obj(to2[0]);
17408
+ }
17409
+ function detachRefs(ctrl, ref) {
17410
+ ctrl.ref?.delete(ctrl);
17411
+ ref?.delete(ctrl);
17412
+ }
17413
+ function replaceRef(ctrl, ref) {
17414
+ if (ref && ctrl.ref !== ref) {
17415
+ ctrl.ref?.delete(ctrl);
17416
+ ref.add(ctrl);
17417
+ ctrl.ref = ref;
17418
+ }
17419
+ }
17420
+
17421
+ // src/constants.ts
17422
+ var config = {
17423
+ default: { tension: 170, friction: 26 },
17424
+ gentle: { tension: 120, friction: 14 },
17425
+ wobbly: { tension: 180, friction: 12 },
17426
+ stiff: { tension: 210, friction: 20 },
17427
+ slow: { tension: 280, friction: 60 },
17428
+ molasses: { tension: 280, friction: 120 }
17429
+ };
17430
+
17431
+ // src/AnimationConfig.ts
17432
+ var defaults = {
17433
+ ...config.default,
17434
+ mass: 1,
17435
+ damping: 1,
17436
+ easing: easings.linear,
17437
+ clamp: false
17438
+ };
17439
+ var AnimationConfig = class {
17440
+ constructor() {
17441
+ /**
17442
+ * The initial velocity of one or more values.
17443
+ *
17444
+ * @default 0
17445
+ */
17446
+ this.velocity = 0;
17447
+ Object.assign(this, defaults);
17448
+ }
17449
+ };
17450
+ function mergeConfig(config2, newConfig, defaultConfig) {
17451
+ if (defaultConfig) {
17452
+ defaultConfig = { ...defaultConfig };
17453
+ sanitizeConfig(defaultConfig, newConfig);
17454
+ newConfig = { ...defaultConfig, ...newConfig };
17455
+ }
17456
+ sanitizeConfig(config2, newConfig);
17457
+ Object.assign(config2, newConfig);
17458
+ for (const key in defaults) {
17459
+ if (config2[key] == null) {
17460
+ config2[key] = defaults[key];
17461
+ }
17462
+ }
17463
+ let { frequency, damping } = config2;
17464
+ const { mass } = config2;
17465
+ if (!is.und(frequency)) {
17466
+ if (frequency < 0.01)
17467
+ frequency = 0.01;
17468
+ if (damping < 0)
17469
+ damping = 0;
17470
+ config2.tension = Math.pow(2 * Math.PI / frequency, 2) * mass;
17471
+ config2.friction = 4 * Math.PI * damping * mass / frequency;
17472
+ }
17473
+ return config2;
17474
+ }
17475
+ function sanitizeConfig(config2, props) {
17476
+ if (!is.und(props.decay)) {
17477
+ config2.duration = void 0;
17478
+ } else {
17479
+ const isTensionConfig = !is.und(props.tension) || !is.und(props.friction);
17480
+ if (isTensionConfig || !is.und(props.frequency) || !is.und(props.damping) || !is.und(props.mass)) {
17481
+ config2.duration = void 0;
17482
+ config2.decay = void 0;
17483
+ }
17484
+ if (isTensionConfig) {
17485
+ config2.frequency = void 0;
17486
+ }
17487
+ }
17488
+ }
17489
+
17490
+ // src/Animation.ts
17491
+ var emptyArray = [];
17492
+ var Animation = class {
17493
+ constructor() {
17494
+ this.changed = false;
17495
+ this.values = emptyArray;
17496
+ this.toValues = null;
17497
+ this.fromValues = emptyArray;
17498
+ this.config = new AnimationConfig();
17499
+ this.immediate = false;
17500
+ }
17501
+ };
17502
+ function scheduleProps(callId, { key, props, defaultProps, state, actions }) {
17503
+ return new Promise((resolve, reject) => {
17504
+ let delay;
17505
+ let timeout;
17506
+ let cancel = matchProp(props.cancel ?? defaultProps?.cancel, key);
17507
+ if (cancel) {
17508
+ onStart();
17509
+ } else {
17510
+ if (!is.und(props.pause)) {
17511
+ state.paused = matchProp(props.pause, key);
17512
+ }
17513
+ let pause = defaultProps?.pause;
17514
+ if (pause !== true) {
17515
+ pause = state.paused || matchProp(pause, key);
17516
+ }
17517
+ delay = callProp(props.delay || 0, key);
17518
+ if (pause) {
17519
+ state.resumeQueue.add(onResume);
17520
+ actions.pause();
17521
+ } else {
17522
+ actions.resume();
17523
+ onResume();
17524
+ }
17525
+ }
17526
+ function onPause() {
17527
+ state.resumeQueue.add(onResume);
17528
+ state.timeouts.delete(timeout);
17529
+ timeout.cancel();
17530
+ delay = timeout.time - raf.now();
17531
+ }
17532
+ function onResume() {
17533
+ if (delay > 0 && !globals_exports.skipAnimation) {
17534
+ state.delayed = true;
17535
+ timeout = raf.setTimeout(onStart, delay);
17536
+ state.pauseQueue.add(onPause);
17537
+ state.timeouts.add(timeout);
17538
+ } else {
17539
+ onStart();
17540
+ }
17541
+ }
17542
+ function onStart() {
17543
+ if (state.delayed) {
17544
+ state.delayed = false;
17545
+ }
17546
+ state.pauseQueue.delete(onPause);
17547
+ state.timeouts.delete(timeout);
17548
+ if (callId <= (state.cancelId || 0)) {
17549
+ cancel = true;
17550
+ }
17551
+ try {
17552
+ actions.start({ ...props, callId, cancel }, resolve);
17553
+ } catch (err) {
17554
+ reject(err);
17555
+ }
17556
+ }
17557
+ });
17558
+ }
17559
+
17560
+ // src/AnimationResult.ts
17561
+ 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(
17562
+ target.get(),
17563
+ results.every((result) => result.finished)
17564
+ );
17565
+ var getNoopResult = (value) => ({
17566
+ value,
17567
+ noop: true,
17568
+ finished: true,
17569
+ cancelled: false
17570
+ });
17571
+ var getFinishedResult = (value, finished, cancelled = false) => ({
17572
+ value,
17573
+ finished,
17574
+ cancelled
17575
+ });
17576
+ var getCancelledResult = (value) => ({
17577
+ value,
17578
+ cancelled: true,
17579
+ finished: false
17580
+ });
17581
+
17582
+ // src/runAsync.ts
17583
+ function runAsync(to2, props, state, target) {
17584
+ const { callId, parentId, onRest } = props;
17585
+ const { asyncTo: prevTo, promise: prevPromise } = state;
17586
+ if (!parentId && to2 === prevTo && !props.reset) {
17587
+ return prevPromise;
17588
+ }
17589
+ return state.promise = (async () => {
17590
+ state.asyncId = callId;
17591
+ state.asyncTo = to2;
17592
+ const defaultProps = getDefaultProps(
17593
+ props,
17594
+ (value, key) => (
17595
+ // The `onRest` prop is only called when the `runAsync` promise is resolved.
17596
+ key === "onRest" ? void 0 : value
17597
+ )
17598
+ );
17599
+ let preventBail;
17600
+ let bail;
17601
+ const bailPromise = new Promise(
17602
+ (resolve, reject) => (preventBail = resolve, bail = reject)
17603
+ );
17604
+ const bailIfEnded = (bailSignal) => {
17605
+ const bailResult = (
17606
+ // The `cancel` prop or `stop` method was used.
17607
+ callId <= (state.cancelId || 0) && getCancelledResult(target) || // The async `to` prop was replaced.
17608
+ callId !== state.asyncId && getFinishedResult(target, false)
17609
+ );
17610
+ if (bailResult) {
17611
+ bailSignal.result = bailResult;
17612
+ bail(bailSignal);
17613
+ throw bailSignal;
17614
+ }
17615
+ };
17616
+ const animate = (arg1, arg2) => {
17617
+ const bailSignal = new BailSignal();
17618
+ const skipAnimationSignal = new SkipAnimationSignal();
17619
+ return (async () => {
17620
+ if (globals_exports.skipAnimation) {
17621
+ stopAsync(state);
17622
+ skipAnimationSignal.result = getFinishedResult(target, false);
17623
+ bail(skipAnimationSignal);
17624
+ throw skipAnimationSignal;
17625
+ }
17626
+ bailIfEnded(bailSignal);
17627
+ const props2 = is.obj(arg1) ? { ...arg1 } : { ...arg2, to: arg1 };
17628
+ props2.parentId = callId;
17629
+ eachProp(defaultProps, (value, key) => {
17630
+ if (is.und(props2[key])) {
17631
+ props2[key] = value;
17632
+ }
17633
+ });
17634
+ const result2 = await target.start(props2);
17635
+ bailIfEnded(bailSignal);
17636
+ if (state.paused) {
17637
+ await new Promise((resume) => {
17638
+ state.resumeQueue.add(resume);
17639
+ });
17640
+ }
17641
+ return result2;
17642
+ })();
17643
+ };
17644
+ let result;
17645
+ if (globals_exports.skipAnimation) {
17646
+ stopAsync(state);
17647
+ return getFinishedResult(target, false);
17648
+ }
17649
+ try {
17650
+ let animating;
17651
+ if (is.arr(to2)) {
17652
+ animating = (async (queue) => {
17653
+ for (const props2 of queue) {
17654
+ await animate(props2);
17655
+ }
17656
+ })(to2);
17657
+ } else {
17658
+ animating = Promise.resolve(to2(animate, target.stop.bind(target)));
17659
+ }
17660
+ await Promise.all([animating.then(preventBail), bailPromise]);
17661
+ result = getFinishedResult(target.get(), true, false);
17662
+ } catch (err) {
17663
+ if (err instanceof BailSignal) {
17664
+ result = err.result;
17665
+ } else if (err instanceof SkipAnimationSignal) {
17666
+ result = err.result;
17667
+ } else {
17668
+ throw err;
17669
+ }
17670
+ } finally {
17671
+ if (callId == state.asyncId) {
17672
+ state.asyncId = parentId;
17673
+ state.asyncTo = parentId ? prevTo : void 0;
17674
+ state.promise = parentId ? prevPromise : void 0;
17675
+ }
17676
+ }
17677
+ if (is.fun(onRest)) {
17678
+ raf.batchedUpdates(() => {
17679
+ onRest(result, target, target.item);
17680
+ });
17681
+ }
17682
+ return result;
17683
+ })();
17684
+ }
17685
+ function stopAsync(state, cancelId) {
17686
+ flush(state.timeouts, (t) => t.cancel());
17687
+ state.pauseQueue.clear();
17688
+ state.resumeQueue.clear();
17689
+ state.asyncId = state.asyncTo = state.promise = void 0;
17690
+ if (cancelId)
17691
+ state.cancelId = cancelId;
17692
+ }
17693
+ var BailSignal = class extends Error {
17694
+ constructor() {
17695
+ super(
17696
+ "An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise."
17697
+ );
17698
+ }
17699
+ };
17700
+ var SkipAnimationSignal = class extends Error {
17701
+ constructor() {
17702
+ super("SkipAnimationSignal");
17703
+ }
17704
+ };
17705
+ var isFrameValue = (value) => value instanceof FrameValue;
17706
+ var nextId = 1;
17707
+ var FrameValue = class extends FluidValue {
17708
+ constructor() {
17709
+ super(...arguments);
17710
+ this.id = nextId++;
17711
+ this._priority = 0;
17712
+ }
17713
+ get priority() {
17714
+ return this._priority;
17715
+ }
17716
+ set priority(priority) {
17717
+ if (this._priority != priority) {
17718
+ this._priority = priority;
17719
+ this._onPriorityChange(priority);
17720
+ }
17721
+ }
17722
+ /** Get the current value */
17723
+ get() {
17724
+ const node = getAnimated(this);
17725
+ return node && node.getValue();
17726
+ }
17727
+ /** Create a spring that maps our value to another value */
17728
+ to(...args) {
17729
+ return globals_exports.to(this, args);
17730
+ }
17731
+ /** @deprecated Use the `to` method instead. */
17732
+ interpolate(...args) {
17733
+ deprecateInterpolate();
17734
+ return globals_exports.to(this, args);
17735
+ }
17736
+ toJSON() {
17737
+ return this.get();
17738
+ }
17739
+ observerAdded(count) {
17740
+ if (count == 1)
17741
+ this._attach();
17742
+ }
17743
+ observerRemoved(count) {
17744
+ if (count == 0)
17745
+ this._detach();
17746
+ }
17747
+ /** Called when the first child is added. */
17748
+ _attach() {
17749
+ }
17750
+ /** Called when the last child is removed. */
17751
+ _detach() {
17752
+ }
17753
+ /** Tell our children about our new value */
17754
+ _onChange(value, idle = false) {
17755
+ callFluidObservers(this, {
17756
+ type: "change",
17757
+ parent: this,
17758
+ value,
17759
+ idle
17760
+ });
17761
+ }
17762
+ /** Tell our children about our new priority */
17763
+ _onPriorityChange(priority) {
17764
+ if (!this.idle) {
17765
+ frameLoop.sort(this);
17766
+ }
17767
+ callFluidObservers(this, {
17768
+ type: "priority",
17769
+ parent: this,
17770
+ priority
17771
+ });
17772
+ }
17773
+ };
17774
+
17775
+ // src/SpringPhase.ts
17776
+ var $P = Symbol.for("SpringPhase");
17777
+ var HAS_ANIMATED = 1;
17778
+ var IS_ANIMATING = 2;
17779
+ var IS_PAUSED = 4;
17780
+ var hasAnimated = (target) => (target[$P] & HAS_ANIMATED) > 0;
17781
+ var isAnimating = (target) => (target[$P] & IS_ANIMATING) > 0;
17782
+ var isPaused = (target) => (target[$P] & IS_PAUSED) > 0;
17783
+ var setActiveBit = (target, active) => active ? target[$P] |= IS_ANIMATING | HAS_ANIMATED : target[$P] &= ~IS_ANIMATING;
17784
+ var setPausedBit = (target, paused) => paused ? target[$P] |= IS_PAUSED : target[$P] &= ~IS_PAUSED;
17785
+
17786
+ // src/SpringValue.ts
17787
+ var SpringValue = class extends FrameValue {
17788
+ constructor(arg1, arg2) {
17789
+ super();
17790
+ /** The animation state */
17791
+ this.animation = new Animation();
17792
+ /** Some props have customizable default values */
17793
+ this.defaultProps = {};
17794
+ /** The state for `runAsync` calls */
17795
+ this._state = {
17796
+ paused: false,
17797
+ delayed: false,
17798
+ pauseQueue: /* @__PURE__ */ new Set(),
17799
+ resumeQueue: /* @__PURE__ */ new Set(),
17800
+ timeouts: /* @__PURE__ */ new Set()
17801
+ };
17802
+ /** The promise resolvers of pending `start` calls */
17803
+ this._pendingCalls = /* @__PURE__ */ new Set();
17804
+ /** The counter for tracking `scheduleProps` calls */
17805
+ this._lastCallId = 0;
17806
+ /** The last `scheduleProps` call that changed the `to` prop */
17807
+ this._lastToId = 0;
17808
+ this._memoizedDuration = 0;
17809
+ if (!is.und(arg1) || !is.und(arg2)) {
17810
+ const props = is.obj(arg1) ? { ...arg1 } : { ...arg2, from: arg1 };
17811
+ if (is.und(props.default)) {
17812
+ props.default = true;
17813
+ }
17814
+ this.start(props);
17815
+ }
17816
+ }
17817
+ /** Equals true when not advancing on each frame. */
17818
+ get idle() {
17819
+ return !(isAnimating(this) || this._state.asyncTo) || isPaused(this);
17820
+ }
17821
+ get goal() {
17822
+ return getFluidValue(this.animation.to);
17823
+ }
17824
+ get velocity() {
17825
+ const node = getAnimated(this);
17826
+ return node instanceof AnimatedValue ? node.lastVelocity || 0 : node.getPayload().map((node2) => node2.lastVelocity || 0);
17827
+ }
17828
+ /**
17829
+ * When true, this value has been animated at least once.
17830
+ */
17831
+ get hasAnimated() {
17832
+ return hasAnimated(this);
17833
+ }
17834
+ /**
17835
+ * When true, this value has an unfinished animation,
17836
+ * which is either active or paused.
17837
+ */
17838
+ get isAnimating() {
17839
+ return isAnimating(this);
17840
+ }
17841
+ /**
17842
+ * When true, all current and future animations are paused.
17843
+ */
17844
+ get isPaused() {
17845
+ return isPaused(this);
17846
+ }
17847
+ /**
17848
+ *
17849
+ *
17850
+ */
17851
+ get isDelayed() {
17852
+ return this._state.delayed;
17853
+ }
17854
+ /** Advance the current animation by a number of milliseconds */
17855
+ advance(dt) {
17856
+ let idle = true;
17857
+ let changed = false;
17858
+ const anim = this.animation;
17859
+ let { toValues } = anim;
17860
+ const { config: config2 } = anim;
17861
+ const payload = getPayload(anim.to);
17862
+ if (!payload && hasFluidValue(anim.to)) {
17863
+ toValues = toArray(getFluidValue(anim.to));
17864
+ }
17865
+ anim.values.forEach((node2, i) => {
17866
+ if (node2.done)
17867
+ return;
17868
+ const to2 = (
17869
+ // Animated strings always go from 0 to 1.
17870
+ node2.constructor == AnimatedString ? 1 : payload ? payload[i].lastPosition : toValues[i]
17871
+ );
17872
+ let finished = anim.immediate;
17873
+ let position = to2;
17874
+ if (!finished) {
17875
+ position = node2.lastPosition;
17876
+ if (config2.tension <= 0) {
17877
+ node2.done = true;
17878
+ return;
17879
+ }
17880
+ let elapsed = node2.elapsedTime += dt;
17881
+ const from = anim.fromValues[i];
17882
+ const v0 = node2.v0 != null ? node2.v0 : node2.v0 = is.arr(config2.velocity) ? config2.velocity[i] : config2.velocity;
17883
+ let velocity;
17884
+ const precision = config2.precision || (from == to2 ? 5e-3 : Math.min(1, Math.abs(to2 - from) * 1e-3));
17885
+ if (!is.und(config2.duration)) {
17886
+ let p = 1;
17887
+ if (config2.duration > 0) {
17888
+ if (this._memoizedDuration !== config2.duration) {
17889
+ this._memoizedDuration = config2.duration;
17890
+ if (node2.durationProgress > 0) {
17891
+ node2.elapsedTime = config2.duration * node2.durationProgress;
17892
+ elapsed = node2.elapsedTime += dt;
17893
+ }
17894
+ }
17895
+ p = (config2.progress || 0) + elapsed / this._memoizedDuration;
17896
+ p = p > 1 ? 1 : p < 0 ? 0 : p;
17897
+ node2.durationProgress = p;
17898
+ }
17899
+ position = from + config2.easing(p) * (to2 - from);
17900
+ velocity = (position - node2.lastPosition) / dt;
17901
+ finished = p == 1;
17902
+ } else if (config2.decay) {
17903
+ const decay = config2.decay === true ? 0.998 : config2.decay;
17904
+ const e = Math.exp(-(1 - decay) * elapsed);
17905
+ position = from + v0 / (1 - decay) * (1 - e);
17906
+ finished = Math.abs(node2.lastPosition - position) <= precision;
17907
+ velocity = v0 * e;
17908
+ } else {
17909
+ velocity = node2.lastVelocity == null ? v0 : node2.lastVelocity;
17910
+ const restVelocity = config2.restVelocity || precision / 10;
17911
+ const bounceFactor = config2.clamp ? 0 : config2.bounce;
17912
+ const canBounce = !is.und(bounceFactor);
17913
+ const isGrowing = from == to2 ? node2.v0 > 0 : from < to2;
17914
+ let isMoving;
17915
+ let isBouncing = false;
17916
+ const step = 1;
17917
+ const numSteps = Math.ceil(dt / step);
17918
+ for (let n = 0; n < numSteps; ++n) {
17919
+ isMoving = Math.abs(velocity) > restVelocity;
17920
+ if (!isMoving) {
17921
+ finished = Math.abs(to2 - position) <= precision;
17922
+ if (finished) {
17923
+ break;
17924
+ }
17925
+ }
17926
+ if (canBounce) {
17927
+ isBouncing = position == to2 || position > to2 == isGrowing;
17928
+ if (isBouncing) {
17929
+ velocity = -velocity * bounceFactor;
17930
+ position = to2;
17931
+ }
17932
+ }
17933
+ const springForce = -config2.tension * 1e-6 * (position - to2);
17934
+ const dampingForce = -config2.friction * 1e-3 * velocity;
17935
+ const acceleration = (springForce + dampingForce) / config2.mass;
17936
+ velocity = velocity + acceleration * step;
17937
+ position = position + velocity * step;
17938
+ }
17939
+ }
17940
+ node2.lastVelocity = velocity;
17941
+ if (Number.isNaN(position)) {
17942
+ console.warn(`Got NaN while animating:`, this);
17943
+ finished = true;
17944
+ }
17945
+ }
17946
+ if (payload && !payload[i].done) {
17947
+ finished = false;
17948
+ }
17949
+ if (finished) {
17950
+ node2.done = true;
17951
+ } else {
17952
+ idle = false;
17953
+ }
17954
+ if (node2.setValue(position, config2.round)) {
17955
+ changed = true;
17956
+ }
17957
+ });
17958
+ const node = getAnimated(this);
17959
+ const currVal = node.getValue();
17960
+ if (idle) {
17961
+ const finalVal = getFluidValue(anim.to);
17962
+ if ((currVal !== finalVal || changed) && !config2.decay) {
17963
+ node.setValue(finalVal);
17964
+ this._onChange(finalVal);
17965
+ } else if (changed && config2.decay) {
17966
+ this._onChange(currVal);
17967
+ }
17968
+ this._stop();
17969
+ } else if (changed) {
17970
+ this._onChange(currVal);
17971
+ }
17972
+ }
17973
+ /** Set the current value, while stopping the current animation */
17974
+ set(value) {
17975
+ raf.batchedUpdates(() => {
17976
+ this._stop();
17977
+ this._focus(value);
17978
+ this._set(value);
17979
+ });
17980
+ return this;
17981
+ }
17982
+ /**
17983
+ * Freeze the active animation in time, as well as any updates merged
17984
+ * before `resume` is called.
17985
+ */
17986
+ pause() {
17987
+ this._update({ pause: true });
17988
+ }
17989
+ /** Resume the animation if paused. */
17990
+ resume() {
17991
+ this._update({ pause: false });
17992
+ }
17993
+ /** Skip to the end of the current animation. */
17994
+ finish() {
17995
+ if (isAnimating(this)) {
17996
+ const { to: to2, config: config2 } = this.animation;
17997
+ raf.batchedUpdates(() => {
17998
+ this._onStart();
17999
+ if (!config2.decay) {
18000
+ this._set(to2, false);
18001
+ }
18002
+ this._stop();
18003
+ });
18004
+ }
18005
+ return this;
18006
+ }
18007
+ /** Push props into the pending queue. */
18008
+ update(props) {
18009
+ const queue = this.queue || (this.queue = []);
18010
+ queue.push(props);
18011
+ return this;
18012
+ }
18013
+ start(to2, arg2) {
18014
+ let queue;
18015
+ if (!is.und(to2)) {
18016
+ queue = [is.obj(to2) ? to2 : { ...arg2, to: to2 }];
18017
+ } else {
18018
+ queue = this.queue || [];
18019
+ this.queue = [];
18020
+ }
18021
+ return Promise.all(
18022
+ queue.map((props) => {
18023
+ const up = this._update(props);
18024
+ return up;
18025
+ })
18026
+ ).then((results) => getCombinedResult(this, results));
18027
+ }
18028
+ /**
18029
+ * Stop the current animation, and cancel any delayed updates.
18030
+ *
18031
+ * Pass `true` to call `onRest` with `cancelled: true`.
18032
+ */
18033
+ stop(cancel) {
18034
+ const { to: to2 } = this.animation;
18035
+ this._focus(this.get());
18036
+ stopAsync(this._state, cancel && this._lastCallId);
18037
+ raf.batchedUpdates(() => this._stop(to2, cancel));
18038
+ return this;
18039
+ }
18040
+ /** Restart the animation. */
18041
+ reset() {
18042
+ this._update({ reset: true });
18043
+ }
18044
+ /** @internal */
18045
+ eventObserved(event) {
18046
+ if (event.type == "change") {
18047
+ this._start();
18048
+ } else if (event.type == "priority") {
18049
+ this.priority = event.priority + 1;
18050
+ }
18051
+ }
18052
+ /**
18053
+ * Parse the `to` and `from` range from the given `props` object.
18054
+ *
18055
+ * This also ensures the initial value is available to animated components
18056
+ * during the render phase.
18057
+ */
18058
+ _prepareNode(props) {
18059
+ const key = this.key || "";
18060
+ let { to: to2, from } = props;
18061
+ to2 = is.obj(to2) ? to2[key] : to2;
18062
+ if (to2 == null || isAsyncTo(to2)) {
18063
+ to2 = void 0;
18064
+ }
18065
+ from = is.obj(from) ? from[key] : from;
18066
+ if (from == null) {
18067
+ from = void 0;
18068
+ }
18069
+ const range = { to: to2, from };
18070
+ if (!hasAnimated(this)) {
18071
+ if (props.reverse)
18072
+ [to2, from] = [from, to2];
18073
+ from = getFluidValue(from);
18074
+ if (!is.und(from)) {
18075
+ this._set(from);
18076
+ } else if (!getAnimated(this)) {
18077
+ this._set(to2);
18078
+ }
18079
+ }
18080
+ return range;
18081
+ }
18082
+ /** Every update is processed by this method before merging. */
18083
+ _update({ ...props }, isLoop) {
18084
+ const { key, defaultProps } = this;
18085
+ if (props.default)
18086
+ Object.assign(
18087
+ defaultProps,
18088
+ getDefaultProps(
18089
+ props,
18090
+ (value, prop) => /^on/.test(prop) ? resolveProp(value, key) : value
18091
+ )
18092
+ );
18093
+ mergeActiveFn(this, props, "onProps");
18094
+ sendEvent(this, "onProps", props, this);
18095
+ const range = this._prepareNode(props);
18096
+ if (Object.isFrozen(this)) {
18097
+ throw Error(
18098
+ "Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?"
18099
+ );
18100
+ }
18101
+ const state = this._state;
18102
+ return scheduleProps(++this._lastCallId, {
18103
+ key,
18104
+ props,
18105
+ defaultProps,
18106
+ state,
18107
+ actions: {
18108
+ pause: () => {
18109
+ if (!isPaused(this)) {
18110
+ setPausedBit(this, true);
18111
+ flushCalls(state.pauseQueue);
18112
+ sendEvent(
18113
+ this,
18114
+ "onPause",
18115
+ getFinishedResult(this, checkFinished(this, this.animation.to)),
18116
+ this
18117
+ );
18118
+ }
18119
+ },
18120
+ resume: () => {
18121
+ if (isPaused(this)) {
18122
+ setPausedBit(this, false);
18123
+ if (isAnimating(this)) {
18124
+ this._resume();
18125
+ }
18126
+ flushCalls(state.resumeQueue);
18127
+ sendEvent(
18128
+ this,
18129
+ "onResume",
18130
+ getFinishedResult(this, checkFinished(this, this.animation.to)),
18131
+ this
18132
+ );
18133
+ }
18134
+ },
18135
+ start: this._merge.bind(this, range)
18136
+ }
18137
+ }).then((result) => {
18138
+ if (props.loop && result.finished && !(isLoop && result.noop)) {
18139
+ const nextProps = createLoopUpdate(props);
18140
+ if (nextProps) {
18141
+ return this._update(nextProps, true);
18142
+ }
18143
+ }
18144
+ return result;
18145
+ });
18146
+ }
18147
+ /** Merge props into the current animation */
18148
+ _merge(range, props, resolve) {
18149
+ if (props.cancel) {
18150
+ this.stop(true);
18151
+ return resolve(getCancelledResult(this));
18152
+ }
18153
+ const hasToProp = !is.und(range.to);
18154
+ const hasFromProp = !is.und(range.from);
18155
+ if (hasToProp || hasFromProp) {
18156
+ if (props.callId > this._lastToId) {
18157
+ this._lastToId = props.callId;
18158
+ } else {
18159
+ return resolve(getCancelledResult(this));
18160
+ }
18161
+ }
18162
+ const { key, defaultProps, animation: anim } = this;
18163
+ const { to: prevTo, from: prevFrom } = anim;
18164
+ let { to: to2 = prevTo, from = prevFrom } = range;
18165
+ if (hasFromProp && !hasToProp && (!props.default || is.und(to2))) {
18166
+ to2 = from;
18167
+ }
18168
+ if (props.reverse)
18169
+ [to2, from] = [from, to2];
18170
+ const hasFromChanged = !isEqual(from, prevFrom);
18171
+ if (hasFromChanged) {
18172
+ anim.from = from;
18173
+ }
18174
+ from = getFluidValue(from);
18175
+ const hasToChanged = !isEqual(to2, prevTo);
18176
+ if (hasToChanged) {
18177
+ this._focus(to2);
18178
+ }
18179
+ const hasAsyncTo = isAsyncTo(props.to);
18180
+ const { config: config2 } = anim;
18181
+ const { decay, velocity } = config2;
18182
+ if (hasToProp || hasFromProp) {
18183
+ config2.velocity = 0;
18184
+ }
18185
+ if (props.config && !hasAsyncTo) {
18186
+ mergeConfig(
18187
+ config2,
18188
+ callProp(props.config, key),
18189
+ // Avoid calling the same "config" prop twice.
18190
+ props.config !== defaultProps.config ? callProp(defaultProps.config, key) : void 0
18191
+ );
18192
+ }
18193
+ let node = getAnimated(this);
18194
+ if (!node || is.und(to2)) {
18195
+ return resolve(getFinishedResult(this, true));
18196
+ }
18197
+ const reset = (
18198
+ // When `reset` is undefined, the `from` prop implies `reset: true`,
18199
+ // except for declarative updates. When `reset` is defined, there
18200
+ // must exist a value to animate from.
18201
+ is.und(props.reset) ? hasFromProp && !props.default : !is.und(from) && matchProp(props.reset, key)
18202
+ );
18203
+ const value = reset ? from : this.get();
18204
+ const goal = computeGoal(to2);
18205
+ const isAnimatable = is.num(goal) || is.arr(goal) || isAnimatedString(goal);
18206
+ const immediate = !hasAsyncTo && (!isAnimatable || matchProp(defaultProps.immediate || props.immediate, key));
18207
+ if (hasToChanged) {
18208
+ const nodeType = getAnimatedType(to2);
18209
+ if (nodeType !== node.constructor) {
18210
+ if (immediate) {
18211
+ node = this._set(goal);
18212
+ } else
18213
+ throw Error(
18214
+ `Cannot animate between ${node.constructor.name} and ${nodeType.name}, as the "to" prop suggests`
18215
+ );
18216
+ }
18217
+ }
18218
+ const goalType = node.constructor;
18219
+ let started = hasFluidValue(to2);
18220
+ let finished = false;
18221
+ if (!started) {
18222
+ const hasValueChanged = reset || !hasAnimated(this) && hasFromChanged;
18223
+ if (hasToChanged || hasValueChanged) {
18224
+ finished = isEqual(computeGoal(value), goal);
18225
+ started = !finished;
18226
+ }
18227
+ if (!isEqual(anim.immediate, immediate) && !immediate || !isEqual(config2.decay, decay) || !isEqual(config2.velocity, velocity)) {
18228
+ started = true;
18229
+ }
18230
+ }
18231
+ if (finished && isAnimating(this)) {
18232
+ if (anim.changed && !reset) {
18233
+ started = true;
18234
+ } else if (!started) {
18235
+ this._stop(prevTo);
18236
+ }
18237
+ }
18238
+ if (!hasAsyncTo) {
18239
+ if (started || hasFluidValue(prevTo)) {
18240
+ anim.values = node.getPayload();
18241
+ anim.toValues = hasFluidValue(to2) ? null : goalType == AnimatedString ? [1] : toArray(goal);
18242
+ }
18243
+ if (anim.immediate != immediate) {
18244
+ anim.immediate = immediate;
18245
+ if (!immediate && !reset) {
18246
+ this._set(prevTo);
18247
+ }
18248
+ }
18249
+ if (started) {
18250
+ const { onRest } = anim;
18251
+ each(ACTIVE_EVENTS, (type) => mergeActiveFn(this, props, type));
18252
+ const result = getFinishedResult(this, checkFinished(this, prevTo));
18253
+ flushCalls(this._pendingCalls, result);
18254
+ this._pendingCalls.add(resolve);
18255
+ if (anim.changed)
18256
+ raf.batchedUpdates(() => {
18257
+ anim.changed = !reset;
18258
+ onRest?.(result, this);
18259
+ if (reset) {
18260
+ callProp(defaultProps.onRest, result);
18261
+ } else {
18262
+ anim.onStart?.(result, this);
18263
+ }
18264
+ });
18265
+ }
18266
+ }
18267
+ if (reset) {
18268
+ this._set(value);
18269
+ }
18270
+ if (hasAsyncTo) {
18271
+ resolve(runAsync(props.to, props, this._state, this));
18272
+ } else if (started) {
18273
+ this._start();
18274
+ } else if (isAnimating(this) && !hasToChanged) {
18275
+ this._pendingCalls.add(resolve);
18276
+ } else {
18277
+ resolve(getNoopResult(value));
18278
+ }
18279
+ }
18280
+ /** Update the `animation.to` value, which might be a `FluidValue` */
18281
+ _focus(value) {
18282
+ const anim = this.animation;
18283
+ if (value !== anim.to) {
18284
+ if (getFluidObservers(this)) {
18285
+ this._detach();
18286
+ }
18287
+ anim.to = value;
18288
+ if (getFluidObservers(this)) {
18289
+ this._attach();
18290
+ }
18291
+ }
18292
+ }
18293
+ _attach() {
18294
+ let priority = 0;
18295
+ const { to: to2 } = this.animation;
18296
+ if (hasFluidValue(to2)) {
18297
+ addFluidObserver(to2, this);
18298
+ if (isFrameValue(to2)) {
18299
+ priority = to2.priority + 1;
18300
+ }
18301
+ }
18302
+ this.priority = priority;
18303
+ }
18304
+ _detach() {
18305
+ const { to: to2 } = this.animation;
18306
+ if (hasFluidValue(to2)) {
18307
+ removeFluidObserver(to2, this);
18308
+ }
18309
+ }
18310
+ /**
18311
+ * Update the current value from outside the frameloop,
18312
+ * and return the `Animated` node.
18313
+ */
18314
+ _set(arg, idle = true) {
18315
+ const value = getFluidValue(arg);
18316
+ if (!is.und(value)) {
18317
+ const oldNode = getAnimated(this);
18318
+ if (!oldNode || !isEqual(value, oldNode.getValue())) {
18319
+ const nodeType = getAnimatedType(value);
18320
+ if (!oldNode || oldNode.constructor != nodeType) {
18321
+ setAnimated(this, nodeType.create(value));
18322
+ } else {
18323
+ oldNode.setValue(value);
18324
+ }
18325
+ if (oldNode) {
18326
+ raf.batchedUpdates(() => {
18327
+ this._onChange(value, idle);
18328
+ });
18329
+ }
18330
+ }
18331
+ }
18332
+ return getAnimated(this);
18333
+ }
18334
+ _onStart() {
18335
+ const anim = this.animation;
18336
+ if (!anim.changed) {
18337
+ anim.changed = true;
18338
+ sendEvent(
18339
+ this,
18340
+ "onStart",
18341
+ getFinishedResult(this, checkFinished(this, anim.to)),
18342
+ this
18343
+ );
18344
+ }
18345
+ }
18346
+ _onChange(value, idle) {
18347
+ if (!idle) {
18348
+ this._onStart();
18349
+ callProp(this.animation.onChange, value, this);
18350
+ }
18351
+ callProp(this.defaultProps.onChange, value, this);
18352
+ super._onChange(value, idle);
18353
+ }
18354
+ // This method resets the animation state (even if already animating) to
18355
+ // ensure the latest from/to range is used, and it also ensures this spring
18356
+ // is added to the frameloop.
18357
+ _start() {
18358
+ const anim = this.animation;
18359
+ getAnimated(this).reset(getFluidValue(anim.to));
18360
+ if (!anim.immediate) {
18361
+ anim.fromValues = anim.values.map((node) => node.lastPosition);
18362
+ }
18363
+ if (!isAnimating(this)) {
18364
+ setActiveBit(this, true);
18365
+ if (!isPaused(this)) {
18366
+ this._resume();
18367
+ }
18368
+ }
18369
+ }
18370
+ _resume() {
18371
+ if (globals_exports.skipAnimation) {
18372
+ this.finish();
18373
+ } else {
18374
+ frameLoop.start(this);
18375
+ }
18376
+ }
18377
+ /**
18378
+ * Exit the frameloop and notify `onRest` listeners.
18379
+ *
18380
+ * Always wrap `_stop` calls with `batchedUpdates`.
18381
+ */
18382
+ _stop(goal, cancel) {
18383
+ if (isAnimating(this)) {
18384
+ setActiveBit(this, false);
18385
+ const anim = this.animation;
18386
+ each(anim.values, (node) => {
18387
+ node.done = true;
18388
+ });
18389
+ if (anim.toValues) {
18390
+ anim.onChange = anim.onPause = anim.onResume = void 0;
18391
+ }
18392
+ callFluidObservers(this, {
18393
+ type: "idle",
18394
+ parent: this
18395
+ });
18396
+ const result = cancel ? getCancelledResult(this.get()) : getFinishedResult(this.get(), checkFinished(this, goal ?? anim.to));
18397
+ flushCalls(this._pendingCalls, result);
18398
+ if (anim.changed) {
18399
+ anim.changed = false;
18400
+ sendEvent(this, "onRest", result, this);
18401
+ }
18402
+ }
18403
+ }
18404
+ };
18405
+ function checkFinished(target, to2) {
18406
+ const goal = computeGoal(to2);
18407
+ const value = computeGoal(target.get());
18408
+ return isEqual(value, goal);
18409
+ }
18410
+ function createLoopUpdate(props, loop = props.loop, to2 = props.to) {
18411
+ const loopRet = callProp(loop);
18412
+ if (loopRet) {
18413
+ const overrides = loopRet !== true && inferTo(loopRet);
18414
+ const reverse = (overrides || props).reverse;
18415
+ const reset = !overrides || overrides.reset;
18416
+ return createUpdate({
18417
+ ...props,
18418
+ loop,
18419
+ // Avoid updating default props when looping.
18420
+ default: false,
18421
+ // Never loop the `pause` prop.
18422
+ pause: void 0,
18423
+ // For the "reverse" prop to loop as expected, the "to" prop
18424
+ // must be undefined. The "reverse" prop is ignored when the
18425
+ // "to" prop is an array or function.
18426
+ to: !reverse || isAsyncTo(to2) ? to2 : void 0,
18427
+ // Ignore the "from" prop except on reset.
18428
+ from: reset ? props.from : void 0,
18429
+ reset,
18430
+ // The "loop" prop can return a "useSpring" props object to
18431
+ // override any of the original props.
18432
+ ...overrides
18433
+ });
18434
+ }
18435
+ }
18436
+ function createUpdate(props) {
18437
+ const { to: to2, from } = props = inferTo(props);
18438
+ const keys = /* @__PURE__ */ new Set();
18439
+ if (is.obj(to2))
18440
+ findDefined(to2, keys);
18441
+ if (is.obj(from))
18442
+ findDefined(from, keys);
18443
+ props.keys = keys.size ? Array.from(keys) : null;
18444
+ return props;
18445
+ }
18446
+ function declareUpdate(props) {
18447
+ const update2 = createUpdate(props);
18448
+ if (is.und(update2.default)) {
18449
+ update2.default = getDefaultProps(update2);
18450
+ }
18451
+ return update2;
18452
+ }
18453
+ function findDefined(values, keys) {
18454
+ eachProp(values, (value, key) => value != null && keys.add(key));
18455
+ }
18456
+ var ACTIVE_EVENTS = [
18457
+ "onStart",
18458
+ "onRest",
18459
+ "onChange",
18460
+ "onPause",
18461
+ "onResume"
18462
+ ];
18463
+ function mergeActiveFn(target, props, type) {
18464
+ target.animation[type] = props[type] !== getDefaultProp(props, type) ? resolveProp(props[type], target.key) : void 0;
18465
+ }
18466
+ function sendEvent(target, type, ...args) {
18467
+ target.animation[type]?.(...args);
18468
+ target.defaultProps[type]?.(...args);
18469
+ }
18470
+ var BATCHED_EVENTS = ["onStart", "onChange", "onRest"];
18471
+ var nextId2 = 1;
18472
+ var Controller = class {
18473
+ constructor(props, flush3) {
18474
+ this.id = nextId2++;
18475
+ /** The animated values */
18476
+ this.springs = {};
18477
+ /** The queue of props passed to the `update` method. */
18478
+ this.queue = [];
18479
+ /** The counter for tracking `scheduleProps` calls */
18480
+ this._lastAsyncId = 0;
18481
+ /** The values currently being animated */
18482
+ this._active = /* @__PURE__ */ new Set();
18483
+ /** The values that changed recently */
18484
+ this._changed = /* @__PURE__ */ new Set();
18485
+ /** Equals false when `onStart` listeners can be called */
18486
+ this._started = false;
18487
+ /** State used by the `runAsync` function */
18488
+ this._state = {
18489
+ paused: false,
18490
+ pauseQueue: /* @__PURE__ */ new Set(),
18491
+ resumeQueue: /* @__PURE__ */ new Set(),
18492
+ timeouts: /* @__PURE__ */ new Set()
18493
+ };
18494
+ /** The event queues that are flushed once per frame maximum */
18495
+ this._events = {
18496
+ onStart: /* @__PURE__ */ new Map(),
18497
+ onChange: /* @__PURE__ */ new Map(),
18498
+ onRest: /* @__PURE__ */ new Map()
18499
+ };
18500
+ this._onFrame = this._onFrame.bind(this);
18501
+ if (flush3) {
18502
+ this._flush = flush3;
18503
+ }
18504
+ if (props) {
18505
+ this.start({ default: true, ...props });
18506
+ }
18507
+ }
18508
+ /**
18509
+ * Equals `true` when no spring values are in the frameloop, and
18510
+ * no async animation is currently active.
18511
+ */
18512
+ get idle() {
18513
+ return !this._state.asyncTo && Object.values(this.springs).every((spring) => {
18514
+ return spring.idle && !spring.isDelayed && !spring.isPaused;
18515
+ });
18516
+ }
18517
+ get item() {
18518
+ return this._item;
18519
+ }
18520
+ set item(item) {
18521
+ this._item = item;
18522
+ }
18523
+ /** Get the current values of our springs */
18524
+ get() {
18525
+ const values = {};
18526
+ this.each((spring, key) => values[key] = spring.get());
18527
+ return values;
18528
+ }
18529
+ /** Set the current values without animating. */
18530
+ set(values) {
18531
+ for (const key in values) {
18532
+ const value = values[key];
18533
+ if (!is.und(value)) {
18534
+ this.springs[key].set(value);
18535
+ }
18536
+ }
18537
+ }
18538
+ /** Push an update onto the queue of each value. */
18539
+ update(props) {
18540
+ if (props) {
18541
+ this.queue.push(createUpdate(props));
18542
+ }
18543
+ return this;
18544
+ }
18545
+ /**
18546
+ * Start the queued animations for every spring, and resolve the returned
18547
+ * promise once all queued animations have finished or been cancelled.
18548
+ *
18549
+ * When you pass a queue (instead of nothing), that queue is used instead of
18550
+ * the queued animations added with the `update` method, which are left alone.
18551
+ */
18552
+ start(props) {
18553
+ let { queue } = this;
18554
+ if (props) {
18555
+ queue = toArray(props).map(createUpdate);
18556
+ } else {
18557
+ this.queue = [];
18558
+ }
18559
+ if (this._flush) {
18560
+ return this._flush(this, queue);
18561
+ }
18562
+ prepareKeys(this, queue);
18563
+ return flushUpdateQueue(this, queue);
18564
+ }
18565
+ /** @internal */
18566
+ stop(arg, keys) {
18567
+ if (arg !== !!arg) {
18568
+ keys = arg;
18569
+ }
18570
+ if (keys) {
18571
+ const springs = this.springs;
18572
+ each(toArray(keys), (key) => springs[key].stop(!!arg));
18573
+ } else {
18574
+ stopAsync(this._state, this._lastAsyncId);
18575
+ this.each((spring) => spring.stop(!!arg));
18576
+ }
18577
+ return this;
18578
+ }
18579
+ /** Freeze the active animation in time */
18580
+ pause(keys) {
18581
+ if (is.und(keys)) {
18582
+ this.start({ pause: true });
18583
+ } else {
18584
+ const springs = this.springs;
18585
+ each(toArray(keys), (key) => springs[key].pause());
18586
+ }
18587
+ return this;
18588
+ }
18589
+ /** Resume the animation if paused. */
18590
+ resume(keys) {
18591
+ if (is.und(keys)) {
18592
+ this.start({ pause: false });
18593
+ } else {
18594
+ const springs = this.springs;
18595
+ each(toArray(keys), (key) => springs[key].resume());
18596
+ }
18597
+ return this;
18598
+ }
18599
+ /** Call a function once per spring value */
18600
+ each(iterator) {
18601
+ eachProp(this.springs, iterator);
18602
+ }
18603
+ /** @internal Called at the end of every animation frame */
18604
+ _onFrame() {
18605
+ const { onStart, onChange, onRest } = this._events;
18606
+ const active = this._active.size > 0;
18607
+ const changed = this._changed.size > 0;
18608
+ if (active && !this._started || changed && !this._started) {
18609
+ this._started = true;
18610
+ flush(onStart, ([onStart2, result]) => {
18611
+ result.value = this.get();
18612
+ onStart2(result, this, this._item);
18613
+ });
18614
+ }
18615
+ const idle = !active && this._started;
18616
+ const values = changed || idle && onRest.size ? this.get() : null;
18617
+ if (changed && onChange.size) {
18618
+ flush(onChange, ([onChange2, result]) => {
18619
+ result.value = values;
18620
+ onChange2(result, this, this._item);
18621
+ });
18622
+ }
18623
+ if (idle) {
18624
+ this._started = false;
18625
+ flush(onRest, ([onRest2, result]) => {
18626
+ result.value = values;
18627
+ onRest2(result, this, this._item);
18628
+ });
18629
+ }
18630
+ }
18631
+ /** @internal */
18632
+ eventObserved(event) {
18633
+ if (event.type == "change") {
18634
+ this._changed.add(event.parent);
18635
+ if (!event.idle) {
18636
+ this._active.add(event.parent);
18637
+ }
18638
+ } else if (event.type == "idle") {
18639
+ this._active.delete(event.parent);
18640
+ } else
18641
+ return;
18642
+ raf.onFrame(this._onFrame);
18643
+ }
18644
+ };
18645
+ function flushUpdateQueue(ctrl, queue) {
18646
+ return Promise.all(queue.map((props) => flushUpdate(ctrl, props))).then(
18647
+ (results) => getCombinedResult(ctrl, results)
18648
+ );
18649
+ }
18650
+ async function flushUpdate(ctrl, props, isLoop) {
18651
+ const { keys, to: to2, from, loop, onRest, onResolve } = props;
18652
+ const defaults2 = is.obj(props.default) && props.default;
18653
+ if (loop) {
18654
+ props.loop = false;
18655
+ }
18656
+ if (to2 === false)
18657
+ props.to = null;
18658
+ if (from === false)
18659
+ props.from = null;
18660
+ const asyncTo = is.arr(to2) || is.fun(to2) ? to2 : void 0;
18661
+ if (asyncTo) {
18662
+ props.to = void 0;
18663
+ props.onRest = void 0;
18664
+ if (defaults2) {
18665
+ defaults2.onRest = void 0;
18666
+ }
18667
+ } else {
18668
+ each(BATCHED_EVENTS, (key) => {
18669
+ const handler = props[key];
18670
+ if (is.fun(handler)) {
18671
+ const queue = ctrl["_events"][key];
18672
+ props[key] = ({ finished, cancelled }) => {
18673
+ const result2 = queue.get(handler);
18674
+ if (result2) {
18675
+ if (!finished)
18676
+ result2.finished = false;
18677
+ if (cancelled)
18678
+ result2.cancelled = true;
18679
+ } else {
18680
+ queue.set(handler, {
18681
+ value: null,
18682
+ finished: finished || false,
18683
+ cancelled: cancelled || false
18684
+ });
18685
+ }
18686
+ };
18687
+ if (defaults2) {
18688
+ defaults2[key] = props[key];
18689
+ }
18690
+ }
18691
+ });
18692
+ }
18693
+ const state = ctrl["_state"];
18694
+ if (props.pause === !state.paused) {
18695
+ state.paused = props.pause;
18696
+ flushCalls(props.pause ? state.pauseQueue : state.resumeQueue);
18697
+ } else if (state.paused) {
18698
+ props.pause = true;
18699
+ }
18700
+ const promises = (keys || Object.keys(ctrl.springs)).map(
18701
+ (key) => ctrl.springs[key].start(props)
18702
+ );
18703
+ const cancel = props.cancel === true || getDefaultProp(props, "cancel") === true;
18704
+ if (asyncTo || cancel && state.asyncId) {
18705
+ promises.push(
18706
+ scheduleProps(++ctrl["_lastAsyncId"], {
18707
+ props,
18708
+ state,
18709
+ actions: {
18710
+ pause: noop,
18711
+ resume: noop,
18712
+ start(props2, resolve) {
18713
+ if (cancel) {
18714
+ stopAsync(state, ctrl["_lastAsyncId"]);
18715
+ resolve(getCancelledResult(ctrl));
18716
+ } else {
18717
+ props2.onRest = onRest;
18718
+ resolve(
18719
+ runAsync(
18720
+ asyncTo,
18721
+ props2,
18722
+ state,
18723
+ ctrl
18724
+ )
18725
+ );
18726
+ }
18727
+ }
18728
+ }
18729
+ })
18730
+ );
18731
+ }
18732
+ if (state.paused) {
18733
+ await new Promise((resume) => {
18734
+ state.resumeQueue.add(resume);
18735
+ });
18736
+ }
18737
+ const result = getCombinedResult(ctrl, await Promise.all(promises));
18738
+ if (loop && result.finished && !(isLoop && result.noop)) {
18739
+ const nextProps = createLoopUpdate(props, loop, to2);
18740
+ if (nextProps) {
18741
+ prepareKeys(ctrl, [nextProps]);
18742
+ return flushUpdate(ctrl, nextProps, true);
18743
+ }
18744
+ }
18745
+ if (onResolve) {
18746
+ raf.batchedUpdates(() => onResolve(result, ctrl, ctrl.item));
18747
+ }
18748
+ return result;
18749
+ }
18750
+ function getSprings(ctrl, props) {
18751
+ const springs = { ...ctrl.springs };
18752
+ if (props) {
18753
+ each(toArray(props), (props2) => {
18754
+ if (is.und(props2.keys)) {
18755
+ props2 = createUpdate(props2);
18756
+ }
18757
+ if (!is.obj(props2.to)) {
18758
+ props2 = { ...props2, to: void 0 };
18759
+ }
18760
+ prepareSprings(springs, props2, (key) => {
18761
+ return createSpring(key);
18762
+ });
18763
+ });
18764
+ }
18765
+ setSprings(ctrl, springs);
18766
+ return springs;
18767
+ }
18768
+ function setSprings(ctrl, springs) {
18769
+ eachProp(springs, (spring, key) => {
18770
+ if (!ctrl.springs[key]) {
18771
+ ctrl.springs[key] = spring;
18772
+ addFluidObserver(spring, ctrl);
18773
+ }
18774
+ });
18775
+ }
18776
+ function createSpring(key, observer) {
18777
+ const spring = new SpringValue();
18778
+ spring.key = key;
18779
+ if (observer) {
18780
+ addFluidObserver(spring, observer);
18781
+ }
18782
+ return spring;
18783
+ }
18784
+ function prepareSprings(springs, props, create) {
18785
+ if (props.keys) {
18786
+ each(props.keys, (key) => {
18787
+ const spring = springs[key] || (springs[key] = create(key));
18788
+ spring["_prepareNode"](props);
18789
+ });
18790
+ }
18791
+ }
18792
+ function prepareKeys(ctrl, queue) {
18793
+ each(queue, (props) => {
18794
+ prepareSprings(ctrl.springs, props, (key) => {
18795
+ return createSpring(key, ctrl);
18796
+ });
18797
+ });
18798
+ }
18799
+ var SpringContext = ({
18800
+ children,
18801
+ ...props
18802
+ }) => {
18803
+ const inherited = React.useContext(ctx);
18804
+ const pause = props.pause || !!inherited.pause, immediate = props.immediate || !!inherited.immediate;
18805
+ props = useMemoOne(() => ({ pause, immediate }), [pause, immediate]);
18806
+ const { Provider } = ctx;
18807
+ return /* @__PURE__ */ React__namespace.createElement(Provider, { value: props }, children);
18808
+ };
18809
+ var ctx = makeContext(SpringContext, {});
18810
+ SpringContext.Provider = ctx.Provider;
18811
+ SpringContext.Consumer = ctx.Consumer;
18812
+ function makeContext(target, init) {
18813
+ Object.assign(target, React__namespace.createContext(init));
18814
+ target.Provider._context = target;
18815
+ target.Consumer._context = target;
18816
+ return target;
18817
+ }
18818
+ var SpringRef = () => {
18819
+ const current = [];
18820
+ const SpringRef2 = function(props) {
18821
+ deprecateDirectCall();
18822
+ const results = [];
18823
+ each(current, (ctrl, i) => {
18824
+ if (is.und(props)) {
18825
+ results.push(ctrl.start());
18826
+ } else {
18827
+ const update2 = _getProps(props, ctrl, i);
18828
+ if (update2) {
18829
+ results.push(ctrl.start(update2));
18830
+ }
18831
+ }
18832
+ });
18833
+ return results;
18834
+ };
18835
+ SpringRef2.current = current;
18836
+ SpringRef2.add = function(ctrl) {
18837
+ if (!current.includes(ctrl)) {
18838
+ current.push(ctrl);
18839
+ }
18840
+ };
18841
+ SpringRef2.delete = function(ctrl) {
18842
+ const i = current.indexOf(ctrl);
18843
+ if (~i)
18844
+ current.splice(i, 1);
18845
+ };
18846
+ SpringRef2.pause = function() {
18847
+ each(current, (ctrl) => ctrl.pause(...arguments));
18848
+ return this;
18849
+ };
18850
+ SpringRef2.resume = function() {
18851
+ each(current, (ctrl) => ctrl.resume(...arguments));
18852
+ return this;
18853
+ };
18854
+ SpringRef2.set = function(values) {
18855
+ each(current, (ctrl, i) => {
18856
+ const update2 = is.fun(values) ? values(i, ctrl) : values;
18857
+ if (update2) {
18858
+ ctrl.set(update2);
18859
+ }
18860
+ });
18861
+ };
18862
+ SpringRef2.start = function(props) {
18863
+ const results = [];
18864
+ each(current, (ctrl, i) => {
18865
+ if (is.und(props)) {
18866
+ results.push(ctrl.start());
18867
+ } else {
18868
+ const update2 = this._getProps(props, ctrl, i);
18869
+ if (update2) {
18870
+ results.push(ctrl.start(update2));
18871
+ }
18872
+ }
18873
+ });
18874
+ return results;
18875
+ };
18876
+ SpringRef2.stop = function() {
18877
+ each(current, (ctrl) => ctrl.stop(...arguments));
18878
+ return this;
18879
+ };
18880
+ SpringRef2.update = function(props) {
18881
+ each(current, (ctrl, i) => ctrl.update(this._getProps(props, ctrl, i)));
18882
+ return this;
18883
+ };
18884
+ const _getProps = function(arg, ctrl, index) {
18885
+ return is.fun(arg) ? arg(index, ctrl) : arg;
18886
+ };
18887
+ SpringRef2._getProps = _getProps;
18888
+ return SpringRef2;
18889
+ };
18890
+
18891
+ // src/hooks/useSprings.ts
18892
+ function useSprings(length, props, deps) {
18893
+ const propsFn = is.fun(props) && props;
18894
+ if (propsFn && !deps)
18895
+ deps = [];
18896
+ const ref = React.useMemo(
18897
+ () => propsFn || arguments.length == 3 ? SpringRef() : void 0,
18898
+ []
18899
+ );
18900
+ const layoutId = React.useRef(0);
18901
+ const forceUpdate = useForceUpdate();
18902
+ const state = React.useMemo(
18903
+ () => ({
18904
+ ctrls: [],
18905
+ queue: [],
18906
+ flush(ctrl, updates2) {
18907
+ const springs2 = getSprings(ctrl, updates2);
18908
+ const canFlushSync = layoutId.current > 0 && !state.queue.length && !Object.keys(springs2).some((key) => !ctrl.springs[key]);
18909
+ return canFlushSync ? flushUpdateQueue(ctrl, updates2) : new Promise((resolve) => {
18910
+ setSprings(ctrl, springs2);
18911
+ state.queue.push(() => {
18912
+ resolve(flushUpdateQueue(ctrl, updates2));
18913
+ });
18914
+ forceUpdate();
18915
+ });
18916
+ }
18917
+ }),
18918
+ []
18919
+ );
18920
+ const ctrls = React.useRef([...state.ctrls]);
18921
+ const updates = [];
18922
+ const prevLength = usePrev(length) || 0;
18923
+ React.useMemo(() => {
18924
+ each(ctrls.current.slice(length, prevLength), (ctrl) => {
18925
+ detachRefs(ctrl, ref);
18926
+ ctrl.stop(true);
18927
+ });
18928
+ ctrls.current.length = length;
18929
+ declareUpdates(prevLength, length);
18930
+ }, [length]);
18931
+ React.useMemo(() => {
18932
+ declareUpdates(0, Math.min(prevLength, length));
18933
+ }, deps);
18934
+ function declareUpdates(startIndex, endIndex) {
18935
+ for (let i = startIndex; i < endIndex; i++) {
18936
+ const ctrl = ctrls.current[i] || (ctrls.current[i] = new Controller(null, state.flush));
18937
+ const update2 = propsFn ? propsFn(i, ctrl) : props[i];
18938
+ if (update2) {
18939
+ updates[i] = declareUpdate(update2);
18940
+ }
18941
+ }
18942
+ }
18943
+ const springs = ctrls.current.map((ctrl, i) => getSprings(ctrl, updates[i]));
18944
+ const context = React.useContext(SpringContext);
18945
+ const prevContext = usePrev(context);
18946
+ const hasContext = context !== prevContext && hasProps(context);
18947
+ useIsomorphicLayoutEffect(() => {
18948
+ layoutId.current++;
18949
+ state.ctrls = ctrls.current;
18950
+ const { queue } = state;
18951
+ if (queue.length) {
18952
+ state.queue = [];
18953
+ each(queue, (cb) => cb());
18954
+ }
18955
+ each(ctrls.current, (ctrl, i) => {
18956
+ ref?.add(ctrl);
18957
+ if (hasContext) {
18958
+ ctrl.start({ default: context });
18959
+ }
18960
+ const update2 = updates[i];
18961
+ if (update2) {
18962
+ replaceRef(ctrl, update2.ref);
18963
+ if (ctrl.ref) {
18964
+ ctrl.queue.push(update2);
18965
+ } else {
18966
+ ctrl.start(update2);
18967
+ }
18968
+ }
18969
+ });
18970
+ });
18971
+ useOnce(() => () => {
18972
+ each(state.ctrls, (ctrl) => ctrl.stop(true));
18973
+ });
18974
+ const values = springs.map((x) => ({ ...x }));
18975
+ return ref ? [values, ref] : values;
18976
+ }
18977
+
18978
+ // src/hooks/useSpring.ts
18979
+ function useSpring(props, deps) {
18980
+ const isFn = is.fun(props);
18981
+ const [[values], ref] = useSprings(
18982
+ 1,
18983
+ isFn ? props : [props],
18984
+ isFn ? deps || [] : deps
18985
+ );
18986
+ return isFn || arguments.length == 2 ? [values, ref] : values;
18987
+ }
18988
+ var Interpolation = class extends FrameValue {
18989
+ constructor(source, args) {
18990
+ super();
18991
+ this.source = source;
18992
+ /** Equals false when in the frameloop */
18993
+ this.idle = true;
18994
+ /** The inputs which are currently animating */
18995
+ this._active = /* @__PURE__ */ new Set();
18996
+ this.calc = createInterpolator(...args);
18997
+ const value = this._get();
18998
+ const nodeType = getAnimatedType(value);
18999
+ setAnimated(this, nodeType.create(value));
19000
+ }
19001
+ advance(_dt) {
19002
+ const value = this._get();
19003
+ const oldValue = this.get();
19004
+ if (!isEqual(value, oldValue)) {
19005
+ getAnimated(this).setValue(value);
19006
+ this._onChange(value, this.idle);
19007
+ }
19008
+ if (!this.idle && checkIdle(this._active)) {
19009
+ becomeIdle(this);
19010
+ }
19011
+ }
19012
+ _get() {
19013
+ const inputs = is.arr(this.source) ? this.source.map(getFluidValue) : toArray(getFluidValue(this.source));
19014
+ return this.calc(...inputs);
19015
+ }
19016
+ _start() {
19017
+ if (this.idle && !checkIdle(this._active)) {
19018
+ this.idle = false;
19019
+ each(getPayload(this), (node) => {
19020
+ node.done = false;
19021
+ });
19022
+ if (globals_exports.skipAnimation) {
19023
+ raf.batchedUpdates(() => this.advance());
19024
+ becomeIdle(this);
19025
+ } else {
19026
+ frameLoop.start(this);
19027
+ }
19028
+ }
19029
+ }
19030
+ // Observe our sources only when we're observed.
19031
+ _attach() {
19032
+ let priority = 1;
19033
+ each(toArray(this.source), (source) => {
19034
+ if (hasFluidValue(source)) {
19035
+ addFluidObserver(source, this);
19036
+ }
19037
+ if (isFrameValue(source)) {
19038
+ if (!source.idle) {
19039
+ this._active.add(source);
19040
+ }
19041
+ priority = Math.max(priority, source.priority + 1);
19042
+ }
19043
+ });
19044
+ this.priority = priority;
19045
+ this._start();
19046
+ }
19047
+ // Stop observing our sources once we have no observers.
19048
+ _detach() {
19049
+ each(toArray(this.source), (source) => {
19050
+ if (hasFluidValue(source)) {
19051
+ removeFluidObserver(source, this);
19052
+ }
19053
+ });
19054
+ this._active.clear();
19055
+ becomeIdle(this);
19056
+ }
19057
+ /** @internal */
19058
+ eventObserved(event) {
19059
+ if (event.type == "change") {
19060
+ if (event.idle) {
19061
+ this.advance();
19062
+ } else {
19063
+ this._active.add(event.parent);
19064
+ this._start();
19065
+ }
19066
+ } else if (event.type == "idle") {
19067
+ this._active.delete(event.parent);
19068
+ } else if (event.type == "priority") {
19069
+ this.priority = toArray(this.source).reduce(
19070
+ (highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1),
19071
+ 0
19072
+ );
19073
+ }
19074
+ }
19075
+ };
19076
+ function isIdle(source) {
19077
+ return source.idle !== false;
19078
+ }
19079
+ function checkIdle(active) {
19080
+ return !active.size || Array.from(active).every(isIdle);
19081
+ }
19082
+ function becomeIdle(self) {
19083
+ if (!self.idle) {
19084
+ self.idle = true;
19085
+ each(getPayload(self), (node) => {
19086
+ node.done = true;
19087
+ });
19088
+ callFluidObservers(self, {
19089
+ type: "idle",
19090
+ parent: self
19091
+ });
19092
+ }
19093
+ }
19094
+ globals_exports.assign({
19095
+ createStringInterpolator: createStringInterpolator2,
19096
+ to: (source, args) => new Interpolation(source, args)
19097
+ });
19098
+
19099
+ // src/index.ts
19100
+
19101
+ // src/applyAnimatedValues.ts
19102
+ var isCustomPropRE = /^--/;
19103
+ function dangerousStyleValue(name, value) {
19104
+ if (value == null || typeof value === "boolean" || value === "")
19105
+ return "";
19106
+ if (typeof value === "number" && value !== 0 && !isCustomPropRE.test(name) && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]))
19107
+ return value + "px";
19108
+ return ("" + value).trim();
19109
+ }
19110
+ var attributeCache = {};
19111
+ function applyAnimatedValues(instance, props) {
19112
+ if (!instance.nodeType || !instance.setAttribute) {
19113
+ return false;
19114
+ }
19115
+ const isFilterElement = instance.nodeName === "filter" || instance.parentNode && instance.parentNode.nodeName === "filter";
19116
+ const {
19117
+ className,
19118
+ style,
19119
+ children,
19120
+ scrollTop,
19121
+ scrollLeft,
19122
+ viewBox,
19123
+ ...attributes
19124
+ } = props;
19125
+ const values = Object.values(attributes);
19126
+ const names = Object.keys(attributes).map(
19127
+ (name) => isFilterElement || instance.hasAttribute(name) ? name : attributeCache[name] || (attributeCache[name] = name.replace(
19128
+ /([A-Z])/g,
19129
+ // Attributes are written in dash case
19130
+ (n) => "-" + n.toLowerCase()
19131
+ ))
19132
+ );
19133
+ if (children !== void 0) {
19134
+ instance.textContent = children;
19135
+ }
19136
+ for (const name in style) {
19137
+ if (style.hasOwnProperty(name)) {
19138
+ const value = dangerousStyleValue(name, style[name]);
19139
+ if (isCustomPropRE.test(name)) {
19140
+ instance.style.setProperty(name, value);
19141
+ } else {
19142
+ instance.style[name] = value;
19143
+ }
19144
+ }
19145
+ }
19146
+ names.forEach((name, i) => {
19147
+ instance.setAttribute(name, values[i]);
19148
+ });
19149
+ if (className !== void 0) {
19150
+ instance.className = className;
19151
+ }
19152
+ if (scrollTop !== void 0) {
19153
+ instance.scrollTop = scrollTop;
19154
+ }
19155
+ if (scrollLeft !== void 0) {
19156
+ instance.scrollLeft = scrollLeft;
19157
+ }
19158
+ if (viewBox !== void 0) {
19159
+ instance.setAttribute("viewBox", viewBox);
19160
+ }
19161
+ }
19162
+ var isUnitlessNumber = {
19163
+ animationIterationCount: true,
19164
+ borderImageOutset: true,
19165
+ borderImageSlice: true,
19166
+ borderImageWidth: true,
19167
+ boxFlex: true,
19168
+ boxFlexGroup: true,
19169
+ boxOrdinalGroup: true,
19170
+ columnCount: true,
19171
+ columns: true,
19172
+ flex: true,
19173
+ flexGrow: true,
19174
+ flexPositive: true,
19175
+ flexShrink: true,
19176
+ flexNegative: true,
19177
+ flexOrder: true,
19178
+ gridRow: true,
19179
+ gridRowEnd: true,
19180
+ gridRowSpan: true,
19181
+ gridRowStart: true,
19182
+ gridColumn: true,
19183
+ gridColumnEnd: true,
19184
+ gridColumnSpan: true,
19185
+ gridColumnStart: true,
19186
+ fontWeight: true,
19187
+ lineClamp: true,
19188
+ lineHeight: true,
19189
+ opacity: true,
19190
+ order: true,
19191
+ orphans: true,
19192
+ tabSize: true,
19193
+ widows: true,
19194
+ zIndex: true,
19195
+ zoom: true,
19196
+ // SVG-related properties
19197
+ fillOpacity: true,
19198
+ floodOpacity: true,
19199
+ stopOpacity: true,
19200
+ strokeDasharray: true,
19201
+ strokeDashoffset: true,
19202
+ strokeMiterlimit: true,
19203
+ strokeOpacity: true,
19204
+ strokeWidth: true
19205
+ };
19206
+ var prefixKey = (prefix, key) => prefix + key.charAt(0).toUpperCase() + key.substring(1);
19207
+ var prefixes = ["Webkit", "Ms", "Moz", "O"];
19208
+ isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => {
19209
+ prefixes.forEach((prefix) => acc[prefixKey(prefix, prop)] = acc[prop]);
19210
+ return acc;
19211
+ }, isUnitlessNumber);
19212
+ var domTransforms = /^(matrix|translate|scale|rotate|skew)/;
19213
+ var pxTransforms = /^(translate)/;
19214
+ var degTransforms = /^(rotate|skew)/;
19215
+ var addUnit = (value, unit) => is.num(value) && value !== 0 ? value + unit : value;
19216
+ var isValueIdentity = (value, id) => is.arr(value) ? value.every((v) => isValueIdentity(v, id)) : is.num(value) ? value === id : parseFloat(value) === id;
19217
+ var AnimatedStyle = class extends AnimatedObject {
19218
+ constructor({ x, y, z, ...style }) {
19219
+ const inputs = [];
19220
+ const transforms = [];
19221
+ if (x || y || z) {
19222
+ inputs.push([x || 0, y || 0, z || 0]);
19223
+ transforms.push((xyz) => [
19224
+ `translate3d(${xyz.map((v) => addUnit(v, "px")).join(",")})`,
19225
+ // prettier-ignore
19226
+ isValueIdentity(xyz, 0)
19227
+ ]);
19228
+ }
19229
+ eachProp(style, (value, key) => {
19230
+ if (key === "transform") {
19231
+ inputs.push([value || ""]);
19232
+ transforms.push((transform) => [transform, transform === ""]);
19233
+ } else if (domTransforms.test(key)) {
19234
+ delete style[key];
19235
+ if (is.und(value))
19236
+ return;
19237
+ const unit = pxTransforms.test(key) ? "px" : degTransforms.test(key) ? "deg" : "";
19238
+ inputs.push(toArray(value));
19239
+ transforms.push(
19240
+ key === "rotate3d" ? ([x2, y2, z2, deg]) => [
19241
+ `rotate3d(${x2},${y2},${z2},${addUnit(deg, unit)})`,
19242
+ isValueIdentity(deg, 0)
19243
+ ] : (input) => [
19244
+ `${key}(${input.map((v) => addUnit(v, unit)).join(",")})`,
19245
+ isValueIdentity(input, key.startsWith("scale") ? 1 : 0)
19246
+ ]
19247
+ );
19248
+ }
19249
+ });
19250
+ if (inputs.length) {
19251
+ style.transform = new FluidTransform(inputs, transforms);
19252
+ }
19253
+ super(style);
19254
+ }
19255
+ };
19256
+ var FluidTransform = class extends FluidValue {
19257
+ constructor(inputs, transforms) {
19258
+ super();
19259
+ this.inputs = inputs;
19260
+ this.transforms = transforms;
19261
+ this._value = null;
19262
+ }
19263
+ get() {
19264
+ return this._value || (this._value = this._get());
19265
+ }
19266
+ _get() {
19267
+ let transform = "";
19268
+ let identity = true;
19269
+ each(this.inputs, (input, i) => {
19270
+ const arg1 = getFluidValue(input[0]);
19271
+ const [t, id] = this.transforms[i](
19272
+ is.arr(arg1) ? arg1 : input.map(getFluidValue)
19273
+ );
19274
+ transform += " " + t;
19275
+ identity = identity && id;
19276
+ });
19277
+ return identity ? "none" : transform;
19278
+ }
19279
+ // Start observing our inputs once we have an observer.
19280
+ observerAdded(count) {
19281
+ if (count == 1)
19282
+ each(
19283
+ this.inputs,
19284
+ (input) => each(
19285
+ input,
19286
+ (value) => hasFluidValue(value) && addFluidObserver(value, this)
19287
+ )
19288
+ );
19289
+ }
19290
+ // Stop observing our inputs once we have no observers.
19291
+ observerRemoved(count) {
19292
+ if (count == 0)
19293
+ each(
19294
+ this.inputs,
19295
+ (input) => each(
19296
+ input,
19297
+ (value) => hasFluidValue(value) && removeFluidObserver(value, this)
19298
+ )
19299
+ );
19300
+ }
19301
+ eventObserved(event) {
19302
+ if (event.type == "change") {
19303
+ this._value = null;
19304
+ }
19305
+ callFluidObservers(this, event);
19306
+ }
19307
+ };
19308
+
19309
+ // src/primitives.ts
19310
+ var primitives = [
19311
+ "a",
19312
+ "abbr",
19313
+ "address",
19314
+ "area",
19315
+ "article",
19316
+ "aside",
19317
+ "audio",
19318
+ "b",
19319
+ "base",
19320
+ "bdi",
19321
+ "bdo",
19322
+ "big",
19323
+ "blockquote",
19324
+ "body",
19325
+ "br",
19326
+ "button",
19327
+ "canvas",
19328
+ "caption",
19329
+ "cite",
19330
+ "code",
19331
+ "col",
19332
+ "colgroup",
19333
+ "data",
19334
+ "datalist",
19335
+ "dd",
19336
+ "del",
19337
+ "details",
19338
+ "dfn",
19339
+ "dialog",
19340
+ "div",
19341
+ "dl",
19342
+ "dt",
19343
+ "em",
19344
+ "embed",
19345
+ "fieldset",
19346
+ "figcaption",
19347
+ "figure",
19348
+ "footer",
19349
+ "form",
19350
+ "h1",
19351
+ "h2",
19352
+ "h3",
19353
+ "h4",
19354
+ "h5",
19355
+ "h6",
19356
+ "head",
19357
+ "header",
19358
+ "hgroup",
19359
+ "hr",
19360
+ "html",
19361
+ "i",
19362
+ "iframe",
19363
+ "img",
19364
+ "input",
19365
+ "ins",
19366
+ "kbd",
19367
+ "keygen",
19368
+ "label",
19369
+ "legend",
19370
+ "li",
19371
+ "link",
19372
+ "main",
19373
+ "map",
19374
+ "mark",
19375
+ "menu",
19376
+ "menuitem",
19377
+ "meta",
19378
+ "meter",
19379
+ "nav",
19380
+ "noscript",
19381
+ "object",
19382
+ "ol",
19383
+ "optgroup",
19384
+ "option",
19385
+ "output",
19386
+ "p",
19387
+ "param",
19388
+ "picture",
19389
+ "pre",
19390
+ "progress",
19391
+ "q",
19392
+ "rp",
19393
+ "rt",
19394
+ "ruby",
19395
+ "s",
19396
+ "samp",
19397
+ "script",
19398
+ "section",
19399
+ "select",
19400
+ "small",
19401
+ "source",
19402
+ "span",
19403
+ "strong",
19404
+ "style",
19405
+ "sub",
19406
+ "summary",
19407
+ "sup",
19408
+ "table",
19409
+ "tbody",
19410
+ "td",
19411
+ "textarea",
19412
+ "tfoot",
19413
+ "th",
19414
+ "thead",
19415
+ "time",
19416
+ "title",
19417
+ "tr",
19418
+ "track",
19419
+ "u",
19420
+ "ul",
19421
+ "var",
19422
+ "video",
19423
+ "wbr",
19424
+ // SVG
19425
+ "circle",
19426
+ "clipPath",
19427
+ "defs",
19428
+ "ellipse",
19429
+ "foreignObject",
19430
+ "g",
19431
+ "image",
19432
+ "line",
19433
+ "linearGradient",
19434
+ "mask",
19435
+ "path",
19436
+ "pattern",
19437
+ "polygon",
19438
+ "polyline",
19439
+ "radialGradient",
19440
+ "rect",
19441
+ "stop",
19442
+ "svg",
19443
+ "text",
19444
+ "tspan"
19445
+ ];
19446
+ globals_exports.assign({
19447
+ batchedUpdates: ReactDOM.unstable_batchedUpdates,
19448
+ createStringInterpolator: createStringInterpolator2,
19449
+ colors: colors2
19450
+ });
19451
+ var host = createHost(primitives, {
19452
+ applyAnimatedValues,
19453
+ createAnimatedStyle: (style) => new AnimatedStyle(style),
19454
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
19455
+ getComponentProps: ({ scrollTop, scrollLeft, ...props }) => props
19456
+ });
19457
+ var animated = host.animated;
19458
+
19459
+ const Collapse = ({ isVisible, children }) => {
19460
+ const contentRef = React.useRef(null);
19461
+ const [contentHeight, setContentHeight] = React.useState(contentRef.current?.scrollHeight);
19462
+ React.useEffect(() => {
19463
+ if (contentRef.current) {
19464
+ setContentHeight(contentRef.current?.scrollHeight ?? 0);
19465
+ }
19466
+ }, [children]);
19467
+ const styles = useSpring({
19468
+ opacity: isVisible ? 1 : 0,
19469
+ height: isVisible ? contentHeight : 0,
19470
+ });
19471
+ return React.createElement(animated.div, { style: styles }, isVisible ? React.createElement("div", { ref: contentRef }, children) : undefined);
19472
+ };
19473
+
15974
19474
  // packages/core/number/src/number.ts
15975
19475
  function clamp(value, [min, max]) {
15976
19476
  return Math.min(max, Math.max(min, value));
@@ -17139,7 +20639,7 @@ var Progress = React__namespace.forwardRef(
17139
20639
  );
17140
20640
  Progress.displayName = PROGRESS_NAME;
17141
20641
  var INDICATOR_NAME = "ProgressIndicator";
17142
- var ProgressIndicator = React__namespace.forwardRef(
20642
+ var ProgressIndicator$1 = React__namespace.forwardRef(
17143
20643
  (props, forwardedRef) => {
17144
20644
  const { __scopeProgress, ...indicatorProps } = props;
17145
20645
  const context = useProgressContext(INDICATOR_NAME, __scopeProgress);
@@ -17155,7 +20655,7 @@ var ProgressIndicator = React__namespace.forwardRef(
17155
20655
  );
17156
20656
  }
17157
20657
  );
17158
- ProgressIndicator.displayName = INDICATOR_NAME;
20658
+ ProgressIndicator$1.displayName = INDICATOR_NAME;
17159
20659
  function defaultGetValueLabel(value, max) {
17160
20660
  return `${Math.round(value / max * 100)}%`;
17161
20661
  }
@@ -17183,16 +20683,31 @@ function getInvalidValueError(propValue, componentName) {
17183
20683
  Defaulting to \`null\`.`;
17184
20684
  }
17185
20685
  var Root = Progress;
17186
- var Indicator = ProgressIndicator;
20686
+ var Indicator = ProgressIndicator$1;
17187
20687
 
20688
+ const ProgressIndicator = (props) => {
20689
+ const { value, color = undefined, testId, label, extraClasses = '', labelClasses = '', valuesLength, max, index, ...tooltipProps } = props;
20690
+ const tooltipData = getQTipData(tooltipProps);
20691
+ const previousWidth = React.useRef(0);
20692
+ const [animatedWidth, setAnimatedWidth] = React.useState(previousWidth.current);
20693
+ React.useEffect(() => {
20694
+ const timeout = setTimeout(() => {
20695
+ const newWidth = (Number(value) / Number(max)) * 100;
20696
+ setAnimatedWidth(newWidth);
20697
+ previousWidth.current = newWidth;
20698
+ }, 100);
20699
+ return () => clearTimeout(timeout);
20700
+ }, [value]);
20701
+ return (React.createElement(Indicator, { className: `tw-ease-[cubic-bezier(0.65, 0, 0.35, 1)] tw-w-full tw-h-full tw-duration-[660ms] tw-flex tw-bg-sq-color-dark ${extraClasses}`, ...tooltipData, "data-qtip-text": tooltipProps.tooltip ? tooltipProps.tooltip : `${value}%`, "data-testid": `progress-bar-indicator-${testId ? testId : value}`, key: `${index}-${value}`, style: {
20702
+ // Background color will default to the theme color if undefined
20703
+ backgroundColor: color ? color : undefined,
20704
+ animation: 'width 660ms forwards',
20705
+ width: `${animatedWidth}%`,
20706
+ } }, label ? (React.createElement("span", { className: `tw-left-1 tw-text-xs tw-text-sq-text-color dark:tw-text-sq-dark-text tw-items-center ${labelClasses}` }, label)) : undefined));
20707
+ };
17188
20708
  const ProgressBar = ({ values = [], max = 100, containerExtraClasses = '', }) => {
17189
- return (React.createElement(Root, { className: `tw-relative tw-h-[18px] tw-w-full tw-overflow-hidden tw-rounded-[2.5px] tw-bg-sq-dark-gray dark:tw-bg-sq-dark-disabled-gray tw-flex tw-flex-1 ${containerExtraClasses}`, max: max, value: values.reduce((acc, { value }) => acc + value, 0) }, values.map(({ value, color = undefined, testId, label, extraClasses = '', labelClasses = '', ...tooltipProps }, i) => {
17190
- const tooltipData = getQTipData(tooltipProps);
17191
- return (React.createElement(Indicator, { className: `tw-ease-[cubic-bezier(0.65, 0, 0.35, 1)] tw-w-full tw-h-full tw-duration-[660ms] tw-flex tw-bg-sq-color-dark ${extraClasses}`, ...tooltipData, "data-qtip-text": tooltipProps.tooltip ? tooltipProps.tooltip : `${value}%`, "data-testid": `progress-bar-indicator-${testId ? testId : value}`, key: `${i}-${value}`, style: {
17192
- // Background color will default to the theme color if undefined
17193
- backgroundColor: values.length === 1 ? undefined : color,
17194
- width: `${(Number(value) / Number(max)) * 100}%`,
17195
- } }, label ? (React.createElement("span", { className: `tw-left-1 tw-text-xs tw-text-sq-text-color dark:tw-text-sq-dark-text tw-items-center ${labelClasses}` }, label)) : undefined));
20709
+ return (React.createElement(Root, { className: `tw-relative tw-h-[18px] tw-w-full tw-overflow-hidden tw-rounded-[2.5px] tw-bg-sq-dark-gray dark:tw-bg-sq-dark-disabled-gray tw-flex tw-flex-1 ${containerExtraClasses}`, max: max, value: values.reduce((acc, { value }) => acc + value, 0) }, values.map((props, i) => {
20710
+ return React.createElement(ProgressIndicator, { ...props, max: max, valuesLength: values.length, index: i, key: i });
17196
20711
  })));
17197
20712
  };
17198
20713
 
@@ -17202,6 +20717,7 @@ exports.Button = Button;
17202
20717
  exports.ButtonWithDropdown = ButtonWithDropdown;
17203
20718
  exports.ButtonWithPopover = ButtonWithPopover;
17204
20719
  exports.Checkbox = Checkbox;
20720
+ exports.Collapse = Collapse;
17205
20721
  exports.Icon = Icon;
17206
20722
  exports.InputGroup = InputGroup;
17207
20723
  exports.Modal = Modal;