@kumix/ui 0.4.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/README.md +15 -13
  2. package/dist/components/agents/agent-activity/index.js +1 -1
  3. package/dist/components/agents/approval-card/index.js +2 -3
  4. package/dist/components/agents/approval-card/index.js.map +1 -1
  5. package/dist/components/agents/prompt-input.js +1 -2
  6. package/dist/components/agents/prompt-input.js.map +1 -1
  7. package/dist/components/agents/todo-list.js +1 -1
  8. package/dist/components/agents/tool-result.js +1 -1
  9. package/dist/components/charts/bar-chart/context.d.ts +114 -0
  10. package/dist/components/charts/bar-chart/context.d.ts.map +1 -0
  11. package/dist/components/charts/bar-chart/context.js +60 -0
  12. package/dist/components/charts/bar-chart/context.js.map +1 -0
  13. package/dist/components/charts/bar-chart/legend.d.ts +6 -0
  14. package/dist/components/charts/bar-chart/legend.d.ts.map +1 -0
  15. package/dist/components/charts/bar-chart/legend.js +21 -0
  16. package/dist/components/charts/bar-chart/legend.js.map +1 -0
  17. package/dist/components/charts/bar-chart/plot.d.ts +10 -0
  18. package/dist/components/charts/bar-chart/plot.d.ts.map +1 -0
  19. package/dist/components/charts/bar-chart/plot.js +290 -0
  20. package/dist/components/charts/bar-chart/plot.js.map +1 -0
  21. package/dist/components/charts/bar-chart/tooltip.d.ts +20 -0
  22. package/dist/components/charts/bar-chart/tooltip.d.ts.map +1 -0
  23. package/dist/components/charts/bar-chart/tooltip.js +57 -0
  24. package/dist/components/charts/bar-chart/tooltip.js.map +1 -0
  25. package/dist/components/charts/bar-chart.d.ts +9 -0
  26. package/dist/components/charts/bar-chart.d.ts.map +1 -0
  27. package/dist/components/charts/bar-chart.js +51 -0
  28. package/dist/components/charts/bar-chart.js.map +1 -0
  29. package/dist/components/charts/bump-chart/plot.js +1 -1
  30. package/dist/components/charts/bump-chart/point.js +1 -1
  31. package/dist/components/charts/bump-chart.js +1 -1
  32. package/dist/components/charts/composition-chart/plot.js +5 -1
  33. package/dist/components/charts/composition-chart/plot.js.map +1 -1
  34. package/dist/components/charts/composition-chart/tooltip-content.js +1 -1
  35. package/dist/components/charts/donut-chart.d.ts +1 -1
  36. package/dist/components/charts/donut-chart.js +1 -1
  37. package/dist/components/charts/funnel-chart.js +1 -1
  38. package/dist/components/charts/heat-calendar/tooltip.js +1 -1
  39. package/dist/components/charts/line-chart/context.d.ts +154 -0
  40. package/dist/components/charts/line-chart/context.d.ts.map +1 -0
  41. package/dist/components/charts/line-chart/context.js +67 -0
  42. package/dist/components/charts/line-chart/context.js.map +1 -0
  43. package/dist/components/charts/line-chart/legend.d.ts +6 -0
  44. package/dist/components/charts/line-chart/legend.d.ts.map +1 -0
  45. package/dist/components/charts/line-chart/legend.js +21 -0
  46. package/dist/components/charts/line-chart/legend.js.map +1 -0
  47. package/dist/components/charts/line-chart/plot.d.ts +12 -0
  48. package/dist/components/charts/line-chart/plot.d.ts.map +1 -0
  49. package/dist/components/charts/line-chart/plot.js +604 -0
  50. package/dist/components/charts/line-chart/plot.js.map +1 -0
  51. package/dist/components/charts/line-chart/tooltip.d.ts +22 -0
  52. package/dist/components/charts/line-chart/tooltip.d.ts.map +1 -0
  53. package/dist/components/charts/line-chart/tooltip.js +108 -0
  54. package/dist/components/charts/line-chart/tooltip.js.map +1 -0
  55. package/dist/components/charts/line-chart.d.ts +10 -0
  56. package/dist/components/charts/line-chart.d.ts.map +1 -0
  57. package/dist/components/charts/line-chart.js +53 -0
  58. package/dist/components/charts/line-chart.js.map +1 -0
  59. package/dist/components/charts/liquidity-heatmap.js +1 -1
  60. package/dist/components/charts/price-target-fan.js +1 -1
  61. package/dist/components/charts/returns-calendar/tooltip.js +1 -1
  62. package/dist/components/charts/returns-calendar.d.ts.map +1 -1
  63. package/dist/components/charts/sankey-chart/context.d.ts +2 -0
  64. package/dist/components/charts/sankey-chart/context.js +2 -0
  65. package/dist/components/charts/sankey-chart/plot.d.ts +8 -0
  66. package/dist/components/charts/sankey-chart/plot.d.ts.map +1 -0
  67. package/dist/components/charts/sankey-chart/plot.js +342 -0
  68. package/dist/components/charts/sankey-chart/plot.js.map +1 -0
  69. package/dist/components/charts/sankey-chart/tooltip.d.ts +10 -0
  70. package/dist/components/charts/sankey-chart/tooltip.d.ts.map +1 -0
  71. package/dist/components/charts/sankey-chart/tooltip.js +147 -0
  72. package/dist/components/charts/sankey-chart/tooltip.js.map +1 -0
  73. package/dist/components/charts/sankey-chart.d.ts +17 -0
  74. package/dist/components/charts/sankey-chart.d.ts.map +1 -0
  75. package/dist/components/charts/sankey-chart.js +76 -0
  76. package/dist/components/charts/sankey-chart.js.map +1 -0
  77. package/dist/components/charts/sparkline.d.ts +26 -0
  78. package/dist/components/charts/sparkline.d.ts.map +1 -0
  79. package/dist/components/charts/sparkline.js +197 -0
  80. package/dist/components/charts/sparkline.js.map +1 -0
  81. package/dist/components/charts/treemap/tooltip.js +1 -1
  82. package/dist/components/charts/treemap.d.ts.map +1 -1
  83. package/dist/components/charts/volume-profile/tooltip.js +1 -1
  84. package/dist/components/charts/xy/axis.d.ts +24 -0
  85. package/dist/components/charts/xy/axis.d.ts.map +1 -0
  86. package/dist/components/charts/xy/axis.js +90 -0
  87. package/dist/components/charts/xy/axis.js.map +1 -0
  88. package/dist/components/charts/xy/data-table.d.ts +9 -0
  89. package/dist/components/charts/xy/data-table.d.ts.map +1 -0
  90. package/dist/components/charts/xy/data-table.js +29 -0
  91. package/dist/components/charts/xy/data-table.js.map +1 -0
  92. package/dist/components/charts/xy/inspector.d.ts +27 -0
  93. package/dist/components/charts/xy/inspector.d.ts.map +1 -0
  94. package/dist/components/charts/xy/inspector.js +110 -0
  95. package/dist/components/charts/xy/inspector.js.map +1 -0
  96. package/dist/components/charts/xy/legend.d.ts +13 -0
  97. package/dist/components/charts/xy/legend.d.ts.map +1 -0
  98. package/dist/components/charts/xy/legend.js +42 -0
  99. package/dist/components/charts/xy/legend.js.map +1 -0
  100. package/dist/components/charts/xy/tooltip-content.d.ts +2 -0
  101. package/dist/components/charts/xy/tooltip-content.js +66 -0
  102. package/dist/components/charts/xy/tooltip-content.js.map +1 -0
  103. package/dist/components/motion/attachment-upload.js +1 -1
  104. package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
  105. package/dist/components/motion/availability-scheduler/day-row.js +2 -2
  106. package/dist/components/motion/availability-scheduler/index.js +1 -1
  107. package/dist/components/motion/avatar-group.d.ts +48 -0
  108. package/dist/components/motion/avatar-group.d.ts.map +1 -0
  109. package/dist/components/motion/avatar-group.js +196 -0
  110. package/dist/components/motion/avatar-group.js.map +1 -0
  111. package/dist/components/motion/bottom-sheet.js +1 -1
  112. package/dist/components/motion/bouncy-accordion.d.ts.map +1 -1
  113. package/dist/components/motion/bouncy-accordion.js +20 -34
  114. package/dist/components/motion/bouncy-accordion.js.map +1 -1
  115. package/dist/components/motion/breadcrumb.js +0 -3
  116. package/dist/components/motion/breadcrumb.js.map +1 -1
  117. package/dist/components/motion/button/magnetic.js +1 -1
  118. package/dist/components/motion/card-dealer.d.ts +36 -0
  119. package/dist/components/motion/card-dealer.d.ts.map +1 -0
  120. package/dist/components/motion/card-dealer.js +232 -0
  121. package/dist/components/motion/card-dealer.js.map +1 -0
  122. package/dist/components/motion/color-picker.js +1 -1
  123. package/dist/components/motion/combobox.js +1 -1
  124. package/dist/components/motion/context-menu.js +1 -1
  125. package/dist/components/motion/crash/crash-balloon.d.ts +9 -0
  126. package/dist/components/motion/crash/crash-balloon.d.ts.map +1 -0
  127. package/dist/components/motion/crash/crash-balloon.js +829 -0
  128. package/dist/components/motion/crash/crash-balloon.js.map +1 -0
  129. package/dist/components/motion/crash/crash-parts.d.ts +59 -0
  130. package/dist/components/motion/crash/crash-parts.d.ts.map +1 -0
  131. package/dist/components/motion/crash/crash-parts.js +2 -0
  132. package/dist/components/motion/crash/crash-tower.d.ts +9 -0
  133. package/dist/components/motion/crash/crash-tower.d.ts.map +1 -0
  134. package/dist/components/motion/crash/crash-tower.js +370 -0
  135. package/dist/components/motion/crash/crash-tower.js.map +1 -0
  136. package/dist/components/motion/crash.d.ts +9 -0
  137. package/dist/components/motion/crash.d.ts.map +1 -0
  138. package/dist/components/motion/crash.js +590 -0
  139. package/dist/components/motion/crash.js.map +1 -0
  140. package/dist/components/motion/date-range-picker.js +1 -1
  141. package/dist/components/motion/feedback-widget.js +0 -1
  142. package/dist/components/motion/feedback-widget.js.map +1 -1
  143. package/dist/components/motion/hold-action-button.js +1 -1
  144. package/dist/components/motion/liquid.js +2 -2
  145. package/dist/components/motion/liquid.js.map +1 -1
  146. package/dist/components/motion/loader.js +5 -4
  147. package/dist/components/motion/loader.js.map +1 -1
  148. package/dist/components/motion/mines.d.ts +41 -0
  149. package/dist/components/motion/mines.d.ts.map +1 -0
  150. package/dist/components/motion/mines.js +762 -0
  151. package/dist/components/motion/mines.js.map +1 -0
  152. package/dist/components/motion/morphing-modal.js +6 -4
  153. package/dist/components/motion/morphing-modal.js.map +1 -1
  154. package/dist/components/motion/morphing-tabs.js +1 -1
  155. package/dist/components/motion/multi-select/index.js +1 -1
  156. package/dist/components/motion/pagination.d.ts +31 -0
  157. package/dist/components/motion/pagination.d.ts.map +1 -0
  158. package/dist/components/motion/pagination.js +193 -0
  159. package/dist/components/motion/pagination.js.map +1 -0
  160. package/dist/components/motion/plinko.d.ts +59 -0
  161. package/dist/components/motion/plinko.d.ts.map +1 -0
  162. package/dist/components/motion/plinko.js +385 -0
  163. package/dist/components/motion/plinko.js.map +1 -0
  164. package/dist/components/motion/popover-morph.d.ts +11 -2
  165. package/dist/components/motion/popover-morph.d.ts.map +1 -1
  166. package/dist/components/motion/popover-morph.js +98 -4
  167. package/dist/components/motion/popover-morph.js.map +1 -1
  168. package/dist/components/motion/pull-to-refresh.js +1 -1
  169. package/dist/components/motion/range-slider-bubble.js +1 -1
  170. package/dist/components/motion/range-slider-fluid.js +1 -1
  171. package/dist/components/motion/range-slider-inline.js +1 -1
  172. package/dist/components/motion/range-slider-ruler.js +1 -1
  173. package/dist/components/motion/range-slider-wave.js +1 -1
  174. package/dist/components/motion/range-slider.js +1 -1
  175. package/dist/components/motion/signup-form.js +0 -1
  176. package/dist/components/motion/signup-form.js.map +1 -1
  177. package/dist/components/motion/slide-action-button.js +1 -1
  178. package/dist/components/motion/swap/field.js +1 -1
  179. package/dist/components/motion/swap/token-picker.js +1 -1
  180. package/dist/components/motion/swap.d.ts +1 -1
  181. package/dist/components/motion/swap.js +2 -2
  182. package/dist/components/motion/table/index.js +2 -2
  183. package/dist/components/motion/table/table-header.js +1 -1
  184. package/dist/components/motion/tooltip.d.ts +2 -2
  185. package/dist/components/motion/tooltip.d.ts.map +1 -1
  186. package/dist/components/motion/wallet-card/index.js +1 -2
  187. package/dist/components/motion/wallet-card/index.js.map +1 -1
  188. package/dist/components/motion/wheel-picker.js +1 -1
  189. package/dist/components/reui/badge.d.ts +1 -1
  190. package/dist/components/reui/cascader/cascader-columns.js +1 -1
  191. package/dist/components/reui/cascader/cascader-footer.js +1 -1
  192. package/dist/components/reui/cascader/cascader-nav.js +1 -1
  193. package/dist/components/reui/cascader/cascader-virtual.js +1 -1
  194. package/dist/components/reui/cascader/cascader.d.ts +1 -1
  195. package/dist/components/reui/cascader/cascader.js +2 -2
  196. package/dist/components/reui/code-block/code-block.d.ts +2 -1
  197. package/dist/components/reui/code-block/code-block.d.ts.map +1 -1
  198. package/dist/components/reui/data-grid/data-grid-column-filter.js +1 -1
  199. package/dist/components/reui/data-grid/data-grid-pagination.js +1 -1
  200. package/dist/components/reui/data-grid/data-grid-table.d.ts +1 -1
  201. package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
  202. package/dist/components/reui/data-grid/data-grid-table.js +1 -1
  203. package/dist/components/reui/date-selector.js +2 -2
  204. package/dist/components/reui/emoji-picker.js +2 -2
  205. package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +1 -1
  206. package/dist/components/reui/event-calendar/event-calendar-content.js +1 -1
  207. package/dist/components/reui/event-calendar/event-calendar-dnd.js +1 -1
  208. package/dist/components/reui/event-calendar/event-calendar-event.js +1 -1
  209. package/dist/components/reui/event-calendar/event-calendar-month-view.js +2 -2
  210. package/dist/components/reui/event-calendar/event-calendar-nav.js +2 -2
  211. package/dist/components/reui/event-calendar/event-calendar-resource-view.js +1 -1
  212. package/dist/components/reui/event-calendar/event-calendar-time-grid.js +1 -1
  213. package/dist/components/reui/event-calendar/event-calendar.d.ts +1 -1
  214. package/dist/components/reui/filters/filters-advanced.js +4 -4
  215. package/dist/components/reui/filters/filters-builder.js +1 -1
  216. package/dist/components/reui/filters/filters-chip.js +2 -2
  217. package/dist/components/reui/filters/filters-context.d.ts +1 -1
  218. package/dist/components/reui/filters/filters-editors.js +3 -3
  219. package/dist/components/reui/filters/filters.d.ts +3 -3
  220. package/dist/components/reui/filters/filters.js +6 -6
  221. package/dist/components/reui/gantt/gantt-bar.js +1 -1
  222. package/dist/components/reui/gantt/gantt-dnd.js +1 -1
  223. package/dist/components/reui/gantt/gantt-nav.js +2 -2
  224. package/dist/components/reui/gantt/gantt-view.js +3 -3
  225. package/dist/components/reui/gantt/gantt.d.ts +1 -1
  226. package/dist/components/reui/icon-tile.d.ts +1 -1
  227. package/dist/components/reui/phone-input.js +2 -2
  228. package/dist/components/reui/tree.d.ts +1 -0
  229. package/dist/components/reui/tree.d.ts.map +1 -1
  230. package/dist/components/ui/attachment.d.ts +1 -1
  231. package/dist/components/ui/badge.d.ts +1 -1
  232. package/dist/components/ui/bubble.d.ts +1 -1
  233. package/dist/components/ui/button-group.d.ts +1 -1
  234. package/dist/components/ui/button.d.ts +2 -2
  235. package/dist/components/ui/command.js +1 -1
  236. package/dist/components/ui/field.d.ts +1 -1
  237. package/dist/components/ui/field.js +1 -1
  238. package/dist/components/ui/item.d.ts +1 -1
  239. package/dist/components/ui/marker.d.ts +1 -1
  240. package/dist/components/ui/sidebar.d.ts +1 -1
  241. package/dist/components/ui/sidebar.js +1 -1
  242. package/dist/components/ui/tabs.d.ts +1 -1
  243. package/dist/context-CQbvWVnM.js +393 -0
  244. package/dist/context-CQbvWVnM.js.map +1 -0
  245. package/dist/context-tv-kneJV.d.ts +204 -0
  246. package/dist/context-tv-kneJV.d.ts.map +1 -0
  247. package/dist/{copy-menu-CKW3jM1J.js → copy-menu-LU54Aruj.js} +2 -2
  248. package/dist/{copy-menu-CKW3jM1J.js.map → copy-menu-LU54Aruj.js.map} +1 -1
  249. package/dist/crash-parts-CUv5gFYQ.js +1053 -0
  250. package/dist/crash-parts-CUv5gFYQ.js.map +1 -0
  251. package/dist/{ease-CHhXKlG3.d.ts → ease-DjhlGGZO.d.ts} +4 -2
  252. package/dist/ease-DjhlGGZO.d.ts.map +1 -0
  253. package/dist/hooks/use-highlighted-code.d.ts +1 -1
  254. package/dist/hooks/use-highlighted-code.d.ts.map +1 -1
  255. package/dist/hooks/use-modal-scope.js +2 -2
  256. package/dist/hooks/use-modal-scope.js.map +1 -1
  257. package/dist/lib/audio-context.d.ts +11 -0
  258. package/dist/lib/audio-context.d.ts.map +1 -0
  259. package/dist/lib/audio-context.js +37 -0
  260. package/dist/lib/audio-context.js.map +1 -0
  261. package/dist/lib/ease.d.ts +2 -2
  262. package/dist/lib/ease.js +8 -1
  263. package/dist/lib/ease.js.map +1 -1
  264. package/dist/lib/focusable.d.ts +2 -0
  265. package/dist/lib/focusable.d.ts.map +1 -0
  266. package/dist/lib/focusable.js +12 -0
  267. package/dist/lib/focusable.js.map +1 -0
  268. package/dist/lib/game-sounds.d.ts +18 -0
  269. package/dist/lib/game-sounds.d.ts.map +1 -0
  270. package/dist/lib/game-sounds.js +142 -0
  271. package/dist/lib/game-sounds.js.map +1 -0
  272. package/dist/lib/tick-sound.d.ts +4 -3
  273. package/dist/lib/tick-sound.d.ts.map +1 -1
  274. package/dist/lib/tick-sound.js +30 -37
  275. package/dist/lib/tick-sound.js.map +1 -1
  276. package/dist/model-CvWolJdo.d.ts +14 -0
  277. package/dist/model-CvWolJdo.d.ts.map +1 -0
  278. package/dist/path-VEfFUowr.d.ts +3 -0
  279. package/dist/path-VEfFUowr.d.ts.map +1 -0
  280. package/dist/{plot-DAKl-Lu1.js → plot-CTQFrQKi.js} +2 -2
  281. package/dist/{plot-DAKl-Lu1.js.map → plot-CTQFrQKi.js.map} +1 -1
  282. package/dist/scale-DSsaupNc.d.ts +7 -0
  283. package/dist/scale-DSsaupNc.d.ts.map +1 -0
  284. package/dist/tooltip-CNEYdIX3.d.ts.map +1 -1
  285. package/dist/tooltip-content-K0vPsEtI.d.ts +17 -0
  286. package/dist/tooltip-content-K0vPsEtI.d.ts.map +1 -0
  287. package/dist/use-crash-game-B3RHxFkm.d.ts +108 -0
  288. package/dist/use-crash-game-B3RHxFkm.d.ts.map +1 -0
  289. package/dist/use-inspection-CZhdpH8J.js +127 -0
  290. package/dist/use-inspection-CZhdpH8J.js.map +1 -0
  291. package/dist/use-points-C2jpElHh.js +118 -0
  292. package/dist/use-points-C2jpElHh.js.map +1 -0
  293. package/dist/use-width-CkKCh1b3.js +23 -0
  294. package/dist/use-width-CkKCh1b3.js.map +1 -0
  295. package/package.json +7 -7
  296. package/dist/ease-CHhXKlG3.d.ts.map +0 -1
