tiptap-markdown-react 1.2.0 → 1.3.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.
@@ -0,0 +1,2164 @@
1
+ "use client";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import { useRef, useState, useEffect, useLayoutEffect } from "react";
4
+ import { l as normalizeImageCrop, m as cropImageBox, o as styles$2, R as ReportContent, p as parseChartFenceBody } from "./ReportContent-Cb67MCs9.js";
5
+ import { Chart, CategoryScale, LinearScale, PointElement, LineElement, BarElement, ArcElement, LineController, BarController, PieController, DoughnutController, Filler, Legend, Tooltip } from "chart.js";
6
+ import { createPortal } from "react-dom";
7
+ function Svg({ size = "1em", children, ...rest }) {
8
+ return /* @__PURE__ */ jsx(
9
+ "svg",
10
+ {
11
+ xmlns: "http://www.w3.org/2000/svg",
12
+ width: size,
13
+ height: size,
14
+ viewBox: "0 0 24 24",
15
+ fill: "none",
16
+ stroke: "currentColor",
17
+ strokeWidth: 2,
18
+ strokeLinecap: "round",
19
+ strokeLinejoin: "round",
20
+ "aria-hidden": "true",
21
+ focusable: "false",
22
+ ...rest,
23
+ children
24
+ }
25
+ );
26
+ }
27
+ const BoldIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
28
+ /* @__PURE__ */ jsx("path", { d: "M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" }),
29
+ /* @__PURE__ */ jsx("path", { d: "M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" })
30
+ ] });
31
+ const ItalicIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
32
+ /* @__PURE__ */ jsx("line", { x1: "19", x2: "10", y1: "4", y2: "4" }),
33
+ /* @__PURE__ */ jsx("line", { x1: "14", x2: "5", y1: "20", y2: "20" }),
34
+ /* @__PURE__ */ jsx("line", { x1: "15", x2: "9", y1: "4", y2: "20" })
35
+ ] });
36
+ const UnderlineIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
37
+ /* @__PURE__ */ jsx("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
38
+ /* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "20", y2: "20" })
39
+ ] });
40
+ const StrikethroughIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
41
+ /* @__PURE__ */ jsx("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
42
+ /* @__PURE__ */ jsx("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
43
+ /* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "12", y2: "12" })
44
+ ] });
45
+ const CodeIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
46
+ /* @__PURE__ */ jsx("polyline", { points: "16 18 22 12 16 6" }),
47
+ /* @__PURE__ */ jsx("polyline", { points: "8 6 2 12 8 18" })
48
+ ] });
49
+ const LinkIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
50
+ /* @__PURE__ */ jsx("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
51
+ /* @__PURE__ */ jsx("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
52
+ ] });
53
+ const EraserIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
54
+ /* @__PURE__ */ jsx("path", { d: "m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21" }),
55
+ /* @__PURE__ */ jsx("path", { d: "M22 21H7" }),
56
+ /* @__PURE__ */ jsx("path", { d: "m5 11 9 9" })
57
+ ] });
58
+ const RotateCcwIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
59
+ /* @__PURE__ */ jsx("path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }),
60
+ /* @__PURE__ */ jsx("path", { d: "M3 3v5h5" })
61
+ ] });
62
+ const ExternalLinkIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
63
+ /* @__PURE__ */ jsx("path", { d: "M15 3h6v6" }),
64
+ /* @__PURE__ */ jsx("path", { d: "M10 14 21 3" }),
65
+ /* @__PURE__ */ jsx("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" })
66
+ ] });
67
+ const ImageIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
68
+ /* @__PURE__ */ jsx("rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2" }),
69
+ /* @__PURE__ */ jsx("circle", { cx: "9", cy: "9", r: "2" }),
70
+ /* @__PURE__ */ jsx("path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" })
71
+ ] });
72
+ const BlockSvg = ({ size = "1em", children, ...rest }) => /* @__PURE__ */ jsx(
73
+ "svg",
74
+ {
75
+ xmlns: "http://www.w3.org/2000/svg",
76
+ width: size,
77
+ height: size,
78
+ viewBox: "0 0 24 24",
79
+ fill: "currentColor",
80
+ stroke: "none",
81
+ "aria-hidden": "true",
82
+ focusable: "false",
83
+ ...rest,
84
+ children
85
+ }
86
+ );
87
+ const AlignLeftIcon = (p) => /* @__PURE__ */ jsxs(BlockSvg, { ...p, children: [
88
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "3.4", width: "18", height: "2.4", rx: "1.2" }),
89
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "8.6", width: "12", height: "2.4", rx: "1.2" }),
90
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "13.8", width: "18", height: "2.4", rx: "1.2" }),
91
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "19", width: "12", height: "2.4", rx: "1.2" })
92
+ ] });
93
+ const AlignCenterIcon = (p) => /* @__PURE__ */ jsxs(BlockSvg, { ...p, children: [
94
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "3.4", width: "18", height: "2.4", rx: "1.2" }),
95
+ /* @__PURE__ */ jsx("rect", { x: "6", y: "8.6", width: "12", height: "2.4", rx: "1.2" }),
96
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "13.8", width: "18", height: "2.4", rx: "1.2" }),
97
+ /* @__PURE__ */ jsx("rect", { x: "6", y: "19", width: "12", height: "2.4", rx: "1.2" })
98
+ ] });
99
+ const AlignRightIcon = (p) => /* @__PURE__ */ jsxs(BlockSvg, { ...p, children: [
100
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "3.4", width: "18", height: "2.4", rx: "1.2" }),
101
+ /* @__PURE__ */ jsx("rect", { x: "9", y: "8.6", width: "12", height: "2.4", rx: "1.2" }),
102
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "13.8", width: "18", height: "2.4", rx: "1.2" }),
103
+ /* @__PURE__ */ jsx("rect", { x: "9", y: "19", width: "12", height: "2.4", rx: "1.2" })
104
+ ] });
105
+ const AlignJustifyIcon = (p) => /* @__PURE__ */ jsxs(BlockSvg, { ...p, children: [
106
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "3.4", width: "18", height: "2.4", rx: "1.2" }),
107
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "8.6", width: "18", height: "2.4", rx: "1.2" }),
108
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "13.8", width: "18", height: "2.4", rx: "1.2" }),
109
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "19", width: "18", height: "2.4", rx: "1.2" })
110
+ ] });
111
+ const IndentIncreaseIcon = (p) => /* @__PURE__ */ jsxs(BlockSvg, { ...p, children: [
112
+ /* @__PURE__ */ jsx("path", { d: "M3 6.6 8.5 10.8 3 15 Z" }),
113
+ /* @__PURE__ */ jsx("rect", { x: "10.5", y: "3.6", width: "10.5", height: "2.4", rx: "1.2" }),
114
+ /* @__PURE__ */ jsx("rect", { x: "10.5", y: "10.8", width: "10.5", height: "2.4", rx: "1.2" }),
115
+ /* @__PURE__ */ jsx("rect", { x: "10.5", y: "18", width: "10.5", height: "2.4", rx: "1.2" })
116
+ ] });
117
+ const IndentDecreaseIcon = (p) => /* @__PURE__ */ jsxs(BlockSvg, { ...p, children: [
118
+ /* @__PURE__ */ jsx("path", { d: "M8.5 6.6 3 10.8 8.5 15 Z" }),
119
+ /* @__PURE__ */ jsx("rect", { x: "10.5", y: "3.6", width: "10.5", height: "2.4", rx: "1.2" }),
120
+ /* @__PURE__ */ jsx("rect", { x: "10.5", y: "10.8", width: "10.5", height: "2.4", rx: "1.2" }),
121
+ /* @__PURE__ */ jsx("rect", { x: "10.5", y: "18", width: "10.5", height: "2.4", rx: "1.2" })
122
+ ] });
123
+ const LineHeightIcon = (p) => /* @__PURE__ */ jsxs(BlockSvg, { ...p, children: [
124
+ /* @__PURE__ */ jsx("rect", { x: "1.8", y: "4.4", width: "2.4", height: "15.2", rx: "1.2" }),
125
+ /* @__PURE__ */ jsx("path", { d: "M3 2.4 5.4 5.8 H0.6 Z" }),
126
+ /* @__PURE__ */ jsx("path", { d: "M3 21.6 0.6 18.2 H5.4 Z" }),
127
+ /* @__PURE__ */ jsx("rect", { x: "9", y: "5.6", width: "12", height: "2.4", rx: "1.2" }),
128
+ /* @__PURE__ */ jsx("rect", { x: "9", y: "16", width: "12", height: "2.4", rx: "1.2" })
129
+ ] });
130
+ const CaptionsIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
131
+ /* @__PURE__ */ jsx("rect", { width: "18", height: "14", x: "3", y: "5", rx: "2", ry: "2" }),
132
+ /* @__PURE__ */ jsx("path", { d: "M7 15h4" }),
133
+ /* @__PURE__ */ jsx("path", { d: "M15 15h2" }),
134
+ /* @__PURE__ */ jsx("path", { d: "M7 11h2" }),
135
+ /* @__PURE__ */ jsx("path", { d: "M13 11h4" })
136
+ ] });
137
+ const CropIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
138
+ /* @__PURE__ */ jsx("path", { d: "M6 2v14a2 2 0 0 0 2 2h14" }),
139
+ /* @__PURE__ */ jsx("path", { d: "M18 22V8a2 2 0 0 0-2-2H2" })
140
+ ] });
141
+ const ImportIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
142
+ /* @__PURE__ */ jsx("path", { d: "M12 3v12" }),
143
+ /* @__PURE__ */ jsx("path", { d: "m8 11 4 4 4-4" }),
144
+ /* @__PURE__ */ jsx("path", { d: "M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4" })
145
+ ] });
146
+ const ListUnorderedIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
147
+ /* @__PURE__ */ jsx("line", { x1: "8", x2: "21", y1: "6", y2: "6" }),
148
+ /* @__PURE__ */ jsx("line", { x1: "8", x2: "21", y1: "12", y2: "12" }),
149
+ /* @__PURE__ */ jsx("line", { x1: "8", x2: "21", y1: "18", y2: "18" }),
150
+ /* @__PURE__ */ jsx("line", { x1: "3", x2: "3.01", y1: "6", y2: "6" }),
151
+ /* @__PURE__ */ jsx("line", { x1: "3", x2: "3.01", y1: "12", y2: "12" }),
152
+ /* @__PURE__ */ jsx("line", { x1: "3", x2: "3.01", y1: "18", y2: "18" })
153
+ ] });
154
+ const ListOrderedIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
155
+ /* @__PURE__ */ jsx("line", { x1: "10", x2: "21", y1: "6", y2: "6" }),
156
+ /* @__PURE__ */ jsx("line", { x1: "10", x2: "21", y1: "12", y2: "12" }),
157
+ /* @__PURE__ */ jsx("line", { x1: "10", x2: "21", y1: "18", y2: "18" }),
158
+ /* @__PURE__ */ jsx("path", { d: "M4 6h1v4" }),
159
+ /* @__PURE__ */ jsx("path", { d: "M4 10h2" }),
160
+ /* @__PURE__ */ jsx("path", { d: "M6 18H4c0-1 2-2 2-3s-1-1.5-2-1" })
161
+ ] });
162
+ const DetailsIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
163
+ /* @__PURE__ */ jsx("path", { d: "m9 7 4 5-4 5" }),
164
+ /* @__PURE__ */ jsx("path", { d: "M15 7h5" }),
165
+ /* @__PURE__ */ jsx("path", { d: "M15 12h5" }),
166
+ /* @__PURE__ */ jsx("path", { d: "M15 17h5" })
167
+ ] });
168
+ const ListChecksIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
169
+ /* @__PURE__ */ jsx("path", { d: "m3 17 2 2 4-4" }),
170
+ /* @__PURE__ */ jsx("path", { d: "m3 7 2 2 4-4" }),
171
+ /* @__PURE__ */ jsx("path", { d: "M13 6h8" }),
172
+ /* @__PURE__ */ jsx("path", { d: "M13 12h8" }),
173
+ /* @__PURE__ */ jsx("path", { d: "M13 18h8" })
174
+ ] });
175
+ const UndoIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
176
+ /* @__PURE__ */ jsx("path", { d: "M9 14 4 9l5-5" }),
177
+ /* @__PURE__ */ jsx("path", { d: "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5 5.5 5.5 0 0 1-5.5 5.5H11" })
178
+ ] });
179
+ const RedoIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
180
+ /* @__PURE__ */ jsx("path", { d: "m15 14 5-5-5-5" }),
181
+ /* @__PURE__ */ jsx("path", { d: "M20 9H9.5A5.5 5.5 0 0 0 4 14.5 5.5 5.5 0 0 0 9.5 20H13" })
182
+ ] });
183
+ const ChevronDownIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" }) });
184
+ const CheckIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" }) });
185
+ const TrashIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
186
+ /* @__PURE__ */ jsx("path", { d: "M3 6h18" }),
187
+ /* @__PURE__ */ jsx("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" }),
188
+ /* @__PURE__ */ jsx("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }),
189
+ /* @__PURE__ */ jsx("line", { x1: "10", x2: "10", y1: "11", y2: "17" }),
190
+ /* @__PURE__ */ jsx("line", { x1: "14", x2: "14", y1: "11", y2: "17" })
191
+ ] });
192
+ const LockIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
193
+ /* @__PURE__ */ jsx("rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2" }),
194
+ /* @__PURE__ */ jsx("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" })
195
+ ] });
196
+ const MenuIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
197
+ /* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "12", y2: "12" }),
198
+ /* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "6", y2: "6" }),
199
+ /* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "18", y2: "18" })
200
+ ] });
201
+ const SearchIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
202
+ /* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "8" }),
203
+ /* @__PURE__ */ jsx("path", { d: "m21 21-4.3-4.3" })
204
+ ] });
205
+ const XIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
206
+ /* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }),
207
+ /* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })
208
+ ] });
209
+ const ChevronLeftIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "m15 18-6-6 6-6" }) });
210
+ const ChevronRightIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "m9 18 6-6-6-6" }) });
211
+ const ZoomInIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
212
+ /* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "8" }),
213
+ /* @__PURE__ */ jsx("path", { d: "m21 21-4.3-4.3" }),
214
+ /* @__PURE__ */ jsx("path", { d: "M11 8v6" }),
215
+ /* @__PURE__ */ jsx("path", { d: "M8 11h6" })
216
+ ] });
217
+ const ZoomOutIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
218
+ /* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "8" }),
219
+ /* @__PURE__ */ jsx("path", { d: "m21 21-4.3-4.3" }),
220
+ /* @__PURE__ */ jsx("path", { d: "M8 11h6" })
221
+ ] });
222
+ const RotateCwIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
223
+ /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8" }),
224
+ /* @__PURE__ */ jsx("path", { d: "M21 3v5h-5" })
225
+ ] });
226
+ const FitIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
227
+ /* @__PURE__ */ jsx("path", { d: "m15 15 6 6" }),
228
+ /* @__PURE__ */ jsx("path", { d: "m15 9 6-6" }),
229
+ /* @__PURE__ */ jsx("path", { d: "M21 16v5h-5" }),
230
+ /* @__PURE__ */ jsx("path", { d: "M21 8V3h-5" }),
231
+ /* @__PURE__ */ jsx("path", { d: "M3 16v5h5" }),
232
+ /* @__PURE__ */ jsx("path", { d: "m3 21 6-6" }),
233
+ /* @__PURE__ */ jsx("path", { d: "M3 8V3h5" }),
234
+ /* @__PURE__ */ jsx("path", { d: "M9 9 3 3" })
235
+ ] });
236
+ const ExpandIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
237
+ /* @__PURE__ */ jsx("path", { d: "M15 3h6v6" }),
238
+ /* @__PURE__ */ jsx("path", { d: "m21 3-7 7" }),
239
+ /* @__PURE__ */ jsx("path", { d: "M9 21H3v-6" }),
240
+ /* @__PURE__ */ jsx("path", { d: "m3 21 7-7" })
241
+ ] });
242
+ const ChevronUpIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "m18 15-6-6-6 6" }) });
243
+ const ReplaceIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
244
+ /* @__PURE__ */ jsx("path", { d: "M14 4a1 1 0 0 1 1-1" }),
245
+ /* @__PURE__ */ jsx("path", { d: "M15 10a1 1 0 0 1-1-1" }),
246
+ /* @__PURE__ */ jsx("path", { d: "M21 4a1 1 0 0 0-1-1" }),
247
+ /* @__PURE__ */ jsx("path", { d: "M21 9a1 1 0 0 1-1 1" }),
248
+ /* @__PURE__ */ jsx("path", { d: "m3 7 3 3 3-3" }),
249
+ /* @__PURE__ */ jsx("path", { d: "M6 10V5a2 2 0 0 1 2-2h2" }),
250
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "14", width: "7", height: "7", rx: "1" })
251
+ ] });
252
+ const ReplaceAllIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
253
+ /* @__PURE__ */ jsx("path", { d: "M14 14a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1" }),
254
+ /* @__PURE__ */ jsx("path", { d: "M14 4a1 1 0 0 1 1-1" }),
255
+ /* @__PURE__ */ jsx("path", { d: "M15 10a1 1 0 0 1-1-1" }),
256
+ /* @__PURE__ */ jsx("path", { d: "M19 14a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1" }),
257
+ /* @__PURE__ */ jsx("path", { d: "M21 4a1 1 0 0 0-1-1" }),
258
+ /* @__PURE__ */ jsx("path", { d: "M21 9a1 1 0 0 1-1 1" }),
259
+ /* @__PURE__ */ jsx("path", { d: "m3 7 3 3 3-3" }),
260
+ /* @__PURE__ */ jsx("path", { d: "M6 10V5a2 2 0 0 1 2-2h2" }),
261
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "14", width: "7", height: "7", rx: "1" })
262
+ ] });
263
+ const ColumnBeforeIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
264
+ /* @__PURE__ */ jsx("rect", { x: "10", y: "4", width: "11", height: "16", rx: "1" }),
265
+ /* @__PURE__ */ jsx("path", { d: "M14 4v16" }),
266
+ /* @__PURE__ */ jsx("path", { d: "M5 9v6" }),
267
+ /* @__PURE__ */ jsx("path", { d: "M2 12h6" })
268
+ ] });
269
+ const ColumnAfterIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
270
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "4", width: "11", height: "16", rx: "1" }),
271
+ /* @__PURE__ */ jsx("path", { d: "M10 4v16" }),
272
+ /* @__PURE__ */ jsx("path", { d: "M19 9v6" }),
273
+ /* @__PURE__ */ jsx("path", { d: "M16 12h6" })
274
+ ] });
275
+ const ColumnDeleteIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
276
+ /* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "16", height: "16", rx: "1" }),
277
+ /* @__PURE__ */ jsx("path", { d: "M12 4v16" }),
278
+ /* @__PURE__ */ jsx("path", { d: "m8 9 8 6" }),
279
+ /* @__PURE__ */ jsx("path", { d: "m16 9-8 6" })
280
+ ] });
281
+ const RowBeforeIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
282
+ /* @__PURE__ */ jsx("rect", { x: "4", y: "10", width: "16", height: "11", rx: "1" }),
283
+ /* @__PURE__ */ jsx("path", { d: "M4 14h16" }),
284
+ /* @__PURE__ */ jsx("path", { d: "M9 5h6" }),
285
+ /* @__PURE__ */ jsx("path", { d: "M12 2v6" })
286
+ ] });
287
+ const RowAfterIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
288
+ /* @__PURE__ */ jsx("rect", { x: "4", y: "3", width: "16", height: "11", rx: "1" }),
289
+ /* @__PURE__ */ jsx("path", { d: "M4 10h16" }),
290
+ /* @__PURE__ */ jsx("path", { d: "M9 19h6" }),
291
+ /* @__PURE__ */ jsx("path", { d: "M12 16v6" })
292
+ ] });
293
+ const RowDeleteIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
294
+ /* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "16", height: "16", rx: "1" }),
295
+ /* @__PURE__ */ jsx("path", { d: "M4 12h16" }),
296
+ /* @__PURE__ */ jsx("path", { d: "m9 8 6 8" }),
297
+ /* @__PURE__ */ jsx("path", { d: "m15 8-6 8" })
298
+ ] });
299
+ const TableDeleteIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
300
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "5", width: "18", height: "14", rx: "1" }),
301
+ /* @__PURE__ */ jsx("path", { d: "M3 9h18" }),
302
+ /* @__PURE__ */ jsx("path", { d: "M9 5v14" }),
303
+ /* @__PURE__ */ jsx("path", { d: "M15 5v14" }),
304
+ /* @__PURE__ */ jsx("path", { d: "m7 2 10 20" })
305
+ ] });
306
+ const CopyIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
307
+ /* @__PURE__ */ jsx("rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2" }),
308
+ /* @__PURE__ */ jsx("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })
309
+ ] });
310
+ const ChevronsUpDownIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
311
+ /* @__PURE__ */ jsx("path", { d: "m7 15 5 5 5-5" }),
312
+ /* @__PURE__ */ jsx("path", { d: "m7 9 5-5 5 5" })
313
+ ] });
314
+ const GripIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, fill: "currentColor", strokeWidth: 0, children: [
315
+ /* @__PURE__ */ jsx("circle", { cx: "9", cy: "6", r: "1.25" }),
316
+ /* @__PURE__ */ jsx("circle", { cx: "15", cy: "6", r: "1.25" }),
317
+ /* @__PURE__ */ jsx("circle", { cx: "9", cy: "12", r: "1.25" }),
318
+ /* @__PURE__ */ jsx("circle", { cx: "15", cy: "12", r: "1.25" }),
319
+ /* @__PURE__ */ jsx("circle", { cx: "9", cy: "18", r: "1.25" }),
320
+ /* @__PURE__ */ jsx("circle", { cx: "15", cy: "18", r: "1.25" })
321
+ ] });
322
+ const DownloadIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
323
+ /* @__PURE__ */ jsx("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
324
+ /* @__PURE__ */ jsx("polyline", { points: "7 10 12 15 17 10" }),
325
+ /* @__PURE__ */ jsx("line", { x1: "12", x2: "12", y1: "15", y2: "3" })
326
+ ] });
327
+ const KeyboardIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
328
+ /* @__PURE__ */ jsx("rect", { width: "20", height: "16", x: "2", y: "4", rx: "2" }),
329
+ /* @__PURE__ */ jsx("path", { d: "M6 8h.01" }),
330
+ /* @__PURE__ */ jsx("path", { d: "M10 8h.01" }),
331
+ /* @__PURE__ */ jsx("path", { d: "M14 8h.01" }),
332
+ /* @__PURE__ */ jsx("path", { d: "M18 8h.01" }),
333
+ /* @__PURE__ */ jsx("path", { d: "M6 12h.01" }),
334
+ /* @__PURE__ */ jsx("path", { d: "M10 12h.01" }),
335
+ /* @__PURE__ */ jsx("path", { d: "M14 12h.01" }),
336
+ /* @__PURE__ */ jsx("path", { d: "M18 12h.01" }),
337
+ /* @__PURE__ */ jsx("path", { d: "M7 16h10" })
338
+ ] });
339
+ const defaultChartLabels = {
340
+ tabLabel: (chartType, index) => `${chartType} ${index + 1}`,
341
+ done: "Done",
342
+ cancel: "Cancel",
343
+ configLabel: "Chart config (JSON)",
344
+ tableLabel: "Data table (Markdown)",
345
+ editTitle: "Edit chart"
346
+ };
347
+ const defaultToolbarLabels = {
348
+ undo: "Undo",
349
+ redo: "Redo",
350
+ style: "Style",
351
+ normalText: "Normal text",
352
+ headingLabel: (level) => `Heading ${level}`,
353
+ fontSize: "Font size",
354
+ fontSizeDefault: "Default",
355
+ bold: "Bold",
356
+ italic: "Italic",
357
+ underline: "Underline",
358
+ strike: "Strikethrough",
359
+ code: "Inline code",
360
+ textColor: "Text color",
361
+ highlight: "Highlight",
362
+ colorNone: "None",
363
+ colorTheme: "THEME",
364
+ scriptMenu: "Superscript / Subscript",
365
+ scriptNormal: "Normal",
366
+ superscript: "Superscript",
367
+ subscript: "Subscript",
368
+ link: "Link",
369
+ align: "Alignment",
370
+ alignLeft: "Align left",
371
+ alignCenter: "Align center",
372
+ alignRight: "Align right",
373
+ alignJustify: "Justify",
374
+ indent: "Indent",
375
+ indentIncrease: "Increase indent",
376
+ indentDecrease: "Decrease indent",
377
+ lineHeight: "Line height",
378
+ lineHeightDefault: "Default",
379
+ linkPrompt: "Enter URL",
380
+ linkApply: "Apply link",
381
+ linkOpen: "Open in new window",
382
+ linkRemove: "Remove link",
383
+ linkInvalid: "The editor rejected this address",
384
+ image: "Image",
385
+ imageUploadFailed: "Image upload failed",
386
+ imageAlign: "Image alignment",
387
+ imageAlignLeft: "Align left",
388
+ imageAlignCenter: "Align center",
389
+ imageAlignRight: "Align right",
390
+ imageCaption: "Caption",
391
+ imageCaptionPlaceholder: "Add a caption…",
392
+ imageCrop: "Crop",
393
+ imageCropApply: "Apply",
394
+ imageCropCancel: "Cancel",
395
+ imageCropReset: "Reset crop",
396
+ imagePreview: "Preview",
397
+ imagePreviewClose: "Close",
398
+ imagePreviewPrev: "Previous image",
399
+ imagePreviewNext: "Next image",
400
+ imagePreviewZoomOut: "Zoom out",
401
+ imagePreviewZoomIn: "Zoom in",
402
+ imagePreviewFit: "Fit",
403
+ imagePreviewRotate: "Rotate",
404
+ importMarkdownFailed: "Markdown import failed",
405
+ importDocument: "Import",
406
+ importDocumentHint: "Import a file",
407
+ importDocumentOther: "Document",
408
+ importDocumentBusy: "Importing…",
409
+ importDocumentUploading: (percent) => `Uploading ${percent}%`,
410
+ importDocumentConverting: "Converting…",
411
+ importDocumentFailed: "Import failed",
412
+ blockquote: "Blockquote",
413
+ details: "Toggle",
414
+ bulletList: "Bullet list",
415
+ orderedList: "Ordered list",
416
+ numberingFormat: "Numbering format",
417
+ taskList: "Task list",
418
+ more: "More",
419
+ search: "Find & replace",
420
+ codeBlock: "Code block",
421
+ hr: "Divider",
422
+ importMarkdown: "Markdown",
423
+ tableInsert: "Insert table",
424
+ tableRowMenu: "Row actions",
425
+ tableColumnMenu: "Column actions",
426
+ tableClearContent: "Clear content",
427
+ tableResetCellStyles: "Reset cell styles",
428
+ tableAppendRow: "Add row",
429
+ tableAppendColumn: "Add column",
430
+ tableSizeSelected: (cols, rows) => `${cols} × ${rows}`,
431
+ tableAddColumnBefore: "Add column before",
432
+ tableAddColumnAfter: "Add column after",
433
+ tableDeleteColumn: "Delete column",
434
+ tableAddRowBefore: "Add row before",
435
+ tableAddRowAfter: "Add row after",
436
+ tableDeleteRow: "Delete row",
437
+ tableAddColumnBeforeN: (n) => `Add ${n} columns before`,
438
+ tableAddColumnAfterN: (n) => `Add ${n} columns after`,
439
+ tableDeleteColumnN: (n) => `Delete ${n} columns`,
440
+ tableAddRowBeforeN: (n) => `Add ${n} rows before`,
441
+ tableAddRowAfterN: (n) => `Add ${n} rows after`,
442
+ tableDeleteRowN: (n) => `Delete ${n} rows`,
443
+ tableDeleteTable: "Delete table",
444
+ inlineMath: "Inline equation",
445
+ blockMath: "Block equation",
446
+ mathPlaceholder: "E = mc^2",
447
+ mathDone: "Done",
448
+ mathCancel: "Cancel",
449
+ mathNewInline: "New equation",
450
+ mathNewBlock: "Add a TeX equation"
451
+ };
452
+ const defaultBlockDragLabels = {
453
+ dragHandle: "Drag to move",
454
+ menuLabel: "Block actions",
455
+ turnInto: "Turn into",
456
+ paragraph: "Normal text",
457
+ headingLabel: (level) => `Heading ${level}`,
458
+ bulletList: "Bullet list",
459
+ orderedList: "Ordered list",
460
+ taskList: "Task list",
461
+ blockquote: "Blockquote",
462
+ codeBlock: "Code block",
463
+ copy: "Copy",
464
+ duplicate: "Duplicate",
465
+ resetFormatting: "Reset formatting",
466
+ downloadImage: "Download image",
467
+ delete: "Delete"
468
+ };
469
+ const defaultSlashMenuLabels = {
470
+ menuLabel: "Insert block",
471
+ groupText: "Text",
472
+ groupList: "Lists",
473
+ groupAdvanced: "Advanced",
474
+ normalText: "Normal text",
475
+ headingLabel: (level) => `Heading ${level}`,
476
+ bulletList: "Bullet list",
477
+ orderedList: "Ordered list",
478
+ taskList: "Task list",
479
+ blockquote: "Blockquote",
480
+ details: "Toggle",
481
+ codeBlock: "Code block",
482
+ divider: "Divider",
483
+ table: "Table",
484
+ inlineMath: "Inline equation",
485
+ blockMath: "Block equation"
486
+ };
487
+ const defaultShortcutLabels = {
488
+ panelTitle: "Shortcuts",
489
+ close: "Close",
490
+ colFormat: "Format",
491
+ colShortcut: "Shortcut",
492
+ colMarkdown: "Markdown",
493
+ formatGroup: "Formatting",
494
+ insertGroup: "Insert",
495
+ editGroup: "Editing",
496
+ bold: "Bold",
497
+ italic: "Italic",
498
+ strike: "Strikethrough",
499
+ underline: "Underline",
500
+ inlineCode: "Inline code",
501
+ highlight: "Highlight",
502
+ headingLabel: (level) => `Heading ${level}`,
503
+ paragraph: "Normal text",
504
+ blockquote: "Blockquote",
505
+ bulletList: "Bullet list",
506
+ orderedList: "Ordered list",
507
+ taskList: "Task list",
508
+ codeBlock: "Code block",
509
+ divider: "Divider",
510
+ undo: "Undo",
511
+ redo: "Redo",
512
+ hardBreak: "Hard break",
513
+ findReplace: "Find & replace",
514
+ alignLeft: "Align left",
515
+ alignCenter: "Align center",
516
+ alignRight: "Align right",
517
+ alignJustify: "Justify",
518
+ imageUpload: "Upload image",
519
+ smartQuote: "Smart quotes",
520
+ ellipsis: "Ellipsis",
521
+ emDash: "Em dash",
522
+ emoji: "Emoji"
523
+ };
524
+ const defaultCharacterCountLabels = {
525
+ label: "Document statistics",
526
+ characters: (count2) => `${count2} ${count2 === 1 ? "character" : "characters"}`,
527
+ words: (count2) => `${count2} ${count2 === 1 ? "word" : "words"}`
528
+ };
529
+ const defaultEmojiSuggestionLabels = {
530
+ menuLabel: "Emoji"
531
+ };
532
+ const defaultLinkPopoverLabels = {
533
+ field: "Enter URL",
534
+ apply: "Apply link",
535
+ open: "Open in new window",
536
+ remove: "Remove link",
537
+ invalid: "The editor rejected this address"
538
+ };
539
+ const defaultColorPaletteLabels = {
540
+ none: "None",
541
+ theme: "THEME"
542
+ };
543
+ const defaultTocLabels = {
544
+ title: "Contents",
545
+ expand: "Expand",
546
+ collapse: "Collapse"
547
+ };
548
+ const defaultCodeBlockLabels = {
549
+ autoDetect: "Auto-detect",
550
+ delete: "Delete code block",
551
+ copy: "Copy code",
552
+ expand: "Expand code",
553
+ collapse: "Collapse code",
554
+ language: "Code language"
555
+ };
556
+ const defaultFindLabels = {
557
+ find: "Find",
558
+ replace: "Replace with",
559
+ next: "Next match",
560
+ previous: "Previous match",
561
+ replaceOne: "Replace",
562
+ replaceAll: "Replace all",
563
+ close: "Close",
564
+ caseSensitive: "Match case",
565
+ wholeWord: "Whole word",
566
+ useRegex: "Use regular expression",
567
+ counter: (current, total) => `${current} / ${total}`,
568
+ invalidRegex: "Invalid pattern",
569
+ readOnly: "Read-only"
570
+ };
571
+ const defaultImageUploadLabels = {
572
+ dropzoneClick: "Click to upload",
573
+ dropzoneRest: " or drag and drop",
574
+ dropzoneLimits: (limit, maxSizeMb) => {
575
+ const count2 = `Maximum ${limit} file${limit === 1 ? "" : "s"}`;
576
+ return maxSizeMb == null ? `${count2}.` : `${count2}, ${maxSizeMb}MB each.`;
577
+ },
578
+ uploadingCount: (count2) => `Uploading ${count2} files`,
579
+ clearAll: "Clear all",
580
+ remove: "Remove",
581
+ failed: "Upload failed",
582
+ fallbackAlt: "image"
583
+ };
584
+ const zh = {
585
+ toolbar: {
586
+ undo: "撤销",
587
+ redo: "重做",
588
+ style: "样式",
589
+ normalText: "正文",
590
+ headingLabel: (level) => `标题 ${level}`,
591
+ fontSize: "字号",
592
+ fontSizeDefault: "默认",
593
+ bold: "加粗",
594
+ italic: "斜体",
595
+ underline: "下划线",
596
+ strike: "删除线",
597
+ code: "行内代码",
598
+ textColor: "文字颜色",
599
+ highlight: "高亮",
600
+ colorNone: "无",
601
+ colorTheme: "主题色",
602
+ scriptMenu: "上标 / 下标",
603
+ scriptNormal: "常规",
604
+ superscript: "上标",
605
+ subscript: "下标",
606
+ link: "链接",
607
+ align: "对齐",
608
+ alignLeft: "左对齐",
609
+ alignCenter: "居中",
610
+ alignRight: "右对齐",
611
+ alignJustify: "两端对齐",
612
+ indent: "缩进",
613
+ indentIncrease: "增加缩进",
614
+ indentDecrease: "减少缩进",
615
+ lineHeight: "行高",
616
+ lineHeightDefault: "默认",
617
+ linkPrompt: "输入链接地址",
618
+ linkApply: "应用链接",
619
+ linkOpen: "在新窗口打开",
620
+ linkRemove: "移除链接",
621
+ linkInvalid: "编辑器不接受这个地址",
622
+ image: "图片",
623
+ imageUploadFailed: "图片上传失败",
624
+ imageAlign: "图片对齐",
625
+ imageAlignLeft: "左对齐",
626
+ imageAlignCenter: "居中",
627
+ imageAlignRight: "右对齐",
628
+ imageCaption: "图片描述",
629
+ imageCaptionPlaceholder: "添加描述…",
630
+ imageCrop: "图片剪裁",
631
+ imageCropApply: "应用",
632
+ imageCropCancel: "取消",
633
+ imageCropReset: "重置剪裁",
634
+ imagePreview: "图片预览",
635
+ imagePreviewClose: "关闭",
636
+ imagePreviewPrev: "上一张",
637
+ imagePreviewNext: "下一张",
638
+ imagePreviewZoomOut: "缩小",
639
+ imagePreviewZoomIn: "放大",
640
+ imagePreviewFit: "自适应",
641
+ imagePreviewRotate: "旋转",
642
+ importMarkdownFailed: "Markdown 导入失败",
643
+ importDocument: "导入",
644
+ importDocumentHint: "导入文件",
645
+ importDocumentOther: "文档",
646
+ importDocumentBusy: "正在导入…",
647
+ importDocumentUploading: (percent) => `上传中 ${percent}%`,
648
+ importDocumentConverting: "正在转换…",
649
+ importDocumentFailed: "导入失败",
650
+ blockquote: "引用",
651
+ details: "折叠块",
652
+ bulletList: "无序列表",
653
+ orderedList: "有序列表",
654
+ numberingFormat: "编号格式",
655
+ taskList: "任务列表",
656
+ more: "更多",
657
+ search: "查找替换",
658
+ codeBlock: "代码块",
659
+ hr: "分隔线",
660
+ importMarkdown: "Markdown",
661
+ tableInsert: "插入表格",
662
+ tableRowMenu: "行操作",
663
+ tableColumnMenu: "列操作",
664
+ tableClearContent: "清空内容",
665
+ tableResetCellStyles: "重置单元格样式",
666
+ tableAppendRow: "添加行",
667
+ tableAppendColumn: "添加列",
668
+ tableSizeSelected: (cols, rows) => `${cols} × ${rows}`,
669
+ tableAddColumnBefore: "在左侧插入列",
670
+ tableAddColumnAfter: "在右侧插入列",
671
+ tableDeleteColumn: "删除列",
672
+ tableAddRowBefore: "在上方插入行",
673
+ tableAddRowAfter: "在下方插入行",
674
+ tableDeleteRow: "删除行",
675
+ tableAddColumnBeforeN: (n) => `在左侧插入 ${n} 列`,
676
+ tableAddColumnAfterN: (n) => `在右侧插入 ${n} 列`,
677
+ tableDeleteColumnN: (n) => `删除 ${n} 列`,
678
+ tableAddRowBeforeN: (n) => `在上方插入 ${n} 行`,
679
+ tableAddRowAfterN: (n) => `在下方插入 ${n} 行`,
680
+ tableDeleteRowN: (n) => `删除 ${n} 行`,
681
+ tableDeleteTable: "删除表格",
682
+ inlineMath: "行内公式",
683
+ blockMath: "块级公式",
684
+ mathPlaceholder: "E = mc^2",
685
+ mathDone: "完成",
686
+ mathCancel: "取消",
687
+ mathNewInline: "新建公式",
688
+ mathNewBlock: "插入 TeX 公式"
689
+ },
690
+ slashMenu: {
691
+ menuLabel: "插入块",
692
+ groupText: "文本",
693
+ groupList: "列表",
694
+ groupAdvanced: "高级",
695
+ normalText: "正文",
696
+ headingLabel: (level) => `标题 ${level}`,
697
+ bulletList: "无序列表",
698
+ orderedList: "有序列表",
699
+ taskList: "任务列表",
700
+ blockquote: "引用",
701
+ details: "折叠块",
702
+ codeBlock: "代码块",
703
+ divider: "分隔线",
704
+ table: "表格",
705
+ inlineMath: "行内公式",
706
+ blockMath: "块级公式"
707
+ },
708
+ chart: {
709
+ tabLabel: (chartType, index) => `${chartType} ${index + 1}`,
710
+ done: "完成",
711
+ cancel: "取消",
712
+ configLabel: "图表配置(JSON)",
713
+ tableLabel: "数据表(Markdown)",
714
+ editTitle: "编辑图表"
715
+ },
716
+ blockDrag: {
717
+ dragHandle: "拖动以移动",
718
+ menuLabel: "块操作",
719
+ turnInto: "转换成",
720
+ paragraph: "正文",
721
+ headingLabel: (level) => `标题 ${level}`,
722
+ bulletList: "无序列表",
723
+ orderedList: "有序列表",
724
+ taskList: "任务列表",
725
+ blockquote: "引用",
726
+ codeBlock: "代码块",
727
+ copy: "复制",
728
+ duplicate: "再制一份",
729
+ resetFormatting: "清除格式",
730
+ downloadImage: "下载图片",
731
+ delete: "删除"
732
+ },
733
+ shortcut: {
734
+ panelTitle: "快捷键",
735
+ close: "关闭",
736
+ colFormat: "格式",
737
+ colShortcut: "快捷键",
738
+ colMarkdown: "Markdown",
739
+ formatGroup: "格式",
740
+ insertGroup: "插入",
741
+ editGroup: "编辑",
742
+ bold: "加粗",
743
+ italic: "斜体",
744
+ strike: "删除线",
745
+ underline: "下划线",
746
+ inlineCode: "行内代码",
747
+ highlight: "高亮",
748
+ headingLabel: (level) => `标题 ${level}`,
749
+ paragraph: "正文",
750
+ blockquote: "引用",
751
+ bulletList: "无序列表",
752
+ orderedList: "有序列表",
753
+ taskList: "任务列表",
754
+ codeBlock: "代码块",
755
+ divider: "分隔线",
756
+ undo: "撤销",
757
+ redo: "重做",
758
+ hardBreak: "硬换行",
759
+ findReplace: "查找替换",
760
+ alignLeft: "左对齐",
761
+ alignCenter: "居中",
762
+ alignRight: "右对齐",
763
+ alignJustify: "两端对齐",
764
+ imageUpload: "上传图片",
765
+ smartQuote: "智能引号",
766
+ ellipsis: "省略号",
767
+ emDash: "破折号",
768
+ emoji: "表情"
769
+ },
770
+ characterCount: {
771
+ label: "字数统计",
772
+ characters: (count2) => `${count2} 字符`,
773
+ words: (count2) => `${count2} 词`
774
+ },
775
+ emoji: {
776
+ menuLabel: "表情"
777
+ },
778
+ link: {
779
+ field: "输入链接地址",
780
+ apply: "应用链接",
781
+ open: "在新窗口打开",
782
+ remove: "移除链接",
783
+ invalid: "编辑器不接受这个地址"
784
+ },
785
+ palette: {
786
+ none: "无",
787
+ theme: "主题色"
788
+ },
789
+ toc: {
790
+ title: "目录",
791
+ expand: "展开",
792
+ collapse: "收起"
793
+ },
794
+ codeBlock: {
795
+ autoDetect: "自动识别",
796
+ delete: "删除代码块",
797
+ copy: "复制代码",
798
+ expand: "展开代码",
799
+ collapse: "收起代码",
800
+ language: "代码语言"
801
+ },
802
+ find: {
803
+ find: "查找",
804
+ replace: "替换为",
805
+ next: "下一处",
806
+ previous: "上一处",
807
+ replaceOne: "替换",
808
+ replaceAll: "全部替换",
809
+ close: "关闭",
810
+ caseSensitive: "区分大小写",
811
+ wholeWord: "全词匹配",
812
+ useRegex: "正则表达式",
813
+ counter: (current, total) => `${current} / ${total}`,
814
+ invalidRegex: "正则无效",
815
+ readOnly: "只读"
816
+ },
817
+ imageUpload: {
818
+ dropzoneClick: "点击上传",
819
+ dropzoneRest: ",或拖拽到此处",
820
+ dropzoneLimits: (limit, maxSizeMb) => {
821
+ const count2 = `最多 ${limit} 个文件`;
822
+ return maxSizeMb == null ? `${count2}。` : `${count2},每个 ${maxSizeMb}MB。`;
823
+ },
824
+ uploadingCount: (count2) => `正在上传 ${count2} 个文件`,
825
+ clearAll: "全部清除",
826
+ remove: "移除",
827
+ failed: "上传失败",
828
+ fallbackAlt: "图片"
829
+ }
830
+ };
831
+ const en = {
832
+ toolbar: defaultToolbarLabels,
833
+ slashMenu: defaultSlashMenuLabels,
834
+ chart: defaultChartLabels,
835
+ blockDrag: defaultBlockDragLabels,
836
+ shortcut: defaultShortcutLabels,
837
+ characterCount: defaultCharacterCountLabels,
838
+ emoji: defaultEmojiSuggestionLabels,
839
+ link: defaultLinkPopoverLabels,
840
+ palette: defaultColorPaletteLabels,
841
+ toc: defaultTocLabels,
842
+ codeBlock: defaultCodeBlockLabels,
843
+ find: defaultFindLabels,
844
+ imageUpload: defaultImageUploadLabels
845
+ };
846
+ const bundles = { en, zh };
847
+ function getLocaleBundle(locale = "en") {
848
+ return bundles[locale] ?? en;
849
+ }
850
+ const IMAGE_PREVIEW_EVENT = "tmr-image-preview";
851
+ const ZOOM_STEP = 1.25;
852
+ const ZOOM_MIN = 0.25;
853
+ const ZOOM_MAX = 8;
854
+ const PAD_X = 48;
855
+ const PAD_Y = 88;
856
+ function requestImagePreview(img) {
857
+ img.dispatchEvent(
858
+ new CustomEvent(IMAGE_PREVIEW_EVENT, { bubbles: true, detail: { img } })
859
+ );
860
+ }
861
+ function listPreviewImages(root2) {
862
+ return [...root2.querySelectorAll("img")].filter((node) => {
863
+ if (!(node instanceof HTMLImageElement)) return false;
864
+ if (!node.getAttribute("src")) return false;
865
+ if (node.closest("[data-image-lightbox]")) return false;
866
+ return true;
867
+ });
868
+ }
869
+ function toPreviewImage(img) {
870
+ return {
871
+ src: img.getAttribute("src") ?? "",
872
+ alt: img.getAttribute("alt") ?? "",
873
+ crop: normalizeImageCrop(img.getAttribute("data-crop"))
874
+ };
875
+ }
876
+ function previewImageFromTarget(target) {
877
+ if (!(target instanceof Element)) return null;
878
+ if (target.closest("[data-image-lightbox], [data-resize-handle], [data-image-cropping]")) {
879
+ return null;
880
+ }
881
+ const frame2 = target.closest(".tmr-image-crop");
882
+ const node = frame2 ? frame2.querySelector("img") : target.closest("img");
883
+ if (!(node instanceof HTMLImageElement)) return null;
884
+ if (!node.getAttribute("src")) return null;
885
+ if (node.closest("[data-image-lightbox]")) return null;
886
+ return node;
887
+ }
888
+ function previewPixelSize(naturalWidth, naturalHeight, crop) {
889
+ if (naturalWidth <= 0 || naturalHeight <= 0) return { width: 0, height: 0 };
890
+ if (!crop) return { width: naturalWidth, height: naturalHeight };
891
+ return { width: naturalWidth * crop.w, height: naturalHeight * crop.h };
892
+ }
893
+ function fitPreviewBox(input) {
894
+ const { imageWidth, imageHeight } = input;
895
+ if (imageWidth <= 0 || imageHeight <= 0) return null;
896
+ const quarter = (input.rotation % 360 + 360) % 360;
897
+ const swapped = quarter === 90 || quarter === 270;
898
+ const screenW = swapped ? imageHeight : imageWidth;
899
+ const screenH = swapped ? imageWidth : imageHeight;
900
+ const availW = Math.max(64, input.viewportWidth - PAD_X * 2);
901
+ const availH = Math.max(64, input.viewportHeight - PAD_Y * 2);
902
+ const fitScale = Math.min(availW / screenW, availH / screenH);
903
+ if (!Number.isFinite(fitScale) || fitScale <= 0) return null;
904
+ return {
905
+ width: imageWidth * fitScale,
906
+ height: imageHeight * fitScale,
907
+ actualZoom: 1 / fitScale
908
+ };
909
+ }
910
+ function nextPreviewZoom(action, zoom, actualZoom) {
911
+ if (action === "fit") return 1;
912
+ const max = Math.max(ZOOM_MAX, actualZoom);
913
+ const min = Math.min(ZOOM_MIN, actualZoom);
914
+ const next = action === "in" ? zoom * ZOOM_STEP : zoom / ZOOM_STEP;
915
+ return Math.min(max, Math.max(min, next));
916
+ }
917
+ const root = "_root_21634_3";
918
+ const backdrop = "_backdrop_21634_13";
919
+ const stage = "_stage_21634_21";
920
+ const frame = "_frame_21634_31";
921
+ const close = "_close_21634_50";
922
+ const bar$1 = "_bar_21634_72";
923
+ const tool = "_tool_21634_88";
924
+ const count = "_count_21634_118";
925
+ const styles$1 = {
926
+ root,
927
+ backdrop,
928
+ stage,
929
+ frame,
930
+ close,
931
+ bar: bar$1,
932
+ tool,
933
+ count
934
+ };
935
+ function ImagePreviewHost({
936
+ children,
937
+ locale = "en",
938
+ activate = "click"
939
+ }) {
940
+ const ref = useRef(null);
941
+ const [session, setSession] = useState(
942
+ null
943
+ );
944
+ useEffect(() => {
945
+ const el = ref.current;
946
+ if (!el) return;
947
+ const openFrom = (img) => {
948
+ if (!el.contains(img)) return;
949
+ const nodes = listPreviewImages(el);
950
+ const index = nodes.indexOf(img);
951
+ if (index < 0) return;
952
+ setSession({ images: nodes.map(toPreviewImage), index });
953
+ };
954
+ const onActivate = (event) => {
955
+ const img = previewImageFromTarget(event.target);
956
+ if (!img) return;
957
+ event.preventDefault();
958
+ openFrom(img);
959
+ };
960
+ const onRequest = (event) => {
961
+ var _a;
962
+ const img = (_a = event.detail) == null ? void 0 : _a.img;
963
+ if (!(img instanceof HTMLImageElement)) return;
964
+ openFrom(img);
965
+ };
966
+ const eventName = activate === "dblclick" ? "dblclick" : "click";
967
+ el.addEventListener(eventName, onActivate);
968
+ el.addEventListener(IMAGE_PREVIEW_EVENT, onRequest);
969
+ return () => {
970
+ el.removeEventListener(eventName, onActivate);
971
+ el.removeEventListener(IMAGE_PREVIEW_EVENT, onRequest);
972
+ };
973
+ }, [activate]);
974
+ const labels = getLocaleBundle(locale).toolbar;
975
+ return /* @__PURE__ */ jsxs(
976
+ "div",
977
+ {
978
+ ref,
979
+ className: styles$1.root,
980
+ "data-image-preview": activate === "click" ? "click" : void 0,
981
+ children: [
982
+ children,
983
+ session && typeof document !== "undefined" ? createPortal(
984
+ /* @__PURE__ */ jsx(
985
+ ImageLightbox,
986
+ {
987
+ images: session.images,
988
+ index: session.index,
989
+ label: labels.imagePreview,
990
+ closeLabel: labels.imagePreviewClose,
991
+ prevLabel: labels.imagePreviewPrev,
992
+ nextLabel: labels.imagePreviewNext,
993
+ zoomOutLabel: labels.imagePreviewZoomOut,
994
+ zoomInLabel: labels.imagePreviewZoomIn,
995
+ fitLabel: labels.imagePreviewFit,
996
+ rotateLabel: labels.imagePreviewRotate,
997
+ onIndex: (index) => setSession((current) => current ? { ...current, index } : current),
998
+ onClose: () => setSession(null)
999
+ }
1000
+ ),
1001
+ document.body
1002
+ ) : null
1003
+ ]
1004
+ }
1005
+ );
1006
+ }
1007
+ function ImageLightbox({
1008
+ images,
1009
+ index,
1010
+ label,
1011
+ closeLabel,
1012
+ prevLabel,
1013
+ nextLabel,
1014
+ zoomOutLabel,
1015
+ zoomInLabel,
1016
+ fitLabel,
1017
+ rotateLabel,
1018
+ onIndex,
1019
+ onClose
1020
+ }) {
1021
+ const image = images[index];
1022
+ const dialogRef = useRef(null);
1023
+ const imgRef = useRef(null);
1024
+ const [natural, setNatural] = useState(null);
1025
+ const [viewport, setViewport] = useState(() => ({
1026
+ w: typeof window === "undefined" ? 0 : window.innerWidth,
1027
+ h: typeof window === "undefined" ? 0 : window.innerHeight
1028
+ }));
1029
+ const [zoom, setZoom] = useState(1);
1030
+ const [rotation, setRotation] = useState(0);
1031
+ useEffect(() => {
1032
+ setZoom(1);
1033
+ setRotation(0);
1034
+ setNatural(null);
1035
+ }, [index, image == null ? void 0 : image.src]);
1036
+ useEffect(() => {
1037
+ const node = imgRef.current;
1038
+ if (!node) return;
1039
+ const read = () => {
1040
+ if (node.naturalWidth > 0) {
1041
+ setNatural({ w: node.naturalWidth, h: node.naturalHeight });
1042
+ }
1043
+ };
1044
+ read();
1045
+ node.addEventListener("load", read);
1046
+ return () => node.removeEventListener("load", read);
1047
+ }, [index, image == null ? void 0 : image.src]);
1048
+ useEffect(() => {
1049
+ const onResize = () => setViewport({ w: window.innerWidth, h: window.innerHeight });
1050
+ window.addEventListener("resize", onResize);
1051
+ return () => window.removeEventListener("resize", onResize);
1052
+ }, []);
1053
+ useEffect(() => {
1054
+ var _a;
1055
+ const prev = document.body.style.overflow;
1056
+ document.body.style.overflow = "hidden";
1057
+ (_a = dialogRef.current) == null ? void 0 : _a.focus();
1058
+ return () => {
1059
+ document.body.style.overflow = prev;
1060
+ };
1061
+ }, []);
1062
+ const pixels = image ? previewPixelSize((natural == null ? void 0 : natural.w) ?? 0, (natural == null ? void 0 : natural.h) ?? 0, image.crop) : { width: 0, height: 0 };
1063
+ const fit = fitPreviewBox({
1064
+ viewportWidth: viewport.w,
1065
+ viewportHeight: viewport.h,
1066
+ imageWidth: pixels.width,
1067
+ imageHeight: pixels.height,
1068
+ rotation
1069
+ });
1070
+ const actualZoom = (fit == null ? void 0 : fit.actualZoom) ?? 1;
1071
+ useEffect(() => {
1072
+ const onKey = (event) => {
1073
+ if (event.key === "Escape") {
1074
+ event.preventDefault();
1075
+ event.stopPropagation();
1076
+ onClose();
1077
+ return;
1078
+ }
1079
+ if (event.key === "ArrowLeft") {
1080
+ event.preventDefault();
1081
+ event.stopPropagation();
1082
+ if (index > 0) onIndex(index - 1);
1083
+ return;
1084
+ }
1085
+ if (event.key === "ArrowRight") {
1086
+ event.preventDefault();
1087
+ event.stopPropagation();
1088
+ if (index < images.length - 1) onIndex(index + 1);
1089
+ return;
1090
+ }
1091
+ };
1092
+ document.addEventListener("keydown", onKey, true);
1093
+ return () => document.removeEventListener("keydown", onKey, true);
1094
+ }, [images.length, index, onClose, onIndex]);
1095
+ if (!image) return null;
1096
+ const applyZoom = (action) => {
1097
+ setZoom(nextPreviewZoom(action, zoom, actualZoom));
1098
+ };
1099
+ const cropStyle = image.crop ? cropImageBox(image.crop) : null;
1100
+ return /* @__PURE__ */ jsxs(
1101
+ "div",
1102
+ {
1103
+ ref: dialogRef,
1104
+ className: styles$1.backdrop,
1105
+ "data-image-lightbox": "",
1106
+ role: "dialog",
1107
+ "aria-modal": "true",
1108
+ "aria-label": label,
1109
+ tabIndex: -1,
1110
+ children: [
1111
+ /* @__PURE__ */ jsx(
1112
+ "button",
1113
+ {
1114
+ type: "button",
1115
+ className: styles$1.close,
1116
+ "data-image-preview-action": "close",
1117
+ title: closeLabel,
1118
+ "aria-label": closeLabel,
1119
+ onClick: onClose,
1120
+ children: /* @__PURE__ */ jsx(XIcon, { size: 22 })
1121
+ }
1122
+ ),
1123
+ /* @__PURE__ */ jsx(
1124
+ "div",
1125
+ {
1126
+ className: styles$1.stage,
1127
+ onClick: (event) => {
1128
+ if (event.target === event.currentTarget) onClose();
1129
+ },
1130
+ children: /* @__PURE__ */ jsx(
1131
+ "div",
1132
+ {
1133
+ className: styles$1.frame,
1134
+ style: {
1135
+ width: fit ? `${fit.width}px` : void 0,
1136
+ height: fit ? `${fit.height}px` : void 0,
1137
+ visibility: fit ? "visible" : "hidden",
1138
+ transform: `rotate(${rotation}deg) scale(${zoom})`
1139
+ },
1140
+ children: /* @__PURE__ */ jsx(
1141
+ "img",
1142
+ {
1143
+ ref: imgRef,
1144
+ src: image.src,
1145
+ alt: image.alt,
1146
+ draggable: false,
1147
+ style: cropStyle ? {
1148
+ position: "absolute",
1149
+ maxWidth: "none",
1150
+ width: cropStyle.width,
1151
+ height: cropStyle.height,
1152
+ left: cropStyle.left,
1153
+ top: cropStyle.top
1154
+ } : void 0
1155
+ }
1156
+ )
1157
+ }
1158
+ )
1159
+ }
1160
+ ),
1161
+ /* @__PURE__ */ jsxs("div", { className: styles$1.bar, role: "toolbar", "aria-label": label, children: [
1162
+ /* @__PURE__ */ jsx(
1163
+ "button",
1164
+ {
1165
+ type: "button",
1166
+ className: styles$1.tool,
1167
+ "data-image-preview-action": "prev",
1168
+ title: prevLabel,
1169
+ "aria-label": prevLabel,
1170
+ disabled: index <= 0,
1171
+ onClick: () => onIndex(index - 1),
1172
+ children: /* @__PURE__ */ jsx(ChevronLeftIcon, { size: 16 })
1173
+ }
1174
+ ),
1175
+ /* @__PURE__ */ jsxs("span", { className: styles$1.count, children: [
1176
+ index + 1,
1177
+ "/",
1178
+ images.length
1179
+ ] }),
1180
+ /* @__PURE__ */ jsx(
1181
+ "button",
1182
+ {
1183
+ type: "button",
1184
+ className: styles$1.tool,
1185
+ "data-image-preview-action": "next",
1186
+ title: nextLabel,
1187
+ "aria-label": nextLabel,
1188
+ disabled: index >= images.length - 1,
1189
+ onClick: () => onIndex(index + 1),
1190
+ children: /* @__PURE__ */ jsx(ChevronRightIcon, { size: 16 })
1191
+ }
1192
+ ),
1193
+ /* @__PURE__ */ jsx(
1194
+ "button",
1195
+ {
1196
+ type: "button",
1197
+ className: styles$1.tool,
1198
+ "data-image-preview-action": "zoom-out",
1199
+ title: zoomOutLabel,
1200
+ "aria-label": zoomOutLabel,
1201
+ onClick: () => applyZoom("out"),
1202
+ children: /* @__PURE__ */ jsx(ZoomOutIcon, { size: 16 })
1203
+ }
1204
+ ),
1205
+ /* @__PURE__ */ jsx(
1206
+ "button",
1207
+ {
1208
+ type: "button",
1209
+ className: styles$1.tool,
1210
+ "data-image-preview-action": "zoom-in",
1211
+ title: zoomInLabel,
1212
+ "aria-label": zoomInLabel,
1213
+ onClick: () => applyZoom("in"),
1214
+ children: /* @__PURE__ */ jsx(ZoomInIcon, { size: 16 })
1215
+ }
1216
+ ),
1217
+ /* @__PURE__ */ jsx(
1218
+ "button",
1219
+ {
1220
+ type: "button",
1221
+ className: styles$1.tool,
1222
+ "data-image-preview-action": "fit",
1223
+ title: fitLabel,
1224
+ "aria-label": fitLabel,
1225
+ "aria-pressed": Math.abs(zoom - 1) < 0.02,
1226
+ onClick: () => applyZoom("fit"),
1227
+ children: /* @__PURE__ */ jsx(FitIcon, { size: 16 })
1228
+ }
1229
+ ),
1230
+ /* @__PURE__ */ jsx(
1231
+ "button",
1232
+ {
1233
+ type: "button",
1234
+ className: styles$1.tool,
1235
+ "data-image-preview-action": "rotate",
1236
+ title: rotateLabel,
1237
+ "aria-label": rotateLabel,
1238
+ onClick: () => setRotation((current) => (current + 90) % 360),
1239
+ children: /* @__PURE__ */ jsx(RotateCwIcon, { size: 16 })
1240
+ }
1241
+ )
1242
+ ] })
1243
+ ]
1244
+ }
1245
+ );
1246
+ }
1247
+ function toNumber(value) {
1248
+ if (typeof value === "number" && !Number.isNaN(value)) return value;
1249
+ if (typeof value === "string") {
1250
+ const n = Number(value.replace(/,/g, ""));
1251
+ if (!Number.isNaN(n)) return n;
1252
+ }
1253
+ return 0;
1254
+ }
1255
+ function mapChartDataItems(config, dataSource) {
1256
+ const xKey = config.x;
1257
+ const yKey = config.y;
1258
+ const legendKey = config.colorLegend;
1259
+ const groupKey = config.groupBy;
1260
+ let rows = [...dataSource];
1261
+ const sortKey = config.sortBy;
1262
+ if (sortKey) {
1263
+ rows.sort((a, b) => {
1264
+ const av = a[sortKey];
1265
+ const bv = b[sortKey];
1266
+ if (typeof av === "number" && typeof bv === "number") return av - bv;
1267
+ return String(av ?? "").localeCompare(String(bv ?? ""), void 0, {
1268
+ numeric: true
1269
+ });
1270
+ });
1271
+ }
1272
+ return rows.map((row) => {
1273
+ const point = {
1274
+ x: row[xKey],
1275
+ y: toNumber(row[yKey])
1276
+ };
1277
+ if (legendKey) point.type = String(row[legendKey] ?? "");
1278
+ if (groupKey) point.category = String(row[groupKey] ?? "");
1279
+ return point;
1280
+ });
1281
+ }
1282
+ function buildChartJsData(config, payload) {
1283
+ const points = mapChartDataItems(config, payload.dataSource);
1284
+ const type = config.chartType;
1285
+ const isCartesian = !["pie", "donut"].includes(type);
1286
+ if (!isCartesian) {
1287
+ return {
1288
+ labels: points.map((p) => String(p.x)),
1289
+ datasets: [
1290
+ {
1291
+ label: config.title || config.y || "value",
1292
+ data: points.map((p) => p.y)
1293
+ }
1294
+ ],
1295
+ isCartesian: false
1296
+ };
1297
+ }
1298
+ const seriesKeys = /* @__PURE__ */ new Set();
1299
+ for (const p of points) {
1300
+ seriesKeys.add(p.type || config.title || config.y || "series");
1301
+ }
1302
+ const seriesList = [...seriesKeys];
1303
+ const labelSet = [];
1304
+ for (const p of points) {
1305
+ const lab = String(p.x);
1306
+ if (!labelSet.includes(lab)) labelSet.push(lab);
1307
+ }
1308
+ const datasets = seriesList.map((series) => ({
1309
+ label: series,
1310
+ data: labelSet.map((lab) => {
1311
+ const hit = points.find(
1312
+ (p) => String(p.x) === lab && (p.type || config.title || config.y || "series") === series
1313
+ );
1314
+ return hit ? hit.y : 0;
1315
+ })
1316
+ }));
1317
+ return { labels: labelSet, datasets, isCartesian: true };
1318
+ }
1319
+ const DEFAULT_PALETTE = [
1320
+ "#3b82f6",
1321
+ "#10b981",
1322
+ "#f59e0b",
1323
+ "#ef4444",
1324
+ "#8b5cf6",
1325
+ "#06b6d4",
1326
+ "#ec4899",
1327
+ "#84cc16"
1328
+ ];
1329
+ function readCssVar(el, name, fallback) {
1330
+ if (!el || typeof getComputedStyle === "undefined") return fallback;
1331
+ const v = getComputedStyle(el).getPropertyValue(name).trim();
1332
+ return v || fallback;
1333
+ }
1334
+ function resolveChartTheme(host, override) {
1335
+ const base = {
1336
+ backgroundColor: readCssVar(host, "--tmr-bg", "#ffffff"),
1337
+ textColor: readCssVar(host, "--tmr-fg", "#1f2937"),
1338
+ gridColor: readCssVar(host, "--tmr-border", "#e5e7eb"),
1339
+ borderColor: readCssVar(host, "--tmr-border", "#e5e7eb"),
1340
+ fontFamily: readCssVar(
1341
+ host,
1342
+ "--tmr-font",
1343
+ "ui-sans-serif, system-ui, sans-serif"
1344
+ ),
1345
+ palette: DEFAULT_PALETTE
1346
+ };
1347
+ if (!override) return base;
1348
+ return {
1349
+ backgroundColor: override.backgroundColor ?? base.backgroundColor,
1350
+ textColor: override.textColor ?? base.textColor,
1351
+ gridColor: override.gridColor ?? base.gridColor,
1352
+ borderColor: override.borderColor ?? base.borderColor,
1353
+ fontFamily: override.fontFamily ?? base.fontFamily,
1354
+ palette: override.palette && override.palette.length > 0 ? override.palette : base.palette
1355
+ };
1356
+ }
1357
+ let registered = false;
1358
+ function ensureRegister() {
1359
+ if (registered) return;
1360
+ if (typeof window === "undefined") return;
1361
+ Chart.register(
1362
+ CategoryScale,
1363
+ LinearScale,
1364
+ PointElement,
1365
+ LineElement,
1366
+ BarElement,
1367
+ ArcElement,
1368
+ LineController,
1369
+ BarController,
1370
+ PieController,
1371
+ DoughnutController,
1372
+ Filler,
1373
+ Legend,
1374
+ Tooltip
1375
+ );
1376
+ registered = true;
1377
+ }
1378
+ function toChartJsType(chartType) {
1379
+ switch (chartType) {
1380
+ case "bar":
1381
+ return "bar";
1382
+ case "column":
1383
+ return "bar";
1384
+ case "line":
1385
+ return "line";
1386
+ case "area":
1387
+ return "line";
1388
+ case "pie":
1389
+ return "pie";
1390
+ case "donut":
1391
+ return "doughnut";
1392
+ default:
1393
+ return "bar";
1394
+ }
1395
+ }
1396
+ function renderOrUpdateChart({
1397
+ canvas,
1398
+ config,
1399
+ payload,
1400
+ theme,
1401
+ chart
1402
+ }) {
1403
+ if (typeof window === "undefined") return null;
1404
+ ensureRegister();
1405
+ const host = canvas.parentElement;
1406
+ const colors = resolveChartTheme(host, theme);
1407
+ const built = buildChartJsData(config, payload);
1408
+ const jsType = toChartJsType(config.chartType);
1409
+ const isBarHorizontal = config.chartType === "bar";
1410
+ const isArea = config.chartType === "area";
1411
+ const datasets = built.datasets.map((ds, i) => {
1412
+ const color = colors.palette[i % colors.palette.length];
1413
+ if (!built.isCartesian) {
1414
+ return {
1415
+ ...ds,
1416
+ backgroundColor: built.labels.map(
1417
+ (_, j) => colors.palette[j % colors.palette.length]
1418
+ ),
1419
+ borderWidth: 0
1420
+ };
1421
+ }
1422
+ return {
1423
+ ...ds,
1424
+ backgroundColor: isArea ? `${color}33` : color,
1425
+ borderColor: color,
1426
+ borderWidth: 2,
1427
+ fill: isArea,
1428
+ tension: 0.25
1429
+ };
1430
+ });
1431
+ const configuration = {
1432
+ type: jsType,
1433
+ data: {
1434
+ labels: built.labels,
1435
+ datasets
1436
+ },
1437
+ options: {
1438
+ indexAxis: isBarHorizontal ? "y" : "x",
1439
+ responsive: true,
1440
+ maintainAspectRatio: false,
1441
+ plugins: {
1442
+ legend: {
1443
+ display: built.datasets.length > 1 || !built.isCartesian,
1444
+ labels: {
1445
+ color: colors.textColor,
1446
+ font: { family: colors.fontFamily }
1447
+ }
1448
+ },
1449
+ title: { display: false },
1450
+ tooltip: {
1451
+ titleFont: { family: colors.fontFamily },
1452
+ bodyFont: { family: colors.fontFamily }
1453
+ }
1454
+ },
1455
+ scales: built.isCartesian ? {
1456
+ x: {
1457
+ ticks: {
1458
+ color: colors.textColor,
1459
+ font: { family: colors.fontFamily }
1460
+ },
1461
+ grid: { color: colors.gridColor },
1462
+ border: { color: colors.borderColor }
1463
+ },
1464
+ y: {
1465
+ ticks: {
1466
+ color: colors.textColor,
1467
+ font: { family: colors.fontFamily }
1468
+ },
1469
+ grid: { color: colors.gridColor },
1470
+ border: { color: colors.borderColor }
1471
+ }
1472
+ } : void 0
1473
+ }
1474
+ };
1475
+ if (chart) {
1476
+ chart.config.type = jsType;
1477
+ chart.data.labels = configuration.data.labels;
1478
+ chart.data.datasets = configuration.data.datasets;
1479
+ chart.options = configuration.options;
1480
+ chart.update("none");
1481
+ return chart;
1482
+ }
1483
+ return new Chart(canvas, configuration);
1484
+ }
1485
+ function destroyChart(chart) {
1486
+ chart == null ? void 0 : chart.destroy();
1487
+ }
1488
+ const anchor = "_anchor_14ilx_4";
1489
+ const nav = "_nav_14ilx_18";
1490
+ const rail = "_rail_14ilx_42";
1491
+ const list = "_list_14ilx_43";
1492
+ const card = "_card_14ilx_56";
1493
+ const cardOpen = "_cardOpen_14ilx_57";
1494
+ const tick = "_tick_14ilx_61";
1495
+ const bar = "_bar_14ilx_73";
1496
+ const barActive = "_barActive_14ilx_74";
1497
+ const cardInner = "_cardInner_14ilx_117";
1498
+ const item = "_item_14ilx_123";
1499
+ const itemActive = "_itemActive_14ilx_143";
1500
+ const itemText = "_itemText_14ilx_150";
1501
+ const styles = {
1502
+ anchor,
1503
+ nav,
1504
+ rail,
1505
+ list,
1506
+ card,
1507
+ cardOpen,
1508
+ tick,
1509
+ bar,
1510
+ barActive,
1511
+ cardInner,
1512
+ item,
1513
+ itemActive,
1514
+ itemText
1515
+ };
1516
+ function easeOutCubic(t) {
1517
+ return 1 - (1 - t) * (1 - t) * (1 - t);
1518
+ }
1519
+ function scrollToTocHeading(headingId, scrollContainer, options) {
1520
+ const el = scrollContainer.querySelector(
1521
+ `[data-toc-id="${CSS.escape(headingId)}"]`
1522
+ );
1523
+ if (!el) return;
1524
+ const startTop = scrollContainer.scrollTop;
1525
+ const rootRect = scrollContainer.getBoundingClientRect();
1526
+ const elRect = el.getBoundingClientRect();
1527
+ const targetTop = startTop + (elRect.top - rootRect.top);
1528
+ if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
1529
+ scrollContainer.scrollTop = targetTop;
1530
+ return;
1531
+ }
1532
+ const duration = (options == null ? void 0 : options.duration) ?? 400;
1533
+ const start = performance.now();
1534
+ const animate = () => {
1535
+ const t = Math.min((performance.now() - start) / duration, 1);
1536
+ scrollContainer.scrollTop = startTop + (targetTop - startTop) * easeOutCubic(t);
1537
+ if (t < 1) requestAnimationFrame(animate);
1538
+ };
1539
+ requestAnimationFrame(animate);
1540
+ }
1541
+ function barWidth(level) {
1542
+ if (level <= 1) return 20;
1543
+ if (level === 2) return 14;
1544
+ if (level === 3) return 10;
1545
+ return 6;
1546
+ }
1547
+ function findScrollParent(start) {
1548
+ let node = start.parentElement;
1549
+ while (node && node !== document.documentElement) {
1550
+ const style = getComputedStyle(node);
1551
+ const overflowY = style.overflowY;
1552
+ const canScroll = overflowY === "auto" || overflowY === "scroll" || overflowY === "overlay";
1553
+ if (canScroll && (node.scrollHeight > node.clientHeight + 1 || style.maxHeight !== "none")) {
1554
+ return node;
1555
+ }
1556
+ node = node.parentElement;
1557
+ }
1558
+ return document.scrollingElement ?? document.documentElement;
1559
+ }
1560
+ function isViewportScroller(node) {
1561
+ return node === document.documentElement || node === document.body || node === document.scrollingElement;
1562
+ }
1563
+ function EditorToc({ items, editorDom, locale = "en" }) {
1564
+ var _a;
1565
+ const t = getLocaleBundle(locale).toc;
1566
+ const [open, setOpen] = useState(false);
1567
+ const [activeId, setActiveId] = useState(((_a = items[0]) == null ? void 0 : _a.id) ?? "");
1568
+ const [roving, setRoving] = useState(0);
1569
+ const navRef = useRef(null);
1570
+ const itemRefs = useRef([]);
1571
+ const hideTimer = useRef(null);
1572
+ const pinnedId = useRef(null);
1573
+ const pinScroll = useRef(null);
1574
+ const pinTimer = useRef(null);
1575
+ const clearHide = () => {
1576
+ if (hideTimer.current !== null) {
1577
+ window.clearTimeout(hideTimer.current);
1578
+ hideTimer.current = null;
1579
+ }
1580
+ };
1581
+ const show = () => {
1582
+ clearHide();
1583
+ setOpen(true);
1584
+ };
1585
+ const hideSoon = () => {
1586
+ clearHide();
1587
+ hideTimer.current = window.setTimeout(() => {
1588
+ var _a2;
1589
+ hideTimer.current = null;
1590
+ if ((_a2 = navRef.current) == null ? void 0 : _a2.contains(document.activeElement)) return;
1591
+ setOpen(false);
1592
+ }, 80);
1593
+ };
1594
+ useEffect(
1595
+ () => () => {
1596
+ clearHide();
1597
+ if (pinTimer.current !== null) window.clearTimeout(pinTimer.current);
1598
+ },
1599
+ []
1600
+ );
1601
+ useEffect(() => {
1602
+ const headings = items.map(
1603
+ (item2) => editorDom.querySelector(
1604
+ `[data-toc-id="${CSS.escape(item2.id)}"]`
1605
+ )
1606
+ ).filter((el) => el !== null);
1607
+ if (!headings.length) return;
1608
+ const scrollParent = findScrollParent(editorDom);
1609
+ const viewport = isViewportScroller(scrollParent);
1610
+ const visible = /* @__PURE__ */ new Set();
1611
+ const scrollPos = () => viewport ? window.scrollY : scrollParent.scrollTop;
1612
+ const apply = () => {
1613
+ var _a2;
1614
+ const pos = scrollPos();
1615
+ if (pinnedId.current) {
1616
+ const lockedAt = pinScroll.current;
1617
+ if (lockedAt === null || Math.abs(pos - lockedAt) <= 2) {
1618
+ setActiveId(pinnedId.current);
1619
+ return;
1620
+ }
1621
+ pinnedId.current = null;
1622
+ pinScroll.current = null;
1623
+ }
1624
+ const maxScroll = viewport ? Math.max(
1625
+ 0,
1626
+ (((_a2 = document.scrollingElement) == null ? void 0 : _a2.scrollHeight) ?? 0) - window.innerHeight
1627
+ ) : Math.max(0, scrollParent.scrollHeight - scrollParent.clientHeight);
1628
+ if (maxScroll > 1 && pos >= maxScroll - 2) {
1629
+ const rootBottom = viewport ? window.innerHeight : scrollParent.getBoundingClientRect().bottom;
1630
+ let lastInView = null;
1631
+ for (const heading of headings) {
1632
+ if (heading.getBoundingClientRect().top < rootBottom - 8) {
1633
+ lastInView = heading;
1634
+ }
1635
+ }
1636
+ const id2 = (lastInView ?? headings[headings.length - 1]).getAttribute(
1637
+ "data-toc-id"
1638
+ );
1639
+ if (id2) setActiveId(id2);
1640
+ return;
1641
+ }
1642
+ const rootTop = viewport ? 0 : scrollParent.getBoundingClientRect().top;
1643
+ let best = null;
1644
+ let bestTop = Infinity;
1645
+ for (const el of visible) {
1646
+ const top = el.getBoundingClientRect().top;
1647
+ if (top < bestTop) {
1648
+ bestTop = top;
1649
+ best = el;
1650
+ }
1651
+ }
1652
+ if (!best) {
1653
+ let last = null;
1654
+ for (const heading of headings) {
1655
+ if (heading.getBoundingClientRect().top <= rootTop + 12) last = heading;
1656
+ }
1657
+ best = last ?? headings[0];
1658
+ }
1659
+ const id = best.getAttribute("data-toc-id");
1660
+ if (id) setActiveId(id);
1661
+ };
1662
+ const observer = new IntersectionObserver(
1663
+ (entries) => {
1664
+ for (const entry of entries) {
1665
+ if (entry.isIntersecting) visible.add(entry.target);
1666
+ else visible.delete(entry.target);
1667
+ }
1668
+ apply();
1669
+ },
1670
+ {
1671
+ root: viewport ? null : scrollParent,
1672
+ rootMargin: "0px 0px -60% 0px",
1673
+ threshold: [0, 1]
1674
+ }
1675
+ );
1676
+ for (const heading of headings) observer.observe(heading);
1677
+ const onScroll = () => apply();
1678
+ const scrollTarget = viewport ? window : scrollParent;
1679
+ scrollTarget.addEventListener("scroll", onScroll, { passive: true });
1680
+ apply();
1681
+ return () => {
1682
+ observer.disconnect();
1683
+ scrollTarget.removeEventListener("scroll", onScroll);
1684
+ };
1685
+ }, [items, editorDom]);
1686
+ useEffect(() => {
1687
+ var _a2;
1688
+ if ((_a2 = navRef.current) == null ? void 0 : _a2.contains(document.activeElement)) return;
1689
+ const index = items.findIndex((item2) => item2.id === activeId);
1690
+ if (index >= 0) setRoving(index);
1691
+ }, [activeId, items]);
1692
+ useEffect(() => {
1693
+ var _a2, _b;
1694
+ if (!open || !activeId) return;
1695
+ const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1696
+ (_b = (_a2 = navRef.current) == null ? void 0 : _a2.querySelector(`[data-toc-item="${CSS.escape(activeId)}"]`)) == null ? void 0 : _b.scrollIntoView({ block: "nearest", behavior: reduce ? "auto" : "smooth" });
1697
+ }, [activeId, open]);
1698
+ useEffect(() => {
1699
+ var _a2;
1700
+ if (!open || !navRef.current) return;
1701
+ const rail2 = navRef.current.querySelector("[data-toc-rail]");
1702
+ if (!(rail2 == null ? void 0 : rail2.contains(document.activeElement))) return;
1703
+ const index = Math.max(
1704
+ 0,
1705
+ items.findIndex((item2) => item2.id === activeId)
1706
+ );
1707
+ (_a2 = itemRefs.current[index]) == null ? void 0 : _a2.focus();
1708
+ }, [open, activeId, items]);
1709
+ const jump = (item2) => {
1710
+ const scroller = findScrollParent(editorDom);
1711
+ pinnedId.current = item2.id;
1712
+ pinScroll.current = null;
1713
+ setActiveId(item2.id);
1714
+ scrollToTocHeading(item2.id, scroller);
1715
+ if (pinTimer.current !== null) window.clearTimeout(pinTimer.current);
1716
+ pinTimer.current = window.setTimeout(() => {
1717
+ pinTimer.current = null;
1718
+ if (pinnedId.current !== item2.id) return;
1719
+ pinScroll.current = isViewportScroller(scroller) ? window.scrollY : scroller.scrollTop;
1720
+ }, 480);
1721
+ };
1722
+ const move = (delta) => {
1723
+ var _a2;
1724
+ const next = Math.min(items.length - 1, Math.max(0, roving + delta));
1725
+ setRoving(next);
1726
+ setOpen(true);
1727
+ (_a2 = itemRefs.current[next]) == null ? void 0 : _a2.focus();
1728
+ };
1729
+ return /* @__PURE__ */ jsx("div", { className: styles.anchor, children: /* @__PURE__ */ jsxs(
1730
+ "nav",
1731
+ {
1732
+ ref: navRef,
1733
+ className: styles.nav,
1734
+ "aria-label": t.title,
1735
+ "data-editor-toc": "",
1736
+ onMouseEnter: show,
1737
+ onMouseLeave: hideSoon,
1738
+ onFocus: show,
1739
+ onBlur: (event) => {
1740
+ if (!event.currentTarget.contains(event.relatedTarget)) hideSoon();
1741
+ },
1742
+ onKeyDown: (event) => {
1743
+ if (event.key === "ArrowDown") {
1744
+ event.preventDefault();
1745
+ move(1);
1746
+ } else if (event.key === "ArrowUp") {
1747
+ event.preventDefault();
1748
+ move(-1);
1749
+ } else if (event.key === "Escape") {
1750
+ setOpen(false);
1751
+ }
1752
+ },
1753
+ children: [
1754
+ /* @__PURE__ */ jsx("ul", { className: styles.rail, "data-toc-rail": "", "aria-hidden": open, inert: open, children: items.map((item2, index) => {
1755
+ const active = item2.id === activeId;
1756
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
1757
+ "button",
1758
+ {
1759
+ type: "button",
1760
+ tabIndex: !open && index === roving ? 0 : -1,
1761
+ className: styles.tick,
1762
+ style: { "--bar-width": `${barWidth(item2.level)}px` },
1763
+ "aria-current": active ? "true" : void 0,
1764
+ "aria-label": item2.text,
1765
+ onClick: () => jump(item2),
1766
+ children: /* @__PURE__ */ jsx("span", { className: active ? styles.barActive : styles.bar })
1767
+ }
1768
+ ) }, item2.id);
1769
+ }) }),
1770
+ /* @__PURE__ */ jsx("div", { className: open ? styles.cardOpen : styles.card, inert: !open, children: /* @__PURE__ */ jsx("div", { className: styles.cardInner, children: /* @__PURE__ */ jsx("ul", { className: styles.list, children: items.map((item2, index) => {
1771
+ const active = item2.id === activeId;
1772
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
1773
+ "button",
1774
+ {
1775
+ type: "button",
1776
+ ref: (node) => {
1777
+ itemRefs.current[index] = node;
1778
+ },
1779
+ "data-toc-item": item2.id,
1780
+ tabIndex: open && index === roving ? 0 : -1,
1781
+ className: active ? `${styles.item} ${styles.itemActive}` : styles.item,
1782
+ style: {
1783
+ "--toc-indent": `${(item2.level - 1) * 12 + 10}px`
1784
+ },
1785
+ "aria-current": active ? "true" : void 0,
1786
+ "aria-label": item2.text,
1787
+ onClick: () => jump(item2),
1788
+ children: /* @__PURE__ */ jsx("span", { className: styles.itemText, children: item2.text })
1789
+ }
1790
+ ) }, item2.id);
1791
+ }) }) }) })
1792
+ ]
1793
+ }
1794
+ ) });
1795
+ }
1796
+ function useIsMobile(breakpoint = 768) {
1797
+ const [isMobile, setIsMobile] = useState(false);
1798
+ useEffect(() => {
1799
+ const mq = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
1800
+ const update = () => setIsMobile(mq.matches);
1801
+ update();
1802
+ mq.addEventListener("change", update);
1803
+ return () => mq.removeEventListener("change", update);
1804
+ }, [breakpoint]);
1805
+ return isMobile;
1806
+ }
1807
+ const HEADING_TAG = /^H([1-6])$/;
1808
+ function sameTocItems(a, b) {
1809
+ if (a.length !== b.length) return false;
1810
+ return a.every(
1811
+ (item2, index) => {
1812
+ var _a, _b, _c;
1813
+ return item2.id === ((_a = b[index]) == null ? void 0 : _a.id) && item2.level === ((_b = b[index]) == null ? void 0 : _b.level) && item2.text === ((_c = b[index]) == null ? void 0 : _c.text);
1814
+ }
1815
+ );
1816
+ }
1817
+ function readTocItems(root2) {
1818
+ const nodes = root2.querySelectorAll("[data-toc-id]");
1819
+ const items = [];
1820
+ nodes.forEach((el) => {
1821
+ const id = el.getAttribute("data-toc-id");
1822
+ const match = HEADING_TAG.exec(el.tagName);
1823
+ if (!id || !match) return;
1824
+ const text = (el.textContent ?? "").replace(/\s+/g, " ").trim();
1825
+ if (!text) return;
1826
+ items.push({ id, level: Number(match[1]), text });
1827
+ });
1828
+ return items;
1829
+ }
1830
+ function findCitationRefElement(target, root2) {
1831
+ let node = null;
1832
+ if (target instanceof Element) node = target;
1833
+ else if (target instanceof Text) node = target.parentElement;
1834
+ else if (target instanceof Node) node = target.parentElement;
1835
+ if (!(node instanceof Element)) return null;
1836
+ const el = node.closest(".citation-ref");
1837
+ if (!(el instanceof HTMLElement)) return null;
1838
+ if (!root2.contains(el)) return null;
1839
+ return el;
1840
+ }
1841
+ function readCitationAttrs(el) {
1842
+ var _a;
1843
+ return {
1844
+ index: el.getAttribute("data-index") || ((_a = el.textContent) == null ? void 0 : _a.trim()) || "",
1845
+ url: el.getAttribute("data-url"),
1846
+ title: el.getAttribute("data-title")
1847
+ };
1848
+ }
1849
+ function CitationInteractive({
1850
+ containerRef,
1851
+ onCitationEnter,
1852
+ onCitationLeave
1853
+ }) {
1854
+ const enterRef = useRef(onCitationEnter);
1855
+ const leaveRef = useRef(onCitationLeave);
1856
+ enterRef.current = onCitationEnter;
1857
+ leaveRef.current = onCitationLeave;
1858
+ useEffect(() => {
1859
+ const root2 = containerRef.current;
1860
+ if (!root2) return;
1861
+ let currentEl = null;
1862
+ const emitEnter = (el) => {
1863
+ currentEl = el;
1864
+ const attrs = readCitationAttrs(el);
1865
+ enterRef.current({ index: attrs.index, attrs, anchorEl: el });
1866
+ };
1867
+ const emitLeave = () => {
1868
+ if (!currentEl) return;
1869
+ currentEl = null;
1870
+ leaveRef.current();
1871
+ };
1872
+ const ACTIVE_ATTR = "data-tmr-citation-active";
1873
+ const onClick = (e) => {
1874
+ const el = findCitationRefElement(e.target, root2);
1875
+ if (el) {
1876
+ e.preventDefault();
1877
+ e.stopPropagation();
1878
+ if (el === currentEl && el.hasAttribute(ACTIVE_ATTR)) {
1879
+ emitLeave();
1880
+ return;
1881
+ }
1882
+ emitEnter(el);
1883
+ return;
1884
+ }
1885
+ emitLeave();
1886
+ };
1887
+ const onKeyDown = (e) => {
1888
+ if (e.key === "Escape") emitLeave();
1889
+ };
1890
+ root2.addEventListener("click", onClick, true);
1891
+ document.addEventListener("keydown", onKeyDown);
1892
+ return () => {
1893
+ root2.removeEventListener("click", onClick, true);
1894
+ document.removeEventListener("keydown", onKeyDown);
1895
+ };
1896
+ }, [containerRef]);
1897
+ return null;
1898
+ }
1899
+ function ContentOutline({
1900
+ toc = false,
1901
+ locale = "en",
1902
+ watch,
1903
+ children
1904
+ }) {
1905
+ const ref = useRef(null);
1906
+ const [items, setItems] = useState([]);
1907
+ const mobile = useIsMobile(768);
1908
+ useLayoutEffect(() => {
1909
+ const el = ref.current;
1910
+ if (!el || !toc) {
1911
+ setItems((prev) => prev.length === 0 ? prev : []);
1912
+ return;
1913
+ }
1914
+ const read = () => {
1915
+ const next = readTocItems(el);
1916
+ setItems((prev) => sameTocItems(prev, next) ? prev : next);
1917
+ };
1918
+ read();
1919
+ const observer = new MutationObserver(read);
1920
+ observer.observe(el, {
1921
+ childList: true,
1922
+ subtree: true,
1923
+ characterData: true
1924
+ });
1925
+ return () => observer.disconnect();
1926
+ }, [toc, watch]);
1927
+ const root2 = ref.current;
1928
+ const show = toc && !mobile && items.length > 0 && root2 !== null;
1929
+ return /* @__PURE__ */ jsxs("div", { className: styles$2.editorHost, children: [
1930
+ show && root2 ? /* @__PURE__ */ jsx(EditorToc, { items, editorDom: root2, locale }) : null,
1931
+ /* @__PURE__ */ jsx("div", { ref, className: show ? styles$2.withToc : void 0, children })
1932
+ ] });
1933
+ }
1934
+ function ReaderReportContent({
1935
+ html,
1936
+ className,
1937
+ toc = false,
1938
+ locale = "en",
1939
+ ...rest
1940
+ }) {
1941
+ return /* @__PURE__ */ jsx(ContentOutline, { toc, locale, watch: html, children: /* @__PURE__ */ jsx(ImagePreviewHost, { locale, activate: "click", children: /* @__PURE__ */ jsx(ReportContent, { html, className, ...rest }) }) });
1942
+ }
1943
+ function ReportContentInteractive({
1944
+ onCitationEnter,
1945
+ onCitationLeave,
1946
+ className,
1947
+ html,
1948
+ toc = false,
1949
+ locale = "en",
1950
+ ...rest
1951
+ }) {
1952
+ const ref = useRef(null);
1953
+ return /* @__PURE__ */ jsxs("div", { ref, className, children: [
1954
+ /* @__PURE__ */ jsx(ReaderReportContent, { html, toc, locale, ...rest }),
1955
+ /* @__PURE__ */ jsx(
1956
+ CitationInteractive,
1957
+ {
1958
+ containerRef: ref,
1959
+ onCitationEnter,
1960
+ onCitationLeave
1961
+ }
1962
+ )
1963
+ ] });
1964
+ }
1965
+ function hydrateOne(el, theme, registry) {
1966
+ const raw = el.getAttribute("data-chart");
1967
+ const payload = parseChartFenceBody(raw ?? "");
1968
+ if (!(payload == null ? void 0 : payload.config.length)) return;
1969
+ let host = el.querySelector(".tmr-chart-canvas-host");
1970
+ if (!host) {
1971
+ host = document.createElement("div");
1972
+ host.className = "tmr-chart-canvas-host";
1973
+ el.appendChild(host);
1974
+ }
1975
+ host.classList.remove("tmr-chart-skeleton");
1976
+ let canvas = host.querySelector("canvas");
1977
+ if (!canvas) {
1978
+ canvas = document.createElement("canvas");
1979
+ host.innerHTML = "";
1980
+ host.appendChild(canvas);
1981
+ }
1982
+ const config = payload.config[0];
1983
+ const height = config.height ?? 320;
1984
+ host.style.height = `${height}px`;
1985
+ if (payload.config.length > 1 && !el.querySelector(".tmr-chart-tabs")) {
1986
+ const tabs = document.createElement("div");
1987
+ tabs.className = "tmr-chart-tabs";
1988
+ tabs.setAttribute("role", "tablist");
1989
+ payload.config.forEach((c, i) => {
1990
+ var _a;
1991
+ const btn = document.createElement("button");
1992
+ btn.type = "button";
1993
+ btn.className = "tmr-chart-tab";
1994
+ btn.setAttribute("role", "tab");
1995
+ btn.dataset.active = i === 0 ? "true" : "false";
1996
+ btn.textContent = ((_a = c.title) == null ? void 0 : _a.trim()) || `${c.chartType} ${i + 1}`;
1997
+ btn.addEventListener("click", () => {
1998
+ tabs.querySelectorAll(".tmr-chart-tab").forEach((b, j) => {
1999
+ b.dataset.active = j === i ? "true" : "false";
2000
+ });
2001
+ const existing2 = registry.get(el);
2002
+ destroyChart(existing2);
2003
+ const next = renderOrUpdateChart({
2004
+ canvas,
2005
+ config: payload.config[i],
2006
+ payload,
2007
+ theme,
2008
+ chart: null
2009
+ });
2010
+ if (next) registry.set(el, next);
2011
+ const titleEl = el.querySelector(".tmr-chart-title");
2012
+ if (titleEl && payload.config[i].title) {
2013
+ titleEl.textContent = String(payload.config[i].title);
2014
+ titleEl.classList.remove("tmr-chart-title--empty");
2015
+ }
2016
+ });
2017
+ tabs.appendChild(btn);
2018
+ });
2019
+ el.insertBefore(tabs, host);
2020
+ }
2021
+ const existing = registry.get(el);
2022
+ const chart = renderOrUpdateChart({
2023
+ canvas,
2024
+ config,
2025
+ payload,
2026
+ theme,
2027
+ chart: existing ?? null
2028
+ });
2029
+ if (chart) registry.set(el, chart);
2030
+ }
2031
+ function ChartMount({
2032
+ containerRef,
2033
+ chartTheme,
2034
+ html
2035
+ }) {
2036
+ const registryRef = useRef(/* @__PURE__ */ new Map());
2037
+ useEffect(() => {
2038
+ const container = containerRef.current;
2039
+ if (!container) return;
2040
+ const registry = registryRef.current;
2041
+ registry.forEach((chart) => destroyChart(chart));
2042
+ registry.clear();
2043
+ container.querySelectorAll('div[data-type="chart"]').forEach((el) => hydrateOne(el, chartTheme, registry));
2044
+ return () => {
2045
+ registry.forEach((chart) => destroyChart(chart));
2046
+ registry.clear();
2047
+ };
2048
+ }, [containerRef, chartTheme, html]);
2049
+ return null;
2050
+ }
2051
+ function mountChartsInContainer(container, chartTheme) {
2052
+ const registry = /* @__PURE__ */ new Map();
2053
+ container.querySelectorAll('div[data-type="chart"]').forEach((el) => hydrateOne(el, chartTheme, registry));
2054
+ return () => {
2055
+ registry.forEach((c) => destroyChart(c));
2056
+ registry.clear();
2057
+ };
2058
+ }
2059
+ function ReportContentWithCharts({
2060
+ onCitationEnter,
2061
+ onCitationLeave,
2062
+ chartTheme,
2063
+ className,
2064
+ html,
2065
+ toc = false,
2066
+ locale = "en",
2067
+ ...rest
2068
+ }) {
2069
+ const ref = useRef(null);
2070
+ return /* @__PURE__ */ jsxs("div", { ref, className, children: [
2071
+ /* @__PURE__ */ jsx(ReaderReportContent, { html, toc, locale, ...rest }),
2072
+ /* @__PURE__ */ jsx(
2073
+ ChartMount,
2074
+ {
2075
+ containerRef: ref,
2076
+ chartTheme,
2077
+ html
2078
+ }
2079
+ ),
2080
+ onCitationEnter && onCitationLeave ? /* @__PURE__ */ jsx(
2081
+ CitationInteractive,
2082
+ {
2083
+ containerRef: ref,
2084
+ onCitationEnter,
2085
+ onCitationLeave
2086
+ }
2087
+ ) : null
2088
+ ] });
2089
+ }
2090
+ export {
2091
+ LinkIcon as $,
2092
+ AlignRightIcon as A,
2093
+ RotateCcwIcon as B,
2094
+ ChartMount as C,
2095
+ DownloadIcon as D,
2096
+ EraserIcon as E,
2097
+ ExternalLinkIcon as F,
2098
+ GripIcon as G,
2099
+ TableDeleteIcon as H,
2100
+ ImagePreviewHost as I,
2101
+ ColumnBeforeIcon as J,
2102
+ KeyboardIcon as K,
2103
+ ColumnAfterIcon as L,
2104
+ ColumnDeleteIcon as M,
2105
+ RowBeforeIcon as N,
2106
+ RowAfterIcon as O,
2107
+ RowDeleteIcon as P,
2108
+ RedoIcon as Q,
2109
+ ReaderReportContent as R,
2110
+ SearchIcon as S,
2111
+ TrashIcon as T,
2112
+ UndoIcon as U,
2113
+ BoldIcon as V,
2114
+ ItalicIcon as W,
2115
+ XIcon as X,
2116
+ UnderlineIcon as Y,
2117
+ StrikethroughIcon as Z,
2118
+ CodeIcon as _,
2119
+ CitationInteractive as a,
2120
+ ImageIcon as a0,
2121
+ DetailsIcon as a1,
2122
+ AlignJustifyIcon as a2,
2123
+ IndentIncreaseIcon as a3,
2124
+ IndentDecreaseIcon as a4,
2125
+ LineHeightIcon as a5,
2126
+ ListUnorderedIcon as a6,
2127
+ ListOrderedIcon as a7,
2128
+ ListChecksIcon as a8,
2129
+ ChevronLeftIcon as a9,
2130
+ ChevronRightIcon as aa,
2131
+ FitIcon as ab,
2132
+ ImportIcon as ac,
2133
+ LockIcon as ad,
2134
+ MenuIcon as ae,
2135
+ RotateCwIcon as af,
2136
+ ZoomInIcon as ag,
2137
+ ZoomOutIcon as ah,
2138
+ ReportContentInteractive as b,
2139
+ ReportContentWithCharts as c,
2140
+ ChevronUpIcon as d,
2141
+ ChevronDownIcon as e,
2142
+ findCitationRefElement as f,
2143
+ getLocaleBundle as g,
2144
+ ReplaceIcon as h,
2145
+ ReplaceAllIcon as i,
2146
+ renderOrUpdateChart as j,
2147
+ destroyChart as k,
2148
+ CheckIcon as l,
2149
+ mountChartsInContainer as m,
2150
+ CopyIcon as n,
2151
+ ChevronsUpDownIcon as o,
2152
+ EditorToc as p,
2153
+ sameTocItems as q,
2154
+ readCitationAttrs as r,
2155
+ scrollToTocHeading as s,
2156
+ AlignCenterIcon as t,
2157
+ useIsMobile as u,
2158
+ AlignLeftIcon as v,
2159
+ CropIcon as w,
2160
+ CaptionsIcon as x,
2161
+ ExpandIcon as y,
2162
+ requestImagePreview as z
2163
+ };
2164
+ //# sourceMappingURL=ReportContentWithCharts-B-K-EiAG.js.map