@krizaka/ui 4.4.0 → 4.4.1

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 (259) hide show
  1. package/dist/account-menu.d.ts +1 -1
  2. package/dist/account-menu.js +1 -1
  3. package/dist/account-menu.js.map +1 -1
  4. package/dist/account-settings.d.ts +1 -1
  5. package/dist/account-settings.js +13 -6
  6. package/dist/account-settings.js.map +1 -1
  7. package/dist/agenda.d.ts +1 -1
  8. package/dist/agenda.js +2 -1
  9. package/dist/agenda.js.map +1 -1
  10. package/dist/analysis-report.js +19 -11
  11. package/dist/analysis-report.js.map +1 -1
  12. package/dist/app-frame.d.ts +1 -1
  13. package/dist/app-frame.js.map +1 -1
  14. package/dist/app-header/search.js +2 -2
  15. package/dist/app-header/search.js.map +1 -1
  16. package/dist/avatar/defaults.js +3 -1
  17. package/dist/avatar/defaults.js.map +1 -1
  18. package/dist/avatar.js +3 -1
  19. package/dist/avatar.js.map +1 -1
  20. package/dist/bird-plate.js +8 -2
  21. package/dist/bird-plate.js.map +1 -1
  22. package/dist/chapter.js +7 -4
  23. package/dist/chapter.js.map +1 -1
  24. package/dist/chat.js +1 -1
  25. package/dist/chip.d.ts +1 -1
  26. package/dist/chip.js +1 -1
  27. package/dist/{chunk-SNSQLGGS.js → chunk-5VZ37TY3.js} +1 -1
  28. package/dist/{chunk-XWJDBQU7.js.map → chunk-5VZ37TY3.js.map} +1 -1
  29. package/dist/{chunk-MTVX4RRF.js → chunk-HP7BDMVK.js} +11 -3
  30. package/dist/chunk-HP7BDMVK.js.map +1 -0
  31. package/dist/{chunk-PK3L6WQT.js → chunk-LNAAWT4Y.js} +4 -2
  32. package/dist/{chunk-PK3L6WQT.js.map → chunk-LNAAWT4Y.js.map} +1 -1
  33. package/dist/{chunk-UIP3WX5O.js → chunk-MDSP7DJR.js} +2 -2
  34. package/dist/chunk-MDSP7DJR.js.map +1 -0
  35. package/dist/{chunk-IEGTRCDI.js → chunk-NQENOT6L.js} +2 -2
  36. package/dist/{chunk-IEGTRCDI.js.map → chunk-NQENOT6L.js.map} +1 -1
  37. package/dist/{chunk-FM42KOAU.js → chunk-P7AFIKWG.js} +5 -3
  38. package/dist/chunk-P7AFIKWG.js.map +1 -0
  39. package/dist/{chunk-BCD2CRFG.js → chunk-PJNR4NTS.js} +2 -2
  40. package/dist/chunk-PJNR4NTS.js.map +1 -0
  41. package/dist/{chunk-ZFR6ZNXD.js → chunk-PVQ2KKPZ.js} +1 -1
  42. package/dist/chunk-PVQ2KKPZ.js.map +1 -0
  43. package/dist/{chunk-U4XTZMB7.js → chunk-QA3WETWT.js} +1 -1
  44. package/dist/{chunk-U4XTZMB7.js.map → chunk-QA3WETWT.js.map} +1 -1
  45. package/dist/{chunk-YXETEQQJ.js → chunk-SG2RKUVJ.js} +2 -2
  46. package/dist/{chunk-EOWV6BNQ.js → chunk-TXFX4PMN.js} +4 -2
  47. package/dist/{chunk-EOWV6BNQ.js.map → chunk-TXFX4PMN.js.map} +1 -1
  48. package/dist/{chunk-XWJDBQU7.js → chunk-V5RO6JYI.js} +1 -1
  49. package/dist/{chunk-SNSQLGGS.js.map → chunk-V5RO6JYI.js.map} +1 -1
  50. package/dist/{chunk-VUD4IEVJ.js → chunk-VZ6ZALIJ.js} +1 -1
  51. package/dist/chunk-VZ6ZALIJ.js.map +1 -0
  52. package/dist/{chunk-2DHL7NJW.js → chunk-XVRKKYWU.js} +5 -3
  53. package/dist/{chunk-2DHL7NJW.js.map → chunk-XVRKKYWU.js.map} +1 -1
  54. package/dist/{chunk-CDNOT2KR.js → chunk-YTYNKMNS.js} +1 -1
  55. package/dist/chunk-YTYNKMNS.js.map +1 -0
  56. package/dist/code-block.js.map +1 -1
  57. package/dist/combobox.js +2 -2
  58. package/dist/copy-button.js +2 -2
  59. package/dist/copy-button.js.map +1 -1
  60. package/dist/data-table.js +3 -3
  61. package/dist/desktop-window.d.ts +1 -1
  62. package/dist/desktop-window.js +3 -1
  63. package/dist/desktop-window.js.map +1 -1
  64. package/dist/drop-overlay.js +8 -8
  65. package/dist/drop-overlay.js.map +1 -1
  66. package/dist/elephant.d.ts +1 -1
  67. package/dist/elephant.js.map +1 -1
  68. package/dist/embed-facade.d.ts +1 -1
  69. package/dist/embed-facade.js +3 -1
  70. package/dist/embed-facade.js.map +1 -1
  71. package/dist/engine-flow.js +7 -2
  72. package/dist/engine-flow.js.map +1 -1
  73. package/dist/entity-header.js +9 -3
  74. package/dist/entity-header.js.map +1 -1
  75. package/dist/file-upload.d.ts +1 -1
  76. package/dist/file-upload.js.map +1 -1
  77. package/dist/filter-bar.d.ts +4 -4
  78. package/dist/filter-bar.js +2 -2
  79. package/dist/flock.js +9 -6
  80. package/dist/flock.js.map +1 -1
  81. package/dist/form.d.ts +3 -3
  82. package/dist/form.js.map +1 -1
  83. package/dist/genui.js +3 -3
  84. package/dist/glossary-term.d.ts +1 -1
  85. package/dist/glossary-term.js.map +1 -1
  86. package/dist/glossary.d.ts +1 -1
  87. package/dist/glossary.js.map +1 -1
  88. package/dist/identity-card.js +1 -1
  89. package/dist/index.js +1 -1
  90. package/dist/kind-config-editor.d.ts +2 -2
  91. package/dist/kind-config-editor.js +1 -1
  92. package/dist/kind-config-editor.js.map +1 -1
  93. package/dist/kpi-explained.d.ts +1 -1
  94. package/dist/kpi-explained.js +4 -4
  95. package/dist/kpi-explained.js.map +1 -1
  96. package/dist/landing-page.js +1 -1
  97. package/dist/{lightbox-Q45BZ3HW.js → lightbox-MRB2YZEP.js} +1 -1
  98. package/dist/lightbox-MRB2YZEP.js.map +1 -0
  99. package/dist/map/cards.js +4 -2
  100. package/dist/map/cards.js.map +1 -1
  101. package/dist/map/pin.js +2 -1
  102. package/dist/map/pin.js.map +1 -1
  103. package/dist/map.d.ts +1 -1
  104. package/dist/map.js.map +1 -1
  105. package/dist/mascot-quote.js +1 -1
  106. package/dist/mascot-state.js +1 -1
  107. package/dist/mascots.js +1 -1
  108. package/dist/match-dialog.js +1 -1
  109. package/dist/motion.d.ts +1 -1
  110. package/dist/motion.js.map +1 -1
  111. package/dist/native/form.d.ts +3 -3
  112. package/dist/native/form.js.map +1 -1
  113. package/dist/native/markdown.d.ts +1 -1
  114. package/dist/native/markdown.js.map +1 -1
  115. package/dist/native/vertical-video.js.map +1 -1
  116. package/dist/native.d.ts +12 -12
  117. package/dist/native.js +12 -7
  118. package/dist/native.js.map +1 -1
  119. package/dist/nav-bar.d.ts +2 -2
  120. package/dist/nav-bar.js +1 -1
  121. package/dist/nav-bar.js.map +1 -1
  122. package/dist/next-actions.d.ts +1 -1
  123. package/dist/next-actions.js.map +1 -1
  124. package/dist/notification-preferences.d.ts +1 -1
  125. package/dist/notification-preferences.js +5 -2
  126. package/dist/notification-preferences.js.map +1 -1
  127. package/dist/page-index.js +2 -2
  128. package/dist/page-index.js.map +1 -1
  129. package/dist/product-page.js +1 -1
  130. package/dist/promo-code-field.d.ts +1 -1
  131. package/dist/promo-code-field.js.map +1 -1
  132. package/dist/qr-code.d.ts +1 -1
  133. package/dist/qr-code.js +1 -1
  134. package/dist/rail-nav.js +3 -3
  135. package/dist/rail-nav.js.map +1 -1
  136. package/dist/retro-tv.d.ts +1 -1
  137. package/dist/retro-tv.js.map +1 -1
  138. package/dist/reviews.d.ts +2 -2
  139. package/dist/reviews.js.map +1 -1
  140. package/dist/router.d.ts +1 -1
  141. package/dist/router.js +8 -8
  142. package/dist/router.js.map +1 -1
  143. package/dist/{schema-CL7t7xqb.d.ts → schema-Dd05m48Q.d.ts} +9 -9
  144. package/dist/service-card.js +22 -13
  145. package/dist/service-card.js.map +1 -1
  146. package/dist/settings-layout.js +1 -1
  147. package/dist/shop/booking.js.map +1 -1
  148. package/dist/shop/gallery.js +7 -6
  149. package/dist/shop/gallery.js.map +1 -1
  150. package/dist/shop/hero.js.map +1 -1
  151. package/dist/shop/look.d.ts +2 -2
  152. package/dist/shop/look.js +1 -1
  153. package/dist/shop/look.js.map +1 -1
  154. package/dist/shop/map-gate.d.ts +1 -1
  155. package/dist/shop/map-gate.js +2 -2
  156. package/dist/shop/map-gate.js.map +1 -1
  157. package/dist/shop/services.js.map +1 -1
  158. package/dist/shop-composer.d.ts +12 -12
  159. package/dist/shop-composer.js +27 -14
  160. package/dist/shop-composer.js.map +1 -1
  161. package/dist/shop-gallery.js +1 -1
  162. package/dist/shop.d.ts +2 -2
  163. package/dist/shop.js +2 -2
  164. package/dist/shop.js.map +1 -1
  165. package/dist/signature.js +2 -1
  166. package/dist/signature.js.map +1 -1
  167. package/dist/site-cahier.js +7 -3
  168. package/dist/site-cahier.js.map +1 -1
  169. package/dist/site-footer.js +6 -2
  170. package/dist/site-footer.js.map +1 -1
  171. package/dist/slot-picker.js +5 -2
  172. package/dist/slot-picker.js.map +1 -1
  173. package/dist/stat.js +1 -1
  174. package/dist/status-chip.d.ts +1 -1
  175. package/dist/status-chip.js.map +1 -1
  176. package/dist/tabs.js.map +1 -1
  177. package/dist/tag-input.js +2 -2
  178. package/dist/tag-selector.js +1 -1
  179. package/dist/text-style.js +4 -3
  180. package/dist/text-style.js.map +1 -1
  181. package/dist/usage.js +8 -3
  182. package/dist/usage.js.map +1 -1
  183. package/dist/versus-card.js +1 -1
  184. package/dist/versus-card.js.map +1 -1
  185. package/dist/vertical-video.js +1 -1
  186. package/dist/vertical-video.js.map +1 -1
  187. package/dist/wall.d.ts +4 -4
  188. package/dist/wall.js +1 -1
  189. package/dist/wall.js.map +1 -1
  190. package/package.json +5 -5
  191. package/registry/account-menu.json +1 -1
  192. package/registry/account-settings.json +2 -2
  193. package/registry/agenda.json +1 -1
  194. package/registry/analysis-report.json +2 -2
  195. package/registry/app-frame.json +3 -3
  196. package/registry/app-header.json +1 -1
  197. package/registry/avatar.json +1 -1
  198. package/registry/badge.json +2 -2
  199. package/registry/bird-plate.json +1 -1
  200. package/registry/chapter.json +1 -1
  201. package/registry/chip.json +1 -1
  202. package/registry/copy-button.json +1 -1
  203. package/registry/data-table.json +1 -1
  204. package/registry/desktop-window.json +1 -1
  205. package/registry/drop-overlay.json +1 -1
  206. package/registry/elephant.json +1 -1
  207. package/registry/embed-facade.json +2 -2
  208. package/registry/engine-flow.json +2 -2
  209. package/registry/entity-header.json +1 -1
  210. package/registry/file-upload.json +1 -1
  211. package/registry/filter-bar.json +1 -1
  212. package/registry/flock.json +2 -2
  213. package/registry/form.json +7 -7
  214. package/registry/glossary-term.json +1 -1
  215. package/registry/glossary.json +1 -1
  216. package/registry/index.json +7 -7
  217. package/registry/kind-config-editor.json +1 -1
  218. package/registry/kpi-explained.json +1 -1
  219. package/registry/map.json +4 -4
  220. package/registry/mascot-state.json +1 -1
  221. package/registry/mascots.json +2 -2
  222. package/registry/nav-bar.json +4 -4
  223. package/registry/next-actions.json +1 -1
  224. package/registry/notification-preferences.json +1 -1
  225. package/registry/page-index.json +1 -1
  226. package/registry/page.json +1 -1
  227. package/registry/promo-code-field.json +1 -1
  228. package/registry/qr-code.json +2 -2
  229. package/registry/rail-nav.json +3 -3
  230. package/registry/retro-tv.json +1 -1
  231. package/registry/reviews.json +1 -1
  232. package/registry/router.json +1 -1
  233. package/registry/service-card.json +1 -1
  234. package/registry/settings-layout.json +1 -1
  235. package/registry/shop-composer.json +7 -7
  236. package/registry/shop-gallery.json +1 -1
  237. package/registry/shop.json +11 -11
  238. package/registry/signature.json +1 -1
  239. package/registry/site-cahier.json +1 -1
  240. package/registry/site-footer.json +3 -3
  241. package/registry/slot-picker.json +1 -1
  242. package/registry/stat.json +1 -1
  243. package/registry/status-chip.json +1 -1
  244. package/registry/tabs.json +1 -1
  245. package/registry/text-style.json +1 -1
  246. package/registry/usage.json +2 -2
  247. package/registry/versus-card.json +1 -1
  248. package/registry/vertical-video.json +1 -1
  249. package/registry/wall.json +5 -5
  250. package/registry/waveform.json +2 -2
  251. package/dist/chunk-BCD2CRFG.js.map +0 -1
  252. package/dist/chunk-CDNOT2KR.js.map +0 -1
  253. package/dist/chunk-FM42KOAU.js.map +0 -1
  254. package/dist/chunk-MTVX4RRF.js.map +0 -1
  255. package/dist/chunk-UIP3WX5O.js.map +0 -1
  256. package/dist/chunk-VUD4IEVJ.js.map +0 -1
  257. package/dist/chunk-ZFR6ZNXD.js.map +0 -1
  258. package/dist/lightbox-Q45BZ3HW.js.map +0 -1
  259. /package/dist/{chunk-YXETEQQJ.js.map → chunk-SG2RKUVJ.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cx.ts","../src/text-style/text-style.ts","../src/text-style/styled-text.tsx","../src/text-style/text-style-picker.tsx"],"sourcesContent":["/** Joins class names, skipping the falsy ones. */\nexport function cx(...parts: Array<string | false | null | undefined>): string {\n return parts.filter(Boolean).join(\" \");\n}\n","// Server-safe (no hook, no React): the value of a text style, its validation and its CSS. A shop owner's choice is stored\n// by the app, so the value is plain data and its CSS is built from fixed tables of CSS variables — what comes from a\n// database never reaches a style sheet as text. The fonts are the curated roles of @krizaka/fonts (the product theme\n// says which family a role is), the sizes are the type scale's steps, the tones are the text roles and the brand hue.\nimport type { CSSProperties } from \"react\";\nimport * as z from \"zod/mini\";\n\n/** The curated families of `@krizaka/fonts`, by role: `display` (the headlines), `text` (reading), `mono` (the typewriter), `cahier` (the pen). */\nexport const fontIds = [\"display\", \"text\", \"mono\", \"cahier\"] as const;\nexport type FontId = (typeof fontIds)[number];\n\n/** The steps of the type scale, smallest to largest. Never pixels. */\nexport const sizeSteps = [\"xs\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\", \"3xl\", \"4xl\"] as const;\nexport type SizeStep = (typeof sizeSteps)[number];\n\nexport const textWeights = [400, 500, 600, 700] as const;\nexport type TextWeight = (typeof textWeights)[number];\n\nexport const leadings = [\"tight\", \"normal\", \"relaxed\"] as const;\nexport type Leading = (typeof leadings)[number];\n\nexport const trackings = [\"tight\", \"normal\", \"wide\"] as const;\nexport type Tracking = (typeof trackings)[number];\n\nexport const aligns = [\"start\", \"center\", \"end\"] as const;\nexport type Align = (typeof aligns)[number];\n\nexport const cases = [\"none\", \"upper\", \"small-caps\"] as const;\nexport type Case = (typeof cases)[number];\n\n/** The text roles of the tokens, and the brand hue. */\nexport const toneIds = [\"primary\", \"secondary\", \"muted\", \"accent\"] as const;\nexport type ToneId = (typeof toneIds)[number];\n\n/** A text style: what a shop owner chooses, stored as it is. */\nexport type TextStyle = {\n font: FontId;\n size: SizeStep;\n weight: TextWeight;\n leading: Leading;\n tracking: Tracking;\n align: Align;\n case: Case;\n italic: boolean;\n tone: ToneId;\n};\n\n/** What `parseTextStyle` answers for anything that is not a text style. */\nexport const defaultTextStyle: Readonly<TextStyle> = Object.freeze({\n font: \"text\",\n size: \"md\",\n weight: 400,\n leading: \"normal\",\n tracking: \"normal\",\n align: \"start\",\n case: \"none\",\n italic: false,\n tone: \"primary\",\n});\n\n/** The weights each face is cut in: a picker offers these, never a synthesised bold. */\nexport const fontWeights: Readonly<Record<FontId, readonly TextWeight[]>> = {\n display: [400],\n text: [400, 600, 700],\n mono: [400, 700],\n cahier: [500],\n};\n\nconst schema = z.object({\n font: z.enum(fontIds),\n size: z.enum(sizeSteps),\n weight: z.union([z.literal(400), z.literal(500), z.literal(600), z.literal(700)]),\n leading: z.enum(leadings),\n tracking: z.enum(trackings),\n align: z.enum(aligns),\n case: z.enum(cases),\n italic: z.boolean(),\n tone: z.enum(toneIds),\n});\n\n/**\n * Validates what was stored (or sent): the text style, or `defaultTextStyle` for anything invalid — a free font name, a\n * hex colour, a pixel size, CSS text, a value that is not an object. Keys a text style does not have are dropped; keys it\n * lacks (a value stored before one was added) take their default. Usable on a server.\n */\nexport function parseTextStyle(input: unknown): TextStyle {\n if (typeof input !== \"object\" || input === null || Array.isArray(input)) return { ...defaultTextStyle };\n const own = Object.fromEntries(Object.entries(input).filter(([, v]) => v !== undefined));\n const parsed = schema.safeParse({ ...defaultTextStyle, ...own });\n return parsed.success ? { ...parsed.data } : { ...defaultTextStyle };\n}\n\nconst rem: Record<SizeStep, string> = { xs: \"0.75rem\", sm: \"0.875rem\", md: \"1rem\", lg: \"1.125rem\", xl: \"1.25rem\", \"2xl\": \"1.5rem\", \"3xl\": \"1.875rem\", \"4xl\": \"2.25rem\" };\nconst lineHeight: Record<Leading, string> = { tight: \"1.15\", normal: \"1.4\", relaxed: \"1.7\" };\nconst letterSpacing: Record<Tracking, string> = { tight: \"-0.02em\", normal: \"0em\", wide: \"0.08em\" };\nconst textAlign: Record<Align, CSSProperties[\"textAlign\"]> = { start: \"start\", center: \"center\", end: \"end\" };\nconst tone: Record<ToneId, string> = {\n primary: \"var(--kz-text-primary)\",\n secondary: \"var(--kz-text-secondary)\",\n muted: \"var(--kz-text-muted)\",\n accent: \"var(--kz-accent-text)\",\n};\n\n/** The CSS variable of a text role: the product theme's face for `display`, the preset's for the others. */\nexport const fontVariable: Readonly<Record<FontId, string>> = {\n display: \"var(--kz-font-display)\",\n text: \"var(--kz-font-text)\",\n mono: \"var(--kz-font-mono)\",\n cahier: \"var(--kz-font-cahier)\",\n};\n\n/** A step's size as a CSS value: `var(--kz-text-style-<step>, <rem>)` — a product may re-cut the scale with the variable. */\nexport const sizeVariable = (step: SizeStep): string => `var(--kz-text-style-${step}, ${rem[step]})`;\n\n/** A tone's colour as a CSS value: a role of the tokens. */\nexport const toneVariable = (id: ToneId): string => tone[id];\n\n/** The `className` and `style` that draw a text style. Built from fixed tables of CSS variables only. */\nexport function textStyleProps(style: unknown): { className: string; style: CSSProperties } {\n const v = parseTextStyle(style);\n return {\n className: \"kz-text-style\",\n style: {\n fontFamily: fontVariable[v.font],\n fontSize: sizeVariable(v.size),\n fontWeight: v.weight,\n lineHeight: `var(--kz-text-style-leading-${v.leading}, ${lineHeight[v.leading]})`,\n letterSpacing: `var(--kz-text-style-tracking-${v.tracking}, ${letterSpacing[v.tracking]})`,\n textAlign: textAlign[v.align],\n textTransform: v.case === \"upper\" ? \"uppercase\" : \"none\",\n fontVariantCaps: v.case === \"small-caps\" ? \"small-caps\" : \"normal\",\n fontStyle: v.italic ? \"italic\" : \"normal\",\n color: toneVariable(v.tone),\n },\n };\n}\n\n/** A colour read from the page, as `[r, g, b]` in 0–255, or `null` when it cannot be read (the check then says nothing). */\nexport function parseColor(text: string): [number, number, number] | null {\n const value = text.trim().toLowerCase();\n const hex = /^#([0-9a-f]{3,8})$/.exec(value)?.[1];\n if (hex && [3, 4, 6, 8].includes(hex.length)) {\n const full = hex.length <= 4 ? [...hex].map((c) => c + c).join(\"\") : hex;\n return [0, 2, 4].map((i) => Number.parseInt(full.slice(i, i + 2), 16)) as [number, number, number];\n }\n const rgb = /^rgba?\\(([^)]+)\\)$/.exec(value)?.[1];\n if (rgb) {\n const parts = rgb.split(/[\\s,/]+/).filter(Boolean).slice(0, 3).map((p) => (p.endsWith(\"%\") ? (Number.parseFloat(p) / 100) * 255 : Number.parseFloat(p)));\n return parts.length === 3 && parts.every(Number.isFinite) ? (parts as [number, number, number]) : null;\n }\n const srgb = /^color\\(srgb\\s+([^)]+)\\)$/.exec(value)?.[1];\n if (srgb) {\n const parts = srgb.split(/[\\s/]+/).filter(Boolean).slice(0, 3).map((p) => Number.parseFloat(p) * 255);\n return parts.length === 3 && parts.every(Number.isFinite) ? (parts as [number, number, number]) : null;\n }\n return null;\n}\n\nconst channel = (c: number) => {\n const s = Math.min(Math.max(c, 0), 255) / 255;\n return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;\n};\nconst luminance = ([r, g, b]: [number, number, number]) => 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);\n\n/** The WCAG contrast ratio of two colours (1 – 21). */\nexport function contrastRatio(foreground: [number, number, number], background: [number, number, number]): number {\n const a = luminance(foreground);\n const b = luminance(background);\n return (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);\n}\n\n/** The ratio WCAG asks of large text. */\nexport const largeTextRatio = 3;\n/** The ratio WCAG asks of body text. */\nexport const bodyTextRatio = 4.5;\n\n/** Large text for WCAG: 24 px and over, or bold from 18.66 px (`xl`, 20 px, in bold). */\nexport function isLargeText(style: Pick<TextStyle, \"size\" | \"weight\">): boolean {\n const at = sizeSteps.indexOf(style.size);\n return at >= sizeSteps.indexOf(\"2xl\") || (at >= sizeSteps.indexOf(\"xl\") && style.weight >= 700);\n}\n\n/** The ratio a style's text must reach on its surface. */\nexport const requiredContrast = (style: Pick<TextStyle, \"size\" | \"weight\">): number => (isLargeText(style) ? largeTextRatio : bodyTextRatio);\n\n/** True when body text in this step is under the minimum: a warning to show, never a size to force. */\nexport const isUnderMinimumSize = (size: SizeStep, minimum: SizeStep): boolean => sizeSteps.indexOf(size) < sizeSteps.indexOf(minimum);\n","// Server-safe: a text drawn with a stored text style. Whatever is passed as `value` goes through `parseTextStyle`.\nimport * as React from \"react\";\n\nimport { cx } from \"../cx\";\nimport { textStyleProps } from \"./text-style\";\n\nexport type StyledTextProps<T extends React.ElementType = \"p\"> = {\n /** The element drawn: `h1`…`h6`, `p`, `span`, `div`. */\n as?: T;\n /** The stored text style — validated here: anything invalid draws the default. */\n value?: unknown;\n /** Merged after the style's own class. */\n className?: string;\n children?: React.ReactNode;\n} & Omit<React.ComponentPropsWithoutRef<T>, \"as\" | \"value\" | \"className\" | \"style\" | \"children\">;\n\n/** A text role drawn from a `TextStyle`: its font, size, weight, spacing, alignment, case and tone, all from CSS variables. */\nexport function StyledText<T extends React.ElementType = \"p\">({ as, value, className, children, ...rest }: StyledTextProps<T>) {\n const Tag: React.ElementType = as ?? \"p\";\n const props = textStyleProps(value);\n return (\n <Tag {...rest} className={cx(props.className, className)} style={props.style}>\n {children}\n </Tag>\n );\n}\n","// Client (state, an observer). A control for the look of one text role — font, size, weight, spacing, alignment, case,\n// italic, tone — over the primitives: the font as a radio group whose options are drawn in their own face, the size as\n// a step slider, the choices as segmented radio groups, italic as a switch, the tone as swatches. It is controlled, shows\n// a live preview, and warns (never clamps) when the tone lacks contrast on the surface or body text is too small.\nimport { Button } from \"@krizaka/ui/button\";\nimport { RadioGroup } from \"@krizaka/ui/radio-group\";\nimport { Slider } from \"@krizaka/ui/slider\";\nimport { Switch } from \"@krizaka/ui/switch\";\nimport { RadioGroup as RadioGroupPrimitive } from \"radix-ui\";\nimport * as React from \"react\";\n\nimport { cx } from \"../cx\";\nimport { StyledText } from \"./styled-text\";\nimport {\n type Align,\n aligns,\n type Case,\n cases,\n contrastRatio,\n type FontId,\n fontIds,\n fontVariable,\n fontWeights,\n isUnderMinimumSize,\n type Leading,\n leadings,\n parseColor,\n parseTextStyle,\n type SizeStep,\n sizeSteps,\n type TextStyle,\n type TextWeight,\n textWeights,\n type ToneId,\n toneIds,\n toneVariable,\n type Tracking,\n trackings,\n} from \"./text-style\";\n\n/** The controls of the picker, in the order they are drawn. */\nexport const textStyleFields = [\"font\", \"size\", \"weight\", \"leading\", \"tracking\", \"align\", \"case\", \"italic\", \"tone\"] as const;\nexport type TextStyleField = (typeof textStyleFields)[number];\n\nexport type TextStyleLabels = {\n /** The name of the whole control. */\n picker: string;\n font: string;\n size: string;\n weight: string;\n leading: string;\n tracking: string;\n align: string;\n case: string;\n italic: string;\n tone: string;\n presets: string;\n preview: string;\n fonts: Record<FontId, string>;\n weights: Record<TextWeight, string>;\n leadings: Record<Leading, string>;\n trackings: Record<Tracking, string>;\n aligns: Record<Align, string>;\n cases: Record<Case, string>;\n tones: Record<ToneId, string>;\n /** The contrast warning: `{ratio}` is what the tone reaches, `{min}` what it must. */\n contrastWarning: string;\n /** The small-text warning: `{size}` is the smallest step advised for body text. */\n minSizeWarning: string;\n};\n\n/** The English words. */\nexport const textStyleLabels: TextStyleLabels = {\n picker: \"Text style\",\n font: \"Font\",\n size: \"Size\",\n weight: \"Weight\",\n leading: \"Line height\",\n tracking: \"Letter spacing\",\n align: \"Alignment\",\n case: \"Case\",\n italic: \"Italic\",\n tone: \"Colour\",\n presets: \"Presets\",\n preview: \"Preview\",\n fonts: { display: \"Display\", text: \"Text\", mono: \"Typewriter\", cahier: \"Pen\" },\n weights: { 400: \"Regular\", 500: \"Medium\", 600: \"Semibold\", 700: \"Bold\" },\n leadings: { tight: \"Tight\", normal: \"Normal\", relaxed: \"Relaxed\" },\n trackings: { tight: \"Tight\", normal: \"Normal\", wide: \"Wide\" },\n aligns: { start: \"Start\", center: \"Centre\", end: \"End\" },\n cases: { none: \"Aa\", upper: \"AA\", \"small-caps\": \"Small caps\" },\n tones: { primary: \"Primary\", secondary: \"Secondary\", muted: \"Muted\", accent: \"Accent\" },\n contrastWarning: \"This colour reaches only {ratio}:1 on the background; {min}:1 is needed to read it comfortably.\",\n minSizeWarning: \"Body text under “{size}” is hard to read.\",\n};\n\n/** The French words. */\nexport const textStyleLabelsFr: TextStyleLabels = {\n picker: \"Style du texte\",\n font: \"Police\",\n size: \"Taille\",\n weight: \"Graisse\",\n leading: \"Interligne\",\n tracking: \"Espacement des lettres\",\n align: \"Alignement\",\n case: \"Casse\",\n italic: \"Italique\",\n tone: \"Couleur\",\n presets: \"Préréglages\",\n preview: \"Aperçu\",\n fonts: { display: \"Titre\", text: \"Texte\", mono: \"Machine à écrire\", cahier: \"Stylo\" },\n weights: { 400: \"Normal\", 500: \"Moyen\", 600: \"Demi-gras\", 700: \"Gras\" },\n leadings: { tight: \"Serré\", normal: \"Normal\", relaxed: \"Aéré\" },\n trackings: { tight: \"Serré\", normal: \"Normal\", wide: \"Large\" },\n aligns: { start: \"Début\", center: \"Centré\", end: \"Fin\" },\n cases: { none: \"Aa\", upper: \"AA\", \"small-caps\": \"Petites capitales\" },\n tones: { primary: \"Principale\", secondary: \"Secondaire\", muted: \"Discrète\", accent: \"Accent\" },\n contrastWarning: \"Cette couleur n’atteint que {ratio}:1 sur le fond ; {min}:1 est nécessaire pour la lire confortablement.\",\n minSizeWarning: \"Un texte courant sous « {size} » se lit mal.\",\n};\n\nexport type TextStylePreset = {\n /** A stable key. */\n id: string;\n /** The name on the button, passed translated (« Titre », « Prix »…). */\n label: string;\n /** The style it applies; what it does not say takes the default. Validated when applied. */\n value: Partial<TextStyle>;\n};\n\nexport type TextStylePickerProps = {\n /** The text style, controlled. Validated by `parseTextStyle`: anything invalid shows the default. */\n value: TextStyle;\n /** Called with the whole new text style at each change. */\n onChange: (value: TextStyle) => void;\n /** The sample the preview shows, passed translated (\"Boulangerie Martin\"). */\n previewText: string;\n /** Styles the person can start from, as data. */\n presets?: readonly TextStylePreset[];\n /** The controls to show, in the order of `textStyleFields` (just `[\"font\", \"size\"]`). A preset then changes only these. */\n fields?: readonly TextStyleField[];\n /** A denser form for a popover from a toolbar. */\n compact?: boolean;\n /** The words, passed translated: `textStyleLabels` (EN) or `textStyleLabelsFr`, or the host's own. */\n labels?: Partial<TextStyleLabels>;\n /** The colour the text will sit on, for the preview and the contrast check (a CSS colour). By default the page's own surface. */\n surface?: string;\n /**\n * What the text is for: `body` (reading text, which `minBodySize` guards) or `title` (a heading, which may be small).\n * @default \"body\"\n */\n role?: \"body\" | \"title\";\n /**\n * The smallest step advised for body text: under it, a warning shows — the size is never forced.\n * @default \"sm\"\n */\n minBodySize?: SizeStep;\n /** Merged last on the root. */\n className?: string;\n};\n\ntype Rgb = [number, number, number];\ntype Rgba = [number, number, number, number];\n\nfunction parseColorWithAlpha(text: string): Rgba | null {\n const value = text.trim().toLowerCase();\n if (value === \"transparent\") return [0, 0, 0, 0];\n const color = parseColor(value);\n if (!color) return null;\n\n const hex = /^#([0-9a-f]{4}|[0-9a-f]{8})$/.exec(value)?.[1];\n if (hex) {\n const alpha = hex.length === 4 ? Number.parseInt(hex[3]! + hex[3]!, 16) : Number.parseInt(hex.slice(6, 8), 16);\n return [...color, alpha / 255];\n }\n\n const components =\n /^rgba?\\(([^)]+)\\)$/.exec(value)?.[1] ??\n /^color\\(srgb\\s+([^)]+)\\)$/.exec(value)?.[1];\n if (!components) return [...color, 1];\n\n const [channels, slashAlpha] = components.split(\"/\");\n const parts = channels!.trim().split(/[\\s,]+/).filter(Boolean);\n const alpha = slashAlpha?.trim() ?? (parts.length === 4 ? parts[3] : undefined);\n if (alpha === undefined) return [...color, 1];\n const parsed = alpha.endsWith(\"%\") ? Number.parseFloat(alpha) / 100 : Number.parseFloat(alpha);\n return Number.isFinite(parsed) && parsed >= 0 && parsed <= 1 ? [...color, parsed] : null;\n}\n\nconst over = (foreground: Rgba, background: Rgba): Rgba => {\n const alpha = foreground[3] + background[3] * (1 - foreground[3]);\n if (alpha === 0) return [0, 0, 0, 0];\n return [\n (foreground[0] * foreground[3] + background[0] * background[3] * (1 - foreground[3])) / alpha,\n (foreground[1] * foreground[3] + background[1] * background[3] * (1 - foreground[3])) / alpha,\n (foreground[2] * foreground[3] + background[2] * background[3] * (1 - foreground[3])) / alpha,\n alpha,\n ];\n};\n\n/** The composited colour behind an element, or null when a background layer cannot be read. */\nfunction surfaceOf(element: HTMLElement): Rgb | null {\n const layers: HTMLElement[] = [];\n for (let node: HTMLElement | null = element; node; node = node.parentElement) {\n layers.push(node);\n if (node === document.documentElement) break;\n }\n let background: Rgba = [0, 0, 0, 0];\n for (const node of layers.reverse()) {\n const color = window.getComputedStyle(node).backgroundColor;\n const layer: Rgba | null = color ? parseColorWithAlpha(color) : [0, 0, 0, 0];\n if (!layer) return null;\n background = over(layer, background);\n }\n return background[3] >= 1 ? [background[0], background[1], background[2]] : null;\n}\n\n/** What the tone reaches on its surface, measured on the preview as it is drawn (the theme and the product's tokens included). */\nfunction useContrast(ref: React.RefObject<HTMLElement | null>, key: string): { ratio: number; required: number } | null {\n const [measurement, setMeasurement] = React.useState<{ ratio: number; required: number } | null>(null);\n React.useEffect(() => {\n const element = ref.current;\n if (!element) return;\n const measure = () => {\n const sample = element.querySelector<HTMLElement>(\"[data-text-style-sample]\") ?? element;\n const computed = window.getComputedStyle(sample);\n const foreground = parseColor(computed.color);\n const background = surfaceOf(sample);\n const fontSize = Number.parseFloat(computed.fontSize);\n const fontWeight = Number.parseFloat(computed.fontWeight);\n const required = fontSize >= 24 || (fontSize >= 18.66 && fontWeight >= 700) ? 3 : 4.5;\n setMeasurement(foreground && background && Number.isFinite(fontSize) && Number.isFinite(fontWeight) ? { ratio: contrastRatio(foreground, background), required } : null);\n };\n measure();\n if (typeof MutationObserver === \"undefined\") return;\n const observer = new MutationObserver(measure);\n for (let node: HTMLElement | null = element; node; node = node.parentElement) {\n observer.observe(node, { attributes: true, attributeFilter: [\"class\", \"style\", \"data-theme\"] });\n if (node === document.documentElement) break;\n }\n return () => observer.disconnect();\n }, [ref, key]);\n return measurement;\n}\n\nconst nearest = (weights: readonly TextWeight[], weight: TextWeight): TextWeight =>\n weights.reduce((best, w) => (Math.abs(w - weight) < Math.abs(best - weight) ? w : best), weights[0]!);\n\n/** The control of a text style: font, size, weight, spacing, alignment, case, italic and tone, with a live preview. */\nexport function TextStylePicker({\n value,\n onChange,\n previewText,\n presets,\n fields = textStyleFields,\n compact,\n labels: given,\n surface,\n role = \"body\",\n minBodySize = \"sm\",\n className,\n}: TextStylePickerProps) {\n const labels = { ...textStyleLabels, ...given };\n const style = parseTextStyle(value);\n const shown = (field: TextStyleField) => fields.includes(field);\n const id = React.useId();\n const previewRef = React.useRef<HTMLDivElement>(null);\n const measurement = useContrast(previewRef, `${style.font}|${style.size}|${style.weight}|${style.tone}|${surface ?? \"\"}`);\n\n const set = (patch: Partial<TextStyle>) => onChange(parseTextStyle({ ...style, ...patch }));\n const setFont = (font: FontId) => set({ font, weight: nearest(fontWeights[font], style.weight) });\n const applyPreset = (preset: TextStylePreset) => {\n const next = parseTextStyle(preset.value);\n const patch = Object.fromEntries(textStyleFields.filter(shown).map((f) => [f, next[f]])) as Partial<TextStyle>;\n if (patch.font !== undefined || patch.weight !== undefined) {\n const font = patch.font ?? style.font;\n const weight = patch.weight ?? style.weight;\n set({ ...patch, weight: nearest(fontWeights[font], weight) });\n } else {\n set(patch);\n }\n };\n\n const warnings: string[] = [];\n if (measurement && measurement.ratio < measurement.required) {\n warnings.push(labels.contrastWarning.replace(\"{ratio}\", measurement.ratio.toFixed(1)).replace(\"{min}\", String(measurement.required)));\n }\n if (role === \"body\" && isUnderMinimumSize(style.size, minBodySize)) warnings.push(labels.minSizeWarning.replace(\"{size}\", minBodySize));\n\n const group = (field: TextStyleField, title: string, control: React.ReactNode, className?: string) => (\n <div key={field} className={cx(\"flex min-w-0 flex-col gap-2\", className)} data-field={field}>\n <span id={`${id}-${field}`} className=\"text-xs font-semibold text-fg-secondary\">\n {title}\n </span>\n {control}\n </div>\n );\n const segmented = <T extends string | number>(field: TextStyleField, title: string, items: readonly T[], current: T, text: (item: T) => string, choose: (item: T) => void, disabled?: (item: T) => boolean) =>\n group(\n field,\n title,\n <RadioGroup.Root variant=\"segmented\" aria-labelledby={`${id}-${field}`} value={String(current)} onValueChange={(next) => choose(items.find((item) => String(item) === next)!)} className=\"w-full max-w-full\">\n {items.map((item) => (\n <RadioGroup.Segment key={item} value={String(item)} disabled={disabled?.(item)} className=\"min-w-0 px-1 text-xs\">\n {text(item)}\n </RadioGroup.Segment>\n ))}\n </RadioGroup.Root>,\n \"sm:col-span-2\",\n );\n\n const controls: Record<TextStyleField, () => React.ReactNode> = {\n font: () =>\n group(\n \"font\",\n labels.font,\n <RadioGroup.Root variant=\"cards\" aria-labelledby={`${id}-font`} value={style.font} onValueChange={(next) => setFont(next as FontId)} className=\"grid-cols-[repeat(auto-fit,minmax(9rem,1fr))]\">\n {fontIds.map((font) => (\n <RadioGroup.Card key={font} value={font} style={{ fontFamily: fontVariable[font] }}>\n {labels.fonts[font]}\n </RadioGroup.Card>\n ))}\n </RadioGroup.Root>,\n ),\n size: () =>\n group(\n \"size\",\n labels.size,\n <Slider\n label={labels.size}\n min={0}\n max={sizeSteps.length - 1}\n step={1}\n ticks\n value={sizeSteps.indexOf(style.size)}\n onValueChange={(index) => set({ size: sizeSteps[index]! })}\n formatValue={(index) => sizeSteps[index]!}\n floatingValue\n />,\n ),\n weight: () => segmented(\"weight\", labels.weight, textWeights, style.weight, (w) => labels.weights[w], (weight) => set({ weight }), (w) => !fontWeights[style.font].includes(w)),\n leading: () => segmented(\"leading\", labels.leading, leadings, style.leading, (l) => labels.leadings[l], (leading) => set({ leading })),\n tracking: () => segmented(\"tracking\", labels.tracking, trackings, style.tracking, (t) => labels.trackings[t], (tracking) => set({ tracking })),\n align: () => segmented(\"align\", labels.align, aligns, style.align, (a) => labels.aligns[a], (align) => set({ align })),\n case: () => segmented(\"case\", labels.case, cases, style.case, (c) => labels.cases[c], (next) => set({ case: next })),\n italic: () => (\n <div key=\"italic\" className=\"flex min-w-0 items-center justify-between gap-3\" data-field=\"italic\">\n <span id={`${id}-italic`} className=\"text-xs font-semibold text-fg-secondary\">\n {labels.italic}\n </span>\n <Switch aria-labelledby={`${id}-italic`} checked={style.italic} onCheckedChange={(italic) => set({ italic })} />\n </div>\n ),\n tone: () =>\n group(\n \"tone\",\n labels.tone,\n <RadioGroupPrimitive.Root aria-labelledby={`${id}-tone`} value={style.tone} onValueChange={(next) => set({ tone: next as ToneId })} orientation=\"horizontal\" className=\"flex flex-wrap gap-3\">\n {toneIds.map((tone) => (\n <RadioGroupPrimitive.Item\n key={tone}\n value={tone}\n aria-label={labels.tones[tone]}\n title={labels.tones[tone]}\n style={{ backgroundColor: toneVariable(tone) }}\n className=\"h-8 w-8 rounded-full border border-border-strong focus-visible:outline-hidden focus-visible:focus-ring data-[state=checked]:ring-2 data-[state=checked]:ring-accent data-[state=checked]:ring-offset-2 data-[state=checked]:ring-offset-surface-0\"\n />\n ))}\n </RadioGroupPrimitive.Root>,\n ),\n };\n\n return (\n <div role=\"group\" aria-label={labels.picker} data-compact={compact ? \"\" : undefined} className={cx(\"flex min-w-0 flex-col\", compact ? \"gap-3\" : \"gap-5\", className)}>\n <div\n ref={previewRef}\n data-preview=\"\"\n aria-label={labels.preview}\n role=\"group\"\n style={surface ? { backgroundColor: surface } : undefined}\n className={cx(\"min-w-0 overflow-hidden rounded-xl border border-border-default\", surface ? \"\" : \"bg-surface-1\", compact ? \"p-3\" : \"p-5\")}\n >\n <StyledText as=\"p\" value={style} className=\"break-words\" data-text-style-sample=\"\">\n {previewText}\n </StyledText>\n </div>\n <div role=\"status\" aria-live=\"polite\" data-warnings=\"\">\n {warnings.map((warning) => (\n <p key={warning} className=\"text-xs font-medium text-fg-warning\">\n {warning}\n </p>\n ))}\n </div>\n {presets?.length ? (\n <div role=\"group\" aria-label={labels.presets} className=\"flex flex-wrap gap-2\">\n {presets.map((preset) => (\n <Button key={preset.id} type=\"button\" size=\"sm\" variant=\"outline\" onClick={() => applyPreset(preset)}>\n {preset.label}\n </Button>\n ))}\n </div>\n ) : null}\n <div className={cx(\"grid grid-cols-1 gap-x-6\", compact ? \"gap-y-3\" : \"gap-y-5 sm:grid-cols-2\")}>\n {textStyleFields.filter(shown).map((field) => (\n <React.Fragment key={field}>{controls[field]()}</React.Fragment>\n ))}\n </div>\n </div>\n );\n}\n"],"mappings":";;;AACO,SAAS,MAAM,OAAyD;AAC7E,SAAO,MAAM,OAAO,OAAO,EAAE,KAAK,GAAG;AACvC;;;ACEA,YAAY,OAAO;AAGZ,IAAM,UAAU,CAAC,WAAW,QAAQ,QAAQ,QAAQ;AAIpD,IAAM,YAAY,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM,OAAO,OAAO,KAAK;AAGpE,IAAM,cAAc,CAAC,KAAK,KAAK,KAAK,GAAG;AAGvC,IAAM,WAAW,CAAC,SAAS,UAAU,SAAS;AAG9C,IAAM,YAAY,CAAC,SAAS,UAAU,MAAM;AAG5C,IAAM,SAAS,CAAC,SAAS,UAAU,KAAK;AAGxC,IAAM,QAAQ,CAAC,QAAQ,SAAS,YAAY;AAI5C,IAAM,UAAU,CAAC,WAAW,aAAa,SAAS,QAAQ;AAiB1D,IAAM,mBAAwC,OAAO,OAAO;AAAA,EACjE,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AACR,CAAC;AAGM,IAAM,cAA+D;AAAA,EAC1E,SAAS,CAAC,GAAG;AAAA,EACb,MAAM,CAAC,KAAK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AS,KAAK,EAAE,KAAxB,KAA0B,CAChD,GACH;AAAA,KACF;AAEJ;","names":["jsx","alpha","className","tone"]}
1
+ {"version":3,"sources":["../src/cx.ts","../src/text-style/text-style.ts","../src/text-style/styled-text.tsx","../src/text-style/text-style-picker.tsx"],"sourcesContent":["/** Joins class names, skipping the falsy ones. */\nexport function cx(...parts: Array<string | false | null | undefined>): string {\n return parts.filter(Boolean).join(\" \");\n}\n","// Server-safe (no hook, no React): the value of a text style, its validation and its CSS. A shop owner's choice is stored\n// by the app, so the value is plain data and its CSS is built from fixed tables of CSS variables — what comes from a\n// database never reaches a style sheet as text. The fonts are the curated roles of @krizaka/fonts (the product theme\n// says which family a role is), the sizes are the type scale's steps, the tones are the text roles and the brand hue.\nimport type { CSSProperties } from \"react\";\nimport * as z from \"zod/mini\";\n\n/** The curated families of `@krizaka/fonts`, by role: `display` (the headlines), `text` (reading), `mono` (the typewriter), `cahier` (the pen). */\nexport const fontIds = [\"display\", \"text\", \"mono\", \"cahier\"] as const;\nexport type FontId = (typeof fontIds)[number];\n\n/** The steps of the type scale, smallest to largest. Never pixels. */\nexport const sizeSteps = [\"xs\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\", \"3xl\", \"4xl\"] as const;\nexport type SizeStep = (typeof sizeSteps)[number];\n\nexport const textWeights = [400, 500, 600, 700] as const;\nexport type TextWeight = (typeof textWeights)[number];\n\nexport const leadings = [\"tight\", \"normal\", \"relaxed\"] as const;\nexport type Leading = (typeof leadings)[number];\n\nexport const trackings = [\"tight\", \"normal\", \"wide\"] as const;\nexport type Tracking = (typeof trackings)[number];\n\nexport const aligns = [\"start\", \"center\", \"end\"] as const;\nexport type Align = (typeof aligns)[number];\n\nexport const cases = [\"none\", \"upper\", \"small-caps\"] as const;\nexport type Case = (typeof cases)[number];\n\n/** The text roles of the tokens, and the brand hue. */\nexport const toneIds = [\"primary\", \"secondary\", \"muted\", \"accent\"] as const;\nexport type ToneId = (typeof toneIds)[number];\n\n/** A text style: what a shop owner chooses, stored as it is. */\nexport type TextStyle = {\n font: FontId;\n size: SizeStep;\n weight: TextWeight;\n leading: Leading;\n tracking: Tracking;\n align: Align;\n case: Case;\n italic: boolean;\n tone: ToneId;\n};\n\n/** What `parseTextStyle` answers for anything that is not a text style. */\nexport const defaultTextStyle: Readonly<TextStyle> = Object.freeze({\n font: \"text\",\n size: \"md\",\n weight: 400,\n leading: \"normal\",\n tracking: \"normal\",\n align: \"start\",\n case: \"none\",\n italic: false,\n tone: \"primary\",\n});\n\n/** The weights each face is cut in: a picker offers these, never a synthesised bold. */\nexport const fontWeights: Readonly<Record<FontId, readonly TextWeight[]>> = {\n display: [400],\n text: [400, 600, 700],\n mono: [400, 700],\n cahier: [500],\n};\n\nconst schema = z.object({\n font: z.enum(fontIds),\n size: z.enum(sizeSteps),\n weight: z.union([z.literal(400), z.literal(500), z.literal(600), z.literal(700)]),\n leading: z.enum(leadings),\n tracking: z.enum(trackings),\n align: z.enum(aligns),\n case: z.enum(cases),\n italic: z.boolean(),\n tone: z.enum(toneIds),\n});\n\n/**\n * Validates what was stored (or sent): the text style, or `defaultTextStyle` for anything invalid — a free font name, a\n * hex colour, a pixel size, CSS text, a value that is not an object. Keys a text style does not have are dropped; keys it\n * lacks (a value stored before one was added) take their default. Usable on a server.\n */\nexport function parseTextStyle(input: unknown): TextStyle {\n if (typeof input !== \"object\" || input === null || Array.isArray(input)) return { ...defaultTextStyle };\n const own = Object.fromEntries(Object.entries(input).filter(([, v]) => v !== undefined));\n const parsed = schema.safeParse({ ...defaultTextStyle, ...own });\n return parsed.success ? { ...parsed.data } : { ...defaultTextStyle };\n}\n\nconst rem: Record<SizeStep, string> = { xs: \"0.75rem\", sm: \"0.875rem\", md: \"1rem\", lg: \"1.125rem\", xl: \"1.25rem\", \"2xl\": \"1.5rem\", \"3xl\": \"1.875rem\", \"4xl\": \"2.25rem\" };\nconst lineHeight: Record<Leading, string> = { tight: \"1.15\", normal: \"1.4\", relaxed: \"1.7\" };\nconst letterSpacing: Record<Tracking, string> = { tight: \"-0.02em\", normal: \"0em\", wide: \"0.08em\" };\nconst textAlign: Record<Align, CSSProperties[\"textAlign\"]> = { start: \"start\", center: \"center\", end: \"end\" };\nconst tone: Record<ToneId, string> = {\n primary: \"var(--kz-text-primary)\",\n secondary: \"var(--kz-text-secondary)\",\n muted: \"var(--kz-text-muted)\",\n accent: \"var(--kz-accent-text)\",\n};\n\n/** The CSS variable of a text role: the product theme's face for `display`, the preset's for the others. */\nexport const fontVariable: Readonly<Record<FontId, string>> = {\n display: \"var(--kz-font-display)\",\n text: \"var(--kz-font-text)\",\n mono: \"var(--kz-font-mono)\",\n cahier: \"var(--kz-font-cahier)\",\n};\n\n/** A step's size as a CSS value: `var(--kz-text-style-<step>, <rem>)` — a product may re-cut the scale with the variable. */\nexport const sizeVariable = (step: SizeStep): string => `var(--kz-text-style-${step}, ${rem[step]})`;\n\n/** A tone's colour as a CSS value: a role of the tokens. */\nexport const toneVariable = (id: ToneId): string => tone[id];\n\n/** The `className` and `style` that draw a text style. Built from fixed tables of CSS variables only. */\nexport function textStyleProps(style: unknown): { className: string; style: CSSProperties } {\n const v = parseTextStyle(style);\n return {\n className: \"kz-text-style\",\n style: {\n fontFamily: fontVariable[v.font],\n fontSize: sizeVariable(v.size),\n fontWeight: v.weight,\n lineHeight: `var(--kz-text-style-leading-${v.leading}, ${lineHeight[v.leading]})`,\n letterSpacing: `var(--kz-text-style-tracking-${v.tracking}, ${letterSpacing[v.tracking]})`,\n textAlign: textAlign[v.align],\n textTransform: v.case === \"upper\" ? \"uppercase\" : \"none\",\n fontVariantCaps: v.case === \"small-caps\" ? \"small-caps\" : \"normal\",\n fontStyle: v.italic ? \"italic\" : \"normal\",\n color: toneVariable(v.tone),\n },\n };\n}\n\n/** A colour read from the page, as `[r, g, b]` in 0–255, or `null` when it cannot be read (the check then says nothing). */\nexport function parseColor(text: string): [number, number, number] | null {\n const value = text.trim().toLowerCase();\n const hex = /^#([0-9a-f]{3,8})$/.exec(value)?.[1];\n if (hex && [3, 4, 6, 8].includes(hex.length)) {\n const full = hex.length <= 4 ? [...hex].map((c) => c + c).join(\"\") : hex;\n return [0, 2, 4].map((i) => Number.parseInt(full.slice(i, i + 2), 16)) as [number, number, number];\n }\n const rgb = /^rgba?\\(([^)]+)\\)$/.exec(value)?.[1];\n if (rgb) {\n const parts = rgb.split(/[\\s,/]+/).filter(Boolean).slice(0, 3).map((p) => (p.endsWith(\"%\") ? (Number.parseFloat(p) / 100) * 255 : Number.parseFloat(p)));\n return parts.length === 3 && parts.every(Number.isFinite) ? (parts as [number, number, number]) : null;\n }\n const srgb = /^color\\(srgb\\s+([^)]+)\\)$/.exec(value)?.[1];\n if (srgb) {\n const parts = srgb.split(/[\\s/]+/).filter(Boolean).slice(0, 3).map((p) => Number.parseFloat(p) * 255);\n return parts.length === 3 && parts.every(Number.isFinite) ? (parts as [number, number, number]) : null;\n }\n return null;\n}\n\nconst channel = (c: number) => {\n const s = Math.min(Math.max(c, 0), 255) / 255;\n return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;\n};\nconst luminance = ([r, g, b]: [number, number, number]) => 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);\n\n/** The WCAG contrast ratio of two colours (1 – 21). */\nexport function contrastRatio(foreground: [number, number, number], background: [number, number, number]): number {\n const a = luminance(foreground);\n const b = luminance(background);\n return (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);\n}\n\n/** The ratio WCAG asks of large text. */\nexport const largeTextRatio = 3;\n/** The ratio WCAG asks of body text. */\nexport const bodyTextRatio = 4.5;\n\n/** Large text for WCAG: 24 px and over, or bold from 18.66 px (`xl`, 20 px, in bold). */\nexport function isLargeText(style: Pick<TextStyle, \"size\" | \"weight\">): boolean {\n const at = sizeSteps.indexOf(style.size);\n return at >= sizeSteps.indexOf(\"2xl\") || (at >= sizeSteps.indexOf(\"xl\") && style.weight >= 700);\n}\n\n/** The ratio a style's text must reach on its surface. */\nexport const requiredContrast = (style: Pick<TextStyle, \"size\" | \"weight\">): number => (isLargeText(style) ? largeTextRatio : bodyTextRatio);\n\n/** True when body text in this step is under the minimum: a warning to show, never a size to force. */\nexport const isUnderMinimumSize = (size: SizeStep, minimum: SizeStep): boolean => sizeSteps.indexOf(size) < sizeSteps.indexOf(minimum);\n","// Server-safe: a text drawn with a stored text style. Whatever is passed as `value` goes through `parseTextStyle`.\nimport * as React from \"react\";\n\nimport { cx } from \"../cx\";\nimport { textStyleProps } from \"./text-style\";\n\nexport type StyledTextProps<T extends React.ElementType = \"p\"> = {\n /** The element drawn: `h1`…`h6`, `p`, `span`, `div`. */\n as?: T;\n /** The stored text style — validated here: anything invalid draws the default. */\n value?: unknown;\n /** Merged after the style's own class. */\n className?: string;\n children?: React.ReactNode;\n} & Omit<React.ComponentPropsWithoutRef<T>, \"as\" | \"value\" | \"className\" | \"style\" | \"children\">;\n\n/** A text role drawn from a `TextStyle`: its font, size, weight, spacing, alignment, case and tone, all from CSS variables. */\nexport function StyledText<T extends React.ElementType = \"p\">({ as, value, className, children, ...rest }: StyledTextProps<T>) {\n const Tag: React.ElementType = as ?? \"p\";\n const props = textStyleProps(value);\n return (\n <Tag {...rest} className={cx(props.className, className)} style={props.style}>\n {children}\n </Tag>\n );\n}\n","// Client (state, an observer). A control for the look of one text role — font, size, weight, spacing, alignment, case,\n// italic, tone — over the primitives: the font as a radio group whose options are drawn in their own face, the size as\n// a step slider, the choices as segmented radio groups, italic as a switch, the tone as swatches. It is controlled, shows\n// a live preview, and warns (never clamps) when the tone lacks contrast on the surface or body text is too small.\nimport { Button } from \"@krizaka/ui/button\";\nimport { RadioGroup } from \"@krizaka/ui/radio-group\";\nimport { Slider } from \"@krizaka/ui/slider\";\nimport { Switch } from \"@krizaka/ui/switch\";\nimport { RadioGroup as RadioGroupPrimitive } from \"radix-ui\";\nimport * as React from \"react\";\n\nimport { cx } from \"../cx\";\nimport { StyledText } from \"./styled-text\";\nimport {\n type Align,\n aligns,\n type Case,\n cases,\n contrastRatio,\n type FontId,\n fontIds,\n fontVariable,\n fontWeights,\n isUnderMinimumSize,\n type Leading,\n leadings,\n parseColor,\n parseTextStyle,\n type SizeStep,\n sizeSteps,\n type TextStyle,\n type TextWeight,\n textWeights,\n type ToneId,\n toneIds,\n toneVariable,\n type Tracking,\n trackings,\n} from \"./text-style\";\n\n/** The controls of the picker, in the order they are drawn. */\nexport const textStyleFields = [\"font\", \"size\", \"weight\", \"leading\", \"tracking\", \"align\", \"case\", \"italic\", \"tone\"] as const;\nexport type TextStyleField = (typeof textStyleFields)[number];\n\nexport type TextStyleLabels = {\n /** The name of the whole control. */\n picker: string;\n font: string;\n size: string;\n weight: string;\n leading: string;\n tracking: string;\n align: string;\n case: string;\n italic: string;\n tone: string;\n presets: string;\n preview: string;\n fonts: Record<FontId, string>;\n weights: Record<TextWeight, string>;\n leadings: Record<Leading, string>;\n trackings: Record<Tracking, string>;\n aligns: Record<Align, string>;\n cases: Record<Case, string>;\n tones: Record<ToneId, string>;\n /** The contrast warning: `{ratio}` is what the tone reaches, `{min}` what it must. */\n contrastWarning: string;\n /** The small-text warning: `{size}` is the smallest step advised for body text. */\n minSizeWarning: string;\n};\n\n/** The English words. */\nexport const textStyleLabels: TextStyleLabels = {\n picker: \"Text style\",\n font: \"Font\",\n size: \"Size\",\n weight: \"Weight\",\n leading: \"Line height\",\n tracking: \"Letter spacing\",\n align: \"Alignment\",\n case: \"Case\",\n italic: \"Italic\",\n tone: \"Colour\",\n presets: \"Presets\",\n preview: \"Preview\",\n fonts: { display: \"Display\", text: \"Text\", mono: \"Typewriter\", cahier: \"Pen\" },\n weights: { 400: \"Regular\", 500: \"Medium\", 600: \"Semibold\", 700: \"Bold\" },\n leadings: { tight: \"Tight\", normal: \"Normal\", relaxed: \"Relaxed\" },\n trackings: { tight: \"Tight\", normal: \"Normal\", wide: \"Wide\" },\n aligns: { start: \"Start\", center: \"Centre\", end: \"End\" },\n cases: { none: \"Aa\", upper: \"AA\", \"small-caps\": \"Small caps\" },\n tones: { primary: \"Primary\", secondary: \"Secondary\", muted: \"Muted\", accent: \"Accent\" },\n contrastWarning: \"This colour reaches only {ratio}:1 on the background; {min}:1 is needed to read it comfortably.\",\n minSizeWarning: \"Body text under “{size}” is hard to read.\",\n};\n\n/** The French words. */\nexport const textStyleLabelsFr: TextStyleLabels = {\n picker: \"Style du texte\",\n font: \"Police\",\n size: \"Taille\",\n weight: \"Graisse\",\n leading: \"Interligne\",\n tracking: \"Espacement des lettres\",\n align: \"Alignement\",\n case: \"Casse\",\n italic: \"Italique\",\n tone: \"Couleur\",\n presets: \"Préréglages\",\n preview: \"Aperçu\",\n fonts: { display: \"Titre\", text: \"Texte\", mono: \"Machine à écrire\", cahier: \"Stylo\" },\n weights: { 400: \"Normal\", 500: \"Moyen\", 600: \"Demi-gras\", 700: \"Gras\" },\n leadings: { tight: \"Serré\", normal: \"Normal\", relaxed: \"Aéré\" },\n trackings: { tight: \"Serré\", normal: \"Normal\", wide: \"Large\" },\n aligns: { start: \"Début\", center: \"Centré\", end: \"Fin\" },\n cases: { none: \"Aa\", upper: \"AA\", \"small-caps\": \"Petites capitales\" },\n tones: { primary: \"Principale\", secondary: \"Secondaire\", muted: \"Discrète\", accent: \"Accent\" },\n contrastWarning: \"Cette couleur n’atteint que {ratio}:1 sur le fond ; {min}:1 est nécessaire pour la lire confortablement.\",\n minSizeWarning: \"Un texte courant sous « {size} » se lit mal.\",\n};\n\nexport type TextStylePreset = {\n /** A stable key. */\n id: string;\n /** The name on the button, passed translated (« Titre », « Prix »…). */\n label: string;\n /** The style it applies; what it does not say takes the default. Validated when applied. */\n value: Partial<TextStyle>;\n};\n\nexport type TextStylePickerProps = {\n /** The text style, controlled. Validated by `parseTextStyle`: anything invalid shows the default. */\n value: TextStyle;\n /** Called with the whole new text style at each change. */\n onChange: (value: TextStyle) => void;\n /** The sample the preview shows, passed translated (\"Boulangerie Martin\"). */\n previewText: string;\n /** Styles the person can start from, as data. */\n presets?: readonly TextStylePreset[];\n /** The controls to show, in the order of `textStyleFields` (just `[\"font\", \"size\"]`). A preset then changes only these. */\n fields?: readonly TextStyleField[];\n /** A denser form for a popover from a toolbar. */\n compact?: boolean;\n /** The words, passed translated: `textStyleLabels` (EN) or `textStyleLabelsFr`, or the host's own. */\n labels?: Partial<TextStyleLabels>;\n /** The colour the text will sit on, for the preview and the contrast check (a CSS colour). By default the page's own surface. */\n surface?: string;\n /**\n * What the text is for: `body` (reading text, which `minBodySize` guards) or `title` (a heading, which may be small).\n * @default \"body\"\n */\n role?: \"body\" | \"title\";\n /**\n * The smallest step advised for body text: under it, a warning shows — the size is never forced.\n * @default \"sm\"\n */\n minBodySize?: SizeStep;\n /** Merged last on the root. */\n className?: string;\n};\n\ntype Rgb = [number, number, number];\ntype Rgba = [number, number, number, number];\n\nfunction parseColorWithAlpha(text: string): Rgba | null {\n const value = text.trim().toLowerCase();\n if (value === \"transparent\") return [0, 0, 0, 0];\n const color = parseColor(value);\n if (!color) return null;\n\n const hex = /^#([0-9a-f]{4}|[0-9a-f]{8})$/.exec(value)?.[1];\n if (hex) {\n const alpha = hex.length === 4 ? Number.parseInt(hex[3]! + hex[3]!, 16) : Number.parseInt(hex.slice(6, 8), 16);\n return [...color, alpha / 255];\n }\n\n const components =\n /^rgba?\\(([^)]+)\\)$/.exec(value)?.[1] ??\n /^color\\(srgb\\s+([^)]+)\\)$/.exec(value)?.[1];\n if (!components) return [...color, 1];\n\n const [channels, slashAlpha] = components.split(\"/\");\n const parts = channels!.trim().split(/[\\s,]+/).filter(Boolean);\n const alpha = slashAlpha?.trim() ?? (parts.length === 4 ? parts[3] : undefined);\n if (alpha === undefined) return [...color, 1];\n const parsed = alpha.endsWith(\"%\") ? Number.parseFloat(alpha) / 100 : Number.parseFloat(alpha);\n return Number.isFinite(parsed) && parsed >= 0 && parsed <= 1 ? [...color, parsed] : null;\n}\n\nconst over = (foreground: Rgba, background: Rgba): Rgba => {\n const alpha = foreground[3] + background[3] * (1 - foreground[3]);\n if (alpha === 0) return [0, 0, 0, 0];\n return [\n (foreground[0] * foreground[3] + background[0] * background[3] * (1 - foreground[3])) / alpha,\n (foreground[1] * foreground[3] + background[1] * background[3] * (1 - foreground[3])) / alpha,\n (foreground[2] * foreground[3] + background[2] * background[3] * (1 - foreground[3])) / alpha,\n alpha,\n ];\n};\n\n/** The composited colour behind an element, or null when a background layer cannot be read. */\nfunction surfaceOf(element: HTMLElement): Rgb | null {\n const layers: HTMLElement[] = [];\n for (let node: HTMLElement | null = element; node; node = node.parentElement) {\n layers.push(node);\n if (node === document.documentElement) break;\n }\n let background: Rgba = [0, 0, 0, 0];\n for (const node of layers.reverse()) {\n const color = getComputedStyle(node).backgroundColor;\n const layer: Rgba | null = color ? parseColorWithAlpha(color) : [0, 0, 0, 0];\n if (!layer) return null;\n background = over(layer, background);\n }\n const [red, green, blue, alpha] = background;\n return alpha >= 1 ? [red, green, blue] : null;\n}\n\n/** What the tone reaches on its surface, measured on the preview as it is drawn (the theme and the product's tokens included). */\nfunction useContrast(ref: React.RefObject<HTMLElement | null>, key: string): { ratio: number; required: number } | null {\n const [measurement, setMeasurement] = React.useState<{ ratio: number; required: number } | null>(null);\n React.useEffect(() => {\n const element = ref.current;\n if (!element) return;\n const measure = () => {\n const sample = element.querySelector<HTMLElement>(\"[data-text-style-sample]\") ?? element;\n const computed = getComputedStyle(sample);\n const foreground = parseColor(computed.color);\n const background = surfaceOf(sample);\n const fontSize = Number.parseFloat(computed.fontSize);\n const fontWeight = Number.parseFloat(computed.fontWeight);\n const required = fontSize >= 24 || (fontSize >= 18.66 && fontWeight >= 700) ? 3 : 4.5;\n setMeasurement(foreground && background && Number.isFinite(fontSize) && Number.isFinite(fontWeight) ? { ratio: contrastRatio(foreground, background), required } : null);\n };\n measure();\n if (typeof MutationObserver === \"undefined\") return;\n const observer = new MutationObserver(measure);\n for (let node: HTMLElement | null = element; node; node = node.parentElement) {\n observer.observe(node, { attributes: true, attributeFilter: [\"class\", \"style\", \"data-theme\"] });\n if (node === document.documentElement) break;\n }\n return () => observer.disconnect();\n }, [ref, key]);\n return measurement;\n}\n\nconst nearest = (weights: readonly TextWeight[], weight: TextWeight): TextWeight =>\n weights.reduce((best, w) => (Math.abs(w - weight) < Math.abs(best - weight) ? w : best), weights[0]!);\n\n/** The control of a text style: font, size, weight, spacing, alignment, case, italic and tone, with a live preview. */\nexport function TextStylePicker({\n value,\n onChange,\n previewText,\n presets,\n fields = textStyleFields,\n compact,\n labels: given,\n surface,\n role = \"body\",\n minBodySize = \"sm\",\n className,\n}: TextStylePickerProps) {\n const labels = { ...textStyleLabels, ...given };\n const style = parseTextStyle(value);\n const shown = (field: TextStyleField) => fields.includes(field);\n const id = React.useId();\n const previewRef = React.useRef<HTMLDivElement>(null);\n const measurement = useContrast(previewRef, `${style.font}|${style.size}|${style.weight}|${style.tone}|${surface ?? \"\"}`);\n\n const set = (patch: Partial<TextStyle>) => onChange(parseTextStyle({ ...style, ...patch }));\n const setFont = (font: FontId) => set({ font, weight: nearest(fontWeights[font], style.weight) });\n const applyPreset = (preset: TextStylePreset) => {\n const next = parseTextStyle(preset.value);\n const patch = Object.fromEntries(textStyleFields.filter(shown).map((f) => [f, next[f]])) as Partial<TextStyle>;\n if (patch.font !== undefined || patch.weight !== undefined) {\n const font = patch.font ?? style.font;\n const weight = patch.weight ?? style.weight;\n set({ ...patch, weight: nearest(fontWeights[font], weight) });\n } else {\n set(patch);\n }\n };\n\n const warnings: string[] = [];\n if (measurement && measurement.ratio < measurement.required) {\n warnings.push(labels.contrastWarning.replace(\"{ratio}\", measurement.ratio.toFixed(1)).replace(\"{min}\", String(measurement.required)));\n }\n if (role === \"body\" && isUnderMinimumSize(style.size, minBodySize)) warnings.push(labels.minSizeWarning.replace(\"{size}\", minBodySize));\n\n const group = (field: TextStyleField, title: string, control: React.ReactNode, className?: string) => (\n <div key={field} className={cx(\"flex min-w-0 flex-col gap-2\", className)} data-field={field}>\n <span id={`${id}-${field}`} className=\"text-xs font-semibold text-fg-secondary\">\n {title}\n </span>\n {control}\n </div>\n );\n const segmented = <T extends string | number>(field: TextStyleField, title: string, items: readonly T[], current: T, text: (item: T) => string, choose: (item: T) => void, disabled?: (item: T) => boolean) =>\n group(\n field,\n title,\n <RadioGroup.Root variant=\"segmented\" aria-labelledby={`${id}-${field}`} value={String(current)} onValueChange={(next) => choose(items.find((item) => String(item) === next)!)} className=\"w-full max-w-full\">\n {items.map((item) => (\n <RadioGroup.Segment key={item} value={String(item)} disabled={disabled?.(item)} className=\"min-w-0 px-1 text-xs\">\n {text(item)}\n </RadioGroup.Segment>\n ))}\n </RadioGroup.Root>,\n \"sm:col-span-2\",\n );\n\n const controls: Record<TextStyleField, () => React.ReactNode> = {\n font: () =>\n group(\n \"font\",\n labels.font,\n <RadioGroup.Root variant=\"cards\" aria-labelledby={`${id}-font`} value={style.font} onValueChange={(next) => setFont(next as FontId)} className=\"grid-cols-[repeat(auto-fit,minmax(9rem,1fr))]\">\n {fontIds.map((font) => (\n <RadioGroup.Card key={font} value={font} style={{ fontFamily: fontVariable[font] }}>\n {labels.fonts[font]}\n </RadioGroup.Card>\n ))}\n </RadioGroup.Root>,\n ),\n size: () =>\n group(\n \"size\",\n labels.size,\n <Slider\n label={labels.size}\n min={0}\n max={sizeSteps.length - 1}\n step={1}\n ticks\n value={sizeSteps.indexOf(style.size)}\n onValueChange={(index) => set({ size: sizeSteps[index]! })}\n formatValue={(index) => sizeSteps[index]!}\n floatingValue\n />,\n ),\n weight: () => segmented(\"weight\", labels.weight, textWeights, style.weight, (w) => labels.weights[w], (weight) => set({ weight }), (w) => !fontWeights[style.font].includes(w)),\n leading: () => segmented(\"leading\", labels.leading, leadings, style.leading, (l) => labels.leadings[l], (leading) => set({ leading })),\n tracking: () => segmented(\"tracking\", labels.tracking, trackings, style.tracking, (t) => labels.trackings[t], (tracking) => set({ tracking })),\n align: () => segmented(\"align\", labels.align, aligns, style.align, (a) => labels.aligns[a], (align) => set({ align })),\n case: () => segmented(\"case\", labels.case, cases, style.case, (c) => labels.cases[c], (next) => set({ case: next })),\n italic: () => (\n <div key=\"italic\" className=\"flex min-w-0 items-center justify-between gap-3\" data-field=\"italic\">\n <span id={`${id}-italic`} className=\"text-xs font-semibold text-fg-secondary\">\n {labels.italic}\n </span>\n <Switch aria-labelledby={`${id}-italic`} checked={style.italic} onCheckedChange={(italic) => set({ italic })} />\n </div>\n ),\n tone: () =>\n group(\n \"tone\",\n labels.tone,\n <RadioGroupPrimitive.Root aria-labelledby={`${id}-tone`} value={style.tone} onValueChange={(next) => set({ tone: next as ToneId })} orientation=\"horizontal\" className=\"flex flex-wrap gap-3\">\n {toneIds.map((tone) => (\n <RadioGroupPrimitive.Item\n key={tone}\n value={tone}\n aria-label={labels.tones[tone]}\n title={labels.tones[tone]}\n style={{ backgroundColor: toneVariable(tone) }}\n className=\"h-8 w-8 rounded-full border border-border-strong focus-visible:outline-hidden focus-visible:focus-ring data-[state=checked]:ring-2 data-[state=checked]:ring-accent data-[state=checked]:ring-offset-2 data-[state=checked]:ring-offset-surface-0\"\n />\n ))}\n </RadioGroupPrimitive.Root>,\n ),\n };\n\n return (\n <div role=\"group\" aria-label={labels.picker} data-compact={compact ? \"\" : undefined} className={cx(\"flex min-w-0 flex-col\", compact ? \"gap-3\" : \"gap-5\", className)}>\n <div\n ref={previewRef}\n data-preview=\"\"\n aria-label={labels.preview}\n role=\"group\"\n style={surface ? { backgroundColor: surface } : undefined}\n className={cx(\"min-w-0 overflow-hidden rounded-xl border border-border-default\", surface ? \"\" : \"bg-surface-1\", compact ? \"p-3\" : \"p-5\")}\n >\n <StyledText as=\"p\" value={style} className=\"break-words\" data-text-style-sample=\"\">\n {previewText}\n </StyledText>\n </div>\n <div role=\"status\" aria-live=\"polite\" data-warnings=\"\">\n {warnings.map((warning) => (\n <p key={warning} className=\"text-xs font-medium text-fg-warning\">\n {warning}\n </p>\n ))}\n </div>\n {presets?.length ? (\n <div role=\"group\" aria-label={labels.presets} className=\"flex flex-wrap gap-2\">\n {presets.map((preset) => (\n <Button key={preset.id} type=\"button\" size=\"sm\" variant=\"outline\" onClick={() => applyPreset(preset)}>\n {preset.label}\n </Button>\n ))}\n </div>\n ) : null}\n <div className={cx(\"grid grid-cols-1 gap-x-6\", compact ? \"gap-y-3\" : \"gap-y-5 sm:grid-cols-2\")}>\n {textStyleFields.filter(shown).map((field) => (\n <React.Fragment key={field}>{controls[field]()}</React.Fragment>\n ))}\n </div>\n </div>\n );\n}\n"],"mappings":";;;AACO,SAAS,MAAM,OAAyD;AAC7E,SAAO,MAAM,OAAO,OAAO,EAAE,KAAK,GAAG;AACvC;;;ACEA,YAAY,OAAO;AAGZ,IAAM,UAAU,CAAC,WAAW,QAAQ,QAAQ,QAAQ;AAIpD,IAAM,YAAY,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM,OAAO,OAAO,KAAK;AAGpE,IAAM,cAAc,CAAC,KAAK,KAAK,KAAK,GAAG;AAGvC,IAAM,WAAW,CAAC,SAAS,UAAU,SAAS;AAG9C,IAAM,YAAY,CAAC,SAAS,UAAU,MAAM;AAG5C,IAAM,SAAS,CAAC,SAAS,UAAU,KAAK;AAGxC,IAAM,QAAQ,CAAC,QAAQ,SAAS,YAAY;AAI5C,IAAM,UAAU,CAAC,WAAW,aAAa,SAAS,QAAQ;AAiB1D,IAAM,mBAAwC,OAAO,OAAO;AAAA,EACjE,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AACR,CAAC;AAGM,IAAM,cAA+D;AAAA,EAC1E,SAAS,CAAC,GAAG;AAAA,EACb,MAAM,CAAC,KAAK,KAAK,GAAG;AAAA,EACpB,MAAM,CAAC,KAAK,GAAG;AAAA,EACf,QAAQ,CAAC,GAAG;AACd;AAEA,IAAM,SAAW,SAAO;AAAA,EACtB,MAAQ,OAAK,OAAO;AAA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
  import {
9
9
  StatGrid
10
- } from "./chunk-U4XTZMB7.js";
10
+ } from "./chunk-QA3WETWT.js";
11
11
 
12
12
  // src/usage/model.ts
13
13
  import { formatNumber, formatPercent } from "@krizaka/intl";
@@ -42,7 +42,10 @@ function usageTile(input, { locale = "fr-CA", words } = {}) {
42
42
  const w = { ...wordsOf(locale), ...words };
43
43
  const change = changeOf(input.value, input.previous);
44
44
  const trend = direction(change);
45
- const text = change === null ? void 0 : trend === "flat" ? w.same : w.vsPrevious.replace("{change}", formatPercent(change, { locale, signDisplay: "exceptZero", maximumFractionDigits: 0 }));
45
+ let text;
46
+ if (change !== null) {
47
+ text = trend === "flat" ? w.same : w.vsPrevious.replace("{change}", formatPercent(change, { locale, signDisplay: "exceptZero", maximumFractionDigits: 0 }));
48
+ }
46
49
  return {
47
50
  id: input.id,
48
51
  label: input.label,
@@ -151,7 +154,9 @@ function UsageChart({ title, days, outcomes, emptyLabel, columns, loading, local
151
154
  const write = (n) => formatNumber2(n, { locale });
152
155
  return /* @__PURE__ */ jsxs("figure", { "aria-busy": loading || void 0, className: s.chart({ className }), ...props, children: [
153
156
  /* @__PURE__ */ jsx("figcaption", { className: s.chartTitle(), children: title }),
154
- loading ? /* @__PURE__ */ jsx("div", { className: s.skeleton() }) : empty ? /* @__PURE__ */ jsx("p", { className: s.state(), children: emptyLabel }) : /* @__PURE__ */ jsxs(Fragment, { children: [
157
+ loading && /* @__PURE__ */ jsx("div", { className: s.skeleton() }),
158
+ !loading && empty && /* @__PURE__ */ jsx("p", { className: s.state(), children: emptyLabel }),
159
+ !loading && !empty && /* @__PURE__ */ jsxs(Fragment, { children: [
155
160
  /* @__PURE__ */ jsx("div", { "aria-hidden": true, className: s.plot(), children: bars.map((bar) => /* @__PURE__ */ jsx(Column, { bar, outcomes }, bar.label)) }),
156
161
  /* @__PURE__ */ jsx("ul", { className: s.legend(), children: outcomes.map((o) => /* @__PURE__ */ jsxs("li", { children: [
157
162
  /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: s.swatch({ tone: o.tone }) }),
package/dist/usage.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/usage/model.ts","../src/usage/usage.tsx"],"sourcesContent":["// Headless: the arithmetic and the words of the usage blocks (period, tiles, chart rows), read by the web entry.\nimport { formatNumber, formatPercent } from \"@krizaka/intl\";\nimport type * as React from \"react\";\n\nimport type { StatStripItem, StatTrend } from \"../stat\";\n\n/** The periods a usage page offers, in days. */\nexport const USAGE_PERIODS = [7, 30, 90] as const;\nexport type UsagePeriod = (typeof USAGE_PERIODS)[number];\n\n/** Reads `?period=` back: anything but an offered period is the default, so the address can never break the page. */\nexport function parsePeriod(raw: string | string[] | null | undefined, allowed: readonly number[] = USAGE_PERIODS, fallback = 30): number {\n const value = Number(Array.isArray(raw) ? raw[0] : raw);\n return allowed.includes(value) ? value : fallback;\n}\n\n/** The address of a period: the same path with `period` set, every other parameter kept. */\nexport function periodHref(base: string, period: number, param = \"period\"): string {\n const [path = \"\", query = \"\"] = base.split(\"?\");\n const params = new URLSearchParams(query);\n params.set(param, String(period));\n return `${path}?${params.toString()}`;\n}\n\nconst WORDS = {\n fr: { vsPrevious: \"{change} vs période précédente\", same: \"stable\", up: \"en hausse\", down: \"en baisse\" },\n en: { vsPrevious: \"{change} vs previous period\", same: \"steady\", up: \"up\", down: \"down\" },\n} as const;\n\nexport type UsageWords = {\n /** The change against the previous period; `{change}` is replaced by the signed percentage. */\n vsPrevious: string;\n /** When the figure did not move. */\n same: string;\n};\n\nconst FLAT = 0.005;\n\nexport interface UsageTileInput {\n id: string;\n label: string;\n value: number;\n /** The same figure for the previous period: the trend is computed from it. */\n previous?: number;\n /** Which direction is good news (latency, failures: `down`). Default `up`. */\n good?: \"up\" | \"down\";\n /** The shape of the period, rendered by the app (a `Sparkline` of @krizaka/charts, 64 × 18). */\n chart?: React.ReactNode;\n /** Digits of the figure. Default 0. */\n digits?: number;\n}\n\nexport interface UsageTileOptions {\n /** Default `fr-CA`: French figures and words with no props. */\n /** The language of the figures and the words. Default `fr-CA`. */\n locale?: string;\n /** Your own words for the change: `{change}` is the percentage. */\n words?: Partial<UsageWords>;\n}\n\nconst wordsOf = (locale: string): (typeof WORDS)[keyof typeof WORDS] => (locale.toLowerCase().startsWith(\"en\") ? WORDS.en : WORDS.fr);\n\nfunction direction(change: number | null): StatTrend | undefined {\n if (change === null) return undefined;\n if (Math.abs(change) < FLAT) return \"flat\";\n return change > 0 ? \"up\" : \"down\";\n}\n\nfunction changeOf(value: number, previous: number | undefined): number | null {\n if (previous === undefined) return null;\n if (previous === 0) return value === 0 ? 0 : null;\n return value / previous - 1;\n}\n\n/** One strip figure: the value written for the locale, the change against the previous period said in words. */\nexport function usageTile(input: UsageTileInput, { locale = \"fr-CA\", words }: UsageTileOptions = {}): StatStripItem {\n const w = { ...wordsOf(locale), ...words };\n const change = changeOf(input.value, input.previous);\n const trend = direction(change);\n const text = change === null ? undefined : trend === \"flat\" ? w.same : w.vsPrevious.replace(\"{change}\", formatPercent(change, { locale, signDisplay: \"exceptZero\", maximumFractionDigits: 0 }));\n return {\n id: input.id,\n label: input.label,\n value: formatNumber(input.value, { locale, maximumFractionDigits: input.digits ?? 0 }),\n trend,\n trendLabel: text,\n chart: input.chart,\n };\n}\n\n/** One bar of the usage chart: a day, its counts by outcome. */\nexport interface UsageDay {\n /** The day, written by the app (`3 nov.`). */\n label: string;\n values: Readonly<Partial<Record<string, number>>>;\n}\n\nexport interface UsageOutcome {\n id: string;\n label: string;\n /** `accent`, `success`, `warning`, `danger` or `muted`: tones of the tokens, never a colour. */\n tone: \"accent\" | \"success\" | \"warning\" | \"danger\" | \"muted\";\n}\n\nexport interface UsageBar {\n label: string;\n total: number;\n /** Height of the whole bar, 0–1 of the tallest day. */\n height: number;\n segments: { id: string; value: number; share: number }[];\n}\n\n/** The bars of the chart: heights relative to the tallest day, segments as shares of their bar. */\nexport function usageBars(days: readonly UsageDay[], outcomes: readonly UsageOutcome[]): UsageBar[] {\n const totals = days.map((d) => outcomes.reduce((sum, o) => sum + (d.values[o.id] ?? 0), 0));\n const max = Math.max(1, ...totals);\n return days.map((d, i) => {\n const total = totals[i] ?? 0;\n return {\n label: d.label,\n total,\n height: total / max,\n segments: outcomes.map((o) => ({ id: o.id, value: d.values[o.id] ?? 0, share: total === 0 ? 0 : (d.values[o.id] ?? 0) / total })),\n };\n });\n}\n","// Server-safe. The blocks of a « Credits & usage » page: the balance on a Meter, the period switch (the address holds it),\n// the figures on the strip, the activity stacked by outcome. Words are props (French by default for the few built in);\n// figures are written with @krizaka/intl. Demo data only in the examples.\nimport { formatNumber } from \"@krizaka/intl\";\nimport type * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { BlockLink, type LinkComponent } from \"../block-link\";\nimport { Meter } from \"../meter\";\nimport { StatGrid } from \"../stat\";\nimport { periodHref, USAGE_PERIODS, type UsageBar, usageBars, type UsageDay, type UsageOutcome, usageTile,type UsageTileInput, type UsageTileOptions } from \"./model\";\n\nexport const usage = tv({\n slots: {\n credits: \"flex w-full min-w-0 flex-col gap-3 rounded-xl border border-border-default bg-surface-1 p-5\",\n creditsHead: \"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1\",\n creditsTitle: \"m-0 text-sm font-semibold text-fg-secondary\",\n creditsFigure: \"m-0 font-display text-3xl font-bold tabular-nums text-fg\",\n creditsFoot: \"m-0 flex flex-wrap items-center justify-between gap-x-4 gap-y-2 text-xs text-fg-secondary\",\n switchList: \"m-0 inline-flex list-none gap-1 rounded-lg border border-border-default bg-surface-1 p-1\",\n switchLink:\n \"inline-flex min-h-9 min-w-11 items-center justify-center rounded-md px-3 text-sm font-semibold tabular-nums text-fg-secondary no-underline transition-colors \" +\n \"hover:text-fg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring aria-[current=page]:bg-accent-soft aria-[current=page]:text-fg\",\n chart: \"m-0 flex w-full min-w-0 flex-col gap-3 rounded-xl border border-border-default bg-surface-1 p-5\",\n chartTitle: \"text-sm font-semibold text-fg\",\n plot: \"flex h-40 w-full items-end gap-1\",\n column: \"flex h-full min-w-0 flex-1 flex-col justify-end\",\n bar: \"flex w-full flex-col-reverse overflow-hidden rounded-sm\",\n legend: \"m-0 flex list-none flex-wrap gap-x-4 gap-y-1 p-0 text-xs text-fg-secondary\",\n swatch: \"mr-1.5 inline-block h-2 w-2 rounded-full align-baseline\",\n state: \"m-0 flex h-40 items-center justify-center rounded-lg border border-dashed border-border-default px-4 text-center text-sm text-fg-secondary\",\n skeleton: \"h-40 w-full animate-pulse rounded-lg bg-surface-3 motion-reduce:animate-none\",\n },\n variants: {\n tone: {\n accent: { swatch: \"bg-accent\" },\n success: { swatch: \"bg-success\" },\n warning: { swatch: \"bg-warning\" },\n danger: { swatch: \"bg-danger\" },\n muted: { swatch: \"bg-border-strong\" },\n },\n },\n});\n\nconst FILL: Record<UsageOutcome[\"tone\"], string> = { accent: \"bg-accent\", success: \"bg-success\", warning: \"bg-warning\", danger: \"bg-danger\", muted: \"bg-border-strong\" };\n\nconst CREDIT_WORDS = {\n fr: { of: \"sur\", left: \"restants\" },\n en: { of: \"of\", left: \"left\" },\n} as const;\n\nexport type CreditsMeterProps = Omit<React.ComponentProps<\"section\">, \"children\"> & {\n /** What the balance is (« Crédits »): the heading and the meter's name. */\n label: string;\n /** Credits left. */\n balance: number;\n /** The allowance of the period; the meter fills with what is left. */\n total: number;\n /** The renewal, written by the app (« Renouvelés le 1er novembre »). */\n renewal?: React.ReactNode;\n /** The way to buy more: a link or a button. */\n action?: React.ReactNode;\n /** Default `fr-CA`. */\n locale?: string;\n};\n\n/** The balance: the figure large, a meter that turns to warning then danger as it runs low, the renewal and the way to buy. */\nexport function CreditsMeter({ label, balance, total, renewal, action, locale = \"fr-CA\", className, ...props }: CreditsMeterProps) {\n const s = usage();\n const w = locale.toLowerCase().startsWith(\"en\") ? CREDIT_WORDS.en : CREDIT_WORDS.fr;\n const write = (n: number) => formatNumber(n, { locale });\n const words = `${write(balance)} ${w.of} ${write(total)}`;\n return (\n <section aria-label={label} className={s.credits({ className })} {...props}>\n <div className={s.creditsHead()}>\n <h3 className={s.creditsTitle()}>{label}</h3>\n <p className={s.creditsFigure()}>\n {write(balance)} <span className=\"sr-only\">{w.left}</span>\n </p>\n </div>\n <Meter label={label} value={balance} max={Math.max(1, total)} valueText={words} optimum=\"high\" thresholds={{ low: 0.2, high: 0.5 }} size=\"lg\" />\n <p className={s.creditsFoot()}>\n <span>{words}</span>\n {renewal ? <span>{renewal}</span> : null}\n {action}\n </p>\n </section>\n );\n}\n\nexport type PeriodSwitchProps = Omit<React.ComponentProps<\"nav\">, \"children\"> & {\n /** The accessible name (« Période »). */\n label: string;\n /** The period shown, from `parsePeriod(searchParams.period)`. */\n value: number;\n /** The page's path (and any other parameters); each period is a link to it with `?period=`. */\n href: string;\n /** The periods offered, in days. Default 7 · 30 · 90. */\n periods?: readonly number[];\n /** The query parameter. Default `period`. */\n param?: string;\n /** The text of a period. Default `7 j` (`7 d` for an English locale). */\n periodLabel?: (days: number) => string;\n /** Default `fr-CA`. */\n locale?: string;\n /** The app's router link (Next's `Link`); default a plain `<a>`. */\n linkAs?: LinkComponent;\n};\n\n/** 7 · 30 · 90 d: links, so the address holds the period (`?period=30`) and the server renders it. */\nexport function PeriodSwitch({ label, value, href, periods = USAGE_PERIODS, param = \"period\", periodLabel, locale = \"fr-CA\", linkAs, className, ...props }: PeriodSwitchProps) {\n const s = usage();\n const unit = locale.toLowerCase().startsWith(\"en\") ? \"d\" : \"j\";\n const text = periodLabel ?? ((days: number) => `${days} ${unit}`);\n return (\n <nav aria-label={label} className={className} {...props}>\n <ul className={s.switchList()}>\n {periods.map((days) => (\n <li key={days}>\n <BlockLink href={periodHref(href, days, param)} linkAs={linkAs} className={s.switchLink()} aria-current={days === value ? \"page\" : undefined}>\n {text(days)}\n </BlockLink>\n </li>\n ))}\n </ul>\n </nav>\n );\n}\n\nexport type UsageTilesProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n /** 2 to 4 figures. */\n tiles: readonly UsageTileInput[];\n /** The period switch, above the row. */\n period?: React.ReactNode;\n /** The data is on its way: the row keeps its height. */\n loading?: boolean;\n} & UsageTileOptions;\n\n/** The figures of the period on the strip, each compared with the previous period in words. */\nexport function UsageTiles({ tiles, period, loading, locale, words, className, ...props }: UsageTilesProps) {\n const s = usage();\n if (loading) return <div aria-busy=\"true\" className={s.skeleton({ className: [\"h-20\", className].filter(Boolean).join(\" \") })} {...props} />;\n return <StatGrid variant=\"strip\" items={tiles.map((t) => usageTile(t, { locale, words }))} period={period} className={className} {...props} />;\n}\n\nexport type UsageChartProps = Omit<React.ComponentProps<\"figure\">, \"children\"> & {\n /** What it draws (« Activité par résultat »). */\n title: string;\n /** The days, oldest first. */\n days: readonly UsageDay[];\n /** The outcomes stacked in each bar, bottom first. */\n outcomes: readonly UsageOutcome[];\n /** Said when there is nothing in the period. */\n emptyLabel: string;\n /** The text version's column headings: the day, the total. */\n columns: { day: string; total: string };\n /** The data is on its way: a skeleton keeps the height. */\n loading?: boolean;\n /** Default `fr-CA`. */\n locale?: string;\n};\n\nfunction Column({ bar, outcomes }: { bar: UsageBar; outcomes: readonly UsageOutcome[] }) {\n const s = usage();\n return (\n <div className={s.column()}>\n <div className={s.bar()} style={{ height: `${bar.height * 100}%` }}>\n {bar.segments.map((seg, i) =>\n seg.value > 0 ? <span key={seg.id} className={FILL[outcomes[i]?.tone ?? \"muted\"]} style={{ height: `${seg.share * 100}%` }} /> : null,\n )}\n </div>\n </div>\n );\n}\n\n/** The activity of the period, one bar per day stacked by outcome — with its legend and its text version (a table). */\nexport function UsageChart({ title, days, outcomes, emptyLabel, columns, loading, locale = \"fr-CA\", className, ...props }: UsageChartProps) {\n const s = usage();\n const bars = usageBars(days, outcomes);\n const sum = (id: string) => days.reduce((n, d) => n + (d.values[id] ?? 0), 0);\n const empty = bars.every((b) => b.total === 0);\n const write = (n: number) => formatNumber(n, { locale });\n return (\n <figure aria-busy={loading || undefined} className={s.chart({ className })} {...props}>\n <figcaption className={s.chartTitle()}>{title}</figcaption>\n {loading ? (\n <div className={s.skeleton()} />\n ) : empty ? (\n <p className={s.state()}>{emptyLabel}</p>\n ) : (\n <>\n <div aria-hidden className={s.plot()}>\n {bars.map((bar) => (\n <Column key={bar.label} bar={bar} outcomes={outcomes} />\n ))}\n </div>\n <ul className={s.legend()}>\n {outcomes.map((o) => (\n <li key={o.id}>\n <span aria-hidden className={s.swatch({ tone: o.tone })} />\n {o.label} <span className=\"tabular-nums text-fg\">{write(sum(o.id))}</span>\n </li>\n ))}\n </ul>\n <table className=\"sr-only\">\n <caption>{title}</caption>\n <thead>\n <tr>\n <th scope=\"col\">{columns.day}</th>\n {outcomes.map((o) => (\n <th key={o.id} scope=\"col\">\n {o.label}\n </th>\n ))}\n <th scope=\"col\">{columns.total}</th>\n </tr>\n </thead>\n <tbody>\n {days.map((d, i) => (\n <tr key={d.label}>\n <th scope=\"row\">{d.label}</th>\n {outcomes.map((o) => (\n <td key={o.id}>{write(d.values[o.id] ?? 0)}</td>\n ))}\n <td>{write(bars[i]?.total ?? 0)}</td>\n </tr>\n ))}\n </tbody>\n </table>\n </>\n )}\n </figure>\n );\n}\n"],"mappings":";;;;;;;;;;;;AACA,SAAS,cAAc,qBAAqB;AAMrC,IAAM,gBAAgB,CAAC,GAAG,IAAI,EAAE;AAIhC,SAAS,YAAY,KAA2C,UAA6B,eAAe,WAAW,IAAY;AACxI,QAAM,QAAQ,OAAO,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,GAAG;AACtD,SAAO,QAAQ,SAAS,KAAK,IAAI,QAAQ;AAC3C;AAGO,SAAS,WAAW,MAAc,QAAgB,QAAQ,UAAkB;AACjF,QAAM,CAAC,OAAO,IAAI,QAAQ,EAAE,IAAI,KAAK,MAAM,GAAG;AAC9C,QAAM,SAAS,IAAI,gBAAgB,KAAK;AACxC,SAAO,IAAI,OAAO,OAAO,MAAM,CAAC;AAChC,SAAO,GAAG,IAAI,IA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,GACH;AAAA,MACA,qBAAC,WAAM,WAAU,WACf;AAAA,4BAAC,aAAS,iBAAM;AAAA,QAChB,oBAAC,WACC,+BAAC,QACC;AAAA,8BAAC,QAAG,OAAM,OAAO,kBAAQ,KAAI;AAAA,UAC5B,SAAS,IAAI,CAAC,MACb,oBAAC,QAAc,OAAM,OAClB,YAAE,SADI,EAAE,EAEX,CACD;AAAA,UACD,oBAAC,QAAG,OAAM,OAAO,kBAAQ,OAAM;AAAA,WACjC,GACF;AAAA,QACA,oBAAC,WACE,eAAK,IAAI,CAAC,GAAG,MACZ,qBAAC,QACC;AAAA,8BAAC,QAAG,OAAM,OAAO,YAAE,OAAM;AAAA,UACxB,SAAS,IAAI,CAAC,MACb,oBAAC,QAAe,gBAAM,EAAE,OAAO,EAAE,EAAE,KAAK,CAAC,KAAhC,EAAE,EAAgC,CAC5C;AAAA,UACD,oBAAC,QAAI,gBAAM,KAAK,CAAC,GAAG,SAAS,CAAC,GAAE;AAAA,aALzB,EAAE,KAMX,CACD,GACH;AAAA,SACF;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":["formatNumber","formatNumber"]}
1
+ {"version":3,"sources":["../src/usage/model.ts","../src/usage/usage.tsx"],"sourcesContent":["// Headless: the arithmetic and the words of the usage blocks (period, tiles, chart rows), read by the web entry.\nimport { formatNumber, formatPercent } from \"@krizaka/intl\";\nimport type * as React from \"react\";\n\nimport type { StatStripItem, StatTrend } from \"../stat\";\n\n/** The periods a usage page offers, in days. */\nexport const USAGE_PERIODS = [7, 30, 90] as const;\nexport type UsagePeriod = (typeof USAGE_PERIODS)[number];\n\n/** Reads `?period=` back: anything but an offered period is the default, so the address can never break the page. */\nexport function parsePeriod(raw: string | string[] | null | undefined, allowed: readonly number[] = USAGE_PERIODS, fallback = 30): number {\n const value = Number(Array.isArray(raw) ? raw[0] : raw);\n return allowed.includes(value) ? value : fallback;\n}\n\n/** The address of a period: the same path with `period` set, every other parameter kept. */\nexport function periodHref(base: string, period: number, param = \"period\"): string {\n const [path = \"\", query = \"\"] = base.split(\"?\");\n const params = new URLSearchParams(query);\n params.set(param, String(period));\n return `${path}?${params.toString()}`;\n}\n\nconst WORDS = {\n fr: { vsPrevious: \"{change} vs période précédente\", same: \"stable\", up: \"en hausse\", down: \"en baisse\" },\n en: { vsPrevious: \"{change} vs previous period\", same: \"steady\", up: \"up\", down: \"down\" },\n} as const;\n\nexport type UsageWords = {\n /** The change against the previous period; `{change}` is replaced by the signed percentage. */\n vsPrevious: string;\n /** When the figure did not move. */\n same: string;\n};\n\nconst FLAT = 0.005;\n\nexport interface UsageTileInput {\n id: string;\n label: string;\n value: number;\n /** The same figure for the previous period: the trend is computed from it. */\n previous?: number;\n /** Which direction is good news (latency, failures: `down`). Default `up`. */\n good?: \"up\" | \"down\";\n /** The shape of the period, rendered by the app (a `Sparkline` of @krizaka/charts, 64 × 18). */\n chart?: React.ReactNode;\n /** Digits of the figure. Default 0. */\n digits?: number;\n}\n\nexport interface UsageTileOptions {\n /** Default `fr-CA`: French figures and words with no props. */\n /** The language of the figures and the words. Default `fr-CA`. */\n locale?: string;\n /** Your own words for the change: `{change}` is the percentage. */\n words?: Partial<UsageWords>;\n}\n\nconst wordsOf = (locale: string): (typeof WORDS)[keyof typeof WORDS] => (locale.toLowerCase().startsWith(\"en\") ? WORDS.en : WORDS.fr);\n\nfunction direction(change: number | null): StatTrend | undefined {\n if (change === null) return undefined;\n if (Math.abs(change) < FLAT) return \"flat\";\n return change > 0 ? \"up\" : \"down\";\n}\n\nfunction changeOf(value: number, previous: number | undefined): number | null {\n if (previous === undefined) return null;\n if (previous === 0) return value === 0 ? 0 : null;\n return value / previous - 1;\n}\n\n/** One strip figure: the value written for the locale, the change against the previous period said in words. */\nexport function usageTile(input: UsageTileInput, { locale = \"fr-CA\", words }: UsageTileOptions = {}): StatStripItem {\n const w = { ...wordsOf(locale), ...words };\n const change = changeOf(input.value, input.previous);\n const trend = direction(change);\n let text: string | undefined;\n if (change !== null) {\n text = trend === \"flat\" ? w.same : w.vsPrevious.replace(\"{change}\", formatPercent(change, { locale, signDisplay: \"exceptZero\", maximumFractionDigits: 0 }));\n }\n return {\n id: input.id,\n label: input.label,\n value: formatNumber(input.value, { locale, maximumFractionDigits: input.digits ?? 0 }),\n trend,\n trendLabel: text,\n chart: input.chart,\n };\n}\n\n/** One bar of the usage chart: a day, its counts by outcome. */\nexport interface UsageDay {\n /** The day, written by the app (`3 nov.`). */\n label: string;\n values: Readonly<Partial<Record<string, number>>>;\n}\n\nexport interface UsageOutcome {\n id: string;\n label: string;\n /** `accent`, `success`, `warning`, `danger` or `muted`: tones of the tokens, never a colour. */\n tone: \"accent\" | \"success\" | \"warning\" | \"danger\" | \"muted\";\n}\n\nexport interface UsageBar {\n label: string;\n total: number;\n /** Height of the whole bar, 0–1 of the tallest day. */\n height: number;\n segments: { id: string; value: number; share: number }[];\n}\n\n/** The bars of the chart: heights relative to the tallest day, segments as shares of their bar. */\nexport function usageBars(days: readonly UsageDay[], outcomes: readonly UsageOutcome[]): UsageBar[] {\n const totals = days.map((d) => outcomes.reduce((sum, o) => sum + (d.values[o.id] ?? 0), 0));\n const max = Math.max(1, ...totals);\n return days.map((d, i) => {\n const total = totals[i] ?? 0;\n return {\n label: d.label,\n total,\n height: total / max,\n segments: outcomes.map((o) => ({ id: o.id, value: d.values[o.id] ?? 0, share: total === 0 ? 0 : (d.values[o.id] ?? 0) / total })),\n };\n });\n}\n","// Server-safe. The blocks of a « Credits & usage » page: the balance on a Meter, the period switch (the address holds it),\n// the figures on the strip, the activity stacked by outcome. Words are props (French by default for the few built in);\n// figures are written with @krizaka/intl. Demo data only in the examples.\nimport { formatNumber } from \"@krizaka/intl\";\nimport type * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { BlockLink, type LinkComponent } from \"../block-link\";\nimport { Meter } from \"../meter\";\nimport { StatGrid } from \"../stat\";\nimport { periodHref, USAGE_PERIODS, type UsageBar, usageBars, type UsageDay, type UsageOutcome, usageTile,type UsageTileInput, type UsageTileOptions } from \"./model\";\n\nexport const usage = tv({\n slots: {\n credits: \"flex w-full min-w-0 flex-col gap-3 rounded-xl border border-border-default bg-surface-1 p-5\",\n creditsHead: \"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1\",\n creditsTitle: \"m-0 text-sm font-semibold text-fg-secondary\",\n creditsFigure: \"m-0 font-display text-3xl font-bold tabular-nums text-fg\",\n creditsFoot: \"m-0 flex flex-wrap items-center justify-between gap-x-4 gap-y-2 text-xs text-fg-secondary\",\n switchList: \"m-0 inline-flex list-none gap-1 rounded-lg border border-border-default bg-surface-1 p-1\",\n switchLink:\n \"inline-flex min-h-9 min-w-11 items-center justify-center rounded-md px-3 text-sm font-semibold tabular-nums text-fg-secondary no-underline transition-colors \" +\n \"hover:text-fg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring aria-[current=page]:bg-accent-soft aria-[current=page]:text-fg\",\n chart: \"m-0 flex w-full min-w-0 flex-col gap-3 rounded-xl border border-border-default bg-surface-1 p-5\",\n chartTitle: \"text-sm font-semibold text-fg\",\n plot: \"flex h-40 w-full items-end gap-1\",\n column: \"flex h-full min-w-0 flex-1 flex-col justify-end\",\n bar: \"flex w-full flex-col-reverse overflow-hidden rounded-sm\",\n legend: \"m-0 flex list-none flex-wrap gap-x-4 gap-y-1 p-0 text-xs text-fg-secondary\",\n swatch: \"mr-1.5 inline-block h-2 w-2 rounded-full align-baseline\",\n state: \"m-0 flex h-40 items-center justify-center rounded-lg border border-dashed border-border-default px-4 text-center text-sm text-fg-secondary\",\n skeleton: \"h-40 w-full animate-pulse rounded-lg bg-surface-3 motion-reduce:animate-none\",\n },\n variants: {\n tone: {\n accent: { swatch: \"bg-accent\" },\n success: { swatch: \"bg-success\" },\n warning: { swatch: \"bg-warning\" },\n danger: { swatch: \"bg-danger\" },\n muted: { swatch: \"bg-border-strong\" },\n },\n },\n});\n\nconst FILL: Record<UsageOutcome[\"tone\"], string> = { accent: \"bg-accent\", success: \"bg-success\", warning: \"bg-warning\", danger: \"bg-danger\", muted: \"bg-border-strong\" };\n\nconst CREDIT_WORDS = {\n fr: { of: \"sur\", left: \"restants\" },\n en: { of: \"of\", left: \"left\" },\n} as const;\n\nexport type CreditsMeterProps = Omit<React.ComponentProps<\"section\">, \"children\"> & {\n /** What the balance is (« Crédits »): the heading and the meter's name. */\n label: string;\n /** Credits left. */\n balance: number;\n /** The allowance of the period; the meter fills with what is left. */\n total: number;\n /** The renewal, written by the app (« Renouvelés le 1er novembre »). */\n renewal?: React.ReactNode;\n /** The way to buy more: a link or a button. */\n action?: React.ReactNode;\n /** Default `fr-CA`. */\n locale?: string;\n};\n\n/** The balance: the figure large, a meter that turns to warning then danger as it runs low, the renewal and the way to buy. */\nexport function CreditsMeter({ label, balance, total, renewal, action, locale = \"fr-CA\", className, ...props }: CreditsMeterProps) {\n const s = usage();\n const w = locale.toLowerCase().startsWith(\"en\") ? CREDIT_WORDS.en : CREDIT_WORDS.fr;\n const write = (n: number) => formatNumber(n, { locale });\n const words = `${write(balance)} ${w.of} ${write(total)}`;\n return (\n <section aria-label={label} className={s.credits({ className })} {...props}>\n <div className={s.creditsHead()}>\n <h3 className={s.creditsTitle()}>{label}</h3>\n <p className={s.creditsFigure()}>\n {write(balance)} <span className=\"sr-only\">{w.left}</span>\n </p>\n </div>\n <Meter label={label} value={balance} max={Math.max(1, total)} valueText={words} optimum=\"high\" thresholds={{ low: 0.2, high: 0.5 }} size=\"lg\" />\n <p className={s.creditsFoot()}>\n <span>{words}</span>\n {renewal ? <span>{renewal}</span> : null}\n {action}\n </p>\n </section>\n );\n}\n\nexport type PeriodSwitchProps = Omit<React.ComponentProps<\"nav\">, \"children\"> & {\n /** The accessible name (« Période »). */\n label: string;\n /** The period shown, from `parsePeriod(searchParams.period)`. */\n value: number;\n /** The page's path (and any other parameters); each period is a link to it with `?period=`. */\n href: string;\n /** The periods offered, in days. Default 7 · 30 · 90. */\n periods?: readonly number[];\n /** The query parameter. Default `period`. */\n param?: string;\n /** The text of a period. Default `7 j` (`7 d` for an English locale). */\n periodLabel?: (days: number) => string;\n /** Default `fr-CA`. */\n locale?: string;\n /** The app's router link (Next's `Link`); default a plain `<a>`. */\n linkAs?: LinkComponent;\n};\n\n/** 7 · 30 · 90 d: links, so the address holds the period (`?period=30`) and the server renders it. */\nexport function PeriodSwitch({ label, value, href, periods = USAGE_PERIODS, param = \"period\", periodLabel, locale = \"fr-CA\", linkAs, className, ...props }: PeriodSwitchProps) {\n const s = usage();\n const unit = locale.toLowerCase().startsWith(\"en\") ? \"d\" : \"j\";\n const text = periodLabel ?? ((days: number) => `${days} ${unit}`);\n return (\n <nav aria-label={label} className={className} {...props}>\n <ul className={s.switchList()}>\n {periods.map((days) => (\n <li key={days}>\n <BlockLink href={periodHref(href, days, param)} linkAs={linkAs} className={s.switchLink()} aria-current={days === value ? \"page\" : undefined}>\n {text(days)}\n </BlockLink>\n </li>\n ))}\n </ul>\n </nav>\n );\n}\n\nexport type UsageTilesProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n /** 2 to 4 figures. */\n tiles: readonly UsageTileInput[];\n /** The period switch, above the row. */\n period?: React.ReactNode;\n /** The data is on its way: the row keeps its height. */\n loading?: boolean;\n} & UsageTileOptions;\n\n/** The figures of the period on the strip, each compared with the previous period in words. */\nexport function UsageTiles({ tiles, period, loading, locale, words, className, ...props }: UsageTilesProps) {\n const s = usage();\n if (loading) return <div aria-busy=\"true\" className={s.skeleton({ className: [\"h-20\", className].filter(Boolean).join(\" \") })} {...props} />;\n return <StatGrid variant=\"strip\" items={tiles.map((t) => usageTile(t, { locale, words }))} period={period} className={className} {...props} />;\n}\n\nexport type UsageChartProps = Omit<React.ComponentProps<\"figure\">, \"children\"> & {\n /** What it draws (« Activité par résultat »). */\n title: string;\n /** The days, oldest first. */\n days: readonly UsageDay[];\n /** The outcomes stacked in each bar, bottom first. */\n outcomes: readonly UsageOutcome[];\n /** Said when there is nothing in the period. */\n emptyLabel: string;\n /** The text version's column headings: the day, the total. */\n columns: { day: string; total: string };\n /** The data is on its way: a skeleton keeps the height. */\n loading?: boolean;\n /** Default `fr-CA`. */\n locale?: string;\n};\n\nfunction Column({ bar, outcomes }: Readonly<{ bar: UsageBar; outcomes: readonly UsageOutcome[] }>) {\n const s = usage();\n return (\n <div className={s.column()}>\n <div className={s.bar()} style={{ height: `${bar.height * 100}%` }}>\n {bar.segments.map((seg, i) =>\n seg.value > 0 ? <span key={seg.id} className={FILL[outcomes[i]?.tone ?? \"muted\"]} style={{ height: `${seg.share * 100}%` }} /> : null,\n )}\n </div>\n </div>\n );\n}\n\n/** The activity of the period, one bar per day stacked by outcome — with its legend and its text version (a table). */\nexport function UsageChart({ title, days, outcomes, emptyLabel, columns, loading, locale = \"fr-CA\", className, ...props }: UsageChartProps) {\n const s = usage();\n const bars = usageBars(days, outcomes);\n const sum = (id: string) => days.reduce((n, d) => n + (d.values[id] ?? 0), 0);\n const empty = bars.every((b) => b.total === 0);\n const write = (n: number) => formatNumber(n, { locale });\n return (\n <figure aria-busy={loading || undefined} className={s.chart({ className })} {...props}>\n <figcaption className={s.chartTitle()}>{title}</figcaption>\n {loading && <div className={s.skeleton()} />}\n {!loading && empty && <p className={s.state()}>{emptyLabel}</p>}\n {!loading && !empty && (\n <>\n <div aria-hidden className={s.plot()}>\n {bars.map((bar) => (\n <Column key={bar.label} bar={bar} outcomes={outcomes} />\n ))}\n </div>\n <ul className={s.legend()}>\n {outcomes.map((o) => (\n <li key={o.id}>\n <span aria-hidden className={s.swatch({ tone: o.tone })} />\n {o.label} <span className=\"tabular-nums text-fg\">{write(sum(o.id))}</span>\n </li>\n ))}\n </ul>\n <table className=\"sr-only\">\n <caption>{title}</caption>\n <thead>\n <tr>\n <th scope=\"col\">{columns.day}</th>\n {outcomes.map((o) => (\n <th key={o.id} scope=\"col\">\n {o.label}\n </th>\n ))}\n <th scope=\"col\">{columns.total}</th>\n </tr>\n </thead>\n <tbody>\n {days.map((d, i) => (\n <tr key={d.label}>\n <th sc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AAC,KAAhC,EAAE,EAAgC,CAC5C;AAAA,UACD,oBAAC,QAAI,gBAAM,KAAK,CAAC,GAAG,SAAS,CAAC,GAAE;AAAA,aALzB,EAAE,KAMX,CACD,GACH;AAAA,SACF;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":["formatNumber","formatNumber"]}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  Mascot
4
- } from "./chunk-FM42KOAU.js";
4
+ } from "./chunk-P7AFIKWG.js";
5
5
  import {
6
6
  cn
7
7
  } from "./chunk-NSLXEDIS.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/versus-card/versus-card.tsx"],"sourcesContent":["// Client (the birds hold an id). The arcade « character select » card of the Krizaka style (blocks.css): two subjects face to\n// face — a component and its alternative, two releases — each a bird as the fighter, with stat bars, and a « VS » mark between\n// them. Every bar is a real figure passed in by the host (`value` of `max`, and its text), read as a definition list: the bars\n// repeat the numbers, they never replace them. No winner is computed: the reader compares.\nimport type * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport type { MascotBird } from \"../mascots/geometry\";\nimport { Mascot } from \"../mascots/mascot\";\n\nexport interface FighterStat {\n /** What is measured (`Bundle size`, `Coverage`). */\n label: string;\n /** The measured value, from 0 to `max`. Real data: a stat that is not a finite number is left out. */\n value: number;\n /** The top of the bar. @default 100 */\n max?: number;\n /** The value as the reader reads it (`4.1 kB`, `92 %`); `value` when omitted. */\n display?: React.ReactNode;\n}\n\nexport interface Fighter {\n /** The subject's name (`@krizaka/ui 2.7`, `Radix Dialog`). */\n name: React.ReactNode;\n /** The bird that fights for it. */\n bird: MascotBird;\n /** One line under the name. */\n caption?: React.ReactNode;\n /** Its stat bars, from real data. */\n stats: readonly FighterStat[];\n}\n\nexport type VersusCardProps = Omit<React.HTMLAttributes<HTMLElement>, \"title\"> & {\n /** The accessible name of the match: `Krizaka UI 2.7 versus 2.6`. */\n label: string;\n /** The subject on the left. */\n left: Fighter;\n /** The subject on the right (its bird faces left). */\n right: Fighter;\n /** The mark between them. @default \"VS\" */\n vs?: React.ReactNode;\n /** Where the figures come from, under the card. */\n source?: React.ReactNode;\n};\n\nfunction FighterPane({ fighter, side }: { fighter: Fighter; side: \"left\" | \"right\" }) {\n const stats = fighter.stats.filter((s) => Number.isFinite(s.value) && Number.isFinite(s.max ?? 100) && (s.max ?? 100) > 0);\n return (\n <div className=\"kz-versus-fighter\" data-side={side}>\n <div className=\"kz-versus-bird\" aria-hidden=\"true\">\n <Mascot bird={fighter.bird} tone=\"own\" size={104} animated={false} />\n </div>\n <p className=\"kz-versus-name\">{fighter.name}</p>\n {fighter.caption && <p className=\"kz-versus-caption\">{fighter.caption}</p>}\n <dl className=\"kz-versus-stats\">\n {stats.map((s) => {\n const fill = Math.min(100, Math.max(0, (s.value / (s.max ?? 100)) * 100));\n return (\n <div key={s.label} className=\"kz-versus-stat\">\n <dt>{s.label}</dt>\n <dd>\n <span className=\"kz-versus-value\">{s.display ?? s.value}</span>\n <span className=\"kz-versus-bar\" aria-hidden=\"true\" style={{ [\"--kz-versus-fill\" as string]: `${Math.round(fill * 10) / 10}%` }} />\n </dd>\n </div>\n );\n })}\n </dl>\n </div>\n );\n}\n\n/** An arcade versus card: two subjects face to face, a bird each, stat bars from real data, a « VS » between them. */\nexport function VersusCard({ label, left, right, vs = \"VS\", source, className, ...props }: VersusCardProps) {\n return (\n <section className={cn(\"kz-versus\", className)} aria-label={label} {...props}>\n <FighterPane fighter={left} side=\"left\" />\n <span className=\"kz-versus-mark\">{vs}</span>\n <FighterPane fighter={right} side=\"right\" />\n {source && <p className=\"kz-versus-source\">{source}</p>}\n </section>\n );\n}\n"],"mappings":";;;;;;;;;AAkDQ,cAUM,YAVN;AALR,SAAS,YAAY,EAAE,SAAS,KAAK,GAAiD;AACpF,QAAM,QAAQ,QAAQ,MAAM,OAAO,CAAC,MAAM,OAAO,SAAS,EAAE,KAAK,KAAK,OAAO,SAAS,EAAE,OAAO,GAAG,MAAM,EAAE,OAAO,OAA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3,"sources":["../src/versus-card/versus-card.tsx"],"sourcesContent":["// Client (the birds hold an id). The arcade « character select » card of the Krizaka style (blocks.css): two subjects face to\n// face — a component and its alternative, two releases — each a bird as the fighter, with stat bars, and a « VS » mark between\n// them. Every bar is a real figure passed in by the host (`value` of `max`, and its text), read as a definition list: the bars\n// repeat the numbers, they never replace them. No winner is computed: the reader compares.\nimport type * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport type { MascotBird } from \"../mascots/geometry\";\nimport { Mascot } from \"../mascots/mascot\";\n\nexport interface FighterStat {\n /** What is measured (`Bundle size`, `Coverage`). */\n label: string;\n /** The measured value, from 0 to `max`. Real data: a stat that is not a finite number is left out. */\n value: number;\n /** The top of the bar. @default 100 */\n max?: number;\n /** The value as the reader reads it (`4.1 kB`, `92 %`); `value` when omitted. */\n display?: React.ReactNode;\n}\n\nexport interface Fighter {\n /** The subject's name (`@krizaka/ui 2.7`, `Radix Dialog`). */\n name: React.ReactNode;\n /** The bird that fights for it. */\n bird: MascotBird;\n /** One line under the name. */\n caption?: React.ReactNode;\n /** Its stat bars, from real data. */\n stats: readonly FighterStat[];\n}\n\nexport type VersusCardProps = Omit<React.HTMLAttributes<HTMLElement>, \"title\"> & {\n /** The accessible name of the match: `Krizaka UI 2.7 versus 2.6`. */\n label: string;\n /** The subject on the left. */\n left: Fighter;\n /** The subject on the right (its bird faces left). */\n right: Fighter;\n /** The mark between them. @default \"VS\" */\n vs?: React.ReactNode;\n /** Where the figures come from, under the card. */\n source?: React.ReactNode;\n};\n\nfunction FighterPane({ fighter, side }: Readonly<{ fighter: Fighter; side: \"left\" | \"right\" }>) {\n const stats = fighter.stats.filter((s) => Number.isFinite(s.value) && Number.isFinite(s.max ?? 100) && (s.max ?? 100) > 0);\n return (\n <div className=\"kz-versus-fighter\" data-side={side}>\n <div className=\"kz-versus-bird\" aria-hidden=\"true\">\n <Mascot bird={fighter.bird} tone=\"own\" size={104} animated={false} />\n </div>\n <p className=\"kz-versus-name\">{fighter.name}</p>\n {fighter.caption && <p className=\"kz-versus-caption\">{fighter.caption}</p>}\n <dl className=\"kz-versus-stats\">\n {stats.map((s) => {\n const fill = Math.min(100, Math.max(0, (s.value / (s.max ?? 100)) * 100));\n return (\n <div key={s.label} className=\"kz-versus-stat\">\n <dt>{s.label}</dt>\n <dd>\n <span className=\"kz-versus-value\">{s.display ?? s.value}</span>\n <span className=\"kz-versus-bar\" aria-hidden=\"true\" style={{ [\"--kz-versus-fill\" as string]: `${Math.round(fill * 10) / 10}%` }} />\n </dd>\n </div>\n );\n })}\n </dl>\n </div>\n );\n}\n\n/** An arcade versus card: two subjects face to face, a bird each, stat bars from real data, a « VS » between them. */\nexport function VersusCard({ label, left, right, vs = \"VS\", source, className, ...props }: VersusCardProps) {\n return (\n <section className={cn(\"kz-versus\", className)} aria-label={label} {...props}>\n <FighterPane fighter={left} side=\"left\" />\n <span className=\"kz-versus-mark\">{vs}</span>\n <FighterPane fighter={right} side=\"right\" />\n {source && <p className=\"kz-versus-source\">{source}</p>}\n </section>\n );\n}\n"],"mappings":";;;;;;;;;AAkDQ,cAUM,YAVN;AALR,SAAS,YAAY,EAAE,SAAS,KAAK,GAA2D;AAC9F,QAAM,QAAQ,QAAQ,MAAM,OAAO,CAAC,MAAM,OAAO,SAAS,EAAE,KAAK,KAAK,OAAO,SAAS,EAAE,OAAO,GAAG,MAAM,EAAE,OAAO,OAAO,CAAC;AACzH,SACE,qBAAC,SAAI,WAAU,qBAAoB,aAAW,MAC5C;AAAA,wBAAC,SAAI,WAAU,kBAAiB,eAAY,QAC1C,8BAAC,UAAO,MAAM,QAAQ,MAAM,MAAK,OAAM,MAAM,KAAK,UAAU,OAAO,GACrE;AAAA,IACA,oBAAC,OAAE,WAAU,kBAAkB,kBAAQ,MAAK;AAAA,IAC3C,QAAQ,WAAW,oBAAC,OAAE,WAAU,qBAAqB,kBAAQ,SAAQ;AAAA,IACtE,oBAAC,QAAG,WAAU,mBACX,gBAAM,IAAI,CAAC,MAAM;AAChB,YAAM,OAAO,KAAK,IAAI,KAAK,KAAK,IAAI,GAAI,EAAE,SAAS,EAAE,OAAO,OAAQ,GAAG,CAAC;AACxE,aACE,qBAAC,SAAkB,WAAU,kBAC3B;AAAA,4BAAC,QAAI,YAAE,OAAM;AAAA,QACb,qBAAC,QACC;AAAA,8BAAC,UAAK,WAAU,mBAAmB,YAAE,WAAW,EAAE,OAAM;AAAA,UACxD,oBAAC,UAAK,WAAU,iBAAgB,eAAY,QAAO,OAAO,EAAE,CAAC,kBAA4B,GAAG,GAAG,KAAK,MAAM,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG;AAAA,WAClI;AAAA,WALQ,EAAE,KAMZ;AAAA,IAEJ,CAAC,GACH;AAAA,KACF;AAEJ;AAGO,SAAS,WAAW,EAAE,OAAO,MAAM,OAAO,KAAK,MAAM,QAAQ,WAAW,GAAG,MAAM,GAAoB;AAC1G,SACE,qBAAC,aAAQ,WAAW,GAAG,aAAa,SAAS,GAAG,cAAY,OAAQ,GAAG,OACrE;AAAA,wBAAC,eAAY,SAAS,MAAM,MAAK,QAAO;AAAA,IACxC,oBAAC,UAAK,WAAU,kBAAkB,cAAG;AAAA,IACrC,oBAAC,eAAY,SAAS,OAAO,MAAK,SAAQ;AAAA,IACzC,UAAU,oBAAC,OAAE,WAAU,oBAAoB,kBAAO;AAAA,KACrD;AAEJ;","names":[]}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  Avatar
4
- } from "./chunk-PK3L6WQT.js";
4
+ } from "./chunk-LNAAWT4Y.js";
5
5
  import {
6
6
  IconButton
7
7
  } from "./chunk-ZPOVOEO3.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/vertical-video/short-feed.tsx","../src/vertical-video/vertical-video.tsx","../src/verified-badge/verified-badge.tsx","../src/vertical-video/model.ts"],"sourcesContent":["// Client (an observer, keys). A vertical feed of short videos: one slide per screen, CSS scroll-snap, the slide in view\n// plays and the others pause, the next one preloads, only the slides near the one in view are mounted (the rest keep their\n// height). ↑/↓ (and PageUp/PageDown) go to the previous / next, with the focus following.\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\n\nexport interface ShortFeedProps<T> extends Omit<React.ComponentProps<\"section\">, \"children\"> {\n /** The feed's accessible name (\"Videos\"), passed translated. */\n label: string;\n /** The videos, in order. */\n items: readonly T[];\n /** A stable key for an item. */\n getId: (item: T) => string;\n /** One slide: `active` is true for the one in view, `preload` for the next, `near` false for the ones kept empty. */\n renderItem: (item: T, state: { active: boolean; preload: \"none\" | \"metadata\" | \"auto\"; index: number }) => React.ReactNode;\n /** The slides mounted around the one in view (before and after). Default 1; the others keep their height empty. */\n window?: number;\n /** Called when the slide in view changes. */\n onActiveChange?: (index: number, item: T) => void;\n}\n\n/** A vertical snap-scrolling feed that plays the video in view, preloads the next and pauses the rest. */\nexport function ShortFeed<T>({ label, items, getId, renderItem, window: around = 1, onActiveChange, className, onKeyDown, ...props }: ShortFeedProps<T>) {\n const root = React.useRef<HTMLElement>(null);\n const [active, setActive] = React.useState(0);\n const slides = React.useRef<(HTMLDivElement | null)[]>([]);\n\n React.useEffect(() => {\n const host = root.current;\n if (!host || typeof IntersectionObserver === \"undefined\") return;\n const observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (!entry.isIntersecting || entry.intersectionRatio < 0.6) continue;\n const index = Number((entry.target as HTMLElement).dataset.index);\n setActive(index);\n }\n },\n { root: host, threshold: [0.6] },\n );\n for (const slide of slides.current) if (slide) observer.observe(slide);\n return () => observer.disconnect();\n }, [items.length]);\n\n const first = React.useRef(true);\n React.useEffect(() => {\n if (first.current) {\n first.current = false;\n return;\n }\n const item = items[active];\n if (item !== undefined) onActiveChange?.(active, item);\n // Only a change of the slide in view is an event.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [active]);\n\n const go = (index: number) => {\n const target = slides.current[Math.max(0, Math.min(items.length - 1, index))];\n if (!target) return;\n target.scrollIntoView({ behavior: window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches ? \"auto\" : \"smooth\", block: \"start\" });\n target.querySelector<HTMLElement>(\"article\")?.focus({ preventScroll: true });\n };\n\n return (\n <section\n ref={root}\n aria-label={label}\n aria-roledescription=\"carousel\"\n className={cn(\"h-dvh snap-y snap-mandatory overflow-y-auto overscroll-contain bg-surface-0 [scrollbar-width:none]\", className)}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (event.key === \"ArrowDown\" || event.key === \"PageDown\") {\n event.preventDefault();\n go(active + 1);\n } else if (event.key === \"ArrowUp\" || event.key === \"PageUp\") {\n event.preventDefault();\n go(active - 1);\n }\n }}\n {...props}\n >\n {items.map((item, index) => {\n const near = Math.abs(index - active) <= around;\n return (\n <div\n key={getId(item)}\n ref={(el) => {\n slides.current[index] = el;\n }}\n data-index={index}\n role=\"group\"\n aria-roledescription=\"slide\"\n aria-label={`${index + 1} / ${items.length}`}\n className=\"mx-auto flex h-full max-w-[calc(100dvh*9/16)] snap-start snap-always items-center\"\n >\n {near ? renderItem(item, { active: index === active, preload: index === active + 1 ? \"auto\" : index === active ? \"auto\" : \"none\", index }) : null}\n </div>\n );\n })}\n </section>\n );\n}\n","// Client (a video element, an observer, keys). A 9:16 clip filling its frame, with the action rail of a short-video feed on\n// the right (avatar + follow, like, comment, share, a slot for tip / unlock, more) and the caption block bottom-left. Every\n// word is a prop; counts are formatted with @krizaka/intl; everything over the picture reads on the invariant `scrim` /\n// `fg-on-media` tokens, so it is legible in both themes. Under reduced motion nothing autoplays: the poster and a play button.\nimport { formatCompact } from \"@krizaka/intl\";\nimport * as React from \"react\";\n\nimport { Avatar } from \"../avatar/avatar\";\nimport { IconButton } from \"../button/button\";\nimport { cn } from \"../cn\";\nimport { VerifiedBadge } from \"../verified-badge/verified-badge\";\nimport { type VerticalVideoLabels, verticalVideoLabels, type VerticalVideoShared } from \"./model\";\n\nexport { type VerticalVideoLabels, verticalVideoLabels };\n\nexport interface VerticalVideoCreator {\n name: string;\n /** Their portrait. */\n avatarSrc?: string;\n /** The seal's words (\"Verified\"): shows the seal beside the name. */\n verifiedLabel?: string;\n}\n\nexport interface VerticalVideoProps extends Omit<React.ComponentProps<\"article\">, \"title\" | \"children\">, VerticalVideoShared {\n /** The clip — absent, the poster alone shows (MP4 or WebM; an HLS address only in Safari — use the player of `@krizaka/ui/video-player` for HLS). */\n src?: string;\n /** The picture until the first frame, and under reduced motion. */\n poster?: string;\n /** The next slide's: `auto` loads it ahead, `none` waits. Default `metadata`. */\n preload?: \"none\" | \"metadata\" | \"auto\";\n /** Plays again at the end. Default `true`. */\n loop?: boolean;\n /** Starts muted (autoplay needs it). Default `true`. */\n muted?: boolean;\n /** Who made it: name, portrait, the seal's words. */\n creator: VerticalVideoCreator;\n /**\n * How it takes its space: `frame` draws its own 9:16 box from its width; `fill` fills the box it is given (a bento\n * tile, a grid cell, a phone frame) — the clip covers it, cropped at the edges, the rail and the caption over it.\n * @default \"frame\"\n */\n fit?: \"frame\" | \"fill\";\n}\n\nconst glyph = (d: string) => (\n <svg viewBox=\"0 0 24 24\" className=\"h-6 w-6\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d={d} />\n </svg>\n);\nconst HEART = \"M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10z\";\nconst COMMENT = \"M4 5h16v11H9l-5 4z\";\nconst SHARE = \"M4 12v7h16v-7M12 3v12M7 8l5-5 5 5\";\nconst MORE = \"M5 12h.01M12 12h.01M19 12h.01\";\n\nconst useReducedMotion = () =>\n React.useSyncExternalStore(\n (notify) => {\n const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n query.addEventListener(\"change\", notify);\n return () => query.removeEventListener(\"change\", notify);\n },\n () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n () => false,\n );\n\n/** One short video: 9:16, the rail of actions on the right, the creator's caption bottom-left, a progress hairline. */\nexport function VerticalVideo({\n title,\n src,\n poster,\n active = true,\n preload = \"metadata\",\n loop = true,\n muted = true,\n creator,\n disclosure,\n caption,\n tags = [],\n credit,\n likes,\n comments,\n shares,\n liked = false,\n following = false,\n onLike,\n onComment,\n onShare,\n onFollow,\n onMore,\n tipSlot,\n topStart,\n aboveCaption,\n fit = \"frame\",\n locale = \"en\",\n labels: custom,\n className,\n onKeyDown,\n ...props\n}: VerticalVideoProps) {\n const labels = { ...verticalVideoLabels, ...custom };\n const reduce = useReducedMotion();\n const video = React.useRef<HTMLVideoElement>(null);\n const [playing, setPlaying] = React.useState(false);\n const [paused, setPaused] = React.useState(false); // the viewer's pause: it holds until they play again\n const [progress, setProgress] = React.useState(0);\n const [open, setOpen] = React.useState(false);\n const [heart, setHeart] = React.useState(0);\n\n const shouldPlay = active && !paused && !reduce;\n React.useEffect(() => {\n const el = video.current;\n if (!el) return;\n if (shouldPlay) void el.play().catch(() => undefined);\n else el.pause();\n }, [shouldPlay, src]);\n\n const press = () => {\n const el = video.current;\n if (!el) return;\n if (el.paused) {\n setPaused(false);\n void el.play().catch(() => undefined);\n } else {\n setPaused(true);\n el.pause();\n }\n };\n const like = () => onLike?.(!liked);\n const doubleTap = () => {\n if (!liked) like();\n setHeart((n) => n + 1); // a heart blooms over the picture (still under reduced motion: it shows and goes)\n };\n const count = (n?: number) => (n === undefined ? undefined : formatCompact(n, { locale }));\n const name = creator.name;\n\n return (\n <article\n aria-label={title}\n tabIndex={0}\n data-playing={playing ? \"\" : undefined}\n data-fit={fit}\n className={cn(\"relative isolate w-full overflow-hidden\", fit === \"fill\" ? \"h-full min-h-0\" : \"aspect-[9/16]\", \"bg-surface-0 text-fg-on-media focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\", className)}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || event.target !== event.currentTarget) return;\n if (event.key === \" \" || event.key.toLowerCase() === \"k\") {\n event.preventDefault();\n press();\n } else if (event.key.toLowerCase() === \"l\") like();\n }}\n {...props}\n >\n <video\n ref={video}\n src={src}\n poster={poster}\n muted={muted}\n loop={loop}\n playsInline\n preload={preload}\n className=\"absolute inset-0 -z-10 h-full w-full object-cover\"\n onPlay={() => setPlaying(true)}\n onPause={() => setPlaying(false)}\n onTimeUpdate={(event) => {\n const el = event.currentTarget;\n setProgress(el.duration ? el.currentTime / el.duration : 0);\n }}\n />\n {/* The tap target: a tap pauses or plays, a double tap likes. It is a button, so the keyboard has it too. */}\n <button type=\"button\" aria-label={playing ? labels.pause : labels.play} onClick={press} onDoubleClick={doubleTap} className=\"absolute inset-0 cursor-pointer bg-transparent focus-visible:outline-hidden\">\n {!playing && (\n <span aria-hidden className=\"absolute left-1/2 top-1/2 grid h-16 w-16 -translate-x-1/2 -translate-y-1/2 place-items-center rounded-full bg-scrim backdrop-blur-md\">\n <svg viewBox=\"0 0 24 24\" className=\"h-7 w-7\" fill=\"currentColor\"><path d=\"M8 5v14l11-7z\" /></svg>\n </span>\n )}\n </button>\n {heart > 0 && (\n <span key={heart} aria-hidden className=\"pointer-events-none absolute left-1/2 top-1/2 grid -translate-x-1/2 -translate-y-1/2 place-items-center text-accent motion-safe:animate-ping\">\n <svg viewBox=\"0 0 24 24\" className=\"h-20 w-20\" fill=\"currentColor\"><path d={HEART} /></svg>\n </span>\n )}\n <div aria-hidden className=\"pointer-events-none absolute inset-x-0 bottom-0 h-2/5 bg-linear-to-t from-scrim to-transparent\" />\n {topStart && <div className=\"absolute left-3 top-3\">{topStart}</div>}\n\n <div role=\"group\" aria-label={labels.actions} className=\"absolute bottom-16 right-2 flex flex-col items-center gap-3\">\n <div className=\"relative\">\n <Avatar src={creator.avatarSrc} alt={name} fallback={name.slice(0, 1)} size=\"md\" className=\"ring-2 ring-white\" />\n {onFollow && (\n <IconButton\n label={format(following ? labels.following : labels.follow, name)}\n aria-pressed={following}\n size=\"icon\"\n variant={following ? \"secondary\" : \"primary\"}\n shape=\"pill\"\n onClick={() => onFollow(!following)}\n className=\"absolute -bottom-3 left-1/2 h-6 min-h-6 w-6 min-w-6 -translate-x-1/2 p-0\"\n >\n {glyph(following ? \"M5 12l5 5 9-10\" : \"M12 5v14M5 12h14\")}\n </IconButton>\n )}\n </div>\n <Rail label={labels.like} count={count(likes)} pressed={liked} onClick={like} tone={liked ? \"text-accent\" : undefined}>\n <svg viewBox=\"0 0 24 24\" className=\"h-6 w-6\" fill={liked ? \"currentColor\" : \"none\"} stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden><path d={HEART} /></svg>\n </Rail>\n <Rail label={labels.comment} count={count(comments)} onClick={onComment}>{glyph(COMMENT)}</Rail>\n <Rail label={labels.share} count={count(shares)} onClick={onShare}>{glyph(SHARE)}</Rail>\n {tipSlot}\n {onMore && <Rail label={labels.more} onClick={onMore}>{glyph(MORE)}</Rail>}\n </div>\n\n <div className=\"absolute bottom-4 left-3 right-16 flex min-w-0 flex-col gap-1.5\">\n {aboveCaption}\n <p className=\"flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-sm font-bold\">\n {name}\n {creator.verifiedLabel && <VerifiedBadge label={creator.verifiedLabel} onMedia size=\"sm\" />}\n {disclosure && <span className=\"whitespace-nowrap rounded-full bg-scrim px-2 py-0.5 text-[10px] font-bold uppercase tracking-wide text-fg-on-media backdrop-blur-md\">{disclosure}</span>}\n </p>\n {caption && (\n <p className={cn(\"text-sm leading-snug\", !open && \"line-clamp-2\")}>\n {caption}\n {tags.length > 0 && <span className=\"font-semibold\"> {tags.map((tag) => `#${tag}`).join(\" \")}</span>}\n </p>\n )}\n {caption && caption.length > 90 && (\n <button type=\"button\" aria-expanded={open} onClick={() => setOpen((v) => !v)} className=\"w-fit rounded text-xs font-semibold underline focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\">\n {open ? labels.collapse : labels.expand}\n </button>\n )}\n {credit && <p className=\"text-xs opacity-90\">{credit}</p>}\n </div>\n\n <div role=\"progressbar\" aria-label={labels.progress} aria-valuemin={0} aria-valuemax={100} aria-valuenow={Math.round(progress * 100)} className=\"absolute inset-x-0 bottom-0 h-1 bg-scrim\">\n <div className=\"h-full bg-white\" style={{ width: `${progress * 100}%` }} />\n </div>\n </article>\n );\n}\n\n/** \"Follow {name}\" → \"Follow Elena\". */\nconst format = (message: string, name: string) => message.replace(\"{name}\", name);\n\nfunction Rail({ label, count, pressed, onClick, tone, children }: { label: string; count?: string | undefined; pressed?: boolean; onClick?: (() => void) | undefined; tone?: string | undefined; children: React.ReactNode }) {\n return (\n <div className=\"flex flex-col items-center gap-0.5\">\n <IconButton label={label} aria-pressed={pressed} variant=\"ghost\" shape=\"pill\" onClick={onClick} className={cn(\"h-11 min-h-11 w-11 min-w-11 bg-scrim text-fg-on-media backdrop-blur-md hover:bg-scrim\", tone)}>\n {children}\n </IconButton>\n {count !== undefined && <span className=\"text-xs font-semibold tabular-nums\">{count}</span>}\n </div>\n );\n}\n","// Server-safe. A seal that says the person or the account was verified: the accent, named in words.\nimport type * as React from \"react\";\n\nexport type VerifiedBadgeProps = Omit<React.ComponentProps<\"span\">, \"children\"> & {\n /** Its words (“Verified”), read — and shown with `showLabel` — passed translated. */\n label: string;\n /** Show the words beside the seal. Default false: the seal alone, named. */\n showLabel?: boolean;\n /** The seal's size: sm (14 px), md (16 px, default), lg (20 px). */\n size?: \"sm\" | \"md\" | \"lg\";\n /** On a photo: a ring of the media around the seal. */\n onMedia?: boolean;\n};\n\nconst SIZE = { sm: \"h-3.5 w-3.5\", md: \"h-4 w-4\", lg: \"h-5 w-5\" } as const;\n\n/** A seal that says the person or the account was verified (a selfie check, an ID), named in words. */\nexport function VerifiedBadge({ label, showLabel, size = \"md\", onMedia, className, ...props }: VerifiedBadgeProps) {\n return (\n <span role=\"img\" aria-label={label} className={[\"inline-flex items-center gap-1 text-xs font-bold\", onMedia ? \"text-fg-on-media\" : \"text-fg-accent\", className].filter(Boolean).join(\" \")} {...props}>\n <svg viewBox=\"0 0 24 24\" className={[SIZE[size], \"shrink-0\"].join(\" \")} aria-hidden>\n <path\n d=\"M12 2.5l2.4 1.7 2.9-.1.9 2.8 2.3 1.8-.9 2.8.9 2.8-2.3 1.8-.9 2.8-2.9-.1L12 21.5l-2.4-1.7-2.9.1-.9-2.8-2.3-1.8.9-2.8-.9-2.8 2.3-1.8.9-2.8 2.9.1z\"\n className={onMedia ? \"fill-accent stroke-fg-on-media\" : \"fill-accent\"}\n strokeWidth=\"1.2\"\n />\n <path d=\"M8.3 12.3l2.5 2.5 4.9-5.2\" fill=\"none\" className=\"stroke-on-accent\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n {showLabel ? <span aria-hidden>{label}</span> : null}\n </span>\n );\n}\n","// Headless: what the web (`vertical-video.tsx`) and the native (`native/vertical-video.tsx`) VerticalVideo share — the words,\n// the content and the callbacks. Each platform adds its media (`src`/`poster` · `uri`/`posterUri`) and its frame.\nimport type * as React from \"react\";\n\nexport interface VerticalVideoLabels {\n /** \"Play\" / \"Pause\" — the tap target over the picture. */\n play: string;\n pause: string;\n /** \"Like\" / \"Unlike\" (the button's name; the state is `aria-pressed`). */\n like: string;\n comment: string;\n share: string;\n more: string;\n /** \"Follow Elena\" — `{name}` is replaced by the creator's name. */\n follow: string;\n /** \"Following Elena\". */\n following: string;\n /** \"More\" / \"Less\" on a long caption. */\n expand: string;\n collapse: string;\n /** The progress bar's name (\"Progress\"). */\n progress: string;\n /** The rail's name (\"Actions\"). */\n actions: string;\n}\n\nexport const verticalVideoLabels: VerticalVideoLabels = {\n play: \"Play\",\n pause: \"Pause\",\n like: \"Like\",\n comment: \"Comments\",\n share: \"Share\",\n more: \"More\",\n follow: \"Follow {name}\",\n following: \"Following {name}\",\n expand: \"More\",\n collapse: \"Less\",\n progress: \"Progress\",\n actions: \"Actions\",\n};\n\n/** The props both platforms read: the same content, counts, state, callbacks and slots. */\nexport interface VerticalVideoShared {\n /** The video's accessible name (\"Video: Night shoot, part 2\"), passed translated. */\n title: string;\n /** Plays while `true`; a `ShortFeed` passes it for the slide in view. Default `true`. */\n active?: boolean;\n /** A pill beside the name: \"AI-GENERATED\" — said on the picture, never only in a page's footnote. */\n disclosure?: string;\n /** The caption: collapsed to two lines, expandable when long. */\n caption?: string;\n /** Tags under the caption (without `#`). */\n tags?: readonly string[];\n /** The sound or credit line (\"Original sound — Elena\"). */\n credit?: string;\n /** The like count under its button, compact (`12.4K`) in `locale`. */\n likes?: number;\n /** The comment count under its button. */\n comments?: number;\n /** The share count under its button. */\n shares?: number;\n /** Whether the viewer likes it: `aria-pressed` on the like button. */\n liked?: boolean;\n /** Whether the viewer follows the creator: the \"+\" on the avatar becomes a check. */\n following?: boolean;\n /** The viewer likes or unlikes (the button, `L`, a double tap). */\n onLike?: (liked: boolean) => void;\n /** Opens the comments; without it the button still shows. */\n onComment?: () => void;\n /** Opens the share sheet. */\n onShare?: () => void;\n /** The viewer follows or unfollows; without it the avatar has no \"+\". */\n onFollow?: (following: boolean) => void;\n /** The \"more\" button's action (report, hide); without it the button is not drawn. */\n onMore?: () => void;\n /** The product's own action on the rail: a tip, an unlock — a button of yours (≥ 44 px, named). */\n tipSlot?: React.ReactNode;\n /** Top left: a chip over the picture (an auction's time left). */\n topStart?: React.ReactNode;\n /** Above the caption: a goal gauge, a challenge's progress. */\n aboveCaption?: React.ReactNode;\n /** The locale of the counts. Default `en`. */\n locale?: string;\n /** Every word, passed translated. */\n labels?: Partial<VerticalVideoLabels>;\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,YAAY,WAAW;AAmFb;AA/DH,SAAS,UAAa,EAAE,OAAO,OAAO,OAAO,YAAY,QAAQ,SAAS,GAAG,gBAAgB,WAAW,WAAW,GAAG,MAAM,GAAsB;AACvJ,QAAM,OAAa,aAAoB,IAAI;AAC3C,QAAM,CAAC,QAAQ,SAAS,IAAU,eAAS,CAAC;AAC5C,QAAM,SAAe,aAAkC,CAAC,CAAC;AAEzD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K,iBAAe,KAAK,MAAM,WAAW,GAAG,GAAG,WAAU,4CAC9I,0BAAAA,KAAC,SAAI,WAAU,mBAAkB,OAAO,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,GAAG,GAC3E;AAAA;AAAA;AAAA,EACF;AAEJ;AAGA,IAAM,SAAS,CAAC,SAAiB,SAAiB,QAAQ,QAAQ,UAAU,IAAI;AAEhF,SAAS,KAAK,EAAE,OAAO,OAAO,SAAS,SAAS,MAAM,SAAS,GAA+J;AAC5N,SACE,gBAAAC,MAAC,SAAI,WAAU,sCACb;AAAA,oBAAAD,KAAC,cAAW,OAAc,gBAAc,SAAS,SAAQ,SAAQ,OAAM,QAAO,SAAkB,WAAW,GAAG,yFAAyF,IAAI,GACxM,UACH;AAAA,IACC,UAAU,UAAa,gBAAAA,KAAC,UAAK,WAAU,sCAAsC,iBAAM;AAAA,KACtF;AAEJ;","names":["React","jsx","jsx","jsxs","jsx","jsxs"]}
1
+ {"version":3,"sources":["../src/vertical-video/short-feed.tsx","../src/vertical-video/vertical-video.tsx","../src/verified-badge/verified-badge.tsx","../src/vertical-video/model.ts"],"sourcesContent":["// Client (an observer, keys). A vertical feed of short videos: one slide per screen, CSS scroll-snap, the slide in view\n// plays and the others pause, the next one preloads, only the slides near the one in view are mounted (the rest keep their\n// height). ↑/↓ (and PageUp/PageDown) go to the previous / next, with the focus following.\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\n\nexport interface ShortFeedProps<T> extends Omit<React.ComponentProps<\"section\">, \"children\"> {\n /** The feed's accessible name (\"Videos\"), passed translated. */\n label: string;\n /** The videos, in order. */\n items: readonly T[];\n /** A stable key for an item. */\n getId: (item: T) => string;\n /** One slide: `active` is true for the one in view, `preload` for the next, `near` false for the ones kept empty. */\n renderItem: (item: T, state: { active: boolean; preload: \"none\" | \"metadata\" | \"auto\"; index: number }) => React.ReactNode;\n /** The slides mounted around the one in view (before and after). Default 1; the others keep their height empty. */\n window?: number;\n /** Called when the slide in view changes. */\n onActiveChange?: (index: number, item: T) => void;\n}\n\n/** A vertical snap-scrolling feed that plays the video in view, preloads the next and pauses the rest. */\nexport function ShortFeed<T>({ label, items, getId, renderItem, window: around = 1, onActiveChange, className, onKeyDown, ...props }: ShortFeedProps<T>) {\n const root = React.useRef<HTMLElement>(null);\n const [active, setActive] = React.useState(0);\n const slides = React.useRef<(HTMLDivElement | null)[]>([]);\n\n React.useEffect(() => {\n const host = root.current;\n if (!host || typeof IntersectionObserver === \"undefined\") return;\n const observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (!entry.isIntersecting || entry.intersectionRatio < 0.6) continue;\n const index = Number((entry.target as HTMLElement).dataset.index);\n setActive(index);\n }\n },\n { root: host, threshold: [0.6] },\n );\n for (const slide of slides.current) if (slide) observer.observe(slide);\n return () => observer.disconnect();\n }, [items.length]);\n\n const first = React.useRef(true);\n React.useEffect(() => {\n if (first.current) {\n first.current = false;\n return;\n }\n const item = items[active];\n if (item !== undefined) onActiveChange?.(active, item);\n // Only a change of the slide in view is an event.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [active]);\n\n const go = (index: number) => {\n const target = slides.current[Math.max(0, Math.min(items.length - 1, index))];\n if (!target) return;\n target.scrollIntoView({ behavior: window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches ? \"auto\" : \"smooth\", block: \"start\" });\n target.querySelector<HTMLElement>(\"article\")?.focus({ preventScroll: true });\n };\n\n return (\n <section\n ref={root}\n aria-label={label}\n aria-roledescription=\"carousel\"\n className={cn(\"h-dvh snap-y snap-mandatory overflow-y-auto overscroll-contain bg-surface-0 [scrollbar-width:none]\", className)}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (event.key === \"ArrowDown\" || event.key === \"PageDown\") {\n event.preventDefault();\n go(active + 1);\n } else if (event.key === \"ArrowUp\" || event.key === \"PageUp\") {\n event.preventDefault();\n go(active - 1);\n }\n }}\n {...props}\n >\n {items.map((item, index) => {\n const near = Math.abs(index - active) <= around;\n return (\n <div\n key={getId(item)}\n ref={(el) => {\n slides.current[index] = el;\n }}\n data-index={index}\n role=\"group\"\n aria-roledescription=\"slide\"\n aria-label={`${index + 1} / ${items.length}`}\n className=\"mx-auto flex h-full max-w-[calc(100dvh*9/16)] snap-start snap-always items-center\"\n >\n {near ? renderItem(item, { active: index === active, preload: index === active + 1 ? \"auto\" : index === active ? \"auto\" : \"none\", index }) : null}\n </div>\n );\n })}\n </section>\n );\n}\n","// Client (a video element, an observer, keys). A 9:16 clip filling its frame, with the action rail of a short-video feed on\n// the right (avatar + follow, like, comment, share, a slot for tip / unlock, more) and the caption block bottom-left. Every\n// word is a prop; counts are formatted with @krizaka/intl; everything over the picture reads on the invariant `scrim` /\n// `fg-on-media` tokens, so it is legible in both themes. Under reduced motion nothing autoplays: the poster and a play button.\nimport { formatCompact } from \"@krizaka/intl\";\nimport * as React from \"react\";\n\nimport { Avatar } from \"../avatar/avatar\";\nimport { IconButton } from \"../button/button\";\nimport { cn } from \"../cn\";\nimport { VerifiedBadge } from \"../verified-badge/verified-badge\";\nimport { verticalVideoLabels, type VerticalVideoShared } from \"./model\";\n\nexport type { VerticalVideoLabels } from \"./model\";\nexport { verticalVideoLabels };\n\nexport interface VerticalVideoCreator {\n name: string;\n /** Their portrait. */\n avatarSrc?: string;\n /** The seal's words (\"Verified\"): shows the seal beside the name. */\n verifiedLabel?: string;\n}\n\nexport interface VerticalVideoProps extends Omit<React.ComponentProps<\"article\">, \"title\" | \"children\">, VerticalVideoShared {\n /** The clip — absent, the poster alone shows (MP4 or WebM; an HLS address only in Safari — use the player of `@krizaka/ui/video-player` for HLS). */\n src?: string;\n /** The picture until the first frame, and under reduced motion. */\n poster?: string;\n /** The next slide's: `auto` loads it ahead, `none` waits. Default `metadata`. */\n preload?: \"none\" | \"metadata\" | \"auto\";\n /** Plays again at the end. Default `true`. */\n loop?: boolean;\n /** Starts muted (autoplay needs it). Default `true`. */\n muted?: boolean;\n /** Who made it: name, portrait, the seal's words. */\n creator: VerticalVideoCreator;\n /**\n * How it takes its space: `frame` draws its own 9:16 box from its width; `fill` fills the box it is given (a bento\n * tile, a grid cell, a phone frame) — the clip covers it, cropped at the edges, the rail and the caption over it.\n * @default \"frame\"\n */\n fit?: \"frame\" | \"fill\";\n}\n\nconst glyph = (d: string) => (\n <svg viewBox=\"0 0 24 24\" className=\"h-6 w-6\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d={d} />\n </svg>\n);\nconst HEART = \"M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10z\";\nconst COMMENT = \"M4 5h16v11H9l-5 4z\";\nconst SHARE = \"M4 12v7h16v-7M12 3v12M7 8l5-5 5 5\";\nconst MORE = \"M5 12h.01M12 12h.01M19 12h.01\";\n\nconst useReducedMotion = () =>\n React.useSyncExternalStore(\n (notify) => {\n const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n query.addEventListener(\"change\", notify);\n return () => query.removeEventListener(\"change\", notify);\n },\n () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n () => false,\n );\n\n/** One short video: 9:16, the rail of actions on the right, the creator's caption bottom-left, a progress hairline. */\nexport function VerticalVideo({\n title,\n src,\n poster,\n active = true,\n preload = \"metadata\",\n loop = true,\n muted = true,\n creator,\n disclosure,\n caption,\n tags = [],\n credit,\n likes,\n comments,\n shares,\n liked = false,\n following = false,\n onLike,\n onComment,\n onShare,\n onFollow,\n onMore,\n tipSlot,\n topStart,\n aboveCaption,\n fit = \"frame\",\n locale = \"en\",\n labels: custom,\n className,\n onKeyDown,\n ...props\n}: VerticalVideoProps) {\n const labels = { ...verticalVideoLabels, ...custom };\n const reduce = useReducedMotion();\n const video = React.useRef<HTMLVideoElement>(null);\n const [playing, setPlaying] = React.useState(false);\n const [paused, setPaused] = React.useState(false); // the viewer's pause: it holds until they play again\n const [progress, setProgress] = React.useState(0);\n const [open, setOpen] = React.useState(false);\n const [heart, setHeart] = React.useState(0);\n\n const shouldPlay = active && !paused && !reduce;\n React.useEffect(() => {\n const el = video.current;\n if (!el) return;\n if (shouldPlay) void el.play().catch(() => undefined);\n else el.pause();\n }, [shouldPlay, src]);\n\n const press = () => {\n const el = video.current;\n if (!el) return;\n if (el.paused) {\n setPaused(false);\n void el.play().catch(() => undefined);\n } else {\n setPaused(true);\n el.pause();\n }\n };\n const like = () => onLike?.(!liked);\n const doubleTap = () => {\n if (!liked) like();\n setHeart((n) => n + 1); // a heart blooms over the picture (still under reduced motion: it shows and goes)\n };\n const count = (n?: number) => (n === undefined ? undefined : formatCompact(n, { locale }));\n const name = creator.name;\n\n return (\n <article\n aria-label={title}\n tabIndex={0}\n data-playing={playing ? \"\" : undefined}\n data-fit={fit}\n className={cn(\"relative isolate w-full overflow-hidden\", fit === \"fill\" ? \"h-full min-h-0\" : \"aspect-[9/16]\", \"bg-surface-0 text-fg-on-media focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\", className)}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || event.target !== event.currentTarget) return;\n if (event.key === \" \" || event.key.toLowerCase() === \"k\") {\n event.preventDefault();\n press();\n } else if (event.key.toLowerCase() === \"l\") like();\n }}\n {...props}\n >\n <video\n ref={video}\n src={src}\n poster={poster}\n muted={muted}\n loop={loop}\n playsInline\n preload={preload}\n className=\"absolute inset-0 -z-10 h-full w-full object-cover\"\n onPlay={() => setPlaying(true)}\n onPause={() => setPlaying(false)}\n onTimeUpdate={(event) => {\n const el = event.currentTarget;\n setProgress(el.duration ? el.currentTime / el.duration : 0);\n }}\n />\n {/* The tap target: a tap pauses or plays, a double tap likes. It is a button, so the keyboard has it too. */}\n <button type=\"button\" aria-label={playing ? labels.pause : labels.play} onClick={press} onDoubleClick={doubleTap} className=\"absolute inset-0 cursor-pointer bg-transparent focus-visible:outline-hidden\">\n {!playing && (\n <span aria-hidden className=\"absolute left-1/2 top-1/2 grid h-16 w-16 -translate-x-1/2 -translate-y-1/2 place-items-center rounded-full bg-scrim backdrop-blur-md\">\n <svg viewBox=\"0 0 24 24\" className=\"h-7 w-7\" fill=\"currentColor\"><path d=\"M8 5v14l11-7z\" /></svg>\n </span>\n )}\n </button>\n {heart > 0 && (\n <span key={heart} aria-hidden className=\"pointer-events-none absolute left-1/2 top-1/2 grid -translate-x-1/2 -translate-y-1/2 place-items-center text-accent motion-safe:animate-ping\">\n <svg viewBox=\"0 0 24 24\" className=\"h-20 w-20\" fill=\"currentColor\"><path d={HEART} /></svg>\n </span>\n )}\n <div aria-hidden className=\"pointer-events-none absolute inset-x-0 bottom-0 h-2/5 bg-linear-to-t from-scrim to-transparent\" />\n {topStart && <div className=\"absolute left-3 top-3\">{topStart}</div>}\n\n <div role=\"group\" aria-label={labels.actions} className=\"absolute bottom-16 right-2 flex flex-col items-center gap-3\">\n <div className=\"relative\">\n <Avatar src={creator.avatarSrc} alt={name} fallback={name.slice(0, 1)} size=\"md\" className=\"ring-2 ring-white\" />\n {onFollow && (\n <IconButton\n label={format(following ? labels.following : labels.follow, name)}\n aria-pressed={following}\n size=\"icon\"\n variant={following ? \"secondary\" : \"primary\"}\n shape=\"pill\"\n onClick={() => onFollow(!following)}\n className=\"absolute -bottom-3 left-1/2 h-6 min-h-6 w-6 min-w-6 -translate-x-1/2 p-0\"\n >\n {glyph(following ? \"M5 12l5 5 9-10\" : \"M12 5v14M5 12h14\")}\n </IconButton>\n )}\n </div>\n <Rail label={labels.like} count={count(likes)} pressed={liked} onClick={like} tone={liked ? \"text-accent\" : undefined}>\n <svg viewBox=\"0 0 24 24\" className=\"h-6 w-6\" fill={liked ? \"currentColor\" : \"none\"} stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden><path d={HEART} /></svg>\n </Rail>\n <Rail label={labels.comment} count={count(comments)} onClick={onComment}>{glyph(COMMENT)}</Rail>\n <Rail label={labels.share} count={count(shares)} onClick={onShare}>{glyph(SHARE)}</Rail>\n {tipSlot}\n {onMore && <Rail label={labels.more} onClick={onMore}>{glyph(MORE)}</Rail>}\n </div>\n\n <div className=\"absolute bottom-4 left-3 right-16 flex min-w-0 flex-col gap-1.5\">\n {aboveCaption}\n <p className=\"flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-sm font-bold\">\n {name}\n {creator.verifiedLabel && <VerifiedBadge label={creator.verifiedLabel} onMedia size=\"sm\" />}\n {disclosure && <span className=\"whitespace-nowrap rounded-full bg-scrim px-2 py-0.5 text-[10px] font-bold uppercase tracking-wide text-fg-on-media backdrop-blur-md\">{disclosure}</span>}\n </p>\n {caption && (\n <p className={cn(\"text-sm leading-snug\", !open && \"line-clamp-2\")}>\n {caption}\n {tags.length > 0 && <span className=\"font-semibold\"> {tags.map((tag) => `#${tag}`).join(\" \")}</span>}\n </p>\n )}\n {caption && caption.length > 90 && (\n <button type=\"button\" aria-expanded={open} onClick={() => setOpen((v) => !v)} className=\"w-fit rounded text-xs font-semibold underline focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\">\n {open ? labels.collapse : labels.expand}\n </button>\n )}\n {credit && <p className=\"text-xs opacity-90\">{credit}</p>}\n </div>\n\n <div role=\"progressbar\" aria-label={labels.progress} aria-valuemin={0} aria-valuemax={100} aria-valuenow={Math.round(progress * 100)} className=\"absolute inset-x-0 bottom-0 h-1 bg-scrim\">\n <div className=\"h-full bg-white\" style={{ width: `${progress * 100}%` }} />\n </div>\n </article>\n );\n}\n\n/** \"Follow {name}\" → \"Follow Elena\". */\nconst format = (message: string, name: string) => message.replace(\"{name}\", name);\n\nfunction Rail({ label, count, pressed, onClick, tone, children }: { label: string; count?: string | undefined; pressed?: boolean; onClick?: (() => void) | undefined; tone?: string | undefined; children: React.ReactNode }) {\n return (\n <div className=\"flex flex-col items-center gap-0.5\">\n <IconButton label={label} aria-pressed={pressed} variant=\"ghost\" shape=\"pill\" onClick={onClick} className={cn(\"h-11 min-h-11 w-11 min-w-11 bg-scrim text-fg-on-media backdrop-blur-md hover:bg-scrim\", tone)}>\n {children}\n </IconButton>\n {count !== undefined && <span className=\"text-xs font-semibold tabular-nums\">{count}</span>}\n </div>\n );\n}\n","// Server-safe. A seal that says the person or the account was verified: the accent, named in words.\nimport type * as React from \"react\";\n\nexport type VerifiedBadgeProps = Omit<React.ComponentProps<\"span\">, \"children\"> & {\n /** Its words (“Verified”), read — and shown with `showLabel` — passed translated. */\n label: string;\n /** Show the words beside the seal. Default false: the seal alone, named. */\n showLabel?: boolean;\n /** The seal's size: sm (14 px), md (16 px, default), lg (20 px). */\n size?: \"sm\" | \"md\" | \"lg\";\n /** On a photo: a ring of the media around the seal. */\n onMedia?: boolean;\n};\n\nconst SIZE = { sm: \"h-3.5 w-3.5\", md: \"h-4 w-4\", lg: \"h-5 w-5\" } as const;\n\n/** A seal that says the person or the account was verified (a selfie check, an ID), named in words. */\nexport function VerifiedBadge({ label, showLabel, size = \"md\", onMedia, className, ...props }: VerifiedBadgeProps) {\n return (\n <span role=\"img\" aria-label={label} className={[\"inline-flex items-center gap-1 text-xs font-bold\", onMedia ? \"text-fg-on-media\" : \"text-fg-accent\", className].filter(Boolean).join(\" \")} {...props}>\n <svg viewBox=\"0 0 24 24\" className={[SIZE[size], \"shrink-0\"].join(\" \")} aria-hidden>\n <path\n d=\"M12 2.5l2.4 1.7 2.9-.1.9 2.8 2.3 1.8-.9 2.8.9 2.8-2.3 1.8-.9 2.8-2.9-.1L12 21.5l-2.4-1.7-2.9.1-.9-2.8-2.3-1.8.9-2.8-.9-2.8 2.3-1.8.9-2.8 2.9.1z\"\n className={onMedia ? \"fill-accent stroke-fg-on-media\" : \"fill-accent\"}\n strokeWidth=\"1.2\"\n />\n <path d=\"M8.3 12.3l2.5 2.5 4.9-5.2\" fill=\"none\" className=\"stroke-on-accent\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n {showLabel ? <span aria-hidden>{label}</span> : null}\n </span>\n );\n}\n","// Headless: what the web (`vertical-video.tsx`) and the native (`native/vertical-video.tsx`) VerticalVideo share — the words,\n// the content and the callbacks. Each platform adds its media (`src`/`poster` · `uri`/`posterUri`) and its frame.\nimport type * as React from \"react\";\n\nexport interface VerticalVideoLabels {\n /** \"Play\" / \"Pause\" — the tap target over the picture. */\n play: string;\n pause: string;\n /** \"Like\" / \"Unlike\" (the button's name; the state is `aria-pressed`). */\n like: string;\n comment: string;\n share: string;\n more: string;\n /** \"Follow Elena\" — `{name}` is replaced by the creator's name. */\n follow: string;\n /** \"Following Elena\". */\n following: string;\n /** \"More\" / \"Less\" on a long caption. */\n expand: string;\n collapse: string;\n /** The progress bar's name (\"Progress\"). */\n progress: string;\n /** The rail's name (\"Actions\"). */\n actions: string;\n}\n\nexport const verticalVideoLabels: VerticalVideoLabels = {\n play: \"Play\",\n pause: \"Pause\",\n like: \"Like\",\n comment: \"Comments\",\n share: \"Share\",\n more: \"More\",\n follow: \"Follow {name}\",\n following: \"Following {name}\",\n expand: \"More\",\n collapse: \"Less\",\n progress: \"Progress\",\n actions: \"Actions\",\n};\n\n/** The props both platforms read: the same content, counts, state, callbacks and slots. */\nexport interface VerticalVideoShared {\n /** The video's accessible name (\"Video: Night shoot, part 2\"), passed translated. */\n title: string;\n /** Plays while `true`; a `ShortFeed` passes it for the slide in view. Default `true`. */\n active?: boolean;\n /** A pill beside the name: \"AI-GENERATED\" — said on the picture, never only in a page's footnote. */\n disclosure?: string;\n /** The caption: collapsed to two lines, expandable when long. */\n caption?: string;\n /** Tags under the caption (without `#`). */\n tags?: readonly string[];\n /** The sound or credit line (\"Original sound — Elena\"). */\n credit?: string;\n /** The like count under its button, compact (`12.4K`) in `locale`. */\n likes?: number;\n /** The comment count under its button. */\n comments?: number;\n /** The share count under its button. */\n shares?: number;\n /** Whether the viewer likes it: `aria-pressed` on the like button. */\n liked?: boolean;\n /** Whether the viewer follows the creator: the \"+\" on the avatar becomes a check. */\n following?: boolean;\n /** The viewer likes or unlikes (the button, `L`, a double tap). */\n onLike?: (liked: boolean) => void;\n /** Opens the comments; without it the button still shows. */\n onComment?: () => void;\n /** Opens the share sheet. */\n onShare?: () => void;\n /** The viewer follows or unfollows; without it the avatar has no \"+\". */\n onFollow?: (following: boolean) => void;\n /** The \"more\" button's action (report, hide); without it the button is not drawn. */\n onMore?: () => void;\n /** The product's own action on the rail: a tip, an unlock — a button of yours (≥ 44 px, named). */\n tipSlot?: React.ReactNode;\n /** Top left: a chip over the picture (an auction's time left). */\n topStart?: React.ReactNode;\n /** Above the caption: a goal gauge, a challenge's progress. */\n aboveCaption?: React.ReactNode;\n /** The locale of the counts. Default `en`. */\n locale?: string;\n /** Every word, passed translated. */\n labels?: Partial<VerticalVideoLabels>;\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,YAAY,WAAW;AAmFb;AA/DH,SAAS,UAAa,EAAE,OAAO,OAAO,OAAO,YAAY,QAAQ,SAAS,GAAG,gBAAgB,WAAW,WAAW,GAAG,MAAM,GAAsB;AACvJ,QAAM,OAAa,aAAoB,IAAI;AAC3C,QAAM,CAAC,QAAQ,SAAS,IAAU,eAAS,CAAC;AAC5C,QAAM,SAAe,aAAkC,CAAC,CAAC;AAEzD,EAAM,gBAAU,MAAM;AACpB,UAAM,OAAO,KAAK;AAClB,QAAI,CAAC,QAAQ,OAAO,yBAAyB,YAAa;AAC1D,UAAM,WAAW,IAAI;AAAA,MACnB,CAAC,YAAY;AACX,mBAAW,SAAS,SAAS;AAC3B,cAAI,CAAC,MAAM,kBAAkB,MAAM,oBAAoB,IAAK;AAC5D,gBAAM,QAAQ,OAAQ,MAAM,OAAuB,QAAQ,KAAK;AAChE,oBAAU,KAAK;AAAA,QACjB;AAAA,MACF;AAAA,MACA,EAAE,MAAM,MAAM,WAAW,CAAC,GAAG,EAAE;AAAA,IACjC;AACA,eAAW,SAAS,OAAO,QAAS,KAAI,MAAO,UAAS,QAAQ,KAAK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