vue-stream-markdown 0.2.3 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +1 -1
  2. package/dist/{blockquote-Crr-D7fY.js → blockquote-ClgbyGJ2.js} +2 -2
  3. package/dist/button-BKN2jNlv.js +6 -0
  4. package/dist/{button-DVWlhfQ9.js → button-BVOWJPmC.js} +2 -2
  5. package/dist/{code-Bz8LM16H.js → code-DG1O8Nim.js} +10 -10
  6. package/dist/code-block-C3VwzdZn.js +10 -0
  7. package/dist/{code-block-CmUZxKNr.js → code-block-wjjUUcJZ.js} +22 -11
  8. package/dist/composables-CcP6Ysj8.js +10954 -0
  9. package/dist/{delete-DFoiOzHW.js → delete-C9W-KhtX.js} +2 -2
  10. package/dist/dropdown-ByLAwToD.js +6 -0
  11. package/dist/{emphasis-DvaBuxeK.js → emphasis-DiWz4428.js} +2 -2
  12. package/dist/error-component-Bhq210EM.js +5 -0
  13. package/dist/{error-component-BTe-SuY7.js → error-component-BrESW9p1.js} +2 -2
  14. package/dist/{footnote-definition-ByWh1N3S.js → footnote-definition-lObKczNc.js} +5 -5
  15. package/dist/{footnote-reference-BJ4J7BFo.js → footnote-reference-D4hG5a5R.js} +1 -1
  16. package/dist/{heading-1fssqGGO.js → heading-CV3_yOWw.js} +2 -2
  17. package/dist/{icon-DcLTFhFW.js → icon-CRNiOEiK.js} +1 -1
  18. package/dist/icon-CVg4xQw0.js +4 -0
  19. package/dist/image-C9bwOpvz.js +9 -0
  20. package/dist/{image-xPrAKT9D.js → image-CRAZ3iRD.js} +17 -12
  21. package/dist/{image-DXnmoID_.js → image-CS78DShm.js} +13 -10
  22. package/dist/index.d.ts +294 -182
  23. package/dist/index.js +10387 -18754
  24. package/dist/{inline-math-CPkpjl8t.js → inline-math-BE7gPPl0.js} +3 -3
  25. package/dist/{link-BACrkxRW.js → link-EaqqdLrN.js} +4 -4
  26. package/dist/{list-Cu8G46hK.js → list-EaQaXX4p.js} +2 -2
  27. package/dist/{list-item-BMgDS1tS.js → list-item-KAU_GIzi.js} +2 -2
  28. package/dist/{math-XsZX0VMw.js → math-CsyxsUp9.js} +3 -3
  29. package/dist/{mermaid-CQdSlhqn.js → mermaid-CA30wprV.js} +25 -11
  30. package/dist/modal-C0X_IXfp.js +4 -0
  31. package/dist/{modal-C1riNMrs.js → modal-D8sOifLe.js} +1 -1
  32. package/dist/node-list--ReOjYkK.js +4 -0
  33. package/dist/{node-list-7H-lIfUX.js → node-list-VskJkISk.js} +2 -81
  34. package/dist/{paragraph-Cfd37HUK.js → paragraph-D6OuJvHb.js} +2 -2
  35. package/dist/{previewers-C7PKsIbc.js → previewers-CwjTiQh8.js} +1 -1
  36. package/dist/segmented-D-zfh_BF.js +7 -0
  37. package/dist/{segmented-C9j-IIDc.js → segmented-DafF5jPA.js} +1 -1
  38. package/dist/{shiki-BoBbCakv.js → shiki-C1omjtbf.js} +2 -2
  39. package/dist/{strong-BzOBAWrG.js → strong-Clqsbyuc.js} +2 -2
  40. package/dist/{table-YY5M01Jm.js → table-DQZFzn1X.js} +13 -8
  41. package/dist/{tooltip-DarhJuZR.js → tooltip-BfznjscC.js} +1 -1
  42. package/dist/tooltip-Yf5TSh_Q.js +4 -0
  43. package/dist/vanilla-C7Ds8DWX.js +4 -0
  44. package/dist/{vanilla-Z6d1vQmX.js → vanilla-CfMvJwq0.js} +1 -1
  45. package/dist/{zoom-container-DQMpHHGQ.js → zoom-container-Ci1d-2Rg.js} +2 -2
  46. package/dist/zoom-container-Dd5Vtieh.js +7 -0
  47. package/package.json +3 -5
  48. package/dist/button-Dw4uJRaD.js +0 -6
  49. package/dist/code-block-Bitp8x1w.js +0 -10
  50. package/dist/composables-CzUVrTt_.js +0 -2151
  51. package/dist/dropdown-CSRjqK0u.js +0 -6
  52. package/dist/error-component-DDnC0bqw.js +0 -5
  53. package/dist/icon-DE3AzDqz.js +0 -4
  54. package/dist/image-Dl-r78_E.js +0 -9
  55. package/dist/modal-C7O4jt5-.js +0 -4
  56. package/dist/node-list-DMwAmH_n.js +0 -4
  57. package/dist/segmented-BRTZXoDN.js +0 -7
  58. package/dist/tooltip-vDDEbLwf.js +0 -4
  59. package/dist/vanilla-CzQw2_b4.js +0 -4
  60. package/dist/zoom-container-JLbwB4gy.js +0 -7
