@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 @@
1
+ {"version":3,"file":"crash-parts-CUv5gFYQ.js","names":["HistoryIcon"],"sources":["../src/components/motion/crash/use-crash-game.ts","../src/components/motion/crash/crash-parts.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { useReducedMotion } from \"motion/react\";\n\nimport { EASE_OUT } from \"../../../lib/ease\";\nimport { createGameSounds, type GameSounds } from \"../../../lib/game-sounds\";\n\n// The game every Crash design shares: the clock, the crash point, cashing out,\n// milestones, history, sound and announcements. A design only draws it.\n\nexport interface CrashProps {\n /** Multiplier to cash out at automatically (controlled), or null for manual play. Applies from the next round. */\n autoCashOut?: number | null;\n /** Initial auto cash-out when uncontrolled. Default null (off). */\n defaultAutoCashOut?: number | null;\n /** Called when the Auto menu changes between rounds. */\n onAutoCashOutChange?: (autoCashOut: number | null) => void;\n /**\n * Decides each round's crash point, called once when the round starts.\n * Return a number, or a Promise for one (a server round, a provably fair\n * hash): the main button shows Starting… until it settles, and a rejection\n * returns to Start. Values below 1 or not finite become 1, and values are\n * floored to two decimals. Default `crashPoint()`. Ignored when `crashAt`\n * is passed.\n */\n getCrashPoint?: () => number | Promise<number>;\n /**\n * Live rounds (controlled), for a server that keeps the crash point secret\n * until it happens: the round `onStart` was given and its crash point once\n * revealed, or null. A round flies open-ended until its own crash point\n * arrives; a value for any other round is ignored, so a reveal from last\n * round can't end this one. A value at or below the current multiplier\n * crashes at once, at that value, and a cash out above it never happened:\n * the round ends lost and `onCashOut` is not called. A value still ahead\n * means the display is behind the server: the flight runs out to it\n * quickly and takes no more hand cash outs (an auto target below it still\n * pays). Whether a round is live is fixed when it starts; dropping\n * `crashAt` mid-round ends it at the current multiplier.\n */\n crashAt?: CrashReveal | null;\n /** Called when the player starts a round, before its crash point is known, with the round's number (unique on the page). */\n onStart?: (round: number) => void;\n /**\n * Called when the player cashes out, by hand or automatically. In a live\n * round it waits until the crash point is revealed, so it only fires for a\n * cash out that stands.\n */\n onCashOut?: (multiplier: number) => void;\n /** Called when the round crashes, with the cash-out multiplier or null if the player was still in. */\n onCrash?: (crashPoint: number, cashedOut: number | null) => void;\n /** Play synthesized sounds (controlled): a climbing chime at each milestone (2× to 5×, then 10×, 20×, 50×…), a cash-out arpeggio and a crash blast. */\n sound?: boolean;\n /** Initial sound state when uncontrolled. Default false. */\n defaultSound?: boolean;\n /** Called when the sound button is toggled. */\n onSoundChange?: (sound: boolean) => void;\n /** Accessible name for the game. Default \"Crash\". */\n \"aria-label\"?: string;\n className?: string;\n}\n\nexport type CrashPhase = \"idle\" | \"starting\" | \"running\" | \"crashed\";\n\n/** A live round's crash point, tagged with the round `onStart` was given. */\nexport interface CrashReveal {\n round: number;\n value: number;\n}\n\n// The multiplier grows exponentially: 2× after 5.8s, 10× after 19s.\nexport const GROWTH = 0.12;\nexport const growth = (seconds: number) => Math.exp(GROWTH * seconds);\nexport const timeAt = (multiplier: number) => Math.log(multiplier) / GROWTH;\nconst MAX_CRASH = 1_000_000;\n// The highest multiplier a round can show: a passed crash point settles no\n// higher, and an open live round stops climbing here (about 32 minutes in)\n// rather than overflowing to Infinity.\nconst CEILING = 1e100;\n\n/**\n * A crash point from one uniform draw in [0, 1): the round reaches `m` with\n * probability (1 − houseEdge) / m, floored to two decimals and capped at\n * 1,000,000×. The default edge of 0 is a fair game. Pass your own `random`\n * for a seeded or provably fair round, for example the first 52 bits of a\n * round's HMAC-SHA256: `crashPoint(() => parseInt(hash.slice(0, 13), 16) / 2 ** 52, 0.01)`.\n */\nexport function crashPoint(random: () => number = Math.random, houseEdge = 0) {\n const edge = Math.min(Math.max(houseEdge, 0), 1);\n return Math.min(MAX_CRASH, Math.max(1, Math.floor((100 * (1 - edge)) / (1 - random())) / 100));\n}\n\n/**\n * A passed crash point as the game plays it: at least 1 and floored to two\n * decimals, the way crash games display them. The round ends on exactly the\n * caller's value up to the 1e100 ceiling; `crashPoint()` caps at 1,000,000.\n * Anything not finite plays as 1.\n */\nconst settle = (point: number) => {\n if (!Number.isFinite(point)) return 1;\n return Math.max(1, floor2(Math.min(point, CEILING)));\n};\n\n/**\n * Multipliers announced (and chimed) while the player is in: 2× to 5×, then\n * 10×, 20×, 50×, 100× and on, so a long flight stays quiet enough to follow.\n */\nexport function milestone(index: number) {\n if (index < 4) return index + 2;\n return [10, 20, 50][(index - 4) % 3] * 10 ** Math.floor((index - 4) / 3);\n}\n\n// Auto cash-out targets offered in the menu, after Off.\nexport const AUTO_STEPS = [1.5, 2, 3, 5, 10, 25, 100];\n\n// Skipping after a cash out runs the rest of the flight in at most this long.\nconst SKIP_TIME = 0.8;\n// Presses this soon after a start, a cash-out press or a crash are the same\n// press repeated (a double tap, a mash), not the next action (ms).\nconst PRESS_GUARD = 400;\n// Round numbers, unique on the page, so a live reveal kept by the parent\n// across a remount can't match a fresh round.\nlet rounds = 0;\nconst HISTORY = 12;\n\n// Motion shared by every design.\n// A loss shakes the readout once, quickly; a burst spreads from the crash.\nexport const SHAKE = { duration: 0.3, ease: EASE_OUT } as const;\nexport const BURST = { duration: 0.45, ease: EASE_OUT } as const;\n// Status lines and markers swap on a spring with no bounce.\nexport const SWAP = { type: \"spring\", duration: 0.3, bounce: 0 } as const;\n// A milestone swells the readout and lets it settle with a little give.\nexport const PULSE = { type: \"spring\", duration: 0.35, bounce: 0.3 } as const;\n// Exits are shorter than entrances.\nexport const EXIT = { duration: 0.12, ease: EASE_OUT } as const;\n\nexport function useCrashGame({\n autoCashOut: autoProp,\n defaultAutoCashOut = null,\n onAutoCashOutChange,\n getCrashPoint,\n crashAt,\n onStart,\n onCashOut,\n onCrash,\n sound,\n defaultSound = false,\n onSoundChange,\n}: Omit<CrashProps, \"aria-label\" | \"className\">) {\n // Live rounds: the crash point arrives through `crashAt` while flying.\n const live = crashAt !== undefined;\n const reduce = useReducedMotion() ?? false;\n const [internalAuto, setInternalAuto] = useState(defaultAutoCashOut);\n const rawAuto = autoProp === undefined ? internalAuto : autoProp;\n const auto =\n rawAuto === null || !Number.isFinite(rawAuto) ? null : Math.max(1.01, floor2(rawAuto));\n const [phase, setPhase] = useState<CrashPhase>(\"idle\");\n const [round, setRound] = useState(0);\n const [elapsed, setElapsed] = useState(0);\n const [cashed, setCashed] = useState<number | null>(null);\n // Seconds into the flight at the cash out. The value is floored to two\n // decimals, so a design that counts steps (Tower's blocks) needs the time.\n const [cashedT, setCashedT] = useState<number | null>(null);\n const [crashedAt, setCrashedAt] = useState<number | null>(null);\n const [history, setHistory] = useState<{ id: number; value: number }[]>([]);\n const [announcement, setAnnouncement] = useState(\"\");\n // Counts milestones passed this round; each one pulses the readout.\n const [pulse, setPulse] = useState(0);\n // The auto target locked in when the round started.\n const [roundAuto, setRoundAuto] = useState<number | null>(null);\n // The flight lives in a ref so each frame can read and advance it. The\n // crash point stays out of state until it is reached. `milestone` indexes\n // the next multiplier to announce. `pressTime` is the last take-off,\n // cash-out press or crash, in performance.now() ms. `held` is a live cash out waiting on\n // the crash point before `onCashOut` hears of it.\n const flight = useRef({\n round: 0,\n live: false,\n t: 0,\n rate: 1,\n crash: 1,\n auto: null as number | null,\n milestone: 0,\n pressTime: Number.NEGATIVE_INFINITY,\n held: false,\n });\n const cashedRef = useRef<number | null>(null);\n // A round is in progress from Start until it crashes or fails to start. A\n // ref, not render state: two clicks in one frame both see the old phase,\n // so a second start would ask for a second crash point (a second server\n // round), and a click landing just after the crash frame would cash out a\n // round that has already ended.\n const busy = useRef(false);\n // Drops a crash point that settles after unmount. Set in the effect body\n // as well as cleared in its cleanup, so StrictMode's dev remount turns it\n // back on.\n const alive = useRef(true);\n useEffect(() => {\n alive.current = true;\n return () => {\n alive.current = false;\n };\n }, []);\n\n const [internalSound, setInternalSound] = useState(defaultSound);\n const soundOn = sound ?? internalSound;\n const player = useRef<GameSounds | null>(null);\n const getPlayer = () => {\n if (!player.current) player.current = createGameSounds();\n return player.current;\n };\n useEffect(\n () => () => {\n player.current?.dispose();\n player.current = null;\n },\n [],\n );\n\n const running = phase === \"running\";\n const starting = phase === \"starting\";\n const crashed = phase === \"crashed\";\n // Unknown only in a live round the server hasn't ended yet. From the\n // round's own mode, which a prop change mid-round doesn't move.\n const roundLive = flight.current.live;\n const crashKnown = !roundLive || crashAt?.round === round;\n // A live round the server has ended while the display catches up.\n const overtaken = running && roundLive && crashKnown;\n const t = crashed && crashedAt !== null ? timeAt(crashedAt) : elapsed;\n const multiplier = crashed && crashedAt !== null ? crashedAt : floor2(growth(t));\n\n const cashOut = (value: number, time: number) => {\n if (!busy.current || cashedRef.current !== null) return;\n cashedRef.current = value;\n setCashed(value);\n setCashedT(time);\n setAnnouncement(`Cashed out at ${formatMultiplier(value)}.`);\n if (soundOn) getPlayer().cashOut();\n // A live cash out stands only if the crash point turns out above it.\n if (Number.isFinite(flight.current.crash)) onCashOut?.(value);\n else flight.current.held = true;\n };\n\n // Takes off once the crash point is settled (Infinity: not yet revealed).\n const fly = (id: number, crash: number) => {\n flight.current = {\n round: id,\n live,\n t: 0,\n rate: 1,\n crash,\n auto,\n milestone: 0,\n // Kept from start(): an async crash point can take a while, and the\n // first tap after it lands is a real cash out.\n pressTime: flight.current.pressTime,\n held: false,\n };\n setPhase(\"running\");\n setAnnouncement(\n auto === null\n ? \"Round started.\"\n : `Round started. Auto cash out at ${formatMultiplier(auto)}.`,\n );\n };\n\n const start = () => {\n // From the ref, not render state: two clicks in one frame both see the\n // old phase, and a second start would ask for a second crash point (a\n // second server round).\n if (busy.current) return;\n busy.current = true;\n rounds += 1;\n const id = rounds;\n // Before any state changes: if it throws, the round never began and the\n // last one's result stays as it was.\n try {\n onStart?.(id);\n } catch (error) {\n busy.current = false;\n throw error;\n }\n // The guard against a double tap on Start cashing out at once.\n flight.current.pressTime = performance.now();\n cashedRef.current = null;\n setCashed(null);\n setCashedT(null);\n setCrashedAt(null);\n setElapsed(0);\n setPulse(0);\n setRoundAuto(auto);\n setRound(id);\n if (soundOn) getPlayer().prepare();\n if (live) {\n fly(id, Number.POSITIVE_INFINITY);\n return;\n }\n let point: number | Promise<number>;\n try {\n point = getCrashPoint ? getCrashPoint() : crashPoint();\n } catch {\n point = Promise.reject();\n }\n if (typeof point === \"number\") {\n fly(id, settle(point));\n return;\n }\n setPhase(\"starting\");\n setAnnouncement(\"Starting round.\");\n // Promise.resolve: a plain-JS caller may hand back something else.\n Promise.resolve(point).then(\n (value) => {\n if (alive.current) fly(id, settle(value));\n },\n () => {\n if (!alive.current) return;\n busy.current = false;\n setPhase(\"idle\");\n setAnnouncement(\"The round couldn't start. Try again.\");\n },\n );\n };\n\n // Runs the rest of the flight quickly; reduced motion jumps to the crash.\n // A live round still waiting on its crash point can't be run out.\n const skip = () => {\n const f = flight.current;\n if (!Number.isFinite(f.crash)) return;\n f.rate = reduce ? 1e9 : Math.max(1, (timeAt(f.crash) - f.t) / SKIP_TIME);\n };\n\n const onFrame = useStable((dt: number) => {\n // The round already ended: a frame booked before a throwing onCrash.\n if (!busy.current) return false;\n const f = flight.current;\n const wasIn = cashedRef.current === null;\n // A live round's crash point lands whenever the server reveals it; one\n // already behind the plane crashes at once, at that value. One ahead is\n // a display running late: the server has crashed, so the flight runs\n // out to it like a skip.\n if (f.live && !Number.isFinite(f.crash) && crashAt?.round === f.round) {\n f.crash = settle(crashAt.value);\n f.rate = reduce ? 1e9 : Math.max(1, (timeAt(f.crash) - f.t) / SKIP_TIME);\n // The server's crash came before the player's cash out: it never\n // happened, so the round is lost after all.\n if (cashedRef.current !== null && cashedRef.current > f.crash) {\n cashedRef.current = null;\n setCashed(null);\n setCashedT(null);\n f.held = false;\n }\n }\n // The live round lost its crash point source mid-flight: nothing can\n // end it any more, so it ends here. A held cash out was never confirmed\n // by the server, so it doesn't stand.\n if (f.live && !live && !Number.isFinite(f.crash)) {\n f.crash = settle(growth(f.t));\n if (f.held) {\n f.held = false;\n cashedRef.current = null;\n setCashed(null);\n setCashedT(null);\n }\n }\n // A held live cash out stands now the crash point is known.\n if (f.held && Number.isFinite(f.crash) && cashedRef.current !== null) {\n f.held = false;\n onCashOut?.(cashedRef.current);\n }\n const end = timeAt(f.crash);\n f.t = Math.min(end, f.t + dt * f.rate, timeAt(CEILING));\n const value = growth(f.t);\n if (cashedRef.current === null) {\n // A target at or below the crash point always pays, at the target. The\n // crash check covers a target equal to the crash point.\n if (f.auto !== null && f.auto <= f.crash && (value >= f.auto || f.t >= end))\n cashOut(f.auto, timeAt(f.auto));\n // Finite: an open live round that runs for hours overflows to Infinity.\n // Not during a live run-out: the round is already decided.\n else if (\n f.rate === 1 &&\n f.t < end &&\n Number.isFinite(value) &&\n value >= milestone(f.milestone)\n ) {\n // A long frame can cross several; only the last is told.\n while (value >= milestone(f.milestone + 1)) f.milestone++;\n setAnnouncement(formatShort(milestone(f.milestone)));\n setPulse((count) => count + 1);\n f.milestone++;\n if (soundOn) getPlayer().gem(f.milestone);\n }\n }\n if (f.t < end) {\n setElapsed(f.t);\n return true;\n }\n busy.current = false;\n f.pressTime = performance.now();\n setCrashedAt(f.crash);\n setPhase(\"crashed\");\n setHistory((current) => [{ id: f.round, value: f.crash }, ...current].slice(0, HISTORY));\n setAnnouncement(\n cashedRef.current === null\n ? `Crashed at ${formatMultiplier(f.crash)}. The round is lost.`\n : // A cash out on this same frame (a target at the crash point, a\n // long frame) would otherwise never be heard.\n `${wasIn ? `Cashed out at ${formatMultiplier(cashedRef.current)}. ` : \"\"}Crashed at ${formatMultiplier(f.crash)}.`,\n );\n if (soundOn) getPlayer().mine();\n onCrash?.(f.crash, cashedRef.current);\n return false;\n });\n\n useEffect(() => {\n if (phase !== \"running\") return;\n let last = performance.now();\n // performance.now(), not the frame timestamp, so both ends share one clock.\n let id = requestAnimationFrame(function step() {\n const now = performance.now();\n const dt = Math.max(0, now - last) / 1000;\n last = now;\n // The next frame is booked first, so a consumer callback that throws\n // can't stall a running round; the crash cancels it.\n id = requestAnimationFrame(step);\n if (!onFrame(dt)) cancelAnimationFrame(id);\n });\n return () => cancelAnimationFrame(id);\n }, [phase, onFrame]);\n\n // Stable, so the menu and sound button can skip the 60fps re-renders.\n const setAuto = useStable((value: string) => {\n const next = value === \"off\" ? null : Number(value);\n if (autoProp === undefined) setInternalAuto(next);\n onAutoCashOutChange?.(next);\n });\n // A custom target from the prop gets its own option, so the menu can show it.\n const autoOptions = useMemo(\n () =>\n auto === null || AUTO_STEPS.includes(auto)\n ? AUTO_STEPS\n : [...AUTO_STEPS, auto].sort((a, b) => a - b),\n [auto],\n );\n\n const toggleSound = useStable(() => {\n const next = !soundOn;\n if (next) getPlayer().prepare();\n if (sound === undefined) setInternalSound(next);\n onSoundChange?.(next);\n });\n\n /** Start, cash out or skip, whichever the round is ready for. */\n const act = () => {\n const now = performance.now();\n // A double tap on Start mustn't cash out at 1.01×, nor a mashed cash out\n // skip or start the next round. An auto cash out doesn't count as a\n // press, so it can be skipped at once.\n if (starting || now - flight.current.pressTime < PRESS_GUARD) return;\n if (!running) start();\n else if (cashedRef.current === null) {\n // The server already ended this live round; the display is catching\n // up. `overtaken` covers the frame before onFrame takes the reveal.\n if (overtaken || (flight.current.live && Number.isFinite(flight.current.crash))) return;\n flight.current.pressTime = now;\n cashOut(floor2(growth(flight.current.t)), flight.current.t);\n } else skip();\n };\n const actionLabel = starting\n ? \"Starting…\"\n : running\n ? cashed === null\n ? overtaken\n ? \"Crashing…\"\n : `Cash out ${formatMultiplier(multiplier)}`\n : crashKnown\n ? \"Skip to crash\"\n : \"Waiting for crash\"\n : crashed\n ? \"Play again\"\n : \"Start\";\n /** The main action can't act right now: the crash point is still coming, or a live round is already over. */\n const actionBusy =\n starting || (running && cashed !== null && !crashKnown) || (overtaken && cashed === null);\n\n // Red is kept for a loss: a crash after a cash out is no bad news.\n const lost = crashed && cashed === null;\n // At the end of a round the readout becomes the result: won or lost, the\n // number that counts, and one line of context.\n const eyebrow = lost\n ? \"Crashed\"\n : crashed\n ? \"Cashed out\"\n : running\n ? \"In flight\"\n : starting\n ? \"Starting\"\n : \"Ready\";\n // In flight the round's locked target, not a menu change made since.\n const shownAuto = running ? roundAuto : auto;\n const status = crashed\n ? cashed !== null\n ? // Within 10% of the crash is a close call.\n multiplier / cashed < 1.1\n ? `Crashed at ${formatMultiplier(multiplier)}, a close call`\n : `It flew on to ${formatMultiplier(multiplier)}`\n : roundAuto !== null\n ? `Short of your ${formatShort(roundAuto)} target`\n : \"You were still in\"\n : shownAuto !== null\n ? `Auto cash out at ${formatMultiplier(shownAuto)}`\n : running\n ? \"Cash out before it crashes\"\n : \"Start a round\";\n\n // What a design marks ahead of the flight: the auto target until it pays\n // (the menu's choice while idle, the locked one in flight), and the last\n // round's crash point as a faint trace. Both are null when there is none.\n const target = cashed !== null || crashed ? null : running ? roundAuto : auto;\n const ghost = (crashed ? history[1] : history[0])?.value ?? null;\n\n return {\n reduce,\n /** The built-in fair crash point decides the round, so \"1 in m\" odds hold. */\n fair: !live && !getCrashPoint,\n target,\n ghost,\n /** The auto target the current or last round played with. */\n roundAuto,\n phase,\n running,\n starting,\n crashed,\n lost,\n /** A skip is running the rest of the flight out; scenery that streams with t would only flicker. */\n skipping: running && flight.current.rate > 1,\n /** Seconds into the flight, frozen at the crash. */\n t,\n multiplier,\n cashed,\n /** Seconds into the flight at the cash out, or null. */\n cashedT,\n round,\n pulse,\n history,\n auto,\n autoOptions,\n setAuto,\n soundOn,\n toggleSound,\n act,\n actionLabel,\n actionBusy,\n eyebrow,\n status,\n announcement,\n };\n}\n\nexport type CrashGame = ReturnType<typeof useCrashGame>;\n\n/**\n * A callback with one identity for the component's life that runs the latest\n * render's code. Stands in for useEffectEvent, which needs React 19.2.\n */\nexport function useStable<A extends unknown[], R>(fn: (...args: A) => R) {\n const ref = useRef(fn);\n useLayoutEffect(() => {\n ref.current = fn;\n });\n return useCallback((...args: A) => ref.current(...args), []);\n}\n\n/**\n * How hot a multiplier reads: cool under 2×, warm to 10×, hot beyond. The\n * readout and the history colour by it, so size reads without the digits.\n */\nexport function heat(multiplier: number) {\n return multiplier >= 10 ? \"hot\" : multiplier >= 2 ? \"warm\" : \"cool\";\n}\n\nexport function floor2(value: number) {\n return Math.floor(value * 100 + 1e-9) / 100;\n}\n\n// Truncated, never rounded up: a 10,960× payout reads 10.9K×, not 11K×.\nconst COMPACT = new Intl.NumberFormat(\"en\", {\n notation: \"compact\",\n maximumFractionDigits: 1,\n roundingMode: \"trunc\",\n});\n\n/**\n * Large values: compact up to trillions, then scientific (1.4e100), since\n * compact notation stops at T and would print 1e100 as a 100-digit string.\n */\nfunction formatLarge(multiplier: number) {\n if (multiplier < 1e15) return COMPACT.format(multiplier);\n // From toExponential, not log10: 1e100 / 10 ** 100 is 0.999….\n const [mantissa, exponent] = multiplier.toExponential(6).split(\"e\");\n return `${Math.floor(Number(mantissa) * 10) / 10}e${Number(exponent)}`;\n}\n\n/** A multiplier as Crash shows it: 2.50×, or shortened when large (12.5K×, 1.4e20×). */\nexport function formatMultiplier(multiplier: number) {\n return `${multiplier < 10_000 ? multiplier.toFixed(2) : formatLarge(multiplier)}×`;\n}\n\n/** Scale and menu labels: 1.5×, 2×, 1.2K×. */\nexport function formatShort(multiplier: number) {\n return `${multiplier < 1000 ? +multiplier.toFixed(2) : formatLarge(multiplier)}×`;\n}\n","\"use client\";\n\n// Pieces every Crash design shares, so each design only draws its stage.\n\nimport {\n memo,\n type ReactNode,\n type Ref,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { Check, History as HistoryIcon, Volume2, VolumeX, X } from \"lucide-react\";\nimport { AnimatePresence, motion, type Transition } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_IN_OUT, EASE_OUT, SPRING_LAYOUT } from \"../../../lib/ease\";\nimport { PresenceGate, type PresenceGateRenderProps } from \"../../../lib/presence-gate\";\nimport { ActionSwapCascadeIcon } from \"../action-swap-cascade\";\nimport { Button } from \"../button\";\nimport { NumberTicker } from \"../number-ticker\";\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from \"../select\";\nimport { Tooltip } from \"../tooltip\";\nimport {\n type CrashGame,\n EXIT,\n formatMultiplier,\n formatShort,\n growth,\n heat,\n PULSE,\n SHAKE,\n SWAP,\n useStable,\n} from \"./use-crash-game\";\n\n/**\n * Primary for small text: a shade darker on light surfaces and lighter on\n * dark ones, so 10-12px labels keep 4.5:1. Large text and marks use plain\n * primary.\n */\nexport const PRIMARY_TEXT =\n \"text-[color:color-mix(in_oklab,var(--color-primary)_75%,black)] dark:text-[color:color-mix(in_oklab,var(--color-primary)_80%,white)]\";\n\n// Readout and history colours per heat: neutral, then primary, then amber.\nconst HEAT_TEXT = {\n cool: \"text-foreground\",\n warm: \"text-primary\",\n hot: \"text-amber-700 dark:text-amber-400\",\n} as const;\nconst HEAT_PILL = {\n cool: \"bg-foreground/5 text-muted-foreground\",\n warm: `bg-primary/10 ${PRIMARY_TEXT}`,\n hot: \"bg-amber-500/15 text-amber-700 dark:text-amber-400\",\n} as const;\n\n/** The width of the viewBox an SVG stage draws in. */\nexport const STAGE_W = 400;\n/**\n * SVG stage labels: 10px on screen however narrow the card. A viewBox scales\n * its text with the stage, so the shell sets --crash-label in viewBox units.\n * The server render has no width to go on and draws them at 10 units.\n */\nexport const STAGE_LABEL = \"text-[length:var(--crash-label,10px)]\";\n\n/**\n * The frame every design sits in: one card holding the recent rounds and\n * sound, the stage with the readout pinned top left, and the controls. Each\n * design draws only its stage, which must keep the top-left corner clear.\n */\nexport function CrashShell({\n game,\n \"aria-label\": ariaLabel,\n className,\n children,\n miniature,\n}: {\n game: CrashGame;\n \"aria-label\": string;\n className?: string;\n children: ReactNode;\n /** The design's own replay of the round on the result ticket. */\n miniature?: (props: CrashMiniatureProps) => ReactNode;\n}) {\n const mainRef = useRef<HTMLButtonElement>(null);\n const stageRef = useRef<HTMLDivElement>(null);\n // Written straight to the style, so a resize doesn't re-render the game.\n useLayoutEffect(() => {\n const node = stageRef.current;\n if (!node) return;\n const measure = () => {\n const width = node.clientWidth;\n if (width > 0)\n node.style.setProperty(\"--crash-label\", `${Math.max(10, (10 * STAGE_W) / width)}px`);\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(node);\n return () => observer.disconnect();\n }, []);\n // The ticket opens per round once the crash has played; tapping the stage\n // or Escape puts it away, and the next round clears it.\n const [openRound, setOpenRound] = useState<number | null>(null);\n const resultShown = game.crashed && openRound === game.round;\n const { crashed, round } = game;\n // Read when the round ends, so a reduced-motion change can't reopen a closed ticket.\n const ticketDelay = useStable(() => (game.reduce ? 0.15 : TICKET_DELAY) * 1000);\n useEffect(() => {\n if (!crashed) return;\n // A timer, not an animation callback, so a cut-short animation can't keep it shut.\n // Focus stays where it is: nothing focusable sits under the ticket, and\n // the main button, which now says Play again, kept focus through the round.\n const id = setTimeout(() => setOpenRound(round), ticketDelay());\n return () => clearTimeout(id);\n }, [crashed, round, ticketDelay]);\n const closeResult = () => {\n setOpenRound(null);\n mainRef.current?.focus();\n };\n\n return (\n <section\n aria-label={ariaLabel}\n // Focusable by script and click only: a tap on the stage keeps focus in\n // the game, so Escape still reaches the ticket.\n tabIndex={-1}\n className={cn(\"w-full max-w-md outline-none\", className)}\n onKeyDown={(event) => {\n if (event.key !== \"Escape\" || !resultShown) return;\n // An open Auto menu takes this Escape (it listens on window, after us).\n if (\n event.target instanceof Element &&\n event.target.closest('[role=\"listbox\"],[aria-expanded=\"true\"]')\n )\n return;\n // Escape is used up here; an enclosing dialog must not close too.\n event.stopPropagation();\n closeResult();\n }}\n >\n {/* 24px card corners = 12px stage and control corners + 12px padding. */}\n <div className=\"border-border flex flex-col gap-3 rounded-3xl border p-3\">\n <div className=\"flex h-8 items-center gap-2 pl-1\">\n <HistoryIcon\n aria-hidden=\"true\"\n className=\"text-muted-foreground size-3.5 shrink-0\"\n strokeWidth={2}\n />\n {/* The game changes every frame; these take only what they show, so they skip those renders. */}\n <CrashHistory history={game.history} reduce={game.reduce} className=\"min-w-0 flex-1\" />\n <SoundToggle on={game.soundOn} onToggle={game.toggleSound} />\n </div>\n {/* A 10:7 stage in every design, so switching between them never\n jumps. A container: its width also fixes its height. */}\n <div\n ref={stageRef}\n className=\"bg-muted/40 @container relative aspect-[10/7] overflow-hidden rounded-xl\"\n >\n {children}\n <div className=\"pointer-events-none absolute top-4 left-4\">\n <CrashEyebrow game={game} />\n {/* Smaller on narrow stages, so the readout leaves the design room. */}\n <CrashMultiplier\n game={game}\n className=\"mt-1 text-3xl @min-[20rem]:text-4xl [&>span]:origin-left\"\n />\n <CrashStatus game={game} className=\"mt-2\" />\n </div>\n <AnimatePresence>\n {resultShown ? (\n <PresenceGate key=\"result\">\n {({ gate }) => (\n <ResultTicket\n game={game}\n gate={gate}\n onClose={closeResult}\n miniature={miniature}\n />\n )}\n </PresenceGate>\n ) : null}\n </AnimatePresence>\n </div>\n <CrashControls game={game} mainRef={mainRef} />\n </div>\n <CrashAnnouncer game={game} />\n </section>\n );\n}\n\n// The ticket rises once each design's crash (tumble, pop, topple: 0.6s to\n// 0.75s) has mostly played, the same receipt Mines ends on: a stub notched at a\n// dashed tear line, the outcome above, the round's figures and a miniature\n// of the flight below.\nconst TICKET_DELAY = 0.7;\n// Rises with a little settle (a rare, end-of-round moment), leaves quickly.\nconst CARD_IN = { type: \"spring\", duration: 0.4, bounce: 0.15 } as const;\nconst CARD_OUT = { duration: 0.15, ease: EASE_OUT } as const;\n// Inside, chunks arrive in reading order, then the flight replays.\nconst CHUNK = { duration: 0.25, ease: EASE_OUT } as const;\n// The tear line sits this far down; the side notches are cut there.\nconst TEAR = 104;\n// A drop-shadow on the ticket's wrapper: the notch mask would clip a\n// box-shadow on the ticket itself.\nconst TICKET_SHADOW =\n \"[filter:drop-shadow(0_1px_1px_rgb(0_0_0/0.12))_drop-shadow(0_12px_16px_rgb(0_0_0/0.3))]\";\nconst NOTCH_MASK = `radial-gradient(circle 9px at 0 ${TEAR}px, transparent 98%, black), radial-gradient(circle 9px at 100% ${TEAR}px, transparent 98%, black)`;\n\n/**\n * The end-of-round receipt over a dimmed stage. It has no buttons: the main\n * action already says Play again, and tapping the stage (or Escape) puts it\n * away to look at the flight.\n */\nfunction ResultTicket({\n game,\n gate,\n onClose,\n miniature,\n}: {\n game: CrashGame;\n gate: PresenceGateRenderProps[\"gate\"];\n onClose: () => void;\n miniature?: (props: CrashMiniatureProps) => ReactNode;\n}) {\n const { reduce } = game;\n return (\n <>\n <motion.button\n type=\"button\"\n aria-label=\"Hide result and show the flight\"\n onClick={onClose}\n {...gate}\n 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\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0, transition: CARD_OUT }}\n transition={{ duration: 0.2, ease: EASE_OUT }}\n />\n <div\n inert={gate.inert}\n className=\"pointer-events-none absolute inset-0 z-20 grid place-items-center p-4\"\n >\n <motion.div\n role=\"group\"\n aria-label=\"Round result\"\n // Sized here: the ticket is a size container, so it can't take its\n // width from its contents.\n className={cn(\"w-full max-w-[17rem]\", TICKET_SHADOW)}\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 16, scale: 0.96 }}\n animate={{ opacity: 1, y: 0, scale: 1 }}\n exit={\n reduce\n ? { opacity: 0, transition: CARD_OUT }\n : { opacity: 0, y: 8, scale: 0.98, transition: CARD_OUT }\n }\n transition={reduce ? { duration: 0.2 } : CARD_IN}\n >\n <Ticket game={game} miniature={miniature} />\n </motion.div>\n </div>\n </>\n );\n}\n\nfunction Chunk({\n delay,\n reduce,\n className,\n children,\n}: {\n delay: number;\n reduce: boolean;\n className?: string;\n children: ReactNode;\n}) {\n return (\n <motion.div\n className={className}\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 6 }}\n animate={{ opacity: 1, y: 0 }}\n transition={{ ...CHUNK, delay: reduce ? 0 : delay }}\n >\n {children}\n </motion.div>\n );\n}\n\nfunction Ticket({\n game,\n miniature,\n}: {\n game: CrashGame;\n miniature?: (props: CrashMiniatureProps) => ReactNode;\n}) {\n const { cashed, multiplier: crash, roundAuto, reduce, t } = game;\n const won = cashed !== null;\n return (\n <div\n // The stub is about 200px tall; a short stage (its width sets its\n // height) scales it down rather than clipping it.\n className=\"bg-card text-foreground @container w-full rounded-2xl @max-[17rem]:scale-[0.72] @min-[17rem]:@max-[21rem]:scale-[0.85]\"\n style={{\n WebkitMaskImage: NOTCH_MASK,\n WebkitMaskComposite: \"source-in\",\n maskImage: NOTCH_MASK,\n maskComposite: \"intersect\",\n }}\n >\n <div\n className={cn(\n \"flex flex-col items-center justify-center gap-1 rounded-t-2xl px-5 text-center\",\n won ? \"bg-primary/10\" : \"bg-rose-500/10\",\n )}\n style={{ height: TEAR }}\n >\n <Chunk delay={0.05} reduce={reduce}>\n <p\n className={cn(\n \"text-xs font-medium tracking-wide uppercase\",\n won ? PRIMARY_TEXT : \"text-rose-700 dark:text-rose-400\",\n )}\n >\n {won ? \"Cashed out\" : \"Crashed\"}\n </p>\n </Chunk>\n <Chunk delay={0.1} reduce={reduce}>\n <p\n className={cn(\n \"text-3xl font-semibold\",\n !won && \"text-muted-foreground line-through decoration-2\",\n )}\n >\n {won ? (\n <NumberTicker\n value={cashed}\n decimals={2}\n format={(value) => formatMultiplier(value).slice(0, -1)}\n suffix=\"×\"\n startOnView={false}\n duration={0.6}\n stagger={0.05}\n />\n ) : (\n // The multiplier is lost: struck through, as Mines does. A plain\n // span, since a line-through skips the ticker's inline-block digits.\n <span className=\"tabular-nums\">{formatMultiplier(crash)}</span>\n )}\n </p>\n </Chunk>\n </div>\n <div aria-hidden=\"true\" className=\"border-border mx-4 border-t-2 border-dashed\" />\n <div className=\"flex items-center gap-4 px-5 pt-4 pb-5\">\n <Chunk delay={0.18} reduce={reduce} className=\"flex-1\">\n <dl className=\"grid gap-1.5 text-xs\">\n <Row label=\"Crashed at\" value={formatMultiplier(crash)} />\n <Row label=\"Flight\" value={`${t.toFixed(1)}s`} />\n {won && game.fair ? (\n // The built-in round reaches m with a chance of 1 in m, as with\n // Mines' odds; a custom crash point makes no such promise.\n <Row label=\"Odds beaten\" value={`1 in ${formatMultiplier(cashed).slice(0, -1)}`} />\n ) : won ? (\n <Row label=\"You left at\" value={formatMultiplier(cashed)} />\n ) : (\n <Row\n label=\"Auto target\"\n value={roundAuto === null ? \"Off\" : formatShort(roundAuto)}\n />\n )}\n </dl>\n </Chunk>\n {/* A narrow ticket keeps the figures on one line each and drops the miniature. */}\n {miniature ? (\n <Chunk delay={0.24} reduce={reduce} className=\"@max-[15rem]:hidden\">\n {miniature({\n crash,\n cashed,\n cashedT: game.cashedT,\n target: won ? null : roundAuto,\n reduce,\n })}\n </Chunk>\n ) : null}\n </div>\n </div>\n );\n}\n\nfunction Row({ label, value }: { label: string; value: string }) {\n return (\n <div className=\"flex justify-between gap-2 whitespace-nowrap\">\n <dt className=\"text-muted-foreground\">{label}</dt>\n <dd className=\"font-medium tabular-nums\">{value}</dd>\n </div>\n );\n}\n\n/** What a design's ticket miniature replays: the round's crash, your cash out and a missed target. */\nexport interface CrashMiniatureProps {\n crash: number;\n cashed: number | null;\n /** Seconds into the flight at the cash out, for designs that count steps. */\n cashedT: number | null;\n /** The auto target, only when the round crashed short of it. */\n target: number | null;\n reduce: boolean;\n}\n\n// The parachute drifting down from a cash out is a once-a-round moment, so it\n// may take its time.\nexport const CHUTE: Transition = {\n y: { duration: 2.2, ease: EASE_OUT },\n rotate: { duration: 2.2, ease: EASE_IN_OUT },\n opacity: { duration: 2.2, times: [0, 0.08, 0.7, 1] },\n};\n\nexport const clamp01 = (value: number) => Math.min(1, Math.max(0, value));\n\n/** Wraps scenery that streams past into a loop `span` long. */\nexport const wrap = (value: number, span: number) => ((value % span) + span) % span;\n\n/** A tick step of 1, 2 or 5 times a power of ten, at least `min`. */\nexport function niceAtLeast(min: number) {\n const power = 10 ** Math.floor(Math.log10(min));\n // toPrecision drops float noise (0.30000000000000004), so steps add up cleanly.\n return Number(\n (([1, 2, 5, 10].find((unit) => unit * power >= min) ?? 10) * power).toPrecision(12),\n );\n}\n\n/** The parachute that opens at a cash out: a scalloped canopy, three lines and the player. */\nexport function Parachute() {\n return (\n <g className=\"text-primary\">\n <path d=\"M-9,0Q-9,-11 0,-11Q9,-11 9,0Q6,-3 3,0Q0,-3 -3,0Q-6,-3 -9,0Z\" fill=\"currentColor\" />\n <path\n d=\"M-9,0L0,10M0,0L0,10M9,0L0,10\"\n stroke=\"currentColor\"\n strokeWidth={0.75}\n opacity={0.6}\n fill=\"none\"\n />\n <circle cy={11.5} r={2} fill=\"currentColor\" />\n </g>\n );\n}\n\n/** Every miniature is 88 × 48, like Mines' mini map. */\nexport const MINI = { width: 88, height: 48 } as const;\n// The replay starts once the ticket's figures are in, and draws over 0.6s.\nexport const MINI_REPLAY = { delay: 0.3, duration: 0.6, ease: EASE_OUT } as const;\n\n/** The sound toggle: a quiet 32px icon button in the card's header. */\nconst SoundToggle = memo(function SoundToggle({\n on,\n onToggle,\n}: {\n on: boolean;\n onToggle: () => void;\n}) {\n return (\n // aria-label names the button; the tooltip shows the same label on hover\n // and focus. Tooltip's asLabel would hydrate differently from the server.\n <Tooltip content=\"Sound\" side=\"top\">\n <Button\n variant=\"ghost\"\n onClick={onToggle}\n aria-label=\"Sound\"\n aria-pressed={on}\n pressScale={0.96}\n className={cn(\"size-8 shrink-0 rounded-xl px-0\", on && \"text-foreground\")}\n >\n <ActionSwapCascadeIcon value={on ? \"on\" : \"off\"} className=\"size-4\">\n {on ? (\n <Volume2 aria-hidden=\"true\" className=\"size-4\" />\n ) : (\n <VolumeX aria-hidden=\"true\" className=\"size-4\" />\n )}\n </ActionSwapCascadeIcon>\n </Button>\n </Tooltip>\n );\n});\n\n/** The Auto menu and the main action, in one 40px row with 12px corners. */\nfunction CrashControls({ game, mainRef }: { game: CrashGame; mainRef: Ref<HTMLButtonElement> }) {\n return (\n <div className=\"flex items-center gap-2\">\n <AutoMenu\n auto={game.auto}\n options={game.autoOptions}\n onChange={game.setAuto}\n disabled={game.running || game.starting}\n />\n\n <Button\n ref={mainRef}\n 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\"\n // aria-disabled, not disabled: the button keeps keyboard focus while the\n // crash point is on its way.\n aria-disabled={game.actionBusy || undefined}\n aria-busy={game.starting || undefined}\n // No press or hover response while it can't act. Passed only then:\n // Button spreads props last, so an explicit undefined would drop its hover.\n pressScale={game.actionBusy ? 1 : 0.96}\n {...(game.actionBusy ? { whileHover: {} } : {})}\n onClick={game.act}\n // A held Enter repeats clicks; it would cash out, skip and start\n // rounds on its own.\n onKeyDown={(event) => {\n if (event.repeat && event.key === \"Enter\") event.preventDefault();\n }}\n >\n {game.actionLabel}\n {/* Progress toward the auto target, on the same log scale the\n multiplier grows on, so it fills at a steady pace. */}\n {game.running && game.target !== null ? (\n <span\n aria-hidden=\"true\"\n className=\"bg-primary-foreground/45 pointer-events-none absolute inset-x-0 bottom-0 h-[3px] origin-left\"\n style={{\n transform: `scaleX(${Math.min(1, Math.log(growth(game.t)) / Math.log(game.target)).toFixed(4)})`,\n }}\n />\n ) : null}\n </Button>\n </div>\n );\n}\n\n/** The Auto cash-out menu. */\nconst AutoMenu = memo(function AutoMenu({\n auto,\n options,\n onChange,\n disabled,\n}: {\n auto: number | null;\n options: number[];\n onChange: (value: string) => void;\n disabled: boolean;\n}) {\n return (\n <Select\n value={auto === null ? \"off\" : String(auto)}\n onValueChange={onChange}\n disabled={disabled}\n className=\"w-32 shrink-0\"\n >\n <SelectTrigger className=\"h-10 tabular-nums\">\n <span className=\"flex items-baseline gap-1.5\">\n <span className=\"text-muted-foreground text-xs\">Auto</span>\n {/* Options register after mount; the placeholder covers the server render. */}\n <SelectValue placeholder={auto === null ? \"Off\" : formatShort(auto)} />\n </span>\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"off\">Off</SelectItem>\n {options.map((step) => (\n <SelectItem key={step} value={String(step)}>\n {formatShort(step)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n );\n});\n\n/** Recent crash points, newest first, sliding in from the left. */\nconst CrashHistory = memo(function CrashHistory({\n history,\n reduce,\n className,\n}: {\n history: CrashGame[\"history\"];\n reduce: boolean;\n className?: string;\n}) {\n return (\n <ul\n aria-label=\"Recent crashes\"\n className={cn(\n \"flex items-center gap-1.5 overflow-hidden [mask-image:linear-gradient(to_right,black_85%,transparent)]\",\n className,\n )}\n >\n <AnimatePresence initial={false} mode=\"popLayout\">\n {history.length === 0 ? (\n <motion.li\n key=\"empty\"\n className=\"text-muted-foreground text-xs\"\n initial={false}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0, transition: EXIT }}\n >\n Recent rounds show here\n </motion.li>\n ) : (\n history.map((entry) => (\n <motion.li\n key={entry.id}\n layout={!reduce}\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.9, x: -8 }}\n animate={{ opacity: 1, scale: 1, x: 0 }}\n exit={{ opacity: 0, transition: EXIT }}\n transition={reduce ? { duration: 0.15 } : SPRING_LAYOUT}\n className={cn(\n \"shrink-0 rounded-full px-2 py-0.5 text-xs font-medium tabular-nums\",\n HEAT_PILL[heat(entry.value)],\n )}\n >\n {formatMultiplier(entry.value)}\n </motion.li>\n ))\n )}\n </AnimatePresence>\n </ul>\n );\n});\n\n/**\n * The live multiplier, warming as it climbs, that becomes the result at the\n * crash: red and shaking on a loss, your cash out in primary on a win.\n */\nfunction CrashMultiplier({ game, className }: { game: CrashGame; className?: string }) {\n const { lost, crashed, cashed, reduce, pulse, round } = game;\n // After a crash you cashed out of, the number that counts is yours.\n const final = crashed && cashed !== null;\n return (\n <motion.p\n key={round}\n className={cn(\n \"font-semibold tracking-tight tabular-nums transition-colors duration-150\",\n className,\n // Warms with the climb, so size reads without the digits; the result overrides.\n lost\n ? \"text-rose-600 dark:text-rose-400\"\n : final\n ? \"text-primary\"\n : HEAT_TEXT[heat(game.multiplier)],\n )}\n animate={lost && !reduce ? { x: [0, -6, 6, -3, 3, 0] } : { x: 0 }}\n transition={SHAKE}\n >\n {/* Remounts per milestone for a quick swell, and once more when the\n crash hands the readout your cash out, which blurs in. */}\n <motion.span\n key={final ? \"final\" : pulse}\n className=\"inline-block\"\n initial={\n reduce\n ? final\n ? { opacity: 0 }\n : false\n : final\n ? { opacity: 0, scale: 0.96, filter: \"blur(4px)\" }\n : pulse > 0\n ? { scale: 1.08 }\n : false\n }\n animate={{ opacity: 1, scale: 1, filter: \"blur(0px)\" }}\n transition={final ? SWAP : PULSE}\n >\n {formatMultiplier(final ? cashed : game.multiplier)}\n </motion.span>\n </motion.p>\n );\n}\n\n/**\n * The line under the multiplier: a hint before and during the flight, a\n * solid badge from the cash out until the crash, then the round's context.\n */\nfunction CrashStatus({ game, className }: { game: CrashGame; className?: string }) {\n const { cashed, crashed, status, reduce } = game;\n return (\n <div className={cn(\"flex h-6 items-center\", className)}>\n <AnimatePresence initial={false} mode=\"popLayout\">\n {cashed !== null && !crashed ? (\n <motion.p\n key=\"cashed\"\n 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\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.96, filter: \"blur(4px)\" }}\n animate={{ opacity: 1, scale: 1, filter: \"blur(0px)\" }}\n exit={{ opacity: 0, transition: EXIT }}\n transition={SWAP}\n >\n <Check aria-hidden=\"true\" className=\"size-3.5\" strokeWidth={2.5} />\n Cashed out {formatMultiplier(cashed)}\n </motion.p>\n ) : (\n <motion.p\n key={status}\n className=\"text-muted-foreground text-xs tabular-nums\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 4, filter: \"blur(4px)\" }}\n animate={{ opacity: 1, y: 0, filter: \"blur(0px)\" }}\n exit={{ opacity: 0, transition: EXIT }}\n transition={SWAP}\n >\n {status}\n </motion.p>\n )}\n </AnimatePresence>\n </div>\n );\n}\n\n/**\n * The small uppercase state label: Ready, In flight, then the result:\n * Cashed out with a check, or Crashed with a cross.\n */\nfunction CrashEyebrow({ game, className }: { game: CrashGame; className?: string }) {\n const { lost, crashed, running, cashed, reduce } = game;\n const icon = crashed ? (lost ? \"lost\" : \"won\") : running && cashed === null ? \"live\" : null;\n return (\n <p\n className={cn(\n \"flex h-4 items-center gap-1.5 text-[11px] font-medium tracking-[0.08em] uppercase transition-colors duration-150\",\n lost\n ? \"text-rose-700 dark:text-rose-400\"\n : crashed\n ? PRIMARY_TEXT\n : \"text-muted-foreground\",\n className,\n )}\n >\n <AnimatePresence initial={false} mode=\"popLayout\">\n {icon ? (\n <motion.span\n key={icon}\n aria-hidden=\"true\"\n className=\"grid size-3.5 place-items-center\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.25, filter: \"blur(4px)\" }}\n animate={{ opacity: 1, scale: 1, filter: \"blur(0px)\" }}\n exit={{ opacity: 0, transition: EXIT }}\n transition={SWAP}\n >\n {icon === \"live\" ? (\n <span className=\"bg-primary size-1.5 rounded-full\" />\n ) : icon === \"won\" ? (\n <Check className=\"size-3.5\" strokeWidth={3} />\n ) : (\n <X className=\"size-3.5\" strokeWidth={3} />\n )}\n </motion.span>\n ) : null}\n </AnimatePresence>\n {game.eyebrow}\n </p>\n );\n}\n\n/** The polite live region for starts, milestones, cash outs and crashes. */\nfunction CrashAnnouncer({ game }: { game: CrashGame }) {\n return (\n <p aria-live=\"polite\" className=\"sr-only\">\n {game.announcement}\n </p>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAuEA,MAAa,SAAS;AACtB,MAAa,UAAU,YAAoB,KAAK,IAAI,SAAS,OAAO;AACpE,MAAa,UAAU,eAAuB,KAAK,IAAI,UAAU,IAAI;AACrE,MAAM,YAAY;AAIlB,MAAM,UAAU;;;;;;;;AAShB,SAAgB,WAAW,SAAuB,KAAK,QAAQ,YAAY,GAAG;CAE5E,OAAO,KAAK,IAAI,WAAW,KAAK,IAAI,GAAG,KAAK,MAAO,OAAO,IAD7C,KAAK,IAAI,KAAK,IAAI,WAAW,CAAC,GAAG,CACmB,MAAO,IAAI,OAAO,EAAE,IAAI,GAAG,CAAC;AAC/F;;;;;;;AAQA,MAAM,UAAU,UAAkB;CAChC,IAAI,CAAC,OAAO,SAAS,KAAK,GAAG,OAAO;CACpC,OAAO,KAAK,IAAI,GAAG,OAAO,KAAK,IAAI,OAAO,OAAO,CAAC,CAAC;AACrD;;;;;AAMA,SAAgB,UAAU,OAAe;CACvC,IAAI,QAAQ,GAAG,OAAO,QAAQ;CAC9B,OAAO;EAAC;EAAI;EAAI;CAAE,CAAC,EAAE,QAAQ,KAAK,KAAK,MAAM,KAAK,OAAO,QAAQ,KAAK,CAAC;AACzE;AAGA,MAAa,aAAa;CAAC;CAAK;CAAG;CAAG;CAAG;CAAI;CAAI;AAAG;AAGpD,MAAM,YAAY;AAGlB,MAAM,cAAc;AAGpB,IAAI,SAAS;AACb,MAAM,UAAU;AAIhB,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KAAG,OAAO;KAAM,QAAQ;IAAY;IAClF,SAAS;KAAE,SAAS;KAAG,OAAO;KAAG,QAAQ;IAAY;IACrD,MAAM;KAAE,SAAS;KAAG,YAAY;IAAK;IACrC,YAAY;IAEX,UAAA,SAAS,SACR,oBAAC,QAAD,EAAM,WAAU,mCAAoC,CAAA,IAClD,SAAS,QACX,oBAAC,OAAD;KAAO,WAAU;KAAW,aAAa;IAAI,CAAA,IAE7C,oBAAC,GAAD;KAAG,WAAU;KAAW,aAAa;IAAI,CAAA;GAEhC,GAfN,IAeM,IACX;EACW,CAAA,GAChB,KAAK,OACL;;AAEP;;AAGA,SAAS,eAAe,EAAE,QAA6B;CACrD,OACE,oBAAC,KAAD;EAAG,aAAU;EAAS,WAAU;EAC7B,UAAA,KAAK;CACL,CAAA;AAEP"}
@@ -1,4 +1,6 @@
1
1
  declare const EASE_OUT: readonly [0.16, 1, 0.3, 1];
2
+ /** Accelerating curve for things that fall (a dropped ball, a toppled block). Not for UI entrances. */
3
+ declare const EASE_IN: readonly [0.55, 0, 1, 0.45];
2
4
  declare const EASE_IN_OUT: readonly [0.77, 0, 0.175, 1];
3
5
  declare const EASE_DRAWER: readonly [0.32, 0.72, 0, 1];
4
6
  /** CSS string form of EASE_OUT for inline style transitions. */
@@ -44,5 +46,5 @@ declare const SPRING_GLIDE: {
44
46
  readonly damping: 50;
45
47
  readonly mass: 0.5;
46
48
  };
47
- export { SPRING_GLIDE as a, SPRING_PANEL as c, EASE_OUT_CSS as i, SPRING_PRESS as l, EASE_IN_OUT as n, SPRING_LAYOUT as o, EASE_OUT as r, SPRING_MOUSE as s, EASE_DRAWER as t, SPRING_SWAP as u };
48
- //# sourceMappingURL=ease-CHhXKlG3.d.ts.map
49
+ export { EASE_OUT_CSS as a, SPRING_MOUSE as c, SPRING_SWAP as d, EASE_OUT as i, SPRING_PANEL as l, EASE_IN as n, SPRING_GLIDE as o, EASE_IN_OUT as r, SPRING_LAYOUT as s, EASE_DRAWER as t, SPRING_PRESS as u };
50
+ //# sourceMappingURL=ease-DjhlGGZO.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ease-DjhlGGZO.d.ts","names":[],"sources":["../src/lib/ease.ts"],"mappings":"A,cAAa;;cAEA;cACA;cACA;;cAGA;;cAGA;;;;;;;cAQA;;;;;;;cAQA;;;;;;;cAQA;;;;;;;cAQA;;;;;;;cAQA"}
@@ -1,3 +1,3 @@
1
1
  import * as React$1 from "react";
2
- export declare function useHighlightedCode(value: string, language: string): (string | number | bigint | boolean | React$1.JSX.Element[] | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | null | undefined> | null | undefined)[];
2
+ export declare function useHighlightedCode(value: string, language: string): (string | number | bigint | boolean | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | null | undefined> | React$1.JSX.Element[] | null | undefined)[];
3
3
  //# sourceMappingURL=use-highlighted-code.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-highlighted-code.d.ts","names":["React"],"sources":["../../src/hooks/use-highlighted-code.ts"],"mappings":";wBAMgB,mBAAmB,eAAe,yDAAgBA,QAAA,IAAA,YAAAA,QAAA,+BAAAA,QAAA,8BAAA,SAAAA,QAAA,aAAA,6CAAAA,QAAA,cAAAA,QAAA,+BAAAA,QAAA,8BAAA,SAAAA,QAAA"}
1
+ {"version":3,"file":"use-highlighted-code.d.ts","names":["React"],"sources":["../../src/hooks/use-highlighted-code.ts"],"mappings":";wBAMgB,mBAAmB,eAAe,yDAAgBA,QAAA,+BAAAA,QAAA,8BAAA,SAAAA,QAAA,aAAA,6CAAAA,QAAA,cAAAA,QAAA,+BAAAA,QAAA,8BAAA,SAAAA,QAAA,iCAAAA,QAAA,IAAA"}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
+ import { FOCUSABLE_SELECTOR } from "../lib/focusable.js";
2
3
  import { useEffect, useLayoutEffect, useRef } from "react";
3
4
  // src/hooks/use-modal-scope.ts
4
- const FOCUSABLE = "button:not(:disabled), a[href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
5
5
  const inertOwners = /* @__PURE__ */ new Map();
6
6
  let scrollOwners = 0;
7
7
  let previousOverflow = "";
@@ -28,7 +28,7 @@ function useModalScope(open, root, panel, onClose) {
28
28
  previousOverflow = document.body.style.overflow;
29
29
  document.body.style.overflow = "hidden";
30
30
  }
31
- const focusables = () => Array.from(panel.current?.querySelectorAll(FOCUSABLE) ?? []).filter((element) => element.tabIndex >= 0 && !element.closest("[inert]"));
31
+ const focusables = () => Array.from(panel.current?.querySelectorAll(FOCUSABLE_SELECTOR) ?? []).filter((element) => element.tabIndex >= 0 && !element.closest("[inert]"));
32
32
  const focusFirst = () => (focusables()[0] ?? panel.current)?.focus({ preventScroll: true });
33
33
  focusFirst();
34
34
  const onFocus = (event) => {
@@ -1 +1 @@
1
- {"version":3,"file":"use-modal-scope.js","names":[],"sources":["../../src/hooks/use-modal-scope.ts"],"sourcesContent":["\"use client\";\n\nimport { type RefObject, useEffect, useLayoutEffect, useRef } from \"react\";\n\nconst FOCUSABLE =\n 'button:not(:disabled), a[href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])';\nconst inertOwners = new Map<HTMLElement, { count: number; previous: boolean }>();\nlet scrollOwners = 0;\nlet previousOverflow = \"\";\n\n/** A portal root owns sibling inertness and scroll locking until its open state ends. */\nexport function useModalScope(\n open: boolean,\n root: RefObject<HTMLElement | null>,\n panel: RefObject<HTMLElement | null>,\n onClose: () => void,\n) {\n const close = useRef(onClose);\n useLayoutEffect(() => {\n close.current = onClose;\n });\n useEffect(() => {\n if (!open || !root.current || !panel.current) return;\n const returnFocus =\n document.activeElement instanceof HTMLElement ? document.activeElement : null;\n const siblings = Array.from(document.body.children).filter(\n (element): element is HTMLElement =>\n element instanceof HTMLElement && element !== root.current,\n );\n for (const element of siblings) {\n const owner = inertOwners.get(element) ?? {\n count: 0,\n previous: element.inert,\n };\n owner.count += 1;\n inertOwners.set(element, owner);\n element.inert = true;\n }\n if (scrollOwners++ === 0) {\n previousOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n }\n const focusables = () =>\n Array.from(panel.current?.querySelectorAll<HTMLElement>(FOCUSABLE) ?? []).filter(\n (element) => element.tabIndex >= 0 && !element.closest(\"[inert]\"),\n );\n const focusFirst = () => (focusables()[0] ?? panel.current)?.focus({ preventScroll: true });\n focusFirst();\n const onFocus = (event: FocusEvent) => {\n if (\n event.target instanceof Node &&\n !panel.current?.contains(event.target) &&\n !root.current?.inert\n )\n focusFirst();\n };\n const onKey = (event: KeyboardEvent) => {\n if (root.current?.inert) return;\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n close.current();\n }\n if (event.key !== \"Tab\") return;\n const elements = focusables();\n const first = elements[0];\n const last = elements[elements.length - 1];\n if (!first || !last) {\n event.preventDefault();\n panel.current?.focus();\n } else if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n document.addEventListener(\"focusin\", onFocus);\n document.addEventListener(\"keydown\", onKey);\n return () => {\n document.removeEventListener(\"focusin\", onFocus);\n document.removeEventListener(\"keydown\", onKey);\n for (const element of siblings) {\n const owner = inertOwners.get(element);\n if (owner && --owner.count === 0) {\n element.inert = owner.previous;\n inertOwners.delete(element);\n }\n }\n if (--scrollOwners === 0) document.body.style.overflow = previousOverflow;\n if (returnFocus?.isConnected && !returnFocus.closest(\"[inert]\"))\n returnFocus.focus({ preventScroll: true });\n };\n }, [open,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IACrB,MAAM,gBAAgB;IACtB,MAAM,QAAQ;GAChB;GACA,IAAI,MAAM,QAAQ,OAAO;GACzB,MAAM,WAAW,WAAW;GAC5B,MAAM,QAAQ,SAAS;GACvB,MAAM,OAAO,SAAS,SAAS,SAAS;GACxC,IAAI,CAAC,SAAS,CAAC,MAAM;IACnB,MAAM,eAAe;IACrB,MAAM,SAAS,MAAM;GACvB,OAAO,IAAI,MAAM,YAAY,SAAS,kBAAkB,OAAO;IAC7D,MAAM,eAAe;IACrB,KAAK,MAAM;GACb,OAAO,IAAI,CAAC,MAAM,YAAY,SAAS,kBAAkB,MAAM;IAC7D,MAAM,eAAe;IACrB,MAAM,MAAM;GACd;EACF;EACA,SAAS,iBAAiB,WAAW,OAAO;EAC5C,SAAS,iBAAiB,WAAW,KAAK;EAC1C,aAAa;GACX,SAAS,oBAAoB,WAAW,OAAO;GAC/C,SAAS,oBAAoB,WAAW,KAAK;GAC7C,KAAK,MAAM,WAAW,UAAU;IAC9B,MAAM,QAAQ,YAAY,IAAI,OAAO;IACrC,IAAI,SAAS,EAAE,MAAM,UAAU,GAAG;KAChC,QAAQ,QAAQ,MAAM;KACtB,YAAY,OAAO,OAAO;IAC5B;GACF;GACA,IAAI,EAAE,iBAAiB,GAAG,SAAS,KAAK,MAAM,WAAW;GACzD,IAAI,aAAa,eAAe,CAAC,YAAY,QAAQ,SAAS,GAC5D,YAAY,MAAM,EAAE,eAAe,KAAK,CAAC;EAC7C;CACF,GAAG;EAAC;EAAM;EAAM;CAAK,CAAC;AACxB"}
1
+ {"version":3,"file":"use-modal-scope.js","names":[],"sources":["../../src/hooks/use-modal-scope.ts"],"sourcesContent":["\"use client\";\n\nimport { type RefObject, useEffect, useLayoutEffect, useRef } from \"react\";\n\nimport { FOCUSABLE_SELECTOR } from \"../lib/focusable\";\n\nconst inertOwners = new Map<HTMLElement, { count: number; previous: boolean }>();\nlet scrollOwners = 0;\nlet previousOverflow = \"\";\n\n/** A portal root owns sibling inertness and scroll locking until its open state ends. */\nexport function useModalScope(\n open: boolean,\n root: RefObject<HTMLElement | null>,\n panel: RefObject<HTMLElement | null>,\n onClose: () => void,\n) {\n const close = useRef(onClose);\n useLayoutEffect(() => {\n close.current = onClose;\n });\n useEffect(() => {\n if (!open || !root.current || !panel.current) return;\n const returnFocus =\n document.activeElement instanceof HTMLElement ? document.activeElement : null;\n const siblings = Array.from(document.body.children).filter(\n (element): element is HTMLElement =>\n element instanceof HTMLElement && element !== root.current,\n );\n for (const element of siblings) {\n const owner = inertOwners.get(element) ?? {\n count: 0,\n previous: element.inert,\n };\n owner.count += 1;\n inertOwners.set(element, owner);\n element.inert = true;\n }\n if (scrollOwners++ === 0) {\n previousOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n }\n const focusables = () =>\n Array.from(panel.current?.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR) ?? []).filter(\n (element) => element.tabIndex >= 0 && !element.closest(\"[inert]\"),\n );\n const focusFirst = () => (focusables()[0] ?? panel.current)?.focus({ preventScroll: true });\n focusFirst();\n const onFocus = (event: FocusEvent) => {\n if (\n event.target instanceof Node &&\n !panel.current?.contains(event.target) &&\n !root.current?.inert\n )\n focusFirst();\n };\n const onKey = (event: KeyboardEvent) => {\n if (root.current?.inert) return;\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n close.current();\n }\n if (event.key !== \"Tab\") return;\n const elements = focusables();\n const first = elements[0];\n const last = elements[elements.length - 1];\n if (!first || !last) {\n event.preventDefault();\n panel.current?.focus();\n } else if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n document.addEventListener(\"focusin\", onFocus);\n document.addEventListener(\"keydown\", onKey);\n return () => {\n document.removeEventListener(\"focusin\", onFocus);\n document.removeEventListener(\"keydown\", onKey);\n for (const element of siblings) {\n const owner = inertOwners.get(element);\n if (owner && --owner.count === 0) {\n element.inert = owner.previous;\n inertOwners.delete(element);\n }\n }\n if (--scrollOwners === 0) document.body.style.overflow = previousOverflow;\n if (returnFocus?.isConnected && !returnFocus.closest(\"[inert]\"))\n returnFocus.focus({ preventScroll: true });\n };\n }, [open, root, panel]);\n}\n"],"mappings":";;;;AAMA,MAAM,8BAAc,IAAI,IAAuD;AAC/E,IAAI,eAAe;AACnB,IAAI,mBAAmB;;AAGvB,SAAgB,cACd,MACA,MACA,OACA,SACA;CACA,MAAM,QAAQ,OAAO,OAAO;CAC5B,sBAAsB;EACpB,MAAM,UAAU;CAClB,CAAC;CACD,gBAAgB;EACd,IAAI,CAAC,QAAQ,CAAC,KAAK,WAAW,CAAC,MAAM,SAAS;EAC9C,MAAM,cACJ,SAAS,yBAAyB,cAAc,SAAS,gBAAgB;EAC3E,MAAM,WAAW,MAAM,KAAK,SAAS,KAAK,QAAQ,CAAC,CAAC,QACjD,YACC,mBAAmB,eAAe,YAAY,KAAK,OACvD;EACA,KAAK,MAAM,WAAW,UAAU;GAC9B,MAAM,QAAQ,YAAY,IAAI,OAAO,KAAK;IACxC,OAAO;IACP,UAAU,QAAQ;GACpB;GACA,MAAM,SAAS;GACf,YAAY,IAAI,SAAS,KAAK;GAC9B,QAAQ,QAAQ;EAClB;EACA,IAAI,mBAAmB,GAAG;GACxB,mBAAmB,SAAS,KAAK,MAAM;GACvC,SAAS,KAAK,MAAM,WAAW;EACjC;EACA,MAAM,mBACJ,MAAM,KAAK,MAAM,SAAS,iBAA8B,kBAAkB,KAAK,CAAC,CAAC,CAAC,CAAC,QAChF,YAAY,QAAQ,YAAY,KAAK,CAAC,QAAQ,QAAQ,SAAS,CAClE;EACF,MAAM,oBAAoB,WAAW,CAAC,CAAC,MAAM,MAAM,QAAA,EAAU,MAAM,EAAE,eAAe,KAAK,CAAC;EAC1F,WAAW;EACX,MAAM,WAAW,UAAsB;GACrC,IACE,MAAM,kBAAkB,QACxB,CAAC,MAAM,SAAS,SAAS,MAAM,MAAM,KACrC,CAAC,KAAK,SAAS,OAEf,WAAW;EACf;EACA,MAAM,SAAS,UAAyB;GACtC,IAAI,KAAK,SAAS,OAAO;GACzB,IAAI,MAAM,QAAQ,UAAU;IAC1B,MAAM,eAAe;IACrB,MAAM,gBAAgB;IACtB,MAAM,QAAQ;GAChB;GACA,IAAI,MAAM,QAAQ,OAAO;GACzB,MAAM,WAAW,WAAW;GAC5B,MAAM,QAAQ,SAAS;GACvB,MAAM,OAAO,SAAS,SAAS,SAAS;GACxC,IAAI,CAAC,SAAS,CAAC,MAAM;IACnB,MAAM,eAAe;IACrB,MAAM,SAAS,MAAM;GACvB,OAAO,IAAI,MAAM,YAAY,SAAS,kBAAkB,OAAO;IAC7D,MAAM,eAAe;IACrB,KAAK,MAAM;GACb,OAAO,IAAI,CAAC,MAAM,YAAY,SAAS,kBAAkB,MAAM;IAC7D,MAAM,eAAe;IACrB,MAAM,MAAM;GACd;EACF;EACA,SAAS,iBAAiB,WAAW,OAAO;EAC5C,SAAS,iBAAiB,WAAW,KAAK;EAC1C,aAAa;GACX,SAAS,oBAAoB,WAAW,OAAO;GAC/C,SAAS,oBAAoB,WAAW,KAAK;GAC7C,KAAK,MAAM,WAAW,UAAU;IAC9B,MAAM,QAAQ,YAAY,IAAI,OAAO;IACrC,IAAI,SAAS,EAAE,MAAM,UAAU,GAAG;KAChC,QAAQ,QAAQ,MAAM;KACtB,YAAY,OAAO,OAAO;IAC5B;GACF;GACA,IAAI,EAAE,iBAAiB,GAAG,SAAS,KAAK,MAAM,WAAW;GACzD,IAAI,aAAa,eAAe,CAAC,YAAY,QAAQ,SAAS,GAC5D,YAAY,MAAM,EAAE,eAAe,KAAK,CAAC;EAC7C;CACF,GAAG;EAAC;EAAM;EAAM;CAAK,CAAC;AACxB"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Registers a sound player. Call the returned function when the player is
3
+ * disposed; the context closes after the last one.
4
+ */
5
+ export declare function retainAudioContext(): () => void;
6
+ /**
7
+ * The shared context, created on first call and resumed if suspended. Null
8
+ * during SSR and in browsers without Web Audio.
9
+ */
10
+ export declare function getAudioContext(): AudioContext | null;
11
+ //# sourceMappingURL=audio-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audio-context.d.ts","names":[],"sources":["../../src/lib/audio-context.ts"],"mappings":";;;;wBASgB;;;;;wBAkBA,mBAAmB"}
@@ -0,0 +1,37 @@
1
+ // src/lib/audio-context.ts
2
+ let context = null;
3
+ let users = 0;
4
+ /**
5
+ * Registers a sound player. Call the returned function when the player is
6
+ * disposed; the context closes after the last one.
7
+ */
8
+ function retainAudioContext() {
9
+ users++;
10
+ let released = false;
11
+ return () => {
12
+ if (released) return;
13
+ released = true;
14
+ users--;
15
+ if (users === 0 && context) {
16
+ context.close();
17
+ context = null;
18
+ }
19
+ };
20
+ }
21
+ /**
22
+ * The shared context, created on first call and resumed if suspended. Null
23
+ * during SSR and in browsers without Web Audio.
24
+ */
25
+ function getAudioContext() {
26
+ if (!context) {
27
+ if (typeof window === "undefined") return null;
28
+ const Ctor = window.AudioContext ?? window.webkitAudioContext;
29
+ if (!Ctor) return null;
30
+ context = new Ctor();
31
+ }
32
+ if (context.state === "suspended") context.resume().catch(() => void 0);
33
+ return context;
34
+ }
35
+ export { getAudioContext, retainAudioContext };
36
+
37
+ //# sourceMappingURL=audio-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audio-context.js","names":[],"sources":["../../src/lib/audio-context.ts"],"sourcesContent":["type AudioContextCtor = typeof AudioContext;\n\nlet context: AudioContext | null = null;\nlet users = 0;\n\n/**\n * Registers a sound player. Call the returned function when the player is\n * disposed; the context closes after the last one.\n */\nexport function retainAudioContext() {\n users++;\n let released = false;\n return () => {\n if (released) return;\n released = true;\n users--;\n if (users === 0 && context) {\n void context.close();\n context = null;\n }\n };\n}\n\n/**\n * The shared context, created on first call and resumed if suspended. Null\n * during SSR and in browsers without Web Audio.\n */\nexport function getAudioContext(): AudioContext | null {\n if (!context) {\n if (typeof window === \"undefined\") return null;\n const Ctor =\n window.AudioContext ??\n (window as unknown as { webkitAudioContext?: AudioContextCtor }).webkitAudioContext;\n if (!Ctor) return null;\n context = new Ctor();\n }\n // Browsers may refuse outside a user gesture. Players call this from\n // pointer and key handlers first, so a later call finds it running.\n if (context.state === \"suspended\") void context.resume().catch(() => undefined);\n return context;\n}\n"],"mappings":";AAEA,IAAI,UAA+B;AACnC,IAAI,QAAQ;;;;;AAMZ,SAAgB,qBAAqB;CACnC;CACA,IAAI,WAAW;CACf,aAAa;EACX,IAAI,UAAU;EACd,WAAW;EACX;EACA,IAAI,UAAU,KAAK,SAAS;GAC1B,QAAa,MAAM;GACnB,UAAU;EACZ;CACF;AACF;;;;;AAMA,SAAgB,kBAAuC;CACrD,IAAI,CAAC,SAAS;EACZ,IAAI,OAAO,WAAW,aAAa,OAAO;EAC1C,MAAM,OACJ,OAAO,gBACN,OAAgE;EACnE,IAAI,CAAC,MAAM,OAAO;EAClB,UAAU,IAAI,KAAK;CACrB;CAGA,IAAI,QAAQ,UAAU,aAAa,QAAa,OAAO,CAAC,CAAC,YAAY,KAAA,CAAS;CAC9E,OAAO;AACT"}
@@ -1,2 +1,2 @@
1
- import { a as SPRING_GLIDE, c as SPRING_PANEL, i as EASE_OUT_CSS, l as SPRING_PRESS, n as EASE_IN_OUT, o as SPRING_LAYOUT, r as EASE_OUT, s as SPRING_MOUSE, t as EASE_DRAWER, u as SPRING_SWAP } from "../ease-CHhXKlG3.js";
2
- export { EASE_DRAWER, EASE_IN_OUT, EASE_OUT, EASE_OUT_CSS, SPRING_GLIDE, SPRING_LAYOUT, SPRING_MOUSE, SPRING_PANEL, SPRING_PRESS, SPRING_SWAP };
1
+ import { a as EASE_OUT_CSS, c as SPRING_MOUSE, d as SPRING_SWAP, i as EASE_OUT, l as SPRING_PANEL, n as EASE_IN, o as SPRING_GLIDE, r as EASE_IN_OUT, s as SPRING_LAYOUT, t as EASE_DRAWER, u as SPRING_PRESS } from "../ease-DjhlGGZO.js";
2
+ export { EASE_DRAWER, EASE_IN, EASE_IN_OUT, EASE_OUT, EASE_OUT_CSS, SPRING_GLIDE, SPRING_LAYOUT, SPRING_MOUSE, SPRING_PANEL, SPRING_PRESS, SPRING_SWAP };
package/dist/lib/ease.js CHANGED
@@ -5,6 +5,13 @@ const EASE_OUT = [
5
5
  .3,
6
6
  1
7
7
  ];
8
+ /** Accelerating curve for things that fall (a dropped ball, a toppled block). Not for UI entrances. */
9
+ const EASE_IN = [
10
+ .55,
11
+ 0,
12
+ 1,
13
+ .45
14
+ ];
8
15
  const EASE_IN_OUT = [
9
16
  .77,
10
17
  0,
@@ -60,6 +67,6 @@ const SPRING_GLIDE = {
60
67
  damping: 50,
61
68
  mass: .5
62
69
  };
63
- export { EASE_DRAWER, EASE_IN_OUT, EASE_OUT, EASE_OUT_CSS, SPRING_GLIDE, SPRING_LAYOUT, SPRING_MOUSE, SPRING_PANEL, SPRING_PRESS, SPRING_SWAP };
70
+ export { EASE_DRAWER, EASE_IN, EASE_IN_OUT, EASE_OUT, EASE_OUT_CSS, SPRING_GLIDE, SPRING_LAYOUT, SPRING_MOUSE, SPRING_PANEL, SPRING_PRESS, SPRING_SWAP };
64
71
 
65
72
  //# sourceMappingURL=ease.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ease.js","names":[],"sources":["../../src/lib/ease.ts"],"sourcesContent":["export const EASE_OUT = [0.16, 1, 0.3, 1] as const;\nexport const EASE_IN_OUT = [0.77, 0, 0.175, 1] as const;\nexport const EASE_DRAWER = [0.32, 0.72, 0, 1] as const;\n\n/** CSS string form of EASE_OUT for inline style transitions. */\nexport const EASE_OUT_CSS = \"cubic-bezier(0.16, 1, 0.3, 1)\";\n\n/** Press feedback on buttons and other tappable surfaces. */\nexport const SPRING_PRESS = {\n type: \"spring\",\n stiffness: 500,\n damping: 30,\n mass: 0.6,\n} as const;\n\n/** Content swaps — label/icon slots trading places inside a control. */\nexport const SPRING_SWAP = {\n type: \"spring\",\n stiffness: 460,\n damping: 30,\n mass: 0.55,\n} as const;\n\n/** Overlay panel entrances — modals and sheets summoned by pointer. */\nexport const SPRING_PANEL = {\n type: \"spring\",\n stiffness: 420,\n damping: 40,\n mass: 0.5,\n} as const;\n\n/** Shared-layout glides — pills, indicators and panels morphing between positions. */\nexport const SPRING_LAYOUT = {\n type: \"spring\",\n stiffness: 360,\n damping: 32,\n mass: 0.6,\n} as const;\n\n/** Cursor-follow physics for decorative mouse tracking (magnetic, tilt, dock). */\nexport const SPRING_MOUSE = {\n stiffness: 200,\n damping: 15,\n mass: 0.3,\n} as const;\n\n/** Dragged handles and fills (sliders) — critically damped `useSpring` config,\n * so the value follows the pointer butterily and never rebounds off an end. */\nexport const SPRING_GLIDE = {\n stiffness: 700,\n damping: 50,\n mass: 0.5,\n} as const;\n"],"mappings":";AAAA,MAAa,WAAW;CAAC;CAAM;CAAG;CAAK;AAAC;AACxC,MAAa,cAAc;CAAC;CAAM;CAAG;CAAO;AAAC;AAC7C,MAAa,cAAc;CAAC;CAAM;CAAM;CAAG;AAAC;;AAG5C,MAAa,eAAe;;AAG5B,MAAa,eAAe;CAC1B,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;;AAGA,MAAa,cAAc;CACzB,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;;AAGA,MAAa,eAAe;CAC1B,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;;AAGA,MAAa,gBAAgB;CAC3B,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;;AAGA,MAAa,eAAe;CAC1B,WAAW;CACX,SAAS;CACT,MAAM;AACR;;;AAIA,MAAa,eAAe;CAC1B,WAAW;CACX,SAAS;CACT,MAAM;AACR"}
1
+ {"version":3,"file":"ease.js","names":[],"sources":["../../src/lib/ease.ts"],"sourcesContent":["export const EASE_OUT = [0.16, 1, 0.3, 1] as const;\n/** Accelerating curve for things that fall (a dropped ball, a toppled block). Not for UI entrances. */\nexport const EASE_IN = [0.55, 0, 1, 0.45] as const;\nexport const EASE_IN_OUT = [0.77, 0, 0.175, 1] as const;\nexport const EASE_DRAWER = [0.32, 0.72, 0, 1] as const;\n\n/** CSS string form of EASE_OUT for inline style transitions. */\nexport const EASE_OUT_CSS = \"cubic-bezier(0.16, 1, 0.3, 1)\";\n\n/** Press feedback on buttons and other tappable surfaces. */\nexport const SPRING_PRESS = {\n type: \"spring\",\n stiffness: 500,\n damping: 30,\n mass: 0.6,\n} as const;\n\n/** Content swaps — label/icon slots trading places inside a control. */\nexport const SPRING_SWAP = {\n type: \"spring\",\n stiffness: 460,\n damping: 30,\n mass: 0.55,\n} as const;\n\n/** Overlay panel entrances — modals and sheets summoned by pointer. */\nexport const SPRING_PANEL = {\n type: \"spring\",\n stiffness: 420,\n damping: 40,\n mass: 0.5,\n} as const;\n\n/** Shared-layout glides — pills, indicators and panels morphing between positions. */\nexport const SPRING_LAYOUT = {\n type: \"spring\",\n stiffness: 360,\n damping: 32,\n mass: 0.6,\n} as const;\n\n/** Cursor-follow physics for decorative mouse tracking (magnetic, tilt, dock). */\nexport const SPRING_MOUSE = {\n stiffness: 200,\n damping: 15,\n mass: 0.3,\n} as const;\n\n/** Dragged handles and fills (sliders) — critically damped `useSpring` config,\n * so the value follows the pointer butterily and never rebounds off an end. */\nexport const SPRING_GLIDE = {\n stiffness: 700,\n damping: 50,\n mass: 0.5,\n} as const;\n"],"mappings":";AAAA,MAAa,WAAW;CAAC;CAAM;CAAG;CAAK;AAAC;;AAExC,MAAa,UAAU;CAAC;CAAM;CAAG;CAAG;AAAI;AACxC,MAAa,cAAc;CAAC;CAAM;CAAG;CAAO;AAAC;AAC7C,MAAa,cAAc;CAAC;CAAM;CAAM;CAAG;AAAC;;AAG5C,MAAa,eAAe;;AAG5B,MAAa,eAAe;CAC1B,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;;AAGA,MAAa,cAAc;CACzB,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;;AAGA,MAAa,eAAe;CAC1B,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;;AAGA,MAAa,gBAAgB;CAC3B,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;;AAGA,MAAa,eAAe;CAC1B,WAAW;CACX,SAAS;CACT,MAAM;AACR;;;AAIA,MAAa,eAAe;CAC1B,WAAW;CACX,SAAS;CACT,MAAM;AACR"}
@@ -0,0 +1,2 @@
1
+ export declare const FOCUSABLE_SELECTOR: string;
2
+ //# sourceMappingURL=focusable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focusable.d.ts","names":[],"sources":["../../src/lib/focusable.ts"],"mappings":"A,qBAAa"}
@@ -0,0 +1,12 @@
1
+ // src/lib/focusable.ts
2
+ const FOCUSABLE_SELECTOR = [
3
+ "a[href]",
4
+ "button:not(:disabled)",
5
+ "input:not(:disabled):not([type='hidden'])",
6
+ "select:not(:disabled)",
7
+ "textarea:not(:disabled)",
8
+ "[tabindex]:not([tabindex='-1'])"
9
+ ].join(",");
10
+ export { FOCUSABLE_SELECTOR };
11
+
12
+ //# sourceMappingURL=focusable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focusable.js","names":[],"sources":["../../src/lib/focusable.ts"],"sourcesContent":["export const FOCUSABLE_SELECTOR = [\n \"a[href]\",\n \"button:not(:disabled)\",\n \"input:not(:disabled):not([type='hidden'])\",\n \"select:not(:disabled)\",\n \"textarea:not(:disabled)\",\n \"[tabindex]:not([tabindex='-1'])\",\n].join(\",\");\n"],"mappings":";AAAA,MAAa,qBAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,GAAG"}
@@ -0,0 +1,18 @@
1
+ export interface GameSounds {
2
+ /** Unlock audio; call from a click or key handler. */
3
+ prepare: () => void;
4
+ /** A gem; `streak` counts gems in a row, from 1. */
5
+ gem: (streak: number) => void;
6
+ /** A mine. */
7
+ mine: () => void;
8
+ /** Cashing out. */
9
+ cashOut: () => void;
10
+ dispose: () => void;
11
+ }
12
+ /**
13
+ * Lazily-initialized game sounds on the page's shared AudioContext. Nothing is created
14
+ * until the first call. Safe during SSR and without Web Audio: every call
15
+ * becomes a silent no-op.
16
+ */
17
+ export declare function createGameSounds(): GameSounds;
18
+ //# sourceMappingURL=game-sounds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-sounds.d.ts","names":[],"sources":["../../src/lib/game-sounds.ts"],"mappings":"A,iBAqDiB;;EAEf;;EAEA,MAAM;;EAEN;;EAEA;EACA;;;;;;;wBAQc,oBAAoB"}
@@ -0,0 +1,142 @@
1
+ import { getAudioContext, retainAudioContext } from "./audio-context.js";
2
+ // src/lib/game-sounds.ts
3
+ const MASTER_GAIN = .12;
4
+ const BASE = 783.99;
5
+ const SCALE = [
6
+ 0,
7
+ 2,
8
+ 4,
9
+ 7,
10
+ 9
11
+ ];
12
+ let master = null;
13
+ function ensureContext() {
14
+ const ctx = getAudioContext();
15
+ if (ctx && master?.context !== ctx) {
16
+ master = ctx.createGain();
17
+ master.gain.value = MASTER_GAIN;
18
+ master.connect(ctx.destination);
19
+ }
20
+ return ctx;
21
+ }
22
+ /** A pitched tone with a fast attack and exponential decay. */
23
+ function tone(context, frequency, at, { duration = .18, type = "sine", gain = 1 } = {}) {
24
+ if (!master) return;
25
+ const osc = context.createOscillator();
26
+ const env = context.createGain();
27
+ osc.type = type;
28
+ osc.frequency.setValueAtTime(frequency, at);
29
+ env.gain.setValueAtTime(1e-4, at);
30
+ env.gain.exponentialRampToValueAtTime(gain, at + .005);
31
+ env.gain.exponentialRampToValueAtTime(1e-4, at + duration);
32
+ osc.connect(env).connect(master);
33
+ osc.start(at);
34
+ osc.stop(at + duration + .02);
35
+ osc.onended = () => env.disconnect();
36
+ }
37
+ function note(step) {
38
+ const octave = Math.floor(step / SCALE.length);
39
+ const semitones = SCALE[step % SCALE.length] + octave * 12;
40
+ return BASE * 2 ** (semitones / 12);
41
+ }
42
+ /**
43
+ * Lazily-initialized game sounds on the page's shared AudioContext. Nothing is created
44
+ * until the first call. Safe during SSR and without Web Audio: every call
45
+ * becomes a silent no-op.
46
+ */
47
+ function createGameSounds() {
48
+ const release = retainAudioContext();
49
+ let disposed = false;
50
+ const live = () => disposed ? null : ensureContext();
51
+ return {
52
+ prepare() {
53
+ live();
54
+ },
55
+ gem(streak) {
56
+ const context = live();
57
+ if (!context) return;
58
+ const now = context.currentTime;
59
+ const run = streak % 5 === 0;
60
+ const at = run ? now + .06 : now;
61
+ if (run) [-2, -1].forEach((offset, index) => {
62
+ tone(context, note(Math.max(0, streak - 1 + offset)), now + index * .03, {
63
+ gain: .35,
64
+ duration: .08
65
+ });
66
+ });
67
+ const frequency = note(Math.min(streak - 1, SCALE.length * 2));
68
+ tone(context, frequency, at, { gain: .9 });
69
+ tone(context, frequency * 2, at, {
70
+ type: "triangle",
71
+ gain: .15,
72
+ duration: .12
73
+ });
74
+ if (streak >= 3) tone(context, frequency * 1.5, at + .05, {
75
+ gain: .25,
76
+ duration: .1
77
+ });
78
+ },
79
+ mine() {
80
+ const context = live();
81
+ if (!context || !master) return;
82
+ const now = context.currentTime;
83
+ const length = Math.ceil(context.sampleRate * .45);
84
+ const buffer = context.createBuffer(1, length, context.sampleRate);
85
+ const data = buffer.getChannelData(0);
86
+ for (let i = 0; i < length; i++) data[i] = (Math.random() * 2 - 1) * (1 - i / length) ** 2;
87
+ const noise = context.createBufferSource();
88
+ noise.buffer = buffer;
89
+ const filter = context.createBiquadFilter();
90
+ filter.type = "lowpass";
91
+ filter.frequency.setValueAtTime(1600, now);
92
+ filter.frequency.exponentialRampToValueAtTime(180, now + .4);
93
+ const env = context.createGain();
94
+ env.gain.setValueAtTime(1.1, now);
95
+ env.gain.exponentialRampToValueAtTime(1e-4, now + .45);
96
+ noise.connect(filter).connect(env).connect(master);
97
+ noise.start(now);
98
+ noise.onended = () => env.disconnect();
99
+ const thump = context.createOscillator();
100
+ const thumpEnv = context.createGain();
101
+ thump.type = "sine";
102
+ thump.frequency.setValueAtTime(110, now);
103
+ thump.frequency.exponentialRampToValueAtTime(42, now + .3);
104
+ thumpEnv.gain.setValueAtTime(1.4, now);
105
+ thumpEnv.gain.exponentialRampToValueAtTime(1e-4, now + .32);
106
+ thump.connect(thumpEnv).connect(master);
107
+ thump.start(now);
108
+ thump.stop(now + .34);
109
+ thump.onended = () => thumpEnv.disconnect();
110
+ },
111
+ cashOut() {
112
+ const context = live();
113
+ if (!context) return;
114
+ const now = context.currentTime;
115
+ [
116
+ 523.25,
117
+ 659.25,
118
+ 783.99,
119
+ 1046.5
120
+ ].forEach((frequency, index) => {
121
+ const last = index === 3;
122
+ tone(context, frequency, now + index * .06, {
123
+ type: "triangle",
124
+ gain: .6,
125
+ duration: last ? .45 : .14
126
+ });
127
+ if (last) tone(context, frequency * 2, now + index * .06, {
128
+ gain: .15,
129
+ duration: .5
130
+ });
131
+ });
132
+ },
133
+ dispose() {
134
+ if (disposed) return;
135
+ disposed = true;
136
+ release();
137
+ }
138
+ };
139
+ }
140
+ export { createGameSounds };
141
+
142
+ //# sourceMappingURL=game-sounds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-sounds.js","names":[],"sources":["../../src/lib/game-sounds.ts"],"sourcesContent":["import { getAudioContext, retainAudioContext } from \"./audio-context\";\n\nconst MASTER_GAIN = 0.12;\n// Pentatonic steps from G5, so any run of gems stays in key. Two octaves of\n// climb tops out at G7, bright but not shrill.\nconst BASE = 783.99;\nconst SCALE = [0, 2, 4, 7, 9];\n\n// The context is shared page-wide (lib/audio-context.ts). The master gain\n// belongs to it, so it is rebuilt if the context was closed and recreated.\nlet master: GainNode | null = null;\n\nfunction ensureContext() {\n const ctx = getAudioContext();\n if (ctx && master?.context !== ctx) {\n master = ctx.createGain();\n master.gain.value = MASTER_GAIN;\n master.connect(ctx.destination);\n }\n return ctx;\n}\n\n/** A pitched tone with a fast attack and exponential decay. */\nfunction tone(\n context: AudioContext,\n frequency: number,\n at: number,\n {\n duration = 0.18,\n type = \"sine\",\n gain = 1,\n }: { duration?: number; type?: OscillatorType; gain?: number } = {},\n) {\n if (!master) return;\n const osc = context.createOscillator();\n const env = context.createGain();\n osc.type = type;\n osc.frequency.setValueAtTime(frequency, at);\n env.gain.setValueAtTime(0.0001, at);\n env.gain.exponentialRampToValueAtTime(gain, at + 0.005);\n env.gain.exponentialRampToValueAtTime(0.0001, at + duration);\n osc.connect(env).connect(master);\n osc.start(at);\n osc.stop(at + duration + 0.02);\n osc.onended = () => env.disconnect();\n}\n\nfunction note(step: number) {\n const octave = Math.floor(step / SCALE.length);\n const semitones = SCALE[step % SCALE.length] + octave * 12;\n return BASE * 2 ** (semitones / 12);\n}\n\nexport interface GameSounds {\n /** Unlock audio; call from a click or key handler. */\n prepare: () => void;\n /** A gem; `streak` counts gems in a row, from 1. */\n gem: (streak: number) => void;\n /** A mine. */\n mine: () => void;\n /** Cashing out. */\n cashOut: () => void;\n dispose: () => void;\n}\n\n/**\n * Lazily-initialized game sounds on the page's shared AudioContext. Nothing is created\n * until the first call. Safe during SSR and without Web Audio: every call\n * becomes a silent no-op.\n */\nexport function createGameSounds(): GameSounds {\n const release = retainAudioContext();\n let disposed = false;\n const live = () => (disposed ? null : ensureContext());\n\n return {\n prepare() {\n live();\n },\n gem(streak) {\n const context = live();\n if (!context) return;\n const now = context.currentTime;\n // Every fifth gem in a row leads in with a quick two-note run, so the\n // chime waits for it. Notes can't start in the past.\n const run = streak % 5 === 0;\n const at = run ? now + 0.06 : now;\n if (run) {\n [-2, -1].forEach((offset, index) => {\n tone(context, note(Math.max(0, streak - 1 + offset)), now + index * 0.03, {\n gain: 0.35,\n duration: 0.08,\n });\n });\n }\n // Each gem in a row climbs the scale, capped two octaves up.\n const frequency = note(Math.min(streak - 1, SCALE.length * 2));\n // Glassy: a sine fundamental with a quiet triangle an octave up.\n tone(context, frequency, at, { gain: 0.9 });\n tone(context, frequency * 2, at, { type: \"triangle\", gain: 0.15, duration: 0.12 });\n // From the third gem in a row, a sparkle a fifth above answers the chime.\n if (streak >= 3) tone(context, frequency * 1.5, at + 0.05, { gain: 0.25, duration: 0.1 });\n },\n mine() {\n const context = live();\n if (!context || !master) return;\n const now = context.currentTime;\n // A burst of noise swept down through a low-pass filter…\n const length = Math.ceil(context.sampleRate * 0.45);\n const buffer = context.createBuffer(1, length, context.sampleRate);\n const data = buffer.getChannelData(0);\n for (let i = 0; i < length; i++) data[i] = (Math.random() * 2 - 1) * (1 - i / length) ** 2;\n const noise = context.createBufferSource();\n noise.buffer = buffer;\n const filter = context.createBiquadFilter();\n filter.type = \"lowpass\";\n filter.frequency.setValueAtTime(1600, now);\n filter.frequency.exponentialRampToValueAtTime(180, now + 0.4);\n const env = context.createGain();\n env.gain.setValueAtTime(1.1, now);\n env.gain.exponentialRampToValueAtTime(0.0001, now + 0.45);\n noise.connect(filter).connect(env).connect(master);\n noise.start(now);\n noise.onended = () => env.disconnect();\n // …over a low thump that drops in pitch.\n const thump = context.createOscillator();\n const thumpEnv = context.createGain();\n thump.type = \"sine\";\n thump.frequency.setValueAtTime(110, now);\n thump.frequency.exponentialRampToValueAtTime(42, now + 0.3);\n thumpEnv.gain.setValueAtTime(1.4, now);\n thumpEnv.gain.exponentialRampToValueAtTime(0.0001, now + 0.32);\n thump.connect(thumpEnv).connect(master);\n thump.start(now);\n thump.stop(now + 0.34);\n thump.onended = () => thumpEnv.disconnect();\n },\n cashOut() {\n const context = live();\n if (!context) return;\n const now = context.currentTime;\n // A rising major arpeggio, C5 E5 G5 C6, ending on a held shimmer.\n [523.25, 659.25, 783.99, 1046.5].forEach((frequency, index) => {\n const last = index === 3;\n tone(context, frequency, now + index * 0.06, {\n type: \"triangle\",\n gain: 0.6,\n duration: last ? 0.45 : 0.14,\n });\n if (last) tone(context, frequency * 2, now + index * 0.06, { gain: 0.15, duration: 0.5 });\n });\n },\n dispose() {\n if (disposed) return;\n disposed = true;\n release();\n },\n };\n}\n"],"mappings":";;AAEA,MAAM,cAAc;AAGpB,MAAM,O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CAAC,CAAC,QAAQ,MAAM;GACjD,MAAM,MAAM,GAAG;GACf,MAAM,gBAAgB,IAAI,WAAW;GAErC,MAAM,QAAQ,QAAQ,iBAAiB;GACvC,MAAM,WAAW,QAAQ,WAAW;GACpC,MAAM,OAAO;GACb,MAAM,UAAU,eAAe,KAAK,GAAG;GACvC,MAAM,UAAU,6BAA6B,IAAI,MAAM,EAAG;GAC1D,SAAS,KAAK,eAAe,KAAK,GAAG;GACrC,SAAS,KAAK,6BAA6B,MAAQ,MAAM,GAAI;GAC7D,MAAM,QAAQ,QAAQ,CAAC,CAAC,QAAQ,MAAM;GACtC,MAAM,MAAM,GAAG;GACf,MAAM,KAAK,MAAM,GAAI;GACrB,MAAM,gBAAgB,SAAS,WAAW;EAC5C;EACA,UAAU;GACR,MAAM,UAAU,KAAK;GACrB,IAAI,CAAC,SAAS;GACd,MAAM,MAAM,QAAQ;GAEpB;IAAC;IAAQ;IAAQ;IAAQ;GAAM,CAAC,CAAC,SAAS,WAAW,UAAU;IAC7D,MAAM,OAAO,UAAU;IACvB,KAAK,SAAS,WAAW,MAAM,QAAQ,KAAM;KAC3C,MAAM;KACN,MAAM;KACN,UAAU,OAAO,MAAO;IAC1B,CAAC;IACD,IAAI,MAAM,KAAK,SAAS,YAAY,GAAG,MAAM,QAAQ,KAAM;KAAE,MAAM;KAAM,UAAU;IAAI,CAAC;GAC1F,CAAC;EACH;EACA,UAAU;GACR,IAAI,UAAU;GACd,WAAW;GACX,QAAQ;EACV;CACF;AACF"}
@@ -1,13 +1,14 @@
1
1
  interface TickPlayer {
2
2
  prepare: () => void;
3
- play: () => void;
3
+ /** `rate` below 1 plays a lower, longer tick; above 1 a higher, shorter one. */
4
+ play: (rate?: number) => void;
4
5
  dispose: () => void;
5
6
  }
6
7
  /**
7
8
  * Lazily-initialized tick player. No `AudioContext` is created until the first
8
9
  * `prepare()` or `play()` call anywhere on the page. Every player shares the
9
- * same context/buffer, ref-counted so `dispose()` only tears it down once the
10
- * last consumer is gone. Safe during SSR or in browsers without Web Audio:
10
+ * same context and buffer; the context closes once the last player anywhere
11
+ * on the page is disposed. Safe during SSR or in browsers without Web Audio:
11
12
  * `prepare()` and `play()` become silent no-ops.
12
13
  */
13
14
  export declare function createTickPlayer(): TickPlayer;
@@ -1 +1 @@
1
- {"version":3,"file":"tick-sound.d.ts","names":[],"sources":["../../src/lib/tick-sound.ts"],"mappings":"A,UAwFU;EACR;EACA;EACA;;;;;;;;;wBAUc,oBAAoB"}
1
+ {"version":3,"file":"tick-sound.d.ts","names":[],"sources":["../../src/lib/tick-sound.ts"],"mappings":"A,UAiEU;EACR;;EAEA,OAAO;EACP;;;;;;;;;wBAUc,oBAAoB"}