@useknest/widget-core 0.1.0-beta.8 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/attachments.d.ts +44 -0
- package/dist/attachments.d.ts.map +1 -0
- package/dist/auth.d.ts +2 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/constants.d.ts +16 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +732 -547
- package/dist/persistence.d.ts +27 -0
- package/dist/persistence.d.ts.map +1 -0
- package/dist/realtime.d.ts +24 -0
- package/dist/realtime.d.ts.map +1 -0
- package/dist/scroll-lock.d.ts +4 -0
- package/dist/scroll-lock.d.ts.map +1 -0
- package/dist/streaming.d.ts +8 -1
- package/dist/streaming.d.ts.map +1 -1
- package/dist/types.d.ts +24 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,71 +1,85 @@
|
|
|
1
|
-
import { createClient as
|
|
2
|
-
import { marked as
|
|
3
|
-
import * as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
return `${
|
|
1
|
+
import { createClient as be } from "@supabase/supabase-js";
|
|
2
|
+
import { marked as Y } from "marked";
|
|
3
|
+
import * as Z from "@sentry/browser";
|
|
4
|
+
const W = "https://useknest.com", X = "/api/v1", et = "https://lghrsugmhzpccpriqhrx.supabase.co", tt = "sb_publishable_-KUwilDA78QM849gk662FA_kEzMezNS";
|
|
5
|
+
function Ie(n = W) {
|
|
6
|
+
return `${n}${X}/chat-messages`;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
return `${
|
|
8
|
+
function ye(n = W) {
|
|
9
|
+
return `${n}${X}/widget-config`;
|
|
10
10
|
}
|
|
11
|
-
const
|
|
11
|
+
const Re = "Sorry, I didn't get a response.", re = "Unknown error occurred", Oe = "This domain is not authorized. Please add it to your allowed origins in the Knest dashboard.", Ne = "This chatbot has reached its usage limit. Please contact the site owner to upgrade their plan.", nt = "https://useknest.com/default-avatar.svg", at = "#3b82f6", rt = "Hi! I'm your AI assistant. I'm trained to answer questions about your documentation. How can I help you today?", st = [
|
|
12
12
|
"How do I get started?",
|
|
13
13
|
"What features are available?",
|
|
14
14
|
"How do I integrate this?"
|
|
15
|
-
],
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
], fe = ["image/jpeg", "image/png", "image/gif", "image/webp"], ve = [
|
|
16
|
+
"application/pdf",
|
|
17
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
18
|
+
"text/plain"
|
|
19
|
+
], Ee = [...fe, ...ve], it = Ee.join(","), we = 10 * 1024 * 1024, ot = 5;
|
|
20
|
+
function Le(n = W) {
|
|
21
|
+
return `${n}${X}/chat-attachments/upload-url`;
|
|
18
22
|
}
|
|
19
|
-
function
|
|
23
|
+
function Fe(n = W) {
|
|
24
|
+
return `${n}${X}/chat-attachments/signed-url`;
|
|
25
|
+
}
|
|
26
|
+
function ut(n) {
|
|
27
|
+
return fe.includes(n);
|
|
28
|
+
}
|
|
29
|
+
const lt = "A human agent will get back to you shortly.", ct = "We are online", dt = "Customer online", Ce = "knest-widget-config-", ke = 1440 * 60 * 1e3;
|
|
30
|
+
function J(n) {
|
|
31
|
+
return Ce + n;
|
|
32
|
+
}
|
|
33
|
+
function _e(n, u) {
|
|
20
34
|
try {
|
|
21
|
-
const
|
|
22
|
-
if (!
|
|
23
|
-
const { config:
|
|
24
|
-
return Date.now() -
|
|
35
|
+
const e = localStorage.getItem(J(n));
|
|
36
|
+
if (!e) return null;
|
|
37
|
+
const { config: l, cachedAt: c } = JSON.parse(e);
|
|
38
|
+
return Date.now() - c > ke ? (localStorage.removeItem(J(n)), null) : (u && l.updatedAt, l);
|
|
25
39
|
} catch {
|
|
26
40
|
return null;
|
|
27
41
|
}
|
|
28
42
|
}
|
|
29
|
-
function
|
|
43
|
+
function De(n, u) {
|
|
30
44
|
try {
|
|
31
|
-
const
|
|
32
|
-
localStorage.setItem(
|
|
45
|
+
const e = { config: u, cachedAt: Date.now() };
|
|
46
|
+
localStorage.setItem(J(n), JSON.stringify(e));
|
|
33
47
|
} catch {
|
|
34
48
|
}
|
|
35
49
|
}
|
|
36
|
-
async function
|
|
50
|
+
async function se(n, u) {
|
|
37
51
|
try {
|
|
38
|
-
const
|
|
52
|
+
const e = await fetch(ye(u), {
|
|
39
53
|
method: "GET",
|
|
40
54
|
headers: {
|
|
41
|
-
"X-Api-Key":
|
|
55
|
+
"X-Api-Key": n
|
|
42
56
|
}
|
|
43
57
|
});
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
return
|
|
58
|
+
if (e.ok) {
|
|
59
|
+
const c = await e.json();
|
|
60
|
+
return De(n, c), { config: c, error: null };
|
|
47
61
|
}
|
|
48
|
-
if (
|
|
49
|
-
const
|
|
50
|
-
return console.warn("Widget config auth error:",
|
|
62
|
+
if (e.status === 401 || e.status === 403) {
|
|
63
|
+
const c = await e.json().catch(() => ({}));
|
|
64
|
+
return console.warn("Widget config auth error:", e.status, c), { config: null, error: "auth" };
|
|
51
65
|
}
|
|
52
|
-
const
|
|
53
|
-
return console.warn("Failed to fetch widget config:",
|
|
54
|
-
} catch (
|
|
55
|
-
return console.error("Error fetching widget config:",
|
|
66
|
+
const l = await e.text();
|
|
67
|
+
return console.warn("Failed to fetch widget config:", e.status, l), { config: null, error: "network" };
|
|
68
|
+
} catch (e) {
|
|
69
|
+
return console.error("Error fetching widget config:", e), { config: null, error: "network" };
|
|
56
70
|
}
|
|
57
71
|
}
|
|
58
|
-
async function
|
|
59
|
-
const
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
}), { config:
|
|
72
|
+
async function gt(n, u, e) {
|
|
73
|
+
const l = _e(n);
|
|
74
|
+
return l ? (e && se(n, u).then((c) => {
|
|
75
|
+
c.config && c.config.updatedAt !== l.updatedAt && e(c.config);
|
|
76
|
+
}), { config: l, error: null }) : se(n, u);
|
|
63
77
|
}
|
|
64
|
-
let
|
|
65
|
-
async function
|
|
66
|
-
return x || (
|
|
78
|
+
let _ = null, H = !1, x = null;
|
|
79
|
+
async function pt(n, u) {
|
|
80
|
+
return x || (H && _ ? !0 : (x = (async () => {
|
|
67
81
|
try {
|
|
68
|
-
|
|
82
|
+
_ = be(n, u, {
|
|
69
83
|
auth: {
|
|
70
84
|
// Persist session in localStorage for cross-page persistence.
|
|
71
85
|
persistSession: !0,
|
|
@@ -74,105 +88,107 @@ async function Xe(a, d) {
|
|
|
74
88
|
}
|
|
75
89
|
});
|
|
76
90
|
const {
|
|
77
|
-
data: { session:
|
|
78
|
-
} = await
|
|
79
|
-
if (
|
|
80
|
-
return
|
|
81
|
-
const { error:
|
|
82
|
-
return
|
|
83
|
-
} catch (
|
|
84
|
-
return console.error("Widget auth initialization failed:",
|
|
91
|
+
data: { session: e }
|
|
92
|
+
} = await _.auth.getSession();
|
|
93
|
+
if (e)
|
|
94
|
+
return H = !0, !0;
|
|
95
|
+
const { error: l } = await _.auth.signInAnonymously();
|
|
96
|
+
return l ? (console.error("Widget auth error:", l.message), !1) : (H = !0, !0);
|
|
97
|
+
} catch (e) {
|
|
98
|
+
return console.error("Widget auth initialization failed:", e), !1;
|
|
85
99
|
} finally {
|
|
86
100
|
x = null;
|
|
87
101
|
}
|
|
88
102
|
})(), x));
|
|
89
103
|
}
|
|
90
|
-
async function
|
|
91
|
-
if (!
|
|
104
|
+
async function Q() {
|
|
105
|
+
if (!_)
|
|
92
106
|
return null;
|
|
93
107
|
const {
|
|
94
|
-
data: { session:
|
|
95
|
-
} = await
|
|
96
|
-
return
|
|
108
|
+
data: { session: n }
|
|
109
|
+
} = await _.auth.getSession();
|
|
110
|
+
return n?.access_token || null;
|
|
97
111
|
}
|
|
98
|
-
function
|
|
99
|
-
return
|
|
112
|
+
function Pe() {
|
|
113
|
+
return H;
|
|
100
114
|
}
|
|
101
|
-
function
|
|
102
|
-
return
|
|
115
|
+
function xe() {
|
|
116
|
+
return _;
|
|
103
117
|
}
|
|
104
|
-
async function
|
|
105
|
-
const { publishableApiKey:
|
|
118
|
+
async function ft(n) {
|
|
119
|
+
const { publishableApiKey: u, content: e, threadId: l, callbacks: c, baseUrl: p, metadata: h, user: i } = n;
|
|
106
120
|
try {
|
|
107
|
-
if (!
|
|
121
|
+
if (!Pe())
|
|
108
122
|
throw new Error("Widget not authenticated. Call initWidgetAuth() first.");
|
|
109
|
-
const
|
|
110
|
-
if (!
|
|
123
|
+
const m = await Q();
|
|
124
|
+
if (!m)
|
|
111
125
|
throw new Error("No access token available. Please refresh and try again.");
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
const
|
|
126
|
+
const b = { content: e };
|
|
127
|
+
l && (b.threadId = l), h && (b.metadata = h), i && (!i.id && !i.email ? console.warn("[Knest] user prop ignored: at least id or email is required.") : (b.user = i, i.email && (b.email = i.email), i.fullName && (b.fullName = i.fullName)));
|
|
128
|
+
const R = await fetch(Ie(p), {
|
|
115
129
|
method: "POST",
|
|
116
130
|
headers: {
|
|
117
131
|
"Content-Type": "application/json",
|
|
118
|
-
"X-Api-Key":
|
|
119
|
-
Authorization: `Bearer ${
|
|
132
|
+
"X-Api-Key": u,
|
|
133
|
+
Authorization: `Bearer ${m}`
|
|
120
134
|
},
|
|
121
135
|
credentials: "include",
|
|
122
|
-
body: JSON.stringify(
|
|
136
|
+
body: JSON.stringify(b)
|
|
123
137
|
});
|
|
124
|
-
if (!
|
|
125
|
-
if (
|
|
126
|
-
throw new Error(
|
|
127
|
-
if (
|
|
128
|
-
const
|
|
129
|
-
throw
|
|
138
|
+
if (!R.ok) {
|
|
139
|
+
if (R.status === 401 || R.status === 403)
|
|
140
|
+
throw new Error(Oe);
|
|
141
|
+
if (R.status === 429) {
|
|
142
|
+
const E = await R.json();
|
|
143
|
+
throw E.code === "USAGE_LIMIT_EXCEEDED" ? new Error(Ne) : new Error(E.error || "Rate limited");
|
|
130
144
|
}
|
|
131
|
-
const
|
|
132
|
-
throw new Error(
|
|
145
|
+
const A = await R.json();
|
|
146
|
+
throw new Error(A.error || "Failed to send message");
|
|
133
147
|
}
|
|
134
|
-
const
|
|
135
|
-
if (!
|
|
148
|
+
const v = R.body?.getReader();
|
|
149
|
+
if (!v)
|
|
136
150
|
throw new Error("Response body is not readable");
|
|
137
|
-
const
|
|
138
|
-
let
|
|
151
|
+
const w = new TextDecoder();
|
|
152
|
+
let k = "", L = !1;
|
|
139
153
|
for (; ; ) {
|
|
140
|
-
const { done:
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
const T =
|
|
154
|
+
const { done: A, value: E } = await v.read();
|
|
155
|
+
if (A) break;
|
|
156
|
+
k += w.decode(E, { stream: !0 });
|
|
157
|
+
const T = k.split(`
|
|
144
158
|
`);
|
|
145
|
-
|
|
146
|
-
for (const
|
|
147
|
-
if (
|
|
159
|
+
k = T.pop() || "";
|
|
160
|
+
for (const a of T)
|
|
161
|
+
if (a.startsWith("data: "))
|
|
148
162
|
try {
|
|
149
|
-
const
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
else if (
|
|
153
|
-
|
|
154
|
-
else if (
|
|
155
|
-
|
|
156
|
-
else if (
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
163
|
+
const t = JSON.parse(a.slice(6));
|
|
164
|
+
if (t.type === "init")
|
|
165
|
+
t.threadId && c.onInit && c.onInit(t.threadId);
|
|
166
|
+
else if (t.type === "content")
|
|
167
|
+
t.content && (L = !0, c.onContent(t.content));
|
|
168
|
+
else if (t.type === "complete")
|
|
169
|
+
c.onComplete && c.onComplete(t.sources || []);
|
|
170
|
+
else if (t.type === "done")
|
|
171
|
+
t.humanTakeover && (L = !0), c.onDone && c.onDone({ humanTakeover: t.humanTakeover });
|
|
172
|
+
else if (t.type === "error")
|
|
173
|
+
throw new Error(t.error || re);
|
|
174
|
+
} catch (t) {
|
|
175
|
+
console.error("Error parsing SSE data:", t, a);
|
|
160
176
|
}
|
|
161
177
|
}
|
|
162
|
-
|
|
163
|
-
} catch (
|
|
164
|
-
const
|
|
165
|
-
|
|
178
|
+
L || c.onError(Re);
|
|
179
|
+
} catch (m) {
|
|
180
|
+
const b = m instanceof Error ? m.message : re;
|
|
181
|
+
c.onError(b);
|
|
166
182
|
}
|
|
167
183
|
}
|
|
168
|
-
var
|
|
169
|
-
function
|
|
170
|
-
return
|
|
184
|
+
var ie = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
185
|
+
function Ue(n) {
|
|
186
|
+
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
|
171
187
|
}
|
|
172
|
-
var
|
|
173
|
-
function
|
|
174
|
-
return
|
|
175
|
-
var
|
|
188
|
+
var V = { exports: {} }, oe;
|
|
189
|
+
function Me() {
|
|
190
|
+
return oe || (oe = 1, (function(n) {
|
|
191
|
+
var u = typeof window < "u" ? window : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? self : {};
|
|
176
192
|
/**
|
|
177
193
|
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
178
194
|
*
|
|
@@ -181,8 +197,8 @@ function Le() {
|
|
|
181
197
|
* @namespace
|
|
182
198
|
* @public
|
|
183
199
|
*/
|
|
184
|
-
var
|
|
185
|
-
var
|
|
200
|
+
var e = (function(l) {
|
|
201
|
+
var c = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i, p = 0, h = {}, i = {
|
|
186
202
|
/**
|
|
187
203
|
* By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
|
|
188
204
|
* current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
|
|
@@ -204,7 +220,7 @@ function Le() {
|
|
|
204
220
|
* @memberof Prism
|
|
205
221
|
* @public
|
|
206
222
|
*/
|
|
207
|
-
manual:
|
|
223
|
+
manual: l.Prism && l.Prism.manual,
|
|
208
224
|
/**
|
|
209
225
|
* By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
|
|
210
226
|
* `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
|
|
@@ -226,7 +242,7 @@ function Le() {
|
|
|
226
242
|
* @memberof Prism
|
|
227
243
|
* @public
|
|
228
244
|
*/
|
|
229
|
-
disableWorkerMessageHandler:
|
|
245
|
+
disableWorkerMessageHandler: l.Prism && l.Prism.disableWorkerMessageHandler,
|
|
230
246
|
/**
|
|
231
247
|
* A namespace for utility methods.
|
|
232
248
|
*
|
|
@@ -237,8 +253,8 @@ function Le() {
|
|
|
237
253
|
* @memberof Prism
|
|
238
254
|
*/
|
|
239
255
|
util: {
|
|
240
|
-
encode: function
|
|
241
|
-
return
|
|
256
|
+
encode: function a(t) {
|
|
257
|
+
return t instanceof m ? new m(t.type, a(t.content), t.alias) : Array.isArray(t) ? t.map(a) : t.replace(/&/g, "&").replace(/</g, "<").replace(/\u00a0/g, " ");
|
|
242
258
|
},
|
|
243
259
|
/**
|
|
244
260
|
* Returns the name of the type of the given value.
|
|
@@ -256,8 +272,8 @@ function Le() {
|
|
|
256
272
|
* type(String) === 'Function'
|
|
257
273
|
* type(/abc+/) === 'RegExp'
|
|
258
274
|
*/
|
|
259
|
-
type: function(
|
|
260
|
-
return Object.prototype.toString.call(
|
|
275
|
+
type: function(a) {
|
|
276
|
+
return Object.prototype.toString.call(a).slice(8, -1);
|
|
261
277
|
},
|
|
262
278
|
/**
|
|
263
279
|
* Returns a unique number for the given object. Later calls will still return the same number.
|
|
@@ -265,8 +281,8 @@ function Le() {
|
|
|
265
281
|
* @param {Object} obj
|
|
266
282
|
* @returns {number}
|
|
267
283
|
*/
|
|
268
|
-
objId: function(
|
|
269
|
-
return
|
|
284
|
+
objId: function(a) {
|
|
285
|
+
return a.__id || Object.defineProperty(a, "__id", { value: ++p }), a.__id;
|
|
270
286
|
},
|
|
271
287
|
/**
|
|
272
288
|
* Creates a deep clone of the given object.
|
|
@@ -278,30 +294,30 @@ function Le() {
|
|
|
278
294
|
* @returns {T}
|
|
279
295
|
* @template T
|
|
280
296
|
*/
|
|
281
|
-
clone: function
|
|
297
|
+
clone: function a(t, r) {
|
|
282
298
|
r = r || {};
|
|
283
|
-
var s,
|
|
284
|
-
switch (
|
|
299
|
+
var s, o;
|
|
300
|
+
switch (i.util.type(t)) {
|
|
285
301
|
case "Object":
|
|
286
|
-
if (
|
|
287
|
-
return r[
|
|
302
|
+
if (o = i.util.objId(t), r[o])
|
|
303
|
+
return r[o];
|
|
288
304
|
s = /** @type {Record<string, any>} */
|
|
289
|
-
{}, r[
|
|
290
|
-
for (var
|
|
291
|
-
|
|
305
|
+
{}, r[o] = s;
|
|
306
|
+
for (var g in t)
|
|
307
|
+
t.hasOwnProperty(g) && (s[g] = a(t[g], r));
|
|
292
308
|
return (
|
|
293
309
|
/** @type {any} */
|
|
294
310
|
s
|
|
295
311
|
);
|
|
296
312
|
case "Array":
|
|
297
|
-
return
|
|
313
|
+
return o = i.util.objId(t), r[o] ? r[o] : (s = [], r[o] = s, /** @type {Array} */
|
|
298
314
|
/** @type {any} */
|
|
299
|
-
|
|
300
|
-
s[
|
|
315
|
+
t.forEach(function(f, d) {
|
|
316
|
+
s[d] = a(f, r);
|
|
301
317
|
}), /** @type {any} */
|
|
302
318
|
s);
|
|
303
319
|
default:
|
|
304
|
-
return
|
|
320
|
+
return t;
|
|
305
321
|
}
|
|
306
322
|
},
|
|
307
323
|
/**
|
|
@@ -312,12 +328,12 @@ function Le() {
|
|
|
312
328
|
* @param {Element} element
|
|
313
329
|
* @returns {string}
|
|
314
330
|
*/
|
|
315
|
-
getLanguage: function(
|
|
316
|
-
for (;
|
|
317
|
-
var
|
|
318
|
-
if (
|
|
319
|
-
return
|
|
320
|
-
|
|
331
|
+
getLanguage: function(a) {
|
|
332
|
+
for (; a; ) {
|
|
333
|
+
var t = c.exec(a.className);
|
|
334
|
+
if (t)
|
|
335
|
+
return t[1].toLowerCase();
|
|
336
|
+
a = a.parentElement;
|
|
321
337
|
}
|
|
322
338
|
return "none";
|
|
323
339
|
},
|
|
@@ -328,8 +344,8 @@ function Le() {
|
|
|
328
344
|
* @param {string} language
|
|
329
345
|
* @returns {void}
|
|
330
346
|
*/
|
|
331
|
-
setLanguage: function(
|
|
332
|
-
|
|
347
|
+
setLanguage: function(a, t) {
|
|
348
|
+
a.className = a.className.replace(RegExp(c, "gi"), ""), a.classList.add("language-" + t);
|
|
333
349
|
},
|
|
334
350
|
/**
|
|
335
351
|
* Returns the script element that is currently executing.
|
|
@@ -349,12 +365,12 @@ function Le() {
|
|
|
349
365
|
try {
|
|
350
366
|
throw new Error();
|
|
351
367
|
} catch (s) {
|
|
352
|
-
var
|
|
353
|
-
if (
|
|
354
|
-
var
|
|
355
|
-
for (var r in
|
|
356
|
-
if (
|
|
357
|
-
return
|
|
368
|
+
var a = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(s.stack) || [])[1];
|
|
369
|
+
if (a) {
|
|
370
|
+
var t = document.getElementsByTagName("script");
|
|
371
|
+
for (var r in t)
|
|
372
|
+
if (t[r].src == a)
|
|
373
|
+
return t[r];
|
|
358
374
|
}
|
|
359
375
|
return null;
|
|
360
376
|
}
|
|
@@ -378,14 +394,14 @@ function Le() {
|
|
|
378
394
|
* @param {boolean} [defaultActivation=false]
|
|
379
395
|
* @returns {boolean}
|
|
380
396
|
*/
|
|
381
|
-
isActive: function(
|
|
382
|
-
for (var s = "no-" +
|
|
383
|
-
var
|
|
384
|
-
if (
|
|
397
|
+
isActive: function(a, t, r) {
|
|
398
|
+
for (var s = "no-" + t; a; ) {
|
|
399
|
+
var o = a.classList;
|
|
400
|
+
if (o.contains(t))
|
|
385
401
|
return !0;
|
|
386
|
-
if (
|
|
402
|
+
if (o.contains(s))
|
|
387
403
|
return !1;
|
|
388
|
-
|
|
404
|
+
a = a.parentElement;
|
|
389
405
|
}
|
|
390
406
|
return !!r;
|
|
391
407
|
}
|
|
@@ -401,10 +417,10 @@ function Le() {
|
|
|
401
417
|
/**
|
|
402
418
|
* The grammar for plain, unformatted text.
|
|
403
419
|
*/
|
|
404
|
-
plain:
|
|
405
|
-
plaintext:
|
|
406
|
-
text:
|
|
407
|
-
txt:
|
|
420
|
+
plain: h,
|
|
421
|
+
plaintext: h,
|
|
422
|
+
text: h,
|
|
423
|
+
txt: h,
|
|
408
424
|
/**
|
|
409
425
|
* Creates a deep copy of the language with the given id and appends the given tokens.
|
|
410
426
|
*
|
|
@@ -433,10 +449,10 @@ function Le() {
|
|
|
433
449
|
* 'color': /\b(?:red|green|blue)\b/
|
|
434
450
|
* });
|
|
435
451
|
*/
|
|
436
|
-
extend: function(
|
|
437
|
-
var r =
|
|
438
|
-
for (var s in
|
|
439
|
-
r[s] =
|
|
452
|
+
extend: function(a, t) {
|
|
453
|
+
var r = i.util.clone(i.languages[a]);
|
|
454
|
+
for (var s in t)
|
|
455
|
+
r[s] = t[s];
|
|
440
456
|
return r;
|
|
441
457
|
},
|
|
442
458
|
/**
|
|
@@ -514,31 +530,31 @@ function Le() {
|
|
|
514
530
|
* @returns {Grammar} The new grammar object.
|
|
515
531
|
* @public
|
|
516
532
|
*/
|
|
517
|
-
insertBefore: function(
|
|
533
|
+
insertBefore: function(a, t, r, s) {
|
|
518
534
|
s = s || /** @type {any} */
|
|
519
|
-
|
|
520
|
-
var
|
|
521
|
-
for (var
|
|
522
|
-
if (
|
|
523
|
-
if (
|
|
524
|
-
for (var
|
|
525
|
-
r.hasOwnProperty(
|
|
526
|
-
r.hasOwnProperty(
|
|
535
|
+
i.languages;
|
|
536
|
+
var o = s[a], g = {};
|
|
537
|
+
for (var f in o)
|
|
538
|
+
if (o.hasOwnProperty(f)) {
|
|
539
|
+
if (f == t)
|
|
540
|
+
for (var d in r)
|
|
541
|
+
r.hasOwnProperty(d) && (g[d] = r[d]);
|
|
542
|
+
r.hasOwnProperty(f) || (g[f] = o[f]);
|
|
527
543
|
}
|
|
528
|
-
var
|
|
529
|
-
return s[
|
|
530
|
-
|
|
531
|
-
}),
|
|
544
|
+
var S = s[a];
|
|
545
|
+
return s[a] = g, i.languages.DFS(i.languages, function(I, F) {
|
|
546
|
+
F === S && I != a && (this[I] = g);
|
|
547
|
+
}), g;
|
|
532
548
|
},
|
|
533
549
|
// Traverse a language definition with Depth First Search
|
|
534
|
-
DFS: function
|
|
535
|
-
|
|
536
|
-
var
|
|
537
|
-
for (var
|
|
538
|
-
if (
|
|
539
|
-
r.call(
|
|
540
|
-
var
|
|
541
|
-
|
|
550
|
+
DFS: function a(t, r, s, o) {
|
|
551
|
+
o = o || {};
|
|
552
|
+
var g = i.util.objId;
|
|
553
|
+
for (var f in t)
|
|
554
|
+
if (t.hasOwnProperty(f)) {
|
|
555
|
+
r.call(t, f, t[f], s || f);
|
|
556
|
+
var d = t[f], S = i.util.type(d);
|
|
557
|
+
S === "Object" && !o[g(d)] ? (o[g(d)] = !0, a(d, r, null, o)) : S === "Array" && !o[g(d)] && (o[g(d)] = !0, a(d, r, f, o));
|
|
542
558
|
}
|
|
543
559
|
}
|
|
544
560
|
},
|
|
@@ -555,8 +571,8 @@ function Le() {
|
|
|
555
571
|
* @memberof Prism
|
|
556
572
|
* @public
|
|
557
573
|
*/
|
|
558
|
-
highlightAll: function(
|
|
559
|
-
|
|
574
|
+
highlightAll: function(a, t) {
|
|
575
|
+
i.highlightAllUnder(document, a, t);
|
|
560
576
|
},
|
|
561
577
|
/**
|
|
562
578
|
* Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
|
|
@@ -573,15 +589,15 @@ function Le() {
|
|
|
573
589
|
* @memberof Prism
|
|
574
590
|
* @public
|
|
575
591
|
*/
|
|
576
|
-
highlightAllUnder: function(
|
|
592
|
+
highlightAllUnder: function(a, t, r) {
|
|
577
593
|
var s = {
|
|
578
594
|
callback: r,
|
|
579
|
-
container:
|
|
595
|
+
container: a,
|
|
580
596
|
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
|
|
581
597
|
};
|
|
582
|
-
|
|
583
|
-
for (var
|
|
584
|
-
|
|
598
|
+
i.hooks.run("before-highlightall", s), s.elements = Array.prototype.slice.apply(s.container.querySelectorAll(s.selector)), i.hooks.run("before-all-elements-highlight", s);
|
|
599
|
+
for (var o = 0, g; g = s.elements[o++]; )
|
|
600
|
+
i.highlightElement(g, t === !0, s.callback);
|
|
585
601
|
},
|
|
586
602
|
/**
|
|
587
603
|
* Highlights the code inside a single element.
|
|
@@ -611,39 +627,39 @@ function Le() {
|
|
|
611
627
|
* @memberof Prism
|
|
612
628
|
* @public
|
|
613
629
|
*/
|
|
614
|
-
highlightElement: function(
|
|
615
|
-
var s =
|
|
616
|
-
|
|
617
|
-
var
|
|
618
|
-
|
|
619
|
-
var
|
|
620
|
-
element:
|
|
630
|
+
highlightElement: function(a, t, r) {
|
|
631
|
+
var s = i.util.getLanguage(a), o = i.languages[s];
|
|
632
|
+
i.util.setLanguage(a, s);
|
|
633
|
+
var g = a.parentElement;
|
|
634
|
+
g && g.nodeName.toLowerCase() === "pre" && i.util.setLanguage(g, s);
|
|
635
|
+
var f = a.textContent, d = {
|
|
636
|
+
element: a,
|
|
621
637
|
language: s,
|
|
622
|
-
grammar:
|
|
623
|
-
code:
|
|
638
|
+
grammar: o,
|
|
639
|
+
code: f
|
|
624
640
|
};
|
|
625
|
-
function
|
|
626
|
-
|
|
641
|
+
function S(F) {
|
|
642
|
+
d.highlightedCode = F, i.hooks.run("before-insert", d), d.element.innerHTML = d.highlightedCode, i.hooks.run("after-highlight", d), i.hooks.run("complete", d), r && r.call(d.element);
|
|
627
643
|
}
|
|
628
|
-
if (
|
|
629
|
-
|
|
644
|
+
if (i.hooks.run("before-sanity-check", d), g = d.element.parentElement, g && g.nodeName.toLowerCase() === "pre" && !g.hasAttribute("tabindex") && g.setAttribute("tabindex", "0"), !d.code) {
|
|
645
|
+
i.hooks.run("complete", d), r && r.call(d.element);
|
|
630
646
|
return;
|
|
631
647
|
}
|
|
632
|
-
if (
|
|
633
|
-
|
|
648
|
+
if (i.hooks.run("before-highlight", d), !d.grammar) {
|
|
649
|
+
S(i.util.encode(d.code));
|
|
634
650
|
return;
|
|
635
651
|
}
|
|
636
|
-
if (
|
|
637
|
-
var
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
},
|
|
641
|
-
language:
|
|
642
|
-
code:
|
|
652
|
+
if (t && l.Worker) {
|
|
653
|
+
var I = new Worker(i.filename);
|
|
654
|
+
I.onmessage = function(F) {
|
|
655
|
+
S(F.data);
|
|
656
|
+
}, I.postMessage(JSON.stringify({
|
|
657
|
+
language: d.language,
|
|
658
|
+
code: d.code,
|
|
643
659
|
immediateClose: !0
|
|
644
660
|
}));
|
|
645
661
|
} else
|
|
646
|
-
|
|
662
|
+
S(i.highlight(d.code, d.grammar, d.language));
|
|
647
663
|
},
|
|
648
664
|
/**
|
|
649
665
|
* Low-level function, only use if you know what you’re doing. It accepts a string of text as input
|
|
@@ -665,15 +681,15 @@ function Le() {
|
|
|
665
681
|
* @example
|
|
666
682
|
* Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
|
|
667
683
|
*/
|
|
668
|
-
highlight: function(
|
|
684
|
+
highlight: function(a, t, r) {
|
|
669
685
|
var s = {
|
|
670
|
-
code:
|
|
671
|
-
grammar:
|
|
686
|
+
code: a,
|
|
687
|
+
grammar: t,
|
|
672
688
|
language: r
|
|
673
689
|
};
|
|
674
|
-
if (
|
|
690
|
+
if (i.hooks.run("before-tokenize", s), !s.grammar)
|
|
675
691
|
throw new Error('The language "' + s.language + '" has no grammar.');
|
|
676
|
-
return s.tokens =
|
|
692
|
+
return s.tokens = i.tokenize(s.code, s.grammar), i.hooks.run("after-tokenize", s), m.stringify(i.util.encode(s.tokens), s.language);
|
|
677
693
|
},
|
|
678
694
|
/**
|
|
679
695
|
* This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
|
|
@@ -699,15 +715,15 @@ function Le() {
|
|
|
699
715
|
* }
|
|
700
716
|
* });
|
|
701
717
|
*/
|
|
702
|
-
tokenize: function(
|
|
703
|
-
var r =
|
|
718
|
+
tokenize: function(a, t) {
|
|
719
|
+
var r = t.rest;
|
|
704
720
|
if (r) {
|
|
705
721
|
for (var s in r)
|
|
706
|
-
|
|
707
|
-
delete
|
|
722
|
+
t[s] = r[s];
|
|
723
|
+
delete t.rest;
|
|
708
724
|
}
|
|
709
|
-
var
|
|
710
|
-
return
|
|
725
|
+
var o = new v();
|
|
726
|
+
return w(o, o.head, a), R(a, o, t, o.head, 0), L(o);
|
|
711
727
|
},
|
|
712
728
|
/**
|
|
713
729
|
* @namespace
|
|
@@ -728,9 +744,9 @@ function Le() {
|
|
|
728
744
|
* @param {HookCallback} callback The callback function which is given environment variables.
|
|
729
745
|
* @public
|
|
730
746
|
*/
|
|
731
|
-
add: function(
|
|
732
|
-
var r =
|
|
733
|
-
r[
|
|
747
|
+
add: function(a, t) {
|
|
748
|
+
var r = i.hooks.all;
|
|
749
|
+
r[a] = r[a] || [], r[a].push(t);
|
|
734
750
|
},
|
|
735
751
|
/**
|
|
736
752
|
* Runs a hook invoking all registered callbacks with the given environment variables.
|
|
@@ -741,135 +757,135 @@ function Le() {
|
|
|
741
757
|
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
|
742
758
|
* @public
|
|
743
759
|
*/
|
|
744
|
-
run: function(
|
|
745
|
-
var r =
|
|
760
|
+
run: function(a, t) {
|
|
761
|
+
var r = i.hooks.all[a];
|
|
746
762
|
if (!(!r || !r.length))
|
|
747
|
-
for (var s = 0,
|
|
748
|
-
|
|
763
|
+
for (var s = 0, o; o = r[s++]; )
|
|
764
|
+
o(t);
|
|
749
765
|
}
|
|
750
766
|
},
|
|
751
767
|
Token: m
|
|
752
768
|
};
|
|
753
|
-
|
|
754
|
-
function m(
|
|
755
|
-
this.type =
|
|
769
|
+
l.Prism = i;
|
|
770
|
+
function m(a, t, r, s) {
|
|
771
|
+
this.type = a, this.content = t, this.alias = r, this.length = (s || "").length | 0;
|
|
756
772
|
}
|
|
757
|
-
m.stringify = function
|
|
758
|
-
if (typeof
|
|
759
|
-
return
|
|
760
|
-
if (Array.isArray(
|
|
773
|
+
m.stringify = function a(t, r) {
|
|
774
|
+
if (typeof t == "string")
|
|
775
|
+
return t;
|
|
776
|
+
if (Array.isArray(t)) {
|
|
761
777
|
var s = "";
|
|
762
|
-
return
|
|
763
|
-
s +=
|
|
778
|
+
return t.forEach(function(S) {
|
|
779
|
+
s += a(S, r);
|
|
764
780
|
}), s;
|
|
765
781
|
}
|
|
766
|
-
var
|
|
767
|
-
type:
|
|
768
|
-
content:
|
|
782
|
+
var o = {
|
|
783
|
+
type: t.type,
|
|
784
|
+
content: a(t.content, r),
|
|
769
785
|
tag: "span",
|
|
770
|
-
classes: ["token",
|
|
786
|
+
classes: ["token", t.type],
|
|
771
787
|
attributes: {},
|
|
772
788
|
language: r
|
|
773
|
-
},
|
|
774
|
-
|
|
775
|
-
var
|
|
776
|
-
for (var
|
|
777
|
-
|
|
778
|
-
return "<" +
|
|
789
|
+
}, g = t.alias;
|
|
790
|
+
g && (Array.isArray(g) ? Array.prototype.push.apply(o.classes, g) : o.classes.push(g)), i.hooks.run("wrap", o);
|
|
791
|
+
var f = "";
|
|
792
|
+
for (var d in o.attributes)
|
|
793
|
+
f += " " + d + '="' + (o.attributes[d] || "").replace(/"/g, """) + '"';
|
|
794
|
+
return "<" + o.tag + ' class="' + o.classes.join(" ") + '"' + f + ">" + o.content + "</" + o.tag + ">";
|
|
779
795
|
};
|
|
780
|
-
function
|
|
781
|
-
|
|
782
|
-
var
|
|
783
|
-
if (
|
|
784
|
-
var
|
|
785
|
-
|
|
796
|
+
function b(a, t, r, s) {
|
|
797
|
+
a.lastIndex = t;
|
|
798
|
+
var o = a.exec(r);
|
|
799
|
+
if (o && s && o[1]) {
|
|
800
|
+
var g = o[1].length;
|
|
801
|
+
o.index += g, o[0] = o[0].slice(g);
|
|
786
802
|
}
|
|
787
|
-
return
|
|
803
|
+
return o;
|
|
788
804
|
}
|
|
789
|
-
function
|
|
790
|
-
for (var
|
|
791
|
-
if (!(!r.hasOwnProperty(
|
|
792
|
-
var
|
|
793
|
-
|
|
794
|
-
for (var
|
|
795
|
-
if (
|
|
805
|
+
function R(a, t, r, s, o, g) {
|
|
806
|
+
for (var f in r)
|
|
807
|
+
if (!(!r.hasOwnProperty(f) || !r[f])) {
|
|
808
|
+
var d = r[f];
|
|
809
|
+
d = Array.isArray(d) ? d : [d];
|
|
810
|
+
for (var S = 0; S < d.length; ++S) {
|
|
811
|
+
if (g && g.cause == f + "," + S)
|
|
796
812
|
return;
|
|
797
|
-
var
|
|
798
|
-
if (
|
|
799
|
-
var
|
|
800
|
-
|
|
813
|
+
var I = d[S], F = I.inside, ee = !!I.lookbehind, te = !!I.greedy, me = I.alias;
|
|
814
|
+
if (te && !I.pattern.global) {
|
|
815
|
+
var Ae = I.pattern.toString().match(/[imsuy]*$/)[0];
|
|
816
|
+
I.pattern = RegExp(I.pattern.source, Ae + "g");
|
|
801
817
|
}
|
|
802
|
-
for (var
|
|
803
|
-
var
|
|
804
|
-
if (
|
|
818
|
+
for (var ne = I.pattern || I, y = s.next, N = o; y !== t.tail && !(g && N >= g.reach); N += y.value.length, y = y.next) {
|
|
819
|
+
var D = y.value;
|
|
820
|
+
if (t.length > a.length)
|
|
805
821
|
return;
|
|
806
|
-
if (!(
|
|
807
|
-
var
|
|
808
|
-
if (
|
|
809
|
-
if (
|
|
822
|
+
if (!(D instanceof m)) {
|
|
823
|
+
var M = 1, O;
|
|
824
|
+
if (te) {
|
|
825
|
+
if (O = b(ne, N, a, ee), !O || O.index >= a.length)
|
|
810
826
|
break;
|
|
811
|
-
var
|
|
812
|
-
for (
|
|
813
|
-
|
|
814
|
-
if (
|
|
827
|
+
var $ = O.index, Se = O.index + O[0].length, C = N;
|
|
828
|
+
for (C += y.value.length; $ >= C; )
|
|
829
|
+
y = y.next, C += y.value.length;
|
|
830
|
+
if (C -= y.value.length, N = C, y.value instanceof m)
|
|
815
831
|
continue;
|
|
816
|
-
for (var P =
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
} else if (
|
|
832
|
+
for (var P = y; P !== t.tail && (C < Se || typeof P.value == "string"); P = P.next)
|
|
833
|
+
M++, C += P.value.length;
|
|
834
|
+
M--, D = a.slice(N, C), O.index -= N;
|
|
835
|
+
} else if (O = b(ne, 0, D, ee), !O)
|
|
820
836
|
continue;
|
|
821
|
-
var
|
|
822
|
-
|
|
823
|
-
var G =
|
|
824
|
-
|
|
825
|
-
var
|
|
826
|
-
if (
|
|
827
|
-
var
|
|
828
|
-
cause:
|
|
829
|
-
reach:
|
|
837
|
+
var $ = O.index, B = O[0], j = D.slice(0, $), ae = D.slice($ + B.length), K = N + D.length;
|
|
838
|
+
g && K > g.reach && (g.reach = K);
|
|
839
|
+
var G = y.prev;
|
|
840
|
+
j && (G = w(t, G, j), N += j.length), k(t, G, M);
|
|
841
|
+
var Te = new m(f, F ? i.tokenize(B, F) : B, me, B);
|
|
842
|
+
if (y = w(t, G, Te), ae && w(t, y, ae), M > 1) {
|
|
843
|
+
var q = {
|
|
844
|
+
cause: f + "," + S,
|
|
845
|
+
reach: K
|
|
830
846
|
};
|
|
831
|
-
|
|
847
|
+
R(a, t, r, y.prev, N, q), g && q.reach > g.reach && (g.reach = q.reach);
|
|
832
848
|
}
|
|
833
849
|
}
|
|
834
850
|
}
|
|
835
851
|
}
|
|
836
852
|
}
|
|
837
853
|
}
|
|
838
|
-
function
|
|
839
|
-
var
|
|
840
|
-
|
|
854
|
+
function v() {
|
|
855
|
+
var a = { value: null, prev: null, next: null }, t = { value: null, prev: a, next: null };
|
|
856
|
+
a.next = t, this.head = a, this.tail = t, this.length = 0;
|
|
841
857
|
}
|
|
842
|
-
function
|
|
843
|
-
var s =
|
|
844
|
-
return
|
|
858
|
+
function w(a, t, r) {
|
|
859
|
+
var s = t.next, o = { value: r, prev: t, next: s };
|
|
860
|
+
return t.next = o, s.prev = o, a.length++, o;
|
|
845
861
|
}
|
|
846
|
-
function
|
|
847
|
-
for (var s =
|
|
862
|
+
function k(a, t, r) {
|
|
863
|
+
for (var s = t.next, o = 0; o < r && s !== a.tail; o++)
|
|
848
864
|
s = s.next;
|
|
849
|
-
|
|
865
|
+
t.next = s, s.prev = t, a.length -= o;
|
|
850
866
|
}
|
|
851
|
-
function
|
|
852
|
-
for (var
|
|
853
|
-
|
|
854
|
-
return
|
|
867
|
+
function L(a) {
|
|
868
|
+
for (var t = [], r = a.head.next; r !== a.tail; )
|
|
869
|
+
t.push(r.value), r = r.next;
|
|
870
|
+
return t;
|
|
855
871
|
}
|
|
856
|
-
if (!
|
|
857
|
-
return
|
|
858
|
-
var
|
|
859
|
-
|
|
860
|
-
}, !1)),
|
|
861
|
-
var
|
|
862
|
-
|
|
863
|
-
function
|
|
864
|
-
|
|
872
|
+
if (!l.document)
|
|
873
|
+
return l.addEventListener && (i.disableWorkerMessageHandler || l.addEventListener("message", function(a) {
|
|
874
|
+
var t = JSON.parse(a.data), r = t.language, s = t.code, o = t.immediateClose;
|
|
875
|
+
l.postMessage(i.highlight(s, i.languages[r], r)), o && l.close();
|
|
876
|
+
}, !1)), i;
|
|
877
|
+
var A = i.util.currentScript();
|
|
878
|
+
A && (i.filename = A.src, A.hasAttribute("data-manual") && (i.manual = !0));
|
|
879
|
+
function E() {
|
|
880
|
+
i.manual || i.highlightAll();
|
|
865
881
|
}
|
|
866
|
-
if (!
|
|
867
|
-
var
|
|
868
|
-
|
|
882
|
+
if (!i.manual) {
|
|
883
|
+
var T = document.readyState;
|
|
884
|
+
T === "loading" || T === "interactive" && A && A.defer ? document.addEventListener("DOMContentLoaded", E) : window.requestAnimationFrame ? window.requestAnimationFrame(E) : window.setTimeout(E, 16);
|
|
869
885
|
}
|
|
870
|
-
return
|
|
871
|
-
})(
|
|
872
|
-
|
|
886
|
+
return i;
|
|
887
|
+
})(u);
|
|
888
|
+
n.exports && (n.exports = e), typeof ie < "u" && (ie.Prism = e), e.languages.markup = {
|
|
873
889
|
comment: {
|
|
874
890
|
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
|
|
875
891
|
greedy: !0
|
|
@@ -946,9 +962,9 @@ function Le() {
|
|
|
946
962
|
},
|
|
947
963
|
/&#x?[\da-f]{1,8};/i
|
|
948
964
|
]
|
|
949
|
-
},
|
|
950
|
-
|
|
951
|
-
}), Object.defineProperty(
|
|
965
|
+
}, e.languages.markup.tag.inside["attr-value"].inside.entity = e.languages.markup.entity, e.languages.markup.doctype.inside["internal-subset"].inside = e.languages.markup, e.hooks.add("wrap", function(l) {
|
|
966
|
+
l.type === "entity" && (l.attributes.title = l.content.replace(/&/, "&"));
|
|
967
|
+
}), Object.defineProperty(e.languages.markup.tag, "addInlined", {
|
|
952
968
|
/**
|
|
953
969
|
* Adds an inlined language to markup.
|
|
954
970
|
*
|
|
@@ -960,34 +976,34 @@ function Le() {
|
|
|
960
976
|
* @example
|
|
961
977
|
* addInlined('style', 'css');
|
|
962
978
|
*/
|
|
963
|
-
value: function(
|
|
964
|
-
var
|
|
965
|
-
|
|
979
|
+
value: function(c, p) {
|
|
980
|
+
var h = {};
|
|
981
|
+
h["language-" + p] = {
|
|
966
982
|
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
|
967
983
|
lookbehind: !0,
|
|
968
|
-
inside:
|
|
969
|
-
},
|
|
970
|
-
var
|
|
984
|
+
inside: e.languages[p]
|
|
985
|
+
}, h.cdata = /^<!\[CDATA\[|\]\]>$/i;
|
|
986
|
+
var i = {
|
|
971
987
|
"included-cdata": {
|
|
972
988
|
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
973
|
-
inside:
|
|
989
|
+
inside: h
|
|
974
990
|
}
|
|
975
991
|
};
|
|
976
|
-
|
|
992
|
+
i["language-" + p] = {
|
|
977
993
|
pattern: /[\s\S]+/,
|
|
978
|
-
inside:
|
|
994
|
+
inside: e.languages[p]
|
|
979
995
|
};
|
|
980
996
|
var m = {};
|
|
981
|
-
m[
|
|
997
|
+
m[c] = {
|
|
982
998
|
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
|
|
983
|
-
return
|
|
999
|
+
return c;
|
|
984
1000
|
}), "i"),
|
|
985
1001
|
lookbehind: !0,
|
|
986
1002
|
greedy: !0,
|
|
987
|
-
inside:
|
|
988
|
-
},
|
|
1003
|
+
inside: i
|
|
1004
|
+
}, e.languages.insertBefore("markup", "cdata", m);
|
|
989
1005
|
}
|
|
990
|
-
}), Object.defineProperty(
|
|
1006
|
+
}), Object.defineProperty(e.languages.markup.tag, "addAttribute", {
|
|
991
1007
|
/**
|
|
992
1008
|
* Adds an pattern to highlight languages embedded in HTML attributes.
|
|
993
1009
|
*
|
|
@@ -999,10 +1015,10 @@ function Le() {
|
|
|
999
1015
|
* @example
|
|
1000
1016
|
* addAttribute('style', 'css');
|
|
1001
1017
|
*/
|
|
1002
|
-
value: function(
|
|
1003
|
-
|
|
1018
|
+
value: function(l, c) {
|
|
1019
|
+
e.languages.markup.tag.inside["special-attr"].push({
|
|
1004
1020
|
pattern: RegExp(
|
|
1005
|
-
/(^|["'\s])/.source + "(?:" +
|
|
1021
|
+
/(^|["'\s])/.source + "(?:" + l + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
|
|
1006
1022
|
"i"
|
|
1007
1023
|
),
|
|
1008
1024
|
lookbehind: !0,
|
|
@@ -1014,8 +1030,8 @@ function Le() {
|
|
|
1014
1030
|
value: {
|
|
1015
1031
|
pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
|
1016
1032
|
lookbehind: !0,
|
|
1017
|
-
alias: [
|
|
1018
|
-
inside:
|
|
1033
|
+
alias: [c, "language-" + c],
|
|
1034
|
+
inside: e.languages[c]
|
|
1019
1035
|
},
|
|
1020
1036
|
punctuation: [
|
|
1021
1037
|
{
|
|
@@ -1029,12 +1045,12 @@ function Le() {
|
|
|
1029
1045
|
}
|
|
1030
1046
|
});
|
|
1031
1047
|
}
|
|
1032
|
-
}),
|
|
1033
|
-
var
|
|
1034
|
-
|
|
1048
|
+
}), e.languages.html = e.languages.markup, e.languages.mathml = e.languages.markup, e.languages.svg = e.languages.markup, e.languages.xml = e.languages.extend("markup", {}), e.languages.ssml = e.languages.xml, e.languages.atom = e.languages.xml, e.languages.rss = e.languages.xml, (function(l) {
|
|
1049
|
+
var c = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
1050
|
+
l.languages.css = {
|
|
1035
1051
|
comment: /\/\*[\s\S]*?\*\//,
|
|
1036
1052
|
atrule: {
|
|
1037
|
-
pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" +
|
|
1053
|
+
pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + c.source + ")*?" + /(?:;|(?=\s*\{))/.source),
|
|
1038
1054
|
inside: {
|
|
1039
1055
|
rule: /^@[\w-]+/,
|
|
1040
1056
|
"selector-function-argument": {
|
|
@@ -1051,23 +1067,23 @@ function Le() {
|
|
|
1051
1067
|
},
|
|
1052
1068
|
url: {
|
|
1053
1069
|
// https://drafts.csswg.org/css-values-3/#urls
|
|
1054
|
-
pattern: RegExp("\\burl\\((?:" +
|
|
1070
|
+
pattern: RegExp("\\burl\\((?:" + c.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"),
|
|
1055
1071
|
greedy: !0,
|
|
1056
1072
|
inside: {
|
|
1057
1073
|
function: /^url/i,
|
|
1058
1074
|
punctuation: /^\(|\)$/,
|
|
1059
1075
|
string: {
|
|
1060
|
-
pattern: RegExp("^" +
|
|
1076
|
+
pattern: RegExp("^" + c.source + "$"),
|
|
1061
1077
|
alias: "url"
|
|
1062
1078
|
}
|
|
1063
1079
|
}
|
|
1064
1080
|
},
|
|
1065
1081
|
selector: {
|
|
1066
|
-
pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` +
|
|
1082
|
+
pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + c.source + ")*(?=\\s*\\{)"),
|
|
1067
1083
|
lookbehind: !0
|
|
1068
1084
|
},
|
|
1069
1085
|
string: {
|
|
1070
|
-
pattern:
|
|
1086
|
+
pattern: c,
|
|
1071
1087
|
greedy: !0
|
|
1072
1088
|
},
|
|
1073
1089
|
property: {
|
|
@@ -1080,10 +1096,10 @@ function Le() {
|
|
|
1080
1096
|
lookbehind: !0
|
|
1081
1097
|
},
|
|
1082
1098
|
punctuation: /[(){};:,]/
|
|
1083
|
-
},
|
|
1084
|
-
var
|
|
1085
|
-
|
|
1086
|
-
})(
|
|
1099
|
+
}, l.languages.css.atrule.inside.rest = l.languages.css;
|
|
1100
|
+
var p = l.languages.markup;
|
|
1101
|
+
p && (p.tag.addInlined("style", "css"), p.tag.addAttribute("style", "css"));
|
|
1102
|
+
})(e), e.languages.clike = {
|
|
1087
1103
|
comment: [
|
|
1088
1104
|
{
|
|
1089
1105
|
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
@@ -1113,9 +1129,9 @@ function Le() {
|
|
|
1113
1129
|
number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
1114
1130
|
operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
1115
1131
|
punctuation: /[{}[\];(),.:]/
|
|
1116
|
-
},
|
|
1132
|
+
}, e.languages.javascript = e.languages.extend("clike", {
|
|
1117
1133
|
"class-name": [
|
|
1118
|
-
|
|
1134
|
+
e.languages.clike["class-name"],
|
|
1119
1135
|
{
|
|
1120
1136
|
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
|
1121
1137
|
lookbehind: !0
|
|
@@ -1146,7 +1162,7 @@ function Le() {
|
|
|
1146
1162
|
lookbehind: !0
|
|
1147
1163
|
},
|
|
1148
1164
|
operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
1149
|
-
}),
|
|
1165
|
+
}), e.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/, e.languages.insertBefore("javascript", "keyword", {
|
|
1150
1166
|
regex: {
|
|
1151
1167
|
pattern: RegExp(
|
|
1152
1168
|
// lookbehind
|
|
@@ -1166,7 +1182,7 @@ function Le() {
|
|
|
1166
1182
|
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
1167
1183
|
lookbehind: !0,
|
|
1168
1184
|
alias: "language-regex",
|
|
1169
|
-
inside:
|
|
1185
|
+
inside: e.languages.regex
|
|
1170
1186
|
},
|
|
1171
1187
|
"regex-delimiter": /^\/|\/$/,
|
|
1172
1188
|
"regex-flags": /^[a-z]+$/
|
|
@@ -1181,26 +1197,26 @@ function Le() {
|
|
|
1181
1197
|
{
|
|
1182
1198
|
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
1183
1199
|
lookbehind: !0,
|
|
1184
|
-
inside:
|
|
1200
|
+
inside: e.languages.javascript
|
|
1185
1201
|
},
|
|
1186
1202
|
{
|
|
1187
1203
|
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
1188
1204
|
lookbehind: !0,
|
|
1189
|
-
inside:
|
|
1205
|
+
inside: e.languages.javascript
|
|
1190
1206
|
},
|
|
1191
1207
|
{
|
|
1192
1208
|
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
1193
1209
|
lookbehind: !0,
|
|
1194
|
-
inside:
|
|
1210
|
+
inside: e.languages.javascript
|
|
1195
1211
|
},
|
|
1196
1212
|
{
|
|
1197
1213
|
pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
|
|
1198
1214
|
lookbehind: !0,
|
|
1199
|
-
inside:
|
|
1215
|
+
inside: e.languages.javascript
|
|
1200
1216
|
}
|
|
1201
1217
|
],
|
|
1202
1218
|
constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
1203
|
-
}),
|
|
1219
|
+
}), e.languages.insertBefore("javascript", "string", {
|
|
1204
1220
|
hashbang: {
|
|
1205
1221
|
pattern: /^#!.*/,
|
|
1206
1222
|
greedy: !0,
|
|
@@ -1222,7 +1238,7 @@ function Le() {
|
|
|
1222
1238
|
pattern: /^\$\{|\}$/,
|
|
1223
1239
|
alias: "punctuation"
|
|
1224
1240
|
},
|
|
1225
|
-
rest:
|
|
1241
|
+
rest: e.languages.javascript
|
|
1226
1242
|
}
|
|
1227
1243
|
},
|
|
1228
1244
|
string: /[\s\S]+/
|
|
@@ -1234,22 +1250,22 @@ function Le() {
|
|
|
1234
1250
|
greedy: !0,
|
|
1235
1251
|
alias: "property"
|
|
1236
1252
|
}
|
|
1237
|
-
}),
|
|
1253
|
+
}), e.languages.insertBefore("javascript", "operator", {
|
|
1238
1254
|
"literal-property": {
|
|
1239
1255
|
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
1240
1256
|
lookbehind: !0,
|
|
1241
1257
|
alias: "property"
|
|
1242
1258
|
}
|
|
1243
|
-
}),
|
|
1259
|
+
}), e.languages.markup && (e.languages.markup.tag.addInlined("script", "javascript"), e.languages.markup.tag.addAttribute(
|
|
1244
1260
|
/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
|
|
1245
1261
|
"javascript"
|
|
1246
|
-
)),
|
|
1247
|
-
if (typeof
|
|
1262
|
+
)), e.languages.js = e.languages.javascript, (function() {
|
|
1263
|
+
if (typeof e > "u" || typeof document > "u")
|
|
1248
1264
|
return;
|
|
1249
1265
|
Element.prototype.matches || (Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector);
|
|
1250
|
-
var
|
|
1251
|
-
return "✖ Error " +
|
|
1252
|
-
},
|
|
1266
|
+
var l = "Loading…", c = function(A, E) {
|
|
1267
|
+
return "✖ Error " + A + " while fetching file: " + E;
|
|
1268
|
+
}, p = "✖ Error: File does not exist or is empty", h = {
|
|
1253
1269
|
js: "javascript",
|
|
1254
1270
|
py: "python",
|
|
1255
1271
|
rb: "ruby",
|
|
@@ -1259,56 +1275,56 @@ function Le() {
|
|
|
1259
1275
|
bat: "batch",
|
|
1260
1276
|
h: "c",
|
|
1261
1277
|
tex: "latex"
|
|
1262
|
-
},
|
|
1263
|
-
function
|
|
1264
|
-
var
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
},
|
|
1278
|
+
}, i = "data-src-status", m = "loading", b = "loaded", R = "failed", v = "pre[data-src]:not([" + i + '="' + b + '"]):not([' + i + '="' + m + '"])';
|
|
1279
|
+
function w(A, E, T) {
|
|
1280
|
+
var a = new XMLHttpRequest();
|
|
1281
|
+
a.open("GET", A, !0), a.onreadystatechange = function() {
|
|
1282
|
+
a.readyState == 4 && (a.status < 400 && a.responseText ? E(a.responseText) : a.status >= 400 ? T(c(a.status, a.statusText)) : T(p));
|
|
1283
|
+
}, a.send(null);
|
|
1268
1284
|
}
|
|
1269
|
-
function
|
|
1270
|
-
var
|
|
1271
|
-
if (
|
|
1272
|
-
var
|
|
1273
|
-
return
|
|
1285
|
+
function k(A) {
|
|
1286
|
+
var E = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(A || "");
|
|
1287
|
+
if (E) {
|
|
1288
|
+
var T = Number(E[1]), a = E[2], t = E[3];
|
|
1289
|
+
return a ? t ? [T, Number(t)] : [T, void 0] : [T, T];
|
|
1274
1290
|
}
|
|
1275
1291
|
}
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
}),
|
|
1279
|
-
var
|
|
1292
|
+
e.hooks.add("before-highlightall", function(A) {
|
|
1293
|
+
A.selector += ", " + v;
|
|
1294
|
+
}), e.hooks.add("before-sanity-check", function(A) {
|
|
1295
|
+
var E = (
|
|
1280
1296
|
/** @type {HTMLPreElement} */
|
|
1281
|
-
|
|
1297
|
+
A.element
|
|
1282
1298
|
);
|
|
1283
|
-
if (
|
|
1284
|
-
|
|
1285
|
-
var
|
|
1286
|
-
|
|
1287
|
-
var
|
|
1288
|
-
if (
|
|
1289
|
-
var r = (/\.(\w+)$/.exec(
|
|
1290
|
-
|
|
1299
|
+
if (E.matches(v)) {
|
|
1300
|
+
A.code = "", E.setAttribute(i, m);
|
|
1301
|
+
var T = E.appendChild(document.createElement("CODE"));
|
|
1302
|
+
T.textContent = l;
|
|
1303
|
+
var a = E.getAttribute("data-src"), t = A.language;
|
|
1304
|
+
if (t === "none") {
|
|
1305
|
+
var r = (/\.(\w+)$/.exec(a) || [, "none"])[1];
|
|
1306
|
+
t = h[r] || r;
|
|
1291
1307
|
}
|
|
1292
|
-
|
|
1293
|
-
var s =
|
|
1294
|
-
s && s.loadLanguages(
|
|
1295
|
-
|
|
1296
|
-
function(
|
|
1297
|
-
|
|
1298
|
-
var
|
|
1299
|
-
if (
|
|
1300
|
-
var
|
|
1301
|
-
|
|
1302
|
-
`),
|
|
1308
|
+
e.util.setLanguage(T, t), e.util.setLanguage(E, t);
|
|
1309
|
+
var s = e.plugins.autoloader;
|
|
1310
|
+
s && s.loadLanguages(t), w(
|
|
1311
|
+
a,
|
|
1312
|
+
function(o) {
|
|
1313
|
+
E.setAttribute(i, b);
|
|
1314
|
+
var g = k(E.getAttribute("data-range"));
|
|
1315
|
+
if (g) {
|
|
1316
|
+
var f = o.split(/\r\n?|\n/g), d = g[0], S = g[1] == null ? f.length : g[1];
|
|
1317
|
+
d < 0 && (d += f.length), d = Math.max(0, Math.min(d - 1, f.length)), S < 0 && (S += f.length), S = Math.max(0, Math.min(S, f.length)), o = f.slice(d, S).join(`
|
|
1318
|
+
`), E.hasAttribute("data-start") || E.setAttribute("data-start", String(d + 1));
|
|
1303
1319
|
}
|
|
1304
|
-
|
|
1320
|
+
T.textContent = o, e.highlightElement(T);
|
|
1305
1321
|
},
|
|
1306
|
-
function(
|
|
1307
|
-
|
|
1322
|
+
function(o) {
|
|
1323
|
+
E.setAttribute(i, R), T.textContent = o;
|
|
1308
1324
|
}
|
|
1309
1325
|
);
|
|
1310
1326
|
}
|
|
1311
|
-
}),
|
|
1327
|
+
}), e.plugins.fileHighlight = {
|
|
1312
1328
|
/**
|
|
1313
1329
|
* Executes the File Highlight plugin for all matching `pre` elements under the given container.
|
|
1314
1330
|
*
|
|
@@ -1316,23 +1332,23 @@ function Le() {
|
|
|
1316
1332
|
*
|
|
1317
1333
|
* @param {ParentNode} [container=document]
|
|
1318
1334
|
*/
|
|
1319
|
-
highlight: function(
|
|
1320
|
-
for (var
|
|
1321
|
-
|
|
1335
|
+
highlight: function(E) {
|
|
1336
|
+
for (var T = (E || document).querySelectorAll(v), a = 0, t; t = T[a++]; )
|
|
1337
|
+
e.highlightElement(t);
|
|
1322
1338
|
}
|
|
1323
1339
|
};
|
|
1324
|
-
var
|
|
1325
|
-
|
|
1326
|
-
|
|
1340
|
+
var L = !1;
|
|
1341
|
+
e.fileHighlight = function() {
|
|
1342
|
+
L || (console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."), L = !0), e.plugins.fileHighlight.highlight.apply(this, arguments);
|
|
1327
1343
|
};
|
|
1328
1344
|
})();
|
|
1329
|
-
})(
|
|
1345
|
+
})(V)), V.exports;
|
|
1330
1346
|
}
|
|
1331
|
-
var
|
|
1332
|
-
const
|
|
1333
|
-
var
|
|
1334
|
-
function
|
|
1335
|
-
return
|
|
1347
|
+
var $e = Me();
|
|
1348
|
+
const ue = /* @__PURE__ */ Ue($e);
|
|
1349
|
+
var le = {}, ce;
|
|
1350
|
+
function Be() {
|
|
1351
|
+
return ce || (ce = 1, Prism.languages.python = {
|
|
1336
1352
|
comment: {
|
|
1337
1353
|
pattern: /(^|[^\\])#.*/,
|
|
1338
1354
|
lookbehind: !0,
|
|
@@ -1392,13 +1408,13 @@ function Ce() {
|
|
|
1392
1408
|
number: /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
|
|
1393
1409
|
operator: /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
|
1394
1410
|
punctuation: /[{}[\];(),.:]/
|
|
1395
|
-
}, Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest = Prism.languages.python, Prism.languages.py = Prism.languages.python),
|
|
1411
|
+
}, Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest = Prism.languages.python, Prism.languages.py = Prism.languages.python), le;
|
|
1396
1412
|
}
|
|
1397
|
-
|
|
1398
|
-
var
|
|
1399
|
-
function
|
|
1400
|
-
return
|
|
1401
|
-
|
|
1413
|
+
Be();
|
|
1414
|
+
var de = {}, ge;
|
|
1415
|
+
function Ge() {
|
|
1416
|
+
return ge || (ge = 1, (function(n) {
|
|
1417
|
+
n.languages.typescript = n.languages.extend("javascript", {
|
|
1402
1418
|
"class-name": {
|
|
1403
1419
|
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,
|
|
1404
1420
|
lookbehind: !0,
|
|
@@ -1407,15 +1423,15 @@ function ke() {
|
|
|
1407
1423
|
// see below
|
|
1408
1424
|
},
|
|
1409
1425
|
builtin: /\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/
|
|
1410
|
-
}),
|
|
1426
|
+
}), n.languages.typescript.keyword.push(
|
|
1411
1427
|
/\b(?:abstract|declare|is|keyof|readonly|require)\b/,
|
|
1412
1428
|
// keywords that have to be followed by an identifier
|
|
1413
1429
|
/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,
|
|
1414
1430
|
// This is for `import type *, {}`
|
|
1415
1431
|
/\btype\b(?=\s*(?:[\{*]|$))/
|
|
1416
|
-
), delete
|
|
1417
|
-
var
|
|
1418
|
-
delete
|
|
1432
|
+
), delete n.languages.typescript.parameter, delete n.languages.typescript["literal-property"];
|
|
1433
|
+
var u = n.languages.extend("typescript", {});
|
|
1434
|
+
delete u["class-name"], n.languages.typescript["class-name"].inside = u, n.languages.insertBefore("typescript", "function", {
|
|
1419
1435
|
decorator: {
|
|
1420
1436
|
pattern: /@[$\w\xA0-\uFFFF]+/,
|
|
1421
1437
|
inside: {
|
|
@@ -1436,26 +1452,26 @@ function ke() {
|
|
|
1436
1452
|
pattern: /<[\s\S]+/,
|
|
1437
1453
|
// everything after the first <
|
|
1438
1454
|
alias: "class-name",
|
|
1439
|
-
inside:
|
|
1455
|
+
inside: u
|
|
1440
1456
|
}
|
|
1441
1457
|
}
|
|
1442
1458
|
}
|
|
1443
|
-
}),
|
|
1444
|
-
})(Prism)),
|
|
1459
|
+
}), n.languages.ts = n.languages.typescript;
|
|
1460
|
+
})(Prism)), de;
|
|
1445
1461
|
}
|
|
1446
|
-
|
|
1447
|
-
(function(
|
|
1448
|
-
var
|
|
1462
|
+
Ge();
|
|
1463
|
+
(function(n) {
|
|
1464
|
+
var u = "\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b", e = {
|
|
1449
1465
|
pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
|
|
1450
1466
|
lookbehind: !0,
|
|
1451
1467
|
alias: "punctuation",
|
|
1452
1468
|
// this looks reasonably well in all themes
|
|
1453
1469
|
inside: null
|
|
1454
1470
|
// see below
|
|
1455
|
-
},
|
|
1456
|
-
bash:
|
|
1471
|
+
}, l = {
|
|
1472
|
+
bash: e,
|
|
1457
1473
|
environment: {
|
|
1458
|
-
pattern: RegExp("\\$" +
|
|
1474
|
+
pattern: RegExp("\\$" + u),
|
|
1459
1475
|
alias: "constant"
|
|
1460
1476
|
},
|
|
1461
1477
|
variable: [
|
|
@@ -1495,7 +1511,7 @@ ke();
|
|
|
1495
1511
|
operator: /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
|
|
1496
1512
|
punctuation: /[\[\]]/,
|
|
1497
1513
|
environment: {
|
|
1498
|
-
pattern: RegExp("(\\{)" +
|
|
1514
|
+
pattern: RegExp("(\\{)" + u),
|
|
1499
1515
|
lookbehind: !0,
|
|
1500
1516
|
alias: "constant"
|
|
1501
1517
|
}
|
|
@@ -1506,7 +1522,7 @@ ke();
|
|
|
1506
1522
|
// Escape sequences from echo and printf's manuals, and escaped quotes.
|
|
1507
1523
|
entity: /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
|
|
1508
1524
|
};
|
|
1509
|
-
|
|
1525
|
+
n.languages.bash = {
|
|
1510
1526
|
shebang: {
|
|
1511
1527
|
pattern: /^#!\s*\/.*/,
|
|
1512
1528
|
alias: "important"
|
|
@@ -1544,7 +1560,7 @@ ke();
|
|
|
1544
1560
|
pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
|
|
1545
1561
|
inside: {
|
|
1546
1562
|
environment: {
|
|
1547
|
-
pattern: RegExp("(^|[\\s;|&]|[<>]\\()" +
|
|
1563
|
+
pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + u),
|
|
1548
1564
|
lookbehind: !0,
|
|
1549
1565
|
alias: "constant"
|
|
1550
1566
|
}
|
|
@@ -1564,7 +1580,7 @@ ke();
|
|
|
1564
1580
|
pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
|
|
1565
1581
|
lookbehind: !0,
|
|
1566
1582
|
greedy: !0,
|
|
1567
|
-
inside:
|
|
1583
|
+
inside: l
|
|
1568
1584
|
},
|
|
1569
1585
|
// Here-document with quotes around the tag
|
|
1570
1586
|
// → No expansion (so no “inside”).
|
|
@@ -1573,7 +1589,7 @@ ke();
|
|
|
1573
1589
|
lookbehind: !0,
|
|
1574
1590
|
greedy: !0,
|
|
1575
1591
|
inside: {
|
|
1576
|
-
bash:
|
|
1592
|
+
bash: e
|
|
1577
1593
|
}
|
|
1578
1594
|
},
|
|
1579
1595
|
// “Normal” string
|
|
@@ -1582,7 +1598,7 @@ ke();
|
|
|
1582
1598
|
pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
|
|
1583
1599
|
lookbehind: !0,
|
|
1584
1600
|
greedy: !0,
|
|
1585
|
-
inside:
|
|
1601
|
+
inside: l
|
|
1586
1602
|
},
|
|
1587
1603
|
{
|
|
1588
1604
|
// https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
|
|
@@ -1595,15 +1611,15 @@ ke();
|
|
|
1595
1611
|
pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
|
|
1596
1612
|
greedy: !0,
|
|
1597
1613
|
inside: {
|
|
1598
|
-
entity:
|
|
1614
|
+
entity: l.entity
|
|
1599
1615
|
}
|
|
1600
1616
|
}
|
|
1601
1617
|
],
|
|
1602
1618
|
environment: {
|
|
1603
|
-
pattern: RegExp("\\$?" +
|
|
1619
|
+
pattern: RegExp("\\$?" + u),
|
|
1604
1620
|
alias: "constant"
|
|
1605
1621
|
},
|
|
1606
|
-
variable:
|
|
1622
|
+
variable: l.variable,
|
|
1607
1623
|
function: {
|
|
1608
1624
|
pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
|
|
1609
1625
|
lookbehind: !0
|
|
@@ -1642,8 +1658,8 @@ ke();
|
|
|
1642
1658
|
pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
|
|
1643
1659
|
lookbehind: !0
|
|
1644
1660
|
}
|
|
1645
|
-
},
|
|
1646
|
-
for (var
|
|
1661
|
+
}, e.inside = n.languages.bash;
|
|
1662
|
+
for (var c = [
|
|
1647
1663
|
"comment",
|
|
1648
1664
|
"function-name",
|
|
1649
1665
|
"for-or-select",
|
|
@@ -1659,9 +1675,9 @@ ke();
|
|
|
1659
1675
|
"operator",
|
|
1660
1676
|
"punctuation",
|
|
1661
1677
|
"number"
|
|
1662
|
-
],
|
|
1663
|
-
|
|
1664
|
-
|
|
1678
|
+
], p = l.variable[1].inside, h = 0; h < c.length; h++)
|
|
1679
|
+
p[c[h]] = n.languages.bash[c[h]];
|
|
1680
|
+
n.languages.sh = n.languages.bash, n.languages.shell = n.languages.bash;
|
|
1665
1681
|
})(Prism);
|
|
1666
1682
|
Prism.languages.json = {
|
|
1667
1683
|
property: {
|
|
@@ -1688,12 +1704,12 @@ Prism.languages.json = {
|
|
|
1688
1704
|
}
|
|
1689
1705
|
};
|
|
1690
1706
|
Prism.languages.webmanifest = Prism.languages.json;
|
|
1691
|
-
(function(
|
|
1692
|
-
var
|
|
1693
|
-
|
|
1707
|
+
(function(n) {
|
|
1708
|
+
var u = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
1709
|
+
n.languages.css = {
|
|
1694
1710
|
comment: /\/\*[\s\S]*?\*\//,
|
|
1695
1711
|
atrule: {
|
|
1696
|
-
pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" +
|
|
1712
|
+
pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + u.source + ")*?" + /(?:;|(?=\s*\{))/.source),
|
|
1697
1713
|
inside: {
|
|
1698
1714
|
rule: /^@[\w-]+/,
|
|
1699
1715
|
"selector-function-argument": {
|
|
@@ -1710,23 +1726,23 @@ Prism.languages.webmanifest = Prism.languages.json;
|
|
|
1710
1726
|
},
|
|
1711
1727
|
url: {
|
|
1712
1728
|
// https://drafts.csswg.org/css-values-3/#urls
|
|
1713
|
-
pattern: RegExp("\\burl\\((?:" +
|
|
1729
|
+
pattern: RegExp("\\burl\\((?:" + u.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"),
|
|
1714
1730
|
greedy: !0,
|
|
1715
1731
|
inside: {
|
|
1716
1732
|
function: /^url/i,
|
|
1717
1733
|
punctuation: /^\(|\)$/,
|
|
1718
1734
|
string: {
|
|
1719
|
-
pattern: RegExp("^" +
|
|
1735
|
+
pattern: RegExp("^" + u.source + "$"),
|
|
1720
1736
|
alias: "url"
|
|
1721
1737
|
}
|
|
1722
1738
|
}
|
|
1723
1739
|
},
|
|
1724
1740
|
selector: {
|
|
1725
|
-
pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` +
|
|
1741
|
+
pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + u.source + ")*(?=\\s*\\{)"),
|
|
1726
1742
|
lookbehind: !0
|
|
1727
1743
|
},
|
|
1728
1744
|
string: {
|
|
1729
|
-
pattern:
|
|
1745
|
+
pattern: u,
|
|
1730
1746
|
greedy: !0
|
|
1731
1747
|
},
|
|
1732
1748
|
property: {
|
|
@@ -1739,9 +1755,9 @@ Prism.languages.webmanifest = Prism.languages.json;
|
|
|
1739
1755
|
lookbehind: !0
|
|
1740
1756
|
},
|
|
1741
1757
|
punctuation: /[(){};:,]/
|
|
1742
|
-
},
|
|
1743
|
-
var
|
|
1744
|
-
|
|
1758
|
+
}, n.languages.css.atrule.inside.rest = n.languages.css;
|
|
1759
|
+
var e = n.languages.markup;
|
|
1760
|
+
e && (e.tag.addInlined("style", "css"), e.tag.addAttribute("style", "css"));
|
|
1745
1761
|
})(Prism);
|
|
1746
1762
|
Prism.languages.markup = {
|
|
1747
1763
|
comment: {
|
|
@@ -1823,8 +1839,8 @@ Prism.languages.markup = {
|
|
|
1823
1839
|
};
|
|
1824
1840
|
Prism.languages.markup.tag.inside["attr-value"].inside.entity = Prism.languages.markup.entity;
|
|
1825
1841
|
Prism.languages.markup.doctype.inside["internal-subset"].inside = Prism.languages.markup;
|
|
1826
|
-
Prism.hooks.add("wrap", function(
|
|
1827
|
-
|
|
1842
|
+
Prism.hooks.add("wrap", function(n) {
|
|
1843
|
+
n.type === "entity" && (n.attributes.title = n.content.replace(/&/, "&"));
|
|
1828
1844
|
});
|
|
1829
1845
|
Object.defineProperty(Prism.languages.markup.tag, "addInlined", {
|
|
1830
1846
|
/**
|
|
@@ -1838,32 +1854,32 @@ Object.defineProperty(Prism.languages.markup.tag, "addInlined", {
|
|
|
1838
1854
|
* @example
|
|
1839
1855
|
* addInlined('style', 'css');
|
|
1840
1856
|
*/
|
|
1841
|
-
value: function(
|
|
1842
|
-
var
|
|
1843
|
-
|
|
1857
|
+
value: function(u, e) {
|
|
1858
|
+
var l = {};
|
|
1859
|
+
l["language-" + e] = {
|
|
1844
1860
|
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
|
1845
1861
|
lookbehind: !0,
|
|
1846
|
-
inside: Prism.languages[
|
|
1847
|
-
},
|
|
1848
|
-
var
|
|
1862
|
+
inside: Prism.languages[e]
|
|
1863
|
+
}, l.cdata = /^<!\[CDATA\[|\]\]>$/i;
|
|
1864
|
+
var c = {
|
|
1849
1865
|
"included-cdata": {
|
|
1850
1866
|
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
1851
|
-
inside:
|
|
1867
|
+
inside: l
|
|
1852
1868
|
}
|
|
1853
1869
|
};
|
|
1854
|
-
|
|
1870
|
+
c["language-" + e] = {
|
|
1855
1871
|
pattern: /[\s\S]+/,
|
|
1856
|
-
inside: Prism.languages[
|
|
1872
|
+
inside: Prism.languages[e]
|
|
1857
1873
|
};
|
|
1858
|
-
var
|
|
1859
|
-
|
|
1874
|
+
var p = {};
|
|
1875
|
+
p[u] = {
|
|
1860
1876
|
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
|
|
1861
|
-
return
|
|
1877
|
+
return u;
|
|
1862
1878
|
}), "i"),
|
|
1863
1879
|
lookbehind: !0,
|
|
1864
1880
|
greedy: !0,
|
|
1865
|
-
inside:
|
|
1866
|
-
}, Prism.languages.insertBefore("markup", "cdata",
|
|
1881
|
+
inside: c
|
|
1882
|
+
}, Prism.languages.insertBefore("markup", "cdata", p);
|
|
1867
1883
|
}
|
|
1868
1884
|
});
|
|
1869
1885
|
Object.defineProperty(Prism.languages.markup.tag, "addAttribute", {
|
|
@@ -1878,10 +1894,10 @@ Object.defineProperty(Prism.languages.markup.tag, "addAttribute", {
|
|
|
1878
1894
|
* @example
|
|
1879
1895
|
* addAttribute('style', 'css');
|
|
1880
1896
|
*/
|
|
1881
|
-
value: function(
|
|
1897
|
+
value: function(n, u) {
|
|
1882
1898
|
Prism.languages.markup.tag.inside["special-attr"].push({
|
|
1883
1899
|
pattern: RegExp(
|
|
1884
|
-
/(^|["'\s])/.source + "(?:" +
|
|
1900
|
+
/(^|["'\s])/.source + "(?:" + n + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
|
|
1885
1901
|
"i"
|
|
1886
1902
|
),
|
|
1887
1903
|
lookbehind: !0,
|
|
@@ -1893,8 +1909,8 @@ Object.defineProperty(Prism.languages.markup.tag, "addAttribute", {
|
|
|
1893
1909
|
value: {
|
|
1894
1910
|
pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
|
1895
1911
|
lookbehind: !0,
|
|
1896
|
-
alias: [
|
|
1897
|
-
inside: Prism.languages[
|
|
1912
|
+
alias: [u, "language-" + u],
|
|
1913
|
+
inside: Prism.languages[u]
|
|
1898
1914
|
},
|
|
1899
1915
|
punctuation: [
|
|
1900
1916
|
{
|
|
@@ -1949,7 +1965,7 @@ Prism.languages.sql = {
|
|
|
1949
1965
|
operator: /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
|
|
1950
1966
|
punctuation: /[;[\]()`,.]/
|
|
1951
1967
|
};
|
|
1952
|
-
const
|
|
1968
|
+
const He = {
|
|
1953
1969
|
js: "javascript",
|
|
1954
1970
|
ts: "typescript",
|
|
1955
1971
|
shell: "bash",
|
|
@@ -1957,24 +1973,101 @@ const De = {
|
|
|
1957
1973
|
html: "markup",
|
|
1958
1974
|
xml: "markup"
|
|
1959
1975
|
};
|
|
1960
|
-
|
|
1976
|
+
Y.setOptions({
|
|
1961
1977
|
breaks: !0,
|
|
1962
1978
|
gfm: !0
|
|
1963
1979
|
});
|
|
1964
|
-
const
|
|
1965
|
-
|
|
1966
|
-
const
|
|
1967
|
-
if (
|
|
1968
|
-
const
|
|
1969
|
-
return `<pre><code class="language-${
|
|
1980
|
+
const he = new Y.Renderer();
|
|
1981
|
+
he.code = ({ text: n, lang: u }) => {
|
|
1982
|
+
const e = u ? He[u] || u : "plaintext", l = ue.languages[e];
|
|
1983
|
+
if (l) {
|
|
1984
|
+
const p = ue.highlight(n, l, e);
|
|
1985
|
+
return `<pre><code class="language-${e}">${p}</code></pre>`;
|
|
1970
1986
|
}
|
|
1971
|
-
return `<pre><code>${
|
|
1987
|
+
return `<pre><code>${n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</code></pre>`;
|
|
1972
1988
|
};
|
|
1973
|
-
|
|
1974
|
-
function
|
|
1975
|
-
return
|
|
1989
|
+
Y.use({ renderer: he });
|
|
1990
|
+
function Et(n) {
|
|
1991
|
+
return Y.parse(n);
|
|
1992
|
+
}
|
|
1993
|
+
function ht(n) {
|
|
1994
|
+
return n < 1024 ? `${n} B` : n < 1024 * 1024 ? `${(n / 1024).toFixed(1)} KB` : `${(n / (1024 * 1024)).toFixed(1)} MB`;
|
|
1995
|
+
}
|
|
1996
|
+
function mt(n) {
|
|
1997
|
+
return Ee.includes(n.type) ? n.size > we ? "File exceeds the 10MB size limit." : null : `File type "${n.type}" is not supported.`;
|
|
1998
|
+
}
|
|
1999
|
+
async function ze({
|
|
2000
|
+
publishableApiKey: n,
|
|
2001
|
+
threadId: u,
|
|
2002
|
+
fileName: e,
|
|
2003
|
+
fileType: l,
|
|
2004
|
+
fileSize: c,
|
|
2005
|
+
baseUrl: p
|
|
2006
|
+
}) {
|
|
2007
|
+
const h = await Q(), i = await fetch(Le(p), {
|
|
2008
|
+
method: "POST",
|
|
2009
|
+
headers: {
|
|
2010
|
+
"Content-Type": "application/json",
|
|
2011
|
+
"X-Api-Key": n,
|
|
2012
|
+
...h ? { Authorization: `Bearer ${h}` } : {}
|
|
2013
|
+
},
|
|
2014
|
+
body: JSON.stringify({ threadId: u, fileName: e, fileType: l, fileSize: c })
|
|
2015
|
+
});
|
|
2016
|
+
if (!i.ok) {
|
|
2017
|
+
const m = await i.json().catch(() => ({}));
|
|
2018
|
+
throw new Error(
|
|
2019
|
+
m.error || `Upload URL request failed: ${i.status}`
|
|
2020
|
+
);
|
|
2021
|
+
}
|
|
2022
|
+
return i.json();
|
|
2023
|
+
}
|
|
2024
|
+
async function Ye(n, u) {
|
|
2025
|
+
const e = await fetch(n, {
|
|
2026
|
+
method: "PUT",
|
|
2027
|
+
headers: { "Content-Type": u.type },
|
|
2028
|
+
body: u
|
|
2029
|
+
});
|
|
2030
|
+
if (!e.ok)
|
|
2031
|
+
throw new Error(`Storage upload failed: ${e.status}`);
|
|
2032
|
+
}
|
|
2033
|
+
async function At({
|
|
2034
|
+
publishableApiKey: n,
|
|
2035
|
+
threadId: u,
|
|
2036
|
+
file: e,
|
|
2037
|
+
baseUrl: l
|
|
2038
|
+
}) {
|
|
2039
|
+
const { uploadUrl: c, storagePath: p } = await ze({
|
|
2040
|
+
publishableApiKey: n,
|
|
2041
|
+
threadId: u,
|
|
2042
|
+
fileName: e.name,
|
|
2043
|
+
fileType: e.type,
|
|
2044
|
+
fileSize: e.size,
|
|
2045
|
+
baseUrl: l
|
|
2046
|
+
});
|
|
2047
|
+
return await Ye(c, e), { fileName: e.name, fileType: e.type, fileSize: e.size, storagePath: p };
|
|
2048
|
+
}
|
|
2049
|
+
async function St({
|
|
2050
|
+
publishableApiKey: n,
|
|
2051
|
+
storagePath: u,
|
|
2052
|
+
baseUrl: e
|
|
2053
|
+
}) {
|
|
2054
|
+
const l = await Q();
|
|
2055
|
+
try {
|
|
2056
|
+
const c = await fetch(Fe(e), {
|
|
2057
|
+
method: "POST",
|
|
2058
|
+
headers: {
|
|
2059
|
+
"Content-Type": "application/json",
|
|
2060
|
+
"X-Api-Key": n,
|
|
2061
|
+
...l ? { Authorization: `Bearer ${l}` } : {}
|
|
2062
|
+
},
|
|
2063
|
+
body: JSON.stringify({ storagePath: u })
|
|
2064
|
+
});
|
|
2065
|
+
return c.ok && (await c.json()).url || null;
|
|
2066
|
+
} catch {
|
|
2067
|
+
return null;
|
|
2068
|
+
}
|
|
1976
2069
|
}
|
|
1977
|
-
const
|
|
2070
|
+
const We = "https://005d25250a41bd0071570b0c0a2b2c4d@o4510467570073600.ingest.us.sentry.io/4510472944156672", Xe = [
|
|
1978
2071
|
"@useknest",
|
|
1979
2072
|
"useknest",
|
|
1980
2073
|
"widget-core",
|
|
@@ -1984,22 +2077,21 @@ const _e = "https://005d25250a41bd0071570b0c0a2b2c4d@o4510467570073600.ingest.us
|
|
|
1984
2077
|
"widget.js",
|
|
1985
2078
|
"knest"
|
|
1986
2079
|
];
|
|
1987
|
-
function
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
return Pe.some((g) => u.includes(g));
|
|
2080
|
+
function je(n) {
|
|
2081
|
+
const u = n.exception?.values?.[0]?.stacktrace?.frames;
|
|
2082
|
+
return !u || u.length === 0 ? !1 : u.some((e) => {
|
|
2083
|
+
const l = e.filename || "";
|
|
2084
|
+
return Xe.some((c) => l.includes(c));
|
|
1993
2085
|
});
|
|
1994
2086
|
}
|
|
1995
|
-
let
|
|
1996
|
-
function
|
|
1997
|
-
|
|
1998
|
-
dsn:
|
|
2087
|
+
let pe = !1;
|
|
2088
|
+
function Tt() {
|
|
2089
|
+
pe || (Z.init({
|
|
2090
|
+
dsn: We,
|
|
1999
2091
|
// Only capture errors, not performance data.
|
|
2000
2092
|
tracesSampleRate: 0,
|
|
2001
2093
|
integrations: [
|
|
2002
|
-
|
|
2094
|
+
Z.breadcrumbsIntegration({
|
|
2003
2095
|
console: !1,
|
|
2004
2096
|
dom: !0,
|
|
2005
2097
|
fetch: !0,
|
|
@@ -2007,47 +2099,140 @@ function Ve() {
|
|
|
2007
2099
|
xhr: !1
|
|
2008
2100
|
})
|
|
2009
2101
|
],
|
|
2010
|
-
//
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
beforeSend(a) {
|
|
2018
|
-
return xe(a) ? a : null;
|
|
2102
|
+
// Filter out errors that don't originate from our widget code, then stamp the
|
|
2103
|
+
// source tag so all events reaching Sentry are identifiable as widget errors.
|
|
2104
|
+
// NOTE: we do NOT use initialScope to set this tag — that would apply it to every
|
|
2105
|
+
// event the SDK captures (including host-page errors via GlobalHandlers/onerror),
|
|
2106
|
+
// which would bypass the isWidgetError check and let customer errors through.
|
|
2107
|
+
beforeSend(n) {
|
|
2108
|
+
return je(n) ? (n.tags = { ...n.tags, source: "knest-widget" }, n) : null;
|
|
2019
2109
|
}
|
|
2020
|
-
}),
|
|
2110
|
+
}), pe = !0);
|
|
2021
2111
|
}
|
|
2022
|
-
function
|
|
2023
|
-
const
|
|
2024
|
-
|
|
2112
|
+
function bt(n, u) {
|
|
2113
|
+
const e = typeof n == "string" ? new Error(n) : n;
|
|
2114
|
+
Z.captureException(e, {
|
|
2025
2115
|
tags: { source: "knest-widget" },
|
|
2026
|
-
extra:
|
|
2116
|
+
extra: u
|
|
2027
2117
|
});
|
|
2028
2118
|
}
|
|
2119
|
+
function It(n, u, e) {
|
|
2120
|
+
const l = xe();
|
|
2121
|
+
if (!l) return () => {
|
|
2122
|
+
};
|
|
2123
|
+
const c = e?.role === "visitor" ? "agent" : "visitor";
|
|
2124
|
+
let p = l.channel(`thread:${n}`).on("broadcast", { event: "new-message" }, (h) => {
|
|
2125
|
+
u(h.payload);
|
|
2126
|
+
});
|
|
2127
|
+
if (e) {
|
|
2128
|
+
const { onPresenceChange: h } = e;
|
|
2129
|
+
p = p.on("presence", { event: "sync" }, () => {
|
|
2130
|
+
try {
|
|
2131
|
+
const i = p.presenceState(), m = Object.values(i).flat().some((b) => b.type === c);
|
|
2132
|
+
h(m);
|
|
2133
|
+
} catch {
|
|
2134
|
+
}
|
|
2135
|
+
});
|
|
2136
|
+
}
|
|
2137
|
+
return p.subscribe((h) => {
|
|
2138
|
+
h === "SUBSCRIBED" && e && p.track({ type: e.role }).catch(() => {
|
|
2139
|
+
});
|
|
2140
|
+
}), () => {
|
|
2141
|
+
e && p.untrack().catch(() => {
|
|
2142
|
+
}), p.unsubscribe();
|
|
2143
|
+
};
|
|
2144
|
+
}
|
|
2145
|
+
const Ke = "knest-widget-chat-", qe = 14400 * 1e3, Ve = 300, U = /* @__PURE__ */ new Map();
|
|
2146
|
+
function z(n) {
|
|
2147
|
+
return Ke + n;
|
|
2148
|
+
}
|
|
2149
|
+
function yt(n) {
|
|
2150
|
+
try {
|
|
2151
|
+
const u = localStorage.getItem(z(n));
|
|
2152
|
+
if (!u) return null;
|
|
2153
|
+
const e = JSON.parse(u);
|
|
2154
|
+
return Date.now() - e.savedAt > qe ? (localStorage.removeItem(z(n)), null) : e;
|
|
2155
|
+
} catch {
|
|
2156
|
+
return null;
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
function Ze(n, u) {
|
|
2160
|
+
try {
|
|
2161
|
+
localStorage.setItem(z(n), JSON.stringify(u));
|
|
2162
|
+
} catch {
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
function Rt(n, u) {
|
|
2166
|
+
const e = U.get(n);
|
|
2167
|
+
e !== void 0 && clearTimeout(e);
|
|
2168
|
+
const l = setTimeout(() => {
|
|
2169
|
+
Ze(n, u), U.delete(n);
|
|
2170
|
+
}, Ve);
|
|
2171
|
+
U.set(n, l);
|
|
2172
|
+
}
|
|
2173
|
+
function Ot(n) {
|
|
2174
|
+
const u = U.get(n);
|
|
2175
|
+
u !== void 0 && (clearTimeout(u), U.delete(n));
|
|
2176
|
+
try {
|
|
2177
|
+
localStorage.removeItem(z(n));
|
|
2178
|
+
} catch {
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
const Nt = 440;
|
|
2182
|
+
function vt() {
|
|
2183
|
+
document.body.style.overflow = "hidden";
|
|
2184
|
+
}
|
|
2185
|
+
function wt() {
|
|
2186
|
+
document.body.style.overflow = "";
|
|
2187
|
+
}
|
|
2029
2188
|
export {
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2189
|
+
it as ACCEPTED_FILE_TYPES_STRING,
|
|
2190
|
+
Ee as ALLOWED_ATTACHMENT_TYPES,
|
|
2191
|
+
ve as ALLOWED_DOCUMENT_TYPES,
|
|
2192
|
+
fe as ALLOWED_IMAGE_TYPES,
|
|
2193
|
+
X as API_PATH,
|
|
2194
|
+
Oe as AUTH_ERROR_MESSAGE,
|
|
2195
|
+
nt as DEFAULT_AVATAR_URL,
|
|
2196
|
+
W as DEFAULT_BASE_URL,
|
|
2197
|
+
at as DEFAULT_BRAND_COLOR,
|
|
2198
|
+
re as DEFAULT_ERROR_MESSAGE,
|
|
2199
|
+
st as DEFAULT_EXAMPLE_QUESTIONS,
|
|
2200
|
+
rt as DEFAULT_WELCOME_MESSAGE,
|
|
2201
|
+
Re as FALLBACK_ERROR_MESSAGE,
|
|
2202
|
+
lt as HUMAN_TAKEOVER_CAPTION,
|
|
2203
|
+
ot as MAX_ATTACHMENTS_PER_MESSAGE,
|
|
2204
|
+
we as MAX_ATTACHMENT_SIZE_BYTES,
|
|
2205
|
+
Nt as MOBILE_BREAKPOINT_PX,
|
|
2206
|
+
dt as PRESENCE_LABEL_DASHBOARD,
|
|
2207
|
+
ct as PRESENCE_LABEL_WIDGET,
|
|
2208
|
+
tt as PUBLIC_SUPABASE_PUBLISHABLE_KEY,
|
|
2209
|
+
et as PUBLIC_SUPABASE_URL,
|
|
2210
|
+
Ne as USAGE_LIMIT_MESSAGE,
|
|
2211
|
+
bt as captureWidgetException,
|
|
2212
|
+
Ot as clearChatState,
|
|
2213
|
+
St as fetchSignedUrl,
|
|
2214
|
+
gt as fetchWidgetConfig,
|
|
2215
|
+
Et as formatContent,
|
|
2216
|
+
ht as formatFileSize,
|
|
2217
|
+
Q as getAccessToken,
|
|
2218
|
+
Fe as getAttachmentSignedUrlEndpoint,
|
|
2219
|
+
Le as getAttachmentUploadUrl,
|
|
2220
|
+
Ie as getChatApiUrl,
|
|
2221
|
+
ye as getConfigApiUrl,
|
|
2222
|
+
xe as getSupabaseClient,
|
|
2223
|
+
pt as initWidgetAuth,
|
|
2224
|
+
Tt as initWidgetSentry,
|
|
2225
|
+
Pe as isAuthenticated,
|
|
2226
|
+
ut as isImageType,
|
|
2227
|
+
yt as loadChatState,
|
|
2228
|
+
vt as lockBodyScroll,
|
|
2229
|
+
ze as requestUploadUrl,
|
|
2230
|
+
Ze as saveChatState,
|
|
2231
|
+
Rt as saveChatStateDebounced,
|
|
2232
|
+
ft as streamChatMessage,
|
|
2233
|
+
It as subscribeToThread,
|
|
2234
|
+
wt as unlockBodyScroll,
|
|
2235
|
+
At as uploadAttachment,
|
|
2236
|
+
Ye as uploadToStorage,
|
|
2237
|
+
mt as validateAttachment
|
|
2053
2238
|
};
|