xertica-ui 2.7.0 → 2.8.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 (228) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +19 -11
  3. package/bin/generate-tokens.ts +25 -9
  4. package/components/assistant/xertica-assistant/xertica-assistant.tsx +1 -1
  5. package/components/ui/button/button.test.tsx +2 -2
  6. package/components/ui/button/button.tsx +6 -6
  7. package/components/ui/card/card.tsx +14 -2
  8. package/components/ui/input/input.tsx +1 -1
  9. package/components/ui/input-otp/input-otp.tsx +1 -1
  10. package/components/ui/search/search.tsx +1 -1
  11. package/components/ui/select/select.tsx +2 -2
  12. package/components/ui/switch/switch.tsx +1 -1
  13. package/components/ui/textarea/textarea.tsx +1 -1
  14. package/contexts/BrandColorsContext.tsx +50 -2
  15. package/contexts/theme-data.ts +100 -3
  16. package/dist/AssistantChart-BFBJXVcm.js +3383 -0
  17. package/dist/AssistantChart-BTnE94FR.cjs +3551 -0
  18. package/dist/AssistantChart-BvccsQMx.cjs +3551 -0
  19. package/dist/AssistantChart-CkskcBVD.js +3383 -0
  20. package/dist/AssistantChart-CrPkO9ip.js +3383 -0
  21. package/dist/AssistantChart-DKz2O1R8.cjs +3551 -0
  22. package/dist/AssistantChart-DYL6UEvo.cjs +3551 -0
  23. package/dist/AssistantChart-keo-ogKi.js +3383 -0
  24. package/dist/AudioPlayer-AoU5MTiM.cjs +1282 -0
  25. package/dist/AudioPlayer-Bx1vrblm.js +1278 -0
  26. package/dist/AudioPlayer-D0-I6J3J.cjs +1282 -0
  27. package/dist/AudioPlayer-DIWX_Yg7.cjs +1282 -0
  28. package/dist/AudioPlayer-DrWJnS7c.js +1278 -0
  29. package/dist/AudioPlayer-_P-Z7pAK.js +1278 -0
  30. package/dist/BrandColorsContext-B25Bpr3b.cjs +819 -0
  31. package/dist/BrandColorsContext-BCieATdW.js +812 -0
  32. package/dist/BrandColorsContext-DP0DXAXS.js +824 -0
  33. package/dist/BrandColorsContext-DjpC9wR_.cjs +798 -0
  34. package/dist/BrandColorsContext-MpXFhte7.cjs +831 -0
  35. package/dist/BrandColorsContext-V3tOc-Zw.js +791 -0
  36. package/dist/CodeBlock-CK4rO6lM.js +221 -0
  37. package/dist/CodeBlock-CKXamfVd.cjs +223 -0
  38. package/dist/CodeBlock-CVmE7isS.cjs +223 -0
  39. package/dist/CodeBlock-D7i5-cMv.js +221 -0
  40. package/dist/CodeBlock-Dg56j2ut.cjs +223 -0
  41. package/dist/CodeBlock-Dt6nUQoo.js +221 -0
  42. package/dist/CustomTooltipContent-Bxynuq7T.js +33 -0
  43. package/dist/CustomTooltipContent-BzjOSA0P.cjs +54 -0
  44. package/dist/CustomTooltipContent-C-ZeCNsf.js +33 -0
  45. package/dist/CustomTooltipContent-CON_QrXm.cjs +54 -0
  46. package/dist/CustomTooltipContent-UR_n2QfW.js +33 -0
  47. package/dist/CustomTooltipContent-v1SXjoFn.cjs +54 -0
  48. package/dist/FeatureCard-4n_8a63v.cjs +497 -0
  49. package/dist/FeatureCard-BLiAWT3w.js +485 -0
  50. package/dist/FeatureCard-BXRW97Ef.cjs +497 -0
  51. package/dist/FeatureCard-CDgLlWE2.js +485 -0
  52. package/dist/FeatureCard-CgQ8lq-I.cjs +497 -0
  53. package/dist/FeatureCard-Cp8cVC6T.cjs +497 -0
  54. package/dist/FeatureCard-D0MwrTRP.js +485 -0
  55. package/dist/FeatureCard-uE5i0in_.js +485 -0
  56. package/dist/ImageWithFallback-BOh1FM3I.js +98 -0
  57. package/dist/ImageWithFallback-BQO7952C.js +98 -0
  58. package/dist/ImageWithFallback-BkMXHCvV.cjs +122 -0
  59. package/dist/ImageWithFallback-C72nwszA.cjs +122 -0
  60. package/dist/ImageWithFallback-CCUMDuEC.cjs +122 -0
  61. package/dist/ImageWithFallback-DQD5TTlY.js +98 -0
  62. package/dist/LanguageSelector-1XhM7R1i.cjs +48 -0
  63. package/dist/LanguageSelector-B3ZVNc55.js +46 -0
  64. package/dist/LanguageSelector-Cj6zl0CM.js +46 -0
  65. package/dist/LanguageSelector-DK1zD4VH.cjs +48 -0
  66. package/dist/LanguageSelector-DseCAa0p.cjs +48 -0
  67. package/dist/LanguageSelector-Du09anfM.js +46 -0
  68. package/dist/LanguageSelector-PZHlFfEs.cjs +48 -0
  69. package/dist/LanguageSelector-SB-NJSmx.js +46 -0
  70. package/dist/PasswordStrengthMeter-B3S6i_k4.cjs +179 -0
  71. package/dist/PasswordStrengthMeter-B8ky1nJI.js +173 -0
  72. package/dist/PasswordStrengthMeter-C5VEopH-.cjs +179 -0
  73. package/dist/PasswordStrengthMeter-CIm7_jNT.js +173 -0
  74. package/dist/PasswordStrengthMeter-DKSAbQzu.js +173 -0
  75. package/dist/PasswordStrengthMeter-DxLu54p-.cjs +179 -0
  76. package/dist/PasswordStrengthMeter-k-e9Pole.cjs +179 -0
  77. package/dist/PasswordStrengthMeter-pAi2viq5.js +173 -0
  78. package/dist/ThemeToggle-4pQbVkpK.js +215 -0
  79. package/dist/ThemeToggle-B6rIVLvC.cjs +219 -0
  80. package/dist/ThemeToggle-BUOTps5l.cjs +219 -0
  81. package/dist/ThemeToggle-CO5mPl6e.js +215 -0
  82. package/dist/ThemeToggle-DbZQ0JSV.cjs +219 -0
  83. package/dist/ThemeToggle-vLXEq2TS.js +215 -0
  84. package/dist/VerifyEmailPage-BTjI2c9n.js +2954 -0
  85. package/dist/VerifyEmailPage-CJGfDSOx.js +2954 -0
  86. package/dist/VerifyEmailPage-DOlZUNc0.cjs +2963 -0
  87. package/dist/VerifyEmailPage-DQPRl_RJ.js +2954 -0
  88. package/dist/VerifyEmailPage-DrdqMbLC.cjs +2963 -0
  89. package/dist/VerifyEmailPage-hyDfeCRa.cjs +2963 -0
  90. package/dist/VerifyEmailPage-kKSXl8vu.cjs +2963 -0
  91. package/dist/VerifyEmailPage-w4N-bDhU.js +2954 -0
  92. package/dist/XerticaOrbe-B9tegV1n.js +1925 -0
  93. package/dist/XerticaOrbe-BQ_NjwPS.cjs +1927 -0
  94. package/dist/XerticaOrbe-BdUX171Q.cjs +1927 -0
  95. package/dist/XerticaOrbe-BdlKXRHU.cjs +1927 -0
  96. package/dist/XerticaOrbe-CByPAFE5.js +1925 -0
  97. package/dist/XerticaOrbe-Ccu9eFMu.js +1925 -0
  98. package/dist/XerticaProvider-BVid1oqn.cjs +46 -0
  99. package/dist/XerticaProvider-Bz_YfNY4.js +44 -0
  100. package/dist/XerticaProvider-CtvYfRbZ.cjs +46 -0
  101. package/dist/XerticaProvider-DMiyExQS.js +44 -0
  102. package/dist/XerticaProvider-DP2lzKip.cjs +46 -0
  103. package/dist/XerticaProvider-De79hhgp.js +44 -0
  104. package/dist/XerticaProvider-Dkk1Vbsy.js +44 -0
  105. package/dist/XerticaProvider-EdzH9Nrw.cjs +46 -0
  106. package/dist/alert-dialog-9XYAn5z5.js +819 -0
  107. package/dist/alert-dialog-B281hud0.cjs +872 -0
  108. package/dist/alert-dialog-BVWbrcrw.cjs +872 -0
  109. package/dist/alert-dialog-B_Ko1xpu.js +819 -0
  110. package/dist/alert-dialog-CIxE8T-J.cjs +872 -0
  111. package/dist/alert-dialog-DW-_iPuf.js +819 -0
  112. package/dist/assistant.cjs.js +2 -2
  113. package/dist/assistant.es.js +2 -2
  114. package/dist/avatar-BJwIMbZ_.js +54 -0
  115. package/dist/avatar-C4Zh5fAJ.cjs +77 -0
  116. package/dist/avatar-CTEUKZUT.js +54 -0
  117. package/dist/avatar-D1bZhlhL.cjs +77 -0
  118. package/dist/avatar-DKIxHeKG.cjs +77 -0
  119. package/dist/avatar-v16eZC8p.js +54 -0
  120. package/dist/blocks.cjs.js +2 -2
  121. package/dist/blocks.es.js +2 -2
  122. package/dist/brand.cjs.js +4 -4
  123. package/dist/brand.es.js +4 -4
  124. package/dist/breadcrumb-B1mUiaWB.cjs +98 -0
  125. package/dist/breadcrumb-BIRgmem-.js +90 -0
  126. package/dist/breadcrumb-BSng-oUf.cjs +98 -0
  127. package/dist/breadcrumb-CES7furU.js +90 -0
  128. package/dist/breadcrumb-CP275kbF.cjs +98 -0
  129. package/dist/breadcrumb-D7hr1EvJ.js +90 -0
  130. package/dist/button-BYtQygX5.cjs +85 -0
  131. package/dist/button-BnAW-a_w.js +62 -0
  132. package/dist/button-CUPDQews.js +62 -0
  133. package/dist/button-DFa-rtPy.js +62 -0
  134. package/dist/button-DV1G6XrI.cjs +85 -0
  135. package/dist/button-Kd9Fj53S.cjs +85 -0
  136. package/dist/cli.js +94 -10
  137. package/dist/components/ui/card/card.d.ts +11 -1
  138. package/dist/contexts/theme-data.d.ts +15 -1
  139. package/dist/dropdown-menu-B9wTZ0uX.cjs +225 -0
  140. package/dist/dropdown-menu-BeBtZOrs.cjs +225 -0
  141. package/dist/dropdown-menu-D7mRDGis.js +190 -0
  142. package/dist/dropdown-menu-D8ZmqHB7.js +190 -0
  143. package/dist/dropdown-menu-_AWBeOts.cjs +225 -0
  144. package/dist/dropdown-menu-qGzLO_HO.js +190 -0
  145. package/dist/hooks.cjs.js +1 -1
  146. package/dist/hooks.es.js +1 -1
  147. package/dist/index.cjs.js +24 -24
  148. package/dist/index.es.js +24 -24
  149. package/dist/input-B53E6K8G.js +65 -0
  150. package/dist/input-B7Q7vcoG.cjs +91 -0
  151. package/dist/input-BysqLMK1.js +65 -0
  152. package/dist/input-CStdFsaH.cjs +91 -0
  153. package/dist/input-CXYth6nW.cjs +91 -0
  154. package/dist/input-CX_fWE2D.cjs +91 -0
  155. package/dist/input-CitUVnEn.js +65 -0
  156. package/dist/input-wkBYTp-B.js +65 -0
  157. package/dist/layout.cjs.js +1 -1
  158. package/dist/layout.es.js +1 -1
  159. package/dist/media.cjs.js +1 -1
  160. package/dist/media.es.js +1 -1
  161. package/dist/pages.cjs.js +1 -1
  162. package/dist/pages.es.js +1 -1
  163. package/dist/rich-text-editor-BHiRUzWZ.js +2894 -0
  164. package/dist/rich-text-editor-BWMRUMJ2.js +2894 -0
  165. package/dist/rich-text-editor-BoE6Ks5x.cjs +2968 -0
  166. package/dist/rich-text-editor-BzuEwR_X.js +2894 -0
  167. package/dist/rich-text-editor-CcopGbQ-.js +2894 -0
  168. package/dist/rich-text-editor-CmxSRJIi.cjs +2968 -0
  169. package/dist/rich-text-editor-DyYAu28v.cjs +2968 -0
  170. package/dist/rich-text-editor-JS_eMQCC.cjs +2968 -0
  171. package/dist/select-BNfFJwYp.js +130 -0
  172. package/dist/select-CN8IDjGB.js +130 -0
  173. package/dist/select-CwRzQHA7.cjs +161 -0
  174. package/dist/select-CwgD3nMD.js +130 -0
  175. package/dist/select-DEHUm_AC.cjs +161 -0
  176. package/dist/select-DJDgpVm3.cjs +161 -0
  177. package/dist/select-DSLWQLmo.cjs +161 -0
  178. package/dist/select-YFx0wCYT.js +130 -0
  179. package/dist/sidebar-BF7JEL7U.js +1151 -0
  180. package/dist/sidebar-Bjr2doX5.cjs +1154 -0
  181. package/dist/sidebar-CMrNCmhb.cjs +1154 -0
  182. package/dist/sidebar-CO9x8AVn.cjs +1154 -0
  183. package/dist/sidebar-Cn_KB4c6.js +1151 -0
  184. package/dist/sidebar-Db_C30ph.cjs +1154 -0
  185. package/dist/sidebar-miPHsRz4.js +1151 -0
  186. package/dist/sidebar-pZF8mLLu.js +1151 -0
  187. package/dist/skeleton-BX2XTjMO.cjs +87 -0
  188. package/dist/skeleton-BoLK0iV7.js +78 -0
  189. package/dist/skeleton-Bysq8yeB.js +79 -0
  190. package/dist/skeleton-C7nspYnC.cjs +87 -0
  191. package/dist/skeleton-DL4V5Vub.cjs +87 -0
  192. package/dist/skeleton-DSMhdqp1.js +78 -0
  193. package/dist/skeleton-DhJswvTW.cjs +88 -0
  194. package/dist/skeleton-DicUfozA.js +78 -0
  195. package/dist/slider-77T_Eqw4.js +56 -0
  196. package/dist/slider-B6puMLXS.cjs +78 -0
  197. package/dist/slider-B785N7lZ.js +56 -0
  198. package/dist/slider-C6yssKyZ.cjs +78 -0
  199. package/dist/slider-CKZO9gVh.cjs +78 -0
  200. package/dist/slider-Cn-ImSze.js +56 -0
  201. package/dist/tooltip-BiJVGob3.cjs +72 -0
  202. package/dist/tooltip-D2OPn-1v.cjs +72 -0
  203. package/dist/tooltip-DlCHQuh1.js +48 -0
  204. package/dist/tooltip-fQ2Va0G8.cjs +72 -0
  205. package/dist/tooltip-oAw00FX2.js +48 -0
  206. package/dist/tooltip-u147L0wD.js +48 -0
  207. package/dist/ui.cjs.js +13 -13
  208. package/dist/ui.es.js +13 -13
  209. package/dist/xertica-assistant-C2A0R94j.js +2173 -0
  210. package/dist/xertica-assistant-CSUprvTR.js +2173 -0
  211. package/dist/xertica-assistant-Caubm0HR.js +2173 -0
  212. package/dist/xertica-assistant-DEexPM2u.cjs +2180 -0
  213. package/dist/xertica-assistant-Dh1dmEx3.cjs +2180 -0
  214. package/dist/xertica-assistant-GGcyHEZG.cjs +2180 -0
  215. package/dist/xertica-assistant-USefPe2L.js +2173 -0
  216. package/dist/xertica-assistant-cwSHFwfv.cjs +2180 -0
  217. package/dist/xertica-ui.css +1 -1
  218. package/package.json +3 -2
  219. package/styles/xertica/base.css +38 -0
  220. package/styles/xertica/tokens.css +9 -0
  221. package/templates/src/app/App.tsx +5 -1
  222. package/templates/src/features/home/ui/HomeContent.tsx +12 -13
  223. package/templates/src/features/template/ui/TemplateContent.tsx +569 -26
  224. package/templates/src/locales/en/pages/templates.json +112 -4
  225. package/templates/src/locales/es/pages/templates.json +112 -4
  226. package/templates/src/locales/pt-BR/pages/templates.json +112 -4
  227. package/templates/src/styles/xertica/tokens.css +9 -0
  228. package/templates/vite.config.ts +25 -0
