@cloudvoyant/helical-ui 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/index.cjs +2863 -0
  2. package/dist/index.d.cts +965 -0
  3. package/dist/index.d.ts +965 -0
  4. package/dist/index.js +2539 -0
  5. package/package.json +86 -0
  6. package/src/components.css +129 -0
  7. package/src/theme.css +189 -0
  8. package/src/themes/amber-minimal.css +83 -0
  9. package/src/themes/amethyst-haze.css +83 -0
  10. package/src/themes/anthropic.css +60 -0
  11. package/src/themes/anyscale.css +73 -0
  12. package/src/themes/bold-tech.css +82 -0
  13. package/src/themes/bubblegum.css +85 -0
  14. package/src/themes/caffeine.css +73 -0
  15. package/src/themes/candyland.css +75 -0
  16. package/src/themes/catppuccin.css +81 -0
  17. package/src/themes/claude.css +81 -0
  18. package/src/themes/claymorphism.css +83 -0
  19. package/src/themes/clean-slate.css +82 -0
  20. package/src/themes/cosmic-night.css +82 -0
  21. package/src/themes/cyberpunk.css +81 -0
  22. package/src/themes/darkmatter.css +84 -0
  23. package/src/themes/default.css +62 -0
  24. package/src/themes/doom-64.css +95 -0
  25. package/src/themes/elegant-luxury.css +82 -0
  26. package/src/themes/graphite.css +59 -0
  27. package/src/themes/green.css +57 -0
  28. package/src/themes/helical-ui.css +88 -0
  29. package/src/themes/kodama-grove.css +81 -0
  30. package/src/themes/lambda.css +63 -0
  31. package/src/themes/mdbook.css +108 -0
  32. package/src/themes/midnight-bloom.css +82 -0
  33. package/src/themes/mocha-mousse.css +82 -0
  34. package/src/themes/modern-minimal.css +76 -0
  35. package/src/themes/mono.css +81 -0
  36. package/src/themes/nature.css +76 -0
  37. package/src/themes/neo-brutalism.css +81 -0
  38. package/src/themes/northern-lights.css +76 -0
  39. package/src/themes/notebook.css +95 -0
  40. package/src/themes/ocean-breeze.css +82 -0
  41. package/src/themes/openai.css +59 -0
  42. package/src/themes/pastel-dreams.css +82 -0
  43. package/src/themes/perpetuity.css +91 -0
  44. package/src/themes/quantum-rose.css +85 -0
  45. package/src/themes/retro-arcade.css +81 -0
  46. package/src/themes/rose.css +57 -0
  47. package/src/themes/sage-garden.css +84 -0
  48. package/src/themes/slate.css +57 -0
  49. package/src/themes/soft-pop.css +95 -0
  50. package/src/themes/solar-dusk.css +83 -0
  51. package/src/themes/starry-night.css +74 -0
  52. package/src/themes/sunset-horizon.css +82 -0
  53. package/src/themes/supabase.css +83 -0
  54. package/src/themes/t3-chat.css +72 -0
  55. package/src/themes/tangerine.css +81 -0
  56. package/src/themes/twitter.css +82 -0
  57. package/src/themes/vercel.css +85 -0
  58. package/src/themes/vintage-paper.css +82 -0
  59. package/src/themes/violet-bloom.css +95 -0
  60. package/src/themes/vitepress.css +60 -0
  61. package/src/themes.css +4184 -0
