@alfadocs/ui-kit-debug 1.43.0 → 1.44.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 (186) hide show
  1. package/dist/_chunks/{calendar-ChJQzRw-.js → calendar-U6N0F99w.js} +383 -359
  2. package/dist/_chunks/calendar-U6N0F99w.js.map +1 -0
  3. package/dist/_chunks/calendar-workspace-DBYAtdyd.js +12161 -0
  4. package/dist/_chunks/calendar-workspace-DBYAtdyd.js.map +1 -0
  5. package/dist/_chunks/{face-scheme-Dg6ZyLKb.js → face-scheme-Bm6pe7R8.js} +265 -275
  6. package/dist/_chunks/face-scheme-Bm6pe7R8.js.map +1 -0
  7. package/dist/_chunks/help-me-write-templates-GUeEn3Ff.js +741 -0
  8. package/dist/_chunks/help-me-write-templates-GUeEn3Ff.js.map +1 -0
  9. package/dist/_chunks/{notes-panel-CRAovkjx.js → notes-panel-CY4KmDo-.js} +159 -152
  10. package/dist/_chunks/notes-panel-CY4KmDo-.js.map +1 -0
  11. package/dist/_chunks/{panel-subview-PMBRPFOa.js → panel-subview-CYnuX-KR.js} +61 -40
  12. package/dist/_chunks/panel-subview-CYnuX-KR.js.map +1 -0
  13. package/dist/_chunks/rich-text-editor-BYE6kK4u.js +3839 -0
  14. package/dist/_chunks/rich-text-editor-BYE6kK4u.js.map +1 -0
  15. package/dist/_chunks/undo-2-CYNAzclj.js +26 -0
  16. package/dist/_chunks/undo-2-CYNAzclj.js.map +1 -0
  17. package/dist/_chunks/variables-menu-vXUaSBj4.js +401 -0
  18. package/dist/_chunks/variables-menu-vXUaSBj4.js.map +1 -0
  19. package/dist/agent-catalog.json +84 -3
  20. package/dist/agent-i18n/en.json +14 -3
  21. package/dist/components/calendar/calendar.d.ts +6 -0
  22. package/dist/components/calendar/calendar.d.ts.map +1 -1
  23. package/dist/components/calendar/index.js +1 -1
  24. package/dist/components/face-scheme/index.js +1 -1
  25. package/dist/components/index.d.ts +1 -0
  26. package/dist/components/index.d.ts.map +1 -1
  27. package/dist/components/notes-panel/index.js +1 -1
  28. package/dist/components/notes-panel/notes-panel.d.ts +4 -0
  29. package/dist/components/notes-panel/notes-panel.d.ts.map +1 -1
  30. package/dist/components/panel-subview/index.js +1 -1
  31. package/dist/components/panel-subview/panel-subview.d.ts +6 -0
  32. package/dist/components/panel-subview/panel-subview.d.ts.map +1 -1
  33. package/dist/components/rich-text-editor/editor-toolbar.d.ts +35 -3
  34. package/dist/components/rich-text-editor/editor-toolbar.d.ts.map +1 -1
  35. package/dist/components/rich-text-editor/index.d.ts +1 -1
  36. package/dist/components/rich-text-editor/index.d.ts.map +1 -1
  37. package/dist/components/rich-text-editor/index.js +1 -1
  38. package/dist/components/rich-text-editor/rich-text-editor.agent.d.ts.map +1 -1
  39. package/dist/components/rich-text-editor/rich-text-editor.d.ts +98 -15
  40. package/dist/components/rich-text-editor/rich-text-editor.d.ts.map +1 -1
  41. package/dist/components/variables-menu/index.d.ts +4 -0
  42. package/dist/components/variables-menu/index.d.ts.map +1 -0
  43. package/dist/components/variables-menu/index.js +6 -0
  44. package/dist/components/variables-menu/index.js.map +1 -0
  45. package/dist/components/variables-menu/variables-menu.agent.d.ts +10 -0
  46. package/dist/components/variables-menu/variables-menu.agent.d.ts.map +1 -0
  47. package/dist/components/variables-menu/variables-menu.d.ts +53 -0
  48. package/dist/components/variables-menu/variables-menu.d.ts.map +1 -0
  49. package/dist/host-compat.css +5 -5
  50. package/dist/i18n/locales/ar.d.ts +77 -6
  51. package/dist/i18n/locales/ar.d.ts.map +1 -1
  52. package/dist/i18n/locales/ar.js +78 -7
  53. package/dist/i18n/locales/ar.js.map +1 -1
  54. package/dist/i18n/locales/de.d.ts +77 -6
  55. package/dist/i18n/locales/de.d.ts.map +1 -1
  56. package/dist/i18n/locales/de.js +78 -7
  57. package/dist/i18n/locales/de.js.map +1 -1
  58. package/dist/i18n/locales/el.d.ts +77 -6
  59. package/dist/i18n/locales/el.d.ts.map +1 -1
  60. package/dist/i18n/locales/el.js +78 -7
  61. package/dist/i18n/locales/el.js.map +1 -1
  62. package/dist/i18n/locales/en.d.ts +77 -6
  63. package/dist/i18n/locales/en.d.ts.map +1 -1
  64. package/dist/i18n/locales/en.js +85 -7
  65. package/dist/i18n/locales/en.js.map +1 -1
  66. package/dist/i18n/locales/es.d.ts +77 -6
  67. package/dist/i18n/locales/es.d.ts.map +1 -1
  68. package/dist/i18n/locales/es.js +78 -7
  69. package/dist/i18n/locales/es.js.map +1 -1
  70. package/dist/i18n/locales/fr.d.ts +77 -6
  71. package/dist/i18n/locales/fr.d.ts.map +1 -1
  72. package/dist/i18n/locales/fr.js +78 -7
  73. package/dist/i18n/locales/fr.js.map +1 -1
  74. package/dist/i18n/locales/hi.d.ts +77 -6
  75. package/dist/i18n/locales/hi.d.ts.map +1 -1
  76. package/dist/i18n/locales/hi.js +78 -7
  77. package/dist/i18n/locales/hi.js.map +1 -1
  78. package/dist/i18n/locales/it.d.ts +77 -6
  79. package/dist/i18n/locales/it.d.ts.map +1 -1
  80. package/dist/i18n/locales/it.js +78 -7
  81. package/dist/i18n/locales/it.js.map +1 -1
  82. package/dist/i18n/locales/ja.d.ts +77 -6
  83. package/dist/i18n/locales/ja.d.ts.map +1 -1
  84. package/dist/i18n/locales/ja.js +78 -7
  85. package/dist/i18n/locales/ja.js.map +1 -1
  86. package/dist/i18n/locales/nl.d.ts +77 -6
  87. package/dist/i18n/locales/nl.d.ts.map +1 -1
  88. package/dist/i18n/locales/nl.js +78 -7
  89. package/dist/i18n/locales/nl.js.map +1 -1
  90. package/dist/i18n/locales/pl.d.ts +77 -6
  91. package/dist/i18n/locales/pl.d.ts.map +1 -1
  92. package/dist/i18n/locales/pl.js +78 -7
  93. package/dist/i18n/locales/pl.js.map +1 -1
  94. package/dist/i18n/locales/pt.d.ts +77 -6
  95. package/dist/i18n/locales/pt.d.ts.map +1 -1
  96. package/dist/i18n/locales/pt.js +78 -7
  97. package/dist/i18n/locales/pt.js.map +1 -1
  98. package/dist/i18n/locales/ro.d.ts +77 -6
  99. package/dist/i18n/locales/ro.d.ts.map +1 -1
  100. package/dist/i18n/locales/ro.js +78 -7
  101. package/dist/i18n/locales/ro.js.map +1 -1
  102. package/dist/i18n/locales/ru.d.ts +77 -6
  103. package/dist/i18n/locales/ru.d.ts.map +1 -1
  104. package/dist/i18n/locales/ru.js +78 -7
  105. package/dist/i18n/locales/ru.js.map +1 -1
  106. package/dist/i18n/locales/sq.d.ts +77 -6
  107. package/dist/i18n/locales/sq.d.ts.map +1 -1
  108. package/dist/i18n/locales/sq.js +78 -7
  109. package/dist/i18n/locales/sq.js.map +1 -1
  110. package/dist/i18n/locales/sv.d.ts +77 -6
  111. package/dist/i18n/locales/sv.d.ts.map +1 -1
  112. package/dist/i18n/locales/sv.js +78 -7
  113. package/dist/i18n/locales/sv.js.map +1 -1
  114. package/dist/i18n/locales/tr.d.ts +77 -6
  115. package/dist/i18n/locales/tr.d.ts.map +1 -1
  116. package/dist/i18n/locales/tr.js +78 -7
  117. package/dist/i18n/locales/tr.js.map +1 -1
  118. package/dist/i18n/locales/zh.d.ts +77 -6
  119. package/dist/i18n/locales/zh.d.ts.map +1 -1
  120. package/dist/i18n/locales/zh.js +78 -7
  121. package/dist/i18n/locales/zh.js.map +1 -1
  122. package/dist/index.js +916 -913
  123. package/dist/index.js.map +1 -1
  124. package/dist/locales/ar.json +78 -7
  125. package/dist/locales/de.json +78 -7
  126. package/dist/locales/el.json +78 -7
  127. package/dist/locales/en.json +78 -7
  128. package/dist/locales/es.json +78 -7
  129. package/dist/locales/fr.json +78 -7
  130. package/dist/locales/hi.json +78 -7
  131. package/dist/locales/it.json +78 -7
  132. package/dist/locales/ja.json +78 -7
  133. package/dist/locales/nl.json +78 -7
  134. package/dist/locales/pl.json +78 -7
  135. package/dist/locales/pt.json +78 -7
  136. package/dist/locales/ro.json +78 -7
  137. package/dist/locales/ru.json +78 -7
  138. package/dist/locales/sq.json +78 -7
  139. package/dist/locales/sv.json +78 -7
  140. package/dist/locales/tr.json +78 -7
  141. package/dist/locales/zh.json +78 -7
  142. package/dist/patterns/calendar/calendar-bookings-panel.d.ts +8 -3
  143. package/dist/patterns/calendar/calendar-bookings-panel.d.ts.map +1 -1
  144. package/dist/patterns/calendar/calendar-care-rules.d.ts +49 -0
  145. package/dist/patterns/calendar/calendar-care-rules.d.ts.map +1 -0
  146. package/dist/patterns/calendar/calendar-task-editor.d.ts +31 -0
  147. package/dist/patterns/calendar/calendar-task-editor.d.ts.map +1 -0
  148. package/dist/patterns/calendar/calendar-waiting-list-panel.d.ts.map +1 -1
  149. package/dist/patterns/calendar/calendar-workspace.d.ts +8 -1
  150. package/dist/patterns/calendar/calendar-workspace.d.ts.map +1 -1
  151. package/dist/patterns/calendar/calendar-workspace.model.d.ts +39 -12
  152. package/dist/patterns/calendar/calendar-workspace.model.d.ts.map +1 -1
  153. package/dist/patterns/calendar/calendar.data.d.ts +9 -0
  154. package/dist/patterns/calendar/calendar.data.d.ts.map +1 -1
  155. package/dist/patterns/calendar/calendar.journey.d.ts +35 -3
  156. package/dist/patterns/calendar/calendar.journey.d.ts.map +1 -1
  157. package/dist/patterns/calendar/calendar.model.d.ts +23 -1
  158. package/dist/patterns/calendar/calendar.model.d.ts.map +1 -1
  159. package/dist/patterns/calendar/calendar.sheets.d.ts +21 -3
  160. package/dist/patterns/calendar/calendar.sheets.d.ts.map +1 -1
  161. package/dist/patterns/calendar/calendar.surface.d.ts +6 -1
  162. package/dist/patterns/calendar/calendar.surface.d.ts.map +1 -1
  163. package/dist/patterns/calendar/calendar.types.d.ts +32 -1
  164. package/dist/patterns/calendar/calendar.types.d.ts.map +1 -1
  165. package/dist/patterns/calendar/index.js +1 -1
  166. package/dist/patterns/help-me-write-templates/help-me-write-templates.d.ts +58 -26
  167. package/dist/patterns/help-me-write-templates/help-me-write-templates.d.ts.map +1 -1
  168. package/dist/patterns/help-me-write-templates/index.d.ts +1 -1
  169. package/dist/patterns/help-me-write-templates/index.d.ts.map +1 -1
  170. package/dist/patterns/help-me-write-templates/index.js +1 -1
  171. package/dist/tokens.css +6 -6
  172. package/package.json +5 -1
  173. package/dist/_chunks/calendar-ChJQzRw-.js.map +0 -1
  174. package/dist/_chunks/calendar-workspace-DhXqqu-D.js +0 -11392
  175. package/dist/_chunks/calendar-workspace-DhXqqu-D.js.map +0 -1
  176. package/dist/_chunks/face-scheme-Dg6ZyLKb.js.map +0 -1
  177. package/dist/_chunks/help-me-write-templates-B-m7zgJa.js +0 -775
  178. package/dist/_chunks/help-me-write-templates-B-m7zgJa.js.map +0 -1
  179. package/dist/_chunks/highlighter-DSkckT2Q.js +0 -15
  180. package/dist/_chunks/highlighter-DSkckT2Q.js.map +0 -1
  181. package/dist/_chunks/notes-panel-CRAovkjx.js.map +0 -1
  182. package/dist/_chunks/panel-subview-PMBRPFOa.js.map +0 -1
  183. package/dist/_chunks/rich-text-editor-DUMeifwc.js +0 -3176
  184. package/dist/_chunks/rich-text-editor-DUMeifwc.js.map +0 -1
  185. package/dist/_chunks/wand-sparkles-DAjKyhz7.js +0 -27
  186. package/dist/_chunks/wand-sparkles-DAjKyhz7.js.map +0 -1