@@ -0,0 +1,2894 @@
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
3
+ import { c as cn, B as Button } from './button-DFa-rtPy.js';
4
+ import * as React from 'react';
5
+ import { useRef, useState, useCallback, useEffect } from 'react';
6
+ import * as RechartsPrimitive from 'recharts';
7
+ import { cva } from 'class-variance-authority';
8
+ import { XCircle, AlertTriangle, Info, CheckCircle, RefreshCw, BarChart3, WifiOff, XIcon, Undo, Redo, ChevronDown, Type, Heading1, Heading2, Heading3, Bold, Italic, Underline, AlignLeft, AlignCenter, AlignRight, List, ListOrdered, Link, X, Search, ChevronUp } from 'lucide-react';
9
+ import { C as Card, e as CardHeader, f as CardTitle, c as CardDescription, a as CardAction, b as CardContent, d as CardFooter, S as Skeleton } from './skeleton-Bysq8yeB.js';
10
+ import { S as Select, h as SelectTrigger, i as SelectValue, a as SelectContent, c as SelectItem } from './select-CwgD3nMD.js';
11
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
12
+ import { D as DropdownMenu, n as DropdownMenuTrigger, b as DropdownMenuContent, d as DropdownMenuItem } from './dropdown-menu-D7mRDGis.js';
13
+ import { P as Popover, c as PopoverTrigger, b as PopoverContent, I as Input } from './input-BysqLMK1.js';
14
+
15
+ function ScrollArea({
16
+ className,
17
+ children,
18
+ ...props
19
+ }) {
20
+ return /* @__PURE__ */ jsxs(
21
+ ScrollAreaPrimitive.Root,
22
+ {
23
+ "data-slot": "scroll-area",
24
+ className: cn("relative", className),
25
+ ...props,
26
+ children: [
27
+ /* @__PURE__ */ jsx(
28
+ ScrollAreaPrimitive.Viewport,
29
+ {
30
+ "data-slot": "scroll-area-viewport",
31
+ tabIndex: 0,
32
+ role: "region",
33
+ "aria-label": "Região rolável",
34
+ className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",
35
+ children
36
+ }
37
+ ),
38
+ /* @__PURE__ */ jsx(ScrollBar, {}),
39
+ /* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, {})
40
+ ]
41
+ }
42
+ );
43
+ }
44
+ function ScrollBar({
45
+ className,
46
+ orientation = "vertical",
47
+ ...props
48
+ }) {
49
+ return /* @__PURE__ */ jsx(
50
+ ScrollAreaPrimitive.ScrollAreaScrollbar,
51
+ {
52
+ "data-slot": "scroll-area-scrollbar",
53
+ orientation,
54
+ className: cn(
55
+ "flex touch-none p-px transition-colors select-none",
56
+ orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent",
57
+ orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent",
58
+ className
59
+ ),
60
+ ...props,
61
+ children: /* @__PURE__ */ jsx(
62
+ ScrollAreaPrimitive.ScrollAreaThumb,
63
+ {
64
+ "data-slot": "scroll-area-thumb",
65
+ className: "bg-border relative flex-1 rounded-full"
66
+ }
67
+ )
68
+ }
69
+ );
70
+ }
71
+
72
+ const alertVariants = cva(
73
+ "relative w-full rounded-[var(--radius)] border-l-4 px-4 py-3 grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-5 [&>svg]:translate-y-0.5 [&>svg]:text-current",
74
+ {
75
+ variants: {
76
+ variant: {
77
+ default: "bg-muted/50 border-l-border text-foreground [&>svg]:text-muted-foreground",
78
+ success: "bg-[color:var(--success)]/10 dark:bg-[color:var(--success)]/20 border-l-[color:var(--success)] text-foreground [&>svg]:text-[color:var(--success)]",
79
+ info: "bg-[color:var(--info)]/10 dark:bg-[color:var(--info)]/20 border-l-[color:var(--info)] text-foreground [&>svg]:text-[color:var(--info)]",
80
+ warning: "bg-[color:var(--warning)]/10 dark:bg-[color:var(--warning)]/20 border-l-[color:var(--warning)] text-foreground [&>svg]:text-[color:var(--warning)]",
81
+ destructive: "bg-[color:var(--destructive)]/10 dark:bg-[color:var(--destructive)]/20 border-l-[color:var(--destructive)] text-foreground [&>svg]:text-[color:var(--destructive)]"
82
+ }
83
+ },
84
+ defaultVariants: {
85
+ variant: "default"
86
+ }
87
+ }
88
+ );
89
+ const alertIcons = {
90
+ default: Info,
91
+ success: CheckCircle,
92
+ info: Info,
93
+ warning: AlertTriangle,
94
+ destructive: XCircle
95
+ };
96
+ function Alert({ className, variant, icon, children, ...props }) {
97
+ const alertVariant = variant && variant in alertIcons ? variant : "default";
98
+ const DefaultIcon = alertIcons[alertVariant];
99
+ return /* @__PURE__ */ jsxs(
100
+ "div",
101
+ {
102
+ "data-slot": "alert",
103
+ role: "alert",
104
+ className: cn(alertVariants({ variant }), className),
105
+ ...props,
106
+ children: [
107
+ icon !== void 0 ? icon : /* @__PURE__ */ jsx(DefaultIcon, { className: "flex-shrink-0" }),
108
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children })
109
+ ]
110
+ }
111
+ );
112
+ }
113
+ function AlertTitle({ className, ...props }) {
114
+ return /* @__PURE__ */ jsx(
115
+ "div",
116
+ {
117
+ "data-slot": "alert-title",
118
+ className: cn("font-medium mb-1 leading-tight", className),
119
+ ...props
120
+ }
121
+ );
122
+ }
123
+ function AlertDescription({ className, ...props }) {
124
+ return /* @__PURE__ */ jsx("div", { "data-slot": "alert-description", className: cn("leading-relaxed", className), ...props });
125
+ }
126
+
127
+ const Empty = React.forwardRef(
128
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
129
+ "div",
130
+ {
131
+ ref,
132
+ className: cn(
133
+ "flex min-h-[400px] flex-col items-center justify-center rounded-[var(--radius-card)] border border-dashed border-border p-8 text-center animate-in fade-in-50",
134
+ className
135
+ ),
136
+ ...props
137
+ }
138
+ )
139
+ );
140
+ Empty.displayName = "Empty";
141
+ const EmptyIcon = React.forwardRef(
142
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
143
+ "div",
144
+ {
145
+ ref,
146
+ className: cn(
147
+ "mx-auto flex h-20 w-20 items-center justify-center rounded-full bg-muted",
148
+ className
149
+ ),
150
+ ...props
151
+ }
152
+ )
153
+ );
154
+ EmptyIcon.displayName = "EmptyIcon";
155
+ const EmptyImage = React.forwardRef(
156
+ ({ className, alt, ...props }, ref) => /* @__PURE__ */ jsx(
157
+ "img",
158
+ {
159
+ ref,
160
+ alt,
161
+ className: cn("mx-auto mb-4 h-48 w-48 object-contain opacity-50", className),
162
+ ...props
163
+ }
164
+ )
165
+ );
166
+ EmptyImage.displayName = "EmptyImage";
167
+ const EmptyTitle = React.forwardRef(
168
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("h3", { ref, className: cn("mt-4 font-semibold text-foreground", className), ...props })
169
+ );
170
+ EmptyTitle.displayName = "EmptyTitle";
171
+ const EmptyDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
172
+ "p",
173
+ {
174
+ ref,
175
+ className: cn("mt-2 text-sm text-muted-foreground max-w-sm mx-auto", className),
176
+ ...props
177
+ }
178
+ ));
179
+ EmptyDescription.displayName = "EmptyDescription";
180
+ const EmptyAction = React.forwardRef(
181
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
182
+ "div",
183
+ {
184
+ ref,
185
+ className: cn("mt-6 flex flex-col gap-2 sm:flex-row sm:gap-4", className),
186
+ ...props
187
+ }
188
+ )
189
+ );
190
+ EmptyAction.displayName = "EmptyAction";
191
+
192
+ const THEMES = { light: "", dark: ".dark" };
193
+ const defaultPeriods = [
194
+ { value: "7d", label: "7 days" },
195
+ { value: "30d", label: "30 days" },
196
+ { value: "90d", label: "90 days" }
197
+ ];
198
+ const defaultChartColors = [
199
+ "var(--chart-1)",
200
+ "var(--chart-2)",
201
+ "var(--chart-3)",
202
+ "var(--chart-4)",
203
+ "var(--chart-5)",
204
+ "var(--chart-6)",
205
+ "var(--chart-7)",
206
+ "var(--chart-8)"
207
+ ];
208
+ const chartBarSizes = {
209
+ sm: 8,
210
+ md: 14,
211
+ lg: 22,
212
+ xl: 32
213
+ };
214
+ const ChartContext = React.createContext(null);
215
+ function useChart() {
216
+ const context = React.useContext(ChartContext);
217
+ if (!context) {
218
+ throw new Error("useChart must be used within a <ChartContainer />");
219
+ }
220
+ return context;
221
+ }
222
+ function ChartContainer({
223
+ id,
224
+ className,
225
+ children,
226
+ config,
227
+ ...props
228
+ }) {
229
+ const uniqueId = React.useId();
230
+ const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
231
+ return /* @__PURE__ */ jsx(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxs(
232
+ "div",
233
+ {
234
+ "data-slot": "chart",
235
+ "data-chart": chartId,
236
+ className: cn(
237
+ "[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border relative h-[300px] min-h-[200px] w-full min-w-0 overflow-hidden text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
238
+ className
239
+ ),
240
+ ...props,
241
+ children: [
242
+ /* @__PURE__ */ jsx(ChartStyle, { id: chartId, config }),
243
+ /* @__PURE__ */ jsx(RechartsPrimitive.ResponsiveContainer, { width: "100%", height: "100%", children })
244
+ ]
245
+ }
246
+ ) });
247
+ }
248
+ const SAFE_CSS_COLOR = /^(#[0-9a-fA-F]{3,8}|(rgb|rgba|hsl|hsla|var)\([^;{}<>]*\)|[a-zA-Z-]+)$/;
249
+ const ChartStyle = ({ id, config }) => {
250
+ const colorConfig = Object.entries(config).filter(([, config2]) => config2.theme || config2.color);
251
+ if (!colorConfig.length) {
252
+ return null;
253
+ }
254
+ return /* @__PURE__ */ jsx(
255
+ "style",
256
+ {
257
+ dangerouslySetInnerHTML: {
258
+ __html: Object.entries(THEMES).map(
259
+ ([theme, prefix]) => `
260
+ ${prefix} [data-chart=${id}] {
261
+ ${colorConfig.map(([key, itemConfig]) => {
262
+ const color = itemConfig.theme?.[theme] || itemConfig.color;
263
+ if (!color || !SAFE_CSS_COLOR.test(color.trim())) {
264
+ return null;
265
+ }
266
+ return ` --color-${key}: ${color};`;
267
+ }).join("\n")}
268
+ }
269
+ `
270
+ ).join("\n")
271
+ }
272
+ }
273
+ );
274
+ };
275
+ const ChartTooltip = RechartsPrimitive.Tooltip;
276
+ function ChartTooltipContent({
277
+ active,
278
+ payload,
279
+ className,
280
+ indicator = "dot",
281
+ hideLabel = false,
282
+ hideIndicator = false,
283
+ label,
284
+ labelFormatter,
285
+ labelClassName,
286
+ formatter,
287
+ color,
288
+ nameKey,
289
+ labelKey
290
+ }) {
291
+ const { config } = useChart();
292
+ const tooltipLabel = React.useMemo(() => {
293
+ if (hideLabel || !payload?.length) {
294
+ return null;
295
+ }
296
+ const [item] = payload;
297
+ const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
298
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
299
+ const value = !labelKey && typeof label === "string" ? config[label]?.label || label : itemConfig?.label;
300
+ if (labelFormatter) {
301
+ return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
302
+ }
303
+ if (!value) {
304
+ return null;
305
+ }
306
+ return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: value });
307
+ }, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
308
+ if (!active || !payload?.length) {
309
+ return null;
310
+ }
311
+ const nestLabel = payload.length === 1 && indicator !== "dot";
312
+ return /* @__PURE__ */ jsxs(
313
+ "div",
314
+ {
315
+ className: cn(
316
+ "border-border/50 bg-background/95 backdrop-blur-sm grid min-w-[8rem] items-start gap-1.5 rounded-xl border px-3 py-2 text-xs shadow-xl",
317
+ className
318
+ ),
319
+ children: [
320
+ !nestLabel ? tooltipLabel : null,
321
+ /* @__PURE__ */ jsx("div", { className: "grid gap-1.5", children: payload.map((item, index) => {
322
+ const key = `${nameKey || item.name || item.dataKey || "value"}`;
323
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
324
+ const indicatorColor = color || item.payload?.fill || item.color;
325
+ return /* @__PURE__ */ jsx(
326
+ "div",
327
+ {
328
+ className: cn(
329
+ "[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
330
+ indicator === "dot" && "items-center"
331
+ ),
332
+ children: formatter && item?.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ jsxs(Fragment, { children: [
333
+ itemConfig?.icon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx(
334
+ "div",
335
+ {
336
+ className: cn(
337
+ "shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
338
+ {
339
+ "h-2.5 w-2.5": indicator === "dot",
340
+ "w-1": indicator === "line",
341
+ "w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
342
+ "my-0.5": nestLabel && indicator === "dashed"
343
+ }
344
+ ),
345
+ style: {
346
+ "--color-bg": indicatorColor,
347
+ "--color-border": indicatorColor
348
+ }
349
+ }
350
+ ),
351
+ /* @__PURE__ */ jsxs(
352
+ "div",
353
+ {
354
+ className: cn(
355
+ "flex flex-1 justify-between leading-none",
356
+ nestLabel ? "items-end" : "items-center"
357
+ ),
358
+ children: [
359
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
360
+ nestLabel ? tooltipLabel : null,
361
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: itemConfig?.label || item.name })
362
+ ] }),
363
+ item.value && /* @__PURE__ */ jsx("span", { className: "text-foreground font-mono font-semibold tabular-nums", children: item.value.toLocaleString() })
364
+ ]
365
+ }
366
+ )
367
+ ] })
368
+ },
369
+ `${item.dataKey ?? index}`
370
+ );
371
+ }) })
372
+ ]
373
+ }
374
+ );
375
+ }
376
+ const ChartLegend = RechartsPrimitive.Legend;
377
+ function ChartLegendContent({
378
+ className,
379
+ hideIcon = false,
380
+ payload,
381
+ verticalAlign = "bottom",
382
+ nameKey
383
+ }) {
384
+ const { config } = useChart();
385
+ if (!payload?.length) {
386
+ return null;
387
+ }
388
+ return /* @__PURE__ */ jsx(
389
+ "div",
390
+ {
391
+ className: cn(
392
+ "flex items-center justify-center gap-4",
393
+ verticalAlign === "top" ? "pb-3" : "pt-3",
394
+ className
395
+ ),
396
+ children: payload.map((item) => {
397
+ const key = `${nameKey ? item.value : item.dataKey || item.value || "value"}`;
398
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
399
+ return /* @__PURE__ */ jsxs(
400
+ "div",
401
+ {
402
+ className: cn(
403
+ "[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"
404
+ ),
405
+ children: [
406
+ itemConfig?.icon && !hideIcon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : /* @__PURE__ */ jsx(
407
+ "div",
408
+ {
409
+ className: "h-2 w-2 shrink-0 rounded-full bg-(--color-bg)",
410
+ style: {
411
+ "--color-bg": item.color || `var(--color-${key})`
412
+ }
413
+ }
414
+ ),
415
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs", children: itemConfig?.label || item.value })
416
+ ]
417
+ },
418
+ item.value
419
+ );
420
+ })
421
+ }
422
+ );
423
+ }
424
+ function getPayloadConfigFromPayload(config, payload, key) {
425
+ if (typeof payload !== "object" || payload === null) {
426
+ return void 0;
427
+ }
428
+ const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
429
+ let configLabelKey = key;
430
+ if (key in payload && typeof payload[key] === "string") {
431
+ configLabelKey = payload[key];
432
+ } else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
433
+ configLabelKey = payloadPayload[key];
434
+ }
435
+ return configLabelKey in config ? config[configLabelKey] : config[key];
436
+ }
437
+ function getChartSeries(config, series) {
438
+ if (series?.length) {
439
+ return series;
440
+ }
441
+ return Object.entries(config).map(([key, item]) => ({
442
+ key,
443
+ label: item.label
444
+ }));
445
+ }
446
+ function getSeriesColor(key, index, colors) {
447
+ if (Array.isArray(colors)) {
448
+ return colors[index] || defaultChartColors[index % defaultChartColors.length];
449
+ }
450
+ return colors?.[key] || defaultChartColors[index % defaultChartColors.length];
451
+ }
452
+ function getChartConfigWithColors(config, keys, colors) {
453
+ return keys.reduce((nextConfig, key, index) => {
454
+ const item = config[key];
455
+ if (item?.theme && !colors) {
456
+ nextConfig[key] = item;
457
+ return nextConfig;
458
+ }
459
+ nextConfig[key] = {
460
+ label: item?.label || key,
461
+ icon: item?.icon,
462
+ color: colors ? getSeriesColor(key, index, colors) : item?.color || getSeriesColor(key, index)
463
+ };
464
+ return nextConfig;
465
+ }, {});
466
+ }
467
+ function buildChartConfig(keys, colors) {
468
+ return keys.reduce((cfg, key, index) => {
469
+ cfg[key] = {
470
+ label: key,
471
+ color: getSeriesColor(key, index, colors)
472
+ };
473
+ return cfg;
474
+ }, {});
475
+ }
476
+ function formatTick(value) {
477
+ if (typeof value !== "number") {
478
+ return value;
479
+ }
480
+ return Intl.NumberFormat("en", {
481
+ notation: "compact",
482
+ maximumFractionDigits: 1
483
+ }).format(value);
484
+ }
485
+ function defaultFilterData(data, period) {
486
+ const match = period.match(/^(\d+)/);
487
+ if (!match) {
488
+ return data;
489
+ }
490
+ const limit = Number(match[1]);
491
+ return data.slice(Math.max(data.length - limit, 0));
492
+ }
493
+ function getErrorDescription(error) {
494
+ if (typeof error === "string") {
495
+ return error;
496
+ }
497
+ if (error instanceof Error) {
498
+ return error.message;
499
+ }
500
+ return void 0;
501
+ }
502
+ function getBarSize(barSize = "md") {
503
+ return typeof barSize === "number" ? barSize : chartBarSizes[barSize];
504
+ }
505
+ function hasChartData(data, series) {
506
+ if (!data.length || !series.length) {
507
+ return false;
508
+ }
509
+ return data.some(
510
+ (item) => series.some((serie) => {
511
+ const value = item[serie.key];
512
+ return value !== null && value !== void 0 && value !== "";
513
+ })
514
+ );
515
+ }
516
+ function hasPieData(data, nameKey, valueKey) {
517
+ return data.some((item) => {
518
+ const name = item[nameKey];
519
+ const value = item[valueKey];
520
+ return name !== null && name !== void 0 && name !== "" && value !== null && value !== void 0 && value !== "";
521
+ });
522
+ }
523
+ function ChartState({
524
+ type,
525
+ className,
526
+ error,
527
+ onRetry,
528
+ retryLabel = "Try again",
529
+ emptyTitle = "No data available",
530
+ emptyDescription = "There is no data available for this chart yet.",
531
+ errorTitle = "Connection error",
532
+ errorDescription,
533
+ loadingLabel = "Loading chart data"
534
+ }) {
535
+ if (type === "loading") {
536
+ return /* @__PURE__ */ jsxs(
537
+ "div",
538
+ {
539
+ className: cn(
540
+ "flex min-h-[240px] flex-col justify-end gap-3 rounded-[var(--radius-card)] border border-border p-6",
541
+ className
542
+ ),
543
+ "aria-label": typeof loadingLabel === "string" ? loadingLabel : void 0,
544
+ children: [
545
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-2/5" }),
546
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-14 w-3/5" }),
547
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-24 w-4/5" }),
548
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-36 w-full" })
549
+ ]
550
+ }
551
+ );
552
+ }
553
+ if (type === "error") {
554
+ return /* @__PURE__ */ jsx(
555
+ "div",
556
+ {
557
+ className: cn(
558
+ "flex min-h-[240px] items-center justify-center rounded-[var(--radius-card)] border border-border p-6",
559
+ className
560
+ ),
561
+ children: /* @__PURE__ */ jsxs(Alert, { variant: "destructive", className: "max-w-xl", children: [
562
+ /* @__PURE__ */ jsx(AlertTitle, { children: errorTitle }),
563
+ /* @__PURE__ */ jsx(AlertDescription, { children: errorDescription || getErrorDescription(error) || "Unable to load chart data. Check your connection and try again." }),
564
+ onRetry ? /* @__PURE__ */ jsx("div", { className: "mt-3", children: /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "outline", onClick: onRetry, children: [
565
+ /* @__PURE__ */ jsx(RefreshCw, { className: "size-4" }),
566
+ retryLabel
567
+ ] }) }) : null
568
+ ] })
569
+ }
570
+ );
571
+ }
572
+ return /* @__PURE__ */ jsxs(Empty, { className: cn("min-h-[240px]", className), children: [
573
+ /* @__PURE__ */ jsx(EmptyIcon, { children: /* @__PURE__ */ jsx(BarChart3, { className: "size-10 text-muted-foreground" }) }),
574
+ /* @__PURE__ */ jsx(EmptyTitle, { children: emptyTitle }),
575
+ /* @__PURE__ */ jsx(EmptyDescription, { children: emptyDescription }),
576
+ onRetry ? /* @__PURE__ */ jsx(EmptyAction, { children: /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "outline", onClick: onRetry, children: [
577
+ /* @__PURE__ */ jsx(WifiOff, { className: "size-4" }),
578
+ retryLabel
579
+ ] }) }) : null
580
+ ] });
581
+ }
582
+ function getChartState(state, hasData, className) {
583
+ if (state.isLoading) {
584
+ return /* @__PURE__ */ jsx(ChartState, { ...state, type: "loading", className });
585
+ }
586
+ if (state.error) {
587
+ return /* @__PURE__ */ jsx(ChartState, { ...state, type: "error", className });
588
+ }
589
+ if (!hasData) {
590
+ return /* @__PURE__ */ jsx(ChartState, { ...state, type: "empty", className });
591
+ }
592
+ return null;
593
+ }
594
+ function ChartCard({
595
+ title,
596
+ description,
597
+ action,
598
+ footer,
599
+ children,
600
+ className,
601
+ contentClassName,
602
+ ...props
603
+ }) {
604
+ return /* @__PURE__ */ jsxs(Card, { className: cn("w-full min-w-0 overflow-hidden", className), ...props, children: [
605
+ /* @__PURE__ */ jsxs(CardHeader, { children: [
606
+ /* @__PURE__ */ jsx(CardTitle, { children: title }),
607
+ description ? /* @__PURE__ */ jsx(CardDescription, { children: description }) : null,
608
+ action ? /* @__PURE__ */ jsx(CardAction, { children: action }) : null
609
+ ] }),
610
+ /* @__PURE__ */ jsx(CardContent, { className: contentClassName, children }),
611
+ footer ? /* @__PURE__ */ jsx(CardFooter, { children: footer }) : null
612
+ ] });
613
+ }
614
+ function AreaGradientDefs({
615
+ seriesKeys,
616
+ opacity = 0.3
617
+ }) {
618
+ return /* @__PURE__ */ jsx("defs", { children: seriesKeys.map((key) => /* @__PURE__ */ jsxs("linearGradient", { id: `gradient-${key}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
619
+ /* @__PURE__ */ jsx("stop", { offset: "5%", stopColor: `var(--color-${key})`, stopOpacity: opacity }),
620
+ /* @__PURE__ */ jsx("stop", { offset: "95%", stopColor: `var(--color-${key})`, stopOpacity: 0 })
621
+ ] }, key)) });
622
+ }
623
+ function DashboardBarChart({
624
+ data,
625
+ config,
626
+ indexKey = "name",
627
+ series,
628
+ colors,
629
+ barSize = "md",
630
+ stacked = false,
631
+ showGrid = true,
632
+ showLegend = true,
633
+ valueFormatter = formatTick,
634
+ isLoading,
635
+ error,
636
+ onRetry,
637
+ retryLabel,
638
+ emptyTitle,
639
+ emptyDescription,
640
+ errorTitle,
641
+ errorDescription,
642
+ loadingLabel,
643
+ stateClassName,
644
+ className,
645
+ ...props
646
+ }) {
647
+ const chartSeries = getChartSeries(config, series);
648
+ const chartConfig = getChartConfigWithColors(
649
+ config,
650
+ chartSeries.map((item) => item.key),
651
+ colors
652
+ );
653
+ const chartState = getChartState(
654
+ {
655
+ isLoading,
656
+ error,
657
+ onRetry,
658
+ retryLabel,
659
+ emptyTitle,
660
+ emptyDescription,
661
+ errorTitle,
662
+ errorDescription,
663
+ loadingLabel
664
+ },
665
+ hasChartData(data, chartSeries),
666
+ cn("h-[320px] w-full", stateClassName)
667
+ );
668
+ const barElements = React.useMemo(() => {
669
+ const topOfStack = /* @__PURE__ */ new Set();
670
+ if (stacked) {
671
+ const lastByStack = /* @__PURE__ */ new Map();
672
+ chartSeries.forEach((s) => lastByStack.set(s.stackId || "total", s.key));
673
+ lastByStack.forEach((key) => topOfStack.add(key));
674
+ }
675
+ return chartSeries.map((item) => {
676
+ const isTop = !stacked || topOfStack.has(item.key);
677
+ return /* @__PURE__ */ jsx(
678
+ RechartsPrimitive.Bar,
679
+ {
680
+ dataKey: item.key,
681
+ fill: `var(--color-${item.key})`,
682
+ radius: isTop ? [4, 4, 0, 0] : [0, 0, 0, 0],
683
+ barSize: getBarSize(barSize),
684
+ stackId: stacked ? item.stackId || "total" : item.stackId,
685
+ isAnimationActive: true,
686
+ animationDuration: 600,
687
+ animationEasing: "ease-out"
688
+ },
689
+ item.key
690
+ );
691
+ });
692
+ }, [stacked, chartSeries]);
693
+ if (chartState) {
694
+ return chartState;
695
+ }
696
+ return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: cn("h-[320px] w-full", className), ...props, children: /* @__PURE__ */ jsxs(RechartsPrimitive.BarChart, { data, accessibilityLayer: true, barGap: 4, children: [
697
+ showGrid ? /* @__PURE__ */ jsx(
698
+ RechartsPrimitive.CartesianGrid,
699
+ {
700
+ vertical: false,
701
+ strokeDasharray: "3 3",
702
+ stroke: "var(--border)",
703
+ strokeOpacity: 0.5
704
+ }
705
+ ) : null,
706
+ /* @__PURE__ */ jsx(
707
+ RechartsPrimitive.XAxis,
708
+ {
709
+ dataKey: indexKey,
710
+ tickLine: false,
711
+ axisLine: false,
712
+ tickMargin: 8
713
+ }
714
+ ),
715
+ /* @__PURE__ */ jsx(
716
+ RechartsPrimitive.YAxis,
717
+ {
718
+ tickLine: false,
719
+ axisLine: false,
720
+ tickMargin: 8,
721
+ tickFormatter: valueFormatter
722
+ }
723
+ ),
724
+ /* @__PURE__ */ jsx(
725
+ ChartTooltip,
726
+ {
727
+ cursor: { fill: "var(--muted)", opacity: 0.4, radius: 4 },
728
+ content: /* @__PURE__ */ jsx(ChartTooltipContent, {})
729
+ }
730
+ ),
731
+ showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }) : null,
732
+ barElements
733
+ ] }) });
734
+ }
735
+ function DashboardLineChart({
736
+ data,
737
+ config,
738
+ indexKey = "name",
739
+ series,
740
+ colors,
741
+ showDots = false,
742
+ showGrid = true,
743
+ showLegend = true,
744
+ curveType = "monotone",
745
+ strokeWidth = 2,
746
+ valueFormatter = formatTick,
747
+ isLoading,
748
+ error,
749
+ onRetry,
750
+ retryLabel,
751
+ emptyTitle,
752
+ emptyDescription,
753
+ errorTitle,
754
+ errorDescription,
755
+ loadingLabel,
756
+ stateClassName,
757
+ className,
758
+ ...props
759
+ }) {
760
+ const chartSeries = getChartSeries(config, series);
761
+ const chartConfig = getChartConfigWithColors(
762
+ config,
763
+ chartSeries.map((item) => item.key),
764
+ colors
765
+ );
766
+ const chartState = getChartState(
767
+ {
768
+ isLoading,
769
+ error,
770
+ onRetry,
771
+ retryLabel,
772
+ emptyTitle,
773
+ emptyDescription,
774
+ errorTitle,
775
+ errorDescription,
776
+ loadingLabel
777
+ },
778
+ hasChartData(data, chartSeries),
779
+ cn("h-[320px] w-full", stateClassName)
780
+ );
781
+ if (chartState) {
782
+ return chartState;
783
+ }
784
+ return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: cn("h-[320px] w-full", className), ...props, children: /* @__PURE__ */ jsxs(RechartsPrimitive.LineChart, { data, accessibilityLayer: true, children: [
785
+ showGrid ? /* @__PURE__ */ jsx(
786
+ RechartsPrimitive.CartesianGrid,
787
+ {
788
+ vertical: false,
789
+ strokeDasharray: "3 3",
790
+ stroke: "var(--border)",
791
+ strokeOpacity: 0.5
792
+ }
793
+ ) : null,
794
+ /* @__PURE__ */ jsx(
795
+ RechartsPrimitive.XAxis,
796
+ {
797
+ dataKey: indexKey,
798
+ tickLine: false,
799
+ axisLine: false,
800
+ tickMargin: 8
801
+ }
802
+ ),
803
+ /* @__PURE__ */ jsx(
804
+ RechartsPrimitive.YAxis,
805
+ {
806
+ tickLine: false,
807
+ axisLine: false,
808
+ tickMargin: 8,
809
+ tickFormatter: valueFormatter
810
+ }
811
+ ),
812
+ /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, { indicator: "line" }) }),
813
+ showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }) : null,
814
+ chartSeries.map((item) => /* @__PURE__ */ jsx(
815
+ RechartsPrimitive.Line,
816
+ {
817
+ type: curveType,
818
+ dataKey: item.key,
819
+ stroke: `var(--color-${item.key})`,
820
+ strokeWidth,
821
+ dot: showDots ? { r: 3, fill: `var(--color-${item.key})`, strokeWidth: 0 } : false,
822
+ activeDot: { r: 5, strokeWidth: 0 },
823
+ yAxisId: item.yAxisId,
824
+ isAnimationActive: true,
825
+ animationDuration: 600,
826
+ animationEasing: "ease-out"
827
+ },
828
+ item.key
829
+ ))
830
+ ] }) });
831
+ }
832
+ function HorizontalBarChart({
833
+ data,
834
+ config,
835
+ indexKey = "name",
836
+ series,
837
+ colors,
838
+ barSize = "md",
839
+ stacked = false,
840
+ categoryWidth = 96,
841
+ showGrid = true,
842
+ showLegend = true,
843
+ valueFormatter = formatTick,
844
+ isLoading,
845
+ error,
846
+ onRetry,
847
+ retryLabel,
848
+ emptyTitle,
849
+ emptyDescription,
850
+ errorTitle,
851
+ errorDescription,
852
+ loadingLabel,
853
+ stateClassName,
854
+ className,
855
+ ...props
856
+ }) {
857
+ const chartSeries = getChartSeries(config, series);
858
+ const chartConfig = getChartConfigWithColors(
859
+ config,
860
+ chartSeries.map((item) => item.key),
861
+ colors
862
+ );
863
+ const chartState = getChartState(
864
+ {
865
+ isLoading,
866
+ error,
867
+ onRetry,
868
+ retryLabel,
869
+ emptyTitle,
870
+ emptyDescription,
871
+ errorTitle,
872
+ errorDescription,
873
+ loadingLabel
874
+ },
875
+ hasChartData(data, chartSeries),
876
+ cn("h-[320px] w-full", stateClassName)
877
+ );
878
+ if (chartState) {
879
+ return chartState;
880
+ }
881
+ return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: cn("h-[320px] w-full", className), ...props, children: /* @__PURE__ */ jsxs(
882
+ RechartsPrimitive.BarChart,
883
+ {
884
+ data,
885
+ layout: "vertical",
886
+ accessibilityLayer: true,
887
+ margin: { left: 8, right: 16 },
888
+ children: [
889
+ showGrid ? /* @__PURE__ */ jsx(
890
+ RechartsPrimitive.CartesianGrid,
891
+ {
892
+ horizontal: false,
893
+ strokeDasharray: "3 3",
894
+ stroke: "var(--border)",
895
+ strokeOpacity: 0.5
896
+ }
897
+ ) : null,
898
+ /* @__PURE__ */ jsx(
899
+ RechartsPrimitive.XAxis,
900
+ {
901
+ type: "number",
902
+ tickLine: false,
903
+ axisLine: false,
904
+ tickMargin: 8,
905
+ tickFormatter: valueFormatter
906
+ }
907
+ ),
908
+ /* @__PURE__ */ jsx(
909
+ RechartsPrimitive.YAxis,
910
+ {
911
+ dataKey: indexKey,
912
+ type: "category",
913
+ tickLine: false,
914
+ axisLine: false,
915
+ tickMargin: 8,
916
+ width: categoryWidth
917
+ }
918
+ ),
919
+ /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
920
+ showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }) : null,
921
+ chartSeries.map((item) => /* @__PURE__ */ jsx(
922
+ RechartsPrimitive.Bar,
923
+ {
924
+ dataKey: item.key,
925
+ fill: `var(--color-${item.key})`,
926
+ radius: [0, 4, 4, 0],
927
+ barSize: getBarSize(barSize),
928
+ stackId: stacked ? item.stackId || "total" : item.stackId,
929
+ isAnimationActive: true,
930
+ animationDuration: 600,
931
+ animationEasing: "ease-out"
932
+ },
933
+ item.key
934
+ ))
935
+ ]
936
+ }
937
+ ) });
938
+ }
939
+ function InteractiveTimeSeriesChart({
940
+ data,
941
+ config,
942
+ indexKey = "date",
943
+ series,
944
+ colors,
945
+ periods = defaultPeriods,
946
+ defaultPeriod = periods[1]?.value || periods[0]?.value || "30d",
947
+ defaultSeries,
948
+ filterData = defaultFilterData,
949
+ showGrid = true,
950
+ showLegend = false,
951
+ showDots = false,
952
+ gradientFill = true,
953
+ curveType = "monotone",
954
+ strokeWidth = 2,
955
+ valueFormatter = formatTick,
956
+ isLoading,
957
+ error,
958
+ onRetry,
959
+ retryLabel,
960
+ emptyTitle,
961
+ emptyDescription,
962
+ errorTitle,
963
+ errorDescription,
964
+ loadingLabel,
965
+ stateClassName,
966
+ className,
967
+ ...props
968
+ }) {
969
+ const chartSeries = getChartSeries(config, series);
970
+ const chartConfig = getChartConfigWithColors(
971
+ config,
972
+ chartSeries.map((item) => item.key),
973
+ colors
974
+ );
975
+ const [period, setPeriod] = React.useState(defaultPeriod);
976
+ const [activeSeries, setActiveSeries] = React.useState(
977
+ defaultSeries || chartSeries[0]?.key || ""
978
+ );
979
+ const filteredData = React.useMemo(() => filterData(data, period), [data, filterData, period]);
980
+ const visibleSeries = chartSeries.length > 1 ? chartSeries.filter((item) => item.key === activeSeries) : chartSeries;
981
+ const chartState = getChartState(
982
+ {
983
+ isLoading,
984
+ error,
985
+ onRetry,
986
+ retryLabel,
987
+ emptyTitle,
988
+ emptyDescription,
989
+ errorTitle,
990
+ errorDescription,
991
+ loadingLabel
992
+ },
993
+ hasChartData(filteredData, visibleSeries),
994
+ cn("h-[320px] w-full", stateClassName)
995
+ );
996
+ return /* @__PURE__ */ jsxs("div", { className: "w-full space-y-4", children: [
997
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [
998
+ chartSeries.length > 1 ? /* @__PURE__ */ jsx(
999
+ "div",
1000
+ {
1001
+ className: "inline-flex h-10 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
1002
+ role: "group",
1003
+ "aria-label": "Selecionar metrica do grafico",
1004
+ children: chartSeries.map((item) => {
1005
+ const label = item.label || config[item.key]?.label || item.key;
1006
+ return /* @__PURE__ */ jsx(
1007
+ Button,
1008
+ {
1009
+ type: "button",
1010
+ variant: "ghost",
1011
+ size: "sm",
1012
+ "aria-pressed": activeSeries === item.key,
1013
+ onClick: () => setActiveSeries(item.key),
1014
+ className: cn(
1015
+ "h-8 px-3 text-sm font-medium transition-all",
1016
+ activeSeries === item.key ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"
1017
+ ),
1018
+ children: label
1019
+ },
1020
+ item.key
1021
+ );
1022
+ })
1023
+ }
1024
+ ) : /* @__PURE__ */ jsx("div", {}),
1025
+ /* @__PURE__ */ jsxs(Select, { value: period, onValueChange: setPeriod, children: [
1026
+ /* @__PURE__ */ jsx(
1027
+ SelectTrigger,
1028
+ {
1029
+ className: "w-full sm:w-[160px]",
1030
+ size: "sm",
1031
+ "aria-label": "Selecionar periodo do grafico",
1032
+ children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Period" })
1033
+ }
1034
+ ),
1035
+ /* @__PURE__ */ jsx(SelectContent, { children: periods.map((item) => /* @__PURE__ */ jsx(SelectItem, { value: item.value, children: item.label }, item.value)) })
1036
+ ] })
1037
+ ] }),
1038
+ chartState || /* @__PURE__ */ jsx(
1039
+ ChartContainer,
1040
+ {
1041
+ config: chartConfig,
1042
+ className: cn("h-[320px] w-full", className),
1043
+ ...props,
1044
+ children: /* @__PURE__ */ jsxs(RechartsPrimitive.AreaChart, { data: filteredData, accessibilityLayer: true, children: [
1045
+ gradientFill && /* @__PURE__ */ jsx(AreaGradientDefs, { seriesKeys: visibleSeries.map((s) => s.key), opacity: 0.4 }),
1046
+ showGrid ? /* @__PURE__ */ jsx(
1047
+ RechartsPrimitive.CartesianGrid,
1048
+ {
1049
+ vertical: false,
1050
+ strokeDasharray: "3 3",
1051
+ stroke: "var(--border)",
1052
+ strokeOpacity: 0.5
1053
+ }
1054
+ ) : null,
1055
+ /* @__PURE__ */ jsx(
1056
+ RechartsPrimitive.XAxis,
1057
+ {
1058
+ dataKey: indexKey,
1059
+ tickLine: false,
1060
+ axisLine: false,
1061
+ tickMargin: 8
1062
+ }
1063
+ ),
1064
+ /* @__PURE__ */ jsx(
1065
+ RechartsPrimitive.YAxis,
1066
+ {
1067
+ tickLine: false,
1068
+ axisLine: false,
1069
+ tickMargin: 8,
1070
+ tickFormatter: valueFormatter
1071
+ }
1072
+ ),
1073
+ /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, { indicator: "line" }) }),
1074
+ showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }) : null,
1075
+ visibleSeries.map((item) => /* @__PURE__ */ jsx(
1076
+ RechartsPrimitive.Area,
1077
+ {
1078
+ type: curveType,
1079
+ dataKey: item.key,
1080
+ stroke: `var(--color-${item.key})`,
1081
+ fill: gradientFill ? `url(#gradient-${item.key})` : `var(--color-${item.key})`,
1082
+ fillOpacity: gradientFill ? 1 : 0.16,
1083
+ strokeWidth,
1084
+ dot: showDots ? { r: 3, fill: `var(--color-${item.key})`, strokeWidth: 0 } : false,
1085
+ activeDot: { r: 5, strokeWidth: 0 },
1086
+ isAnimationActive: true,
1087
+ animationDuration: 600,
1088
+ animationEasing: "ease-out"
1089
+ },
1090
+ item.key
1091
+ ))
1092
+ ] })
1093
+ }
1094
+ )
1095
+ ] });
1096
+ }
1097
+ function ComboMetricChart({
1098
+ data,
1099
+ config,
1100
+ indexKey = "name",
1101
+ series,
1102
+ colors,
1103
+ barSize = "md",
1104
+ showGrid = true,
1105
+ showLegend = true,
1106
+ gradientFill = false,
1107
+ curveType = "monotone",
1108
+ valueFormatter = formatTick,
1109
+ isLoading,
1110
+ error,
1111
+ onRetry,
1112
+ retryLabel,
1113
+ emptyTitle,
1114
+ emptyDescription,
1115
+ errorTitle,
1116
+ errorDescription,
1117
+ loadingLabel,
1118
+ stateClassName,
1119
+ className,
1120
+ ...props
1121
+ }) {
1122
+ const chartSeries = getChartSeries(config, series);
1123
+ const chartConfig = getChartConfigWithColors(
1124
+ config,
1125
+ chartSeries.map((item) => item.key),
1126
+ colors
1127
+ );
1128
+ const chartState = getChartState(
1129
+ {
1130
+ isLoading,
1131
+ error,
1132
+ onRetry,
1133
+ retryLabel,
1134
+ emptyTitle,
1135
+ emptyDescription,
1136
+ errorTitle,
1137
+ errorDescription,
1138
+ loadingLabel
1139
+ },
1140
+ hasChartData(data, chartSeries),
1141
+ cn("h-[340px] w-full", stateClassName)
1142
+ );
1143
+ if (chartState) {
1144
+ return chartState;
1145
+ }
1146
+ const areaSeries = gradientFill ? chartSeries.filter((s) => s.type === "area").map((s) => s.key) : [];
1147
+ return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: cn("h-[340px] w-full", className), ...props, children: /* @__PURE__ */ jsxs(RechartsPrimitive.ComposedChart, { data, accessibilityLayer: true, children: [
1148
+ gradientFill && areaSeries.length > 0 && /* @__PURE__ */ jsx(AreaGradientDefs, { seriesKeys: areaSeries, opacity: 0.35 }),
1149
+ showGrid ? /* @__PURE__ */ jsx(
1150
+ RechartsPrimitive.CartesianGrid,
1151
+ {
1152
+ vertical: false,
1153
+ strokeDasharray: "3 3",
1154
+ stroke: "var(--border)",
1155
+ strokeOpacity: 0.5
1156
+ }
1157
+ ) : null,
1158
+ /* @__PURE__ */ jsx(
1159
+ RechartsPrimitive.XAxis,
1160
+ {
1161
+ dataKey: indexKey,
1162
+ tickLine: false,
1163
+ axisLine: false,
1164
+ tickMargin: 8
1165
+ }
1166
+ ),
1167
+ /* @__PURE__ */ jsx(
1168
+ RechartsPrimitive.YAxis,
1169
+ {
1170
+ tickLine: false,
1171
+ axisLine: false,
1172
+ tickMargin: 8,
1173
+ tickFormatter: valueFormatter
1174
+ }
1175
+ ),
1176
+ /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
1177
+ showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }) : null,
1178
+ chartSeries.map(
1179
+ (item) => item.type === "line" ? /* @__PURE__ */ jsx(
1180
+ RechartsPrimitive.Line,
1181
+ {
1182
+ type: curveType,
1183
+ dataKey: item.key,
1184
+ stroke: `var(--color-${item.key})`,
1185
+ strokeWidth: 2,
1186
+ dot: false,
1187
+ activeDot: { r: 5, strokeWidth: 0 },
1188
+ yAxisId: item.yAxisId,
1189
+ isAnimationActive: true,
1190
+ animationDuration: 600,
1191
+ animationEasing: "ease-out"
1192
+ },
1193
+ item.key
1194
+ ) : item.type === "area" ? /* @__PURE__ */ jsx(
1195
+ RechartsPrimitive.Area,
1196
+ {
1197
+ type: curveType,
1198
+ dataKey: item.key,
1199
+ stroke: `var(--color-${item.key})`,
1200
+ fill: gradientFill ? `url(#gradient-${item.key})` : `var(--color-${item.key})`,
1201
+ fillOpacity: gradientFill ? 1 : 0.12,
1202
+ strokeWidth: 2,
1203
+ dot: false,
1204
+ activeDot: { r: 5, strokeWidth: 0 },
1205
+ yAxisId: item.yAxisId,
1206
+ isAnimationActive: true,
1207
+ animationDuration: 600,
1208
+ animationEasing: "ease-out"
1209
+ },
1210
+ item.key
1211
+ ) : /* @__PURE__ */ jsx(
1212
+ RechartsPrimitive.Bar,
1213
+ {
1214
+ dataKey: item.key,
1215
+ fill: `var(--color-${item.key})`,
1216
+ radius: [4, 4, 0, 0],
1217
+ barSize: getBarSize(barSize),
1218
+ yAxisId: item.yAxisId,
1219
+ isAnimationActive: true,
1220
+ animationDuration: 600,
1221
+ animationEasing: "ease-out"
1222
+ },
1223
+ item.key
1224
+ )
1225
+ )
1226
+ ] }) });
1227
+ }
1228
+ function DonutBreakdownChart({
1229
+ data,
1230
+ config,
1231
+ nameKey = "name",
1232
+ valueKey = "value",
1233
+ colors,
1234
+ centerLabel,
1235
+ centerValue,
1236
+ showLegend = true,
1237
+ innerRadius = "58%",
1238
+ outerRadius = "82%",
1239
+ isLoading,
1240
+ error,
1241
+ onRetry,
1242
+ retryLabel,
1243
+ emptyTitle,
1244
+ emptyDescription,
1245
+ errorTitle,
1246
+ errorDescription,
1247
+ loadingLabel,
1248
+ stateClassName,
1249
+ className,
1250
+ ...props
1251
+ }) {
1252
+ const [activeIndex, setActiveIndex] = React.useState(0);
1253
+ const chartKeys = data.map((entry, index) => String(entry[nameKey] || `segment-${index}`));
1254
+ const chartConfig = getChartConfigWithColors(config, chartKeys, colors);
1255
+ const chartState = getChartState(
1256
+ {
1257
+ isLoading,
1258
+ error,
1259
+ onRetry,
1260
+ retryLabel,
1261
+ emptyTitle,
1262
+ emptyDescription,
1263
+ errorTitle,
1264
+ errorDescription,
1265
+ loadingLabel
1266
+ },
1267
+ hasPieData(data, nameKey, valueKey),
1268
+ cn("h-[320px] w-full", stateClassName)
1269
+ );
1270
+ if (chartState) {
1271
+ return chartState;
1272
+ }
1273
+ return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: cn("h-[320px] w-full", className), ...props, children: /* @__PURE__ */ jsxs(RechartsPrimitive.PieChart, { accessibilityLayer: true, children: [
1274
+ /* @__PURE__ */ jsx(
1275
+ ChartTooltip,
1276
+ {
1277
+ cursor: false,
1278
+ content: /* @__PURE__ */ jsx(ChartTooltipContent, { hideLabel: true, nameKey })
1279
+ }
1280
+ ),
1281
+ showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, { nameKey }), verticalAlign: "bottom" }) : null,
1282
+ /* @__PURE__ */ jsxs(
1283
+ RechartsPrimitive.Pie,
1284
+ {
1285
+ data,
1286
+ dataKey: valueKey,
1287
+ nameKey,
1288
+ innerRadius,
1289
+ outerRadius,
1290
+ paddingAngle: 3,
1291
+ onMouseEnter: (_, index) => setActiveIndex(index),
1292
+ isAnimationActive: true,
1293
+ animationDuration: 600,
1294
+ animationEasing: "ease-out",
1295
+ children: [
1296
+ data.map((entry, index) => {
1297
+ const key = String(entry[nameKey] || `segment-${index}`);
1298
+ return /* @__PURE__ */ jsx(
1299
+ RechartsPrimitive.Cell,
1300
+ {
1301
+ fill: `var(--color-${key})`,
1302
+ opacity: index === activeIndex ? 1 : 0.7,
1303
+ stroke: "transparent"
1304
+ },
1305
+ key
1306
+ );
1307
+ }),
1308
+ centerValue || centerLabel ? /* @__PURE__ */ jsx(
1309
+ RechartsPrimitive.Label,
1310
+ {
1311
+ position: "center",
1312
+ content: ({ viewBox }) => {
1313
+ if (!viewBox || !("cx" in viewBox) || !("cy" in viewBox)) {
1314
+ return null;
1315
+ }
1316
+ return /* @__PURE__ */ jsxs("text", { x: viewBox.cx, y: viewBox.cy, textAnchor: "middle", dominantBaseline: "middle", children: [
1317
+ centerValue ? /* @__PURE__ */ jsx(
1318
+ "tspan",
1319
+ {
1320
+ x: viewBox.cx,
1321
+ y: viewBox.cy,
1322
+ className: "fill-foreground text-2xl font-semibold",
1323
+ children: centerValue
1324
+ }
1325
+ ) : null,
1326
+ centerLabel ? /* @__PURE__ */ jsx(
1327
+ "tspan",
1328
+ {
1329
+ x: viewBox.cx,
1330
+ y: Number(viewBox.cy) + 22,
1331
+ className: "fill-muted-foreground text-xs",
1332
+ children: centerLabel
1333
+ }
1334
+ ) : null
1335
+ ] });
1336
+ }
1337
+ }
1338
+ ) : null
1339
+ ]
1340
+ }
1341
+ )
1342
+ ] }) });
1343
+ }
1344
+ function SparklineChart({
1345
+ data,
1346
+ dataKey,
1347
+ color = "var(--chart-1)",
1348
+ filled = true,
1349
+ showEndDot = true,
1350
+ curveType = "monotone",
1351
+ strokeWidth = 2,
1352
+ className
1353
+ }) {
1354
+ const sparkId = React.useId().replace(/:/g, "");
1355
+ const lastPoint = data[data.length - 1];
1356
+ const lastValue = lastPoint ? lastPoint[dataKey] : void 0;
1357
+ return /* @__PURE__ */ jsxs("div", { className: cn("relative h-12 w-full min-w-0", className), children: [
1358
+ /* @__PURE__ */ jsx(RechartsPrimitive.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
1359
+ RechartsPrimitive.AreaChart,
1360
+ {
1361
+ data,
1362
+ margin: { top: 4, right: showEndDot ? 8 : 0, bottom: 0, left: 0 },
1363
+ children: [
1364
+ filled && /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: `spark-gradient-${sparkId}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
1365
+ /* @__PURE__ */ jsx("stop", { offset: "5%", stopColor: color, stopOpacity: 0.3 }),
1366
+ /* @__PURE__ */ jsx("stop", { offset: "95%", stopColor: color, stopOpacity: 0 })
1367
+ ] }) }),
1368
+ /* @__PURE__ */ jsx(
1369
+ RechartsPrimitive.Area,
1370
+ {
1371
+ type: curveType,
1372
+ dataKey,
1373
+ stroke: color,
1374
+ strokeWidth,
1375
+ fill: filled ? `url(#spark-gradient-${sparkId})` : "none",
1376
+ fillOpacity: 1,
1377
+ dot: false,
1378
+ activeDot: false,
1379
+ isAnimationActive: true,
1380
+ animationDuration: 600,
1381
+ animationEasing: "ease-out"
1382
+ }
1383
+ )
1384
+ ]
1385
+ }
1386
+ ) }),
1387
+ showEndDot && lastValue !== void 0 && lastValue !== null && /* @__PURE__ */ jsx(
1388
+ "div",
1389
+ {
1390
+ className: "pointer-events-none absolute right-0 top-1/2 h-2.5 w-2.5 -translate-y-1/2 rounded-full ring-2 ring-background",
1391
+ style: { backgroundColor: color }
1392
+ }
1393
+ )
1394
+ ] });
1395
+ }
1396
+ function RadarMetricChart({
1397
+ data,
1398
+ labelKey,
1399
+ series,
1400
+ colors,
1401
+ filled = true,
1402
+ fillOpacity = 0.25,
1403
+ showDots = false,
1404
+ showGrid = true,
1405
+ showLegend,
1406
+ valueFormatter,
1407
+ isLoading,
1408
+ error,
1409
+ onRetry,
1410
+ retryLabel,
1411
+ emptyTitle,
1412
+ emptyDescription,
1413
+ errorTitle,
1414
+ errorDescription,
1415
+ loadingLabel,
1416
+ stateClassName,
1417
+ className
1418
+ }) {
1419
+ const chartConfig = React.useMemo(
1420
+ () => buildChartConfig(
1421
+ series.map((s) => s.key),
1422
+ colors
1423
+ ),
1424
+ [series, colors]
1425
+ );
1426
+ const hasData = data.length > 0 && series.length > 0;
1427
+ const chartState = getChartState(
1428
+ {
1429
+ isLoading,
1430
+ error,
1431
+ emptyTitle,
1432
+ emptyDescription,
1433
+ errorTitle,
1434
+ errorDescription,
1435
+ loadingLabel,
1436
+ stateClassName,
1437
+ onRetry,
1438
+ retryLabel
1439
+ },
1440
+ hasData
1441
+ );
1442
+ const displayLegend = showLegend ?? series.length > 1;
1443
+ return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: cn("h-[300px] w-full", className), children: chartState ?? /* @__PURE__ */ jsxs(RechartsPrimitive.RadarChart, { data, accessibilityLayer: true, children: [
1444
+ showGrid && /* @__PURE__ */ jsx(RechartsPrimitive.PolarGrid, { stroke: "var(--border)", strokeOpacity: 0.6 }),
1445
+ /* @__PURE__ */ jsx(
1446
+ RechartsPrimitive.PolarAngleAxis,
1447
+ {
1448
+ dataKey: labelKey,
1449
+ tick: { fill: "var(--muted-foreground)", fontSize: 12 }
1450
+ }
1451
+ ),
1452
+ /* @__PURE__ */ jsx(
1453
+ RechartsPrimitive.PolarRadiusAxis,
1454
+ {
1455
+ tick: false,
1456
+ axisLine: false,
1457
+ tickFormatter: valueFormatter
1458
+ }
1459
+ ),
1460
+ /* @__PURE__ */ jsx(
1461
+ ChartTooltip,
1462
+ {
1463
+ content: /* @__PURE__ */ jsx(
1464
+ ChartTooltipContent,
1465
+ {
1466
+ formatter: valueFormatter ? (v) => valueFormatter(v) : void 0
1467
+ }
1468
+ )
1469
+ }
1470
+ ),
1471
+ displayLegend && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }),
1472
+ series.map((s) => /* @__PURE__ */ jsx(
1473
+ RechartsPrimitive.Radar,
1474
+ {
1475
+ name: s.label ?? s.key,
1476
+ dataKey: s.key,
1477
+ stroke: `var(--color-${s.key})`,
1478
+ fill: filled ? `var(--color-${s.key})` : "none",
1479
+ fillOpacity: filled ? fillOpacity : 0,
1480
+ dot: showDots ? { r: 3, fill: `var(--color-${s.key})` } : false,
1481
+ isAnimationActive: true,
1482
+ animationDuration: 600,
1483
+ animationEasing: "ease-out"
1484
+ },
1485
+ s.key
1486
+ ))
1487
+ ] }) });
1488
+ }
1489
+ function PieMetricChart({
1490
+ data,
1491
+ nameKey,
1492
+ valueKey,
1493
+ colors,
1494
+ outerRadius = "80%",
1495
+ innerRadius = 0,
1496
+ showLabels = false,
1497
+ showLegend = true,
1498
+ explodeIndex,
1499
+ explodeOffset = 12,
1500
+ valueFormatter,
1501
+ isLoading,
1502
+ error,
1503
+ onRetry,
1504
+ retryLabel,
1505
+ emptyTitle,
1506
+ emptyDescription,
1507
+ errorTitle,
1508
+ errorDescription,
1509
+ loadingLabel,
1510
+ stateClassName,
1511
+ className
1512
+ }) {
1513
+ const names = React.useMemo(() => data.map((d) => String(d[nameKey] ?? "")), [data, nameKey]);
1514
+ const chartConfig = React.useMemo(() => buildChartConfig(names, colors), [names, colors]);
1515
+ const hasData = hasPieData(data, nameKey, valueKey);
1516
+ const chartState = getChartState(
1517
+ {
1518
+ isLoading,
1519
+ error,
1520
+ emptyTitle,
1521
+ emptyDescription,
1522
+ errorTitle,
1523
+ errorDescription,
1524
+ loadingLabel,
1525
+ stateClassName,
1526
+ onRetry,
1527
+ retryLabel
1528
+ },
1529
+ hasData
1530
+ );
1531
+ return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: cn("h-[300px] w-full", className), children: chartState ?? /* @__PURE__ */ jsxs(RechartsPrimitive.PieChart, { accessibilityLayer: true, children: [
1532
+ /* @__PURE__ */ jsx(
1533
+ ChartTooltip,
1534
+ {
1535
+ content: /* @__PURE__ */ jsx(
1536
+ ChartTooltipContent,
1537
+ {
1538
+ nameKey,
1539
+ formatter: valueFormatter ? (v) => valueFormatter(v) : void 0
1540
+ }
1541
+ )
1542
+ }
1543
+ ),
1544
+ showLegend && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, { nameKey }) }),
1545
+ /* @__PURE__ */ jsx(
1546
+ RechartsPrimitive.Pie,
1547
+ {
1548
+ data,
1549
+ dataKey: valueKey,
1550
+ nameKey,
1551
+ outerRadius,
1552
+ innerRadius,
1553
+ paddingAngle: 2,
1554
+ label: showLabels ? ({ cx, cy, midAngle, innerRadius: ir, outerRadius: or, percent }) => {
1555
+ if (midAngle == null || percent == null) return null;
1556
+ const RADIAN = Math.PI / 180;
1557
+ const radius = Number(ir) + (Number(or) - Number(ir)) * 1.35;
1558
+ const x = Number(cx) + radius * Math.cos(-midAngle * RADIAN);
1559
+ const y = Number(cy) + radius * Math.sin(-midAngle * RADIAN);
1560
+ return percent > 0.04 ? /* @__PURE__ */ jsx(
1561
+ "text",
1562
+ {
1563
+ x,
1564
+ y,
1565
+ fill: "var(--foreground)",
1566
+ textAnchor: x > Number(cx) ? "start" : "end",
1567
+ dominantBaseline: "central",
1568
+ fontSize: 12,
1569
+ fontWeight: 500,
1570
+ children: `${(percent * 100).toFixed(0)}%`
1571
+ }
1572
+ ) : null;
1573
+ } : false,
1574
+ labelLine: false,
1575
+ isAnimationActive: true,
1576
+ animationDuration: 600,
1577
+ animationEasing: "ease-out",
1578
+ children: data.map((entry, index) => {
1579
+ const name = String(entry[nameKey] ?? "");
1580
+ const isExploded = index === explodeIndex;
1581
+ return /* @__PURE__ */ jsx(
1582
+ RechartsPrimitive.Cell,
1583
+ {
1584
+ fill: chartConfig[name]?.color ?? `var(--chart-${index % 8 + 1})`,
1585
+ stroke: "var(--background)",
1586
+ strokeWidth: 2,
1587
+ style: isExploded ? {
1588
+ filter: `drop-shadow(0 4px 8px color-mix(in srgb, ${chartConfig[name]?.color ?? "var(--chart-1)"} 40%, transparent))`
1589
+ } : void 0
1590
+ },
1591
+ `cell-${index}`
1592
+ );
1593
+ })
1594
+ }
1595
+ )
1596
+ ] }) });
1597
+ }
1598
+ function RadialBarMetricChart({
1599
+ data,
1600
+ dataKey = "value",
1601
+ nameKey = "name",
1602
+ colors,
1603
+ innerRadius = "30%",
1604
+ outerRadius = "100%",
1605
+ startAngle = 90,
1606
+ endAngle = -270,
1607
+ showBackground = true,
1608
+ showLegend = true,
1609
+ valueFormatter,
1610
+ isLoading,
1611
+ error,
1612
+ onRetry,
1613
+ retryLabel,
1614
+ emptyTitle,
1615
+ emptyDescription,
1616
+ errorTitle,
1617
+ errorDescription,
1618
+ loadingLabel,
1619
+ stateClassName,
1620
+ className
1621
+ }) {
1622
+ const names = React.useMemo(() => data.map((d) => String(d[nameKey] ?? "")), [data, nameKey]);
1623
+ const chartConfig = React.useMemo(() => buildChartConfig(names, colors), [names, colors]);
1624
+ const hasData = data.length > 0;
1625
+ const chartState = getChartState(
1626
+ {
1627
+ isLoading,
1628
+ error,
1629
+ emptyTitle,
1630
+ emptyDescription,
1631
+ errorTitle,
1632
+ errorDescription,
1633
+ loadingLabel,
1634
+ stateClassName,
1635
+ onRetry,
1636
+ retryLabel
1637
+ },
1638
+ hasData
1639
+ );
1640
+ const coloredData = React.useMemo(
1641
+ () => data.map((item, index) => {
1642
+ const name = String(item[nameKey] ?? "");
1643
+ return {
1644
+ ...item,
1645
+ fill: chartConfig[name]?.color ?? `var(--chart-${index % 8 + 1})`
1646
+ };
1647
+ }),
1648
+ [data, nameKey, chartConfig]
1649
+ );
1650
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex w-full flex-col gap-3", className), children: [
1651
+ /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: "h-[260px] w-full", children: chartState ?? /* @__PURE__ */ jsxs(
1652
+ RechartsPrimitive.RadialBarChart,
1653
+ {
1654
+ data: coloredData,
1655
+ innerRadius,
1656
+ outerRadius,
1657
+ startAngle,
1658
+ endAngle,
1659
+ accessibilityLayer: true,
1660
+ children: [
1661
+ /* @__PURE__ */ jsx(
1662
+ ChartTooltip,
1663
+ {
1664
+ cursor: false,
1665
+ content: /* @__PURE__ */ jsx(
1666
+ ChartTooltipContent,
1667
+ {
1668
+ nameKey,
1669
+ formatter: valueFormatter ? (v) => valueFormatter(v) : void 0
1670
+ }
1671
+ )
1672
+ }
1673
+ ),
1674
+ /* @__PURE__ */ jsx(
1675
+ RechartsPrimitive.RadialBar,
1676
+ {
1677
+ dataKey,
1678
+ background: showBackground ? { fill: "var(--muted)" } : false,
1679
+ cornerRadius: 6,
1680
+ isAnimationActive: true,
1681
+ animationDuration: 700,
1682
+ animationEasing: "ease-out"
1683
+ }
1684
+ )
1685
+ ]
1686
+ }
1687
+ ) }),
1688
+ showLegend && !chartState && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap justify-center gap-x-4 gap-y-1.5 px-2", children: coloredData.map((item, index) => {
1689
+ const d = item;
1690
+ const name = String(d[nameKey] ?? "");
1691
+ const fillColor = d.fill ?? `var(--chart-${index % 8 + 1})`;
1692
+ const val = d[dataKey];
1693
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
1694
+ /* @__PURE__ */ jsx(
1695
+ "span",
1696
+ {
1697
+ className: "inline-block h-2.5 w-2.5 shrink-0 rounded-full",
1698
+ style: { backgroundColor: fillColor }
1699
+ }
1700
+ ),
1701
+ /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
1702
+ name,
1703
+ val !== void 0 && val !== null && /* @__PURE__ */ jsx("span", { className: "ml-1 font-medium text-foreground", children: valueFormatter ? valueFormatter(val) : String(val) })
1704
+ ] })
1705
+ ] }, name);
1706
+ }) })
1707
+ ] });
1708
+ }
1709
+ function GaugeChart({
1710
+ value,
1711
+ min = 0,
1712
+ max = 100,
1713
+ thresholds,
1714
+ label,
1715
+ valueFormatter,
1716
+ showNeedle = true,
1717
+ className
1718
+ }) {
1719
+ const percent = Math.min(1, Math.max(0, (value - min) / (max - min)));
1720
+ const percentInt = Math.round(percent * 100);
1721
+ const activeColor = React.useMemo(() => {
1722
+ if (!thresholds || thresholds.length === 0) return "var(--chart-1)";
1723
+ for (const t of thresholds) {
1724
+ if (percentInt <= t.value) return t.color;
1725
+ }
1726
+ return thresholds[thresholds.length - 1].color;
1727
+ }, [thresholds, percentInt]);
1728
+ const displayText = valueFormatter ? valueFormatter(value, percentInt) : `${percentInt}%`;
1729
+ const cx = 100;
1730
+ const cy = 100;
1731
+ const R = 80;
1732
+ const r = 54;
1733
+ const polar = (angleDeg, radius) => {
1734
+ const rad = angleDeg * Math.PI / 180;
1735
+ return {
1736
+ x: cx + radius * Math.cos(rad),
1737
+ y: cy - radius * Math.sin(rad)
1738
+ };
1739
+ };
1740
+ const trackStart = polar(180, R);
1741
+ const trackEnd = polar(0, R);
1742
+ const trackStartI = polar(180, r);
1743
+ const trackEndI = polar(0, r);
1744
+ const trackPath = [
1745
+ `M ${trackStart.x} ${trackStart.y}`,
1746
+ `A ${R} ${R} 0 0 1 ${trackEnd.x} ${trackEnd.y}`,
1747
+ `L ${trackEndI.x} ${trackEndI.y}`,
1748
+ `A ${r} ${r} 0 0 0 ${trackStartI.x} ${trackStartI.y}`,
1749
+ "Z"
1750
+ ].join(" ");
1751
+ const valueAngle = 180 - percent * 180;
1752
+ const valueEnd = polar(valueAngle, R);
1753
+ const valueEndI = polar(valueAngle, r);
1754
+ const valuePath = percent <= 0 ? "" : percent >= 1 ? trackPath : [
1755
+ `M ${trackStart.x} ${trackStart.y}`,
1756
+ `A ${R} ${R} 0 0 1 ${valueEnd.x} ${valueEnd.y}`,
1757
+ `L ${valueEndI.x} ${valueEndI.y}`,
1758
+ `A ${r} ${r} 0 0 0 ${trackStartI.x} ${trackStartI.y}`,
1759
+ "Z"
1760
+ ].join(" ");
1761
+ const needleAngle = 180 - percent * 180;
1762
+ const needleTip = polar(needleAngle, r - 6);
1763
+ const needleBase1 = polar(needleAngle + 90, 5);
1764
+ const needleBase2 = polar(needleAngle - 90, 5);
1765
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col items-center gap-2", className), children: [
1766
+ /* @__PURE__ */ jsx("div", { className: "relative w-full max-w-[260px]", children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 200 130", className: "w-full", "aria-label": `Gauge: ${displayText}`, children: [
1767
+ /* @__PURE__ */ jsx("path", { d: trackPath, fill: "var(--muted)" }),
1768
+ valuePath && /* @__PURE__ */ jsx("path", { d: valuePath, fill: activeColor }),
1769
+ showNeedle && /* @__PURE__ */ jsxs("g", { children: [
1770
+ /* @__PURE__ */ jsx(
1771
+ "polygon",
1772
+ {
1773
+ points: `${needleTip.x},${needleTip.y} ${needleBase1.x},${needleBase1.y} ${needleBase2.x},${needleBase2.y}`,
1774
+ fill: "var(--foreground)",
1775
+ opacity: 0.85
1776
+ }
1777
+ ),
1778
+ /* @__PURE__ */ jsx("circle", { cx, cy, r: 5, fill: "var(--foreground)" })
1779
+ ] }),
1780
+ /* @__PURE__ */ jsx(
1781
+ "text",
1782
+ {
1783
+ x: cx,
1784
+ y: cy + 18,
1785
+ textAnchor: "middle",
1786
+ dominantBaseline: "middle",
1787
+ fontSize: 22,
1788
+ fontWeight: 700,
1789
+ fill: "currentColor",
1790
+ className: "fill-foreground",
1791
+ children: displayText
1792
+ }
1793
+ ),
1794
+ label && /* @__PURE__ */ jsx(
1795
+ "text",
1796
+ {
1797
+ x: cx,
1798
+ y: cy + 36,
1799
+ textAnchor: "middle",
1800
+ dominantBaseline: "middle",
1801
+ fontSize: 10,
1802
+ fill: "currentColor",
1803
+ className: "fill-muted-foreground",
1804
+ children: label
1805
+ }
1806
+ )
1807
+ ] }) }),
1808
+ thresholds && thresholds.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap justify-center gap-x-3 gap-y-1", children: thresholds.map((t, i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
1809
+ /* @__PURE__ */ jsx(
1810
+ "span",
1811
+ {
1812
+ className: "inline-block h-2 w-2 shrink-0 rounded-full",
1813
+ style: { backgroundColor: t.color }
1814
+ }
1815
+ ),
1816
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t.label })
1817
+ ] }, i)) })
1818
+ ] });
1819
+ }
1820
+
1821
+ function Table({ className, ...props }) {
1822
+ return /* @__PURE__ */ jsx("div", { "data-slot": "table-container", className: "relative w-full overflow-x-auto", children: /* @__PURE__ */ jsx(
1823
+ "table",
1824
+ {
1825
+ "data-slot": "table",
1826
+ className: cn("w-full caption-bottom text-sm", className),
1827
+ ...props
1828
+ }
1829
+ ) });
1830
+ }
1831
+ function TableHeader({ className, ...props }) {
1832
+ return /* @__PURE__ */ jsx("thead", { "data-slot": "table-header", className: cn("[&_tr]:border-b", className), ...props });
1833
+ }
1834
+ function TableBody({ className, ...props }) {
1835
+ return /* @__PURE__ */ jsx(
1836
+ "tbody",
1837
+ {
1838
+ "data-slot": "table-body",
1839
+ className: cn("[&_tr:last-child]:border-0", className),
1840
+ ...props
1841
+ }
1842
+ );
1843
+ }
1844
+ function TableFooter({ className, ...props }) {
1845
+ return /* @__PURE__ */ jsx(
1846
+ "tfoot",
1847
+ {
1848
+ "data-slot": "table-footer",
1849
+ className: cn("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0", className),
1850
+ ...props
1851
+ }
1852
+ );
1853
+ }
1854
+ function TableRow({ className, ...props }) {
1855
+ return /* @__PURE__ */ jsx(
1856
+ "tr",
1857
+ {
1858
+ "data-slot": "table-row",
1859
+ className: cn(
1860
+ "hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",
1861
+ className
1862
+ ),
1863
+ ...props
1864
+ }
1865
+ );
1866
+ }
1867
+ function TableHead({ className, ...props }) {
1868
+ return /* @__PURE__ */ jsx(
1869
+ "th",
1870
+ {
1871
+ "data-slot": "table-head",
1872
+ className: cn(
1873
+ "text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
1874
+ className
1875
+ ),
1876
+ ...props
1877
+ }
1878
+ );
1879
+ }
1880
+ function TableCell({ className, ...props }) {
1881
+ return /* @__PURE__ */ jsx(
1882
+ "td",
1883
+ {
1884
+ "data-slot": "table-cell",
1885
+ className: cn(
1886
+ "p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
1887
+ className
1888
+ ),
1889
+ ...props
1890
+ }
1891
+ );
1892
+ }
1893
+ function TableCaption({ className, ...props }) {
1894
+ return /* @__PURE__ */ jsx(
1895
+ "caption",
1896
+ {
1897
+ "data-slot": "table-caption",
1898
+ className: cn("text-muted-foreground mt-4 text-sm", className),
1899
+ ...props
1900
+ }
1901
+ );
1902
+ }
1903
+
1904
+ const Textarea = React.forwardRef(
1905
+ ({ className, size = "md", ...props }, ref) => {
1906
+ const sizeClasses = {
1907
+ sm: "px-2 py-1 text-sm",
1908
+ md: "px-3 py-2 text-base",
1909
+ lg: "px-4 py-3 text-base"
1910
+ };
1911
+ return /* @__PURE__ */ jsx(
1912
+ "textarea",
1913
+ {
1914
+ "data-slot": "textarea",
1915
+ className: cn(
1916
+ "flex min-h-16 w-full bg-background rounded-[var(--radius)] border border-input-stroke transition-colors outline-none resize-none text-foreground",
1917
+ "placeholder:text-muted-foreground",
1918
+ "focus:ring-2 focus:ring-primary focus:border-transparent",
1919
+ "disabled:cursor-not-allowed disabled:opacity-50",
1920
+ sizeClasses[size],
1921
+ className
1922
+ ),
1923
+ ref,
1924
+ ...props
1925
+ }
1926
+ );
1927
+ }
1928
+ );
1929
+ Textarea.displayName = "Textarea";
1930
+
1931
+ function Dialog({ ...props }) {
1932
+ return /* @__PURE__ */ jsx(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
1933
+ }
1934
+ function DialogTrigger({ ...props }) {
1935
+ return /* @__PURE__ */ jsx(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
1936
+ }
1937
+ function DialogPortal({ ...props }) {
1938
+ return /* @__PURE__ */ jsx(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
1939
+ }
1940
+ function DialogClose({ ...props }) {
1941
+ return /* @__PURE__ */ jsx(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
1942
+ }
1943
+ const DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1944
+ DialogPrimitive.Overlay,
1945
+ {
1946
+ ref,
1947
+ "data-slot": "dialog-overlay",
1948
+ className: cn(
1949
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/40 backdrop-blur-sm",
1950
+ className
1951
+ ),
1952
+ ...props
1953
+ }
1954
+ ));
1955
+ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
1956
+ const dialogVariants = cva(
1957
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 flex flex-col w-full translate-x-[-50%] translate-y-[-50%] border shadow-elevation-sm duration-200 rounded-[var(--radius-card)] overflow-hidden max-h-[calc(100dvh-2rem)]",
1958
+ {
1959
+ variants: {
1960
+ size: {
1961
+ sm: "max-w-sm",
1962
+ md: "max-w-md",
1963
+ lg: "max-w-lg",
1964
+ xl: "max-w-xl",
1965
+ "2xl": "max-w-2xl",
1966
+ "3xl": "max-w-3xl",
1967
+ "4xl": "max-w-4xl",
1968
+ "5xl": "max-w-5xl",
1969
+ full: "max-w-[calc(100vw-2rem)] h-[calc(100dvh-2rem)]"
1970
+ }
1971
+ },
1972
+ defaultVariants: {
1973
+ size: "lg"
1974
+ }
1975
+ }
1976
+ );
1977
+ const DialogContent = React.forwardRef(({ className, children, size, showClose = true, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [
1978
+ /* @__PURE__ */ jsx(DialogOverlay, {}),
1979
+ /* @__PURE__ */ jsxs(
1980
+ DialogPrimitive.Content,
1981
+ {
1982
+ ref,
1983
+ "data-slot": "dialog-content",
1984
+ className: cn(dialogVariants({ size }), className),
1985
+ ...props,
1986
+ children: [
1987
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4 p-6 overflow-y-auto flex-1 min-h-0", children }),
1988
+ showClose && /* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute top-4 right-4 z-10 rounded-full p-2 opacity-70 transition-all hover:opacity-100 hover:bg-accent focus:ring-2 focus:ring-primary focus:ring-offset-2 focus:outline-none disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", children: [
1989
+ /* @__PURE__ */ jsx(XIcon, {}),
1990
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
1991
+ ] })
1992
+ ]
1993
+ }
1994
+ )
1995
+ ] }));
1996
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
1997
+ function DialogHeader({ className, ...props }) {
1998
+ return /* @__PURE__ */ jsx(
1999
+ "div",
2000
+ {
2001
+ "data-slot": "dialog-header",
2002
+ className: cn("flex flex-col gap-2 text-left shrink-0", className),
2003
+ ...props
2004
+ }
2005
+ );
2006
+ }
2007
+ function DialogBody({ className, ...props }) {
2008
+ return /* @__PURE__ */ jsx(
2009
+ "div",
2010
+ {
2011
+ "data-slot": "dialog-body",
2012
+ className: cn("flex-1 overflow-y-auto min-h-0 -mx-6 px-6", className),
2013
+ ...props
2014
+ }
2015
+ );
2016
+ }
2017
+ function DialogFooter({ className, ...props }) {
2018
+ return /* @__PURE__ */ jsx(
2019
+ "div",
2020
+ {
2021
+ "data-slot": "dialog-footer",
2022
+ className: cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end shrink-0", className),
2023
+ ...props
2024
+ }
2025
+ );
2026
+ }
2027
+ function DialogTitle({ className, ...props }) {
2028
+ return /* @__PURE__ */ jsx(
2029
+ DialogPrimitive.Title,
2030
+ {
2031
+ "data-slot": "dialog-title",
2032
+ className: cn(
2033
+ "text-foreground font-semibold leading-tight text-[length:var(--text-h4)]",
2034
+ className
2035
+ ),
2036
+ ...props
2037
+ }
2038
+ );
2039
+ }
2040
+ function DialogDescription({
2041
+ className,
2042
+ ...props
2043
+ }) {
2044
+ return /* @__PURE__ */ jsx(
2045
+ DialogPrimitive.Description,
2046
+ {
2047
+ "data-slot": "dialog-description",
2048
+ className: cn("text-muted-foreground", className),
2049
+ ...props
2050
+ }
2051
+ );
2052
+ }
2053
+
2054
+ function useRichTextEditor({
2055
+ value,
2056
+ onChange
2057
+ }) {
2058
+ const editorRef = useRef(null);
2059
+ const searchInputRef = useRef(null);
2060
+ const linkInputRef = useRef(null);
2061
+ const savedSelection = useRef(null);
2062
+ const [wordCount, setWordCount] = useState(0);
2063
+ const [characterCount, setCharacterCount] = useState(0);
2064
+ const [activeFormats, setActiveFormats] = useState({
2065
+ bold: false,
2066
+ italic: false,
2067
+ underline: false,
2068
+ justifyLeft: false,
2069
+ justifyCenter: false,
2070
+ justifyRight: false,
2071
+ insertUnorderedList: false,
2072
+ insertOrderedList: false,
2073
+ link: false,
2074
+ h1: false,
2075
+ h2: false,
2076
+ h3: false,
2077
+ p: true
2078
+ });
2079
+ const [isSearchOpen, setIsSearchOpen] = useState(false);
2080
+ const [searchQuery, setSearchQuery] = useState("");
2081
+ const [linkUrl, setLinkUrl] = useState("https://");
2082
+ const [isLinkOpen, setIsLinkOpen] = useState(false);
2083
+ const [hasSavedSelection, setHasSavedSelection] = useState(false);
2084
+ const findParentTag = useCallback((node, tagName) => {
2085
+ let current = node;
2086
+ while (current && current !== editorRef.current) {
2087
+ if (current.nodeName === tagName) return current;
2088
+ current = current.parentNode;
2089
+ }
2090
+ return null;
2091
+ }, []);
2092
+ const updateActiveFormats = useCallback(() => {
2093
+ let formatBlock = "";
2094
+ try {
2095
+ formatBlock = document.queryCommandValue("formatBlock");
2096
+ } catch (_e) {
2097
+ }
2098
+ const selection = window.getSelection();
2099
+ const anchorNode = selection?.anchorNode;
2100
+ const focusNode = selection?.focusNode;
2101
+ setActiveFormats({
2102
+ bold: document.queryCommandState("bold"),
2103
+ italic: document.queryCommandState("italic"),
2104
+ underline: document.queryCommandState("underline"),
2105
+ justifyLeft: document.queryCommandState("justifyLeft"),
2106
+ justifyCenter: document.queryCommandState("justifyCenter"),
2107
+ justifyRight: document.queryCommandState("justifyRight"),
2108
+ insertUnorderedList: document.queryCommandState("insertUnorderedList"),
2109
+ insertOrderedList: document.queryCommandState("insertOrderedList"),
2110
+ link: !!(findParentTag(anchorNode || null, "A") || findParentTag(focusNode || null, "A")),
2111
+ h1: formatBlock === "h1" || formatBlock === "H1",
2112
+ h2: formatBlock === "h2" || formatBlock === "H2",
2113
+ h3: formatBlock === "h3" || formatBlock === "H3",
2114
+ p: formatBlock === "p" || formatBlock === "P" || formatBlock === "div" || formatBlock === "DIV" || formatBlock === ""
2115
+ });
2116
+ }, [findParentTag]);
2117
+ const updateActiveFormatsRef = useRef(updateActiveFormats);
2118
+ useEffect(() => {
2119
+ updateActiveFormatsRef.current = updateActiveFormats;
2120
+ }, [updateActiveFormats]);
2121
+ useEffect(() => {
2122
+ if (editorRef.current && editorRef.current.innerHTML !== value) {
2123
+ editorRef.current.innerHTML = value;
2124
+ }
2125
+ const handleSelectionChange = () => {
2126
+ if (document.activeElement === editorRef.current) {
2127
+ updateActiveFormatsRef.current();
2128
+ }
2129
+ };
2130
+ document.addEventListener("selectionchange", handleSelectionChange);
2131
+ return () => document.removeEventListener("selectionchange", handleSelectionChange);
2132
+ }, []);
2133
+ useEffect(() => {
2134
+ const text = editorRef.current?.innerText || "";
2135
+ setWordCount(text.trim() ? text.trim().split(/\s+/).length : 0);
2136
+ setCharacterCount(text.trim() ? text.length : 0);
2137
+ }, [value]);
2138
+ const handleInput = useCallback(() => {
2139
+ if (editorRef.current) {
2140
+ onChange?.(editorRef.current.innerHTML);
2141
+ updateActiveFormats();
2142
+ const text = editorRef.current.innerText || "";
2143
+ setWordCount(text.trim() ? text.trim().split(/\s+/).length : 0);
2144
+ setCharacterCount(text.trim() ? text.length : 0);
2145
+ }
2146
+ }, [onChange, updateActiveFormats]);
2147
+ const execCommand = useCallback(
2148
+ (command, val = "") => {
2149
+ document.execCommand(command, false, val);
2150
+ updateActiveFormats();
2151
+ editorRef.current?.focus();
2152
+ if (editorRef.current) {
2153
+ onChange?.(editorRef.current.innerHTML);
2154
+ }
2155
+ },
2156
+ [onChange, updateActiveFormats]
2157
+ );
2158
+ const performSearch = useCallback((text, backward = false) => {
2159
+ if (!text || !editorRef.current) return;
2160
+ const editor = editorRef.current;
2161
+ const selection = window.getSelection();
2162
+ if (!selection) return;
2163
+ const walker = document.createTreeWalker(editor, NodeFilter.SHOW_TEXT);
2164
+ const segments = [];
2165
+ let offset = 0;
2166
+ let node;
2167
+ while (node = walker.nextNode()) {
2168
+ segments.push({ node, start: offset });
2169
+ offset += node.length;
2170
+ }
2171
+ const fullText = segments.reduce((acc, s) => acc + (s.node.textContent ?? ""), "");
2172
+ let searchFrom = 0;
2173
+ if (selection.rangeCount > 0) {
2174
+ const range2 = selection.getRangeAt(0);
2175
+ if (editor.contains(range2.startContainer)) {
2176
+ const seg = segments.find((s) => s.node === range2.startContainer);
2177
+ if (seg) {
2178
+ searchFrom = backward ? seg.start + range2.startOffset - 1 : seg.start + range2.endOffset;
2179
+ }
2180
+ }
2181
+ }
2182
+ const lowerFull = fullText.toLowerCase();
2183
+ const lowerQuery = text.toLowerCase();
2184
+ let matchStart = -1;
2185
+ if (backward) {
2186
+ matchStart = lowerFull.lastIndexOf(lowerQuery, Math.max(0, searchFrom));
2187
+ if (matchStart === -1) matchStart = lowerFull.lastIndexOf(lowerQuery);
2188
+ } else {
2189
+ matchStart = lowerFull.indexOf(lowerQuery, searchFrom);
2190
+ if (matchStart === -1) matchStart = lowerFull.indexOf(lowerQuery);
2191
+ }
2192
+ if (matchStart === -1) return;
2193
+ const matchEnd = matchStart + text.length;
2194
+ const range = document.createRange();
2195
+ let startSet = false;
2196
+ let endSet = false;
2197
+ for (let i = 0; i < segments.length && !endSet; i++) {
2198
+ const seg = segments[i];
2199
+ const segEnd = seg.start + seg.node.length;
2200
+ if (!startSet && matchStart < segEnd && matchStart >= seg.start) {
2201
+ range.setStart(seg.node, matchStart - seg.start);
2202
+ startSet = true;
2203
+ }
2204
+ if (startSet && matchEnd <= segEnd) {
2205
+ range.setEnd(seg.node, matchEnd - seg.start);
2206
+ endSet = true;
2207
+ }
2208
+ }
2209
+ if (startSet && endSet) {
2210
+ selection.removeAllRanges();
2211
+ selection.addRange(range);
2212
+ range.startContainer.parentElement?.scrollIntoView?.({ block: "nearest" });
2213
+ }
2214
+ }, []);
2215
+ const handleCreateLink = useCallback(() => {
2216
+ if (savedSelection.current) {
2217
+ const selection2 = window.getSelection();
2218
+ selection2?.removeAllRanges();
2219
+ selection2?.addRange(savedSelection.current);
2220
+ }
2221
+ const selection = window.getSelection();
2222
+ const anchorNode = selection?.anchorNode;
2223
+ const existingLink = findParentTag(anchorNode || null, "A");
2224
+ if (existingLink) {
2225
+ if (linkUrl) {
2226
+ existingLink.setAttribute("href", linkUrl);
2227
+ existingLink.setAttribute("target", "_blank");
2228
+ existingLink.setAttribute("rel", "noopener noreferrer");
2229
+ existingLink.style.color = "hsl(var(--primary))";
2230
+ existingLink.style.textDecoration = "underline";
2231
+ existingLink.style.cursor = "pointer";
2232
+ }
2233
+ handleInput();
2234
+ setIsLinkOpen(false);
2235
+ savedSelection.current = null;
2236
+ return;
2237
+ }
2238
+ if (!selection || selection.rangeCount === 0 || selection.isCollapsed) {
2239
+ return;
2240
+ }
2241
+ if (linkUrl) {
2242
+ document.execCommand("createLink", false, linkUrl);
2243
+ setTimeout(() => {
2244
+ const anchor = findParentTag(window.getSelection()?.anchorNode || null, "A");
2245
+ if (anchor) {
2246
+ anchor.setAttribute("target", "_blank");
2247
+ anchor.setAttribute("rel", "noopener noreferrer");
2248
+ anchor.style.color = "hsl(var(--primary))";
2249
+ anchor.style.textDecoration = "underline";
2250
+ anchor.style.cursor = "pointer";
2251
+ }
2252
+ handleInput();
2253
+ }, 10);
2254
+ setIsLinkOpen(false);
2255
+ savedSelection.current = null;
2256
+ }
2257
+ }, [linkUrl, findParentTag, handleInput]);
2258
+ const handleUnlink = useCallback(() => {
2259
+ const selection = window.getSelection();
2260
+ const anchorNode = selection?.anchorNode;
2261
+ const existingLink = findParentTag(anchorNode || null, "A");
2262
+ if (existingLink) {
2263
+ const parent = existingLink.parentNode;
2264
+ while (existingLink.firstChild) {
2265
+ parent?.insertBefore(existingLink.firstChild, existingLink);
2266
+ }
2267
+ parent?.removeChild(existingLink);
2268
+ handleInput();
2269
+ } else {
2270
+ document.execCommand("unlink", false, "");
2271
+ }
2272
+ }, [findParentTag, handleInput]);
2273
+ const onLinkPopoverOpenChange = useCallback(
2274
+ (open) => {
2275
+ if (open) {
2276
+ const selection = window.getSelection();
2277
+ const anchorNode = selection?.anchorNode;
2278
+ const focusNode = selection?.focusNode;
2279
+ const existingLink = findParentTag(anchorNode || null, "A") || findParentTag(focusNode || null, "A");
2280
+ if (existingLink) {
2281
+ setLinkUrl(existingLink.getAttribute("href") || "https://");
2282
+ } else {
2283
+ setLinkUrl("https://");
2284
+ }
2285
+ if (selection && selection.rangeCount > 0 && (!selection.isCollapsed || existingLink)) {
2286
+ savedSelection.current = selection.getRangeAt(0).cloneRange();
2287
+ setHasSavedSelection(true);
2288
+ } else {
2289
+ savedSelection.current = null;
2290
+ setHasSavedSelection(false);
2291
+ }
2292
+ setTimeout(() => linkInputRef.current?.focus(), 100);
2293
+ } else {
2294
+ setHasSavedSelection(false);
2295
+ }
2296
+ setIsLinkOpen(open);
2297
+ },
2298
+ [findParentTag]
2299
+ );
2300
+ return {
2301
+ // Refs
2302
+ editorRef,
2303
+ searchInputRef,
2304
+ linkInputRef,
2305
+ // State
2306
+ activeFormats,
2307
+ isSearchOpen,
2308
+ setIsSearchOpen,
2309
+ searchQuery,
2310
+ setSearchQuery,
2311
+ linkUrl,
2312
+ setLinkUrl,
2313
+ isLinkOpen,
2314
+ hasSavedSelection,
2315
+ // Computed
2316
+ wordCount,
2317
+ characterCount,
2318
+ // Handlers
2319
+ updateActiveFormats,
2320
+ execCommand,
2321
+ handleInput,
2322
+ performSearch,
2323
+ handleCreateLink,
2324
+ handleUnlink,
2325
+ onLinkPopoverOpenChange
2326
+ };
2327
+ }
2328
+
2329
+ function RichTextEditor({
2330
+ value,
2331
+ onChange,
2332
+ placeholder,
2333
+ className,
2334
+ actionButton,
2335
+ allowSearch = true,
2336
+ allowLinks = true,
2337
+ allowUndoRedo = true,
2338
+ allowHeadings = true,
2339
+ allowFormatting = true,
2340
+ allowAlignment = true,
2341
+ allowLists = true,
2342
+ showWordCount = true,
2343
+ showCharacterCount = true,
2344
+ disabled = false,
2345
+ readOnly = false,
2346
+ onFocus,
2347
+ onBlur,
2348
+ minHeight,
2349
+ maxHeight
2350
+ }) {
2351
+ const isEditable = !disabled && !readOnly;
2352
+ const showToolbar = isEditable;
2353
+ const {
2354
+ editorRef,
2355
+ searchInputRef,
2356
+ linkInputRef,
2357
+ activeFormats,
2358
+ isSearchOpen,
2359
+ setIsSearchOpen,
2360
+ searchQuery,
2361
+ setSearchQuery,
2362
+ linkUrl,
2363
+ setLinkUrl,
2364
+ isLinkOpen,
2365
+ hasSavedSelection,
2366
+ wordCount,
2367
+ characterCount,
2368
+ updateActiveFormats,
2369
+ execCommand,
2370
+ handleInput,
2371
+ performSearch,
2372
+ handleCreateLink,
2373
+ handleUnlink,
2374
+ onLinkPopoverOpenChange
2375
+ } = useRichTextEditor({ value, onChange });
2376
+ const getCurrentBlockLabel = () => {
2377
+ if (activeFormats.h1)
2378
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2379
+ /* @__PURE__ */ jsx(Heading1, { className: "w-4 h-4 mr-1 shrink-0" }),
2380
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: "Título 1" })
2381
+ ] });
2382
+ if (activeFormats.h2)
2383
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2384
+ /* @__PURE__ */ jsx(Heading2, { className: "w-4 h-4 mr-1 shrink-0" }),
2385
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: "Título 2" })
2386
+ ] });
2387
+ if (activeFormats.h3)
2388
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2389
+ /* @__PURE__ */ jsx(Heading3, { className: "w-4 h-4 mr-1 shrink-0" }),
2390
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: "Título 3" })
2391
+ ] });
2392
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2393
+ /* @__PURE__ */ jsx(Type, { className: "w-4 h-4 mr-1 shrink-0" }),
2394
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: "Parágrafo" })
2395
+ ] });
2396
+ };
2397
+ return /* @__PURE__ */ jsxs(
2398
+ "div",
2399
+ {
2400
+ className: cn(
2401
+ "flex flex-col h-full w-full bg-background sm:border border-border sm:shadow-sm sm:rounded-lg overflow-hidden",
2402
+ disabled && "opacity-50 pointer-events-none",
2403
+ className
2404
+ ),
2405
+ children: [
2406
+ /* @__PURE__ */ jsx("style", { children: `
2407
+ [contenteditable]:empty:before {
2408
+ content: attr(data-placeholder);
2409
+ color: hsl(var(--muted-foreground));
2410
+ pointer-events: none;
2411
+ display: block;
2412
+ }
2413
+ .prose-editor ul {
2414
+ list-style-type: disc !important;
2415
+ padding-left: 1.5rem !important;
2416
+ margin-top: 0.5rem !important;
2417
+ margin-bottom: 0.5rem !important;
2418
+ }
2419
+ .prose-editor ol {
2420
+ list-style-type: decimal !important;
2421
+ padding-left: 1.5rem !important;
2422
+ margin-top: 0.5rem !important;
2423
+ margin-bottom: 0.5rem !important;
2424
+ }
2425
+ .prose-editor b, .prose-editor strong {
2426
+ font-weight: 600 !important;
2427
+ }
2428
+ .prose-editor i, .prose-editor em {
2429
+ font-style: italic !important;
2430
+ }
2431
+ .prose-editor u {
2432
+ text-decoration: underline !important;
2433
+ }
2434
+ .prose-editor h1 {
2435
+ font-size: 2.25rem !important;
2436
+ font-weight: 700 !important;
2437
+ margin-bottom: 1.25rem !important;
2438
+ line-height: 1.2 !important;
2439
+ margin-top: 2rem !important;
2440
+ color: hsl(var(--foreground));
2441
+ }
2442
+ .prose-editor h2 {
2443
+ font-size: 1.75rem !important;
2444
+ font-weight: 600 !important;
2445
+ margin-bottom: 1rem !important;
2446
+ margin-top: 1.5rem !important;
2447
+ color: hsl(var(--foreground));
2448
+ }
2449
+ .prose-editor h3 {
2450
+ font-size: 1.35rem !important;
2451
+ font-weight: 600 !important;
2452
+ margin-bottom: 0.75rem !important;
2453
+ margin-top: 1.25rem !important;
2454
+ color: hsl(var(--foreground));
2455
+ }
2456
+ .prose-editor p {
2457
+ margin-bottom: 1rem !important;
2458
+ line-height: 1.6 !important;
2459
+ }
2460
+ .prose-editor a {
2461
+ color: var(--info) !important;
2462
+ text-decoration: underline !important;
2463
+ cursor: pointer !important;
2464
+ }
2465
+ .prose-editor h1:first-child, .prose-editor h2:first-child, .prose-editor h3:first-child, .prose-editor p:first-child {
2466
+ margin-top: 0 !important;
2467
+ }
2468
+ .prose-editor {
2469
+ outline: none !important;
2470
+ }
2471
+ ` }),
2472
+ showToolbar && /* @__PURE__ */ jsxs("div", { className: "px-3 py-2 border-b border-border bg-muted/30 flex items-center gap-1 flex-wrap shrink-0", children: [
2473
+ allowUndoRedo && /* @__PURE__ */ jsxs(Fragment, { children: [
2474
+ /* @__PURE__ */ jsx(
2475
+ Button,
2476
+ {
2477
+ variant: "ghost",
2478
+ size: "icon",
2479
+ className: "h-8 w-8 text-muted-foreground",
2480
+ onClick: () => execCommand("undo"),
2481
+ title: "Desfazer",
2482
+ "aria-label": "Desfazer",
2483
+ children: /* @__PURE__ */ jsx(Undo, { className: "w-4 h-4" })
2484
+ }
2485
+ ),
2486
+ /* @__PURE__ */ jsx(
2487
+ Button,
2488
+ {
2489
+ variant: "ghost",
2490
+ size: "icon",
2491
+ className: "h-8 w-8 text-muted-foreground",
2492
+ onClick: () => execCommand("redo"),
2493
+ title: "Refazer",
2494
+ "aria-label": "Refazer",
2495
+ children: /* @__PURE__ */ jsx(Redo, { className: "w-4 h-4" })
2496
+ }
2497
+ ),
2498
+ /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
2499
+ ] }),
2500
+ allowHeadings && /* @__PURE__ */ jsxs(Fragment, { children: [
2501
+ /* @__PURE__ */ jsxs(DropdownMenu, { modal: false, children: [
2502
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
2503
+ Button,
2504
+ {
2505
+ variant: "ghost",
2506
+ size: "sm",
2507
+ className: "h-8 gap-0 text-muted-foreground w-[120px] justify-start px-2",
2508
+ children: [
2509
+ getCurrentBlockLabel(),
2510
+ /* @__PURE__ */ jsx(ChevronDown, { className: "w-3 h-3 ml-auto opacity-50 shrink-0" })
2511
+ ]
2512
+ }
2513
+ ) }),
2514
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "start", className: "w-[160px]", style: { zIndex: 9999 }, children: [
2515
+ /* @__PURE__ */ jsxs(
2516
+ DropdownMenuItem,
2517
+ {
2518
+ onPointerDown: (e) => e.preventDefault(),
2519
+ onClick: () => execCommand("formatBlock", "P"),
2520
+ className: "gap-2",
2521
+ children: [
2522
+ /* @__PURE__ */ jsx(Type, { className: "w-4 h-4 text-muted-foreground" }),
2523
+ " Parágrafo"
2524
+ ]
2525
+ }
2526
+ ),
2527
+ /* @__PURE__ */ jsxs(
2528
+ DropdownMenuItem,
2529
+ {
2530
+ onPointerDown: (e) => e.preventDefault(),
2531
+ onClick: () => execCommand("formatBlock", "H1"),
2532
+ className: "gap-2",
2533
+ children: [
2534
+ /* @__PURE__ */ jsx(Heading1, { className: "w-4 h-4 text-muted-foreground" }),
2535
+ " Título 1"
2536
+ ]
2537
+ }
2538
+ ),
2539
+ /* @__PURE__ */ jsxs(
2540
+ DropdownMenuItem,
2541
+ {
2542
+ onPointerDown: (e) => e.preventDefault(),
2543
+ onClick: () => execCommand("formatBlock", "H2"),
2544
+ className: "gap-2",
2545
+ children: [
2546
+ /* @__PURE__ */ jsx(Heading2, { className: "w-4 h-4 text-muted-foreground" }),
2547
+ " Título 2"
2548
+ ]
2549
+ }
2550
+ ),
2551
+ /* @__PURE__ */ jsxs(
2552
+ DropdownMenuItem,
2553
+ {
2554
+ onPointerDown: (e) => e.preventDefault(),
2555
+ onClick: () => execCommand("formatBlock", "H3"),
2556
+ className: "gap-2",
2557
+ children: [
2558
+ /* @__PURE__ */ jsx(Heading3, { className: "w-4 h-4 text-muted-foreground" }),
2559
+ " Título 3"
2560
+ ]
2561
+ }
2562
+ )
2563
+ ] })
2564
+ ] }),
2565
+ /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
2566
+ ] }),
2567
+ allowFormatting && /* @__PURE__ */ jsxs(Fragment, { children: [
2568
+ /* @__PURE__ */ jsx(
2569
+ Button,
2570
+ {
2571
+ variant: "ghost",
2572
+ size: "icon",
2573
+ className: cn(
2574
+ "h-8 w-8 text-muted-foreground",
2575
+ activeFormats.bold && "bg-muted text-foreground"
2576
+ ),
2577
+ onClick: () => execCommand("bold"),
2578
+ title: "Negrito",
2579
+ "aria-label": "Negrito",
2580
+ children: /* @__PURE__ */ jsx(Bold, { className: "w-4 h-4" })
2581
+ }
2582
+ ),
2583
+ /* @__PURE__ */ jsx(
2584
+ Button,
2585
+ {
2586
+ variant: "ghost",
2587
+ size: "icon",
2588
+ className: cn(
2589
+ "h-8 w-8 text-muted-foreground",
2590
+ activeFormats.italic && "bg-muted text-foreground"
2591
+ ),
2592
+ onClick: () => execCommand("italic"),
2593
+ title: "Itálico",
2594
+ "aria-label": "Itálico",
2595
+ children: /* @__PURE__ */ jsx(Italic, { className: "w-4 h-4" })
2596
+ }
2597
+ ),
2598
+ /* @__PURE__ */ jsx(
2599
+ Button,
2600
+ {
2601
+ variant: "ghost",
2602
+ size: "icon",
2603
+ className: cn(
2604
+ "h-8 w-8 text-muted-foreground",
2605
+ activeFormats.underline && "bg-muted text-foreground"
2606
+ ),
2607
+ onClick: () => execCommand("underline"),
2608
+ title: "Sublinhado",
2609
+ "aria-label": "Sublinhado",
2610
+ children: /* @__PURE__ */ jsx(Underline, { className: "w-4 h-4" })
2611
+ }
2612
+ ),
2613
+ /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
2614
+ ] }),
2615
+ allowAlignment && /* @__PURE__ */ jsxs(Fragment, { children: [
2616
+ /* @__PURE__ */ jsx(
2617
+ Button,
2618
+ {
2619
+ variant: "ghost",
2620
+ size: "icon",
2621
+ className: cn(
2622
+ "h-8 w-8 text-muted-foreground",
2623
+ activeFormats.justifyLeft && "bg-muted text-foreground"
2624
+ ),
2625
+ onClick: () => execCommand("justifyLeft"),
2626
+ title: "Alinhar à esquerda",
2627
+ "aria-label": "Alinhar à esquerda",
2628
+ children: /* @__PURE__ */ jsx(AlignLeft, { className: "w-4 h-4" })
2629
+ }
2630
+ ),
2631
+ /* @__PURE__ */ jsx(
2632
+ Button,
2633
+ {
2634
+ variant: "ghost",
2635
+ size: "icon",
2636
+ className: cn(
2637
+ "h-8 w-8 text-muted-foreground",
2638
+ activeFormats.justifyCenter && "bg-muted text-foreground"
2639
+ ),
2640
+ onClick: () => execCommand("justifyCenter"),
2641
+ title: "Centralizar",
2642
+ "aria-label": "Centralizar",
2643
+ children: /* @__PURE__ */ jsx(AlignCenter, { className: "w-4 h-4" })
2644
+ }
2645
+ ),
2646
+ /* @__PURE__ */ jsx(
2647
+ Button,
2648
+ {
2649
+ variant: "ghost",
2650
+ size: "icon",
2651
+ className: cn(
2652
+ "h-8 w-8 text-muted-foreground",
2653
+ activeFormats.justifyRight && "bg-muted text-foreground"
2654
+ ),
2655
+ onClick: () => execCommand("justifyRight"),
2656
+ title: "Alinhar à direita",
2657
+ "aria-label": "Alinhar à direita",
2658
+ children: /* @__PURE__ */ jsx(AlignRight, { className: "w-4 h-4" })
2659
+ }
2660
+ ),
2661
+ /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
2662
+ ] }),
2663
+ allowLists && /* @__PURE__ */ jsxs(Fragment, { children: [
2664
+ /* @__PURE__ */ jsx(
2665
+ Button,
2666
+ {
2667
+ variant: "ghost",
2668
+ size: "icon",
2669
+ className: cn(
2670
+ "h-8 w-8 text-muted-foreground",
2671
+ activeFormats.insertUnorderedList && "bg-muted text-foreground"
2672
+ ),
2673
+ onClick: () => execCommand("insertUnorderedList"),
2674
+ title: "Lista com marcadores",
2675
+ "aria-label": "Lista com marcadores",
2676
+ children: /* @__PURE__ */ jsx(List, { className: "w-4 h-4" })
2677
+ }
2678
+ ),
2679
+ /* @__PURE__ */ jsx(
2680
+ Button,
2681
+ {
2682
+ variant: "ghost",
2683
+ size: "icon",
2684
+ className: cn(
2685
+ "h-8 w-8 text-muted-foreground",
2686
+ activeFormats.insertOrderedList && "bg-muted text-foreground"
2687
+ ),
2688
+ onClick: () => execCommand("insertOrderedList"),
2689
+ title: "Lista numerada",
2690
+ "aria-label": "Lista numerada",
2691
+ children: /* @__PURE__ */ jsx(ListOrdered, { className: "w-4 h-4" })
2692
+ }
2693
+ ),
2694
+ /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
2695
+ ] }),
2696
+ allowLinks && /* @__PURE__ */ jsxs(Fragment, { children: [
2697
+ /* @__PURE__ */ jsxs(Popover, { open: isLinkOpen, onOpenChange: onLinkPopoverOpenChange, modal: false, children: [
2698
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
2699
+ Button,
2700
+ {
2701
+ variant: "ghost",
2702
+ size: "icon",
2703
+ className: cn(
2704
+ "h-8 w-8 text-muted-foreground",
2705
+ (activeFormats.link || isLinkOpen) && "bg-muted text-foreground"
2706
+ ),
2707
+ title: "Inserir link",
2708
+ "aria-label": "Inserir link",
2709
+ children: /* @__PURE__ */ jsx(Link, { className: "w-4 h-4" })
2710
+ }
2711
+ ) }),
2712
+ /* @__PURE__ */ jsx(PopoverContent, { className: "w-80 p-3", align: "start", style: { zIndex: 9999 }, children: !activeFormats.link && !hasSavedSelection ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground py-1", children: "Selecione um texto para criar um link." }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
2713
+ /* @__PURE__ */ jsx("div", { className: "text-xs font-medium", children: activeFormats.link ? "Editar Link" : "Inserir Link" }),
2714
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
2715
+ /* @__PURE__ */ jsx(
2716
+ Input,
2717
+ {
2718
+ ref: linkInputRef,
2719
+ placeholder: "https://...",
2720
+ value: linkUrl,
2721
+ onChange: (e) => setLinkUrl(e.target.value),
2722
+ onKeyDown: (e) => {
2723
+ if (e.key === "Enter") {
2724
+ e.preventDefault();
2725
+ e.stopPropagation();
2726
+ handleCreateLink();
2727
+ }
2728
+ },
2729
+ className: "h-8 text-xs"
2730
+ }
2731
+ ),
2732
+ /* @__PURE__ */ jsx(Button, { size: "sm", className: "h-8", onClick: handleCreateLink, children: "Aplicar" })
2733
+ ] })
2734
+ ] }) })
2735
+ ] }),
2736
+ /* @__PURE__ */ jsx(
2737
+ Button,
2738
+ {
2739
+ variant: "ghost",
2740
+ size: "icon",
2741
+ className: "h-8 w-8 text-muted-foreground",
2742
+ onClick: handleUnlink,
2743
+ title: "Remover link",
2744
+ "aria-label": "Remover link",
2745
+ children: /* @__PURE__ */ jsx(X, { className: "w-4 h-4" })
2746
+ }
2747
+ ),
2748
+ /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
2749
+ ] }),
2750
+ (allowFormatting || allowHeadings || allowAlignment || allowLists || allowLinks) && /* @__PURE__ */ jsx(
2751
+ Button,
2752
+ {
2753
+ variant: "ghost",
2754
+ size: "icon",
2755
+ className: "h-8 w-8 text-muted-foreground",
2756
+ onClick: () => execCommand("removeFormat"),
2757
+ title: "Limpar formatação",
2758
+ "aria-label": "Limpar formatação",
2759
+ children: /* @__PURE__ */ jsx(Type, { className: "w-4 h-4" })
2760
+ }
2761
+ ),
2762
+ allowSearch && /* @__PURE__ */ jsx(
2763
+ Button,
2764
+ {
2765
+ variant: "ghost",
2766
+ size: "icon",
2767
+ className: cn(
2768
+ "h-8 w-8 text-muted-foreground",
2769
+ isSearchOpen && "bg-muted text-foreground"
2770
+ ),
2771
+ onClick: () => {
2772
+ setIsSearchOpen(!isSearchOpen);
2773
+ if (!isSearchOpen) setTimeout(() => searchInputRef.current?.focus(), 100);
2774
+ },
2775
+ title: "Buscar",
2776
+ "aria-label": "Buscar",
2777
+ children: /* @__PURE__ */ jsx(Search, { className: "w-4 h-4" })
2778
+ }
2779
+ ),
2780
+ actionButton && /* @__PURE__ */ jsxs(Fragment, { children: [
2781
+ /* @__PURE__ */ jsx("div", { className: "flex-1" }),
2782
+ actionButton
2783
+ ] })
2784
+ ] }),
2785
+ isSearchOpen && /* @__PURE__ */ jsxs("div", { className: "px-3 py-1.5 border-b border-border bg-muted/20 flex items-center gap-2", children: [
2786
+ /* @__PURE__ */ jsxs("div", { className: "relative flex-1 max-w-sm", children: [
2787
+ /* @__PURE__ */ jsx(Search, { className: "absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground" }),
2788
+ /* @__PURE__ */ jsx(
2789
+ Input,
2790
+ {
2791
+ ref: searchInputRef,
2792
+ placeholder: "Buscar no texto...",
2793
+ value: searchQuery,
2794
+ onChange: (e) => setSearchQuery(e.target.value),
2795
+ onKeyDown: (e) => {
2796
+ if (e.key === "Enter") {
2797
+ e.preventDefault();
2798
+ performSearch(searchQuery, e.shiftKey);
2799
+ }
2800
+ if (e.key === "Escape") {
2801
+ setIsSearchOpen(false);
2802
+ }
2803
+ },
2804
+ className: "h-8 pl-8 text-xs bg-background"
2805
+ }
2806
+ )
2807
+ ] }),
2808
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
2809
+ /* @__PURE__ */ jsx(
2810
+ Button,
2811
+ {
2812
+ variant: "ghost",
2813
+ size: "icon",
2814
+ className: "h-7 w-7",
2815
+ onMouseDown: (e) => e.preventDefault(),
2816
+ onClick: () => performSearch(searchQuery, true),
2817
+ title: "Anterior",
2818
+ children: /* @__PURE__ */ jsx(ChevronUp, { className: "w-4 h-4" })
2819
+ }
2820
+ ),
2821
+ /* @__PURE__ */ jsx(
2822
+ Button,
2823
+ {
2824
+ variant: "ghost",
2825
+ size: "icon",
2826
+ className: "h-7 w-7",
2827
+ onMouseDown: (e) => e.preventDefault(),
2828
+ onClick: () => performSearch(searchQuery, false),
2829
+ title: "Próximo",
2830
+ children: /* @__PURE__ */ jsx(ChevronDown, { className: "w-4 h-4" })
2831
+ }
2832
+ ),
2833
+ /* @__PURE__ */ jsx("div", { className: "w-px h-4 bg-border mx-1" }),
2834
+ /* @__PURE__ */ jsx(
2835
+ Button,
2836
+ {
2837
+ variant: "ghost",
2838
+ size: "icon",
2839
+ className: "h-7 w-7 text-muted-foreground hover:text-foreground",
2840
+ onClick: () => setIsSearchOpen(false),
2841
+ title: "Fechar busca",
2842
+ children: /* @__PURE__ */ jsx(X, { className: "w-4 h-4" })
2843
+ }
2844
+ )
2845
+ ] }),
2846
+ /* @__PURE__ */ jsx("div", { className: "hidden sm:block text-[10px] text-muted-foreground ml-auto uppercase tracking-wider font-medium", children: "Pressione Enter para buscar" })
2847
+ ] }),
2848
+ /* @__PURE__ */ jsx(
2849
+ "div",
2850
+ {
2851
+ className: "flex-1 overflow-y-auto p-4 sm:p-8 bg-background scrollbar-thin",
2852
+ style: { minHeight, maxHeight },
2853
+ children: /* @__PURE__ */ jsx(
2854
+ "div",
2855
+ {
2856
+ ref: editorRef,
2857
+ contentEditable: isEditable,
2858
+ role: "textbox",
2859
+ "aria-multiline": "true",
2860
+ "aria-label": placeholder || "Editor de texto",
2861
+ "aria-readonly": readOnly,
2862
+ "aria-disabled": disabled,
2863
+ onInput: handleInput,
2864
+ onSelect: isEditable ? updateActiveFormats : void 0,
2865
+ onFocus: () => {
2866
+ updateActiveFormats();
2867
+ onFocus?.();
2868
+ },
2869
+ onBlur,
2870
+ className: "prose-editor min-h-full max-w-none focus:outline-none",
2871
+ "data-placeholder": placeholder
2872
+ }
2873
+ )
2874
+ }
2875
+ ),
2876
+ (showWordCount || showCharacterCount) && /* @__PURE__ */ jsx("div", { className: "px-4 py-2 border-t border-border bg-muted/20 flex items-center justify-between", children: /* @__PURE__ */ jsxs("div", { className: "text-[10px] sm:text-xs text-muted-foreground font-medium uppercase tracking-wider flex items-center gap-2", children: [
2877
+ showWordCount && /* @__PURE__ */ jsxs("span", { children: [
2878
+ wordCount,
2879
+ " ",
2880
+ wordCount === 1 ? "palavra" : "palavras"
2881
+ ] }),
2882
+ showWordCount && showCharacterCount && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "•" }),
2883
+ showCharacterCount && /* @__PURE__ */ jsxs("span", { children: [
2884
+ characterCount,
2885
+ " ",
2886
+ characterCount === 1 ? "caractere" : "caracteres"
2887
+ ] })
2888
+ ] }) })
2889
+ ]
2890
+ }
2891
+ );
2892
+ }
2893
+
2894
+ export { Alert as A, EmptyTitle as B, ChartCard as C, DashboardBarChart as D, Empty as E, RadialBarMetricChart as F, GaugeChart as G, HorizontalBarChart as H, InteractiveTimeSeriesChart as I, RichTextEditor as J, ScrollBar as K, SparklineChart as L, TableBody as M, TableCaption as N, TableCell as O, PieMetricChart as P, TableFooter as Q, RadarMetricChart as R, ScrollArea as S, Table as T, TableHead as U, TableHeader as V, TableRow as W, Textarea as X, useChart as Y, useRichTextEditor as Z, AlertDescription as a, AlertTitle as b, ChartContainer as c, ChartLegend as d, ChartLegendContent as e, ChartStyle as f, ChartTooltip as g, ChartTooltipContent as h, ComboMetricChart as i, DashboardLineChart as j, Dialog as k, DialogBody as l, DialogClose as m, DialogContent as n, DialogDescription as o, DialogFooter as p, DialogHeader as q, DialogOverlay as r, DialogPortal as s, DialogTitle as t, DialogTrigger as u, DonutBreakdownChart as v, EmptyAction as w, EmptyDescription as x, EmptyIcon as y, EmptyImage as z };