@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,762 @@
1
+ "use client";
2
+ import { EASE_OUT } from "../../lib/ease.js";
3
+ import { createGameSounds } from "../../lib/game-sounds.js";
4
+ import { t as PresenceGate } from "../../presence-gate-DC7yL1Ls.js";
5
+ import { ActionSwapCascadeIcon } from "./action-swap-cascade.js";
6
+ import { AdaptiveStepper, AdaptiveStepperDecrement, AdaptiveStepperIncrement, AdaptiveStepperValue } from "./adaptive-stepper.js";
7
+ import { Button } from "./button/base.js";
8
+ import { NumberTicker } from "./number-ticker.js";
9
+ import { t as Tooltip } from "../../tooltip-CuHpilPN.js";
10
+ import { useEffect, useRef, useState } from "react";
11
+ import { cn } from "@kumix/utils";
12
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
13
+ import { AnimatePresence, motion, useAnimate, useReducedMotion } from "motion/react";
14
+ import { Gem, Volume2, VolumeX } from "lucide-react";
15
+ // src/components/motion/mines.tsx
16
+ /**
17
+ * Fair payout after `gems` safe picks on a board of `tiles` with `mines`:
18
+ * the inverse of the chance of picking that many gems in a row. `mines` is
19
+ * kept between 0 and tiles − 1 and `gems` between 0 and the safe tiles, so
20
+ * the result is always finite.
21
+ */
22
+ function minesMultiplier(tiles, mines, gems) {
23
+ const safeMines = Math.max(0, Math.min(Math.round(mines), tiles - 1));
24
+ const safeGems = Math.max(0, Math.min(Math.round(gems), tiles - safeMines));
25
+ let multiplier = 1;
26
+ for (let i = 0; i < safeGems; i++) multiplier *= (tiles - i) / (tiles - safeMines - i);
27
+ return multiplier;
28
+ }
29
+ const ICON_SPRING = {
30
+ type: "spring",
31
+ duration: .3,
32
+ bounce: 0
33
+ };
34
+ const RIPPLE_STEP = .025;
35
+ const SHAKE = {
36
+ duration: .3,
37
+ ease: EASE_OUT
38
+ };
39
+ const GEM_POP = {
40
+ type: "spring",
41
+ duration: .35,
42
+ bounce: .4
43
+ };
44
+ const PULSE_STEP = .04;
45
+ const PULSE_TIME = .35;
46
+ const EXIT = {
47
+ duration: .12,
48
+ ease: EASE_OUT
49
+ };
50
+ /**
51
+ * A mines board: pick tiles to find gems, each raising the multiplier, and
52
+ * cash out before you hit a mine. The round's end reveals every tile.
53
+ */
54
+ function Mines({ size: sizeProp = 5, mines: minesProp, defaultMines = 3, onMinesChange, onReveal, onCashOut, sound, defaultSound = false, onSoundChange, showResult = true, "aria-label": ariaLabel = "Mines", className }) {
55
+ const reduce = useReducedMotion() ?? false;
56
+ const size = Math.max(2, Math.round(sizeProp) || 2);
57
+ useEffect(() => {
58
+ if (process.env.NODE_ENV !== "production" && size !== sizeProp) console.warn(`Mines: size must be a whole number of at least 2; using ${size}.`);
59
+ }, [size, sizeProp]);
60
+ const tiles = size * size;
61
+ const [internalMines, setInternalMines] = useState(defaultMines);
62
+ const chosenMines = Math.min(Math.max(1, Math.round(minesProp ?? internalMines) || 1), tiles - 1);
63
+ const [phase, setPhase] = useState("idle");
64
+ const [mineSet, setMineSet] = useState(/* @__PURE__ */ new Set());
65
+ const [picked, setPicked] = useState([]);
66
+ const [cursor, setCursor] = useState(0);
67
+ const [announcement, setAnnouncement] = useState("");
68
+ const [resultOpen, setResultOpen] = useState(false);
69
+ const sectionRef = useRef(null);
70
+ const mainButtonRef = useRef(null);
71
+ const tileRefs = useRef([]);
72
+ const [, animate] = useAnimate();
73
+ const resetBoard = () => {
74
+ setPhase("idle");
75
+ setPicked([]);
76
+ setMineSet(/* @__PURE__ */ new Set());
77
+ setResultOpen(false);
78
+ };
79
+ const [boardSize, setBoardSize] = useState(size);
80
+ if (boardSize !== size) {
81
+ setBoardSize(size);
82
+ resetBoard();
83
+ setCursor(0);
84
+ }
85
+ const mines = phase === "idle" ? chosenMines : mineSet.size;
86
+ const gems = picked.filter((tile) => !mineSet.has(tile)).length;
87
+ const multiplier = minesMultiplier(tiles, mines, gems);
88
+ const next = minesMultiplier(tiles, mines, gems + 1);
89
+ const over = phase === "busted" || phase === "cashed";
90
+ const safe = (tiles - mines - gems) / (tiles - gems);
91
+ const lastPick = picked.at(-1) ?? Math.floor(tiles / 2);
92
+ const resultShown = resultOpen && showResult && over;
93
+ const [internalSound, setInternalSound] = useState(defaultSound);
94
+ const soundOn = sound ?? internalSound;
95
+ const player = useRef(null);
96
+ const getPlayer = () => {
97
+ if (!player.current) player.current = createGameSounds();
98
+ return player.current;
99
+ };
100
+ useEffect(() => () => {
101
+ player.current?.dispose();
102
+ player.current = null;
103
+ }, []);
104
+ const setMines = (value) => {
105
+ if (over) resetBoard();
106
+ if (minesProp === void 0) setInternalMines(value);
107
+ onMinesChange?.(value);
108
+ };
109
+ const closeResult = () => {
110
+ setResultOpen(false);
111
+ mainButtonRef.current?.focus();
112
+ };
113
+ const start = () => {
114
+ resetBoard();
115
+ const order = Array.from({ length: tiles }, (_, i) => i);
116
+ for (let i = order.length - 1; i > 0; i--) {
117
+ const j = Math.floor(Math.random() * (i + 1));
118
+ [order[i], order[j]] = [order[j], order[i]];
119
+ }
120
+ setMineSet(new Set(order.slice(0, chosenMines)));
121
+ setPhase("playing");
122
+ if (!reduce) tileRefs.current.forEach((tile, index) => {
123
+ if (!tile) return;
124
+ const wave = Math.floor(index / size) + index % size;
125
+ animate(tile, {
126
+ scale: [.94, 1],
127
+ opacity: [.5, 1]
128
+ }, {
129
+ duration: .2,
130
+ delay: wave * .025,
131
+ ease: EASE_OUT
132
+ });
133
+ });
134
+ setAnnouncement(`Round started with ${chosenMines} ${chosenMines === 1 ? "mine" : "mines"}.`);
135
+ if (soundOn) getPlayer().prepare();
136
+ };
137
+ const cashOut = (finalGems = gems) => {
138
+ if (phase !== "playing" || finalGems === 0) return;
139
+ const value = minesMultiplier(tiles, mines, finalGems);
140
+ setPhase("cashed");
141
+ setAnnouncement(`Cashed out at ${formatMultiplier(value)}.`);
142
+ if (soundOn) getPlayer().cashOut();
143
+ onCashOut?.(value, finalGems);
144
+ };
145
+ const pick = (tile) => {
146
+ if (phase !== "playing" || picked.includes(tile)) return;
147
+ setPicked((current) => [...current, tile]);
148
+ if (mineSet.has(tile)) {
149
+ setPhase("busted");
150
+ setAnnouncement("Mine. The round is over.");
151
+ if (soundOn) getPlayer().mine();
152
+ onReveal?.(tile, "mine", 0);
153
+ return;
154
+ }
155
+ const found = gems + 1;
156
+ const node = tileRefs.current[tile];
157
+ if (node && !reduce) animate(node, { scale: [.92, 1] }, GEM_POP);
158
+ const value = minesMultiplier(tiles, mines, found);
159
+ if (soundOn) getPlayer().gem(found);
160
+ onReveal?.(tile, "gem", value);
161
+ if (found === tiles - mines) {
162
+ cashOut(found);
163
+ return;
164
+ }
165
+ setAnnouncement(`Gem. ${formatMultiplier(value)}.`);
166
+ };
167
+ const onKeyDown = (event, tile) => {
168
+ const row = Math.floor(tile / size);
169
+ const col = tile % size;
170
+ const target = {
171
+ ArrowRight: row * size + Math.min(size - 1, col + 1),
172
+ ArrowLeft: row * size + Math.max(0, col - 1),
173
+ ArrowDown: Math.min(size - 1, row + 1) * size + col,
174
+ ArrowUp: Math.max(0, row - 1) * size + col,
175
+ Home: row * size,
176
+ End: row * size + size - 1
177
+ }[event.key];
178
+ if (target === void 0) return;
179
+ event.preventDefault();
180
+ setCursor(target);
181
+ tileRefs.current[target]?.focus();
182
+ };
183
+ let closingEnd = 0;
184
+ if (over) for (let tile = 0; tile < tiles; tile++) {
185
+ const order = picked.indexOf(tile);
186
+ const end = order === -1 ? ringFrom(lastPick, tile, size) * RIPPLE_STEP + ICON_SPRING.duration : phase === "cashed" && !reduce ? order * PULSE_STEP + PULSE_TIME : 0;
187
+ closingEnd = Math.max(closingEnd, end);
188
+ }
189
+ useEffect(() => {
190
+ if (!over || !showResult) return;
191
+ const id = setTimeout(() => {
192
+ if (sectionRef.current?.contains(document.activeElement)) mainButtonRef.current?.focus({ preventScroll: true });
193
+ setResultOpen(true);
194
+ }, closingEnd * 1e3);
195
+ return () => clearTimeout(id);
196
+ }, [
197
+ over,
198
+ showResult,
199
+ closingEnd
200
+ ]);
201
+ const toggleSound = () => {
202
+ const nextSound = !soundOn;
203
+ if (nextSound) getPlayer().prepare();
204
+ if (sound === void 0) setInternalSound(nextSound);
205
+ onSoundChange?.(nextSound);
206
+ };
207
+ return /* @__PURE__ */ jsxs("section", {
208
+ ref: sectionRef,
209
+ "aria-label": ariaLabel,
210
+ className: cn("flex w-full max-w-md flex-col gap-4", className),
211
+ onKeyDown: (event) => {
212
+ if (event.key !== "Escape" || !resultShown) return;
213
+ event.stopPropagation();
214
+ closeResult();
215
+ },
216
+ children: [
217
+ /* @__PURE__ */ jsxs("div", {
218
+ className: "flex flex-wrap items-center justify-between gap-3",
219
+ children: [/* @__PURE__ */ jsxs(AdaptiveStepper, {
220
+ value: chosenMines,
221
+ onValueChange: setMines,
222
+ min: 1,
223
+ max: tiles - 1,
224
+ disabled: phase === "playing",
225
+ formatValueText: (value) => `${value} ${value === 1 ? "mine" : "mines"}`,
226
+ "aria-label": "Mine count",
227
+ children: [
228
+ /* @__PURE__ */ jsx(AdaptiveStepperDecrement, {}),
229
+ /* @__PURE__ */ jsx(AdaptiveStepperValue, { children: (value) => /* @__PURE__ */ jsxs("span", {
230
+ className: "inline-flex items-center gap-1.5",
231
+ children: [/* @__PURE__ */ jsx(MineIcon, { className: "text-muted-foreground size-4" }), value]
232
+ }) }),
233
+ /* @__PURE__ */ jsx(AdaptiveStepperIncrement, {})
234
+ ]
235
+ }), /* @__PURE__ */ jsxs("div", {
236
+ className: "text-right",
237
+ children: [/* @__PURE__ */ jsx("div", {
238
+ className: "text-foreground text-2xl font-semibold",
239
+ children: phase === "busted" ? /* @__PURE__ */ jsx("span", {
240
+ className: "text-muted-foreground tabular-nums line-through decoration-2",
241
+ children: formatMultiplier(multiplier)
242
+ }) : /* @__PURE__ */ jsx(NumberTicker, {
243
+ value: multiplier,
244
+ decimals: 2,
245
+ format: compact,
246
+ suffix: "×",
247
+ startOnView: false,
248
+ duration: .35
249
+ })
250
+ }), /* @__PURE__ */ jsx("p", {
251
+ className: "text-muted-foreground flex items-center justify-end gap-1.5 text-xs tabular-nums",
252
+ children: over ? phase === "busted" ? "Multiplier lost" : "Multiplier" : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(OddsRing, {
253
+ safe,
254
+ reduce
255
+ }), phase === "playing" ? `${Math.round(safe * 100)}% safe · next ${formatMultiplier(next)}` : `First pick ${Math.round(safe * 100)}% safe`] })
256
+ })]
257
+ })]
258
+ }),
259
+ /* @__PURE__ */ jsxs("div", {
260
+ className: "bg-muted/40 relative rounded-3xl p-3",
261
+ children: [/* @__PURE__ */ jsxs("fieldset", {
262
+ inert: resultShown,
263
+ className: "m-0 grid min-w-0 gap-2 border-0 p-0",
264
+ style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` },
265
+ children: [/* @__PURE__ */ jsx("legend", {
266
+ className: "sr-only",
267
+ children: "Tiles"
268
+ }), Array.from({ length: tiles }, (_, tile) => {
269
+ const isPicked = picked.includes(tile);
270
+ const isMine = mineSet.has(tile);
271
+ const shown = isPicked || over;
272
+ const content = shown ? isMine ? "mine" : "gem" : null;
273
+ const hit = isPicked && isMine;
274
+ const row = Math.floor(tile / size);
275
+ const col = tile % size;
276
+ const ripple = ringFrom(lastPick, tile, size);
277
+ const order = picked.indexOf(tile);
278
+ const celebrate = phase === "cashed" && isPicked && !reduce;
279
+ const interactive = phase === "playing" && !isPicked;
280
+ return /* @__PURE__ */ jsxs(motion.button, {
281
+ ref: (node) => {
282
+ tileRefs.current[tile] = node;
283
+ },
284
+ type: "button",
285
+ tabIndex: tile === cursor ? 0 : -1,
286
+ "aria-disabled": !interactive,
287
+ "aria-label": `Row ${row + 1}, column ${col + 1}, ${tileState(content, isPicked, order)}`,
288
+ onFocus: () => setCursor(tile),
289
+ onClick: () => pick(tile),
290
+ onKeyDown: (event) => onKeyDown(event, tile),
291
+ animate: hit && !reduce ? { x: [
292
+ 0,
293
+ -5,
294
+ 5,
295
+ -3,
296
+ 3,
297
+ 0
298
+ ] } : { x: 0 },
299
+ transition: SHAKE,
300
+ className: cn("relative grid aspect-square place-items-center rounded-xl border outline-none", hit && "z-10", "transition-[translate,scale,background-color,border-color] duration-150 ease-out", "focus-visible:ring-ring focus-visible:ring-2", interactive ? "border-border bg-card cursor-pointer hover:-translate-y-0.5 hover:border-(--color-border-strong) active:scale-[0.96]" : "cursor-default border-transparent", !interactive && !shown && "bg-card/60", content === "gem" && (isPicked ? "bg-primary/15" : "bg-card/40"), content === "mine" && (hit ? "bg-rose-500/20" : "bg-card/40")),
301
+ children: [
302
+ hit && !reduce ? /* @__PURE__ */ jsx(motion.span, {
303
+ "aria-hidden": "true",
304
+ className: "pointer-events-none absolute inset-0 rounded-xl border-2 border-rose-500",
305
+ initial: {
306
+ scale: 1,
307
+ opacity: .7
308
+ },
309
+ animate: {
310
+ scale: 1.7,
311
+ opacity: 0
312
+ },
313
+ transition: {
314
+ duration: .45,
315
+ ease: EASE_OUT
316
+ }
317
+ }) : null,
318
+ isPicked && !isMine ? /* @__PURE__ */ jsx(motion.span, {
319
+ "aria-hidden": "true",
320
+ initial: { opacity: 0 },
321
+ animate: { opacity: 1 },
322
+ transition: {
323
+ duration: .15,
324
+ ease: EASE_OUT,
325
+ delay: .1
326
+ },
327
+ className: "text-primary/70 absolute top-1.5 left-2 text-[10px] font-medium tabular-nums",
328
+ children: order + 1
329
+ }) : null,
330
+ /* @__PURE__ */ jsx(AnimatePresence, {
331
+ initial: false,
332
+ children: content ? /* @__PURE__ */ jsx(motion.span, {
333
+ "aria-hidden": "true",
334
+ initial: reduce ? { opacity: 0 } : {
335
+ opacity: 0,
336
+ scale: .25,
337
+ filter: "blur(4px)"
338
+ },
339
+ animate: celebrate ? {
340
+ opacity: 1,
341
+ scale: [
342
+ 1,
343
+ 1.2,
344
+ 1
345
+ ],
346
+ filter: "blur(0px)"
347
+ } : {
348
+ opacity: isPicked ? 1 : .4,
349
+ scale: 1,
350
+ filter: "blur(0px)"
351
+ },
352
+ exit: reduce ? {
353
+ opacity: 0,
354
+ transition: EXIT
355
+ } : {
356
+ opacity: 0,
357
+ scale: .9,
358
+ transition: EXIT
359
+ },
360
+ transition: celebrate ? {
361
+ duration: PULSE_TIME,
362
+ ease: EASE_OUT,
363
+ delay: order * PULSE_STEP
364
+ } : {
365
+ ...ICON_SPRING,
366
+ delay: isPicked ? 0 : ripple * RIPPLE_STEP
367
+ },
368
+ className: cn("grid place-items-center", content === "gem" ? "text-primary" : "text-rose-500 dark:text-rose-400"),
369
+ children: content === "gem" ? /* @__PURE__ */ jsx(Gem, {
370
+ className: "size-[45%] min-h-5 min-w-5",
371
+ strokeWidth: 2
372
+ }) : /* @__PURE__ */ jsx(MineIcon, { className: "size-[45%] min-h-5 min-w-5" })
373
+ }, content) : null
374
+ })
375
+ ]
376
+ }, tile);
377
+ })]
378
+ }), /* @__PURE__ */ jsx(AnimatePresence, { children: resultShown ? /* @__PURE__ */ jsx(PresenceGate, { children: ({ gate }) => /* @__PURE__ */ jsx(ResultCard, {
379
+ gate,
380
+ outcome: phase === "cashed" ? "cashed" : "busted",
381
+ multiplier,
382
+ gems,
383
+ safeTiles: tiles - mines,
384
+ mines,
385
+ size,
386
+ picked,
387
+ mineSet,
388
+ reduce,
389
+ onClose: closeResult
390
+ }) }, "result") : null })]
391
+ }),
392
+ /* @__PURE__ */ jsxs("div", {
393
+ className: "flex items-center gap-2",
394
+ children: [/* @__PURE__ */ jsx(Button, {
395
+ ref: mainButtonRef,
396
+ className: "flex-1 aria-disabled:cursor-not-allowed aria-disabled:opacity-50",
397
+ pressScale: .96,
398
+ "aria-disabled": phase === "playing" && gems === 0 || void 0,
399
+ onClick: () => phase === "playing" ? cashOut() : start(),
400
+ children: phase === "playing" ? `Cash out ${formatMultiplier(multiplier)}` : over ? "Play again" : "Start"
401
+ }), /* @__PURE__ */ jsx(Tooltip, {
402
+ content: "Sound",
403
+ side: "top",
404
+ children: /* @__PURE__ */ jsx(Button, {
405
+ variant: "secondary",
406
+ onClick: toggleSound,
407
+ "aria-label": "Sound",
408
+ "aria-pressed": soundOn,
409
+ pressScale: .96,
410
+ className: cn("w-10 px-0", soundOn ? "text-foreground" : "text-muted-foreground"),
411
+ children: /* @__PURE__ */ jsx(ActionSwapCascadeIcon, {
412
+ value: soundOn ? "on" : "off",
413
+ className: "size-4",
414
+ children: soundOn ? /* @__PURE__ */ jsx(Volume2, {
415
+ "aria-hidden": "true",
416
+ className: "size-4"
417
+ }) : /* @__PURE__ */ jsx(VolumeX, {
418
+ "aria-hidden": "true",
419
+ className: "size-4"
420
+ })
421
+ })
422
+ })
423
+ })]
424
+ }),
425
+ /* @__PURE__ */ jsx("p", {
426
+ "aria-live": "polite",
427
+ className: "sr-only",
428
+ children: announcement
429
+ })
430
+ ]
431
+ });
432
+ }
433
+ const TEAR = 104;
434
+ const NOTCH_MASK = `radial-gradient(circle 9px at 0 ${TEAR}px, transparent 98%, black), radial-gradient(circle 9px at 100% ${TEAR}px, transparent 98%, black)`;
435
+ const CARD_IN = {
436
+ type: "spring",
437
+ duration: .4,
438
+ bounce: .15
439
+ };
440
+ const CARD_OUT = {
441
+ duration: .15,
442
+ ease: EASE_OUT
443
+ };
444
+ /**
445
+ * The end-of-round summary over a dimmed board. It has no buttons: the main
446
+ * action below the board already says Play again, and tapping anywhere on
447
+ * the board (or Escape) puts the card away to study the board.
448
+ */
449
+ function ResultCard(props) {
450
+ const { gate, reduce, onClose } = props;
451
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(motion.button, {
452
+ type: "button",
453
+ "aria-label": "Hide result and show the board",
454
+ onClick: onClose,
455
+ ...gate,
456
+ className: "bg-background/55 focus-visible:ring-ring absolute inset-0 z-20 cursor-default rounded-3xl backdrop-blur-[2px] outline-none focus-visible:ring-2",
457
+ initial: { opacity: 0 },
458
+ animate: { opacity: 1 },
459
+ exit: {
460
+ opacity: 0,
461
+ transition: CARD_OUT
462
+ },
463
+ transition: {
464
+ duration: .2,
465
+ ease: EASE_OUT
466
+ }
467
+ }), /* @__PURE__ */ jsx("div", {
468
+ inert: gate.inert,
469
+ className: "pointer-events-none absolute inset-0 z-20 grid place-items-center p-4",
470
+ children: /* @__PURE__ */ jsx(motion.div, {
471
+ role: "group",
472
+ "aria-label": "Round result",
473
+ className: cn("w-full max-w-[17rem]", TICKET_SHADOW),
474
+ initial: reduce ? { opacity: 0 } : {
475
+ opacity: 0,
476
+ y: 16,
477
+ scale: .96
478
+ },
479
+ animate: {
480
+ opacity: 1,
481
+ y: 0,
482
+ scale: 1
483
+ },
484
+ exit: reduce ? {
485
+ opacity: 0,
486
+ transition: CARD_OUT
487
+ } : {
488
+ opacity: 0,
489
+ y: 8,
490
+ scale: .98,
491
+ transition: CARD_OUT
492
+ },
493
+ transition: reduce ? { duration: .2 } : CARD_IN,
494
+ children: /* @__PURE__ */ jsx(Ticket, { ...props })
495
+ })
496
+ })] });
497
+ }
498
+ const STAGE = {
499
+ duration: .25,
500
+ ease: EASE_OUT
501
+ };
502
+ const REPLAY_START = .3;
503
+ const REPLAY_STEP = .05;
504
+ const CELL_SPRING = {
505
+ type: "spring",
506
+ duration: .3,
507
+ bounce: .3
508
+ };
509
+ function Stage({ delay, reduce, className, children }) {
510
+ return /* @__PURE__ */ jsx(motion.div, {
511
+ className,
512
+ initial: reduce ? { opacity: 0 } : {
513
+ opacity: 0,
514
+ y: 6
515
+ },
516
+ animate: {
517
+ opacity: 1,
518
+ y: 0
519
+ },
520
+ transition: {
521
+ ...STAGE,
522
+ delay: reduce ? 0 : delay
523
+ },
524
+ children
525
+ });
526
+ }
527
+ function MiniMap({ size, picked, mineSet, reduce }) {
528
+ const hit = picked.at(-1);
529
+ const gap = size > 10 ? 1 : 3;
530
+ return /* @__PURE__ */ jsx("div", {
531
+ "aria-hidden": "true",
532
+ className: "grid shrink-0",
533
+ style: {
534
+ gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))`,
535
+ gap,
536
+ width: Math.min(88, size * 8 + (size - 1) * gap)
537
+ },
538
+ children: Array.from({ length: size * size }, (_, tile) => {
539
+ const isMine = mineSet.has(tile);
540
+ const isPicked = picked.includes(tile);
541
+ const order = picked.indexOf(tile);
542
+ return /* @__PURE__ */ jsx(motion.span, {
543
+ initial: isPicked && !reduce ? {
544
+ opacity: 0,
545
+ scale: .4
546
+ } : false,
547
+ animate: {
548
+ opacity: 1,
549
+ scale: 1
550
+ },
551
+ transition: {
552
+ ...CELL_SPRING,
553
+ delay: REPLAY_START + order * REPLAY_STEP
554
+ },
555
+ className: cn("aspect-square rounded-[2px]", isPicked && !isMine && "bg-primary", isPicked && isMine && tile === hit && "bg-rose-500", !isPicked && isMine && "ring-1 ring-rose-500/60 ring-inset", !isPicked && !isMine && "bg-foreground/10")
556
+ }, tile);
557
+ })
558
+ });
559
+ }
560
+ const TICKET_SHADOW = "[filter:drop-shadow(0_1px_1px_rgb(0_0_0/0.12))_drop-shadow(0_12px_16px_rgb(0_0_0/0.3))]";
561
+ /** A ticket stub, notched at a dashed tear line. */
562
+ function Ticket({ outcome, multiplier, gems, safeTiles, mines, size, picked, mineSet, reduce }) {
563
+ const cashed = outcome === "cashed";
564
+ return /* @__PURE__ */ jsxs("div", {
565
+ className: "bg-card text-foreground @container w-full rounded-2xl",
566
+ style: {
567
+ WebkitMaskImage: NOTCH_MASK,
568
+ WebkitMaskComposite: "source-in",
569
+ maskImage: NOTCH_MASK,
570
+ maskComposite: "intersect"
571
+ },
572
+ children: [
573
+ /* @__PURE__ */ jsxs("div", {
574
+ className: cn("flex flex-col items-center justify-center gap-1 rounded-t-2xl px-5 text-center", cashed ? "bg-primary/10" : "bg-rose-500/10"),
575
+ style: { height: TEAR },
576
+ children: [/* @__PURE__ */ jsx(Stage, {
577
+ delay: .05,
578
+ reduce,
579
+ children: /* @__PURE__ */ jsx("p", {
580
+ className: cn("text-xs font-medium tracking-wide uppercase", cashed ? "text-primary" : "text-rose-600 dark:text-rose-400"),
581
+ children: cashed ? "Cashed out" : "Mine hit"
582
+ })
583
+ }), /* @__PURE__ */ jsx(Stage, {
584
+ delay: .1,
585
+ reduce,
586
+ children: /* @__PURE__ */ jsx("p", {
587
+ className: cn("text-3xl font-semibold", !cashed && "text-muted-foreground line-through decoration-2"),
588
+ children: cashed ? /* @__PURE__ */ jsx(NumberTicker, {
589
+ value: multiplier,
590
+ decimals: 2,
591
+ format: compact,
592
+ suffix: "×",
593
+ startOnView: false,
594
+ duration: .6,
595
+ stagger: .05
596
+ }) : /* @__PURE__ */ jsx("span", {
597
+ className: "tabular-nums",
598
+ children: formatMultiplier(multiplier)
599
+ })
600
+ })
601
+ })]
602
+ }),
603
+ /* @__PURE__ */ jsx("div", {
604
+ "aria-hidden": "true",
605
+ className: "border-border mx-4 border-t-2 border-dashed"
606
+ }),
607
+ /* @__PURE__ */ jsxs("div", {
608
+ className: "flex items-center gap-4 px-5 pt-4 pb-5",
609
+ children: [/* @__PURE__ */ jsx(Stage, {
610
+ delay: .18,
611
+ reduce,
612
+ className: "flex-1",
613
+ children: /* @__PURE__ */ jsxs("dl", {
614
+ className: "grid gap-1.5 text-xs",
615
+ children: [
616
+ /* @__PURE__ */ jsx(Row, {
617
+ label: "Gems",
618
+ value: `${gems} of ${safeTiles}`
619
+ }),
620
+ /* @__PURE__ */ jsx(Row, {
621
+ label: "Mines",
622
+ value: mines
623
+ }),
624
+ /* @__PURE__ */ jsx(Row, {
625
+ label: cashed ? "Odds beaten" : "Lost on pick",
626
+ value: cashed ? `1 in ${compact(multiplier)}` : picked.length
627
+ })
628
+ ]
629
+ })
630
+ }), /* @__PURE__ */ jsx(Stage, {
631
+ delay: .24,
632
+ reduce,
633
+ className: "@max-[15rem]:hidden",
634
+ children: /* @__PURE__ */ jsx(MiniMap, {
635
+ size,
636
+ picked,
637
+ mineSet,
638
+ reduce
639
+ })
640
+ })]
641
+ })
642
+ ]
643
+ });
644
+ }
645
+ function Row({ label, value }) {
646
+ return /* @__PURE__ */ jsxs("div", {
647
+ className: "flex justify-between gap-2 whitespace-nowrap",
648
+ children: [/* @__PURE__ */ jsx("dt", {
649
+ className: "text-muted-foreground",
650
+ children: label
651
+ }), /* @__PURE__ */ jsx("dd", {
652
+ className: "font-medium tabular-nums",
653
+ children: value
654
+ })]
655
+ });
656
+ }
657
+ const SPIKES = Array.from({ length: 8 }, (_, i) => {
658
+ const angle = i * Math.PI / 4;
659
+ const main = i % 2 === 0;
660
+ const [cos, sin] = [Math.cos(angle), Math.sin(angle)];
661
+ const reach = main ? 10.5 : 9;
662
+ return {
663
+ main,
664
+ x1: 12 + cos * 6,
665
+ y1: 12 + sin * 6,
666
+ x2: 12 + cos * reach,
667
+ y2: 12 + sin * reach
668
+ };
669
+ });
670
+ /** A mine on Lucide's 24px grid, sized to pair with the gem. */
671
+ function MineIcon({ className }) {
672
+ return /* @__PURE__ */ jsxs("svg", {
673
+ "aria-hidden": "true",
674
+ viewBox: "0 0 24 24",
675
+ fill: "currentColor",
676
+ stroke: "currentColor",
677
+ strokeLinecap: "round",
678
+ className,
679
+ children: [
680
+ SPIKES.map((spike) => /* @__PURE__ */ jsx("line", {
681
+ x1: spike.x1,
682
+ y1: spike.y1,
683
+ x2: spike.x2,
684
+ y2: spike.y2,
685
+ strokeWidth: spike.main ? 2.5 : 2
686
+ }, `${spike.x2.toFixed(2)}-${spike.y2.toFixed(2)}`)),
687
+ /* @__PURE__ */ jsx("circle", {
688
+ cx: 12,
689
+ cy: 12,
690
+ r: 6.5,
691
+ stroke: "none"
692
+ }),
693
+ /* @__PURE__ */ jsx("circle", {
694
+ cx: 9.75,
695
+ cy: 9.75,
696
+ r: 1.6,
697
+ fill: "white",
698
+ fillOpacity: .75,
699
+ stroke: "none"
700
+ })
701
+ ]
702
+ });
703
+ }
704
+ /** A small ring that fills with the chance the next pick is safe. */
705
+ function OddsRing({ safe, reduce }) {
706
+ return /* @__PURE__ */ jsxs("svg", {
707
+ "aria-hidden": "true",
708
+ viewBox: "0 0 14 14",
709
+ className: "size-3.5 -rotate-90",
710
+ children: [/* @__PURE__ */ jsx("circle", {
711
+ cx: 7,
712
+ cy: 7,
713
+ r: 5.5,
714
+ fill: "none",
715
+ strokeWidth: 2,
716
+ className: "stroke-foreground/10"
717
+ }), /* @__PURE__ */ jsx(motion.circle, {
718
+ cx: 7,
719
+ cy: 7,
720
+ r: 5.5,
721
+ fill: "none",
722
+ strokeWidth: 2,
723
+ strokeLinecap: "round",
724
+ className: safe < .5 ? "stroke-rose-500 dark:stroke-rose-400" : "stroke-primary",
725
+ initial: false,
726
+ animate: { pathLength: safe },
727
+ transition: reduce ? { duration: 0 } : {
728
+ duration: .2,
729
+ ease: EASE_OUT
730
+ }
731
+ })]
732
+ });
733
+ }
734
+ /** What a tile shows, and for revealed tiles whether the player picked it. */
735
+ function tileState(content, isPicked, order) {
736
+ if (!content) return "hidden";
737
+ if (!isPicked) return `${content}, not picked`;
738
+ return content === "mine" ? "mine, hit" : `gem, pick ${order + 1}`;
739
+ }
740
+ /** Rings between two tiles: 0 for the same tile, 1 for its neighbours. */
741
+ function ringFrom(from, tile, size) {
742
+ return Math.max(Math.abs(Math.floor(tile / size) - Math.floor(from / size)), Math.abs(tile % size - from % size));
743
+ }
744
+ const SHORT = new Intl.NumberFormat("en", {
745
+ notation: "compact",
746
+ maximumFractionDigits: 1
747
+ });
748
+ const SCIENTIFIC = new Intl.NumberFormat("en", {
749
+ notation: "scientific",
750
+ maximumFractionDigits: 1
751
+ });
752
+ function compact(multiplier) {
753
+ if (multiplier < 1e4) return multiplier.toFixed(2);
754
+ return (multiplier < 0x38d7ea4c68000 ? SHORT : SCIENTIFIC).format(multiplier);
755
+ }
756
+ /** A multiplier as Mines shows it: 2.50×, or shortened when large (5.2M×). */
757
+ function formatMultiplier(multiplier) {
758
+ return `${compact(multiplier)}×`;
759
+ }
760
+ export { Mines, formatMultiplier, minesMultiplier };
761
+
762
+ //# sourceMappingURL=mines.js.map