@feedmepos/mf-remy-panel 0.0.2 → 0.0.4
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.
- package/dist/App.vue.d.ts +2 -0
- package/dist/Entry.vue.d.ts +2 -0
- package/dist/HomeView-40a46f7c.js +17 -0
- package/dist/app-f34db2cf.js +4355 -0
- package/dist/app.d.ts +99 -0
- package/dist/app.js +11 -0
- package/dist/components/ChatFollowUps.vue.d.ts +19 -0
- package/dist/components/ChatInput.vue.d.ts +6 -0
- package/dist/components/ChatMessageAssistant.vue.d.ts +15 -0
- package/dist/components/ChatMessageUser.vue.d.ts +15 -0
- package/dist/components/ChatMessages.vue.d.ts +16 -0
- package/dist/components/HistoryView.vue.d.ts +8 -0
- package/dist/components/MessageActions.vue.d.ts +16 -0
- package/dist/components/MessageContent.vue.d.ts +18 -0
- package/dist/components/Navigator.vue.d.ts +2 -0
- package/dist/components/RemyChatPanel.vue.d.ts +6 -0
- package/dist/favicon.ico +0 -0
- package/dist/main.d.ts +1 -0
- package/dist/router/index.d.ts +2 -0
- package/dist/router/shared.d.ts +2 -0
- package/dist/stores/counter.d.ts +13 -0
- package/dist/stores/remyChat.d.ts +320 -0
- package/dist/style.css +10 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -0
- package/dist/views/HomeView.vue.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,4355 @@
|
|
|
1
|
+
var Vs = Object.defineProperty;
|
|
2
|
+
var Ks = (s, e, t) => e in s ? Vs(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var B = (s, e, t) => (Ks(s, typeof e != "symbol" ? e + "" : e, t), t), Qs = (s, e, t) => {
|
|
4
|
+
if (!e.has(s))
|
|
5
|
+
throw TypeError("Cannot " + t);
|
|
6
|
+
};
|
|
7
|
+
var on = (s, e, t) => {
|
|
8
|
+
if (e.has(s))
|
|
9
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
10
|
+
e instanceof WeakSet ? e.add(s) : e.set(s, t);
|
|
11
|
+
};
|
|
12
|
+
var $t = (s, e, t) => (Qs(s, e, "access private method"), t);
|
|
13
|
+
import { ref as Q, computed as He, watch as ut, defineComponent as Oe, openBlock as S, createElementBlock as N, createElementVNode as L, toDisplayString as re, createCommentVNode as le, onMounted as Xt, resolveComponent as be, Fragment as Be, renderList as et, createBlock as ke, normalizeStyle as hs, unref as q, createVNode as Z, normalizeClass as wt, nextTick as Hn, createTextVNode as ds, withCtx as Qe, onUnmounted as Js, Transition as Fn, defineAsyncComponent as ei } from "vue";
|
|
14
|
+
import { useI18n as pt, useCoreStore as ti } from "@feedmepos/mf-common";
|
|
15
|
+
import { defineStore as ni } from "pinia";
|
|
16
|
+
import { createRouter as si, createWebHistory as ii } from "vue-router";
|
|
17
|
+
const oi = {
|
|
18
|
+
chat: {
|
|
19
|
+
title: "Remy Chat",
|
|
20
|
+
empty: "Start a conversation with Remy",
|
|
21
|
+
placeholder: "Ask Remy anything... (Use / for commands)",
|
|
22
|
+
send: "Send",
|
|
23
|
+
clear: "Clear History",
|
|
24
|
+
confirmClear: "Are you sure you want to clear the chat history?",
|
|
25
|
+
streaming: "Streaming...",
|
|
26
|
+
commands: "Available Commands",
|
|
27
|
+
followUps: "Suggested follow-ups",
|
|
28
|
+
sessionMenu: "Session Menu",
|
|
29
|
+
newSession: "New Chat Session",
|
|
30
|
+
viewAllHistory: "View All History",
|
|
31
|
+
confirmNewSession: "Start a new chat session? Current conversation will be saved.",
|
|
32
|
+
close: "Close",
|
|
33
|
+
historyTitle: "Chat History",
|
|
34
|
+
noHistory: "No chat history yet",
|
|
35
|
+
emptySession: "Empty session",
|
|
36
|
+
untitledSession: "Untitled conversation",
|
|
37
|
+
messages: "messages",
|
|
38
|
+
yesterday: "Yesterday",
|
|
39
|
+
back: "Back",
|
|
40
|
+
deleteSession: "Delete session",
|
|
41
|
+
confirmDeleteSession: "Are you sure you want to delete this session? This cannot be undone."
|
|
42
|
+
},
|
|
43
|
+
feedback: {
|
|
44
|
+
helpful: "Helpful",
|
|
45
|
+
unhelpful: "Not helpful",
|
|
46
|
+
copy: "Copy to clipboard"
|
|
47
|
+
},
|
|
48
|
+
commands: {
|
|
49
|
+
explain: "Explain the selected code or concept",
|
|
50
|
+
fix: "Suggest fixes for the code",
|
|
51
|
+
test: "Generate tests for the code"
|
|
52
|
+
}
|
|
53
|
+
}, ri = {
|
|
54
|
+
"mf-remy-panel": {
|
|
55
|
+
title: "My great app",
|
|
56
|
+
description: "This is a great app",
|
|
57
|
+
count: "Count: {count}"
|
|
58
|
+
},
|
|
59
|
+
remy: oi
|
|
60
|
+
}, ai = {
|
|
61
|
+
chat: {
|
|
62
|
+
title: "Remy 聊天",
|
|
63
|
+
empty: "开始与 Remy 对话",
|
|
64
|
+
placeholder: "向 Remy 提问...(使用 / 查看命令)",
|
|
65
|
+
send: "发送",
|
|
66
|
+
clear: "清除历史",
|
|
67
|
+
confirmClear: "确定要清除聊天历史吗?",
|
|
68
|
+
streaming: "正在生成...",
|
|
69
|
+
commands: "可用命令",
|
|
70
|
+
followUps: "建议的后续问题",
|
|
71
|
+
sessionMenu: "会话菜单",
|
|
72
|
+
newSession: "新建聊天会话",
|
|
73
|
+
viewAllHistory: "查看所有历史",
|
|
74
|
+
confirmNewSession: "开始新的聊天会话?当前对话将被保存。",
|
|
75
|
+
close: "关闭",
|
|
76
|
+
historyTitle: "聊天历史",
|
|
77
|
+
noHistory: "还没有聊天历史",
|
|
78
|
+
emptySession: "空会话",
|
|
79
|
+
untitledSession: "无标题对话",
|
|
80
|
+
messages: "条消息",
|
|
81
|
+
yesterday: "昨天",
|
|
82
|
+
back: "返回",
|
|
83
|
+
deleteSession: "删除会话",
|
|
84
|
+
confirmDeleteSession: "确定要删除此会话吗?此操作无法撤消。"
|
|
85
|
+
},
|
|
86
|
+
feedback: {
|
|
87
|
+
helpful: "有帮助",
|
|
88
|
+
unhelpful: "没有帮助",
|
|
89
|
+
copy: "复制到剪贴板"
|
|
90
|
+
},
|
|
91
|
+
commands: {
|
|
92
|
+
explain: "解释所选代码或概念",
|
|
93
|
+
fix: "建议代码修复",
|
|
94
|
+
test: "为代码生成测试"
|
|
95
|
+
}
|
|
96
|
+
}, li = {
|
|
97
|
+
"mf-remy-panel": {
|
|
98
|
+
title: "我的应用",
|
|
99
|
+
description: "这是一个好应用",
|
|
100
|
+
count: "计数: {count}"
|
|
101
|
+
},
|
|
102
|
+
remy: ai
|
|
103
|
+
}, ci = "RemyChatDB", ui = 1, Re = "sessions", fi = "current-session", pi = 5e3;
|
|
104
|
+
class hi {
|
|
105
|
+
constructor() {
|
|
106
|
+
B(this, "db", null);
|
|
107
|
+
}
|
|
108
|
+
async openDB() {
|
|
109
|
+
return this.db ? this.db : new Promise((e, t) => {
|
|
110
|
+
const n = indexedDB.open(ci, ui);
|
|
111
|
+
n.onerror = () => t(n.error), n.onsuccess = () => {
|
|
112
|
+
this.db = n.result, e(this.db);
|
|
113
|
+
}, n.onupgradeneeded = (o) => {
|
|
114
|
+
const r = o.target.result;
|
|
115
|
+
r.objectStoreNames.contains(Re) || r.createObjectStore(Re, { keyPath: "id", autoIncrement: !1 });
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async saveSession(e) {
|
|
120
|
+
const t = await this.openDB();
|
|
121
|
+
return new Promise((n, o) => {
|
|
122
|
+
const a = t.transaction([Re], "readwrite").objectStore(Re).put(e);
|
|
123
|
+
a.onerror = () => o(a.error), a.onsuccess = () => n();
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
async loadSession(e) {
|
|
127
|
+
const t = await this.openDB();
|
|
128
|
+
return new Promise((n, o) => {
|
|
129
|
+
const a = t.transaction([Re], "readonly").objectStore(Re).get(e);
|
|
130
|
+
a.onerror = () => o(a.error), a.onsuccess = () => n(a.result || null);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
async clearSession(e) {
|
|
134
|
+
const t = await this.openDB();
|
|
135
|
+
return new Promise((n, o) => {
|
|
136
|
+
const a = t.transaction([Re], "readwrite").objectStore(Re).delete(e);
|
|
137
|
+
a.onerror = () => o(a.error), a.onsuccess = () => n();
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
async listSessions() {
|
|
141
|
+
const e = await this.openDB();
|
|
142
|
+
return new Promise((t, n) => {
|
|
143
|
+
const i = e.transaction([Re], "readonly").objectStore(Re).getAll();
|
|
144
|
+
i.onerror = () => n(i.error), i.onsuccess = () => {
|
|
145
|
+
const a = i.result;
|
|
146
|
+
a.sort((c, g) => g.updatedAt - c.updatedAt), t(a);
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
class di {
|
|
152
|
+
constructor() {
|
|
153
|
+
B(this, "eventSource", null);
|
|
154
|
+
B(this, "retryCount", 0);
|
|
155
|
+
B(this, "maxRetries", 10);
|
|
156
|
+
B(this, "baseDelay", 1e3);
|
|
157
|
+
// 1 second
|
|
158
|
+
B(this, "maxDelay", 3e4);
|
|
159
|
+
// 30 seconds
|
|
160
|
+
B(this, "retryTimeout", null);
|
|
161
|
+
}
|
|
162
|
+
connect(e, t, n, o) {
|
|
163
|
+
this.disconnect();
|
|
164
|
+
try {
|
|
165
|
+
this.eventSource = new EventSource(e), this.eventSource.onopen = () => {
|
|
166
|
+
this.retryCount = 0, o == null || o();
|
|
167
|
+
}, this.eventSource.onmessage = (r) => {
|
|
168
|
+
try {
|
|
169
|
+
const i = JSON.parse(r.data);
|
|
170
|
+
t(i);
|
|
171
|
+
} catch (i) {
|
|
172
|
+
console.error("Failed to parse SSE message:", i);
|
|
173
|
+
}
|
|
174
|
+
}, this.eventSource.onerror = () => {
|
|
175
|
+
if (this.disconnect(), this.retryCount < this.maxRetries) {
|
|
176
|
+
const r = Math.min(
|
|
177
|
+
this.baseDelay * Math.pow(2, this.retryCount),
|
|
178
|
+
this.maxDelay
|
|
179
|
+
);
|
|
180
|
+
this.retryCount++, console.log(`SSE connection failed. Retrying in ${r}ms (attempt ${this.retryCount}/${this.maxRetries})`), this.retryTimeout = setTimeout(() => {
|
|
181
|
+
this.connect(e, t, n, o);
|
|
182
|
+
}, r);
|
|
183
|
+
} else
|
|
184
|
+
n == null || n(new Error("SSE connection failed after maximum retries"));
|
|
185
|
+
};
|
|
186
|
+
} catch (r) {
|
|
187
|
+
n == null || n(r);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
disconnect() {
|
|
191
|
+
this.retryTimeout && (clearTimeout(this.retryTimeout), this.retryTimeout = null), this.eventSource && (this.eventSource.close(), this.eventSource = null);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const Vt = ni("remyChat", () => {
|
|
195
|
+
const s = Q([]), e = Q(/* @__PURE__ */ new Map()), t = Q(/* @__PURE__ */ new Map()), n = Q("remy"), o = Q(fi), r = Q(!1), i = Q(!1), a = Q(null), c = new hi(), g = new di();
|
|
196
|
+
let u = null;
|
|
197
|
+
const _ = He(() => {
|
|
198
|
+
const w = s.value[s.value.length - 1];
|
|
199
|
+
return (w == null ? void 0 : w.followUps) || [];
|
|
200
|
+
}), d = He(() => {
|
|
201
|
+
const w = e.value.get(n.value);
|
|
202
|
+
return (w == null ? void 0 : w.commands) || [];
|
|
203
|
+
});
|
|
204
|
+
ut(
|
|
205
|
+
s,
|
|
206
|
+
() => {
|
|
207
|
+
u && clearTimeout(u), u = setTimeout(() => {
|
|
208
|
+
J();
|
|
209
|
+
}, pi);
|
|
210
|
+
},
|
|
211
|
+
{ deep: !0 }
|
|
212
|
+
);
|
|
213
|
+
function f(w) {
|
|
214
|
+
e.value.set(w.id, w), w.commands && w.commands.forEach((P) => {
|
|
215
|
+
t.value.set(P.name, P);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function y(w) {
|
|
219
|
+
t.value.set(w.name, w);
|
|
220
|
+
}
|
|
221
|
+
async function T(w, P) {
|
|
222
|
+
if (!w.trim() || r.value)
|
|
223
|
+
return;
|
|
224
|
+
const D = {
|
|
225
|
+
id: `msg-${Date.now()}-user`,
|
|
226
|
+
type: "user",
|
|
227
|
+
content: w,
|
|
228
|
+
timestamp: Date.now(),
|
|
229
|
+
participant: n.value,
|
|
230
|
+
command: P
|
|
231
|
+
};
|
|
232
|
+
s.value.push(D);
|
|
233
|
+
const X = {
|
|
234
|
+
id: `msg-${Date.now()}-assistant`,
|
|
235
|
+
type: "assistant",
|
|
236
|
+
content: "",
|
|
237
|
+
contentParts: [],
|
|
238
|
+
timestamp: Date.now(),
|
|
239
|
+
participant: n.value,
|
|
240
|
+
isStreaming: !0
|
|
241
|
+
};
|
|
242
|
+
s.value.push(X), a.value = X.id, r.value = !0;
|
|
243
|
+
const p = e.value.get(n.value);
|
|
244
|
+
if (!p) {
|
|
245
|
+
console.error(`Participant ${n.value} not found`), r.value = !1;
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const k = {
|
|
249
|
+
prompt: w,
|
|
250
|
+
command: P,
|
|
251
|
+
participant: n.value
|
|
252
|
+
}, R = {
|
|
253
|
+
markdown: (j) => {
|
|
254
|
+
M({
|
|
255
|
+
type: "markdown",
|
|
256
|
+
data: { content: j, isPartial: !0 }
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
progress: (j, $) => {
|
|
260
|
+
M({
|
|
261
|
+
type: "progress",
|
|
262
|
+
data: { message: j, percentage: $ }
|
|
263
|
+
});
|
|
264
|
+
},
|
|
265
|
+
done: () => {
|
|
266
|
+
K();
|
|
267
|
+
}
|
|
268
|
+
}, F = new AbortController();
|
|
269
|
+
try {
|
|
270
|
+
await p.handler(k, s.value.slice(0, -1), R, F.signal);
|
|
271
|
+
} catch (j) {
|
|
272
|
+
console.error("Chat handler error:", j), R.markdown(`
|
|
273
|
+
|
|
274
|
+
❌ Error: ${j.message}`), R.done();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function M(w) {
|
|
278
|
+
const P = s.value.findIndex(
|
|
279
|
+
(X) => X.id === a.value
|
|
280
|
+
);
|
|
281
|
+
if (P === -1)
|
|
282
|
+
return;
|
|
283
|
+
const D = { ...s.value[P] };
|
|
284
|
+
if (D.contentParts || (D.contentParts = []), w.type === "markdown") {
|
|
285
|
+
const X = D.contentParts[D.contentParts.length - 1];
|
|
286
|
+
X && X.type === "markdown" ? X.data.content += w.data.content : D.contentParts.push(w), D.content = D.contentParts.filter((p) => p.type === "markdown").map((p) => p.data.content).join(`
|
|
287
|
+
`);
|
|
288
|
+
} else
|
|
289
|
+
D.contentParts.push(w);
|
|
290
|
+
s.value[P] = D;
|
|
291
|
+
}
|
|
292
|
+
function K() {
|
|
293
|
+
const w = s.value.findIndex(
|
|
294
|
+
(P) => P.id === a.value
|
|
295
|
+
);
|
|
296
|
+
w !== -1 && (s.value[w] = {
|
|
297
|
+
...s.value[w],
|
|
298
|
+
isStreaming: !1
|
|
299
|
+
}), r.value = !1, a.value = null;
|
|
300
|
+
}
|
|
301
|
+
function C(w, P) {
|
|
302
|
+
const D = P || {}.VITE_REMY_SSE_ENDPOINT;
|
|
303
|
+
if (!D) {
|
|
304
|
+
console.error("SSE endpoint not configured");
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
g.connect(
|
|
308
|
+
D,
|
|
309
|
+
(X) => {
|
|
310
|
+
X.messageId !== w && X.messageId || (X.type === "done" ? (K(), g.disconnect()) : M(X));
|
|
311
|
+
},
|
|
312
|
+
(X) => {
|
|
313
|
+
console.error("SSE connection error:", X), M({
|
|
314
|
+
type: "markdown",
|
|
315
|
+
data: { content: `
|
|
316
|
+
|
|
317
|
+
❌ Connection error: ${X.message}` }
|
|
318
|
+
}), K(), i.value = !1;
|
|
319
|
+
},
|
|
320
|
+
() => {
|
|
321
|
+
i.value = !0;
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
function Y(w, P) {
|
|
326
|
+
const D = s.value.find((X) => X.id === w);
|
|
327
|
+
D && (D.followUps || (D.followUps = []), D.followUps.push(P));
|
|
328
|
+
}
|
|
329
|
+
function I(w, P) {
|
|
330
|
+
const D = s.value.find((X) => X.id === w);
|
|
331
|
+
D && (D.feedback = P ? "helpful" : "unhelpful");
|
|
332
|
+
}
|
|
333
|
+
async function J() {
|
|
334
|
+
var w;
|
|
335
|
+
try {
|
|
336
|
+
const P = JSON.parse(JSON.stringify(s.value)), D = {
|
|
337
|
+
id: o.value,
|
|
338
|
+
messages: P,
|
|
339
|
+
createdAt: ((w = s.value[0]) == null ? void 0 : w.timestamp) || Date.now(),
|
|
340
|
+
updatedAt: Date.now()
|
|
341
|
+
};
|
|
342
|
+
await c.saveSession(D);
|
|
343
|
+
} catch (P) {
|
|
344
|
+
console.error("Failed to save session:", P);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
async function Se(w) {
|
|
348
|
+
try {
|
|
349
|
+
const P = w || o.value, D = await c.loadSession(P);
|
|
350
|
+
D && (s.value = D.messages, o.value = D.id);
|
|
351
|
+
} catch (P) {
|
|
352
|
+
console.error("Failed to load session:", P);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
async function Ge() {
|
|
356
|
+
try {
|
|
357
|
+
await c.clearSession(o.value), s.value = [], r.value = !1, a.value = null;
|
|
358
|
+
} catch (w) {
|
|
359
|
+
console.error("Failed to clear history:", w);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function pe(w) {
|
|
363
|
+
e.value.has(w) && (n.value = w);
|
|
364
|
+
}
|
|
365
|
+
async function he() {
|
|
366
|
+
try {
|
|
367
|
+
return await c.listSessions();
|
|
368
|
+
} catch (w) {
|
|
369
|
+
return console.error("Failed to list sessions:", w), [];
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
async function Fe() {
|
|
373
|
+
try {
|
|
374
|
+
s.value.length > 0 && await J(), o.value = `session-${Date.now()}`, s.value = [], r.value = !1, a.value = null;
|
|
375
|
+
} catch (w) {
|
|
376
|
+
console.error("Failed to create new session:", w);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
async function se(w) {
|
|
380
|
+
try {
|
|
381
|
+
await c.clearSession(w), w === o.value && (s.value = [], r.value = !1, a.value = null);
|
|
382
|
+
} catch (P) {
|
|
383
|
+
console.error("Failed to delete session:", P);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return {
|
|
387
|
+
// State
|
|
388
|
+
messages: s,
|
|
389
|
+
participants: e,
|
|
390
|
+
commands: t,
|
|
391
|
+
currentParticipant: n,
|
|
392
|
+
sessionId: o,
|
|
393
|
+
isStreaming: r,
|
|
394
|
+
isConnected: i,
|
|
395
|
+
latestFollowUps: _,
|
|
396
|
+
availableCommands: d,
|
|
397
|
+
// Actions
|
|
398
|
+
registerParticipant: f,
|
|
399
|
+
registerCommand: y,
|
|
400
|
+
sendMessage: T,
|
|
401
|
+
addFollowUp: Y,
|
|
402
|
+
provideFeedback: I,
|
|
403
|
+
saveSession: J,
|
|
404
|
+
loadSession: Se,
|
|
405
|
+
clearHistory: Ge,
|
|
406
|
+
switchParticipant: pe,
|
|
407
|
+
connectSSE: C,
|
|
408
|
+
addStreamContent: M,
|
|
409
|
+
finishStreaming: K,
|
|
410
|
+
listSessions: he,
|
|
411
|
+
newSession: Fe,
|
|
412
|
+
deleteSession: se
|
|
413
|
+
};
|
|
414
|
+
}), gi = { class: "flex flex-col gap-1 p-1 bg-blue-200 rounded max-w-[85%] ml-auto text-[0.8rem]" }, mi = { class: "flex items-center gap-2 text-sm" }, _i = { class: "font-semibold text-blue-900" }, bi = {
|
|
415
|
+
key: 0,
|
|
416
|
+
class: "font-mono bg-blue-300 px-1.5 py-0.5 rounded text-[13px] text-blue-900"
|
|
417
|
+
}, yi = { class: "ml-auto text-blue-400 text-[13px]" }, xi = { class: "text-blue-900 leading-6 whitespace-pre-wrap break-words" }, ki = /* @__PURE__ */ Oe({
|
|
418
|
+
__name: "ChatMessageUser",
|
|
419
|
+
props: {
|
|
420
|
+
message: {}
|
|
421
|
+
},
|
|
422
|
+
setup(s) {
|
|
423
|
+
const e = s, t = He(() => new Date(e.message.timestamp).toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit" })), n = He(() => e.message.command ? `/${e.message.command}` : "");
|
|
424
|
+
return (o, r) => (S(), N("div", gi, [
|
|
425
|
+
L("div", mi, [
|
|
426
|
+
L("span", _i, "@" + re(s.message.participant), 1),
|
|
427
|
+
n.value ? (S(), N("span", bi, re(n.value), 1)) : le("", !0),
|
|
428
|
+
L("span", yi, re(t.value), 1)
|
|
429
|
+
]),
|
|
430
|
+
L("div", xi, re(s.message.content), 1)
|
|
431
|
+
]));
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
const Ne = (s, e) => {
|
|
435
|
+
const t = s.__vccOpts || s;
|
|
436
|
+
for (const [n, o] of e)
|
|
437
|
+
t[n] = o;
|
|
438
|
+
return t;
|
|
439
|
+
}, wi = /* @__PURE__ */ Ne(ki, [["__scopeId", "data-v-81730532"]]);
|
|
440
|
+
function bn() {
|
|
441
|
+
return {
|
|
442
|
+
async: !1,
|
|
443
|
+
breaks: !1,
|
|
444
|
+
extensions: null,
|
|
445
|
+
gfm: !0,
|
|
446
|
+
hooks: null,
|
|
447
|
+
pedantic: !1,
|
|
448
|
+
renderer: null,
|
|
449
|
+
silent: !1,
|
|
450
|
+
tokenizer: null,
|
|
451
|
+
walkTokens: null
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
let nt = bn();
|
|
455
|
+
function gs(s) {
|
|
456
|
+
nt = s;
|
|
457
|
+
}
|
|
458
|
+
const ms = /[&<>"']/, Ei = new RegExp(ms.source, "g"), _s = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, Ti = new RegExp(_s.source, "g"), vi = {
|
|
459
|
+
"&": "&",
|
|
460
|
+
"<": "<",
|
|
461
|
+
">": ">",
|
|
462
|
+
'"': """,
|
|
463
|
+
"'": "'"
|
|
464
|
+
}, jn = (s) => vi[s];
|
|
465
|
+
function xe(s, e) {
|
|
466
|
+
if (e) {
|
|
467
|
+
if (ms.test(s))
|
|
468
|
+
return s.replace(Ei, jn);
|
|
469
|
+
} else if (_s.test(s))
|
|
470
|
+
return s.replace(Ti, jn);
|
|
471
|
+
return s;
|
|
472
|
+
}
|
|
473
|
+
const Si = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
474
|
+
function Ai(s) {
|
|
475
|
+
return s.replace(Si, (e, t) => (t = t.toLowerCase(), t === "colon" ? ":" : t.charAt(0) === "#" ? t.charAt(1) === "x" ? String.fromCharCode(parseInt(t.substring(2), 16)) : String.fromCharCode(+t.substring(1)) : ""));
|
|
476
|
+
}
|
|
477
|
+
const Ri = /(^|[^\[])\^/g;
|
|
478
|
+
function G(s, e) {
|
|
479
|
+
let t = typeof s == "string" ? s : s.source;
|
|
480
|
+
e = e || "";
|
|
481
|
+
const n = {
|
|
482
|
+
replace: (o, r) => {
|
|
483
|
+
let i = typeof r == "string" ? r : r.source;
|
|
484
|
+
return i = i.replace(Ri, "$1"), t = t.replace(o, i), n;
|
|
485
|
+
},
|
|
486
|
+
getRegex: () => new RegExp(t, e)
|
|
487
|
+
};
|
|
488
|
+
return n;
|
|
489
|
+
}
|
|
490
|
+
function Wn(s) {
|
|
491
|
+
try {
|
|
492
|
+
s = encodeURI(s).replace(/%25/g, "%");
|
|
493
|
+
} catch {
|
|
494
|
+
return null;
|
|
495
|
+
}
|
|
496
|
+
return s;
|
|
497
|
+
}
|
|
498
|
+
const Et = { exec: () => null };
|
|
499
|
+
function Gn(s, e) {
|
|
500
|
+
const t = s.replace(/\|/g, (r, i, a) => {
|
|
501
|
+
let c = !1, g = i;
|
|
502
|
+
for (; --g >= 0 && a[g] === "\\"; )
|
|
503
|
+
c = !c;
|
|
504
|
+
return c ? "|" : " |";
|
|
505
|
+
}), n = t.split(/ \|/);
|
|
506
|
+
let o = 0;
|
|
507
|
+
if (n[0].trim() || n.shift(), n.length > 0 && !n[n.length - 1].trim() && n.pop(), e)
|
|
508
|
+
if (n.length > e)
|
|
509
|
+
n.splice(e);
|
|
510
|
+
else
|
|
511
|
+
for (; n.length < e; )
|
|
512
|
+
n.push("");
|
|
513
|
+
for (; o < n.length; o++)
|
|
514
|
+
n[o] = n[o].trim().replace(/\\\|/g, "|");
|
|
515
|
+
return n;
|
|
516
|
+
}
|
|
517
|
+
function zt(s, e, t) {
|
|
518
|
+
const n = s.length;
|
|
519
|
+
if (n === 0)
|
|
520
|
+
return "";
|
|
521
|
+
let o = 0;
|
|
522
|
+
for (; o < n; ) {
|
|
523
|
+
const r = s.charAt(n - o - 1);
|
|
524
|
+
if (r === e && !t)
|
|
525
|
+
o++;
|
|
526
|
+
else if (r !== e && t)
|
|
527
|
+
o++;
|
|
528
|
+
else
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
return s.slice(0, n - o);
|
|
532
|
+
}
|
|
533
|
+
function Mi(s, e) {
|
|
534
|
+
if (s.indexOf(e[1]) === -1)
|
|
535
|
+
return -1;
|
|
536
|
+
let t = 0;
|
|
537
|
+
for (let n = 0; n < s.length; n++)
|
|
538
|
+
if (s[n] === "\\")
|
|
539
|
+
n++;
|
|
540
|
+
else if (s[n] === e[0])
|
|
541
|
+
t++;
|
|
542
|
+
else if (s[n] === e[1] && (t--, t < 0))
|
|
543
|
+
return n;
|
|
544
|
+
return -1;
|
|
545
|
+
}
|
|
546
|
+
function qn(s, e, t, n) {
|
|
547
|
+
const o = e.href, r = e.title ? xe(e.title) : null, i = s[1].replace(/\\([\[\]])/g, "$1");
|
|
548
|
+
if (s[0].charAt(0) !== "!") {
|
|
549
|
+
n.state.inLink = !0;
|
|
550
|
+
const a = {
|
|
551
|
+
type: "link",
|
|
552
|
+
raw: t,
|
|
553
|
+
href: o,
|
|
554
|
+
title: r,
|
|
555
|
+
text: i,
|
|
556
|
+
tokens: n.inlineTokens(i)
|
|
557
|
+
};
|
|
558
|
+
return n.state.inLink = !1, a;
|
|
559
|
+
}
|
|
560
|
+
return {
|
|
561
|
+
type: "image",
|
|
562
|
+
raw: t,
|
|
563
|
+
href: o,
|
|
564
|
+
title: r,
|
|
565
|
+
text: xe(i)
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
function Ci(s, e) {
|
|
569
|
+
const t = s.match(/^(\s+)(?:```)/);
|
|
570
|
+
if (t === null)
|
|
571
|
+
return e;
|
|
572
|
+
const n = t[1];
|
|
573
|
+
return e.split(`
|
|
574
|
+
`).map((o) => {
|
|
575
|
+
const r = o.match(/^\s+/);
|
|
576
|
+
if (r === null)
|
|
577
|
+
return o;
|
|
578
|
+
const [i] = r;
|
|
579
|
+
return i.length >= n.length ? o.slice(n.length) : o;
|
|
580
|
+
}).join(`
|
|
581
|
+
`);
|
|
582
|
+
}
|
|
583
|
+
class Wt {
|
|
584
|
+
// set by the lexer
|
|
585
|
+
constructor(e) {
|
|
586
|
+
B(this, "options");
|
|
587
|
+
B(this, "rules");
|
|
588
|
+
// set by the lexer
|
|
589
|
+
B(this, "lexer");
|
|
590
|
+
this.options = e || nt;
|
|
591
|
+
}
|
|
592
|
+
space(e) {
|
|
593
|
+
const t = this.rules.block.newline.exec(e);
|
|
594
|
+
if (t && t[0].length > 0)
|
|
595
|
+
return {
|
|
596
|
+
type: "space",
|
|
597
|
+
raw: t[0]
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
code(e) {
|
|
601
|
+
const t = this.rules.block.code.exec(e);
|
|
602
|
+
if (t) {
|
|
603
|
+
const n = t[0].replace(/^ {1,4}/gm, "");
|
|
604
|
+
return {
|
|
605
|
+
type: "code",
|
|
606
|
+
raw: t[0],
|
|
607
|
+
codeBlockStyle: "indented",
|
|
608
|
+
text: this.options.pedantic ? n : zt(n, `
|
|
609
|
+
`)
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
fences(e) {
|
|
614
|
+
const t = this.rules.block.fences.exec(e);
|
|
615
|
+
if (t) {
|
|
616
|
+
const n = t[0], o = Ci(n, t[3] || "");
|
|
617
|
+
return {
|
|
618
|
+
type: "code",
|
|
619
|
+
raw: n,
|
|
620
|
+
lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2],
|
|
621
|
+
text: o
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
heading(e) {
|
|
626
|
+
const t = this.rules.block.heading.exec(e);
|
|
627
|
+
if (t) {
|
|
628
|
+
let n = t[2].trim();
|
|
629
|
+
if (/#$/.test(n)) {
|
|
630
|
+
const o = zt(n, "#");
|
|
631
|
+
(this.options.pedantic || !o || / $/.test(o)) && (n = o.trim());
|
|
632
|
+
}
|
|
633
|
+
return {
|
|
634
|
+
type: "heading",
|
|
635
|
+
raw: t[0],
|
|
636
|
+
depth: t[1].length,
|
|
637
|
+
text: n,
|
|
638
|
+
tokens: this.lexer.inline(n)
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
hr(e) {
|
|
643
|
+
const t = this.rules.block.hr.exec(e);
|
|
644
|
+
if (t)
|
|
645
|
+
return {
|
|
646
|
+
type: "hr",
|
|
647
|
+
raw: t[0]
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
blockquote(e) {
|
|
651
|
+
const t = this.rules.block.blockquote.exec(e);
|
|
652
|
+
if (t) {
|
|
653
|
+
const n = zt(t[0].replace(/^ *>[ \t]?/gm, ""), `
|
|
654
|
+
`), o = this.lexer.state.top;
|
|
655
|
+
this.lexer.state.top = !0;
|
|
656
|
+
const r = this.lexer.blockTokens(n);
|
|
657
|
+
return this.lexer.state.top = o, {
|
|
658
|
+
type: "blockquote",
|
|
659
|
+
raw: t[0],
|
|
660
|
+
tokens: r,
|
|
661
|
+
text: n
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
list(e) {
|
|
666
|
+
let t = this.rules.block.list.exec(e);
|
|
667
|
+
if (t) {
|
|
668
|
+
let n = t[1].trim();
|
|
669
|
+
const o = n.length > 1, r = {
|
|
670
|
+
type: "list",
|
|
671
|
+
raw: "",
|
|
672
|
+
ordered: o,
|
|
673
|
+
start: o ? +n.slice(0, -1) : "",
|
|
674
|
+
loose: !1,
|
|
675
|
+
items: []
|
|
676
|
+
};
|
|
677
|
+
n = o ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = o ? n : "[*+-]");
|
|
678
|
+
const i = new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`);
|
|
679
|
+
let a = "", c = "", g = !1;
|
|
680
|
+
for (; e; ) {
|
|
681
|
+
let u = !1;
|
|
682
|
+
if (!(t = i.exec(e)) || this.rules.block.hr.test(e))
|
|
683
|
+
break;
|
|
684
|
+
a = t[0], e = e.substring(a.length);
|
|
685
|
+
let _ = t[2].split(`
|
|
686
|
+
`, 1)[0].replace(/^\t+/, (K) => " ".repeat(3 * K.length)), d = e.split(`
|
|
687
|
+
`, 1)[0], f = 0;
|
|
688
|
+
this.options.pedantic ? (f = 2, c = _.trimStart()) : (f = t[2].search(/[^ ]/), f = f > 4 ? 1 : f, c = _.slice(f), f += t[1].length);
|
|
689
|
+
let y = !1;
|
|
690
|
+
if (!_ && /^ *$/.test(d) && (a += d + `
|
|
691
|
+
`, e = e.substring(d.length + 1), u = !0), !u) {
|
|
692
|
+
const K = new RegExp(`^ {0,${Math.min(3, f - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), C = new RegExp(`^ {0,${Math.min(3, f - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), Y = new RegExp(`^ {0,${Math.min(3, f - 1)}}(?:\`\`\`|~~~)`), I = new RegExp(`^ {0,${Math.min(3, f - 1)}}#`);
|
|
693
|
+
for (; e; ) {
|
|
694
|
+
const J = e.split(`
|
|
695
|
+
`, 1)[0];
|
|
696
|
+
if (d = J, this.options.pedantic && (d = d.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ")), Y.test(d) || I.test(d) || K.test(d) || C.test(e))
|
|
697
|
+
break;
|
|
698
|
+
if (d.search(/[^ ]/) >= f || !d.trim())
|
|
699
|
+
c += `
|
|
700
|
+
` + d.slice(f);
|
|
701
|
+
else {
|
|
702
|
+
if (y || _.search(/[^ ]/) >= 4 || Y.test(_) || I.test(_) || C.test(_))
|
|
703
|
+
break;
|
|
704
|
+
c += `
|
|
705
|
+
` + d;
|
|
706
|
+
}
|
|
707
|
+
!y && !d.trim() && (y = !0), a += J + `
|
|
708
|
+
`, e = e.substring(J.length + 1), _ = d.slice(f);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
r.loose || (g ? r.loose = !0 : /\n *\n *$/.test(a) && (g = !0));
|
|
712
|
+
let T = null, M;
|
|
713
|
+
this.options.gfm && (T = /^\[[ xX]\] /.exec(c), T && (M = T[0] !== "[ ] ", c = c.replace(/^\[[ xX]\] +/, ""))), r.items.push({
|
|
714
|
+
type: "list_item",
|
|
715
|
+
raw: a,
|
|
716
|
+
task: !!T,
|
|
717
|
+
checked: M,
|
|
718
|
+
loose: !1,
|
|
719
|
+
text: c,
|
|
720
|
+
tokens: []
|
|
721
|
+
}), r.raw += a;
|
|
722
|
+
}
|
|
723
|
+
r.items[r.items.length - 1].raw = a.trimEnd(), r.items[r.items.length - 1].text = c.trimEnd(), r.raw = r.raw.trimEnd();
|
|
724
|
+
for (let u = 0; u < r.items.length; u++)
|
|
725
|
+
if (this.lexer.state.top = !1, r.items[u].tokens = this.lexer.blockTokens(r.items[u].text, []), !r.loose) {
|
|
726
|
+
const _ = r.items[u].tokens.filter((f) => f.type === "space"), d = _.length > 0 && _.some((f) => /\n.*\n/.test(f.raw));
|
|
727
|
+
r.loose = d;
|
|
728
|
+
}
|
|
729
|
+
if (r.loose)
|
|
730
|
+
for (let u = 0; u < r.items.length; u++)
|
|
731
|
+
r.items[u].loose = !0;
|
|
732
|
+
return r;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
html(e) {
|
|
736
|
+
const t = this.rules.block.html.exec(e);
|
|
737
|
+
if (t)
|
|
738
|
+
return {
|
|
739
|
+
type: "html",
|
|
740
|
+
block: !0,
|
|
741
|
+
raw: t[0],
|
|
742
|
+
pre: t[1] === "pre" || t[1] === "script" || t[1] === "style",
|
|
743
|
+
text: t[0]
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
def(e) {
|
|
747
|
+
const t = this.rules.block.def.exec(e);
|
|
748
|
+
if (t) {
|
|
749
|
+
const n = t[1].toLowerCase().replace(/\s+/g, " "), o = t[2] ? t[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
750
|
+
return {
|
|
751
|
+
type: "def",
|
|
752
|
+
tag: n,
|
|
753
|
+
raw: t[0],
|
|
754
|
+
href: o,
|
|
755
|
+
title: r
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
table(e) {
|
|
760
|
+
const t = this.rules.block.table.exec(e);
|
|
761
|
+
if (!t || !/[:|]/.test(t[2]))
|
|
762
|
+
return;
|
|
763
|
+
const n = Gn(t[1]), o = t[2].replace(/^\||\| *$/g, "").split("|"), r = t[3] && t[3].trim() ? t[3].replace(/\n[ \t]*$/, "").split(`
|
|
764
|
+
`) : [], i = {
|
|
765
|
+
type: "table",
|
|
766
|
+
raw: t[0],
|
|
767
|
+
header: [],
|
|
768
|
+
align: [],
|
|
769
|
+
rows: []
|
|
770
|
+
};
|
|
771
|
+
if (n.length === o.length) {
|
|
772
|
+
for (const a of o)
|
|
773
|
+
/^ *-+: *$/.test(a) ? i.align.push("right") : /^ *:-+: *$/.test(a) ? i.align.push("center") : /^ *:-+ *$/.test(a) ? i.align.push("left") : i.align.push(null);
|
|
774
|
+
for (const a of n)
|
|
775
|
+
i.header.push({
|
|
776
|
+
text: a,
|
|
777
|
+
tokens: this.lexer.inline(a)
|
|
778
|
+
});
|
|
779
|
+
for (const a of r)
|
|
780
|
+
i.rows.push(Gn(a, i.header.length).map((c) => ({
|
|
781
|
+
text: c,
|
|
782
|
+
tokens: this.lexer.inline(c)
|
|
783
|
+
})));
|
|
784
|
+
return i;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
lheading(e) {
|
|
788
|
+
const t = this.rules.block.lheading.exec(e);
|
|
789
|
+
if (t)
|
|
790
|
+
return {
|
|
791
|
+
type: "heading",
|
|
792
|
+
raw: t[0],
|
|
793
|
+
depth: t[2].charAt(0) === "=" ? 1 : 2,
|
|
794
|
+
text: t[1],
|
|
795
|
+
tokens: this.lexer.inline(t[1])
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
paragraph(e) {
|
|
799
|
+
const t = this.rules.block.paragraph.exec(e);
|
|
800
|
+
if (t) {
|
|
801
|
+
const n = t[1].charAt(t[1].length - 1) === `
|
|
802
|
+
` ? t[1].slice(0, -1) : t[1];
|
|
803
|
+
return {
|
|
804
|
+
type: "paragraph",
|
|
805
|
+
raw: t[0],
|
|
806
|
+
text: n,
|
|
807
|
+
tokens: this.lexer.inline(n)
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
text(e) {
|
|
812
|
+
const t = this.rules.block.text.exec(e);
|
|
813
|
+
if (t)
|
|
814
|
+
return {
|
|
815
|
+
type: "text",
|
|
816
|
+
raw: t[0],
|
|
817
|
+
text: t[0],
|
|
818
|
+
tokens: this.lexer.inline(t[0])
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
escape(e) {
|
|
822
|
+
const t = this.rules.inline.escape.exec(e);
|
|
823
|
+
if (t)
|
|
824
|
+
return {
|
|
825
|
+
type: "escape",
|
|
826
|
+
raw: t[0],
|
|
827
|
+
text: xe(t[1])
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
tag(e) {
|
|
831
|
+
const t = this.rules.inline.tag.exec(e);
|
|
832
|
+
if (t)
|
|
833
|
+
return !this.lexer.state.inLink && /^<a /i.test(t[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && /^<\/a>/i.test(t[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(t[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0]) && (this.lexer.state.inRawBlock = !1), {
|
|
834
|
+
type: "html",
|
|
835
|
+
raw: t[0],
|
|
836
|
+
inLink: this.lexer.state.inLink,
|
|
837
|
+
inRawBlock: this.lexer.state.inRawBlock,
|
|
838
|
+
block: !1,
|
|
839
|
+
text: t[0]
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
link(e) {
|
|
843
|
+
const t = this.rules.inline.link.exec(e);
|
|
844
|
+
if (t) {
|
|
845
|
+
const n = t[2].trim();
|
|
846
|
+
if (!this.options.pedantic && /^</.test(n)) {
|
|
847
|
+
if (!/>$/.test(n))
|
|
848
|
+
return;
|
|
849
|
+
const i = zt(n.slice(0, -1), "\\");
|
|
850
|
+
if ((n.length - i.length) % 2 === 0)
|
|
851
|
+
return;
|
|
852
|
+
} else {
|
|
853
|
+
const i = Mi(t[2], "()");
|
|
854
|
+
if (i > -1) {
|
|
855
|
+
const c = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
|
|
856
|
+
t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, c).trim(), t[3] = "";
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
let o = t[2], r = "";
|
|
860
|
+
if (this.options.pedantic) {
|
|
861
|
+
const i = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);
|
|
862
|
+
i && (o = i[1], r = i[3]);
|
|
863
|
+
} else
|
|
864
|
+
r = t[3] ? t[3].slice(1, -1) : "";
|
|
865
|
+
return o = o.trim(), /^</.test(o) && (this.options.pedantic && !/>$/.test(n) ? o = o.slice(1) : o = o.slice(1, -1)), qn(t, {
|
|
866
|
+
href: o && o.replace(this.rules.inline.anyPunctuation, "$1"),
|
|
867
|
+
title: r && r.replace(this.rules.inline.anyPunctuation, "$1")
|
|
868
|
+
}, t[0], this.lexer);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
reflink(e, t) {
|
|
872
|
+
let n;
|
|
873
|
+
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
874
|
+
const o = (n[2] || n[1]).replace(/\s+/g, " "), r = t[o.toLowerCase()];
|
|
875
|
+
if (!r) {
|
|
876
|
+
const i = n[0].charAt(0);
|
|
877
|
+
return {
|
|
878
|
+
type: "text",
|
|
879
|
+
raw: i,
|
|
880
|
+
text: i
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
return qn(n, r, n[0], this.lexer);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
emStrong(e, t, n = "") {
|
|
887
|
+
let o = this.rules.inline.emStrongLDelim.exec(e);
|
|
888
|
+
if (!o || o[3] && n.match(/[\p{L}\p{N}]/u))
|
|
889
|
+
return;
|
|
890
|
+
if (!(o[1] || o[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
891
|
+
const i = [...o[0]].length - 1;
|
|
892
|
+
let a, c, g = i, u = 0;
|
|
893
|
+
const _ = o[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
894
|
+
for (_.lastIndex = 0, t = t.slice(-1 * e.length + i); (o = _.exec(t)) != null; ) {
|
|
895
|
+
if (a = o[1] || o[2] || o[3] || o[4] || o[5] || o[6], !a)
|
|
896
|
+
continue;
|
|
897
|
+
if (c = [...a].length, o[3] || o[4]) {
|
|
898
|
+
g += c;
|
|
899
|
+
continue;
|
|
900
|
+
} else if ((o[5] || o[6]) && i % 3 && !((i + c) % 3)) {
|
|
901
|
+
u += c;
|
|
902
|
+
continue;
|
|
903
|
+
}
|
|
904
|
+
if (g -= c, g > 0)
|
|
905
|
+
continue;
|
|
906
|
+
c = Math.min(c, c + g + u);
|
|
907
|
+
const d = [...o[0]][0].length, f = e.slice(0, i + o.index + d + c);
|
|
908
|
+
if (Math.min(i, c) % 2) {
|
|
909
|
+
const T = f.slice(1, -1);
|
|
910
|
+
return {
|
|
911
|
+
type: "em",
|
|
912
|
+
raw: f,
|
|
913
|
+
text: T,
|
|
914
|
+
tokens: this.lexer.inlineTokens(T)
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
const y = f.slice(2, -2);
|
|
918
|
+
return {
|
|
919
|
+
type: "strong",
|
|
920
|
+
raw: f,
|
|
921
|
+
text: y,
|
|
922
|
+
tokens: this.lexer.inlineTokens(y)
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
codespan(e) {
|
|
928
|
+
const t = this.rules.inline.code.exec(e);
|
|
929
|
+
if (t) {
|
|
930
|
+
let n = t[2].replace(/\n/g, " ");
|
|
931
|
+
const o = /[^ ]/.test(n), r = /^ /.test(n) && / $/.test(n);
|
|
932
|
+
return o && r && (n = n.substring(1, n.length - 1)), n = xe(n, !0), {
|
|
933
|
+
type: "codespan",
|
|
934
|
+
raw: t[0],
|
|
935
|
+
text: n
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
br(e) {
|
|
940
|
+
const t = this.rules.inline.br.exec(e);
|
|
941
|
+
if (t)
|
|
942
|
+
return {
|
|
943
|
+
type: "br",
|
|
944
|
+
raw: t[0]
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
del(e) {
|
|
948
|
+
const t = this.rules.inline.del.exec(e);
|
|
949
|
+
if (t)
|
|
950
|
+
return {
|
|
951
|
+
type: "del",
|
|
952
|
+
raw: t[0],
|
|
953
|
+
text: t[2],
|
|
954
|
+
tokens: this.lexer.inlineTokens(t[2])
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
autolink(e) {
|
|
958
|
+
const t = this.rules.inline.autolink.exec(e);
|
|
959
|
+
if (t) {
|
|
960
|
+
let n, o;
|
|
961
|
+
return t[2] === "@" ? (n = xe(t[1]), o = "mailto:" + n) : (n = xe(t[1]), o = n), {
|
|
962
|
+
type: "link",
|
|
963
|
+
raw: t[0],
|
|
964
|
+
text: n,
|
|
965
|
+
href: o,
|
|
966
|
+
tokens: [
|
|
967
|
+
{
|
|
968
|
+
type: "text",
|
|
969
|
+
raw: n,
|
|
970
|
+
text: n
|
|
971
|
+
}
|
|
972
|
+
]
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
url(e) {
|
|
977
|
+
var n;
|
|
978
|
+
let t;
|
|
979
|
+
if (t = this.rules.inline.url.exec(e)) {
|
|
980
|
+
let o, r;
|
|
981
|
+
if (t[2] === "@")
|
|
982
|
+
o = xe(t[0]), r = "mailto:" + o;
|
|
983
|
+
else {
|
|
984
|
+
let i;
|
|
985
|
+
do
|
|
986
|
+
i = t[0], t[0] = ((n = this.rules.inline._backpedal.exec(t[0])) == null ? void 0 : n[0]) ?? "";
|
|
987
|
+
while (i !== t[0]);
|
|
988
|
+
o = xe(t[0]), t[1] === "www." ? r = "http://" + t[0] : r = t[0];
|
|
989
|
+
}
|
|
990
|
+
return {
|
|
991
|
+
type: "link",
|
|
992
|
+
raw: t[0],
|
|
993
|
+
text: o,
|
|
994
|
+
href: r,
|
|
995
|
+
tokens: [
|
|
996
|
+
{
|
|
997
|
+
type: "text",
|
|
998
|
+
raw: o,
|
|
999
|
+
text: o
|
|
1000
|
+
}
|
|
1001
|
+
]
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
inlineText(e) {
|
|
1006
|
+
const t = this.rules.inline.text.exec(e);
|
|
1007
|
+
if (t) {
|
|
1008
|
+
let n;
|
|
1009
|
+
return this.lexer.state.inRawBlock ? n = t[0] : n = xe(t[0]), {
|
|
1010
|
+
type: "text",
|
|
1011
|
+
raw: t[0],
|
|
1012
|
+
text: n
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
const Ii = /^(?: *(?:\n|$))+/, Oi = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/, Ni = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, Rt = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Di = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, bs = /(?:[*+-]|\d{1,9}[.)])/, ys = G(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bs).getRegex(), yn = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, Li = /^[^\n]+/, xn = /(?!\s*\])(?:\\.|[^\[\]\\])+/, Pi = G(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", xn).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), $i = G(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bs).getRegex(), Kt = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", kn = /<!--(?!-?>)[\s\S]*?(?:-->|$)/, zi = G("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))", "i").replace("comment", kn).replace("tag", Kt).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), xs = G(yn).replace("hr", Rt).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Kt).getRegex(), Ui = G(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", xs).getRegex(), wn = {
|
|
1018
|
+
blockquote: Ui,
|
|
1019
|
+
code: Oi,
|
|
1020
|
+
def: Pi,
|
|
1021
|
+
fences: Ni,
|
|
1022
|
+
heading: Di,
|
|
1023
|
+
hr: Rt,
|
|
1024
|
+
html: zi,
|
|
1025
|
+
lheading: ys,
|
|
1026
|
+
list: $i,
|
|
1027
|
+
newline: Ii,
|
|
1028
|
+
paragraph: xs,
|
|
1029
|
+
table: Et,
|
|
1030
|
+
text: Li
|
|
1031
|
+
}, Yn = G("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", Rt).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Kt).getRegex(), Bi = {
|
|
1032
|
+
...wn,
|
|
1033
|
+
table: Yn,
|
|
1034
|
+
paragraph: G(yn).replace("hr", Rt).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", Yn).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Kt).getRegex()
|
|
1035
|
+
}, Hi = {
|
|
1036
|
+
...wn,
|
|
1037
|
+
html: G(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", kn).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
|
|
1038
|
+
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
1039
|
+
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
1040
|
+
fences: Et,
|
|
1041
|
+
// fences not supported
|
|
1042
|
+
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
1043
|
+
paragraph: G(yn).replace("hr", Rt).replace("heading", ` *#{1,6} *[^
|
|
1044
|
+
]`).replace("lheading", ys).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
|
|
1045
|
+
}, ks = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Fi = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, ws = /^( {2,}|\\)\n(?!\s*$)/, ji = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, Mt = "\\p{P}$+<=>`^|~", Wi = G(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, Mt).getRegex(), Gi = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g, qi = G(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, Mt).getRegex(), Yi = G("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, Mt).getRegex(), Zi = G("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, Mt).getRegex(), Xi = G(/\\([punct])/, "gu").replace(/punct/g, Mt).getRegex(), Vi = G(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), Ki = G(kn).replace("(?:-->|$)", "-->").getRegex(), Qi = G("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Ki).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), Gt = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, Ji = G(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", Gt).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), Es = G(/^!?\[(label)\]\[(ref)\]/).replace("label", Gt).replace("ref", xn).getRegex(), Ts = G(/^!?\[(ref)\](?:\[\])?/).replace("ref", xn).getRegex(), eo = G("reflink|nolink(?!\\()", "g").replace("reflink", Es).replace("nolink", Ts).getRegex(), En = {
|
|
1046
|
+
_backpedal: Et,
|
|
1047
|
+
// only used for GFM url
|
|
1048
|
+
anyPunctuation: Xi,
|
|
1049
|
+
autolink: Vi,
|
|
1050
|
+
blockSkip: Gi,
|
|
1051
|
+
br: ws,
|
|
1052
|
+
code: Fi,
|
|
1053
|
+
del: Et,
|
|
1054
|
+
emStrongLDelim: qi,
|
|
1055
|
+
emStrongRDelimAst: Yi,
|
|
1056
|
+
emStrongRDelimUnd: Zi,
|
|
1057
|
+
escape: ks,
|
|
1058
|
+
link: Ji,
|
|
1059
|
+
nolink: Ts,
|
|
1060
|
+
punctuation: Wi,
|
|
1061
|
+
reflink: Es,
|
|
1062
|
+
reflinkSearch: eo,
|
|
1063
|
+
tag: Qi,
|
|
1064
|
+
text: ji,
|
|
1065
|
+
url: Et
|
|
1066
|
+
}, to = {
|
|
1067
|
+
...En,
|
|
1068
|
+
link: G(/^!?\[(label)\]\((.*?)\)/).replace("label", Gt).getRegex(),
|
|
1069
|
+
reflink: G(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", Gt).getRegex()
|
|
1070
|
+
}, hn = {
|
|
1071
|
+
...En,
|
|
1072
|
+
escape: G(ks).replace("])", "~|])").getRegex(),
|
|
1073
|
+
url: G(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
|
|
1074
|
+
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
1075
|
+
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
|
|
1076
|
+
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
1077
|
+
}, no = {
|
|
1078
|
+
...hn,
|
|
1079
|
+
br: G(ws).replace("{2,}", "*").getRegex(),
|
|
1080
|
+
text: G(hn.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
1081
|
+
}, Ut = {
|
|
1082
|
+
normal: wn,
|
|
1083
|
+
gfm: Bi,
|
|
1084
|
+
pedantic: Hi
|
|
1085
|
+
}, mt = {
|
|
1086
|
+
normal: En,
|
|
1087
|
+
gfm: hn,
|
|
1088
|
+
breaks: no,
|
|
1089
|
+
pedantic: to
|
|
1090
|
+
};
|
|
1091
|
+
class Ce {
|
|
1092
|
+
constructor(e) {
|
|
1093
|
+
B(this, "tokens");
|
|
1094
|
+
B(this, "options");
|
|
1095
|
+
B(this, "state");
|
|
1096
|
+
B(this, "tokenizer");
|
|
1097
|
+
B(this, "inlineQueue");
|
|
1098
|
+
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || nt, this.options.tokenizer = this.options.tokenizer || new Wt(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
|
|
1099
|
+
inLink: !1,
|
|
1100
|
+
inRawBlock: !1,
|
|
1101
|
+
top: !0
|
|
1102
|
+
};
|
|
1103
|
+
const t = {
|
|
1104
|
+
block: Ut.normal,
|
|
1105
|
+
inline: mt.normal
|
|
1106
|
+
};
|
|
1107
|
+
this.options.pedantic ? (t.block = Ut.pedantic, t.inline = mt.pedantic) : this.options.gfm && (t.block = Ut.gfm, this.options.breaks ? t.inline = mt.breaks : t.inline = mt.gfm), this.tokenizer.rules = t;
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* Expose Rules
|
|
1111
|
+
*/
|
|
1112
|
+
static get rules() {
|
|
1113
|
+
return {
|
|
1114
|
+
block: Ut,
|
|
1115
|
+
inline: mt
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Static Lex Method
|
|
1120
|
+
*/
|
|
1121
|
+
static lex(e, t) {
|
|
1122
|
+
return new Ce(t).lex(e);
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Static Lex Inline Method
|
|
1126
|
+
*/
|
|
1127
|
+
static lexInline(e, t) {
|
|
1128
|
+
return new Ce(t).inlineTokens(e);
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Preprocessing
|
|
1132
|
+
*/
|
|
1133
|
+
lex(e) {
|
|
1134
|
+
e = e.replace(/\r\n|\r/g, `
|
|
1135
|
+
`), this.blockTokens(e, this.tokens);
|
|
1136
|
+
for (let t = 0; t < this.inlineQueue.length; t++) {
|
|
1137
|
+
const n = this.inlineQueue[t];
|
|
1138
|
+
this.inlineTokens(n.src, n.tokens);
|
|
1139
|
+
}
|
|
1140
|
+
return this.inlineQueue = [], this.tokens;
|
|
1141
|
+
}
|
|
1142
|
+
blockTokens(e, t = []) {
|
|
1143
|
+
this.options.pedantic ? e = e.replace(/\t/g, " ").replace(/^ +$/gm, "") : e = e.replace(/^( *)(\t+)/gm, (a, c, g) => c + " ".repeat(g.length));
|
|
1144
|
+
let n, o, r, i;
|
|
1145
|
+
for (; e; )
|
|
1146
|
+
if (!(this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((a) => (n = a.call({ lexer: this }, e, t)) ? (e = e.substring(n.raw.length), t.push(n), !0) : !1))) {
|
|
1147
|
+
if (n = this.tokenizer.space(e)) {
|
|
1148
|
+
e = e.substring(n.raw.length), n.raw.length === 1 && t.length > 0 ? t[t.length - 1].raw += `
|
|
1149
|
+
` : t.push(n);
|
|
1150
|
+
continue;
|
|
1151
|
+
}
|
|
1152
|
+
if (n = this.tokenizer.code(e)) {
|
|
1153
|
+
e = e.substring(n.raw.length), o = t[t.length - 1], o && (o.type === "paragraph" || o.type === "text") ? (o.raw += `
|
|
1154
|
+
` + n.raw, o.text += `
|
|
1155
|
+
` + n.text, this.inlineQueue[this.inlineQueue.length - 1].src = o.text) : t.push(n);
|
|
1156
|
+
continue;
|
|
1157
|
+
}
|
|
1158
|
+
if (n = this.tokenizer.fences(e)) {
|
|
1159
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1160
|
+
continue;
|
|
1161
|
+
}
|
|
1162
|
+
if (n = this.tokenizer.heading(e)) {
|
|
1163
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1164
|
+
continue;
|
|
1165
|
+
}
|
|
1166
|
+
if (n = this.tokenizer.hr(e)) {
|
|
1167
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1168
|
+
continue;
|
|
1169
|
+
}
|
|
1170
|
+
if (n = this.tokenizer.blockquote(e)) {
|
|
1171
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1172
|
+
continue;
|
|
1173
|
+
}
|
|
1174
|
+
if (n = this.tokenizer.list(e)) {
|
|
1175
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1176
|
+
continue;
|
|
1177
|
+
}
|
|
1178
|
+
if (n = this.tokenizer.html(e)) {
|
|
1179
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1180
|
+
continue;
|
|
1181
|
+
}
|
|
1182
|
+
if (n = this.tokenizer.def(e)) {
|
|
1183
|
+
e = e.substring(n.raw.length), o = t[t.length - 1], o && (o.type === "paragraph" || o.type === "text") ? (o.raw += `
|
|
1184
|
+
` + n.raw, o.text += `
|
|
1185
|
+
` + n.raw, this.inlineQueue[this.inlineQueue.length - 1].src = o.text) : this.tokens.links[n.tag] || (this.tokens.links[n.tag] = {
|
|
1186
|
+
href: n.href,
|
|
1187
|
+
title: n.title
|
|
1188
|
+
});
|
|
1189
|
+
continue;
|
|
1190
|
+
}
|
|
1191
|
+
if (n = this.tokenizer.table(e)) {
|
|
1192
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1193
|
+
continue;
|
|
1194
|
+
}
|
|
1195
|
+
if (n = this.tokenizer.lheading(e)) {
|
|
1196
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1197
|
+
continue;
|
|
1198
|
+
}
|
|
1199
|
+
if (r = e, this.options.extensions && this.options.extensions.startBlock) {
|
|
1200
|
+
let a = 1 / 0;
|
|
1201
|
+
const c = e.slice(1);
|
|
1202
|
+
let g;
|
|
1203
|
+
this.options.extensions.startBlock.forEach((u) => {
|
|
1204
|
+
g = u.call({ lexer: this }, c), typeof g == "number" && g >= 0 && (a = Math.min(a, g));
|
|
1205
|
+
}), a < 1 / 0 && a >= 0 && (r = e.substring(0, a + 1));
|
|
1206
|
+
}
|
|
1207
|
+
if (this.state.top && (n = this.tokenizer.paragraph(r))) {
|
|
1208
|
+
o = t[t.length - 1], i && o.type === "paragraph" ? (o.raw += `
|
|
1209
|
+
` + n.raw, o.text += `
|
|
1210
|
+
` + n.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src = o.text) : t.push(n), i = r.length !== e.length, e = e.substring(n.raw.length);
|
|
1211
|
+
continue;
|
|
1212
|
+
}
|
|
1213
|
+
if (n = this.tokenizer.text(e)) {
|
|
1214
|
+
e = e.substring(n.raw.length), o = t[t.length - 1], o && o.type === "text" ? (o.raw += `
|
|
1215
|
+
` + n.raw, o.text += `
|
|
1216
|
+
` + n.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src = o.text) : t.push(n);
|
|
1217
|
+
continue;
|
|
1218
|
+
}
|
|
1219
|
+
if (e) {
|
|
1220
|
+
const a = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
1221
|
+
if (this.options.silent) {
|
|
1222
|
+
console.error(a);
|
|
1223
|
+
break;
|
|
1224
|
+
} else
|
|
1225
|
+
throw new Error(a);
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
return this.state.top = !0, t;
|
|
1229
|
+
}
|
|
1230
|
+
inline(e, t = []) {
|
|
1231
|
+
return this.inlineQueue.push({ src: e, tokens: t }), t;
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Lexing/Compiling
|
|
1235
|
+
*/
|
|
1236
|
+
inlineTokens(e, t = []) {
|
|
1237
|
+
let n, o, r, i = e, a, c, g;
|
|
1238
|
+
if (this.tokens.links) {
|
|
1239
|
+
const u = Object.keys(this.tokens.links);
|
|
1240
|
+
if (u.length > 0)
|
|
1241
|
+
for (; (a = this.tokenizer.rules.inline.reflinkSearch.exec(i)) != null; )
|
|
1242
|
+
u.includes(a[0].slice(a[0].lastIndexOf("[") + 1, -1)) && (i = i.slice(0, a.index) + "[" + "a".repeat(a[0].length - 2) + "]" + i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
|
|
1243
|
+
}
|
|
1244
|
+
for (; (a = this.tokenizer.rules.inline.blockSkip.exec(i)) != null; )
|
|
1245
|
+
i = i.slice(0, a.index) + "[" + "a".repeat(a[0].length - 2) + "]" + i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
1246
|
+
for (; (a = this.tokenizer.rules.inline.anyPunctuation.exec(i)) != null; )
|
|
1247
|
+
i = i.slice(0, a.index) + "++" + i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
1248
|
+
for (; e; )
|
|
1249
|
+
if (c || (g = ""), c = !1, !(this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((u) => (n = u.call({ lexer: this }, e, t)) ? (e = e.substring(n.raw.length), t.push(n), !0) : !1))) {
|
|
1250
|
+
if (n = this.tokenizer.escape(e)) {
|
|
1251
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1252
|
+
continue;
|
|
1253
|
+
}
|
|
1254
|
+
if (n = this.tokenizer.tag(e)) {
|
|
1255
|
+
e = e.substring(n.raw.length), o = t[t.length - 1], o && n.type === "text" && o.type === "text" ? (o.raw += n.raw, o.text += n.text) : t.push(n);
|
|
1256
|
+
continue;
|
|
1257
|
+
}
|
|
1258
|
+
if (n = this.tokenizer.link(e)) {
|
|
1259
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1260
|
+
continue;
|
|
1261
|
+
}
|
|
1262
|
+
if (n = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
1263
|
+
e = e.substring(n.raw.length), o = t[t.length - 1], o && n.type === "text" && o.type === "text" ? (o.raw += n.raw, o.text += n.text) : t.push(n);
|
|
1264
|
+
continue;
|
|
1265
|
+
}
|
|
1266
|
+
if (n = this.tokenizer.emStrong(e, i, g)) {
|
|
1267
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1268
|
+
continue;
|
|
1269
|
+
}
|
|
1270
|
+
if (n = this.tokenizer.codespan(e)) {
|
|
1271
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1272
|
+
continue;
|
|
1273
|
+
}
|
|
1274
|
+
if (n = this.tokenizer.br(e)) {
|
|
1275
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1276
|
+
continue;
|
|
1277
|
+
}
|
|
1278
|
+
if (n = this.tokenizer.del(e)) {
|
|
1279
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1280
|
+
continue;
|
|
1281
|
+
}
|
|
1282
|
+
if (n = this.tokenizer.autolink(e)) {
|
|
1283
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1284
|
+
continue;
|
|
1285
|
+
}
|
|
1286
|
+
if (!this.state.inLink && (n = this.tokenizer.url(e))) {
|
|
1287
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1288
|
+
continue;
|
|
1289
|
+
}
|
|
1290
|
+
if (r = e, this.options.extensions && this.options.extensions.startInline) {
|
|
1291
|
+
let u = 1 / 0;
|
|
1292
|
+
const _ = e.slice(1);
|
|
1293
|
+
let d;
|
|
1294
|
+
this.options.extensions.startInline.forEach((f) => {
|
|
1295
|
+
d = f.call({ lexer: this }, _), typeof d == "number" && d >= 0 && (u = Math.min(u, d));
|
|
1296
|
+
}), u < 1 / 0 && u >= 0 && (r = e.substring(0, u + 1));
|
|
1297
|
+
}
|
|
1298
|
+
if (n = this.tokenizer.inlineText(r)) {
|
|
1299
|
+
e = e.substring(n.raw.length), n.raw.slice(-1) !== "_" && (g = n.raw.slice(-1)), c = !0, o = t[t.length - 1], o && o.type === "text" ? (o.raw += n.raw, o.text += n.text) : t.push(n);
|
|
1300
|
+
continue;
|
|
1301
|
+
}
|
|
1302
|
+
if (e) {
|
|
1303
|
+
const u = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
1304
|
+
if (this.options.silent) {
|
|
1305
|
+
console.error(u);
|
|
1306
|
+
break;
|
|
1307
|
+
} else
|
|
1308
|
+
throw new Error(u);
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
return t;
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
class qt {
|
|
1315
|
+
constructor(e) {
|
|
1316
|
+
B(this, "options");
|
|
1317
|
+
this.options = e || nt;
|
|
1318
|
+
}
|
|
1319
|
+
code(e, t, n) {
|
|
1320
|
+
var r;
|
|
1321
|
+
const o = (r = (t || "").match(/^\S*/)) == null ? void 0 : r[0];
|
|
1322
|
+
return e = e.replace(/\n$/, "") + `
|
|
1323
|
+
`, o ? '<pre><code class="language-' + xe(o) + '">' + (n ? e : xe(e, !0)) + `</code></pre>
|
|
1324
|
+
` : "<pre><code>" + (n ? e : xe(e, !0)) + `</code></pre>
|
|
1325
|
+
`;
|
|
1326
|
+
}
|
|
1327
|
+
blockquote(e) {
|
|
1328
|
+
return `<blockquote>
|
|
1329
|
+
${e}</blockquote>
|
|
1330
|
+
`;
|
|
1331
|
+
}
|
|
1332
|
+
html(e, t) {
|
|
1333
|
+
return e;
|
|
1334
|
+
}
|
|
1335
|
+
heading(e, t, n) {
|
|
1336
|
+
return `<h${t}>${e}</h${t}>
|
|
1337
|
+
`;
|
|
1338
|
+
}
|
|
1339
|
+
hr() {
|
|
1340
|
+
return `<hr>
|
|
1341
|
+
`;
|
|
1342
|
+
}
|
|
1343
|
+
list(e, t, n) {
|
|
1344
|
+
const o = t ? "ol" : "ul", r = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
1345
|
+
return "<" + o + r + `>
|
|
1346
|
+
` + e + "</" + o + `>
|
|
1347
|
+
`;
|
|
1348
|
+
}
|
|
1349
|
+
listitem(e, t, n) {
|
|
1350
|
+
return `<li>${e}</li>
|
|
1351
|
+
`;
|
|
1352
|
+
}
|
|
1353
|
+
checkbox(e) {
|
|
1354
|
+
return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
|
|
1355
|
+
}
|
|
1356
|
+
paragraph(e) {
|
|
1357
|
+
return `<p>${e}</p>
|
|
1358
|
+
`;
|
|
1359
|
+
}
|
|
1360
|
+
table(e, t) {
|
|
1361
|
+
return t && (t = `<tbody>${t}</tbody>`), `<table>
|
|
1362
|
+
<thead>
|
|
1363
|
+
` + e + `</thead>
|
|
1364
|
+
` + t + `</table>
|
|
1365
|
+
`;
|
|
1366
|
+
}
|
|
1367
|
+
tablerow(e) {
|
|
1368
|
+
return `<tr>
|
|
1369
|
+
${e}</tr>
|
|
1370
|
+
`;
|
|
1371
|
+
}
|
|
1372
|
+
tablecell(e, t) {
|
|
1373
|
+
const n = t.header ? "th" : "td";
|
|
1374
|
+
return (t.align ? `<${n} align="${t.align}">` : `<${n}>`) + e + `</${n}>
|
|
1375
|
+
`;
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* span level renderer
|
|
1379
|
+
*/
|
|
1380
|
+
strong(e) {
|
|
1381
|
+
return `<strong>${e}</strong>`;
|
|
1382
|
+
}
|
|
1383
|
+
em(e) {
|
|
1384
|
+
return `<em>${e}</em>`;
|
|
1385
|
+
}
|
|
1386
|
+
codespan(e) {
|
|
1387
|
+
return `<code>${e}</code>`;
|
|
1388
|
+
}
|
|
1389
|
+
br() {
|
|
1390
|
+
return "<br>";
|
|
1391
|
+
}
|
|
1392
|
+
del(e) {
|
|
1393
|
+
return `<del>${e}</del>`;
|
|
1394
|
+
}
|
|
1395
|
+
link(e, t, n) {
|
|
1396
|
+
const o = Wn(e);
|
|
1397
|
+
if (o === null)
|
|
1398
|
+
return n;
|
|
1399
|
+
e = o;
|
|
1400
|
+
let r = '<a href="' + e + '"';
|
|
1401
|
+
return t && (r += ' title="' + t + '"'), r += ">" + n + "</a>", r;
|
|
1402
|
+
}
|
|
1403
|
+
image(e, t, n) {
|
|
1404
|
+
const o = Wn(e);
|
|
1405
|
+
if (o === null)
|
|
1406
|
+
return n;
|
|
1407
|
+
e = o;
|
|
1408
|
+
let r = `<img src="${e}" alt="${n}"`;
|
|
1409
|
+
return t && (r += ` title="${t}"`), r += ">", r;
|
|
1410
|
+
}
|
|
1411
|
+
text(e) {
|
|
1412
|
+
return e;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
class Tn {
|
|
1416
|
+
// no need for block level renderers
|
|
1417
|
+
strong(e) {
|
|
1418
|
+
return e;
|
|
1419
|
+
}
|
|
1420
|
+
em(e) {
|
|
1421
|
+
return e;
|
|
1422
|
+
}
|
|
1423
|
+
codespan(e) {
|
|
1424
|
+
return e;
|
|
1425
|
+
}
|
|
1426
|
+
del(e) {
|
|
1427
|
+
return e;
|
|
1428
|
+
}
|
|
1429
|
+
html(e) {
|
|
1430
|
+
return e;
|
|
1431
|
+
}
|
|
1432
|
+
text(e) {
|
|
1433
|
+
return e;
|
|
1434
|
+
}
|
|
1435
|
+
link(e, t, n) {
|
|
1436
|
+
return "" + n;
|
|
1437
|
+
}
|
|
1438
|
+
image(e, t, n) {
|
|
1439
|
+
return "" + n;
|
|
1440
|
+
}
|
|
1441
|
+
br() {
|
|
1442
|
+
return "";
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
class Ie {
|
|
1446
|
+
constructor(e) {
|
|
1447
|
+
B(this, "options");
|
|
1448
|
+
B(this, "renderer");
|
|
1449
|
+
B(this, "textRenderer");
|
|
1450
|
+
this.options = e || nt, this.options.renderer = this.options.renderer || new qt(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.textRenderer = new Tn();
|
|
1451
|
+
}
|
|
1452
|
+
/**
|
|
1453
|
+
* Static Parse Method
|
|
1454
|
+
*/
|
|
1455
|
+
static parse(e, t) {
|
|
1456
|
+
return new Ie(t).parse(e);
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* Static Parse Inline Method
|
|
1460
|
+
*/
|
|
1461
|
+
static parseInline(e, t) {
|
|
1462
|
+
return new Ie(t).parseInline(e);
|
|
1463
|
+
}
|
|
1464
|
+
/**
|
|
1465
|
+
* Parse Loop
|
|
1466
|
+
*/
|
|
1467
|
+
parse(e, t = !0) {
|
|
1468
|
+
let n = "";
|
|
1469
|
+
for (let o = 0; o < e.length; o++) {
|
|
1470
|
+
const r = e[o];
|
|
1471
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[r.type]) {
|
|
1472
|
+
const i = r, a = this.options.extensions.renderers[i.type].call({ parser: this }, i);
|
|
1473
|
+
if (a !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(i.type)) {
|
|
1474
|
+
n += a || "";
|
|
1475
|
+
continue;
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
switch (r.type) {
|
|
1479
|
+
case "space":
|
|
1480
|
+
continue;
|
|
1481
|
+
case "hr": {
|
|
1482
|
+
n += this.renderer.hr();
|
|
1483
|
+
continue;
|
|
1484
|
+
}
|
|
1485
|
+
case "heading": {
|
|
1486
|
+
const i = r;
|
|
1487
|
+
n += this.renderer.heading(this.parseInline(i.tokens), i.depth, Ai(this.parseInline(i.tokens, this.textRenderer)));
|
|
1488
|
+
continue;
|
|
1489
|
+
}
|
|
1490
|
+
case "code": {
|
|
1491
|
+
const i = r;
|
|
1492
|
+
n += this.renderer.code(i.text, i.lang, !!i.escaped);
|
|
1493
|
+
continue;
|
|
1494
|
+
}
|
|
1495
|
+
case "table": {
|
|
1496
|
+
const i = r;
|
|
1497
|
+
let a = "", c = "";
|
|
1498
|
+
for (let u = 0; u < i.header.length; u++)
|
|
1499
|
+
c += this.renderer.tablecell(this.parseInline(i.header[u].tokens), { header: !0, align: i.align[u] });
|
|
1500
|
+
a += this.renderer.tablerow(c);
|
|
1501
|
+
let g = "";
|
|
1502
|
+
for (let u = 0; u < i.rows.length; u++) {
|
|
1503
|
+
const _ = i.rows[u];
|
|
1504
|
+
c = "";
|
|
1505
|
+
for (let d = 0; d < _.length; d++)
|
|
1506
|
+
c += this.renderer.tablecell(this.parseInline(_[d].tokens), { header: !1, align: i.align[d] });
|
|
1507
|
+
g += this.renderer.tablerow(c);
|
|
1508
|
+
}
|
|
1509
|
+
n += this.renderer.table(a, g);
|
|
1510
|
+
continue;
|
|
1511
|
+
}
|
|
1512
|
+
case "blockquote": {
|
|
1513
|
+
const i = r, a = this.parse(i.tokens);
|
|
1514
|
+
n += this.renderer.blockquote(a);
|
|
1515
|
+
continue;
|
|
1516
|
+
}
|
|
1517
|
+
case "list": {
|
|
1518
|
+
const i = r, a = i.ordered, c = i.start, g = i.loose;
|
|
1519
|
+
let u = "";
|
|
1520
|
+
for (let _ = 0; _ < i.items.length; _++) {
|
|
1521
|
+
const d = i.items[_], f = d.checked, y = d.task;
|
|
1522
|
+
let T = "";
|
|
1523
|
+
if (d.task) {
|
|
1524
|
+
const M = this.renderer.checkbox(!!f);
|
|
1525
|
+
g ? d.tokens.length > 0 && d.tokens[0].type === "paragraph" ? (d.tokens[0].text = M + " " + d.tokens[0].text, d.tokens[0].tokens && d.tokens[0].tokens.length > 0 && d.tokens[0].tokens[0].type === "text" && (d.tokens[0].tokens[0].text = M + " " + d.tokens[0].tokens[0].text)) : d.tokens.unshift({
|
|
1526
|
+
type: "text",
|
|
1527
|
+
text: M + " "
|
|
1528
|
+
}) : T += M + " ";
|
|
1529
|
+
}
|
|
1530
|
+
T += this.parse(d.tokens, g), u += this.renderer.listitem(T, y, !!f);
|
|
1531
|
+
}
|
|
1532
|
+
n += this.renderer.list(u, a, c);
|
|
1533
|
+
continue;
|
|
1534
|
+
}
|
|
1535
|
+
case "html": {
|
|
1536
|
+
const i = r;
|
|
1537
|
+
n += this.renderer.html(i.text, i.block);
|
|
1538
|
+
continue;
|
|
1539
|
+
}
|
|
1540
|
+
case "paragraph": {
|
|
1541
|
+
const i = r;
|
|
1542
|
+
n += this.renderer.paragraph(this.parseInline(i.tokens));
|
|
1543
|
+
continue;
|
|
1544
|
+
}
|
|
1545
|
+
case "text": {
|
|
1546
|
+
let i = r, a = i.tokens ? this.parseInline(i.tokens) : i.text;
|
|
1547
|
+
for (; o + 1 < e.length && e[o + 1].type === "text"; )
|
|
1548
|
+
i = e[++o], a += `
|
|
1549
|
+
` + (i.tokens ? this.parseInline(i.tokens) : i.text);
|
|
1550
|
+
n += t ? this.renderer.paragraph(a) : a;
|
|
1551
|
+
continue;
|
|
1552
|
+
}
|
|
1553
|
+
default: {
|
|
1554
|
+
const i = 'Token with "' + r.type + '" type was not found.';
|
|
1555
|
+
if (this.options.silent)
|
|
1556
|
+
return console.error(i), "";
|
|
1557
|
+
throw new Error(i);
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
return n;
|
|
1562
|
+
}
|
|
1563
|
+
/**
|
|
1564
|
+
* Parse Inline Tokens
|
|
1565
|
+
*/
|
|
1566
|
+
parseInline(e, t) {
|
|
1567
|
+
t = t || this.renderer;
|
|
1568
|
+
let n = "";
|
|
1569
|
+
for (let o = 0; o < e.length; o++) {
|
|
1570
|
+
const r = e[o];
|
|
1571
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[r.type]) {
|
|
1572
|
+
const i = this.options.extensions.renderers[r.type].call({ parser: this }, r);
|
|
1573
|
+
if (i !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
|
|
1574
|
+
n += i || "";
|
|
1575
|
+
continue;
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
switch (r.type) {
|
|
1579
|
+
case "escape": {
|
|
1580
|
+
const i = r;
|
|
1581
|
+
n += t.text(i.text);
|
|
1582
|
+
break;
|
|
1583
|
+
}
|
|
1584
|
+
case "html": {
|
|
1585
|
+
const i = r;
|
|
1586
|
+
n += t.html(i.text);
|
|
1587
|
+
break;
|
|
1588
|
+
}
|
|
1589
|
+
case "link": {
|
|
1590
|
+
const i = r;
|
|
1591
|
+
n += t.link(i.href, i.title, this.parseInline(i.tokens, t));
|
|
1592
|
+
break;
|
|
1593
|
+
}
|
|
1594
|
+
case "image": {
|
|
1595
|
+
const i = r;
|
|
1596
|
+
n += t.image(i.href, i.title, i.text);
|
|
1597
|
+
break;
|
|
1598
|
+
}
|
|
1599
|
+
case "strong": {
|
|
1600
|
+
const i = r;
|
|
1601
|
+
n += t.strong(this.parseInline(i.tokens, t));
|
|
1602
|
+
break;
|
|
1603
|
+
}
|
|
1604
|
+
case "em": {
|
|
1605
|
+
const i = r;
|
|
1606
|
+
n += t.em(this.parseInline(i.tokens, t));
|
|
1607
|
+
break;
|
|
1608
|
+
}
|
|
1609
|
+
case "codespan": {
|
|
1610
|
+
const i = r;
|
|
1611
|
+
n += t.codespan(i.text);
|
|
1612
|
+
break;
|
|
1613
|
+
}
|
|
1614
|
+
case "br": {
|
|
1615
|
+
n += t.br();
|
|
1616
|
+
break;
|
|
1617
|
+
}
|
|
1618
|
+
case "del": {
|
|
1619
|
+
const i = r;
|
|
1620
|
+
n += t.del(this.parseInline(i.tokens, t));
|
|
1621
|
+
break;
|
|
1622
|
+
}
|
|
1623
|
+
case "text": {
|
|
1624
|
+
const i = r;
|
|
1625
|
+
n += t.text(i.text);
|
|
1626
|
+
break;
|
|
1627
|
+
}
|
|
1628
|
+
default: {
|
|
1629
|
+
const i = 'Token with "' + r.type + '" type was not found.';
|
|
1630
|
+
if (this.options.silent)
|
|
1631
|
+
return console.error(i), "";
|
|
1632
|
+
throw new Error(i);
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
return n;
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
class Tt {
|
|
1640
|
+
constructor(e) {
|
|
1641
|
+
B(this, "options");
|
|
1642
|
+
this.options = e || nt;
|
|
1643
|
+
}
|
|
1644
|
+
/**
|
|
1645
|
+
* Process markdown before marked
|
|
1646
|
+
*/
|
|
1647
|
+
preprocess(e) {
|
|
1648
|
+
return e;
|
|
1649
|
+
}
|
|
1650
|
+
/**
|
|
1651
|
+
* Process HTML after marked is finished
|
|
1652
|
+
*/
|
|
1653
|
+
postprocess(e) {
|
|
1654
|
+
return e;
|
|
1655
|
+
}
|
|
1656
|
+
/**
|
|
1657
|
+
* Process all tokens before walk tokens
|
|
1658
|
+
*/
|
|
1659
|
+
processAllTokens(e) {
|
|
1660
|
+
return e;
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
B(Tt, "passThroughHooks", /* @__PURE__ */ new Set([
|
|
1664
|
+
"preprocess",
|
|
1665
|
+
"postprocess",
|
|
1666
|
+
"processAllTokens"
|
|
1667
|
+
]));
|
|
1668
|
+
var At, dn, Zt, vs;
|
|
1669
|
+
class so {
|
|
1670
|
+
constructor(...e) {
|
|
1671
|
+
on(this, At);
|
|
1672
|
+
on(this, Zt);
|
|
1673
|
+
B(this, "defaults", bn());
|
|
1674
|
+
B(this, "options", this.setOptions);
|
|
1675
|
+
B(this, "parse", $t(this, At, dn).call(this, Ce.lex, Ie.parse));
|
|
1676
|
+
B(this, "parseInline", $t(this, At, dn).call(this, Ce.lexInline, Ie.parseInline));
|
|
1677
|
+
B(this, "Parser", Ie);
|
|
1678
|
+
B(this, "Renderer", qt);
|
|
1679
|
+
B(this, "TextRenderer", Tn);
|
|
1680
|
+
B(this, "Lexer", Ce);
|
|
1681
|
+
B(this, "Tokenizer", Wt);
|
|
1682
|
+
B(this, "Hooks", Tt);
|
|
1683
|
+
this.use(...e);
|
|
1684
|
+
}
|
|
1685
|
+
/**
|
|
1686
|
+
* Run callback for every token
|
|
1687
|
+
*/
|
|
1688
|
+
walkTokens(e, t) {
|
|
1689
|
+
var o, r;
|
|
1690
|
+
let n = [];
|
|
1691
|
+
for (const i of e)
|
|
1692
|
+
switch (n = n.concat(t.call(this, i)), i.type) {
|
|
1693
|
+
case "table": {
|
|
1694
|
+
const a = i;
|
|
1695
|
+
for (const c of a.header)
|
|
1696
|
+
n = n.concat(this.walkTokens(c.tokens, t));
|
|
1697
|
+
for (const c of a.rows)
|
|
1698
|
+
for (const g of c)
|
|
1699
|
+
n = n.concat(this.walkTokens(g.tokens, t));
|
|
1700
|
+
break;
|
|
1701
|
+
}
|
|
1702
|
+
case "list": {
|
|
1703
|
+
const a = i;
|
|
1704
|
+
n = n.concat(this.walkTokens(a.items, t));
|
|
1705
|
+
break;
|
|
1706
|
+
}
|
|
1707
|
+
default: {
|
|
1708
|
+
const a = i;
|
|
1709
|
+
(r = (o = this.defaults.extensions) == null ? void 0 : o.childTokens) != null && r[a.type] ? this.defaults.extensions.childTokens[a.type].forEach((c) => {
|
|
1710
|
+
const g = a[c].flat(1 / 0);
|
|
1711
|
+
n = n.concat(this.walkTokens(g, t));
|
|
1712
|
+
}) : a.tokens && (n = n.concat(this.walkTokens(a.tokens, t)));
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
return n;
|
|
1716
|
+
}
|
|
1717
|
+
use(...e) {
|
|
1718
|
+
const t = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
1719
|
+
return e.forEach((n) => {
|
|
1720
|
+
const o = { ...n };
|
|
1721
|
+
if (o.async = this.defaults.async || o.async || !1, n.extensions && (n.extensions.forEach((r) => {
|
|
1722
|
+
if (!r.name)
|
|
1723
|
+
throw new Error("extension name required");
|
|
1724
|
+
if ("renderer" in r) {
|
|
1725
|
+
const i = t.renderers[r.name];
|
|
1726
|
+
i ? t.renderers[r.name] = function(...a) {
|
|
1727
|
+
let c = r.renderer.apply(this, a);
|
|
1728
|
+
return c === !1 && (c = i.apply(this, a)), c;
|
|
1729
|
+
} : t.renderers[r.name] = r.renderer;
|
|
1730
|
+
}
|
|
1731
|
+
if ("tokenizer" in r) {
|
|
1732
|
+
if (!r.level || r.level !== "block" && r.level !== "inline")
|
|
1733
|
+
throw new Error("extension level must be 'block' or 'inline'");
|
|
1734
|
+
const i = t[r.level];
|
|
1735
|
+
i ? i.unshift(r.tokenizer) : t[r.level] = [r.tokenizer], r.start && (r.level === "block" ? t.startBlock ? t.startBlock.push(r.start) : t.startBlock = [r.start] : r.level === "inline" && (t.startInline ? t.startInline.push(r.start) : t.startInline = [r.start]));
|
|
1736
|
+
}
|
|
1737
|
+
"childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
|
|
1738
|
+
}), o.extensions = t), n.renderer) {
|
|
1739
|
+
const r = this.defaults.renderer || new qt(this.defaults);
|
|
1740
|
+
for (const i in n.renderer) {
|
|
1741
|
+
if (!(i in r))
|
|
1742
|
+
throw new Error(`renderer '${i}' does not exist`);
|
|
1743
|
+
if (i === "options")
|
|
1744
|
+
continue;
|
|
1745
|
+
const a = i, c = n.renderer[a], g = r[a];
|
|
1746
|
+
r[a] = (...u) => {
|
|
1747
|
+
let _ = c.apply(r, u);
|
|
1748
|
+
return _ === !1 && (_ = g.apply(r, u)), _ || "";
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
o.renderer = r;
|
|
1752
|
+
}
|
|
1753
|
+
if (n.tokenizer) {
|
|
1754
|
+
const r = this.defaults.tokenizer || new Wt(this.defaults);
|
|
1755
|
+
for (const i in n.tokenizer) {
|
|
1756
|
+
if (!(i in r))
|
|
1757
|
+
throw new Error(`tokenizer '${i}' does not exist`);
|
|
1758
|
+
if (["options", "rules", "lexer"].includes(i))
|
|
1759
|
+
continue;
|
|
1760
|
+
const a = i, c = n.tokenizer[a], g = r[a];
|
|
1761
|
+
r[a] = (...u) => {
|
|
1762
|
+
let _ = c.apply(r, u);
|
|
1763
|
+
return _ === !1 && (_ = g.apply(r, u)), _;
|
|
1764
|
+
};
|
|
1765
|
+
}
|
|
1766
|
+
o.tokenizer = r;
|
|
1767
|
+
}
|
|
1768
|
+
if (n.hooks) {
|
|
1769
|
+
const r = this.defaults.hooks || new Tt();
|
|
1770
|
+
for (const i in n.hooks) {
|
|
1771
|
+
if (!(i in r))
|
|
1772
|
+
throw new Error(`hook '${i}' does not exist`);
|
|
1773
|
+
if (i === "options")
|
|
1774
|
+
continue;
|
|
1775
|
+
const a = i, c = n.hooks[a], g = r[a];
|
|
1776
|
+
Tt.passThroughHooks.has(i) ? r[a] = (u) => {
|
|
1777
|
+
if (this.defaults.async)
|
|
1778
|
+
return Promise.resolve(c.call(r, u)).then((d) => g.call(r, d));
|
|
1779
|
+
const _ = c.call(r, u);
|
|
1780
|
+
return g.call(r, _);
|
|
1781
|
+
} : r[a] = (...u) => {
|
|
1782
|
+
let _ = c.apply(r, u);
|
|
1783
|
+
return _ === !1 && (_ = g.apply(r, u)), _;
|
|
1784
|
+
};
|
|
1785
|
+
}
|
|
1786
|
+
o.hooks = r;
|
|
1787
|
+
}
|
|
1788
|
+
if (n.walkTokens) {
|
|
1789
|
+
const r = this.defaults.walkTokens, i = n.walkTokens;
|
|
1790
|
+
o.walkTokens = function(a) {
|
|
1791
|
+
let c = [];
|
|
1792
|
+
return c.push(i.call(this, a)), r && (c = c.concat(r.call(this, a))), c;
|
|
1793
|
+
};
|
|
1794
|
+
}
|
|
1795
|
+
this.defaults = { ...this.defaults, ...o };
|
|
1796
|
+
}), this;
|
|
1797
|
+
}
|
|
1798
|
+
setOptions(e) {
|
|
1799
|
+
return this.defaults = { ...this.defaults, ...e }, this;
|
|
1800
|
+
}
|
|
1801
|
+
lexer(e, t) {
|
|
1802
|
+
return Ce.lex(e, t ?? this.defaults);
|
|
1803
|
+
}
|
|
1804
|
+
parser(e, t) {
|
|
1805
|
+
return Ie.parse(e, t ?? this.defaults);
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
At = new WeakSet(), dn = function(e, t) {
|
|
1809
|
+
return (n, o) => {
|
|
1810
|
+
const r = { ...o }, i = { ...this.defaults, ...r };
|
|
1811
|
+
this.defaults.async === !0 && r.async === !1 && (i.silent || console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."), i.async = !0);
|
|
1812
|
+
const a = $t(this, Zt, vs).call(this, !!i.silent, !!i.async);
|
|
1813
|
+
if (typeof n > "u" || n === null)
|
|
1814
|
+
return a(new Error("marked(): input parameter is undefined or null"));
|
|
1815
|
+
if (typeof n != "string")
|
|
1816
|
+
return a(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
1817
|
+
if (i.hooks && (i.hooks.options = i), i.async)
|
|
1818
|
+
return Promise.resolve(i.hooks ? i.hooks.preprocess(n) : n).then((c) => e(c, i)).then((c) => i.hooks ? i.hooks.processAllTokens(c) : c).then((c) => i.walkTokens ? Promise.all(this.walkTokens(c, i.walkTokens)).then(() => c) : c).then((c) => t(c, i)).then((c) => i.hooks ? i.hooks.postprocess(c) : c).catch(a);
|
|
1819
|
+
try {
|
|
1820
|
+
i.hooks && (n = i.hooks.preprocess(n));
|
|
1821
|
+
let c = e(n, i);
|
|
1822
|
+
i.hooks && (c = i.hooks.processAllTokens(c)), i.walkTokens && this.walkTokens(c, i.walkTokens);
|
|
1823
|
+
let g = t(c, i);
|
|
1824
|
+
return i.hooks && (g = i.hooks.postprocess(g)), g;
|
|
1825
|
+
} catch (c) {
|
|
1826
|
+
return a(c);
|
|
1827
|
+
}
|
|
1828
|
+
};
|
|
1829
|
+
}, Zt = new WeakSet(), vs = function(e, t) {
|
|
1830
|
+
return (n) => {
|
|
1831
|
+
if (n.message += `
|
|
1832
|
+
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
1833
|
+
const o = "<p>An error occurred:</p><pre>" + xe(n.message + "", !0) + "</pre>";
|
|
1834
|
+
return t ? Promise.resolve(o) : o;
|
|
1835
|
+
}
|
|
1836
|
+
if (t)
|
|
1837
|
+
return Promise.reject(n);
|
|
1838
|
+
throw n;
|
|
1839
|
+
};
|
|
1840
|
+
};
|
|
1841
|
+
const tt = new so();
|
|
1842
|
+
function H(s, e) {
|
|
1843
|
+
return tt.parse(s, e);
|
|
1844
|
+
}
|
|
1845
|
+
H.options = H.setOptions = function(s) {
|
|
1846
|
+
return tt.setOptions(s), H.defaults = tt.defaults, gs(H.defaults), H;
|
|
1847
|
+
};
|
|
1848
|
+
H.getDefaults = bn;
|
|
1849
|
+
H.defaults = nt;
|
|
1850
|
+
H.use = function(...s) {
|
|
1851
|
+
return tt.use(...s), H.defaults = tt.defaults, gs(H.defaults), H;
|
|
1852
|
+
};
|
|
1853
|
+
H.walkTokens = function(s, e) {
|
|
1854
|
+
return tt.walkTokens(s, e);
|
|
1855
|
+
};
|
|
1856
|
+
H.parseInline = tt.parseInline;
|
|
1857
|
+
H.Parser = Ie;
|
|
1858
|
+
H.parser = Ie.parse;
|
|
1859
|
+
H.Renderer = qt;
|
|
1860
|
+
H.TextRenderer = Tn;
|
|
1861
|
+
H.Lexer = Ce;
|
|
1862
|
+
H.lexer = Ce.lex;
|
|
1863
|
+
H.Tokenizer = Wt;
|
|
1864
|
+
H.Hooks = Tt;
|
|
1865
|
+
H.parse = H;
|
|
1866
|
+
H.options;
|
|
1867
|
+
H.setOptions;
|
|
1868
|
+
H.use;
|
|
1869
|
+
H.walkTokens;
|
|
1870
|
+
H.parseInline;
|
|
1871
|
+
Ie.parse;
|
|
1872
|
+
Ce.lex;
|
|
1873
|
+
/*! @license DOMPurify 3.3.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.1/LICENSE */
|
|
1874
|
+
const {
|
|
1875
|
+
entries: Ss,
|
|
1876
|
+
setPrototypeOf: Zn,
|
|
1877
|
+
isFrozen: io,
|
|
1878
|
+
getPrototypeOf: oo,
|
|
1879
|
+
getOwnPropertyDescriptor: ro
|
|
1880
|
+
} = Object;
|
|
1881
|
+
let {
|
|
1882
|
+
freeze: ge,
|
|
1883
|
+
seal: we,
|
|
1884
|
+
create: gn
|
|
1885
|
+
} = Object, {
|
|
1886
|
+
apply: mn,
|
|
1887
|
+
construct: _n
|
|
1888
|
+
} = typeof Reflect < "u" && Reflect;
|
|
1889
|
+
ge || (ge = function(e) {
|
|
1890
|
+
return e;
|
|
1891
|
+
});
|
|
1892
|
+
we || (we = function(e) {
|
|
1893
|
+
return e;
|
|
1894
|
+
});
|
|
1895
|
+
mn || (mn = function(e, t) {
|
|
1896
|
+
for (var n = arguments.length, o = new Array(n > 2 ? n - 2 : 0), r = 2; r < n; r++)
|
|
1897
|
+
o[r - 2] = arguments[r];
|
|
1898
|
+
return e.apply(t, o);
|
|
1899
|
+
});
|
|
1900
|
+
_n || (_n = function(e) {
|
|
1901
|
+
for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), o = 1; o < t; o++)
|
|
1902
|
+
n[o - 1] = arguments[o];
|
|
1903
|
+
return new e(...n);
|
|
1904
|
+
});
|
|
1905
|
+
const Bt = me(Array.prototype.forEach), ao = me(Array.prototype.lastIndexOf), Xn = me(Array.prototype.pop), _t = me(Array.prototype.push), lo = me(Array.prototype.splice), jt = me(String.prototype.toLowerCase), rn = me(String.prototype.toString), an = me(String.prototype.match), bt = me(String.prototype.replace), co = me(String.prototype.indexOf), uo = me(String.prototype.trim), ve = me(Object.prototype.hasOwnProperty), de = me(RegExp.prototype.test), yt = fo(TypeError);
|
|
1906
|
+
function me(s) {
|
|
1907
|
+
return function(e) {
|
|
1908
|
+
e instanceof RegExp && (e.lastIndex = 0);
|
|
1909
|
+
for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), o = 1; o < t; o++)
|
|
1910
|
+
n[o - 1] = arguments[o];
|
|
1911
|
+
return mn(s, e, n);
|
|
1912
|
+
};
|
|
1913
|
+
}
|
|
1914
|
+
function fo(s) {
|
|
1915
|
+
return function() {
|
|
1916
|
+
for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
|
|
1917
|
+
t[n] = arguments[n];
|
|
1918
|
+
return _n(s, t);
|
|
1919
|
+
};
|
|
1920
|
+
}
|
|
1921
|
+
function O(s, e) {
|
|
1922
|
+
let t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : jt;
|
|
1923
|
+
Zn && Zn(s, null);
|
|
1924
|
+
let n = e.length;
|
|
1925
|
+
for (; n--; ) {
|
|
1926
|
+
let o = e[n];
|
|
1927
|
+
if (typeof o == "string") {
|
|
1928
|
+
const r = t(o);
|
|
1929
|
+
r !== o && (io(e) || (e[n] = r), o = r);
|
|
1930
|
+
}
|
|
1931
|
+
s[o] = !0;
|
|
1932
|
+
}
|
|
1933
|
+
return s;
|
|
1934
|
+
}
|
|
1935
|
+
function po(s) {
|
|
1936
|
+
for (let e = 0; e < s.length; e++)
|
|
1937
|
+
ve(s, e) || (s[e] = null);
|
|
1938
|
+
return s;
|
|
1939
|
+
}
|
|
1940
|
+
function Me(s) {
|
|
1941
|
+
const e = gn(null);
|
|
1942
|
+
for (const [t, n] of Ss(s))
|
|
1943
|
+
ve(s, t) && (Array.isArray(n) ? e[t] = po(n) : n && typeof n == "object" && n.constructor === Object ? e[t] = Me(n) : e[t] = n);
|
|
1944
|
+
return e;
|
|
1945
|
+
}
|
|
1946
|
+
function xt(s, e) {
|
|
1947
|
+
for (; s !== null; ) {
|
|
1948
|
+
const n = ro(s, e);
|
|
1949
|
+
if (n) {
|
|
1950
|
+
if (n.get)
|
|
1951
|
+
return me(n.get);
|
|
1952
|
+
if (typeof n.value == "function")
|
|
1953
|
+
return me(n.value);
|
|
1954
|
+
}
|
|
1955
|
+
s = oo(s);
|
|
1956
|
+
}
|
|
1957
|
+
function t() {
|
|
1958
|
+
return null;
|
|
1959
|
+
}
|
|
1960
|
+
return t;
|
|
1961
|
+
}
|
|
1962
|
+
const Vn = ge(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), ln = ge(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), cn = ge(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), ho = ge(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), un = ge(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), go = ge(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), Kn = ge(["#text"]), Qn = ge(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]), fn = ge(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), Jn = ge(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), Ht = ge(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), mo = we(/\{\{[\w\W]*|[\w\W]*\}\}/gm), _o = we(/<%[\w\W]*|[\w\W]*%>/gm), bo = we(/\$\{[\w\W]*/gm), yo = we(/^data-[\-\w.\u00B7-\uFFFF]+$/), xo = we(/^aria-[\-\w]+$/), As = we(
|
|
1963
|
+
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
|
|
1964
|
+
// eslint-disable-line no-useless-escape
|
|
1965
|
+
), ko = we(/^(?:\w+script|data):/i), wo = we(
|
|
1966
|
+
/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
|
|
1967
|
+
// eslint-disable-line no-control-regex
|
|
1968
|
+
), Rs = we(/^html$/i), Eo = we(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
1969
|
+
var es = /* @__PURE__ */ Object.freeze({
|
|
1970
|
+
__proto__: null,
|
|
1971
|
+
ARIA_ATTR: xo,
|
|
1972
|
+
ATTR_WHITESPACE: wo,
|
|
1973
|
+
CUSTOM_ELEMENT: Eo,
|
|
1974
|
+
DATA_ATTR: yo,
|
|
1975
|
+
DOCTYPE_NAME: Rs,
|
|
1976
|
+
ERB_EXPR: _o,
|
|
1977
|
+
IS_ALLOWED_URI: As,
|
|
1978
|
+
IS_SCRIPT_OR_DATA: ko,
|
|
1979
|
+
MUSTACHE_EXPR: mo,
|
|
1980
|
+
TMPLIT_EXPR: bo
|
|
1981
|
+
});
|
|
1982
|
+
const kt = {
|
|
1983
|
+
element: 1,
|
|
1984
|
+
attribute: 2,
|
|
1985
|
+
text: 3,
|
|
1986
|
+
cdataSection: 4,
|
|
1987
|
+
entityReference: 5,
|
|
1988
|
+
// Deprecated
|
|
1989
|
+
entityNode: 6,
|
|
1990
|
+
// Deprecated
|
|
1991
|
+
progressingInstruction: 7,
|
|
1992
|
+
comment: 8,
|
|
1993
|
+
document: 9,
|
|
1994
|
+
documentType: 10,
|
|
1995
|
+
documentFragment: 11,
|
|
1996
|
+
notation: 12
|
|
1997
|
+
// Deprecated
|
|
1998
|
+
}, To = function() {
|
|
1999
|
+
return typeof window > "u" ? null : window;
|
|
2000
|
+
}, vo = function(e, t) {
|
|
2001
|
+
if (typeof e != "object" || typeof e.createPolicy != "function")
|
|
2002
|
+
return null;
|
|
2003
|
+
let n = null;
|
|
2004
|
+
const o = "data-tt-policy-suffix";
|
|
2005
|
+
t && t.hasAttribute(o) && (n = t.getAttribute(o));
|
|
2006
|
+
const r = "dompurify" + (n ? "#" + n : "");
|
|
2007
|
+
try {
|
|
2008
|
+
return e.createPolicy(r, {
|
|
2009
|
+
createHTML(i) {
|
|
2010
|
+
return i;
|
|
2011
|
+
},
|
|
2012
|
+
createScriptURL(i) {
|
|
2013
|
+
return i;
|
|
2014
|
+
}
|
|
2015
|
+
});
|
|
2016
|
+
} catch {
|
|
2017
|
+
return console.warn("TrustedTypes policy " + r + " could not be created."), null;
|
|
2018
|
+
}
|
|
2019
|
+
}, ts = function() {
|
|
2020
|
+
return {
|
|
2021
|
+
afterSanitizeAttributes: [],
|
|
2022
|
+
afterSanitizeElements: [],
|
|
2023
|
+
afterSanitizeShadowDOM: [],
|
|
2024
|
+
beforeSanitizeAttributes: [],
|
|
2025
|
+
beforeSanitizeElements: [],
|
|
2026
|
+
beforeSanitizeShadowDOM: [],
|
|
2027
|
+
uponSanitizeAttribute: [],
|
|
2028
|
+
uponSanitizeElement: [],
|
|
2029
|
+
uponSanitizeShadowNode: []
|
|
2030
|
+
};
|
|
2031
|
+
};
|
|
2032
|
+
function Ms() {
|
|
2033
|
+
let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : To();
|
|
2034
|
+
const e = (E) => Ms(E);
|
|
2035
|
+
if (e.version = "3.3.1", e.removed = [], !s || !s.document || s.document.nodeType !== kt.document || !s.Element)
|
|
2036
|
+
return e.isSupported = !1, e;
|
|
2037
|
+
let {
|
|
2038
|
+
document: t
|
|
2039
|
+
} = s;
|
|
2040
|
+
const n = t, o = n.currentScript, {
|
|
2041
|
+
DocumentFragment: r,
|
|
2042
|
+
HTMLTemplateElement: i,
|
|
2043
|
+
Node: a,
|
|
2044
|
+
Element: c,
|
|
2045
|
+
NodeFilter: g,
|
|
2046
|
+
NamedNodeMap: u = s.NamedNodeMap || s.MozNamedAttrMap,
|
|
2047
|
+
HTMLFormElement: _,
|
|
2048
|
+
DOMParser: d,
|
|
2049
|
+
trustedTypes: f
|
|
2050
|
+
} = s, y = c.prototype, T = xt(y, "cloneNode"), M = xt(y, "remove"), K = xt(y, "nextSibling"), C = xt(y, "childNodes"), Y = xt(y, "parentNode");
|
|
2051
|
+
if (typeof i == "function") {
|
|
2052
|
+
const E = t.createElement("template");
|
|
2053
|
+
E.content && E.content.ownerDocument && (t = E.content.ownerDocument);
|
|
2054
|
+
}
|
|
2055
|
+
let I, J = "";
|
|
2056
|
+
const {
|
|
2057
|
+
implementation: Se,
|
|
2058
|
+
createNodeIterator: Ge,
|
|
2059
|
+
createDocumentFragment: pe,
|
|
2060
|
+
getElementsByTagName: he
|
|
2061
|
+
} = t, {
|
|
2062
|
+
importNode: Fe
|
|
2063
|
+
} = n;
|
|
2064
|
+
let se = ts();
|
|
2065
|
+
e.isSupported = typeof Ss == "function" && typeof Y == "function" && Se && Se.createHTMLDocument !== void 0;
|
|
2066
|
+
const {
|
|
2067
|
+
MUSTACHE_EXPR: w,
|
|
2068
|
+
ERB_EXPR: P,
|
|
2069
|
+
TMPLIT_EXPR: D,
|
|
2070
|
+
DATA_ATTR: X,
|
|
2071
|
+
ARIA_ATTR: p,
|
|
2072
|
+
IS_SCRIPT_OR_DATA: k,
|
|
2073
|
+
ATTR_WHITESPACE: R,
|
|
2074
|
+
CUSTOM_ELEMENT: F
|
|
2075
|
+
} = es;
|
|
2076
|
+
let {
|
|
2077
|
+
IS_ALLOWED_URI: j
|
|
2078
|
+
} = es, $ = null;
|
|
2079
|
+
const Ee = O({}, [...Vn, ...ln, ...cn, ...un, ...Kn]);
|
|
2080
|
+
let ee = null;
|
|
2081
|
+
const ue = O({}, [...Qn, ...fn, ...Jn, ...Ht]);
|
|
2082
|
+
let z = Object.seal(gn(null, {
|
|
2083
|
+
tagNameCheck: {
|
|
2084
|
+
writable: !0,
|
|
2085
|
+
configurable: !1,
|
|
2086
|
+
enumerable: !0,
|
|
2087
|
+
value: null
|
|
2088
|
+
},
|
|
2089
|
+
attributeNameCheck: {
|
|
2090
|
+
writable: !0,
|
|
2091
|
+
configurable: !1,
|
|
2092
|
+
enumerable: !0,
|
|
2093
|
+
value: null
|
|
2094
|
+
},
|
|
2095
|
+
allowCustomizedBuiltInElements: {
|
|
2096
|
+
writable: !0,
|
|
2097
|
+
configurable: !1,
|
|
2098
|
+
enumerable: !0,
|
|
2099
|
+
value: !1
|
|
2100
|
+
}
|
|
2101
|
+
})), je = null, it = null;
|
|
2102
|
+
const De = Object.seal(gn(null, {
|
|
2103
|
+
tagCheck: {
|
|
2104
|
+
writable: !0,
|
|
2105
|
+
configurable: !1,
|
|
2106
|
+
enumerable: !0,
|
|
2107
|
+
value: null
|
|
2108
|
+
},
|
|
2109
|
+
attributeCheck: {
|
|
2110
|
+
writable: !0,
|
|
2111
|
+
configurable: !1,
|
|
2112
|
+
enumerable: !0,
|
|
2113
|
+
value: null
|
|
2114
|
+
}
|
|
2115
|
+
}));
|
|
2116
|
+
let Ct = !0, ht = !0, It = !1, Ot = !0, Te = !1, qe = !0, ae = !1, dt = !1, Ye = !1, v = !1, Ze = !1, te = !1, W = !0, Xe = !1;
|
|
2117
|
+
const Le = "user-content-";
|
|
2118
|
+
let Ve = !0, Pe = !1, m = {}, b = null;
|
|
2119
|
+
const A = O({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
|
|
2120
|
+
let U = null;
|
|
2121
|
+
const ie = O({}, ["audio", "video", "img", "source", "image", "track"]);
|
|
2122
|
+
let ye = null;
|
|
2123
|
+
const Nt = O({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), ot = "http://www.w3.org/1998/Math/MathML", Dt = "http://www.w3.org/2000/svg", $e = "http://www.w3.org/1999/xhtml";
|
|
2124
|
+
let rt = $e, Jt = !1, en = null;
|
|
2125
|
+
const js = O({}, [ot, Dt, $e], rn);
|
|
2126
|
+
let Lt = O({}, ["mi", "mo", "mn", "ms", "mtext"]), Pt = O({}, ["annotation-xml"]);
|
|
2127
|
+
const Ws = O({}, ["title", "style", "font", "a", "script"]);
|
|
2128
|
+
let gt = null;
|
|
2129
|
+
const Gs = ["application/xhtml+xml", "text/html"], qs = "text/html";
|
|
2130
|
+
let oe = null, at = null;
|
|
2131
|
+
const Ys = t.createElement("form"), Mn = function(l) {
|
|
2132
|
+
return l instanceof RegExp || l instanceof Function;
|
|
2133
|
+
}, tn = function() {
|
|
2134
|
+
let l = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
2135
|
+
if (!(at && at === l)) {
|
|
2136
|
+
if ((!l || typeof l != "object") && (l = {}), l = Me(l), gt = // eslint-disable-next-line unicorn/prefer-includes
|
|
2137
|
+
Gs.indexOf(l.PARSER_MEDIA_TYPE) === -1 ? qs : l.PARSER_MEDIA_TYPE, oe = gt === "application/xhtml+xml" ? rn : jt, $ = ve(l, "ALLOWED_TAGS") ? O({}, l.ALLOWED_TAGS, oe) : Ee, ee = ve(l, "ALLOWED_ATTR") ? O({}, l.ALLOWED_ATTR, oe) : ue, en = ve(l, "ALLOWED_NAMESPACES") ? O({}, l.ALLOWED_NAMESPACES, rn) : js, ye = ve(l, "ADD_URI_SAFE_ATTR") ? O(Me(Nt), l.ADD_URI_SAFE_ATTR, oe) : Nt, U = ve(l, "ADD_DATA_URI_TAGS") ? O(Me(ie), l.ADD_DATA_URI_TAGS, oe) : ie, b = ve(l, "FORBID_CONTENTS") ? O({}, l.FORBID_CONTENTS, oe) : A, je = ve(l, "FORBID_TAGS") ? O({}, l.FORBID_TAGS, oe) : Me({}), it = ve(l, "FORBID_ATTR") ? O({}, l.FORBID_ATTR, oe) : Me({}), m = ve(l, "USE_PROFILES") ? l.USE_PROFILES : !1, Ct = l.ALLOW_ARIA_ATTR !== !1, ht = l.ALLOW_DATA_ATTR !== !1, It = l.ALLOW_UNKNOWN_PROTOCOLS || !1, Ot = l.ALLOW_SELF_CLOSE_IN_ATTR !== !1, Te = l.SAFE_FOR_TEMPLATES || !1, qe = l.SAFE_FOR_XML !== !1, ae = l.WHOLE_DOCUMENT || !1, v = l.RETURN_DOM || !1, Ze = l.RETURN_DOM_FRAGMENT || !1, te = l.RETURN_TRUSTED_TYPE || !1, Ye = l.FORCE_BODY || !1, W = l.SANITIZE_DOM !== !1, Xe = l.SANITIZE_NAMED_PROPS || !1, Ve = l.KEEP_CONTENT !== !1, Pe = l.IN_PLACE || !1, j = l.ALLOWED_URI_REGEXP || As, rt = l.NAMESPACE || $e, Lt = l.MATHML_TEXT_INTEGRATION_POINTS || Lt, Pt = l.HTML_INTEGRATION_POINTS || Pt, z = l.CUSTOM_ELEMENT_HANDLING || {}, l.CUSTOM_ELEMENT_HANDLING && Mn(l.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (z.tagNameCheck = l.CUSTOM_ELEMENT_HANDLING.tagNameCheck), l.CUSTOM_ELEMENT_HANDLING && Mn(l.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (z.attributeNameCheck = l.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), l.CUSTOM_ELEMENT_HANDLING && typeof l.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (z.allowCustomizedBuiltInElements = l.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), Te && (ht = !1), Ze && (v = !0), m && ($ = O({}, Kn), ee = [], m.html === !0 && (O($, Vn), O(ee, Qn)), m.svg === !0 && (O($, ln), O(ee, fn), O(ee, Ht)), m.svgFilters === !0 && (O($, cn), O(ee, fn), O(ee, Ht)), m.mathMl === !0 && (O($, un), O(ee, Jn), O(ee, Ht))), l.ADD_TAGS && (typeof l.ADD_TAGS == "function" ? De.tagCheck = l.ADD_TAGS : ($ === Ee && ($ = Me($)), O($, l.ADD_TAGS, oe))), l.ADD_ATTR && (typeof l.ADD_ATTR == "function" ? De.attributeCheck = l.ADD_ATTR : (ee === ue && (ee = Me(ee)), O(ee, l.ADD_ATTR, oe))), l.ADD_URI_SAFE_ATTR && O(ye, l.ADD_URI_SAFE_ATTR, oe), l.FORBID_CONTENTS && (b === A && (b = Me(b)), O(b, l.FORBID_CONTENTS, oe)), l.ADD_FORBID_CONTENTS && (b === A && (b = Me(b)), O(b, l.ADD_FORBID_CONTENTS, oe)), Ve && ($["#text"] = !0), ae && O($, ["html", "head", "body"]), $.table && (O($, ["tbody"]), delete je.tbody), l.TRUSTED_TYPES_POLICY) {
|
|
2138
|
+
if (typeof l.TRUSTED_TYPES_POLICY.createHTML != "function")
|
|
2139
|
+
throw yt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
2140
|
+
if (typeof l.TRUSTED_TYPES_POLICY.createScriptURL != "function")
|
|
2141
|
+
throw yt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
2142
|
+
I = l.TRUSTED_TYPES_POLICY, J = I.createHTML("");
|
|
2143
|
+
} else
|
|
2144
|
+
I === void 0 && (I = vo(f, o)), I !== null && typeof J == "string" && (J = I.createHTML(""));
|
|
2145
|
+
ge && ge(l), at = l;
|
|
2146
|
+
}
|
|
2147
|
+
}, Cn = O({}, [...ln, ...cn, ...ho]), In = O({}, [...un, ...go]), Zs = function(l) {
|
|
2148
|
+
let h = Y(l);
|
|
2149
|
+
(!h || !h.tagName) && (h = {
|
|
2150
|
+
namespaceURI: rt,
|
|
2151
|
+
tagName: "template"
|
|
2152
|
+
});
|
|
2153
|
+
const x = jt(l.tagName), V = jt(h.tagName);
|
|
2154
|
+
return en[l.namespaceURI] ? l.namespaceURI === Dt ? h.namespaceURI === $e ? x === "svg" : h.namespaceURI === ot ? x === "svg" && (V === "annotation-xml" || Lt[V]) : !!Cn[x] : l.namespaceURI === ot ? h.namespaceURI === $e ? x === "math" : h.namespaceURI === Dt ? x === "math" && Pt[V] : !!In[x] : l.namespaceURI === $e ? h.namespaceURI === Dt && !Pt[V] || h.namespaceURI === ot && !Lt[V] ? !1 : !In[x] && (Ws[x] || !Cn[x]) : !!(gt === "application/xhtml+xml" && en[l.namespaceURI]) : !1;
|
|
2155
|
+
}, Ae = function(l) {
|
|
2156
|
+
_t(e.removed, {
|
|
2157
|
+
element: l
|
|
2158
|
+
});
|
|
2159
|
+
try {
|
|
2160
|
+
Y(l).removeChild(l);
|
|
2161
|
+
} catch {
|
|
2162
|
+
M(l);
|
|
2163
|
+
}
|
|
2164
|
+
}, Ke = function(l, h) {
|
|
2165
|
+
try {
|
|
2166
|
+
_t(e.removed, {
|
|
2167
|
+
attribute: h.getAttributeNode(l),
|
|
2168
|
+
from: h
|
|
2169
|
+
});
|
|
2170
|
+
} catch {
|
|
2171
|
+
_t(e.removed, {
|
|
2172
|
+
attribute: null,
|
|
2173
|
+
from: h
|
|
2174
|
+
});
|
|
2175
|
+
}
|
|
2176
|
+
if (h.removeAttribute(l), l === "is")
|
|
2177
|
+
if (v || Ze)
|
|
2178
|
+
try {
|
|
2179
|
+
Ae(h);
|
|
2180
|
+
} catch {
|
|
2181
|
+
}
|
|
2182
|
+
else
|
|
2183
|
+
try {
|
|
2184
|
+
h.setAttribute(l, "");
|
|
2185
|
+
} catch {
|
|
2186
|
+
}
|
|
2187
|
+
}, On = function(l) {
|
|
2188
|
+
let h = null, x = null;
|
|
2189
|
+
if (Ye)
|
|
2190
|
+
l = "<remove></remove>" + l;
|
|
2191
|
+
else {
|
|
2192
|
+
const ne = an(l, /^[\r\n\t ]+/);
|
|
2193
|
+
x = ne && ne[0];
|
|
2194
|
+
}
|
|
2195
|
+
gt === "application/xhtml+xml" && rt === $e && (l = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + l + "</body></html>");
|
|
2196
|
+
const V = I ? I.createHTML(l) : l;
|
|
2197
|
+
if (rt === $e)
|
|
2198
|
+
try {
|
|
2199
|
+
h = new d().parseFromString(V, gt);
|
|
2200
|
+
} catch {
|
|
2201
|
+
}
|
|
2202
|
+
if (!h || !h.documentElement) {
|
|
2203
|
+
h = Se.createDocument(rt, "template", null);
|
|
2204
|
+
try {
|
|
2205
|
+
h.documentElement.innerHTML = Jt ? J : V;
|
|
2206
|
+
} catch {
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
const fe = h.body || h.documentElement;
|
|
2210
|
+
return l && x && fe.insertBefore(t.createTextNode(x), fe.childNodes[0] || null), rt === $e ? he.call(h, ae ? "html" : "body")[0] : ae ? h.documentElement : fe;
|
|
2211
|
+
}, Nn = function(l) {
|
|
2212
|
+
return Ge.call(
|
|
2213
|
+
l.ownerDocument || l,
|
|
2214
|
+
l,
|
|
2215
|
+
// eslint-disable-next-line no-bitwise
|
|
2216
|
+
g.SHOW_ELEMENT | g.SHOW_COMMENT | g.SHOW_TEXT | g.SHOW_PROCESSING_INSTRUCTION | g.SHOW_CDATA_SECTION,
|
|
2217
|
+
null
|
|
2218
|
+
);
|
|
2219
|
+
}, nn = function(l) {
|
|
2220
|
+
return l instanceof _ && (typeof l.nodeName != "string" || typeof l.textContent != "string" || typeof l.removeChild != "function" || !(l.attributes instanceof u) || typeof l.removeAttribute != "function" || typeof l.setAttribute != "function" || typeof l.namespaceURI != "string" || typeof l.insertBefore != "function" || typeof l.hasChildNodes != "function");
|
|
2221
|
+
}, Dn = function(l) {
|
|
2222
|
+
return typeof a == "function" && l instanceof a;
|
|
2223
|
+
};
|
|
2224
|
+
function ze(E, l, h) {
|
|
2225
|
+
Bt(E, (x) => {
|
|
2226
|
+
x.call(e, l, h, at);
|
|
2227
|
+
});
|
|
2228
|
+
}
|
|
2229
|
+
const Ln = function(l) {
|
|
2230
|
+
let h = null;
|
|
2231
|
+
if (ze(se.beforeSanitizeElements, l, null), nn(l))
|
|
2232
|
+
return Ae(l), !0;
|
|
2233
|
+
const x = oe(l.nodeName);
|
|
2234
|
+
if (ze(se.uponSanitizeElement, l, {
|
|
2235
|
+
tagName: x,
|
|
2236
|
+
allowedTags: $
|
|
2237
|
+
}), qe && l.hasChildNodes() && !Dn(l.firstElementChild) && de(/<[/\w!]/g, l.innerHTML) && de(/<[/\w!]/g, l.textContent) || l.nodeType === kt.progressingInstruction || qe && l.nodeType === kt.comment && de(/<[/\w]/g, l.data))
|
|
2238
|
+
return Ae(l), !0;
|
|
2239
|
+
if (!(De.tagCheck instanceof Function && De.tagCheck(x)) && (!$[x] || je[x])) {
|
|
2240
|
+
if (!je[x] && $n(x) && (z.tagNameCheck instanceof RegExp && de(z.tagNameCheck, x) || z.tagNameCheck instanceof Function && z.tagNameCheck(x)))
|
|
2241
|
+
return !1;
|
|
2242
|
+
if (Ve && !b[x]) {
|
|
2243
|
+
const V = Y(l) || l.parentNode, fe = C(l) || l.childNodes;
|
|
2244
|
+
if (fe && V) {
|
|
2245
|
+
const ne = fe.length;
|
|
2246
|
+
for (let _e = ne - 1; _e >= 0; --_e) {
|
|
2247
|
+
const Ue = T(fe[_e], !0);
|
|
2248
|
+
Ue.__removalCount = (l.__removalCount || 0) + 1, V.insertBefore(Ue, K(l));
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
return Ae(l), !0;
|
|
2253
|
+
}
|
|
2254
|
+
return l instanceof c && !Zs(l) || (x === "noscript" || x === "noembed" || x === "noframes") && de(/<\/no(script|embed|frames)/i, l.innerHTML) ? (Ae(l), !0) : (Te && l.nodeType === kt.text && (h = l.textContent, Bt([w, P, D], (V) => {
|
|
2255
|
+
h = bt(h, V, " ");
|
|
2256
|
+
}), l.textContent !== h && (_t(e.removed, {
|
|
2257
|
+
element: l.cloneNode()
|
|
2258
|
+
}), l.textContent = h)), ze(se.afterSanitizeElements, l, null), !1);
|
|
2259
|
+
}, Pn = function(l, h, x) {
|
|
2260
|
+
if (W && (h === "id" || h === "name") && (x in t || x in Ys))
|
|
2261
|
+
return !1;
|
|
2262
|
+
if (!(ht && !it[h] && de(X, h))) {
|
|
2263
|
+
if (!(Ct && de(p, h))) {
|
|
2264
|
+
if (!(De.attributeCheck instanceof Function && De.attributeCheck(h, l))) {
|
|
2265
|
+
if (!ee[h] || it[h]) {
|
|
2266
|
+
if (
|
|
2267
|
+
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
2268
|
+
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
2269
|
+
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
|
|
2270
|
+
!($n(l) && (z.tagNameCheck instanceof RegExp && de(z.tagNameCheck, l) || z.tagNameCheck instanceof Function && z.tagNameCheck(l)) && (z.attributeNameCheck instanceof RegExp && de(z.attributeNameCheck, h) || z.attributeNameCheck instanceof Function && z.attributeNameCheck(h, l)) || // Alternative, second condition checks if it's an `is`-attribute, AND
|
|
2271
|
+
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
2272
|
+
h === "is" && z.allowCustomizedBuiltInElements && (z.tagNameCheck instanceof RegExp && de(z.tagNameCheck, x) || z.tagNameCheck instanceof Function && z.tagNameCheck(x)))
|
|
2273
|
+
)
|
|
2274
|
+
return !1;
|
|
2275
|
+
} else if (!ye[h]) {
|
|
2276
|
+
if (!de(j, bt(x, R, ""))) {
|
|
2277
|
+
if (!((h === "src" || h === "xlink:href" || h === "href") && l !== "script" && co(x, "data:") === 0 && U[l])) {
|
|
2278
|
+
if (!(It && !de(k, bt(x, R, "")))) {
|
|
2279
|
+
if (x)
|
|
2280
|
+
return !1;
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
return !0;
|
|
2289
|
+
}, $n = function(l) {
|
|
2290
|
+
return l !== "annotation-xml" && an(l, F);
|
|
2291
|
+
}, zn = function(l) {
|
|
2292
|
+
ze(se.beforeSanitizeAttributes, l, null);
|
|
2293
|
+
const {
|
|
2294
|
+
attributes: h
|
|
2295
|
+
} = l;
|
|
2296
|
+
if (!h || nn(l))
|
|
2297
|
+
return;
|
|
2298
|
+
const x = {
|
|
2299
|
+
attrName: "",
|
|
2300
|
+
attrValue: "",
|
|
2301
|
+
keepAttr: !0,
|
|
2302
|
+
allowedAttributes: ee,
|
|
2303
|
+
forceKeepAttr: void 0
|
|
2304
|
+
};
|
|
2305
|
+
let V = h.length;
|
|
2306
|
+
for (; V--; ) {
|
|
2307
|
+
const fe = h[V], {
|
|
2308
|
+
name: ne,
|
|
2309
|
+
namespaceURI: _e,
|
|
2310
|
+
value: Ue
|
|
2311
|
+
} = fe, lt = oe(ne), sn = Ue;
|
|
2312
|
+
let ce = ne === "value" ? sn : uo(sn);
|
|
2313
|
+
if (x.attrName = lt, x.attrValue = ce, x.keepAttr = !0, x.forceKeepAttr = void 0, ze(se.uponSanitizeAttribute, l, x), ce = x.attrValue, Xe && (lt === "id" || lt === "name") && (Ke(ne, l), ce = Le + ce), qe && de(/((--!?|])>)|<\/(style|title|textarea)/i, ce)) {
|
|
2314
|
+
Ke(ne, l);
|
|
2315
|
+
continue;
|
|
2316
|
+
}
|
|
2317
|
+
if (lt === "attributename" && an(ce, "href")) {
|
|
2318
|
+
Ke(ne, l);
|
|
2319
|
+
continue;
|
|
2320
|
+
}
|
|
2321
|
+
if (x.forceKeepAttr)
|
|
2322
|
+
continue;
|
|
2323
|
+
if (!x.keepAttr) {
|
|
2324
|
+
Ke(ne, l);
|
|
2325
|
+
continue;
|
|
2326
|
+
}
|
|
2327
|
+
if (!Ot && de(/\/>/i, ce)) {
|
|
2328
|
+
Ke(ne, l);
|
|
2329
|
+
continue;
|
|
2330
|
+
}
|
|
2331
|
+
Te && Bt([w, P, D], (Bn) => {
|
|
2332
|
+
ce = bt(ce, Bn, " ");
|
|
2333
|
+
});
|
|
2334
|
+
const Un = oe(l.nodeName);
|
|
2335
|
+
if (!Pn(Un, lt, ce)) {
|
|
2336
|
+
Ke(ne, l);
|
|
2337
|
+
continue;
|
|
2338
|
+
}
|
|
2339
|
+
if (I && typeof f == "object" && typeof f.getAttributeType == "function" && !_e)
|
|
2340
|
+
switch (f.getAttributeType(Un, lt)) {
|
|
2341
|
+
case "TrustedHTML": {
|
|
2342
|
+
ce = I.createHTML(ce);
|
|
2343
|
+
break;
|
|
2344
|
+
}
|
|
2345
|
+
case "TrustedScriptURL": {
|
|
2346
|
+
ce = I.createScriptURL(ce);
|
|
2347
|
+
break;
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
if (ce !== sn)
|
|
2351
|
+
try {
|
|
2352
|
+
_e ? l.setAttributeNS(_e, ne, ce) : l.setAttribute(ne, ce), nn(l) ? Ae(l) : Xn(e.removed);
|
|
2353
|
+
} catch {
|
|
2354
|
+
Ke(ne, l);
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
ze(se.afterSanitizeAttributes, l, null);
|
|
2358
|
+
}, Xs = function E(l) {
|
|
2359
|
+
let h = null;
|
|
2360
|
+
const x = Nn(l);
|
|
2361
|
+
for (ze(se.beforeSanitizeShadowDOM, l, null); h = x.nextNode(); )
|
|
2362
|
+
ze(se.uponSanitizeShadowNode, h, null), Ln(h), zn(h), h.content instanceof r && E(h.content);
|
|
2363
|
+
ze(se.afterSanitizeShadowDOM, l, null);
|
|
2364
|
+
};
|
|
2365
|
+
return e.sanitize = function(E) {
|
|
2366
|
+
let l = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, h = null, x = null, V = null, fe = null;
|
|
2367
|
+
if (Jt = !E, Jt && (E = "<!-->"), typeof E != "string" && !Dn(E))
|
|
2368
|
+
if (typeof E.toString == "function") {
|
|
2369
|
+
if (E = E.toString(), typeof E != "string")
|
|
2370
|
+
throw yt("dirty is not a string, aborting");
|
|
2371
|
+
} else
|
|
2372
|
+
throw yt("toString is not a function");
|
|
2373
|
+
if (!e.isSupported)
|
|
2374
|
+
return E;
|
|
2375
|
+
if (dt || tn(l), e.removed = [], typeof E == "string" && (Pe = !1), Pe) {
|
|
2376
|
+
if (E.nodeName) {
|
|
2377
|
+
const Ue = oe(E.nodeName);
|
|
2378
|
+
if (!$[Ue] || je[Ue])
|
|
2379
|
+
throw yt("root node is forbidden and cannot be sanitized in-place");
|
|
2380
|
+
}
|
|
2381
|
+
} else if (E instanceof a)
|
|
2382
|
+
h = On("<!---->"), x = h.ownerDocument.importNode(E, !0), x.nodeType === kt.element && x.nodeName === "BODY" || x.nodeName === "HTML" ? h = x : h.appendChild(x);
|
|
2383
|
+
else {
|
|
2384
|
+
if (!v && !Te && !ae && // eslint-disable-next-line unicorn/prefer-includes
|
|
2385
|
+
E.indexOf("<") === -1)
|
|
2386
|
+
return I && te ? I.createHTML(E) : E;
|
|
2387
|
+
if (h = On(E), !h)
|
|
2388
|
+
return v ? null : te ? J : "";
|
|
2389
|
+
}
|
|
2390
|
+
h && Ye && Ae(h.firstChild);
|
|
2391
|
+
const ne = Nn(Pe ? E : h);
|
|
2392
|
+
for (; V = ne.nextNode(); )
|
|
2393
|
+
Ln(V), zn(V), V.content instanceof r && Xs(V.content);
|
|
2394
|
+
if (Pe)
|
|
2395
|
+
return E;
|
|
2396
|
+
if (v) {
|
|
2397
|
+
if (Ze)
|
|
2398
|
+
for (fe = pe.call(h.ownerDocument); h.firstChild; )
|
|
2399
|
+
fe.appendChild(h.firstChild);
|
|
2400
|
+
else
|
|
2401
|
+
fe = h;
|
|
2402
|
+
return (ee.shadowroot || ee.shadowrootmode) && (fe = Fe.call(n, fe, !0)), fe;
|
|
2403
|
+
}
|
|
2404
|
+
let _e = ae ? h.outerHTML : h.innerHTML;
|
|
2405
|
+
return ae && $["!doctype"] && h.ownerDocument && h.ownerDocument.doctype && h.ownerDocument.doctype.name && de(Rs, h.ownerDocument.doctype.name) && (_e = "<!DOCTYPE " + h.ownerDocument.doctype.name + `>
|
|
2406
|
+
` + _e), Te && Bt([w, P, D], (Ue) => {
|
|
2407
|
+
_e = bt(_e, Ue, " ");
|
|
2408
|
+
}), I && te ? I.createHTML(_e) : _e;
|
|
2409
|
+
}, e.setConfig = function() {
|
|
2410
|
+
let E = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
2411
|
+
tn(E), dt = !0;
|
|
2412
|
+
}, e.clearConfig = function() {
|
|
2413
|
+
at = null, dt = !1;
|
|
2414
|
+
}, e.isValidAttribute = function(E, l, h) {
|
|
2415
|
+
at || tn({});
|
|
2416
|
+
const x = oe(E), V = oe(l);
|
|
2417
|
+
return Pn(x, V, h);
|
|
2418
|
+
}, e.addHook = function(E, l) {
|
|
2419
|
+
typeof l == "function" && _t(se[E], l);
|
|
2420
|
+
}, e.removeHook = function(E, l) {
|
|
2421
|
+
if (l !== void 0) {
|
|
2422
|
+
const h = ao(se[E], l);
|
|
2423
|
+
return h === -1 ? void 0 : lo(se[E], h, 1)[0];
|
|
2424
|
+
}
|
|
2425
|
+
return Xn(se[E]);
|
|
2426
|
+
}, e.removeHooks = function(E) {
|
|
2427
|
+
se[E] = [];
|
|
2428
|
+
}, e.removeAllHooks = function() {
|
|
2429
|
+
se = ts();
|
|
2430
|
+
}, e;
|
|
2431
|
+
}
|
|
2432
|
+
var So = Ms();
|
|
2433
|
+
function Ao(s) {
|
|
2434
|
+
return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
|
|
2435
|
+
}
|
|
2436
|
+
function Cs(s) {
|
|
2437
|
+
return s instanceof Map ? s.clear = s.delete = s.set = function() {
|
|
2438
|
+
throw new Error("map is read-only");
|
|
2439
|
+
} : s instanceof Set && (s.add = s.clear = s.delete = function() {
|
|
2440
|
+
throw new Error("set is read-only");
|
|
2441
|
+
}), Object.freeze(s), Object.getOwnPropertyNames(s).forEach((e) => {
|
|
2442
|
+
const t = s[e], n = typeof t;
|
|
2443
|
+
(n === "object" || n === "function") && !Object.isFrozen(t) && Cs(t);
|
|
2444
|
+
}), s;
|
|
2445
|
+
}
|
|
2446
|
+
class ns {
|
|
2447
|
+
/**
|
|
2448
|
+
* @param {CompiledMode} mode
|
|
2449
|
+
*/
|
|
2450
|
+
constructor(e) {
|
|
2451
|
+
e.data === void 0 && (e.data = {}), this.data = e.data, this.isMatchIgnored = !1;
|
|
2452
|
+
}
|
|
2453
|
+
ignoreMatch() {
|
|
2454
|
+
this.isMatchIgnored = !0;
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
function Is(s) {
|
|
2458
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2459
|
+
}
|
|
2460
|
+
function We(s, ...e) {
|
|
2461
|
+
const t = /* @__PURE__ */ Object.create(null);
|
|
2462
|
+
for (const n in s)
|
|
2463
|
+
t[n] = s[n];
|
|
2464
|
+
return e.forEach(function(n) {
|
|
2465
|
+
for (const o in n)
|
|
2466
|
+
t[o] = n[o];
|
|
2467
|
+
}), /** @type {T} */
|
|
2468
|
+
t;
|
|
2469
|
+
}
|
|
2470
|
+
const Ro = "</span>", ss = (s) => !!s.scope, Mo = (s, { prefix: e }) => {
|
|
2471
|
+
if (s.startsWith("language:"))
|
|
2472
|
+
return s.replace("language:", "language-");
|
|
2473
|
+
if (s.includes(".")) {
|
|
2474
|
+
const t = s.split(".");
|
|
2475
|
+
return [
|
|
2476
|
+
`${e}${t.shift()}`,
|
|
2477
|
+
...t.map((n, o) => `${n}${"_".repeat(o + 1)}`)
|
|
2478
|
+
].join(" ");
|
|
2479
|
+
}
|
|
2480
|
+
return `${e}${s}`;
|
|
2481
|
+
};
|
|
2482
|
+
class Co {
|
|
2483
|
+
/**
|
|
2484
|
+
* Creates a new HTMLRenderer
|
|
2485
|
+
*
|
|
2486
|
+
* @param {Tree} parseTree - the parse tree (must support `walk` API)
|
|
2487
|
+
* @param {{classPrefix: string}} options
|
|
2488
|
+
*/
|
|
2489
|
+
constructor(e, t) {
|
|
2490
|
+
this.buffer = "", this.classPrefix = t.classPrefix, e.walk(this);
|
|
2491
|
+
}
|
|
2492
|
+
/**
|
|
2493
|
+
* Adds texts to the output stream
|
|
2494
|
+
*
|
|
2495
|
+
* @param {string} text */
|
|
2496
|
+
addText(e) {
|
|
2497
|
+
this.buffer += Is(e);
|
|
2498
|
+
}
|
|
2499
|
+
/**
|
|
2500
|
+
* Adds a node open to the output stream (if needed)
|
|
2501
|
+
*
|
|
2502
|
+
* @param {Node} node */
|
|
2503
|
+
openNode(e) {
|
|
2504
|
+
if (!ss(e))
|
|
2505
|
+
return;
|
|
2506
|
+
const t = Mo(
|
|
2507
|
+
e.scope,
|
|
2508
|
+
{ prefix: this.classPrefix }
|
|
2509
|
+
);
|
|
2510
|
+
this.span(t);
|
|
2511
|
+
}
|
|
2512
|
+
/**
|
|
2513
|
+
* Adds a node close to the output stream (if needed)
|
|
2514
|
+
*
|
|
2515
|
+
* @param {Node} node */
|
|
2516
|
+
closeNode(e) {
|
|
2517
|
+
ss(e) && (this.buffer += Ro);
|
|
2518
|
+
}
|
|
2519
|
+
/**
|
|
2520
|
+
* returns the accumulated buffer
|
|
2521
|
+
*/
|
|
2522
|
+
value() {
|
|
2523
|
+
return this.buffer;
|
|
2524
|
+
}
|
|
2525
|
+
// helpers
|
|
2526
|
+
/**
|
|
2527
|
+
* Builds a span element
|
|
2528
|
+
*
|
|
2529
|
+
* @param {string} className */
|
|
2530
|
+
span(e) {
|
|
2531
|
+
this.buffer += `<span class="${e}">`;
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
const is = (s = {}) => {
|
|
2535
|
+
const e = { children: [] };
|
|
2536
|
+
return Object.assign(e, s), e;
|
|
2537
|
+
};
|
|
2538
|
+
class vn {
|
|
2539
|
+
constructor() {
|
|
2540
|
+
this.rootNode = is(), this.stack = [this.rootNode];
|
|
2541
|
+
}
|
|
2542
|
+
get top() {
|
|
2543
|
+
return this.stack[this.stack.length - 1];
|
|
2544
|
+
}
|
|
2545
|
+
get root() {
|
|
2546
|
+
return this.rootNode;
|
|
2547
|
+
}
|
|
2548
|
+
/** @param {Node} node */
|
|
2549
|
+
add(e) {
|
|
2550
|
+
this.top.children.push(e);
|
|
2551
|
+
}
|
|
2552
|
+
/** @param {string} scope */
|
|
2553
|
+
openNode(e) {
|
|
2554
|
+
const t = is({ scope: e });
|
|
2555
|
+
this.add(t), this.stack.push(t);
|
|
2556
|
+
}
|
|
2557
|
+
closeNode() {
|
|
2558
|
+
if (this.stack.length > 1)
|
|
2559
|
+
return this.stack.pop();
|
|
2560
|
+
}
|
|
2561
|
+
closeAllNodes() {
|
|
2562
|
+
for (; this.closeNode(); )
|
|
2563
|
+
;
|
|
2564
|
+
}
|
|
2565
|
+
toJSON() {
|
|
2566
|
+
return JSON.stringify(this.rootNode, null, 4);
|
|
2567
|
+
}
|
|
2568
|
+
/**
|
|
2569
|
+
* @typedef { import("./html_renderer").Renderer } Renderer
|
|
2570
|
+
* @param {Renderer} builder
|
|
2571
|
+
*/
|
|
2572
|
+
walk(e) {
|
|
2573
|
+
return this.constructor._walk(e, this.rootNode);
|
|
2574
|
+
}
|
|
2575
|
+
/**
|
|
2576
|
+
* @param {Renderer} builder
|
|
2577
|
+
* @param {Node} node
|
|
2578
|
+
*/
|
|
2579
|
+
static _walk(e, t) {
|
|
2580
|
+
return typeof t == "string" ? e.addText(t) : t.children && (e.openNode(t), t.children.forEach((n) => this._walk(e, n)), e.closeNode(t)), e;
|
|
2581
|
+
}
|
|
2582
|
+
/**
|
|
2583
|
+
* @param {Node} node
|
|
2584
|
+
*/
|
|
2585
|
+
static _collapse(e) {
|
|
2586
|
+
typeof e != "string" && e.children && (e.children.every((t) => typeof t == "string") ? e.children = [e.children.join("")] : e.children.forEach((t) => {
|
|
2587
|
+
vn._collapse(t);
|
|
2588
|
+
}));
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
class Io extends vn {
|
|
2592
|
+
/**
|
|
2593
|
+
* @param {*} options
|
|
2594
|
+
*/
|
|
2595
|
+
constructor(e) {
|
|
2596
|
+
super(), this.options = e;
|
|
2597
|
+
}
|
|
2598
|
+
/**
|
|
2599
|
+
* @param {string} text
|
|
2600
|
+
*/
|
|
2601
|
+
addText(e) {
|
|
2602
|
+
e !== "" && this.add(e);
|
|
2603
|
+
}
|
|
2604
|
+
/** @param {string} scope */
|
|
2605
|
+
startScope(e) {
|
|
2606
|
+
this.openNode(e);
|
|
2607
|
+
}
|
|
2608
|
+
endScope() {
|
|
2609
|
+
this.closeNode();
|
|
2610
|
+
}
|
|
2611
|
+
/**
|
|
2612
|
+
* @param {Emitter & {root: DataNode}} emitter
|
|
2613
|
+
* @param {string} name
|
|
2614
|
+
*/
|
|
2615
|
+
__addSublanguage(e, t) {
|
|
2616
|
+
const n = e.root;
|
|
2617
|
+
t && (n.scope = `language:${t}`), this.add(n);
|
|
2618
|
+
}
|
|
2619
|
+
toHTML() {
|
|
2620
|
+
return new Co(this, this.options).value();
|
|
2621
|
+
}
|
|
2622
|
+
finalize() {
|
|
2623
|
+
return this.closeAllNodes(), !0;
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
function vt(s) {
|
|
2627
|
+
return s ? typeof s == "string" ? s : s.source : null;
|
|
2628
|
+
}
|
|
2629
|
+
function Os(s) {
|
|
2630
|
+
return st("(?=", s, ")");
|
|
2631
|
+
}
|
|
2632
|
+
function Oo(s) {
|
|
2633
|
+
return st("(?:", s, ")*");
|
|
2634
|
+
}
|
|
2635
|
+
function No(s) {
|
|
2636
|
+
return st("(?:", s, ")?");
|
|
2637
|
+
}
|
|
2638
|
+
function st(...s) {
|
|
2639
|
+
return s.map((t) => vt(t)).join("");
|
|
2640
|
+
}
|
|
2641
|
+
function Do(s) {
|
|
2642
|
+
const e = s[s.length - 1];
|
|
2643
|
+
return typeof e == "object" && e.constructor === Object ? (s.splice(s.length - 1, 1), e) : {};
|
|
2644
|
+
}
|
|
2645
|
+
function Sn(...s) {
|
|
2646
|
+
return "(" + (Do(s).capture ? "" : "?:") + s.map((n) => vt(n)).join("|") + ")";
|
|
2647
|
+
}
|
|
2648
|
+
function Ns(s) {
|
|
2649
|
+
return new RegExp(s.toString() + "|").exec("").length - 1;
|
|
2650
|
+
}
|
|
2651
|
+
function Lo(s, e) {
|
|
2652
|
+
const t = s && s.exec(e);
|
|
2653
|
+
return t && t.index === 0;
|
|
2654
|
+
}
|
|
2655
|
+
const Po = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
|
|
2656
|
+
function An(s, { joinWith: e }) {
|
|
2657
|
+
let t = 0;
|
|
2658
|
+
return s.map((n) => {
|
|
2659
|
+
t += 1;
|
|
2660
|
+
const o = t;
|
|
2661
|
+
let r = vt(n), i = "";
|
|
2662
|
+
for (; r.length > 0; ) {
|
|
2663
|
+
const a = Po.exec(r);
|
|
2664
|
+
if (!a) {
|
|
2665
|
+
i += r;
|
|
2666
|
+
break;
|
|
2667
|
+
}
|
|
2668
|
+
i += r.substring(0, a.index), r = r.substring(a.index + a[0].length), a[0][0] === "\\" && a[1] ? i += "\\" + String(Number(a[1]) + o) : (i += a[0], a[0] === "(" && t++);
|
|
2669
|
+
}
|
|
2670
|
+
return i;
|
|
2671
|
+
}).map((n) => `(${n})`).join(e);
|
|
2672
|
+
}
|
|
2673
|
+
const $o = /\b\B/, Ds = "[a-zA-Z]\\w*", Rn = "[a-zA-Z_]\\w*", Ls = "\\b\\d+(\\.\\d+)?", Ps = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)", $s = "\\b(0b[01]+)", zo = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~", Uo = (s = {}) => {
|
|
2674
|
+
const e = /^#![ ]*\//;
|
|
2675
|
+
return s.binary && (s.begin = st(
|
|
2676
|
+
e,
|
|
2677
|
+
/.*\b/,
|
|
2678
|
+
s.binary,
|
|
2679
|
+
/\b.*/
|
|
2680
|
+
)), We({
|
|
2681
|
+
scope: "meta",
|
|
2682
|
+
begin: e,
|
|
2683
|
+
end: /$/,
|
|
2684
|
+
relevance: 0,
|
|
2685
|
+
/** @type {ModeCallback} */
|
|
2686
|
+
"on:begin": (t, n) => {
|
|
2687
|
+
t.index !== 0 && n.ignoreMatch();
|
|
2688
|
+
}
|
|
2689
|
+
}, s);
|
|
2690
|
+
}, St = {
|
|
2691
|
+
begin: "\\\\[\\s\\S]",
|
|
2692
|
+
relevance: 0
|
|
2693
|
+
}, Bo = {
|
|
2694
|
+
scope: "string",
|
|
2695
|
+
begin: "'",
|
|
2696
|
+
end: "'",
|
|
2697
|
+
illegal: "\\n",
|
|
2698
|
+
contains: [St]
|
|
2699
|
+
}, Ho = {
|
|
2700
|
+
scope: "string",
|
|
2701
|
+
begin: '"',
|
|
2702
|
+
end: '"',
|
|
2703
|
+
illegal: "\\n",
|
|
2704
|
+
contains: [St]
|
|
2705
|
+
}, Fo = {
|
|
2706
|
+
begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
|
|
2707
|
+
}, Qt = function(s, e, t = {}) {
|
|
2708
|
+
const n = We(
|
|
2709
|
+
{
|
|
2710
|
+
scope: "comment",
|
|
2711
|
+
begin: s,
|
|
2712
|
+
end: e,
|
|
2713
|
+
contains: []
|
|
2714
|
+
},
|
|
2715
|
+
t
|
|
2716
|
+
);
|
|
2717
|
+
n.contains.push({
|
|
2718
|
+
scope: "doctag",
|
|
2719
|
+
// hack to avoid the space from being included. the space is necessary to
|
|
2720
|
+
// match here to prevent the plain text rule below from gobbling up doctags
|
|
2721
|
+
begin: "[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",
|
|
2722
|
+
end: /(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,
|
|
2723
|
+
excludeBegin: !0,
|
|
2724
|
+
relevance: 0
|
|
2725
|
+
});
|
|
2726
|
+
const o = Sn(
|
|
2727
|
+
// list of common 1 and 2 letter words in English
|
|
2728
|
+
"I",
|
|
2729
|
+
"a",
|
|
2730
|
+
"is",
|
|
2731
|
+
"so",
|
|
2732
|
+
"us",
|
|
2733
|
+
"to",
|
|
2734
|
+
"at",
|
|
2735
|
+
"if",
|
|
2736
|
+
"in",
|
|
2737
|
+
"it",
|
|
2738
|
+
"on",
|
|
2739
|
+
// note: this is not an exhaustive list of contractions, just popular ones
|
|
2740
|
+
/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,
|
|
2741
|
+
// contractions - can't we'd they're let's, etc
|
|
2742
|
+
/[A-Za-z]+[-][a-z]+/,
|
|
2743
|
+
// `no-way`, etc.
|
|
2744
|
+
/[A-Za-z][a-z]{2,}/
|
|
2745
|
+
// allow capitalized words at beginning of sentences
|
|
2746
|
+
);
|
|
2747
|
+
return n.contains.push(
|
|
2748
|
+
{
|
|
2749
|
+
// TODO: how to include ", (, ) without breaking grammars that use these for
|
|
2750
|
+
// comment delimiters?
|
|
2751
|
+
// begin: /[ ]+([()"]?([A-Za-z'-]{3,}|is|a|I|so|us|[tT][oO]|at|if|in|it|on)[.]?[()":]?([.][ ]|[ ]|\))){3}/
|
|
2752
|
+
// ---
|
|
2753
|
+
// this tries to find sequences of 3 english words in a row (without any
|
|
2754
|
+
// "programming" type syntax) this gives us a strong signal that we've
|
|
2755
|
+
// TRULY found a comment - vs perhaps scanning with the wrong language.
|
|
2756
|
+
// It's possible to find something that LOOKS like the start of the
|
|
2757
|
+
// comment - but then if there is no readable text - good chance it is a
|
|
2758
|
+
// false match and not a comment.
|
|
2759
|
+
//
|
|
2760
|
+
// for a visual example please see:
|
|
2761
|
+
// https://github.com/highlightjs/highlight.js/issues/2827
|
|
2762
|
+
begin: st(
|
|
2763
|
+
/[ ]+/,
|
|
2764
|
+
// necessary to prevent us gobbling up doctags like /* @author Bob Mcgill */
|
|
2765
|
+
"(",
|
|
2766
|
+
o,
|
|
2767
|
+
/[.]?[:]?([.][ ]|[ ])/,
|
|
2768
|
+
"){3}"
|
|
2769
|
+
)
|
|
2770
|
+
// look for 3 words in a row
|
|
2771
|
+
}
|
|
2772
|
+
), n;
|
|
2773
|
+
}, jo = Qt("//", "$"), Wo = Qt("/\\*", "\\*/"), Go = Qt("#", "$"), qo = {
|
|
2774
|
+
scope: "number",
|
|
2775
|
+
begin: Ls,
|
|
2776
|
+
relevance: 0
|
|
2777
|
+
}, Yo = {
|
|
2778
|
+
scope: "number",
|
|
2779
|
+
begin: Ps,
|
|
2780
|
+
relevance: 0
|
|
2781
|
+
}, Zo = {
|
|
2782
|
+
scope: "number",
|
|
2783
|
+
begin: $s,
|
|
2784
|
+
relevance: 0
|
|
2785
|
+
}, Xo = {
|
|
2786
|
+
scope: "regexp",
|
|
2787
|
+
begin: /\/(?=[^/\n]*\/)/,
|
|
2788
|
+
end: /\/[gimuy]*/,
|
|
2789
|
+
contains: [
|
|
2790
|
+
St,
|
|
2791
|
+
{
|
|
2792
|
+
begin: /\[/,
|
|
2793
|
+
end: /\]/,
|
|
2794
|
+
relevance: 0,
|
|
2795
|
+
contains: [St]
|
|
2796
|
+
}
|
|
2797
|
+
]
|
|
2798
|
+
}, Vo = {
|
|
2799
|
+
scope: "title",
|
|
2800
|
+
begin: Ds,
|
|
2801
|
+
relevance: 0
|
|
2802
|
+
}, Ko = {
|
|
2803
|
+
scope: "title",
|
|
2804
|
+
begin: Rn,
|
|
2805
|
+
relevance: 0
|
|
2806
|
+
}, Qo = {
|
|
2807
|
+
// excludes method names from keyword processing
|
|
2808
|
+
begin: "\\.\\s*" + Rn,
|
|
2809
|
+
relevance: 0
|
|
2810
|
+
}, Jo = function(s) {
|
|
2811
|
+
return Object.assign(
|
|
2812
|
+
s,
|
|
2813
|
+
{
|
|
2814
|
+
/** @type {ModeCallback} */
|
|
2815
|
+
"on:begin": (e, t) => {
|
|
2816
|
+
t.data._beginMatch = e[1];
|
|
2817
|
+
},
|
|
2818
|
+
/** @type {ModeCallback} */
|
|
2819
|
+
"on:end": (e, t) => {
|
|
2820
|
+
t.data._beginMatch !== e[1] && t.ignoreMatch();
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
);
|
|
2824
|
+
};
|
|
2825
|
+
var Ft = /* @__PURE__ */ Object.freeze({
|
|
2826
|
+
__proto__: null,
|
|
2827
|
+
APOS_STRING_MODE: Bo,
|
|
2828
|
+
BACKSLASH_ESCAPE: St,
|
|
2829
|
+
BINARY_NUMBER_MODE: Zo,
|
|
2830
|
+
BINARY_NUMBER_RE: $s,
|
|
2831
|
+
COMMENT: Qt,
|
|
2832
|
+
C_BLOCK_COMMENT_MODE: Wo,
|
|
2833
|
+
C_LINE_COMMENT_MODE: jo,
|
|
2834
|
+
C_NUMBER_MODE: Yo,
|
|
2835
|
+
C_NUMBER_RE: Ps,
|
|
2836
|
+
END_SAME_AS_BEGIN: Jo,
|
|
2837
|
+
HASH_COMMENT_MODE: Go,
|
|
2838
|
+
IDENT_RE: Ds,
|
|
2839
|
+
MATCH_NOTHING_RE: $o,
|
|
2840
|
+
METHOD_GUARD: Qo,
|
|
2841
|
+
NUMBER_MODE: qo,
|
|
2842
|
+
NUMBER_RE: Ls,
|
|
2843
|
+
PHRASAL_WORDS_MODE: Fo,
|
|
2844
|
+
QUOTE_STRING_MODE: Ho,
|
|
2845
|
+
REGEXP_MODE: Xo,
|
|
2846
|
+
RE_STARTERS_RE: zo,
|
|
2847
|
+
SHEBANG: Uo,
|
|
2848
|
+
TITLE_MODE: Vo,
|
|
2849
|
+
UNDERSCORE_IDENT_RE: Rn,
|
|
2850
|
+
UNDERSCORE_TITLE_MODE: Ko
|
|
2851
|
+
});
|
|
2852
|
+
function er(s, e) {
|
|
2853
|
+
s.input[s.index - 1] === "." && e.ignoreMatch();
|
|
2854
|
+
}
|
|
2855
|
+
function tr(s, e) {
|
|
2856
|
+
s.className !== void 0 && (s.scope = s.className, delete s.className);
|
|
2857
|
+
}
|
|
2858
|
+
function nr(s, e) {
|
|
2859
|
+
e && s.beginKeywords && (s.begin = "\\b(" + s.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)", s.__beforeBegin = er, s.keywords = s.keywords || s.beginKeywords, delete s.beginKeywords, s.relevance === void 0 && (s.relevance = 0));
|
|
2860
|
+
}
|
|
2861
|
+
function sr(s, e) {
|
|
2862
|
+
Array.isArray(s.illegal) && (s.illegal = Sn(...s.illegal));
|
|
2863
|
+
}
|
|
2864
|
+
function ir(s, e) {
|
|
2865
|
+
if (s.match) {
|
|
2866
|
+
if (s.begin || s.end)
|
|
2867
|
+
throw new Error("begin & end are not supported with match");
|
|
2868
|
+
s.begin = s.match, delete s.match;
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
function or(s, e) {
|
|
2872
|
+
s.relevance === void 0 && (s.relevance = 1);
|
|
2873
|
+
}
|
|
2874
|
+
const rr = (s, e) => {
|
|
2875
|
+
if (!s.beforeMatch)
|
|
2876
|
+
return;
|
|
2877
|
+
if (s.starts)
|
|
2878
|
+
throw new Error("beforeMatch cannot be used with starts");
|
|
2879
|
+
const t = Object.assign({}, s);
|
|
2880
|
+
Object.keys(s).forEach((n) => {
|
|
2881
|
+
delete s[n];
|
|
2882
|
+
}), s.keywords = t.keywords, s.begin = st(t.beforeMatch, Os(t.begin)), s.starts = {
|
|
2883
|
+
relevance: 0,
|
|
2884
|
+
contains: [
|
|
2885
|
+
Object.assign(t, { endsParent: !0 })
|
|
2886
|
+
]
|
|
2887
|
+
}, s.relevance = 0, delete t.beforeMatch;
|
|
2888
|
+
}, ar = [
|
|
2889
|
+
"of",
|
|
2890
|
+
"and",
|
|
2891
|
+
"for",
|
|
2892
|
+
"in",
|
|
2893
|
+
"not",
|
|
2894
|
+
"or",
|
|
2895
|
+
"if",
|
|
2896
|
+
"then",
|
|
2897
|
+
"parent",
|
|
2898
|
+
// common variable name
|
|
2899
|
+
"list",
|
|
2900
|
+
// common variable name
|
|
2901
|
+
"value"
|
|
2902
|
+
// common variable name
|
|
2903
|
+
], lr = "keyword";
|
|
2904
|
+
function zs(s, e, t = lr) {
|
|
2905
|
+
const n = /* @__PURE__ */ Object.create(null);
|
|
2906
|
+
return typeof s == "string" ? o(t, s.split(" ")) : Array.isArray(s) ? o(t, s) : Object.keys(s).forEach(function(r) {
|
|
2907
|
+
Object.assign(
|
|
2908
|
+
n,
|
|
2909
|
+
zs(s[r], e, r)
|
|
2910
|
+
);
|
|
2911
|
+
}), n;
|
|
2912
|
+
function o(r, i) {
|
|
2913
|
+
e && (i = i.map((a) => a.toLowerCase())), i.forEach(function(a) {
|
|
2914
|
+
const c = a.split("|");
|
|
2915
|
+
n[c[0]] = [r, cr(c[0], c[1])];
|
|
2916
|
+
});
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
function cr(s, e) {
|
|
2920
|
+
return e ? Number(e) : ur(s) ? 0 : 1;
|
|
2921
|
+
}
|
|
2922
|
+
function ur(s) {
|
|
2923
|
+
return ar.includes(s.toLowerCase());
|
|
2924
|
+
}
|
|
2925
|
+
const os = {}, Je = (s) => {
|
|
2926
|
+
console.error(s);
|
|
2927
|
+
}, rs = (s, ...e) => {
|
|
2928
|
+
console.log(`WARN: ${s}`, ...e);
|
|
2929
|
+
}, ct = (s, e) => {
|
|
2930
|
+
os[`${s}/${e}`] || (console.log(`Deprecated as of ${s}. ${e}`), os[`${s}/${e}`] = !0);
|
|
2931
|
+
}, Yt = new Error();
|
|
2932
|
+
function Us(s, e, { key: t }) {
|
|
2933
|
+
let n = 0;
|
|
2934
|
+
const o = s[t], r = {}, i = {};
|
|
2935
|
+
for (let a = 1; a <= e.length; a++)
|
|
2936
|
+
i[a + n] = o[a], r[a + n] = !0, n += Ns(e[a - 1]);
|
|
2937
|
+
s[t] = i, s[t]._emit = r, s[t]._multi = !0;
|
|
2938
|
+
}
|
|
2939
|
+
function fr(s) {
|
|
2940
|
+
if (Array.isArray(s.begin)) {
|
|
2941
|
+
if (s.skip || s.excludeBegin || s.returnBegin)
|
|
2942
|
+
throw Je("skip, excludeBegin, returnBegin not compatible with beginScope: {}"), Yt;
|
|
2943
|
+
if (typeof s.beginScope != "object" || s.beginScope === null)
|
|
2944
|
+
throw Je("beginScope must be object"), Yt;
|
|
2945
|
+
Us(s, s.begin, { key: "beginScope" }), s.begin = An(s.begin, { joinWith: "" });
|
|
2946
|
+
}
|
|
2947
|
+
}
|
|
2948
|
+
function pr(s) {
|
|
2949
|
+
if (Array.isArray(s.end)) {
|
|
2950
|
+
if (s.skip || s.excludeEnd || s.returnEnd)
|
|
2951
|
+
throw Je("skip, excludeEnd, returnEnd not compatible with endScope: {}"), Yt;
|
|
2952
|
+
if (typeof s.endScope != "object" || s.endScope === null)
|
|
2953
|
+
throw Je("endScope must be object"), Yt;
|
|
2954
|
+
Us(s, s.end, { key: "endScope" }), s.end = An(s.end, { joinWith: "" });
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
function hr(s) {
|
|
2958
|
+
s.scope && typeof s.scope == "object" && s.scope !== null && (s.beginScope = s.scope, delete s.scope);
|
|
2959
|
+
}
|
|
2960
|
+
function dr(s) {
|
|
2961
|
+
hr(s), typeof s.beginScope == "string" && (s.beginScope = { _wrap: s.beginScope }), typeof s.endScope == "string" && (s.endScope = { _wrap: s.endScope }), fr(s), pr(s);
|
|
2962
|
+
}
|
|
2963
|
+
function gr(s) {
|
|
2964
|
+
function e(i, a) {
|
|
2965
|
+
return new RegExp(
|
|
2966
|
+
vt(i),
|
|
2967
|
+
"m" + (s.case_insensitive ? "i" : "") + (s.unicodeRegex ? "u" : "") + (a ? "g" : "")
|
|
2968
|
+
);
|
|
2969
|
+
}
|
|
2970
|
+
class t {
|
|
2971
|
+
constructor() {
|
|
2972
|
+
this.matchIndexes = {}, this.regexes = [], this.matchAt = 1, this.position = 0;
|
|
2973
|
+
}
|
|
2974
|
+
// @ts-ignore
|
|
2975
|
+
addRule(a, c) {
|
|
2976
|
+
c.position = this.position++, this.matchIndexes[this.matchAt] = c, this.regexes.push([c, a]), this.matchAt += Ns(a) + 1;
|
|
2977
|
+
}
|
|
2978
|
+
compile() {
|
|
2979
|
+
this.regexes.length === 0 && (this.exec = () => null);
|
|
2980
|
+
const a = this.regexes.map((c) => c[1]);
|
|
2981
|
+
this.matcherRe = e(An(a, { joinWith: "|" }), !0), this.lastIndex = 0;
|
|
2982
|
+
}
|
|
2983
|
+
/** @param {string} s */
|
|
2984
|
+
exec(a) {
|
|
2985
|
+
this.matcherRe.lastIndex = this.lastIndex;
|
|
2986
|
+
const c = this.matcherRe.exec(a);
|
|
2987
|
+
if (!c)
|
|
2988
|
+
return null;
|
|
2989
|
+
const g = c.findIndex((_, d) => d > 0 && _ !== void 0), u = this.matchIndexes[g];
|
|
2990
|
+
return c.splice(0, g), Object.assign(c, u);
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2993
|
+
class n {
|
|
2994
|
+
constructor() {
|
|
2995
|
+
this.rules = [], this.multiRegexes = [], this.count = 0, this.lastIndex = 0, this.regexIndex = 0;
|
|
2996
|
+
}
|
|
2997
|
+
// @ts-ignore
|
|
2998
|
+
getMatcher(a) {
|
|
2999
|
+
if (this.multiRegexes[a])
|
|
3000
|
+
return this.multiRegexes[a];
|
|
3001
|
+
const c = new t();
|
|
3002
|
+
return this.rules.slice(a).forEach(([g, u]) => c.addRule(g, u)), c.compile(), this.multiRegexes[a] = c, c;
|
|
3003
|
+
}
|
|
3004
|
+
resumingScanAtSamePosition() {
|
|
3005
|
+
return this.regexIndex !== 0;
|
|
3006
|
+
}
|
|
3007
|
+
considerAll() {
|
|
3008
|
+
this.regexIndex = 0;
|
|
3009
|
+
}
|
|
3010
|
+
// @ts-ignore
|
|
3011
|
+
addRule(a, c) {
|
|
3012
|
+
this.rules.push([a, c]), c.type === "begin" && this.count++;
|
|
3013
|
+
}
|
|
3014
|
+
/** @param {string} s */
|
|
3015
|
+
exec(a) {
|
|
3016
|
+
const c = this.getMatcher(this.regexIndex);
|
|
3017
|
+
c.lastIndex = this.lastIndex;
|
|
3018
|
+
let g = c.exec(a);
|
|
3019
|
+
if (this.resumingScanAtSamePosition() && !(g && g.index === this.lastIndex)) {
|
|
3020
|
+
const u = this.getMatcher(0);
|
|
3021
|
+
u.lastIndex = this.lastIndex + 1, g = u.exec(a);
|
|
3022
|
+
}
|
|
3023
|
+
return g && (this.regexIndex += g.position + 1, this.regexIndex === this.count && this.considerAll()), g;
|
|
3024
|
+
}
|
|
3025
|
+
}
|
|
3026
|
+
function o(i) {
|
|
3027
|
+
const a = new n();
|
|
3028
|
+
return i.contains.forEach((c) => a.addRule(c.begin, { rule: c, type: "begin" })), i.terminatorEnd && a.addRule(i.terminatorEnd, { type: "end" }), i.illegal && a.addRule(i.illegal, { type: "illegal" }), a;
|
|
3029
|
+
}
|
|
3030
|
+
function r(i, a) {
|
|
3031
|
+
const c = (
|
|
3032
|
+
/** @type CompiledMode */
|
|
3033
|
+
i
|
|
3034
|
+
);
|
|
3035
|
+
if (i.isCompiled)
|
|
3036
|
+
return c;
|
|
3037
|
+
[
|
|
3038
|
+
tr,
|
|
3039
|
+
// do this early so compiler extensions generally don't have to worry about
|
|
3040
|
+
// the distinction between match/begin
|
|
3041
|
+
ir,
|
|
3042
|
+
dr,
|
|
3043
|
+
rr
|
|
3044
|
+
].forEach((u) => u(i, a)), s.compilerExtensions.forEach((u) => u(i, a)), i.__beforeBegin = null, [
|
|
3045
|
+
nr,
|
|
3046
|
+
// do this later so compiler extensions that come earlier have access to the
|
|
3047
|
+
// raw array if they wanted to perhaps manipulate it, etc.
|
|
3048
|
+
sr,
|
|
3049
|
+
// default to 1 relevance if not specified
|
|
3050
|
+
or
|
|
3051
|
+
].forEach((u) => u(i, a)), i.isCompiled = !0;
|
|
3052
|
+
let g = null;
|
|
3053
|
+
return typeof i.keywords == "object" && i.keywords.$pattern && (i.keywords = Object.assign({}, i.keywords), g = i.keywords.$pattern, delete i.keywords.$pattern), g = g || /\w+/, i.keywords && (i.keywords = zs(i.keywords, s.case_insensitive)), c.keywordPatternRe = e(g, !0), a && (i.begin || (i.begin = /\B|\b/), c.beginRe = e(c.begin), !i.end && !i.endsWithParent && (i.end = /\B|\b/), i.end && (c.endRe = e(c.end)), c.terminatorEnd = vt(c.end) || "", i.endsWithParent && a.terminatorEnd && (c.terminatorEnd += (i.end ? "|" : "") + a.terminatorEnd)), i.illegal && (c.illegalRe = e(
|
|
3054
|
+
/** @type {RegExp | string} */
|
|
3055
|
+
i.illegal
|
|
3056
|
+
)), i.contains || (i.contains = []), i.contains = [].concat(...i.contains.map(function(u) {
|
|
3057
|
+
return mr(u === "self" ? i : u);
|
|
3058
|
+
})), i.contains.forEach(function(u) {
|
|
3059
|
+
r(
|
|
3060
|
+
/** @type Mode */
|
|
3061
|
+
u,
|
|
3062
|
+
c
|
|
3063
|
+
);
|
|
3064
|
+
}), i.starts && r(i.starts, a), c.matcher = o(c), c;
|
|
3065
|
+
}
|
|
3066
|
+
if (s.compilerExtensions || (s.compilerExtensions = []), s.contains && s.contains.includes("self"))
|
|
3067
|
+
throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
|
|
3068
|
+
return s.classNameAliases = We(s.classNameAliases || {}), r(
|
|
3069
|
+
/** @type Mode */
|
|
3070
|
+
s
|
|
3071
|
+
);
|
|
3072
|
+
}
|
|
3073
|
+
function Bs(s) {
|
|
3074
|
+
return s ? s.endsWithParent || Bs(s.starts) : !1;
|
|
3075
|
+
}
|
|
3076
|
+
function mr(s) {
|
|
3077
|
+
return s.variants && !s.cachedVariants && (s.cachedVariants = s.variants.map(function(e) {
|
|
3078
|
+
return We(s, { variants: null }, e);
|
|
3079
|
+
})), s.cachedVariants ? s.cachedVariants : Bs(s) ? We(s, { starts: s.starts ? We(s.starts) : null }) : Object.isFrozen(s) ? We(s) : s;
|
|
3080
|
+
}
|
|
3081
|
+
var _r = "11.11.1";
|
|
3082
|
+
class br extends Error {
|
|
3083
|
+
constructor(e, t) {
|
|
3084
|
+
super(e), this.name = "HTMLInjectionError", this.html = t;
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
const pn = Is, as = We, ls = Symbol("nomatch"), yr = 7, Hs = function(s) {
|
|
3088
|
+
const e = /* @__PURE__ */ Object.create(null), t = /* @__PURE__ */ Object.create(null), n = [];
|
|
3089
|
+
let o = !0;
|
|
3090
|
+
const r = "Could not find the language '{}', did you forget to load/include a language module?", i = { disableAutodetect: !0, name: "Plain text", contains: [] };
|
|
3091
|
+
let a = {
|
|
3092
|
+
ignoreUnescapedHTML: !1,
|
|
3093
|
+
throwUnescapedHTML: !1,
|
|
3094
|
+
noHighlightRe: /^(no-?highlight)$/i,
|
|
3095
|
+
languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i,
|
|
3096
|
+
classPrefix: "hljs-",
|
|
3097
|
+
cssSelector: "pre code",
|
|
3098
|
+
languages: null,
|
|
3099
|
+
// beta configuration options, subject to change, welcome to discuss
|
|
3100
|
+
// https://github.com/highlightjs/highlight.js/issues/1086
|
|
3101
|
+
__emitter: Io
|
|
3102
|
+
};
|
|
3103
|
+
function c(p) {
|
|
3104
|
+
return a.noHighlightRe.test(p);
|
|
3105
|
+
}
|
|
3106
|
+
function g(p) {
|
|
3107
|
+
let k = p.className + " ";
|
|
3108
|
+
k += p.parentNode ? p.parentNode.className : "";
|
|
3109
|
+
const R = a.languageDetectRe.exec(k);
|
|
3110
|
+
if (R) {
|
|
3111
|
+
const F = pe(R[1]);
|
|
3112
|
+
return F || (rs(r.replace("{}", R[1])), rs("Falling back to no-highlight mode for this block.", p)), F ? R[1] : "no-highlight";
|
|
3113
|
+
}
|
|
3114
|
+
return k.split(/\s+/).find((F) => c(F) || pe(F));
|
|
3115
|
+
}
|
|
3116
|
+
function u(p, k, R) {
|
|
3117
|
+
let F = "", j = "";
|
|
3118
|
+
typeof k == "object" ? (F = p, R = k.ignoreIllegals, j = k.language) : (ct("10.7.0", "highlight(lang, code, ...args) has been deprecated."), ct("10.7.0", `Please use highlight(code, options) instead.
|
|
3119
|
+
https://github.com/highlightjs/highlight.js/issues/2277`), j = p, F = k), R === void 0 && (R = !0);
|
|
3120
|
+
const $ = {
|
|
3121
|
+
code: F,
|
|
3122
|
+
language: j
|
|
3123
|
+
};
|
|
3124
|
+
D("before:highlight", $);
|
|
3125
|
+
const Ee = $.result ? $.result : _($.language, $.code, R);
|
|
3126
|
+
return Ee.code = $.code, D("after:highlight", Ee), Ee;
|
|
3127
|
+
}
|
|
3128
|
+
function _(p, k, R, F) {
|
|
3129
|
+
const j = /* @__PURE__ */ Object.create(null);
|
|
3130
|
+
function $(m, b) {
|
|
3131
|
+
return m.keywords[b];
|
|
3132
|
+
}
|
|
3133
|
+
function Ee() {
|
|
3134
|
+
if (!v.keywords) {
|
|
3135
|
+
te.addText(W);
|
|
3136
|
+
return;
|
|
3137
|
+
}
|
|
3138
|
+
let m = 0;
|
|
3139
|
+
v.keywordPatternRe.lastIndex = 0;
|
|
3140
|
+
let b = v.keywordPatternRe.exec(W), A = "";
|
|
3141
|
+
for (; b; ) {
|
|
3142
|
+
A += W.substring(m, b.index);
|
|
3143
|
+
const U = ae.case_insensitive ? b[0].toLowerCase() : b[0], ie = $(v, U);
|
|
3144
|
+
if (ie) {
|
|
3145
|
+
const [ye, Nt] = ie;
|
|
3146
|
+
if (te.addText(A), A = "", j[U] = (j[U] || 0) + 1, j[U] <= yr && (Xe += Nt), ye.startsWith("_"))
|
|
3147
|
+
A += b[0];
|
|
3148
|
+
else {
|
|
3149
|
+
const ot = ae.classNameAliases[ye] || ye;
|
|
3150
|
+
z(b[0], ot);
|
|
3151
|
+
}
|
|
3152
|
+
} else
|
|
3153
|
+
A += b[0];
|
|
3154
|
+
m = v.keywordPatternRe.lastIndex, b = v.keywordPatternRe.exec(W);
|
|
3155
|
+
}
|
|
3156
|
+
A += W.substring(m), te.addText(A);
|
|
3157
|
+
}
|
|
3158
|
+
function ee() {
|
|
3159
|
+
if (W === "")
|
|
3160
|
+
return;
|
|
3161
|
+
let m = null;
|
|
3162
|
+
if (typeof v.subLanguage == "string") {
|
|
3163
|
+
if (!e[v.subLanguage]) {
|
|
3164
|
+
te.addText(W);
|
|
3165
|
+
return;
|
|
3166
|
+
}
|
|
3167
|
+
m = _(v.subLanguage, W, !0, Ze[v.subLanguage]), Ze[v.subLanguage] = /** @type {CompiledMode} */
|
|
3168
|
+
m._top;
|
|
3169
|
+
} else
|
|
3170
|
+
m = f(W, v.subLanguage.length ? v.subLanguage : null);
|
|
3171
|
+
v.relevance > 0 && (Xe += m.relevance), te.__addSublanguage(m._emitter, m.language);
|
|
3172
|
+
}
|
|
3173
|
+
function ue() {
|
|
3174
|
+
v.subLanguage != null ? ee() : Ee(), W = "";
|
|
3175
|
+
}
|
|
3176
|
+
function z(m, b) {
|
|
3177
|
+
m !== "" && (te.startScope(b), te.addText(m), te.endScope());
|
|
3178
|
+
}
|
|
3179
|
+
function je(m, b) {
|
|
3180
|
+
let A = 1;
|
|
3181
|
+
const U = b.length - 1;
|
|
3182
|
+
for (; A <= U; ) {
|
|
3183
|
+
if (!m._emit[A]) {
|
|
3184
|
+
A++;
|
|
3185
|
+
continue;
|
|
3186
|
+
}
|
|
3187
|
+
const ie = ae.classNameAliases[m[A]] || m[A], ye = b[A];
|
|
3188
|
+
ie ? z(ye, ie) : (W = ye, Ee(), W = ""), A++;
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
3191
|
+
function it(m, b) {
|
|
3192
|
+
return m.scope && typeof m.scope == "string" && te.openNode(ae.classNameAliases[m.scope] || m.scope), m.beginScope && (m.beginScope._wrap ? (z(W, ae.classNameAliases[m.beginScope._wrap] || m.beginScope._wrap), W = "") : m.beginScope._multi && (je(m.beginScope, b), W = "")), v = Object.create(m, { parent: { value: v } }), v;
|
|
3193
|
+
}
|
|
3194
|
+
function De(m, b, A) {
|
|
3195
|
+
let U = Lo(m.endRe, A);
|
|
3196
|
+
if (U) {
|
|
3197
|
+
if (m["on:end"]) {
|
|
3198
|
+
const ie = new ns(m);
|
|
3199
|
+
m["on:end"](b, ie), ie.isMatchIgnored && (U = !1);
|
|
3200
|
+
}
|
|
3201
|
+
if (U) {
|
|
3202
|
+
for (; m.endsParent && m.parent; )
|
|
3203
|
+
m = m.parent;
|
|
3204
|
+
return m;
|
|
3205
|
+
}
|
|
3206
|
+
}
|
|
3207
|
+
if (m.endsWithParent)
|
|
3208
|
+
return De(m.parent, b, A);
|
|
3209
|
+
}
|
|
3210
|
+
function Ct(m) {
|
|
3211
|
+
return v.matcher.regexIndex === 0 ? (W += m[0], 1) : (Pe = !0, 0);
|
|
3212
|
+
}
|
|
3213
|
+
function ht(m) {
|
|
3214
|
+
const b = m[0], A = m.rule, U = new ns(A), ie = [A.__beforeBegin, A["on:begin"]];
|
|
3215
|
+
for (const ye of ie)
|
|
3216
|
+
if (ye && (ye(m, U), U.isMatchIgnored))
|
|
3217
|
+
return Ct(b);
|
|
3218
|
+
return A.skip ? W += b : (A.excludeBegin && (W += b), ue(), !A.returnBegin && !A.excludeBegin && (W = b)), it(A, m), A.returnBegin ? 0 : b.length;
|
|
3219
|
+
}
|
|
3220
|
+
function It(m) {
|
|
3221
|
+
const b = m[0], A = k.substring(m.index), U = De(v, m, A);
|
|
3222
|
+
if (!U)
|
|
3223
|
+
return ls;
|
|
3224
|
+
const ie = v;
|
|
3225
|
+
v.endScope && v.endScope._wrap ? (ue(), z(b, v.endScope._wrap)) : v.endScope && v.endScope._multi ? (ue(), je(v.endScope, m)) : ie.skip ? W += b : (ie.returnEnd || ie.excludeEnd || (W += b), ue(), ie.excludeEnd && (W = b));
|
|
3226
|
+
do
|
|
3227
|
+
v.scope && te.closeNode(), !v.skip && !v.subLanguage && (Xe += v.relevance), v = v.parent;
|
|
3228
|
+
while (v !== U.parent);
|
|
3229
|
+
return U.starts && it(U.starts, m), ie.returnEnd ? 0 : b.length;
|
|
3230
|
+
}
|
|
3231
|
+
function Ot() {
|
|
3232
|
+
const m = [];
|
|
3233
|
+
for (let b = v; b !== ae; b = b.parent)
|
|
3234
|
+
b.scope && m.unshift(b.scope);
|
|
3235
|
+
m.forEach((b) => te.openNode(b));
|
|
3236
|
+
}
|
|
3237
|
+
let Te = {};
|
|
3238
|
+
function qe(m, b) {
|
|
3239
|
+
const A = b && b[0];
|
|
3240
|
+
if (W += m, A == null)
|
|
3241
|
+
return ue(), 0;
|
|
3242
|
+
if (Te.type === "begin" && b.type === "end" && Te.index === b.index && A === "") {
|
|
3243
|
+
if (W += k.slice(b.index, b.index + 1), !o) {
|
|
3244
|
+
const U = new Error(`0 width match regex (${p})`);
|
|
3245
|
+
throw U.languageName = p, U.badRule = Te.rule, U;
|
|
3246
|
+
}
|
|
3247
|
+
return 1;
|
|
3248
|
+
}
|
|
3249
|
+
if (Te = b, b.type === "begin")
|
|
3250
|
+
return ht(b);
|
|
3251
|
+
if (b.type === "illegal" && !R) {
|
|
3252
|
+
const U = new Error('Illegal lexeme "' + A + '" for mode "' + (v.scope || "<unnamed>") + '"');
|
|
3253
|
+
throw U.mode = v, U;
|
|
3254
|
+
} else if (b.type === "end") {
|
|
3255
|
+
const U = It(b);
|
|
3256
|
+
if (U !== ls)
|
|
3257
|
+
return U;
|
|
3258
|
+
}
|
|
3259
|
+
if (b.type === "illegal" && A === "")
|
|
3260
|
+
return W += `
|
|
3261
|
+
`, 1;
|
|
3262
|
+
if (Ve > 1e5 && Ve > b.index * 3)
|
|
3263
|
+
throw new Error("potential infinite loop, way more iterations than matches");
|
|
3264
|
+
return W += A, A.length;
|
|
3265
|
+
}
|
|
3266
|
+
const ae = pe(p);
|
|
3267
|
+
if (!ae)
|
|
3268
|
+
throw Je(r.replace("{}", p)), new Error('Unknown language: "' + p + '"');
|
|
3269
|
+
const dt = gr(ae);
|
|
3270
|
+
let Ye = "", v = F || dt;
|
|
3271
|
+
const Ze = {}, te = new a.__emitter(a);
|
|
3272
|
+
Ot();
|
|
3273
|
+
let W = "", Xe = 0, Le = 0, Ve = 0, Pe = !1;
|
|
3274
|
+
try {
|
|
3275
|
+
if (ae.__emitTokens)
|
|
3276
|
+
ae.__emitTokens(k, te);
|
|
3277
|
+
else {
|
|
3278
|
+
for (v.matcher.considerAll(); ; ) {
|
|
3279
|
+
Ve++, Pe ? Pe = !1 : v.matcher.considerAll(), v.matcher.lastIndex = Le;
|
|
3280
|
+
const m = v.matcher.exec(k);
|
|
3281
|
+
if (!m)
|
|
3282
|
+
break;
|
|
3283
|
+
const b = k.substring(Le, m.index), A = qe(b, m);
|
|
3284
|
+
Le = m.index + A;
|
|
3285
|
+
}
|
|
3286
|
+
qe(k.substring(Le));
|
|
3287
|
+
}
|
|
3288
|
+
return te.finalize(), Ye = te.toHTML(), {
|
|
3289
|
+
language: p,
|
|
3290
|
+
value: Ye,
|
|
3291
|
+
relevance: Xe,
|
|
3292
|
+
illegal: !1,
|
|
3293
|
+
_emitter: te,
|
|
3294
|
+
_top: v
|
|
3295
|
+
};
|
|
3296
|
+
} catch (m) {
|
|
3297
|
+
if (m.message && m.message.includes("Illegal"))
|
|
3298
|
+
return {
|
|
3299
|
+
language: p,
|
|
3300
|
+
value: pn(k),
|
|
3301
|
+
illegal: !0,
|
|
3302
|
+
relevance: 0,
|
|
3303
|
+
_illegalBy: {
|
|
3304
|
+
message: m.message,
|
|
3305
|
+
index: Le,
|
|
3306
|
+
context: k.slice(Le - 100, Le + 100),
|
|
3307
|
+
mode: m.mode,
|
|
3308
|
+
resultSoFar: Ye
|
|
3309
|
+
},
|
|
3310
|
+
_emitter: te
|
|
3311
|
+
};
|
|
3312
|
+
if (o)
|
|
3313
|
+
return {
|
|
3314
|
+
language: p,
|
|
3315
|
+
value: pn(k),
|
|
3316
|
+
illegal: !1,
|
|
3317
|
+
relevance: 0,
|
|
3318
|
+
errorRaised: m,
|
|
3319
|
+
_emitter: te,
|
|
3320
|
+
_top: v
|
|
3321
|
+
};
|
|
3322
|
+
throw m;
|
|
3323
|
+
}
|
|
3324
|
+
}
|
|
3325
|
+
function d(p) {
|
|
3326
|
+
const k = {
|
|
3327
|
+
value: pn(p),
|
|
3328
|
+
illegal: !1,
|
|
3329
|
+
relevance: 0,
|
|
3330
|
+
_top: i,
|
|
3331
|
+
_emitter: new a.__emitter(a)
|
|
3332
|
+
};
|
|
3333
|
+
return k._emitter.addText(p), k;
|
|
3334
|
+
}
|
|
3335
|
+
function f(p, k) {
|
|
3336
|
+
k = k || a.languages || Object.keys(e);
|
|
3337
|
+
const R = d(p), F = k.filter(pe).filter(Fe).map(
|
|
3338
|
+
(ue) => _(ue, p, !1)
|
|
3339
|
+
);
|
|
3340
|
+
F.unshift(R);
|
|
3341
|
+
const j = F.sort((ue, z) => {
|
|
3342
|
+
if (ue.relevance !== z.relevance)
|
|
3343
|
+
return z.relevance - ue.relevance;
|
|
3344
|
+
if (ue.language && z.language) {
|
|
3345
|
+
if (pe(ue.language).supersetOf === z.language)
|
|
3346
|
+
return 1;
|
|
3347
|
+
if (pe(z.language).supersetOf === ue.language)
|
|
3348
|
+
return -1;
|
|
3349
|
+
}
|
|
3350
|
+
return 0;
|
|
3351
|
+
}), [$, Ee] = j, ee = $;
|
|
3352
|
+
return ee.secondBest = Ee, ee;
|
|
3353
|
+
}
|
|
3354
|
+
function y(p, k, R) {
|
|
3355
|
+
const F = k && t[k] || R;
|
|
3356
|
+
p.classList.add("hljs"), p.classList.add(`language-${F}`);
|
|
3357
|
+
}
|
|
3358
|
+
function T(p) {
|
|
3359
|
+
let k = null;
|
|
3360
|
+
const R = g(p);
|
|
3361
|
+
if (c(R))
|
|
3362
|
+
return;
|
|
3363
|
+
if (D(
|
|
3364
|
+
"before:highlightElement",
|
|
3365
|
+
{ el: p, language: R }
|
|
3366
|
+
), p.dataset.highlighted) {
|
|
3367
|
+
console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.", p);
|
|
3368
|
+
return;
|
|
3369
|
+
}
|
|
3370
|
+
if (p.children.length > 0 && (a.ignoreUnescapedHTML || (console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."), console.warn("https://github.com/highlightjs/highlight.js/wiki/security"), console.warn("The element with unescaped HTML:"), console.warn(p)), a.throwUnescapedHTML))
|
|
3371
|
+
throw new br(
|
|
3372
|
+
"One of your code blocks includes unescaped HTML.",
|
|
3373
|
+
p.innerHTML
|
|
3374
|
+
);
|
|
3375
|
+
k = p;
|
|
3376
|
+
const F = k.textContent, j = R ? u(F, { language: R, ignoreIllegals: !0 }) : f(F);
|
|
3377
|
+
p.innerHTML = j.value, p.dataset.highlighted = "yes", y(p, R, j.language), p.result = {
|
|
3378
|
+
language: j.language,
|
|
3379
|
+
// TODO: remove with version 11.0
|
|
3380
|
+
re: j.relevance,
|
|
3381
|
+
relevance: j.relevance
|
|
3382
|
+
}, j.secondBest && (p.secondBest = {
|
|
3383
|
+
language: j.secondBest.language,
|
|
3384
|
+
relevance: j.secondBest.relevance
|
|
3385
|
+
}), D("after:highlightElement", { el: p, result: j, text: F });
|
|
3386
|
+
}
|
|
3387
|
+
function M(p) {
|
|
3388
|
+
a = as(a, p);
|
|
3389
|
+
}
|
|
3390
|
+
const K = () => {
|
|
3391
|
+
I(), ct("10.6.0", "initHighlighting() deprecated. Use highlightAll() now.");
|
|
3392
|
+
};
|
|
3393
|
+
function C() {
|
|
3394
|
+
I(), ct("10.6.0", "initHighlightingOnLoad() deprecated. Use highlightAll() now.");
|
|
3395
|
+
}
|
|
3396
|
+
let Y = !1;
|
|
3397
|
+
function I() {
|
|
3398
|
+
function p() {
|
|
3399
|
+
I();
|
|
3400
|
+
}
|
|
3401
|
+
if (document.readyState === "loading") {
|
|
3402
|
+
Y || window.addEventListener("DOMContentLoaded", p, !1), Y = !0;
|
|
3403
|
+
return;
|
|
3404
|
+
}
|
|
3405
|
+
document.querySelectorAll(a.cssSelector).forEach(T);
|
|
3406
|
+
}
|
|
3407
|
+
function J(p, k) {
|
|
3408
|
+
let R = null;
|
|
3409
|
+
try {
|
|
3410
|
+
R = k(s);
|
|
3411
|
+
} catch (F) {
|
|
3412
|
+
if (Je("Language definition for '{}' could not be registered.".replace("{}", p)), o)
|
|
3413
|
+
Je(F);
|
|
3414
|
+
else
|
|
3415
|
+
throw F;
|
|
3416
|
+
R = i;
|
|
3417
|
+
}
|
|
3418
|
+
R.name || (R.name = p), e[p] = R, R.rawDefinition = k.bind(null, s), R.aliases && he(R.aliases, { languageName: p });
|
|
3419
|
+
}
|
|
3420
|
+
function Se(p) {
|
|
3421
|
+
delete e[p];
|
|
3422
|
+
for (const k of Object.keys(t))
|
|
3423
|
+
t[k] === p && delete t[k];
|
|
3424
|
+
}
|
|
3425
|
+
function Ge() {
|
|
3426
|
+
return Object.keys(e);
|
|
3427
|
+
}
|
|
3428
|
+
function pe(p) {
|
|
3429
|
+
return p = (p || "").toLowerCase(), e[p] || e[t[p]];
|
|
3430
|
+
}
|
|
3431
|
+
function he(p, { languageName: k }) {
|
|
3432
|
+
typeof p == "string" && (p = [p]), p.forEach((R) => {
|
|
3433
|
+
t[R.toLowerCase()] = k;
|
|
3434
|
+
});
|
|
3435
|
+
}
|
|
3436
|
+
function Fe(p) {
|
|
3437
|
+
const k = pe(p);
|
|
3438
|
+
return k && !k.disableAutodetect;
|
|
3439
|
+
}
|
|
3440
|
+
function se(p) {
|
|
3441
|
+
p["before:highlightBlock"] && !p["before:highlightElement"] && (p["before:highlightElement"] = (k) => {
|
|
3442
|
+
p["before:highlightBlock"](
|
|
3443
|
+
Object.assign({ block: k.el }, k)
|
|
3444
|
+
);
|
|
3445
|
+
}), p["after:highlightBlock"] && !p["after:highlightElement"] && (p["after:highlightElement"] = (k) => {
|
|
3446
|
+
p["after:highlightBlock"](
|
|
3447
|
+
Object.assign({ block: k.el }, k)
|
|
3448
|
+
);
|
|
3449
|
+
});
|
|
3450
|
+
}
|
|
3451
|
+
function w(p) {
|
|
3452
|
+
se(p), n.push(p);
|
|
3453
|
+
}
|
|
3454
|
+
function P(p) {
|
|
3455
|
+
const k = n.indexOf(p);
|
|
3456
|
+
k !== -1 && n.splice(k, 1);
|
|
3457
|
+
}
|
|
3458
|
+
function D(p, k) {
|
|
3459
|
+
const R = p;
|
|
3460
|
+
n.forEach(function(F) {
|
|
3461
|
+
F[R] && F[R](k);
|
|
3462
|
+
});
|
|
3463
|
+
}
|
|
3464
|
+
function X(p) {
|
|
3465
|
+
return ct("10.7.0", "highlightBlock will be removed entirely in v12.0"), ct("10.7.0", "Please use highlightElement now."), T(p);
|
|
3466
|
+
}
|
|
3467
|
+
Object.assign(s, {
|
|
3468
|
+
highlight: u,
|
|
3469
|
+
highlightAuto: f,
|
|
3470
|
+
highlightAll: I,
|
|
3471
|
+
highlightElement: T,
|
|
3472
|
+
// TODO: Remove with v12 API
|
|
3473
|
+
highlightBlock: X,
|
|
3474
|
+
configure: M,
|
|
3475
|
+
initHighlighting: K,
|
|
3476
|
+
initHighlightingOnLoad: C,
|
|
3477
|
+
registerLanguage: J,
|
|
3478
|
+
unregisterLanguage: Se,
|
|
3479
|
+
listLanguages: Ge,
|
|
3480
|
+
getLanguage: pe,
|
|
3481
|
+
registerAliases: he,
|
|
3482
|
+
autoDetection: Fe,
|
|
3483
|
+
inherit: as,
|
|
3484
|
+
addPlugin: w,
|
|
3485
|
+
removePlugin: P
|
|
3486
|
+
}), s.debugMode = function() {
|
|
3487
|
+
o = !1;
|
|
3488
|
+
}, s.safeMode = function() {
|
|
3489
|
+
o = !0;
|
|
3490
|
+
}, s.versionString = _r, s.regex = {
|
|
3491
|
+
concat: st,
|
|
3492
|
+
lookahead: Os,
|
|
3493
|
+
either: Sn,
|
|
3494
|
+
optional: No,
|
|
3495
|
+
anyNumberOfTimes: Oo
|
|
3496
|
+
};
|
|
3497
|
+
for (const p in Ft)
|
|
3498
|
+
typeof Ft[p] == "object" && Cs(Ft[p]);
|
|
3499
|
+
return Object.assign(s, Ft), s;
|
|
3500
|
+
}, ft = Hs({});
|
|
3501
|
+
ft.newInstance = () => Hs({});
|
|
3502
|
+
var xr = ft;
|
|
3503
|
+
ft.HighlightJS = ft;
|
|
3504
|
+
ft.default = ft;
|
|
3505
|
+
const cs = /* @__PURE__ */ Ao(xr);
|
|
3506
|
+
function kr(s) {
|
|
3507
|
+
const e = {
|
|
3508
|
+
className: "attr",
|
|
3509
|
+
begin: /"(\\.|[^\\"\r\n])*"(?=\s*:)/,
|
|
3510
|
+
relevance: 1.01
|
|
3511
|
+
}, t = {
|
|
3512
|
+
match: /[{}[\],:]/,
|
|
3513
|
+
className: "punctuation",
|
|
3514
|
+
relevance: 0
|
|
3515
|
+
}, n = [
|
|
3516
|
+
"true",
|
|
3517
|
+
"false",
|
|
3518
|
+
"null"
|
|
3519
|
+
], o = {
|
|
3520
|
+
scope: "literal",
|
|
3521
|
+
beginKeywords: n.join(" ")
|
|
3522
|
+
};
|
|
3523
|
+
return {
|
|
3524
|
+
name: "JSON",
|
|
3525
|
+
aliases: ["jsonc"],
|
|
3526
|
+
keywords: {
|
|
3527
|
+
literal: n
|
|
3528
|
+
},
|
|
3529
|
+
contains: [
|
|
3530
|
+
e,
|
|
3531
|
+
t,
|
|
3532
|
+
s.QUOTE_STRING_MODE,
|
|
3533
|
+
o,
|
|
3534
|
+
s.C_NUMBER_MODE,
|
|
3535
|
+
s.C_LINE_COMMENT_MODE,
|
|
3536
|
+
s.C_BLOCK_COMMENT_MODE
|
|
3537
|
+
],
|
|
3538
|
+
illegal: "\\S"
|
|
3539
|
+
};
|
|
3540
|
+
}
|
|
3541
|
+
const wr = {
|
|
3542
|
+
key: 0,
|
|
3543
|
+
class: "flex flex-col gap-2 py-1"
|
|
3544
|
+
}, Er = { class: "flex-shrink-0" }, Tr = { class: "flex-1 min-w-0" }, vr = { class: "text-xs text-[var(--color-text-secondary)]" }, Sr = {
|
|
3545
|
+
key: 0,
|
|
3546
|
+
class: "h-0.5 bg-[var(--color-background)] rounded-sm overflow-hidden"
|
|
3547
|
+
}, Ar = ["innerHTML"], Rr = /* @__PURE__ */ Oe({
|
|
3548
|
+
__name: "MessageContent",
|
|
3549
|
+
props: {
|
|
3550
|
+
content: {},
|
|
3551
|
+
contentParts: {},
|
|
3552
|
+
isStreaming: { type: Boolean }
|
|
3553
|
+
},
|
|
3554
|
+
setup(s) {
|
|
3555
|
+
cs.registerLanguage("json", kr);
|
|
3556
|
+
const e = s, t = He(() => {
|
|
3557
|
+
var f;
|
|
3558
|
+
if (!((f = e.contentParts) != null && f.length))
|
|
3559
|
+
return [];
|
|
3560
|
+
const u = e.contentParts.filter((y) => y.type === "progress");
|
|
3561
|
+
if (u.length === 0)
|
|
3562
|
+
return [];
|
|
3563
|
+
const _ = u[u.length - 1], d = u.filter((y) => c(y) >= 100);
|
|
3564
|
+
return c(_) < 100 && !d.includes(_) ? [...d, _] : d;
|
|
3565
|
+
}), n = Q(""), o = Q(""), r = Q(null);
|
|
3566
|
+
Xt(() => {
|
|
3567
|
+
i();
|
|
3568
|
+
}), ut(() => e.content, i), ut(() => e.contentParts, i, { deep: !0 });
|
|
3569
|
+
function i() {
|
|
3570
|
+
var d;
|
|
3571
|
+
if (!e.content && !((d = e.contentParts) != null && d.length)) {
|
|
3572
|
+
n.value = "", o.value = "";
|
|
3573
|
+
return;
|
|
3574
|
+
}
|
|
3575
|
+
const u = new H.Renderer(), _ = u.code.bind(u);
|
|
3576
|
+
u.code = function(f, y, T) {
|
|
3577
|
+
if (y === "json")
|
|
3578
|
+
try {
|
|
3579
|
+
return `<pre><code class="hljs language-json">${cs.highlight(f, { language: "json" }).value}</code></pre>`;
|
|
3580
|
+
} catch (M) {
|
|
3581
|
+
console.error("Highlight error:", M);
|
|
3582
|
+
}
|
|
3583
|
+
return _(f, y, T);
|
|
3584
|
+
}, H.setOptions({
|
|
3585
|
+
breaks: !0,
|
|
3586
|
+
gfm: !0,
|
|
3587
|
+
renderer: u
|
|
3588
|
+
});
|
|
3589
|
+
try {
|
|
3590
|
+
const f = e.content || "", y = H.parse(f), T = So.sanitize(y, {
|
|
3591
|
+
ALLOWED_TAGS: [
|
|
3592
|
+
"p",
|
|
3593
|
+
"br",
|
|
3594
|
+
"strong",
|
|
3595
|
+
"em",
|
|
3596
|
+
"u",
|
|
3597
|
+
"code",
|
|
3598
|
+
"pre",
|
|
3599
|
+
"a",
|
|
3600
|
+
"ul",
|
|
3601
|
+
"ol",
|
|
3602
|
+
"li",
|
|
3603
|
+
"h1",
|
|
3604
|
+
"h2",
|
|
3605
|
+
"h3",
|
|
3606
|
+
"h4",
|
|
3607
|
+
"h5",
|
|
3608
|
+
"h6",
|
|
3609
|
+
"blockquote",
|
|
3610
|
+
"img",
|
|
3611
|
+
"table",
|
|
3612
|
+
"thead",
|
|
3613
|
+
"tbody",
|
|
3614
|
+
"tr",
|
|
3615
|
+
"th",
|
|
3616
|
+
"td",
|
|
3617
|
+
"span",
|
|
3618
|
+
"div"
|
|
3619
|
+
],
|
|
3620
|
+
ALLOWED_ATTR: ["href", "title", "src", "alt", "class", "id"]
|
|
3621
|
+
});
|
|
3622
|
+
n.value = T, e.isStreaming ? a(T) : o.value = T;
|
|
3623
|
+
} catch (f) {
|
|
3624
|
+
console.error("Markdown rendering error:", f), n.value = "<p>Error rendering content</p>", o.value = n.value;
|
|
3625
|
+
}
|
|
3626
|
+
}
|
|
3627
|
+
function a(u) {
|
|
3628
|
+
if (r.value && clearInterval(r.value), !u) {
|
|
3629
|
+
o.value = u;
|
|
3630
|
+
return;
|
|
3631
|
+
}
|
|
3632
|
+
const _ = u.replace(/<[^>]*>/g, ""), d = o.value.replace(/<[^>]*>/g, "");
|
|
3633
|
+
if (_.length <= d.length) {
|
|
3634
|
+
o.value = u;
|
|
3635
|
+
return;
|
|
3636
|
+
}
|
|
3637
|
+
const f = _.length - d.length;
|
|
3638
|
+
if (f <= 3)
|
|
3639
|
+
o.value = u;
|
|
3640
|
+
else {
|
|
3641
|
+
const y = document.createElement("div");
|
|
3642
|
+
y.innerHTML = u;
|
|
3643
|
+
const T = y.innerText.length, M = document.createElement("div");
|
|
3644
|
+
M.innerHTML = o.value;
|
|
3645
|
+
let K = M.innerText.length;
|
|
3646
|
+
const C = Math.max(2, Math.ceil(f / 20));
|
|
3647
|
+
r.value = window.setInterval(() => {
|
|
3648
|
+
if (K += C, K >= T)
|
|
3649
|
+
o.value = u, r.value && (clearInterval(r.value), r.value = null);
|
|
3650
|
+
else {
|
|
3651
|
+
const Y = K / T, I = y.innerText, J = I.substring(0, Math.floor(I.length * Y));
|
|
3652
|
+
o.value = H.parse(J);
|
|
3653
|
+
}
|
|
3654
|
+
}, 16);
|
|
3655
|
+
}
|
|
3656
|
+
}
|
|
3657
|
+
function c(u) {
|
|
3658
|
+
return u.type === "progress" && u.data.percentage !== void 0 ? Math.min(100, Math.max(0, u.data.percentage)) : 0;
|
|
3659
|
+
}
|
|
3660
|
+
function g(u) {
|
|
3661
|
+
var d, f;
|
|
3662
|
+
const _ = u.target;
|
|
3663
|
+
if (_.tagName === "A" && ((d = _.getAttribute("href")) != null && d.startsWith("command:"))) {
|
|
3664
|
+
u.preventDefault();
|
|
3665
|
+
const y = (f = _.getAttribute("href")) == null ? void 0 : f.replace("command:", "");
|
|
3666
|
+
y && console.log("Execute command:", y);
|
|
3667
|
+
}
|
|
3668
|
+
}
|
|
3669
|
+
return (u, _) => {
|
|
3670
|
+
const d = be("fm-icon");
|
|
3671
|
+
return S(), N("div", {
|
|
3672
|
+
class: "text-[var(--color-text)] leading-[1.6]",
|
|
3673
|
+
onClick: g
|
|
3674
|
+
}, [
|
|
3675
|
+
t.value.length > 0 ? (S(), N("div", wr, [
|
|
3676
|
+
(S(!0), N(Be, null, et(t.value, (f, y) => (S(), N("div", {
|
|
3677
|
+
key: y,
|
|
3678
|
+
class: "flex items-start gap-1 bg-[var(--color-background-soft)] rounded"
|
|
3679
|
+
}, [
|
|
3680
|
+
L("div", Er, [
|
|
3681
|
+
c(f) >= 100 ? (S(), ke(d, {
|
|
3682
|
+
key: 0,
|
|
3683
|
+
name: "check_circle",
|
|
3684
|
+
size: "sm",
|
|
3685
|
+
class: "text-gray-300",
|
|
3686
|
+
variant: "outlined"
|
|
3687
|
+
})) : (S(), ke(d, {
|
|
3688
|
+
key: 1,
|
|
3689
|
+
name: "progress_activity",
|
|
3690
|
+
size: "sm",
|
|
3691
|
+
class: "text-gray-300 animate-spin",
|
|
3692
|
+
variant: "outlined"
|
|
3693
|
+
}))
|
|
3694
|
+
]),
|
|
3695
|
+
L("div", Tr, [
|
|
3696
|
+
L("div", vr, re(f.data.message), 1),
|
|
3697
|
+
c(f) < 100 && f.data.percentage !== void 0 ? (S(), N("div", Sr, [
|
|
3698
|
+
L("div", {
|
|
3699
|
+
class: "h-full bg-[var(--color-primary)] transition-[width] duration-300",
|
|
3700
|
+
style: hs({ width: `${c(f)}%` })
|
|
3701
|
+
}, null, 4)
|
|
3702
|
+
])) : le("", !0)
|
|
3703
|
+
])
|
|
3704
|
+
]))), 128))
|
|
3705
|
+
])) : le("", !0),
|
|
3706
|
+
o.value ? (S(), N("div", {
|
|
3707
|
+
key: 1,
|
|
3708
|
+
class: "markdown-content break-words",
|
|
3709
|
+
innerHTML: o.value
|
|
3710
|
+
}, null, 8, Ar)) : le("", !0)
|
|
3711
|
+
]);
|
|
3712
|
+
};
|
|
3713
|
+
}
|
|
3714
|
+
});
|
|
3715
|
+
const Mr = /* @__PURE__ */ Ne(Rr, [["__scopeId", "data-v-24fc8be1"]]), Cr = { class: "flex flex-col gap-1" }, Ir = ["title"], Or = ["title"], Nr = ["title"], Dr = /* @__PURE__ */ Oe({
|
|
3716
|
+
__name: "MessageActions",
|
|
3717
|
+
props: {
|
|
3718
|
+
messageId: {},
|
|
3719
|
+
feedback: {},
|
|
3720
|
+
content: {}
|
|
3721
|
+
},
|
|
3722
|
+
setup(s) {
|
|
3723
|
+
const e = s, { t } = pt(), n = Vt(), o = Q(!1);
|
|
3724
|
+
function r(a) {
|
|
3725
|
+
n.provideFeedback(e.messageId, a);
|
|
3726
|
+
}
|
|
3727
|
+
async function i() {
|
|
3728
|
+
try {
|
|
3729
|
+
await navigator.clipboard.writeText(e.content), o.value = !0, setTimeout(() => {
|
|
3730
|
+
o.value = !1;
|
|
3731
|
+
}, 2e3);
|
|
3732
|
+
} catch (a) {
|
|
3733
|
+
console.error("Failed to copy:", a);
|
|
3734
|
+
}
|
|
3735
|
+
}
|
|
3736
|
+
return (a, c) => {
|
|
3737
|
+
const g = be("fm-icon");
|
|
3738
|
+
return S(), N("div", Cr, [
|
|
3739
|
+
L("button", {
|
|
3740
|
+
class: "flex items-center justify-center w-6 h-6 bg-transparent rounded cursor-pointer transition-colors duration-200 hover:bg-gray-100",
|
|
3741
|
+
title: q(t)("remy.feedback.copy"),
|
|
3742
|
+
onClick: i
|
|
3743
|
+
}, [
|
|
3744
|
+
Z(g, {
|
|
3745
|
+
name: o.value ? "check" : "content_copy",
|
|
3746
|
+
size: "sm",
|
|
3747
|
+
class: "text-gray-300",
|
|
3748
|
+
variant: "outlined"
|
|
3749
|
+
}, null, 8, ["name"])
|
|
3750
|
+
], 8, Ir),
|
|
3751
|
+
L("button", {
|
|
3752
|
+
class: wt(["flex items-center justify-center w-6 h-6 bg-transparent rounded cursor-pointer transition-colors duration-200 hover:bg-gray-100", { "bg-blue-100": s.feedback === "helpful" }]),
|
|
3753
|
+
title: q(t)("remy.feedback.helpful"),
|
|
3754
|
+
onClick: c[0] || (c[0] = (u) => r(!0))
|
|
3755
|
+
}, [
|
|
3756
|
+
Z(g, {
|
|
3757
|
+
name: "thumb_up",
|
|
3758
|
+
size: "sm",
|
|
3759
|
+
class: wt(s.feedback === "helpful" ? "text-blue-500" : "text-gray-300"),
|
|
3760
|
+
variant: "outlined"
|
|
3761
|
+
}, null, 8, ["class"])
|
|
3762
|
+
], 10, Or),
|
|
3763
|
+
L("button", {
|
|
3764
|
+
class: wt(["flex items-center justify-center w-6 h-6 bg-transparent rounded cursor-pointer transition-colors duration-200 hover:bg-gray-100", { "bg-blue-100": s.feedback === "unhelpful" }]),
|
|
3765
|
+
title: q(t)("remy.feedback.unhelpful"),
|
|
3766
|
+
onClick: c[1] || (c[1] = (u) => r(!1))
|
|
3767
|
+
}, [
|
|
3768
|
+
Z(g, {
|
|
3769
|
+
name: "thumb_down",
|
|
3770
|
+
size: "sm",
|
|
3771
|
+
class: wt(s.feedback === "unhelpful" ? "text-blue-500" : "text-gray-300"),
|
|
3772
|
+
variant: "outlined"
|
|
3773
|
+
}, null, 8, ["class"])
|
|
3774
|
+
], 10, Nr)
|
|
3775
|
+
]);
|
|
3776
|
+
};
|
|
3777
|
+
}
|
|
3778
|
+
});
|
|
3779
|
+
const Lr = /* @__PURE__ */ Ne(Dr, [["__scopeId", "data-v-5891f468"]]), Pr = { class: "flex gap-2 items-start group" }, $r = { class: "flex flex-col gap-1 p-1 border-1 rounded flex-1 text-[0.8rem]" }, zr = { class: "flex items-center gap-2 text-sm" }, Ur = { class: "font-semibold text-blue-900" }, Br = {
|
|
3780
|
+
key: 0,
|
|
3781
|
+
class: "flex gap-1 items-center"
|
|
3782
|
+
}, Hr = { class: "ml-auto text-gray-400 text-[13px]" }, Fr = { class: "flex flex-col gap-1" }, jr = {
|
|
3783
|
+
key: 0,
|
|
3784
|
+
class: "text-blue-900 text-xl animate-[blink_1s_step-end_infinite]"
|
|
3785
|
+
}, Wr = /* @__PURE__ */ Oe({
|
|
3786
|
+
__name: "ChatMessageAssistant",
|
|
3787
|
+
props: {
|
|
3788
|
+
message: {}
|
|
3789
|
+
},
|
|
3790
|
+
setup(s) {
|
|
3791
|
+
const e = s, t = He(() => new Date(e.message.timestamp).toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit" })), n = He(() => e.message.isStreaming && e.message.content.length === 0);
|
|
3792
|
+
return (o, r) => {
|
|
3793
|
+
var i;
|
|
3794
|
+
return S(), N("div", Pr, [
|
|
3795
|
+
L("div", $r, [
|
|
3796
|
+
L("div", zr, [
|
|
3797
|
+
L("span", Ur, re(s.message.participant), 1),
|
|
3798
|
+
s.message.isStreaming ? (S(), N("span", Br, [...r[0] || (r[0] = [
|
|
3799
|
+
L("span", { class: "w-1 h-1 bg-blue-300 rounded-full animate-[pulse_1.5s_ease-in-out_infinite]" }, null, -1),
|
|
3800
|
+
L("span", { class: "w-1 h-1 bg-blue-300 rounded-full animate-[pulse_1.5s_ease-in-out_infinite] [animation-delay:0.2s]" }, null, -1),
|
|
3801
|
+
L("span", { class: "w-1 h-1 bg-blue-300 rounded-full animate-[pulse_1.5s_ease-in-out_infinite] [animation-delay:0.4s]" }, null, -1)
|
|
3802
|
+
])])) : le("", !0),
|
|
3803
|
+
L("span", Hr, re(t.value), 1)
|
|
3804
|
+
]),
|
|
3805
|
+
L("div", Fr, [
|
|
3806
|
+
n.value ? (S(), N("div", jr, "▊")) : le("", !0),
|
|
3807
|
+
s.message.content || (i = s.message.contentParts) != null && i.length ? (S(), ke(Mr, {
|
|
3808
|
+
key: 1,
|
|
3809
|
+
content: s.message.content,
|
|
3810
|
+
"content-parts": s.message.contentParts,
|
|
3811
|
+
"is-streaming": s.message.isStreaming
|
|
3812
|
+
}, null, 8, ["content", "content-parts", "is-streaming"])) : le("", !0)
|
|
3813
|
+
])
|
|
3814
|
+
]),
|
|
3815
|
+
s.message.isStreaming ? le("", !0) : (S(), ke(Lr, {
|
|
3816
|
+
key: 0,
|
|
3817
|
+
"message-id": s.message.id,
|
|
3818
|
+
feedback: s.message.feedback,
|
|
3819
|
+
content: s.message.content,
|
|
3820
|
+
class: "opacity-0 group-hover:opacity-100 transition-opacity duration-200"
|
|
3821
|
+
}, null, 8, ["message-id", "feedback", "content"]))
|
|
3822
|
+
]);
|
|
3823
|
+
};
|
|
3824
|
+
}
|
|
3825
|
+
});
|
|
3826
|
+
const Gr = /* @__PURE__ */ Ne(Wr, [["__scopeId", "data-v-bb2d289b"]]), qr = {
|
|
3827
|
+
key: 0,
|
|
3828
|
+
class: "flex items-center justify-center h-full text-center p-8"
|
|
3829
|
+
}, Yr = { class: "text-gray-500" }, Zr = /* @__PURE__ */ Oe({
|
|
3830
|
+
__name: "ChatMessages",
|
|
3831
|
+
props: {
|
|
3832
|
+
messages: {},
|
|
3833
|
+
isStreaming: { type: Boolean }
|
|
3834
|
+
},
|
|
3835
|
+
setup(s) {
|
|
3836
|
+
const e = s, { t } = pt(), n = Q();
|
|
3837
|
+
ut(
|
|
3838
|
+
() => e.messages.length,
|
|
3839
|
+
async () => {
|
|
3840
|
+
await Hn(), o();
|
|
3841
|
+
}
|
|
3842
|
+
), ut(
|
|
3843
|
+
() => e.isStreaming,
|
|
3844
|
+
async () => {
|
|
3845
|
+
await Hn(), o();
|
|
3846
|
+
}
|
|
3847
|
+
);
|
|
3848
|
+
function o() {
|
|
3849
|
+
n.value && (n.value.scrollTop = n.value.scrollHeight);
|
|
3850
|
+
}
|
|
3851
|
+
return (r, i) => (S(), N("div", {
|
|
3852
|
+
ref_key: "messagesContainer",
|
|
3853
|
+
ref: n,
|
|
3854
|
+
class: "flex-1 overflow-y-auto p-8 flex flex-col gap-4 bg-[var(--color-background)]"
|
|
3855
|
+
}, [
|
|
3856
|
+
s.messages.length === 0 ? (S(), N("div", qr, [
|
|
3857
|
+
L("p", Yr, re(q(t)("remy.chat.empty")), 1)
|
|
3858
|
+
])) : le("", !0),
|
|
3859
|
+
(S(!0), N(Be, null, et(s.messages, (a) => (S(), N("div", {
|
|
3860
|
+
key: a.id,
|
|
3861
|
+
class: "animate-[fadeIn_0.2s_ease-in] py-4"
|
|
3862
|
+
}, [
|
|
3863
|
+
a.type === "user" ? (S(), ke(wi, {
|
|
3864
|
+
key: 0,
|
|
3865
|
+
message: a
|
|
3866
|
+
}, null, 8, ["message"])) : (S(), ke(Gr, {
|
|
3867
|
+
key: 1,
|
|
3868
|
+
message: a
|
|
3869
|
+
}, null, 8, ["message"]))
|
|
3870
|
+
]))), 128))
|
|
3871
|
+
], 512));
|
|
3872
|
+
}
|
|
3873
|
+
});
|
|
3874
|
+
const Xr = /* @__PURE__ */ Ne(Zr, [["__scopeId", "data-v-2efcb058"]]), Vr = { class: "relative w-full h-120" }, Kr = {
|
|
3875
|
+
key: 0,
|
|
3876
|
+
class: "absolute bottom-full left-0 right-0 bg-white border border-gray-300 rounded-lg shadow-lg max-h-[300px] overflow-y-auto z-[9999] mb-2"
|
|
3877
|
+
}, Qr = { class: "px-3 py-2 text-xs font-semibold uppercase text-[var(--color-text-muted)] bg-gray-50 border-b border-gray-300" }, Jr = { class: "flex items-end gap-2 p-8 bg-[var(--color-background)] border-t border-gray-300 h-120" }, ea = /* @__PURE__ */ Oe({
|
|
3878
|
+
__name: "ChatInput",
|
|
3879
|
+
emits: ["send"],
|
|
3880
|
+
setup(s, { emit: e }) {
|
|
3881
|
+
const t = e, { t: n } = pt(), o = Vt(), r = Q(""), i = Q(!1), a = Q(""), c = He(() => {
|
|
3882
|
+
if (!a.value)
|
|
3883
|
+
return Array.from(o.commands.values());
|
|
3884
|
+
const f = a.value.toLowerCase();
|
|
3885
|
+
return Array.from(o.commands.values()).filter(
|
|
3886
|
+
(y) => y.name.toLowerCase().includes(f) || y.description.toLowerCase().includes(f)
|
|
3887
|
+
);
|
|
3888
|
+
});
|
|
3889
|
+
function g(f) {
|
|
3890
|
+
const T = f.target.value;
|
|
3891
|
+
if (T.startsWith("/")) {
|
|
3892
|
+
const M = T.slice(1).split(" ")[0];
|
|
3893
|
+
a.value = M, i.value = !0;
|
|
3894
|
+
} else
|
|
3895
|
+
i.value = !1, a.value = "";
|
|
3896
|
+
}
|
|
3897
|
+
function u(f) {
|
|
3898
|
+
const y = r.value.split(" ");
|
|
3899
|
+
y[0] = `/${f.name}`, r.value = y.join(" "), i.value = !1;
|
|
3900
|
+
const T = document.querySelector(".chat-input input");
|
|
3901
|
+
T == null || T.focus();
|
|
3902
|
+
}
|
|
3903
|
+
function _() {
|
|
3904
|
+
if (!r.value.trim() || o.isStreaming)
|
|
3905
|
+
return;
|
|
3906
|
+
const f = r.value.trim();
|
|
3907
|
+
let y, T = f;
|
|
3908
|
+
if (f.startsWith("/")) {
|
|
3909
|
+
const M = f.indexOf(" ");
|
|
3910
|
+
M > 0 ? (y = f.slice(1, M), T = f.slice(M + 1).trim()) : (y = f.slice(1), T = "");
|
|
3911
|
+
}
|
|
3912
|
+
t("send", T, y), r.value = "", i.value = !1;
|
|
3913
|
+
}
|
|
3914
|
+
function d(f) {
|
|
3915
|
+
f.key === "Enter" && !f.shiftKey && (f.preventDefault(), _()), f.key === "Escape" && (i.value = !1);
|
|
3916
|
+
}
|
|
3917
|
+
return (f, y) => {
|
|
3918
|
+
const T = be("FmMenuItem"), M = be("FmTextarea"), K = be("FmButton");
|
|
3919
|
+
return S(), N("div", Vr, [
|
|
3920
|
+
i.value && c.value.length > 0 ? (S(), N("div", Kr, [
|
|
3921
|
+
L("div", Qr, re(q(n)("remy.chat.commands")), 1),
|
|
3922
|
+
(S(!0), N(Be, null, et(c.value, (C) => (S(), ke(T, {
|
|
3923
|
+
key: C.name,
|
|
3924
|
+
label: `/${C.name}`,
|
|
3925
|
+
sublabel: C.description,
|
|
3926
|
+
selectable: "",
|
|
3927
|
+
onClick: (Y) => u(C)
|
|
3928
|
+
}, null, 8, ["label", "sublabel", "onClick"]))), 128))
|
|
3929
|
+
])) : le("", !0),
|
|
3930
|
+
L("div", Jr, [
|
|
3931
|
+
Z(M, {
|
|
3932
|
+
modelValue: r.value,
|
|
3933
|
+
"onUpdate:modelValue": y[0] || (y[0] = (C) => r.value = C),
|
|
3934
|
+
placeholder: q(n)("remy.chat.placeholder"),
|
|
3935
|
+
disabled: q(o).isStreaming,
|
|
3936
|
+
rows: 1,
|
|
3937
|
+
class: "flex-1 h-full",
|
|
3938
|
+
style: { gap: "0px !important" },
|
|
3939
|
+
onInput: g,
|
|
3940
|
+
onKeydown: d
|
|
3941
|
+
}, null, 8, ["modelValue", "placeholder", "disabled"]),
|
|
3942
|
+
Z(K, {
|
|
3943
|
+
label: q(n)("remy.chat.send"),
|
|
3944
|
+
disabled: !r.value.trim() || q(o).isStreaming,
|
|
3945
|
+
onClick: _
|
|
3946
|
+
}, null, 8, ["label", "disabled"])
|
|
3947
|
+
])
|
|
3948
|
+
]);
|
|
3949
|
+
};
|
|
3950
|
+
}
|
|
3951
|
+
});
|
|
3952
|
+
const ta = /* @__PURE__ */ Ne(ea, [["__scopeId", "data-v-8b343c93"]]), na = {
|
|
3953
|
+
key: 0,
|
|
3954
|
+
class: "px-4 py-4 border-t border-gray-300 bg-[var(--color-background-soft)]"
|
|
3955
|
+
}, sa = { class: "text-sm font-semibold text-[var(--color-text-secondary)] mb-3" }, ia = { class: "flex flex-wrap gap-2" }, oa = ["onClick"], ra = {
|
|
3956
|
+
key: 0,
|
|
3957
|
+
class: "font-mono text-[13px] text-[var(--color-primary)] bg-[var(--color-background-soft)] px-1.5 py-0.5 rounded"
|
|
3958
|
+
}, aa = /* @__PURE__ */ Oe({
|
|
3959
|
+
__name: "ChatFollowUps",
|
|
3960
|
+
props: {
|
|
3961
|
+
followUps: {}
|
|
3962
|
+
},
|
|
3963
|
+
emits: ["select"],
|
|
3964
|
+
setup(s, { emit: e }) {
|
|
3965
|
+
const t = e, { t: n } = pt();
|
|
3966
|
+
function o(r) {
|
|
3967
|
+
t("select", r.prompt, r.command);
|
|
3968
|
+
}
|
|
3969
|
+
return (r, i) => s.followUps.length > 0 ? (S(), N("div", na, [
|
|
3970
|
+
L("div", sa, re(q(n)("remy.chat.followUps")), 1),
|
|
3971
|
+
L("div", ia, [
|
|
3972
|
+
(S(!0), N(Be, null, et(s.followUps, (a) => (S(), N("button", {
|
|
3973
|
+
key: a.id,
|
|
3974
|
+
class: "inline-flex items-center gap-1.5 px-3.5 py-2 bg-[var(--color-background)] border border-gray-300 rounded-md text-[var(--color-text)] text-sm cursor-pointer transition-all duration-200 hover:bg-[var(--color-background-mute)] hover:border-[var(--color-primary)] hover:-translate-y-px",
|
|
3975
|
+
onClick: (c) => o(a)
|
|
3976
|
+
}, [
|
|
3977
|
+
a.command ? (S(), N("span", ra, "/" + re(a.command), 1)) : le("", !0),
|
|
3978
|
+
ds(" " + re(a.label), 1)
|
|
3979
|
+
], 8, oa))), 128))
|
|
3980
|
+
])
|
|
3981
|
+
])) : le("", !0);
|
|
3982
|
+
}
|
|
3983
|
+
});
|
|
3984
|
+
const la = /* @__PURE__ */ Ne(aa, [["__scopeId", "data-v-0d4992a8"]]), ca = { class: "flex flex-col h-full bg-[var(--color-background)] overflow-hidden" }, ua = { class: "flex items-center gap-3 bg-[var(--color-background-soft)] border-b border-gray-300 p-4 flex-shrink-0" }, fa = { class: "text-lg font-semibold" }, pa = {
|
|
3985
|
+
key: 0,
|
|
3986
|
+
class: "flex items-center justify-center flex-1"
|
|
3987
|
+
}, ha = {
|
|
3988
|
+
key: 1,
|
|
3989
|
+
class: "flex flex-col items-center justify-center flex-1 gap-3 p-8 text-center"
|
|
3990
|
+
}, da = { class: "text-[var(--color-text-secondary)]" }, ga = {
|
|
3991
|
+
key: 2,
|
|
3992
|
+
class: "flex-1 overflow-y-auto"
|
|
3993
|
+
}, ma = ["onClick"], _a = { class: "flex-1 min-w-0" }, ba = { class: "font-medium text-[var(--color-text)] truncate" }, ya = { class: "text-sm text-[var(--color-text-secondary)] mt-1" }, xa = /* @__PURE__ */ Oe({
|
|
3994
|
+
__name: "HistoryView",
|
|
3995
|
+
emits: ["back", "load-session"],
|
|
3996
|
+
setup(s, { emit: e }) {
|
|
3997
|
+
const t = e, { t: n } = pt(), o = Vt(), r = Q([]), i = Q(!0);
|
|
3998
|
+
Xt(async () => {
|
|
3999
|
+
await a();
|
|
4000
|
+
});
|
|
4001
|
+
async function a() {
|
|
4002
|
+
i.value = !0;
|
|
4003
|
+
try {
|
|
4004
|
+
r.value = await o.listSessions();
|
|
4005
|
+
} finally {
|
|
4006
|
+
i.value = !1;
|
|
4007
|
+
}
|
|
4008
|
+
}
|
|
4009
|
+
function c(f) {
|
|
4010
|
+
if (!f.messages.length)
|
|
4011
|
+
return n("remy.chat.emptySession");
|
|
4012
|
+
const y = f.messages.find((T) => T.type === "user");
|
|
4013
|
+
if (y) {
|
|
4014
|
+
const T = y.content.trim();
|
|
4015
|
+
return T.length > 60 ? T.substring(0, 60) + "..." : T;
|
|
4016
|
+
}
|
|
4017
|
+
return n("remy.chat.untitledSession");
|
|
4018
|
+
}
|
|
4019
|
+
function g(f) {
|
|
4020
|
+
const y = new Date(f), M = Math.floor(((/* @__PURE__ */ new Date()).getTime() - y.getTime()) / (1e3 * 60 * 60 * 24));
|
|
4021
|
+
return M === 0 ? y.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) : M === 1 ? n("remy.chat.yesterday") : M < 7 ? y.toLocaleDateString([], { weekday: "long" }) : y.toLocaleDateString([], { month: "short", day: "numeric" });
|
|
4022
|
+
}
|
|
4023
|
+
function u(f) {
|
|
4024
|
+
t("load-session", f);
|
|
4025
|
+
}
|
|
4026
|
+
async function _(f, y) {
|
|
4027
|
+
y.stopPropagation(), confirm(n("remy.chat.confirmDeleteSession")) && (await o.deleteSession(f), await a());
|
|
4028
|
+
}
|
|
4029
|
+
function d() {
|
|
4030
|
+
t("back");
|
|
4031
|
+
}
|
|
4032
|
+
return (f, y) => {
|
|
4033
|
+
const T = be("fm-button"), M = be("fm-spinner"), K = be("fm-icon");
|
|
4034
|
+
return S(), N("div", ca, [
|
|
4035
|
+
L("div", ua, [
|
|
4036
|
+
Z(T, {
|
|
4037
|
+
variant: "tertiary",
|
|
4038
|
+
size: "md",
|
|
4039
|
+
"prepend-icon": "arrow_back",
|
|
4040
|
+
onClick: d,
|
|
4041
|
+
title: q(n)("remy.chat.back")
|
|
4042
|
+
}, null, 8, ["title"]),
|
|
4043
|
+
L("h2", fa, re(q(n)("remy.chat.historyTitle")), 1)
|
|
4044
|
+
]),
|
|
4045
|
+
i.value ? (S(), N("div", pa, [
|
|
4046
|
+
Z(M, { size: "lg" })
|
|
4047
|
+
])) : r.value.length === 0 ? (S(), N("div", ha, [
|
|
4048
|
+
Z(K, {
|
|
4049
|
+
name: "history",
|
|
4050
|
+
size: "sm",
|
|
4051
|
+
class: "text-[var(--color-text-secondary)]"
|
|
4052
|
+
}),
|
|
4053
|
+
L("p", da, re(q(n)("remy.chat.noHistory")), 1)
|
|
4054
|
+
])) : (S(), N("div", ga, [
|
|
4055
|
+
(S(!0), N(Be, null, et(r.value, (C) => (S(), N("div", {
|
|
4056
|
+
key: C.id,
|
|
4057
|
+
class: "flex items-start gap-3 p-4 border-b border-gray-300 hover:bg-[var(--color-background-soft)] cursor-pointer transition-colors",
|
|
4058
|
+
onClick: (Y) => u(C.id)
|
|
4059
|
+
}, [
|
|
4060
|
+
Z(K, {
|
|
4061
|
+
name: "chat",
|
|
4062
|
+
size: "sm",
|
|
4063
|
+
class: "text-[var(--color-text-secondary)] flex-shrink-0 mt-1"
|
|
4064
|
+
}),
|
|
4065
|
+
L("div", _a, [
|
|
4066
|
+
L("div", ba, re(c(C)), 1),
|
|
4067
|
+
L("div", ya, re(C.messages.length) + " " + re(q(n)("remy.chat.messages")) + " • " + re(g(C.updatedAt)), 1)
|
|
4068
|
+
]),
|
|
4069
|
+
Z(T, {
|
|
4070
|
+
variant: "plain",
|
|
4071
|
+
size: "md",
|
|
4072
|
+
"prepend-icon": "delete",
|
|
4073
|
+
onClick: (Y) => _(C.id, Y),
|
|
4074
|
+
title: q(n)("remy.chat.deleteSession")
|
|
4075
|
+
}, null, 8, ["onClick", "title"])
|
|
4076
|
+
], 8, ma))), 128))
|
|
4077
|
+
]))
|
|
4078
|
+
]);
|
|
4079
|
+
};
|
|
4080
|
+
}
|
|
4081
|
+
});
|
|
4082
|
+
const ka = /* @__PURE__ */ Ne(xa, [["__scopeId", "data-v-d06a87f1"]]), wa = { class: "flex flex-col h-full bg-[var(--color-background)] overflow-hidden" }, Ea = { class: "flex items-center justify-between bg-[var(--color-background-soft)] border-b border-gray-300 flex-shrink-0" }, Ta = { class: "flex items-center" }, va = /* @__PURE__ */ Oe({
|
|
4083
|
+
__name: "RemyChatPanel",
|
|
4084
|
+
emits: ["close"],
|
|
4085
|
+
setup(s, { emit: e }) {
|
|
4086
|
+
const t = e, { t: n } = pt(), o = Vt(), r = Q("chat"), i = Q([]), a = Array.from(o.participants.values());
|
|
4087
|
+
Xt(async () => {
|
|
4088
|
+
await c();
|
|
4089
|
+
});
|
|
4090
|
+
async function c() {
|
|
4091
|
+
const C = await o.listSessions();
|
|
4092
|
+
i.value = C.slice(0, 5);
|
|
4093
|
+
}
|
|
4094
|
+
function g(C) {
|
|
4095
|
+
if (!C.messages.length)
|
|
4096
|
+
return n("remy.chat.emptySession");
|
|
4097
|
+
const Y = C.messages.find((I) => I.type === "user");
|
|
4098
|
+
if (Y) {
|
|
4099
|
+
const I = Y.content.trim();
|
|
4100
|
+
return I.length > 40 ? I.substring(0, 40) + "..." : I;
|
|
4101
|
+
}
|
|
4102
|
+
return n("remy.chat.untitledSession");
|
|
4103
|
+
}
|
|
4104
|
+
function u(C, Y) {
|
|
4105
|
+
o.sendMessage(C, Y);
|
|
4106
|
+
}
|
|
4107
|
+
function _(C, Y) {
|
|
4108
|
+
o.sendMessage(C, Y);
|
|
4109
|
+
}
|
|
4110
|
+
function d(C) {
|
|
4111
|
+
o.switchParticipant(C);
|
|
4112
|
+
}
|
|
4113
|
+
async function f() {
|
|
4114
|
+
o.messages.length > 0 && !confirm(n("remy.chat.confirmNewSession")) || (await o.newSession(), await c());
|
|
4115
|
+
}
|
|
4116
|
+
async function y(C) {
|
|
4117
|
+
await o.loadSession(C), r.value = "chat";
|
|
4118
|
+
}
|
|
4119
|
+
function T() {
|
|
4120
|
+
r.value = "history";
|
|
4121
|
+
}
|
|
4122
|
+
function M() {
|
|
4123
|
+
r.value = "chat";
|
|
4124
|
+
}
|
|
4125
|
+
function K() {
|
|
4126
|
+
t("close");
|
|
4127
|
+
}
|
|
4128
|
+
return (C, Y) => {
|
|
4129
|
+
const I = be("fm-button"), J = be("fm-menu-item"), Se = be("fm-menu"), Ge = be("fm-badge"), pe = be("fm-menu-divider");
|
|
4130
|
+
return S(), N("div", wa, [
|
|
4131
|
+
r.value === "history" ? (S(), ke(ka, {
|
|
4132
|
+
key: 0,
|
|
4133
|
+
onBack: M,
|
|
4134
|
+
onLoadSession: y
|
|
4135
|
+
})) : (S(), N(Be, { key: 1 }, [
|
|
4136
|
+
L("div", Ea, [
|
|
4137
|
+
Z(Se, null, {
|
|
4138
|
+
"menu-button": Qe(() => [
|
|
4139
|
+
Z(I, {
|
|
4140
|
+
variant: "plain",
|
|
4141
|
+
size: "md",
|
|
4142
|
+
"prepend-icon": "person",
|
|
4143
|
+
label: `@${q(o).currentParticipant}`
|
|
4144
|
+
}, null, 8, ["label"])
|
|
4145
|
+
]),
|
|
4146
|
+
default: Qe(() => [
|
|
4147
|
+
(S(!0), N(Be, null, et(q(a), (he) => (S(), ke(J, {
|
|
4148
|
+
key: he.id,
|
|
4149
|
+
label: `@${he.id}`,
|
|
4150
|
+
sublabel: he.description,
|
|
4151
|
+
icon: "person",
|
|
4152
|
+
selectable: "",
|
|
4153
|
+
onClick: (Fe) => d(he.id)
|
|
4154
|
+
}, null, 8, ["label", "sublabel", "onClick"]))), 128))
|
|
4155
|
+
]),
|
|
4156
|
+
_: 1
|
|
4157
|
+
}),
|
|
4158
|
+
L("div", Ta, [
|
|
4159
|
+
q(o).isStreaming ? (S(), ke(Ge, {
|
|
4160
|
+
key: 0,
|
|
4161
|
+
color: "primary",
|
|
4162
|
+
class: "animate-pulse"
|
|
4163
|
+
}, {
|
|
4164
|
+
default: Qe(() => [
|
|
4165
|
+
ds(re(q(n)("remy.chat.streaming")), 1)
|
|
4166
|
+
]),
|
|
4167
|
+
_: 1
|
|
4168
|
+
})) : le("", !0),
|
|
4169
|
+
Z(Se, null, {
|
|
4170
|
+
"menu-button": Qe(() => [
|
|
4171
|
+
Z(I, {
|
|
4172
|
+
"icon-color": "neutral-gray-200",
|
|
4173
|
+
variant: "tertiary",
|
|
4174
|
+
size: "md",
|
|
4175
|
+
"prepend-icon": "history",
|
|
4176
|
+
title: q(n)("remy.chat.sessionMenu")
|
|
4177
|
+
}, null, 8, ["title"])
|
|
4178
|
+
]),
|
|
4179
|
+
default: Qe(() => [
|
|
4180
|
+
Z(J, {
|
|
4181
|
+
label: q(n)("remy.chat.newSession"),
|
|
4182
|
+
icon: "add",
|
|
4183
|
+
onClick: f,
|
|
4184
|
+
selectable: ""
|
|
4185
|
+
}, null, 8, ["label"]),
|
|
4186
|
+
i.value.length > 0 ? (S(), N(Be, { key: 0 }, [
|
|
4187
|
+
Z(pe),
|
|
4188
|
+
(S(!0), N(Be, null, et(i.value, (he) => (S(), ke(J, {
|
|
4189
|
+
key: he.id,
|
|
4190
|
+
label: g(he),
|
|
4191
|
+
icon: "chat",
|
|
4192
|
+
onClick: (Fe) => y(he.id),
|
|
4193
|
+
selectable: ""
|
|
4194
|
+
}, null, 8, ["label", "onClick"]))), 128)),
|
|
4195
|
+
Z(pe)
|
|
4196
|
+
], 64)) : le("", !0),
|
|
4197
|
+
Z(J, {
|
|
4198
|
+
label: q(n)("remy.chat.viewAllHistory"),
|
|
4199
|
+
icon: "list",
|
|
4200
|
+
onClick: T,
|
|
4201
|
+
selectable: ""
|
|
4202
|
+
}, null, 8, ["label"])
|
|
4203
|
+
]),
|
|
4204
|
+
_: 1
|
|
4205
|
+
}),
|
|
4206
|
+
Z(I, {
|
|
4207
|
+
variant: "tertiary",
|
|
4208
|
+
"icon-color": "neutral-gray-200",
|
|
4209
|
+
size: "md",
|
|
4210
|
+
"prepend-icon": "close",
|
|
4211
|
+
onClick: K,
|
|
4212
|
+
title: q(n)("remy.chat.close")
|
|
4213
|
+
}, null, 8, ["title"])
|
|
4214
|
+
])
|
|
4215
|
+
]),
|
|
4216
|
+
Z(Xr, {
|
|
4217
|
+
messages: q(o).messages,
|
|
4218
|
+
"is-streaming": q(o).isStreaming
|
|
4219
|
+
}, null, 8, ["messages", "is-streaming"]),
|
|
4220
|
+
q(o).latestFollowUps.length > 0 ? (S(), ke(la, {
|
|
4221
|
+
key: 0,
|
|
4222
|
+
"follow-ups": q(o).latestFollowUps,
|
|
4223
|
+
onSelect: _
|
|
4224
|
+
}, null, 8, ["follow-ups"])) : le("", !0),
|
|
4225
|
+
Z(ta, { onSend: u })
|
|
4226
|
+
], 64))
|
|
4227
|
+
]);
|
|
4228
|
+
};
|
|
4229
|
+
}
|
|
4230
|
+
});
|
|
4231
|
+
const Fs = /* @__PURE__ */ Ne(va, [["__scopeId", "data-v-b097e54f"]]), Sa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4232
|
+
__proto__: null,
|
|
4233
|
+
default: Fs
|
|
4234
|
+
}, Symbol.toStringTag, { value: "Module" })), Aa = { class: "flex-1 min-w-0 overflow-auto h-full transition-[margin-right] duration-300" }, us = "remy-chat-panel-width", Ra = 400, fs = 300, ps = 800, Ma = /* @__PURE__ */ Oe({
|
|
4235
|
+
__name: "App",
|
|
4236
|
+
setup(s) {
|
|
4237
|
+
ti().registerRemyClickedHandler(() => {
|
|
4238
|
+
c();
|
|
4239
|
+
});
|
|
4240
|
+
const t = () => {
|
|
4241
|
+
try {
|
|
4242
|
+
const d = localStorage.getItem(us);
|
|
4243
|
+
if (d) {
|
|
4244
|
+
const f = parseInt(d, 10);
|
|
4245
|
+
if (!isNaN(f) && f >= fs && f <= ps)
|
|
4246
|
+
return f;
|
|
4247
|
+
}
|
|
4248
|
+
} catch (d) {
|
|
4249
|
+
console.error("Failed to load panel width from localStorage:", d);
|
|
4250
|
+
}
|
|
4251
|
+
return Ra;
|
|
4252
|
+
}, n = Q(!0), o = Q(t()), r = Q(!1), i = He(() => typeof window > "u" ? !1 : window.innerWidth < 768);
|
|
4253
|
+
function a() {
|
|
4254
|
+
n.value = !1;
|
|
4255
|
+
}
|
|
4256
|
+
function c() {
|
|
4257
|
+
n.value = !n.value;
|
|
4258
|
+
}
|
|
4259
|
+
function g(d) {
|
|
4260
|
+
i.value || (r.value = !0, d.preventDefault());
|
|
4261
|
+
}
|
|
4262
|
+
function u(d) {
|
|
4263
|
+
if (!r.value || i.value)
|
|
4264
|
+
return;
|
|
4265
|
+
const f = window.innerWidth - d.clientX;
|
|
4266
|
+
o.value = Math.min(Math.max(f, fs), ps);
|
|
4267
|
+
}
|
|
4268
|
+
function _() {
|
|
4269
|
+
r.value = !1;
|
|
4270
|
+
}
|
|
4271
|
+
return ut(o, (d) => {
|
|
4272
|
+
try {
|
|
4273
|
+
localStorage.setItem(us, d.toString());
|
|
4274
|
+
} catch (f) {
|
|
4275
|
+
console.error("Failed to save panel width to localStorage:", f);
|
|
4276
|
+
}
|
|
4277
|
+
}), Xt(() => {
|
|
4278
|
+
window.addEventListener("mousemove", u), window.addEventListener("mouseup", _);
|
|
4279
|
+
}), Js(() => {
|
|
4280
|
+
window.removeEventListener("mousemove", u), window.removeEventListener("mouseup", _);
|
|
4281
|
+
}), (d, f) => {
|
|
4282
|
+
const y = be("router-view");
|
|
4283
|
+
return S(), N("div", {
|
|
4284
|
+
class: wt(["flex h-full w-full relative overflow-hidden", { "cursor-col-resize select-none": r.value }])
|
|
4285
|
+
}, [
|
|
4286
|
+
L("div", Aa, [
|
|
4287
|
+
Z(y)
|
|
4288
|
+
]),
|
|
4289
|
+
Z(Fn, {
|
|
4290
|
+
"enter-active-class": "transition-all duration-300 ease-out",
|
|
4291
|
+
"leave-active-class": "transition-all duration-300 ease-in",
|
|
4292
|
+
"enter-from-class": "translate-x-full opacity-0 md:translate-x-full md:translate-y-0",
|
|
4293
|
+
"enter-to-class": "translate-x-0 opacity-100",
|
|
4294
|
+
"leave-from-class": "translate-x-0 opacity-100",
|
|
4295
|
+
"leave-to-class": "translate-x-full opacity-0 md:translate-x-full md:translate-y-0"
|
|
4296
|
+
}, {
|
|
4297
|
+
default: Qe(() => [
|
|
4298
|
+
n.value ? (S(), N("div", {
|
|
4299
|
+
key: 0,
|
|
4300
|
+
class: "bg-[var(--color-background)] border-l border-gray-300 flex flex-col h-full inset-0 w-full md:relative md:h-full md:inset-auto md:w-auto relative",
|
|
4301
|
+
style: hs(i.value ? {} : { width: `${o.value}px` })
|
|
4302
|
+
}, [
|
|
4303
|
+
i.value ? le("", !0) : (S(), N("div", {
|
|
4304
|
+
key: 0,
|
|
4305
|
+
class: "absolute left-0 top-0 bottom-0 w-1.5 cursor-col-resize z-50 bg-transparent hover:bg-[var(--color-primary)] transition-colors duration-200 group",
|
|
4306
|
+
onMousedown: g
|
|
4307
|
+
}, [...f[0] || (f[0] = [
|
|
4308
|
+
L("div", { class: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-0.5 h-10 bg-[var(--color-border)] rounded-sm opacity-0 group-hover:opacity-100 transition-opacity duration-200" }, null, -1)
|
|
4309
|
+
])], 32)),
|
|
4310
|
+
Z(Fs, { onClose: a })
|
|
4311
|
+
], 4)) : le("", !0)
|
|
4312
|
+
]),
|
|
4313
|
+
_: 1
|
|
4314
|
+
}),
|
|
4315
|
+
Z(Fn, {
|
|
4316
|
+
"enter-active-class": "transition-opacity duration-300",
|
|
4317
|
+
"leave-active-class": "transition-opacity duration-300",
|
|
4318
|
+
"enter-from-class": "opacity-0",
|
|
4319
|
+
"leave-to-class": "opacity-0"
|
|
4320
|
+
}, {
|
|
4321
|
+
default: Qe(() => [
|
|
4322
|
+
n.value && i.value ? (S(), N("div", {
|
|
4323
|
+
key: 0,
|
|
4324
|
+
class: "fixed inset-0 bg-black/50 z-[999]",
|
|
4325
|
+
onClick: a
|
|
4326
|
+
})) : le("", !0)
|
|
4327
|
+
]),
|
|
4328
|
+
_: 1
|
|
4329
|
+
})
|
|
4330
|
+
], 2);
|
|
4331
|
+
};
|
|
4332
|
+
}
|
|
4333
|
+
});
|
|
4334
|
+
const Pa = /* @__PURE__ */ Ne(Ma, [["__scopeId", "data-v-df0d1985"]]), Ca = [
|
|
4335
|
+
{
|
|
4336
|
+
path: "/",
|
|
4337
|
+
name: "home",
|
|
4338
|
+
component: () => import("./HomeView-40a46f7c.js")
|
|
4339
|
+
}
|
|
4340
|
+
], $a = si({
|
|
4341
|
+
history: ii(),
|
|
4342
|
+
routes: Ca
|
|
4343
|
+
}), za = {
|
|
4344
|
+
"en-US": ri,
|
|
4345
|
+
"zh-CN": li
|
|
4346
|
+
}, Ua = ei(
|
|
4347
|
+
() => Promise.resolve().then(() => Sa)
|
|
4348
|
+
);
|
|
4349
|
+
export {
|
|
4350
|
+
Pa as A,
|
|
4351
|
+
Ua as R,
|
|
4352
|
+
Ne as _,
|
|
4353
|
+
za as i,
|
|
4354
|
+
$a as r
|
|
4355
|
+
};
|