@brightlocal/ui-components 3.2.0 → 3.4.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 (434) hide show
  1. package/AI_USAGE.md +10 -0
  2. package/README.md +3 -1
  3. package/component-meta.json +1458 -380
  4. package/deprecations.json +44 -0
  5. package/dist/_virtual/_rolldown/runtime.cjs +1 -0
  6. package/dist/accordion.cjs +1 -1
  7. package/dist/accordion.js +73 -102
  8. package/dist/alert-dialog.cjs +1 -1
  9. package/dist/alert-dialog.d.ts +6 -4
  10. package/dist/alert-dialog.d.ts.map +1 -1
  11. package/dist/alert-dialog.js +85 -133
  12. package/dist/alert.cjs +1 -1
  13. package/dist/alert.d.ts +4 -4
  14. package/dist/alert.d.ts.map +1 -1
  15. package/dist/alert.js +106 -168
  16. package/dist/aspect-ratio.cjs +1 -1
  17. package/dist/aspect-ratio.js +13 -16
  18. package/dist/avatar.cjs +1 -1
  19. package/dist/avatar.js +30 -45
  20. package/dist/badge.cjs +1 -1
  21. package/dist/badge.d.ts +23 -1
  22. package/dist/badge.d.ts.map +1 -1
  23. package/dist/badge.js +90 -91
  24. package/dist/banner.cjs +1 -1
  25. package/dist/banner.js +102 -148
  26. package/dist/blocks/empty-state.cjs +1 -1
  27. package/dist/blocks/empty-state.d.ts +20 -3
  28. package/dist/blocks/empty-state.d.ts.map +1 -1
  29. package/dist/blocks/empty-state.js +73 -140
  30. package/dist/blocks/input-list.cjs +2 -2
  31. package/dist/blocks/input-list.d.ts +2 -2
  32. package/dist/blocks/input-list.d.ts.map +1 -1
  33. package/dist/blocks/input-list.js +138 -178
  34. package/dist/blocks/progress-state.cjs +1 -1
  35. package/dist/blocks/progress-state.js +223 -347
  36. package/dist/blocks/sidebar.cjs +1 -1
  37. package/dist/blocks/sidebar.d.ts +11 -6
  38. package/dist/blocks/sidebar.d.ts.map +1 -1
  39. package/dist/blocks/sidebar.js +763 -1092
  40. package/dist/brand-illustration-motif.cjs +1 -1
  41. package/dist/brand-illustration-motif.js +40 -61
  42. package/dist/breadcrumb.cjs +1 -1
  43. package/dist/breadcrumb.js +62 -102
  44. package/dist/button-group.cjs +1 -1
  45. package/dist/button-group.js +23 -31
  46. package/dist/button.cjs +1 -1
  47. package/dist/button.d.ts +4 -2
  48. package/dist/button.d.ts.map +1 -1
  49. package/dist/button.js +149 -189
  50. package/dist/calendar.cjs +1 -1
  51. package/dist/calendar.d.ts +87 -3
  52. package/dist/calendar.d.ts.map +1 -1
  53. package/dist/calendar.js +116 -173
  54. package/dist/callout.cjs +1 -1
  55. package/dist/callout.js +73 -96
  56. package/dist/card.cjs +1 -1
  57. package/dist/card.d.ts +10 -4
  58. package/dist/card.d.ts.map +1 -1
  59. package/dist/card.js +233 -316
  60. package/dist/carousel.cjs +1 -1
  61. package/dist/carousel.d.ts +3 -3
  62. package/dist/carousel.d.ts.map +1 -1
  63. package/dist/carousel.js +174 -268
  64. package/dist/centred-layout.cjs +1 -1
  65. package/dist/centred-layout.js +27 -48
  66. package/dist/chart-empty.cjs +1 -1
  67. package/dist/chart-empty.js +18 -27
  68. package/dist/chart.cjs +7 -7
  69. package/dist/chart.d.ts +23 -13
  70. package/dist/chart.d.ts.map +1 -1
  71. package/dist/chart.js +445 -651
  72. package/dist/checkbox.cjs +1 -1
  73. package/dist/checkbox.js +36 -69
  74. package/dist/chip.cjs +1 -1
  75. package/dist/chip.js +116 -173
  76. package/dist/collapsible.cjs +1 -1
  77. package/dist/collapsible.d.ts.map +1 -1
  78. package/dist/collapsible.js +35 -41
  79. package/dist/combobox.cjs +3 -3
  80. package/dist/combobox.d.ts +14 -4
  81. package/dist/combobox.d.ts.map +1 -1
  82. package/dist/combobox.js +439 -638
  83. package/dist/command.cjs +1 -1
  84. package/dist/command.d.ts.map +1 -1
  85. package/dist/command.js +273 -420
  86. package/dist/context-menu.cjs +1 -1
  87. package/dist/context-menu.d.ts +5 -5
  88. package/dist/context-menu.d.ts.map +1 -1
  89. package/dist/context-menu.js +121 -191
  90. package/dist/data-table.cjs +1 -1
  91. package/dist/data-table.d.ts +280 -129
  92. package/dist/data-table.d.ts.map +1 -1
  93. package/dist/data-table.js +687 -948
  94. package/dist/date-picker.cjs +1 -1
  95. package/dist/date-picker.d.ts +15 -4
  96. package/dist/date-picker.d.ts.map +1 -1
  97. package/dist/date-picker.js +156 -231
  98. package/dist/delta.cjs +1 -0
  99. package/dist/delta.d.ts +79 -0
  100. package/dist/delta.d.ts.map +1 -0
  101. package/dist/delta.js +62 -0
  102. package/dist/description-list.cjs +1 -0
  103. package/dist/description-list.d.ts +142 -0
  104. package/dist/description-list.d.ts.map +1 -0
  105. package/dist/description-list.js +173 -0
  106. package/dist/description.cjs +1 -1
  107. package/dist/description.js +11 -20
  108. package/dist/dialog.cjs +1 -1
  109. package/dist/dialog.d.ts +1 -1
  110. package/dist/dialog.d.ts.map +1 -1
  111. package/dist/dialog.js +76 -116
  112. package/dist/drawer.cjs +1 -1
  113. package/dist/drawer.d.ts +11 -11
  114. package/dist/drawer.d.ts.map +1 -1
  115. package/dist/drawer.js +76 -134
  116. package/dist/dropdown-menu.cjs +1 -1
  117. package/dist/dropdown-menu.d.ts +6 -6
  118. package/dist/dropdown-menu.d.ts.map +1 -1
  119. package/dist/dropdown-menu.js +179 -300
  120. package/dist/field.cjs +1 -1
  121. package/dist/field.d.ts +9 -9
  122. package/dist/field.d.ts.map +1 -1
  123. package/dist/field.js +166 -286
  124. package/dist/global-layout.cjs +1 -1
  125. package/dist/global-layout.js +203 -342
  126. package/dist/grid.cjs +1 -1
  127. package/dist/grid.js +16 -29
  128. package/dist/header.cjs +1 -1
  129. package/dist/header.js +21 -38
  130. package/dist/height-transition.cjs +1 -1
  131. package/dist/height-transition.js +38 -55
  132. package/dist/hooks/use-breakpoint.cjs +1 -1
  133. package/dist/hooks/use-breakpoint.js +9 -9
  134. package/dist/hooks/use-debounce.cjs +1 -1
  135. package/dist/hooks/use-debounce.js +12 -11
  136. package/dist/hooks/use-delayed-pending.cjs +1 -1
  137. package/dist/hooks/use-delayed-pending.js +8 -9
  138. package/dist/hooks/use-filter-search-params.cjs +1 -0
  139. package/dist/hooks/use-filter-search-params.d.ts +93 -0
  140. package/dist/hooks/use-filter-search-params.d.ts.map +1 -0
  141. package/dist/hooks/use-filter-search-params.js +122 -0
  142. package/dist/hooks/use-mobile.cjs +1 -1
  143. package/dist/hooks/use-mobile.js +6 -6
  144. package/dist/hooks/use-overlay-pointer-lock.cjs +1 -1
  145. package/dist/hooks/use-overlay-pointer-lock.js +8 -9
  146. package/dist/hooks/use-prefers-reduced-motion.cjs +1 -1
  147. package/dist/hooks/use-prefers-reduced-motion.js +5 -8
  148. package/dist/hover-card.cjs +1 -1
  149. package/dist/hover-card.d.ts +1 -1
  150. package/dist/hover-card.d.ts.map +1 -1
  151. package/dist/hover-card.js +30 -62
  152. package/dist/index.cjs +1 -1
  153. package/dist/index.d.ts +7 -0
  154. package/dist/index.d.ts.map +1 -1
  155. package/dist/index.js +658 -614
  156. package/dist/info-tooltip.cjs +1 -1
  157. package/dist/info-tooltip.js +22 -36
  158. package/dist/input-chip.cjs +1 -1
  159. package/dist/input-chip.d.ts +32 -3
  160. package/dist/input-chip.d.ts.map +1 -1
  161. package/dist/input-chip.js +181 -230
  162. package/dist/input-group.cjs +1 -1
  163. package/dist/input-group.js +174 -221
  164. package/dist/input-otp.cjs +1 -1
  165. package/dist/input-otp.d.ts +3 -3
  166. package/dist/input-otp.d.ts.map +1 -1
  167. package/dist/input-otp.js +102 -146
  168. package/dist/input-password.cjs +1 -1
  169. package/dist/input-password.d.ts +12 -16
  170. package/dist/input-password.d.ts.map +1 -1
  171. package/dist/input-password.js +139 -171
  172. package/dist/input.cjs +1 -1
  173. package/dist/input.d.ts.map +1 -1
  174. package/dist/input.js +51 -73
  175. package/dist/label.cjs +1 -1
  176. package/dist/label.js +20 -38
  177. package/dist/lib/block-illustration.cjs +1 -1
  178. package/dist/lib/block-illustration.d.ts +1 -1
  179. package/dist/lib/block-illustration.d.ts.map +1 -1
  180. package/dist/lib/block-illustration.js +16 -18
  181. package/dist/lib/compose-event-handlers.cjs +1 -0
  182. package/dist/lib/compose-event-handlers.d.ts +9 -0
  183. package/dist/lib/compose-event-handlers.d.ts.map +1 -0
  184. package/dist/lib/compose-event-handlers.js +8 -0
  185. package/dist/lib/download-file.cjs +1 -0
  186. package/dist/lib/download-file.d.ts +14 -0
  187. package/dist/lib/download-file.d.ts.map +1 -0
  188. package/dist/lib/download-file.js +40 -0
  189. package/dist/lib/empty-canvas.cjs +1 -1
  190. package/dist/lib/empty-canvas.js +28 -56
  191. package/dist/lib/empty-chip.cjs +1 -1
  192. package/dist/lib/empty-chip.d.ts +14 -3
  193. package/dist/lib/empty-chip.d.ts.map +1 -1
  194. package/dist/lib/empty-chip.js +15 -11
  195. package/dist/lib/field-aria.cjs +1 -0
  196. package/dist/lib/field-aria.d.ts +34 -0
  197. package/dist/lib/field-aria.d.ts.map +1 -0
  198. package/dist/lib/field-aria.js +52 -0
  199. package/dist/lib/image-file-info.cjs +1 -0
  200. package/dist/lib/image-file-info.d.ts +25 -0
  201. package/dist/lib/image-file-info.d.ts.map +1 -0
  202. package/dist/lib/image-file-info.js +67 -0
  203. package/dist/lib/media-viewer-content.cjs +1 -0
  204. package/dist/lib/media-viewer-content.d.ts +102 -0
  205. package/dist/lib/media-viewer-content.d.ts.map +1 -0
  206. package/dist/lib/media-viewer-content.js +650 -0
  207. package/dist/lib/media-viewer-internal.cjs +1 -0
  208. package/dist/lib/media-viewer-internal.d.ts +98 -0
  209. package/dist/lib/media-viewer-internal.d.ts.map +1 -0
  210. package/dist/lib/media-viewer-internal.js +61 -0
  211. package/dist/lib/media-viewer-motion.cjs +1 -0
  212. package/dist/lib/media-viewer-motion.d.ts +40 -0
  213. package/dist/lib/media-viewer-motion.d.ts.map +1 -0
  214. package/dist/lib/media-viewer-motion.js +37 -0
  215. package/dist/lib/motion.cjs +1 -1
  216. package/dist/lib/motion.d.ts +8 -0
  217. package/dist/lib/motion.d.ts.map +1 -1
  218. package/dist/lib/motion.js +14 -8
  219. package/dist/lib/optical-center.cjs +1 -1
  220. package/dist/lib/optical-center.d.ts +1 -1
  221. package/dist/lib/optical-center.d.ts.map +1 -1
  222. package/dist/lib/optical-center.js +12 -5
  223. package/dist/lib/spring-settle.cjs +1 -1
  224. package/dist/lib/spring-settle.js +1 -1
  225. package/dist/lib/table-internal.cjs +1 -0
  226. package/dist/lib/table-internal.d.ts +62 -0
  227. package/dist/lib/table-internal.d.ts.map +1 -0
  228. package/dist/lib/table-internal.js +18 -0
  229. package/dist/lib/use-controllable.cjs +1 -0
  230. package/dist/lib/use-controllable.d.ts +12 -0
  231. package/dist/lib/use-controllable.d.ts.map +1 -0
  232. package/dist/lib/use-controllable.js +15 -0
  233. package/dist/lib/use-dev-warning.cjs +1 -1
  234. package/dist/lib/utils.cjs +1 -1
  235. package/dist/lib/utils.js +26 -33
  236. package/dist/link.cjs +1 -1
  237. package/dist/link.d.ts +1 -1
  238. package/dist/link.js +78 -124
  239. package/dist/list.cjs +1 -1
  240. package/dist/list.d.ts +224 -39
  241. package/dist/list.d.ts.map +1 -1
  242. package/dist/list.js +323 -171
  243. package/dist/loading.cjs +1 -1
  244. package/dist/loading.js +124 -151
  245. package/dist/logo-mark.cjs +1 -0
  246. package/dist/logo-mark.d.ts +79 -0
  247. package/dist/logo-mark.d.ts.map +1 -0
  248. package/dist/logo-mark.js +219 -0
  249. package/dist/logo.cjs +1 -1
  250. package/dist/logo.d.ts +1 -1
  251. package/dist/logo.d.ts.map +1 -1
  252. package/dist/logo.js +51 -87
  253. package/dist/map.cjs +1 -1
  254. package/dist/map.d.ts.map +1 -1
  255. package/dist/map.js +390 -586
  256. package/dist/media-empty.cjs +1 -1
  257. package/dist/media-empty.js +27 -42
  258. package/dist/media-viewer.cjs +1 -0
  259. package/dist/media-viewer.d.ts +224 -0
  260. package/dist/media-viewer.d.ts.map +1 -0
  261. package/dist/media-viewer.js +295 -0
  262. package/dist/menubar.cjs +1 -1
  263. package/dist/menubar.d.ts +14 -14
  264. package/dist/menubar.d.ts.map +1 -1
  265. package/dist/menubar.js +130 -267
  266. package/dist/multi-select-filter.cjs +1 -1
  267. package/dist/multi-select-filter.d.ts +9 -1
  268. package/dist/multi-select-filter.d.ts.map +1 -1
  269. package/dist/multi-select-filter.js +357 -446
  270. package/dist/navigation-menu.cjs +1 -1
  271. package/dist/navigation-menu.js +108 -172
  272. package/dist/pagination.cjs +1 -1
  273. package/dist/pagination.d.ts +36 -12
  274. package/dist/pagination.d.ts.map +1 -1
  275. package/dist/pagination.js +208 -281
  276. package/dist/popover.cjs +1 -1
  277. package/dist/popover.d.ts +1 -1
  278. package/dist/popover.d.ts.map +1 -1
  279. package/dist/popover.js +34 -45
  280. package/dist/progress.cjs +1 -1
  281. package/dist/progress.d.ts +17 -2
  282. package/dist/progress.d.ts.map +1 -1
  283. package/dist/progress.js +116 -162
  284. package/dist/radio-group.cjs +1 -1
  285. package/dist/radio-group.js +90 -146
  286. package/dist/rating.cjs +1 -1
  287. package/dist/rating.d.ts +80 -13
  288. package/dist/rating.d.ts.map +1 -1
  289. package/dist/rating.js +70 -65
  290. package/dist/relative-date.cjs +1 -1
  291. package/dist/relative-date.d.ts.map +1 -1
  292. package/dist/relative-date.js +73 -89
  293. package/dist/resizable.cjs +1 -1
  294. package/dist/resizable.d.ts +39 -23
  295. package/dist/resizable.d.ts.map +1 -1
  296. package/dist/resizable.js +42 -44
  297. package/dist/result-count.cjs +1 -0
  298. package/dist/result-count.d.ts +110 -0
  299. package/dist/result-count.d.ts.map +1 -0
  300. package/dist/result-count.js +49 -0
  301. package/dist/route-progress.cjs +1 -1
  302. package/dist/route-progress.js +59 -102
  303. package/dist/scroll-area.cjs +1 -1
  304. package/dist/scroll-area.d.ts +9 -1
  305. package/dist/scroll-area.d.ts.map +1 -1
  306. package/dist/scroll-area.js +44 -79
  307. package/dist/select.cjs +2 -2
  308. package/dist/select.d.ts +10 -10
  309. package/dist/select.d.ts.map +1 -1
  310. package/dist/select.js +118 -238
  311. package/dist/separator.cjs +1 -1
  312. package/dist/separator.js +90 -78
  313. package/dist/sheet.cjs +1 -1
  314. package/dist/sheet.d.ts +8 -5
  315. package/dist/sheet.d.ts.map +1 -1
  316. package/dist/sheet.js +250 -317
  317. package/dist/single-select-filter.cjs +1 -1
  318. package/dist/single-select-filter.d.ts +32 -0
  319. package/dist/single-select-filter.d.ts.map +1 -1
  320. package/dist/single-select-filter.js +201 -203
  321. package/dist/skeleton.cjs +1 -1
  322. package/dist/skeleton.js +24 -38
  323. package/dist/slider.cjs +1 -1
  324. package/dist/slider.js +51 -81
  325. package/dist/sonner.cjs +1 -1
  326. package/dist/sonner.d.ts +1 -1
  327. package/dist/sonner.d.ts.map +1 -1
  328. package/dist/sonner.js +101 -125
  329. package/dist/spinner.cjs +1 -1
  330. package/dist/spinner.js +22 -31
  331. package/dist/split-layout.cjs +1 -1
  332. package/dist/split-layout.js +52 -101
  333. package/dist/status.cjs +1 -0
  334. package/dist/status.d.ts +51 -0
  335. package/dist/status.d.ts.map +1 -0
  336. package/dist/status.js +60 -0
  337. package/dist/stepper.cjs +1 -1
  338. package/dist/stepper.js +184 -316
  339. package/dist/switch.cjs +1 -1
  340. package/dist/switch.js +17 -32
  341. package/dist/table.cjs +1 -1
  342. package/dist/table.d.ts +103 -30
  343. package/dist/table.d.ts.map +1 -1
  344. package/dist/table.js +170 -209
  345. package/dist/tabs.cjs +1 -1
  346. package/dist/tabs.d.ts.map +1 -1
  347. package/dist/tabs.js +102 -147
  348. package/dist/text-reveal-motion.cjs +1 -1
  349. package/dist/text-reveal-motion.js +307 -363
  350. package/dist/textarea.cjs +1 -1
  351. package/dist/textarea.d.ts.map +1 -1
  352. package/dist/textarea.js +22 -35
  353. package/dist/toggle-group.cjs +1 -1
  354. package/dist/toggle-group.js +43 -62
  355. package/dist/toggle.cjs +1 -1
  356. package/dist/toggle.js +34 -46
  357. package/dist/tooltip.cjs +1 -1
  358. package/dist/tooltip.d.ts +2 -2
  359. package/dist/tooltip.d.ts.map +1 -1
  360. package/dist/tooltip.js +157 -249
  361. package/dist/typography-heading.cjs +1 -1
  362. package/dist/typography-heading.js +25 -61
  363. package/dist/typography-text.cjs +1 -1
  364. package/dist/typography-text.js +27 -57
  365. package/dist/typography.cjs +1 -1
  366. package/dist/typography.js +132 -340
  367. package/package.json +47 -47
  368. package/src/blocks/empty-state.tsx +34 -18
  369. package/src/blocks/input-list.tsx +14 -9
  370. package/src/blocks/sidebar.tsx +86 -31
  371. package/src/components/accordion.tsx +1 -1
  372. package/src/components/alert-dialog.tsx +4 -2
  373. package/src/components/badge.tsx +127 -15
  374. package/src/components/breadcrumb.tsx +1 -1
  375. package/src/components/button.tsx +8 -6
  376. package/src/components/calendar.tsx +155 -9
  377. package/src/components/card.tsx +63 -10
  378. package/src/components/carousel.tsx +4 -1
  379. package/src/components/chart.tsx +151 -17
  380. package/src/components/checkbox.tsx +1 -1
  381. package/src/components/collapsible.tsx +4 -1
  382. package/src/components/combobox.tsx +40 -7
  383. package/src/components/command.tsx +9 -10
  384. package/src/components/context-menu.tsx +4 -4
  385. package/src/components/data-table.tsx +619 -237
  386. package/src/components/date-picker.tsx +31 -4
  387. package/src/components/delta.tsx +217 -0
  388. package/src/components/description-list.tsx +445 -0
  389. package/src/components/drawer.tsx +5 -5
  390. package/src/components/dropdown-menu.tsx +4 -4
  391. package/src/components/field.tsx +36 -15
  392. package/src/components/global-layout.tsx +1 -1
  393. package/src/components/input-chip.tsx +51 -7
  394. package/src/components/input-group.tsx +1 -1
  395. package/src/components/input-password.tsx +15 -19
  396. package/src/components/input.tsx +10 -1
  397. package/src/components/list.tsx +695 -72
  398. package/src/components/logo-mark.tsx +345 -0
  399. package/src/components/map.tsx +18 -20
  400. package/src/components/media-viewer.tsx +908 -0
  401. package/src/components/multi-select-filter.tsx +255 -121
  402. package/src/components/navigation-menu.tsx +2 -2
  403. package/src/components/pagination.tsx +86 -26
  404. package/src/components/progress.tsx +91 -23
  405. package/src/components/rating.tsx +200 -74
  406. package/src/components/relative-date.tsx +19 -11
  407. package/src/components/resizable.tsx +86 -33
  408. package/src/components/result-count.tsx +253 -0
  409. package/src/components/scroll-area.tsx +31 -5
  410. package/src/components/select.tsx +2 -2
  411. package/src/components/sheet.tsx +14 -4
  412. package/src/components/single-select-filter.tsx +136 -41
  413. package/src/components/slider.tsx +2 -2
  414. package/src/components/status.tsx +162 -0
  415. package/src/components/switch.tsx +1 -1
  416. package/src/components/table.tsx +278 -106
  417. package/src/components/tabs.tsx +1 -0
  418. package/src/components/textarea.tsx +20 -2
  419. package/src/components/toggle.tsx +2 -2
  420. package/src/components/tooltip.tsx +11 -20
  421. package/src/hooks/use-filter-search-params.ts +302 -0
  422. package/src/index.ts +7 -0
  423. package/src/lib/compose-event-handlers.ts +14 -0
  424. package/src/lib/download-file.ts +61 -0
  425. package/src/lib/empty-chip.tsx +52 -0
  426. package/src/lib/field-aria.tsx +97 -0
  427. package/src/lib/image-file-info.ts +102 -0
  428. package/src/lib/media-viewer-content.tsx +1587 -0
  429. package/src/lib/media-viewer-internal.tsx +191 -0
  430. package/src/lib/media-viewer-motion.ts +120 -0
  431. package/src/lib/motion.ts +9 -0
  432. package/src/lib/table-internal.ts +74 -0
  433. package/src/lib/use-controllable.ts +43 -0
  434. package/src/lib/empty-chip.ts +0 -24