@@ -1,2151 +0,0 @@
1
- import { computed, defineAsyncComponent, inject, nextTick, onBeforeUnmount, provide, ref, toValue, unref, watch, watchEffect } from "vue";
2
- import { autoUpdate, computePosition, flip, offset, shift } from "@floating-ui/dom";
3
- import { useEventListener, useStyleTag } from "@vueuse/core";
4
-
5
- //#region src/composables/use-code-options.ts
6
- function useCodeOptions(options) {
7
- const language = computed(() => unref(options.language) || "");
8
- const codeOptions = computed(() => unref(options.codeOptions));
9
- const languageCodeOptions = computed(() => {
10
- var _codeOptions$value;
11
- const specificOptions = (_codeOptions$value = codeOptions.value) === null || _codeOptions$value === void 0 || (_codeOptions$value = _codeOptions$value.language) === null || _codeOptions$value === void 0 ? void 0 : _codeOptions$value[language.value];
12
- return {
13
- ...codeOptions.value,
14
- ...specificOptions ?? {}
15
- };
16
- });
17
- return {
18
- languageCodeOptions,
19
- showLanguageIcon: computed(() => {
20
- var _languageCodeOptions$;
21
- return typeof ((_languageCodeOptions$ = languageCodeOptions.value) === null || _languageCodeOptions$ === void 0 ? void 0 : _languageCodeOptions$.languageIcon) === "boolean" ? languageCodeOptions.value.languageIcon : true;
22
- }),
23
- showLanguageName: computed(() => {
24
- var _languageCodeOptions$2;
25
- return typeof ((_languageCodeOptions$2 = languageCodeOptions.value) === null || _languageCodeOptions$2 === void 0 ? void 0 : _languageCodeOptions$2.languageName) === "boolean" ? languageCodeOptions.value.languageName : true;
26
- }),
27
- showLineNumbers: computed(() => {
28
- var _languageCodeOptions$3;
29
- return typeof ((_languageCodeOptions$3 = languageCodeOptions.value) === null || _languageCodeOptions$3 === void 0 ? void 0 : _languageCodeOptions$3.lineNumbers) === "boolean" ? languageCodeOptions.value.lineNumbers : true;
30
- })
31
- };
32
- }
33
-
34
- //#endregion
35
- //#region src/composables/use-context.ts
36
- const CONTEXT_KEY = Symbol("stream-markdown-context");
37
- function useContext() {
38
- const context = injectContext();
39
- const mode = computed(() => unref(context.mode) ?? "streaming");
40
- const icons = computed(() => unref(context.icons) ?? {});
41
- const uiOptions = computed(() => unref(context.uiOptions) ?? {});
42
- const hideTooltip = computed(() => uiOptions.value.hideTooltip ?? false);
43
- const isDark = computed(() => unref(context.isDark) ?? false);
44
- const enableAnimate = computed(() => unref(context.enableAnimate));
45
- const parsedNodes = computed(() => unref(context.parsedNodes) ?? []);
46
- function provideContext(ctx) {
47
- provide(CONTEXT_KEY, {
48
- ...injectContext(),
49
- ...ctx
50
- });
51
- }
52
- function injectContext() {
53
- return inject(CONTEXT_KEY, {}) || {};
54
- }
55
- return {
56
- context,
57
- provideContext,
58
- injectContext,
59
- mode,
60
- hideTooltip,
61
- icons,
62
- isDark,
63
- enableAnimate,
64
- parsedNodes,
65
- get getContainer() {
66
- return context.getContainer || (() => void 0);
67
- },
68
- get getOverlayContainer() {
69
- return context.getOverlayContainer || (() => null);
70
- },
71
- get onCopied() {
72
- return context.onCopied || (() => {});
73
- }
74
- };
75
- }
76
-
77
- //#endregion
78
- //#region src/composables/use-controls.ts
79
- function useControls(options) {
80
- const controls = computed(() => unref(options.controls) ?? true);
81
- function isControlEnabled(key) {
82
- try {
83
- return getControlValue(key) !== false;
84
- } catch {
85
- return false;
86
- }
87
- }
88
- function getControlValue(key) {
89
- try {
90
- const config = controls.value;
91
- if (typeof config === "boolean") return config;
92
- const path = key.split(".");
93
- let current = config;
94
- for (const part of path) {
95
- if (current === void 0 || current === null || typeof current !== "object") return void 0;
96
- current = current[part];
97
- }
98
- return current;
99
- } catch {
100
- return;
101
- }
102
- }
103
- function resolveControls(type, builtinControls, props) {
104
- const customize = getControlValue(`${type}.customize`);
105
- if (typeof customize !== "function") return builtinControls.filter((item) => {
106
- var _item$visible;
107
- return ((_item$visible = item.visible) === null || _item$visible === void 0 ? void 0 : _item$visible.call(item)) ?? true;
108
- });
109
- return customize(builtinControls, props).filter((item) => {
110
- var _item$visible2;
111
- return ((_item$visible2 = item.visible) === null || _item$visible2 === void 0 ? void 0 : _item$visible2.call(item)) ?? true;
112
- });
113
- }
114
- return {
115
- isControlEnabled,
116
- getControlValue,
117
- resolveControls
118
- };
119
- }
120
-
121
- //#endregion
122
- //#region src/utils/harden.ts
123
- function parseUrl(url, defaultOrigin) {
124
- if (typeof url !== "string") return null;
125
- try {
126
- return new URL(url);
127
- } catch {
128
- if (defaultOrigin) try {
129
- return new URL(url, defaultOrigin);
130
- } catch {
131
- return null;
132
- }
133
- if (url.startsWith("/") || url.startsWith("./") || url.startsWith("../")) try {
134
- return new URL(url, "http://example.com");
135
- } catch {
136
- return null;
137
- }
138
- return null;
139
- }
140
- }
141
- function isPathRelativeUrl(url) {
142
- if (typeof url !== "string") return false;
143
- return url.startsWith("/") || url.startsWith("./") || url.startsWith("../");
144
- }
145
- const safeProtocols = new Set([
146
- "https:",
147
- "http:",
148
- "irc:",
149
- "ircs:",
150
- "mailto:",
151
- "xmpp:",
152
- "blob:"
153
- ]);
154
- const blockedProtocols = new Set([
155
- "javascript:",
156
- "data:",
157
- "file:",
158
- "vbscript:"
159
- ]);
160
- function transformUrl(url, allowedPrefixes, defaultOrigin, allowDataImages = false, isImage = false, allowedProtocols = []) {
161
- if (!url) return null;
162
- if (typeof url === "string" && url.startsWith("#") && !isImage) try {
163
- if (new URL(url, "http://example.com").hash === url) return url;
164
- } catch {}
165
- if (typeof url === "string" && url.startsWith("data:")) {
166
- if (isImage && allowDataImages && url.startsWith("data:image/")) return url;
167
- return null;
168
- }
169
- if (typeof url === "string" && url.startsWith("blob:")) {
170
- try {
171
- if (new URL(url).protocol === "blob:" && url.length > 5) {
172
- const afterProtocol = url.substring(5);
173
- if (afterProtocol && afterProtocol.length > 0 && afterProtocol !== "invalid") return url;
174
- }
175
- } catch {
176
- return null;
177
- }
178
- return null;
179
- }
180
- const parsedUrl = parseUrl(url, defaultOrigin);
181
- if (!parsedUrl) return null;
182
- if (blockedProtocols.has(parsedUrl.protocol)) return null;
183
- if (!(safeProtocols.has(parsedUrl.protocol) || allowedProtocols.includes(parsedUrl.protocol) || allowedProtocols.includes("*"))) return null;
184
- if (parsedUrl.protocol === "mailto:" || !parsedUrl.protocol.match(/^https?:$/)) return parsedUrl.href;
185
- const inputWasRelative = isPathRelativeUrl(url);
186
- if (parsedUrl && allowedPrefixes.some((prefix) => {
187
- const parsedPrefix = parseUrl(prefix, defaultOrigin);
188
- if (!parsedPrefix) return false;
189
- if (parsedPrefix.origin !== parsedUrl.origin) return false;
190
- return parsedUrl.href.startsWith(parsedPrefix.href);
191
- })) {
192
- if (inputWasRelative) return parsedUrl.pathname + parsedUrl.search + parsedUrl.hash;
193
- return parsedUrl.href;
194
- }
195
- if (allowedPrefixes.includes("*")) {
196
- if (parsedUrl.protocol !== "https:" && parsedUrl.protocol !== "http:") return null;
197
- if (inputWasRelative) return parsedUrl.pathname + parsedUrl.search + parsedUrl.hash;
198
- return parsedUrl.href;
199
- }
200
- return null;
201
- }
202
-
203
- //#endregion
204
- //#region src/utils/helper.ts
205
- const fileExtensionPattern = /\.[^/.]+$/;
206
- function flow(fns) {
207
- return (input) => fns.reduce((acc, fn) => fn(acc), input);
208
- }
209
- function save(filename, content, mimeType) {
210
- const blob = typeof content === "string" ? new Blob([content], { type: mimeType }) : content;
211
- const url = URL.createObjectURL(blob);
212
- const a = document.createElement("a");
213
- a.href = url;
214
- a.download = filename;
215
- document.body.appendChild(a);
216
- a.click();
217
- document.body.removeChild(a);
218
- URL.revokeObjectURL(url);
219
- }
220
- async function saveImage(url, alt) {
221
- const blob = await (await fetch(url)).blob();
222
- const originalFilename = new URL(url, window.location.origin).pathname.split("/").pop() || "";
223
- const extension = originalFilename.split(".").pop();
224
- const hasExtension = originalFilename.includes(".") && extension !== void 0 && extension.length <= 4;
225
- let filename = "";
226
- if (hasExtension) filename = originalFilename;
227
- else {
228
- const mimeType = blob.type;
229
- let fileExtension = "png";
230
- if (mimeType.includes("jpeg") || mimeType.includes("jpg")) fileExtension = "jpg";
231
- else if (mimeType.includes("png")) fileExtension = "png";
232
- else if (mimeType.includes("svg")) fileExtension = "svg";
233
- else if (mimeType.includes("gif")) fileExtension = "gif";
234
- else if (mimeType.includes("webp")) fileExtension = "webp";
235
- filename = `${(alt || originalFilename || "image").replace(fileExtensionPattern, "")}.${fileExtension}`;
236
- }
237
- save(filename, blob, blob.type);
238
- }
239
- function svgToPngBlob(svgString, options) {
240
- const scale = (options === null || options === void 0 ? void 0 : options.scale) ?? 5;
241
- return new Promise((resolve, reject) => {
242
- const encoded = `data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(svgString)))}`;
243
- const img = new Image();
244
- img.crossOrigin = "anonymous";
245
- img.onload = () => {
246
- const canvas = document.createElement("canvas");
247
- const w = img.width * scale;
248
- const h$1 = img.height * scale;
249
- canvas.width = w;
250
- canvas.height = h$1;
251
- const ctx = canvas.getContext("2d");
252
- if (!ctx) {
253
- reject(/* @__PURE__ */ new Error("Failed to create 2D canvas context for PNG export"));
254
- return;
255
- }
256
- ctx.drawImage(img, 0, 0, w, h$1);
257
- canvas.toBlob((blob) => {
258
- if (!blob) {
259
- reject(/* @__PURE__ */ new Error("Failed to create PNG blob"));
260
- return;
261
- }
262
- resolve(blob);
263
- }, "image/png");
264
- };
265
- img.onerror = () => reject(/* @__PURE__ */ new Error("Failed to load SVG image"));
266
- img.src = encoded;
267
- });
268
- }
269
-
270
- //#endregion
271
- //#region src/utils/inference.ts
272
- function isClient() {
273
- return typeof window !== "undefined";
274
- }
275
- function isServer() {
276
- return typeof window === "undefined";
277
- }
278
-
279
- //#endregion
280
- //#region src/utils/module.ts
281
- async function hasShiki() {
282
- try {
283
- await import("shiki");
284
- return true;
285
- } catch {
286
- return false;
287
- }
288
- }
289
- async function hasMermaid() {
290
- try {
291
- await import("mermaid");
292
- return true;
293
- } catch {
294
- return false;
295
- }
296
- }
297
- async function hasKatex() {
298
- try {
299
- await import("katex");
300
- return true;
301
- } catch {
302
- return false;
303
- }
304
- }
305
-
306
- //#endregion
307
- //#region src/utils/parser.ts
308
- function findLastLeafNode(nodes) {
309
- for (let i = nodes.length - 1; i >= 0; i--) {
310
- const node = nodes[i];
311
- const nodeWithChildren = node;
312
- if (nodeWithChildren.children && nodeWithChildren.children.length > 0) {
313
- const found = findLastLeafNode(nodeWithChildren.children);
314
- if (found) return found;
315
- continue;
316
- }
317
- return node ?? null;
318
- }
319
- return null;
320
- }
321
- function findNodeParent(targetNode, nodes, parent) {
322
- for (let i = nodes.length - 1; i >= 0; i--) {
323
- if (nodes[i] === targetNode && parent) return {
324
- parent,
325
- index: i
326
- };
327
- const node = nodes[i];
328
- if (node.children) {
329
- const result = findNodeParent(targetNode, node.children, node);
330
- if (result) return result;
331
- }
332
- }
333
- return null;
334
- }
335
-
336
- //#endregion
337
- //#region src/utils/preload.ts
338
- function isAsyncComponent(component) {
339
- return typeof component === "object" && "__asyncLoader" in component;
340
- }
341
- async function preloadAsyncComponents(components, include = [], exclude = []) {
342
- const loaders = [];
343
- Object.entries(components).forEach(([key, component]) => {
344
- if (!isAsyncComponent(component)) return;
345
- if (include.length > 0 && !include.includes(key)) return;
346
- if (exclude.length > 0 && exclude.includes(key)) return;
347
- loaders.push(component.__asyncLoader());
348
- });
349
- await Promise.all(loaders);
350
- }
351
-
352
- //#endregion
353
- //#region src/utils/table.ts
354
- function extractTableDataFromElement(tableElement) {
355
- const headers = [];
356
- const rows = [];
357
- const headerCells = Array.from(tableElement.querySelectorAll("thead th"));
358
- for (const cell of headerCells) {
359
- var _cell$textContent;
360
- headers.push(((_cell$textContent = cell.textContent) === null || _cell$textContent === void 0 ? void 0 : _cell$textContent.trim()) || "");
361
- }
362
- const bodyRows = Array.from(tableElement.querySelectorAll("tbody tr"));
363
- for (const row of bodyRows) {
364
- const rowData = [];
365
- const cells = Array.from(row.querySelectorAll("td"));
366
- for (const cell of cells) {
367
- var _cell$textContent2;
368
- rowData.push(((_cell$textContent2 = cell.textContent) === null || _cell$textContent2 === void 0 ? void 0 : _cell$textContent2.trim()) || "");
369
- }
370
- rows.push(rowData);
371
- }
372
- return {
373
- headers,
374
- rows
375
- };
376
- }
377
- function tableDataToCSV(data) {
378
- const { headers, rows } = data;
379
- const escapeCSV = (value) => {
380
- let needsEscaping = false;
381
- let hasQuote = false;
382
- for (let i = 0; i < value.length; i += 1) {
383
- const char = value[i];
384
- if (char === "\"") {
385
- needsEscaping = true;
386
- hasQuote = true;
387
- break;
388
- }
389
- if (char === "," || char === "\n") needsEscaping = true;
390
- }
391
- if (!needsEscaping) return value;
392
- if (hasQuote) return `"${value.replace(/"/g, "\"\"")}"`;
393
- return `"${value}"`;
394
- };
395
- const totalRows = headers.length > 0 ? rows.length + 1 : rows.length;
396
- const csvRows = Array.from({ length: totalRows });
397
- let rowIndex = 0;
398
- if (headers.length > 0) {
399
- csvRows[rowIndex] = headers.map(escapeCSV).join(",");
400
- rowIndex += 1;
401
- }
402
- for (const row of rows) {
403
- csvRows[rowIndex] = row.map(escapeCSV).join(",");
404
- rowIndex += 1;
405
- }
406
- return csvRows.join("\n");
407
- }
408
- function tableDataToTSV(data) {
409
- const { headers, rows } = data;
410
- const escapeTSV = (value) => {
411
- let needsEscaping = false;
412
- for (let i = 0; i < value.length; i += 1) {
413
- const char = value[i];
414
- if (char === " " || char === "\n" || char === "\r") {
415
- needsEscaping = true;
416
- break;
417
- }
418
- }
419
- if (!needsEscaping) return value;
420
- const parts = [];
421
- for (let i = 0; i < value.length; i += 1) {
422
- const char = value[i];
423
- if (char === " ") parts.push("\\t");
424
- else if (char === "\n") parts.push("\\n");
425
- else if (char === "\r") parts.push("\\r");
426
- else parts.push(char);
427
- }
428
- return parts.join("");
429
- };
430
- const totalRows = headers.length > 0 ? rows.length + 1 : rows.length;
431
- const tsvRows = Array.from({ length: totalRows });
432
- let rowIndex = 0;
433
- if (headers.length > 0) {
434
- tsvRows[rowIndex] = headers.map(escapeTSV).join(" ");
435
- rowIndex += 1;
436
- }
437
- for (const row of rows) {
438
- tsvRows[rowIndex] = row.map(escapeTSV).join(" ");
439
- rowIndex += 1;
440
- }
441
- return tsvRows.join("\n");
442
- }
443
- function escapeMarkdownTableCell(cell) {
444
- let needsEscaping = false;
445
- for (let i = 0; i < cell.length; i += 1) {
446
- const char = cell[i];
447
- if (char === "\\" || char === "|") {
448
- needsEscaping = true;
449
- break;
450
- }
451
- }
452
- if (!needsEscaping) return cell;
453
- const parts = [];
454
- for (let i = 0; i < cell.length; i += 1) {
455
- const char = cell[i];
456
- if (char === "\\") parts.push("\\\\");
457
- else if (char === "|") parts.push("\\|");
458
- else parts.push(char);
459
- }
460
- return parts.join("");
461
- }
462
- function tableDataToMarkdown(data) {
463
- const { headers, rows } = data;
464
- if (headers.length === 0) return "";
465
- const markdownRows = Array.from({ length: rows.length + 2 });
466
- let rowIndex = 0;
467
- markdownRows[rowIndex] = `| ${headers.map((h$1) => escapeMarkdownTableCell(h$1)).join(" | ")} |`;
468
- rowIndex += 1;
469
- const separatorParts = Array.from({ length: headers.length });
470
- for (let i = 0; i < headers.length; i += 1) separatorParts[i] = "---";
471
- markdownRows[rowIndex] = `| ${separatorParts.join(" | ")} |`;
472
- rowIndex += 1;
473
- for (const row of rows) if (row.length < headers.length) {
474
- const paddedRow = Array.from({ length: headers.length });
475
- for (let i = 0; i < headers.length; i += 1) paddedRow[i] = i < row.length ? escapeMarkdownTableCell(row[i]) : "";
476
- markdownRows[rowIndex] = `| ${paddedRow.join(" | ")} |`;
477
- rowIndex += 1;
478
- } else {
479
- markdownRows[rowIndex] = `| ${row.map((cell) => escapeMarkdownTableCell(cell)).join(" | ")} |`;
480
- rowIndex += 1;
481
- }
482
- return markdownRows.join("\n");
483
- }
484
-
485
- //#endregion
486
- //#region src/composables/use-floating.ts
487
- function useFloating(options) {
488
- const hideTooltip = computed(() => unref(options.hideTooltip) ?? false);
489
- const trigger = computed(() => unref(options.trigger) ?? "hover");
490
- const placement = computed(() => unref(options.placement) ?? "top");
491
- const delay = computed(() => unref(options.delay) ?? [100, 100]);
492
- const referenceEl = ref();
493
- const floatingEl = ref();
494
- let showTimer = null;
495
- let hideTimer = null;
496
- const open = ref(false);
497
- const x = ref(null);
498
- const y = ref(null);
499
- const strategy = ref("absolute");
500
- let cleanupAutoUpdate = null;
501
- async function updatePosition() {
502
- if (!referenceEl.value || !floatingEl.value || !isClient()) return;
503
- try {
504
- const position = await computePosition(referenceEl.value, floatingEl.value, {
505
- placement: placement.value,
506
- middleware: [
507
- offset(6),
508
- flip(),
509
- shift({ padding: 5 })
510
- ]
511
- });
512
- x.value = position.x;
513
- y.value = position.y;
514
- strategy.value = position.strategy;
515
- } catch {}
516
- }
517
- watchEffect(() => {
518
- if (cleanupAutoUpdate) {
519
- cleanupAutoUpdate();
520
- cleanupAutoUpdate = null;
521
- }
522
- if (!referenceEl.value || !floatingEl.value || !isClient()) return;
523
- cleanupAutoUpdate = autoUpdate(referenceEl.value, floatingEl.value, updatePosition);
524
- });
525
- watch(placement, () => {
526
- if (open.value) updatePosition();
527
- });
528
- const parentEl = computed(() => {
529
- var _referenceEl$value;
530
- if (!isClient()) return null;
531
- return ((_referenceEl$value = referenceEl.value) === null || _referenceEl$value === void 0 ? void 0 : _referenceEl$value.parentElement) || null;
532
- });
533
- const appendTo = computed(() => {
534
- var _options$getContainer, _options$getContainer2;
535
- if (!isClient()) return ((_options$getContainer = options.getContainer) === null || _options$getContainer === void 0 ? void 0 : _options$getContainer.call(options)) || "body";
536
- const target = ((_options$getContainer2 = options.getContainer) === null || _options$getContainer2 === void 0 ? void 0 : _options$getContainer2.call(options)) || parentEl.value;
537
- if (target instanceof HTMLElement && !document.body.contains(target)) return "body";
538
- return target || "body";
539
- });
540
- const floatingStyle = computed(() => ({
541
- position: strategy.value,
542
- top: `${y.value ?? 0}px`,
543
- left: `${x.value ?? 0}px`
544
- }));
545
- function show() {
546
- clearTimers();
547
- const { show: showDelay } = getDelay();
548
- showTimer = window.setTimeout(() => {
549
- open.value = true;
550
- updatePosition();
551
- }, showDelay);
552
- }
553
- function hide() {
554
- clearTimers();
555
- const { hide: hideDelay } = getDelay();
556
- hideTimer = window.setTimeout(() => {
557
- open.value = false;
558
- }, hideDelay);
559
- }
560
- function toggle() {
561
- open.value = !open.value;
562
- updatePosition();
563
- }
564
- function onMouseEnter() {
565
- if (hideTooltip.value) return;
566
- if (trigger.value === "hover") show();
567
- }
568
- function onMouseLeave() {
569
- if (trigger.value === "hover") hide();
570
- }
571
- function onClick() {
572
- if (trigger.value === "click") toggle();
573
- }
574
- function getDelay() {
575
- if (Array.isArray(delay.value)) return {
576
- show: delay.value[0] ?? 0,
577
- hide: delay.value[1] ?? 0
578
- };
579
- return {
580
- show: delay.value ?? 0,
581
- hide: delay.value ?? 0
582
- };
583
- }
584
- function handleClickOutside(event) {
585
- var _referenceEl$value2, _floatingEl$value;
586
- if (!open.value) return;
587
- const target = event.target;
588
- if (!(((_referenceEl$value2 = referenceEl.value) === null || _referenceEl$value2 === void 0 ? void 0 : _referenceEl$value2.contains(target)) || ((_floatingEl$value = floatingEl.value) === null || _floatingEl$value === void 0 ? void 0 : _floatingEl$value.contains(target)))) open.value = false;
589
- }
590
- function onFloatingEnter() {
591
- if (hideTimer) {
592
- clearTimeout(hideTimer);
593
- hideTimer = null;
594
- }
595
- }
596
- function onFloatingLeave() {
597
- const { hide: hideDelay } = getDelay();
598
- if (trigger.value === "hover") hideTimer = window.setTimeout(() => {
599
- hide();
600
- }, hideDelay);
601
- }
602
- function clearTimers() {
603
- if (showTimer) {
604
- clearTimeout(showTimer);
605
- showTimer = null;
606
- }
607
- if (hideTimer) {
608
- clearTimeout(hideTimer);
609
- hideTimer = null;
610
- }
611
- }
612
- useEventListener(document, "click", handleClickOutside);
613
- return {
614
- referenceEl,
615
- floatingEl,
616
- open,
617
- appendTo,
618
- floatingStyle,
619
- show,
620
- hide,
621
- onMouseEnter,
622
- onMouseLeave,
623
- onClick,
624
- onFloatingEnter,
625
- onFloatingLeave
626
- };
627
- }
628
-
629
- //#endregion
630
- //#region src/locales/index.ts
631
- const SUPPORT_LANGUAGES = ["en-US", "zh-CN"];
632
- const localesGlob = {
633
- "./en-US.json": () => import("./en-US-BE5eeEXk.js"),
634
- "./zh-CN.json": () => import("./zh-CN-BLQuwJEP.js")
635
- };
636
- const localeMessages = ref();
637
- const currentLocale = ref("en-US");
638
- async function loadLocaleMessages(language) {
639
- const load = async (language$1) => {
640
- const fn = localesGlob[`./${language$1}.json`];
641
- if (!fn) return;
642
- localeMessages.value = await fn();
643
- currentLocale.value = language$1;
644
- };
645
- try {
646
- if (typeof language === "string") await load(language);
647
- else localeMessages.value = language;
648
- } catch {
649
- await load("en-US");
650
- }
651
- }
652
- loadLocaleMessages("en-US");
653
-
654
- //#endregion
655
- //#region src/composables/use-i18n.ts
656
- function useI18n() {
657
- function getI18nText(key) {
658
- try {
659
- const messages = localeMessages.value;
660
- if (!messages) return key;
661
- const result = key.split(".").reduce((obj, k) => {
662
- if (obj && typeof obj === "object" && k in obj) return obj[k];
663
- }, messages);
664
- return typeof result === "string" ? result : key;
665
- } catch {
666
- return key;
667
- }
668
- }
669
- return { t: getI18nText };
670
- }
671
-
672
- //#endregion
673
- //#region src/composables/use-katex.ts
674
- let existingKatex = false;
675
- function useKatex() {
676
- const installed = ref(false);
677
- async function render(code, options = {}) {
678
- const { renderToString } = await import("katex");
679
- try {
680
- return { html: renderToString(code, {
681
- output: "html",
682
- strict: "ignore",
683
- ...options
684
- }) };
685
- } catch (error) {
686
- return { error: error.message };
687
- }
688
- }
689
- async function preload() {
690
- if (!isClient()) return;
691
- if (await hasKatex()) {
692
- const loadCSS = async () => {
693
- if (isClient()) await import("katex/dist/katex.min.css");
694
- };
695
- await loadCSS();
696
- }
697
- }
698
- function dispose() {}
699
- if (isClient()) (async () => {
700
- if (existingKatex === true) {
701
- installed.value = true;
702
- return;
703
- }
704
- installed.value = await hasKatex();
705
- existingKatex = installed.value;
706
- })();
707
- return {
708
- installed,
709
- render,
710
- preload,
711
- dispose
712
- };
713
- }
714
-
715
- //#endregion
716
- //#region \0@oxc-project+runtime@0.101.0/helpers/typeof.js
717
- function _typeof(o) {
718
- "@babel/helpers - typeof";
719
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
720
- return typeof o$1;
721
- } : function(o$1) {
722
- return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
723
- }, _typeof(o);
724
- }
725
-
726
- //#endregion
727
- //#region \0@oxc-project+runtime@0.101.0/helpers/toPrimitive.js
728
- function toPrimitive(t, r) {
729
- if ("object" != _typeof(t) || !t) return t;
730
- var e = t[Symbol.toPrimitive];
731
- if (void 0 !== e) {
732
- var i = e.call(t, r || "default");
733
- if ("object" != _typeof(i)) return i;
734
- throw new TypeError("@@toPrimitive must return a primitive value.");
735
- }
736
- return ("string" === r ? String : Number)(t);
737
- }
738
-
739
- //#endregion
740
- //#region \0@oxc-project+runtime@0.101.0/helpers/toPropertyKey.js
741
- function toPropertyKey(t) {
742
- var i = toPrimitive(t, "string");
743
- return "symbol" == _typeof(i) ? i : i + "";
744
- }
745
-
746
- //#endregion
747
- //#region \0@oxc-project+runtime@0.101.0/helpers/defineProperty.js
748
- function _defineProperty(e, r, t) {
749
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
750
- value: t,
751
- enumerable: !0,
752
- configurable: !0,
753
- writable: !0
754
- }) : e[r] = t, e;
755
- }
756
-
757
- //#endregion
758
- //#region \0@oxc-project+runtime@0.101.0/helpers/checkPrivateRedeclaration.js
759
- function _checkPrivateRedeclaration(e, t) {
760
- if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
761
- }
762
-
763
- //#endregion
764
- //#region \0@oxc-project+runtime@0.101.0/helpers/classPrivateFieldInitSpec.js
765
- function _classPrivateFieldInitSpec(e, t, a) {
766
- _checkPrivateRedeclaration(e, t), t.set(e, a);
767
- }
768
-
769
- //#endregion
770
- //#region \0@oxc-project+runtime@0.101.0/helpers/assertClassBrand.js
771
- function _assertClassBrand(e, t, n) {
772
- if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
773
- throw new TypeError("Private element is not present on this object");
774
- }
775
-
776
- //#endregion
777
- //#region \0@oxc-project+runtime@0.101.0/helpers/classPrivateFieldGet2.js
778
- function _classPrivateFieldGet2(s, a) {
779
- return s.get(_assertClassBrand(s, a));
780
- }
781
-
782
- //#endregion
783
- //#region \0@oxc-project+runtime@0.101.0/helpers/classPrivateFieldSet2.js
784
- function _classPrivateFieldSet2(s, a, r) {
785
- return s.set(_assertClassBrand(s, a), r), r;
786
- }
787
-
788
- //#endregion
789
- //#region node_modules/.pnpm/@antfu+utils@9.3.0/node_modules/@antfu/utils/dist/index.mjs
790
- let _Symbol$iterator;
791
- const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
792
- function randomStr(size = 16, dict = urlAlphabet) {
793
- let id = "";
794
- let i = size;
795
- const len = dict.length;
796
- while (i--) id += dict[Math.random() * len | 0];
797
- return id;
798
- }
799
- var Node = class {
800
- constructor(value) {
801
- _defineProperty(this, "value", void 0);
802
- _defineProperty(this, "next", void 0);
803
- this.value = value;
804
- }
805
- };
806
- var _head = /* @__PURE__ */ new WeakMap();
807
- var _tail = /* @__PURE__ */ new WeakMap();
808
- var _size = /* @__PURE__ */ new WeakMap();
809
- _Symbol$iterator = Symbol.iterator;
810
- var Queue = class {
811
- constructor() {
812
- _classPrivateFieldInitSpec(this, _head, void 0);
813
- _classPrivateFieldInitSpec(this, _tail, void 0);
814
- _classPrivateFieldInitSpec(this, _size, void 0);
815
- this.clear();
816
- }
817
- enqueue(value) {
818
- var _this$size;
819
- const node = new Node(value);
820
- if (_classPrivateFieldGet2(_head, this)) {
821
- _classPrivateFieldGet2(_tail, this).next = node;
822
- _classPrivateFieldSet2(_tail, this, node);
823
- } else {
824
- _classPrivateFieldSet2(_head, this, node);
825
- _classPrivateFieldSet2(_tail, this, node);
826
- }
827
- _classPrivateFieldSet2(_size, this, (_this$size = _classPrivateFieldGet2(_size, this), _this$size++, _this$size));
828
- }
829
- dequeue() {
830
- var _this$size3;
831
- const current = _classPrivateFieldGet2(_head, this);
832
- if (!current) return;
833
- _classPrivateFieldSet2(_head, this, _classPrivateFieldGet2(_head, this).next);
834
- _classPrivateFieldSet2(_size, this, (_this$size3 = _classPrivateFieldGet2(_size, this), _this$size3--, _this$size3));
835
- return current.value;
836
- }
837
- peek() {
838
- if (!_classPrivateFieldGet2(_head, this)) return;
839
- return _classPrivateFieldGet2(_head, this).value;
840
- }
841
- clear() {
842
- _classPrivateFieldSet2(_head, this, void 0);
843
- _classPrivateFieldSet2(_tail, this, void 0);
844
- _classPrivateFieldSet2(_size, this, 0);
845
- }
846
- get size() {
847
- return _classPrivateFieldGet2(_size, this);
848
- }
849
- *[_Symbol$iterator]() {
850
- let current = _classPrivateFieldGet2(_head, this);
851
- while (current) {
852
- yield current.value;
853
- current = current.next;
854
- }
855
- }
856
- *drain() {
857
- while (_classPrivateFieldGet2(_head, this)) yield this.dequeue();
858
- }
859
- };
860
- /**
861
- * Throttle execution of a function. Especially useful for rate limiting
862
- * execution of handlers on events like resize and scroll.
863
- *
864
- * @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher)
865
- * are most useful.
866
- * @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through,
867
- * as-is, to `callback` when the throttled-function is executed.
868
- * @param {object} [options] - An object to configure options.
869
- * @param {boolean} [options.noTrailing] - Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds
870
- * while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed
871
- * one final time after the last throttled-function call. (After the throttled-function has not been called for
872
- * `delay` milliseconds, the internal counter is reset).
873
- * @param {boolean} [options.noLeading] - Optional, defaults to false. If noLeading is false, the first throttled-function call will execute callback
874
- * immediately. If noLeading is true, the first the callback execution will be skipped. It should be noted that
875
- * callback will never executed if both noLeading = true and noTrailing = true.
876
- * @param {boolean} [options.debounceMode] - If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is
877
- * false (at end), schedule `callback` to execute after `delay` ms.
878
- *
879
- * @returns {Function} A new, throttled, function.
880
- */
881
- function throttle$1(delay, callback, options) {
882
- var _ref = options || {}, _ref$noTrailing = _ref.noTrailing, noTrailing = _ref$noTrailing === void 0 ? false : _ref$noTrailing, _ref$noLeading = _ref.noLeading, noLeading = _ref$noLeading === void 0 ? false : _ref$noLeading, _ref$debounceMode = _ref.debounceMode, debounceMode = _ref$debounceMode === void 0 ? void 0 : _ref$debounceMode;
883
- var timeoutID;
884
- var cancelled = false;
885
- var lastExec = 0;
886
- function clearExistingTimeout() {
887
- if (timeoutID) clearTimeout(timeoutID);
888
- }
889
- function cancel(options$1) {
890
- var _ref2$upcomingOnly = (options$1 || {}).upcomingOnly, upcomingOnly = _ref2$upcomingOnly === void 0 ? false : _ref2$upcomingOnly;
891
- clearExistingTimeout();
892
- cancelled = !upcomingOnly;
893
- }
894
- function wrapper() {
895
- for (var _len = arguments.length, arguments_ = new Array(_len), _key = 0; _key < _len; _key++) arguments_[_key] = arguments[_key];
896
- var self = this;
897
- var elapsed = Date.now() - lastExec;
898
- if (cancelled) return;
899
- function exec() {
900
- lastExec = Date.now();
901
- callback.apply(self, arguments_);
902
- }
903
- function clear() {
904
- timeoutID = void 0;
905
- }
906
- if (!noLeading && debounceMode && !timeoutID) exec();
907
- clearExistingTimeout();
908
- if (debounceMode === void 0 && elapsed > delay) if (noLeading) {
909
- lastExec = Date.now();
910
- if (!noTrailing) timeoutID = setTimeout(debounceMode ? clear : exec, delay);
911
- } else exec();
912
- else if (noTrailing !== true) timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === void 0 ? delay - elapsed : delay);
913
- }
914
- wrapper.cancel = cancel;
915
- return wrapper;
916
- }
917
- function throttle(...args) {
918
- return throttle$1(...args);
919
- }
920
-
921
- //#endregion
922
- //#region src/composables/use-math-renderer.ts
923
- function useMathRenderer(options) {
924
- const { installed, render: renderKatex } = useKatex();
925
- const renderFlag = ref(false);
926
- const renderingCode = ref("");
927
- const html = ref("");
928
- const errorMessage = ref("");
929
- const node = computed(() => unref(options.node));
930
- const katexOptions = computed(() => {
931
- var _unref;
932
- return ((_unref = unref(options.katexOptions)) === null || _unref === void 0 ? void 0 : _unref.config) ?? {};
933
- });
934
- const throttleTime = computed(() => unref(options.throttle) ?? 150);
935
- const code = computed(() => node.value.value);
936
- const loading = computed(() => node.value.loading);
937
- const isDisplayMode = computed(() => node.value.type !== "inlineMath");
938
- const error = computed(() => {
939
- if (!installed.value) return true;
940
- if (errorMessage.value && renderFlag.value && renderingCode.value === code.value) return true;
941
- return false;
942
- });
943
- watch(() => [code.value, loading.value], throttle(throttleTime, async () => {
944
- const { html: data, error: error$1 } = await renderKatex(code.value, {
945
- ...katexOptions,
946
- displayMode: isDisplayMode.value
947
- });
948
- renderFlag.value = true;
949
- if (data) {
950
- html.value = data;
951
- errorMessage.value = "";
952
- return;
953
- }
954
- if (error$1) errorMessage.value = error$1;
955
- else errorMessage.value = "";
956
- }), { immediate: true });
957
- return {
958
- html,
959
- error,
960
- errorMessage
961
- };
962
- }
963
-
964
- //#endregion
965
- //#region src/composables/use-medium-zoom.ts
966
- function useMediumZoom(options) {
967
- const margin = computed(() => unref(options.margin) ?? 0);
968
- const elementRef = ref();
969
- const clonedElementRef = ref();
970
- const zoomElementRef = ref();
971
- const isAnimating = ref(false);
972
- const showClonedElement = ref(false);
973
- const initialTransform = ref("");
974
- const targetTransform = ref("");
975
- const elementStyle = computed(() => {
976
- if (!isClient()) return { opacity: 1 };
977
- return { opacity: showClonedElement.value ? 0 : 1 };
978
- });
979
- function cloneElement() {
980
- const original = elementRef.value;
981
- if (!original) return;
982
- const cloned = original.cloneNode(true);
983
- const rect = original.getBoundingClientRect();
984
- cloned.style.position = "fixed";
985
- cloned.style.top = `${rect.top}px`;
986
- cloned.style.left = `${rect.left}px`;
987
- cloned.style.width = `${rect.width}px`;
988
- cloned.style.height = `${rect.height}px`;
989
- cloned.style.margin = "0";
990
- cloned.style.padding = "0";
991
- cloned.style.pointerEvents = "none";
992
- cloned.style.zIndex = "10000";
993
- cloned.style.willChange = "transform";
994
- cloned.style.transformOrigin = "top left";
995
- if (original instanceof HTMLImageElement && original.currentSrc) cloned.src = original.currentSrc;
996
- return cloned;
997
- }
998
- function calculateTransforms() {
999
- const original = elementRef.value;
1000
- if (!original || !clonedElementRef.value) return;
1001
- const rect = original.getBoundingClientRect();
1002
- const viewportWidth = window.innerWidth;
1003
- const viewportHeight = window.innerHeight;
1004
- const naturalWidth = original.naturalWidth || rect.width;
1005
- const naturalHeight = original.naturalHeight || rect.height;
1006
- const maxWidth = viewportWidth - margin.value * 2;
1007
- const maxHeight = viewportHeight - margin.value * 2;
1008
- const scaleX = Math.min(maxWidth / rect.width, naturalWidth / rect.width);
1009
- const scaleY = Math.min(maxHeight / rect.height, naturalHeight / rect.height);
1010
- const scale = Math.min(scaleX, scaleY, 1);
1011
- const targetX = (viewportWidth - rect.width * scale) / 2;
1012
- const targetY = (viewportHeight - rect.height * scale) / 2;
1013
- const translateX = targetX - rect.left;
1014
- const translateY = targetY - rect.top;
1015
- initialTransform.value = `translate3d(0, 0, 0) scale(1)`;
1016
- targetTransform.value = `translate3d(${translateX}px, ${translateY}px, 0) scale(${scale})`;
1017
- }
1018
- async function zoomIn() {
1019
- var _clonedElementRef$val, _options$open;
1020
- const el = elementRef.value;
1021
- if (!el) return;
1022
- const cloned = cloneElement();
1023
- if (!cloned) return;
1024
- el.style.visibility = "hidden";
1025
- document.body.appendChild(cloned);
1026
- clonedElementRef.value = cloned;
1027
- showClonedElement.value = true;
1028
- await nextTick();
1029
- calculateTransforms();
1030
- if (clonedElementRef.value) {
1031
- clonedElementRef.value.style.transform = initialTransform.value;
1032
- clonedElementRef.value.style.transition = "none";
1033
- }
1034
- (_clonedElementRef$val = clonedElementRef.value) === null || _clonedElementRef$val === void 0 || _clonedElementRef$val.offsetHeight;
1035
- await nextTick();
1036
- isAnimating.value = true;
1037
- if (clonedElementRef.value) {
1038
- clonedElementRef.value.style.transition = "transform 0.3s cubic-bezier(0.2, 0, 0.2, 1)";
1039
- clonedElementRef.value.style.transform = targetTransform.value;
1040
- }
1041
- (_options$open = options.open) === null || _options$open === void 0 || _options$open.call(options);
1042
- const handleAnimationEnd = () => {
1043
- isAnimating.value = false;
1044
- if (clonedElementRef.value) clonedElementRef.value.style.opacity = "0";
1045
- showClonedElement.value = false;
1046
- cloned.removeEventListener("transitionend", handleAnimationEnd);
1047
- };
1048
- cloned.addEventListener("transitionend", handleAnimationEnd, { once: true });
1049
- }
1050
- async function zoomOut() {
1051
- if (!clonedElementRef.value) {
1052
- var _options$close;
1053
- (_options$close = options.close) === null || _options$close === void 0 || _options$close.call(options);
1054
- return;
1055
- }
1056
- await nextTick();
1057
- showClonedElement.value = true;
1058
- if (clonedElementRef.value) clonedElementRef.value.style.opacity = "1";
1059
- await nextTick();
1060
- if (!clonedElementRef.value) return;
1061
- const el = elementRef.value;
1062
- const zoomEl = zoomElementRef.value;
1063
- if (!el || !zoomEl) return;
1064
- const originalRect = el.getBoundingClientRect();
1065
- const zoomRect = zoomEl.getBoundingClientRect();
1066
- const cloned = clonedElementRef.value;
1067
- const currentTransform = window.getComputedStyle(zoomEl).transform || "none";
1068
- const currentCenterX = zoomRect.left + zoomRect.width / 2;
1069
- const currentCenterY = zoomRect.top + zoomRect.height / 2;
1070
- const targetCenterX = originalRect.left + originalRect.width / 2;
1071
- const targetCenterY = originalRect.top + originalRect.height / 2;
1072
- const scale = Math.min(originalRect.width / zoomRect.width, originalRect.height / zoomRect.height);
1073
- cloned.style.top = `${zoomRect.top}px`;
1074
- cloned.style.left = `${zoomRect.left}px`;
1075
- cloned.style.width = `${zoomRect.width}px`;
1076
- cloned.style.height = `${zoomRect.height}px`;
1077
- cloned.style.transform = currentTransform !== "none" ? currentTransform : "translate3d(0, 0, 0) scale(1)";
1078
- cloned.style.transformOrigin = "center center";
1079
- cloned.style.transition = "none";
1080
- cloned.offsetHeight;
1081
- await nextTick();
1082
- isAnimating.value = true;
1083
- const translateX = targetCenterX - currentCenterX;
1084
- const translateY = targetCenterY - currentCenterY;
1085
- cloned.style.transition = "transform 0.3s cubic-bezier(0.2, 0, 0.2, 1)";
1086
- if (currentTransform !== "none") try {
1087
- const inverseMatrix = new DOMMatrix(currentTransform).inverse();
1088
- const transformedPoint = new DOMPoint(translateX, translateY).matrixTransform(inverseMatrix);
1089
- cloned.style.transform = `${currentTransform} translate3d(${transformedPoint.x}px, ${transformedPoint.y}px, 0) scale(${scale})`;
1090
- } catch {
1091
- cloned.style.transform = `${currentTransform} translate3d(${translateX}px, ${translateY}px, 0) scale(${scale})`;
1092
- }
1093
- else cloned.style.transform = `translate3d(${translateX}px, ${translateY}px, 0) scale(${scale})`;
1094
- const handleAnimationEnd = () => {
1095
- var _options$close2;
1096
- const cloned$1 = clonedElementRef.value;
1097
- if (cloned$1 && cloned$1.parentNode) cloned$1.parentNode.removeChild(cloned$1);
1098
- clonedElementRef.value = void 0;
1099
- if (elementRef.value) elementRef.value.style.visibility = "visible";
1100
- (_options$close2 = options.close) === null || _options$close2 === void 0 || _options$close2.call(options);
1101
- isAnimating.value = false;
1102
- showClonedElement.value = false;
1103
- };
1104
- cloned.addEventListener("transitionend", handleAnimationEnd, { once: true });
1105
- }
1106
- return {
1107
- isAnimating,
1108
- elementStyle,
1109
- elementRef,
1110
- zoomElementRef,
1111
- zoomIn,
1112
- zoomOut
1113
- };
1114
- }
1115
-
1116
- //#endregion
1117
- //#region src/composables/use-mermaid.ts
1118
- let mermaid = null;
1119
- function useMermaid(options) {
1120
- const installed = ref(false);
1121
- const mermaidConfig = computed(() => {
1122
- var _unref;
1123
- return ((_unref = unref(options === null || options === void 0 ? void 0 : options.mermaidOptions)) === null || _unref === void 0 ? void 0 : _unref.config) ?? {};
1124
- });
1125
- const mermaidTheme = computed(() => {
1126
- var _unref2;
1127
- return ((_unref2 = unref(options === null || options === void 0 ? void 0 : options.mermaidOptions)) === null || _unref2 === void 0 ? void 0 : _unref2.theme) ?? ["neutral", "dark"];
1128
- });
1129
- const isDark = computed(() => unref(options === null || options === void 0 ? void 0 : options.isDark) ?? false);
1130
- const lightTheme = computed(() => mermaidTheme.value[0] ?? "neutral");
1131
- const darkTheme = computed(() => mermaidTheme.value[1] ?? "dark");
1132
- const theme = computed(() => isDark.value ? darkTheme.value : lightTheme.value);
1133
- const chart = ref("");
1134
- async function getMermaid() {
1135
- if (mermaid) return mermaid;
1136
- const { default: module } = await import("mermaid");
1137
- module.initialize({
1138
- startOnLoad: false,
1139
- securityLevel: "loose",
1140
- ...mermaidConfig.value
1141
- });
1142
- mermaid = module;
1143
- return mermaid;
1144
- }
1145
- function wrapThemeCode(code) {
1146
- if (code.startsWith("%%{")) return code;
1147
- return `${`%%{init: {"theme": "${theme.value}"}}%%\n`}${code}`;
1148
- }
1149
- async function parseMermaid(code) {
1150
- try {
1151
- const mermaid$1 = await getMermaid();
1152
- chart.value = wrapThemeCode(code);
1153
- await mermaid$1.parse(chart.value);
1154
- return { valid: true };
1155
- } catch (error) {
1156
- return {
1157
- valid: false,
1158
- error: error instanceof Error ? error.message : String(error)
1159
- };
1160
- }
1161
- }
1162
- async function renderMermaid(code) {
1163
- const { valid, error } = await parseMermaid(code);
1164
- if (!valid || !isClient()) return {
1165
- error,
1166
- valid: false
1167
- };
1168
- const id = `mermaid-${randomStr()}`;
1169
- try {
1170
- return {
1171
- svg: (await (await getMermaid()).render(id, wrapThemeCode(code))).svg,
1172
- valid: true
1173
- };
1174
- } catch (error$1) {
1175
- const element = document.getElementById(`d${id}`);
1176
- if (element) element.remove();
1177
- return {
1178
- valid: false,
1179
- error: error$1 instanceof Error ? error$1.message : String(error$1)
1180
- };
1181
- }
1182
- }
1183
- async function saveMermaid(format, code = chart.value, onError) {
1184
- try {
1185
- const { svg } = await renderMermaid(code);
1186
- if (!svg) {
1187
- onError === null || onError === void 0 || onError(/* @__PURE__ */ new Error("SVG not found. Please wait for the diagram to render."));
1188
- return;
1189
- }
1190
- if (format === "svg") save("diagram.svg", svg, "image/svg+xml");
1191
- if (format === "png") {
1192
- const blob = await svgToPngBlob(svg);
1193
- if (blob) save("diagram.png", blob, "image/png");
1194
- }
1195
- } catch (error) {
1196
- onError === null || onError === void 0 || onError(error);
1197
- }
1198
- }
1199
- async function preload() {
1200
- if (mermaid) return;
1201
- installed.value = await hasMermaid();
1202
- if (installed.value) await getMermaid();
1203
- }
1204
- function dispose() {
1205
- chart.value = "";
1206
- }
1207
- if (isClient()) (async () => {
1208
- if (mermaid) {
1209
- installed.value = true;
1210
- return;
1211
- }
1212
- installed.value = await hasMermaid();
1213
- })();
1214
- return {
1215
- installed,
1216
- getMermaid,
1217
- parseMermaid,
1218
- renderMermaid,
1219
- saveMermaid,
1220
- preload,
1221
- dispose
1222
- };
1223
- }
1224
-
1225
- //#endregion
1226
- //#region src/constants/code.ts
1227
- const DEFAULT_LIGHT_THEME = "github-light";
1228
- const DEFAULT_DARK_THEME = "github-dark";
1229
- const LANGUAGE_ALIAS = {};
1230
- const LANGUAGE_EXTENSIONS = {
1231
- "1c-query": "1cq",
1232
- "1c": "1c",
1233
- "abap": "abap",
1234
- "actionscript-3": "as",
1235
- "ada": "ada",
1236
- "adoc": "adoc",
1237
- "angular-html": "html",
1238
- "angular-ts": "ts",
1239
- "apache": "conf",
1240
- "apex": "cls",
1241
- "apl": "apl",
1242
- "applescript": "applescript",
1243
- "ara": "ara",
1244
- "asciidoc": "adoc",
1245
- "asm": "asm",
1246
- "astro": "astro",
1247
- "awk": "awk",
1248
- "ballerina": "bal",
1249
- "bash": "sh",
1250
- "bat": "bat",
1251
- "batch": "bat",
1252
- "be": "be",
1253
- "beancount": "beancount",
1254
- "berry": "berry",
1255
- "bibtex": "bib",
1256
- "bicep": "bicep",
1257
- "blade": "blade.php",
1258
- "bsl": "bsl",
1259
- "c": "c",
1260
- "c#": "cs",
1261
- "c++": "cpp",
1262
- "cadence": "cdc",
1263
- "cairo": "cairo",
1264
- "cdc": "cdc",
1265
- "clarity": "clar",
1266
- "clj": "clj",
1267
- "clojure": "clj",
1268
- "closure-templates": "soy",
1269
- "cmake": "cmake",
1270
- "cmd": "cmd",
1271
- "cobol": "cob",
1272
- "codeowners": "CODEOWNERS",
1273
- "codeql": "ql",
1274
- "coffee": "coffee",
1275
- "coffeescript": "coffee",
1276
- "common-lisp": "lisp",
1277
- "console": "sh",
1278
- "coq": "v",
1279
- "cpp": "cpp",
1280
- "cql": "cql",
1281
- "crystal": "cr",
1282
- "cs": "cs",
1283
- "csharp": "cs",
1284
- "css": "css",
1285
- "csv": "csv",
1286
- "cue": "cue",
1287
- "cypher": "cql",
1288
- "d": "d",
1289
- "dart": "dart",
1290
- "dax": "dax",
1291
- "desktop": "desktop",
1292
- "diff": "diff",
1293
- "docker": "dockerfile",
1294
- "dockerfile": "dockerfile",
1295
- "dotenv": "env",
1296
- "dream-maker": "dm",
1297
- "edge": "edge",
1298
- "elisp": "el",
1299
- "elixir": "ex",
1300
- "elm": "elm",
1301
- "emacs-lisp": "el",
1302
- "erb": "erb",
1303
- "erl": "erl",
1304
- "erlang": "erl",
1305
- "f": "f",
1306
- "f#": "fs",
1307
- "f03": "f03",
1308
- "f08": "f08",
1309
- "f18": "f18",
1310
- "f77": "f77",
1311
- "f90": "f90",
1312
- "f95": "f95",
1313
- "fennel": "fnl",
1314
- "fish": "fish",
1315
- "fluent": "ftl",
1316
- "for": "for",
1317
- "fortran-fixed-form": "f",
1318
- "fortran-free-form": "f90",
1319
- "fs": "fs",
1320
- "fsharp": "fs",
1321
- "fsl": "fsl",
1322
- "ftl": "ftl",
1323
- "gdresource": "tres",
1324
- "gdscript": "gd",
1325
- "gdshader": "gdshader",
1326
- "genie": "gs",
1327
- "gherkin": "feature",
1328
- "git-commit": "gitcommit",
1329
- "git-rebase": "gitrebase",
1330
- "gjs": "js",
1331
- "gleam": "gleam",
1332
- "glimmer-js": "js",
1333
- "glimmer-ts": "ts",
1334
- "glsl": "glsl",
1335
- "gnuplot": "plt",
1336
- "go": "go",
1337
- "gql": "gql",
1338
- "graphql": "graphql",
1339
- "groovy": "groovy",
1340
- "gts": "gts",
1341
- "hack": "hack",
1342
- "haml": "haml",
1343
- "handlebars": "hbs",
1344
- "haskell": "hs",
1345
- "haxe": "hx",
1346
- "hbs": "hbs",
1347
- "hcl": "hcl",
1348
- "hjson": "hjson",
1349
- "hlsl": "hlsl",
1350
- "hs": "hs",
1351
- "html-derivative": "html",
1352
- "html": "html",
1353
- "http": "http",
1354
- "hxml": "hxml",
1355
- "hy": "hy",
1356
- "imba": "imba",
1357
- "ini": "ini",
1358
- "jade": "jade",
1359
- "java": "java",
1360
- "javascript": "js",
1361
- "jinja": "jinja",
1362
- "jison": "jison",
1363
- "jl": "jl",
1364
- "js": "js",
1365
- "json": "json",
1366
- "json5": "json5",
1367
- "jsonc": "jsonc",
1368
- "jsonl": "jsonl",
1369
- "jsonnet": "jsonnet",
1370
- "jssm": "jssm",
1371
- "jsx": "jsx",
1372
- "julia": "jl",
1373
- "kotlin": "kt",
1374
- "kql": "kql",
1375
- "kt": "kt",
1376
- "kts": "kts",
1377
- "kusto": "kql",
1378
- "latex": "tex",
1379
- "lean": "lean",
1380
- "lean4": "lean",
1381
- "less": "less",
1382
- "liquid": "liquid",
1383
- "lisp": "lisp",
1384
- "lit": "lit",
1385
- "llvm": "ll",
1386
- "log": "log",
1387
- "logo": "logo",
1388
- "lua": "lua",
1389
- "luau": "luau",
1390
- "make": "mak",
1391
- "makefile": "mak",
1392
- "markdown": "md",
1393
- "marko": "marko",
1394
- "matlab": "m",
1395
- "md": "md",
1396
- "mdc": "mdc",
1397
- "mdx": "mdx",
1398
- "mediawiki": "wiki",
1399
- "mermaid": "mmd",
1400
- "mips": "s",
1401
- "mipsasm": "s",
1402
- "mmd": "mmd",
1403
- "mojo": "mojo",
1404
- "move": "move",
1405
- "nar": "nar",
1406
- "narrat": "narrat",
1407
- "nextflow": "nf",
1408
- "nf": "nf",
1409
- "nginx": "conf",
1410
- "nim": "nim",
1411
- "nix": "nix",
1412
- "nu": "nu",
1413
- "nushell": "nu",
1414
- "objc": "m",
1415
- "objective-c": "m",
1416
- "objective-cpp": "mm",
1417
- "ocaml": "ml",
1418
- "pascal": "pas",
1419
- "perl": "pl",
1420
- "perl6": "p6",
1421
- "php": "php",
1422
- "plsql": "pls",
1423
- "po": "po",
1424
- "polar": "polar",
1425
- "postcss": "pcss",
1426
- "pot": "pot",
1427
- "potx": "potx",
1428
- "powerquery": "pq",
1429
- "powershell": "ps1",
1430
- "prisma": "prisma",
1431
- "prolog": "pl",
1432
- "properties": "properties",
1433
- "proto": "proto",
1434
- "protobuf": "proto",
1435
- "ps": "ps",
1436
- "ps1": "ps1",
1437
- "pug": "pug",
1438
- "puppet": "pp",
1439
- "purescript": "purs",
1440
- "py": "py",
1441
- "python": "py",
1442
- "ql": "ql",
1443
- "qml": "qml",
1444
- "qmldir": "qmldir",
1445
- "qss": "qss",
1446
- "r": "r",
1447
- "racket": "rkt",
1448
- "raku": "raku",
1449
- "razor": "cshtml",
1450
- "rb": "rb",
1451
- "reg": "reg",
1452
- "regex": "regex",
1453
- "regexp": "regexp",
1454
- "rel": "rel",
1455
- "riscv": "s",
1456
- "rs": "rs",
1457
- "rst": "rst",
1458
- "ruby": "rb",
1459
- "rust": "rs",
1460
- "sas": "sas",
1461
- "sass": "sass",
1462
- "scala": "scala",
1463
- "scheme": "scm",
1464
- "scss": "scss",
1465
- "sdbl": "sdbl",
1466
- "sh": "sh",
1467
- "shader": "shader",
1468
- "shaderlab": "shader",
1469
- "shell": "sh",
1470
- "shellscript": "sh",
1471
- "shellsession": "sh",
1472
- "smalltalk": "st",
1473
- "solidity": "sol",
1474
- "soy": "soy",
1475
- "sparql": "rq",
1476
- "spl": "spl",
1477
- "splunk": "spl",
1478
- "sql": "sql",
1479
- "ssh-config": "config",
1480
- "stata": "do",
1481
- "styl": "styl",
1482
- "stylus": "styl",
1483
- "svelte": "svelte",
1484
- "swift": "swift",
1485
- "system-verilog": "sv",
1486
- "systemd": "service",
1487
- "talon": "talon",
1488
- "talonscript": "talon",
1489
- "tasl": "tasl",
1490
- "tcl": "tcl",
1491
- "templ": "templ",
1492
- "terraform": "tf",
1493
- "tex": "tex",
1494
- "tf": "tf",
1495
- "tfvars": "tfvars",
1496
- "toml": "toml",
1497
- "ts-tags": "ts",
1498
- "ts": "ts",
1499
- "tsp": "tsp",
1500
- "tsv": "tsv",
1501
- "tsx": "tsx",
1502
- "turtle": "ttl",
1503
- "twig": "twig",
1504
- "typ": "typ",
1505
- "typescript": "ts",
1506
- "typespec": "tsp",
1507
- "typst": "typ",
1508
- "v": "v",
1509
- "vala": "vala",
1510
- "vb": "vb",
1511
- "verilog": "v",
1512
- "vhdl": "vhdl",
1513
- "vim": "vim",
1514
- "viml": "vim",
1515
- "vimscript": "vim",
1516
- "vue-html": "html",
1517
- "vue-vine": "vine",
1518
- "vue": "vue",
1519
- "vy": "vy",
1520
- "vyper": "vy",
1521
- "wasm": "wasm",
1522
- "wenyan": "wy",
1523
- "wgsl": "wgsl",
1524
- "wiki": "wiki",
1525
- "wikitext": "wiki",
1526
- "wit": "wit",
1527
- "wl": "wl",
1528
- "wolfram": "wl",
1529
- "xml": "xml",
1530
- "xsl": "xsl",
1531
- "yaml": "yaml",
1532
- "yml": "yml",
1533
- "zenscript": "zs",
1534
- "zig": "zig",
1535
- "zsh": "zsh",
1536
- "文言": "wy"
1537
- };
1538
- const LANGUAGE_ICONS = {
1539
- "adoc": defineAsyncComponent(() => import("./asciidoc-BhsFgAwp.js")),
1540
- "angular-html": defineAsyncComponent(() => import("./angular-BhTq4eiQ.js")),
1541
- "angular-ts": defineAsyncComponent(() => import("./angular-component-Ba6hb3Ou.js")),
1542
- "apache": defineAsyncComponent(() => import("./apache-D-wFNTKM.js")),
1543
- "asciidoc": defineAsyncComponent(() => import("./asciidoc-BhsFgAwp.js")),
1544
- "asm": defineAsyncComponent(() => import("./assembly-DujbfxwO.js")),
1545
- "astro": defineAsyncComponent(() => import("./astro-By5aMeAI.js")),
1546
- "bash": defineAsyncComponent(() => import("./bash-CxLhFc8T.js")),
1547
- "bat": defineAsyncComponent(() => import("./batch-D2KCChyX.js")),
1548
- "batch": defineAsyncComponent(() => import("./batch-D2KCChyX.js")),
1549
- "bicep": defineAsyncComponent(() => import("./bicep-BpMR7zbS.js")),
1550
- "c": defineAsyncComponent(() => import("./c-BL0h9qSZ.js")),
1551
- "c#": defineAsyncComponent(() => import("./csharp-B0k7ij_8.js")),
1552
- "c++": defineAsyncComponent(() => import("./cpp-BFHQMV1Y.js")),
1553
- "cjs": defineAsyncComponent(() => import("./javascript-CgYlNrc3.js")),
1554
- "clj": defineAsyncComponent(() => import("./clojure-CIlREuXX.js")),
1555
- "clojure": defineAsyncComponent(() => import("./clojure-CIlREuXX.js")),
1556
- "cmake": defineAsyncComponent(() => import("./cmake-C1NQwzHz.js")),
1557
- "cmd": defineAsyncComponent(() => import("./batch-D2KCChyX.js")),
1558
- "cobol": defineAsyncComponent(() => import("./cobol-BSROkBc2.js")),
1559
- "codeowners": defineAsyncComponent(() => import("./codeowners-ByOcyZxj.js")),
1560
- "coffee": defineAsyncComponent(() => import("./coffeescript-LQTFO7bN.js")),
1561
- "coffeescript": defineAsyncComponent(() => import("./coffeescript-LQTFO7bN.js")),
1562
- "cpp": defineAsyncComponent(() => import("./cpp-BFHQMV1Y.js")),
1563
- "crystal": defineAsyncComponent(() => import("./crystal-DCVN-7Od.js")),
1564
- "cs": defineAsyncComponent(() => import("./csharp-B0k7ij_8.js")),
1565
- "csharp": defineAsyncComponent(() => import("./csharp-B0k7ij_8.js")),
1566
- "css": defineAsyncComponent(() => import("./css-CC5BGj0-.js")),
1567
- "csv": defineAsyncComponent(() => import("./csv-B5a7HayX.js")),
1568
- "cts": defineAsyncComponent(() => import("./typescript-oV84jXPW.js")),
1569
- "cue": defineAsyncComponent(() => import("./cue-CGNrDM1A.js")),
1570
- "d": defineAsyncComponent(() => import("./d-CMJdAMFb.js")),
1571
- "dart": defineAsyncComponent(() => import("./dart-BBqW-Fvj.js")),
1572
- "diff": defineAsyncComponent(() => import("./diff-UhwhR0nf.js")),
1573
- "docker": defineAsyncComponent(() => import("./docker-CaBsFwYx.js")),
1574
- "dockerfile": defineAsyncComponent(() => import("./docker-CaBsFwYx.js")),
1575
- "dotenv": defineAsyncComponent(() => import("./env-CKkm6DtJ.js")),
1576
- "elixir": defineAsyncComponent(() => import("./elixir-NvxbJYKg.js")),
1577
- "elm": defineAsyncComponent(() => import("./elm-BNn2zGko.js")),
1578
- "erb": defineAsyncComponent(() => import("./ruby-CgygvN8C.js")),
1579
- "erl": defineAsyncComponent(() => import("./erlang-DnQ1MXEC.js")),
1580
- "erlang": defineAsyncComponent(() => import("./erlang-DnQ1MXEC.js")),
1581
- "f": defineAsyncComponent(() => import("./fortran-D7C8ntBV.js")),
1582
- "f#": defineAsyncComponent(() => import("./fsharp-B2meisDr.js")),
1583
- "f03": defineAsyncComponent(() => import("./fortran-D7C8ntBV.js")),
1584
- "f08": defineAsyncComponent(() => import("./fortran-D7C8ntBV.js")),
1585
- "f18": defineAsyncComponent(() => import("./fortran-D7C8ntBV.js")),
1586
- "f77": defineAsyncComponent(() => import("./fortran-D7C8ntBV.js")),
1587
- "f90": defineAsyncComponent(() => import("./fortran-D7C8ntBV.js")),
1588
- "f95": defineAsyncComponent(() => import("./fortran-D7C8ntBV.js")),
1589
- "for": defineAsyncComponent(() => import("./fortran-D7C8ntBV.js")),
1590
- "fortran-fixed-form": defineAsyncComponent(() => import("./fortran-D7C8ntBV.js")),
1591
- "fortran-free-form": defineAsyncComponent(() => import("./fortran-D7C8ntBV.js")),
1592
- "fs": defineAsyncComponent(() => import("./fsharp-B2meisDr.js")),
1593
- "fsharp": defineAsyncComponent(() => import("./fsharp-B2meisDr.js")),
1594
- "git-commit": defineAsyncComponent(() => import("./git-Dibise41.js")),
1595
- "git-rebase": defineAsyncComponent(() => import("./git-Dibise41.js")),
1596
- "gleam": defineAsyncComponent(() => import("./gleam-DghqX0MW.js")),
1597
- "go": defineAsyncComponent(() => import("./go-hIgDRVGB.js")),
1598
- "gql": defineAsyncComponent(() => import("./graphql-Cwvddao6.js")),
1599
- "graphql": defineAsyncComponent(() => import("./graphql-Cwvddao6.js")),
1600
- "groovy": defineAsyncComponent(() => import("./groovy-Z_peiWRr.js")),
1601
- "haml": defineAsyncComponent(() => import("./haml-CK7X58Ac.js")),
1602
- "handlebars": defineAsyncComponent(() => import("./handlebars-CzXueKIL.js")),
1603
- "haskell": defineAsyncComponent(() => import("./haskell-F8Hxt60K.js")),
1604
- "haxe": defineAsyncComponent(() => import("./haxe-rnsd_VXm.js")),
1605
- "hbs": defineAsyncComponent(() => import("./handlebars-CzXueKIL.js")),
1606
- "hs": defineAsyncComponent(() => import("./haskell-F8Hxt60K.js")),
1607
- "html": defineAsyncComponent(() => import("./html-B-vufMHC.js")),
1608
- "http": defineAsyncComponent(() => import("./http-D-fTarEG.js")),
1609
- "jade": defineAsyncComponent(() => import("./pug-DuDhqAK0.js")),
1610
- "java": defineAsyncComponent(() => import("./java-BhCbKSsp.js")),
1611
- "javascript": defineAsyncComponent(() => import("./javascript-CgYlNrc3.js")),
1612
- "jinja": defineAsyncComponent(() => import("./jinja-BwhD62Ck.js")),
1613
- "jl": defineAsyncComponent(() => import("./julia-K2FP98rH.js")),
1614
- "js": defineAsyncComponent(() => import("./javascript-CgYlNrc3.js")),
1615
- "json": defineAsyncComponent(() => import("./json-BITBW2a3.js")),
1616
- "json5": defineAsyncComponent(() => import("./json-BITBW2a3.js")),
1617
- "jsonc": defineAsyncComponent(() => import("./json-BITBW2a3.js")),
1618
- "jsonl": defineAsyncComponent(() => import("./json-BITBW2a3.js")),
1619
- "jsx": defineAsyncComponent(() => import("./javascript-CgYlNrc3.js")),
1620
- "julia": defineAsyncComponent(() => import("./julia-K2FP98rH.js")),
1621
- "kdl": defineAsyncComponent(() => import("./kdl-wzDw_Xgt.js")),
1622
- "kotlin": defineAsyncComponent(() => import("./kotlin-UdhiRb2s.js")),
1623
- "kt": defineAsyncComponent(() => import("./kotlin-UdhiRb2s.js")),
1624
- "kts": defineAsyncComponent(() => import("./kotlin-UdhiRb2s.js")),
1625
- "latex": defineAsyncComponent(() => import("./latex-Cg4biTsQ.js")),
1626
- "less": defineAsyncComponent(() => import("./less-CvaKAB1v.js")),
1627
- "liquid": defineAsyncComponent(() => import("./liquid-DnaYJvE6.js")),
1628
- "lisp": defineAsyncComponent(() => import("./lisp-Dxh5WGkj.js")),
1629
- "log": defineAsyncComponent(() => import("./log-CptO9Lr8.js")),
1630
- "lua": defineAsyncComponent(() => import("./lua-BYE-WkAz.js")),
1631
- "luau": defineAsyncComponent(() => import("./luau-9_yNlfJT.js")),
1632
- "make": defineAsyncComponent(() => import("./makefile-B7idP48b.js")),
1633
- "makefile": defineAsyncComponent(() => import("./makefile-B7idP48b.js")),
1634
- "markdown": defineAsyncComponent(() => import("./markdown-CF1aOY6A.js")),
1635
- "marko": defineAsyncComponent(() => import("./marko-B96CKJZY.js")),
1636
- "matlab": defineAsyncComponent(() => import("./matlab-LSvZWs6_.js")),
1637
- "md": defineAsyncComponent(() => import("./markdown-CF1aOY6A.js")),
1638
- "mdc": defineAsyncComponent(() => import("./markdown-CF1aOY6A.js")),
1639
- "mdx": defineAsyncComponent(() => import("./markdown-CF1aOY6A.js")),
1640
- "mermaid": defineAsyncComponent(() => import("./mermaid-CjPc_PTq.js")),
1641
- "mjs": defineAsyncComponent(() => import("./javascript-CgYlNrc3.js")),
1642
- "mmd": defineAsyncComponent(() => import("./mermaid-CjPc_PTq.js")),
1643
- "mts": defineAsyncComponent(() => import("./typescript-oV84jXPW.js")),
1644
- "nextflow": defineAsyncComponent(() => import("./nextflow-Di2JOuIQ.js")),
1645
- "nf": defineAsyncComponent(() => import("./nextflow-Di2JOuIQ.js")),
1646
- "nginx": defineAsyncComponent(() => import("./nginx-DwP-rcfw.js")),
1647
- "nim": defineAsyncComponent(() => import("./nim-B8CTKDeR.js")),
1648
- "nix": defineAsyncComponent(() => import("./nix-DzZgDL2a.js")),
1649
- "ocaml": defineAsyncComponent(() => import("./ocaml-Bs_vWDxp.js")),
1650
- "perl": defineAsyncComponent(() => import("./perl-BvEAb2FB.js")),
1651
- "php": defineAsyncComponent(() => import("./php-DJ6oc5J7.js")),
1652
- "postcss": defineAsyncComponent(() => import("./postcss-Buy79gTC.js")),
1653
- "powershell": defineAsyncComponent(() => import("./powershell-xWtLU9gf.js")),
1654
- "prisma": defineAsyncComponent(() => import("./prisma-_Jw8lmC9.js")),
1655
- "prolog": defineAsyncComponent(() => import("./prolog-CXJiBRKn.js")),
1656
- "properties": defineAsyncComponent(() => import("./properties-bV3eZsxi.js")),
1657
- "proto": defineAsyncComponent(() => import("./proto-CdPPb7qQ.js")),
1658
- "protobuf": defineAsyncComponent(() => import("./proto-CdPPb7qQ.js")),
1659
- "ps": defineAsyncComponent(() => import("./powershell-xWtLU9gf.js")),
1660
- "ps1": defineAsyncComponent(() => import("./powershell-xWtLU9gf.js")),
1661
- "pug": defineAsyncComponent(() => import("./pug-DuDhqAK0.js")),
1662
- "puppet": defineAsyncComponent(() => import("./puppet-BznIc6wm.js")),
1663
- "py": defineAsyncComponent(() => import("./python-1saA982A.js")),
1664
- "python": defineAsyncComponent(() => import("./python-1saA982A.js")),
1665
- "r": defineAsyncComponent(() => import("./r-C94u3fL1.js")),
1666
- "racket": defineAsyncComponent(() => import("./racket-CJXkPHdl.js")),
1667
- "razor": defineAsyncComponent(() => import("./razor-NEi8COml.js")),
1668
- "rb": defineAsyncComponent(() => import("./ruby-CgygvN8C.js")),
1669
- "rs": defineAsyncComponent(() => import("./rust-DQacYSAC.js")),
1670
- "ruby": defineAsyncComponent(() => import("./ruby-CgygvN8C.js")),
1671
- "rust": defineAsyncComponent(() => import("./rust-DQacYSAC.js")),
1672
- "sass": defineAsyncComponent(() => import("./sass-HD_VNbVH.js")),
1673
- "scala": defineAsyncComponent(() => import("./scala-DFCCsRj5.js")),
1674
- "scheme": defineAsyncComponent(() => import("./scheme-CMuWDKun.js")),
1675
- "scss": defineAsyncComponent(() => import("./sass-HD_VNbVH.js")),
1676
- "sh": defineAsyncComponent(() => import("./bash-CxLhFc8T.js")),
1677
- "shader": defineAsyncComponent(() => import("./shader-CJxZVwVX.js")),
1678
- "shell": defineAsyncComponent(() => import("./bash-CxLhFc8T.js")),
1679
- "shellscript": defineAsyncComponent(() => import("./bash-CxLhFc8T.js")),
1680
- "solidity": defineAsyncComponent(() => import("./solidity-CZfwNrv_.js")),
1681
- "sql": defineAsyncComponent(() => import("./database-LuWYzgPI.js")),
1682
- "stata": defineAsyncComponent(() => import("./stata-DLyUE6pK.js")),
1683
- "styl": defineAsyncComponent(() => import("./sass-HD_VNbVH.js")),
1684
- "stylus": defineAsyncComponent(() => import("./sass-HD_VNbVH.js")),
1685
- "svelte": defineAsyncComponent(() => import("./svelte-D3v3JUId.js")),
1686
- "swift": defineAsyncComponent(() => import("./swift-BuLBBeAo.js")),
1687
- "terraform": defineAsyncComponent(() => import("./terraform-BpdftQxe.js")),
1688
- "tex": defineAsyncComponent(() => import("./latex-Cg4biTsQ.js")),
1689
- "text": defineAsyncComponent(() => import("./text-CVjFFVPk.js")),
1690
- "tf": defineAsyncComponent(() => import("./terraform-BpdftQxe.js")),
1691
- "tfvars": defineAsyncComponent(() => import("./terraform-BpdftQxe.js")),
1692
- "toml": defineAsyncComponent(() => import("./toml-DwuHYrJF.js")),
1693
- "ts": defineAsyncComponent(() => import("./typescript-oV84jXPW.js")),
1694
- "tsv": defineAsyncComponent(() => import("./csv-B5a7HayX.js")),
1695
- "tsx": defineAsyncComponent(() => import("./typescript-oV84jXPW.js")),
1696
- "twig": defineAsyncComponent(() => import("./twig-C3W2hNMC.js")),
1697
- "typ": defineAsyncComponent(() => import("./typst-iMKBhjQc.js")),
1698
- "typescript": defineAsyncComponent(() => import("./typescript-oV84jXPW.js")),
1699
- "typst": defineAsyncComponent(() => import("./typst-iMKBhjQc.js")),
1700
- "v": defineAsyncComponent(() => import("./v-D8a-2CMq.js")),
1701
- "vala": defineAsyncComponent(() => import("./vala-Dnxzb4xr.js")),
1702
- "verilog": defineAsyncComponent(() => import("./verilog-CABQqn01.js")),
1703
- "vim": defineAsyncComponent(() => import("./vim-BGlWyvYm.js")),
1704
- "viml": defineAsyncComponent(() => import("./vim-BGlWyvYm.js")),
1705
- "vimscript": defineAsyncComponent(() => import("./vim-BGlWyvYm.js")),
1706
- "vue-html": defineAsyncComponent(() => import("./vue-D6HdD2dj.js")),
1707
- "vue-vine": defineAsyncComponent(() => import("./vue-D6HdD2dj.js")),
1708
- "vue": defineAsyncComponent(() => import("./vue-D6HdD2dj.js")),
1709
- "xml": defineAsyncComponent(() => import("./xml-B9NfR4AN.js")),
1710
- "xsl": defineAsyncComponent(() => import("./xml-B9NfR4AN.js")),
1711
- "yaml": defineAsyncComponent(() => import("./yaml-CrFdGZgo.js")),
1712
- "yml": defineAsyncComponent(() => import("./yaml-CrFdGZgo.js")),
1713
- "zig": defineAsyncComponent(() => import("./zig-BYI6J86j.js")),
1714
- "zsh": defineAsyncComponent(() => import("./bash-CxLhFc8T.js"))
1715
- };
1716
-
1717
- //#endregion
1718
- //#region src/constants/harden.ts
1719
- const DEFAULT_HARDEN_OPTIONS = {
1720
- allowedLinkPrefixes: ["*"],
1721
- allowedImagePrefixes: ["*"],
1722
- allowedProtocols: ["*"],
1723
- allowDataImages: true
1724
- };
1725
-
1726
- //#endregion
1727
- //#region src/constants/icons.ts
1728
- const ICONS = {
1729
- arrowLeft: defineAsyncComponent(() => import("./arrow-left-Fc4I-KPU.js")),
1730
- check: defineAsyncComponent(() => import("./check-DUf_EYGI.js")),
1731
- code: defineAsyncComponent(() => import("./code-jkFGYUqR.js")),
1732
- collapse: defineAsyncComponent(() => import("./chevron-down-Bd8OWcQz.js")),
1733
- copy: defineAsyncComponent(() => import("./copy-CLBkFmXf.js")),
1734
- cornerDownLeft: defineAsyncComponent(() => import("./corner-down-left-CMgnqWC_.js")),
1735
- download: defineAsyncComponent(() => import("./download-DtpBCWCq.js")),
1736
- error: defineAsyncComponent(() => import("./circle-alert-C3xlkKpn.js")),
1737
- flipHorizontal: defineAsyncComponent(() => import("./flip-horizontal-14eeKks-.js")),
1738
- image: defineAsyncComponent(() => import("./image-BnP_94aa.js")),
1739
- link: defineAsyncComponent(() => import("./link-C8MvJEtb.js")),
1740
- maximize: defineAsyncComponent(() => import("./maximize-BYf7n_fw.js")),
1741
- mermaid: defineAsyncComponent(() => import("./mermaid-CjPc_PTq.js")),
1742
- minimize: defineAsyncComponent(() => import("./minimize-DUcEsZ0x.js")),
1743
- preview: defineAsyncComponent(() => import("./eye-g-R6YkP9.js")),
1744
- rotateLeft: defineAsyncComponent(() => import("./rotate-ccw-square-BJ_A0rAa.js")),
1745
- zoomIn: defineAsyncComponent(() => import("./zoomIn-B7_XWmXc.js")),
1746
- zoomOut: defineAsyncComponent(() => import("./zoomOut-CMmvbGLb.js"))
1747
- };
1748
-
1749
- //#endregion
1750
- //#region src/constants/preload.ts
1751
- const PRELOAD_NODE_RENDERER = [
1752
- "blockquote",
1753
- "delete",
1754
- "emphasis",
1755
- "footnoteDefinition",
1756
- "footnoteReference",
1757
- "heading",
1758
- "image",
1759
- "inlineCode",
1760
- "inlineMath",
1761
- "link",
1762
- "list",
1763
- "listItem",
1764
- "paragraph",
1765
- "strong",
1766
- "table",
1767
- "text",
1768
- "thematicBreak",
1769
- "yaml"
1770
- ];
1771
-
1772
- //#endregion
1773
- //#region src/constants/theme.ts
1774
- const SHADCN_SCHEMAS = [
1775
- "background",
1776
- "foreground",
1777
- "card",
1778
- "card-foreground",
1779
- "popover",
1780
- "popover-foreground",
1781
- "primary",
1782
- "primary-foreground",
1783
- "secondary",
1784
- "secondary-foreground",
1785
- "muted",
1786
- "muted-foreground",
1787
- "accent",
1788
- "accent-foreground",
1789
- "destructive",
1790
- "border",
1791
- "input",
1792
- "ring",
1793
- "chart-1",
1794
- "chart-2",
1795
- "chart-3",
1796
- "chart-4",
1797
- "chart-5",
1798
- "sidebar",
1799
- "sidebar-foreground",
1800
- "sidebar-primary",
1801
- "sidebar-primary-foreground",
1802
- "sidebar-accent",
1803
- "sidebar-accent-foreground",
1804
- "sidebar-border",
1805
- "sidebar-ring"
1806
- ];
1807
-
1808
- //#endregion
1809
- //#region src/composables/use-sanitizers.ts
1810
- function useSanitizers(options) {
1811
- const hardenOptions = computed(() => unref(options.hardenOptions) ?? DEFAULT_HARDEN_OPTIONS);
1812
- const loading = computed(() => unref(options.loading) ?? false);
1813
- const allowedLinkPrefixes = computed(() => hardenOptions.value.allowedLinkPrefixes ?? ["*"]);
1814
- const allowedImagePrefixes = computed(() => hardenOptions.value.allowedImagePrefixes ?? ["*"]);
1815
- const allowedProtocols = computed(() => hardenOptions.value.allowedProtocols ?? ["*"]);
1816
- const allowDataImages = computed(() => hardenOptions.value.allowDataImages ?? true);
1817
- const defaultOrigin = computed(() => hardenOptions.value.defaultOrigin ?? "");
1818
- const isImage = computed(() => unref(options.isImage) ?? false);
1819
- const url = computed(() => unref(options.url) ?? "");
1820
- const transformedUrl = computed(() => transformHardenUrl(url.value));
1821
- const isHardenUrl = computed(() => transformedUrl.value === null);
1822
- function transformHardenUrl(url$1) {
1823
- if (!url$1 || loading.value) return url$1;
1824
- return transformUrl(url$1, isImage.value ? allowedImagePrefixes.value : allowedLinkPrefixes.value, defaultOrigin.value, allowDataImages.value, isImage.value, allowedProtocols.value);
1825
- }
1826
- return {
1827
- hardenOptions,
1828
- transformHardenUrl,
1829
- transformedUrl,
1830
- isHardenUrl
1831
- };
1832
- }
1833
-
1834
- //#endregion
1835
- //#region src/composables/use-shiki.ts
1836
- let highlighter = null;
1837
- let createHighlighterPromise = null;
1838
- function useShiki(options) {
1839
- const installed = ref(false);
1840
- const lang = computed(() => unref(options === null || options === void 0 ? void 0 : options.lang) ?? "plaintext");
1841
- const shikiTheme = computed(() => {
1842
- var _unref;
1843
- return ((_unref = unref(options === null || options === void 0 ? void 0 : options.shikiOptions)) === null || _unref === void 0 ? void 0 : _unref.theme) ?? [DEFAULT_LIGHT_THEME, DEFAULT_DARK_THEME];
1844
- });
1845
- const lightTheme = computed(() => shikiTheme.value[0] ?? DEFAULT_LIGHT_THEME);
1846
- const darkTheme = computed(() => shikiTheme.value[1] ?? DEFAULT_DARK_THEME);
1847
- const langs = computed(() => {
1848
- var _unref2;
1849
- return ((_unref2 = unref(options === null || options === void 0 ? void 0 : options.shikiOptions)) === null || _unref2 === void 0 ? void 0 : _unref2.langs) ?? [];
1850
- });
1851
- const langAlias = computed(() => {
1852
- var _unref3;
1853
- const data = ((_unref3 = unref(options === null || options === void 0 ? void 0 : options.shikiOptions)) === null || _unref3 === void 0 ? void 0 : _unref3.langAlias) ?? {};
1854
- return {
1855
- ...LANGUAGE_ALIAS,
1856
- ...data
1857
- };
1858
- });
1859
- const codeToTokenOptions = computed(() => {
1860
- var _unref4;
1861
- return ((_unref4 = unref(options === null || options === void 0 ? void 0 : options.shikiOptions)) === null || _unref4 === void 0 ? void 0 : _unref4.codeToTokenOptions) ?? {};
1862
- });
1863
- const isDark = computed(() => unref(options === null || options === void 0 ? void 0 : options.isDark) ?? false);
1864
- async function getThemes() {
1865
- const { bundledThemesInfo } = await import("shiki");
1866
- return [lightTheme.value, darkTheme.value].filter((theme) => bundledThemesInfo.find((t) => t.id === theme));
1867
- }
1868
- async function getTheme() {
1869
- const { bundledThemesInfo } = await import("shiki");
1870
- const theme = bundledThemesInfo.find((t) => t.id === (isDark.value ? darkTheme.value : lightTheme.value));
1871
- if (!theme) return isDark.value ? DEFAULT_DARK_THEME : DEFAULT_LIGHT_THEME;
1872
- return theme.id;
1873
- }
1874
- async function getLanguage() {
1875
- if (langAlias.value[lang.value]) return langAlias.value[lang.value];
1876
- const { bundledLanguagesInfo } = await import("shiki");
1877
- const language = bundledLanguagesInfo.find((l) => {
1878
- var _l$aliases;
1879
- return l.id === lang.value || ((_l$aliases = l.aliases) === null || _l$aliases === void 0 ? void 0 : _l$aliases.includes(lang.value));
1880
- });
1881
- if (language) return language.id;
1882
- return "plaintext";
1883
- }
1884
- async function getHighlighter() {
1885
- if (createHighlighterPromise) {
1886
- highlighter = await createHighlighterPromise;
1887
- createHighlighterPromise = null;
1888
- }
1889
- if (highlighter) {
1890
- const loadedLangs = highlighter.getLoadedLanguages();
1891
- const loadedThemes = highlighter.getLoadedThemes();
1892
- const language = await getLanguage();
1893
- const themes = await getThemes();
1894
- if (!loadedLangs.includes(language)) await highlighter.loadLanguage(language);
1895
- for (const theme of themes) if (!loadedThemes.includes(theme)) await highlighter.loadTheme(theme);
1896
- return highlighter;
1897
- }
1898
- createHighlighterPromise = (async () => {
1899
- const { createHighlighter } = await import("shiki");
1900
- return createHighlighter({
1901
- themes: [await getTheme()],
1902
- langs: langs.value,
1903
- langAlias: langAlias.value
1904
- });
1905
- })();
1906
- highlighter = await createHighlighterPromise;
1907
- createHighlighterPromise = null;
1908
- return highlighter;
1909
- }
1910
- async function codeToTokens(code) {
1911
- return (await getHighlighter()).codeToTokens(code, {
1912
- theme: await getTheme(),
1913
- lang: await getLanguage(),
1914
- ...codeToTokenOptions.value
1915
- });
1916
- }
1917
- async function preload() {
1918
- if (highlighter) return;
1919
- installed.value = await hasShiki();
1920
- if (installed.value) await getHighlighter();
1921
- }
1922
- function dispose() {
1923
- highlighter === null || highlighter === void 0 || highlighter.dispose();
1924
- highlighter = null;
1925
- }
1926
- if (isClient()) (async () => {
1927
- if (highlighter) {
1928
- installed.value = true;
1929
- return;
1930
- }
1931
- installed.value = await hasShiki();
1932
- })();
1933
- return {
1934
- installed,
1935
- getHighlighter,
1936
- codeToTokens,
1937
- preload,
1938
- dispose
1939
- };
1940
- }
1941
-
1942
- //#endregion
1943
- //#region src/composables/use-tailwind-v3-theme.ts
1944
- const reg = /^(?:hsl|rgb|oklch|lab|lch)\(/;
1945
- function useTailwindV3Theme(options) {
1946
- const { id, css, load, unload, isLoaded } = useStyleTag("", {
1947
- id: "stream-markdown-tailwind-v3-theme",
1948
- immediate: false
1949
- });
1950
- const styleScope = computed(() => {
1951
- const scope = unref(options.styleScope);
1952
- if (!scope) return [".stream-markdown", ".stream-markdown-overlay"];
1953
- return Array.isArray(scope) ? scope : [scope];
1954
- });
1955
- const element = computed(() => {
1956
- return toValue(options.element) || (isClient() ? document.body : void 0);
1957
- });
1958
- function generateCSS() {
1959
- if (!element.value || !isClient()) return;
1960
- const computedStyle = window.getComputedStyle(element.value);
1961
- const cssVariables = [];
1962
- for (const schema of SHADCN_SCHEMAS) {
1963
- const name = `--${schema}`;
1964
- const value = computedStyle.getPropertyValue(name).trim();
1965
- if (value && !reg.test(value)) cssVariables.push(` ${name}: hsl(${value});`);
1966
- }
1967
- if (cssVariables.length > 0) {
1968
- css.value = styleScope.value.map((scope) => `${scope} {\n${cssVariables.join("\n")}\n}`).join("\n");
1969
- load();
1970
- } else {
1971
- css.value = "";
1972
- unload();
1973
- }
1974
- }
1975
- watchEffect(generateCSS);
1976
- onBeforeUnmount(unload);
1977
- return {
1978
- element,
1979
- id,
1980
- css,
1981
- load,
1982
- unload,
1983
- isLoaded,
1984
- generateCSS
1985
- };
1986
- }
1987
-
1988
- //#endregion
1989
- //#region src/composables/use-zoom.ts
1990
- function useZoom(options = {}) {
1991
- const { minZoom = .5, maxZoom = 3, zoomStep = .1, wheelSensitivity = .01, initialZoom = 1, initialTranslateX = 0, initialTranslateY = 0 } = options;
1992
- const zoom = ref(initialZoom);
1993
- const translateX = ref(initialTranslateX);
1994
- const translateY = ref(initialTranslateY);
1995
- const isDragging = ref(false);
1996
- const dragStart = ref({
1997
- x: 0,
1998
- y: 0
1999
- });
2000
- const isPinching = ref(false);
2001
- const touchZoomState = ref(null);
2002
- const transformStyle = computed(() => ({ transform: `translate(${translateX.value}px, ${translateY.value}px) scale(${zoom.value})` }));
2003
- function zoomIn() {
2004
- if (zoom.value < maxZoom) zoom.value = Math.min(zoom.value + zoomStep, maxZoom);
2005
- }
2006
- function zoomOut() {
2007
- if (zoom.value > minZoom) zoom.value = Math.max(zoom.value - zoomStep, minZoom);
2008
- }
2009
- function resetZoom() {
2010
- zoom.value = initialZoom;
2011
- translateX.value = initialTranslateX;
2012
- translateY.value = initialTranslateY;
2013
- }
2014
- function setZoom(value) {
2015
- zoom.value = Math.min(Math.max(value, minZoom), maxZoom);
2016
- }
2017
- function startDrag(e) {
2018
- if (isPinching.value) return;
2019
- isDragging.value = true;
2020
- dragStart.value = {
2021
- x: e.clientX - translateX.value,
2022
- y: e.clientY - translateY.value
2023
- };
2024
- if (e.pointerType !== "mouse") {
2025
- if (e.target instanceof HTMLElement) e.target.setPointerCapture(e.pointerId);
2026
- }
2027
- }
2028
- function onDrag(e) {
2029
- if (!isDragging.value || isPinching.value) return;
2030
- translateX.value = e.clientX - dragStart.value.x;
2031
- translateY.value = e.clientY - dragStart.value.y;
2032
- }
2033
- function stopDrag() {
2034
- isDragging.value = false;
2035
- }
2036
- function handleWheel(event, containerElement) {
2037
- if (event.ctrlKey || event.metaKey) {
2038
- event.preventDefault();
2039
- const rect = containerElement.getBoundingClientRect();
2040
- const mouseX = event.clientX - rect.left;
2041
- const mouseY = event.clientY - rect.top;
2042
- const containerCenterX = rect.width / 2;
2043
- const containerCenterY = rect.height / 2;
2044
- const offsetX = mouseX - containerCenterX;
2045
- const offsetY = mouseY - containerCenterY;
2046
- const contentMouseX = (offsetX - translateX.value) / zoom.value;
2047
- const contentMouseY = (offsetY - translateY.value) / zoom.value;
2048
- const delta = -event.deltaY * wheelSensitivity;
2049
- const newZoom = Math.min(Math.max(zoom.value + delta, minZoom), maxZoom);
2050
- if (newZoom !== zoom.value) {
2051
- translateX.value = offsetX - contentMouseX * newZoom;
2052
- translateY.value = offsetY - contentMouseY * newZoom;
2053
- zoom.value = newZoom;
2054
- }
2055
- }
2056
- }
2057
- function getTouchDistance(touch1, touch2) {
2058
- const dx = touch1.clientX - touch2.clientX;
2059
- const dy = touch1.clientY - touch2.clientY;
2060
- return Math.sqrt(dx * dx + dy * dy);
2061
- }
2062
- function handleTouchStart(event, containerElement) {
2063
- if (event.touches.length === 2) {
2064
- event.preventDefault();
2065
- isPinching.value = true;
2066
- const touch1 = event.touches[0];
2067
- const touch2 = event.touches[1];
2068
- const distance = getTouchDistance(touch1, touch2);
2069
- const centerX = (touch1.clientX + touch2.clientX) / 2;
2070
- const centerY = (touch1.clientY + touch2.clientY) / 2;
2071
- const rect = containerElement.getBoundingClientRect();
2072
- const containerCenterX = rect.width / 2;
2073
- const containerCenterY = rect.height / 2;
2074
- const offsetX = centerX - rect.left - containerCenterX;
2075
- const offsetY = centerY - rect.top - containerCenterY;
2076
- touchZoomState.value = {
2077
- initialDistance: distance,
2078
- initialZoom: zoom.value,
2079
- initialTranslateX: translateX.value,
2080
- initialTranslateY: translateY.value,
2081
- centerX: offsetX,
2082
- centerY: offsetY
2083
- };
2084
- }
2085
- }
2086
- function handleTouchMove(event, containerElement) {
2087
- if (event.touches.length === 2 && touchZoomState.value) {
2088
- event.preventDefault();
2089
- const touch1 = event.touches[0];
2090
- const touch2 = event.touches[1];
2091
- const scale = getTouchDistance(touch1, touch2) / touchZoomState.value.initialDistance;
2092
- const newZoom = touchZoomState.value.initialZoom * scale;
2093
- const clampedZoom = Math.min(Math.max(newZoom, minZoom), maxZoom);
2094
- if (clampedZoom !== zoom.value) {
2095
- const centerX = (touch1.clientX + touch2.clientX) / 2;
2096
- const centerY = (touch1.clientY + touch2.clientY) / 2;
2097
- const rect = containerElement.getBoundingClientRect();
2098
- const containerCenterX = rect.width / 2;
2099
- const containerCenterY = rect.height / 2;
2100
- const offsetX = centerX - rect.left - containerCenterX;
2101
- const offsetY = centerY - rect.top - containerCenterY;
2102
- const contentFocalX = (touchZoomState.value.centerX - touchZoomState.value.initialTranslateX) / touchZoomState.value.initialZoom;
2103
- const contentFocalY = (touchZoomState.value.centerY - touchZoomState.value.initialTranslateY) / touchZoomState.value.initialZoom;
2104
- zoom.value = clampedZoom;
2105
- translateX.value = offsetX - contentFocalX * clampedZoom;
2106
- translateY.value = offsetY - contentFocalY * clampedZoom;
2107
- }
2108
- }
2109
- }
2110
- function handleTouchEnd(event) {
2111
- if (event.touches.length < 2) {
2112
- touchZoomState.value = null;
2113
- isPinching.value = false;
2114
- }
2115
- }
2116
- function getState() {
2117
- return {
2118
- zoom: zoom.value,
2119
- translateX: translateX.value,
2120
- translateY: translateY.value
2121
- };
2122
- }
2123
- function setState(state) {
2124
- if (state.zoom) zoom.value = Math.min(Math.max(state.zoom, minZoom), maxZoom);
2125
- if (state.translateX) translateX.value = state.translateX;
2126
- if (state.translateY) translateY.value = state.translateY;
2127
- }
2128
- return {
2129
- zoom,
2130
- translateX,
2131
- translateY,
2132
- isDragging,
2133
- transformStyle,
2134
- zoomIn,
2135
- zoomOut,
2136
- resetZoom,
2137
- setZoom,
2138
- startDrag,
2139
- onDrag,
2140
- stopDrag,
2141
- handleWheel,
2142
- getState,
2143
- setState,
2144
- handleTouchStart,
2145
- handleTouchMove,
2146
- handleTouchEnd
2147
- };
2148
- }
2149
-
2150
- //#endregion
2151
- export { tableDataToMarkdown as A, flow as B, loadLocaleMessages as C, escapeMarkdownTableCell as D, useFloating as E, hasKatex as F, useControls as G, saveImage as H, hasMermaid as I, useContext as K, hasShiki as L, preloadAsyncComponents as M, findLastLeafNode as N, extractTableDataFromElement as O, findNodeParent as P, isClient as R, currentLocale as S, localesGlob as T, svgToPngBlob as U, save as V, transformUrl as W, throttle as _, SHADCN_SCHEMAS as a, useI18n as b, DEFAULT_HARDEN_OPTIONS as c, LANGUAGE_ALIAS as d, LANGUAGE_EXTENSIONS as f, useMathRenderer as g, useMediumZoom as h, useSanitizers as i, tableDataToTSV as j, tableDataToCSV as k, DEFAULT_DARK_THEME as l, useMermaid as m, useTailwindV3Theme as n, PRELOAD_NODE_RENDERER as o, LANGUAGE_ICONS as p, useCodeOptions as q, useShiki as r, ICONS as s, useZoom as t, DEFAULT_LIGHT_THEME as u, _defineProperty as v, localeMessages as w, SUPPORT_LANGUAGES as x, useKatex as y, isServer as z };