@@ -0,0 +1,3839 @@
1
+ import { jsx as t, jsxs as x, Fragment as Ce } from "react/jsx-runtime";
2
+ import { useId as Ee, useState as N, useRef as _, useCallback as y, useEffect as D, Fragment as $t, forwardRef as uo, useMemo as Ve, useImperativeHandle as mo } from "react";
3
+ import { c as fn } from "./index-D2ZczOXr.js";
4
+ import { useTranslation as ae } from "react-i18next";
5
+ import { SafeHtml as fo, sanitiseHtml as go } from "../safe-html/index.js";
6
+ import { u as po } from "./registry-DvAUVLHh.js";
7
+ import { S as fr } from "./spinner-hbwuKwMf.js";
8
+ import { B as Ae } from "./button-CaUe1uyd.js";
9
+ import { I as G } from "./icon-button-CehAeZoP.js";
10
+ import { A as ho } from "./ai-consent-banner-D7I2U-cz.js";
11
+ import { T as bo } from "./text-area-Bt3p7Pt0.js";
12
+ import { E as gr } from "./editor-overlay-DwNKaI22.js";
13
+ import { X as Qn } from "./x-B5YnXwCz.js";
14
+ import { R as vo } from "./rotate-ccw-BBQnIVTr.js";
15
+ import { C as yo } from "./check-DrFSN__t.js";
16
+ import { S as at } from "./square-DASBRZ0U.js";
17
+ import { M as ln } from "./mic-CUklMZGF.js";
18
+ import { S as wo } from "./send-C5kDJ-Mz.js";
19
+ import * as Et from "@radix-ui/react-popover";
20
+ import { V as pr } from "./variables-menu-vXUaSBj4.js";
21
+ import { a as gn } from "./tooltip-Cp-PLePW.js";
22
+ import { P as Z } from "./popover-DO-pssF3.js";
23
+ import { D as he } from "./dropdown-menu-DU-Hrf33.js";
24
+ import { D as te } from "./dialog-BJiLqhx6.js";
25
+ import { C as pn } from "./color-picker-Bl5f0iK1.js";
26
+ import { T as Rt } from "./text-input-CUvCb6ST.js";
27
+ import { C as ko } from "./checkbox-CZkipDn7.js";
28
+ import { F as xo } from "./file-upload-BDpb08GM.js";
29
+ import { c as R } from "./createLucideIcon-DhHxpK9K.js";
30
+ import { E as Co } from "./ellipsis-dRo9ouSU.js";
31
+ import { H as Ao, U as _o } from "./undo-2-CYNAzclj.js";
32
+ import { I as No } from "./image-B_5MNK0x.js";
33
+ import { C as hr } from "./chevron-down-DWE7GSq9.js";
34
+ import { P as To } from "./plus-DzMQ_c6b.js";
35
+ import { S as Eo } from "./settings-d25ju_6L.js";
36
+ import { T as zo } from "./trash-2-uumy3fy1.js";
37
+ import { A as zt } from "./astroid-BN4f5VXU.js";
38
+ /**
39
+ * @license lucide-react v1.22.0 - ISC
40
+ *
41
+ * This source code is licensed under the ISC license.
42
+ * See the LICENSE file in the root directory of this source tree.
43
+ */
44
+ const So = [
45
+ ["path", { d: "M4 20h16", key: "14thso" }],
46
+ ["path", { d: "m6 16 6-12 6 12", key: "1b4byz" }],
47
+ ["path", { d: "M8 12h8", key: "1wcyev" }]
48
+ ], Mo = R("baseline", So);
49
+ /**
50
+ * @license lucide-react v1.22.0 - ISC
51
+ *
52
+ * This source code is licensed under the ISC license.
53
+ * See the LICENSE file in the root directory of this source tree.
54
+ */
55
+ const Ro = [
56
+ ["rect", { width: "13", height: "7", x: "3", y: "3", rx: "1", key: "11xb64" }],
57
+ ["path", { d: "m22 15-3-3 3-3", key: "26chmm" }],
58
+ ["rect", { width: "13", height: "7", x: "3", y: "14", rx: "1", key: "k6ky7n" }]
59
+ ], Lo = R("between-horizontal-end", Ro);
60
+ /**
61
+ * @license lucide-react v1.22.0 - ISC
62
+ *
63
+ * This source code is licensed under the ISC license.
64
+ * See the LICENSE file in the root directory of this source tree.
65
+ */
66
+ const $o = [
67
+ ["rect", { width: "13", height: "7", x: "8", y: "3", rx: "1", key: "pkso9a" }],
68
+ ["path", { d: "m2 9 3 3-3 3", key: "1agib5" }],
69
+ ["rect", { width: "13", height: "7", x: "8", y: "14", rx: "1", key: "1q5fc1" }]
70
+ ], Io = R("between-horizontal-start", $o);
71
+ /**
72
+ * @license lucide-react v1.22.0 - ISC
73
+ *
74
+ * This source code is licensed under the ISC license.
75
+ * See the LICENSE file in the root directory of this source tree.
76
+ */
77
+ const Ho = [
78
+ ["rect", { width: "7", height: "13", x: "3", y: "3", rx: "1", key: "1fdu0f" }],
79
+ ["path", { d: "m9 22 3-3 3 3", key: "17z65a" }],
80
+ ["rect", { width: "7", height: "13", x: "14", y: "3", rx: "1", key: "1squn4" }]
81
+ ], Do = R("between-vertical-end", Ho);
82
+ /**
83
+ * @license lucide-react v1.22.0 - ISC
84
+ *
85
+ * This source code is licensed under the ISC license.
86
+ * See the LICENSE file in the root directory of this source tree.
87
+ */
88
+ const Oo = [
89
+ ["rect", { width: "7", height: "13", x: "3", y: "8", rx: "1", key: "1fjrkv" }],
90
+ ["path", { d: "m15 2-3 3-3-3", key: "1uh6eb" }],
91
+ ["rect", { width: "7", height: "13", x: "14", y: "8", rx: "1", key: "w3fjg8" }]
92
+ ], qo = R("between-vertical-start", Oo);
93
+ /**
94
+ * @license lucide-react v1.22.0 - ISC
95
+ *
96
+ * This source code is licensed under the ISC license.
97
+ * See the LICENSE file in the root directory of this source tree.
98
+ */
99
+ const Po = [
100
+ [
101
+ "path",
102
+ { d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8", key: "mg9rjx" }
103
+ ]
104
+ ], Bo = R("bold", Po);
105
+ /**
106
+ * @license lucide-react v1.22.0 - ISC
107
+ *
108
+ * This source code is licensed under the ISC license.
109
+ * See the LICENSE file in the root directory of this source tree.
110
+ */
111
+ const Fo = [
112
+ [
113
+ "path",
114
+ { d: "M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1", key: "ezmyqa" }
115
+ ],
116
+ [
117
+ "path",
118
+ {
119
+ d: "M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",
120
+ key: "e1hn23"
121
+ }
122
+ ]
123
+ ], jo = R("braces", Fo);
124
+ /**
125
+ * @license lucide-react v1.22.0 - ISC
126
+ *
127
+ * This source code is licensed under the ISC license.
128
+ * See the LICENSE file in the root directory of this source tree.
129
+ */
130
+ const Go = [
131
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
132
+ ["path", { d: "M12 3v18", key: "108xh3" }]
133
+ ], Ko = R("columns-2", Go);
134
+ /**
135
+ * @license lucide-react v1.22.0 - ISC
136
+ *
137
+ * This source code is licensed under the ISC license.
138
+ * See the LICENSE file in the root directory of this source tree.
139
+ */
140
+ const Wo = [
141
+ ["path", { d: "M4 12h8", key: "17cfdx" }],
142
+ ["path", { d: "M4 18V6", key: "1rz3zl" }],
143
+ ["path", { d: "M12 18V6", key: "zqpxq5" }],
144
+ ["path", { d: "M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1", key: "9jr5yi" }]
145
+ ], Vo = R("heading-2", Wo);
146
+ /**
147
+ * @license lucide-react v1.22.0 - ISC
148
+ *
149
+ * This source code is licensed under the ISC license.
150
+ * See the LICENSE file in the root directory of this source tree.
151
+ */
152
+ const Xo = [
153
+ ["path", { d: "M4 12h8", key: "17cfdx" }],
154
+ ["path", { d: "M4 18V6", key: "1rz3zl" }],
155
+ ["path", { d: "M12 18V6", key: "zqpxq5" }],
156
+ ["path", { d: "M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2", key: "68ncm8" }],
157
+ ["path", { d: "M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2", key: "1ejuhz" }]
158
+ ], Uo = R("heading-3", Xo);
159
+ /**
160
+ * @license lucide-react v1.22.0 - ISC
161
+ *
162
+ * This source code is licensed under the ISC license.
163
+ * See the LICENSE file in the root directory of this source tree.
164
+ */
165
+ const Zo = [
166
+ ["line", { x1: "19", x2: "10", y1: "4", y2: "4", key: "15jd3p" }],
167
+ ["line", { x1: "14", x2: "5", y1: "20", y2: "20", key: "bu0au3" }],
168
+ ["line", { x1: "15", x2: "9", y1: "4", y2: "20", key: "uljnxc" }]
169
+ ], Qo = R("italic", Zo);
170
+ /**
171
+ * @license lucide-react v1.22.0 - ISC
172
+ *
173
+ * This source code is licensed under the ISC license.
174
+ * See the LICENSE file in the root directory of this source tree.
175
+ */
176
+ const Yo = [
177
+ ["rect", { width: "18", height: "7", x: "3", y: "3", rx: "1", key: "f1a2em" }],
178
+ ["rect", { width: "9", height: "7", x: "3", y: "14", rx: "1", key: "jqznyg" }],
179
+ ["rect", { width: "5", height: "7", x: "16", y: "14", rx: "1", key: "q5h2i8" }]
180
+ ], cn = R("layout-template", Yo);
181
+ /**
182
+ * @license lucide-react v1.22.0 - ISC
183
+ *
184
+ * This source code is licensed under the ISC license.
185
+ * See the LICENSE file in the root directory of this source tree.
186
+ */
187
+ const Jo = [
188
+ ["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71", key: "1cjeqo" }],
189
+ ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71", key: "19qd67" }]
190
+ ], ea = R("link", Jo);
191
+ /**
192
+ * @license lucide-react v1.22.0 - ISC
193
+ *
194
+ * This source code is licensed under the ISC license.
195
+ * See the LICENSE file in the root directory of this source tree.
196
+ */
197
+ const ta = [
198
+ ["path", { d: "M11 5h10", key: "1cz7ny" }],
199
+ ["path", { d: "M11 12h10", key: "1438ji" }],
200
+ ["path", { d: "M11 19h10", key: "11t30w" }],
201
+ ["path", { d: "M4 4h1v5", key: "10yrso" }],
202
+ ["path", { d: "M4 9h2", key: "r1h2o0" }],
203
+ ["path", { d: "M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02", key: "xtkcd5" }]
204
+ ], na = R("list-ordered", ta);
205
+ /**
206
+ * @license lucide-react v1.22.0 - ISC
207
+ *
208
+ * This source code is licensed under the ISC license.
209
+ * See the LICENSE file in the root directory of this source tree.
210
+ */
211
+ const ra = [
212
+ ["path", { d: "M3 5h.01", key: "18ugdj" }],
213
+ ["path", { d: "M3 12h.01", key: "nlz23k" }],
214
+ ["path", { d: "M3 19h.01", key: "noohij" }],
215
+ ["path", { d: "M8 5h13", key: "1pao27" }],
216
+ ["path", { d: "M8 12h13", key: "1za7za" }],
217
+ ["path", { d: "M8 19h13", key: "m83p4d" }]
218
+ ], oa = R("list", ra);
219
+ /**
220
+ * @license lucide-react v1.22.0 - ISC
221
+ *
222
+ * This source code is licensed under the ISC license.
223
+ * See the LICENSE file in the root directory of this source tree.
224
+ */
225
+ const aa = [
226
+ ["path", { d: "M11 7 6 2", key: "1jwth8" }],
227
+ ["path", { d: "M18.992 12H2.041", key: "xw1gg" }],
228
+ [
229
+ "path",
230
+ {
231
+ d: "M21.145 18.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595",
232
+ key: "1nkol4"
233
+ }
234
+ ],
235
+ [
236
+ "path",
237
+ {
238
+ d: "m8.5 4.5 2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33",
239
+ key: "1nk1rd"
240
+ }
241
+ ]
242
+ ], ia = R("paint-bucket", aa);
243
+ /**
244
+ * @license lucide-react v1.22.0 - ISC
245
+ *
246
+ * This source code is licensed under the ISC license.
247
+ * See the LICENSE file in the root directory of this source tree.
248
+ */
249
+ const sa = [
250
+ ["rect", { width: "16", height: "6", x: "2", y: "2", rx: "2", key: "jcyz7m" }],
251
+ ["path", { d: "M10 16v-2a2 2 0 0 1 2-2h8a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2", key: "1b9h7c" }],
252
+ ["rect", { width: "4", height: "6", x: "8", y: "16", rx: "1", key: "d6e7yl" }]
253
+ ], la = R("paint-roller", sa);
254
+ /**
255
+ * @license lucide-react v1.22.0 - ISC
256
+ *
257
+ * This source code is licensed under the ISC license.
258
+ * See the LICENSE file in the root directory of this source tree.
259
+ */
260
+ const ca = [
261
+ [
262
+ "path",
263
+ {
264
+ d: "M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",
265
+ key: "e79jfc"
266
+ }
267
+ ],
268
+ ["circle", { cx: "13.5", cy: "6.5", r: ".5", fill: "currentColor", key: "1okk4w" }],
269
+ ["circle", { cx: "17.5", cy: "10.5", r: ".5", fill: "currentColor", key: "f64h9f" }],
270
+ ["circle", { cx: "6.5", cy: "12.5", r: ".5", fill: "currentColor", key: "qy21gx" }],
271
+ ["circle", { cx: "8.5", cy: "7.5", r: ".5", fill: "currentColor", key: "fotxhn" }]
272
+ ], da = R("palette", ca);
273
+ /**
274
+ * @license lucide-react v1.22.0 - ISC
275
+ *
276
+ * This source code is licensed under the ISC license.
277
+ * See the LICENSE file in the root directory of this source tree.
278
+ */
279
+ const ua = [
280
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
281
+ ["path", { d: "M9 3v18", key: "fh3hqa" }]
282
+ ], ma = R("panel-left", ua);
283
+ /**
284
+ * @license lucide-react v1.22.0 - ISC
285
+ *
286
+ * This source code is licensed under the ISC license.
287
+ * See the LICENSE file in the root directory of this source tree.
288
+ */
289
+ const fa = [
290
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
291
+ ["path", { d: "M15 3v18", key: "14nvp0" }]
292
+ ], ga = R("panel-right", fa);
293
+ /**
294
+ * @license lucide-react v1.22.0 - ISC
295
+ *
296
+ * This source code is licensed under the ISC license.
297
+ * See the LICENSE file in the root directory of this source tree.
298
+ */
299
+ const pa = [
300
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
301
+ ["path", { d: "M14 9h1", key: "l0svgy" }],
302
+ ["path", { d: "M19 9h2", key: "te2zfg" }],
303
+ ["path", { d: "M3 9h2", key: "1h4ldw" }],
304
+ ["path", { d: "M9 9h1", key: "15jzuz" }]
305
+ ], ha = R("panel-top-dashed", pa);
306
+ /**
307
+ * @license lucide-react v1.22.0 - ISC
308
+ *
309
+ * This source code is licensed under the ISC license.
310
+ * See the LICENSE file in the root directory of this source tree.
311
+ */
312
+ const ba = [
313
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
314
+ ["path", { d: "M3 9h18", key: "1pudct" }]
315
+ ], va = R("panel-top", ba);
316
+ /**
317
+ * @license lucide-react v1.22.0 - ISC
318
+ *
319
+ * This source code is licensed under the ISC license.
320
+ * See the LICENSE file in the root directory of this source tree.
321
+ */
322
+ const ya = [
323
+ ["path", { d: "M13 4v16", key: "8vvj80" }],
324
+ ["path", { d: "M17 4v16", key: "7dpous" }],
325
+ ["path", { d: "M19 4H9.5a4.5 4.5 0 0 0 0 9H13", key: "sh4n9v" }]
326
+ ], wa = R("pilcrow", ya);
327
+ /**
328
+ * @license lucide-react v1.22.0 - ISC
329
+ *
330
+ * This source code is licensed under the ISC license.
331
+ * See the LICENSE file in the root directory of this source tree.
332
+ */
333
+ const ka = [
334
+ [
335
+ "path",
336
+ {
337
+ d: "M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",
338
+ key: "rib7q0"
339
+ }
340
+ ],
341
+ [
342
+ "path",
343
+ {
344
+ d: "M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",
345
+ key: "1ymkrd"
346
+ }
347
+ ]
348
+ ], xa = R("quote", ka);
349
+ /**
350
+ * @license lucide-react v1.22.0 - ISC
351
+ *
352
+ * This source code is licensed under the ISC license.
353
+ * See the LICENSE file in the root directory of this source tree.
354
+ */
355
+ const Ca = [
356
+ ["path", { d: "m15 14 5-5-5-5", key: "12vg1m" }],
357
+ ["path", { d: "M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13", key: "6uklza" }]
358
+ ], Aa = R("redo-2", Ca);
359
+ /**
360
+ * @license lucide-react v1.22.0 - ISC
361
+ *
362
+ * This source code is licensed under the ISC license.
363
+ * See the LICENSE file in the root directory of this source tree.
364
+ */
365
+ const _a = [
366
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
367
+ ["path", { d: "M3 12h18", key: "1i2n21" }]
368
+ ], Na = R("rows-2", _a);
369
+ /**
370
+ * @license lucide-react v1.22.0 - ISC
371
+ *
372
+ * This source code is licensed under the ISC license.
373
+ * See the LICENSE file in the root directory of this source tree.
374
+ */
375
+ const Ta = [
376
+ ["path", { d: "m6 16 6-12 6 12", key: "1b4byz" }],
377
+ ["path", { d: "M8 12h8", key: "1wcyev" }],
378
+ ["path", { d: "m16 20 2 2 4-4", key: "13tcca" }]
379
+ ], Yn = R("spell-check", Ta);
380
+ /**
381
+ * @license lucide-react v1.22.0 - ISC
382
+ *
383
+ * This source code is licensed under the ISC license.
384
+ * See the LICENSE file in the root directory of this source tree.
385
+ */
386
+ const Ea = [
387
+ ["path", { d: "M16 4H9a3 3 0 0 0-2.83 4", key: "43sutm" }],
388
+ ["path", { d: "M14 12a4 4 0 0 1 0 8H6", key: "nlfj13" }],
389
+ ["line", { x1: "4", x2: "20", y1: "12", y2: "12", key: "1e0a9i" }]
390
+ ], za = R("strikethrough", Ea);
391
+ /**
392
+ * @license lucide-react v1.22.0 - ISC
393
+ *
394
+ * This source code is licensed under the ISC license.
395
+ * See the LICENSE file in the root directory of this source tree.
396
+ */
397
+ const Sa = [
398
+ ["path", { d: "M12 3v18", key: "108xh3" }],
399
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
400
+ ["path", { d: "M3 9h18", key: "1pudct" }],
401
+ ["path", { d: "M3 15h18", key: "5xshup" }]
402
+ ], Ma = R("table", Sa);
403
+ /**
404
+ * @license lucide-react v1.22.0 - ISC
405
+ *
406
+ * This source code is licensed under the ISC license.
407
+ * See the LICENSE file in the root directory of this source tree.
408
+ */
409
+ const Ra = [
410
+ ["path", { d: "M21 5H3", key: "1fi0y6" }],
411
+ ["path", { d: "M17 12H7", key: "16if0g" }],
412
+ ["path", { d: "M19 19H5", key: "vjpgq2" }]
413
+ ], La = R("text-align-center", Ra);
414
+ /**
415
+ * @license lucide-react v1.22.0 - ISC
416
+ *
417
+ * This source code is licensed under the ISC license.
418
+ * See the LICENSE file in the root directory of this source tree.
419
+ */
420
+ const $a = [
421
+ ["path", { d: "M21 5H3", key: "1fi0y6" }],
422
+ ["path", { d: "M21 12H9", key: "dn1m92" }],
423
+ ["path", { d: "M21 19H7", key: "4cu937" }]
424
+ ], Ia = R("text-align-end", $a);
425
+ /**
426
+ * @license lucide-react v1.22.0 - ISC
427
+ *
428
+ * This source code is licensed under the ISC license.
429
+ * See the LICENSE file in the root directory of this source tree.
430
+ */
431
+ const Ha = [
432
+ ["path", { d: "M21 5H3", key: "1fi0y6" }],
433
+ ["path", { d: "M15 12H3", key: "6jk70r" }],
434
+ ["path", { d: "M17 19H3", key: "z6ezky" }]
435
+ ], Da = R("text-align-start", Ha);
436
+ /**
437
+ * @license lucide-react v1.22.0 - ISC
438
+ *
439
+ * This source code is licensed under the ISC license.
440
+ * See the LICENSE file in the root directory of this source tree.
441
+ */
442
+ const Oa = [
443
+ ["path", { d: "M6 4v6a6 6 0 0 0 12 0V4", key: "9kb039" }],
444
+ ["line", { x1: "4", x2: "20", y1: "20", y2: "20", key: "nun2al" }]
445
+ ], qa = R("underline", Oa);
446
+ /**
447
+ * @license lucide-react v1.22.0 - ISC
448
+ *
449
+ * This source code is licensed under the ISC license.
450
+ * See the LICENSE file in the root directory of this source tree.
451
+ */
452
+ const Pa = [
453
+ [
454
+ "path",
455
+ {
456
+ d: "m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",
457
+ key: "ul74o6"
458
+ }
459
+ ],
460
+ ["path", { d: "m14 7 3 3", key: "1r5n42" }],
461
+ ["path", { d: "M5 6v4", key: "ilb8ba" }],
462
+ ["path", { d: "M19 14v4", key: "blhpug" }],
463
+ ["path", { d: "M10 2v2", key: "7u0qdc" }],
464
+ ["path", { d: "M7 8H3", key: "zfb6yr" }],
465
+ ["path", { d: "M21 16h-4", key: "1cnmox" }],
466
+ ["path", { d: "M11 3H9", key: "1obp7u" }]
467
+ ], Jn = R("wand-sparkles", Pa);
468
+ /**
469
+ * @license lucide-react v1.22.0 - ISC
470
+ *
471
+ * This source code is licensed under the ISC license.
472
+ * See the LICENSE file in the root directory of this source tree.
473
+ */
474
+ const Ba = [
475
+ [
476
+ "path",
477
+ {
478
+ d: "M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",
479
+ key: "1ngwbx"
480
+ }
481
+ ]
482
+ ], Fa = R("wrench", Ba), ja = {
483
+ id: "rich-text-editor",
484
+ capabilities: ["edit_inline"],
485
+ state: {
486
+ html: {
487
+ type: "string",
488
+ descriptionKey: "ui.agent.richTextEditor.state.html",
489
+ description: "Sanitised HTML representation of the editor content.",
490
+ read: (o) => o.getHTML()
491
+ },
492
+ text: {
493
+ type: "string",
494
+ descriptionKey: "ui.agent.richTextEditor.state.text",
495
+ description: "Plain-text content of the editor (tags stripped).",
496
+ read: (o) => o.getText()
497
+ },
498
+ markdown: {
499
+ type: "string",
500
+ descriptionKey: "ui.agent.richTextEditor.state.markdown",
501
+ description: "Markdown representation of the editor content. The Redactor engine has no native Markdown serialiser, so this is always empty — read `html` instead.",
502
+ read: (o) => o.getMarkdown()
503
+ },
504
+ aiBusy: {
505
+ type: "boolean",
506
+ descriptionKey: "ui.agent.richTextEditor.state.aiBusy",
507
+ description: "True while a one-shot AI action (a practice template, spelling or auto-format) is rewriting the note. Read `html` once it is false.",
508
+ read: (o) => o.isAiBusy()
509
+ }
510
+ },
511
+ // Image wrap/align/resize are intentionally NOT agent actions — they target
512
+ // the ephemeral click-selected image the handle can't address. Agents emit
513
+ // `<img class="wysiwyg-img-*" style="width:N%">` via set_content instead.
514
+ actions: {
515
+ set_content: {
516
+ // Replaces the whole document — discards whatever the user had typed.
517
+ safety: "destructive",
518
+ argsType: "{ html: string }",
519
+ argsSchema: {
520
+ type: "object",
521
+ properties: {
522
+ html: {
523
+ type: "string",
524
+ description: "Replacement HTML (sanitised via DOMPurify)."
525
+ }
526
+ },
527
+ required: ["html"]
528
+ },
529
+ idempotent: !0,
530
+ descriptionKey: "ui.agent.richTextEditor.actions.setContent",
531
+ description: "Replace the editor content. Loses unsaved input.",
532
+ invoke: (o, i) => {
533
+ o.setContent(i.html);
534
+ }
535
+ },
536
+ insert_at_cursor: {
537
+ // Reversible via the editor's own undo stack — write, not destructive.
538
+ safety: "write",
539
+ argsType: "{ content: string; asHtml?: boolean }",
540
+ argsSchema: {
541
+ type: "object",
542
+ properties: {
543
+ content: {
544
+ type: "string",
545
+ description: "Content to insert at the caret."
546
+ },
547
+ asHtml: {
548
+ type: "boolean",
549
+ description: "Treat content as HTML (sanitised). Pass false for plain text. Defaults to true."
550
+ }
551
+ },
552
+ required: ["content"]
553
+ },
554
+ descriptionKey: "ui.agent.richTextEditor.actions.insertAtCursor",
555
+ description: "Insert content at the caret (replacing any selection). HTML is sanitised; pass asHtml:false for plain text. Seam for merge/template variables and AI-generated drafts.",
556
+ examples: [
557
+ {
558
+ args: { content: "{{patient.firstName}}", asHtml: !1 },
559
+ note: "Insert a merge variable as plain text."
560
+ }
561
+ ],
562
+ invoke: (o, i) => {
563
+ o.insertAtCursor(i.content, { asHtml: i.asHtml });
564
+ }
565
+ },
566
+ apply_format: {
567
+ // Reversible via undo — write, not destructive.
568
+ safety: "write",
569
+ argsType: "{ format: 'bold' | 'italic' | 'strikethrough' | 'bulletedList' | 'numberedList' | 'heading' | 'quote' | 'paragraph' }",
570
+ argsSchema: {
571
+ type: "object",
572
+ properties: {
573
+ format: {
574
+ type: "string",
575
+ enum: [
576
+ "bold",
577
+ "italic",
578
+ "strikethrough",
579
+ "bulletedList",
580
+ "numberedList",
581
+ "heading",
582
+ "quote",
583
+ "paragraph"
584
+ ],
585
+ description: "Block or inline format to toggle/apply."
586
+ }
587
+ },
588
+ required: ["format"]
589
+ },
590
+ descriptionKey: "ui.agent.richTextEditor.actions.applyFormat",
591
+ description: "Toggle/apply a block or inline format on the current selection (bold, italic, strikethrough, bulleted/numbered list, heading, quote, paragraph).",
592
+ examples: [{ args: { format: "bold" }, note: "Bold the selection." }],
593
+ invoke: (o, i) => {
594
+ o.applyFormat(i.format);
595
+ }
596
+ },
597
+ clear: {
598
+ // Empties the document — loses unsaved input.
599
+ safety: "destructive",
600
+ idempotent: !0,
601
+ descriptionKey: "ui.agent.richTextEditor.actions.clear",
602
+ description: "Empty the editor. Loses unsaved input.",
603
+ invoke: (o) => {
604
+ o.clear();
605
+ }
606
+ },
607
+ focus: {
608
+ safety: "read",
609
+ idempotent: !0,
610
+ descriptionKey: "ui.agent.richTextEditor.actions.focus",
611
+ description: "Move keyboard focus to the editor surface.",
612
+ invoke: (o) => {
613
+ o.focus();
614
+ }
615
+ }
616
+ },
617
+ domHooks: {
618
+ root: { attr: "data-component", value: "rich-text-editor" },
619
+ instanceId: {
620
+ attr: "data-component-id",
621
+ sourceProp: "id",
622
+ description: "Sourced from the id prop."
623
+ }
624
+ }
625
+ }, Ga = "ds:aria-pressed:!bg-[var(--destructive)] ds:aria-pressed:!text-[var(--destructive-foreground)]", Pe = "ds:!size-[var(--min-target-size)]", Ka = "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)]", Wa = "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--destructive)]", er = [
626
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
627
+ "ds:bg-[color-mix(in_srgb,var(--background)_70%,transparent)]",
628
+ "ds:p-[var(--spacing-sm)] ds:[max-block-size:10rem] ds:overflow-y-auto",
629
+ "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--foreground)]",
630
+ // The preview renders arbitrary model-generated rich text, and the
631
+ // `rich-text` SafeHtml profile allows ul/ol/li. Inside a
632
+ // [data-component] preflight's list reset still applies and the host
633
+ // undo deliberately does not reach, so markers and indent have to be
634
+ // asked for explicitly — otherwise a generated bullet list previews as
635
+ // flush, marker-less lines.
636
+ "ds:[&_ul]:list-disc ds:[&_ol]:list-decimal",
637
+ "ds:[&_ul]:ps-[var(--spacing-md)] ds:[&_ol]:ps-[var(--spacing-md)]"
638
+ ].join(" ");
639
+ function tr(o, i) {
640
+ return i ? o ? /\s$/.test(o) ? `${o}${i}` : `${o} ${i}` : i : o;
641
+ }
642
+ function Va({
643
+ open: o,
644
+ onClose: i,
645
+ onRequestAiDraft: d,
646
+ onInsert: c,
647
+ previewAsHtml: g = !0,
648
+ privacyNotice: u,
649
+ onDictate: h
650
+ }) {
651
+ const { t: l } = ae(), b = Ee(), k = Ee(), [A, q] = N(""), [E, z] = N(!1), [K, p] = N(!1), [m, v] = N(null), L = _(null), [T, B] = N(!1), [C, H] = N(""), [S, F] = N(""), j = _(null), P = y(() => {
652
+ var $;
653
+ ($ = j.current) == null || $.abort();
654
+ }, []), Q = y(() => {
655
+ if (!h) return;
656
+ const $ = new AbortController();
657
+ j.current = $, B(!0), H(""), F(l("editor.ai.listening")), h({
658
+ signal: $.signal,
659
+ onPartialTranscript: (X) => {
660
+ $.signal.aborted || H(X);
661
+ },
662
+ onFinalTranscript: (X) => {
663
+ if ($.signal.aborted) return;
664
+ const Y = X.trim();
665
+ H(""), Y && (q((me) => tr(me, Y)), F(Y));
666
+ }
667
+ }).catch(() => {
668
+ }).finally(() => {
669
+ H(""), j.current === $ && (j.current = null, B(!1), F(""));
670
+ });
671
+ }, [h, l]), ue = y(() => {
672
+ T ? P() : Q();
673
+ }, [T, Q, P]);
674
+ D(() => {
675
+ var $, X;
676
+ o ? (q(""), z(!1), p(!1), v(null), H(""), F("")) : (($ = L.current) == null || $.abort(), L.current = null, (X = j.current) == null || X.abort());
677
+ }, [o]), D(
678
+ () => () => {
679
+ var $, X;
680
+ ($ = L.current) == null || $.abort(), (X = j.current) == null || X.abort();
681
+ },
682
+ []
683
+ );
684
+ const Ne = y(() => {
685
+ var Y;
686
+ const $ = A.trim();
687
+ if (!$ || E) return;
688
+ P(), (Y = L.current) == null || Y.abort();
689
+ const X = new AbortController();
690
+ L.current = X, p(!1), z(!0), d({ prompt: $, signal: X.signal }).then((me) => {
691
+ X.signal.aborted || (v(me), z(!1));
692
+ }).catch((me) => {
693
+ X.signal.aborted || me && typeof me == "object" && "name" in me && me.name === "AbortError" || (p(!0), z(!1));
694
+ });
695
+ }, [A, E, d, P]), ne = y(() => {
696
+ m != null && (c(m), i());
697
+ }, [m, c, i]), U = m != null, W = T ? tr(A, C) : A;
698
+ return /* @__PURE__ */ t(
699
+ gr,
700
+ {
701
+ open: o,
702
+ onClose: i,
703
+ ariaLabel: l("editor.ai.dialogTitle"),
704
+ children: U ? /* @__PURE__ */ x("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-sm)]", children: [
705
+ /* @__PURE__ */ t(
706
+ G,
707
+ {
708
+ size: "md",
709
+ intent: "outline",
710
+ className: Pe,
711
+ icon: /* @__PURE__ */ t(Qn, {}),
712
+ "aria-label": l("common.close"),
713
+ onClick: i
714
+ }
715
+ ),
716
+ /* @__PURE__ */ t("div", { className: "ds:min-w-0 ds:flex-1", children: g ? /* @__PURE__ */ t(
717
+ fo,
718
+ {
719
+ html: m,
720
+ profile: "rich-text",
721
+ className: er,
722
+ tabIndex: 0,
723
+ "aria-label": l("editor.ai.dialogTitle")
724
+ }
725
+ ) : (
726
+ // Focusable so a keyboard user can scroll a long draft preview
727
+ // (mirrors the SafeHtml preview branch above). The lint rule's
728
+ // tabIndex allowlist doesn't cover a scrollable, non-interactive
729
+ // text region.
730
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
731
+ /* @__PURE__ */ t("p", { className: er, tabIndex: 0, children: m })
732
+ ) }),
733
+ /* @__PURE__ */ t(
734
+ G,
735
+ {
736
+ size: "md",
737
+ intent: "outline",
738
+ className: `${Pe} ds:rounded-full`,
739
+ icon: /* @__PURE__ */ t(vo, {}),
740
+ "aria-label": l("editor.ai.retry"),
741
+ onClick: () => v(null)
742
+ }
743
+ ),
744
+ /* @__PURE__ */ t(
745
+ G,
746
+ {
747
+ size: "md",
748
+ intent: "primary",
749
+ className: `${Pe} ds:bg-[image:var(--gradient-brand)] ds:rounded-full`,
750
+ icon: /* @__PURE__ */ t(yo, {}),
751
+ "aria-label": l("common.confirm"),
752
+ onClick: ne
753
+ }
754
+ )
755
+ ] }) : /* @__PURE__ */ x(Ce, { children: [
756
+ /* @__PURE__ */ x("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-sm)]", children: [
757
+ /* @__PURE__ */ t(
758
+ G,
759
+ {
760
+ size: "md",
761
+ intent: "outline",
762
+ className: Pe,
763
+ icon: /* @__PURE__ */ t(Qn, {}),
764
+ "aria-label": l("common.close"),
765
+ onClick: i
766
+ }
767
+ ),
768
+ /* @__PURE__ */ t("div", { className: "ds:min-w-0 ds:flex-1", children: /* @__PURE__ */ t(
769
+ bo,
770
+ {
771
+ id: b,
772
+ size: "md",
773
+ value: W,
774
+ onChange: ($) => q($.target.value),
775
+ placeholder: l("editor.ai.promptPlaceholder"),
776
+ "aria-label": l("editor.ai.promptLabel"),
777
+ autoResize: !0,
778
+ minRows: 1,
779
+ maxRows: 3,
780
+ readOnly: T,
781
+ tone: K ? "error" : "default",
782
+ "aria-describedby": K ? k : void 0
783
+ }
784
+ ) }),
785
+ h ? /* @__PURE__ */ t(
786
+ G,
787
+ {
788
+ size: "md",
789
+ intent: "outline",
790
+ className: T ? `${Pe} ${Ga}` : Pe,
791
+ icon: T ? /* @__PURE__ */ t(at, { className: "ds:fill-current" }) : /* @__PURE__ */ t(ln, {}),
792
+ "aria-pressed": T,
793
+ "aria-label": l(T ? "editor.ai.dictateStop" : "editor.ai.dictateStart"),
794
+ onClick: ue
795
+ }
796
+ ) : null,
797
+ /* @__PURE__ */ t(
798
+ G,
799
+ {
800
+ size: "md",
801
+ intent: "primary",
802
+ icon: E ? /* @__PURE__ */ t(fr, { size: "sm", variant: "pulse" }) : /* @__PURE__ */ t(wo, {}),
803
+ className: `${Pe} ds:bg-[image:var(--gradient-brand)] ds:rounded-full`,
804
+ disabled: E || !A.trim(),
805
+ "aria-busy": E || void 0,
806
+ "aria-label": l("editor.ai.generate"),
807
+ onClick: Ne
808
+ }
809
+ )
810
+ ] }),
811
+ h ? /* @__PURE__ */ t("p", { className: "ds:sr-only", role: "status", "aria-live": "polite", children: S }) : null,
812
+ K ? /* @__PURE__ */ t("p", { id: k, role: "alert", className: Wa, children: l("editor.ai.error") }) : u ? /* @__PURE__ */ t("p", { className: Ka, children: u }) : null
813
+ ] })
814
+ }
815
+ );
816
+ }
817
+ const br = {
818
+ // Redactor's own history. AI rewrites push onto it too (see
819
+ // `pushUndoState` in rich-text-editor.tsx), so Undo steps back over them.
820
+ undo: {
821
+ id: "undo",
822
+ icon: /* @__PURE__ */ t(_o, {}),
823
+ label: ["editor.undo", "Undo"],
824
+ command: ["module.buffer.undo"]
825
+ },
826
+ redo: {
827
+ id: "redo",
828
+ icon: /* @__PURE__ */ t(Aa, {}),
829
+ label: ["editor.redo", "Redo"],
830
+ command: ["module.buffer.redo"]
831
+ },
832
+ bold: {
833
+ id: "bold",
834
+ icon: /* @__PURE__ */ t(Bo, {}),
835
+ label: ["editor.bold", "Bold"],
836
+ command: ["module.inline.format", { tag: "b" }],
837
+ toggle: "bold"
838
+ },
839
+ italic: {
840
+ id: "italic",
841
+ icon: /* @__PURE__ */ t(Qo, {}),
842
+ label: ["editor.italic", "Italic"],
843
+ command: ["module.inline.format", { tag: "i" }],
844
+ toggle: "italic"
845
+ },
846
+ underline: {
847
+ id: "underline",
848
+ icon: /* @__PURE__ */ t(qa, {}),
849
+ label: ["editor.underline", "Underline"],
850
+ command: ["module.inline.format", { tag: "u" }],
851
+ toggle: "underline"
852
+ },
853
+ strike: {
854
+ id: "strike",
855
+ icon: /* @__PURE__ */ t(za, {}),
856
+ label: ["editor.strike", "Strikethrough"],
857
+ command: ["module.inline.format", { tag: "del" }],
858
+ toggle: "strike"
859
+ },
860
+ ul: {
861
+ id: "ul",
862
+ icon: /* @__PURE__ */ t(oa, {}),
863
+ label: ["editor.list.bullet", "Bulleted list"],
864
+ command: ["module.list.toggle", "ul"],
865
+ toggle: "ul"
866
+ },
867
+ ol: {
868
+ id: "ol",
869
+ icon: /* @__PURE__ */ t(na, {}),
870
+ label: ["editor.list.ordered", "Numbered list"],
871
+ command: ["module.list.toggle", "ol"],
872
+ toggle: "ol"
873
+ }
874
+ }, an = [
875
+ {
876
+ id: "paragraph",
877
+ tag: "p",
878
+ icon: /* @__PURE__ */ t(wa, {}),
879
+ label: ["editor.paragraph", "Paragraph"]
880
+ },
881
+ {
882
+ id: "h2",
883
+ tag: "h2",
884
+ icon: /* @__PURE__ */ t(Vo, {}),
885
+ label: ["editor.heading2", "Heading 2"]
886
+ },
887
+ {
888
+ id: "h3",
889
+ tag: "h3",
890
+ icon: /* @__PURE__ */ t(Uo, {}),
891
+ label: ["editor.heading3", "Heading 3"]
892
+ },
893
+ {
894
+ id: "quote",
895
+ tag: "blockquote",
896
+ icon: /* @__PURE__ */ t(xa, {}),
897
+ label: ["editor.quote", "Quote"]
898
+ }
899
+ ], Xa = {
900
+ minimal: ["bold", "italic", "underline", "link"],
901
+ standard: [
902
+ "undo",
903
+ "redo",
904
+ "format",
905
+ "bold",
906
+ "italic",
907
+ "underline",
908
+ "strike",
909
+ "ul",
910
+ "ol",
911
+ "link"
912
+ ],
913
+ full: [
914
+ "undo",
915
+ "redo",
916
+ "format",
917
+ "bold",
918
+ "italic",
919
+ "underline",
920
+ "strike",
921
+ "ul",
922
+ "ol",
923
+ "link"
924
+ ]
925
+ }, vr = [
926
+ {
927
+ id: "rowAbove",
928
+ command: "plugin.table.addRowAbove",
929
+ icon: /* @__PURE__ */ t(Io, {}),
930
+ label: ["editor.table.rowAbove", "Add row above"]
931
+ },
932
+ {
933
+ id: "rowBelow",
934
+ command: "plugin.table.addRowBelow",
935
+ icon: /* @__PURE__ */ t(Lo, {}),
936
+ label: ["editor.table.rowBelow", "Add row below"]
937
+ },
938
+ {
939
+ id: "colLeft",
940
+ command: "plugin.table.addColumnLeft",
941
+ icon: /* @__PURE__ */ t(qo, {}),
942
+ label: ["editor.table.columnLeft", "Add column left"]
943
+ },
944
+ {
945
+ id: "colRight",
946
+ command: "plugin.table.addColumnRight",
947
+ icon: /* @__PURE__ */ t(Do, {}),
948
+ label: ["editor.table.columnRight", "Add column right"]
949
+ },
950
+ {
951
+ id: "addHead",
952
+ command: "plugin.table.addHead",
953
+ icon: /* @__PURE__ */ t(va, {}),
954
+ label: ["editor.table.addHeader", "Add header row"]
955
+ },
956
+ {
957
+ id: "deleteHead",
958
+ command: "plugin.table.deleteHead",
959
+ icon: /* @__PURE__ */ t(ha, {}),
960
+ label: ["editor.table.deleteHeader", "Remove header row"]
961
+ },
962
+ {
963
+ id: "deleteRow",
964
+ command: "plugin.table.deleteRow",
965
+ icon: /* @__PURE__ */ t(Na, {}),
966
+ label: ["editor.table.deleteRow", "Delete row"]
967
+ },
968
+ {
969
+ id: "deleteColumn",
970
+ command: "plugin.table.deleteColumn",
971
+ icon: /* @__PURE__ */ t(Ko, {}),
972
+ label: ["editor.table.deleteColumn", "Delete column"]
973
+ },
974
+ {
975
+ id: "deleteTable",
976
+ command: "plugin.table.deleteTable",
977
+ icon: /* @__PURE__ */ t(zo, {}),
978
+ label: ["editor.table.deleteTable", "Delete table"]
979
+ }
980
+ ], St = 6, Ua = fn(
981
+ [
982
+ "ds:@container/toolbar",
983
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
984
+ "ds:bg-[var(--background)] ds:p-[var(--spacing-xs)]",
985
+ "ds:shadow-[var(--shadow-md)]"
986
+ ].join(" ")
987
+ ), Za = "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)]", It = "ds:self-stretch ds:[inline-size:var(--border-width-sm)] ds:bg-[var(--border)] ds:[margin-inline:var(--spacing-2xs)]", it = "ds:text-[length:var(--font-size-sm)] ds:font-medium ds:text-[color:var(--foreground)]";
988
+ function Lt(o) {
989
+ return o.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
990
+ }
991
+ function Qa({
992
+ variables: o,
993
+ recentVariableTokens: i,
994
+ insertVariable: d,
995
+ saveSelection: c
996
+ }) {
997
+ const { t: g } = ae(), [u, h] = N(!1), [l, b] = N(""), k = _(null), A = _(!1), q = o;
998
+ return /* @__PURE__ */ x(
999
+ Et.Root,
1000
+ {
1001
+ open: u,
1002
+ onOpenChange: (E) => {
1003
+ E && c(), h(E), E && b("");
1004
+ },
1005
+ children: [
1006
+ /* @__PURE__ */ t(Et.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
1007
+ G,
1008
+ {
1009
+ ref: k,
1010
+ size: "sm",
1011
+ intent: "ghost",
1012
+ icon: /* @__PURE__ */ t(jo, {}),
1013
+ "aria-label": g("editor.insertVariable", "Insert variable")
1014
+ }
1015
+ ) }),
1016
+ /* @__PURE__ */ t(Et.Portal, { children: /* @__PURE__ */ t(
1017
+ Et.Content,
1018
+ {
1019
+ align: "start",
1020
+ sideOffset: 4,
1021
+ onCloseAutoFocus: (E) => {
1022
+ A.current && (E.preventDefault(), A.current = !1);
1023
+ },
1024
+ children: /* @__PURE__ */ t(
1025
+ pr,
1026
+ {
1027
+ variables: q,
1028
+ recentTokens: i,
1029
+ query: l,
1030
+ onQueryChange: b,
1031
+ searchFocusable: !0,
1032
+ "aria-label": g("editor.insertVariable", "Insert variable"),
1033
+ onSelect: (E) => {
1034
+ A.current = !0, d(E.token), h(!1);
1035
+ },
1036
+ onClose: () => h(!1)
1037
+ }
1038
+ )
1039
+ }
1040
+ ) })
1041
+ ]
1042
+ }
1043
+ );
1044
+ }
1045
+ function Ya({
1046
+ run: o,
1047
+ active: i,
1048
+ onTriggerDown: d
1049
+ }) {
1050
+ const { t: c } = ae(), g = an.find((u) => i.has(u.id)) ?? an[0];
1051
+ return /* @__PURE__ */ x(he.Root, { children: [
1052
+ /* @__PURE__ */ t(he.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
1053
+ Ae,
1054
+ {
1055
+ size: "sm",
1056
+ intent: "ghost",
1057
+ startIcon: g.icon,
1058
+ endIcon: /* @__PURE__ */ t(hr, {}),
1059
+ "aria-label": `${c("editor.format", "Paragraph style")}: ${c(
1060
+ g.label[0],
1061
+ g.label[1]
1062
+ )}`,
1063
+ onMouseDown: d,
1064
+ children: /* @__PURE__ */ t("span", { className: "ds:hidden ds:@[448px]/toolbar:inline", children: c(g.label[0], g.label[1]) })
1065
+ }
1066
+ ) }),
1067
+ /* @__PURE__ */ t(he.Content, { align: "start", children: an.map((u) => /* @__PURE__ */ t(
1068
+ he.Item,
1069
+ {
1070
+ startIcon: u.icon,
1071
+ onSelect: () => o("module.block.format", { tag: u.tag }),
1072
+ children: c(u.label[0], u.label[1])
1073
+ },
1074
+ u.id
1075
+ )) })
1076
+ ] });
1077
+ }
1078
+ function Ja({
1079
+ insertHtml: o,
1080
+ saveSelection: i,
1081
+ restoreSelection: d,
1082
+ getSelectedText: c
1083
+ }) {
1084
+ const { t: g } = ae(), [u, h] = N(!1), [l, b] = N(""), [k, A] = N(""), [q, E] = N(!1), z = Ee(), K = Ee(), p = () => {
1085
+ b(""), A(""), E(!1);
1086
+ }, m = () => {
1087
+ const v = l.trim();
1088
+ if (!v) return;
1089
+ const L = k.trim() || v, T = q ? ' target="_blank" rel="noopener noreferrer"' : "", B = `<a href="${Lt(v)}"${T}>${Lt(L)}</a>`;
1090
+ h(!1), p(), window.requestAnimationFrame(() => {
1091
+ d(), o(B);
1092
+ });
1093
+ };
1094
+ return /* @__PURE__ */ x(te.Root, { open: u, onOpenChange: h, children: [
1095
+ /* @__PURE__ */ t(te.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
1096
+ G,
1097
+ {
1098
+ size: "sm",
1099
+ intent: "ghost",
1100
+ icon: /* @__PURE__ */ t(ea, {}),
1101
+ "aria-label": g("editor.link.insert", "Insert link"),
1102
+ onMouseDown: () => {
1103
+ i(), A(c());
1104
+ }
1105
+ }
1106
+ ) }),
1107
+ /* @__PURE__ */ x(te.Content, { children: [
1108
+ /* @__PURE__ */ t(te.Header, { children: /* @__PURE__ */ t(te.Title, { children: g("editor.link.insert", "Insert link") }) }),
1109
+ /* @__PURE__ */ x(te.Body, { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
1110
+ /* @__PURE__ */ x("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
1111
+ /* @__PURE__ */ t("label", { htmlFor: z, className: it, children: g("editor.link.url", "URL") }),
1112
+ /* @__PURE__ */ t(
1113
+ Rt,
1114
+ {
1115
+ id: z,
1116
+ type: "url",
1117
+ value: l,
1118
+ onChange: (v) => b(v.target.value),
1119
+ placeholder: "https://…"
1120
+ }
1121
+ )
1122
+ ] }),
1123
+ /* @__PURE__ */ x("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
1124
+ /* @__PURE__ */ t("label", { htmlFor: K, className: it, children: g("editor.link.text", "Text to display") }),
1125
+ /* @__PURE__ */ t(
1126
+ Rt,
1127
+ {
1128
+ id: K,
1129
+ value: k,
1130
+ onChange: (v) => A(v.target.value),
1131
+ placeholder: g("editor.link.textPlaceholder", "Link text")
1132
+ }
1133
+ )
1134
+ ] }),
1135
+ /* @__PURE__ */ t(
1136
+ ko,
1137
+ {
1138
+ checked: q,
1139
+ onCheckedChange: (v) => E(v === !0),
1140
+ label: g("editor.link.newTab", "Open in new tab")
1141
+ }
1142
+ )
1143
+ ] }),
1144
+ /* @__PURE__ */ x(te.Footer, { children: [
1145
+ /* @__PURE__ */ t(te.Close, { asChild: !0, children: /* @__PURE__ */ t(Ae, { intent: "secondary", children: g("common.cancel") }) }),
1146
+ /* @__PURE__ */ t(Ae, { onClick: m, disabled: !l.trim(), children: g("editor.link.insertAction", "Insert") })
1147
+ ] })
1148
+ ] })
1149
+ ] });
1150
+ }
1151
+ function ei({
1152
+ insertHtml: o,
1153
+ saveSelection: i,
1154
+ restoreSelection: d,
1155
+ uploadImage: c
1156
+ }) {
1157
+ const { t: g } = ae(), [u, h] = N(!1), [l, b] = N(""), [k, A] = N(""), q = Ee(), E = Ee(), z = (p, m) => {
1158
+ const v = `<img src="${Lt(p)}" alt="${Lt(m)}" loading="lazy">`;
1159
+ h(!1), b(""), A(""), window.requestAnimationFrame(() => {
1160
+ d(), o(v);
1161
+ });
1162
+ }, K = () => {
1163
+ const p = l.trim();
1164
+ p && z(p, k.trim());
1165
+ };
1166
+ return /* @__PURE__ */ x(te.Root, { open: u, onOpenChange: h, children: [
1167
+ /* @__PURE__ */ t(te.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
1168
+ G,
1169
+ {
1170
+ size: "sm",
1171
+ intent: "ghost",
1172
+ icon: /* @__PURE__ */ t(No, {}),
1173
+ "aria-label": g("editor.image.insert", "Insert image"),
1174
+ onMouseDown: () => i()
1175
+ }
1176
+ ) }),
1177
+ /* @__PURE__ */ x(te.Content, { children: [
1178
+ /* @__PURE__ */ t(te.Header, { children: /* @__PURE__ */ t(te.Title, { children: g("editor.image.insert", "Insert image") }) }),
1179
+ /* @__PURE__ */ x(te.Body, { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
1180
+ c ? /* @__PURE__ */ x("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
1181
+ /* @__PURE__ */ t("span", { className: it, children: g("editor.image.upload", "Upload") }),
1182
+ /* @__PURE__ */ t(
1183
+ xo,
1184
+ {
1185
+ variant: "dropzone",
1186
+ accept: {
1187
+ "image/*": [".png", ".jpg", ".jpeg", ".gif", ".webp", ".svg"]
1188
+ },
1189
+ maxFiles: 1,
1190
+ onUpload: async (p, { signal: m }) => {
1191
+ const v = await c(p, m);
1192
+ z(v, p.name);
1193
+ }
1194
+ }
1195
+ ),
1196
+ /* @__PURE__ */ t("span", { className: "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)]", children: g("editor.image.orUrl", "Or paste an image URL") })
1197
+ ] }) : null,
1198
+ /* @__PURE__ */ x("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
1199
+ /* @__PURE__ */ t("label", { htmlFor: q, className: it, children: g("editor.image.url", "Image URL") }),
1200
+ /* @__PURE__ */ t(
1201
+ Rt,
1202
+ {
1203
+ id: q,
1204
+ type: "url",
1205
+ value: l,
1206
+ onChange: (p) => b(p.target.value),
1207
+ placeholder: "https://…"
1208
+ }
1209
+ )
1210
+ ] }),
1211
+ /* @__PURE__ */ x("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
1212
+ /* @__PURE__ */ t("label", { htmlFor: E, className: it, children: g("editor.image.alt", "Alt text") }),
1213
+ /* @__PURE__ */ t(
1214
+ Rt,
1215
+ {
1216
+ id: E,
1217
+ value: k,
1218
+ onChange: (p) => A(p.target.value),
1219
+ placeholder: g(
1220
+ "editor.image.altPlaceholder",
1221
+ "Describe the image"
1222
+ )
1223
+ }
1224
+ )
1225
+ ] })
1226
+ ] }),
1227
+ /* @__PURE__ */ x(te.Footer, { children: [
1228
+ /* @__PURE__ */ t(te.Close, { asChild: !0, children: /* @__PURE__ */ t(Ae, { intent: "secondary", children: g("common.cancel") }) }),
1229
+ /* @__PURE__ */ t(Ae, { onClick: K, disabled: !l.trim(), children: g("editor.image.insertAction", "Insert") })
1230
+ ] })
1231
+ ] })
1232
+ ] });
1233
+ }
1234
+ function ti({
1235
+ run: o,
1236
+ saveSelection: i,
1237
+ restoreSelection: d
1238
+ }) {
1239
+ const { t: c } = ae(), [g, u] = N("#1f2a5c"), h = (b) => {
1240
+ u(b), d(), o("module.inline.format", {
1241
+ tag: "span",
1242
+ style: { color: b },
1243
+ type: "toggle"
1244
+ });
1245
+ }, l = () => {
1246
+ d(), o("module.inline.remove", { style: "color" });
1247
+ };
1248
+ return /* @__PURE__ */ x(Z, { onOpenChange: (b) => b && i(), children: [
1249
+ /* @__PURE__ */ t(Z.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
1250
+ G,
1251
+ {
1252
+ size: "sm",
1253
+ intent: "ghost",
1254
+ icon: /* @__PURE__ */ t(da, {}),
1255
+ "aria-label": c("editor.textColor", "Text colour"),
1256
+ onMouseDown: (b) => {
1257
+ b.preventDefault(), i();
1258
+ }
1259
+ }
1260
+ ) }),
1261
+ /* @__PURE__ */ x(Z.Content, { side: "bottom", align: "start", children: [
1262
+ /* @__PURE__ */ t(Z.Heading, { children: c("editor.textColor", "Text colour") }),
1263
+ /* @__PURE__ */ t("div", { className: "ds:pt-[var(--spacing-sm)]", children: /* @__PURE__ */ t(
1264
+ pn,
1265
+ {
1266
+ variant: "inline",
1267
+ size: "sm",
1268
+ value: g,
1269
+ onChange: h
1270
+ }
1271
+ ) }),
1272
+ /* @__PURE__ */ t("div", { className: "ds:mt-[var(--spacing-sm)] ds:flex ds:items-center ds:justify-end", children: /* @__PURE__ */ t(Ae, { size: "sm", intent: "secondary", onClick: l, children: c("editor.color.remove", "Remove colour") }) })
1273
+ ] })
1274
+ ] });
1275
+ }
1276
+ function ni({
1277
+ run: o,
1278
+ saveSelection: i,
1279
+ restoreSelection: d
1280
+ }) {
1281
+ const { t: c } = ae(), [g, u] = N("#fff3a3"), h = (b) => {
1282
+ u(b), d(), o("module.inline.format", {
1283
+ tag: "span",
1284
+ style: { "background-color": b },
1285
+ type: "toggle"
1286
+ });
1287
+ }, l = () => {
1288
+ d(), o("module.inline.remove", { style: "background-color" });
1289
+ };
1290
+ return /* @__PURE__ */ x(Z, { onOpenChange: (b) => b && i(), children: [
1291
+ /* @__PURE__ */ t(Z.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
1292
+ G,
1293
+ {
1294
+ size: "sm",
1295
+ intent: "ghost",
1296
+ icon: /* @__PURE__ */ t(Ao, {}),
1297
+ "aria-label": c("editor.highlightColor", "Highlight"),
1298
+ onMouseDown: (b) => {
1299
+ b.preventDefault(), i();
1300
+ }
1301
+ }
1302
+ ) }),
1303
+ /* @__PURE__ */ x(Z.Content, { side: "bottom", align: "start", children: [
1304
+ /* @__PURE__ */ t(Z.Heading, { children: c("editor.highlightColor", "Highlight") }),
1305
+ /* @__PURE__ */ t("div", { className: "ds:pt-[var(--spacing-sm)]", children: /* @__PURE__ */ t(
1306
+ pn,
1307
+ {
1308
+ variant: "inline",
1309
+ size: "sm",
1310
+ value: g,
1311
+ onChange: h
1312
+ }
1313
+ ) }),
1314
+ /* @__PURE__ */ t("div", { className: "ds:mt-[var(--spacing-sm)] ds:flex ds:items-center ds:justify-end", children: /* @__PURE__ */ t(Ae, { size: "sm", intent: "secondary", onClick: l, children: c("editor.highlight.remove", "Remove highlight") }) })
1315
+ ] })
1316
+ ] });
1317
+ }
1318
+ function ri(o, i) {
1319
+ const d = Array.from({ length: i }, () => "<td><br></td>").join("");
1320
+ return `<table><tbody>${Array.from({ length: o }, () => `<tr>${d}</tr>`).join("")}</tbody></table>`;
1321
+ }
1322
+ function oi({
1323
+ run: o,
1324
+ insertTable: i,
1325
+ active: d
1326
+ }) {
1327
+ const { t: c } = ae(), [g, u] = N({ r: 0, c: 0 }), h = d.has("table");
1328
+ return /* @__PURE__ */ x(Z, { onOpenChange: (l) => !l && u({ r: 0, c: 0 }), children: [
1329
+ /* @__PURE__ */ t(Z.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
1330
+ G,
1331
+ {
1332
+ size: "sm",
1333
+ intent: "ghost",
1334
+ icon: /* @__PURE__ */ t(Ma, {}),
1335
+ "aria-label": c("editor.table.insert", "Insert table"),
1336
+ onMouseDown: (l) => l.preventDefault()
1337
+ }
1338
+ ) }),
1339
+ /* @__PURE__ */ t(Z.Content, { side: "bottom", align: "start", children: h ? (
1340
+ // Caret is already inside a table — offer the manage ops only, never
1341
+ // a nested-table insert (mirrors Redactor's native dropdown, which
1342
+ // disables "insert table" while the caret is in a table).
1343
+ /* @__PURE__ */ t("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)]", children: vr.map((l) => /* @__PURE__ */ x(
1344
+ "button",
1345
+ {
1346
+ type: "button",
1347
+ onClick: () => o(l.command),
1348
+ className: "ds:flex ds:items-center ds:gap-[var(--spacing-sm)] ds:rounded-[var(--radius-sm)] ds:px-[var(--spacing-sm)] ds:py-[var(--spacing-2xs)] ds:text-start ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--foreground)] ds:hover:bg-[var(--muted)]",
1349
+ children: [
1350
+ /* @__PURE__ */ t(
1351
+ "span",
1352
+ {
1353
+ "aria-hidden": "true",
1354
+ className: "ds:inline-flex ds:size-4 ds:shrink-0 ds:items-center ds:justify-center ds:text-[color:var(--muted-foreground)]",
1355
+ children: l.icon
1356
+ }
1357
+ ),
1358
+ c(l.label[0], l.label[1])
1359
+ ]
1360
+ },
1361
+ l.id
1362
+ )) })
1363
+ ) : /* @__PURE__ */ x(Ce, { children: [
1364
+ /* @__PURE__ */ t(Z.Heading, { children: c("editor.table.insert", "Insert table") }),
1365
+ /* @__PURE__ */ t(
1366
+ "div",
1367
+ {
1368
+ role: "group",
1369
+ "aria-label": c("editor.table.sizePicker", "Table size"),
1370
+ className: "ds:mt-[var(--spacing-sm)] ds:grid ds:w-fit ds:grid-cols-6 ds:gap-[var(--spacing-2xs)]",
1371
+ onMouseLeave: () => u({ r: 0, c: 0 }),
1372
+ children: Array.from({ length: St * St }, (l, b) => {
1373
+ const k = Math.floor(b / St) + 1, A = b % St + 1, q = k <= g.r && A <= g.c;
1374
+ return /* @__PURE__ */ t(
1375
+ "button",
1376
+ {
1377
+ type: "button",
1378
+ "aria-label": c("editor.table.sizeCell", "{{r}}×{{c}}", {
1379
+ r: k,
1380
+ c: A
1381
+ }),
1382
+ onMouseEnter: () => u({ r: k, c: A }),
1383
+ onClick: () => i(ri(k, A)),
1384
+ className: `ds:size-5 ds:rounded-[var(--radius-sm)] ds:border ds:border-[color:var(--border)] ${q ? "ds:bg-[var(--primary)]" : "ds:bg-[var(--muted)]"}`
1385
+ },
1386
+ b
1387
+ );
1388
+ })
1389
+ }
1390
+ ),
1391
+ /* @__PURE__ */ t("p", { className: "ds:mt-[var(--spacing-xs)] ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)]", children: g.r > 0 ? c("editor.table.sizeCell", "{{r}}×{{c}}", {
1392
+ r: g.r,
1393
+ c: g.c
1394
+ }) : c("editor.table.sizeHint", "Pick a size") })
1395
+ ] }) })
1396
+ ] });
1397
+ }
1398
+ const ai = Object.fromEntries(vr.map((o) => [o.id, o])), ii = [
1399
+ "ds:absolute ds:z-20 ds:flex ds:items-center ds:gap-[var(--spacing-2xs)]",
1400
+ "ds:[inset-block-start:var(--rte-tt-top)] ds:[inset-inline-start:var(--rte-tt-start)]",
1401
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
1402
+ "ds:bg-[var(--popover)] ds:p-[var(--spacing-2xs)] ds:shadow-[var(--shadow-lg)]"
1403
+ ].join(" "), si = "#fde68a";
1404
+ function nr({
1405
+ scope: o,
1406
+ icon: i,
1407
+ label: d,
1408
+ onOpenChange: c,
1409
+ saveTableCell: g,
1410
+ applyTableBackground: u
1411
+ }) {
1412
+ const { t: h } = ae(), [l, b] = N(si);
1413
+ return /* @__PURE__ */ x(
1414
+ Z,
1415
+ {
1416
+ onOpenChange: (k) => {
1417
+ c(k), k && g();
1418
+ },
1419
+ children: [
1420
+ /* @__PURE__ */ t(Z.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
1421
+ G,
1422
+ {
1423
+ size: "sm",
1424
+ intent: "ghost",
1425
+ icon: i,
1426
+ tooltip: d,
1427
+ onMouseDown: (k) => k.preventDefault()
1428
+ }
1429
+ ) }),
1430
+ /* @__PURE__ */ x(Z.Content, { side: "bottom", align: "center", children: [
1431
+ /* @__PURE__ */ t(
1432
+ pn,
1433
+ {
1434
+ variant: "inline",
1435
+ size: "sm",
1436
+ value: l,
1437
+ onChange: (k) => {
1438
+ b(k), u(o, k);
1439
+ }
1440
+ }
1441
+ ),
1442
+ /* @__PURE__ */ t(
1443
+ Ae,
1444
+ {
1445
+ size: "sm",
1446
+ intent: "ghost",
1447
+ className: "ds:mt-[var(--spacing-xs)] ds:w-full",
1448
+ onClick: () => u(o, null),
1449
+ children: h("editor.table.clearColor", "Clear colour")
1450
+ }
1451
+ )
1452
+ ] })
1453
+ ]
1454
+ }
1455
+ );
1456
+ }
1457
+ function li({
1458
+ active: o,
1459
+ run: i,
1460
+ areaRef: d,
1461
+ getActiveTableEl: c,
1462
+ enableColor: g = !1,
1463
+ saveTableCell: u,
1464
+ applyTableBackground: h
1465
+ }) {
1466
+ const { t: l } = ae(), b = o.has("table"), [k, A] = N(null), q = _(0), [E, z] = N(!1), K = y((m) => {
1467
+ q.current = Math.max(
1468
+ 0,
1469
+ q.current + (m ? 1 : -1)
1470
+ ), z(q.current > 0);
1471
+ }, []);
1472
+ if (D(() => {
1473
+ if (E) return;
1474
+ if (!b || typeof window > "u") {
1475
+ A(null);
1476
+ return;
1477
+ }
1478
+ const m = () => {
1479
+ const B = d.current, C = c();
1480
+ if (!B || !C) {
1481
+ A(null);
1482
+ return;
1483
+ }
1484
+ const H = B.getBoundingClientRect(), S = C.getBoundingClientRect(), F = getComputedStyle(B).direction === "rtl", j = Math.max(0, S.top - H.top - 44), P = F ? H.right - S.right + S.width / 2 : S.left - H.left + S.width / 2;
1485
+ A({ top: j, start: Math.max(0, P), rtl: F });
1486
+ };
1487
+ m();
1488
+ const v = new ResizeObserver(m), L = d.current, T = c();
1489
+ return L && v.observe(L), T && v.observe(T), window.addEventListener("scroll", m, !0), window.addEventListener("resize", m), () => {
1490
+ v.disconnect(), window.removeEventListener("scroll", m, !0), window.removeEventListener("resize", m);
1491
+ };
1492
+ }, [b, E, d, c]), !b && !E || !k) return null;
1493
+ const p = [
1494
+ ["rowAbove", "rowBelow"],
1495
+ ["colLeft", "colRight"],
1496
+ ["addHead"],
1497
+ ...g ? ["colour"] : [],
1498
+ ["deleteRow", "deleteColumn"],
1499
+ ["deleteTable"]
1500
+ ];
1501
+ return (
1502
+ // Tooltips disambiguate the icon-only ops on hover (and provide each
1503
+ // button's accessible name via IconButton's `tooltip` prop). Radix Tooltip
1504
+ // needs a provider ancestor, so scope one to the bar.
1505
+ /* @__PURE__ */ t(gn, { children: /* @__PURE__ */ t(
1506
+ "div",
1507
+ {
1508
+ role: "group",
1509
+ "aria-label": l("editor.table.toolbar", "Table tools"),
1510
+ className: `${ii} ${k.rtl ? "ds:translate-x-1/2" : "ds:-translate-x-1/2"}`,
1511
+ style: {
1512
+ "--rte-tt-top": `${k.top}px`,
1513
+ "--rte-tt-start": `${k.start}px`
1514
+ },
1515
+ children: p.map((m, v) => /* @__PURE__ */ x($t, { children: [
1516
+ v > 0 ? /* @__PURE__ */ t("span", { "aria-hidden": "true", className: It }) : null,
1517
+ m === "colour" ? /* @__PURE__ */ x(Ce, { children: [
1518
+ /* @__PURE__ */ t(
1519
+ nr,
1520
+ {
1521
+ scope: "cell",
1522
+ icon: /* @__PURE__ */ t(ia, {}),
1523
+ label: l("editor.table.cellColor", "Cell colour"),
1524
+ onOpenChange: K,
1525
+ saveTableCell: u,
1526
+ applyTableBackground: h
1527
+ }
1528
+ ),
1529
+ /* @__PURE__ */ t(
1530
+ nr,
1531
+ {
1532
+ scope: "row",
1533
+ icon: /* @__PURE__ */ t(la, {}),
1534
+ label: l("editor.table.rowColor", "Row colour"),
1535
+ onOpenChange: K,
1536
+ saveTableCell: u,
1537
+ applyTableBackground: h
1538
+ }
1539
+ )
1540
+ ] }) : m.map((L) => {
1541
+ const T = ai[L];
1542
+ return /* @__PURE__ */ t(
1543
+ G,
1544
+ {
1545
+ size: "sm",
1546
+ intent: "ghost",
1547
+ icon: T.icon,
1548
+ tooltip: l(T.label[0], T.label[1]),
1549
+ onMouseDown: (B) => B.preventDefault(),
1550
+ onClick: () => i(T.command)
1551
+ },
1552
+ L
1553
+ );
1554
+ })
1555
+ ] }, m === "colour" ? "colour" : m[0]))
1556
+ }
1557
+ ) })
1558
+ );
1559
+ }
1560
+ const dn = [
1561
+ "wysiwyg-img-inline",
1562
+ "wysiwyg-img-wrap-left",
1563
+ "wysiwyg-img-wrap-right"
1564
+ ], yr = [
1565
+ "wysiwyg-img-align-left",
1566
+ "wysiwyg-img-align-center",
1567
+ "wysiwyg-img-align-right"
1568
+ ];
1569
+ function rr(o, i) {
1570
+ return i.find((d) => o.classList.contains(d)) ?? "";
1571
+ }
1572
+ function ci(o) {
1573
+ const i = o.closest(".redactor-in"), d = i instanceof HTMLElement ? i.clientWidth : 0, c = o.getBoundingClientRect().width;
1574
+ return d <= 0 || c <= 0 ? st : Math.round(Math.min(st, c / d * 100));
1575
+ }
1576
+ const un = 10, st = 100, di = 5, ui = 10, or = (o) => Math.min(st, Math.max(un, Math.round(o))), mi = [
1577
+ {
1578
+ id: "wysiwyg-img-inline",
1579
+ icon: /* @__PURE__ */ t(Mo, {}),
1580
+ label: ["editor.image.inline", "Inline with text"]
1581
+ },
1582
+ {
1583
+ id: "wysiwyg-img-wrap-left",
1584
+ icon: /* @__PURE__ */ t(ma, {}),
1585
+ label: ["editor.image.wrapLeft", "Wrap left"]
1586
+ },
1587
+ {
1588
+ id: "wysiwyg-img-wrap-right",
1589
+ icon: /* @__PURE__ */ t(ga, {}),
1590
+ label: ["editor.image.wrapRight", "Wrap right"]
1591
+ }
1592
+ ], fi = [
1593
+ {
1594
+ id: "wysiwyg-img-align-left",
1595
+ icon: /* @__PURE__ */ t(Da, {}),
1596
+ label: ["editor.image.alignLeft", "Align left"]
1597
+ },
1598
+ {
1599
+ id: "wysiwyg-img-align-center",
1600
+ icon: /* @__PURE__ */ t(La, {}),
1601
+ label: ["editor.image.alignCenter", "Align centre"]
1602
+ },
1603
+ {
1604
+ id: "wysiwyg-img-align-right",
1605
+ icon: /* @__PURE__ */ t(Ia, {}),
1606
+ label: ["editor.image.alignRight", "Align right"]
1607
+ }
1608
+ ], gi = [
1609
+ {
1610
+ id: "tl",
1611
+ pos: "ds:[inset-block-start:calc(var(--spacing-md)*-0.5)] ds:[inset-inline-start:calc(var(--spacing-md)*-0.5)]",
1612
+ cursor: "ds:cursor-nwse-resize",
1613
+ sign: -1,
1614
+ labelKey: "editor.image.resizeTopStart",
1615
+ labelFallback: "Resize image, top-start corner"
1616
+ },
1617
+ {
1618
+ id: "tr",
1619
+ pos: "ds:[inset-block-start:calc(var(--spacing-md)*-0.5)] ds:[inset-inline-end:calc(var(--spacing-md)*-0.5)]",
1620
+ cursor: "ds:cursor-nesw-resize",
1621
+ sign: 1,
1622
+ labelKey: "editor.image.resizeTopEnd",
1623
+ labelFallback: "Resize image, top-end corner"
1624
+ },
1625
+ {
1626
+ id: "bl",
1627
+ pos: "ds:[inset-block-end:calc(var(--spacing-md)*-0.5)] ds:[inset-inline-start:calc(var(--spacing-md)*-0.5)]",
1628
+ cursor: "ds:cursor-nesw-resize",
1629
+ sign: -1,
1630
+ labelKey: "editor.image.resizeBottomStart",
1631
+ labelFallback: "Resize image, bottom-start corner"
1632
+ },
1633
+ {
1634
+ id: "br",
1635
+ pos: "ds:[inset-block-end:calc(var(--spacing-md)*-0.5)] ds:[inset-inline-end:calc(var(--spacing-md)*-0.5)]",
1636
+ cursor: "ds:cursor-nwse-resize",
1637
+ sign: 1,
1638
+ labelKey: "editor.image.resizeBottomEnd",
1639
+ labelFallback: "Resize image, bottom-end corner"
1640
+ }
1641
+ ], pi = [
1642
+ "ds:absolute ds:z-20 ds:pointer-events-none",
1643
+ "ds:[inset-block-start:var(--rte-img-top)] ds:[inset-inline-start:var(--rte-img-start)]",
1644
+ "ds:[inline-size:var(--rte-img-width)] ds:[block-size:var(--rte-img-height)]",
1645
+ "ds:rounded-[var(--radius-2xs)]",
1646
+ "ds:[outline-style:solid] ds:[outline-width:var(--border-width-md)]",
1647
+ "ds:[outline-color:var(--accent)] ds:[outline-offset:var(--focus-ring-offset)]"
1648
+ ].join(" "), hi = [
1649
+ "ds:absolute ds:pointer-events-auto ds:touch-none",
1650
+ "ds:[inline-size:var(--spacing-md)] ds:[block-size:var(--spacing-md)]",
1651
+ "ds:rounded-[var(--radius-2xs)] ds:shadow-[var(--shadow-sm)]",
1652
+ "ds:bg-[var(--accent)] ds:border ds:border-[color:var(--background)]",
1653
+ "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
1654
+ "ds:focus-visible:outline-solid ds:focus-visible:outline-[var(--ring)]",
1655
+ "ds:focus-visible:[outline-offset:var(--focus-ring-offset)]",
1656
+ "ds:forced-colors:bg-[CanvasText]"
1657
+ ].join(" "), bi = [
1658
+ "ds:absolute ds:z-20 ds:flex ds:items-center ds:gap-[var(--spacing-2xs)]",
1659
+ "ds:[inset-block-start:var(--rte-img-bar-top)] ds:[inset-inline-start:var(--rte-img-center)]",
1660
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
1661
+ "ds:bg-[var(--popover)] ds:p-[var(--spacing-2xs)] ds:shadow-[var(--shadow-lg)]"
1662
+ ].join(" ");
1663
+ function vi({
1664
+ areaRef: o,
1665
+ activeImageEl: i,
1666
+ applyImageClass: d,
1667
+ setImageWidth: c
1668
+ }) {
1669
+ const { t: g } = ae(), [u, h] = N(null), l = _(null);
1670
+ D(() => {
1671
+ if (!i || typeof window > "u") {
1672
+ h(null);
1673
+ return;
1674
+ }
1675
+ const p = () => {
1676
+ const B = o.current;
1677
+ if (!B) {
1678
+ h(null);
1679
+ return;
1680
+ }
1681
+ const C = B.getBoundingClientRect(), H = i.getBoundingClientRect(), S = getComputedStyle(B).direction === "rtl", F = H.top - C.top, j = S ? C.right - H.right : H.left - C.left, P = j + H.width / 2, Q = Math.max(0, F - 44);
1682
+ h({
1683
+ top: F,
1684
+ start: Math.max(0, j),
1685
+ width: H.width,
1686
+ height: H.height,
1687
+ center: Math.max(0, P),
1688
+ barTop: Q,
1689
+ pct: ci(i),
1690
+ rtl: S
1691
+ });
1692
+ };
1693
+ p();
1694
+ const m = new ResizeObserver(p);
1695
+ m.observe(i);
1696
+ const v = o.current;
1697
+ v && m.observe(v);
1698
+ const L = i.closest(".redactor-in");
1699
+ let T = null;
1700
+ return L && (T = new MutationObserver(p), T.observe(L, {
1701
+ subtree: !0,
1702
+ childList: !0,
1703
+ characterData: !0,
1704
+ attributes: !0,
1705
+ attributeFilter: ["class", "style", "width", "height", "src"]
1706
+ })), window.addEventListener("scroll", p, !0), window.addEventListener("resize", p), () => {
1707
+ m.disconnect(), T == null || T.disconnect(), window.removeEventListener("scroll", p, !0), window.removeEventListener("resize", p);
1708
+ };
1709
+ }, [i, o]);
1710
+ const b = y(
1711
+ (p) => (m) => {
1712
+ !m.isPrimary || !u || (m.preventDefault(), m.currentTarget.setPointerCapture(m.pointerId), l.current = {
1713
+ pointerId: m.pointerId,
1714
+ startX: m.clientX,
1715
+ startPct: u.pct,
1716
+ sign: p.sign * (u.rtl ? -1 : 1)
1717
+ });
1718
+ },
1719
+ [u]
1720
+ ), k = y(
1721
+ (p) => {
1722
+ const m = l.current;
1723
+ if (!m || p.pointerId !== m.pointerId || !i) return;
1724
+ const v = i.closest(".redactor-in"), L = v instanceof HTMLElement ? v.clientWidth : 0;
1725
+ if (L <= 0) return;
1726
+ const T = m.sign * (p.clientX - m.startX) / L * 100;
1727
+ c(or(m.startPct + T));
1728
+ },
1729
+ [i, c]
1730
+ ), A = y(
1731
+ (p) => {
1732
+ const m = l.current;
1733
+ !m || p.pointerId !== m.pointerId || (p.currentTarget.releasePointerCapture(p.pointerId), l.current = null);
1734
+ },
1735
+ []
1736
+ ), q = y(
1737
+ (p) => {
1738
+ if (!u) return;
1739
+ let m = null;
1740
+ const v = p.shiftKey ? ui : di;
1741
+ switch (p.key) {
1742
+ // Up / right always grow; down / left always shrink — independent of
1743
+ // which corner has focus, so the gesture reads the same everywhere.
1744
+ case "ArrowRight":
1745
+ case "ArrowUp":
1746
+ m = u.pct + v;
1747
+ break;
1748
+ case "ArrowLeft":
1749
+ case "ArrowDown":
1750
+ m = u.pct - v;
1751
+ break;
1752
+ case "Home":
1753
+ m = un;
1754
+ break;
1755
+ case "End":
1756
+ m = st;
1757
+ break;
1758
+ default:
1759
+ return;
1760
+ }
1761
+ p.preventDefault(), c(or(m));
1762
+ },
1763
+ [u, c]
1764
+ );
1765
+ if (!i || !u) return null;
1766
+ const E = rr(i, dn), z = rr(i, yr), K = g("editor.image.widthAnnounce", {
1767
+ width: u.pct,
1768
+ defaultValue: "{{width}} percent"
1769
+ });
1770
+ return /* @__PURE__ */ x(Ce, { children: [
1771
+ /* @__PURE__ */ t(
1772
+ "div",
1773
+ {
1774
+ className: pi,
1775
+ style: {
1776
+ "--rte-img-top": `${u.top}px`,
1777
+ "--rte-img-start": `${u.start}px`,
1778
+ "--rte-img-width": `${u.width}px`,
1779
+ "--rte-img-height": `${u.height}px`
1780
+ },
1781
+ children: gi.map((p) => /* @__PURE__ */ t(
1782
+ "div",
1783
+ {
1784
+ role: "slider",
1785
+ tabIndex: 0,
1786
+ "aria-label": g(p.labelKey, p.labelFallback),
1787
+ "aria-orientation": "horizontal",
1788
+ "aria-valuemin": un,
1789
+ "aria-valuemax": st,
1790
+ "aria-valuenow": u.pct,
1791
+ "aria-valuetext": K,
1792
+ className: `${hi} ${p.pos} ${p.cursor}`,
1793
+ onPointerDown: b(p),
1794
+ onPointerMove: k,
1795
+ onPointerUp: A,
1796
+ onPointerCancel: A,
1797
+ onKeyDown: q
1798
+ },
1799
+ p.id
1800
+ ))
1801
+ }
1802
+ ),
1803
+ /* @__PURE__ */ t(gn, { children: /* @__PURE__ */ t(
1804
+ "div",
1805
+ {
1806
+ role: "group",
1807
+ "aria-label": g("editor.image.toolbar", "Image tools"),
1808
+ className: `${bi} ${u.rtl ? "ds:translate-x-1/2" : "ds:-translate-x-1/2"}`,
1809
+ style: {
1810
+ "--rte-img-bar-top": `${u.barTop}px`,
1811
+ "--rte-img-center": `${u.center}px`
1812
+ },
1813
+ children: [mi, fi].map((p, m) => /* @__PURE__ */ x($t, { children: [
1814
+ m > 0 ? /* @__PURE__ */ t("span", { "aria-hidden": "true", className: It }) : null,
1815
+ p.map((v) => {
1816
+ const L = m === 0 ? E === v.id : z === v.id;
1817
+ return /* @__PURE__ */ t(
1818
+ G,
1819
+ {
1820
+ size: "sm",
1821
+ intent: "ghost",
1822
+ icon: v.icon,
1823
+ "aria-pressed": L,
1824
+ tooltip: g(v.label[0], v.label[1]),
1825
+ onMouseDown: (T) => T.preventDefault(),
1826
+ onClick: () => d(v.id)
1827
+ },
1828
+ v.id
1829
+ );
1830
+ })
1831
+ ] }, m === 0 ? "flow" : "align"))
1832
+ }
1833
+ ) })
1834
+ ] });
1835
+ }
1836
+ function yi({
1837
+ templates: o,
1838
+ onPick: i,
1839
+ onManage: d,
1840
+ noteEmpty: c,
1841
+ onOpenChange: g,
1842
+ trigger: u,
1843
+ side: h = "top"
1844
+ }) {
1845
+ const { t: l } = ae(), b = Ee();
1846
+ return /* @__PURE__ */ x(he.Root, { onOpenChange: g, children: [
1847
+ /* @__PURE__ */ t(he.Trigger, { asChild: !0, children: u }),
1848
+ /* @__PURE__ */ x(he.Content, { side: h, align: "end", sideOffset: 8, children: [
1849
+ /* @__PURE__ */ t(he.Label, { children: o.length > 0 ? l("editor.ai.templatesGroup") : l("editor.ai.noTemplates") }),
1850
+ o.map((k) => /* @__PURE__ */ t(
1851
+ he.Item,
1852
+ {
1853
+ startIcon: /* @__PURE__ */ t(cn, {}),
1854
+ description: k.description || void 0,
1855
+ "aria-disabled": c || void 0,
1856
+ "aria-describedby": c ? b : void 0,
1857
+ className: "ds:aria-disabled:opacity-50 ds:aria-disabled:cursor-not-allowed",
1858
+ onSelect: (A) => {
1859
+ if (c) {
1860
+ A.preventDefault();
1861
+ return;
1862
+ }
1863
+ i(k);
1864
+ },
1865
+ children: k.name
1866
+ },
1867
+ k.id
1868
+ )),
1869
+ c && o.length > 0 ? /* @__PURE__ */ t(
1870
+ "p",
1871
+ {
1872
+ id: b,
1873
+ className: "ds:m-0 ds:px-[var(--spacing-sm)] ds:py-[var(--spacing-2xs)] ds:text-[length:var(--font-size-xs)] ds:text-[color:var(--muted-foreground)]",
1874
+ children: l("editor.ai.templatesNoteEmpty")
1875
+ }
1876
+ ) : null,
1877
+ d && o.length === 0 ? /* @__PURE__ */ t(
1878
+ he.Item,
1879
+ {
1880
+ startIcon: /* @__PURE__ */ t(To, {}),
1881
+ onSelect: () => d("create"),
1882
+ children: l("editor.ai.createFirstTemplate")
1883
+ }
1884
+ ) : null,
1885
+ d && o.length > 0 ? /* @__PURE__ */ x(Ce, { children: [
1886
+ /* @__PURE__ */ t(he.Separator, {}),
1887
+ /* @__PURE__ */ t(
1888
+ he.Item,
1889
+ {
1890
+ startIcon: /* @__PURE__ */ t(Eo, {}),
1891
+ onSelect: () => d("list"),
1892
+ children: l("editor.ai.manageTemplates")
1893
+ }
1894
+ )
1895
+ ] }) : null
1896
+ ] })
1897
+ ] });
1898
+ }
1899
+ const wi = [
1900
+ "ds:absolute ds:z-20 ds:flex ds:items-center ds:gap-[var(--spacing-2xs)]",
1901
+ "ds:[inset-block-start:var(--rte-sel-top)] ds:[inset-inline-start:var(--rte-sel-start)]",
1902
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
1903
+ "ds:bg-[var(--popover)] ds:p-[var(--spacing-2xs)] ds:shadow-[var(--shadow-lg)]"
1904
+ ].join(" "), ki = ["bold", "italic", "underline", "strike"];
1905
+ function xi({
1906
+ active: o,
1907
+ run: i,
1908
+ areaRef: d,
1909
+ getEditorRoot: c,
1910
+ suppressed: g = !1,
1911
+ holdOpen: u = !1,
1912
+ children: h
1913
+ }) {
1914
+ const { t: l } = ae(), b = _(null), [k, A] = N(null), q = _(u);
1915
+ return D(() => {
1916
+ q.current = u;
1917
+ }, [u]), D(() => {
1918
+ if (g || typeof window > "u") {
1919
+ A(null);
1920
+ return;
1921
+ }
1922
+ let E = !1, z = 0, K = !1, p = !1;
1923
+ const m = () => {
1924
+ var Y;
1925
+ if (q.current || E) return;
1926
+ if (p) {
1927
+ A(null);
1928
+ return;
1929
+ }
1930
+ const H = d.current, S = c(), F = window.getSelection();
1931
+ if (!H || !S || !F || F.rangeCount === 0 || F.isCollapsed || !H.contains(document.activeElement)) {
1932
+ A(null);
1933
+ return;
1934
+ }
1935
+ const j = F.getRangeAt(0);
1936
+ if (!S.contains(j.commonAncestorContainer)) {
1937
+ A(null);
1938
+ return;
1939
+ }
1940
+ if (!j.toString().trim()) {
1941
+ A(null);
1942
+ return;
1943
+ }
1944
+ const P = H.getBoundingClientRect(), Q = j.getBoundingClientRect(), ue = getComputedStyle(H).direction === "rtl", Ne = Q.top - P.top - 48, ne = Ne >= 0 ? Ne : Q.bottom - P.top + 8, U = ((Y = b.current) == null ? void 0 : Y.offsetWidth) ?? 0, W = ue ? P.right - Q.right + Q.width / 2 : Q.left - P.left + Q.width / 2, $ = U / 2, X = Math.min(
1945
+ Math.max(W, $),
1946
+ Math.max($, P.width - $)
1947
+ );
1948
+ A({ top: ne, start: X, rtl: ue }), U === 0 && !K && (K = !0, z = requestAnimationFrame(m));
1949
+ }, v = () => {
1950
+ cancelAnimationFrame(z), z = requestAnimationFrame(m);
1951
+ }, L = (H) => {
1952
+ const S = c();
1953
+ S && H.target instanceof Node && S.contains(H.target) && (E = !0, A(null));
1954
+ }, T = () => {
1955
+ E && (E = !1, v());
1956
+ }, B = (H) => {
1957
+ if (H.key !== "Escape") return;
1958
+ const S = d.current;
1959
+ !S || !S.contains(document.activeElement) || (p = !0, A(null));
1960
+ }, C = () => {
1961
+ p = !1, v();
1962
+ };
1963
+ return document.addEventListener("selectionchange", C), document.addEventListener("focusin", v), document.addEventListener("keydown", B, !0), document.addEventListener("pointerdown", L, !0), document.addEventListener("pointerup", T, !0), document.addEventListener("pointercancel", T, !0), window.addEventListener("scroll", v, !0), window.addEventListener("resize", v), v(), () => {
1964
+ cancelAnimationFrame(z), document.removeEventListener("selectionchange", C), document.removeEventListener("focusin", v), document.removeEventListener("keydown", B, !0), document.removeEventListener("pointerdown", L, !0), document.removeEventListener("pointerup", T, !0), document.removeEventListener("pointercancel", T, !0), window.removeEventListener("scroll", v, !0), window.removeEventListener("resize", v);
1965
+ };
1966
+ }, [g, d, c]), g || !k ? null : /* @__PURE__ */ t(gn, { children: /* @__PURE__ */ x(
1967
+ "div",
1968
+ {
1969
+ ref: b,
1970
+ role: "group",
1971
+ "aria-label": l("editor.ai.selectionTools"),
1972
+ "data-component-part": "selection-toolbar",
1973
+ className: `${wi} ${k.rtl ? "ds:translate-x-1/2" : "ds:-translate-x-1/2"}`,
1974
+ style: {
1975
+ "--rte-sel-top": `${k.top}px`,
1976
+ "--rte-sel-start": `${k.start}px`
1977
+ },
1978
+ children: [
1979
+ ki.map((E) => {
1980
+ const z = br[E];
1981
+ return /* @__PURE__ */ t(
1982
+ G,
1983
+ {
1984
+ size: "sm",
1985
+ intent: "ghost",
1986
+ icon: z.icon,
1987
+ tooltip: l(z.label[0], z.label[1]),
1988
+ "aria-pressed": z.toggle ? o.has(z.toggle) : void 0,
1989
+ onMouseDown: (K) => K.preventDefault(),
1990
+ onClick: () => i(...z.command)
1991
+ },
1992
+ E
1993
+ );
1994
+ }),
1995
+ h ? /* @__PURE__ */ x(Ce, { children: [
1996
+ /* @__PURE__ */ t("span", { "aria-hidden": "true", className: It }),
1997
+ h
1998
+ ] }) : null
1999
+ ]
2000
+ }
2001
+ ) });
2002
+ }
2003
+ function Ci({
2004
+ run: o,
2005
+ active: i,
2006
+ preset: d,
2007
+ insertHtml: c,
2008
+ insertTable: g,
2009
+ saveSelection: u,
2010
+ restoreSelection: h,
2011
+ getSelectedText: l,
2012
+ uploadImage: b,
2013
+ enableColor: k = !1,
2014
+ enableImage: A = !1,
2015
+ enableTable: q = !1,
2016
+ showExtensions: E = !1,
2017
+ variables: z,
2018
+ recentVariableTokens: K,
2019
+ insertVariable: p
2020
+ }) {
2021
+ const { t: m } = ae(), v = (U) => U.preventDefault(), L = (U) => Xa[d].includes(U), T = (U) => {
2022
+ if (!L(U)) return null;
2023
+ const W = br[U];
2024
+ return /* @__PURE__ */ t(
2025
+ G,
2026
+ {
2027
+ size: "sm",
2028
+ intent: "ghost",
2029
+ icon: W.icon,
2030
+ "aria-label": m(W.label[0], W.label[1]),
2031
+ "aria-pressed": W.toggle ? i.has(W.toggle) : void 0,
2032
+ onMouseDown: v,
2033
+ onClick: () => o(...W.command)
2034
+ },
2035
+ W.id
2036
+ );
2037
+ }, B = () => /* @__PURE__ */ t("span", { "aria-hidden": "true", className: It }), C = L("format"), H = [T("undo"), T("redo")].filter(Boolean), S = [
2038
+ T("bold"),
2039
+ T("italic"),
2040
+ T("underline"),
2041
+ T("strike"),
2042
+ k ? /* @__PURE__ */ t(
2043
+ ti,
2044
+ {
2045
+ run: o,
2046
+ saveSelection: u,
2047
+ restoreSelection: h
2048
+ },
2049
+ "colour"
2050
+ ) : null,
2051
+ k ? /* @__PURE__ */ t(
2052
+ ni,
2053
+ {
2054
+ run: o,
2055
+ saveSelection: u,
2056
+ restoreSelection: h
2057
+ },
2058
+ "highlight"
2059
+ ) : null
2060
+ ].filter(Boolean), F = H.length > 0 || C || S.length > 0, j = [T("ul"), T("ol")].filter(Boolean), P = [
2061
+ L("link") ? /* @__PURE__ */ t(
2062
+ Ja,
2063
+ {
2064
+ insertHtml: c,
2065
+ saveSelection: u,
2066
+ restoreSelection: h,
2067
+ getSelectedText: l
2068
+ },
2069
+ "link"
2070
+ ) : null,
2071
+ A ? /* @__PURE__ */ t(
2072
+ ei,
2073
+ {
2074
+ insertHtml: c,
2075
+ saveSelection: u,
2076
+ restoreSelection: h,
2077
+ uploadImage: b
2078
+ },
2079
+ "image"
2080
+ ) : null,
2081
+ q ? /* @__PURE__ */ t(
2082
+ oi,
2083
+ {
2084
+ run: o,
2085
+ insertTable: g,
2086
+ active: i
2087
+ },
2088
+ "table"
2089
+ ) : null,
2090
+ z && z.length > 0 && p ? /* @__PURE__ */ t(
2091
+ Qa,
2092
+ {
2093
+ variables: z,
2094
+ recentVariableTokens: K,
2095
+ insertVariable: p,
2096
+ saveSelection: u
2097
+ },
2098
+ "variables"
2099
+ ) : null
2100
+ ].filter(Boolean), Q = E ? [
2101
+ /* @__PURE__ */ t(
2102
+ G,
2103
+ {
2104
+ size: "sm",
2105
+ intent: "ghost",
2106
+ icon: /* @__PURE__ */ t(Fa, {}),
2107
+ "aria-label": m("editor.extensions", "Editor extensions"),
2108
+ disabled: !0,
2109
+ onMouseDown: v
2110
+ },
2111
+ "extensions"
2112
+ )
2113
+ ] : [], ue = [j, P, Q].filter(
2114
+ (U) => U.length > 0
2115
+ ), Ne = ue.length > 0, ne = (U) => ue.map((W, $) => /* @__PURE__ */ x($t, { children: [
2116
+ $ > 0 || U ? /* @__PURE__ */ t(B, {}) : null,
2117
+ W
2118
+ ] }, $));
2119
+ return (
2120
+ // Outer element is the query container + visual chrome; the flex row is an
2121
+ // inner child so `container-type` never lands on the flex parent (which
2122
+ // would blockify the inline controls).
2123
+ /* @__PURE__ */ t("div", { className: Ua(), "data-component": "editor-toolbar", children: /* @__PURE__ */ x(
2124
+ "div",
2125
+ {
2126
+ role: "group",
2127
+ "aria-label": m("editor.toolbarLabel"),
2128
+ className: Za,
2129
+ children: [
2130
+ H,
2131
+ H.length > 0 && (C || S.length > 0) ? /* @__PURE__ */ t(B, {}) : null,
2132
+ C ? /* @__PURE__ */ t(Ya, { run: o, active: i, onTriggerDown: v }) : null,
2133
+ C && S.length > 0 ? /* @__PURE__ */ t(B, {}) : null,
2134
+ S,
2135
+ Ne ? /* @__PURE__ */ x(Ce, { children: [
2136
+ /* @__PURE__ */ t("div", { className: "ds:hidden ds:@[384px]/toolbar:contents", children: ne(F) }),
2137
+ /* @__PURE__ */ x("div", { className: "ds:contents ds:@[384px]/toolbar:hidden", children: [
2138
+ F ? /* @__PURE__ */ t(B, {}) : null,
2139
+ /* @__PURE__ */ x(Z, { children: [
2140
+ /* @__PURE__ */ t(Z.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
2141
+ G,
2142
+ {
2143
+ size: "sm",
2144
+ intent: "ghost",
2145
+ icon: /* @__PURE__ */ t(Co, {}),
2146
+ "aria-label": m("editor.more", "More options"),
2147
+ onMouseDown: v
2148
+ }
2149
+ ) }),
2150
+ /* @__PURE__ */ t(Z.Content, { side: "bottom", align: "end", children: /* @__PURE__ */ t("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-xs)]", children: ne(!1) }) })
2151
+ ] })
2152
+ ] })
2153
+ ] }) : null
2154
+ ]
2155
+ }
2156
+ ) })
2157
+ );
2158
+ }
2159
+ function ye(o) {
2160
+ return go(o, "rich-text");
2161
+ }
2162
+ function Mt(o = "") {
2163
+ const i = String(o).trim();
2164
+ if (i === "" || i === "<p><br></p>" || i === "<p>&nbsp;</p>")
2165
+ return "";
2166
+ const d = i.replace(/<br\s*\/?>/gi, "").replace(/&nbsp;/gi, "").replace(/<[^>]+>/g, "").trim();
2167
+ return d === "" && /<img\b[^>]*>/i.test(i) ? i : d === "" ? "" : i;
2168
+ }
2169
+ function ar(o) {
2170
+ return o.replace(
2171
+ /<img(?![^>]*\sloading=)([^>]*)>/gi,
2172
+ '<img loading="lazy"$1>'
2173
+ );
2174
+ }
2175
+ const sn = /^[A-Za-z0-9_]+$/, wr = /\[\[([A-Za-z0-9_]+)\]\]/g, mn = "rte-variable-invalid", Ai = new RegExp(
2176
+ `\\s*\\b${mn}\\b`,
2177
+ "g"
2178
+ );
2179
+ function ir(o) {
2180
+ return o.includes('data-redactor-type="variable"') ? o.replace(
2181
+ /<span\b[^>]*data-redactor-type="variable"[^>]*>/g,
2182
+ (i) => i.replace(/\s(?:data-label|title)="[^"]*"/g, "").replace(Ai, "").replace(/\sclass=""/g, "")
2183
+ ) : o;
2184
+ }
2185
+ function _i(o) {
2186
+ const i = o.replace(/<[^>]*>/g, " ");
2187
+ return Array.from(i.matchAll(wr), (d) => d[1]);
2188
+ }
2189
+ function sr(o) {
2190
+ return typeof o == "object" && o !== null && "name" in o && o.name === "AiCreditsExhaustedError";
2191
+ }
2192
+ function Ni(o) {
2193
+ return typeof o == "object" && o !== null && "name" in o && o.name === "AbortError";
2194
+ }
2195
+ const Ti = { intro: 3200, landed: 2800 };
2196
+ function Ei(o) {
2197
+ const i = document.createElement("template");
2198
+ return i.content.appendChild(o), i.innerHTML;
2199
+ }
2200
+ function lr(o) {
2201
+ const i = document.createElement("template");
2202
+ return i.innerHTML = o, (i.content.textContent ?? "").replace(/\s+/g, " ").trim();
2203
+ }
2204
+ function cr(o) {
2205
+ return o.replace(/<[^>]*>/g, "").replace(/&nbsp;/gi, "").replace(/[\s\u200B\uFEFF]+/g, "");
2206
+ }
2207
+ function zi(o) {
2208
+ const i = window.getSelection();
2209
+ if (!i || i.rangeCount === 0) return null;
2210
+ const d = i.getRangeAt(0);
2211
+ if (!o.contains(d.startContainer)) return null;
2212
+ const c = document.createRange();
2213
+ return c.selectNodeContents(o), c.setEnd(d.startContainer, d.startOffset), c.toString().length;
2214
+ }
2215
+ function Si(o, i) {
2216
+ var u;
2217
+ const d = window.getSelection();
2218
+ if (!d) return;
2219
+ const c = document.createTreeWalker(o, NodeFilter.SHOW_TEXT);
2220
+ let g = 0;
2221
+ for (let h = c.nextNode(); h; h = c.nextNode()) {
2222
+ const l = h;
2223
+ if (g + l.data.length >= i) {
2224
+ const b = document.createRange(), k = (u = l.parentElement) == null ? void 0 : u.closest(
2225
+ '[data-redactor-type="variable"]'
2226
+ );
2227
+ k ? b.setStartAfter(k) : b.setStart(l, i - g), b.collapse(!0), d.removeAllRanges(), d.addRange(b);
2228
+ return;
2229
+ }
2230
+ g += l.data.length;
2231
+ }
2232
+ }
2233
+ function dr(o) {
2234
+ return `<span data-redactor-type="variable">[[${o}]]</span>`;
2235
+ }
2236
+ function Xe(o, i) {
2237
+ var h;
2238
+ if (i.size === 0 || !o.includes("[[") || typeof DOMParser > "u")
2239
+ return o;
2240
+ const d = new DOMParser().parseFromString(
2241
+ `<body>${o}</body>`,
2242
+ "text/html"
2243
+ ), c = d.createTreeWalker(d.body, NodeFilter.SHOW_TEXT), g = [];
2244
+ for (let l = c.nextNode(); l; l = c.nextNode()) {
2245
+ const b = l;
2246
+ (h = b.parentElement) != null && h.closest('[data-redactor-type="variable"]') || b.data.includes("[[") && g.push(b);
2247
+ }
2248
+ let u = !1;
2249
+ for (const l of g) {
2250
+ const b = d.createDocumentFragment();
2251
+ let k = 0;
2252
+ for (const A of l.data.matchAll(wr)) {
2253
+ const q = i.get(A[1].toLowerCase());
2254
+ if (!q || A.index === void 0) continue;
2255
+ b.append(l.data.slice(k, A.index));
2256
+ const E = d.createElement("span");
2257
+ E.setAttribute("data-redactor-type", "variable"), E.textContent = `[[${q}]]`, b.append(E), k = A.index + A[0].length;
2258
+ }
2259
+ k !== 0 && (b.append(l.data.slice(k)), l.replaceWith(b), u = !0);
2260
+ }
2261
+ return u ? d.body.innerHTML : o;
2262
+ }
2263
+ function Mi(o) {
2264
+ if (!o || typeof o != "object") return;
2265
+ const i = o, d = (c) => {
2266
+ if (c && typeof c == "object" && "url" in c) {
2267
+ const g = c.url;
2268
+ return typeof g == "string" ? g : void 0;
2269
+ }
2270
+ };
2271
+ return typeof i.url == "string" ? i.url : d(i.file) ?? d(i.data) ?? Object.values(i).map(d).find(Boolean);
2272
+ }
2273
+ function Ri(o) {
2274
+ if (o) return o;
2275
+ if (typeof window > "u") return null;
2276
+ const i = window;
2277
+ return i.$R ?? i.Redactor ?? null;
2278
+ }
2279
+ const Li = {
2280
+ bold: ["module.inline.format", { tag: "b" }],
2281
+ italic: ["module.inline.format", { tag: "i" }],
2282
+ strikethrough: ["module.inline.format", { tag: "del" }],
2283
+ bulletedList: ["module.list.toggle", "ul"],
2284
+ numberedList: ["module.list.toggle", "ol"],
2285
+ heading: ["module.block.format", { tag: "h2" }],
2286
+ quote: ["module.block.format", { tag: "blockquote" }],
2287
+ paragraph: ["module.block.format", { tag: "p" }]
2288
+ }, $i = {
2289
+ zh: "zh_cn",
2290
+ pt: "pt_br"
2291
+ };
2292
+ function Ii(o) {
2293
+ const i = o.split("-")[0];
2294
+ return $i[i] ?? i ?? "en";
2295
+ }
2296
+ const Hi = fn(
2297
+ "redactor-theme-alfadocs ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]"
2298
+ ), Di = [
2299
+ "ds:absolute ds:z-30",
2300
+ "ds:[inset-inline-start:var(--rte-typeahead-x)] ds:[inset-block-start:var(--rte-typeahead-y)]"
2301
+ ].join(" "), Oi = fn(
2302
+ [
2303
+ "ds:block ds:[inline-size:100%]",
2304
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
2305
+ "ds:bg-[var(--background)] ds:text-[var(--foreground)]",
2306
+ "ds:shadow-[var(--shadow-md)]",
2307
+ "ds:font-[family-name:var(--font-sans)] ds:text-[length:var(--font-size-base)]",
2308
+ "ds:p-[var(--spacing-md)] ds:[min-block-size:var(--rich-text-editor-min-block-size)]",
2309
+ "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
2310
+ "ds:focus-visible:outline-solid",
2311
+ "ds:focus-visible:outline-[var(--ring)]",
2312
+ "ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
2313
+ "ds:forced-colors:focus-visible:outline-[CanvasText]"
2314
+ ].join(" ")
2315
+ ), kr = [
2316
+ "ds:inline-flex ds:items-center ds:justify-center",
2317
+ "ds:[min-block-size:var(--min-target-size)] ds:[min-inline-size:var(--min-target-size)]",
2318
+ "ds:text-[color:var(--primary-foreground)]",
2319
+ "ds:transition-colors",
2320
+ "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
2321
+ "ds:focus-visible:outline-solid",
2322
+ "ds:focus-visible:outline-[var(--primary-foreground)]",
2323
+ "ds:focus-visible:[outline-offset:calc(var(--focus-ring-width)*-1)]"
2324
+ ].join(" "), qi = `${kr} ds:hover:bg-[color-mix(in_srgb,var(--primary-foreground)_15%,transparent)]`, Pi = `${kr} ds:bg-[var(--destructive)] ds:hover:bg-[color-mix(in_srgb,var(--destructive)_88%,var(--primary-foreground))]`, Bi = {
2325
+ intro: "ds:animate-[ai-pill-shimmer_calc(var(--animation-duration)*6)_var(--ease-in-out)_1]",
2326
+ working: "ds:animate-[ai-pill-shimmer_calc(var(--animation-duration)*6)_var(--ease-in-out)_infinite]",
2327
+ landed: "ds:animate-[ai-pill-shimmer_calc(var(--animation-duration)*4)_var(--ease-out)_1]"
2328
+ }, ur = {
2329
+ intro: "ds:animate-[ai-comet-orbit_calc(var(--animation-duration)*7)_var(--ease-in-out)_1_both]",
2330
+ working: "ds:animate-[ai-comet-orbit_calc(var(--animation-duration)*8)_linear_infinite]",
2331
+ landed: "ds:animate-[ai-comet-orbit_calc(var(--animation-duration)*5)_var(--ease-out)_1_both]"
2332
+ }, Fi = {
2333
+ intro: "ds:[--sparkle-base:8] ds:animate-[ai-sparkle-burst_calc(var(--animation-duration)*5)_var(--ease-in-out)_1_both]",
2334
+ working: "ds:[--sparkle-base:0] ds:animate-[ai-sparkle-twinkle_calc(var(--animation-duration)*8)_var(--ease-in-out)_infinite]",
2335
+ landed: "ds:[--sparkle-base:6] ds:animate-[ai-sparkle-burst_calc(var(--animation-duration)*5)_var(--ease-in-out)_1_both]"
2336
+ }, ot = "ds:absolute ds:opacity-0 ds:text-[color:var(--ai-sparkle)] ds:fill-current ds:drop-shadow-[0_0_var(--spacing-2xs)_var(--ai-sparkle)] ds:[animation-delay:calc(var(--animation-duration)*(var(--sparkle-base)+var(--sparkle-stagger)))]", ji = [
2337
+ {
2338
+ key: "start",
2339
+ className: `${ot} ds:[--sparkle-stagger:0] ds:size-3 ds:[inset-block-start:calc(var(--spacing-xs)*-1)] ds:[inset-inline-start:calc(var(--spacing-2xs)*-1)]`
2340
+ },
2341
+ {
2342
+ key: "top",
2343
+ className: `${ot} ds:[--sparkle-stagger:0.5] ds:size-4 ds:[inset-block-start:calc(var(--spacing-sm)*-1)] ds:[inset-inline-start:40%]`
2344
+ },
2345
+ {
2346
+ key: "end",
2347
+ className: `${ot} ds:[--sparkle-stagger:1] ds:size-3 ds:[inset-block-start:calc(var(--spacing-xs)*-1)] ds:[inset-inline-end:var(--spacing-md)]`
2348
+ },
2349
+ {
2350
+ key: "side",
2351
+ className: `${ot} ds:[--sparkle-stagger:1.5] ds:size-2 ds:[inset-block-start:40%] ds:[inset-inline-end:calc(var(--spacing-sm)*-1)]`
2352
+ },
2353
+ {
2354
+ key: "below",
2355
+ className: `${ot} ds:[--sparkle-stagger:2] ds:size-3 ds:[inset-block-end:calc(var(--spacing-xs)*-1)] ds:[inset-inline-start:25%]`
2356
+ }
2357
+ ], mr = "ds:pointer-events-none ds:absolute ds:[inset-block-start:0] ds:[inset-inline-start:0] ds:opacity-0 ds:[offset-path:inset(0_round_var(--radius-full))] ds:[offset-rotate:0deg]", Gi = [
2358
+ {
2359
+ key: 1,
2360
+ lag: "ds:[animation-delay:calc(var(--animation-duration)*0.2)]",
2361
+ dot: "ds:size-2.5 ds:opacity-[var(--opacity-90)]"
2362
+ },
2363
+ {
2364
+ key: 2,
2365
+ lag: "ds:[animation-delay:calc(var(--animation-duration)*0.4)]",
2366
+ dot: "ds:size-2 ds:opacity-[var(--opacity-70)]"
2367
+ },
2368
+ {
2369
+ key: 3,
2370
+ lag: "ds:[animation-delay:calc(var(--animation-duration)*0.6)]",
2371
+ dot: "ds:size-2 ds:opacity-[var(--opacity-50)]"
2372
+ },
2373
+ {
2374
+ key: 4,
2375
+ lag: "ds:[animation-delay:calc(var(--animation-duration)*0.8)]",
2376
+ dot: "ds:size-1.5 ds:opacity-[var(--opacity-30)]"
2377
+ },
2378
+ {
2379
+ key: 5,
2380
+ lag: "ds:[animation-delay:calc(var(--animation-duration)*1)]",
2381
+ dot: "ds:size-1.5 ds:opacity-[var(--opacity-20)]"
2382
+ },
2383
+ {
2384
+ key: 6,
2385
+ lag: "ds:[animation-delay:calc(var(--animation-duration)*1.2)]",
2386
+ dot: "ds:size-1 ds:opacity-[var(--opacity-10)]"
2387
+ }
2388
+ ], Ki = uo(
2389
+ ({
2390
+ id: o,
2391
+ defaultValue: i,
2392
+ value: d,
2393
+ onChange: c,
2394
+ toolbar: g = "standard",
2395
+ placeholder: u,
2396
+ readOnly: h = !1,
2397
+ ariaLabel: l,
2398
+ minHeight: b,
2399
+ showExtensions: k,
2400
+ className: A,
2401
+ redactor: q,
2402
+ options: E,
2403
+ plugins: z,
2404
+ lang: K,
2405
+ imageUploadUrl: p,
2406
+ onUploadImage: m,
2407
+ onKeyDown: v,
2408
+ onRequestAiDraft: L,
2409
+ aiDraftFormat: T = "html",
2410
+ aiPrivacyNotice: B,
2411
+ aiConsent: C,
2412
+ aiConsentHeadingLevel: H,
2413
+ onDictate: S,
2414
+ onProofread: F,
2415
+ onAutoFormat: j,
2416
+ aiTemplates: P,
2417
+ onAiApplied: Q,
2418
+ aiSparkle: ue = !0,
2419
+ selectionToolbar: Ne,
2420
+ variables: ne,
2421
+ recentVariableTokens: U,
2422
+ onVariableInserted: W,
2423
+ validateVariable: $,
2424
+ onVariableValidityChange: X,
2425
+ renderHelpMeWrite: Y,
2426
+ onAiCreditsExhausted: me
2427
+ }, xr) => {
2428
+ const { t: O, i18n: Cr } = ae(), hn = Ee(), Be = Ve(
2429
+ () => `rte-${hn.replace(/[^a-zA-Z0-9-_]/g, "")}`,
2430
+ [hn]
2431
+ ), I = `#${Be}`, de = _(null), ee = _(null), Ht = _(!1), lt = _(h), V = _(null), Ue = _(null), [ie, bn] = N(!1), [Dt, ze] = N(!1), [Ar, _r] = N(""), [Nr, Tr] = N(
2432
+ "document"
2433
+ ), [Er, Ot] = N(!1), Se = _(me), qt = _(Y);
2434
+ D(() => {
2435
+ Se.current = me, qt.current = Y;
2436
+ }, [me, Y]);
2437
+ const ct = _(null), se = Ve(
2438
+ () => new Map(
2439
+ (ne ?? []).map((e) => e.token).filter((e) => sn.test(e)).map((e) => [e.toLowerCase(), e])
2440
+ ),
2441
+ [ne]
2442
+ ), vn = Ve(
2443
+ () => new Map(
2444
+ (ne ?? []).map(
2445
+ (e) => [e.token.toLowerCase(), e.label]
2446
+ )
2447
+ ),
2448
+ [ne]
2449
+ ), Fe = _(se);
2450
+ D(() => {
2451
+ Fe.current = se;
2452
+ }, [se]);
2453
+ const yn = Ve(
2454
+ () => (ne ?? []).filter((e) => sn.test(e.token)),
2455
+ [ne]
2456
+ ), Pt = _($);
2457
+ D(() => {
2458
+ Pt.current = $;
2459
+ }, [$]);
2460
+ const Bt = $ !== void 0, Ft = y(
2461
+ (e) => Bt && Pt.current ? Pt.current(e) : se.has(e.toLowerCase()),
2462
+ [Bt, se]
2463
+ ), je = se.size > 0 || Bt, [Ge, wn] = N([]), Me = _(X);
2464
+ D(() => {
2465
+ Me.current = X;
2466
+ }, [X]);
2467
+ const _e = _(() => {
2468
+ }), [jt, zr] = N(
2469
+ () => /* @__PURE__ */ new Set()
2470
+ ), dt = _(null), [Sr, Mr] = N(
2471
+ null
2472
+ ), ut = y((e) => {
2473
+ dt.current = e, Mr(e);
2474
+ }, []), Ze = _(null), mt = _(null), le = _(c), ft = _(v);
2475
+ D(() => {
2476
+ le.current = c, ft.current = v;
2477
+ }, [c, v]);
2478
+ const Rr = _(
2479
+ (() => {
2480
+ const e = d ?? i ?? "";
2481
+ return e ? ye(e) : "";
2482
+ })()
2483
+ ), re = y(() => {
2484
+ var n;
2485
+ const e = ee.current;
2486
+ if (e)
2487
+ try {
2488
+ const r = e(I, "source.getCode");
2489
+ if (typeof r == "string") return ir(r);
2490
+ } catch {
2491
+ }
2492
+ return ((n = de.current) == null ? void 0 : n.value) ?? "";
2493
+ }, [I]);
2494
+ D(() => {
2495
+ _e.current = () => {
2496
+ var r;
2497
+ if (!je) {
2498
+ wn((a) => a.length ? [] : a);
2499
+ return;
2500
+ }
2501
+ const e = (r = V.current) == null ? void 0 : r.querySelector(".redactor-in");
2502
+ e == null || e.querySelectorAll('[data-redactor-type="variable"]').forEach((a) => {
2503
+ const s = /^\[\[([A-Za-z0-9_]+)\]\]$/.exec(
2504
+ a.textContent ?? ""
2505
+ ), f = !s || !Ft(s[1]);
2506
+ a.classList.contains(mn) !== f && a.classList.toggle(mn, f);
2507
+ const w = s ? vn.get(s[1].toLowerCase()) ?? s[1] : a.textContent ?? "";
2508
+ a.getAttribute("data-label") !== w && a.setAttribute("data-label", w);
2509
+ const M = a.textContent ?? "";
2510
+ a.getAttribute("title") !== M && a.setAttribute("title", M);
2511
+ });
2512
+ const n = Array.from(
2513
+ new Set(
2514
+ _i(re()).filter(
2515
+ (a) => !Ft(a)
2516
+ )
2517
+ )
2518
+ );
2519
+ wn(
2520
+ (a) => a.length === n.length && a.every((s, f) => s === n[f]) ? a : n
2521
+ );
2522
+ }, _e.current();
2523
+ }, [je, Ft, vn, re]), D(() => {
2524
+ var r;
2525
+ const n = ((r = V.current) == null ? void 0 : r.querySelector(".redactor-in")) ?? de.current;
2526
+ n && (Ge.length > 0 ? (n.setAttribute("aria-invalid", "true"), n.setAttribute("aria-describedby", `${Be}-variables-error`)) : (n.removeAttribute("aria-invalid"), n.removeAttribute("aria-describedby")));
2527
+ }, [Ge, Be, ie]);
2528
+ const Gt = _(!1);
2529
+ D(() => {
2530
+ var e, n;
2531
+ je ? (Gt.current = !0, (e = Me.current) == null || e.call(Me, Ge)) : Gt.current && (Gt.current = !1, (n = Me.current) == null || n.call(Me, []));
2532
+ }, [Ge, je]), D(() => {
2533
+ $ && _e.current();
2534
+ }, [$]);
2535
+ const oe = y(
2536
+ (e, ...n) => {
2537
+ const r = ee.current;
2538
+ if (!r) return !1;
2539
+ const a = lt.current;
2540
+ if (a)
2541
+ try {
2542
+ r(I, "disableReadOnly");
2543
+ } catch {
2544
+ }
2545
+ try {
2546
+ return r(I, e, ...n), !0;
2547
+ } catch {
2548
+ return !1;
2549
+ } finally {
2550
+ if (a)
2551
+ try {
2552
+ r(I, "enableReadOnly");
2553
+ } catch {
2554
+ }
2555
+ }
2556
+ },
2557
+ [I]
2558
+ ), ce = y(
2559
+ (e, n) => {
2560
+ var ve;
2561
+ const r = (n == null ? void 0 : n.asHtml) ?? !0, a = r ? ye(e) : e;
2562
+ if (oe(r ? "insertion.insertHtml" : "insertion.insertText", a)) return;
2563
+ const f = de.current;
2564
+ if (!f) return;
2565
+ const w = f.selectionStart ?? f.value.length, M = f.selectionEnd ?? f.value.length;
2566
+ f.value = f.value.slice(0, w) + a + f.value.slice(M);
2567
+ const J = w + a.length;
2568
+ try {
2569
+ f.setSelectionRange(J, J);
2570
+ } catch {
2571
+ }
2572
+ (ve = le.current) == null || ve.call(le, { html: ye(f.value), markdown: "" });
2573
+ },
2574
+ [oe]
2575
+ ), we = _(null), fe = y(() => {
2576
+ var a;
2577
+ const e = (a = V.current) == null ? void 0 : a.querySelector(".redactor-in"), n = typeof window < "u" ? window.getSelection() : null, r = /* @__PURE__ */ new Set();
2578
+ if (e && n && n.anchorNode && e.contains(n.anchorNode) && typeof document.queryCommandState == "function") {
2579
+ n.rangeCount > 0 && (we.current = n.getRangeAt(0).cloneRange());
2580
+ try {
2581
+ document.queryCommandState("bold") && r.add("bold"), document.queryCommandState("italic") && r.add("italic"), document.queryCommandState("underline") && r.add("underline"), document.queryCommandState("strikeThrough") && r.add("strike"), document.queryCommandState("insertUnorderedList") && r.add("ul"), document.queryCommandState("insertOrderedList") && r.add("ol");
2582
+ const s = String(
2583
+ document.queryCommandValue("formatBlock") || ""
2584
+ ).toLowerCase();
2585
+ /^h[1-6]$/.test(s) ? (r.add("heading"), r.add(s)) : s === "blockquote" ? r.add("quote") : r.add("paragraph");
2586
+ const f = n.anchorNode.nodeType === Node.TEXT_NODE ? n.anchorNode.parentElement : n.anchorNode;
2587
+ f && e.contains(f) && f.closest("table") && r.add("table");
2588
+ } catch {
2589
+ }
2590
+ }
2591
+ zr(
2592
+ (s) => s.size === r.size && [...r].every((f) => s.has(f)) ? s : r
2593
+ );
2594
+ }, []), Re = y(
2595
+ (e, ...n) => {
2596
+ oe(e, ...n), typeof window < "u" ? window.requestAnimationFrame(() => fe()) : fe();
2597
+ },
2598
+ [oe, fe]
2599
+ );
2600
+ D(() => {
2601
+ const e = V.current;
2602
+ if (!e) return;
2603
+ const n = {
2604
+ b: ["module.inline.format", { tag: "b" }],
2605
+ i: ["module.inline.format", { tag: "i" }],
2606
+ u: ["module.inline.format", { tag: "u" }]
2607
+ }, r = (a) => {
2608
+ if (!(a.metaKey || a.ctrlKey) || a.altKey || a.shiftKey || a.isComposing) return;
2609
+ const s = n[a.key.toLowerCase()];
2610
+ if (!s) return;
2611
+ const f = e.querySelector(".redactor-in");
2612
+ !f || !(a.target instanceof Node) || !f.contains(a.target) || lt.current || (a.preventDefault(), a.stopImmediatePropagation(), Re(...s));
2613
+ };
2614
+ return e.addEventListener("keydown", r, !0), () => e.removeEventListener("keydown", r, !0);
2615
+ }, [Re]);
2616
+ const Le = y(
2617
+ (e) => {
2618
+ ce(e, { asHtml: !0 }), typeof window < "u" && window.requestAnimationFrame(() => fe());
2619
+ },
2620
+ [ce, fe]
2621
+ ), [Ke, Kt] = N(null), gt = _(null), Wt = `${Be}-variables`, kn = _(null), [Vt, Lr] = N(void 0), ke = y(() => {
2622
+ gt.current = null, Kt(null);
2623
+ }, []), pt = y(
2624
+ (e, n) => {
2625
+ const r = window.getSelection();
2626
+ if (!r) return;
2627
+ const a = document.createRange();
2628
+ a.setStart(n.node, n.start), a.setEnd(n.node, n.end), r.removeAllRanges(), r.addRange(a), Le(dr(e)), window.requestAnimationFrame(() => _e.current());
2629
+ },
2630
+ [Le]
2631
+ );
2632
+ D(() => {
2633
+ const e = V.current;
2634
+ if (!e || !je) return;
2635
+ const n = () => {
2636
+ var Zn;
2637
+ const s = e.querySelector(".redactor-in"), f = window.getSelection();
2638
+ if (!s || !f || f.rangeCount === 0 || !f.isCollapsed) {
2639
+ ke();
2640
+ return;
2641
+ }
2642
+ const { startContainer: w, startOffset: M } = f.getRangeAt(0);
2643
+ if (w.nodeType !== Node.TEXT_NODE || !s.contains(w) || (((Zn = w.parentElement) == null ? void 0 : Zn.closest(
2644
+ '[data-redactor-type="variable"]'
2645
+ )) ?? null) !== null) {
2646
+ ke();
2647
+ return;
2648
+ }
2649
+ const J = w, ve = J.data.slice(0, M), qe = /\[\[([A-Za-z0-9_]+)\]\]$/.exec(ve);
2650
+ if (qe) {
2651
+ ke(), pt(
2652
+ se.get(qe[1].toLowerCase()) ?? qe[1],
2653
+ { node: J, start: M - qe[0].length, end: M }
2654
+ );
2655
+ return;
2656
+ }
2657
+ const Jt = /\[\[([A-Za-z0-9_ ]{0,40})$/.exec(ve), en = Ue.current;
2658
+ if (!Jt || !en || (ne ?? []).length === 0) {
2659
+ ke();
2660
+ return;
2661
+ }
2662
+ const tn = {
2663
+ node: J,
2664
+ start: M - Jt[0].length,
2665
+ end: M
2666
+ };
2667
+ gt.current = tn;
2668
+ const nn = document.createRange();
2669
+ nn.setStart(J, tn.start), nn.setEnd(J, tn.end);
2670
+ const rn = nn.getBoundingClientRect(), on = en.getBoundingClientRect(), co = getComputedStyle(en).direction === "rtl";
2671
+ Kt({
2672
+ query: Jt[1],
2673
+ left: co ? on.right - rn.right : rn.left - on.left,
2674
+ top: rn.bottom - on.top + 4
2675
+ });
2676
+ }, r = (s) => {
2677
+ var w;
2678
+ if (!gt.current || !["ArrowDown", "ArrowUp", "Home", "End", "Enter", "Escape"].includes(
2679
+ s.key
2680
+ ))
2681
+ return;
2682
+ (((w = kn.current) == null ? void 0 : w.handleKeyDown(s)) ?? !1) && (s.preventDefault(), s.stopImmediatePropagation());
2683
+ }, a = () => ke();
2684
+ return e.addEventListener("input", n), e.addEventListener("keydown", r, !0), e.addEventListener("focusout", a), () => {
2685
+ e.removeEventListener("input", n), e.removeEventListener("keydown", r, !0), e.removeEventListener("focusout", a);
2686
+ };
2687
+ }, [
2688
+ je,
2689
+ se,
2690
+ ne,
2691
+ pt,
2692
+ ke
2693
+ ]), D(() => {
2694
+ var n;
2695
+ const e = (n = V.current) == null ? void 0 : n.querySelector(".redactor-in");
2696
+ e && (Ke ? (e.setAttribute("aria-expanded", "true"), e.setAttribute("aria-controls", `${Wt}-list`), Vt ? e.setAttribute("aria-activedescendant", Vt) : e.removeAttribute("aria-activedescendant")) : (e.removeAttribute("aria-expanded"), e.removeAttribute("aria-controls"), e.removeAttribute("aria-activedescendant")));
2697
+ }, [Ke, Wt, Vt]);
2698
+ const $r = y(
2699
+ (e) => {
2700
+ const n = gt.current;
2701
+ ke(), n && pt(e.token, n), W == null || W(e.token);
2702
+ },
2703
+ [ke, pt, W]
2704
+ ), Ir = y(() => {
2705
+ ke();
2706
+ }, [ke]), Hr = y((e) => {
2707
+ Kt((n) => n && { ...n, query: e });
2708
+ }, []), Qe = y(() => {
2709
+ var n;
2710
+ if (typeof window < "u") {
2711
+ const r = (n = V.current) == null ? void 0 : n.querySelector(".redactor-in"), a = window.getSelection();
2712
+ r && a && a.rangeCount > 0 && a.anchorNode && r.contains(a.anchorNode) && (we.current = a.getRangeAt(0).cloneRange());
2713
+ }
2714
+ const e = ee.current;
2715
+ if (e)
2716
+ try {
2717
+ e(I, "selection.save");
2718
+ } catch {
2719
+ }
2720
+ }, [I]), ge = y(() => {
2721
+ const e = ee.current;
2722
+ if (!e) return;
2723
+ const n = we.current;
2724
+ try {
2725
+ e(I, "editor.focus");
2726
+ } catch {
2727
+ }
2728
+ if (n && typeof window < "u") {
2729
+ const r = window.getSelection();
2730
+ if (r)
2731
+ try {
2732
+ r.removeAllRanges(), r.addRange(n);
2733
+ return;
2734
+ } catch {
2735
+ }
2736
+ }
2737
+ try {
2738
+ e(I, "selection.restore");
2739
+ } catch {
2740
+ }
2741
+ }, [I]), Dr = y(() => {
2742
+ var r;
2743
+ if (typeof window > "u") return "";
2744
+ const e = (r = V.current) == null ? void 0 : r.querySelector(".redactor-in"), n = window.getSelection();
2745
+ return !e || !n || !n.anchorNode || !e.contains(n.anchorNode) ? "" : n.toString();
2746
+ }, []), Or = y(() => {
2747
+ var s;
2748
+ if (typeof window > "u") return null;
2749
+ const e = (s = V.current) == null ? void 0 : s.querySelector(".redactor-in"), n = window.getSelection();
2750
+ if (!e || !n || n.rangeCount === 0) return null;
2751
+ const r = n.anchorNode, a = r && r.nodeType === Node.TEXT_NODE ? r.parentElement : r;
2752
+ return !a || !e.contains(a) ? null : a.closest("table");
2753
+ }, []), xn = _(null), ht = y(() => {
2754
+ var s;
2755
+ if (typeof window > "u") return null;
2756
+ const e = (s = V.current) == null ? void 0 : s.querySelector(".redactor-in"), n = window.getSelection();
2757
+ if (!e || !n || n.rangeCount === 0) return null;
2758
+ const r = n.anchorNode, a = r && r.nodeType === Node.TEXT_NODE ? r.parentElement : r;
2759
+ return !a || !e.contains(a) ? null : a.closest("td,th");
2760
+ }, []), qr = y(() => {
2761
+ xn.current = ht();
2762
+ }, [ht]), Pr = y(
2763
+ (e, n) => {
2764
+ var f;
2765
+ const r = xn.current ?? ht();
2766
+ if (!r) return;
2767
+ const a = e === "row" ? Array.from(((f = r.closest("tr")) == null ? void 0 : f.children) ?? [r]).filter(
2768
+ (w) => w instanceof HTMLElement && (w.tagName === "TD" || w.tagName === "TH")
2769
+ ) : [r], s = ee.current;
2770
+ if (s)
2771
+ try {
2772
+ s(I, "module.buffer.trigger");
2773
+ } catch {
2774
+ }
2775
+ for (const w of a)
2776
+ n ? w.style.setProperty("background-color", n) : w.style.removeProperty("background-color");
2777
+ if (s)
2778
+ try {
2779
+ s(I, "broadcast", "hardsync");
2780
+ } catch {
2781
+ }
2782
+ typeof window < "u" && window.requestAnimationFrame(() => fe());
2783
+ },
2784
+ [ht, I, fe]
2785
+ );
2786
+ D(() => {
2787
+ const e = V.current;
2788
+ if (typeof window > "u" || !e) return;
2789
+ const n = (s) => {
2790
+ const f = e.querySelector(".redactor-in"), w = s.target;
2791
+ if (!f || !(w instanceof Node) || !f.contains(w))
2792
+ return;
2793
+ const M = w instanceof Element ? w.closest("img") : null;
2794
+ ut(M && f.contains(M) ? M : null);
2795
+ }, r = (s) => {
2796
+ s.key === "Escape" && dt.current && ut(null);
2797
+ }, a = (s) => {
2798
+ const f = s.relatedTarget;
2799
+ (!(f instanceof Node) || !e.contains(f)) && ut(null);
2800
+ };
2801
+ return e.addEventListener("click", n), e.addEventListener("keydown", r), e.addEventListener("focusout", a), () => {
2802
+ e.removeEventListener("click", n), e.removeEventListener("keydown", r), e.removeEventListener("focusout", a);
2803
+ };
2804
+ }, [ut]);
2805
+ const Br = y(
2806
+ (e) => {
2807
+ const n = dt.current;
2808
+ if (!n) return;
2809
+ const r = dn.includes(
2810
+ e
2811
+ ) ? dn : yr, a = ee.current;
2812
+ if (a)
2813
+ try {
2814
+ a(I, "module.buffer.trigger");
2815
+ } catch {
2816
+ }
2817
+ for (const s of r) n.classList.remove(s);
2818
+ if (n.classList.add(e), a)
2819
+ try {
2820
+ a(I, "broadcast", "hardsync");
2821
+ } catch {
2822
+ }
2823
+ typeof window < "u" && window.requestAnimationFrame(() => fe());
2824
+ },
2825
+ [I, fe]
2826
+ ), Fr = y(
2827
+ (e) => {
2828
+ const n = dt.current;
2829
+ if (!n) return;
2830
+ const r = ee.current;
2831
+ if (r)
2832
+ try {
2833
+ r(I, "module.buffer.trigger");
2834
+ } catch {
2835
+ }
2836
+ if (n.style.setProperty("width", `${e}%`), r)
2837
+ try {
2838
+ r(I, "broadcast", "hardsync");
2839
+ } catch {
2840
+ }
2841
+ typeof window < "u" && window.requestAnimationFrame(() => fe());
2842
+ },
2843
+ [I, fe]
2844
+ ), jr = y(
2845
+ (e) => {
2846
+ var r;
2847
+ const n = ee.current;
2848
+ if (n && typeof window < "u") {
2849
+ const a = (r = V.current) == null ? void 0 : r.querySelector(".redactor-in"), s = window.getSelection(), f = s == null ? void 0 : s.anchorNode, w = f && f.nodeType === Node.TEXT_NODE ? f.parentElement : f, M = w && (a != null && a.contains(w)) ? w.closest("ul,ol") : null;
2850
+ if (M)
2851
+ try {
2852
+ n(I, "caret.setAfter", M);
2853
+ } catch {
2854
+ }
2855
+ }
2856
+ Le(e), typeof window < "u" && window.requestAnimationFrame(() => {
2857
+ var s;
2858
+ const a = (s = V.current) == null ? void 0 : s.querySelector(".redactor-in");
2859
+ a == null || a.querySelectorAll("table td, table th").forEach((f) => {
2860
+ let w = f.lastChild;
2861
+ for (; w && w.nodeType === Node.TEXT_NODE && !(w.textContent ?? "").trim(); ) {
2862
+ const M = w.previousSibling;
2863
+ f.removeChild(w), w = M;
2864
+ }
2865
+ });
2866
+ });
2867
+ },
2868
+ [Le, I]
2869
+ ), Gr = y(
2870
+ async (e, n) => {
2871
+ if (m) return m(e, n);
2872
+ if (!p) throw new Error("No image upload URL configured.");
2873
+ const r = new FormData();
2874
+ r.append("file", e);
2875
+ const a = await fetch(p, {
2876
+ method: "POST",
2877
+ body: r,
2878
+ credentials: "same-origin",
2879
+ signal: n
2880
+ });
2881
+ if (!a.ok) throw new Error(`Image upload failed (${a.status}).`);
2882
+ const s = Mi(await a.json());
2883
+ if (!s) throw new Error("Image upload response contained no URL.");
2884
+ return s;
2885
+ },
2886
+ [p, m]
2887
+ ), Ye = _(null), bt = _(null), [xe, Cn] = N(!1), [Kr, An] = N(!1), [Wr, vt] = N(""), yt = y(() => {
2888
+ const e = bt.current;
2889
+ e != null && e.parentNode && e.parentNode.removeChild(e), bt.current = null;
2890
+ }, []), _n = y((e) => {
2891
+ var a;
2892
+ const n = (a = V.current) == null ? void 0 : a.querySelector(
2893
+ ".redactor-in"
2894
+ );
2895
+ if (!n) return;
2896
+ let r = bt.current;
2897
+ if (!r || !n.contains(r)) {
2898
+ r = document.createElement("span"), r.setAttribute("data-rte-interim", ""), r.setAttribute("contenteditable", "false");
2899
+ const s = window.getSelection();
2900
+ if (s && s.rangeCount > 0 && n.contains(s.anchorNode)) {
2901
+ const f = s.getRangeAt(0);
2902
+ f.collapse(!1), f.insertNode(r);
2903
+ } else
2904
+ n.appendChild(r);
2905
+ bt.current = r;
2906
+ }
2907
+ r.textContent = e;
2908
+ }, []), wt = y(() => {
2909
+ var e;
2910
+ (e = Ye.current) == null || e.abort();
2911
+ }, []), Nn = y(() => {
2912
+ var f;
2913
+ if (typeof window > "u") return !1;
2914
+ const e = window.getSelection(), n = (f = V.current) == null ? void 0 : f.querySelector(".redactor-in");
2915
+ if (!e || e.rangeCount === 0 || !n) return !1;
2916
+ const { startContainer: r, startOffset: a } = e.getRangeAt(0);
2917
+ if (!n.contains(r) || r.nodeType !== Node.TEXT_NODE || a === 0)
2918
+ return !1;
2919
+ const s = r.data.charAt(a - 1);
2920
+ return /\S/.test(s) && s !== " ";
2921
+ }, []), pe = C !== void 0 && !C.granted, Xt = _(null), kt = y(() => {
2922
+ if (!S || pe) return;
2923
+ const e = new AbortController();
2924
+ Ye.current = e, An(!1), Cn(!0), vt(O("editor.ai.listening")), yt(), S({
2925
+ signal: e.signal,
2926
+ // Interim text shows live in the editor (grey + caret); each final
2927
+ // replaces it with committed text at the caret.
2928
+ onPartialTranscript: (n) => {
2929
+ e.signal.aborted || _n(n);
2930
+ },
2931
+ onFinalTranscript: (n) => {
2932
+ if (e.signal.aborted) return;
2933
+ yt();
2934
+ const r = n.trim();
2935
+ if (r) {
2936
+ const a = Xt.current;
2937
+ if (a) {
2938
+ Xt.current = null, we.current = a, ge(), ce(`${r} `, { asHtml: !1 }), vt(r);
2939
+ return;
2940
+ }
2941
+ const s = Nn() ? " " : "";
2942
+ ce(`${s}${r} `, { asHtml: !1 }), vt(r);
2943
+ }
2944
+ }
2945
+ }).catch((n) => {
2946
+ var r;
2947
+ if (!(e.signal.aborted || n && typeof n == "object" && "name" in n && n.name === "AbortError")) {
2948
+ if (sr(n) && ((r = Se.current) == null || r.call(Se), qt.current)) {
2949
+ Ot(!0), ze(!0);
2950
+ return;
2951
+ }
2952
+ An(!0);
2953
+ }
2954
+ }).finally(() => {
2955
+ yt(), Ye.current === e && (Ye.current = null, Cn(!1), vt(""));
2956
+ });
2957
+ }, [
2958
+ S,
2959
+ pe,
2960
+ ce,
2961
+ ge,
2962
+ yt,
2963
+ _n,
2964
+ Nn,
2965
+ O
2966
+ ]);
2967
+ D(() => () => {
2968
+ var e;
2969
+ return (e = Ye.current) == null ? void 0 : e.abort();
2970
+ }, []);
2971
+ const [Tn, Je] = N(null), $e = _(null), xt = _(null), [Vr, En] = N(!1), Xr = ((C == null ? void 0 : C.pending) ?? !1) || Vr, Ct = _(!1), zn = y(() => {
2972
+ $e.current = null, xt.current = null, Ct.current = !1, Je(null);
2973
+ }, []), Ur = y(() => {
2974
+ var n;
2975
+ Ct.current = !0;
2976
+ const e = (n = C == null ? void 0 : C.onGrant) == null ? void 0 : n.call(C);
2977
+ e && typeof e.then == "function" && (En(!0), Promise.resolve(e).catch(() => {
2978
+ }).finally(() => En(!1)));
2979
+ }, [C]), Sn = _((C == null ? void 0 : C.granted) ?? !0);
2980
+ D(() => {
2981
+ const e = Sn.current;
2982
+ if (Sn.current = (C == null ? void 0 : C.granted) ?? !0, !e && (C != null && C.granted) && $e.current) {
2983
+ const n = $e.current, r = Ct.current;
2984
+ $e.current = null, Ct.current = !1, Je(null);
2985
+ const a = xt.current;
2986
+ if (xt.current = null, !r) return;
2987
+ n === "write" ? ze(!0) : n === "action" ? a == null || a() : (ge(), kt());
2988
+ }
2989
+ }, [C == null ? void 0 : C.granted, ge, kt]), D(() => {
2990
+ pe && (ze(!1), xe && wt());
2991
+ }, [pe, xe, wt]);
2992
+ const Mn = y(
2993
+ (e = "document") => {
2994
+ if (xe) {
2995
+ wt();
2996
+ return;
2997
+ }
2998
+ Qe();
2999
+ const n = we.current;
3000
+ if (Xt.current = e === "selection" && n && !n.collapsed ? n.cloneRange() : null, pe) {
3001
+ $e.current = "dictate", Je("dictate");
3002
+ return;
3003
+ }
3004
+ kt();
3005
+ },
3006
+ [xe, wt, pe, Qe, kt]
3007
+ ), Rn = y(
3008
+ (e = "document") => {
3009
+ Qe();
3010
+ const n = we.current, r = n ? n.cloneRange() : null, a = e === "selection" && !!(r && !r.collapsed);
3011
+ if (r && !a && r.collapse(!1), ct.current = r, Tr(a ? "selection" : "document"), _r(a && r ? r.toString() : ""), pe) {
3012
+ $e.current = "write", Je("write");
3013
+ return;
3014
+ }
3015
+ ze(!0);
3016
+ },
3017
+ [Qe, pe]
3018
+ ), Ln = Ve(() => C != null && C.granted ? /* @__PURE__ */ x(Ce, { children: [
3019
+ O(
3020
+ "editor.ai.consentRecorded",
3021
+ "AI assistance consent has been recorded."
3022
+ ),
3023
+ B ? /* @__PURE__ */ x(Ce, { children: [
3024
+ " ",
3025
+ B
3026
+ ] }) : null
3027
+ ] }) : B, [C, B, O]), [et, Ut] = N(null), [Zr, At] = N(!1), [$n, In] = N(!1), [Qr, Ie] = N(""), Hn = _(null), [be, tt] = N(
3028
+ ue ? "intro" : null
3029
+ );
3030
+ D(() => {
3031
+ if (be !== "intro" && be !== "landed") return;
3032
+ const e = setTimeout(
3033
+ () => tt(null),
3034
+ Ti[be]
3035
+ );
3036
+ return () => clearTimeout(e);
3037
+ }, [be]);
3038
+ const Te = _(null), _t = _(Q);
3039
+ D(() => {
3040
+ _t.current = Q;
3041
+ }, [Q]);
3042
+ const nt = (e) => e.preventDefault(), Dn = y(
3043
+ (e) => {
3044
+ var r;
3045
+ const n = ee.current;
3046
+ if (n)
3047
+ try {
3048
+ const a = n(I);
3049
+ (r = a == null ? void 0 : a.broadcast) == null || r.call(a, "state", !1, e);
3050
+ } catch {
3051
+ }
3052
+ },
3053
+ [I]
3054
+ ), On = _(!1), He = y(
3055
+ (e) => {
3056
+ const n = ee.current;
3057
+ if (!n || On.current === e) return;
3058
+ On.current = e;
3059
+ const r = e || h;
3060
+ lt.current = r;
3061
+ try {
3062
+ n(I, r ? "enableReadOnly" : "disableReadOnly");
3063
+ } catch {
3064
+ }
3065
+ },
3066
+ [I, h]
3067
+ ), Zt = y(
3068
+ (e) => {
3069
+ var r;
3070
+ const n = Xe(
3071
+ ye(e),
3072
+ Fe.current
3073
+ );
3074
+ !oe("source.setCode", n) && de.current && (de.current.value = n), (r = le.current) == null || r.call(le, { html: n, markdown: "" });
3075
+ },
3076
+ [oe]
3077
+ ), De = y(
3078
+ (e) => {
3079
+ var s;
3080
+ const n = (s = V.current) == null ? void 0 : s.querySelector(".redactor-in"), r = typeof window < "u" ? window.getSelection() : null;
3081
+ if (e === "selection" && n && r && r.rangeCount > 0 && !r.isCollapsed) {
3082
+ const f = r.getRangeAt(0);
3083
+ if (n.contains(f.commonAncestorContainer)) {
3084
+ const w = f.toString();
3085
+ if (w.trim())
3086
+ return {
3087
+ scope: "selection",
3088
+ range: f.cloneRange(),
3089
+ html: Ei(f.cloneContents()),
3090
+ text: w
3091
+ };
3092
+ }
3093
+ }
3094
+ const a = re();
3095
+ return { scope: "document", range: null, html: a, text: lr(a) };
3096
+ },
3097
+ [re]
3098
+ ), Qt = y(
3099
+ (e, n, r, a) => {
3100
+ if (Te.current || !r.text.trim()) return;
3101
+ const s = new AbortController();
3102
+ Te.current = s, Ut(e), In(!1), Hn.current = e, Ie(O("editor.ai.generating")), At(!1), ue && tt("working");
3103
+ const f = re();
3104
+ He(!0), Promise.resolve(
3105
+ n({
3106
+ html: r.html,
3107
+ text: r.text,
3108
+ scope: r.scope,
3109
+ signal: s.signal
3110
+ })
3111
+ ).then((w) => {
3112
+ var J;
3113
+ if (s.signal.aborted) return;
3114
+ He(!1);
3115
+ const M = String(w ?? "");
3116
+ if (re() !== f) {
3117
+ In(!0), Ie("");
3118
+ return;
3119
+ }
3120
+ if (!lr(M)) {
3121
+ At(!0), Ie("");
3122
+ return;
3123
+ }
3124
+ if (Dn(f), r.scope === "selection" && r.range) {
3125
+ if (!r.range.startContainer.isConnected) {
3126
+ At(!0), Ie("");
3127
+ return;
3128
+ }
3129
+ we.current = r.range, ge();
3130
+ const ve = Xe(
3131
+ ye(M),
3132
+ Fe.current
3133
+ );
3134
+ oe("insertion.insertHtml", ve) || ce(M, { asHtml: !0 });
3135
+ } else
3136
+ Zt(M);
3137
+ ue && tt("landed"), Ie(O("editor.ai.actionDone")), (J = _t.current) == null || J.call(_t, {
3138
+ action: e,
3139
+ template: a,
3140
+ scope: r.scope,
3141
+ previousHtml: f,
3142
+ undo: () => Zt(f)
3143
+ });
3144
+ }).catch((w) => {
3145
+ var M;
3146
+ if (He(!1), !(s.signal.aborted || Ni(w))) {
3147
+ if (sr(w) && ((M = Se.current) == null || M.call(Se), qt.current)) {
3148
+ Ot(!0), ze(!0);
3149
+ return;
3150
+ }
3151
+ At(!0), Ie("");
3152
+ }
3153
+ }).finally(() => {
3154
+ Te.current === s && (Te.current = null, He(!1), Ut(null), tt((w) => w === "working" ? null : w));
3155
+ });
3156
+ },
3157
+ [
3158
+ ue,
3159
+ He,
3160
+ re,
3161
+ ge,
3162
+ oe,
3163
+ ce,
3164
+ Zt,
3165
+ Dn,
3166
+ O
3167
+ ]
3168
+ ), rt = y(
3169
+ (e, n, r, a) => {
3170
+ if (pe) {
3171
+ xt.current = () => Qt(e, n, r, a), $e.current = "action", Je("action");
3172
+ return;
3173
+ }
3174
+ Qt(e, n, r, a);
3175
+ },
3176
+ [pe, Qt]
3177
+ ), qn = y(
3178
+ (e, n) => {
3179
+ const r = P == null ? void 0 : P.onRun;
3180
+ r && rt(
3181
+ "template",
3182
+ (a) => r({ ...a, template: e }),
3183
+ n,
3184
+ e
3185
+ );
3186
+ },
3187
+ [P, rt]
3188
+ ), Pn = y(() => {
3189
+ var e;
3190
+ (e = Te.current) == null || e.abort(), Te.current = null, He(!1), Ut(null), Ie(""), tt((n) => n === "working" ? null : n);
3191
+ }, [He]), Bn = _(null);
3192
+ D(() => {
3193
+ const e = et ?? Hn.current;
3194
+ if (!e) return;
3195
+ const n = e === "template" ? "ai-templates" : `ai-${e}`, r = requestAnimationFrame(() => {
3196
+ var s, f;
3197
+ const a = document.activeElement;
3198
+ a && a !== document.body && a.isConnected || (f = (s = Bn.current) == null ? void 0 : s.querySelector(`[data-component-part="${n}"]`)) == null || f.focus();
3199
+ });
3200
+ return () => cancelAnimationFrame(r);
3201
+ }, [et]), D(() => () => {
3202
+ var e;
3203
+ return (e = Te.current) == null ? void 0 : e.abort();
3204
+ }, []), D(() => {
3205
+ const e = de.current;
3206
+ if (!e) return;
3207
+ e.value = Rr.current, _e.current();
3208
+ const n = Ri(q);
3209
+ if (!n) {
3210
+ bn(!0);
3211
+ return;
3212
+ }
3213
+ ee.current = n, e.value = Xe(e.value, Fe.current);
3214
+ const r = {
3215
+ lang: K ?? Ii(Cr.language || "en"),
3216
+ // The kit renders its OWN toolbar (EditorToolbar) and drives Redactor
3217
+ // via the command API, so Redactor's native toolbar is suppressed.
3218
+ toolbar: !1,
3219
+ plugins: z ?? [],
3220
+ placeholder: u ?? O("editor.placeholder"),
3221
+ toolbarFixed: !1,
3222
+ // Platform parity (RedactorWysiwyg.js:84): no inline shortcode expansion.
3223
+ shortcodes: !1,
3224
+ // The kit owns image editing: ImageFloatingToolbar provides DS-native,
3225
+ // keyboard-accessible resize + wrap/align, so Redactor's own image
3226
+ // popup AND its single-handle drag-resizer are both disabled to avoid a
3227
+ // second, untokenised, mouse-only UI competing with ours.
3228
+ imageEditable: !1,
3229
+ imageResizable: !1
3230
+ }, a = p ? { imageUpload: p } : {}, s = (E == null ? void 0 : E.callbacks) ?? {}, f = {
3231
+ ...r,
3232
+ ...a,
3233
+ ...E ?? {},
3234
+ // Re-pin safety-critical keys LAST so consumer `options` can't override
3235
+ // the sanitising change handler or re-enable Redactor's native image UI
3236
+ // (the kit's ImageFloatingToolbar replaces both — see kitDefaults above).
3237
+ imageEditable: !1,
3238
+ imageResizable: !1,
3239
+ callbacks: {
3240
+ ...s,
3241
+ changed(w) {
3242
+ _e.current();
3243
+ const M = Mt(
3244
+ ar(ir(w))
3245
+ ), J = ye(M), ve = jn.current;
3246
+ if (ve && Date.now() < ve.until && cr(J) === ve.text) {
3247
+ mt.current = J;
3248
+ return;
3249
+ }
3250
+ J !== mt.current && (mt.current = J, Ht.current = !0, le.current && (Ze.current && clearTimeout(Ze.current), Ze.current = setTimeout(() => {
3251
+ var qe;
3252
+ (qe = le.current) == null || qe.call(le, { html: J, markdown: "" });
3253
+ }, 100)));
3254
+ },
3255
+ keydown(w) {
3256
+ var M;
3257
+ (M = ft.current) == null || M.call(ft, w);
3258
+ },
3259
+ observe() {
3260
+ fe();
3261
+ }
3262
+ }
3263
+ };
3264
+ try {
3265
+ if (n(I, f), mt.current = ye(
3266
+ Mt(ar(re()))
3267
+ ), _e.current(), h)
3268
+ try {
3269
+ n(I, "enableReadOnly");
3270
+ } catch {
3271
+ }
3272
+ } catch {
3273
+ bn(!0);
3274
+ }
3275
+ return () => {
3276
+ Ze.current && clearTimeout(Ze.current);
3277
+ try {
3278
+ n(I, "destroy");
3279
+ } catch {
3280
+ }
3281
+ ee.current = null;
3282
+ };
3283
+ }, []);
3284
+ const Fn = _(se), jn = _(
3285
+ null
3286
+ );
3287
+ D(() => {
3288
+ var r, a;
3289
+ if (Fn.current === se || (Fn.current = se, !ee.current || se.size === 0)) return;
3290
+ const e = re(), n = Xe(e, se);
3291
+ if (n !== e) {
3292
+ const s = (r = V.current) == null ? void 0 : r.querySelector(".redactor-in"), w = s != null && s.contains(document.activeElement) && s ? zi(s) : null;
3293
+ jn.current = {
3294
+ text: cr(e),
3295
+ until: Date.now() + 1e3
3296
+ }, oe("source.setCode", n);
3297
+ const M = (a = V.current) == null ? void 0 : a.querySelector(".redactor-in");
3298
+ w !== null && M && Si(M, w);
3299
+ }
3300
+ window.requestAnimationFrame(() => _e.current());
3301
+ }, [se, re, oe]), D(() => {
3302
+ if (!ee.current || d === void 0) return;
3303
+ if (Ht.current) {
3304
+ Ht.current = !1;
3305
+ return;
3306
+ }
3307
+ const e = Xe(
3308
+ ye(Mt(d)),
3309
+ Fe.current
3310
+ );
3311
+ Mt(re()) !== e && oe("source.setCode", e);
3312
+ }, [d, re, oe]), D(() => {
3313
+ lt.current = h;
3314
+ const e = ee.current;
3315
+ if (e)
3316
+ try {
3317
+ e(I, h ? "enableReadOnly" : "disableReadOnly");
3318
+ } catch {
3319
+ }
3320
+ }, [h, I]), D(() => {
3321
+ if (!ie || d === void 0) return;
3322
+ const e = de.current;
3323
+ if (!e) return;
3324
+ const n = ye(d);
3325
+ e.value !== n && document.activeElement !== e && (e.value = n);
3326
+ }, [ie, d]);
3327
+ const We = Ve(
3328
+ () => ({
3329
+ getHTML() {
3330
+ return re();
3331
+ },
3332
+ getText() {
3333
+ return re().replace(/<[^>]*>/g, " ").replace(/&nbsp;/gi, " ").replace(/\s+/g, " ").trim();
3334
+ },
3335
+ getMarkdown() {
3336
+ return "";
3337
+ },
3338
+ isAiBusy() {
3339
+ return Te.current !== null;
3340
+ },
3341
+ setContent(e) {
3342
+ const n = ye(e);
3343
+ oe(
3344
+ "source.setCode",
3345
+ Xe(n, Fe.current)
3346
+ ) || de.current && (de.current.value = n);
3347
+ },
3348
+ insertAtCursor: ce,
3349
+ applyFormat(e) {
3350
+ const n = Li[e];
3351
+ n && Re(...n);
3352
+ },
3353
+ focus() {
3354
+ var n;
3355
+ const e = ee.current;
3356
+ if (e)
3357
+ try {
3358
+ e(I, "editor.focus");
3359
+ return;
3360
+ } catch {
3361
+ }
3362
+ (n = de.current) == null || n.focus();
3363
+ },
3364
+ clear() {
3365
+ oe("source.setCode", "") || de.current && (de.current.value = "");
3366
+ }
3367
+ }),
3368
+ [I, re, oe, ce, Re]
3369
+ );
3370
+ mo(xr, () => We, [We]), po(ja, We, o);
3371
+ const Yr = y(
3372
+ (e) => {
3373
+ var n;
3374
+ _e.current(), (n = le.current) == null || n.call(le, {
3375
+ html: ye(e.target.value),
3376
+ markdown: ""
3377
+ });
3378
+ },
3379
+ []
3380
+ ), Nt = l ?? O("editor.regionLabel"), Jr = u ?? O("editor.placeholder");
3381
+ D(() => {
3382
+ var a;
3383
+ if (ie) return;
3384
+ const e = (a = V.current) == null ? void 0 : a.querySelector(".redactor-in");
3385
+ if (!e) return;
3386
+ const n = () => {
3387
+ e.getAttribute("role") !== "textbox" && e.setAttribute("role", "textbox"), e.getAttribute("aria-multiline") !== "true" && e.setAttribute("aria-multiline", "true"), e.getAttribute("aria-label") !== Nt && e.setAttribute("aria-label", Nt), e.hasAttribute("aria-labelledby") && e.removeAttribute("aria-labelledby");
3388
+ };
3389
+ n();
3390
+ const r = new MutationObserver(n);
3391
+ return r.observe(e, {
3392
+ attributes: !0,
3393
+ attributeFilter: ["role", "aria-labelledby"]
3394
+ }), () => r.disconnect();
3395
+ }, [ie, Nt]);
3396
+ const Tt = et !== null, eo = y(
3397
+ (e) => {
3398
+ sn.test(e) && (ie ? ce(`[[${e}]]`, { asHtml: !1 }) : (ge(), Le(dr(e))), W == null || W(e));
3399
+ },
3400
+ [
3401
+ ie,
3402
+ ce,
3403
+ ge,
3404
+ Le,
3405
+ W
3406
+ ]
3407
+ ), Yt = _(null), [to, no] = N(!1), [ro, oo] = N(!1), ao = y(
3408
+ (e, n) => {
3409
+ if (oo(e), !e) return;
3410
+ const r = De(n);
3411
+ Yt.current = r, no(!r.text.trim());
3412
+ },
3413
+ [De]
3414
+ ), io = y(
3415
+ (e) => {
3416
+ const n = Yt.current ?? De("document");
3417
+ Yt.current = null, qn(e, n);
3418
+ },
3419
+ [De, qn]
3420
+ ), Gn = (e, n) => {
3421
+ if (!n) return null;
3422
+ const r = et === e;
3423
+ return {
3424
+ key: e,
3425
+ // While running, the segment becomes a Stop/Cancel button (progress
3426
+ // shows on the scrim spinner).
3427
+ icon: r ? /* @__PURE__ */ t(at, { "aria-hidden": "true", className: "ds:size-5 ds:fill-current" }) : e === "proofread" ? /* @__PURE__ */ t(Yn, { "aria-hidden": "true", className: "ds:size-5" }) : /* @__PURE__ */ t(Jn, { "aria-hidden": "true", className: "ds:size-5" }),
3428
+ label: r ? O("common.cancel") : e === "proofread" ? O("editor.ai.proofread", "Check spelling & grammar") : O("editor.ai.autoFormat", "Auto-format document"),
3429
+ onClick: r ? Pn : () => rt(e, n, De("document")),
3430
+ running: r
3431
+ };
3432
+ }, Oe = [];
3433
+ if (S && Oe.push({
3434
+ key: "dictate",
3435
+ icon: xe ? /* @__PURE__ */ t(at, { "aria-hidden": "true", className: "ds:size-5 ds:fill-current" }) : /* @__PURE__ */ t(ln, { "aria-hidden": "true", className: "ds:size-5" }),
3436
+ label: O(xe ? "editor.ai.dictateStop" : "editor.ai.dictateStart"),
3437
+ onClick: () => Mn("document"),
3438
+ recording: xe
3439
+ }), P) {
3440
+ const e = et === "template";
3441
+ Oe.push({
3442
+ key: "templates",
3443
+ icon: e ? /* @__PURE__ */ t(at, { "aria-hidden": "true", className: "ds:size-5 ds:fill-current" }) : /* @__PURE__ */ t(cn, { "aria-hidden": "true", className: "ds:size-5" }),
3444
+ label: O(e ? "common.cancel" : "editor.ai.templates"),
3445
+ onClick: e ? Pn : void 0,
3446
+ running: e,
3447
+ menu: !e
3448
+ });
3449
+ }
3450
+ const Kn = Gn("proofread", F);
3451
+ Kn && Oe.push(Kn);
3452
+ const Wn = Gn("format", j);
3453
+ Wn && Oe.push(Wn), (L || Y) && Oe.push({
3454
+ key: "write",
3455
+ icon: /* @__PURE__ */ t(zt, { "aria-hidden": "true", className: "ds:size-5" }),
3456
+ label: O("editor.ai.helpMeWrite"),
3457
+ onClick: () => Rn("document")
3458
+ });
3459
+ const Vn = (e, n) => P ? /* @__PURE__ */ t(
3460
+ yi,
3461
+ {
3462
+ side: n === "document" ? "top" : "bottom",
3463
+ templates: P.templates,
3464
+ onPick: io,
3465
+ onManage: P.onManage,
3466
+ noteEmpty: to,
3467
+ onOpenChange: (r) => ao(r, n),
3468
+ trigger: e
3469
+ }
3470
+ ) : null, Xn = !!(L || Y), Un = !!(P || F || j || Xn || S), so = !ie && !h && (Ne ?? Un), lo = y(
3471
+ () => {
3472
+ var e;
3473
+ return ((e = V.current) == null ? void 0 : e.querySelector(".redactor-in")) ?? null;
3474
+ },
3475
+ []
3476
+ );
3477
+ return /* @__PURE__ */ x(
3478
+ "div",
3479
+ {
3480
+ ref: V,
3481
+ className: [Hi(), A].filter(Boolean).join(" "),
3482
+ "data-component": "rich-text-editor",
3483
+ "data-component-id": o,
3484
+ "data-min-height": b,
3485
+ children: [
3486
+ !ie && !h ? /* @__PURE__ */ t(
3487
+ Ci,
3488
+ {
3489
+ run: Re,
3490
+ active: jt,
3491
+ preset: g,
3492
+ insertHtml: Le,
3493
+ insertTable: jr,
3494
+ saveSelection: Qe,
3495
+ restoreSelection: ge,
3496
+ getSelectedText: Dr,
3497
+ uploadImage: p || m ? Gr : void 0,
3498
+ enableColor: (z == null ? void 0 : z.includes("fontcolor")) ?? !1,
3499
+ enableImage: !!(p || m),
3500
+ enableTable: (z == null ? void 0 : z.includes("table")) ?? !1,
3501
+ showExtensions: k,
3502
+ variables: yn,
3503
+ recentVariableTokens: U,
3504
+ insertVariable: eo
3505
+ }
3506
+ ) : null,
3507
+ /* @__PURE__ */ x("div", { className: "ds:relative", ref: Ue, children: [
3508
+ /* @__PURE__ */ t(
3509
+ "textarea",
3510
+ {
3511
+ ref: de,
3512
+ id: Be,
3513
+ "aria-label": Nt,
3514
+ "aria-multiline": "true",
3515
+ "aria-busy": Tt || void 0,
3516
+ placeholder: Jr,
3517
+ onChange: ie ? Yr : void 0,
3518
+ readOnly: ie ? h : void 0,
3519
+ className: ie ? Oi() : void 0
3520
+ }
3521
+ ),
3522
+ Tt ? /* @__PURE__ */ t(
3523
+ "div",
3524
+ {
3525
+ "aria-hidden": "true",
3526
+ className: "ds:absolute ds:inset-0 ds:z-[5] ds:flex ds:items-center ds:justify-center ds:cursor-wait ds:rounded-[var(--radius-md)] ds:bg-[color-mix(in_srgb,var(--background)_40%,transparent)]",
3527
+ children: /* @__PURE__ */ t(fr, { size: "lg", variant: "prism" })
3528
+ }
3529
+ ) : null,
3530
+ /* @__PURE__ */ x("div", { className: "ds:sticky ds:bottom-0 ds:z-10", children: [
3531
+ Oe.length > 0 ? /* @__PURE__ */ x(
3532
+ "div",
3533
+ {
3534
+ ref: Bn,
3535
+ className: "ds:absolute ds:[inset-block-end:var(--spacing-md)] ds:[inset-inline-end:var(--spacing-md)] ds:z-10",
3536
+ "data-ai-sparkle": be ?? void 0,
3537
+ children: [
3538
+ /* @__PURE__ */ x("div", { className: "ds:relative ds:flex ds:items-center ds:overflow-hidden ds:rounded-full ds:bg-[var(--primary)] ds:bg-[image:var(--gradient-brand)] ds:shadow-[0_8px_24px_color-mix(in_srgb,var(--primary)_35%,transparent)]", children: [
3539
+ Oe.map((e, n) => {
3540
+ const r = /* @__PURE__ */ t(
3541
+ "button",
3542
+ {
3543
+ type: "button",
3544
+ onClick: e.onClick,
3545
+ "aria-pressed": e.recording || void 0,
3546
+ "aria-busy": e.running || void 0,
3547
+ "aria-haspopup": e.menu ? "menu" : void 0,
3548
+ "data-component-part": `ai-${e.key}`,
3549
+ disabled: Tt && !e.running || void 0,
3550
+ "aria-label": e.label,
3551
+ className: e.recording ? Pi : qi,
3552
+ children: e.icon
3553
+ }
3554
+ );
3555
+ return /* @__PURE__ */ x($t, { children: [
3556
+ n > 0 ? /* @__PURE__ */ t(
3557
+ "span",
3558
+ {
3559
+ "aria-hidden": "true",
3560
+ className: "ds:self-stretch ds:[inline-size:var(--border-width-sm)] ds:bg-[color-mix(in_srgb,var(--primary-foreground)_35%,transparent)]"
3561
+ }
3562
+ ) : null,
3563
+ e.menu ? Vn(r, "document") : r
3564
+ ] }, e.key);
3565
+ }),
3566
+ be ? /* @__PURE__ */ t(
3567
+ "span",
3568
+ {
3569
+ "aria-hidden": "true",
3570
+ className: `ds:pointer-events-none ds:absolute ds:inset-0 ds:-translate-x-full ds:bg-[linear-gradient(90deg,transparent,color-mix(in_srgb,var(--primary-foreground)_45%,transparent),transparent)] ${Bi[be]}`
3571
+ }
3572
+ ) : null
3573
+ ] }),
3574
+ be ? /* @__PURE__ */ x("span", { "aria-hidden": "true", className: "ds:pointer-events-none", children: [
3575
+ Gi.map((e) => /* @__PURE__ */ t(
3576
+ "span",
3577
+ {
3578
+ className: `${mr} ${ur[be]} ${e.lag}`,
3579
+ children: /* @__PURE__ */ t(
3580
+ "span",
3581
+ {
3582
+ className: `ds:block ds:rounded-full ds:bg-[var(--ai-sparkle)] ds:shadow-[0_0_var(--spacing-2xs)_var(--ai-sparkle)] ${e.dot}`
3583
+ }
3584
+ )
3585
+ },
3586
+ e.key
3587
+ )),
3588
+ /* @__PURE__ */ t("span", { className: `${mr} ${ur[be]}`, children: /* @__PURE__ */ t(zt, { className: "ds:block ds:size-3 ds:fill-current ds:text-[color:var(--primary-foreground)] ds:drop-shadow-[0_0_var(--spacing-2xs)_var(--ai-sparkle)]" }) }),
3589
+ ji.map((e) => /* @__PURE__ */ t(
3590
+ zt,
3591
+ {
3592
+ className: `${e.className} ${Fi[be]}`
3593
+ },
3594
+ e.key
3595
+ ))
3596
+ ] }) : null
3597
+ ]
3598
+ }
3599
+ ) : null,
3600
+ Y ? Y({
3601
+ open: Dt && !pe,
3602
+ onClose: () => {
3603
+ ze(!1), Ot(!1);
3604
+ },
3605
+ selectionText: Ar,
3606
+ scope: Nr,
3607
+ creditsExhausted: Er,
3608
+ getHTML: We.getHTML,
3609
+ getText: We.getText,
3610
+ insertAtSelection: (e) => {
3611
+ ct.current && (we.current = ct.current.cloneRange()), ge(), ce(e, { asHtml: !0 });
3612
+ },
3613
+ insertAfterSelection: (e) => {
3614
+ const n = ct.current ?? we.current;
3615
+ if (n) {
3616
+ const r = n.cloneRange();
3617
+ r.collapse(!1), we.current = r;
3618
+ }
3619
+ ge(), ce(e, { asHtml: !0 });
3620
+ },
3621
+ setContent: We.setContent,
3622
+ onDictate: S,
3623
+ privacyNotice: Ln
3624
+ }) : L ? /* @__PURE__ */ t(
3625
+ Va,
3626
+ {
3627
+ open: Dt && !pe,
3628
+ onClose: () => ze(!1),
3629
+ onRequestAiDraft: L,
3630
+ onInsert: (e) => {
3631
+ ge(), ce(e, { asHtml: T !== "text" });
3632
+ },
3633
+ previewAsHtml: T !== "text",
3634
+ privacyNotice: Ln,
3635
+ onDictate: S
3636
+ }
3637
+ ) : null,
3638
+ C ? /* @__PURE__ */ t(
3639
+ gr,
3640
+ {
3641
+ open: Tn !== null,
3642
+ onClose: zn,
3643
+ ariaLabel: O(
3644
+ "editor.ai.consentRegionLabel",
3645
+ "AI assistance consent for this document"
3646
+ ),
3647
+ footer: /* @__PURE__ */ t(Ae, { intent: "ghost", size: "sm", onClick: zn, children: O("common.close") }),
3648
+ children: /* @__PURE__ */ t(
3649
+ ho,
3650
+ {
3651
+ granted: C.granted,
3652
+ grantedAt: C.grantedAt,
3653
+ grantedBy: C.grantedBy,
3654
+ canGrant: (C.canGrant ?? !0) && C.onGrant !== void 0,
3655
+ pending: Xr,
3656
+ onGrantConsent: Ur,
3657
+ headingLevel: H,
3658
+ "aria-label": O(
3659
+ "editor.ai.consentRegionLabel",
3660
+ "AI assistance consent for this document"
3661
+ )
3662
+ }
3663
+ )
3664
+ }
3665
+ ) : null
3666
+ ] }),
3667
+ !ie && !h && ((z == null ? void 0 : z.includes("table")) ?? !1) ? /* @__PURE__ */ t(
3668
+ li,
3669
+ {
3670
+ active: jt,
3671
+ run: Re,
3672
+ areaRef: Ue,
3673
+ getActiveTableEl: Or,
3674
+ enableColor: (z == null ? void 0 : z.includes("fontcolor")) ?? !1,
3675
+ saveTableCell: qr,
3676
+ applyTableBackground: Pr
3677
+ }
3678
+ ) : null,
3679
+ !ie && !h ? /* @__PURE__ */ t(
3680
+ vi,
3681
+ {
3682
+ areaRef: Ue,
3683
+ activeImageEl: Sr,
3684
+ applyImageClass: Br,
3685
+ setImageWidth: Fr
3686
+ }
3687
+ ) : null,
3688
+ so ? /* @__PURE__ */ t(
3689
+ xi,
3690
+ {
3691
+ active: jt,
3692
+ run: Re,
3693
+ areaRef: Ue,
3694
+ getEditorRoot: lo,
3695
+ suppressed: Tt || Dt || Tn !== null,
3696
+ holdOpen: ro,
3697
+ children: Un ? /* @__PURE__ */ x(Ce, { children: [
3698
+ S ? /* @__PURE__ */ t(
3699
+ G,
3700
+ {
3701
+ size: "sm",
3702
+ intent: "ghost",
3703
+ "data-component-part": "selection-ai-dictate",
3704
+ onMouseDown: nt,
3705
+ icon: xe ? /* @__PURE__ */ t(at, {}) : /* @__PURE__ */ t(ln, {}),
3706
+ "aria-pressed": xe,
3707
+ tooltip: O(xe ? "editor.ai.dictateStop" : "editor.ai.dictateStart"),
3708
+ onClick: () => Mn("selection")
3709
+ }
3710
+ ) : null,
3711
+ P ? Vn(
3712
+ /* @__PURE__ */ t(
3713
+ Ae,
3714
+ {
3715
+ size: "sm",
3716
+ intent: "ghost",
3717
+ "data-component-part": "selection-ai-templates",
3718
+ onMouseDown: nt,
3719
+ startIcon: /* @__PURE__ */ t(cn, {}),
3720
+ endIcon: /* @__PURE__ */ t(hr, {}),
3721
+ children: O("editor.ai.templates")
3722
+ }
3723
+ ),
3724
+ "selection"
3725
+ ) : null,
3726
+ F ? /* @__PURE__ */ t(
3727
+ G,
3728
+ {
3729
+ size: "sm",
3730
+ intent: "ghost",
3731
+ "data-component-part": "selection-ai-proofread",
3732
+ onMouseDown: nt,
3733
+ icon: /* @__PURE__ */ t(Yn, {}),
3734
+ tooltip: O("editor.ai.proofread"),
3735
+ onClick: () => rt(
3736
+ "proofread",
3737
+ F,
3738
+ De("selection")
3739
+ )
3740
+ }
3741
+ ) : null,
3742
+ j ? /* @__PURE__ */ t(
3743
+ G,
3744
+ {
3745
+ size: "sm",
3746
+ intent: "ghost",
3747
+ "data-component-part": "selection-ai-format",
3748
+ onMouseDown: nt,
3749
+ icon: /* @__PURE__ */ t(Jn, {}),
3750
+ tooltip: O("editor.ai.autoFormat"),
3751
+ onClick: () => rt(
3752
+ "format",
3753
+ j,
3754
+ De("selection")
3755
+ )
3756
+ }
3757
+ ) : null,
3758
+ Xn ? /* @__PURE__ */ t(
3759
+ G,
3760
+ {
3761
+ size: "sm",
3762
+ intent: "ghost",
3763
+ "data-component-part": "selection-ai-write",
3764
+ onMouseDown: nt,
3765
+ icon: /* @__PURE__ */ t(zt, {}),
3766
+ tooltip: O("editor.ai.helpMeWrite"),
3767
+ onClick: () => Rn("selection")
3768
+ }
3769
+ ) : null
3770
+ ] }) : null
3771
+ }
3772
+ ) : null,
3773
+ Ke ? /* @__PURE__ */ t(
3774
+ "div",
3775
+ {
3776
+ className: Di,
3777
+ style: {
3778
+ "--rte-typeahead-x": `${Ke.left}px`,
3779
+ "--rte-typeahead-y": `${Ke.top}px`
3780
+ },
3781
+ children: /* @__PURE__ */ t(
3782
+ pr,
3783
+ {
3784
+ ref: kn,
3785
+ id: Wt,
3786
+ variables: yn,
3787
+ recentTokens: U,
3788
+ query: Ke.query,
3789
+ onQueryChange: Hr,
3790
+ onSelect: $r,
3791
+ onClose: Ir,
3792
+ searchFocusable: !1,
3793
+ onActiveDescendantChange: Lr
3794
+ }
3795
+ )
3796
+ }
3797
+ ) : null
3798
+ ] }),
3799
+ S ? /* @__PURE__ */ t("p", { className: "ds:sr-only", role: "status", "aria-live": "polite", children: Wr }) : null,
3800
+ Ge.length > 0 ? /* @__PURE__ */ t(
3801
+ "p",
3802
+ {
3803
+ id: `${Be}-variables-error`,
3804
+ role: "alert",
3805
+ className: "ds:m-0 ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--destructive)]",
3806
+ children: O("editor.variableInvalid", {
3807
+ tokens: Ge.map((e) => `[[${e}]]`).join(", ")
3808
+ })
3809
+ }
3810
+ ) : null,
3811
+ S && Kr ? /* @__PURE__ */ t(
3812
+ "p",
3813
+ {
3814
+ role: "alert",
3815
+ className: "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--destructive)]",
3816
+ children: O("editor.ai.dictationError")
3817
+ }
3818
+ ) : null,
3819
+ P || F || j ? /* @__PURE__ */ t("p", { className: "ds:sr-only", role: "status", "aria-live": "polite", children: Qr }) : null,
3820
+ Zr || $n ? /* @__PURE__ */ t(
3821
+ "p",
3822
+ {
3823
+ role: "alert",
3824
+ className: "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--destructive)]",
3825
+ children: O($n ? "editor.ai.actionStale" : "editor.ai.actionError")
3826
+ }
3827
+ ) : null
3828
+ ]
3829
+ }
3830
+ );
3831
+ }
3832
+ );
3833
+ Ki.displayName = "RichTextEditor";
3834
+ export {
3835
+ Ki as R,
3836
+ ja as r,
3837
+ Hi as w
3838
+ };
3839
+ //# sourceMappingURL=rich-text-editor-BYE6kK4u.js.map