@@ -0,0 +1,650 @@
1
+ "use client";
2
+ import { Button as H, ButtonVariants as Ye } from "../button.js";
3
+ import { DialogOverlay as Ke, DialogPortal as Ge } from "../dialog.js";
4
+ import { InfoTooltip as He } from "../info-tooltip.js";
5
+ import { MediaEmpty as Je } from "../media-empty.js";
6
+ import { composeEventHandlers as Z } from "./compose-event-handlers.js";
7
+ import { ItemActionsMenu as Qe, MediaViewerActionsRegistry as et, MediaViewerControlsContext as tt, TruncatedText as nt, useMediaViewerContext as we } from "./media-viewer-internal.js";
8
+ import { DRAG_STEP_SHARE as at, RUBBER_BAND_SHARE as rt, ZOOM_REST as de, glideTiming as it, rubberBand as ot, zoomKeyframe as fe } from "./media-viewer-motion.js";
9
+ import { downloadFile as st } from "./download-file.js";
10
+ import { describeImageFile as ct, useImageFileInfo as lt } from "./image-file-info.js";
11
+ import { RelativeDate as ut } from "../relative-date.js";
12
+ import * as c from "react";
13
+ import { ChevronLeft as dt, ChevronRight as ft, Download as mt, ZoomIn as pt, ZoomOut as ht } from "@brightlocal/icons";
14
+ import { cn as A } from "@brightlocal/ui-components/lib/utils";
15
+ import { Fragment as J, jsx as m, jsxs as I } from "react/jsx-runtime";
16
+ import { useOverlayPointerLock as gt } from "@brightlocal/ui-components/hooks/use-overlay-pointer-lock";
17
+ import * as wt from "@radix-ui/react-dialog";
18
+ import { MOTION_DURATION_BASE_MS as ye, MOTION_DURATION_SLOW_MS as me, MOTION_EASE_DECELERATE as yt, MOTION_EASE_EMPHASIZED as bt } from "@brightlocal/ui-components/lib/motion";
19
+ import { usePrefersReducedMotion as vt } from "@brightlocal/ui-components/hooks/use-prefers-reduced-motion";
20
+ var Y = [
21
+ 1,
22
+ 1.5,
23
+ 2,
24
+ 3
25
+ ], pe = 2.5, he = A("group/nav absolute inset-y-0 flex w-16 items-center justify-center outline-none sm:w-20", "duration-fast opacity-0 transition-opacity ease-out", "group-hover/stage:opacity-100 focus-visible:opacity-100", "disabled:invisible pointer-coarse:hidden"), ge = A(Ye({ variant: "ghost" }), "pointer-events-none size-9 p-0 group-hover/nav:bg-accent group-hover/nav:text-accent-foreground group-focus-visible/nav:shadow-default"), Rt = (t, u) => `${t} of ${u}`;
26
+ function xt(t, u, g) {
27
+ const [p, v] = c.useState(() => /* @__PURE__ */ new Set()), [y, S] = c.useState(() => /* @__PURE__ */ new Map()), [R, e] = c.useState(() => /* @__PURE__ */ new Set()), [s, o] = c.useState(() => /* @__PURE__ */ new Map()), x = c.useCallback((f, n, d) => {
28
+ if (!n || !d) return null;
29
+ const l = n / d;
30
+ return S((h) => h.get(f) === l ? h : new Map(h).set(f, l)), l;
31
+ }, []), i = c.useCallback((f) => {
32
+ v((n) => new Set(n).add(f));
33
+ }, []);
34
+ return c.useEffect(() => {
35
+ if (!g) return;
36
+ let f = !1;
37
+ for (const n of [
38
+ t[u],
39
+ t[u + 1],
40
+ t[u - 1]
41
+ ]) {
42
+ if (!n || n.expired) continue;
43
+ const d = new Image();
44
+ d.src = n.src, d.decode().then(() => {
45
+ f || (x(n.src, d.naturalWidth, d.naturalHeight), o((l) => l.get(n.src) === d.naturalWidth ? l : new Map(l).set(n.src, d.naturalWidth)), e((l) => l.has(n.src) ? l : new Set(l).add(n.src)));
46
+ }).catch(() => {
47
+ });
48
+ }
49
+ return () => {
50
+ f = !0;
51
+ };
52
+ }, [
53
+ g,
54
+ t,
55
+ u,
56
+ x
57
+ ]), {
58
+ failed: p,
59
+ ratios: y,
60
+ widths: s,
61
+ ready: R,
62
+ noteRatio: x,
63
+ markFailed: i
64
+ };
65
+ }
66
+ function Mt({ index: t, openCount: u, openedAtRef: g, triggersRef: p, reducedMotion: v, setOpen: y, revealed: S, reveal: R }) {
67
+ const e = c.useRef(null), s = c.useRef(null), o = c.useRef(null), x = c.useRef(0), i = c.useRef(0), f = (l) => {
68
+ const h = p.current.get(l);
69
+ return h?.isConnected ? h : null;
70
+ };
71
+ return {
72
+ imageRef: e,
73
+ overlayRef: s,
74
+ barRef: o,
75
+ revealed: S,
76
+ reveal: R,
77
+ zoomIn: (l, h, _) => {
78
+ if (x.current === u || (x.current = u, l.style.visibility = "visible", R(), _ - g.current > 500)) return;
79
+ const N = v || h ? null : f(t), P = N ? fe(N, l) : null;
80
+ P ? l.animate([P, de], {
81
+ duration: me,
82
+ easing: bt
83
+ }) : l.animate([{ opacity: 0 }, { opacity: 1 }], {
84
+ duration: me,
85
+ easing: "ease-out"
86
+ });
87
+ },
88
+ requestClose: ({ fade: l = !1 } = {}) => {
89
+ if (i.current === u) return;
90
+ const h = e.current, _ = v || l ? null : f(t);
91
+ h?.getAnimations().forEach((a) => a.cancel());
92
+ const N = h && _ ? fe(_, h) : null;
93
+ if (!h || !N) {
94
+ y(!1);
95
+ return;
96
+ }
97
+ i.current = u;
98
+ const P = {
99
+ duration: ye,
100
+ easing: "ease-in-out",
101
+ fill: "forwards"
102
+ };
103
+ for (const a of [s.current, o.current]) a?.animate([{ opacity: 1 }, { opacity: 0 }], P);
104
+ h.animate([de, N], P).finished.catch(() => {
105
+ }).finally(() => y(!1));
106
+ }
107
+ };
108
+ }
109
+ function St({ index: t, total: u, reducedMotion: g, onStep: p }) {
110
+ const v = c.useRef(null), y = c.useRef(null), S = c.useRef(null), R = c.useRef(null), e = () => v.current?.clientWidth ?? 0, s = (a) => {
111
+ const b = y.current;
112
+ b && (b.style.transform = a ? `translateX(${a}px)` : "");
113
+ }, o = (a) => a > 0 && t === 0 || a < 0 && t === u - 1, x = (a) => o(a) ? ot(a, e() * rt) : a, i = (a, b) => {
114
+ const T = y.current?.animate([{ transform: `translateX(${a}px)` }, { transform: "none" }], it(a, b));
115
+ R.current = T ? {
116
+ from: a,
117
+ animation: T
118
+ } : null;
119
+ }, f = (a, b = 0) => {
120
+ s(0), !(!a || g) && i(a, b);
121
+ }, n = () => {
122
+ const a = R.current?.animation.playState;
123
+ return a === "running" || a === "paused";
124
+ }, d = () => {
125
+ const a = R.current;
126
+ if (R.current = null, !a || a.animation.playState === "finished") return 0;
127
+ const b = a.animation.effect?.getComputedTiming().progress, T = a.from * (1 - (b ?? 0));
128
+ return a.animation.cancel(), s(T), T;
129
+ }, l = (a, b = 0, T = 0) => {
130
+ if (a === t || a < 0 || a >= u) return;
131
+ const z = e();
132
+ b && !g && z && Math.abs(a - t) === 1 && (S.current = {
133
+ from: (a > t ? 1 : -1) * z + b,
134
+ speed: T
135
+ }), p(a);
136
+ }, h = (a) => l(t + a), _ = () => Math.min(e() * at, 160), N = (a, b = _()) => {
137
+ const T = t + (a < 0 ? 1 : -1);
138
+ return Math.abs(a) > b && T >= 0 && T < u;
139
+ }, P = (a, b, T = 0) => {
140
+ const z = b < 0 ? 1 : -1, K = !(T * b < 0 && Math.abs(T) > 0.2) && (Math.abs(b) > _() || Math.abs(T) > 0.5), W = t + z;
141
+ K && W >= 0 && W < u ? l(W, a, T) : f(a, T);
142
+ };
143
+ return c.useLayoutEffect(() => {
144
+ const a = S.current;
145
+ S.current = null, R.current?.animation.cancel(), R.current = null, s(0), a?.from && i(a.from, a.speed);
146
+ }, [t]), {
147
+ frameRef: v,
148
+ trackRef: y,
149
+ moveTrack: s,
150
+ pastEnd: o,
151
+ resist: x,
152
+ settle: f,
153
+ gliding: n,
154
+ stopGlide: d,
155
+ goTo: l,
156
+ step: h,
157
+ canStep: N,
158
+ release: P
159
+ };
160
+ }
161
+ function Tt(t, u, g) {
162
+ const p = c.useRef({
163
+ x: 0,
164
+ y: 0
165
+ }), v = c.useRef(t), y = c.useRef(null), S = c.useRef(!1), R = (n) => {
166
+ const d = u.current, l = g.current;
167
+ if (!d || !l) return;
168
+ const h = v.current, _ = Math.max(0, (d.offsetWidth * h - l.clientWidth) / 2), N = Math.max(0, (d.offsetHeight * h - l.clientHeight) / 2), P = p.current;
169
+ P.x = Math.min(_, Math.max(-_, P.x)), P.y = Math.min(N, Math.max(-N, P.y)), d.style.transition = n ? `transform ${ye}ms ${yt}` : "none", d.style.transform = h === 1 ? "" : `translate(${P.x}px, ${P.y}px) scale(${h})`;
170
+ };
171
+ c.useLayoutEffect(() => {
172
+ const n = t / v.current;
173
+ v.current = t, p.current = t === 1 ? {
174
+ x: 0,
175
+ y: 0
176
+ } : {
177
+ x: p.current.x * n,
178
+ y: p.current.y * n
179
+ }, R(!0);
180
+ }, [t]);
181
+ const e = (n, d) => {
182
+ p.current.x += n, p.current.y += d, R(!1);
183
+ };
184
+ return {
185
+ panBy: e,
186
+ reset: () => {
187
+ const n = u.current;
188
+ p.current = {
189
+ x: 0,
190
+ y: 0
191
+ }, v.current = 1, n && (n.style.transition = "none", n.style.transform = "");
192
+ },
193
+ onPointerDown: (n) => {
194
+ n.pointerType === "mouse" && n.button !== 0 || (S.current = !1, n.target instanceof Node && u.current?.contains(n.target) && (y.current = {
195
+ x: n.clientX,
196
+ y: n.clientY,
197
+ moved: !1
198
+ }, n.currentTarget.setPointerCapture?.(n.pointerId)));
199
+ },
200
+ onPointerMove: (n) => {
201
+ const d = y.current;
202
+ if (!d) return;
203
+ const l = n.clientX - d.x, h = n.clientY - d.y;
204
+ !d.moved && Math.hypot(l, h) < 4 || (d.moved = !0, d.x = n.clientX, d.y = n.clientY, e(l, h));
205
+ },
206
+ onPointerUp: () => {
207
+ S.current = !!y.current?.moved, y.current = null;
208
+ },
209
+ consumePan: () => {
210
+ const n = S.current;
211
+ return S.current = !1, n;
212
+ }
213
+ };
214
+ }
215
+ function Pt(t, u) {
216
+ const g = c.useRef(!1), p = c.useRef(null);
217
+ return {
218
+ consumeSwipe: () => {
219
+ const s = g.current;
220
+ return g.current = !1, s;
221
+ },
222
+ onPointerDown: (s) => {
223
+ g.current = !1, !(s.pointerType === "mouse" || !u) && (p.current = {
224
+ x: s.clientX,
225
+ y: s.clientY,
226
+ axis: null,
227
+ base: 0,
228
+ offset: 0,
229
+ speed: 0,
230
+ lastX: s.clientX,
231
+ lastTime: s.timeStamp
232
+ });
233
+ },
234
+ onPointerMove: (s) => {
235
+ const o = p.current;
236
+ if (!o) return;
237
+ const x = s.clientX - o.x, i = s.clientY - o.y;
238
+ if (!o.axis) {
239
+ if (Math.hypot(x, i) < 8) return;
240
+ o.axis = Math.abs(x) > Math.abs(i) ? "x" : "y", o.axis === "x" && (o.base = t.stopGlide());
241
+ }
242
+ if (o.axis !== "x") return;
243
+ const f = s.timeStamp - o.lastTime;
244
+ if (f > 0) {
245
+ const n = (s.clientX - o.lastX) / f;
246
+ o.speed = o.speed * 0.3 + n * 0.7;
247
+ }
248
+ o.lastX = s.clientX, o.lastTime = s.timeStamp, o.offset = t.resist(o.base + x), t.moveTrack(o.offset);
249
+ },
250
+ onPointerUp: (s) => {
251
+ const o = p.current;
252
+ if (p.current = null, !o || o.axis !== "x") return;
253
+ g.current = !0;
254
+ const x = s.timeStamp - o.lastTime > 80 ? 0 : o.speed;
255
+ t.release(o.offset, s.clientX - o.x, x);
256
+ },
257
+ onPointerCancel: () => {
258
+ const s = p.current;
259
+ p.current = null, s?.axis === "x" && t.settle(s.offset);
260
+ }
261
+ };
262
+ }
263
+ function Et(t, u, g, p) {
264
+ const v = c.useRef(u), y = c.useRef(g), S = c.useRef(p);
265
+ c.useLayoutEffect(() => {
266
+ v.current = u, y.current = g, S.current = p;
267
+ });
268
+ const R = c.useRef({
269
+ swiping: !1,
270
+ intent: 0,
271
+ offset: 0,
272
+ pull: 0,
273
+ previous: 0,
274
+ fading: 0,
275
+ speed: 0,
276
+ last: 0,
277
+ inertia: 0,
278
+ inertiaTimer: 0,
279
+ inertiaPrevious: 0,
280
+ inertiaFaintest: 0,
281
+ inertiaFading: !1,
282
+ cancelTimer: 0
283
+ });
284
+ c.useEffect(() => {
285
+ if (!t) return;
286
+ const e = R.current, s = (i) => {
287
+ e.inertia = i, window.clearTimeout(e.inertiaTimer), e.inertiaTimer = window.setTimeout(() => {
288
+ e.inertia = 0;
289
+ }, 300);
290
+ }, o = (i) => {
291
+ s(i), e.inertiaPrevious = Math.abs(i), e.inertiaFaintest = Math.abs(i), e.inertiaFading = !1;
292
+ }, x = (i) => {
293
+ if (i.ctrlKey) return;
294
+ if (!y.current) {
295
+ i.preventDefault(), S.current(-i.deltaX, -i.deltaY);
296
+ return;
297
+ }
298
+ if (Math.abs(i.deltaY) > Math.abs(i.deltaX) || i.target instanceof Element && i.target.closest('[data-slot="media-viewer-thumbnails"]')) return;
299
+ i.preventDefault();
300
+ const f = v.current, n = Math.abs(i.deltaX), d = i.timeStamp - e.last;
301
+ if (e.last = i.timeStamp, e.swiping)
302
+ d > 0 && (e.speed = e.speed * 0.3 + -i.deltaX / d * 0.7);
303
+ else {
304
+ window.clearTimeout(e.cancelTimer);
305
+ const h = e.inertia !== 0 && Math.sign(i.deltaX) === Math.sign(e.inertia);
306
+ h && (n < e.inertiaPrevious && (e.inertiaFading || (e.inertiaFaintest = n), e.inertiaFading = !0), e.inertiaFading && (e.inertiaFaintest = Math.min(e.inertiaFaintest, n)), e.inertiaPrevious = n);
307
+ const _ = e.inertiaFading && n >= e.inertiaFaintest * 2;
308
+ if (h && !_ && (f.gliding() || n <= Math.abs(e.inertia) * 1.2)) {
309
+ s(i.deltaX), e.intent = 0;
310
+ return;
311
+ }
312
+ if (e.intent += i.deltaX, Math.abs(e.intent) <= 30) {
313
+ e.cancelTimer = window.setTimeout(() => {
314
+ e.intent = 0;
315
+ }, 600);
316
+ return;
317
+ }
318
+ e.intent = 0, e.swiping = !0, e.inertia = 0, e.inertiaFading = !1, e.offset = f.stopGlide(), e.pull = 0, e.speed = 0, e.fading = 0;
319
+ }
320
+ window.clearTimeout(e.cancelTimer);
321
+ const l = t.clientWidth;
322
+ if (e.offset = Math.max(-l, Math.min(l, e.offset - i.deltaX)), e.pull -= i.deltaX, f.moveTrack(f.resist(e.offset)), e.fading = n < e.previous ? e.fading + 1 : 0, e.previous = n, f.pastEnd(e.offset) && e.fading >= 2) {
323
+ e.swiping = !1, o(i.deltaX), f.release(f.resist(e.offset), 0);
324
+ return;
325
+ }
326
+ if (f.canStep(e.pull, l * 0.2)) {
327
+ e.swiping = !1, o(i.deltaX), f.release(f.resist(e.offset), e.pull, e.speed);
328
+ return;
329
+ }
330
+ e.cancelTimer = window.setTimeout(() => {
331
+ e.swiping = !1, f.release(f.resist(e.offset), 0);
332
+ }, 600);
333
+ };
334
+ return t.addEventListener("wheel", x, { passive: !1 }), () => {
335
+ t.removeEventListener("wheel", x), window.clearTimeout(e.cancelTimer), window.clearTimeout(e.inertiaTimer);
336
+ };
337
+ }, [t]);
338
+ }
339
+ function kt({ dataHook: t, hasPrevious: u, hasNext: g, previousLabel: p, nextLabel: v, onStep: y }) {
340
+ return /* @__PURE__ */ I(J, { children: [/* @__PURE__ */ m("button", {
341
+ "aria-label": p ?? "Previous",
342
+ className: A(he, "left-0"),
343
+ "data-hook": `${t}-previous`,
344
+ "data-slot": "media-viewer-previous",
345
+ disabled: !u,
346
+ type: "button",
347
+ onClick: () => y(-1),
348
+ children: /* @__PURE__ */ m("span", {
349
+ "aria-hidden": !0,
350
+ className: ge,
351
+ children: /* @__PURE__ */ m(dt, {})
352
+ })
353
+ }), /* @__PURE__ */ m("button", {
354
+ "aria-label": v ?? "Next",
355
+ className: A(he, "right-0"),
356
+ "data-hook": `${t}-next`,
357
+ "data-slot": "media-viewer-next",
358
+ disabled: !g,
359
+ type: "button",
360
+ onClick: () => y(1),
361
+ children: /* @__PURE__ */ m("span", {
362
+ "aria-hidden": !0,
363
+ className: ge,
364
+ children: /* @__PURE__ */ m(ft, {})
365
+ })
366
+ })] });
367
+ }
368
+ function _t({ dataHook: t, items: u, index: g, failed: p, label: v, onSelect: y, onRatio: S }) {
369
+ const R = c.useRef(null);
370
+ return c.useEffect(() => {
371
+ R.current?.querySelector('[aria-current="true"]')?.scrollIntoView?.({
372
+ block: "nearest",
373
+ inline: "nearest"
374
+ });
375
+ }, [g]), /* @__PURE__ */ m("div", {
376
+ ref: R,
377
+ "aria-label": v ?? "Images",
378
+ className: "mb-2 flex max-w-full gap-1.5 justify-self-center overflow-x-auto p-1 [grid-area:strip] sm:mb-0",
379
+ "data-hook": `${t}-thumbnails`,
380
+ "data-slot": "media-viewer-thumbnails",
381
+ role: "group",
382
+ children: u.map((e, s) => {
383
+ const o = s === g, x = e.expired || p.has(e.src);
384
+ return /* @__PURE__ */ m("button", {
385
+ "aria-current": o ? "true" : void 0,
386
+ "aria-label": e.alt,
387
+ className: A("bg-muted relative size-12 shrink-0 overflow-hidden rounded-md outline-none", "duration-fast focus-visible:shadow-default transition-opacity ease-out", o ? "opacity-100" : "opacity-50 hover:opacity-100"),
388
+ "data-hook": `${t}-thumbnail-${s}`,
389
+ "data-slot": "media-viewer-thumbnail",
390
+ type: "button",
391
+ onClick: () => y(s),
392
+ children: x ? null : /* @__PURE__ */ m("img", {
393
+ alt: "",
394
+ className: "size-full object-cover object-top",
395
+ decoding: "async",
396
+ draggable: !1,
397
+ loading: "lazy",
398
+ src: e.thumbnailSrc ?? e.src,
399
+ onLoad: (i) => S(e.src, i.currentTarget.naturalWidth, i.currentTarget.naturalHeight)
400
+ })
401
+ }, e.src);
402
+ })
403
+ });
404
+ }
405
+ var be = c.forwardRef(({ dataHook: t, children: u, formatPosition: g, previousLabel: p, nextLabel: v, thumbnailsLabel: y, unavailableMessage: S, zoomInLabel: R, zoomOutLabel: e, downloadLabel: s, infoLabel: o, dateLabels: x, className: i, trackingEl: f, trackingLabel: n, onClick: d, onCloseAutoFocus: l, onEscapeKeyDown: h, onKeyDown: _, onOpenAutoFocus: N, ...P }, a) => {
406
+ const { items: b, index: T, setIndex: z, openerRef: K, open: W, setOpen: ve, openCount: Q, openedAtRef: Re, revealed: xe, reveal: Me, triggersRef: Se, renderActions: ee, actionsLabel: Te } = we("MediaViewerContent"), te = vt();
407
+ gt();
408
+ const F = b.length, E = Math.min(Math.max(T, 0), Math.max(F - 1, 0)), Pe = E > 0, Ee = E < F - 1, j = `${Q}:${E}`, [ne, ke] = c.useState({
409
+ key: "",
410
+ level: 0
411
+ }), B = ne.key === j ? ne.level : 0, C = B > 0, q = (r) => ke((w) => {
412
+ const M = w.key === j ? w.level : 0, D = Math.min(Math.max(M + r, 0), Y.length - 1);
413
+ return D === M && w.key === j ? w : {
414
+ key: j,
415
+ level: D
416
+ };
417
+ }), { failed: G, ratios: _e, widths: ae, ready: Ne, noteRatio: re, markFailed: Ce } = xt(b, E, W), V = Mt({
418
+ index: E,
419
+ openCount: Q,
420
+ openedAtRef: Re,
421
+ triggersRef: Se,
422
+ reducedMotion: te,
423
+ setOpen: ve,
424
+ revealed: xe,
425
+ reveal: Me
426
+ }), X = St({
427
+ index: E,
428
+ total: F,
429
+ reducedMotion: te,
430
+ onStep: (r) => {
431
+ V.reveal(), L.reset(), z(r);
432
+ }
433
+ }), U = Pt(X, !C), { frameRef: ie, trackRef: De } = X, { imageRef: oe, overlayRef: Ae, barRef: Ie } = V, L = Tt(Y[B] ?? 1, oe, ie), [$e, Fe] = c.useState(null), Xe = c.useCallback((r) => {
434
+ Fe(r), typeof a == "function" ? a(r) : a && (a.current = r);
435
+ }, [a]);
436
+ Et($e, X, !C, L.panBy);
437
+ const k = b[E], O = !!(k && !k.expired && !G.has(k.src)), Le = lt(O ? k?.downloadSrc ?? k?.src : void 0, W), Oe = (r, w, M) => {
438
+ const D = r.currentTarget, $ = re(w, D.naturalWidth, D.naturalHeight);
439
+ M && ($ && D.style.setProperty("--media-ratio", String($)), V.zoomIn(D, $ !== null && 1 / $ > pe, r.timeStamp));
440
+ }, ze = (r) => {
441
+ r.defaultPrevented || r.target.closest('[role="menu"]') || (r.key === "ArrowLeft" ? (r.preventDefault(), X.step(-1)) : r.key === "ArrowRight" ? (r.preventDefault(), X.step(1)) : (r.key === "+" || r.key === "=") && O ? (r.preventDefault(), q(1)) : r.key === "-" && O && (r.preventDefault(), q(-1)));
442
+ }, We = (r) => {
443
+ const w = K.current;
444
+ w?.isConnected && (r.preventDefault(), w.focus());
445
+ }, Ve = (r) => {
446
+ r.preventDefault(), r.currentTarget?.focus();
447
+ }, Be = (r) => {
448
+ U.consumeSwipe() || L.consumePan() || r.target instanceof HTMLElement && r.target.hasAttribute("data-media-viewer-backdrop") && V.requestClose({ fade: C });
449
+ }, se = /* @__PURE__ */ I(J, { children: [k && ee ? /* @__PURE__ */ m(Qe, {
450
+ dataHook: `${t}-actions-menu`,
451
+ label: Te(k, E),
452
+ variant: "ghost",
453
+ children: ee(k, E)
454
+ }) : null, /* @__PURE__ */ m(He, {
455
+ ariaLabel: o ?? "Image details",
456
+ className: "text-foreground hover:bg-accent size-9 items-center justify-center rounded-md",
457
+ content: ct(Le),
458
+ dataHook: `${t}-info`,
459
+ disabled: !O
460
+ })] }), ce = /* @__PURE__ */ I(J, { children: [
461
+ /* @__PURE__ */ m(H, {
462
+ iconOnly: !0,
463
+ ariaLabel: s ?? "Download",
464
+ dataHook: `${t}-download`,
465
+ disabled: !O,
466
+ variant: "ghost",
467
+ onClick: () => {
468
+ k && st(k.downloadSrc ?? k.src);
469
+ },
470
+ children: /* @__PURE__ */ m(mt, { "aria-hidden": !0 })
471
+ }),
472
+ /* @__PURE__ */ m(H, {
473
+ iconOnly: !0,
474
+ ariaLabel: R ?? "Zoom in",
475
+ dataHook: `${t}-zoom-in`,
476
+ disabled: !O || B === Y.length - 1,
477
+ variant: "ghost",
478
+ onClick: () => q(1),
479
+ children: /* @__PURE__ */ m(pt, { "aria-hidden": !0 })
480
+ }),
481
+ /* @__PURE__ */ m(H, {
482
+ iconOnly: !0,
483
+ ariaLabel: e ?? "Zoom out",
484
+ dataHook: `${t}-zoom-out`,
485
+ disabled: !O || B === 0,
486
+ variant: "ghost",
487
+ onClick: () => q(-1),
488
+ children: /* @__PURE__ */ m(ht, { "aria-hidden": !0 })
489
+ })
490
+ ] }), [Ue, le] = c.useState(0), Ze = c.useMemo(() => () => (le((r) => r + 1), () => le((r) => r - 1)), []), je = (r) => {
491
+ const w = b[r];
492
+ if (!w) return null;
493
+ const M = r === E, D = w.expired || G.has(w.src);
494
+ if (D && !M) return null;
495
+ const $ = _e.get(w.src), ue = $ !== void 0 && 1 / $ > pe;
496
+ return /* @__PURE__ */ m("div", {
497
+ "aria-hidden": M ? void 0 : !0,
498
+ className: A("[container-type:size] absolute inset-0 flex px-4 pt-8 pb-4 sm:px-20", M && !C ? "overflow-auto" : "overflow-hidden"),
499
+ "data-media-viewer-backdrop": M ? "" : void 0,
500
+ "data-slot": M ? "media-viewer-slide" : "media-viewer-peek",
501
+ style: M ? void 0 : { transform: `translateX(${(r - E) * 100}%)` },
502
+ children: D ? /* @__PURE__ */ m("div", {
503
+ className: "m-auto w-full max-w-3xl",
504
+ children: /* @__PURE__ */ m("div", {
505
+ className: "aspect-[4/3] w-full",
506
+ children: /* @__PURE__ */ m(Je, {
507
+ dataHook: `${t}-empty`,
508
+ message: S ?? "Image no longer available"
509
+ })
510
+ })
511
+ }) : /* @__PURE__ */ m("img", {
512
+ ref: M ? oe : void 0,
513
+ alt: M ? w.alt : "",
514
+ className: A("m-auto block h-auto", M && C && "cursor-grab active:cursor-grabbing", ue ? "w-full max-w-(--media-natural-width)" : "w-[min(100cqw,calc(100cqh*var(--media-ratio,1)),var(--media-natural-width,100cqw))]"),
515
+ "data-fit": M ? ue ? "width" : "contain" : void 0,
516
+ "data-hook": M ? `${t}-image` : void 0,
517
+ "data-media-viewer-backdrop": M && !C ? "" : void 0,
518
+ "data-slot": M ? "media-viewer-image" : void 0,
519
+ "data-zoom": M ? Y[B] : void 0,
520
+ decoding: "sync",
521
+ draggable: !1,
522
+ src: Ne.has(w.src) ? w.src : w.thumbnailSrc ?? w.src,
523
+ style: {
524
+ "--media-ratio": $,
525
+ "--media-natural-width": ae.has(w.src) ? `${ae.get(w.src)}px` : void 0,
526
+ visibility: M && !V.revealed ? "hidden" : void 0
527
+ },
528
+ onError: () => Ce(w.src),
529
+ onLoad: (qe) => Oe(qe, w.src, M)
530
+ })
531
+ }, w.src);
532
+ };
533
+ return /* @__PURE__ */ I(Ge, { children: [/* @__PURE__ */ m(Ke, {
534
+ ref: Ae,
535
+ className: "data-[state=closed]:duration-fast bg-black/85 data-[state=closed]:ease-out"
536
+ }), /* @__PURE__ */ I(wt.Content, {
537
+ ref: Xe,
538
+ "aria-describedby": void 0,
539
+ className: A("dark text-foreground group/viewer data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:duration-fast fixed inset-0 z-50 grid h-dvh w-screen grid-rows-[minmax(0,1fr)_auto] ease-out outline-none", i),
540
+ "data-hook": t,
541
+ "data-media-viewer-backdrop": "",
542
+ "data-slot": "media-viewer-content",
543
+ "data-tracking-el": f ?? "media-viewer",
544
+ "data-tracking-label": n,
545
+ ...P,
546
+ onClick: (r) => Z(d, Be)(r),
547
+ onCloseAutoFocus: (r) => Z(l, We)(r),
548
+ onEscapeKeyDown: (r) => Z(h, (w) => {
549
+ w.preventDefault(), V.requestClose({ fade: C });
550
+ })(r),
551
+ onKeyDown: (r) => Z(_, ze)(r),
552
+ onOpenAutoFocus: (r) => Z(N, Ve)(r),
553
+ children: [/* @__PURE__ */ I("div", {
554
+ ref: ie,
555
+ className: A("group/stage relative min-h-0 overflow-hidden select-none", C ? "touch-none" : "touch-pan-y"),
556
+ "data-hook": `${t}-frame`,
557
+ "data-slot": "media-viewer-frame",
558
+ onPointerCancel: C ? L.onPointerUp : U.onPointerCancel,
559
+ onPointerDown: C ? L.onPointerDown : U.onPointerDown,
560
+ onPointerMove: C ? L.onPointerMove : U.onPointerMove,
561
+ onPointerUp: C ? L.onPointerUp : U.onPointerUp,
562
+ children: [/* @__PURE__ */ m("div", {
563
+ ref: De,
564
+ className: "relative size-full",
565
+ children: [
566
+ E - 1,
567
+ E,
568
+ E + 1
569
+ ].map(je)
570
+ }), F > 1 ? /* @__PURE__ */ m(kt, {
571
+ dataHook: t,
572
+ hasNext: Ee,
573
+ hasPrevious: Pe,
574
+ nextLabel: v,
575
+ previousLabel: p,
576
+ onStep: X.step
577
+ }) : null]
578
+ }), /* @__PURE__ */ I("div", {
579
+ ref: Ie,
580
+ className: A("grid items-center gap-x-4 gap-y-1 px-4 pt-6 pb-3 sm:px-8", "grid-cols-[minmax(0,1fr)_auto] [grid-template-areas:'strip_strip'_'title_actions'_'caption_actions'_'date_actions']", "sm:grid-cols-[minmax(0,1fr)_minmax(0,2fr)_minmax(0,1fr)] sm:[grid-template-areas:'title_strip_actions'_'caption_strip_actions'_'date_strip_actions']"),
581
+ "data-media-viewer-backdrop": "",
582
+ "data-slot": "media-viewer-bar",
583
+ children: [
584
+ F > 1 ? /* @__PURE__ */ m("span", {
585
+ "aria-atomic": "true",
586
+ "aria-live": "polite",
587
+ className: "sr-only",
588
+ "data-hook": `${t}-position`,
589
+ "data-slot": "media-viewer-position",
590
+ role: "status",
591
+ children: (g ?? Rt)(E + 1, F)
592
+ }) : null,
593
+ F > 1 ? /* @__PURE__ */ m(_t, {
594
+ dataHook: t,
595
+ failed: G,
596
+ index: E,
597
+ items: b,
598
+ label: y,
599
+ onRatio: re,
600
+ onSelect: X.goTo
601
+ }) : null,
602
+ k?.alt ? /* @__PURE__ */ m(nt, {
603
+ dataHook: `${t}-caption`,
604
+ full: k.alt,
605
+ render: (r) => /* @__PURE__ */ m("p", {
606
+ ref: r,
607
+ "aria-hidden": !0,
608
+ className: "text-body-xs truncate [grid-area:caption]",
609
+ "data-hook": `${t}-caption`,
610
+ "data-slot": "media-viewer-caption",
611
+ children: k.alt
612
+ })
613
+ }) : null,
614
+ k?.date ? /* @__PURE__ */ m(ut, {
615
+ className: "truncate [grid-area:date]",
616
+ dataHook: `${t}-date`,
617
+ labels: x,
618
+ value: k.date
619
+ }) : null,
620
+ /* @__PURE__ */ m(tt.Provider, {
621
+ value: {
622
+ lead: ce,
623
+ more: se
624
+ },
625
+ children: /* @__PURE__ */ I(et.Provider, {
626
+ value: Ze,
627
+ children: [Ue ? null : /* @__PURE__ */ I("div", {
628
+ className: "flex items-center justify-end gap-1 [grid-area:actions]",
629
+ "data-hook": `${t}-actions`,
630
+ "data-slot": "media-viewer-actions",
631
+ children: [ce, se]
632
+ }), u]
633
+ })
634
+ })
635
+ ]
636
+ })]
637
+ })] });
638
+ });
639
+ be.displayName = "MediaViewerView";
640
+ var Nt = c.forwardRef((t, u) => {
641
+ const { viewable: g } = we("MediaViewerContent");
642
+ return g ? /* @__PURE__ */ m(be, {
643
+ ref: u,
644
+ ...t
645
+ }) : null;
646
+ });
647
+ Nt.displayName = "MediaViewerContent";
648
+ export {
649
+ Nt as MediaViewerContent
650
+ };
@@ -0,0 +1 @@
1
+ "use client";const g=require("../_virtual/_rolldown/runtime.cjs"),h=require("../button.cjs"),u=require("../dropdown-menu.cjs"),a=require("../tooltip.cjs");let r=require("react");r=g.__toESM(r,1);let w=require("@brightlocal/icons"),n=require("react/jsx-runtime");var p=r.createContext({lead:null,more:null}),m=r.createContext(null),c=r.createContext(null);function q(t){const e=r.useContext(c);if(!e)throw new Error(`${t} must be used within <MediaViewer>`);return e}var T=(t,e)=>`More actions for ${t.alt||`image ${e+1}`}`,_=(t,e,i)=>t.alt||`Image ${e+1} of ${i}`;function f({dataHook:t,label:e,variant:i,children:l}){return(0,n.jsxs)(u.DropdownMenu,{children:[(0,n.jsx)(u.DropdownMenuTrigger,{asChild:!0,children:(0,n.jsx)(h.Button,{iconOnly:!0,ariaLabel:e,dataHook:t,size:i==="secondary"?"sm":void 0,variant:i,children:(0,n.jsx)(w.Ellipsis,{"aria-hidden":!0})})}),(0,n.jsx)(u.DropdownMenuContent,{align:"end",dataHook:`${t}-content`,children:l})]})}function b({dataHook:t,forwardRef:e,full:i,render:l}){const[s,d]=r.useState(null),[x,C]=r.useState(!1),M=r.useCallback(o=>{d(o),e?.(o)},[e]);return(0,n.jsxs)(a.Tooltip,{open:x,onOpenChange:o=>C(o&&!!s&&s.scrollWidth>s.clientWidth),children:[(0,n.jsx)(a.TooltipTrigger,{asChild:!0,children:l(M)}),(0,n.jsx)(a.TooltipContent,{dataHook:`${t}-full`,side:"top",children:i})]})}exports.ItemActionsMenu=f;exports.MediaViewerActionsRegistry=m;exports.MediaViewerContext=c;exports.MediaViewerControlsContext=p;exports.TruncatedText=b;exports.defaultActionsLabel=T;exports.defaultTriggerLabel=_;exports.useMediaViewerContext=q;