package/dist/index.js ADDED
@@ -0,0 +1,2539 @@
1
+ // src/button.ts
2
+ import { cva } from "class-variance-authority";
3
+ var fills = {
4
+ solid: {
5
+ primary: "bg-primary text-primary-foreground hover:bg-primary/90",
6
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
7
+ success: "bg-success text-success-foreground hover:bg-success/90",
8
+ danger: "bg-danger text-danger-foreground hover:bg-danger/90",
9
+ warn: "bg-warn text-warn-foreground hover:bg-warn/90",
10
+ info: "bg-info text-info-foreground hover:bg-info/90"
11
+ },
12
+ outline: {
13
+ primary: "border border-primary/40 bg-background text-primary hover:bg-primary/10",
14
+ secondary: "border border-secondary-foreground/30 bg-background text-secondary-foreground hover:bg-secondary",
15
+ success: "border border-success/50 bg-background text-success hover:bg-success/10",
16
+ danger: "border border-danger/50 bg-background text-danger hover:bg-danger/10",
17
+ warn: "border border-warn/60 bg-background text-warn hover:bg-warn/15",
18
+ info: "border border-info/50 bg-background text-info hover:bg-info/10"
19
+ },
20
+ text: {
21
+ primary: "bg-transparent text-primary hover:bg-primary/10",
22
+ secondary: "bg-transparent text-secondary-foreground hover:bg-secondary",
23
+ success: "bg-transparent text-success hover:bg-success/10",
24
+ danger: "bg-transparent text-danger hover:bg-danger/10",
25
+ warn: "bg-transparent text-warn hover:bg-warn/15",
26
+ info: "bg-transparent text-info hover:bg-info/10"
27
+ }
28
+ };
29
+ var compoundVariants = Object.entries(fills).flatMap(
30
+ ([variant, colors]) => Object.entries(colors).map(([color, className]) => ({ variant, color, className }))
31
+ );
32
+ var buttonVariants = cva(
33
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
34
+ {
35
+ variants: {
36
+ variant: {
37
+ solid: "",
38
+ outline: "",
39
+ text: ""
40
+ },
41
+ color: {
42
+ primary: "",
43
+ secondary: "",
44
+ success: "",
45
+ danger: "",
46
+ warn: "",
47
+ info: ""
48
+ },
49
+ size: {
50
+ sm: "h-9 px-3",
51
+ md: "h-10 px-4 py-2",
52
+ lg: "h-11 px-8",
53
+ icon: "size-10"
54
+ }
55
+ },
56
+ compoundVariants,
57
+ defaultVariants: {
58
+ variant: "solid",
59
+ color: "primary",
60
+ size: "md"
61
+ }
62
+ }
63
+ );
64
+
65
+ // src/toggle-button.ts
66
+ import { cva as cva2 } from "class-variance-authority";
67
+ var toggleButtonVariants = cva2(
68
+ "inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
69
+ {
70
+ variants: {
71
+ variant: {
72
+ default: "bg-transparent",
73
+ outline: "border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground"
74
+ },
75
+ size: {
76
+ default: "h-9 min-w-9 px-2",
77
+ sm: "h-8 min-w-8 px-1.5",
78
+ lg: "h-10 min-w-10 px-2.5"
79
+ }
80
+ },
81
+ defaultVariants: { variant: "default", size: "default" }
82
+ }
83
+ );
84
+
85
+ // src/tooltip.ts
86
+ var tooltipPositionerBase = "z-50 [--z-index:50]!";
87
+ var tooltipArrowBase = "[--arrow-size:0.5rem] [--arrow-background:var(--color-popover)] z-[60]! [--arrow-size-half:calc(var(--arrow-size)/2_+_1px)]!";
88
+ var tooltipContentBase = "relative z-50 max-w-xs rounded-md border bg-popover px-3 py-1.5 text-xs text-popover-foreground shadow-md outline-none";
89
+
90
+ // src/popover.ts
91
+ var popoverPositionerBase = "z-50 [--z-index:50]!";
92
+ var popoverArrowBase = "[--arrow-size:0.5rem] [--arrow-background:var(--color-popover)] z-[60]! [--arrow-size-half:calc(var(--arrow-size)/2_+_1px)]!";
93
+ var popoverContentBase = "relative z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none";
94
+ var popoverTitleBase = "text-sm font-semibold leading-none";
95
+ var popoverDescriptionBase = "text-sm text-muted-foreground";
96
+ var popoverCloseTriggerBase = "absolute end-3.5 top-3.5 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-[3px] focus:ring-ring/30 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0";
97
+ var popoverIndicatorBase = "transition-transform data-[state=open]:rotate-180";
98
+
99
+ // src/dialog.ts
100
+ var dialogBackdropBase = "bg-black/50";
101
+ var dialogPositionerBase = "fixed inset-0 z-50 [--z-index:50]! flex items-start justify-center overflow-y-auto p-4";
102
+ var dialogContentBase = "relative z-50 my-auto grid w-full max-w-lg gap-4 border bg-background p-6 shadow-lg sm:rounded-lg outline-none";
103
+ var dialogTitleBase = "text-lg font-semibold leading-none tracking-tight";
104
+ var dialogDescriptionBase = "text-sm text-muted-foreground";
105
+ var dialogHeaderBase = "flex flex-col gap-2";
106
+ var dialogFooterBase = "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end";
107
+ var dialogHeaderStickyBase = "sticky top-0 z-10 bg-background";
108
+ var dialogFooterStickyBase = "sticky bottom-0 z-10 bg-background";
109
+ var dialogFullscreenContentBase = "h-dvh w-full max-w-none rounded-none border-0 p-0 sm:rounded-none";
110
+ var dialogCloseTriggerBase = "absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-[3px] focus:ring-ring/30 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0";
111
+
112
+ // src/window.ts
113
+ var windowPositionerBase = "z-50 [--z-index:50]!";
114
+ var windowContentBase = "relative z-50 flex w-80 flex-col overflow-hidden rounded-lg border bg-popover text-popover-foreground shadow-lg";
115
+ var windowDragTriggerBase = "flex flex-col";
116
+ var windowHeaderBase = "flex cursor-move items-center justify-between gap-2 border-b px-4 py-2.5";
117
+ var windowTitleBase = "text-sm font-semibold leading-none";
118
+ var windowControlBase = "flex items-center gap-1";
119
+ var windowStageTriggerBase = "inline-flex size-6 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus:outline-none focus:ring-[3px] focus:ring-ring/30 [&_svg]:size-3.5 [&_svg]:shrink-0";
120
+ var windowCloseTriggerBase = "inline-flex size-6 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus:outline-none focus:ring-[3px] focus:ring-ring/30 [&_svg]:size-3.5 [&_svg]:shrink-0";
121
+ var windowBodyBase = "flex flex-1 flex-col gap-4 overflow-auto p-4 text-sm";
122
+ var windowResizeTriggerBase = "absolute bottom-0 right-0 size-4 cursor-se-resize";
123
+
124
+ // src/badge.ts
125
+ import { cva as cva3 } from "class-variance-authority";
126
+ var fills2 = {
127
+ solid: {
128
+ primary: "border-transparent bg-primary text-primary-foreground",
129
+ secondary: "border-transparent bg-secondary text-secondary-foreground",
130
+ success: "border-transparent bg-success text-success-foreground",
131
+ danger: "border-transparent bg-danger text-danger-foreground",
132
+ warn: "border-transparent bg-warn text-warn-foreground",
133
+ info: "border-transparent bg-info text-info-foreground"
134
+ },
135
+ subtle: {
136
+ primary: "border-transparent bg-primary/10 text-primary",
137
+ secondary: "border-transparent bg-secondary/10 text-secondary-foreground",
138
+ success: "border-transparent bg-success/10 text-success",
139
+ danger: "border-transparent bg-danger/10 text-danger",
140
+ warn: "border-transparent bg-warn/10 text-warn",
141
+ info: "border-transparent bg-info/10 text-info"
142
+ },
143
+ outline: {
144
+ primary: "border-primary/40 bg-transparent text-primary",
145
+ secondary: "border-secondary-foreground/30 bg-transparent text-secondary-foreground",
146
+ success: "border-success/50 bg-transparent text-success",
147
+ danger: "border-danger/50 bg-transparent text-danger",
148
+ warn: "border-warn/50 bg-transparent text-warn",
149
+ info: "border-info/50 bg-transparent text-info"
150
+ },
151
+ surface: {
152
+ primary: "border-primary/40 bg-primary/10 text-primary",
153
+ secondary: "border-secondary-foreground/30 bg-secondary text-secondary-foreground",
154
+ success: "border-success/50 bg-success/10 text-success",
155
+ danger: "border-danger/50 bg-danger/10 text-danger",
156
+ warn: "border-warn/50 bg-warn/10 text-warn",
157
+ info: "border-info/50 bg-info/10 text-info"
158
+ },
159
+ plain: {
160
+ primary: "border-transparent bg-transparent text-primary",
161
+ secondary: "border-transparent bg-transparent text-secondary-foreground",
162
+ success: "border-transparent bg-transparent text-success",
163
+ danger: "border-transparent bg-transparent text-danger",
164
+ warn: "border-transparent bg-transparent text-warn",
165
+ info: "border-transparent bg-transparent text-info"
166
+ }
167
+ };
168
+ var compoundVariants2 = Object.entries(fills2).flatMap(
169
+ ([variant, colors]) => Object.entries(colors).map(([color, className]) => ({ variant, color, className }))
170
+ );
171
+ var badgeVariants = cva3(
172
+ "inline-flex items-center gap-1 rounded-md border font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
173
+ {
174
+ variants: {
175
+ variant: {
176
+ solid: "",
177
+ subtle: "",
178
+ outline: "",
179
+ surface: "",
180
+ plain: ""
181
+ },
182
+ color: {
183
+ primary: "",
184
+ secondary: "",
185
+ success: "",
186
+ danger: "",
187
+ warn: "",
188
+ info: ""
189
+ },
190
+ size: {
191
+ xs: "px-1.5 py-0.5 text-[10px]",
192
+ sm: "px-2 py-0.5 text-xs",
193
+ md: "px-2.5 py-1 text-xs",
194
+ lg: "px-3 py-1 text-sm"
195
+ }
196
+ },
197
+ compoundVariants: compoundVariants2,
198
+ defaultVariants: {
199
+ variant: "subtle",
200
+ color: "primary",
201
+ size: "sm"
202
+ }
203
+ }
204
+ );
205
+
206
+ // src/layout.ts
207
+ var containerBase = "relative mx-auto w-full max-w-[90rem] px-4 md:px-6 lg:px-8";
208
+ var rowBase = "flex flex-row";
209
+ var colBase = "flex flex-col";
210
+ var stackBase = "flex flex-col gap-1";
211
+ var hstackBase = "flex flex-row gap-1";
212
+ var vstackBase = "flex flex-col gap-1";
213
+ var centerBase = "flex items-center justify-center";
214
+
215
+ // src/item.ts
216
+ import { cva as cva4 } from "class-variance-authority";
217
+ var itemVariants = cva4("flex-1 p-3 text-sm", {
218
+ variants: {
219
+ variant: {
220
+ plain: "",
221
+ surface: "rounded-md border border-border bg-card text-card-foreground"
222
+ }
223
+ },
224
+ defaultVariants: {
225
+ variant: "plain"
226
+ }
227
+ });
228
+
229
+ // src/card.ts
230
+ import { cva as cva5 } from "class-variance-authority";
231
+ var cardVariants = cva5("flex flex-col overflow-hidden rounded-lg border bg-card text-card-foreground", {
232
+ variants: {
233
+ variant: {
234
+ outline: "border-border shadow-xs",
235
+ elevated: "border-transparent shadow-md",
236
+ subtle: "border-transparent bg-muted"
237
+ },
238
+ size: {
239
+ sm: "gap-3 p-3 [--card-padding:0.75rem]",
240
+ md: "gap-4 p-4 [--card-padding:1rem]",
241
+ lg: "gap-6 p-6 [--card-padding:1.5rem]"
242
+ },
243
+ orientation: {
244
+ vertical: "",
245
+ horizontal: "flex-row"
246
+ }
247
+ },
248
+ defaultVariants: {
249
+ variant: "outline",
250
+ size: "md",
251
+ orientation: "vertical"
252
+ }
253
+ });
254
+ var cardCoverVariants = cva5("shrink-0 overflow-hidden", {
255
+ variants: {
256
+ variant: {
257
+ flush: "",
258
+ inset: "rounded-md"
259
+ },
260
+ orientation: {
261
+ vertical: "",
262
+ horizontal: ""
263
+ }
264
+ },
265
+ compoundVariants: [
266
+ {
267
+ variant: "flush",
268
+ orientation: "vertical",
269
+ className: "-mx-[var(--card-padding)] -mt-[var(--card-padding)]"
270
+ },
271
+ {
272
+ variant: "flush",
273
+ orientation: "horizontal",
274
+ className: "-ml-[var(--card-padding)] -mt-[var(--card-padding)] -mb-[var(--card-padding)]"
275
+ }
276
+ ],
277
+ defaultVariants: {
278
+ variant: "flush",
279
+ orientation: "vertical"
280
+ }
281
+ });
282
+ var cardHeaderBase = "flex flex-col gap-1";
283
+ var cardBodyBase = "";
284
+ var cardFooterBase = "flex items-center gap-2";
285
+ var cardTitleBase = "font-semibold leading-tight";
286
+ var cardDescriptionBase = "text-sm text-muted-foreground";
287
+
288
+ // src/scroll.ts
289
+ var scrollRootBase = "relative flex h-full w-full flex-col overflow-hidden [--scrollbar-size:0.5rem] [--scrollbar-margin:2px]";
290
+ var scrollViewportBase = "flex h-full w-full flex-col rounded-[inherit] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden";
291
+ var scrollContentBase = "min-w-full";
292
+ var scrollScrollbarBase = "relative m-[var(--scrollbar-margin)] flex touch-none select-none rounded-full bg-border/10 opacity-0 transition-opacity duration-150 data-[hover]:opacity-100 data-[scrolling]:opacity-100 data-[orientation=vertical]:w-[var(--scrollbar-size)] data-[orientation=vertical]:flex-col data-[orientation=horizontal]:h-[var(--scrollbar-size)] data-[orientation=horizontal]:flex-row [&:not([data-overflow-x],[data-overflow-y])]:hidden";
293
+ var scrollThumbBase = "rounded-[inherit] bg-border/40 transition-colors data-[orientation=vertical]:w-full data-[orientation=horizontal]:h-full";
294
+ var scrollCornerBase = "m-[var(--scrollbar-margin)] bg-muted opacity-0 transition-opacity duration-150 data-[hover]:opacity-100";
295
+
296
+ // src/page.ts
297
+ import { cva as cva6 } from "class-variance-authority";
298
+
299
+ // src/cn.ts
300
+ import { clsx } from "clsx";
301
+ import { twMerge } from "tailwind-merge";
302
+ function cn(...inputs) {
303
+ return twMerge(clsx(inputs));
304
+ }
305
+
306
+ // src/page.ts
307
+ var pageVariants = cva6("min-h-svh w-full", {
308
+ variants: {
309
+ variant: {
310
+ default: 'grid grid-cols-[auto_minmax(0,1fr)_auto] grid-rows-[minmax(100svh,1fr)_auto] [grid-template-areas:"left_content_right"_"footer_footer_footer"]',
311
+ landing: colBase
312
+ }
313
+ },
314
+ defaultVariants: { variant: "default" }
315
+ });
316
+ var pageGutterAreaBase = "h-full min-w-0 [grid-area:left]";
317
+ var pageGutterVariants = cva6(
318
+ "sticky top-0 h-svh w-4 shrink-0 overflow-hidden p-0.5 md:w-56 md:p-2 lg:w-72 lg:p-3",
319
+ {
320
+ variants: {
321
+ side: {
322
+ left: "",
323
+ right: ""
324
+ }
325
+ },
326
+ defaultVariants: { side: "left" }
327
+ }
328
+ );
329
+ var pageGutterContentVariants = cva6("hidden h-full w-full flex-col md:flex", {
330
+ variants: {
331
+ align: {
332
+ start: "justify-start",
333
+ center: "justify-center",
334
+ end: "justify-end"
335
+ }
336
+ },
337
+ defaultVariants: { align: "start" }
338
+ });
339
+ var pageContentBase = "min-w-0 [grid-area:content]";
340
+ var pageFooterBase = "w-full shrink-0 [grid-area:footer]";
341
+ var pageSectionBase = cn(colBase, "min-h-svh w-full");
342
+
343
+ // src/splitter.ts
344
+ var splitterRootBase = "";
345
+ var splitterPanelBase = "";
346
+ var splitterResizeTriggerBase = "group relative grid place-items-center outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 data-[orientation=horizontal]:-mx-1 data-[orientation=horizontal]:min-w-2 data-[orientation=vertical]:-my-1 data-[orientation=vertical]:min-h-2";
347
+ var splitterResizeTriggerSeparatorBase = "absolute bg-border group-data-[orientation=horizontal]:inset-y-0 group-data-[orientation=horizontal]:right-1 group-data-[orientation=horizontal]:w-px group-data-[orientation=vertical]:inset-x-0 group-data-[orientation=vertical]:bottom-1 group-data-[orientation=vertical]:h-px";
348
+ var splitterResizeTriggerIndicatorBase = "relative z-10 rounded-full border border-border bg-muted shadow-xs data-[dragging]:bg-muted-foreground data-[focus]:bg-accent data-[disabled]:hidden data-[orientation=horizontal]:h-6 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-6";
349
+
350
+ // src/sidebar.ts
351
+ import { cva as cva7 } from "class-variance-authority";
352
+ var SIDEBAR_WIDTH = "16rem";
353
+ var SIDEBAR_WIDTH_MOBILE = "18rem";
354
+ var SIDEBAR_WIDTH_ICON = "3rem";
355
+ var SIDEBAR_KEYBOARD_SHORTCUT = "b";
356
+ var sidebarMenuButtonVariants = cva7(
357
+ "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
358
+ {
359
+ variants: {
360
+ variant: {
361
+ default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
362
+ outline: "bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]"
363
+ },
364
+ size: {
365
+ default: "h-8 text-sm",
366
+ sm: "h-7 text-xs",
367
+ lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!"
368
+ }
369
+ },
370
+ defaultVariants: {
371
+ variant: "default",
372
+ size: "default"
373
+ }
374
+ }
375
+ );
376
+ var sidebarStyles = {
377
+ wrapperClass: "group/sidebar-wrapper min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
378
+ // Base (static) classes for the desktop sidebar container. Side- and
379
+ // variant-specific classes are applied inline in the framework wrappers via
380
+ // ternaries, exactly as in the shadcn source. The `flex` direction bases are
381
+ // provided by the Row/Col layout primitives at render time.
382
+ containerClass: "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",
383
+ gapClass: "relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear group-data-[collapsible=offcanvas]:w-0",
384
+ innerClass: "flex h-full w-full flex-col bg-sidebar data-[variant=floating]:rounded-lg data-[variant=floating]:border data-[variant=floating]:border-sidebar-border data-[variant=floating]:shadow-sm",
385
+ headerClass: "gap-2 p-2",
386
+ footerClass: "gap-2 p-2",
387
+ separatorClass: "mx-2 w-auto bg-sidebar-border",
388
+ contentClass: "min-h-0 flex-1 gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
389
+ groupClass: "relative w-full min-w-0 p-2",
390
+ groupLabelClass: "flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
391
+ groupActionClass: "absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 after:absolute after:-inset-2 md:after:hidden group-data-[collapsible=icon]:hidden",
392
+ groupContentClass: "w-full text-sm",
393
+ menuClass: "flex w-full min-w-0 flex-col gap-1",
394
+ menuItemClass: "group/menu-item relative",
395
+ menuActionClass: "absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform peer-hover/menu-button:text-sidebar-accent-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 after:absolute after:-inset-2 md:after:hidden peer-data-[size=sm]/menu-button:top-1 peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 group-data-[collapsible=icon]:hidden",
396
+ menuBadgeClass: "pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground peer-data-[size=sm]/menu-button:top-1 peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 group-data-[collapsible=icon]:hidden",
397
+ menuSkeletonClass: "flex h-8 items-center gap-2 rounded-md px-2",
398
+ menuSubClass: "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",
399
+ menuSubItemClass: "group/menu-sub-item relative",
400
+ menuSubButtonClass: "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground data-[size=sm]:text-xs data-[size=md]:text-sm group-data-[collapsible=icon]:hidden",
401
+ triggerClass: "flex size-7 shrink-0 items-center justify-center rounded-md text-sidebar-foreground ring-sidebar-ring outline-hidden transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
402
+ railClass: "absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[side=left]:cursor-w-resize group-data-[side=right]:cursor-e-resize [[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize [[data-side=left][data-collapsible=offcanvas]_&]:-right-2 [[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
403
+ insetClass: "relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
404
+ inputClass: "h-8 w-full bg-background shadow-none",
405
+ tooltipContentClass: "z-50 w-auto rounded-md bg-sidebar-primary px-2 py-1.5 text-xs text-sidebar-primary-foreground"
406
+ };
407
+
408
+ // src/navbar-menu.ts
409
+ import { cva as cva8 } from "class-variance-authority";
410
+ var navbarMenuRootBase = "group/nav-menu relative flex max-w-max flex-1 items-center justify-center";
411
+ var navbarMenuListBase = "group flex flex-1 list-none items-center justify-center gap-1";
412
+ var navbarMenuItemBase = "relative";
413
+ var navbarMenuTriggerStyle = cva8(
414
+ "group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-3 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=open]:bg-accent/50 data-[state=open]:text-accent-foreground data-[state=open]:hover:bg-accent data-[state=open]:focus:bg-accent",
415
+ {
416
+ variants: {
417
+ density: {
418
+ relaxed: "",
419
+ compact: "h-8 px-2 text-xs"
420
+ },
421
+ variant: {
422
+ default: "",
423
+ link: "bg-transparent px-3 text-muted-foreground hover:bg-transparent hover:text-primary focus:bg-transparent focus:text-primary focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:bg-transparent data-[state=open]:text-primary data-[state=open]:hover:bg-transparent data-[state=open]:focus:bg-transparent data-[active=true]:bg-transparent data-[active=true]:text-primary"
424
+ }
425
+ },
426
+ defaultVariants: { density: "relaxed", variant: "default" }
427
+ }
428
+ );
429
+ var navbarMenuContentBase = "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:zoom-in-95 data-[state=closed]:zoom-out-95 left-0 top-0 w-full min-w-44 bg-popover p-2 text-popover-foreground md:absolute md:w-auto";
430
+ var navbarMenuLinkBase = "data-[active=true]:bg-accent data-[active=true]:text-accent-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex flex-col gap-1 rounded-sm p-2 text-sm transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring";
431
+ var navbarMobileMenuContentBase = "flex flex-col gap-1 py-1";
432
+ var navbarMobileMenuTriggerBase = "flex w-full items-center justify-between rounded-md px-3 py-2 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";
433
+ var navbarMenuViewportPositionerBase = "absolute left-0 top-full z-50 w-full";
434
+ var navbarMenuViewportBase = "absolute left-(--viewport-x) top-0 mt-1.5 h-(--viewport-height) w-(--viewport-width) overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md transition-[width,height] duration-200";
435
+ var navbarMenuIndicatorBase = "data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in top-full z-50 flex h-1.5 items-end justify-center overflow-hidden";
436
+
437
+ // src/tabs.ts
438
+ import { cva as cva9 } from "class-variance-authority";
439
+ var tabsRootBase = "flex flex-col gap-2 data-[orientation=vertical]:flex-row";
440
+ var tabsListBase = "relative z-0 flex w-fit items-center justify-center gap-x-0.5 text-muted-foreground data-[orientation=vertical]:flex-col";
441
+ var tabsListVariants = cva9("", {
442
+ variants: {
443
+ variant: {
444
+ default: "rounded-lg",
445
+ underline: "data-[orientation=vertical]:px-1 data-[orientation=horizontal]:py-1"
446
+ }
447
+ },
448
+ defaultVariants: {
449
+ variant: "default"
450
+ }
451
+ });
452
+ var tabsIndicatorBase = "absolute inset-x-0 bottom-0 h-(--height) w-(--width) transition-[width,translate] duration-200 ease-in-out motion-reduce:transition-none";
453
+ var tabsIndicatorVariants = cva9("", {
454
+ variants: {
455
+ variant: {
456
+ default: "-z-1 rounded-lg bg-accent",
457
+ underline: "z-10 bg-primary data-[orientation=horizontal]:h-0.5 data-[orientation=vertical]:w-0.5"
458
+ }
459
+ },
460
+ defaultVariants: {
461
+ variant: "default"
462
+ }
463
+ });
464
+ var tabsTriggerBase = "relative flex h-9 shrink-0 grow items-center justify-center gap-1.5 rounded-lg border border-transparent px-[calc(--spacing(2.5)-1px)] text-sm font-medium whitespace-nowrap transition-[color,background-color,box-shadow] data-[orientation=vertical]:w-full data-[orientation=vertical]:justify-start hover:text-foreground/72 aria-selected:text-foreground outline-none focus-visible:border-primary focus-visible:ring-3 focus-visible:ring-ring/30 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none sm:h-8 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0";
465
+ var tabsContentBase = "flex-1 outline-none";
466
+
467
+ // src/pagination.ts
468
+ var paginationRootBase = "mx-auto flex w-full justify-center gap-1";
469
+ var paginationTriggerBase = "inline-flex h-9 items-center justify-center gap-2 whitespace-nowrap rounded-md px-3 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0";
470
+ var paginationItemBase = "inline-flex h-9 min-w-9 items-center justify-center whitespace-nowrap rounded-md px-3 text-sm font-medium tabular-nums text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[selected]:bg-accent data-[selected]:text-accent-foreground";
471
+ var paginationEllipsisBase = "flex h-8 w-12 items-end justify-center text-muted-foreground pointer-events-none select-none [&_svg]:size-4";
472
+
473
+ // src/navbar.ts
474
+ import { cva as cva10 } from "class-variance-authority";
475
+ var navbarVariants = cva10(
476
+ "w-full bg-background/80 backdrop-blur transition-[box-shadow,height,translate] duration-300",
477
+ {
478
+ variants: {
479
+ variant: {
480
+ scroll: "border-b border-border",
481
+ sticky: "sticky top-0 z-50 border-b border-border data-[scrolled=true]:bg-background/95 data-[scrolled=true]:shadow-md",
482
+ shrink: "sticky top-0 z-50 border-b border-border data-[scrolled=true]:bg-background/95 data-[scrolled=true]:shadow-md",
483
+ hide: "sticky top-0 z-50 border-b border-border data-[scrolled=true]:bg-background/95 data-[scrolled=true]:shadow-md data-[hidden=true]:-translate-y-full"
484
+ },
485
+ floating: {
486
+ false: "",
487
+ true: "fixed inset-x-0 top-4 z-50 mx-auto w-[calc(100%-2rem)] max-w-6xl rounded-full border"
488
+ }
489
+ },
490
+ defaultVariants: {
491
+ variant: "sticky",
492
+ floating: false
493
+ }
494
+ }
495
+ );
496
+ var navbarContainerBase = "flex items-center justify-between transition-[height,gap,padding] duration-300";
497
+ var navbarDensityVariants = cva10("", {
498
+ variants: {
499
+ density: {
500
+ relaxed: "h-16 gap-4 px-4 md:px-6",
501
+ compact: "h-12 gap-1.5 px-2"
502
+ }
503
+ },
504
+ defaultVariants: {
505
+ density: "relaxed"
506
+ }
507
+ });
508
+ var navbarShrunkBase = "h-12";
509
+ var navbarBrandBase = "flex shrink-0 items-center gap-2";
510
+ var navbarMenuBase = "hidden items-center md:flex";
511
+ var navbarMenuPlacementVariants = cva10("", {
512
+ variants: {
513
+ placement: {
514
+ left: "justify-start",
515
+ center: "justify-center",
516
+ right: "justify-end"
517
+ }
518
+ },
519
+ defaultVariants: {
520
+ placement: "center"
521
+ }
522
+ });
523
+ var navbarActionsBase = "ml-auto hidden items-center gap-2 md:flex";
524
+ var navbarTriggerVariants = cva10(
525
+ "inline-flex h-9 w-9 items-center justify-center text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
526
+ {
527
+ variants: {
528
+ floating: {
529
+ false: "rounded-md border border-border",
530
+ true: "rounded-full"
531
+ }
532
+ },
533
+ defaultVariants: {
534
+ floating: false
535
+ }
536
+ }
537
+ );
538
+ var navbarMobileBase = "md:hidden";
539
+ var navbarActivationAreaBase = "fixed inset-x-0 top-0 z-40 h-12";
540
+ var navbarMobileContentBase = "flex h-full flex-col bg-background";
541
+ var navbarMobileHeaderBase = "flex items-center justify-between gap-2 px-4 py-3";
542
+ var navbarMobileMenuBase = "flex flex-1 flex-col gap-1 overflow-y-auto px-4 py-2";
543
+ var navbarMobileActionsBase = "flex items-center gap-2 border-t border-border px-4 py-4";
544
+
545
+ // src/themes.ts
546
+ var THEMES = [
547
+ { name: "amber-minimal", label: "Amber Minimal" },
548
+ { name: "amethyst-haze", label: "Amethyst Haze" },
549
+ { name: "anthropic", label: "Anthropic" },
550
+ { name: "anyscale", label: "Anyscale" },
551
+ { name: "bold-tech", label: "Bold Tech" },
552
+ { name: "bubblegum", label: "Bubblegum" },
553
+ { name: "caffeine", label: "Caffeine" },
554
+ { name: "candyland", label: "Candyland" },
555
+ { name: "catppuccin", label: "Catppuccin" },
556
+ { name: "claude", label: "Claude" },
557
+ { name: "claymorphism", label: "Claymorphism" },
558
+ { name: "clean-slate", label: "Clean Slate" },
559
+ { name: "cosmic-night", label: "Cosmic Night" },
560
+ { name: "cyberpunk", label: "Cyberpunk" },
561
+ { name: "darkmatter", label: "Darkmatter" },
562
+ { name: "default", label: "Default" },
563
+ { name: "doom-64", label: "Doom 64" },
564
+ { name: "elegant-luxury", label: "Elegant Luxury" },
565
+ { name: "graphite", label: "Graphite" },
566
+ { name: "green", label: "Green" },
567
+ { name: "kodama-grove", label: "Kodama Grove" },
568
+ { name: "lambda", label: "Lambda" },
569
+ { name: "mdbook", label: "mdBook" },
570
+ { name: "midnight-bloom", label: "Midnight Bloom" },
571
+ { name: "mocha-mousse", label: "Mocha Mousse" },
572
+ { name: "modern-minimal", label: "Modern Minimal" },
573
+ { name: "mono", label: "Mono" },
574
+ { name: "nature", label: "Nature" },
575
+ { name: "neo-brutalism", label: "Neo Brutalism" },
576
+ { name: "northern-lights", label: "Northern Lights" },
577
+ { name: "notebook", label: "Notebook" },
578
+ { name: "ocean-breeze", label: "Ocean Breeze" },
579
+ { name: "openai", label: "Openai" },
580
+ { name: "pastel-dreams", label: "Pastel Dreams" },
581
+ { name: "perpetuity", label: "Perpetuity" },
582
+ { name: "quantum-rose", label: "Quantum Rose" },
583
+ { name: "retro-arcade", label: "Retro Arcade" },
584
+ { name: "rose", label: "Rose" },
585
+ { name: "sage-garden", label: "Sage Garden" },
586
+ { name: "slate", label: "Slate" },
587
+ { name: "soft-pop", label: "Soft Pop" },
588
+ { name: "solar-dusk", label: "Solar Dusk" },
589
+ { name: "starry-night", label: "Starry Night" },
590
+ { name: "sunset-horizon", label: "Sunset Horizon" },
591
+ { name: "supabase", label: "Supabase" },
592
+ { name: "t3-chat", label: "T3 Chat" },
593
+ { name: "tangerine", label: "Tangerine" },
594
+ { name: "twitter", label: "Twitter" },
595
+ { name: "vercel", label: "Vercel" },
596
+ { name: "vintage-paper", label: "Vintage Paper" },
597
+ { name: "violet-bloom", label: "Violet Bloom" },
598
+ { name: "vitepress", label: "Vitepress" },
599
+ { name: "helical-ui", label: "Helical UI" }
600
+ ];
601
+ var THEME_NAMES = THEMES.map((t) => t.name);
602
+
603
+ // src/field.ts
604
+ var fieldRootBase = "flex w-full flex-col gap-2 data-invalid:text-destructive";
605
+ var fieldLabelBase = "flex w-fit select-none items-center gap-1 text-sm font-medium leading-none text-foreground";
606
+ var fieldHelperBase = "text-sm text-muted-foreground";
607
+ var fieldErrorBase = "text-sm text-destructive";
608
+ var fieldRequiredIndicatorBase = "text-destructive";
609
+ var fieldsetRootBase = "flex flex-col gap-6";
610
+ var fieldsetLegendBase = "mb-3 text-base font-medium";
611
+ var fieldsetHelperBase = "text-sm text-muted-foreground";
612
+ var fieldsetErrorBase = "text-sm text-destructive";
613
+
614
+ // src/input.ts
615
+ import { cva as cva11 } from "class-variance-authority";
616
+ var inputVariants = cva11(
617
+ "flex w-full min-w-0 rounded-md border border-input bg-transparent px-3 text-sm shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/24 data-invalid:border-destructive data-invalid:ring-[3px] data-invalid:ring-destructive/24",
618
+ {
619
+ variants: {
620
+ size: {
621
+ sm: "h-8 px-2.5",
622
+ md: "h-9",
623
+ lg: "h-10"
624
+ }
625
+ },
626
+ defaultVariants: {
627
+ size: "md"
628
+ }
629
+ }
630
+ );
631
+
632
+ // src/textarea.ts
633
+ var textareaBase = "field-sizing-content flex min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/24 data-invalid:border-destructive data-invalid:ring-[3px] data-invalid:ring-destructive/24";
634
+
635
+ // src/number-input.ts
636
+ var numberInputRootBase = "flex w-full flex-col items-start gap-2";
637
+ var numberInputControlBase = "flex w-full items-center justify-between rounded-md border border-input bg-transparent shadow-xs transition-[box-shadow] outline-none focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/30 aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/24 data-invalid:border-destructive data-invalid:ring-[3px] data-invalid:ring-destructive/24";
638
+ var numberInputInputBase = "h-9 w-full min-w-0 flex-1 border-0 bg-transparent px-3 text-center text-sm tabular-nums shadow-none outline-none ring-0 focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-50";
639
+ var numberInputTriggerBase = "flex size-9 shrink-0 items-center justify-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0";
640
+
641
+ // src/checkbox.ts
642
+ import { cva as cva12 } from "class-variance-authority";
643
+ var checkboxVariants = cva12(
644
+ "relative inline-flex size-4 shrink-0 items-center justify-center rounded-sm border border-input bg-transparent shadow-xs transition-shadow focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/30 focus-visible:ring-offset-1 focus-visible:ring-offset-background data-invalid:border-destructive data-invalid:ring-[3px] data-invalid:ring-destructive/24 disabled:pointer-events-none disabled:opacity-50",
645
+ {
646
+ variants: {
647
+ size: {
648
+ sm: "size-3.5",
649
+ md: "size-4",
650
+ lg: "size-5"
651
+ }
652
+ },
653
+ defaultVariants: {
654
+ size: "md"
655
+ }
656
+ }
657
+ );
658
+ var checkboxIndicatorBase = "flex size-full items-center justify-center text-primary-foreground data-[state=unchecked]:hidden [&_svg]:pointer-events-none [&_svg]:size-3 [&_svg]:shrink-0";
659
+ var checkboxLabelBase = "select-none text-sm font-medium leading-none";
660
+ var checkboxGroupBase = "flex flex-col gap-2";
661
+
662
+ // src/switch.ts
663
+ import { cva as cva13 } from "class-variance-authority";
664
+ var switchVariants = cva13(
665
+ "inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border border-transparent bg-input p-0.5 shadow-xs transition-colors outline-none data-[state=checked]:bg-primary data-invalid:border-destructive data-invalid:ring-[3px] data-invalid:ring-destructive/24 focus-visible:ring-[3px] focus-visible:ring-ring/30 disabled:pointer-events-none disabled:opacity-50",
666
+ {
667
+ variants: {
668
+ size: {
669
+ sm: "h-5 w-9",
670
+ md: "h-6 w-11",
671
+ lg: "h-7 w-12"
672
+ }
673
+ },
674
+ defaultVariants: {
675
+ size: "md"
676
+ }
677
+ }
678
+ );
679
+ var switchControlBase = "flex size-full items-center";
680
+ var switchThumbBase = "pointer-events-none block aspect-square h-full w-auto rounded-full bg-background shadow-sm transition-transform data-[state=checked]:translate-x-[calc(100%-1px)] data-[state=unchecked]:translate-x-0 dark:data-[state=unchecked]:bg-foreground";
681
+ var switchLabelBase = "select-none text-sm font-medium leading-none";
682
+
683
+ // src/select.ts
684
+ import { cva as cva14 } from "class-variance-authority";
685
+ var selectTriggerBase = "flex w-fit cursor-default items-center gap-2 whitespace-nowrap data-[placeholder-shown]:text-muted-foreground data-[state=open]:border-ring data-[state=open]:ring-[3px] data-[state=open]:ring-ring/30 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground";
686
+ var selectValueBase = "flex min-w-0 items-center gap-2 truncate";
687
+ var selectIndicatorBase = "flex items-center justify-center text-muted-foreground";
688
+ var selectClearTriggerBase = "flex items-center justify-center text-muted-foreground opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none [&_svg]:pointer-events-none [&_svg]:size-3.5 [&_svg]:shrink-0";
689
+ var selectPositionerBase = "z-50 [--z-index:50]!";
690
+ var selectContentBase = "relative z-50 max-h-96 min-w-(--reference-width) overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md outline-none";
691
+ var selectItemGroupLabelBase = "px-2 py-1.5 text-xs font-semibold text-muted-foreground";
692
+ var selectItemBase = "relative flex w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 pe-8 text-sm outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground";
693
+ var selectItemTextBase = "flex w-full flex-1 items-center gap-2";
694
+ var selectItemIndicatorBase = "absolute inset-y-0 end-2 flex items-center justify-center text-foreground";
695
+ var nativeSelectVariants = cva14(
696
+ "appearance-none w-full min-w-0 rounded-md border border-input bg-transparent pe-8 ps-2.5 text-sm shadow-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/24",
697
+ {
698
+ variants: {
699
+ size: {
700
+ sm: "h-8",
701
+ md: "h-9",
702
+ lg: "h-10"
703
+ }
704
+ },
705
+ defaultVariants: {
706
+ size: "md"
707
+ }
708
+ }
709
+ );
710
+ var nativeSelectWrapperBase = "relative w-fit [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground";
711
+ var nativeSelectIconBase = "pointer-events-none absolute inset-y-0 end-2.5 flex items-center justify-center text-muted-foreground";
712
+
713
+ // src/combobox.ts
714
+ import { cva as cva15 } from "class-variance-authority";
715
+ var comboboxControlBase = "relative flex w-full flex-wrap items-center gap-1";
716
+ var comboboxInputBase = "pe-8";
717
+ var comboboxTriggerBase = "absolute inset-y-0 end-1 flex w-8 items-center justify-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0";
718
+ var comboboxClearTriggerBase = "absolute inset-y-0 end-9 flex items-center justify-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none [&_svg]:pointer-events-none [&_svg]:size-3.5 [&_svg]:shrink-0";
719
+ var comboboxPositionerBase = "z-50 [--z-index:50]!";
720
+ var comboboxContentBase = "relative z-50 max-h-96 min-w-48 overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md outline-none";
721
+ var comboboxItemGroupLabelBase = "px-2 py-1.5 text-xs font-semibold text-muted-foreground";
722
+ var comboboxItemVariants = cva15(
723
+ "relative flex w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground",
724
+ {
725
+ variants: {
726
+ showIndicator: {
727
+ true: "pe-8",
728
+ false: "pe-2"
729
+ }
730
+ },
731
+ defaultVariants: {
732
+ showIndicator: true
733
+ }
734
+ }
735
+ );
736
+ var comboboxItemIndicatorBase = "absolute inset-y-0 end-2 flex items-center justify-center text-foreground";
737
+ var comboboxListBase = "flex flex-col";
738
+ var comboboxEmptyBase = "px-2 py-1.5 text-center text-sm text-muted-foreground";
739
+
740
+ // src/tags-input.ts
741
+ var tagsInputRootBase = "flex w-full flex-col gap-2";
742
+ var tagsInputControlBase = "flex w-full flex-wrap items-center gap-1.5 rounded-md border border-input bg-transparent p-1.5 shadow-xs transition-[box-shadow] outline-none focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/30 data-invalid:border-destructive data-invalid:ring-[3px] data-invalid:ring-destructive/24 data-disabled:pointer-events-none data-disabled:opacity-50";
743
+ var tagsInputInputBase = "min-w-12 flex-1 border-0 bg-transparent px-1 text-sm outline-none ring-0 placeholder:text-muted-foreground focus-visible:ring-0";
744
+ var tagsInputItemBase = "inline-flex h-6 max-w-full shrink-0 items-center gap-1 rounded-md border bg-secondary px-1.5 text-xs text-secondary-foreground outline-none data-[highlighted]:border-primary/30 data-[highlighted]:bg-primary/10";
745
+ var tagsInputItemTextBase = "truncate";
746
+ var tagsInputItemInputBase = "w-16 border-0 bg-transparent text-xs outline-none";
747
+ var tagsInputItemDeleteTriggerBase = "flex size-4 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none [&_svg]:pointer-events-none [&_svg]:size-3 [&_svg]:shrink-0";
748
+ var tagsInputClearTriggerBase = "ms-auto flex shrink-0 items-center justify-center self-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none [&_svg]:pointer-events-none [&_svg]:size-3.5 [&_svg]:shrink-0";
749
+
750
+ // src/mermaid.ts
751
+ var mermaidRootBase = "not-prose my-4 overflow-x-auto";
752
+ var mermaidSourceBase = "w-full overflow-x-auto bg-muted p-4 font-mono text-sm whitespace-pre";
753
+ var mermaidSvgBase = "flex w-full items-center justify-center [&>svg]:max-w-full";
754
+ var mermaidLoadingBase = "flex min-h-40 w-full items-center justify-center gap-3";
755
+ var mermaidThemeVariableTokens = {
756
+ primaryColor: "--card",
757
+ primaryTextColor: "--foreground",
758
+ primaryBorderColor: "--border",
759
+ lineColor: "--muted-foreground",
760
+ secondaryColor: "--muted",
761
+ tertiaryColor: "--accent",
762
+ background: "--background",
763
+ mainBkg: "--card",
764
+ nodeBorder: "--border"
765
+ };
766
+ var scratchCtx;
767
+ function normalizeMermaidColor(value) {
768
+ scratchCtx ??= document.createElement("canvas").getContext("2d", { willReadFrequently: true });
769
+ if (!scratchCtx) return value;
770
+ scratchCtx.fillStyle = "rgb(1 2 3)";
771
+ scratchCtx.fillStyle = value;
772
+ scratchCtx.clearRect(0, 0, 1, 1);
773
+ scratchCtx.fillRect(0, 0, 1, 1);
774
+ const [r, g, b, a] = scratchCtx.getImageData(0, 0, 1, 1).data;
775
+ if (r === 1 && g === 2 && b === 3 && a === 255) return value;
776
+ if (a === 255) return `#${[r, g, b].map((c) => c.toString(16).padStart(2, "0")).join("")}`;
777
+ return `rgba(${r}, ${g}, ${b}, ${Math.round(a / 255 * 1e3) / 1e3})`;
778
+ }
779
+ function resolveMermaidThemeVariables() {
780
+ const styles = getComputedStyle(document.documentElement);
781
+ const themeVariables = {};
782
+ for (const [key, token] of Object.entries(mermaidThemeVariableTokens)) {
783
+ const value = styles.getPropertyValue(token).trim();
784
+ if (value) themeVariables[key] = normalizeMermaidColor(value);
785
+ }
786
+ return themeVariables;
787
+ }
788
+ var mermaidSeq = 0;
789
+ function mermaidSvgAspectRatio(svg) {
790
+ const match = /viewBox="\s*[-\d.]+\s+[-\d.]+\s+([-\d.]+)\s+([-\d.]+)"/.exec(svg);
791
+ if (!match) return void 0;
792
+ const width = Number(match[1]);
793
+ const height = Number(match[2]);
794
+ if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) return void 0;
795
+ return `${width} / ${height}`;
796
+ }
797
+ async function renderMermaidSource(code) {
798
+ const mermaid = (await import("mermaid")).default;
799
+ const dark = document.documentElement.classList.contains("dark");
800
+ mermaid.initialize({
801
+ startOnLoad: false,
802
+ securityLevel: "strict",
803
+ suppressErrorRendering: true,
804
+ theme: dark ? "dark" : "default",
805
+ themeVariables: resolveMermaidThemeVariables()
806
+ });
807
+ const { svg } = await mermaid.render(`helical-ui-mmd-${Date.now()}-${mermaidSeq++}`, code);
808
+ return svg;
809
+ }
810
+
811
+ // src/clipboard.ts
812
+ var clipboardTriggerBase = "inline-flex h-7 w-7 shrink-0 items-center justify-center gap-1.5 rounded-md text-xs text-muted-foreground transition-colors hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5 [&_svg]:shrink-0";
813
+
814
+ // src/radio-group.ts
815
+ var radioGroupRootBase = "flex flex-col gap-2";
816
+ var radioGroupItemControlBase = "relative inline-flex size-4 shrink-0 items-center justify-center rounded-full border border-input bg-transparent shadow-xs transition-shadow focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/30 focus-visible:ring-offset-1 focus-visible:ring-offset-background data-invalid:border-destructive data-invalid:ring-[3px] data-invalid:ring-destructive/24 data-[state=checked]:border-primary data-[state=checked]:text-primary disabled:pointer-events-none disabled:opacity-50";
817
+ var radioGroupItemTextBase = "select-none text-sm font-medium leading-none";
818
+
819
+ // src/notice.ts
820
+ import { cva as cva16 } from "class-variance-authority";
821
+ var noticeVariants = cva16(
822
+ "not-prose relative my-4 grid w-full items-center gap-y-0.5 rounded-lg border px-3 py-2.5 text-sm grid-cols-[0_1fr] has-[>svg]:grid-cols-[calc(var(--spacing)*3)_1fr] has-[>svg]:gap-x-2.5 [&>svg]:size-4",
823
+ {
824
+ variants: {
825
+ variant: {
826
+ none: "bg-card text-card-foreground",
827
+ info: "border-info/30 bg-info/5 [&>svg]:text-info",
828
+ success: "border-success/30 bg-success/5 [&>svg]:text-success",
829
+ warning: "border-warn/30 bg-warn/5 [&>svg]:text-warn",
830
+ error: "border-danger/30 bg-danger/5 [&>svg]:text-danger"
831
+ }
832
+ },
833
+ defaultVariants: {
834
+ variant: "info"
835
+ }
836
+ }
837
+ );
838
+ var noticeTitleBase = "col-start-2 min-h-4 font-semibold tracking-tight";
839
+ var noticeDescriptionBase = "col-start-2 text-sm text-foreground [&_p]:leading-relaxed";
840
+
841
+ // src/figure.ts
842
+ var figureRootBase = "not-prose my-4 flex flex-col items-center";
843
+ var figureImageBase = "rounded-lg border border-border";
844
+ var figureCaptionBase = "mt-2 text-center text-sm text-muted-foreground";
845
+
846
+ // src/reveal.ts
847
+ var revealRootBase = "not-prose my-4 overflow-hidden rounded-lg border border-border bg-muted/40";
848
+ var revealTriggerBase = "flex w-full cursor-pointer items-center gap-2 px-3 py-2.5 text-sm font-semibold";
849
+ var revealChevronBase = "size-4 shrink-0 text-muted-foreground transition-transform duration-200 data-[state=open]:rotate-90";
850
+ var revealContentBase = "border-t border-border px-3 py-2.5 text-sm text-foreground";
851
+
852
+ // src/prevnext.ts
853
+ var prevNextRootBase = "not-prose mt-8 flex flex-col gap-3 border-t border-border pt-6 sm:flex-row sm:justify-between";
854
+ var prevNextLinkBase = "group flex min-w-0 flex-1 flex-col rounded-lg border border-border px-4 py-3 no-underline transition-colors hover:border-primary";
855
+ var prevNextLinkNextBase = "items-end text-right";
856
+ var prevNextDirectionBase = "text-xs font-medium text-muted-foreground";
857
+ var prevNextTitleBase = "truncate text-sm font-medium text-foreground transition-colors group-hover:text-primary";
858
+ var prevNextSpacerBase = "flex-1";
859
+
860
+ // src/latex.ts
861
+ import katex from "katex";
862
+ var latexRootBase = "not-prose";
863
+ var latexDisplayBase = "my-4 block w-full overflow-x-auto py-1";
864
+ var latexInlineBase = "inline-block align-middle";
865
+ var latexErrorBase = "font-mono text-sm text-destructive";
866
+ function toLaTeX(latex, opts) {
867
+ return katex.renderToString(latex, {
868
+ displayMode: opts?.displayMode ?? false,
869
+ throwOnError: false,
870
+ strict: false
871
+ });
872
+ }
873
+
874
+ // src/code-block.ts
875
+ var codeBlockRootBase = "not-prose my-4 overflow-hidden rounded-lg border";
876
+ var codeBlockHeaderBase = "flex h-10 items-center justify-between gap-2 border-b bg-muted/50 px-4";
877
+ var codeBlockHeaderInfoBase = "flex min-w-0 items-center gap-2 text-muted-foreground";
878
+ var codeBlockTitleBase = "min-w-0 truncate font-mono text-xs";
879
+ var codeBlockBodyBase = "hx-cb relative overflow-x-auto bg-background";
880
+ var codeBlockBodyScrollableBase = "overflow-y-auto";
881
+ var codeBlockContentBase = "text-sm [&>pre]:p-4 [&_.line]:leading-[1.7]";
882
+ var codeBlockLineNumbersBase = "cbln";
883
+ var codeBlockHighlightBase = "cbhl";
884
+ var codeBlockLoadingBase = "flex h-16 items-center justify-center";
885
+ var codeBlockSpinnerBase = "h-4 w-4 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent";
886
+ var codeBlockCopyFloatBase = "absolute right-2 top-2";
887
+ var CODE_BLOCK_STYLES = `
888
+ .hx-cb pre.shiki{margin:0!important;border:0!important;border-radius:0!important;background:transparent!important}
889
+ .hx-cb pre.shiki code{border:0!important;border-radius:0!important;background:transparent!important;padding:0!important}
890
+ :root.dark .hx-cb .shiki,
891
+ :root.dark .hx-cb .shiki span{color:var(--shiki-dark)!important;font-style:var(--shiki-dark-font-style)!important;font-weight:var(--shiki-dark-font-weight)!important;text-decoration:var(--shiki-dark-text-decoration)!important}
892
+ .hx-cb .cbln code{counter-reset:line;counter-increment:line 0}
893
+ .hx-cb .cbln .line::before{content:counter(line);counter-increment:line;display:inline-block;min-width:1.5rem;padding-right:.75rem;margin-right:1rem;text-align:right;font-size:.75rem;line-height:1.7;user-select:none;color:color-mix(in srgb,var(--muted-foreground,#888) 55%,transparent)}
894
+ .hx-cb .cbhl .line-highlighted{display:block;background-color:oklch(0.828 0.189 84.429/.12);border-left:2px solid oklch(0.769 0.188 70.08);margin:0 -1rem;padding:0 1rem}
895
+ `;
896
+ function injectCodeBlockStyles() {
897
+ if (typeof document === "undefined") return;
898
+ if (document.getElementById("hx-code-block")) return;
899
+ const el = document.createElement("style");
900
+ el.id = "hx-code-block";
901
+ el.textContent = CODE_BLOCK_STYLES;
902
+ document.head.appendChild(el);
903
+ }
904
+ function escapeHtml(s) {
905
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
906
+ }
907
+ function plaintextFallback(code) {
908
+ const lines = code.split("\n").map((l) => `<span class="line">${escapeHtml(l)}</span>`).join("\n");
909
+ return `<pre class="shiki" tabindex="-1"><code>${lines}</code></pre>`;
910
+ }
911
+ async function renderCodeToHtml(code, language, highlightLines) {
912
+ injectCodeBlockStyles();
913
+ try {
914
+ const { codeToHtml } = await import("shiki/bundle/full");
915
+ return await codeToHtml(code, {
916
+ lang: language,
917
+ themes: { light: "github-light", dark: "github-dark" },
918
+ tabindex: false,
919
+ transformers: [
920
+ {
921
+ pre(node) {
922
+ if (node.properties?.["style"]) {
923
+ node.properties["style"] = node.properties["style"].replace(/background-color:\s*[^;]+;?\s*/gi, "").replace(/--shiki-dark-bg:\s*[^;]+;?\s*/gi, "");
924
+ }
925
+ },
926
+ line(node, line) {
927
+ if (highlightLines?.includes(line)) {
928
+ this.addClassToHast(node, "line-highlighted");
929
+ }
930
+ }
931
+ }
932
+ ]
933
+ });
934
+ } catch {
935
+ return plaintextFallback(code);
936
+ }
937
+ }
938
+
939
+ // src/manim.ts
940
+ var manimRootBase = "not-prose my-4";
941
+ var manimContainerBase = "relative w-full overflow-hidden rounded-lg border border-border [&_canvas]:!h-auto [&_canvas]:!max-w-full";
942
+ var manimPlaceholderBase = "flex w-full items-center justify-center bg-muted/40";
943
+ var manimPlaceholderLabelBase = "text-sm text-muted-foreground";
944
+ var manimErrorBase = "flex items-center justify-center border-destructive/50 bg-destructive/5 p-6 text-sm text-destructive";
945
+ var manimCaptionBase = "mt-2 text-center text-sm text-muted-foreground";
946
+
947
+ // src/youtube.ts
948
+ var youtubeRootBase = "not-prose my-4";
949
+ var youtubeTitleBase = "mb-2 text-lg font-semibold text-foreground";
950
+ var youtubeFacadeBase = "group relative aspect-video w-full cursor-pointer overflow-hidden rounded-md border border-border bg-muted/40";
951
+ var youtubePlayButtonBase = "absolute inset-0 flex items-center justify-center";
952
+ var youtubePlayButtonInnerBase = "flex items-center justify-center rounded-xl bg-red-600 px-4 py-2 text-white drop-shadow-lg transition-transform group-hover:scale-105";
953
+ var youtubeDescriptionBase = "mt-2 text-sm text-muted-foreground";
954
+ var youtubeChaptersBase = "group mt-3 rounded-lg border border-border bg-muted/40";
955
+ var youtubeChaptersSummaryBase = "flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 text-sm font-medium [&::-webkit-details-marker]:hidden";
956
+ var youtubeChaptersChevronBase = "size-4 shrink-0 text-muted-foreground transition-transform duration-200 group-open:rotate-90";
957
+ var youtubeChaptersListBase = "border-t border-border px-2 py-2";
958
+ var youtubeChapterButtonBase = "inline-flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";
959
+ var youtubeChapterTimeBase = "font-mono text-xs text-primary";
960
+ var youtubeChapterLabelBase = "text-foreground";
961
+ function extractYouTubeId(raw) {
962
+ try {
963
+ const url = new URL(raw);
964
+ const v = url.searchParams.get("v");
965
+ if (v) return v;
966
+ if (url.hostname === "youtu.be") return url.pathname.slice(1);
967
+ } catch {
968
+ }
969
+ return raw;
970
+ }
971
+ function formatTime(seconds) {
972
+ const h = Math.floor(seconds / 3600);
973
+ const m = Math.floor(seconds % 3600 / 60);
974
+ const s = Math.floor(seconds % 60);
975
+ const mm = String(m).padStart(2, "0");
976
+ const ss = String(s).padStart(2, "0");
977
+ return h > 0 ? `${h}:${mm}:${ss}` : `${mm}:${ss}`;
978
+ }
979
+ var TIMESTAMP_RE = /^\s*\[?\(?(?:(\d+):)?(\d{1,2}):(\d{2})\)?\]?\s+(\S.*)$/;
980
+ function parseYouTubeChapters(description) {
981
+ return description.split("\n").map((line) => {
982
+ const m = TIMESTAMP_RE.exec(line);
983
+ if (!m) return null;
984
+ const hours = m[1] ? Number(m[1]) : 0;
985
+ const t = hours * 3600 + Number(m[2]) * 60 + Number(m[3]);
986
+ return { t, label: m[4] };
987
+ }).filter((c) => c !== null);
988
+ }
989
+ async function fetchYouTubeMetadata(url) {
990
+ const videoId = extractYouTubeId(url);
991
+ const res = await fetch(
992
+ `https://noembed.com/embed?url=${encodeURIComponent(`https://www.youtube.com/watch?v=${videoId}`)}`
993
+ );
994
+ if (!res.ok) return {};
995
+ const data = await res.json();
996
+ return { title: data.title, description: data.description };
997
+ }
998
+
999
+ // src/chart.ts
1000
+ import {
1001
+ barY,
1002
+ areaY,
1003
+ colorLegend,
1004
+ defineChart,
1005
+ lineY,
1006
+ createChartRuntime,
1007
+ renderChartSvg
1008
+ } from "@tanstack/charts";
1009
+ import { pie, polar, radialArc } from "@tanstack/charts/polar";
1010
+ import { scaleLinear } from "@tanstack/charts/scales/linear";
1011
+ import { scaleOrdinal } from "@tanstack/charts/scales/ordinal";
1012
+ import { scalePoint } from "@tanstack/charts/scales/point";
1013
+ import { tooltip } from "@tanstack/charts/tooltip";
1014
+ var chartRootBase = "not-prose my-4";
1015
+ var chartPlaceholderBase = "flex items-center justify-center rounded-md border border-border bg-muted/40";
1016
+ var chartPlaceholderLabelBase = "text-sm text-muted-foreground";
1017
+ function defaultChartColor(index) {
1018
+ return `var(--chart-${index % 5 + 1})`;
1019
+ }
1020
+ var COLOR_TOKENS = ["var(--chart-1)", "var(--chart-2)", "var(--chart-3)", "var(--chart-4)", "var(--chart-5)"];
1021
+ function buildChartDefinition(props) {
1022
+ const {
1023
+ type,
1024
+ data,
1025
+ series,
1026
+ xKey = "name",
1027
+ nameKey = "name",
1028
+ showLegend = true,
1029
+ showGrid = true,
1030
+ showAxis = true
1031
+ } = props;
1032
+ const colors = series.map((s, i) => s.color ?? COLOR_TOKENS[i % COLOR_TOKENS.length]);
1033
+ if (type === "pie") {
1034
+ const valueKey = series[0]?.key ?? "value";
1035
+ const slices = pie(data, { value: valueKey });
1036
+ const pieColors = data.map((_, i) => series[0]?.color ?? COLOR_TOKENS[i % COLOR_TOKENS.length]);
1037
+ const spec2 = {
1038
+ marks: [
1039
+ polar({
1040
+ scales: { angle: null, radius: null },
1041
+ radiusRatio: 0.82,
1042
+ marks: [radialArc(slices, { color: nameKey, key: nameKey, cornerRadius: 3 })]
1043
+ })
1044
+ ],
1045
+ scales: { x: null, y: null },
1046
+ color: {
1047
+ domain: data.map((d) => String(d[nameKey])),
1048
+ range: pieColors,
1049
+ legend: showLegend ? colorLegend({}) : void 0
1050
+ },
1051
+ tooltip
1052
+ };
1053
+ return defineChart(spec2);
1054
+ }
1055
+ const rows = data.flatMap(
1056
+ (row) => series.map((s) => ({
1057
+ ...row,
1058
+ _series: s.label ?? s.key,
1059
+ _value: Number(row[s.key])
1060
+ }))
1061
+ );
1062
+ const markOpts = { x: xKey, y: "_value", z: "_series" };
1063
+ const mark = type === "bar" ? barY(rows, { ...markOpts, fillOpacity: 0.85 }) : type === "area" ? areaY(rows, { ...markOpts, fillOpacity: 0.15 }) : lineY(rows, { ...markOpts, strokeWidth: 2 });
1064
+ const spec = {
1065
+ marks: [mark],
1066
+ scales: {
1067
+ x: { scale: () => scalePoint().padding(0.4), axis: showAxis ? {} : void 0 },
1068
+ y: {
1069
+ scale: scaleLinear,
1070
+ nice: true,
1071
+ grid: showGrid,
1072
+ axis: showAxis ? { ticks: { count: 5 } } : void 0
1073
+ }
1074
+ },
1075
+ color: {
1076
+ scale: () => scaleOrdinal().range(colors),
1077
+ domain: series.map((s) => s.label ?? s.key),
1078
+ legend: showLegend ? colorLegend({}) : void 0
1079
+ },
1080
+ tooltip
1081
+ };
1082
+ return defineChart(spec);
1083
+ }
1084
+ function renderChartSvgString(props, opts = {}) {
1085
+ const { width = 720, height = props.height ?? 400, ariaLabel = "Chart" } = opts;
1086
+ const definition = buildChartDefinition(props);
1087
+ const runtime = createChartRuntime();
1088
+ try {
1089
+ const scene = runtime.render(definition, { width, height });
1090
+ return renderChartSvg(scene, { ariaLabel, idPrefix: "hx-chart" });
1091
+ } finally {
1092
+ runtime.destroy();
1093
+ }
1094
+ }
1095
+
1096
+ // src/question.ts
1097
+ var questionCardBase = "not-prose my-4 rounded-lg border border-border bg-card p-4";
1098
+ var questionPromptBase = "mb-3 text-sm font-medium text-foreground";
1099
+ var questionGroupBase = "grid gap-2";
1100
+ var questionOptionBase = "rounded-md px-3 py-2 transition-colors hover:bg-muted/60";
1101
+ var questionOptionCorrectBase = "bg-success/10";
1102
+ var questionOptionIncorrectBase = "bg-destructive/10";
1103
+ var questionCheckButtonBase = "mt-3 rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50";
1104
+ var questionInputBase = "h-9 w-32 rounded-md border border-input bg-background px-3 text-sm text-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50";
1105
+ var questionUnitBase = "text-sm text-muted-foreground";
1106
+ var feedbackCorrectBase = "text-success";
1107
+ var feedbackIncorrectBase = "text-destructive";
1108
+ var feedbackExplanationBase = "mt-1.5 text-sm text-muted-foreground";
1109
+ var quizRootBase = "not-prose my-6 rounded-lg border border-border bg-card/50 p-4";
1110
+ var quizHeaderBase = "mb-4 flex items-center justify-between gap-3";
1111
+ var quizTitleBase = "text-base font-semibold text-foreground";
1112
+ var quizScoreBase = "inline-flex items-center rounded-full bg-muted px-2.5 py-0.5 text-xs font-medium text-muted-foreground";
1113
+ var quizResultBase = "mt-4 rounded-lg border border-border bg-muted/40 p-4";
1114
+ var quizResultTitleBase = "text-lg font-semibold text-foreground";
1115
+ var quizResultTextBase = "mt-1 text-sm text-muted-foreground";
1116
+ var quizSubmitButtonBase = "rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50";
1117
+ var quizResetButtonBase = "inline-flex items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-sm font-medium text-foreground transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2";
1118
+
1119
+ // src/prose.ts
1120
+ import { cva as cva17 } from "class-variance-authority";
1121
+ var proseVariants = cva17(
1122
+ [
1123
+ "text-foreground",
1124
+ "max-w-none",
1125
+ // Top spacing scales WITH the heading — a bigger heading gets more space above it — and the
1126
+ // first child never carries a top margin (otherwise a leading heading opens a large gap).
1127
+ // Previously h1 had mt-0 while h2 had mt-8, so a smaller heading had more top padding than a
1128
+ // larger one.
1129
+ "[&>*:first-child]:mt-0",
1130
+ "[&_h1]:font-bold [&_h1]:tracking-tight [&_h1]:mt-10 [&_h1]:mb-4",
1131
+ "[&_h2]:font-semibold [&_h2]:tracking-tight [&_h2]:mt-8 [&_h2]:mb-3",
1132
+ "[&_h3]:font-semibold [&_h3]:mt-6 [&_h3]:mb-2",
1133
+ "[&_h4]:font-semibold [&_h4]:mt-4 [&_h4]:mb-2",
1134
+ "[&_h5]:font-semibold [&_h5]:mt-4 [&_h5]:mb-1",
1135
+ "[&_h6]:font-semibold [&_h6]:mt-4 [&_h6]:mb-1 [&_h6]:text-muted-foreground",
1136
+ "[&_p]:my-4 [&_p]:leading-7",
1137
+ "[&_a]:text-primary [&_a]:underline [&_a]:underline-offset-2 hover:[&_a]:opacity-80",
1138
+ "[&_strong]:font-semibold",
1139
+ "[&_ul]:my-4 [&_ul]:list-disc [&_ul]:pl-6",
1140
+ "[&_ol]:my-4 [&_ol]:list-decimal [&_ol]:pl-6",
1141
+ "[&_li]:my-1",
1142
+ "[&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-4 [&_blockquote]:italic [&_blockquote]:text-muted-foreground",
1143
+ "[&_hr]:my-8 [&_hr]:border-border",
1144
+ "[&_code]:rounded [&_code]:bg-muted [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:text-[0.875em]",
1145
+ "[&_pre]:rounded-lg [&_pre]:bg-muted [&_pre]:p-4 [&_pre]:overflow-x-auto",
1146
+ "[&_pre_code]:bg-transparent [&_pre_code]:p-0",
1147
+ "[&_img]:rounded-lg [&_img]:my-6",
1148
+ "[&_figure]:my-6",
1149
+ "[&_figcaption]:mt-2 [&_figcaption]:text-center [&_figcaption]:text-sm [&_figcaption]:italic [&_figcaption]:text-muted-foreground"
1150
+ ],
1151
+ {
1152
+ variants: {
1153
+ size: {
1154
+ sm: "text-sm [&_h1]:text-2xl [&_h2]:text-xl [&_h3]:text-lg [&_h4]:text-base [&_h5]:text-sm",
1155
+ base: "text-base [&_h1]:text-4xl [&_h2]:text-2xl [&_h3]:text-xl [&_h4]:text-lg [&_h5]:text-base",
1156
+ lg: "text-lg [&_h1]:text-5xl [&_h2]:text-3xl [&_h3]:text-2xl [&_h4]:text-xl [&_h5]:text-lg"
1157
+ }
1158
+ },
1159
+ defaultVariants: { size: "base" }
1160
+ }
1161
+ );
1162
+
1163
+ // src/toggle-group.ts
1164
+ import { cva as cva18 } from "class-variance-authority";
1165
+ var toggleGroupRootVariants = cva18("inline-flex items-center", {
1166
+ variants: {
1167
+ orientation: { horizontal: "flex-row", vertical: "flex-col" },
1168
+ // `gap` belongs to the variants, not the base. With a `gap-1` base plus a `gap-0` variant
1169
+ // BOTH utilities land on the element and the winner is decided by Tailwind's emission order,
1170
+ // not by the variant — `.gap-1` is emitted after `.gap-0`, which silently defeated `attached`
1171
+ // and left a 1-unit gap between buttons.
1172
+ attached: {
1173
+ true: "gap-0 [&>*]:rounded-none [&>*]:shadow-none [&>*[data-state=on]]:z-10 [&>*[data-state=on]]:border-primary",
1174
+ false: "gap-1"
1175
+ }
1176
+ },
1177
+ // `attached` radii/overlap must follow the layout axis: rounded-s/e and -ms are inline-axis,
1178
+ // which is wrong for a vertical group. Keep them in orientation-scoped compound variants.
1179
+ compoundVariants: [
1180
+ {
1181
+ orientation: "horizontal",
1182
+ attached: true,
1183
+ class: "[&>*:first-child]:rounded-s-md [&>*:last-child]:rounded-e-md [&>*:not(:first-child)]:-ms-px"
1184
+ },
1185
+ {
1186
+ orientation: "vertical",
1187
+ attached: true,
1188
+ class: "[&>*:first-child]:rounded-t-md [&>*:last-child]:rounded-b-md [&>*:not(:first-child)]:-mt-px"
1189
+ }
1190
+ ],
1191
+ defaultVariants: { orientation: "horizontal", attached: false }
1192
+ });
1193
+
1194
+ // src/listbox.ts
1195
+ function defaultListboxFilter(item, query) {
1196
+ if (!query) return true;
1197
+ return item.label.toLowerCase().includes(query.toLowerCase());
1198
+ }
1199
+ var listboxRootBase = "flex flex-col overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-sm";
1200
+ var listboxContentBase = "max-h-72 overflow-y-auto p-1 outline-none";
1201
+ var listboxItemBase = "relative flex w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 pe-8 text-sm outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[state=checked]:font-medium data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0";
1202
+ var listboxItemTextBase = "flex w-full flex-1 items-center gap-2";
1203
+ var listboxItemIndicatorBase = "absolute inset-y-0 end-2 flex items-center justify-center text-foreground";
1204
+ var listboxInputBase = "w-full border-b border-input bg-transparent px-2.5 py-1.5 text-sm outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/30";
1205
+ var listboxEmptyBase = "px-2 py-6 text-center text-sm text-muted-foreground";
1206
+ var listboxLabelBase = "px-2 py-1.5 text-xs font-semibold text-muted-foreground";
1207
+
1208
+ // src/editor/build-extensions.ts
1209
+ import StarterKit from "@tiptap/starter-kit";
1210
+ import Placeholder from "@tiptap/extension-placeholder";
1211
+ import Highlight from "@tiptap/extension-highlight";
1212
+ import Link from "@tiptap/extension-link";
1213
+ import Typography from "@tiptap/extension-typography";
1214
+ import Underline from "@tiptap/extension-underline";
1215
+ import { TextStyle } from "@tiptap/extension-text-style";
1216
+ import { Color } from "@tiptap/extension-color";
1217
+ import TextAlign from "@tiptap/extension-text-align";
1218
+ import TaskList from "@tiptap/extension-task-list";
1219
+ import TaskItem from "@tiptap/extension-task-item";
1220
+ import CharacterCount from "@tiptap/extension-character-count";
1221
+ import { common, createLowlight } from "lowlight";
1222
+
1223
+ // src/editor/extensions/title-heading.ts
1224
+ import { Extension } from "@tiptap/core";
1225
+ import { Plugin, PluginKey } from "@tiptap/pm/state";
1226
+ var TitleHeading = Extension.create({
1227
+ name: "titleHeading",
1228
+ addProseMirrorPlugins() {
1229
+ return [
1230
+ new Plugin({
1231
+ key: new PluginKey("titleHeading"),
1232
+ appendTransaction: (transactions, oldState, newState) => {
1233
+ const tr = newState.tr;
1234
+ let modified = false;
1235
+ const firstNode = newState.doc.firstChild;
1236
+ if (!firstNode) {
1237
+ tr.insert(0, newState.schema.nodes.heading.create({ level: 1 }));
1238
+ modified = true;
1239
+ } else if (firstNode.type.name !== "heading" || firstNode.attrs.level !== 1) {
1240
+ const h1 = newState.schema.nodes.heading.create({ level: 1 }, firstNode.content);
1241
+ tr.replaceWith(0, firstNode.nodeSize, h1);
1242
+ modified = true;
1243
+ }
1244
+ return modified ? tr : null;
1245
+ }
1246
+ })
1247
+ ];
1248
+ }
1249
+ });
1250
+
1251
+ // src/editor/extensions/exit-heading.ts
1252
+ import { Extension as Extension2 } from "@tiptap/core";
1253
+ var ExitHeading = Extension2.create({
1254
+ name: "exitHeading",
1255
+ addKeyboardShortcuts() {
1256
+ return {
1257
+ Enter: ({ editor }) => {
1258
+ const { state } = editor;
1259
+ const { selection } = state;
1260
+ const { $from } = selection;
1261
+ if ($from.parent.type.name === "heading") {
1262
+ if ($from.parent.textContent.length === 0) {
1263
+ return editor.chain().setNode("paragraph").run();
1264
+ }
1265
+ if (selection.empty && $from.parentOffset === $from.parent.textContent.length) {
1266
+ return editor.chain().command(({ tr }) => {
1267
+ tr.split(selection.from);
1268
+ return true;
1269
+ }).setNode("paragraph").run();
1270
+ }
1271
+ }
1272
+ return false;
1273
+ }
1274
+ };
1275
+ }
1276
+ });
1277
+
1278
+ // src/editor/extensions/heading-with-id.ts
1279
+ import { Heading } from "@tiptap/extension-heading";
1280
+ import { mergeAttributes } from "@tiptap/core";
1281
+ var HeadingWithId = Heading.extend({
1282
+ renderHTML({ node, HTMLAttributes }) {
1283
+ const level = node.attrs.level;
1284
+ const id = node.textContent.toLowerCase().replace(/\s+/g, "-");
1285
+ return [`h${level}`, mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, { id }), 0];
1286
+ }
1287
+ });
1288
+
1289
+ // src/editor/extensions/editor-heading.ts
1290
+ import { textblockTypeInputRule } from "@tiptap/core";
1291
+ import { Heading as Heading2 } from "@tiptap/extension-heading";
1292
+ var EditorHeading = Heading2.extend({
1293
+ addInputRules() {
1294
+ const rules = this.options.levels.map(
1295
+ (level) => textblockTypeInputRule({
1296
+ find: new RegExp(`^(#{${level}})\\s$`),
1297
+ type: this.type,
1298
+ getAttributes: { level }
1299
+ })
1300
+ );
1301
+ if (this.options.levels.includes(2)) {
1302
+ rules.unshift(
1303
+ textblockTypeInputRule({
1304
+ find: /^#\s$/,
1305
+ type: this.type,
1306
+ getAttributes: { level: 2 }
1307
+ })
1308
+ );
1309
+ }
1310
+ return rules;
1311
+ }
1312
+ });
1313
+
1314
+ // src/editor/extensions/slash-commands.ts
1315
+ import { Extension as Extension3 } from "@tiptap/core";
1316
+ import { PluginKey as PluginKey2 } from "@tiptap/pm/state";
1317
+ import Suggestion from "@tiptap/suggestion";
1318
+ function registerImageInsertCallback(editor, cb) {
1319
+ editor.storage.slashCommands.onInsertImage = cb;
1320
+ }
1321
+ function unregisterImageInsertCallback(editor) {
1322
+ editor.storage.slashCommands.onInsertImage = void 0;
1323
+ }
1324
+ function registerYouTubeInsertCallback(editor, cb) {
1325
+ editor.storage.slashCommands.onInsertYouTube = cb;
1326
+ }
1327
+ function unregisterYouTubeInsertCallback(editor) {
1328
+ editor.storage.slashCommands.onInsertYouTube = void 0;
1329
+ }
1330
+ var slashCommands = Extension3.create({
1331
+ name: "slashCommands",
1332
+ addOptions() {
1333
+ return {
1334
+ suggestion: {
1335
+ char: "/",
1336
+ pluginKey: new PluginKey2("slashCommands"),
1337
+ command: ({
1338
+ editor,
1339
+ range,
1340
+ props
1341
+ }) => {
1342
+ props.command({ editor, range });
1343
+ },
1344
+ items: ({ query }) => {
1345
+ const commands = [
1346
+ {
1347
+ title: "Heading 1",
1348
+ description: "Large section heading",
1349
+ icon: "Heading1",
1350
+ category: "suggested",
1351
+ shortcut: "#",
1352
+ command: ({ editor, range }) => {
1353
+ editor.chain().focus().deleteRange(range).setNode("heading", { level: 2 }).run();
1354
+ }
1355
+ },
1356
+ {
1357
+ title: "Heading 2",
1358
+ description: "Medium section heading",
1359
+ icon: "Heading2",
1360
+ category: "suggested",
1361
+ shortcut: "##",
1362
+ command: ({ editor, range }) => {
1363
+ editor.chain().focus().deleteRange(range).setNode("heading", { level: 3 }).run();
1364
+ }
1365
+ },
1366
+ {
1367
+ title: "Heading 3",
1368
+ description: "Small section heading",
1369
+ icon: "Heading3",
1370
+ category: "suggested",
1371
+ shortcut: "###",
1372
+ command: ({ editor, range }) => {
1373
+ editor.chain().focus().deleteRange(range).setNode("heading", { level: 4 }).run();
1374
+ }
1375
+ },
1376
+ {
1377
+ title: "Heading 4",
1378
+ description: "Minor section heading",
1379
+ icon: "Heading4",
1380
+ category: "suggested",
1381
+ shortcut: "####",
1382
+ command: ({ editor, range }) => {
1383
+ editor.chain().focus().deleteRange(range).setNode("heading", { level: 5 }).run();
1384
+ }
1385
+ },
1386
+ {
1387
+ title: "Quote",
1388
+ description: "Insert a blockquote",
1389
+ icon: "Quote",
1390
+ category: "basic",
1391
+ shortcut: ">",
1392
+ command: ({ editor, range }) => {
1393
+ editor.chain().focus().deleteRange(range).toggleBlockquote().run();
1394
+ }
1395
+ },
1396
+ {
1397
+ title: "Notice",
1398
+ description: "Insert a styled callout",
1399
+ icon: "MessageSquareWarning",
1400
+ category: "basic",
1401
+ command: ({ editor, range }) => {
1402
+ editor.chain().focus().deleteRange(range).insertNotice({ variant: "info", title: "Note" }).run();
1403
+ }
1404
+ },
1405
+ {
1406
+ title: "Bullet List",
1407
+ description: "Create a bulleted list",
1408
+ icon: "List",
1409
+ category: "suggested",
1410
+ shortcut: "-",
1411
+ command: ({ editor, range }) => {
1412
+ editor.chain().focus().deleteRange(range).toggleBulletList().run();
1413
+ }
1414
+ },
1415
+ {
1416
+ title: "Numbered List",
1417
+ description: "Create a numbered list",
1418
+ icon: "ListOrdered",
1419
+ category: "suggested",
1420
+ shortcut: "1.",
1421
+ command: ({ editor, range }) => {
1422
+ editor.chain().focus().deleteRange(range).toggleOrderedList().run();
1423
+ }
1424
+ },
1425
+ {
1426
+ title: "Todo List",
1427
+ description: "Create a task list with checkboxes",
1428
+ icon: "ListTodo",
1429
+ category: "suggested",
1430
+ shortcut: "[]",
1431
+ command: ({ editor, range }) => {
1432
+ editor.chain().focus().deleteRange(range).toggleTaskList().run();
1433
+ }
1434
+ },
1435
+ {
1436
+ title: "Divider",
1437
+ description: "Insert a horizontal divider",
1438
+ icon: "Minus",
1439
+ category: "basic",
1440
+ shortcut: "---",
1441
+ command: ({ editor, range }) => {
1442
+ editor.chain().focus().deleteRange(range).setHorizontalRule().run();
1443
+ }
1444
+ },
1445
+ {
1446
+ title: "Code Block",
1447
+ description: "Insert a code block with syntax highlighting",
1448
+ icon: "Code",
1449
+ category: "advanced",
1450
+ shortcut: "```",
1451
+ command: ({ editor, range }) => {
1452
+ editor.chain().focus().deleteRange(range).setCodeBlock({ language: "plaintext" }).run();
1453
+ }
1454
+ },
1455
+ {
1456
+ title: "YouTube",
1457
+ description: "Embed a YouTube video",
1458
+ icon: "YouTube",
1459
+ category: "media",
1460
+ command: ({ editor, range }) => {
1461
+ editor.chain().focus().deleteRange(range).run();
1462
+ editor.storage.slashCommands.onInsertYouTube?.(
1463
+ range.from
1464
+ );
1465
+ }
1466
+ },
1467
+ {
1468
+ title: "Image",
1469
+ description: "Upload an image from your computer",
1470
+ icon: "Image",
1471
+ category: "media",
1472
+ command: ({ editor, range }) => {
1473
+ editor.chain().focus().deleteRange(range).run();
1474
+ editor.storage.slashCommands.onInsertImage?.(
1475
+ range.from
1476
+ );
1477
+ }
1478
+ },
1479
+ {
1480
+ title: "Bookmark",
1481
+ description: "Create a rich link preview card",
1482
+ icon: "Bookmark",
1483
+ category: "media",
1484
+ command: ({ editor, range }) => {
1485
+ editor.chain().focus().deleteRange(range).run();
1486
+ editor.storage["bookmarkInput"] = {
1487
+ active: true,
1488
+ position: range.from
1489
+ };
1490
+ }
1491
+ }
1492
+ ];
1493
+ return commands.filter((item) => item.title.toLowerCase().startsWith(query.toLowerCase()));
1494
+ }
1495
+ }
1496
+ };
1497
+ },
1498
+ addStorage() {
1499
+ return { onInsertImage: void 0, onInsertYouTube: void 0 };
1500
+ },
1501
+ addProseMirrorPlugins() {
1502
+ return [
1503
+ Suggestion({
1504
+ editor: this.editor,
1505
+ ...this.options.suggestion
1506
+ })
1507
+ ];
1508
+ }
1509
+ });
1510
+
1511
+ // src/editor/extensions/code-block-custom.ts
1512
+ import CodeBlockLowlight from "@tiptap/extension-code-block-lowlight";
1513
+ var createCodeBlockCustom = (lowlight, nodeView) => CodeBlockLowlight.extend({
1514
+ addNodeView() {
1515
+ return nodeView();
1516
+ },
1517
+ addKeyboardShortcuts() {
1518
+ return {
1519
+ Tab: () => {
1520
+ if (this.editor.isActive("codeBlock")) {
1521
+ return this.editor.commands.insertContent(" ");
1522
+ }
1523
+ return false;
1524
+ },
1525
+ "Shift-Tab": () => {
1526
+ if (this.editor.isActive("codeBlock")) {
1527
+ const { state } = this.editor;
1528
+ const { selection } = state;
1529
+ const { $from } = selection;
1530
+ const textBefore = $from.parent.textBetween(0, $from.parentOffset);
1531
+ if (textBefore.endsWith(" ")) {
1532
+ return this.editor.commands.deleteRange({
1533
+ from: $from.pos - 1,
1534
+ to: $from.pos
1535
+ });
1536
+ }
1537
+ }
1538
+ return false;
1539
+ }
1540
+ };
1541
+ }
1542
+ }).configure({
1543
+ lowlight,
1544
+ defaultLanguage: "javascript"
1545
+ });
1546
+
1547
+ // src/editor/extensions/image-node.ts
1548
+ import { Node as Node2 } from "@tiptap/core";
1549
+ import { Plugin as Plugin2, PluginKey as PluginKey3, NodeSelection, TextSelection } from "@tiptap/pm/state";
1550
+ import { DecorationSet, Decoration } from "@tiptap/pm/view";
1551
+ var imageBackspaceKey = new PluginKey3("imageBackspace");
1552
+ var createImageNode = (nodeView) => Node2.create({
1553
+ name: "imageNode",
1554
+ group: "block",
1555
+ atom: true,
1556
+ addAttributes() {
1557
+ return {
1558
+ src: { default: null },
1559
+ srcset: { default: null },
1560
+ alt: { default: "" },
1561
+ caption: { default: "" }
1562
+ };
1563
+ },
1564
+ parseHTML() {
1565
+ return [{ tag: 'figure[data-type="image-node"]' }];
1566
+ },
1567
+ renderHTML({ HTMLAttributes }) {
1568
+ const { src, srcset, alt, caption } = HTMLAttributes;
1569
+ const imgAttrs = {
1570
+ src,
1571
+ srcset,
1572
+ alt: alt || "",
1573
+ sizes: "(max-width: 768px) 100vw, 720px",
1574
+ class: "w-full object-cover"
1575
+ };
1576
+ if (!caption) {
1577
+ return ["figure", { "data-type": "image-node", class: "my-6 m-0" }, ["img", imgAttrs]];
1578
+ }
1579
+ return [
1580
+ "figure",
1581
+ { "data-type": "image-node", class: "my-6 m-0" },
1582
+ ["img", imgAttrs],
1583
+ ["figcaption", { class: "mt-4 text-sm text-muted-foreground text-center italic" }, caption]
1584
+ ];
1585
+ },
1586
+ addNodeView() {
1587
+ return nodeView();
1588
+ },
1589
+ addCommands() {
1590
+ return {
1591
+ insertImage: (attrs) => ({ commands }) => {
1592
+ return commands.insertContent({
1593
+ type: this.name,
1594
+ attrs
1595
+ });
1596
+ }
1597
+ };
1598
+ },
1599
+ addProseMirrorPlugins() {
1600
+ let arrowKeyPressed = false;
1601
+ const captionFocusPlugin = new Plugin2({
1602
+ key: new PluginKey3("imageNodeCaptionFocus"),
1603
+ props: {
1604
+ handleKeyDown(_view, event) {
1605
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
1606
+ arrowKeyPressed = true;
1607
+ }
1608
+ return false;
1609
+ }
1610
+ },
1611
+ view() {
1612
+ return {
1613
+ update(view, prevState) {
1614
+ const { selection } = view.state;
1615
+ const { selection: prevSelection } = prevState;
1616
+ const movedOntoImage = arrowKeyPressed && selection instanceof NodeSelection && selection.node.type.name === "imageNode" && !(prevSelection instanceof NodeSelection && prevSelection.from === selection.from);
1617
+ arrowKeyPressed = false;
1618
+ if (movedOntoImage) {
1619
+ const pos = selection.from;
1620
+ const nodeSize = selection.node.nodeSize;
1621
+ const dom = view.nodeDOM(pos);
1622
+ const input = dom ? dom.querySelector(".caption-input") : null;
1623
+ if (input) {
1624
+ const { tr, doc } = view.state;
1625
+ const $after = doc.resolve(Math.min(pos + nodeSize, doc.content.size));
1626
+ view.dispatch(tr.setSelection(TextSelection.near($after)));
1627
+ input.focus({ preventScroll: true });
1628
+ setTimeout(() => {
1629
+ const rect = input.getBoundingClientRect();
1630
+ if (rect.bottom > window.innerHeight || rect.top < 0) {
1631
+ input.scrollIntoView({ block: "nearest", behavior: "smooth" });
1632
+ }
1633
+ }, 0);
1634
+ }
1635
+ }
1636
+ }
1637
+ };
1638
+ }
1639
+ });
1640
+ const backspacePlugin = new Plugin2({
1641
+ key: imageBackspaceKey,
1642
+ state: {
1643
+ init: () => null,
1644
+ apply(tr, value) {
1645
+ const meta = tr.getMeta(imageBackspaceKey);
1646
+ if (meta !== void 0) return meta;
1647
+ if (tr.docChanged) return null;
1648
+ if (value === null) return null;
1649
+ const { selection } = tr;
1650
+ if (!selection.empty || selection.$from.parentOffset !== 0) return null;
1651
+ return value;
1652
+ }
1653
+ },
1654
+ props: {
1655
+ handleKeyDown(view, event) {
1656
+ if (event.key !== "Backspace") return false;
1657
+ const { selection, doc } = view.state;
1658
+ const pendingPos = imageBackspaceKey.getState(view.state);
1659
+ if (pendingPos != null) {
1660
+ const node = doc.nodeAt(pendingPos);
1661
+ if (node?.type.name === "imageNode") {
1662
+ view.dispatch(
1663
+ view.state.tr.delete(pendingPos, pendingPos + node.nodeSize).setMeta(imageBackspaceKey, null)
1664
+ );
1665
+ return true;
1666
+ }
1667
+ }
1668
+ if (selection.empty && selection.$from.parentOffset === 0) {
1669
+ const $from = selection.$from;
1670
+ const posBeforeBlock = $from.before($from.depth);
1671
+ const nodeBefore = doc.resolve(posBeforeBlock).nodeBefore;
1672
+ if (nodeBefore?.type.name === "imageNode") {
1673
+ const imageStart = posBeforeBlock - nodeBefore.nodeSize;
1674
+ view.dispatch(view.state.tr.setMeta(imageBackspaceKey, imageStart));
1675
+ return true;
1676
+ }
1677
+ }
1678
+ return false;
1679
+ },
1680
+ decorations(state) {
1681
+ const pendingPos = imageBackspaceKey.getState(state);
1682
+ if (pendingPos == null) return null;
1683
+ const node = state.doc.nodeAt(pendingPos);
1684
+ if (!node) return null;
1685
+ return DecorationSet.create(state.doc, [
1686
+ Decoration.node(pendingPos, pendingPos + node.nodeSize, {
1687
+ class: "image-node-pending-delete"
1688
+ })
1689
+ ]);
1690
+ }
1691
+ }
1692
+ });
1693
+ return [captionFocusPlugin, backspacePlugin];
1694
+ }
1695
+ });
1696
+
1697
+ // src/editor/extensions/url-mention.ts
1698
+ import { Node as Node3, mergeAttributes as mergeAttributes2 } from "@tiptap/core";
1699
+ function safeUrl(value) {
1700
+ if (typeof value !== "string") return "";
1701
+ try {
1702
+ const parsed = new URL(value);
1703
+ return parsed.protocol === "http:" || parsed.protocol === "https:" ? value : "";
1704
+ } catch {
1705
+ return "";
1706
+ }
1707
+ }
1708
+ var LINK_ICON_PATH = "M12.586 4.586a2 2 0 112.828 2.828l-3 3a2 2 0 01-2.828 0 1 1 0 00-1.414 1.414 4 4 0 005.656 0l-3-3a4 4 0 00-5.656-5.656l-1.5 1.5a1 1 0 101.414 1.414l1.5-1.5zm-5 5a2 2 0 012.828 0 1 1 0 101.414-1.414 4 4 0 00-5.656 0l-3 3a4 4 0 105.656 5.656l1.5-1.5a1 1 0 10-1.414-1.414l-1.5 1.5a2 2 0 11-2.828-2.828l3-3z";
1709
+ var createUrlMention = (nodeView) => Node3.create({
1710
+ name: "urlMention",
1711
+ group: "inline",
1712
+ inline: true,
1713
+ atom: true,
1714
+ addAttributes() {
1715
+ return {
1716
+ url: { default: null },
1717
+ title: { default: null },
1718
+ favicon: { default: null }
1719
+ };
1720
+ },
1721
+ parseHTML() {
1722
+ return [
1723
+ {
1724
+ tag: 'span[data-type="url-mention"]'
1725
+ }
1726
+ ];
1727
+ },
1728
+ renderHTML({ HTMLAttributes }) {
1729
+ const { url, title, favicon } = HTMLAttributes;
1730
+ const displayTitle = title || url || "";
1731
+ return [
1732
+ "a",
1733
+ mergeAttributes2(HTMLAttributes, {
1734
+ "data-type": "url-mention",
1735
+ href: safeUrl(url),
1736
+ target: "_blank",
1737
+ rel: "noopener noreferrer",
1738
+ class: "url-mention-pill",
1739
+ style: "text-decoration: none !important; color: inherit;"
1740
+ }),
1741
+ favicon ? [
1742
+ "img",
1743
+ {
1744
+ src: favicon,
1745
+ alt: "",
1746
+ class: "inline-block w-3.5 h-3.5 flex-shrink-0",
1747
+ onerror: "this.style.display='none'"
1748
+ }
1749
+ ] : [
1750
+ "svg",
1751
+ { class: "inline-block w-3.5 h-3.5 flex-shrink-0", fill: "currentColor", viewBox: "0 0 20 20" },
1752
+ ["path", { d: LINK_ICON_PATH }]
1753
+ ],
1754
+ ["span", {}, displayTitle]
1755
+ ];
1756
+ },
1757
+ addNodeView() {
1758
+ return nodeView();
1759
+ },
1760
+ addCommands() {
1761
+ return {
1762
+ insertUrlMention: (attributes) => ({ commands }) => {
1763
+ return commands.insertContent({
1764
+ type: this.name,
1765
+ attrs: attributes
1766
+ });
1767
+ }
1768
+ };
1769
+ }
1770
+ });
1771
+
1772
+ // src/editor/extensions/link-preview.ts
1773
+ import { Node as Node4, mergeAttributes as mergeAttributes3 } from "@tiptap/core";
1774
+ function safeUrl2(value) {
1775
+ if (typeof value !== "string") return "";
1776
+ try {
1777
+ const parsed = new URL(value);
1778
+ return parsed.protocol === "http:" || parsed.protocol === "https:" ? value : "";
1779
+ } catch {
1780
+ return "";
1781
+ }
1782
+ }
1783
+ function safeEmbedUrl(value) {
1784
+ const url = safeUrl2(value);
1785
+ if (!url) return "";
1786
+ try {
1787
+ const parsed = new URL(url);
1788
+ const host = parsed.hostname.replace(/^www\./, "");
1789
+ let videoId;
1790
+ if (host === "youtu.be") {
1791
+ videoId = /^\/([^/]+)/.exec(parsed.pathname)?.[1];
1792
+ } else if (host === "youtube.com" || host === "m.youtube.com" || host === "youtube-nocookie.com") {
1793
+ videoId = parsed.searchParams.get("v") ?? /^\/embed\/([^/]+)/.exec(parsed.pathname)?.[1];
1794
+ }
1795
+ return videoId ? `https://www.youtube-nocookie.com/embed/${encodeURIComponent(videoId)}` : url;
1796
+ } catch {
1797
+ return "";
1798
+ }
1799
+ }
1800
+ var LINK_ICON_PATH2 = "M12.586 4.586a2 2 0 112.828 2.828l-3 3a2 2 0 01-2.828 0 1 1 0 00-1.414 1.414 4 4 0 005.656 0l-3-3a4 4 0 00-5.656-5.656l-1.5 1.5a1 1 0 101.414 1.414l1.5-1.5zm-5 5a2 2 0 012.828 0 1 1 0 101.414-1.414 4 4 0 00-5.656 0l-3 3a4 4 0 105.656 5.656l1.5-1.5a1 1 0 10-1.414-1.414l-1.5 1.5a2 2 0 11-2.828-2.828l3-3z";
1801
+ var createLinkPreview = (nodeView) => Node4.create({
1802
+ name: "linkPreview",
1803
+ group: "block",
1804
+ atom: true,
1805
+ addAttributes() {
1806
+ return {
1807
+ url: { default: null },
1808
+ title: { default: null },
1809
+ description: { default: null },
1810
+ image: { default: null },
1811
+ favicon: { default: null },
1812
+ provider: { default: null },
1813
+ type: { default: "bookmark" }
1814
+ // bookmark | embed
1815
+ };
1816
+ },
1817
+ parseHTML() {
1818
+ return [
1819
+ {
1820
+ tag: 'div[data-type="link-preview"]'
1821
+ }
1822
+ ];
1823
+ },
1824
+ renderHTML({ HTMLAttributes }) {
1825
+ const { url, title, description, image, favicon, type } = HTMLAttributes;
1826
+ if (type === "embed") {
1827
+ return [
1828
+ "div",
1829
+ mergeAttributes3(HTMLAttributes, { "data-type": "link-preview" }),
1830
+ [
1831
+ "div",
1832
+ { class: "relative pb-[56.25%] h-0 overflow-hidden rounded-lg" },
1833
+ [
1834
+ "iframe",
1835
+ {
1836
+ src: safeEmbedUrl(url),
1837
+ title: title || "",
1838
+ frameborder: "0",
1839
+ allowfullscreen: "",
1840
+ class: "absolute top-0 left-0 w-full h-full"
1841
+ }
1842
+ ]
1843
+ ]
1844
+ ];
1845
+ }
1846
+ const hostname = url ? (() => {
1847
+ try {
1848
+ return new URL(url).hostname;
1849
+ } catch {
1850
+ return url;
1851
+ }
1852
+ })() : "";
1853
+ const faviconNode = favicon ? [
1854
+ "img",
1855
+ {
1856
+ src: favicon,
1857
+ alt: "",
1858
+ class: "w-3.5 h-3.5 flex-shrink-0",
1859
+ onerror: "this.style.display='none'"
1860
+ }
1861
+ ] : [
1862
+ "svg",
1863
+ { class: "w-3 h-3 flex-shrink-0", fill: "currentColor", viewBox: "0 0 20 20" },
1864
+ ["path", { d: LINK_ICON_PATH2 }]
1865
+ ];
1866
+ const textBlock = [["div", { class: "text-base font-semibold mb-1 line-clamp-1" }, title || ""]];
1867
+ if (description) {
1868
+ textBlock.push(["p", { class: "text-xs text-muted-foreground mb-2 line-clamp-2 leading-snug" }, description]);
1869
+ }
1870
+ const cardChildren = [
1871
+ [
1872
+ "div",
1873
+ { class: "flex-1 min-w-0 flex flex-col justify-between px-3 py-1.5" },
1874
+ ["div", {}, ...textBlock],
1875
+ [
1876
+ "div",
1877
+ { class: "flex items-center gap-1.5 text-xs text-muted-foreground mt-auto" },
1878
+ faviconNode,
1879
+ ["span", { class: "truncate opacity-80" }, hostname]
1880
+ ]
1881
+ ]
1882
+ ];
1883
+ if (image) {
1884
+ cardChildren.push([
1885
+ "div",
1886
+ { class: "flex-shrink-0 w-44 aspect-video bg-muted" },
1887
+ [
1888
+ "img",
1889
+ {
1890
+ src: image,
1891
+ alt: title || "",
1892
+ class: "w-full h-full object-cover",
1893
+ onerror: "this.parentElement.style.display='none'"
1894
+ }
1895
+ ]
1896
+ ]);
1897
+ }
1898
+ return [
1899
+ "div",
1900
+ mergeAttributes3(HTMLAttributes, {
1901
+ "data-type": "link-preview",
1902
+ class: "link-preview my-4"
1903
+ }),
1904
+ [
1905
+ "a",
1906
+ {
1907
+ href: safeUrl2(url),
1908
+ target: "_blank",
1909
+ rel: "noopener noreferrer",
1910
+ class: "flex transition-colors overflow-hidden bookmark-link",
1911
+ style: "text-decoration: none !important; color: inherit;"
1912
+ },
1913
+ ...cardChildren
1914
+ ]
1915
+ ];
1916
+ },
1917
+ addNodeView() {
1918
+ return nodeView();
1919
+ },
1920
+ addCommands() {
1921
+ return {
1922
+ insertLinkPreview: (attributes) => ({ commands }) => {
1923
+ return commands.insertContent({
1924
+ type: this.name,
1925
+ attrs: attributes
1926
+ });
1927
+ }
1928
+ };
1929
+ }
1930
+ });
1931
+
1932
+ // src/editor/extensions/internal-mention.ts
1933
+ import { Mention } from "@tiptap/extension-mention";
1934
+ var createInternalMention = ({ mentionSource, hrefBuilder, render }) => Mention.extend({
1935
+ name: "internalMention",
1936
+ parseHTML() {
1937
+ return [
1938
+ {
1939
+ tag: 'span[data-type="internal-mention"]'
1940
+ }
1941
+ ];
1942
+ },
1943
+ renderHTML({ node, HTMLAttributes }) {
1944
+ const { id, label, type, seriesId } = node.attrs;
1945
+ const href = hrefBuilder ? hrefBuilder({ id, label, type, seriesId }) : type === "post" && seriesId ? `/read/${seriesId}?post=${id}` : `/read/${id}`;
1946
+ return [
1947
+ "a",
1948
+ {
1949
+ ...HTMLAttributes,
1950
+ class: "internal-mention",
1951
+ "data-type": "internal-mention",
1952
+ "data-id": id,
1953
+ "data-label": label,
1954
+ "data-mention-type": type,
1955
+ "data-series-id": seriesId,
1956
+ href,
1957
+ target: "_blank",
1958
+ rel: "noopener noreferrer"
1959
+ },
1960
+ label
1961
+ ];
1962
+ },
1963
+ addAttributes() {
1964
+ return {
1965
+ id: {
1966
+ default: null,
1967
+ parseHTML: (element) => element.getAttribute("data-id"),
1968
+ renderHTML: (attributes) => ({
1969
+ "data-id": attributes.id
1970
+ })
1971
+ },
1972
+ label: {
1973
+ default: null,
1974
+ parseHTML: (element) => element.getAttribute("data-label"),
1975
+ renderHTML: (attributes) => ({
1976
+ "data-label": attributes.label
1977
+ })
1978
+ },
1979
+ type: {
1980
+ default: "post",
1981
+ parseHTML: (element) => element.getAttribute("data-type"),
1982
+ renderHTML: (attributes) => ({
1983
+ "data-type": attributes.type
1984
+ })
1985
+ },
1986
+ seriesId: {
1987
+ default: null,
1988
+ parseHTML: (element) => element.getAttribute("data-series-id"),
1989
+ renderHTML: (attributes) => ({
1990
+ "data-series-id": attributes.seriesId
1991
+ })
1992
+ }
1993
+ };
1994
+ }
1995
+ }).configure({
1996
+ HTMLAttributes: {
1997
+ class: "internal-mention"
1998
+ },
1999
+ suggestion: {
2000
+ char: "@",
2001
+ allowSpaces: true,
2002
+ command: ({ editor, range, props }) => {
2003
+ editor.chain().focus().insertContentAt(range, [
2004
+ {
2005
+ type: "internalMention",
2006
+ attrs: props
2007
+ }
2008
+ ]).run();
2009
+ },
2010
+ items: async ({ query }) => {
2011
+ if (!mentionSource) return [];
2012
+ try {
2013
+ return await mentionSource(query);
2014
+ } catch {
2015
+ return [];
2016
+ }
2017
+ },
2018
+ render
2019
+ }
2020
+ });
2021
+
2022
+ // src/editor/extensions/notice-node.ts
2023
+ import { Node as Node5, mergeAttributes as mergeAttributes4 } from "@tiptap/core";
2024
+ import { Plugin as Plugin3 } from "@tiptap/pm/state";
2025
+ var createNoticeNode = (nodeView) => Node5.create({
2026
+ name: "notice",
2027
+ group: "block",
2028
+ content: "block+",
2029
+ defining: true,
2030
+ addAttributes() {
2031
+ return {
2032
+ variant: { default: "info" },
2033
+ title: {
2034
+ default: "Note",
2035
+ parseHTML: (element) => element.querySelector("[data-notice-title]")?.textContent ?? "Note"
2036
+ }
2037
+ };
2038
+ },
2039
+ parseHTML() {
2040
+ return [{ tag: 'aside[data-type="notice"]', contentElement: "[data-notice-body]" }];
2041
+ },
2042
+ renderHTML({ HTMLAttributes }) {
2043
+ const { title = "Note", variant: rawVariant = "info", ...attributes } = HTMLAttributes;
2044
+ const variant = rawVariant;
2045
+ return [
2046
+ "aside",
2047
+ mergeAttributes4(attributes, {
2048
+ "data-type": "notice",
2049
+ "data-variant": variant,
2050
+ class: "editor-notice my-4 rounded-lg border border-border bg-muted/40 p-4"
2051
+ }),
2052
+ ["div", { "data-notice-title": "", class: "font-semibold tracking-tight" }, String(title)],
2053
+ ["div", { "data-notice-body": "" }, 0]
2054
+ ];
2055
+ },
2056
+ addNodeView() {
2057
+ return nodeView ? nodeView() : null;
2058
+ },
2059
+ addProseMirrorPlugins() {
2060
+ return [
2061
+ new Plugin3({
2062
+ props: {
2063
+ handleKeyDown: (view, event) => {
2064
+ if (event.key !== "ArrowUp") return false;
2065
+ const { selection } = view.state;
2066
+ const { $from } = selection;
2067
+ if (!selection.empty) return false;
2068
+ let noticeDepth = -1;
2069
+ for (let depth = $from.depth; depth > 0; depth -= 1) {
2070
+ if ($from.node(depth).type.name === this.name) {
2071
+ noticeDepth = depth;
2072
+ break;
2073
+ }
2074
+ }
2075
+ if (noticeDepth < 0 || $from.index(noticeDepth) !== 0) return false;
2076
+ const cursorCoords = view.coordsAtPos(selection.from);
2077
+ const firstLineCoords = view.coordsAtPos($from.start());
2078
+ if (cursorCoords.top > firstLineCoords.top + 2) return false;
2079
+ const dom = view.nodeDOM($from.before(noticeDepth));
2080
+ if (!(dom instanceof HTMLElement)) return false;
2081
+ const titleInput = dom.querySelector('input[aria-label="Notice title"]');
2082
+ if (!titleInput) return false;
2083
+ titleInput.focus();
2084
+ return true;
2085
+ }
2086
+ }
2087
+ })
2088
+ ];
2089
+ },
2090
+ addCommands() {
2091
+ return {
2092
+ insertNotice: (attributes = {}) => ({ commands }) => commands.insertContent({
2093
+ type: this.name,
2094
+ attrs: attributes,
2095
+ content: [{ type: "paragraph", content: [] }]
2096
+ })
2097
+ };
2098
+ }
2099
+ });
2100
+
2101
+ // src/editor/extensions/current-empty-block.ts
2102
+ import { Extension as Extension4 } from "@tiptap/core";
2103
+ import { Plugin as Plugin4, PluginKey as PluginKey4 } from "@tiptap/pm/state";
2104
+ import { Decoration as Decoration2, DecorationSet as DecorationSet2 } from "@tiptap/pm/view";
2105
+ var currentEmptyBlockKey = new PluginKey4("currentEmptyBlock");
2106
+ var CurrentEmptyBlock = Extension4.create({
2107
+ name: "currentEmptyBlock",
2108
+ addProseMirrorPlugins() {
2109
+ return [
2110
+ new Plugin4({
2111
+ key: currentEmptyBlockKey,
2112
+ props: {
2113
+ decorations(state) {
2114
+ const { selection } = state;
2115
+ const { $from } = selection;
2116
+ if (!selection.empty || $from.depth === 0 || $from.parent.content.size > 0) return null;
2117
+ return DecorationSet2.create(state.doc, [
2118
+ Decoration2.node($from.before($from.depth), $from.after($from.depth), {
2119
+ class: "is-current-empty"
2120
+ })
2121
+ ]);
2122
+ }
2123
+ }
2124
+ })
2125
+ ];
2126
+ }
2127
+ });
2128
+
2129
+ // src/editor/build-extensions.ts
2130
+ function buildExtensions(options) {
2131
+ const { nodeViews, mentionSource, hrefBuilder, mentionRender, slashRender, headingWithId } = options;
2132
+ const enforceTitle = options.enforceTitle ?? true;
2133
+ const lowlight = createLowlight(common);
2134
+ return [
2135
+ StarterKit.configure({
2136
+ codeBlock: false,
2137
+ // we use CodeBlockCustom
2138
+ link: false,
2139
+ // we configure Link explicitly below
2140
+ underline: false,
2141
+ // we configure Underline explicitly below
2142
+ heading: false
2143
+ // Reader and editor install their own heading variants below.
2144
+ }),
2145
+ ...headingWithId ? [HeadingWithId.configure({ levels: [1, 2, 3, 4, 5, 6] })] : [EditorHeading.configure({ levels: [1, 2, 3, 4, 5, 6] })],
2146
+ ...enforceTitle ? [TitleHeading, ExitHeading] : [],
2147
+ Placeholder.configure({
2148
+ showOnlyCurrent: false,
2149
+ placeholder: ({ node }) => node.type.name === "codeBlock" ? "" : options.placeholder ? options.placeholder(node.type.name, node.attrs.level) : node.type.name === "heading" && node.attrs.level === 1 ? "Untitled" : "Type '/' for commands"
2150
+ }),
2151
+ CurrentEmptyBlock,
2152
+ Highlight.configure({ multicolor: true }),
2153
+ Link.configure({
2154
+ openOnClick: false,
2155
+ HTMLAttributes: {
2156
+ class: "text-primary underline",
2157
+ target: "_blank",
2158
+ rel: "noopener noreferrer"
2159
+ }
2160
+ }),
2161
+ Typography,
2162
+ Underline,
2163
+ TextStyle,
2164
+ Color,
2165
+ TextAlign.configure({
2166
+ types: ["heading", "paragraph"],
2167
+ alignments: ["left", "center", "right", "justify"],
2168
+ defaultAlignment: "left"
2169
+ }),
2170
+ createCodeBlockCustom(lowlight, nodeViews.codeBlock),
2171
+ CharacterCount.configure({ mode: "textSize" }),
2172
+ TaskList,
2173
+ TaskItem.configure({ nested: true }),
2174
+ createNoticeNode(nodeViews.notice),
2175
+ createInternalMention({
2176
+ mentionSource,
2177
+ hrefBuilder,
2178
+ // Without a framework-supplied render the suggestion is inert, so fall back to a no-op
2179
+ // rather than throwing when a consumer builds extensions headlessly (e.g. unit tests).
2180
+ render: mentionRender ?? (() => ({}))
2181
+ }),
2182
+ createLinkPreview(nodeViews.linkPreview),
2183
+ createImageNode(nodeViews.image),
2184
+ createUrlMention(nodeViews.urlMention),
2185
+ slashCommands.configure({ suggestion: { render: slashRender ?? (() => ({})) } })
2186
+ ];
2187
+ }
2188
+
2189
+ // src/editor/paste-url.ts
2190
+ function insertPastedUrlAsLink(view, event) {
2191
+ const value = event.clipboardData?.getData("text/plain").trim() ?? "";
2192
+ if (!value || /\s/.test(value)) return false;
2193
+ try {
2194
+ const protocol = new URL(value).protocol;
2195
+ if (protocol !== "http:" && protocol !== "https:") return false;
2196
+ } catch {
2197
+ return false;
2198
+ }
2199
+ const link = view.state.schema.marks.link;
2200
+ if (!link) return false;
2201
+ event.preventDefault();
2202
+ const text = view.state.schema.text(value, [link.create({ href: value })]);
2203
+ view.dispatch(view.state.tr.replaceSelectionWith(text, false).scrollIntoView());
2204
+ return true;
2205
+ }
2206
+
2207
+ // src/editor/overlay-position.ts
2208
+ function placeEditorOverlay(rect, { width, height, gap = 8, viewportGap = 16 }) {
2209
+ const spaceBelow = window.innerHeight - rect.bottom;
2210
+ const spaceAbove = rect.top;
2211
+ const preferredTop = spaceBelow < height && spaceAbove > spaceBelow ? rect.top - height - gap : rect.bottom + gap;
2212
+ const maxLeft = Math.max(window.innerWidth - width - viewportGap, viewportGap);
2213
+ const maxTop = Math.max(window.innerHeight - height - viewportGap, viewportGap);
2214
+ return {
2215
+ left: Math.min(Math.max(rect.left, viewportGap), maxLeft),
2216
+ top: Math.min(Math.max(preferredTop, viewportGap), maxTop)
2217
+ };
2218
+ }
2219
+ function placeEditorOverlayAt(editor, position, options) {
2220
+ return placeEditorOverlay(editor.view.coordsAtPos(position), options);
2221
+ }
2222
+ function findEditorScrollContainer(element) {
2223
+ let current = element.parentElement;
2224
+ while (current && current !== document.body) {
2225
+ const overflowY = window.getComputedStyle(current).overflowY;
2226
+ if (/(auto|scroll)/.test(overflowY) && current.scrollHeight > current.clientHeight) return current;
2227
+ current = current.parentElement;
2228
+ }
2229
+ return null;
2230
+ }
2231
+ function lockEditorOverlayScroll(editorElement, overlayElement) {
2232
+ const container = findEditorScrollContainer(editorElement);
2233
+ if (!container) return () => void 0;
2234
+ const preventWheel = (event) => {
2235
+ const target = event.target;
2236
+ if (target instanceof Node && overlayElement?.contains(target)) return;
2237
+ event.preventDefault();
2238
+ };
2239
+ container.addEventListener("wheel", preventWheel, { passive: false });
2240
+ return () => container.removeEventListener("wheel", preventWheel);
2241
+ }
2242
+ export {
2243
+ EditorHeading,
2244
+ ExitHeading,
2245
+ HeadingWithId,
2246
+ SIDEBAR_KEYBOARD_SHORTCUT,
2247
+ SIDEBAR_WIDTH,
2248
+ SIDEBAR_WIDTH_ICON,
2249
+ SIDEBAR_WIDTH_MOBILE,
2250
+ THEMES,
2251
+ THEME_NAMES,
2252
+ TitleHeading,
2253
+ badgeVariants,
2254
+ buildChartDefinition,
2255
+ buildExtensions,
2256
+ buttonVariants,
2257
+ cardBodyBase,
2258
+ cardCoverVariants,
2259
+ cardDescriptionBase,
2260
+ cardFooterBase,
2261
+ cardHeaderBase,
2262
+ cardTitleBase,
2263
+ cardVariants,
2264
+ centerBase,
2265
+ chartPlaceholderBase,
2266
+ chartPlaceholderLabelBase,
2267
+ chartRootBase,
2268
+ checkboxGroupBase,
2269
+ checkboxIndicatorBase,
2270
+ checkboxLabelBase,
2271
+ checkboxVariants,
2272
+ clipboardTriggerBase,
2273
+ cn,
2274
+ codeBlockBodyBase,
2275
+ codeBlockBodyScrollableBase,
2276
+ codeBlockContentBase,
2277
+ codeBlockCopyFloatBase,
2278
+ codeBlockHeaderBase,
2279
+ codeBlockHeaderInfoBase,
2280
+ codeBlockHighlightBase,
2281
+ codeBlockLineNumbersBase,
2282
+ codeBlockLoadingBase,
2283
+ codeBlockRootBase,
2284
+ codeBlockSpinnerBase,
2285
+ codeBlockTitleBase,
2286
+ colBase,
2287
+ comboboxClearTriggerBase,
2288
+ comboboxContentBase,
2289
+ comboboxControlBase,
2290
+ comboboxEmptyBase,
2291
+ comboboxInputBase,
2292
+ comboboxItemGroupLabelBase,
2293
+ comboboxItemIndicatorBase,
2294
+ comboboxItemVariants,
2295
+ comboboxListBase,
2296
+ comboboxPositionerBase,
2297
+ comboboxTriggerBase,
2298
+ containerBase,
2299
+ createCodeBlockCustom,
2300
+ createImageNode,
2301
+ createInternalMention,
2302
+ createLinkPreview,
2303
+ createNoticeNode,
2304
+ createUrlMention,
2305
+ defaultChartColor,
2306
+ defaultListboxFilter,
2307
+ dialogBackdropBase,
2308
+ dialogCloseTriggerBase,
2309
+ dialogContentBase,
2310
+ dialogDescriptionBase,
2311
+ dialogFooterBase,
2312
+ dialogFooterStickyBase,
2313
+ dialogFullscreenContentBase,
2314
+ dialogHeaderBase,
2315
+ dialogHeaderStickyBase,
2316
+ dialogPositionerBase,
2317
+ dialogTitleBase,
2318
+ extractYouTubeId,
2319
+ feedbackCorrectBase,
2320
+ feedbackExplanationBase,
2321
+ feedbackIncorrectBase,
2322
+ fetchYouTubeMetadata,
2323
+ fieldErrorBase,
2324
+ fieldHelperBase,
2325
+ fieldLabelBase,
2326
+ fieldRequiredIndicatorBase,
2327
+ fieldRootBase,
2328
+ fieldsetErrorBase,
2329
+ fieldsetHelperBase,
2330
+ fieldsetLegendBase,
2331
+ fieldsetRootBase,
2332
+ figureCaptionBase,
2333
+ figureImageBase,
2334
+ figureRootBase,
2335
+ findEditorScrollContainer,
2336
+ formatTime,
2337
+ hstackBase,
2338
+ injectCodeBlockStyles,
2339
+ inputVariants,
2340
+ insertPastedUrlAsLink,
2341
+ itemVariants,
2342
+ latexDisplayBase,
2343
+ latexErrorBase,
2344
+ latexInlineBase,
2345
+ latexRootBase,
2346
+ listboxContentBase,
2347
+ listboxEmptyBase,
2348
+ listboxInputBase,
2349
+ listboxItemBase,
2350
+ listboxItemIndicatorBase,
2351
+ listboxItemTextBase,
2352
+ listboxLabelBase,
2353
+ listboxRootBase,
2354
+ lockEditorOverlayScroll,
2355
+ manimCaptionBase,
2356
+ manimContainerBase,
2357
+ manimErrorBase,
2358
+ manimPlaceholderBase,
2359
+ manimPlaceholderLabelBase,
2360
+ manimRootBase,
2361
+ mermaidLoadingBase,
2362
+ mermaidRootBase,
2363
+ mermaidSourceBase,
2364
+ mermaidSvgAspectRatio,
2365
+ mermaidSvgBase,
2366
+ nativeSelectIconBase,
2367
+ nativeSelectVariants,
2368
+ nativeSelectWrapperBase,
2369
+ navbarActionsBase,
2370
+ navbarActivationAreaBase,
2371
+ navbarBrandBase,
2372
+ navbarContainerBase,
2373
+ navbarDensityVariants,
2374
+ navbarMenuBase,
2375
+ navbarMenuContentBase,
2376
+ navbarMenuIndicatorBase,
2377
+ navbarMenuItemBase,
2378
+ navbarMenuLinkBase,
2379
+ navbarMenuListBase,
2380
+ navbarMenuPlacementVariants,
2381
+ navbarMenuRootBase,
2382
+ navbarMenuTriggerStyle,
2383
+ navbarMenuViewportBase,
2384
+ navbarMenuViewportPositionerBase,
2385
+ navbarMobileActionsBase,
2386
+ navbarMobileBase,
2387
+ navbarMobileContentBase,
2388
+ navbarMobileHeaderBase,
2389
+ navbarMobileMenuBase,
2390
+ navbarMobileMenuContentBase,
2391
+ navbarMobileMenuTriggerBase,
2392
+ navbarShrunkBase,
2393
+ navbarTriggerVariants,
2394
+ navbarVariants,
2395
+ noticeDescriptionBase,
2396
+ noticeTitleBase,
2397
+ noticeVariants,
2398
+ numberInputControlBase,
2399
+ numberInputInputBase,
2400
+ numberInputRootBase,
2401
+ numberInputTriggerBase,
2402
+ pageContentBase,
2403
+ pageFooterBase,
2404
+ pageGutterAreaBase,
2405
+ pageGutterContentVariants,
2406
+ pageGutterVariants,
2407
+ pageSectionBase,
2408
+ pageVariants,
2409
+ paginationEllipsisBase,
2410
+ paginationItemBase,
2411
+ paginationRootBase,
2412
+ paginationTriggerBase,
2413
+ parseYouTubeChapters,
2414
+ placeEditorOverlay,
2415
+ placeEditorOverlayAt,
2416
+ popoverArrowBase,
2417
+ popoverCloseTriggerBase,
2418
+ popoverContentBase,
2419
+ popoverDescriptionBase,
2420
+ popoverIndicatorBase,
2421
+ popoverPositionerBase,
2422
+ popoverTitleBase,
2423
+ prevNextDirectionBase,
2424
+ prevNextLinkBase,
2425
+ prevNextLinkNextBase,
2426
+ prevNextRootBase,
2427
+ prevNextSpacerBase,
2428
+ prevNextTitleBase,
2429
+ proseVariants,
2430
+ questionCardBase,
2431
+ questionCheckButtonBase,
2432
+ questionGroupBase,
2433
+ questionInputBase,
2434
+ questionOptionBase,
2435
+ questionOptionCorrectBase,
2436
+ questionOptionIncorrectBase,
2437
+ questionPromptBase,
2438
+ questionUnitBase,
2439
+ quizHeaderBase,
2440
+ quizResetButtonBase,
2441
+ quizResultBase,
2442
+ quizResultTextBase,
2443
+ quizResultTitleBase,
2444
+ quizRootBase,
2445
+ quizScoreBase,
2446
+ quizSubmitButtonBase,
2447
+ quizTitleBase,
2448
+ radioGroupItemControlBase,
2449
+ radioGroupItemTextBase,
2450
+ radioGroupRootBase,
2451
+ registerImageInsertCallback,
2452
+ registerYouTubeInsertCallback,
2453
+ renderChartSvgString,
2454
+ renderCodeToHtml,
2455
+ renderMermaidSource,
2456
+ resolveMermaidThemeVariables,
2457
+ revealChevronBase,
2458
+ revealContentBase,
2459
+ revealRootBase,
2460
+ revealTriggerBase,
2461
+ rowBase,
2462
+ scrollContentBase,
2463
+ scrollCornerBase,
2464
+ scrollRootBase,
2465
+ scrollScrollbarBase,
2466
+ scrollThumbBase,
2467
+ scrollViewportBase,
2468
+ selectClearTriggerBase,
2469
+ selectContentBase,
2470
+ selectIndicatorBase,
2471
+ selectItemBase,
2472
+ selectItemGroupLabelBase,
2473
+ selectItemIndicatorBase,
2474
+ selectItemTextBase,
2475
+ selectPositionerBase,
2476
+ selectTriggerBase,
2477
+ selectValueBase,
2478
+ sidebarMenuButtonVariants,
2479
+ sidebarStyles,
2480
+ slashCommands,
2481
+ splitterPanelBase,
2482
+ splitterResizeTriggerBase,
2483
+ splitterResizeTriggerIndicatorBase,
2484
+ splitterResizeTriggerSeparatorBase,
2485
+ splitterRootBase,
2486
+ stackBase,
2487
+ switchControlBase,
2488
+ switchLabelBase,
2489
+ switchThumbBase,
2490
+ switchVariants,
2491
+ tabsContentBase,
2492
+ tabsIndicatorBase,
2493
+ tabsIndicatorVariants,
2494
+ tabsListBase,
2495
+ tabsListVariants,
2496
+ tabsRootBase,
2497
+ tabsTriggerBase,
2498
+ tagsInputClearTriggerBase,
2499
+ tagsInputControlBase,
2500
+ tagsInputInputBase,
2501
+ tagsInputItemBase,
2502
+ tagsInputItemDeleteTriggerBase,
2503
+ tagsInputItemInputBase,
2504
+ tagsInputItemTextBase,
2505
+ tagsInputRootBase,
2506
+ textareaBase,
2507
+ toLaTeX,
2508
+ toggleButtonVariants,
2509
+ toggleGroupRootVariants,
2510
+ tooltipArrowBase,
2511
+ tooltipContentBase,
2512
+ tooltipPositionerBase,
2513
+ unregisterImageInsertCallback,
2514
+ unregisterYouTubeInsertCallback,
2515
+ vstackBase,
2516
+ windowBodyBase,
2517
+ windowCloseTriggerBase,
2518
+ windowContentBase,
2519
+ windowControlBase,
2520
+ windowDragTriggerBase,
2521
+ windowHeaderBase,
2522
+ windowPositionerBase,
2523
+ windowResizeTriggerBase,
2524
+ windowStageTriggerBase,
2525
+ windowTitleBase,
2526
+ youtubeChapterButtonBase,
2527
+ youtubeChapterLabelBase,
2528
+ youtubeChapterTimeBase,
2529
+ youtubeChaptersBase,
2530
+ youtubeChaptersChevronBase,
2531
+ youtubeChaptersListBase,
2532
+ youtubeChaptersSummaryBase,
2533
+ youtubeDescriptionBase,
2534
+ youtubeFacadeBase,
2535
+ youtubePlayButtonBase,
2536
+ youtubePlayButtonInnerBase,
2537
+ youtubeRootBase,
2538
+ youtubeTitleBase
2539
+ };