@ansidev-oss/vitepress-theme-ansidev 1.0.12 → 1.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.
Files changed (40) hide show
  1. package/dist/client/Donation-BBPb8v5p.js +66 -0
  2. package/dist/client/GoogleAnalytics-34XEM7eO.js +25 -0
  3. package/dist/client/Sharing-CpagX9oy.js +185 -0
  4. package/dist/client/Swetrix-k7SUudua.js +624 -0
  5. package/dist/client/components/PostDate.test.d.ts +1 -0
  6. package/dist/client/composables/index.d.ts +1 -0
  7. package/dist/client/composables/lang.d.ts +27 -0
  8. package/dist/client/composables/lang.test.d.ts +1 -0
  9. package/dist/client/index.js +3769 -9
  10. package/dist/client/medium-zoom-DPl0T7qn.js +266 -0
  11. package/dist/client/record-Cgv_fXDH.js +2739 -0
  12. package/dist/client/styles.css +2 -1
  13. package/dist/node/composables.d.mts +7 -17
  14. package/dist/node/composables.mjs +7 -15
  15. package/dist/node/config.d.mts +2 -17
  16. package/dist/node/config.mjs +9 -6
  17. package/package.json +14 -6
  18. package/src/client/components/PostDate.test.ts +73 -0
  19. package/src/client/components/PostDate.vue +18 -8
  20. package/src/client/components/PostItem.vue +1 -1
  21. package/src/client/composables/index.ts +1 -0
  22. package/src/client/composables/lang.test.ts +52 -0
  23. package/src/client/composables/lang.ts +58 -0
  24. package/src/client/index.ts +5 -0
  25. package/src/client/plugins/sharing/index.ts +3 -1
  26. package/src/client/styles/base.css +30 -0
  27. package/src/client/styles/blog.css +352 -0
  28. package/src/client/styles/index.css +3 -30
  29. package/src/vite-env.d.ts +1 -0
  30. package/dist/client/Donation-D9Xn0MPt.js +0 -76
  31. package/dist/client/GoogleAnalytics-Dp3EGn1x.js +0 -29
  32. package/dist/client/Sharing-ZrU7YF-x.js +0 -190
  33. package/dist/client/Swetrix-CM1mbD6X.js +0 -450
  34. package/dist/client/VPAlgoliaSearchBox-C18GEhLm.js +0 -126
  35. package/dist/client/VPCarbonAds-DwoamMao.js +0 -31
  36. package/dist/client/VPLocalSearchBox-DyteUinQ.js +0 -4086
  37. package/dist/client/index-BtT3qA6T.js +0 -12663
  38. package/dist/client/index-CCR5sUM8.js +0 -10688
  39. package/dist/client/index-CkmxezC0.js +0 -7616
  40. package/dist/client/index-DuYWs0vj.js +0 -265
