bits-lab 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +57 -2
  3. package/dist/Accordion.d.ts +52 -0
  4. package/dist/Accordion.js +192 -0
  5. package/dist/AchievementToast.d.ts +36 -0
  6. package/dist/AchievementToast.js +162 -0
  7. package/dist/AgentCard.d.ts +41 -0
  8. package/dist/AgentCard.js +168 -0
  9. package/dist/ArcadeButtons.d.ts +23 -0
  10. package/dist/ArcadeButtons.js +169 -0
  11. package/dist/AuroraBands.d.ts +19 -0
  12. package/dist/AuroraBands.js +126 -0
  13. package/dist/AvatarTooltips.d.ts +32 -0
  14. package/dist/AvatarTooltips.js +121 -0
  15. package/dist/BarRace.d.ts +39 -0
  16. package/dist/BarRace.js +227 -0
  17. package/dist/BentoGrid.d.ts +50 -0
  18. package/dist/BentoGrid.js +145 -0
  19. package/dist/BootSequence.d.ts +48 -0
  20. package/dist/BootSequence.js +234 -0
  21. package/dist/BreadcrumbTrail.d.ts +31 -0
  22. package/dist/BreadcrumbTrail.js +181 -0
  23. package/dist/CRTPower.d.ts +30 -0
  24. package/dist/CRTPower.js +142 -0
  25. package/dist/CardDeck.d.ts +29 -0
  26. package/dist/CardDeck.js +154 -0
  27. package/dist/ChangelogTimeline.d.ts +35 -0
  28. package/dist/ChangelogTimeline.js +137 -0
  29. package/dist/ChapterProgress.d.ts +23 -0
  30. package/dist/ChapterProgress.js +211 -0
  31. package/dist/ChatBubbles.d.ts +42 -0
  32. package/dist/ChatBubbles.js +198 -0
  33. package/dist/ChiptuneKit.d.ts +158 -0
  34. package/dist/ChiptuneKit.js +207 -0
  35. package/dist/CipherCard.d.ts +22 -0
  36. package/dist/CipherCard.js +91 -0
  37. package/dist/CloudSky.d.ts +28 -0
  38. package/dist/CloudSky.js +222 -0
  39. package/dist/CodeRain.d.ts +24 -0
  40. package/dist/CodeRain.js +158 -0
  41. package/dist/CodeShowcase.d.ts +50 -0
  42. package/dist/CodeShowcase.js +307 -0
  43. package/dist/ColorDial.d.ts +42 -0
  44. package/dist/ColorDial.js +288 -0
  45. package/dist/CommandPalette.d.ts +59 -0
  46. package/dist/CommandPalette.js +349 -0
  47. package/dist/CompareSlider.d.ts +33 -0
  48. package/dist/CompareSlider.js +152 -0
  49. package/dist/Confetti.d.ts +61 -0
  50. package/dist/Confetti.js +176 -0
  51. package/dist/ConnectBeams.d.ts +39 -0
  52. package/dist/ConnectBeams.js +132 -0
  53. package/dist/ContextOrb.d.ts +34 -0
  54. package/dist/ContextOrb.js +269 -0
  55. package/dist/ContourLines.d.ts +20 -0
  56. package/dist/ContourLines.js +159 -0
  57. package/dist/Coverflow.d.ts +27 -0
  58. package/dist/Coverflow.js +167 -0
  59. package/dist/CursorAttractor.d.ts +21 -0
  60. package/dist/CursorAttractor.js +136 -0
  61. package/dist/CutReveal.d.ts +21 -0
  62. package/dist/CutReveal.js +116 -0
  63. package/dist/DateRange.d.ts +45 -0
  64. package/dist/DateRange.js +327 -0
  65. package/dist/DeviceFrame.d.ts +30 -0
  66. package/dist/DeviceFrame.js +145 -0
  67. package/dist/DiffReveal.d.ts +36 -0
  68. package/dist/DiffReveal.js +247 -0
  69. package/dist/DirectionHover.d.ts +15 -0
  70. package/dist/DirectionHover.js +90 -0
  71. package/dist/Discard.d.ts +18 -0
  72. package/dist/Discard.js +61 -0
  73. package/dist/DitherField.d.ts +15 -0
  74. package/dist/DitherField.js +157 -0
  75. package/dist/DotGlobe.d.ts +48 -0
  76. package/dist/DotGlobe.js +312 -0
  77. package/dist/DotMap.d.ts +47 -0
  78. package/dist/DotMap.js +172 -0
  79. package/dist/DropZone.d.ts +57 -0
  80. package/dist/DropZone.js +304 -0
  81. package/dist/DynamicIsland.d.ts +32 -0
  82. package/dist/DynamicIsland.js +92 -0
  83. package/dist/EdgeFX.d.ts +27 -0
  84. package/dist/EdgeFX.js +98 -0
  85. package/dist/ElasticString.d.ts +22 -0
  86. package/dist/ElasticString.js +127 -0
  87. package/dist/ExpandCard.d.ts +44 -0
  88. package/dist/ExpandCard.js +182 -0
  89. package/dist/FeatureTabs.d.ts +34 -0
  90. package/dist/FeatureTabs.js +169 -0
  91. package/dist/FeedList.d.ts +37 -0
  92. package/dist/FeedList.js +163 -0
  93. package/dist/FlickerGrid.d.ts +29 -0
  94. package/dist/FlickerGrid.js +156 -0
  95. package/dist/FocusGrid.d.ts +20 -0
  96. package/dist/FocusGrid.js +48 -0
  97. package/dist/FocusPull.d.ts +26 -0
  98. package/dist/FocusPull.js +106 -0
  99. package/dist/Footprints.d.ts +24 -0
  100. package/dist/Footprints.js +126 -0
  101. package/dist/FunnelFlow.d.ts +34 -0
  102. package/dist/FunnelFlow.js +267 -0
  103. package/dist/GameOver.d.ts +46 -0
  104. package/dist/GameOver.js +191 -0
  105. package/dist/GaugeMeter.d.ts +38 -0
  106. package/dist/GaugeMeter.js +195 -0
  107. package/dist/GlassPanel.d.ts +27 -0
  108. package/dist/GlassPanel.js +80 -0
  109. package/dist/GrainFX.d.ts +34 -0
  110. package/dist/GrainFX.js +122 -0
  111. package/dist/GravityBox.d.ts +30 -0
  112. package/dist/GravityBox.js +220 -0
  113. package/dist/HealthBar.d.ts +33 -0
  114. package/dist/HealthBar.js +140 -0
  115. package/dist/Heatmap.d.ts +42 -0
  116. package/dist/Heatmap.js +232 -0
  117. package/dist/HexField.d.ts +29 -0
  118. package/dist/HexField.js +188 -0
  119. package/dist/HoldToConfirm.d.ts +29 -0
  120. package/dist/HoldToConfirm.js +163 -0
  121. package/dist/HorizontalTrack.d.ts +28 -0
  122. package/dist/HorizontalTrack.js +195 -0
  123. package/dist/HotbarDock.d.ts +40 -0
  124. package/dist/HotbarDock.js +148 -0
  125. package/dist/InkText.d.ts +27 -0
  126. package/dist/InkText.js +65 -0
  127. package/dist/InlineEdit.d.ts +30 -0
  128. package/dist/InlineEdit.js +198 -0
  129. package/dist/InteractiveGrid.d.ts +25 -0
  130. package/dist/InteractiveGrid.js +194 -0
  131. package/dist/InventoryGrid.d.ts +45 -0
  132. package/dist/InventoryGrid.js +272 -0
  133. package/dist/JellyBlob.d.ts +30 -0
  134. package/dist/JellyBlob.js +209 -0
  135. package/dist/KineticHeadline.d.ts +30 -0
  136. package/dist/KineticHeadline.js +133 -0
  137. package/dist/LavaLamp.d.ts +21 -0
  138. package/dist/LavaLamp.js +133 -0
  139. package/dist/LetterSwap.d.ts +20 -0
  140. package/dist/LetterSwap.js +78 -0
  141. package/dist/LevelMap.d.ts +35 -0
  142. package/dist/LevelMap.js +189 -0
  143. package/dist/LightShafts.d.ts +22 -0
  144. package/dist/LightShafts.js +170 -0
  145. package/dist/LightboxGallery.d.ts +26 -0
  146. package/dist/LightboxGallery.js +327 -0
  147. package/dist/LinkPeek.d.ts +36 -0
  148. package/dist/LinkPeek.js +194 -0
  149. package/dist/LogoOrbit.d.ts +37 -0
  150. package/dist/LogoOrbit.js +117 -0
  151. package/dist/Marquee.d.ts +33 -0
  152. package/dist/Marquee.js +148 -0
  153. package/dist/MarqueeLine.d.ts +33 -0
  154. package/dist/MarqueeLine.js +167 -0
  155. package/dist/MasonryWall.d.ts +13 -0
  156. package/dist/MasonryWall.js +90 -0
  157. package/dist/MegaMenu.d.ts +32 -0
  158. package/dist/MegaMenu.js +280 -0
  159. package/dist/MeteorShower.d.ts +24 -0
  160. package/dist/MeteorShower.js +155 -0
  161. package/dist/Minimap.d.ts +21 -0
  162. package/dist/Minimap.js +236 -0
  163. package/dist/MobileTabBar.d.ts +38 -0
  164. package/dist/MobileTabBar.js +148 -0
  165. package/dist/MorphDialog.d.ts +34 -0
  166. package/dist/MorphDialog.js +199 -0
  167. package/dist/MorphPopover.d.ts +33 -0
  168. package/dist/MorphPopover.js +168 -0
  169. package/dist/MorphWords.d.ts +18 -0
  170. package/dist/MorphWords.js +136 -0
  171. package/dist/OTPInput.d.ts +43 -0
  172. package/dist/OTPInput.js +174 -0
  173. package/dist/OverlayKit.d.ts +97 -0
  174. package/dist/OverlayKit.js +466 -0
  175. package/dist/OverlayMenu.d.ts +32 -0
  176. package/dist/OverlayMenu.js +154 -0
  177. package/dist/ParallaxCollage.d.ts +41 -0
  178. package/dist/ParallaxCollage.js +143 -0
  179. package/dist/PasswordMeter.d.ts +44 -0
  180. package/dist/PasswordMeter.js +165 -0
  181. package/dist/PegBoard.d.ts +26 -0
  182. package/dist/PegBoard.js +184 -0
  183. package/dist/PinCard.d.ts +21 -0
  184. package/dist/PinCard.js +84 -0
  185. package/dist/PixelAvatar.d.ts +33 -0
  186. package/dist/PixelAvatar.js +144 -0
  187. package/dist/PixelButton.d.ts +20 -0
  188. package/dist/PixelButton.js +128 -0
  189. package/dist/PixelExplode.d.ts +31 -0
  190. package/dist/PixelExplode.js +164 -0
  191. package/dist/PixelLoader.d.ts +32 -0
  192. package/dist/PixelLoader.js +142 -0
  193. package/dist/PixelParallax.d.ts +41 -0
  194. package/dist/PixelParallax.js +151 -0
  195. package/dist/PixelSpinners.d.ts +21 -0
  196. package/dist/PixelSpinners.js +110 -0
  197. package/dist/PixelType.d.ts +26 -0
  198. package/dist/PixelType.js +220 -0
  199. package/dist/PointerKit.d.ts +23 -0
  200. package/dist/PointerKit.js +222 -0
  201. package/dist/Polaroids.d.ts +41 -0
  202. package/dist/Polaroids.js +293 -0
  203. package/dist/PressStart.d.ts +28 -0
  204. package/dist/PressStart.js +99 -0
  205. package/dist/PricingFlip.d.ts +52 -0
  206. package/dist/PricingFlip.js +190 -0
  207. package/dist/ProximityType.d.ts +26 -0
  208. package/dist/ProximityType.js +135 -0
  209. package/dist/QuestDialog.d.ts +50 -0
  210. package/dist/QuestDialog.js +204 -0
  211. package/dist/QuestLog.d.ts +39 -0
  212. package/dist/QuestLog.js +214 -0
  213. package/dist/RangeDual.d.ts +34 -0
  214. package/dist/RangeDual.js +238 -0
  215. package/dist/RatingPips.d.ts +25 -0
  216. package/dist/RatingPips.js +129 -0
  217. package/dist/RetroHorizon.d.ts +27 -0
  218. package/dist/RetroHorizon.js +169 -0
  219. package/dist/Reveal.d.ts +30 -0
  220. package/dist/Reveal.js +92 -0
  221. package/dist/RingProgress.d.ts +45 -0
  222. package/dist/RingProgress.js +180 -0
  223. package/dist/RollingNumber.d.ts +28 -0
  224. package/dist/RollingNumber.js +108 -0
  225. package/dist/ScanScope.d.ts +24 -0
  226. package/dist/ScanScope.js +164 -0
  227. package/dist/ScoreTicker.d.ts +32 -0
  228. package/dist/ScoreTicker.js +176 -0
  229. package/dist/ScreenScroller.d.ts +24 -0
  230. package/dist/ScreenScroller.js +138 -0
  231. package/dist/Screensaver.d.ts +31 -0
  232. package/dist/Screensaver.js +221 -0
  233. package/dist/ScrollTilt.d.ts +27 -0
  234. package/dist/ScrollTilt.js +100 -0
  235. package/dist/ScrollTypography.d.ts +26 -0
  236. package/dist/ScrollTypography.js +124 -0
  237. package/dist/ScrollZoom.d.ts +31 -0
  238. package/dist/ScrollZoom.js +123 -0
  239. package/dist/ScrubNumber.d.ts +29 -0
  240. package/dist/ScrubNumber.js +152 -0
  241. package/dist/ShadowStack.d.ts +28 -0
  242. package/dist/ShadowStack.js +116 -0
  243. package/dist/SideRail.d.ts +43 -0
  244. package/dist/SideRail.js +253 -0
  245. package/dist/SignalText.d.ts +25 -0
  246. package/dist/SignalText.js +178 -0
  247. package/dist/SkeletonShimmer.d.ts +18 -0
  248. package/dist/SkeletonShimmer.js +111 -0
  249. package/dist/SketchHighlight.d.ts +27 -0
  250. package/dist/SketchHighlight.js +180 -0
  251. package/dist/SlideTabs.d.ts +40 -0
  252. package/dist/SlideTabs.js +190 -0
  253. package/dist/SmartNavbar.d.ts +48 -0
  254. package/dist/SmartNavbar.js +188 -0
  255. package/dist/SparkChart.d.ts +41 -0
  256. package/dist/SparkChart.js +188 -0
  257. package/dist/Spoiler.d.ts +22 -0
  258. package/dist/Spoiler.js +97 -0
  259. package/dist/SpotlightTour.d.ts +38 -0
  260. package/dist/SpotlightTour.js +231 -0
  261. package/dist/SpringDrawer.d.ts +39 -0
  262. package/dist/SpringDrawer.js +360 -0
  263. package/dist/SpriteAnimator.d.ts +41 -0
  264. package/dist/SpriteAnimator.js +124 -0
  265. package/dist/StatCard.d.ts +43 -0
  266. package/dist/StatCard.js +168 -0
  267. package/dist/StepLoader.d.ts +41 -0
  268. package/dist/StepLoader.js +191 -0
  269. package/dist/StepperForm.d.ts +41 -0
  270. package/dist/StepperForm.js +206 -0
  271. package/dist/StickerBoard.d.ts +39 -0
  272. package/dist/StickerBoard.js +209 -0
  273. package/dist/StickyReveal.d.ts +42 -0
  274. package/dist/StickyReveal.js +181 -0
  275. package/dist/StoryViewer.d.ts +36 -0
  276. package/dist/StoryViewer.js +175 -0
  277. package/dist/StreamingText.d.ts +29 -0
  278. package/dist/StreamingText.js +271 -0
  279. package/dist/SuggestionChips.d.ts +32 -0
  280. package/dist/SuggestionChips.js +96 -0
  281. package/dist/SwipeActions.d.ts +30 -0
  282. package/dist/SwipeActions.js +141 -0
  283. package/dist/TagInput.d.ts +30 -0
  284. package/dist/TagInput.js +284 -0
  285. package/dist/TallyUp.d.ts +38 -0
  286. package/dist/TallyUp.js +157 -0
  287. package/dist/TerminalDemo.d.ts +63 -0
  288. package/dist/TerminalDemo.js +214 -0
  289. package/dist/TestimonialWall.d.ts +35 -0
  290. package/dist/TestimonialWall.js +131 -0
  291. package/dist/TextOnPath.d.ts +36 -0
  292. package/dist/TextOnPath.js +130 -0
  293. package/dist/ThinkingShimmer.d.ts +36 -0
  294. package/dist/ThinkingShimmer.js +132 -0
  295. package/dist/ToastStack.d.ts +62 -0
  296. package/dist/ToastStack.js +289 -0
  297. package/dist/ToggleGroup.d.ts +39 -0
  298. package/dist/ToggleGroup.js +190 -0
  299. package/dist/ToggleKit.d.ts +70 -0
  300. package/dist/ToggleKit.js +229 -0
  301. package/dist/TracingLine.d.ts +24 -0
  302. package/dist/TracingLine.js +139 -0
  303. package/dist/TradingCard.d.ts +30 -0
  304. package/dist/TradingCard.js +147 -0
  305. package/dist/VanishInput.d.ts +34 -0
  306. package/dist/VanishInput.js +190 -0
  307. package/dist/VideoHero.d.ts +32 -0
  308. package/dist/VideoHero.js +207 -0
  309. package/dist/VoiceOrb.d.ts +23 -0
  310. package/dist/VoiceOrb.js +182 -0
  311. package/dist/VoxelTiles.d.ts +38 -0
  312. package/dist/VoxelTiles.js +201 -0
  313. package/dist/WarpField.d.ts +18 -0
  314. package/dist/WarpField.js +160 -0
  315. package/dist/WebcamPixels.d.ts +38 -0
  316. package/dist/WebcamPixels.js +292 -0
  317. package/dist/WheelPicker.d.ts +29 -0
  318. package/dist/WheelPicker.js +199 -0
  319. package/dist/WobbleCard.d.ts +23 -0
  320. package/dist/WobbleCard.js +112 -0
  321. package/dist/index.d.ts +158 -0
  322. package/dist/index.js +159 -0
  323. package/package.json +58 -4
