bits-lab 0.0.0-stage → 0.1.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 (323) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -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 +34 -4
@@ -0,0 +1,292 @@
1
+ 'use client';
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useInsertionEffect, useRef, useState } from "react";
4
+ const STYLE_ID = "bl-webcam-pixels";
5
+ const CSS = `
6
+ .bl-cam { position: relative; width: 100%; height: 100%; overflow: hidden; border-radius: var(--bl-radius); background: var(--bl-bg); color: var(--bl-ink); font-family: var(--bl-font); }
7
+ .bl-cam__canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
8
+ .bl-cam__panel { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; }
9
+ .bl-cam__panel h3 { margin: 0; font-size: 18px; font-weight: 700; }
10
+ .bl-cam__panel p { max-width: 36ch; margin: 0; color: var(--bl-muted); font-size: 14px; line-height: 1.5; }
11
+ .bl-cam__btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: 0; border-radius: 999px; background: var(--bl-accent); color: var(--bl-bg); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
12
+ .bl-cam__btn:focus-visible { outline: 2px solid var(--bl-ink); outline-offset: 3px; }
13
+ .bl-cam__btn[data-quiet] { background: color-mix(in srgb, var(--bl-bg) 70%, transparent); color: var(--bl-ink); box-shadow: 0 0 0 1px color-mix(in srgb, var(--bl-ink) 30%, transparent); backdrop-filter: blur(6px); }
14
+ .bl-cam__bar { position: absolute; left: 12px; right: 12px; top: 12px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; pointer-events: none; }
15
+ .bl-cam__bar > * { pointer-events: auto; }
16
+ .bl-cam__live { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--bl-bg) 70%, transparent); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; backdrop-filter: blur(6px); }
17
+ .bl-cam__live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--bl-live); animation: bl-cam-pulse 1.4s ease-in-out infinite; }
18
+ .bl-cam__spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--bl-accent) 25%, transparent); border-top-color: var(--bl-accent); animation: bl-cam-spin 800ms linear infinite; }
19
+ .bl-cam__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
20
+ @keyframes bl-cam-pulse { 50% { opacity: 0.35; } }
21
+ @keyframes bl-cam-spin { to { transform: rotate(360deg); } }
22
+ @media (prefers-reduced-motion: reduce) { .bl-cam__live::before { animation: none; } .bl-cam__spin { animation-duration: 2.4s; } }
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 rgb(hex) {
33
+ const v = hex.replace("#", "");
34
+ const full = v.length === 3 ? v.replace(/./g, (c) => c + c) : v.slice(0, 6);
35
+ const n = parseInt(full, 16);
36
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
37
+ }
38
+ const ASCII_RAMP = " .:-=+*#%@";
39
+ const MESSAGES = {
40
+ denied: ["Camera blocked", "Camera access was turned down. Allow it for this site in your browser\u2019s address bar or settings, then try again."],
41
+ missing: ["No camera found", "Plug in or enable a camera, then try again."],
42
+ busy: ["Camera in use", "Another app or tab is using the camera. Close it, then try again."],
43
+ unsupported: ["Camera not available", "This browser (or an insecure http:// page) can\u2019t share a camera."],
44
+ error: ["Couldn\u2019t start the camera", "Something went wrong while starting it. Try again."]
45
+ };
46
+ function WebcamPixels({
47
+ src,
48
+ mode = "pixels",
49
+ cellSize = 10,
50
+ palette,
51
+ mirror,
52
+ contrast = 1.1,
53
+ fps = 24,
54
+ autoStart = false,
55
+ monochrome = false,
56
+ inkColor = "#73eff7",
57
+ backgroundColor = "#14151f",
58
+ textColor = "#f4f4f4",
59
+ mutedColor = "#94b0c2",
60
+ accentColor = "#73eff7",
61
+ liveColor = "#ef4444",
62
+ radius = 16,
63
+ fontFamily = "ui-sans-serif, system-ui, sans-serif",
64
+ title = "See yourself in pixels",
65
+ description = "Your camera is turned into a live pixel grid right here in the browser. Nothing is recorded or uploaded.",
66
+ label,
67
+ onStatusChange,
68
+ className = "",
69
+ style
70
+ }) {
71
+ useStyles();
72
+ const wrapRef = useRef(null);
73
+ const canvasRef = useRef(null);
74
+ const videoRef = useRef(null);
75
+ const streamRef = useRef(null);
76
+ const [status, setStatus] = useState(src ? "live" : "idle");
77
+ const flip = mirror ?? !src;
78
+ const changeStatus = (next) => {
79
+ setStatus(next);
80
+ onStatusChange?.(next);
81
+ };
82
+ const stop = () => {
83
+ streamRef.current?.getTracks().forEach((t) => t.stop());
84
+ streamRef.current = null;
85
+ if (videoRef.current) videoRef.current.srcObject = null;
86
+ };
87
+ const start = async () => {
88
+ if (!navigator.mediaDevices?.getUserMedia) {
89
+ changeStatus("unsupported");
90
+ return;
91
+ }
92
+ changeStatus("requesting");
93
+ try {
94
+ const stream = await navigator.mediaDevices.getUserMedia({ video: { width: { ideal: 640 }, height: { ideal: 480 }, facingMode: "user" }, audio: false });
95
+ streamRef.current = stream;
96
+ const video = videoRef.current;
97
+ video.srcObject = stream;
98
+ await video.play().catch(() => {
99
+ });
100
+ changeStatus("live");
101
+ } catch (err) {
102
+ stop();
103
+ const name = err?.name;
104
+ changeStatus(name === "NotAllowedError" || name === "SecurityError" ? "denied" : name === "NotFoundError" || name === "OverconstrainedError" ? "missing" : name === "NotReadableError" ? "busy" : "error");
105
+ }
106
+ };
107
+ const turnOff = () => {
108
+ stop();
109
+ changeStatus("idle");
110
+ };
111
+ useEffect(() => {
112
+ if (src) {
113
+ stop();
114
+ changeStatus("live");
115
+ } else if (autoStart) start();
116
+ else changeStatus("idle");
117
+ return stop;
118
+ }, [src]);
119
+ useEffect(() => {
120
+ if (status !== "live") return void 0;
121
+ const wrap = wrapRef.current;
122
+ const canvas = canvasRef.current;
123
+ const ctx = canvas.getContext("2d");
124
+ const sample = document.createElement("canvas");
125
+ const sctx = sample.getContext("2d", { willReadFrequently: true });
126
+ const reduced = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
127
+ const interval = 1e3 / (reduced ? Math.min(fps, 4) : fps);
128
+ const colors = palette?.length ? palette.map(rgb) : null;
129
+ const ink = rgb(inkColor);
130
+ let source = videoRef.current;
131
+ let ready = !src;
132
+ let frame = 0;
133
+ let lastDraw = 0;
134
+ let visible = true;
135
+ let cancelled = false;
136
+ if (src) {
137
+ const isVideo = /\.(mp4|webm|ogv|mov)(\?|$)/i.test(src);
138
+ source = isVideo ? Object.assign(document.createElement("video"), { muted: true, loop: true, playsInline: true, crossOrigin: "anonymous" }) : new Image();
139
+ source.crossOrigin = "anonymous";
140
+ const onReady = () => {
141
+ if (cancelled) return;
142
+ ready = true;
143
+ if (isVideo) source.play().catch(() => {
144
+ });
145
+ render(performance.now(), true);
146
+ };
147
+ source.addEventListener(isVideo ? "loadeddata" : "load", onReady, { once: true });
148
+ source.src = src;
149
+ }
150
+ const nearest = (r, g, b) => {
151
+ let best = colors[0];
152
+ let bestD = Infinity;
153
+ for (const c of colors) {
154
+ const d = (c[0] - r) ** 2 * 0.3 + (c[1] - g) ** 2 * 0.59 + (c[2] - b) ** 2 * 0.11;
155
+ if (d < bestD) {
156
+ bestD = d;
157
+ best = c;
158
+ }
159
+ }
160
+ return best;
161
+ };
162
+ const render = (now, force = false) => {
163
+ frame = 0;
164
+ if (cancelled) return;
165
+ if (visible && ready && (force || now - lastDraw >= interval)) {
166
+ lastDraw = now;
167
+ const dpr = Math.min(2, window.devicePixelRatio || 1);
168
+ const w = wrap.clientWidth;
169
+ const h = wrap.clientHeight;
170
+ if (canvas.width !== Math.round(w * dpr) || canvas.height !== Math.round(h * dpr)) {
171
+ canvas.width = Math.round(w * dpr);
172
+ canvas.height = Math.round(h * dpr);
173
+ }
174
+ const cols = Math.max(1, Math.floor(w / cellSize));
175
+ const rows = Math.max(1, Math.floor(h / cellSize));
176
+ const sw = source.videoWidth || source.naturalWidth || 0;
177
+ const sh = source.videoHeight || source.naturalHeight || 0;
178
+ if (sw && sh) {
179
+ sample.width = cols;
180
+ sample.height = rows;
181
+ const scale = Math.max(cols / sw, rows / sh);
182
+ const cw = cols / scale;
183
+ const ch = rows / scale;
184
+ sctx.save();
185
+ if (flip) {
186
+ sctx.translate(cols, 0);
187
+ sctx.scale(-1, 1);
188
+ }
189
+ sctx.drawImage(source, (sw - cw) / 2, (sh - ch) / 2, cw, ch, 0, 0, cols, rows);
190
+ sctx.restore();
191
+ const data = sctx.getImageData(0, 0, cols, rows).data;
192
+ const cell = cellSize * dpr;
193
+ const ox = (canvas.width - cols * cell) / 2;
194
+ const oy = (canvas.height - rows * cell) / 2;
195
+ ctx.fillStyle = backgroundColor;
196
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
197
+ if (mode === "ascii") {
198
+ ctx.font = `700 ${cell * 1.05}px ui-monospace, SFMono-Regular, Menlo, monospace`;
199
+ ctx.textAlign = "center";
200
+ ctx.textBaseline = "middle";
201
+ }
202
+ for (let i = 0; i < cols * rows; i++) {
203
+ const c = i % cols;
204
+ const r = (i - c) / cols;
205
+ let R = data[i * 4];
206
+ let G = data[i * 4 + 1];
207
+ let B = data[i * 4 + 2];
208
+ R = Math.max(0, Math.min(255, (R - 128) * contrast + 128));
209
+ G = Math.max(0, Math.min(255, (G - 128) * contrast + 128));
210
+ B = Math.max(0, Math.min(255, (B - 128) * contrast + 128));
211
+ const lum = (0.299 * R + 0.587 * G + 0.114 * B) / 255;
212
+ let color = monochrome ? ink : [R, G, B];
213
+ if (colors && !monochrome) color = nearest(R, G, B);
214
+ const x = ox + c * cell;
215
+ const y = oy + r * cell;
216
+ if (mode === "ascii") {
217
+ const ch2 = ASCII_RAMP[Math.min(ASCII_RAMP.length - 1, Math.floor(lum * ASCII_RAMP.length))];
218
+ if (ch2 === " ") continue;
219
+ ctx.fillStyle = `rgb(${color[0]},${color[1]},${color[2]})`;
220
+ ctx.fillText(ch2, x + cell / 2, y + cell / 2);
221
+ } else if (mode === "dots") {
222
+ const rad = cell / 2 * Math.sqrt(lum) * 0.95;
223
+ if (rad < 0.4) continue;
224
+ ctx.fillStyle = `rgb(${color[0]},${color[1]},${color[2]})`;
225
+ ctx.beginPath();
226
+ ctx.arc(x + cell / 2, y + cell / 2, rad, 0, Math.PI * 2);
227
+ ctx.fill();
228
+ } else {
229
+ const k = monochrome ? lum : 1;
230
+ ctx.fillStyle = `rgb(${Math.round(color[0] * k)},${Math.round(color[1] * k)},${Math.round(color[2] * k)})`;
231
+ ctx.fillRect(x, y, cell + 0.5, cell + 0.5);
232
+ }
233
+ }
234
+ }
235
+ }
236
+ if (!(src && source instanceof HTMLImageElement)) frame = requestAnimationFrame(render);
237
+ };
238
+ const io = new IntersectionObserver(([entry]) => {
239
+ visible = entry.isIntersecting;
240
+ });
241
+ io.observe(wrap);
242
+ const resize = new ResizeObserver(() => render(performance.now(), true));
243
+ resize.observe(wrap);
244
+ frame = requestAnimationFrame(render);
245
+ return () => {
246
+ cancelled = true;
247
+ cancelAnimationFrame(frame);
248
+ io.disconnect();
249
+ resize.disconnect();
250
+ if (src && source instanceof HTMLVideoElement) source.pause();
251
+ };
252
+ }, [status, src, mode, cellSize, palette?.join(), flip, contrast, fps, monochrome, inkColor, backgroundColor]);
253
+ const message = MESSAGES[status];
254
+ const statusText = { idle: "Camera off.", requesting: "Waiting for camera permission\u2026", live: src ? "" : "Camera on." }[status] ?? (message ? `${message[0]}. ${message[1]}` : "");
255
+ return /* @__PURE__ */ jsxs(
256
+ "div",
257
+ {
258
+ ref: wrapRef,
259
+ className: `bl-cam ${className}`,
260
+ style: { "--bl-bg": backgroundColor, "--bl-ink": textColor, "--bl-muted": mutedColor, "--bl-accent": accentColor, "--bl-live": liveColor, "--bl-radius": `${radius}px`, "--bl-font": fontFamily, ...style },
261
+ children: [
262
+ /* @__PURE__ */ jsx("video", { ref: videoRef, muted: true, playsInline: true, "aria-hidden": "true", style: { display: "none" } }),
263
+ /* @__PURE__ */ jsx("canvas", { ref: canvasRef, className: "bl-cam__canvas", role: "img", "aria-label": label ?? `${src ? "Image" : "Live camera"} rendered as ${{ ascii: "ASCII art", dots: "halftone dots" }[mode] ?? "pixel art"}`, hidden: status !== "live" }),
264
+ status === "live" && !src && /* @__PURE__ */ jsxs("div", { className: "bl-cam__bar", children: [
265
+ /* @__PURE__ */ jsx("span", { className: "bl-cam__live", children: "LIVE" }),
266
+ /* @__PURE__ */ jsx("button", { type: "button", className: "bl-cam__btn", "data-quiet": "", onClick: turnOff, children: "Stop camera" })
267
+ ] }),
268
+ status === "idle" && /* @__PURE__ */ jsxs("div", { className: "bl-cam__panel", children: [
269
+ /* @__PURE__ */ jsx("h3", { children: title }),
270
+ /* @__PURE__ */ jsx("p", { children: description }),
271
+ /* @__PURE__ */ jsxs("button", { type: "button", className: "bl-cam__btn", onClick: start, children: [
272
+ /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M1.5 4.5h9v7h-9zM10.5 7l4-2.5v7l-4-2.5" }) }),
273
+ "Turn on camera"
274
+ ] })
275
+ ] }),
276
+ status === "requesting" && /* @__PURE__ */ jsxs("div", { className: "bl-cam__panel", children: [
277
+ /* @__PURE__ */ jsx("span", { className: "bl-cam__spin", "aria-hidden": "true" }),
278
+ /* @__PURE__ */ jsx("p", { children: "Waiting for you to allow the camera in your browser\u2019s prompt\u2026" })
279
+ ] }),
280
+ message && /* @__PURE__ */ jsxs("div", { className: "bl-cam__panel", children: [
281
+ /* @__PURE__ */ jsx("h3", { children: message[0] }),
282
+ /* @__PURE__ */ jsx("p", { children: message[1] }),
283
+ status !== "unsupported" && /* @__PURE__ */ jsx("button", { type: "button", className: "bl-cam__btn", onClick: start, children: "Try again" })
284
+ ] }),
285
+ /* @__PURE__ */ jsx("span", { className: "bl-cam__sr", role: "status", children: statusText })
286
+ ]
287
+ }
288
+ );
289
+ }
290
+ export {
291
+ WebcamPixels as default
292
+ };
@@ -0,0 +1,29 @@
1
+ import { type CSSProperties } from 'react';
2
+ export interface WheelOption {
3
+ value: string | number;
4
+ label: string;
5
+ }
6
+ export interface WheelPickerProps {
7
+ options?: (string | number | WheelOption)[];
8
+ value?: string | number;
9
+ defaultValue?: string | number;
10
+ onChange?: (value: string | number, option: WheelOption) => void;
11
+ /** Rows shown; odd numbers work best. */
12
+ visible?: number;
13
+ rowHeight?: number;
14
+ width?: number;
15
+ /** Accessible name. */
16
+ label?: string;
17
+ fontSize?: number;
18
+ radius?: number;
19
+ backgroundColor?: string;
20
+ bandColor?: string;
21
+ textColor?: string;
22
+ mutedColor?: string;
23
+ lineColor?: string;
24
+ accentColor?: string;
25
+ fontFamily?: string;
26
+ className?: string;
27
+ style?: CSSProperties;
28
+ }
29
+ export default function WheelPicker({ options, value, defaultValue, onChange, visible, rowHeight, width, label, fontSize, radius, backgroundColor, bandColor, textColor, mutedColor, lineColor, accentColor, fontFamily, className, style }: WheelPickerProps): import("react").JSX.Element;
@@ -0,0 +1,199 @@
1
+ 'use client';
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useInsertionEffect, useRef, useState } from "react";
4
+ const STYLE_ID = "bl-wheel-picker";
5
+ const CSS = `
6
+ .bl-wheel { position: relative; display: inline-block; width: var(--bl-w); height: calc(var(--bl-row) * var(--bl-visible)); overflow: hidden; border-radius: var(--bl-radius); background: var(--bl-bg); color: var(--bl-ink); font-family: var(--bl-font); font-size: var(--bl-size); box-shadow: inset 0 0 0 1px var(--bl-line); cursor: grab; touch-action: none; user-select: none; outline: none; perspective: 600px; }
7
+ .bl-wheel:focus-visible { box-shadow: inset 0 0 0 2px var(--bl-accent); }
8
+ .bl-wheel[data-dragging] { cursor: grabbing; }
9
+ .bl-wheel__band { position: absolute; left: 6px; right: 6px; top: 50%; height: var(--bl-row); margin-top: calc(var(--bl-row) / -2); border-radius: 8px; background: var(--bl-band); box-shadow: inset 0 0 0 1px var(--bl-line); pointer-events: none; }
10
+ .bl-wheel__drum { position: absolute; inset: 0; transform-style: preserve-3d; }
11
+ .bl-wheel__opt { position: absolute; left: 0; right: 0; top: 50%; height: var(--bl-row); margin-top: calc(var(--bl-row) / -2); display: grid; place-items: center; color: var(--bl-muted); white-space: nowrap; backface-visibility: hidden; transform: rotateX(calc(var(--k) * var(--bl-step) * -1)) translateZ(var(--bl-radius-z)); opacity: calc(1 - var(--far) * 0.75); }
12
+ .bl-wheel__opt[data-current] { color: var(--bl-ink); font-weight: 700; }
13
+ .bl-wheel__fade { position: absolute; inset: 0; background: linear-gradient(var(--bl-bg), transparent 38%, transparent 62%, var(--bl-bg)); pointer-events: none; }
14
+ `;
15
+ function useStyles() {
16
+ useInsertionEffect(() => {
17
+ if (typeof document === "undefined") return;
18
+ const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
19
+ style.textContent = CSS;
20
+ if (!style.isConnected) document.head.appendChild(style);
21
+ }, []);
22
+ }
23
+ const asOption = (o) => typeof o === "object" && o !== null ? o : { value: o, label: String(o) };
24
+ function WheelPicker({
25
+ options = [],
26
+ value,
27
+ defaultValue,
28
+ onChange,
29
+ visible = 5,
30
+ rowHeight = 40,
31
+ width = 140,
32
+ label = "Pick an option",
33
+ fontSize = 18,
34
+ radius = 14,
35
+ backgroundColor = "#1a1c2c",
36
+ bandColor = "rgba(115,239,247,0.08)",
37
+ textColor = "#f4f4f4",
38
+ mutedColor = "#94b0c2",
39
+ lineColor = "#333c57",
40
+ accentColor = "#73eff7",
41
+ fontFamily = "inherit",
42
+ className = "",
43
+ style
44
+ }) {
45
+ useStyles();
46
+ const opts = options.map(asOption);
47
+ const n = opts.length;
48
+ const indexOf = (v) => Math.max(0, opts.findIndex((o) => o.value === v));
49
+ const [inner, setInner] = useState(() => indexOf(value ?? defaultValue ?? opts[0]?.value));
50
+ const index = value !== void 0 ? indexOf(value) : Math.min(inner, Math.max(0, n - 1));
51
+ const [pos, setPos] = useState(index);
52
+ const rootRef = useRef(null);
53
+ const motion = useRef({ raf: 0, v: 0, drag: null });
54
+ const commit = (i) => {
55
+ const next = Math.max(0, Math.min(n - 1, i));
56
+ if (value === void 0) setInner(next);
57
+ if (next !== index) onChange?.(opts[next].value, opts[next]);
58
+ return next;
59
+ };
60
+ const commitRef = useRef(commit);
61
+ commitRef.current = commit;
62
+ useEffect(() => {
63
+ if (!motion.current.drag && !motion.current.raf) setPos(index);
64
+ }, [index]);
65
+ useEffect(() => {
66
+ const root = rootRef.current;
67
+ const m = motion.current;
68
+ const reduced = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
69
+ let p = index;
70
+ const clamp = (v) => Math.max(-0.4, Math.min(n - 0.6, v));
71
+ const show = (v) => {
72
+ p = v;
73
+ setPos(v);
74
+ };
75
+ const settle = (target) => {
76
+ cancelAnimationFrame(m.raf);
77
+ let last = performance.now();
78
+ const step = (now) => {
79
+ const dt = Math.min(0.05, (now - last) / 1e3);
80
+ last = now;
81
+ if (target === void 0 && Math.abs(m.v) > 1.2) {
82
+ m.v *= Math.exp(-dt * 3.2);
83
+ show(clamp(p + m.v * dt));
84
+ } else {
85
+ const goal = target ?? Math.round(Math.max(0, Math.min(n - 1, p)));
86
+ m.v = 0;
87
+ const next = p + (goal - p) * Math.min(1, dt * 14);
88
+ if (Math.abs(goal - next) < 2e-3) {
89
+ show(goal);
90
+ m.raf = 0;
91
+ commitRef.current(goal);
92
+ return;
93
+ }
94
+ show(next);
95
+ }
96
+ m.raf = requestAnimationFrame(step);
97
+ };
98
+ m.raf = requestAnimationFrame(step);
99
+ };
100
+ const jump = (i) => {
101
+ const target = Math.max(0, Math.min(n - 1, i));
102
+ m.v = 0;
103
+ if (reduced) {
104
+ cancelAnimationFrame(m.raf);
105
+ m.raf = 0;
106
+ show(target);
107
+ commitRef.current(target);
108
+ } else settle(target);
109
+ };
110
+ const onDown = (event) => {
111
+ if (event.button > 0) return;
112
+ cancelAnimationFrame(m.raf);
113
+ m.raf = 0;
114
+ root.setPointerCapture?.(event.pointerId);
115
+ m.drag = { y: event.clientY, start: p, at: performance.now(), last: event.clientY };
116
+ m.v = 0;
117
+ root.dataset.dragging = "";
118
+ };
119
+ const onMove = (event) => {
120
+ if (!m.drag) return;
121
+ const now = performance.now();
122
+ const dy = event.clientY - m.drag.y;
123
+ const dt = Math.max(1, now - m.drag.at) / 1e3;
124
+ m.v = -(event.clientY - m.drag.last) / rowHeight / dt * 0.6 + m.v * 0.4;
125
+ m.drag.at = now;
126
+ m.drag.last = event.clientY;
127
+ show(clamp(m.drag.start - dy / rowHeight));
128
+ };
129
+ const onUp = () => {
130
+ if (!m.drag) return;
131
+ m.drag = null;
132
+ delete root.dataset.dragging;
133
+ if (reduced) m.v = 0;
134
+ settle();
135
+ };
136
+ let wheelAcc = 0;
137
+ const onWheel = (event) => {
138
+ event.preventDefault();
139
+ wheelAcc += event.deltaY;
140
+ if (Math.abs(wheelAcc) >= 30) {
141
+ jump(Math.round(p) + Math.sign(wheelAcc));
142
+ wheelAcc = 0;
143
+ }
144
+ };
145
+ const onKey = (event) => {
146
+ const page = Math.max(1, visible - 1);
147
+ const moves = { ArrowDown: 1, ArrowUp: -1, PageDown: page, PageUp: -page, Home: -1e9, End: 1e9 };
148
+ if (moves[event.key] === void 0) return;
149
+ event.preventDefault();
150
+ jump(Math.round(p) + moves[event.key]);
151
+ };
152
+ root.addEventListener("pointerdown", onDown);
153
+ root.addEventListener("pointermove", onMove);
154
+ root.addEventListener("pointerup", onUp);
155
+ root.addEventListener("pointercancel", onUp);
156
+ root.addEventListener("wheel", onWheel, { passive: false });
157
+ root.addEventListener("keydown", onKey);
158
+ return () => {
159
+ cancelAnimationFrame(m.raf);
160
+ m.raf = 0;
161
+ root.removeEventListener("pointerdown", onDown);
162
+ root.removeEventListener("pointermove", onMove);
163
+ root.removeEventListener("pointerup", onUp);
164
+ root.removeEventListener("pointercancel", onUp);
165
+ root.removeEventListener("wheel", onWheel);
166
+ root.removeEventListener("keydown", onKey);
167
+ };
168
+ }, [n, rowHeight, visible, index]);
169
+ const stepDeg = 180 / (visible + 1);
170
+ const radiusZ = rowHeight / 2 / Math.tan(stepDeg / 2 * Math.PI / 180);
171
+ const shown = Math.round(Math.max(0, Math.min(n - 1, pos)));
172
+ return /* @__PURE__ */ jsxs(
173
+ "div",
174
+ {
175
+ ref: rootRef,
176
+ className: `bl-wheel ${className}`,
177
+ role: "spinbutton",
178
+ tabIndex: 0,
179
+ "aria-label": label,
180
+ "aria-valuemin": 0,
181
+ "aria-valuemax": Math.max(0, n - 1),
182
+ "aria-valuenow": index,
183
+ "aria-valuetext": opts[index]?.label ?? "",
184
+ style: { "--bl-w": `${width}px`, "--bl-row": `${rowHeight}px`, "--bl-visible": visible, "--bl-step": `${stepDeg}deg`, "--bl-radius-z": `${radiusZ.toFixed(1)}px`, "--bl-size": `${fontSize}px`, "--bl-radius": `${radius}px`, "--bl-bg": backgroundColor, "--bl-band": bandColor, "--bl-ink": textColor, "--bl-muted": mutedColor, "--bl-line": lineColor, "--bl-accent": accentColor, "--bl-font": fontFamily, ...style },
185
+ children: [
186
+ /* @__PURE__ */ jsx("span", { className: "bl-wheel__band", "aria-hidden": "true" }),
187
+ /* @__PURE__ */ jsx("div", { className: "bl-wheel__drum", "aria-hidden": "true", children: opts.map((o, i) => {
188
+ const k = i - pos;
189
+ if (Math.abs(k) > visible / 2 + 1) return null;
190
+ return /* @__PURE__ */ jsx("span", { className: "bl-wheel__opt", "data-current": i === shown || void 0, style: { "--k": k.toFixed(3), "--far": Math.min(1, Math.abs(k) / (visible / 2 + 0.5)).toFixed(3) }, children: o.label }, String(o.value));
191
+ }) }),
192
+ /* @__PURE__ */ jsx("span", { className: "bl-wheel__fade", "aria-hidden": "true" })
193
+ ]
194
+ }
195
+ );
196
+ }
197
+ export {
198
+ WheelPicker as default
199
+ };
@@ -0,0 +1,23 @@
1
+ import { type CSSProperties, type ReactNode } from 'react';
2
+ export interface WobbleCardProps {
3
+ children?: ReactNode;
4
+ /** How far it leans and stretches; 0 turns the jelly off. */
5
+ intensity?: number;
6
+ stiffness?: number;
7
+ /** Lower damping wobbles longer. */
8
+ damping?: number;
9
+ /** Max width in px. */
10
+ width?: number;
11
+ padding?: number;
12
+ radius?: number;
13
+ backgroundColor?: string;
14
+ textColor?: string;
15
+ lineColor?: string;
16
+ /** Rings the card while the pointer is over it or focus is inside. */
17
+ accentColor?: string;
18
+ sheenColor?: string;
19
+ fontFamily?: string;
20
+ className?: string;
21
+ style?: CSSProperties;
22
+ }
23
+ export default function WobbleCard({ children, intensity, stiffness, damping, width, padding, radius, backgroundColor, textColor, lineColor, accentColor, sheenColor, fontFamily, className, style }: WobbleCardProps): import("react").JSX.Element;
@@ -0,0 +1,112 @@
1
+ 'use client';
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useEffect, useInsertionEffect, useRef } from "react";
4
+ const STYLE_ID = "bl-wobble-card";
5
+ const CSS = `
6
+ .bl-wobble { position: relative; box-sizing: border-box; width: 100%; max-width: var(--bl-w); touch-action: pan-y; }
7
+ .bl-wobble__body { position: relative; box-sizing: border-box; overflow: hidden; padding: var(--bl-pad); border-radius: var(--bl-radius); background: var(--bl-bg); color: var(--bl-ink); font-family: var(--bl-font); box-shadow: 0 0 0 2px var(--bl-line), 0 18px 40px -22px rgba(0,0,0,0.8); transform-origin: 50% 50%; will-change: transform; transition: box-shadow 200ms; }
8
+ .bl-wobble__body::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: radial-gradient(circle at var(--bl-mx, 50%) var(--bl-my, 50%), var(--bl-sheen), transparent 60%); opacity: 0; transition: opacity 250ms; pointer-events: none; }
9
+ .bl-wobble[data-active] .bl-wobble__body { box-shadow: 0 0 0 2px var(--bl-accent), 0 24px 48px -22px rgba(0,0,0,0.85); }
10
+ .bl-wobble[data-active] .bl-wobble__body::before { opacity: 1; }
11
+ .bl-wobble:focus-within .bl-wobble__body { box-shadow: 0 0 0 2px var(--bl-accent), 0 18px 40px -22px rgba(0,0,0,0.8); }
12
+ .bl-wobble__content { position: relative; }
13
+ `;
14
+ function useStyles() {
15
+ useInsertionEffect(() => {
16
+ if (typeof document === "undefined") return;
17
+ const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
18
+ style.textContent = CSS;
19
+ if (!style.isConnected) document.head.appendChild(style);
20
+ }, []);
21
+ }
22
+ function WobbleCard({
23
+ children,
24
+ intensity = 1,
25
+ stiffness = 170,
26
+ damping = 9,
27
+ width = 360,
28
+ padding = 24,
29
+ radius = 18,
30
+ backgroundColor = "#262b44",
31
+ textColor = "#f4f4f4",
32
+ lineColor = "#333c57",
33
+ accentColor = "#73eff7",
34
+ sheenColor = "rgba(115,239,247,0.18)",
35
+ fontFamily = "ui-sans-serif, system-ui, sans-serif",
36
+ className = "",
37
+ style
38
+ }) {
39
+ useStyles();
40
+ const rootRef = useRef(null);
41
+ const bodyRef = useRef(null);
42
+ useEffect(() => {
43
+ const root = rootRef.current;
44
+ const body = bodyRef.current;
45
+ const reduced = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
46
+ const s = { tx: 0, ty: 0, x: 0, y: 0, vx: 0, vy: 0 };
47
+ let frame = 0;
48
+ let last = 0;
49
+ const apply = () => {
50
+ const k = intensity;
51
+ const sx = 1 + k * (0.05 * Math.abs(s.x) - 0.025 * Math.abs(s.y));
52
+ const sy = 1 + k * (0.05 * Math.abs(s.y) - 0.025 * Math.abs(s.x));
53
+ body.style.transform = `translate(${(s.x * 7 * k).toFixed(2)}px, ${(s.y * 7 * k).toFixed(2)}px) skew(${(-s.x * s.y * 5 * k).toFixed(2)}deg, ${(s.x * s.y * 2 * k).toFixed(2)}deg) scale(${sx.toFixed(4)}, ${sy.toFixed(4)})`;
54
+ };
55
+ const tick = (now) => {
56
+ const dt = Math.min(0.05, (now - last) / 1e3 || 0.016);
57
+ last = now;
58
+ for (let t = 0; t < dt; t += 1 / 240) {
59
+ s.vx += (stiffness * (s.tx - s.x) - damping * s.vx) / 240;
60
+ s.vy += (stiffness * (s.ty - s.y) - damping * s.vy) / 240;
61
+ s.x += s.vx / 240;
62
+ s.y += s.vy / 240;
63
+ }
64
+ apply();
65
+ const moving = Math.abs(s.tx - s.x) > 1e-3 || Math.abs(s.ty - s.y) > 1e-3 || Math.abs(s.vx) > 0.01 || Math.abs(s.vy) > 0.01;
66
+ if (moving) frame = requestAnimationFrame(tick);
67
+ else {
68
+ Object.assign(s, { x: s.tx, y: s.ty, vx: 0, vy: 0 });
69
+ apply();
70
+ frame = 0;
71
+ }
72
+ };
73
+ const wake = () => {
74
+ if (reduced || frame) return;
75
+ last = performance.now();
76
+ frame = requestAnimationFrame(tick);
77
+ };
78
+ const onMove = (event) => {
79
+ const rect = root.getBoundingClientRect();
80
+ const px = (event.clientX - rect.left) / rect.width;
81
+ const py = (event.clientY - rect.top) / rect.height;
82
+ root.style.setProperty("--bl-mx", `${(px * 100).toFixed(1)}%`);
83
+ root.style.setProperty("--bl-my", `${(py * 100).toFixed(1)}%`);
84
+ root.dataset.active = "";
85
+ s.tx = Math.max(-1, Math.min(1, px * 2 - 1));
86
+ s.ty = Math.max(-1, Math.min(1, py * 2 - 1));
87
+ wake();
88
+ };
89
+ const onLeave = () => {
90
+ delete root.dataset.active;
91
+ s.tx = 0;
92
+ s.ty = 0;
93
+ s.vx -= s.x * 3;
94
+ s.vy -= s.y * 3;
95
+ wake();
96
+ };
97
+ root.addEventListener("pointermove", onMove);
98
+ root.addEventListener("pointerleave", onLeave);
99
+ root.addEventListener("pointercancel", onLeave);
100
+ return () => {
101
+ cancelAnimationFrame(frame);
102
+ root.removeEventListener("pointermove", onMove);
103
+ root.removeEventListener("pointerleave", onLeave);
104
+ root.removeEventListener("pointercancel", onLeave);
105
+ body.style.transform = "";
106
+ };
107
+ }, [intensity, stiffness, damping]);
108
+ return /* @__PURE__ */ jsx("div", { ref: rootRef, className: `bl-wobble ${className}`, style: { "--bl-w": `${width}px`, "--bl-pad": `${padding}px`, "--bl-radius": `${radius}px`, "--bl-bg": backgroundColor, "--bl-ink": textColor, "--bl-line": lineColor, "--bl-accent": accentColor, "--bl-sheen": sheenColor, "--bl-font": fontFamily, ...style }, children: /* @__PURE__ */ jsx("div", { ref: bodyRef, className: "bl-wobble__body", children: /* @__PURE__ */ jsx("div", { className: "bl-wobble__content", children }) }) });
109
+ }
110
+ export {
111
+ WobbleCard as default
112
+ };