@@ -0,0 +1,624 @@
1
+ import { defineComponent as e, onMounted as t } from "vue";
2
+ // ../../node_modules/.pnpm/swetrix@4.7.0/node_modules/swetrix/dist/esnext/utils.js
3
+ var n = (e) => {
4
+ let t = location.search.match(e);
5
+ return t && t[2] || void 0;
6
+ }, r = /[?&](ref|source|utm_source|gad_source)=([^?&]+)/, i = /[?&](utm_campaign|gad_campaignid)=([^?&]+)/, a = /[?&](utm_medium)=([^?&]+)/, o = /[?&](utm_term)=([^?&]+)/, s = /[?&](utm_content)=([^?&]+)/, c = /[?&](gclid)=([^?&]+)/, l = () => n(c) ? "<gclid>" : void 0, u = () => typeof window < "u", d = () => location?.hostname === "localhost" || location?.hostname === "127.0.0.1" || location?.hostname === "", f = () => navigator?.webdriver, p = () => navigator.languages === void 0 ? navigator.language : navigator.languages[0], m = () => {
7
+ try {
8
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
9
+ } catch {
10
+ return;
11
+ }
12
+ }, h = () => document.referrer || void 0, g = () => {
13
+ if (location.search && location.search.length > 1) return location.search.slice(1);
14
+ let e = location.hash.indexOf("?");
15
+ if (e > -1) {
16
+ let t = location.hash.slice(e + 1);
17
+ if (t) return t;
18
+ }
19
+ }, _ = () => n(r), v = () => n(a) || l(), y = () => n(i), b = () => n(o), x = () => n(s), S = (e, t) => {
20
+ if (t === !0) return e;
21
+ if (!Array.isArray(t) || !e) return "";
22
+ let n = new Set(t), r = e.slice(1).split("&").filter((e) => {
23
+ let t = e.indexOf("="), r = t === -1 ? e : e.slice(0, t);
24
+ try {
25
+ return n.has(decodeURIComponent(r.replace(/\+/g, " ")));
26
+ } catch {
27
+ return n.has(r);
28
+ }
29
+ });
30
+ return r.length ? `?${r.join("&")}` : "";
31
+ }, C = (e, t) => {
32
+ if (t === !0) return e;
33
+ if (!Array.isArray(t) || !e) return "";
34
+ let n = e.slice(1);
35
+ return t.some((e) => e.replace(/^#/, "") === n) ? e : "";
36
+ }, w = (e) => {
37
+ let t = location.pathname || "";
38
+ if (e.hash) {
39
+ let n = location.hash.indexOf("?"), r = n > -1 ? location.hash.substring(0, n) : location.hash;
40
+ t += C(r, e.hash);
41
+ }
42
+ if (e.search) {
43
+ let n = location.hash.indexOf("?"), r = location.search || (n > -1 ? location.hash.substring(n) : "");
44
+ t += S(r, e.search);
45
+ }
46
+ return t;
47
+ }, T = [
48
+ "total",
49
+ "normal",
50
+ "none"
51
+ ], E = { stop() {} }, D = {
52
+ async stop() {},
53
+ async flush() {}
54
+ }, O = "https://api.swetrix.com/log", k = "https://api.swetrix.com", A = "usr_", j = (e) => `${A}${e.trim()}`, M = "replaylibrary.min.js", N = `https://cdn.jsdelivr.net/npm/swetrix@latest/dist/${M}`, P = 5e3, F = 100, I = 524288, L = 5242880, R = 18e5, z = "total", B = {
55
+ mousemove: 50,
56
+ scroll: 150,
57
+ input: "last"
58
+ }, V = {
59
+ script: !0,
60
+ comment: !0,
61
+ headFavicon: !0,
62
+ headWhitespace: !0,
63
+ headMetaDescKeywords: !0,
64
+ headMetaSocial: !0,
65
+ headMetaRobots: !0,
66
+ headMetaHttpEquiv: !0,
67
+ headMetaAuthorship: !0,
68
+ headMetaVerification: !0
69
+ }, H = 2, U = [
70
+ 2e3,
71
+ 5e3,
72
+ 15e3
73
+ ], W = 3, G = [
74
+ "click",
75
+ "keydown",
76
+ "mousedown",
77
+ "mousemove",
78
+ "scroll",
79
+ "touchstart"
80
+ ], K = 3e5, q = (e) => typeof TextEncoder < "u" ? new TextEncoder().encode(e).length : typeof Blob < "u" ? new Blob([e]).size : e.length, J = class {
81
+ constructor(e, t) {
82
+ this.projectID = e, this.options = t, this.pageData = null, this.pageViewsOptions = null, this.errorsOptions = null, this.perfStatsCollected = !1, this.activePage = null, this.errorListenerExists = !1, this.cachedData = null, this.rrwebLoader = null, this.sessionReplayActions = null, this.sessionReplayInitPromise = null, this.identifiedProfileId = null, this.lastIdentifySent = null, this.trackPathChange = this.trackPathChange.bind(this), this.heartbeat = this.heartbeat.bind(this), this.captureError = this.captureError.bind(this), this.getSessionReplayPreloadOption() && this.preloadSessionReplay().catch(() => void 0);
83
+ }
84
+ captureError(e) {
85
+ typeof this.errorsOptions?.sampleRate == "number" && this.errorsOptions.sampleRate >= Math.random() || this.submitError({
86
+ filename: e.filename,
87
+ lineno: e.lineno,
88
+ colno: e.colno,
89
+ name: e.error?.name || "Error",
90
+ message: e.error?.message || e.message,
91
+ stackTrace: e.error?.stack
92
+ }, !0);
93
+ }
94
+ trackErrors(e) {
95
+ return this.errorListenerExists || !this.canTrack() ? E : (this.errorsOptions = e, window.addEventListener("error", this.captureError), this.errorListenerExists = !0, { stop: () => {
96
+ window.removeEventListener("error", this.captureError), this.errorListenerExists = !1;
97
+ } });
98
+ }
99
+ submitError(e, t) {
100
+ let n = { pid: this.projectID }, r = {
101
+ pg: this.activePage || w({
102
+ hash: this.pageViewsOptions?.hash,
103
+ search: this.pageViewsOptions?.search
104
+ }),
105
+ lc: p(),
106
+ tz: m(),
107
+ ...e
108
+ };
109
+ if (t && this.errorsOptions?.callback) {
110
+ let e = this.errorsOptions.callback(r);
111
+ if (e === !1) return;
112
+ e && typeof e == "object" && Object.assign(r, e);
113
+ }
114
+ Object.assign(r, n), this.sendRequest("error", r);
115
+ }
116
+ async track(e) {
117
+ if (!this.canTrack()) return;
118
+ let t = {
119
+ ...e,
120
+ pid: this.projectID,
121
+ pg: this.activePage || w({
122
+ hash: this.pageViewsOptions?.hash,
123
+ search: this.pageViewsOptions?.search
124
+ }),
125
+ lc: p(),
126
+ tz: m(),
127
+ ref: h(),
128
+ so: _(),
129
+ me: v(),
130
+ ca: y(),
131
+ te: b(),
132
+ co: x(),
133
+ qs: g(),
134
+ profileId: e.profileId ?? this.options?.profileId
135
+ };
136
+ await this.sendRequest("custom", t);
137
+ }
138
+ trackPageViews(e) {
139
+ if (!this.canTrack()) return E;
140
+ if (this.pageData) return this.pageData.actions;
141
+ this.pageViewsOptions = e;
142
+ let t;
143
+ e?.unique || (t = setInterval(this.trackPathChange, 2e3)), setTimeout(this.heartbeat, 3e3);
144
+ let n = setInterval(this.heartbeat, 28e3), r = w({
145
+ hash: e?.hash,
146
+ search: e?.search
147
+ });
148
+ return this.pageData = {
149
+ path: r,
150
+ actions: { stop: () => {
151
+ clearInterval(t), clearInterval(n);
152
+ } }
153
+ }, this.trackPage(r, e?.unique), this.pageData.actions;
154
+ }
155
+ getPerformanceStats() {
156
+ if (!this.canTrack() || this.perfStatsCollected || !window.performance?.getEntriesByType) return {};
157
+ let e = window.performance.getEntriesByType("navigation")[0];
158
+ return e ? (this.perfStatsCollected = !0, {
159
+ dns: e.domainLookupEnd - e.domainLookupStart,
160
+ tls: e.secureConnectionStart ? e.requestStart - e.secureConnectionStart : 0,
161
+ conn: e.secureConnectionStart ? e.secureConnectionStart - e.connectStart : e.connectEnd - e.connectStart,
162
+ response: e.responseEnd - e.responseStart,
163
+ render: e.domComplete - e.domContentLoadedEventEnd,
164
+ dom_load: e.domContentLoadedEventEnd - e.responseEnd,
165
+ page_load: e.loadEventStart,
166
+ ttfb: e.responseStart - e.requestStart
167
+ }) : {};
168
+ }
169
+ async getFeatureFlags(e, t) {
170
+ if (!u()) return {};
171
+ let n = e?.profileId ?? this.options?.profileId;
172
+ if (!t && this.cachedData) {
173
+ let e = Date.now();
174
+ if (this.cachedData.profileId === n && e - this.cachedData.timestamp < K) return this.cachedData.flags;
175
+ }
176
+ try {
177
+ return await this.fetchFlagsAndExperiments(e), this.cachedData?.flags || {};
178
+ } catch (e) {
179
+ return console.warn("[Swetrix] Error fetching feature flags:", e), this.cachedData?.flags || {};
180
+ }
181
+ }
182
+ async fetchFlagsAndExperiments(e) {
183
+ let t = this.getApiBase(), n = { pid: this.projectID }, r = e?.profileId ?? this.options?.profileId;
184
+ r && (n.profileId = r);
185
+ let i = await fetch(`${t}/feature-flag/evaluate`, {
186
+ method: "POST",
187
+ headers: { "Content-Type": "application/json" },
188
+ body: JSON.stringify(n)
189
+ });
190
+ if (!i.ok) {
191
+ console.warn("[Swetrix] Failed to fetch feature flags and experiments:", i.status);
192
+ return;
193
+ }
194
+ let a = await i.json(), o = e?.profileId ?? this.options?.profileId;
195
+ this.cachedData = {
196
+ flags: a.flags || {},
197
+ experiments: a.experiments || {},
198
+ timestamp: Date.now(),
199
+ profileId: o
200
+ };
201
+ }
202
+ async getFeatureFlag(e, t, n = !1) {
203
+ return (await this.getFeatureFlags(t))[e] ?? n;
204
+ }
205
+ clearFeatureFlagsCache() {
206
+ this.cachedData = null;
207
+ }
208
+ async identify(e, t) {
209
+ if (typeof e != "string" || !e.trim()) {
210
+ console.error("[Swetrix] identify() expects a non-empty string profileId");
211
+ return;
212
+ }
213
+ let n = e.trim();
214
+ this.options = {
215
+ ...this.options,
216
+ profileId: n
217
+ };
218
+ let r = `${n}:${t ? JSON.stringify(t) : ""}`;
219
+ if (this.canTrack() && this.lastIdentifySent !== r) {
220
+ this.lastIdentifySent = r, this.clearFeatureFlagsCache();
221
+ try {
222
+ let e = this.getApiBase(), r = await fetch(`${e}/log/identify`, {
223
+ method: "POST",
224
+ headers: { "Content-Type": "application/json" },
225
+ body: JSON.stringify({
226
+ pid: this.projectID,
227
+ profileId: n,
228
+ traits: t
229
+ })
230
+ });
231
+ if (!r.ok) return;
232
+ let i = await r.json();
233
+ this.identifiedProfileId = i.profileId || null;
234
+ } catch {}
235
+ }
236
+ }
237
+ async setTraits(e) {
238
+ let t = this.options?.profileId;
239
+ t ? !e || typeof e != "object" || Array.isArray(e) ? console.error("[Swetrix] setTraits() expects an object of traits") : await this.identify(t, e) : console.error("[Swetrix] setTraits() requires the visitor to be identified via identify() first");
240
+ }
241
+ reset() {
242
+ this.options && delete this.options.profileId, this.identifiedProfileId = null, this.lastIdentifySent = null, this.clearFeatureFlagsCache();
243
+ }
244
+ async getExperiments(e, t) {
245
+ if (!u()) return {};
246
+ let n = e?.profileId ?? this.options?.profileId;
247
+ if (!t && this.cachedData) {
248
+ let e = Date.now();
249
+ if (this.cachedData.profileId === n && e - this.cachedData.timestamp < K) return this.cachedData.experiments;
250
+ }
251
+ try {
252
+ return await this.fetchFlagsAndExperiments(e), this.cachedData?.experiments || {};
253
+ } catch (e) {
254
+ return console.warn("[Swetrix] Error fetching experiments:", e), this.cachedData?.experiments || {};
255
+ }
256
+ }
257
+ async getExperiment(e, t, n = null) {
258
+ return (await this.getExperiments(t))[e] ?? n;
259
+ }
260
+ clearExperimentsCache() {
261
+ this.cachedData = null;
262
+ }
263
+ async getProfileId() {
264
+ if (this.identifiedProfileId) return this.identifiedProfileId;
265
+ if (this.options?.profileId) return j(this.options.profileId);
266
+ if (!u()) return null;
267
+ try {
268
+ let e = this.getApiBase(), t = await fetch(`${e}/log/profile-id`, {
269
+ method: "POST",
270
+ headers: { "Content-Type": "application/json" },
271
+ body: JSON.stringify({ pid: this.projectID })
272
+ });
273
+ return t.ok ? (await t.json()).profileId : null;
274
+ } catch {
275
+ return null;
276
+ }
277
+ }
278
+ async getSessionId() {
279
+ if (!u()) return null;
280
+ try {
281
+ let e = this.getApiBase(), t = await fetch(`${e}/log/session-id`, {
282
+ method: "POST",
283
+ headers: { "Content-Type": "application/json" },
284
+ body: JSON.stringify({ pid: this.projectID })
285
+ });
286
+ return t.ok ? (await t.json()).sessionId : null;
287
+ } catch {
288
+ return null;
289
+ }
290
+ }
291
+ async startSessionReplay(e = {}) {
292
+ if (this.sessionReplayActions) return this.sessionReplayActions;
293
+ if (this.sessionReplayInitPromise) return this.sessionReplayInitPromise;
294
+ let t = this.initialiseSessionReplay(e);
295
+ this.sessionReplayInitPromise = t;
296
+ try {
297
+ return await t;
298
+ } finally {
299
+ this.sessionReplayInitPromise === t && (this.sessionReplayInitPromise = null);
300
+ }
301
+ }
302
+ async initialiseSessionReplay(e) {
303
+ if (this.sessionReplayActions) return this.sessionReplayActions;
304
+ if (!this.canTrack()) return D;
305
+ let t = typeof e.maxDurationMs == "number" && e.maxDurationMs > 0 ? e.maxDurationMs : R;
306
+ if (!this.shouldSampleSessionReplay(e.sampleRate)) return D;
307
+ try {
308
+ await this.preloadSessionReplay();
309
+ } catch {
310
+ return D;
311
+ }
312
+ let n = this.getRrwebRecorder();
313
+ if (!n) return D;
314
+ let r = this.getSessionReplayPrivacy(e.privacy), i = this.createReplayId(), a = await this.sendSessionReplayStart(i, r);
315
+ if (!a) return D;
316
+ let o = a.replayId, s = typeof e.flushIntervalMs == "number" && e.flushIntervalMs > 0 ? e.flushIntervalMs : P, c = typeof e.maxEventsPerChunk == "number" && e.maxEventsPerChunk > 0 ? Math.floor(e.maxEventsPerChunk) : F, l = typeof e.maxBytesPerChunk == "number" ? Math.floor(e.maxBytesPerChunk) : NaN, u = l >= 1 ? l : I, d = typeof e.maxBytesPerEvent == "number" ? Math.floor(e.maxBytesPerEvent) : NaN, f = d >= 1 ? d : L, p = typeof e.idleTimeoutMs == "number" && e.idleTimeoutMs > 0 ? e.idleTimeoutMs : null, m = a.nextChunkIndex, h = 0, g = !1, _ = [], v = 0, y = Promise.resolve(), b, x, S = async (e = !1) => {
317
+ if (!_.length) return;
318
+ let t = _;
319
+ _ = [], v = 0;
320
+ let i = m++;
321
+ y = y.catch(() => void 0).then(async () => {
322
+ if (!await this.sendSessionReplayChunk(o, r, i, t, e) && !g && h < W && t.some((e) => e.type === H)) {
323
+ h += 1;
324
+ try {
325
+ n.takeFullSnapshot?.();
326
+ } catch {}
327
+ }
328
+ }), await y;
329
+ }, C = e.rrweb?.emit, w = n(this.getSessionReplayRecordOptions(r, e.rrweb, (e) => {
330
+ try {
331
+ C?.(e);
332
+ } catch {}
333
+ let t = 0;
334
+ try {
335
+ t = q(JSON.stringify(e));
336
+ } catch {
337
+ return;
338
+ }
339
+ t > f || (_.length && v + t > u && S(), _.push(e), v += t, (_.length >= c || v >= u) && S());
340
+ }, !!e.recordIframes, e.maskAllText)), T = setInterval(() => void S(), s), E = () => void S(!0), O = () => {
341
+ document.visibilityState === "hidden" && S(!0);
342
+ }, k = () => {
343
+ x &&= (clearTimeout(x), void 0);
344
+ }, A = async () => {
345
+ g || (g = !0, clearInterval(T), b && clearTimeout(b), k(), window.removeEventListener("pagehide", E), document.removeEventListener("visibilitychange", O), G.forEach((e) => {
346
+ window.removeEventListener(e, j);
347
+ }), w?.(), await S(), this.sessionReplayActions = null, this.sessionReplayInitPromise = null);
348
+ }, j = () => {
349
+ p && !g && (k(), x = setTimeout(() => void A(), p));
350
+ };
351
+ return window.addEventListener("pagehide", E), document.addEventListener("visibilitychange", O), b = setTimeout(() => void A(), t), p && (G.forEach((e) => {
352
+ window.addEventListener(e, j, { passive: !0 });
353
+ }), j()), this.sessionReplayActions = {
354
+ stop: A,
355
+ flush: async () => {
356
+ await S();
357
+ }
358
+ }, this.sessionReplayActions;
359
+ }
360
+ shouldSampleSessionReplay(e) {
361
+ return typeof e == "number" ? e <= 0 ? !1 : e >= 1 || Math.random() < e : !0;
362
+ }
363
+ getSessionReplayPrivacy(e) {
364
+ return T.includes(e) ? e : z;
365
+ }
366
+ getApiBase() {
367
+ return this.options?.apiURL ? this.options.apiURL.replace(/\/log\/?$/, "") : k;
368
+ }
369
+ heartbeat() {
370
+ if (!this.pageViewsOptions?.heartbeatOnBackground && document.visibilityState === "hidden") return;
371
+ let e = { pid: this.projectID };
372
+ this.options?.profileId && (e.profileId = this.options.profileId), this.sendRequest("hb", e);
373
+ }
374
+ trackPathChange() {
375
+ if (!this.pageData) return;
376
+ let e = w({
377
+ hash: this.pageViewsOptions?.hash,
378
+ search: this.pageViewsOptions?.search
379
+ }), { path: t } = this.pageData;
380
+ t !== e && this.trackPage(e, !1);
381
+ }
382
+ trackPage(e, t = !1) {
383
+ if (!this.pageData) return;
384
+ this.pageData.path = e;
385
+ let n = this.getPerformanceStats();
386
+ this.activePage = e, this.submitPageView({ pg: e }, t, n, !0);
387
+ }
388
+ submitPageView(e, t, n, r) {
389
+ let i = {
390
+ pid: this.projectID,
391
+ perf: n,
392
+ unique: t
393
+ }, a = {
394
+ title: u() ? document.title : void 0,
395
+ lc: p(),
396
+ tz: m(),
397
+ ref: h(),
398
+ so: _(),
399
+ me: v(),
400
+ ca: y(),
401
+ te: b(),
402
+ co: x(),
403
+ qs: g(),
404
+ profileId: this.options?.profileId,
405
+ ...e
406
+ };
407
+ if (r && this.pageViewsOptions?.callback) {
408
+ let e = this.pageViewsOptions.callback(a);
409
+ if (e === !1) return;
410
+ e && typeof e == "object" && Object.assign(a, e);
411
+ }
412
+ r && (this.activePage = a.pg || null), typeof a.title == "string" && (a.title = a.title.slice(0, 2048)), Object.assign(a, i), this.sendRequest("", a);
413
+ }
414
+ canTrack() {
415
+ return !(this.options?.disabled || !u() || this.options?.respectDNT && window.navigator?.doNotTrack === "1" || !this.options?.devMode && d() || f());
416
+ }
417
+ getSessionReplayUrl() {
418
+ let e = this.getSessionReplayPreloadOption();
419
+ return e && typeof e == "object" && e.rrwebUrl ? e.rrwebUrl : this.getDefaultSessionReplayUrl();
420
+ }
421
+ getSessionReplayPreloadOption() {
422
+ return this.options?.preloadSessionReplay;
423
+ }
424
+ getDefaultSessionReplayUrl() {
425
+ if (!u()) return N;
426
+ let e = this.getTrackerScript();
427
+ if (e?.src) {
428
+ let { hostname: t, pathname: n } = new URL(e.src);
429
+ return t === "swetrix.org" && /^\/swetrix(\.min)?\.js$/i.test(n) ? N : new URL(M, e.src).toString();
430
+ }
431
+ return N;
432
+ }
433
+ getTrackerScript() {
434
+ return Array.from(document.scripts).find((e) => {
435
+ if (!e.src) return !1;
436
+ try {
437
+ let { pathname: t } = new URL(e.src);
438
+ return /(^|\/)swetrix(\.min)?\.js$/i.test(t);
439
+ } catch {
440
+ return !1;
441
+ }
442
+ });
443
+ }
444
+ getRrwebRecorder() {
445
+ if (!u()) return;
446
+ if (typeof window.rrweb?.record == "function") return window.rrweb.record;
447
+ let e = window.rrwebRecord;
448
+ if (typeof e == "function") return e;
449
+ if (e && typeof e.record == "function") return e.record;
450
+ }
451
+ preloadSessionReplay() {
452
+ if (!u() || this.getRrwebRecorder()) return Promise.resolve();
453
+ if (this.rrwebLoader) return this.rrwebLoader;
454
+ if (window.__SWETRIX_RRWEB_LOADING__) return this.rrwebLoader = window.__SWETRIX_RRWEB_LOADING__, this.rrwebLoader.catch(() => {
455
+ window.__SWETRIX_RRWEB_LOADING__ === this.rrwebLoader && delete window.__SWETRIX_RRWEB_LOADING__, this.rrwebLoader = null;
456
+ }), this.rrwebLoader;
457
+ this.rrwebLoader = this.loadSessionReplayRecorder(), window.__SWETRIX_RRWEB_LOADING__ = this.rrwebLoader;
458
+ let e = this.rrwebLoader;
459
+ return e.catch(() => {
460
+ window.__SWETRIX_RRWEB_LOADING__ === e && delete window.__SWETRIX_RRWEB_LOADING__, this.rrwebLoader === e && (this.rrwebLoader = null);
461
+ }), this.rrwebLoader;
462
+ }
463
+ async loadSessionReplayRecorder() {
464
+ let e = this.getSessionReplayPreloadOption();
465
+ e && typeof e == "object" && e.rrwebUrl || this.getTrackerScript() ? await this.loadSessionReplayScript(this.getSessionReplayUrl()) : await this.loadSessionReplayPackage() || await this.loadSessionReplayScript(this.getDefaultSessionReplayUrl());
466
+ }
467
+ async loadSessionReplayPackage() {
468
+ try {
469
+ let e = await import("./record-Cgv_fXDH.js"), t = e.record || e.default?.record;
470
+ return typeof t == "function" && (window.rrwebRecord = { record: t }, !0);
471
+ } catch {
472
+ return !1;
473
+ }
474
+ }
475
+ loadSessionReplayScript(e) {
476
+ return new Promise((t, n) => {
477
+ let r = document.createElement("script");
478
+ r.async = !0, r.src = e, r.crossOrigin = "anonymous", r.onload = () => t(), r.onerror = () => n(/* @__PURE__ */ Error("Failed to load rrweb")), document.head.appendChild(r);
479
+ });
480
+ }
481
+ getSessionReplayRecordOptions(e, t, n, r, i) {
482
+ let a = t && Object.prototype.hasOwnProperty.call(t, "sampling"), o = t && Object.prototype.hasOwnProperty.call(t, "slimDOMOptions"), s = typeof t?.sampling == "object" && t.sampling !== null ? {
483
+ ...B,
484
+ ...t.sampling
485
+ } : a ? t?.sampling : B, c = typeof t?.slimDOMOptions == "object" && t.slimDOMOptions !== null ? {
486
+ ...V,
487
+ ...t.slimDOMOptions
488
+ } : o ? t?.slimDOMOptions : V, l = {
489
+ recordCanvas: !1,
490
+ recordCrossOriginIframes: !1,
491
+ collectFonts: !1,
492
+ inlineImages: !1,
493
+ ...t,
494
+ sampling: s,
495
+ slimDOMOptions: c,
496
+ emit: n
497
+ }, u = typeof l.maskInputOptions == "object" && l.maskInputOptions !== null ? l.maskInputOptions : {}, d = this.getSessionReplayPrivacy(e), f = r ? void 0 : "iframe", p = (typeof i == "boolean" ? i : d === "total") ? { maskTextSelector: "*" } : {};
498
+ return d === "total" ? {
499
+ ...l,
500
+ ...p,
501
+ maskAllInputs: !0,
502
+ blockSelector: this.mergeSelectors(this.mergeSelectors(l.blockSelector, f), "img, picture, video, audio, canvas, svg"),
503
+ recordCanvas: !1,
504
+ inlineImages: !1,
505
+ emit: n
506
+ } : d === "normal" ? {
507
+ ...l,
508
+ ...p,
509
+ maskAllInputs: !0,
510
+ blockSelector: this.mergeSelectors(l.blockSelector, f),
511
+ emit: n
512
+ } : {
513
+ ...l,
514
+ ...p,
515
+ blockSelector: this.mergeSelectors(l.blockSelector, f),
516
+ maskInputOptions: {
517
+ ...u,
518
+ password: !0
519
+ },
520
+ emit: n
521
+ };
522
+ }
523
+ mergeSelectors(e, t) {
524
+ return t ? typeof e == "string" && e.trim() ? `${e}, ${t}` : t : typeof e == "string" ? e : void 0;
525
+ }
526
+ createReplayId() {
527
+ return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
528
+ }
529
+ async sendSessionReplayStart(e, t) {
530
+ try {
531
+ let n = this.getApiBase(), r = await fetch(`${n}/log/session-replay/start`, {
532
+ method: "POST",
533
+ headers: { "Content-Type": "application/json" },
534
+ body: JSON.stringify({
535
+ pid: this.projectID,
536
+ replayId: e,
537
+ privacy: t,
538
+ pg: this.activePage || w({
539
+ hash: this.pageViewsOptions?.hash,
540
+ search: this.pageViewsOptions?.search
541
+ }),
542
+ lc: p(),
543
+ tz: m(),
544
+ profileId: this.options?.profileId
545
+ })
546
+ });
547
+ if (!r.ok) return null;
548
+ try {
549
+ let t = await r.json();
550
+ return {
551
+ replayId: typeof t.replayId == "string" && t.replayId ? t.replayId : e,
552
+ nextChunkIndex: typeof t.nextChunkIndex == "number" && Number.isFinite(t.nextChunkIndex) && t.nextChunkIndex >= 0 ? Math.floor(t.nextChunkIndex) : 0
553
+ };
554
+ } catch {
555
+ return {
556
+ replayId: e,
557
+ nextChunkIndex: 0
558
+ };
559
+ }
560
+ } catch {
561
+ return null;
562
+ }
563
+ }
564
+ async sendSessionReplayChunk(e, t, n, r, i) {
565
+ let a = `${this.getApiBase()}/log/session-replay/chunk`, o = JSON.stringify({
566
+ pid: this.projectID,
567
+ replayId: e,
568
+ privacy: t,
569
+ chunkIndex: n,
570
+ events: r
571
+ });
572
+ if (i && typeof navigator.sendBeacon == "function" && navigator.sendBeacon(a, new Blob([o], { type: "application/json" }))) return !0;
573
+ let s = i ? 1 : U.length + 1;
574
+ for (let e = 0; e < s; e++) {
575
+ e > 0 && await new Promise((t) => setTimeout(t, U[e - 1]));
576
+ try {
577
+ let e = await fetch(a, {
578
+ method: "POST",
579
+ headers: { "Content-Type": "application/json" },
580
+ keepalive: i && o.length < 6e4,
581
+ body: o
582
+ });
583
+ if (e.ok) return !0;
584
+ if (e.status < 500 && e.status !== 408 && e.status !== 429) return !1;
585
+ } catch {}
586
+ }
587
+ return !1;
588
+ }
589
+ async sendRequest(e, t) {
590
+ let n = this.options?.apiURL || O, r = JSON.stringify(t);
591
+ await fetch(`${n}/${e}`, {
592
+ method: "POST",
593
+ headers: { "Content-Type": "application/json" },
594
+ keepalive: r.length < 6e4,
595
+ body: r
596
+ });
597
+ }
598
+ }, Y = null;
599
+ function X(e, t) {
600
+ return Y ||= new J(e, t), Y;
601
+ }
602
+ function Z(e) {
603
+ return new Promise((t) => {
604
+ Y ? typeof document > "u" || document.readyState === "complete" ? t(Y.trackPageViews(e)) : window.addEventListener("load", () => {
605
+ t(Y.trackPageViews(e));
606
+ }) : t(E);
607
+ });
608
+ }
609
+ function Q(e) {
610
+ return Y ? Y.trackErrors(e) : E;
611
+ }
612
+ // src/client/plugins/swetrix/components/Swetrix.vue
613
+ var $ = /* @__PURE__ */ e({
614
+ __name: "Swetrix",
615
+ props: { swetrix: {} },
616
+ setup(e) {
617
+ let n = e.swetrix, r = !1;
618
+ function i() {
619
+ typeof window < "u" && (r || (r = !0, X(n.id, n.options), Z(), Q()));
620
+ }
621
+ return n?.id && t(i), (e, t) => null;
622
+ }
623
+ });
624
+ export { $ as default };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  export * from '../../shared/composables';
2
2
  export * from './date';
3
+ export * from './lang';
3
4
  export * from './project';
4
5
  export * from './rank';
@@ -0,0 +1,27 @@
1
+ import { type ComputedRef } from 'vue';
2
+ import type { Locale } from 'vue-i18n';
3
+ /**
4
+ * Resolved language of the current page: `frontmatter.lang`, falling back to the site lang.
5
+ */
6
+ export declare const usePageLang: () => ComputedRef<string>;
7
+ /**
8
+ * Keeps `<html lang>` in sync with the resolved page lang.
9
+ * VitePress resets it to the site lang on mount, so re-apply it after mount and on navigation.
10
+ */
11
+ export declare const useHtmlLang: () => void;
12
+ /**
13
+ * Picks the available locale matching `lang` exactly or by base language (`vi-VN` -> `vi`).
14
+ */
15
+ export declare const matchLocale: (lang: string, availableLocales: readonly Locale[]) => Locale | undefined;
16
+ /**
17
+ * Syncs the vue-i18n locale with the resolved page lang, synchronously so SSR renders the right strings.
18
+ * A manual `LocaleSwitcher` choice lasts until the page lang changes.
19
+ */
20
+ export declare const usePageLocale: (i18n: {
21
+ global: {
22
+ locale: {
23
+ value: Locale;
24
+ };
25
+ availableLocales: Locale[];
26
+ };
27
+ }) => void;
@@ -0,0 +1 @@
1
+ export {};