@@ -0,0 +1,293 @@
1
+ 'use client';
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useInsertionEffect, useRef, useState } from "react";
4
+ const STYLE_ID = "bl-polaroids";
5
+ const CSS = `
6
+ .bl-pola { position: relative; display: grid; gap: 10px; width: 100%; font-family: var(--bl-font); }
7
+ .bl-pola__table { position: relative; width: 100%; height: var(--bl-h); overflow: hidden; border-radius: var(--bl-radius); background: var(--bl-bg); box-shadow: inset 0 0 0 2px var(--bl-line); touch-action: none; }
8
+ .bl-pola__photo { position: absolute; top: 0; left: 0; box-sizing: border-box; width: var(--bl-pw); margin: 0; padding: var(--bl-frame) var(--bl-frame) 0; border: 0; background: var(--bl-paper); color: var(--bl-ink); font: inherit; text-align: center; cursor: grab; touch-action: none; filter: drop-shadow(0 3px 4px rgba(0,0,0,0.4)); transition: filter 200ms; outline: none; will-change: transform; }
9
+ .bl-pola__photo[data-held] { cursor: grabbing; filter: drop-shadow(0 22px 18px rgba(0,0,0,0.5)); }
10
+ .bl-pola__photo[data-flying] { filter: drop-shadow(0 14px 12px rgba(0,0,0,0.45)); }
11
+ .bl-pola__photo:focus-visible { box-shadow: 0 0 0 3px var(--bl-accent); }
12
+ .bl-pola__img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #0b0b14; pointer-events: none; user-select: none; }
13
+ .bl-pola__caption { display: block; overflow: hidden; height: var(--bl-caption); line-height: var(--bl-caption); font-size: 14px; white-space: nowrap; text-overflow: ellipsis; }
14
+ .bl-pola__bar { display: flex; justify-content: center; gap: 8px; }
15
+ .bl-pola__btn { padding: 7px 14px; border: 0; border-radius: 8px; background: var(--bl-btn); color: var(--bl-btn-ink); font: inherit; font-size: 14px; cursor: pointer; }
16
+ .bl-pola__btn:hover { filter: brightness(1.15); }
17
+ .bl-pola__btn:focus-visible { outline: 2px solid var(--bl-accent); outline-offset: 2px; }
18
+ .bl-pola__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
19
+ `;
20
+ function useStyles() {
21
+ useInsertionEffect(() => {
22
+ if (typeof document === "undefined") return;
23
+ const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
24
+ style.textContent = CSS;
25
+ if (!style.isConnected) document.head.appendChild(style);
26
+ }, []);
27
+ }
28
+ const jitter = (i, salt) => {
29
+ const x = Math.sin((i + 1) * 12.9898 + salt * 78.233) * 43758.5453;
30
+ return x - Math.floor(x) - 0.5;
31
+ };
32
+ function Polaroids({
33
+ photos = [],
34
+ height = 440,
35
+ photoWidth = 160,
36
+ frame = 10,
37
+ captionHeight = 34,
38
+ friction = 3.2,
39
+ bounce = 0.45,
40
+ spin = 1,
41
+ showControls = true,
42
+ scatterLabel = "Scatter",
43
+ tidyLabel = "Tidy up",
44
+ label = "Photo pile",
45
+ radius = 16,
46
+ backgroundColor = "#5d275d",
47
+ paperColor = "#f4f4f4",
48
+ textColor = "#1a1c2c",
49
+ lineColor = "rgba(0,0,0,0.25)",
50
+ accentColor = "#73eff7",
51
+ buttonColor = "#333c57",
52
+ buttonTextColor = "#f4f4f4",
53
+ fontFamily = '"Pixelify Sans", ui-sans-serif, system-ui, sans-serif',
54
+ className = "",
55
+ style
56
+ }) {
57
+ useStyles();
58
+ const tableRef = useRef(null);
59
+ const nodes = useRef([]);
60
+ const api = useRef(null);
61
+ const [order, setOrder] = useState(() => photos.map((_, i) => i));
62
+ const [announce, setAnnounce] = useState("");
63
+ const name = (i) => photos[i]?.caption || photos[i]?.alt || `Photo ${i + 1}`;
64
+ const raise = (i) => setOrder((list) => [...list.filter((j) => j !== i), i]);
65
+ useEffect(() => {
66
+ setOrder((list) => {
67
+ const kept = list.filter((i) => i < photos.length);
68
+ return [...kept, ...photos.map((_, i) => i).filter((i) => !kept.includes(i))];
69
+ });
70
+ }, [photos.length]);
71
+ useEffect(() => {
72
+ const table = tableRef.current;
73
+ const reduced = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
74
+ const count = photos.length;
75
+ let W = table.clientWidth;
76
+ let H = table.clientHeight;
77
+ const size = (i) => ({ w: nodes.current[i]?.offsetWidth || photoWidth, h: nodes.current[i]?.offsetHeight || photoWidth + captionHeight });
78
+ const bodies = Array.from({ length: count }, (_, i) => {
79
+ const { w, h } = size(i);
80
+ return { x: W / 2 - w / 2 + jitter(i, 1) * W * 0.35, y: H / 2 - h / 2 + jitter(i, 2) * H * 0.3, r: jitter(i, 3) * 30, vx: 0, vy: 0, vr: 0, held: false };
81
+ });
82
+ let raf = 0;
83
+ let last = 0;
84
+ const clamp = (i) => {
85
+ const b = bodies[i];
86
+ const { w, h } = size(i);
87
+ let hit = false;
88
+ if (b.x < 0 || b.x > W - w) {
89
+ b.x = Math.max(0, Math.min(W - w, b.x));
90
+ b.vx = -b.vx * bounce;
91
+ b.vr *= 0.7;
92
+ hit = true;
93
+ }
94
+ if (b.y < 0 || b.y > H - h) {
95
+ b.y = Math.max(0, Math.min(H - h, b.y));
96
+ b.vy = -b.vy * bounce;
97
+ b.vr *= 0.7;
98
+ hit = true;
99
+ }
100
+ return hit;
101
+ };
102
+ const place = (i) => {
103
+ const node = nodes.current[i];
104
+ const b = bodies[i];
105
+ if (node) node.style.transform = `translate(${b.x.toFixed(1)}px, ${b.y.toFixed(1)}px) rotate(${b.r.toFixed(2)}deg)`;
106
+ };
107
+ const tick = (now) => {
108
+ const dt = Math.max(0, Math.min(0.05, (now - last) / 1e3));
109
+ last = now;
110
+ const decay = Math.exp(-friction * dt);
111
+ let moving = false;
112
+ bodies.forEach((b, i) => {
113
+ const node = nodes.current[i];
114
+ if (b.held) return;
115
+ b.x += b.vx * dt;
116
+ b.y += b.vy * dt;
117
+ b.r += b.vr * dt;
118
+ b.vx *= decay;
119
+ b.vy *= decay;
120
+ b.vr *= decay;
121
+ clamp(i);
122
+ const flying = Math.hypot(b.vx, b.vy) > 8 || Math.abs(b.vr) > 4;
123
+ if (flying) moving = true;
124
+ else {
125
+ b.vx = 0;
126
+ b.vy = 0;
127
+ b.vr = 0;
128
+ }
129
+ if (node) node.toggleAttribute("data-flying", flying);
130
+ place(i);
131
+ });
132
+ raf = moving ? requestAnimationFrame(tick) : 0;
133
+ };
134
+ const wake = () => {
135
+ if (raf) return;
136
+ last = performance.now();
137
+ raf = requestAnimationFrame(tick);
138
+ };
139
+ const settle = (i) => {
140
+ const b = bodies[i];
141
+ const k = 1 / friction;
142
+ b.x += b.vx * k;
143
+ b.y += b.vy * k;
144
+ b.r += b.vr * k * 0.3;
145
+ b.vx = b.vy = b.vr = 0;
146
+ clamp(i);
147
+ place(i);
148
+ };
149
+ const launch = (i) => reduced ? settle(i) : wake();
150
+ let drag = null;
151
+ const onDown = (event) => {
152
+ const i = nodes.current.indexOf(event.target.closest(".bl-pola__photo"));
153
+ if (i < 0 || event.button > 0) return;
154
+ event.preventDefault();
155
+ const node = nodes.current[i];
156
+ node.focus({ preventScroll: true });
157
+ try {
158
+ node.setPointerCapture(event.pointerId);
159
+ } catch {
160
+ }
161
+ const rect = table.getBoundingClientRect();
162
+ const b = bodies[i];
163
+ const { w, h } = size(i);
164
+ b.held = true;
165
+ b.vx = b.vy = b.vr = 0;
166
+ node.dataset.held = "";
167
+ drag = { i, id: event.pointerId, rect, dx: event.clientX - rect.left - b.x, dy: event.clientY - rect.top - b.y, gx: event.clientX - rect.left - (b.x + w / 2), gy: event.clientY - rect.top - (b.y + h / 2), samples: [{ x: event.clientX, y: event.clientY, t: event.timeStamp }] };
168
+ raise(i);
169
+ };
170
+ const onMove = (event) => {
171
+ if (!drag || event.pointerId !== drag.id) return;
172
+ const b = bodies[drag.i];
173
+ b.x = event.clientX - drag.rect.left - drag.dx;
174
+ b.y = event.clientY - drag.rect.top - drag.dy;
175
+ clamp(drag.i);
176
+ place(drag.i);
177
+ drag.samples.push({ x: event.clientX, y: event.clientY, t: event.timeStamp });
178
+ while (drag.samples.length > 2 && event.timeStamp - drag.samples[0].t > 80) drag.samples.shift();
179
+ };
180
+ const onUp = (event) => {
181
+ if (!drag || event.pointerId !== drag.id) return;
182
+ const { i, samples, gx, gy } = drag;
183
+ const b = bodies[i];
184
+ const first = samples[0];
185
+ const lastSample = samples[samples.length - 1];
186
+ const span = Math.max(16, lastSample.t - first.t) / 1e3;
187
+ b.vx = (lastSample.x - first.x) / span;
188
+ b.vy = (lastSample.y - first.y) / span;
189
+ b.vr = spin * (gx * b.vy - gy * b.vx) / 900;
190
+ b.held = false;
191
+ delete nodes.current[i].dataset.held;
192
+ drag = null;
193
+ launch(i);
194
+ if (Math.hypot(b.vx, b.vy) > 200) setAnnounce(`${name(i)} tossed.`);
195
+ };
196
+ const onKey = (event) => {
197
+ const i = nodes.current.indexOf(event.target.closest?.(".bl-pola__photo"));
198
+ if (i < 0) return;
199
+ const step = event.shiftKey ? 40 : 10;
200
+ const moves = { ArrowLeft: [-step, 0], ArrowRight: [step, 0], ArrowUp: [0, -step], ArrowDown: [0, step] };
201
+ if (moves[event.key]) {
202
+ event.preventDefault();
203
+ const b = bodies[i];
204
+ b.x += moves[event.key][0];
205
+ b.y += moves[event.key][1];
206
+ clamp(i);
207
+ place(i);
208
+ raise(i);
209
+ setAnnounce(`${name(i)} moved to ${Math.round(b.x)}, ${Math.round(b.y)}.`);
210
+ } else if (event.key === "Enter" || event.key === " ") {
211
+ event.preventDefault();
212
+ raise(i);
213
+ setAnnounce(`${name(i)} on top.`);
214
+ }
215
+ };
216
+ api.current = {
217
+ scatter: () => {
218
+ bodies.forEach((b, i) => {
219
+ const a = Math.random() * Math.PI * 2;
220
+ const speed = 600 + Math.random() * 900;
221
+ b.vx = Math.cos(a) * speed;
222
+ b.vy = Math.sin(a) * speed;
223
+ b.vr = (Math.random() - 0.5) * 400 * spin;
224
+ if (reduced) settle(i);
225
+ });
226
+ if (!reduced) wake();
227
+ setAnnounce("Photos scattered.");
228
+ },
229
+ tidy: () => {
230
+ bodies.forEach((b, i) => {
231
+ const { w, h } = size(i);
232
+ b.x = W / 2 - w / 2 + jitter(i, 4) * 16;
233
+ b.y = H / 2 - h / 2 + jitter(i, 5) * 16;
234
+ b.r = jitter(i, 6) * 10;
235
+ b.vx = b.vy = b.vr = 0;
236
+ place(i);
237
+ });
238
+ setAnnounce("Photos stacked in a neat pile.");
239
+ }
240
+ };
241
+ const resize = new ResizeObserver(() => {
242
+ W = table.clientWidth;
243
+ H = table.clientHeight;
244
+ bodies.forEach((_, i) => {
245
+ clamp(i);
246
+ place(i);
247
+ });
248
+ });
249
+ resize.observe(table);
250
+ bodies.forEach((_, i) => place(i));
251
+ table.addEventListener("pointerdown", onDown);
252
+ table.addEventListener("pointermove", onMove);
253
+ table.addEventListener("pointerup", onUp);
254
+ table.addEventListener("pointercancel", onUp);
255
+ table.addEventListener("keydown", onKey);
256
+ return () => {
257
+ cancelAnimationFrame(raf);
258
+ resize.disconnect();
259
+ table.removeEventListener("pointerdown", onDown);
260
+ table.removeEventListener("pointermove", onMove);
261
+ table.removeEventListener("pointerup", onUp);
262
+ table.removeEventListener("pointercancel", onUp);
263
+ table.removeEventListener("keydown", onKey);
264
+ };
265
+ }, [photos.length, photoWidth, frame, captionHeight, friction, bounce, spin]);
266
+ return /* @__PURE__ */ jsxs("div", { className: `bl-pola ${className}`, style: { "--bl-h": `${height}px`, "--bl-pw": `${photoWidth}px`, "--bl-frame": `${frame}px`, "--bl-caption": `${captionHeight}px`, "--bl-radius": `${radius}px`, "--bl-bg": backgroundColor, "--bl-paper": paperColor, "--bl-ink": textColor, "--bl-line": lineColor, "--bl-accent": accentColor, "--bl-btn": buttonColor, "--bl-btn-ink": buttonTextColor, "--bl-font": fontFamily, ...style }, children: [
267
+ /* @__PURE__ */ jsx("div", { ref: tableRef, className: "bl-pola__table", role: "group", "aria-label": label, children: photos.map((photo, i) => /* @__PURE__ */ jsxs(
268
+ "button",
269
+ {
270
+ ref: (node) => {
271
+ nodes.current[i] = node;
272
+ },
273
+ type: "button",
274
+ className: "bl-pola__photo",
275
+ style: { zIndex: order.indexOf(i) + 1 },
276
+ "aria-label": `${name(i)}. Drag to move, arrows to nudge, Enter to bring to the top.`,
277
+ children: [
278
+ /* @__PURE__ */ jsx("img", { className: "bl-pola__img", src: photo.src, alt: "", draggable: false }),
279
+ /* @__PURE__ */ jsx("span", { className: "bl-pola__caption", children: photo.caption })
280
+ ]
281
+ },
282
+ photo.src ?? i
283
+ )) }),
284
+ showControls && /* @__PURE__ */ jsxs("div", { className: "bl-pola__bar", children: [
285
+ /* @__PURE__ */ jsx("button", { type: "button", className: "bl-pola__btn", onClick: () => api.current?.scatter(), children: scatterLabel }),
286
+ /* @__PURE__ */ jsx("button", { type: "button", className: "bl-pola__btn", onClick: () => api.current?.tidy(), children: tidyLabel })
287
+ ] }),
288
+ /* @__PURE__ */ jsx("span", { className: "bl-pola__sr", "aria-live": "polite", children: announce })
289
+ ] });
290
+ }
291
+ export {
292
+ Polaroids as default
293
+ };
@@ -0,0 +1,28 @@
1
+ import { type CSSProperties } from 'react';
2
+ export interface PressStartProps {
3
+ /** Blinking prompt. */
4
+ text?: string;
5
+ /** Shown after the flash, until `resetAfter`. */
6
+ startedText?: string;
7
+ /** Small line underneath (copyright, version…). Empty to hide. */
8
+ subtext?: string;
9
+ color?: string;
10
+ shadowColor?: string;
11
+ subColor?: string;
12
+ /** Prompt font size, in px. */
13
+ size?: number;
14
+ /** Blink period, in seconds. */
15
+ blinkSpeed?: number;
16
+ /** How long the fast "starting" flash lasts, in ms. */
17
+ flashDuration?: number;
18
+ /** Start on any key press anywhere on the page (ignored while typing in a field). */
19
+ listenGlobally?: boolean;
20
+ /** Return to the prompt after this many ms; 0 to stay started. */
21
+ resetAfter?: number;
22
+ fontFamily?: string;
23
+ /** Called when the flash finishes. */
24
+ onStart?: () => void;
25
+ className?: string;
26
+ style?: CSSProperties;
27
+ }
28
+ export default function PressStart({ text, startedText, subtext, color, shadowColor, subColor, size, blinkSpeed, flashDuration, listenGlobally, resetAfter, fontFamily, onStart, className, style }: PressStartProps): import("react").JSX.Element;
@@ -0,0 +1,99 @@
1
+ 'use client';
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useEffect, useInsertionEffect, useRef, useState } from "react";
4
+ const STYLE_ID = "bl-press-start";
5
+ const CSS = `
6
+ .bl-press-start {
7
+ display: inline-flex; flex-direction: column; align-items: center; gap: 18px;
8
+ border: 0; background: none; cursor: pointer; padding: 12px 16px;
9
+ font-family: var(--bl-font, "Press Start 2P", ui-monospace, monospace);
10
+ }
11
+ .bl-press-start:focus-visible { outline: 4px solid #41a6f6; outline-offset: 6px; }
12
+ .bl-press-start__text {
13
+ color: var(--bl-color); font-size: var(--bl-size); line-height: 1.2; text-transform: uppercase;
14
+ text-shadow: calc(var(--bl-size) / 6) calc(var(--bl-size) / 6) 0 var(--bl-shadow);
15
+ }
16
+ .bl-press-start[data-state="idle"] .bl-press-start__text { animation: bl-ps-blink var(--bl-blink) steps(1) infinite; }
17
+ .bl-press-start[data-state="starting"] .bl-press-start__text { animation: bl-ps-blink 90ms steps(1) infinite; }
18
+ .bl-press-start__sub { color: var(--bl-sub); font-size: calc(var(--bl-size) * 0.45); letter-spacing: 0.1em; text-transform: uppercase; }
19
+ @keyframes bl-ps-blink { 50% { opacity: 0; } }
20
+ @media (prefers-reduced-motion: reduce) {
21
+ .bl-press-start[data-state] .bl-press-start__text { animation: none; }
22
+ }
23
+ `;
24
+ function useStyles() {
25
+ useInsertionEffect(() => {
26
+ if (typeof document === "undefined") return;
27
+ const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
28
+ style.textContent = CSS;
29
+ if (!style.isConnected) document.head.appendChild(style);
30
+ }, []);
31
+ }
32
+ function PressStart({
33
+ text = "Press start",
34
+ startedText = "Get ready!",
35
+ subtext = "\xA9 2026 Bits Lab",
36
+ color = "#ffcd75",
37
+ shadowColor = "#b13e53",
38
+ subColor = "#94b0c2",
39
+ size = 28,
40
+ blinkSpeed = 1.06,
41
+ flashDuration = 700,
42
+ listenGlobally = true,
43
+ resetAfter = 2500,
44
+ fontFamily,
45
+ onStart,
46
+ className = "",
47
+ style
48
+ }) {
49
+ useStyles();
50
+ const [state, setState] = useState("idle");
51
+ const timers = useRef([]);
52
+ const start = useCallback(() => {
53
+ if (state !== "idle") return;
54
+ setState("starting");
55
+ timers.current.push(
56
+ setTimeout(() => {
57
+ setState("started");
58
+ onStart?.();
59
+ if (resetAfter > 0) timers.current.push(setTimeout(() => setState("idle"), resetAfter));
60
+ }, flashDuration)
61
+ );
62
+ }, [state, flashDuration, onStart, resetAfter]);
63
+ useEffect(() => () => timers.current.forEach(clearTimeout), []);
64
+ useEffect(() => {
65
+ if (!listenGlobally) return void 0;
66
+ const onKey = (event) => {
67
+ if (event.repeat || event.metaKey || event.ctrlKey || /input|textarea|select/i.test(event.target.tagName) || event.target.isContentEditable) return;
68
+ start();
69
+ };
70
+ window.addEventListener("keydown", onKey);
71
+ return () => window.removeEventListener("keydown", onKey);
72
+ }, [listenGlobally, start]);
73
+ return /* @__PURE__ */ jsxs(
74
+ "button",
75
+ {
76
+ type: "button",
77
+ className: `bl-press-start ${className}`,
78
+ "data-state": state,
79
+ onClick: start,
80
+ "aria-live": "polite",
81
+ style: {
82
+ "--bl-color": color,
83
+ "--bl-shadow": shadowColor,
84
+ "--bl-sub": subColor,
85
+ "--bl-size": `${size}px`,
86
+ "--bl-blink": `${blinkSpeed}s`,
87
+ ...fontFamily ? { "--bl-font": fontFamily } : null,
88
+ ...style
89
+ },
90
+ children: [
91
+ /* @__PURE__ */ jsx("span", { className: "bl-press-start__text", children: state === "started" ? startedText : text }),
92
+ subtext && /* @__PURE__ */ jsx("span", { className: "bl-press-start__sub", children: subtext })
93
+ ]
94
+ }
95
+ );
96
+ }
97
+ export {
98
+ PressStart as default
99
+ };
@@ -0,0 +1,52 @@
1
+ import { type CSSProperties, type ReactNode } from 'react';
2
+ export type BillingPeriod = 'monthly' | 'yearly';
3
+ export interface PricingPlan {
4
+ id?: string;
5
+ name: string;
6
+ description?: ReactNode;
7
+ /** Price per month when billed monthly; 0 shows freeLabel. */
8
+ monthly: number;
9
+ /** Price per month when billed yearly. */
10
+ yearly?: number;
11
+ features?: string[];
12
+ /** Button label; omit for no button. */
13
+ cta?: ReactNode;
14
+ featured?: boolean;
15
+ /** Ribbon such as "Most popular". */
16
+ badge?: ReactNode;
17
+ }
18
+ export interface PricingFlipProps {
19
+ plans?: PricingPlan[];
20
+ period?: BillingPeriod;
21
+ defaultPeriod?: BillingPeriod;
22
+ onPeriodChange?: (period: BillingPeriod) => void;
23
+ onSelect?: (plan: PricingPlan, period: BillingPeriod) => void;
24
+ /** ISO currency code for Intl.NumberFormat. */
25
+ currency?: string;
26
+ locale?: string;
27
+ monthlyLabel?: string;
28
+ yearlyLabel?: string;
29
+ perLabel?: string;
30
+ freeLabel?: string;
31
+ /** Text under the price in yearly mode, given the formatted yearly total. */
32
+ billedYearly?: (total: string) => string;
33
+ /** Max width of the card grid in px. */
34
+ width?: number;
35
+ priceSize?: number;
36
+ backgroundColor?: string;
37
+ cardColor?: string;
38
+ trackColor?: string;
39
+ textColor?: string;
40
+ mutedColor?: string;
41
+ lineColor?: string;
42
+ accentColor?: string;
43
+ onAccentColor?: string;
44
+ saveColor?: string;
45
+ radius?: number;
46
+ fontFamily?: string;
47
+ /** Accessible name of the period switch. */
48
+ label?: string;
49
+ className?: string;
50
+ style?: CSSProperties;
51
+ }
52
+ export default function PricingFlip({ plans, period: controlled, defaultPeriod, onPeriodChange, onSelect, currency, locale, monthlyLabel, yearlyLabel, perLabel, freeLabel, billedYearly, width, priceSize, backgroundColor, cardColor, trackColor, textColor, mutedColor, lineColor, accentColor, onAccentColor, saveColor, radius, fontFamily, label, className, style }: PricingFlipProps): import("react").JSX.Element;
@@ -0,0 +1,190 @@
1
+ 'use client';
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useId, useInsertionEffect, useRef, useState } from "react";
4
+ const STYLE_ID = "bl-pricing-flip";
5
+ const CSS = `
6
+ .bl-price { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; justify-items: center; width: 100%; color: var(--bl-ink); font-family: var(--bl-font); }
7
+ .bl-price__switch { position: relative; display: inline-grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 999px; background: var(--bl-track); box-shadow: inset 0 0 0 1px var(--bl-line); }
8
+ .bl-price__thumb { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 999px; background: var(--bl-accent); transition: transform 320ms cubic-bezier(.3,1.35,.5,1); }
9
+ .bl-price__switch[data-yearly] .bl-price__thumb { transform: translateX(100%); }
10
+ .bl-price__opt { position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 18px; border: 0; border-radius: 999px; background: transparent; color: var(--bl-muted); font: inherit; font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: color 200ms; }
11
+ .bl-price__opt[aria-checked="true"] { color: var(--bl-on-accent); }
12
+ .bl-price__opt:focus-visible { outline: 2px solid var(--bl-ink); outline-offset: 2px; }
13
+ .bl-price__save { padding: 2px 7px; border-radius: 999px; background: var(--bl-save); color: var(--bl-on-accent); font-size: 11px; font-weight: 700; transform: scale(0.85); transition: transform 320ms cubic-bezier(.3,1.6,.5,1); }
14
+ .bl-price__switch[data-yearly] .bl-price__save { transform: scale(1.08) rotate(-4deg); }
15
+ .bl-price__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 18px; width: 100%; max-width: var(--bl-w); }
16
+ .bl-price__card { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 24px; border-radius: var(--bl-radius); background: var(--bl-card); box-shadow: 0 0 0 1px var(--bl-line); }
17
+ .bl-price__card[data-featured] { box-shadow: 0 0 0 2px var(--bl-accent), 0 24px 50px -28px var(--bl-accent); }
18
+ .bl-price__badge { position: absolute; top: 0; right: 20px; padding: 4px 10px; border-radius: 999px; background: var(--bl-accent); color: var(--bl-on-accent); font-size: 12px; font-weight: 700; transform: translateY(-50%); }
19
+ .bl-price__name { margin: 0; font-size: 18px; font-weight: 700; }
20
+ .bl-price__desc { margin: -6px 0 0; color: var(--bl-muted); font-size: 14px; line-height: 1.5; }
21
+ .bl-price__amount { display: flex; align-items: baseline; gap: 6px; min-height: 1.2em; }
22
+ .bl-price__figure { display: inline-flex; font-size: var(--bl-size); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
23
+ .bl-price__drum { display: inline-block; width: 1ch; height: 1.1em; overflow: hidden; }
24
+ .bl-price__strip { display: block; transition: transform 640ms cubic-bezier(.25,1.25,.5,1); transition-delay: calc(var(--bl-col) * 45ms); }
25
+ .bl-price__strip > span { display: block; height: 1.1em; text-align: center; }
26
+ .bl-price__per { color: var(--bl-muted); font-size: 14px; }
27
+ .bl-price__billed { min-height: 1.4em; margin: -8px 0 0; color: var(--bl-muted); font-size: 13px; transition: opacity 240ms; }
28
+ .bl-price__billed[data-hidden] { opacity: 0; }
29
+ .bl-price__features { display: grid; gap: 9px; margin: 4px 0 0; padding: 0; list-style: none; font-size: 14px; }
30
+ .bl-price__features li { display: flex; gap: 10px; align-items: flex-start; line-height: 1.45; }
31
+ .bl-price__features svg { flex: 0 0 auto; margin-top: 3px; color: var(--bl-accent); }
32
+ .bl-price__cta { margin-top: auto; padding: 11px 16px; border: 0; border-radius: calc(var(--bl-radius) * 0.6); background: var(--bl-track); color: var(--bl-ink); font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; box-shadow: inset 0 0 0 1px var(--bl-line); }
33
+ .bl-price__card[data-featured] .bl-price__cta { background: var(--bl-accent); color: var(--bl-on-accent); box-shadow: none; }
34
+ .bl-price__cta:hover { filter: brightness(1.12); }
35
+ .bl-price__cta:focus-visible { outline: 2px solid var(--bl-ink); outline-offset: 2px; }
36
+ .bl-price__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
37
+ @media (prefers-reduced-motion: reduce) { .bl-price__thumb, .bl-price__strip, .bl-price__save { transition: none; } }
38
+ `;
39
+ function useStyles() {
40
+ useInsertionEffect(() => {
41
+ if (typeof document === "undefined") return;
42
+ const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
43
+ style.textContent = CSS;
44
+ if (!style.isConnected) document.head.appendChild(style);
45
+ }, []);
46
+ }
47
+ const DIGITS = Array.from({ length: 10 }, (_, i) => i);
48
+ function RollingPrice({ text }) {
49
+ const chars = [...text];
50
+ return /* @__PURE__ */ jsx("span", { className: "bl-price__figure", "aria-hidden": "true", children: chars.map((ch, i) => {
51
+ const fromRight = chars.length - i;
52
+ if (!/\d/.test(ch)) return /* @__PURE__ */ jsx("span", { children: ch }, `s${fromRight}-${ch}`);
53
+ return /* @__PURE__ */ jsx("span", { className: "bl-price__drum", children: /* @__PURE__ */ jsx("span", { className: "bl-price__strip", style: { transform: `translateY(${-Number(ch) * 1.1}em)`, "--bl-col": fromRight }, children: DIGITS.map((d) => /* @__PURE__ */ jsx("span", { children: d }, d)) }) }, `d${fromRight}`);
54
+ }) });
55
+ }
56
+ const Check = () => /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M2.5 7.5 5.5 10.5 11.5 3.5" }) });
57
+ function PricingFlip({
58
+ plans = [],
59
+ period: controlled,
60
+ defaultPeriod = "monthly",
61
+ onPeriodChange,
62
+ onSelect,
63
+ currency = "USD",
64
+ locale = "en-US",
65
+ monthlyLabel = "Monthly",
66
+ yearlyLabel = "Yearly",
67
+ perLabel = "/mo",
68
+ freeLabel = "Free",
69
+ billedYearly = (total) => `Billed ${total} yearly`,
70
+ width = 1e3,
71
+ priceSize = 44,
72
+ backgroundColor = "#1a1c2c",
73
+ cardColor = "#262b44",
74
+ trackColor = "#0b0b14",
75
+ textColor = "#f4f4f4",
76
+ mutedColor = "#94b0c2",
77
+ lineColor = "#333c57",
78
+ accentColor = "#73eff7",
79
+ onAccentColor = "#0b0b14",
80
+ saveColor = "#ffcd75",
81
+ radius = 18,
82
+ fontFamily = "ui-sans-serif, system-ui, sans-serif",
83
+ label = "Billing period",
84
+ className = "",
85
+ style
86
+ }) {
87
+ useStyles();
88
+ const uid = useId().replace(/[^a-zA-Z0-9_-]/g, "");
89
+ const [inner, setInner] = useState(defaultPeriod);
90
+ const period = controlled ?? inner;
91
+ const yearly = period === "yearly";
92
+ const [announce, setAnnounce] = useState("");
93
+ const optRefs = useRef([]);
94
+ const money = (value) => new Intl.NumberFormat(locale, { style: "currency", currency, maximumFractionDigits: Number.isInteger(value) ? 0 : 2 }).format(value);
95
+ const savings = plans.filter((p) => p.monthly > 0 && p.yearly != null).map((p) => Math.round((1 - p.yearly / p.monthly) * 100));
96
+ const bestSaving = savings.length ? Math.max(...savings) : 0;
97
+ const choose = (next) => {
98
+ if (next === period) return;
99
+ if (controlled === void 0) setInner(next);
100
+ onPeriodChange?.(next);
101
+ setAnnounce(next === "yearly" ? `Showing yearly prices.${bestSaving > 0 ? ` Save up to ${bestSaving}%.` : ""}` : "Showing monthly prices.");
102
+ };
103
+ const onKeyDown = (event) => {
104
+ if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.key)) return;
105
+ event.preventDefault();
106
+ const next = yearly ? "monthly" : "yearly";
107
+ choose(next);
108
+ optRefs.current[next === "yearly" ? 1 : 0]?.focus();
109
+ };
110
+ return /* @__PURE__ */ jsxs(
111
+ "div",
112
+ {
113
+ className: `bl-price ${className}`,
114
+ style: {
115
+ "--bl-w": `${width}px`,
116
+ "--bl-size": `${priceSize}px`,
117
+ "--bl-radius": `${radius}px`,
118
+ "--bl-bg": backgroundColor,
119
+ "--bl-card": cardColor,
120
+ "--bl-track": trackColor,
121
+ "--bl-ink": textColor,
122
+ "--bl-muted": mutedColor,
123
+ "--bl-line": lineColor,
124
+ "--bl-accent": accentColor,
125
+ "--bl-on-accent": onAccentColor,
126
+ "--bl-save": saveColor,
127
+ "--bl-font": fontFamily,
128
+ ...style
129
+ },
130
+ children: [
131
+ /* @__PURE__ */ jsxs("div", { className: "bl-price__switch", role: "radiogroup", "aria-label": label, "data-yearly": yearly || void 0, children: [
132
+ /* @__PURE__ */ jsx("span", { className: "bl-price__thumb", "aria-hidden": "true" }),
133
+ [
134
+ ["monthly", monthlyLabel],
135
+ ["yearly", yearlyLabel]
136
+ ].map(([value, text], i) => /* @__PURE__ */ jsxs(
137
+ "button",
138
+ {
139
+ ref: (node) => {
140
+ optRefs.current[i] = node;
141
+ },
142
+ type: "button",
143
+ role: "radio",
144
+ className: "bl-price__opt",
145
+ "aria-checked": period === value,
146
+ tabIndex: period === value ? 0 : -1,
147
+ onClick: () => choose(value),
148
+ onKeyDown,
149
+ children: [
150
+ text,
151
+ value === "yearly" && bestSaving > 0 && /* @__PURE__ */ jsxs("span", { className: "bl-price__save", children: [
152
+ "Save ",
153
+ bestSaving,
154
+ "%"
155
+ ] })
156
+ ]
157
+ },
158
+ value
159
+ ))
160
+ ] }),
161
+ /* @__PURE__ */ jsx("div", { className: "bl-price__grid", children: plans.map((plan) => {
162
+ const perMonth = yearly && plan.yearly != null ? plan.yearly : plan.monthly;
163
+ const free = perMonth === 0;
164
+ const shown = free ? freeLabel : money(perMonth);
165
+ const nameId = `${uid}-${plan.id ?? plan.name}`;
166
+ return /* @__PURE__ */ jsxs("section", { className: "bl-price__card", "data-featured": plan.featured || void 0, "aria-labelledby": nameId, children: [
167
+ plan.badge && /* @__PURE__ */ jsx("span", { className: "bl-price__badge", children: plan.badge }),
168
+ /* @__PURE__ */ jsx("h3", { id: nameId, className: "bl-price__name", children: plan.name }),
169
+ plan.description && /* @__PURE__ */ jsx("p", { className: "bl-price__desc", children: plan.description }),
170
+ /* @__PURE__ */ jsxs("div", { className: "bl-price__amount", children: [
171
+ free ? /* @__PURE__ */ jsx("span", { className: "bl-price__figure", "aria-hidden": "true", children: freeLabel }) : /* @__PURE__ */ jsx(RollingPrice, { text: shown }),
172
+ !free && /* @__PURE__ */ jsx("span", { className: "bl-price__per", "aria-hidden": "true", children: perLabel }),
173
+ /* @__PURE__ */ jsx("span", { className: "bl-price__sr", children: free ? freeLabel : `${shown} per month` })
174
+ ] }),
175
+ /* @__PURE__ */ jsx("p", { className: "bl-price__billed", "data-hidden": !yearly || free || plan.yearly == null || void 0, children: yearly && !free && plan.yearly != null ? billedYearly(money(plan.yearly * 12)) : "\xA0" }),
176
+ plan.features && plan.features.length > 0 && /* @__PURE__ */ jsx("ul", { className: "bl-price__features", children: plan.features.map((feature) => /* @__PURE__ */ jsxs("li", { children: [
177
+ /* @__PURE__ */ jsx(Check, {}),
178
+ feature
179
+ ] }, feature)) }),
180
+ plan.cta && /* @__PURE__ */ jsx("button", { type: "button", className: "bl-price__cta", onClick: () => onSelect?.(plan, period), children: plan.cta })
181
+ ] }, plan.id ?? plan.name);
182
+ }) }),
183
+ /* @__PURE__ */ jsx("span", { className: "bl-price__sr", "aria-live": "polite", children: announce })
184
+ ]
185
+ }
186
+ );
187
+ }
188
+ export {
189
+ PricingFlip as default
190
+ };