@@ -0,0 +1,1053 @@
1
+ import { EASE_IN_OUT, EASE_OUT, SPRING_LAYOUT } from "./lib/ease.js";
2
+ import { t as PresenceGate } from "./presence-gate-DC7yL1Ls.js";
3
+ import { ActionSwapCascadeIcon } from "./components/motion/action-swap-cascade.js";
4
+ import { Button } from "./components/motion/button/base.js";
5
+ import { NumberTicker } from "./components/motion/number-ticker.js";
6
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./components/motion/select.js";
7
+ import { t as Tooltip } from "./tooltip-CuHpilPN.js";
8
+ import { createGameSounds } from "./lib/game-sounds.js";
9
+ import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
10
+ import { cn } from "@kumix/utils";
11
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
12
+ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
13
+ import { Check, History, Volume2, VolumeX, X } from "lucide-react";
14
+ // src/components/motion/crash/use-crash-game.ts
15
+ const GROWTH = .12;
16
+ const growth = (seconds) => Math.exp(GROWTH * seconds);
17
+ const timeAt = (multiplier) => Math.log(multiplier) / GROWTH;
18
+ const MAX_CRASH = 1e6;
19
+ const CEILING = 1e100;
20
+ /**
21
+ * A crash point from one uniform draw in [0, 1): the round reaches `m` with
22
+ * probability (1 − houseEdge) / m, floored to two decimals and capped at
23
+ * 1,000,000×. The default edge of 0 is a fair game. Pass your own `random`
24
+ * for a seeded or provably fair round, for example the first 52 bits of a
25
+ * round's HMAC-SHA256: `crashPoint(() => parseInt(hash.slice(0, 13), 16) / 2 ** 52, 0.01)`.
26
+ */
27
+ function crashPoint(random = Math.random, houseEdge = 0) {
28
+ return Math.min(MAX_CRASH, Math.max(1, Math.floor(100 * (1 - Math.min(Math.max(houseEdge, 0), 1)) / (1 - random())) / 100));
29
+ }
30
+ /**
31
+ * A passed crash point as the game plays it: at least 1 and floored to two
32
+ * decimals, the way crash games display them. The round ends on exactly the
33
+ * caller's value up to the 1e100 ceiling; `crashPoint()` caps at 1,000,000.
34
+ * Anything not finite plays as 1.
35
+ */
36
+ const settle = (point) => {
37
+ if (!Number.isFinite(point)) return 1;
38
+ return Math.max(1, floor2(Math.min(point, CEILING)));
39
+ };
40
+ /**
41
+ * Multipliers announced (and chimed) while the player is in: 2× to 5×, then
42
+ * 10×, 20×, 50×, 100× and on, so a long flight stays quiet enough to follow.
43
+ */
44
+ function milestone(index) {
45
+ if (index < 4) return index + 2;
46
+ return [
47
+ 10,
48
+ 20,
49
+ 50
50
+ ][(index - 4) % 3] * 10 ** Math.floor((index - 4) / 3);
51
+ }
52
+ const AUTO_STEPS = [
53
+ 1.5,
54
+ 2,
55
+ 3,
56
+ 5,
57
+ 10,
58
+ 25,
59
+ 100
60
+ ];
61
+ const SKIP_TIME = .8;
62
+ const PRESS_GUARD = 400;
63
+ let rounds = 0;
64
+ const HISTORY = 12;
65
+ const SHAKE = {
66
+ duration: .3,
67
+ ease: EASE_OUT
68
+ };
69
+ const BURST = {
70
+ duration: .45,
71
+ ease: EASE_OUT
72
+ };
73
+ const SWAP = {
74
+ type: "spring",
75
+ duration: .3,
76
+ bounce: 0
77
+ };
78
+ const PULSE = {
79
+ type: "spring",
80
+ duration: .35,
81
+ bounce: .3
82
+ };
83
+ const EXIT = {
84
+ duration: .12,
85
+ ease: EASE_OUT
86
+ };
87
+ function useCrashGame({ autoCashOut: autoProp, defaultAutoCashOut = null, onAutoCashOutChange, getCrashPoint, crashAt, onStart, onCashOut, onCrash, sound, defaultSound = false, onSoundChange }) {
88
+ const live = crashAt !== void 0;
89
+ const reduce = useReducedMotion() ?? false;
90
+ const [internalAuto, setInternalAuto] = useState(defaultAutoCashOut);
91
+ const rawAuto = autoProp === void 0 ? internalAuto : autoProp;
92
+ const auto = rawAuto === null || !Number.isFinite(rawAuto) ? null : Math.max(1.01, floor2(rawAuto));
93
+ const [phase, setPhase] = useState("idle");
94
+ const [round, setRound] = useState(0);
95
+ const [elapsed, setElapsed] = useState(0);
96
+ const [cashed, setCashed] = useState(null);
97
+ const [cashedT, setCashedT] = useState(null);
98
+ const [crashedAt, setCrashedAt] = useState(null);
99
+ const [history, setHistory] = useState([]);
100
+ const [announcement, setAnnouncement] = useState("");
101
+ const [pulse, setPulse] = useState(0);
102
+ const [roundAuto, setRoundAuto] = useState(null);
103
+ const flight = useRef({
104
+ round: 0,
105
+ live: false,
106
+ t: 0,
107
+ rate: 1,
108
+ crash: 1,
109
+ auto: null,
110
+ milestone: 0,
111
+ pressTime: Number.NEGATIVE_INFINITY,
112
+ held: false
113
+ });
114
+ const cashedRef = useRef(null);
115
+ const busy = useRef(false);
116
+ const alive = useRef(true);
117
+ useEffect(() => {
118
+ alive.current = true;
119
+ return () => {
120
+ alive.current = false;
121
+ };
122
+ }, []);
123
+ const [internalSound, setInternalSound] = useState(defaultSound);
124
+ const soundOn = sound ?? internalSound;
125
+ const player = useRef(null);
126
+ const getPlayer = () => {
127
+ if (!player.current) player.current = createGameSounds();
128
+ return player.current;
129
+ };
130
+ useEffect(() => () => {
131
+ player.current?.dispose();
132
+ player.current = null;
133
+ }, []);
134
+ const running = phase === "running";
135
+ const starting = phase === "starting";
136
+ const crashed = phase === "crashed";
137
+ const roundLive = flight.current.live;
138
+ const crashKnown = !roundLive || crashAt?.round === round;
139
+ const overtaken = running && roundLive && crashKnown;
140
+ const t = crashed && crashedAt !== null ? timeAt(crashedAt) : elapsed;
141
+ const multiplier = crashed && crashedAt !== null ? crashedAt : floor2(growth(t));
142
+ const cashOut = (value, time) => {
143
+ if (!busy.current || cashedRef.current !== null) return;
144
+ cashedRef.current = value;
145
+ setCashed(value);
146
+ setCashedT(time);
147
+ setAnnouncement(`Cashed out at ${formatMultiplier(value)}.`);
148
+ if (soundOn) getPlayer().cashOut();
149
+ if (Number.isFinite(flight.current.crash)) onCashOut?.(value);
150
+ else flight.current.held = true;
151
+ };
152
+ const fly = (id, crash) => {
153
+ flight.current = {
154
+ round: id,
155
+ live,
156
+ t: 0,
157
+ rate: 1,
158
+ crash,
159
+ auto,
160
+ milestone: 0,
161
+ pressTime: flight.current.pressTime,
162
+ held: false
163
+ };
164
+ setPhase("running");
165
+ setAnnouncement(auto === null ? "Round started." : `Round started. Auto cash out at ${formatMultiplier(auto)}.`);
166
+ };
167
+ const start = () => {
168
+ if (busy.current) return;
169
+ busy.current = true;
170
+ rounds += 1;
171
+ const id = rounds;
172
+ try {
173
+ onStart?.(id);
174
+ } catch (error) {
175
+ busy.current = false;
176
+ throw error;
177
+ }
178
+ flight.current.pressTime = performance.now();
179
+ cashedRef.current = null;
180
+ setCashed(null);
181
+ setCashedT(null);
182
+ setCrashedAt(null);
183
+ setElapsed(0);
184
+ setPulse(0);
185
+ setRoundAuto(auto);
186
+ setRound(id);
187
+ if (soundOn) getPlayer().prepare();
188
+ if (live) {
189
+ fly(id, Number.POSITIVE_INFINITY);
190
+ return;
191
+ }
192
+ let point;
193
+ try {
194
+ point = getCrashPoint ? getCrashPoint() : crashPoint();
195
+ } catch {
196
+ point = Promise.reject();
197
+ }
198
+ if (typeof point === "number") {
199
+ fly(id, settle(point));
200
+ return;
201
+ }
202
+ setPhase("starting");
203
+ setAnnouncement("Starting round.");
204
+ Promise.resolve(point).then((value) => {
205
+ if (alive.current) fly(id, settle(value));
206
+ }, () => {
207
+ if (!alive.current) return;
208
+ busy.current = false;
209
+ setPhase("idle");
210
+ setAnnouncement("The round couldn't start. Try again.");
211
+ });
212
+ };
213
+ const skip = () => {
214
+ const f = flight.current;
215
+ if (!Number.isFinite(f.crash)) return;
216
+ f.rate = reduce ? 1e9 : Math.max(1, (timeAt(f.crash) - f.t) / SKIP_TIME);
217
+ };
218
+ const onFrame = useStable((dt) => {
219
+ if (!busy.current) return false;
220
+ const f = flight.current;
221
+ const wasIn = cashedRef.current === null;
222
+ if (f.live && !Number.isFinite(f.crash) && crashAt?.round === f.round) {
223
+ f.crash = settle(crashAt.value);
224
+ f.rate = reduce ? 1e9 : Math.max(1, (timeAt(f.crash) - f.t) / SKIP_TIME);
225
+ if (cashedRef.current !== null && cashedRef.current > f.crash) {
226
+ cashedRef.current = null;
227
+ setCashed(null);
228
+ setCashedT(null);
229
+ f.held = false;
230
+ }
231
+ }
232
+ if (f.live && !live && !Number.isFinite(f.crash)) {
233
+ f.crash = settle(growth(f.t));
234
+ if (f.held) {
235
+ f.held = false;
236
+ cashedRef.current = null;
237
+ setCashed(null);
238
+ setCashedT(null);
239
+ }
240
+ }
241
+ if (f.held && Number.isFinite(f.crash) && cashedRef.current !== null) {
242
+ f.held = false;
243
+ onCashOut?.(cashedRef.current);
244
+ }
245
+ const end = timeAt(f.crash);
246
+ f.t = Math.min(end, f.t + dt * f.rate, timeAt(CEILING));
247
+ const value = growth(f.t);
248
+ if (cashedRef.current === null) {
249
+ if (f.auto !== null && f.auto <= f.crash && (value >= f.auto || f.t >= end)) cashOut(f.auto, timeAt(f.auto));
250
+ else if (f.rate === 1 && f.t < end && Number.isFinite(value) && value >= milestone(f.milestone)) {
251
+ while (value >= milestone(f.milestone + 1)) f.milestone++;
252
+ setAnnouncement(formatShort(milestone(f.milestone)));
253
+ setPulse((count) => count + 1);
254
+ f.milestone++;
255
+ if (soundOn) getPlayer().gem(f.milestone);
256
+ }
257
+ }
258
+ if (f.t < end) {
259
+ setElapsed(f.t);
260
+ return true;
261
+ }
262
+ busy.current = false;
263
+ f.pressTime = performance.now();
264
+ setCrashedAt(f.crash);
265
+ setPhase("crashed");
266
+ setHistory((current) => [{
267
+ id: f.round,
268
+ value: f.crash
269
+ }, ...current].slice(0, HISTORY));
270
+ setAnnouncement(cashedRef.current === null ? `Crashed at ${formatMultiplier(f.crash)}. The round is lost.` : `${wasIn ? `Cashed out at ${formatMultiplier(cashedRef.current)}. ` : ""}Crashed at ${formatMultiplier(f.crash)}.`);
271
+ if (soundOn) getPlayer().mine();
272
+ onCrash?.(f.crash, cashedRef.current);
273
+ return false;
274
+ });
275
+ useEffect(() => {
276
+ if (phase !== "running") return;
277
+ let last = performance.now();
278
+ let id = requestAnimationFrame(function step() {
279
+ const now = performance.now();
280
+ const dt = Math.max(0, now - last) / 1e3;
281
+ last = now;
282
+ id = requestAnimationFrame(step);
283
+ if (!onFrame(dt)) cancelAnimationFrame(id);
284
+ });
285
+ return () => cancelAnimationFrame(id);
286
+ }, [phase, onFrame]);
287
+ const setAuto = useStable((value) => {
288
+ const next = value === "off" ? null : Number(value);
289
+ if (autoProp === void 0) setInternalAuto(next);
290
+ onAutoCashOutChange?.(next);
291
+ });
292
+ const autoOptions = useMemo(() => auto === null || AUTO_STEPS.includes(auto) ? AUTO_STEPS : [...AUTO_STEPS, auto].sort((a, b) => a - b), [auto]);
293
+ const toggleSound = useStable(() => {
294
+ const next = !soundOn;
295
+ if (next) getPlayer().prepare();
296
+ if (sound === void 0) setInternalSound(next);
297
+ onSoundChange?.(next);
298
+ });
299
+ /** Start, cash out or skip, whichever the round is ready for. */
300
+ const act = () => {
301
+ const now = performance.now();
302
+ if (starting || now - flight.current.pressTime < PRESS_GUARD) return;
303
+ if (!running) start();
304
+ else if (cashedRef.current === null) {
305
+ if (overtaken || flight.current.live && Number.isFinite(flight.current.crash)) return;
306
+ flight.current.pressTime = now;
307
+ cashOut(floor2(growth(flight.current.t)), flight.current.t);
308
+ } else skip();
309
+ };
310
+ const actionLabel = starting ? "Starting…" : running ? cashed === null ? overtaken ? "Crashing…" : `Cash out ${formatMultiplier(multiplier)}` : crashKnown ? "Skip to crash" : "Waiting for crash" : crashed ? "Play again" : "Start";
311
+ /** The main action can't act right now: the crash point is still coming, or a live round is already over. */
312
+ const actionBusy = starting || running && cashed !== null && !crashKnown || overtaken && cashed === null;
313
+ const lost = crashed && cashed === null;
314
+ const eyebrow = lost ? "Crashed" : crashed ? "Cashed out" : running ? "In flight" : starting ? "Starting" : "Ready";
315
+ const shownAuto = running ? roundAuto : auto;
316
+ const status = crashed ? cashed !== null ? multiplier / cashed < 1.1 ? `Crashed at ${formatMultiplier(multiplier)}, a close call` : `It flew on to ${formatMultiplier(multiplier)}` : roundAuto !== null ? `Short of your ${formatShort(roundAuto)} target` : "You were still in" : shownAuto !== null ? `Auto cash out at ${formatMultiplier(shownAuto)}` : running ? "Cash out before it crashes" : "Start a round";
317
+ const target = cashed !== null || crashed ? null : running ? roundAuto : auto;
318
+ const ghost = (crashed ? history[1] : history[0])?.value ?? null;
319
+ return {
320
+ reduce,
321
+ /** The built-in fair crash point decides the round, so "1 in m" odds hold. */
322
+ fair: !live && !getCrashPoint,
323
+ target,
324
+ ghost,
325
+ /** The auto target the current or last round played with. */
326
+ roundAuto,
327
+ phase,
328
+ running,
329
+ starting,
330
+ crashed,
331
+ lost,
332
+ /** A skip is running the rest of the flight out; scenery that streams with t would only flicker. */
333
+ skipping: running && flight.current.rate > 1,
334
+ /** Seconds into the flight, frozen at the crash. */
335
+ t,
336
+ multiplier,
337
+ cashed,
338
+ /** Seconds into the flight at the cash out, or null. */
339
+ cashedT,
340
+ round,
341
+ pulse,
342
+ history,
343
+ auto,
344
+ autoOptions,
345
+ setAuto,
346
+ soundOn,
347
+ toggleSound,
348
+ act,
349
+ actionLabel,
350
+ actionBusy,
351
+ eyebrow,
352
+ status,
353
+ announcement
354
+ };
355
+ }
356
+ /**
357
+ * A callback with one identity for the component's life that runs the latest
358
+ * render's code. Stands in for useEffectEvent, which needs React 19.2.
359
+ */
360
+ function useStable(fn) {
361
+ const ref = useRef(fn);
362
+ useLayoutEffect(() => {
363
+ ref.current = fn;
364
+ });
365
+ return useCallback((...args) => ref.current(...args), []);
366
+ }
367
+ /**
368
+ * How hot a multiplier reads: cool under 2×, warm to 10×, hot beyond. The
369
+ * readout and the history colour by it, so size reads without the digits.
370
+ */
371
+ function heat(multiplier) {
372
+ return multiplier >= 10 ? "hot" : multiplier >= 2 ? "warm" : "cool";
373
+ }
374
+ function floor2(value) {
375
+ return Math.floor(value * 100 + 1e-9) / 100;
376
+ }
377
+ const COMPACT = new Intl.NumberFormat("en", {
378
+ notation: "compact",
379
+ maximumFractionDigits: 1,
380
+ roundingMode: "trunc"
381
+ });
382
+ /**
383
+ * Large values: compact up to trillions, then scientific (1.4e100), since
384
+ * compact notation stops at T and would print 1e100 as a 100-digit string.
385
+ */
386
+ function formatLarge(multiplier) {
387
+ if (multiplier < 0x38d7ea4c68000) return COMPACT.format(multiplier);
388
+ const [mantissa, exponent] = multiplier.toExponential(6).split("e");
389
+ return `${Math.floor(Number(mantissa) * 10) / 10}e${Number(exponent)}`;
390
+ }
391
+ /** A multiplier as Crash shows it: 2.50×, or shortened when large (12.5K×, 1.4e20×). */
392
+ function formatMultiplier(multiplier) {
393
+ return `${multiplier < 1e4 ? multiplier.toFixed(2) : formatLarge(multiplier)}×`;
394
+ }
395
+ /** Scale and menu labels: 1.5×, 2×, 1.2K×. */
396
+ function formatShort(multiplier) {
397
+ return `${multiplier < 1e3 ? +multiplier.toFixed(2) : formatLarge(multiplier)}×`;
398
+ }
399
+ // src/components/motion/crash/crash-parts.tsx
400
+ /**
401
+ * Primary for small text: a shade darker on light surfaces and lighter on
402
+ * dark ones, so 10-12px labels keep 4.5:1. Large text and marks use plain
403
+ * primary.
404
+ */
405
+ const PRIMARY_TEXT = "text-[color:color-mix(in_oklab,var(--color-primary)_75%,black)] dark:text-[color:color-mix(in_oklab,var(--color-primary)_80%,white)]";
406
+ const HEAT_TEXT = {
407
+ cool: "text-foreground",
408
+ warm: "text-primary",
409
+ hot: "text-amber-700 dark:text-amber-400"
410
+ };
411
+ const HEAT_PILL = {
412
+ cool: "bg-foreground/5 text-muted-foreground",
413
+ warm: `bg-primary/10 ${PRIMARY_TEXT}`,
414
+ hot: "bg-amber-500/15 text-amber-700 dark:text-amber-400"
415
+ };
416
+ /** The width of the viewBox an SVG stage draws in. */
417
+ const STAGE_W = 400;
418
+ /**
419
+ * SVG stage labels: 10px on screen however narrow the card. A viewBox scales
420
+ * its text with the stage, so the shell sets --crash-label in viewBox units.
421
+ * The server render has no width to go on and draws them at 10 units.
422
+ */
423
+ const STAGE_LABEL = "text-[length:var(--crash-label,10px)]";
424
+ /**
425
+ * The frame every design sits in: one card holding the recent rounds and
426
+ * sound, the stage with the readout pinned top left, and the controls. Each
427
+ * design draws only its stage, which must keep the top-left corner clear.
428
+ */
429
+ function CrashShell({ game, "aria-label": ariaLabel, className, children, miniature }) {
430
+ const mainRef = useRef(null);
431
+ const stageRef = useRef(null);
432
+ useLayoutEffect(() => {
433
+ const node = stageRef.current;
434
+ if (!node) return;
435
+ const measure = () => {
436
+ const width = node.clientWidth;
437
+ if (width > 0) node.style.setProperty("--crash-label", `${Math.max(10, 4e3 / width)}px`);
438
+ };
439
+ measure();
440
+ const observer = new ResizeObserver(measure);
441
+ observer.observe(node);
442
+ return () => observer.disconnect();
443
+ }, []);
444
+ const [openRound, setOpenRound] = useState(null);
445
+ const resultShown = game.crashed && openRound === game.round;
446
+ const { crashed, round } = game;
447
+ const ticketDelay = useStable(() => (game.reduce ? .15 : TICKET_DELAY) * 1e3);
448
+ useEffect(() => {
449
+ if (!crashed) return;
450
+ const id = setTimeout(() => setOpenRound(round), ticketDelay());
451
+ return () => clearTimeout(id);
452
+ }, [
453
+ crashed,
454
+ round,
455
+ ticketDelay
456
+ ]);
457
+ const closeResult = () => {
458
+ setOpenRound(null);
459
+ mainRef.current?.focus();
460
+ };
461
+ return /* @__PURE__ */ jsxs("section", {
462
+ "aria-label": ariaLabel,
463
+ tabIndex: -1,
464
+ className: cn("w-full max-w-md outline-none", className),
465
+ onKeyDown: (event) => {
466
+ if (event.key !== "Escape" || !resultShown) return;
467
+ if (event.target instanceof Element && event.target.closest("[role=\"listbox\"],[aria-expanded=\"true\"]")) return;
468
+ event.stopPropagation();
469
+ closeResult();
470
+ },
471
+ children: [/* @__PURE__ */ jsxs("div", {
472
+ className: "border-border flex flex-col gap-3 rounded-3xl border p-3",
473
+ children: [
474
+ /* @__PURE__ */ jsxs("div", {
475
+ className: "flex h-8 items-center gap-2 pl-1",
476
+ children: [
477
+ /* @__PURE__ */ jsx(History, {
478
+ "aria-hidden": "true",
479
+ className: "text-muted-foreground size-3.5 shrink-0",
480
+ strokeWidth: 2
481
+ }),
482
+ /* @__PURE__ */ jsx(CrashHistory, {
483
+ history: game.history,
484
+ reduce: game.reduce,
485
+ className: "min-w-0 flex-1"
486
+ }),
487
+ /* @__PURE__ */ jsx(SoundToggle, {
488
+ on: game.soundOn,
489
+ onToggle: game.toggleSound
490
+ })
491
+ ]
492
+ }),
493
+ /* @__PURE__ */ jsxs("div", {
494
+ ref: stageRef,
495
+ className: "bg-muted/40 @container relative aspect-[10/7] overflow-hidden rounded-xl",
496
+ children: [
497
+ children,
498
+ /* @__PURE__ */ jsxs("div", {
499
+ className: "pointer-events-none absolute top-4 left-4",
500
+ children: [
501
+ /* @__PURE__ */ jsx(CrashEyebrow, { game }),
502
+ /* @__PURE__ */ jsx(CrashMultiplier, {
503
+ game,
504
+ className: "mt-1 text-3xl @min-[20rem]:text-4xl [&>span]:origin-left"
505
+ }),
506
+ /* @__PURE__ */ jsx(CrashStatus, {
507
+ game,
508
+ className: "mt-2"
509
+ })
510
+ ]
511
+ }),
512
+ /* @__PURE__ */ jsx(AnimatePresence, { children: resultShown ? /* @__PURE__ */ jsx(PresenceGate, { children: ({ gate }) => /* @__PURE__ */ jsx(ResultTicket, {
513
+ game,
514
+ gate,
515
+ onClose: closeResult,
516
+ miniature
517
+ }) }, "result") : null })
518
+ ]
519
+ }),
520
+ /* @__PURE__ */ jsx(CrashControls, {
521
+ game,
522
+ mainRef
523
+ })
524
+ ]
525
+ }), /* @__PURE__ */ jsx(CrashAnnouncer, { game })]
526
+ });
527
+ }
528
+ const TICKET_DELAY = .7;
529
+ const CARD_IN = {
530
+ type: "spring",
531
+ duration: .4,
532
+ bounce: .15
533
+ };
534
+ const CARD_OUT = {
535
+ duration: .15,
536
+ ease: EASE_OUT
537
+ };
538
+ const CHUNK = {
539
+ duration: .25,
540
+ ease: EASE_OUT
541
+ };
542
+ const TEAR = 104;
543
+ const TICKET_SHADOW = "[filter:drop-shadow(0_1px_1px_rgb(0_0_0/0.12))_drop-shadow(0_12px_16px_rgb(0_0_0/0.3))]";
544
+ const NOTCH_MASK = `radial-gradient(circle 9px at 0 ${TEAR}px, transparent 98%, black), radial-gradient(circle 9px at 100% ${TEAR}px, transparent 98%, black)`;
545
+ /**
546
+ * The end-of-round receipt over a dimmed stage. It has no buttons: the main
547
+ * action already says Play again, and tapping the stage (or Escape) puts it
548
+ * away to look at the flight.
549
+ */
550
+ function ResultTicket({ game, gate, onClose, miniature }) {
551
+ const { reduce } = game;
552
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(motion.button, {
553
+ type: "button",
554
+ "aria-label": "Hide result and show the flight",
555
+ onClick: onClose,
556
+ ...gate,
557
+ className: "bg-background/55 focus-visible:ring-primary absolute inset-0 z-20 cursor-default backdrop-blur-[2px] outline-none focus-visible:ring-2 focus-visible:ring-inset",
558
+ initial: { opacity: 0 },
559
+ animate: { opacity: 1 },
560
+ exit: {
561
+ opacity: 0,
562
+ transition: CARD_OUT
563
+ },
564
+ transition: {
565
+ duration: .2,
566
+ ease: EASE_OUT
567
+ }
568
+ }), /* @__PURE__ */ jsx("div", {
569
+ inert: gate.inert,
570
+ className: "pointer-events-none absolute inset-0 z-20 grid place-items-center p-4",
571
+ children: /* @__PURE__ */ jsx(motion.div, {
572
+ role: "group",
573
+ "aria-label": "Round result",
574
+ className: cn("w-full max-w-[17rem]", TICKET_SHADOW),
575
+ initial: reduce ? { opacity: 0 } : {
576
+ opacity: 0,
577
+ y: 16,
578
+ scale: .96
579
+ },
580
+ animate: {
581
+ opacity: 1,
582
+ y: 0,
583
+ scale: 1
584
+ },
585
+ exit: reduce ? {
586
+ opacity: 0,
587
+ transition: CARD_OUT
588
+ } : {
589
+ opacity: 0,
590
+ y: 8,
591
+ scale: .98,
592
+ transition: CARD_OUT
593
+ },
594
+ transition: reduce ? { duration: .2 } : CARD_IN,
595
+ children: /* @__PURE__ */ jsx(Ticket, {
596
+ game,
597
+ miniature
598
+ })
599
+ })
600
+ })] });
601
+ }
602
+ function Chunk({ delay, reduce, className, children }) {
603
+ return /* @__PURE__ */ jsx(motion.div, {
604
+ className,
605
+ initial: reduce ? { opacity: 0 } : {
606
+ opacity: 0,
607
+ y: 6
608
+ },
609
+ animate: {
610
+ opacity: 1,
611
+ y: 0
612
+ },
613
+ transition: {
614
+ ...CHUNK,
615
+ delay: reduce ? 0 : delay
616
+ },
617
+ children
618
+ });
619
+ }
620
+ function Ticket({ game, miniature }) {
621
+ const { cashed, multiplier: crash, roundAuto, reduce, t } = game;
622
+ const won = cashed !== null;
623
+ return /* @__PURE__ */ jsxs("div", {
624
+ className: "bg-card text-foreground @container w-full rounded-2xl @max-[17rem]:scale-[0.72] @min-[17rem]:@max-[21rem]:scale-[0.85]",
625
+ style: {
626
+ WebkitMaskImage: NOTCH_MASK,
627
+ WebkitMaskComposite: "source-in",
628
+ maskImage: NOTCH_MASK,
629
+ maskComposite: "intersect"
630
+ },
631
+ children: [
632
+ /* @__PURE__ */ jsxs("div", {
633
+ className: cn("flex flex-col items-center justify-center gap-1 rounded-t-2xl px-5 text-center", won ? "bg-primary/10" : "bg-rose-500/10"),
634
+ style: { height: TEAR },
635
+ children: [/* @__PURE__ */ jsx(Chunk, {
636
+ delay: .05,
637
+ reduce,
638
+ children: /* @__PURE__ */ jsx("p", {
639
+ className: cn("text-xs font-medium tracking-wide uppercase", won ? PRIMARY_TEXT : "text-rose-700 dark:text-rose-400"),
640
+ children: won ? "Cashed out" : "Crashed"
641
+ })
642
+ }), /* @__PURE__ */ jsx(Chunk, {
643
+ delay: .1,
644
+ reduce,
645
+ children: /* @__PURE__ */ jsx("p", {
646
+ className: cn("text-3xl font-semibold", !won && "text-muted-foreground line-through decoration-2"),
647
+ children: won ? /* @__PURE__ */ jsx(NumberTicker, {
648
+ value: cashed,
649
+ decimals: 2,
650
+ format: (value) => formatMultiplier(value).slice(0, -1),
651
+ suffix: "×",
652
+ startOnView: false,
653
+ duration: .6,
654
+ stagger: .05
655
+ }) : /* @__PURE__ */ jsx("span", {
656
+ className: "tabular-nums",
657
+ children: formatMultiplier(crash)
658
+ })
659
+ })
660
+ })]
661
+ }),
662
+ /* @__PURE__ */ jsx("div", {
663
+ "aria-hidden": "true",
664
+ className: "border-border mx-4 border-t-2 border-dashed"
665
+ }),
666
+ /* @__PURE__ */ jsxs("div", {
667
+ className: "flex items-center gap-4 px-5 pt-4 pb-5",
668
+ children: [/* @__PURE__ */ jsx(Chunk, {
669
+ delay: .18,
670
+ reduce,
671
+ className: "flex-1",
672
+ children: /* @__PURE__ */ jsxs("dl", {
673
+ className: "grid gap-1.5 text-xs",
674
+ children: [
675
+ /* @__PURE__ */ jsx(Row, {
676
+ label: "Crashed at",
677
+ value: formatMultiplier(crash)
678
+ }),
679
+ /* @__PURE__ */ jsx(Row, {
680
+ label: "Flight",
681
+ value: `${t.toFixed(1)}s`
682
+ }),
683
+ won && game.fair ? /* @__PURE__ */ jsx(Row, {
684
+ label: "Odds beaten",
685
+ value: `1 in ${formatMultiplier(cashed).slice(0, -1)}`
686
+ }) : won ? /* @__PURE__ */ jsx(Row, {
687
+ label: "You left at",
688
+ value: formatMultiplier(cashed)
689
+ }) : /* @__PURE__ */ jsx(Row, {
690
+ label: "Auto target",
691
+ value: roundAuto === null ? "Off" : formatShort(roundAuto)
692
+ })
693
+ ]
694
+ })
695
+ }), miniature ? /* @__PURE__ */ jsx(Chunk, {
696
+ delay: .24,
697
+ reduce,
698
+ className: "@max-[15rem]:hidden",
699
+ children: miniature({
700
+ crash,
701
+ cashed,
702
+ cashedT: game.cashedT,
703
+ target: won ? null : roundAuto,
704
+ reduce
705
+ })
706
+ }) : null]
707
+ })
708
+ ]
709
+ });
710
+ }
711
+ function Row({ label, value }) {
712
+ return /* @__PURE__ */ jsxs("div", {
713
+ className: "flex justify-between gap-2 whitespace-nowrap",
714
+ children: [/* @__PURE__ */ jsx("dt", {
715
+ className: "text-muted-foreground",
716
+ children: label
717
+ }), /* @__PURE__ */ jsx("dd", {
718
+ className: "font-medium tabular-nums",
719
+ children: value
720
+ })]
721
+ });
722
+ }
723
+ const CHUTE = {
724
+ y: {
725
+ duration: 2.2,
726
+ ease: EASE_OUT
727
+ },
728
+ rotate: {
729
+ duration: 2.2,
730
+ ease: EASE_IN_OUT
731
+ },
732
+ opacity: {
733
+ duration: 2.2,
734
+ times: [
735
+ 0,
736
+ .08,
737
+ .7,
738
+ 1
739
+ ]
740
+ }
741
+ };
742
+ const clamp01 = (value) => Math.min(1, Math.max(0, value));
743
+ /** Wraps scenery that streams past into a loop `span` long. */
744
+ const wrap = (value, span) => (value % span + span) % span;
745
+ /** A tick step of 1, 2 or 5 times a power of ten, at least `min`. */
746
+ function niceAtLeast(min) {
747
+ const power = 10 ** Math.floor(Math.log10(min));
748
+ return Number((([
749
+ 1,
750
+ 2,
751
+ 5,
752
+ 10
753
+ ].find((unit) => unit * power >= min) ?? 10) * power).toPrecision(12));
754
+ }
755
+ /** The parachute that opens at a cash out: a scalloped canopy, three lines and the player. */
756
+ function Parachute() {
757
+ return /* @__PURE__ */ jsxs("g", {
758
+ className: "text-primary",
759
+ children: [
760
+ /* @__PURE__ */ jsx("path", {
761
+ d: "M-9,0Q-9,-11 0,-11Q9,-11 9,0Q6,-3 3,0Q0,-3 -3,0Q-6,-3 -9,0Z",
762
+ fill: "currentColor"
763
+ }),
764
+ /* @__PURE__ */ jsx("path", {
765
+ d: "M-9,0L0,10M0,0L0,10M9,0L0,10",
766
+ stroke: "currentColor",
767
+ strokeWidth: .75,
768
+ opacity: .6,
769
+ fill: "none"
770
+ }),
771
+ /* @__PURE__ */ jsx("circle", {
772
+ cy: 11.5,
773
+ r: 2,
774
+ fill: "currentColor"
775
+ })
776
+ ]
777
+ });
778
+ }
779
+ /** Every miniature is 88 × 48, like Mines' mini map. */
780
+ const MINI = {
781
+ width: 88,
782
+ height: 48
783
+ };
784
+ const MINI_REPLAY = {
785
+ delay: .3,
786
+ duration: .6,
787
+ ease: EASE_OUT
788
+ };
789
+ /** The sound toggle: a quiet 32px icon button in the card's header. */
790
+ const SoundToggle = memo(function SoundToggle({ on, onToggle }) {
791
+ return /* @__PURE__ */ jsx(Tooltip, {
792
+ content: "Sound",
793
+ side: "top",
794
+ children: /* @__PURE__ */ jsx(Button, {
795
+ variant: "ghost",
796
+ onClick: onToggle,
797
+ "aria-label": "Sound",
798
+ "aria-pressed": on,
799
+ pressScale: .96,
800
+ className: cn("size-8 shrink-0 rounded-xl px-0", on && "text-foreground"),
801
+ children: /* @__PURE__ */ jsx(ActionSwapCascadeIcon, {
802
+ value: on ? "on" : "off",
803
+ className: "size-4",
804
+ children: on ? /* @__PURE__ */ jsx(Volume2, {
805
+ "aria-hidden": "true",
806
+ className: "size-4"
807
+ }) : /* @__PURE__ */ jsx(VolumeX, {
808
+ "aria-hidden": "true",
809
+ className: "size-4"
810
+ })
811
+ })
812
+ })
813
+ });
814
+ });
815
+ /** The Auto menu and the main action, in one 40px row with 12px corners. */
816
+ function CrashControls({ game, mainRef }) {
817
+ return /* @__PURE__ */ jsxs("div", {
818
+ className: "flex items-center gap-2",
819
+ children: [/* @__PURE__ */ jsx(AutoMenu, {
820
+ auto: game.auto,
821
+ options: game.autoOptions,
822
+ onChange: game.setAuto,
823
+ disabled: game.running || game.starting
824
+ }), /* @__PURE__ */ jsxs(Button, {
825
+ ref: mainRef,
826
+ className: "aria-disabled:hover:bg-primary relative h-10 flex-1 overflow-hidden rounded-xl tabular-nums aria-disabled:cursor-wait aria-disabled:opacity-60",
827
+ "aria-disabled": game.actionBusy || void 0,
828
+ "aria-busy": game.starting || void 0,
829
+ pressScale: game.actionBusy ? 1 : .96,
830
+ ...game.actionBusy ? { whileHover: {} } : {},
831
+ onClick: game.act,
832
+ onKeyDown: (event) => {
833
+ if (event.repeat && event.key === "Enter") event.preventDefault();
834
+ },
835
+ children: [game.actionLabel, game.running && game.target !== null ? /* @__PURE__ */ jsx("span", {
836
+ "aria-hidden": "true",
837
+ className: "bg-primary-foreground/45 pointer-events-none absolute inset-x-0 bottom-0 h-[3px] origin-left",
838
+ style: { transform: `scaleX(${Math.min(1, Math.log(growth(game.t)) / Math.log(game.target)).toFixed(4)})` }
839
+ }) : null]
840
+ })]
841
+ });
842
+ }
843
+ /** The Auto cash-out menu. */
844
+ const AutoMenu = memo(function AutoMenu({ auto, options, onChange, disabled }) {
845
+ return /* @__PURE__ */ jsxs(Select, {
846
+ value: auto === null ? "off" : String(auto),
847
+ onValueChange: onChange,
848
+ disabled,
849
+ className: "w-32 shrink-0",
850
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
851
+ className: "h-10 tabular-nums",
852
+ children: /* @__PURE__ */ jsxs("span", {
853
+ className: "flex items-baseline gap-1.5",
854
+ children: [/* @__PURE__ */ jsx("span", {
855
+ className: "text-muted-foreground text-xs",
856
+ children: "Auto"
857
+ }), /* @__PURE__ */ jsx(SelectValue, { placeholder: auto === null ? "Off" : formatShort(auto) })]
858
+ })
859
+ }), /* @__PURE__ */ jsxs(SelectContent, { children: [/* @__PURE__ */ jsx(SelectItem, {
860
+ value: "off",
861
+ children: "Off"
862
+ }), options.map((step) => /* @__PURE__ */ jsx(SelectItem, {
863
+ value: String(step),
864
+ children: formatShort(step)
865
+ }, step))] })]
866
+ });
867
+ });
868
+ /** Recent crash points, newest first, sliding in from the left. */
869
+ const CrashHistory = memo(function CrashHistory({ history, reduce, className }) {
870
+ return /* @__PURE__ */ jsx("ul", {
871
+ "aria-label": "Recent crashes",
872
+ className: cn("flex items-center gap-1.5 overflow-hidden [mask-image:linear-gradient(to_right,black_85%,transparent)]", className),
873
+ children: /* @__PURE__ */ jsx(AnimatePresence, {
874
+ initial: false,
875
+ mode: "popLayout",
876
+ children: history.length === 0 ? /* @__PURE__ */ jsx(motion.li, {
877
+ className: "text-muted-foreground text-xs",
878
+ initial: false,
879
+ animate: { opacity: 1 },
880
+ exit: {
881
+ opacity: 0,
882
+ transition: EXIT
883
+ },
884
+ children: "Recent rounds show here"
885
+ }, "empty") : history.map((entry) => /* @__PURE__ */ jsx(motion.li, {
886
+ layout: !reduce,
887
+ initial: reduce ? { opacity: 0 } : {
888
+ opacity: 0,
889
+ scale: .9,
890
+ x: -8
891
+ },
892
+ animate: {
893
+ opacity: 1,
894
+ scale: 1,
895
+ x: 0
896
+ },
897
+ exit: {
898
+ opacity: 0,
899
+ transition: EXIT
900
+ },
901
+ transition: reduce ? { duration: .15 } : SPRING_LAYOUT,
902
+ className: cn("shrink-0 rounded-full px-2 py-0.5 text-xs font-medium tabular-nums", HEAT_PILL[heat(entry.value)]),
903
+ children: formatMultiplier(entry.value)
904
+ }, entry.id))
905
+ })
906
+ });
907
+ });
908
+ /**
909
+ * The live multiplier, warming as it climbs, that becomes the result at the
910
+ * crash: red and shaking on a loss, your cash out in primary on a win.
911
+ */
912
+ function CrashMultiplier({ game, className }) {
913
+ const { lost, crashed, cashed, reduce, pulse, round } = game;
914
+ const final = crashed && cashed !== null;
915
+ return /* @__PURE__ */ jsx(motion.p, {
916
+ className: cn("font-semibold tracking-tight tabular-nums transition-colors duration-150", className, lost ? "text-rose-600 dark:text-rose-400" : final ? "text-primary" : HEAT_TEXT[heat(game.multiplier)]),
917
+ animate: lost && !reduce ? { x: [
918
+ 0,
919
+ -6,
920
+ 6,
921
+ -3,
922
+ 3,
923
+ 0
924
+ ] } : { x: 0 },
925
+ transition: SHAKE,
926
+ children: /* @__PURE__ */ jsx(motion.span, {
927
+ className: "inline-block",
928
+ initial: reduce ? final ? { opacity: 0 } : false : final ? {
929
+ opacity: 0,
930
+ scale: .96,
931
+ filter: "blur(4px)"
932
+ } : pulse > 0 ? { scale: 1.08 } : false,
933
+ animate: {
934
+ opacity: 1,
935
+ scale: 1,
936
+ filter: "blur(0px)"
937
+ },
938
+ transition: final ? SWAP : PULSE,
939
+ children: formatMultiplier(final ? cashed : game.multiplier)
940
+ }, final ? "final" : pulse)
941
+ }, round);
942
+ }
943
+ /**
944
+ * The line under the multiplier: a hint before and during the flight, a
945
+ * solid badge from the cash out until the crash, then the round's context.
946
+ */
947
+ function CrashStatus({ game, className }) {
948
+ const { cashed, crashed, status, reduce } = game;
949
+ return /* @__PURE__ */ jsx("div", {
950
+ className: cn("flex h-6 items-center", className),
951
+ children: /* @__PURE__ */ jsx(AnimatePresence, {
952
+ initial: false,
953
+ mode: "popLayout",
954
+ children: cashed !== null && !crashed ? /* @__PURE__ */ jsxs(motion.p, {
955
+ className: "bg-primary text-primary-foreground inline-flex h-6 items-center gap-1 rounded-full pr-2.5 pl-2 text-xs font-medium tabular-nums",
956
+ initial: reduce ? { opacity: 0 } : {
957
+ opacity: 0,
958
+ scale: .96,
959
+ filter: "blur(4px)"
960
+ },
961
+ animate: {
962
+ opacity: 1,
963
+ scale: 1,
964
+ filter: "blur(0px)"
965
+ },
966
+ exit: {
967
+ opacity: 0,
968
+ transition: EXIT
969
+ },
970
+ transition: SWAP,
971
+ children: [
972
+ /* @__PURE__ */ jsx(Check, {
973
+ "aria-hidden": "true",
974
+ className: "size-3.5",
975
+ strokeWidth: 2.5
976
+ }),
977
+ "Cashed out ",
978
+ formatMultiplier(cashed)
979
+ ]
980
+ }, "cashed") : /* @__PURE__ */ jsx(motion.p, {
981
+ className: "text-muted-foreground text-xs tabular-nums",
982
+ initial: reduce ? { opacity: 0 } : {
983
+ opacity: 0,
984
+ y: 4,
985
+ filter: "blur(4px)"
986
+ },
987
+ animate: {
988
+ opacity: 1,
989
+ y: 0,
990
+ filter: "blur(0px)"
991
+ },
992
+ exit: {
993
+ opacity: 0,
994
+ transition: EXIT
995
+ },
996
+ transition: SWAP,
997
+ children: status
998
+ }, status)
999
+ })
1000
+ });
1001
+ }
1002
+ /**
1003
+ * The small uppercase state label: Ready, In flight, then the result:
1004
+ * Cashed out with a check, or Crashed with a cross.
1005
+ */
1006
+ function CrashEyebrow({ game, className }) {
1007
+ const { lost, crashed, running, cashed, reduce } = game;
1008
+ const icon = crashed ? lost ? "lost" : "won" : running && cashed === null ? "live" : null;
1009
+ return /* @__PURE__ */ jsxs("p", {
1010
+ className: cn("flex h-4 items-center gap-1.5 text-[11px] font-medium tracking-[0.08em] uppercase transition-colors duration-150", lost ? "text-rose-700 dark:text-rose-400" : crashed ? PRIMARY_TEXT : "text-muted-foreground", className),
1011
+ children: [/* @__PURE__ */ jsx(AnimatePresence, {
1012
+ initial: false,
1013
+ mode: "popLayout",
1014
+ children: icon ? /* @__PURE__ */ jsx(motion.span, {
1015
+ "aria-hidden": "true",
1016
+ className: "grid size-3.5 place-items-center",
1017
+ initial: reduce ? { opacity: 0 } : {
1018
+ opacity: 0,
1019
+ scale: .25,
1020
+ filter: "blur(4px)"
1021
+ },
1022
+ animate: {
1023
+ opacity: 1,
1024
+ scale: 1,
1025
+ filter: "blur(0px)"
1026
+ },
1027
+ exit: {
1028
+ opacity: 0,
1029
+ transition: EXIT
1030
+ },
1031
+ transition: SWAP,
1032
+ children: icon === "live" ? /* @__PURE__ */ jsx("span", { className: "bg-primary size-1.5 rounded-full" }) : icon === "won" ? /* @__PURE__ */ jsx(Check, {
1033
+ className: "size-3.5",
1034
+ strokeWidth: 3
1035
+ }) : /* @__PURE__ */ jsx(X, {
1036
+ className: "size-3.5",
1037
+ strokeWidth: 3
1038
+ })
1039
+ }, icon) : null
1040
+ }), game.eyebrow]
1041
+ });
1042
+ }
1043
+ /** The polite live region for starts, milestones, cash outs and crashes. */
1044
+ function CrashAnnouncer({ game }) {
1045
+ return /* @__PURE__ */ jsx("p", {
1046
+ "aria-live": "polite",
1047
+ className: "sr-only",
1048
+ children: game.announcement
1049
+ });
1050
+ }
1051
+ export { useCrashGame as S, crashPoint as _, PRIMARY_TEXT as a, growth as b, STAGE_W as c, wrap as d, BURST as f, SWAP as g, PULSE as h, MINI_REPLAY as i, clamp01 as l, GROWTH as m, CrashShell as n, Parachute as o, EXIT as p, MINI as r, STAGE_LABEL as s, CHUTE as t, niceAtLeast as u, formatMultiplier as v, timeAt as x, formatShort as y };
1052
+
1053
+ //# sourceMappingURL=crash-parts-CUv5gFYQ.js.map