@roudanio/awesome-comment 0.10.7 → 0.10.9
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/awesome-comment.js +550 -553
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/awesome-comment.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { i as
|
|
2
|
-
import { d as
|
|
3
|
-
import { E as
|
|
4
|
-
import { u as U, c as
|
|
5
|
-
import { o as
|
|
6
|
-
import { T as
|
|
7
|
-
import { d as
|
|
8
|
-
const
|
|
9
|
-
de:
|
|
10
|
-
en:
|
|
11
|
-
es:
|
|
12
|
-
fr:
|
|
13
|
-
id:
|
|
14
|
-
it:
|
|
15
|
-
ja:
|
|
16
|
-
ko:
|
|
17
|
-
pt:
|
|
18
|
-
th:
|
|
19
|
-
zh:
|
|
20
|
-
cn:
|
|
1
|
+
import { i as T, r as I, c as J, w as K, d as D, o as ne, q as me, v, x as le, y as w, z as Pe, A, B as m, C as Be, D as we, E as C, G as pe, F as P, H as z, I as f, J as B, f as j, K as je, L as De, M as Ue, N as Te, O as Fe } from "./vendor-vue-BTtW1k2s.js";
|
|
2
|
+
import { d as Le, c as Ke } from "./vendor-pinia-Dzo8X_0B.js";
|
|
3
|
+
import { E as ze, G as Ne } from "./vendor-auth0-DkqbqvnH.js";
|
|
4
|
+
import { u as U, c as Ve } from "./vendor-i18n-B4UB934p.js";
|
|
5
|
+
import { o as Ge } from "./vendor-lodash-CKuyBgAy.js";
|
|
6
|
+
import { T as He, a as Je, R as We, B as Ye } from "./vendor-lucide-Cl8oS5sQ.js";
|
|
7
|
+
import { d as qe } from "./vendor-marked-B6IoMkOX.js";
|
|
8
|
+
const Ze = { admin: "Admin", anonymous: "Anonym", approve_hint: "Wir werden Ihren Kommentar innerhalb von 24 Stunden beantworten, ohne Ihre E-Mail zu spammen. Schauen Sie bitte bald wieder vorbei. :)", discussion: "Diskussion", edit: "Bearbeiten", load_more: "Mehr laden", login: "Anmelden", logout: "Abmelden", placeholder: "Schreiben Sie ein Kommentar...", post_comment: "Kommentar absenden", post_reply: "Antwort absenden", reply: "Antwort", reply_to: "Antwort auf", save_editing: "Speichern", ui_texts: ["Seien Sie der Erste, der die Diskussion beginnt!", "Beteiligen Sie sich an der Konversation (#)", "Laden...", "Kommentare laden"], your_comment: "Dein Kommentar" }, Xe = { admin: "Admin", anonymous: "Anonymous", approve_hint: "We’ll reply to your comment within 24 hours without spamming your email, so please check back soon :)", discussion: "Discussion", edit: "Edit", load_more: "Load More", login: "LOGIN", login_or_verify: "Please log in or complete the verification to post.", logout: "Logout", placeholder: "Write a comment...", post_comment: "POST COMMENT", post_reply: "POST REPLY", reply: "Reply", reply_to: "reply to", save_editing: "Save", ui_texts: ["Be the first to start the discussion!", "Join the Conversation (#)", "Loading...", "Load Comments"], your_comment: "Your comment" }, Qe = { admin: "Administrador", anonymous: "Anónimo", approve_hint: "los comentarios son normalmente aprobados dentro de 24 horas", discussion: "Discusión", edit: "Editar", load_more: "Cargar Más", login: "INICIAR SESIÓN", logout: "Cerrar Sesión", placeholder: "Escribe un comentario...", post_comment: "PUBLICAR COMENTARIO", post_reply: "PUBLICAR RESPUESTA", reply: "Responder", reply_to: "Responder a", save_editing: "Guardar", ui_texts: ["¡Sé el primero en iniciar la discusión!", "Únete a la Conversación (#)", "Cargando...", "Cargar Comentarios"], your_comment: "Tu comentario" }, et = { admin: "Admin", anonymous: "Anonyme", approve_hint: "Nous répondrons à votre commentaire dans les 24 heures sans vous spammer par e-mail, alors revenez bientôt :)", discussion: "Discussion", edit: "Modifier", load_more: "Charger plus", login: "CONNEXION", logout: "Déconnexion", placeholder: "Écrivez un commentaire...", post_comment: "POSTER UN COMMENTAIRE", post_reply: "POSTER UNE RÉPONSE", reply: "Répondre", reply_to: "répondre à", save_editing: "Enregistrer", ui_texts: ["Soyez le premier à lancer la discussion !", "Rejoignez la conversation (#)", "Chargement...", "Charger les commentaires"], your_comment: "Votre commentaire" }, tt = { admin: "Admin", anonymous: "Anonim", approve_hint: "komentar biasanya disetujui dalam waktu 24 jam", discussion: "Diskusi", edit: "Edit", load_more: "Muat Lebih Banyak", login: "MASUK", logout: "Keluar", placeholder: "Tulis komentar...", post_comment: "KIRIM KOMENTAR", post_reply: "KIRIM BALASAN", reply: "Balas", reply_to: "balas ke", save_editing: "Simpan", your_comment: "Komentar Anda" }, nt = { admin: "Amministratore", anonymous: "Anonimo", approve_hint: "i commenti vengono normalmente approvati entro 24 ore", discussion: "Discussione", edit: "Modifica", load_more: "Carica Altri", login: "ACCEDI", logout: "Esci", placeholder: "Scrivi un commento...", post_comment: "INVIA COMMENTO", post_reply: "INVIA RISPOSTA", reply: "Risposta", reply_to: "rispondi a", save_editing: "Salva", your_comment: "Il tuo commento" }, ot = { admin: "管理者", anonymous: "匿名", approve_hint: "コメントは通常24時間以内に承認されます", discussion: "ディスカッション", edit: "編集", load_more: "もっと読み込む", login: "ログイン", logout: "ログアウト", placeholder: "コメントを書く...", post_comment: "コメントを投稿", post_reply: "返信を投稿", reply: "返信", reply_to: "返信先", save_editing: "保存", your_comment: "あなたのコメント" }, st = { admin: "관리자", anonymous: "익명", approve_hint: "댓글은 보통 24시간 내에 승인됩니다", discussion: "토론", edit: "편집", load_more: "더 보기", login: "로그인", logout: "로그아웃", placeholder: "댓글을 입력하세요...", post_comment: "댓글 게시", post_reply: "답글 게시", reply: "답장", reply_to: "답장 대상", save_editing: "저장", your_comment: "당신의 댓글" }, at = { admin: "Administrador", anonymous: "Anônimo", approve_hint: "os comentários são normalmente aprovados dentro de 24 horas", discussion: "Discussão", edit: "Editar", load_more: "Carregar Mais", login: "ENTRAR", logout: "Sair", placeholder: "Escreva um comentário...", post_comment: "PUBLICAR COMENTÁRIO", post_reply: "PUBLICAR RESPOSTA", reply: "Responder", reply_to: "responder a", save_editing: "Salvar", your_comment: "Seu comentário" }, rt = { admin: "แอดมิน", anonymous: "นิรนาม", approve_hint: "โดยปกติความคิดเห็นจะได้รับการอนุมัติภายใน 24 ชั่วโมง", discussion: "การอภิปราย", edit: "แก้ไข", load_more: "โหลดเพิ่ม", login: "ลงชื่อเข้าใช้", logout: "ลงชื่อออก", placeholder: "เขียนความคิดเห็น...", post_comment: "โพสต์ความคิดเห็น", post_reply: "โพสต์การตอบกลับ", reply: "ตอบกลับ", reply_to: "ตอบกลับถึง", save_editing: "บันทึก", ui_texts: ["เป็นคนแรกที่เริ่มการอภิปราย", "เข้าร่วมการสนทนา (#)", "กำลังโหลด...", "โหลดความคิดเห็น"], your_comment: "ความคิดเห็นของคุณ" }, it = { admin: "管理員", anonymous: "匿名", approve_hint: "評論通常在24小時內獲得批準,並且每壹條評論都會獲得回復", discussion: "討論", edit: "修改", load_more: "加載更多", login: "登錄", login_or_verify: "請登錄或完成驗證碼後再發表評論。", logout: "登出", placeholder: "寫評論...", post_comment: "發表評論", post_reply: "發表回複", reply: "回複", reply_to: "回複給", save_editing: "保存", your_comment: "您的評論" }, ct = { admin: "管理员", anonymous: "匿名", approve_hint: "评论通常在24小时内公开(我们也会回复您)", discussion: "讨论", edit: "编辑", load_more: "加载更多", login: "登录", login_or_verify: "请登录或完成验证码后再发表评论。", logout: "登出", placeholder: "写评论...", post_comment: "发表评论", post_reply: "发表回复", reply: "回复", reply_to: "回复给", save_editing: "保存", your_comment: "您的评论" }, ke = {
|
|
9
|
+
de: Ze,
|
|
10
|
+
en: Xe,
|
|
11
|
+
es: Qe,
|
|
12
|
+
fr: et,
|
|
13
|
+
id: tt,
|
|
14
|
+
it: nt,
|
|
15
|
+
ja: ot,
|
|
16
|
+
ko: st,
|
|
17
|
+
pt: at,
|
|
18
|
+
th: rt,
|
|
19
|
+
zh: it,
|
|
20
|
+
cn: ct
|
|
21
21
|
};
|
|
22
|
-
function
|
|
22
|
+
function lt() {
|
|
23
23
|
return !!navigator.userAgent.match(/Macintosh/);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
return (
|
|
25
|
+
function ut(e, s) {
|
|
26
|
+
return (lt() ? e.metaKey : e.ctrlKey) && e.key === s;
|
|
27
27
|
}
|
|
28
|
-
const
|
|
28
|
+
const dt = {
|
|
29
29
|
maxConsecutivePunctuation: 5,
|
|
30
30
|
maxConsecutiveSpaces: 3,
|
|
31
31
|
maxConsecutiveNewlines: 3,
|
|
@@ -35,21 +35,21 @@ const ut = {
|
|
|
35
35
|
allowedPunctuation: [],
|
|
36
36
|
blockPatterns: []
|
|
37
37
|
};
|
|
38
|
-
function
|
|
39
|
-
const t = { ...
|
|
38
|
+
function mt(e, s = {}) {
|
|
39
|
+
const t = { ...dt, ...s }, n = [];
|
|
40
40
|
if (!e || typeof e != "string")
|
|
41
41
|
return { valid: !1, errors: ["Content is required"] };
|
|
42
42
|
const i = e.trim();
|
|
43
43
|
i.length < t.minLength && n.push(`Content must be at least ${t.minLength} characters`), i.length > t.maxLength && n.push(`Content must not exceed ${t.maxLength} characters`);
|
|
44
|
-
const d =
|
|
44
|
+
const d = pt(i, t.maxConsecutivePunctuation);
|
|
45
45
|
d.valid || n.push(...d.errors), /^\w{35,}$/.test(i) && n.push("Content contains too many consecutive letters");
|
|
46
|
-
const
|
|
47
|
-
u.valid || n.push(...u.errors);
|
|
48
|
-
const l = ft(i, t.maxConsecutiveNewlines);
|
|
46
|
+
const l = ft(i, t.maxConsecutiveSpaces);
|
|
49
47
|
l.valid || n.push(...l.errors);
|
|
50
|
-
const
|
|
48
|
+
const c = ht(i, t.maxConsecutiveNewlines);
|
|
49
|
+
c.valid || n.push(...c.errors);
|
|
50
|
+
const o = vt(i, t.minWords);
|
|
51
51
|
if (o.valid || n.push(...o.errors), t.blockPatterns.length > 0) {
|
|
52
|
-
const r =
|
|
52
|
+
const r = gt(i, t.blockPatterns);
|
|
53
53
|
r.valid || n.push(...r.errors);
|
|
54
54
|
}
|
|
55
55
|
return {
|
|
@@ -57,11 +57,11 @@ function dt(e, s = {}) {
|
|
|
57
57
|
errors: n
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function pt(e, s) {
|
|
61
61
|
const t = [], n = ["!", "?", ".", ",", ";", ":", "!", "?", "。", ",", ";", ":", "…", "~", "~"];
|
|
62
|
-
for (const
|
|
63
|
-
const
|
|
64
|
-
o && t.push(`Too many consecutive "${
|
|
62
|
+
for (const l of n) {
|
|
63
|
+
const c = new RegExp(`\\${l}{${s + 1},}`, "g"), o = e.match(c);
|
|
64
|
+
o && t.push(`Too many consecutive "${l}" (max ${s}). Found: ${o[0]}`);
|
|
65
65
|
}
|
|
66
66
|
const i = new RegExp(`[${n.join("")}]{${s + 1},}`, "g"), d = e.match(i);
|
|
67
67
|
return d && t.push(`Too many consecutive punctuation marks (max ${s}). Found: ${d[0]}`), {
|
|
@@ -69,14 +69,14 @@ function mt(e, s) {
|
|
|
69
69
|
errors: t
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function ft(e, s) {
|
|
73
73
|
const t = new RegExp(` {${s + 1},}`, "g");
|
|
74
74
|
return e.match(t) ? {
|
|
75
75
|
valid: !1,
|
|
76
76
|
errors: [`Too many consecutive spaces (max ${s})`]
|
|
77
77
|
} : { valid: !0, errors: [] };
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function ht(e, s) {
|
|
80
80
|
const t = new RegExp(`
|
|
81
81
|
{${s + 1},}`, "g");
|
|
82
82
|
return e.match(t) ? {
|
|
@@ -84,7 +84,7 @@ function ft(e, s) {
|
|
|
84
84
|
errors: [`Too many consecutive line breaks (max ${s})`]
|
|
85
85
|
} : { valid: !0, errors: [] };
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function vt(e, s) {
|
|
88
88
|
const t = e.replace(/[^\p{L}\p{N}\s]/gu, " ").trim(), n = t.match(/[\u4e00-\u9fa5]/g);
|
|
89
89
|
if (n && n.length > t.length * 0.3) {
|
|
90
90
|
if (t.replace(/\s+/g, "").length < s)
|
|
@@ -92,14 +92,14 @@ function ht(e, s) {
|
|
|
92
92
|
valid: !1,
|
|
93
93
|
errors: [`Content must contain at least ${s} characters`]
|
|
94
94
|
};
|
|
95
|
-
} else if (t.split(/\s+/).filter((
|
|
95
|
+
} else if (t.split(/\s+/).filter((l) => l.length > 0).length < s)
|
|
96
96
|
return {
|
|
97
97
|
valid: !1,
|
|
98
98
|
errors: [`Content must contain at least ${s} words`]
|
|
99
99
|
};
|
|
100
100
|
return { valid: !0, errors: [] };
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function gt(e, s) {
|
|
103
103
|
const t = [];
|
|
104
104
|
for (const n of s)
|
|
105
105
|
n.test(e) && t.push(`Content contains blocked pattern: ${n.source}`);
|
|
@@ -108,154 +108,11 @@ function vt(e, s) {
|
|
|
108
108
|
errors: t
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
|
-
var
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
return e < 10 ? `0${e}` : `${e}`;
|
|
115
|
-
}
|
|
116
|
-
function Ne(e) {
|
|
117
|
-
return e = `${e.substring(0, 10)}T${e.substring(11, 19)}Z`, new Date(e);
|
|
118
|
-
}
|
|
119
|
-
function xe(e) {
|
|
120
|
-
const s = e.getFullYear(), t = e.getMonth() + 1, n = e.getDate();
|
|
121
|
-
return `${s}-${ne(t)}-${ne(n)}`;
|
|
122
|
-
}
|
|
123
|
-
function Ae(e) {
|
|
124
|
-
e instanceof Date || (e = Ne(e));
|
|
125
|
-
const s = /* @__PURE__ */ new Date(), t = xe(e);
|
|
126
|
-
if (xe(s) === t) {
|
|
127
|
-
const n = e.getHours(), i = e.getMinutes();
|
|
128
|
-
return `${ne(n)}:${ne(i)}`;
|
|
129
|
-
}
|
|
130
|
-
return t;
|
|
131
|
-
}
|
|
132
|
-
function yt(e) {
|
|
133
|
-
const {
|
|
134
|
-
id: s,
|
|
135
|
-
created_at: t,
|
|
136
|
-
parent_id: n,
|
|
137
|
-
ancestor_id: i,
|
|
138
|
-
post_id: d,
|
|
139
|
-
user_id: u,
|
|
140
|
-
...l
|
|
141
|
-
} = e;
|
|
142
|
-
return {
|
|
143
|
-
...l,
|
|
144
|
-
id: Number(s),
|
|
145
|
-
user_id: u,
|
|
146
|
-
userId: u,
|
|
147
|
-
parentId: Number(n),
|
|
148
|
-
post_id: d,
|
|
149
|
-
postId: d,
|
|
150
|
-
ancestorId: Number(i),
|
|
151
|
-
status: Number(e.status),
|
|
152
|
-
createdAt: Ne(t || l.createdAt || "")
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
const pe = "awesome-comment-comments", Ie = localStorage.getItem(pe), V = Ie ? JSON.parse(Ie) : {}, J = Te("store", () => {
|
|
156
|
-
const e = N("postId"), s = N("siteId"), t = N("comments"), n = N("total"), i = $(!!t?.length), d = $(0), u = $(""), l = $([]), o = $(n || 0), r = N("ApiBaseUrl"), a = $(!1), c = $(!1);
|
|
157
|
-
function k(b) {
|
|
158
|
-
const h = {}, x = [];
|
|
159
|
-
b.forEach((w) => {
|
|
160
|
-
p(Number(w.id));
|
|
161
|
-
const C = yt(w);
|
|
162
|
-
!w.ancestor_id || Number(w.ancestor_id) === 0 ? h[w.id] = C : x.push(C);
|
|
163
|
-
});
|
|
164
|
-
const y = V[e];
|
|
165
|
-
y && (y.createdAt = new Date(y.createdAt), !y.ancestorId || Number(y.ancestorId) === 0 ? h[y.id] = y : x.push(y)), x.forEach((w) => {
|
|
166
|
-
if (w.ancestorId in h) {
|
|
167
|
-
const C = h[w.ancestorId];
|
|
168
|
-
C.children = [w, ...C.children || []];
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
for (const w in h) {
|
|
172
|
-
const C = h[w];
|
|
173
|
-
C.children && (C.children = C.children.sort((F, K) => F.id - K.id));
|
|
174
|
-
}
|
|
175
|
-
return h;
|
|
176
|
-
}
|
|
177
|
-
async function g(b = !1) {
|
|
178
|
-
if (a.value) return;
|
|
179
|
-
u.value = "", a.value = !0;
|
|
180
|
-
let h;
|
|
181
|
-
if (b && t?.length)
|
|
182
|
-
h = k(t);
|
|
183
|
-
else {
|
|
184
|
-
const x = new URLSearchParams();
|
|
185
|
-
x.append("postId", e), s && x.append("siteId", s), x.append("start", d.value.toString());
|
|
186
|
-
const y = await fetch(`${r}/api/comments?${x}`);
|
|
187
|
-
if (!y.ok) {
|
|
188
|
-
u.value = "Load comments failed. " + y.statusText, i.value = !0, a.value = !1;
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
const w = await y.json();
|
|
192
|
-
if (w.code !== 0) {
|
|
193
|
-
u.value = "Load comments failed. " + w.message, i.value = !0, a.value = !1;
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
h = k(w.data || []), o.value = w.meta?.total || w.data?.length || 0;
|
|
197
|
-
}
|
|
198
|
-
c.value = Object.keys(h).length > 20, c.value && delete h[Object.keys(h)[0]], Object.assign(l.value, h), i.value = !0, a.value = !1;
|
|
199
|
-
}
|
|
200
|
-
function _(b, h, x, y = te.Pending, w, C) {
|
|
201
|
-
const { sub: F = "", name: K = "", picture: q = "", email: ae = "", nickname: Z = "" } = x, O = {
|
|
202
|
-
id: b,
|
|
203
|
-
post_id: e,
|
|
204
|
-
postId: e,
|
|
205
|
-
content: h,
|
|
206
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
207
|
-
user: {
|
|
208
|
-
avatar: q,
|
|
209
|
-
email: ae,
|
|
210
|
-
name: Z || K
|
|
211
|
-
},
|
|
212
|
-
user_id: F,
|
|
213
|
-
userId: F,
|
|
214
|
-
status: y,
|
|
215
|
-
isNew: !0
|
|
216
|
-
};
|
|
217
|
-
if (w || C) {
|
|
218
|
-
O.ancestorId = w, O.parentId = C;
|
|
219
|
-
const P = l.value[w];
|
|
220
|
-
if (P.children || (P.children = []), w === C)
|
|
221
|
-
P.children.unshift(O);
|
|
222
|
-
else {
|
|
223
|
-
const re = P.children.findIndex((T) => Number(T.id) === C);
|
|
224
|
-
P.children.splice(re + 1, 0, O);
|
|
225
|
-
}
|
|
226
|
-
} else
|
|
227
|
-
O.ancestorId = 0, O.parentId = 0, l.value = { [b]: O, ...l.value };
|
|
228
|
-
o.value++, y !== te.Approved && (V[e] = O, localStorage.setItem(pe, JSON.stringify(V)));
|
|
229
|
-
}
|
|
230
|
-
function p(b) {
|
|
231
|
-
V[e]?.id === b && (delete V[e], localStorage.setItem(pe, JSON.stringify(V)));
|
|
232
|
-
}
|
|
233
|
-
function S(b, h) {
|
|
234
|
-
let x = l.value[b];
|
|
235
|
-
if (!x) {
|
|
236
|
-
for (const y of Object.values(l.value))
|
|
237
|
-
if (y.children && (x = y.children.find((w) => Number(w.id) === b), x))
|
|
238
|
-
break;
|
|
239
|
-
}
|
|
240
|
-
x && Object.assign(x, h);
|
|
241
|
-
}
|
|
242
|
-
return {
|
|
243
|
-
isLoaded: i,
|
|
244
|
-
message: u,
|
|
245
|
-
postId: e,
|
|
246
|
-
comments: l,
|
|
247
|
-
total: o,
|
|
248
|
-
start: d,
|
|
249
|
-
hasMore: c,
|
|
250
|
-
loadingMore: a,
|
|
251
|
-
loadComments: g,
|
|
252
|
-
addComment: _,
|
|
253
|
-
updateComment: S
|
|
254
|
-
};
|
|
255
|
-
});
|
|
256
|
-
var $e = { exports: {} }, Ce;
|
|
111
|
+
var Q = /* @__PURE__ */ ((e) => (e[e.Pending = 0] = "Pending", e[e.Approved = 1] = "Approved", e[e.Rejected = 2] = "Rejected", e[e.UnReplied = 255] = "UnReplied", e[e["Replied to Admin"] = 256] = "Replied to Admin", e))(Q || {});
|
|
112
|
+
const yt = /@([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/;
|
|
113
|
+
var xe = { exports: {} }, Ae;
|
|
257
114
|
function bt() {
|
|
258
|
-
return
|
|
115
|
+
return Ae || (Ae = 1, (function(e) {
|
|
259
116
|
var s = Object.prototype.hasOwnProperty, t = "~";
|
|
260
117
|
function n() {
|
|
261
118
|
}
|
|
@@ -263,40 +120,40 @@ function bt() {
|
|
|
263
120
|
function i(o, r, a) {
|
|
264
121
|
this.fn = o, this.context = r, this.once = a || !1;
|
|
265
122
|
}
|
|
266
|
-
function d(o, r, a,
|
|
123
|
+
function d(o, r, a, u, y) {
|
|
267
124
|
if (typeof a != "function")
|
|
268
125
|
throw new TypeError("The listener must be a function");
|
|
269
|
-
var g = new i(a,
|
|
270
|
-
return o._events[
|
|
126
|
+
var g = new i(a, u || o, y), b = t ? t + r : r;
|
|
127
|
+
return o._events[b] ? o._events[b].fn ? o._events[b] = [o._events[b], g] : o._events[b].push(g) : (o._events[b] = g, o._eventsCount++), o;
|
|
271
128
|
}
|
|
272
|
-
function
|
|
129
|
+
function l(o, r) {
|
|
273
130
|
--o._eventsCount === 0 ? o._events = new n() : delete o._events[r];
|
|
274
131
|
}
|
|
275
|
-
function
|
|
132
|
+
function c() {
|
|
276
133
|
this._events = new n(), this._eventsCount = 0;
|
|
277
134
|
}
|
|
278
|
-
|
|
135
|
+
c.prototype.eventNames = function() {
|
|
279
136
|
var o = [], r, a;
|
|
280
137
|
if (this._eventsCount === 0) return o;
|
|
281
138
|
for (a in r = this._events)
|
|
282
139
|
s.call(r, a) && o.push(t ? a.slice(1) : a);
|
|
283
140
|
return Object.getOwnPropertySymbols ? o.concat(Object.getOwnPropertySymbols(r)) : o;
|
|
284
|
-
},
|
|
141
|
+
}, c.prototype.listeners = function(o) {
|
|
285
142
|
var r = t ? t + o : o, a = this._events[r];
|
|
286
143
|
if (!a) return [];
|
|
287
144
|
if (a.fn) return [a.fn];
|
|
288
|
-
for (var
|
|
289
|
-
g[
|
|
145
|
+
for (var u = 0, y = a.length, g = new Array(y); u < y; u++)
|
|
146
|
+
g[u] = a[u].fn;
|
|
290
147
|
return g;
|
|
291
|
-
},
|
|
148
|
+
}, c.prototype.listenerCount = function(o) {
|
|
292
149
|
var r = t ? t + o : o, a = this._events[r];
|
|
293
150
|
return a ? a.fn ? 1 : a.length : 0;
|
|
294
|
-
},
|
|
295
|
-
var
|
|
296
|
-
if (!this._events[
|
|
297
|
-
var p = this._events[
|
|
151
|
+
}, c.prototype.emit = function(o, r, a, u, y, g) {
|
|
152
|
+
var b = t ? t + o : o;
|
|
153
|
+
if (!this._events[b]) return !1;
|
|
154
|
+
var p = this._events[b], x = arguments.length, _, h;
|
|
298
155
|
if (p.fn) {
|
|
299
|
-
switch (p.once && this.removeListener(o, p.fn, void 0, !0),
|
|
156
|
+
switch (p.once && this.removeListener(o, p.fn, void 0, !0), x) {
|
|
300
157
|
case 1:
|
|
301
158
|
return p.fn.call(p.context), !0;
|
|
302
159
|
case 2:
|
|
@@ -304,19 +161,19 @@ function bt() {
|
|
|
304
161
|
case 3:
|
|
305
162
|
return p.fn.call(p.context, r, a), !0;
|
|
306
163
|
case 4:
|
|
307
|
-
return p.fn.call(p.context, r, a,
|
|
164
|
+
return p.fn.call(p.context, r, a, u), !0;
|
|
308
165
|
case 5:
|
|
309
|
-
return p.fn.call(p.context, r, a,
|
|
166
|
+
return p.fn.call(p.context, r, a, u, y), !0;
|
|
310
167
|
case 6:
|
|
311
|
-
return p.fn.call(p.context, r, a,
|
|
168
|
+
return p.fn.call(p.context, r, a, u, y, g), !0;
|
|
312
169
|
}
|
|
313
|
-
for (h = 1,
|
|
314
|
-
|
|
315
|
-
p.fn.apply(p.context,
|
|
170
|
+
for (h = 1, _ = new Array(x - 1); h < x; h++)
|
|
171
|
+
_[h - 1] = arguments[h];
|
|
172
|
+
p.fn.apply(p.context, _);
|
|
316
173
|
} else {
|
|
317
|
-
var
|
|
318
|
-
for (h = 0; h <
|
|
319
|
-
switch (p[h].once && this.removeListener(o, p[h].fn, void 0, !0),
|
|
174
|
+
var $ = p.length, k;
|
|
175
|
+
for (h = 0; h < $; h++)
|
|
176
|
+
switch (p[h].once && this.removeListener(o, p[h].fn, void 0, !0), x) {
|
|
320
177
|
case 1:
|
|
321
178
|
p[h].fn.call(p[h].context);
|
|
322
179
|
break;
|
|
@@ -327,109 +184,249 @@ function bt() {
|
|
|
327
184
|
p[h].fn.call(p[h].context, r, a);
|
|
328
185
|
break;
|
|
329
186
|
case 4:
|
|
330
|
-
p[h].fn.call(p[h].context, r, a,
|
|
187
|
+
p[h].fn.call(p[h].context, r, a, u);
|
|
331
188
|
break;
|
|
332
189
|
default:
|
|
333
|
-
if (!
|
|
334
|
-
|
|
335
|
-
p[h].fn.apply(p[h].context,
|
|
190
|
+
if (!_) for (k = 1, _ = new Array(x - 1); k < x; k++)
|
|
191
|
+
_[k - 1] = arguments[k];
|
|
192
|
+
p[h].fn.apply(p[h].context, _);
|
|
336
193
|
}
|
|
337
194
|
}
|
|
338
195
|
return !0;
|
|
339
|
-
},
|
|
196
|
+
}, c.prototype.on = function(o, r, a) {
|
|
340
197
|
return d(this, o, r, a, !1);
|
|
341
|
-
},
|
|
198
|
+
}, c.prototype.once = function(o, r, a) {
|
|
342
199
|
return d(this, o, r, a, !0);
|
|
343
|
-
},
|
|
344
|
-
var
|
|
345
|
-
if (!this._events[
|
|
200
|
+
}, c.prototype.removeListener = function(o, r, a, u) {
|
|
201
|
+
var y = t ? t + o : o;
|
|
202
|
+
if (!this._events[y]) return this;
|
|
346
203
|
if (!r)
|
|
347
|
-
return
|
|
348
|
-
var g = this._events[
|
|
204
|
+
return l(this, y), this;
|
|
205
|
+
var g = this._events[y];
|
|
349
206
|
if (g.fn)
|
|
350
|
-
g.fn === r && (!
|
|
207
|
+
g.fn === r && (!u || g.once) && (!a || g.context === a) && l(this, y);
|
|
351
208
|
else {
|
|
352
|
-
for (var
|
|
353
|
-
(g[
|
|
354
|
-
p.length ? this._events[
|
|
209
|
+
for (var b = 0, p = [], x = g.length; b < x; b++)
|
|
210
|
+
(g[b].fn !== r || u && !g[b].once || a && g[b].context !== a) && p.push(g[b]);
|
|
211
|
+
p.length ? this._events[y] = p.length === 1 ? p[0] : p : l(this, y);
|
|
355
212
|
}
|
|
356
213
|
return this;
|
|
357
|
-
},
|
|
214
|
+
}, c.prototype.removeAllListeners = function(o) {
|
|
358
215
|
var r;
|
|
359
|
-
return o ? (r = t ? t + o : o, this._events[r] &&
|
|
360
|
-
},
|
|
361
|
-
})(
|
|
216
|
+
return o ? (r = t ? t + o : o, this._events[r] && l(this, r)) : (this._events = new n(), this._eventsCount = 0), this;
|
|
217
|
+
}, c.prototype.off = c.prototype.removeListener, c.prototype.addListener = c.prototype.on, c.prefixed = t, c.EventEmitter = c, e.exports = c;
|
|
218
|
+
})(xe)), xe.exports;
|
|
362
219
|
}
|
|
363
220
|
bt();
|
|
364
221
|
class _t extends Error {
|
|
365
222
|
}
|
|
366
223
|
_t.prototype.name = "InvalidTokenError";
|
|
367
|
-
var wt = typeof global == "object" && global && global.Object === Object && global, kt = typeof self == "object" && self && self.Object === Object && self, xt = wt || kt || Function("return this")(),
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
var
|
|
371
|
-
const
|
|
372
|
-
const e =
|
|
373
|
-
async function
|
|
224
|
+
var wt = typeof global == "object" && global && global.Object === Object && global, kt = typeof self == "object" && self && self.Object === Object && self, xt = wt || kt || Function("return this")(), ee = xt.Symbol;
|
|
225
|
+
ee && ee.toStringTag;
|
|
226
|
+
ee && ee.toStringTag;
|
|
227
|
+
var Z = /* @__PURE__ */ ((e) => (e.INIT = "init", e.VERIFYING = "verifying", e.VERIFIED = "verified", e.REFRESH = "refresh", e.ERROR = "error", e))(Z || {});
|
|
228
|
+
const oe = Le("auth", () => {
|
|
229
|
+
const e = T("awesomeAuth"), s = !e && ze(), t = I(!1), n = I(!1), i = I(), d = !!e, l = J(() => e ? e.root : "");
|
|
230
|
+
async function c() {
|
|
374
231
|
return e ? e.accessToken : s ? await s.getAccessTokenSilently() : "";
|
|
375
232
|
}
|
|
376
233
|
function o() {
|
|
377
234
|
e ? e.doSignIn() : s && s.loginWithPopup();
|
|
378
235
|
}
|
|
379
|
-
function r(
|
|
380
|
-
e ? e.doSignOut() : s && s.logout(
|
|
236
|
+
function r(u) {
|
|
237
|
+
e ? e.doSignOut() : s && s.logout(u);
|
|
381
238
|
}
|
|
382
|
-
async function a(
|
|
383
|
-
e && await e.renderButton(
|
|
239
|
+
async function a(u, y) {
|
|
240
|
+
e && await e.renderButton(u, y);
|
|
384
241
|
}
|
|
385
|
-
return e ? (e.on(
|
|
386
|
-
n.value =
|
|
387
|
-
}), e.on(
|
|
388
|
-
n.value =
|
|
389
|
-
}), e.on(
|
|
390
|
-
t.value =
|
|
391
|
-
}), n.value = e.isVerifying, t.value = e.isVerified, i.value = e.user) : s && (
|
|
242
|
+
return e ? (e.on(Z.INIT, (u) => {
|
|
243
|
+
n.value = u, u && (t.value = !1);
|
|
244
|
+
}), e.on(Z.VERIFYING, (u) => {
|
|
245
|
+
n.value = u;
|
|
246
|
+
}), e.on(Z.VERIFIED, (u) => {
|
|
247
|
+
t.value = u, i.value = u ? e.user : void 0;
|
|
248
|
+
}), n.value = e.isVerifying, t.value = e.isVerified, i.value = e.user) : s && (K(
|
|
392
249
|
s.isLoading,
|
|
393
|
-
(
|
|
394
|
-
n.value =
|
|
250
|
+
(u) => {
|
|
251
|
+
n.value = u;
|
|
395
252
|
},
|
|
396
253
|
{ immediate: !0 }
|
|
397
|
-
),
|
|
254
|
+
), K(
|
|
398
255
|
s.isAuthenticated,
|
|
399
|
-
(
|
|
400
|
-
t.value =
|
|
256
|
+
(u) => {
|
|
257
|
+
t.value = u;
|
|
401
258
|
},
|
|
402
259
|
{ immediate: !0 }
|
|
403
|
-
),
|
|
260
|
+
), K(
|
|
404
261
|
s.user,
|
|
405
|
-
(
|
|
406
|
-
i.value =
|
|
262
|
+
(u) => {
|
|
263
|
+
i.value = u;
|
|
407
264
|
},
|
|
408
265
|
{ immediate: !0 }
|
|
409
266
|
)), {
|
|
410
267
|
isAuthenticated: t,
|
|
411
268
|
isAwesomeAuth: d,
|
|
412
269
|
isLoading: n,
|
|
413
|
-
authEndpoint:
|
|
270
|
+
authEndpoint: l,
|
|
414
271
|
user: i,
|
|
415
|
-
getAccessToken:
|
|
272
|
+
getAccessToken: c,
|
|
416
273
|
renderGoogleButton: a,
|
|
417
274
|
login: o,
|
|
418
275
|
logout: r
|
|
419
276
|
};
|
|
420
|
-
})
|
|
277
|
+
});
|
|
278
|
+
function te(e) {
|
|
279
|
+
return e < 10 ? `0${e}` : `${e}`;
|
|
280
|
+
}
|
|
281
|
+
function Re(e) {
|
|
282
|
+
return e = `${e.substring(0, 10)}T${e.substring(11, 19)}Z`, new Date(e);
|
|
283
|
+
}
|
|
284
|
+
function Ie(e) {
|
|
285
|
+
const s = e.getFullYear(), t = e.getMonth() + 1, n = e.getDate();
|
|
286
|
+
return `${s}-${te(t)}-${te(n)}`;
|
|
287
|
+
}
|
|
288
|
+
function $e(e) {
|
|
289
|
+
e instanceof Date || (e = Re(e));
|
|
290
|
+
const s = /* @__PURE__ */ new Date(), t = Ie(e);
|
|
291
|
+
if (Ie(s) === t) {
|
|
292
|
+
const n = e.getHours(), i = e.getMinutes();
|
|
293
|
+
return `${te(n)}:${te(i)}`;
|
|
294
|
+
}
|
|
295
|
+
return t;
|
|
296
|
+
}
|
|
297
|
+
function At(e) {
|
|
298
|
+
const { id: s, created_at: t, parent_id: n, ancestor_id: i, post_id: d, user_id: l, is_shadow_banned: c, ...o } = e, r = t || o.createdAt || "", a = n ?? e.parentId, u = i ?? e.ancestorId, y = c ?? e.isShadowBanned, g = d || e.postId || "";
|
|
299
|
+
return {
|
|
300
|
+
...o,
|
|
301
|
+
id: Number(s),
|
|
302
|
+
user_id: l,
|
|
303
|
+
userId: l,
|
|
304
|
+
parentId: Number(a),
|
|
305
|
+
post_id: g,
|
|
306
|
+
postId: g,
|
|
307
|
+
ancestorId: Number(u),
|
|
308
|
+
status: Number(e.status),
|
|
309
|
+
createdAt: Re(r),
|
|
310
|
+
isShadowBanned: y
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
const he = "awesome-comment-comments", Ce = localStorage.getItem(he), V = Ce ? JSON.parse(Ce) : {};
|
|
314
|
+
function Se(e, s, t) {
|
|
315
|
+
const n = {}, i = [];
|
|
316
|
+
e.forEach((l) => {
|
|
317
|
+
It(Number(l.id), t);
|
|
318
|
+
const c = At(l);
|
|
319
|
+
if (c.isShadowBanned && c.userId !== s)
|
|
320
|
+
return;
|
|
321
|
+
const o = l.ancestor_id ?? l.ancestorId;
|
|
322
|
+
!o || Number(o) === 0 ? n[l.id] = c : i.push(c);
|
|
323
|
+
});
|
|
324
|
+
const d = V[t];
|
|
325
|
+
d && (d.createdAt = new Date(d.createdAt), !d.ancestorId || Number(d.ancestorId) === 0 ? n[d.id] = d : i.push(d)), i.forEach((l) => {
|
|
326
|
+
if (l.ancestorId in n) {
|
|
327
|
+
const c = n[l.ancestorId];
|
|
328
|
+
c.children = [l, ...c.children || []];
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
for (const l in n) {
|
|
332
|
+
const c = n[l];
|
|
333
|
+
c.children && (c.children = c.children.sort((o, r) => o.id - r.id));
|
|
334
|
+
}
|
|
335
|
+
return n;
|
|
336
|
+
}
|
|
337
|
+
function It(e, s) {
|
|
338
|
+
V[s]?.id === e && (delete V[s], localStorage.setItem(he, JSON.stringify(V)));
|
|
339
|
+
}
|
|
340
|
+
const G = Le("store", () => {
|
|
341
|
+
const e = T("postId"), s = T("siteId"), t = T("comments"), n = T("total"), i = I(!!t?.length), d = I(0), l = I(""), c = I([]), o = I(n || 0), r = T("ApiBaseUrl"), a = I(!1), u = I(!1), y = oe();
|
|
342
|
+
async function g(x = !1) {
|
|
343
|
+
if (a.value) return;
|
|
344
|
+
l.value = "", a.value = !0;
|
|
345
|
+
let _;
|
|
346
|
+
if (x && t?.length)
|
|
347
|
+
_ = Se(t, y.user?.sub, e);
|
|
348
|
+
else {
|
|
349
|
+
const h = new URLSearchParams();
|
|
350
|
+
h.append("postId", e), s && h.append("siteId", s), h.append("start", d.value.toString());
|
|
351
|
+
const $ = await fetch(`${r}/api/comments?${h}`);
|
|
352
|
+
if (!$.ok) {
|
|
353
|
+
l.value = "Load comments failed. " + $.statusText, i.value = !0, a.value = !1;
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
const k = await $.json();
|
|
357
|
+
if (k.code !== 0) {
|
|
358
|
+
l.value = "Load comments failed. " + k.message, i.value = !0, a.value = !1;
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
_ = Se(k.data || [], y.user?.sub, e), o.value = k.meta?.total || k.data?.length || 0;
|
|
362
|
+
}
|
|
363
|
+
u.value = Object.keys(_).length > 20, u.value && delete _[Object.keys(_)[0]], Object.assign(c.value, _), i.value = !0, a.value = !1;
|
|
364
|
+
}
|
|
365
|
+
function b(x, _, h, $ = Q.Pending, k, R) {
|
|
366
|
+
const { sub: O = "", name: se = "", picture: W = "", email: Y = "", nickname: ae = "" } = h, N = {
|
|
367
|
+
id: x,
|
|
368
|
+
post_id: e,
|
|
369
|
+
postId: e,
|
|
370
|
+
content: _,
|
|
371
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
372
|
+
user: {
|
|
373
|
+
avatar: W,
|
|
374
|
+
email: Y,
|
|
375
|
+
name: ae || se
|
|
376
|
+
},
|
|
377
|
+
user_id: O,
|
|
378
|
+
userId: O,
|
|
379
|
+
status: $,
|
|
380
|
+
isNew: !0
|
|
381
|
+
};
|
|
382
|
+
if (k || R) {
|
|
383
|
+
N.ancestorId = k, N.parentId = R;
|
|
384
|
+
const M = c.value[k];
|
|
385
|
+
if (M.children || (M.children = []), k === R)
|
|
386
|
+
M.children.unshift(N);
|
|
387
|
+
else {
|
|
388
|
+
const re = M.children.findIndex((ie) => Number(ie.id) === R);
|
|
389
|
+
M.children.splice(re + 1, 0, N);
|
|
390
|
+
}
|
|
391
|
+
} else
|
|
392
|
+
N.ancestorId = 0, N.parentId = 0, c.value = { [x]: N, ...c.value };
|
|
393
|
+
o.value++, $ !== Q.Approved && (V[e] = N, localStorage.setItem(he, JSON.stringify(V)));
|
|
394
|
+
}
|
|
395
|
+
function p(x, _) {
|
|
396
|
+
let h = c.value[x];
|
|
397
|
+
if (!h) {
|
|
398
|
+
for (const $ of Object.values(c.value))
|
|
399
|
+
if ($.children && (h = $.children.find((k) => Number(k.id) === x), h))
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
h && Object.assign(h, _);
|
|
403
|
+
}
|
|
404
|
+
return {
|
|
405
|
+
isLoaded: i,
|
|
406
|
+
message: l,
|
|
407
|
+
postId: e,
|
|
408
|
+
comments: c,
|
|
409
|
+
total: o,
|
|
410
|
+
start: d,
|
|
411
|
+
hasMore: u,
|
|
412
|
+
loadingMore: a,
|
|
413
|
+
loadComments: g,
|
|
414
|
+
addComment: b,
|
|
415
|
+
updateComment: p
|
|
416
|
+
};
|
|
417
|
+
}), $t = { class: "ac-form-control bg-base-200 rounded-lg" }, Ct = {
|
|
421
418
|
class: "sr-only",
|
|
422
419
|
for: "ac-comment"
|
|
423
|
-
},
|
|
420
|
+
}, St = ["placeholder"], Et = { class: "p-2 rounded-b-lg bg-base-300 flex items-center relative" }, Tt = {
|
|
424
421
|
key: 1,
|
|
425
422
|
class: "ac-alert ac-alert-error ms-4 me-auto py-1"
|
|
426
|
-
},
|
|
423
|
+
}, Lt = ["disabled"], Nt = {
|
|
427
424
|
key: 0,
|
|
428
425
|
class: "ac-loading ac-loading-spinner"
|
|
429
|
-
},
|
|
426
|
+
}, Rt = {
|
|
430
427
|
name: "CommentForm"
|
|
431
|
-
},
|
|
432
|
-
...
|
|
428
|
+
}, X = /* @__PURE__ */ D({
|
|
429
|
+
...Rt,
|
|
433
430
|
props: {
|
|
434
431
|
noVersion: { type: Boolean },
|
|
435
432
|
currentId: {},
|
|
@@ -440,62 +437,62 @@ const he = Te("auth", () => {
|
|
|
440
437
|
},
|
|
441
438
|
emits: ["close", "update"],
|
|
442
439
|
setup(e, { emit: s }) {
|
|
443
|
-
const t = e, n = s, i =
|
|
444
|
-
let
|
|
445
|
-
function
|
|
440
|
+
const t = e, n = s, i = oe(), d = G(), { t: l } = U(), c = T("ApiBaseUrl"), o = T("Auth0Domain"), r = T("siteId"), a = T("TurnstileSiteKey"), u = T("AutoFocus"), y = "0.10.9", g = I(), b = I(), p = I(!1), x = I(t.content || ""), _ = I(""), h = I(!1), $ = I(""), k = I(""), R = J(() => !i.isAuthenticated);
|
|
441
|
+
let O = null;
|
|
442
|
+
function se() {
|
|
446
443
|
if (typeof window > "u") return Promise.reject(new Error("Turnstile 仅支持浏览器环境"));
|
|
447
444
|
if (window.turnstile) return Promise.resolve();
|
|
448
|
-
if (
|
|
449
|
-
const
|
|
450
|
-
return
|
|
451
|
-
const
|
|
445
|
+
if (O) return O;
|
|
446
|
+
const E = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit";
|
|
447
|
+
return O = new Promise((S, F) => {
|
|
448
|
+
const H = document.querySelector(`script[src="${E}"]`), L = H || document.createElement("script");
|
|
452
449
|
function ve() {
|
|
453
|
-
|
|
450
|
+
S();
|
|
454
451
|
}
|
|
455
|
-
function
|
|
456
|
-
|
|
452
|
+
function q() {
|
|
453
|
+
F(new Error("Failed to load Turnstile script"));
|
|
457
454
|
}
|
|
458
|
-
|
|
459
|
-
}),
|
|
460
|
-
|
|
461
|
-
}),
|
|
455
|
+
L.addEventListener("load", ve, { once: !0 }), L.addEventListener("error", q, { once: !0 }), H || (L.src = E, L.async = !0, L.defer = !0, document.head.appendChild(L));
|
|
456
|
+
}), O.catch(() => {
|
|
457
|
+
O = null;
|
|
458
|
+
}), O;
|
|
462
459
|
}
|
|
463
|
-
async function
|
|
464
|
-
if (!(!a || !
|
|
465
|
-
if (await
|
|
466
|
-
|
|
460
|
+
async function W() {
|
|
461
|
+
if (!(!a || !b.value)) {
|
|
462
|
+
if (await se(), !window.turnstile) {
|
|
463
|
+
_.value = "Turnstile initialization failed";
|
|
467
464
|
return;
|
|
468
465
|
}
|
|
469
|
-
if (
|
|
470
|
-
window.turnstile.reset(
|
|
466
|
+
if (k.value) {
|
|
467
|
+
window.turnstile.reset(k.value);
|
|
471
468
|
return;
|
|
472
469
|
}
|
|
473
|
-
|
|
470
|
+
k.value = window.turnstile.render(b.value, {
|
|
474
471
|
sitekey: a,
|
|
475
472
|
size: "compact",
|
|
476
|
-
callback: (
|
|
477
|
-
|
|
473
|
+
callback: (E) => {
|
|
474
|
+
$.value = E, _.value = "";
|
|
478
475
|
},
|
|
479
476
|
"expired-callback": () => {
|
|
480
|
-
|
|
477
|
+
$.value = "";
|
|
481
478
|
},
|
|
482
479
|
"error-callback": () => {
|
|
483
|
-
|
|
480
|
+
$.value = "", _.value = "Turnstile validation failed, please try again.";
|
|
484
481
|
}
|
|
485
482
|
});
|
|
486
483
|
}
|
|
487
484
|
}
|
|
488
|
-
function
|
|
489
|
-
if (!
|
|
490
|
-
|
|
485
|
+
function Y() {
|
|
486
|
+
if (!k.value || !window.turnstile) {
|
|
487
|
+
$.value = "";
|
|
491
488
|
return;
|
|
492
489
|
}
|
|
493
490
|
try {
|
|
494
|
-
window.turnstile.remove(
|
|
491
|
+
window.turnstile.remove(k.value);
|
|
495
492
|
} catch {
|
|
496
|
-
window.turnstile.reset(
|
|
493
|
+
window.turnstile.reset(k.value);
|
|
497
494
|
}
|
|
498
|
-
|
|
495
|
+
k.value = "", $.value = "";
|
|
499
496
|
}
|
|
500
497
|
function ae() {
|
|
501
498
|
return i.user ? i.user : {
|
|
@@ -506,45 +503,45 @@ const he = Te("auth", () => {
|
|
|
506
503
|
email: ""
|
|
507
504
|
};
|
|
508
505
|
}
|
|
509
|
-
async function
|
|
506
|
+
async function N(E) {
|
|
510
507
|
if (!i.isAuthenticated) {
|
|
511
508
|
if (!a)
|
|
512
|
-
return
|
|
513
|
-
if (h.value = !0,
|
|
514
|
-
await
|
|
509
|
+
return M();
|
|
510
|
+
if (h.value = !0, !$.value) {
|
|
511
|
+
await me(), await W();
|
|
515
512
|
return;
|
|
516
513
|
}
|
|
517
514
|
}
|
|
518
|
-
if (
|
|
519
|
-
const
|
|
520
|
-
if (!
|
|
521
|
-
if (!
|
|
522
|
-
|
|
515
|
+
if (E.target.matches(":invalid")) return;
|
|
516
|
+
const S = x.value.trim();
|
|
517
|
+
if (!S) return;
|
|
518
|
+
if (!mt(S).valid) {
|
|
519
|
+
_.value = "We encourage meaningful contributions to foster a positive community. Thank you for your understanding!";
|
|
523
520
|
return;
|
|
524
521
|
}
|
|
525
|
-
p.value = !0,
|
|
526
|
-
let
|
|
527
|
-
t.currentId && (
|
|
522
|
+
p.value = !0, _.value = "";
|
|
523
|
+
let F = c + "/api/comment", H = "POST";
|
|
524
|
+
t.currentId && (F += "/" + t.currentId, H = "PATCH");
|
|
528
525
|
try {
|
|
529
|
-
const
|
|
526
|
+
const L = i.isAuthenticated ? await i.getAccessToken() : "", q = {
|
|
530
527
|
"Content-Type": "application/json",
|
|
531
528
|
"Auth-Endpoint": i.authEndpoint
|
|
532
529
|
};
|
|
533
|
-
|
|
534
|
-
const
|
|
530
|
+
L && (q.Authorization = `Bearer ${L}`);
|
|
531
|
+
const Oe = R.value ? {
|
|
535
532
|
referrer: document.referrer || "",
|
|
536
533
|
language: navigator.language || "",
|
|
537
534
|
languages: navigator.languages || [],
|
|
538
535
|
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone || "",
|
|
539
536
|
platform: navigator.platform || ""
|
|
540
|
-
} : null,
|
|
537
|
+
} : null, Me = R.value ? {
|
|
541
538
|
custom: window.custom_comment_data ?? null,
|
|
542
|
-
anonymous:
|
|
543
|
-
} : window.custom_comment_data, ge = await fetch(
|
|
544
|
-
method:
|
|
545
|
-
headers:
|
|
539
|
+
anonymous: Oe
|
|
540
|
+
} : window.custom_comment_data, ge = await fetch(F, {
|
|
541
|
+
method: H,
|
|
542
|
+
headers: q,
|
|
546
543
|
body: JSON.stringify({
|
|
547
|
-
comment:
|
|
544
|
+
comment: S,
|
|
548
545
|
postId: d.postId,
|
|
549
546
|
siteId: r,
|
|
550
547
|
domain: o,
|
|
@@ -552,135 +549,135 @@ const he = Te("auth", () => {
|
|
|
552
549
|
parentId: t.parentId ? Number(t.parentId) : void 0,
|
|
553
550
|
status: t.status,
|
|
554
551
|
window: `${window.innerWidth}x${window.innerHeight} / ${screen.width, screen.height}`,
|
|
555
|
-
customData:
|
|
552
|
+
customData: Me,
|
|
556
553
|
extraData: `${window.BM_LEVEL}:${window.BM_VALUE}`,
|
|
557
|
-
turnstileToken:
|
|
554
|
+
turnstileToken: R.value ? $.value : void 0
|
|
558
555
|
})
|
|
559
|
-
}),
|
|
560
|
-
if (!ge.ok ||
|
|
561
|
-
|
|
556
|
+
}), ce = await ge.json();
|
|
557
|
+
if (!ge.ok || ce.message) {
|
|
558
|
+
_.value = "Failed to post comment: " + (ce.message || "Unknown"), p.value = !1;
|
|
562
559
|
return;
|
|
563
560
|
}
|
|
564
|
-
const { id: ye, status: be } =
|
|
565
|
-
t.ancestorId || t.parentId ? d.addComment(ye,
|
|
566
|
-
} catch (
|
|
567
|
-
|
|
561
|
+
const { id: ye, status: be } = ce.data, _e = ae();
|
|
562
|
+
t.ancestorId || t.parentId ? d.addComment(ye, S, _e, be, t.ancestorId, t.parentId) : t.currentId ? n("update", S) : d.addComment(ye, S, _e, be), x.value = "", n("close"), R.value && (Y(), h.value = !1);
|
|
563
|
+
} catch (L) {
|
|
564
|
+
_.value = L.message || String(L);
|
|
568
565
|
}
|
|
569
566
|
p.value = !1;
|
|
570
567
|
}
|
|
571
|
-
function
|
|
568
|
+
function M() {
|
|
572
569
|
i.login();
|
|
573
570
|
}
|
|
574
|
-
function
|
|
575
|
-
|
|
571
|
+
function re(E) {
|
|
572
|
+
ut(E, "Enter") && N(E);
|
|
576
573
|
}
|
|
577
|
-
function
|
|
574
|
+
function ie() {
|
|
578
575
|
n("close");
|
|
579
576
|
}
|
|
580
|
-
return
|
|
581
|
-
(
|
|
582
|
-
}),
|
|
577
|
+
return ne(() => {
|
|
578
|
+
(u || t.currentId) && g.value?.focus();
|
|
579
|
+
}), K(
|
|
583
580
|
() => h.value,
|
|
584
|
-
async (
|
|
585
|
-
!
|
|
581
|
+
async (E) => {
|
|
582
|
+
!E || i.isAuthenticated || (await me(), await W());
|
|
586
583
|
}
|
|
587
|
-
),
|
|
584
|
+
), K(
|
|
588
585
|
() => i.isAuthenticated,
|
|
589
|
-
(
|
|
590
|
-
|
|
586
|
+
(E) => {
|
|
587
|
+
E && (h.value = !1, Y());
|
|
591
588
|
}
|
|
592
|
-
), (
|
|
589
|
+
), (E, S) => (f(), v("form", {
|
|
593
590
|
class: "mb-6",
|
|
594
|
-
onSubmit:
|
|
591
|
+
onSubmit: le(N, ["prevent"])
|
|
595
592
|
}, [
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
593
|
+
w("div", $t, [
|
|
594
|
+
w("label", Ct, A(m(l)("your_comment")), 1),
|
|
595
|
+
Pe(w("textarea", {
|
|
599
596
|
id: "ac-comment",
|
|
600
597
|
ref_key: "textarea",
|
|
601
598
|
ref: g,
|
|
602
|
-
"onUpdate:modelValue":
|
|
603
|
-
placeholder: m(
|
|
599
|
+
"onUpdate:modelValue": S[0] || (S[0] = (F) => x.value = F),
|
|
600
|
+
placeholder: m(l)("placeholder"),
|
|
604
601
|
class: "ac-textarea ac-textarea-bordered bg-base-200 rounded-b-none focus:outline-none",
|
|
605
602
|
required: "",
|
|
606
603
|
rows: "3",
|
|
607
604
|
onKeydown: [
|
|
608
|
-
|
|
605
|
+
S[1] || (S[1] = le(() => {
|
|
609
606
|
}, ["stop"])),
|
|
610
|
-
we(
|
|
611
|
-
we(
|
|
607
|
+
we(re, ["enter"]),
|
|
608
|
+
we(ie, ["esc"])
|
|
612
609
|
],
|
|
613
|
-
onKeyup:
|
|
610
|
+
onKeyup: S[2] || (S[2] = le(() => {
|
|
614
611
|
}, ["stop"]))
|
|
615
|
-
}, null, 40,
|
|
616
|
-
[
|
|
612
|
+
}, null, 40, St), [
|
|
613
|
+
[Be, x.value]
|
|
617
614
|
]),
|
|
618
|
-
|
|
619
|
-
e.noVersion ?
|
|
615
|
+
w("div", Et, [
|
|
616
|
+
e.noVersion ? C("", !0) : (f(), v("div", {
|
|
620
617
|
key: 0,
|
|
621
|
-
class:
|
|
622
|
-
}, " v" +
|
|
623
|
-
|
|
624
|
-
h.value && !m(i).isAuthenticated ? (f(), v(
|
|
625
|
-
m(i).isAwesomeAuth ?
|
|
618
|
+
class: pe(["text-xs text-neutral-400/40", { "me-auto": !_.value }])
|
|
619
|
+
}, " v" + A(m(y)), 3)),
|
|
620
|
+
_.value ? (f(), v("div", Tt, A(_.value), 1)) : C("", !0),
|
|
621
|
+
h.value && !m(i).isAuthenticated ? (f(), v(P, { key: 2 }, [
|
|
622
|
+
m(i).isAwesomeAuth ? C("", !0) : (f(), v("button", {
|
|
626
623
|
key: 0,
|
|
627
624
|
class: "ac-btn ac-btn-secondary ac-btn-xs mx-4",
|
|
628
625
|
type: "button",
|
|
629
|
-
onClick:
|
|
630
|
-
},
|
|
626
|
+
onClick: M
|
|
627
|
+
}, A(m(l)("login")), 1)),
|
|
631
628
|
m(a) ? (f(), v("div", {
|
|
632
629
|
key: 1,
|
|
633
630
|
ref_key: "turnstileContainer",
|
|
634
|
-
ref:
|
|
631
|
+
ref: b,
|
|
635
632
|
class: "absolute right-2 top-10"
|
|
636
|
-
}, null, 512)) :
|
|
637
|
-
], 64)) :
|
|
638
|
-
|
|
639
|
-
disabled: p.value || h.value && !m(i).isAuthenticated &&
|
|
633
|
+
}, null, 512)) : C("", !0)
|
|
634
|
+
], 64)) : C("", !0),
|
|
635
|
+
w("button", {
|
|
636
|
+
disabled: p.value || h.value && !m(i).isAuthenticated && !$.value,
|
|
640
637
|
class: "ac-btn ac-btn-primary ac-btn-sm"
|
|
641
638
|
}, [
|
|
642
|
-
p.value ? (f(), v("span",
|
|
643
|
-
e.currentId ? (f(), v(
|
|
644
|
-
|
|
645
|
-
], 64)) : e.parentId ? (f(), v(
|
|
646
|
-
|
|
647
|
-
], 64)) : (f(), v(
|
|
648
|
-
|
|
639
|
+
p.value ? (f(), v("span", Nt)) : C("", !0),
|
|
640
|
+
e.currentId ? (f(), v(P, { key: 1 }, [
|
|
641
|
+
z(A(m(l)("save_editing")), 1)
|
|
642
|
+
], 64)) : e.parentId ? (f(), v(P, { key: 2 }, [
|
|
643
|
+
z(A(m(l)("post_reply")), 1)
|
|
644
|
+
], 64)) : (f(), v(P, { key: 3 }, [
|
|
645
|
+
z(A(m(l)("post_comment")), 1)
|
|
649
646
|
], 64))
|
|
650
|
-
], 8,
|
|
647
|
+
], 8, Lt)
|
|
651
648
|
])
|
|
652
649
|
])
|
|
653
650
|
], 32));
|
|
654
651
|
}
|
|
655
|
-
}),
|
|
652
|
+
}), Ot = { class: "flex items-center gap-2" }, Mt = ["aria-label", "title", "disabled"], Pt = {
|
|
656
653
|
key: 0,
|
|
657
654
|
class: "ac-loading ac-loading-spinner"
|
|
658
|
-
},
|
|
655
|
+
}, Bt = { class: "text-sm text-gray-500 dark:text-gray-400" }, jt = ["aria-label", "title", "disabled"], Dt = {
|
|
659
656
|
key: 0,
|
|
660
657
|
class: "ac-loading ac-loading-spinner"
|
|
661
|
-
},
|
|
658
|
+
}, Ut = ["aria-label", "title"], ue = "awesome-comment-likes", Ft = /* @__PURE__ */ D({
|
|
662
659
|
__name: "comment-actions",
|
|
663
660
|
props: {
|
|
664
661
|
comment: {}
|
|
665
662
|
},
|
|
666
663
|
emits: ["reply"],
|
|
667
664
|
setup(e, { emit: s }) {
|
|
668
|
-
const t = e, n = s, i =
|
|
665
|
+
const t = e, n = s, i = G(), { t: d } = U(), l = T("ApiBaseUrl"), c = T("siteId"), o = I(0);
|
|
669
666
|
async function r(a = !0) {
|
|
670
667
|
if (o.value) return;
|
|
671
|
-
const
|
|
672
|
-
if (
|
|
673
|
-
const
|
|
674
|
-
if (
|
|
668
|
+
const u = localStorage.getItem(ue);
|
|
669
|
+
if (u) {
|
|
670
|
+
const b = JSON.parse(u), p = Date.now(), x = b[t.comment.id];
|
|
671
|
+
if (b[t.comment.id] = p, localStorage.setItem(ue, JSON.stringify(b)), x && p - x < 6e4) {
|
|
675
672
|
i.updateComment(t.comment.id, {
|
|
676
673
|
like: Math.max((t.comment.like || 0) + (a ? 1 : -1), 0)
|
|
677
674
|
});
|
|
678
675
|
return;
|
|
679
676
|
}
|
|
680
677
|
} else
|
|
681
|
-
localStorage.setItem(
|
|
678
|
+
localStorage.setItem(ue, JSON.stringify({ [t.comment.id]: Date.now() }));
|
|
682
679
|
o.value = a ? 1 : -1;
|
|
683
|
-
const g = await (await fetch(`${
|
|
680
|
+
const g = await (await fetch(`${l}/api/like/${t.comment.id}`, {
|
|
684
681
|
method: "POST",
|
|
685
682
|
headers: {
|
|
686
683
|
"Content-Type": "application/json"
|
|
@@ -688,96 +685,96 @@ const he = Te("auth", () => {
|
|
|
688
685
|
body: JSON.stringify({
|
|
689
686
|
like: a,
|
|
690
687
|
postId: t.comment.postId || i.postId,
|
|
691
|
-
siteId:
|
|
688
|
+
siteId: c
|
|
692
689
|
})
|
|
693
690
|
})).json();
|
|
694
691
|
i.updateComment(t.comment.id, {
|
|
695
692
|
like: g.data?.like || 0
|
|
696
693
|
}), o.value = 0;
|
|
697
694
|
}
|
|
698
|
-
return (a,
|
|
699
|
-
|
|
695
|
+
return (a, u) => (f(), v("div", Ot, [
|
|
696
|
+
w("button", {
|
|
700
697
|
"aria-label": m(d)("like"),
|
|
701
698
|
title: m(d)("like"),
|
|
702
699
|
class: "ac-btn ac-btn-sm ac-btn-circle border-0 shadow-none",
|
|
703
700
|
disabled: o.value !== 0,
|
|
704
701
|
type: "button",
|
|
705
|
-
onClick:
|
|
702
|
+
onClick: u[0] || (u[0] = (y) => r())
|
|
706
703
|
}, [
|
|
707
|
-
o.value > 0 ? (f(), v("span",
|
|
704
|
+
o.value > 0 ? (f(), v("span", Pt)) : (f(), B(m(He), {
|
|
708
705
|
key: 1,
|
|
709
706
|
size: 16
|
|
710
707
|
}))
|
|
711
|
-
], 8,
|
|
712
|
-
|
|
713
|
-
|
|
708
|
+
], 8, Mt),
|
|
709
|
+
w("span", Bt, A(e.comment.like || 0), 1),
|
|
710
|
+
w("button", {
|
|
714
711
|
"aria-label": m(d)("dislike"),
|
|
715
712
|
title: m(d)("dislike"),
|
|
716
713
|
class: "ac-btn ac-btn-sm ac-btn-circle border-0 shadow-none",
|
|
717
714
|
disabled: o.value !== 0,
|
|
718
715
|
type: "button",
|
|
719
|
-
onClick:
|
|
716
|
+
onClick: u[1] || (u[1] = (y) => r(!1))
|
|
720
717
|
}, [
|
|
721
|
-
o.value < 0 ? (f(), v("span",
|
|
718
|
+
o.value < 0 ? (f(), v("span", Dt)) : (f(), B(m(Je), {
|
|
722
719
|
key: 1,
|
|
723
720
|
size: 16
|
|
724
721
|
}))
|
|
725
|
-
], 8,
|
|
726
|
-
|
|
722
|
+
], 8, jt),
|
|
723
|
+
w("button", {
|
|
727
724
|
"aria-label": m(d)("reply"),
|
|
728
725
|
title: m(d)("reply"),
|
|
729
726
|
class: "ac-btn ac-btn-sm ac-btn-circle border-0 shadow-none -me-1.5",
|
|
730
727
|
type: "button",
|
|
731
|
-
onClick:
|
|
728
|
+
onClick: u[2] || (u[2] = (y) => n("reply"))
|
|
732
729
|
}, [
|
|
733
|
-
|
|
734
|
-
], 8,
|
|
730
|
+
j(m(We), { size: 16 })
|
|
731
|
+
], 8, Ut)
|
|
735
732
|
]));
|
|
736
733
|
}
|
|
737
|
-
}),
|
|
734
|
+
}), Kt = ["href"], zt = ["innerHTML"], Vt = {
|
|
738
735
|
key: 1,
|
|
739
736
|
class: "text-gray-500 break-words overflow-x-auto whitespace-pre-line pb-3 mb-0 dark:text-gray-400"
|
|
740
|
-
},
|
|
737
|
+
}, Gt = ["href"], Ht = /* @__PURE__ */ D({
|
|
741
738
|
__name: "comment-content",
|
|
742
739
|
props: {
|
|
743
740
|
ancestorId: {},
|
|
744
741
|
comment: {}
|
|
745
742
|
},
|
|
746
743
|
setup(e) {
|
|
747
|
-
const s = e, { t } = U(), n =
|
|
748
|
-
function i(
|
|
749
|
-
return
|
|
744
|
+
const s = e, { t } = U(), n = G();
|
|
745
|
+
function i(l) {
|
|
746
|
+
return qe(l).replace(/<a/g, '<a target="_blank"');
|
|
750
747
|
}
|
|
751
|
-
function d(
|
|
748
|
+
function d(l) {
|
|
752
749
|
if (s.ancestorId) {
|
|
753
|
-
const o = n.comments[s.ancestorId]?.children?.find((r) => Number(r.id) === Number(
|
|
750
|
+
const o = n.comments[s.ancestorId]?.children?.find((r) => Number(r.id) === Number(l));
|
|
754
751
|
return o?.isAdmin ? t("admin") : o?.user?.name || o?.user?.email || "";
|
|
755
752
|
}
|
|
756
753
|
return "";
|
|
757
754
|
}
|
|
758
|
-
return (
|
|
755
|
+
return (l, c) => e.comment.isAdmin ? (f(), v(P, { key: 0 }, [
|
|
759
756
|
e.comment.parentId && e.comment.parentId !== e.comment.ancestorId ? (f(), v("a", {
|
|
760
757
|
key: 0,
|
|
761
758
|
href: `#awcm-${e.comment.parentId}`,
|
|
762
759
|
class: "inline-block px-2 py-1 rounded-lg mt-2 bg-base-300 text-gray-500 dark:bg-neutral-400/20 dark:text-gray-400",
|
|
763
760
|
target: "_self"
|
|
764
|
-
}, "@" +
|
|
765
|
-
|
|
761
|
+
}, "@" + A(d(e.comment.parentId)), 9, Kt)) : C("", !0),
|
|
762
|
+
w("article", {
|
|
766
763
|
class: "text-gray-500 break-words overflow-x-auto dark:text-gray-400",
|
|
767
764
|
innerHTML: i(e.comment.content)
|
|
768
|
-
}, null, 8,
|
|
769
|
-
], 64)) : (f(), v("p",
|
|
765
|
+
}, null, 8, zt)
|
|
766
|
+
], 64)) : (f(), v("p", Vt, [
|
|
770
767
|
e.comment.parentId && e.comment.parentId !== e.comment.ancestorId ? (f(), v("a", {
|
|
771
768
|
key: 0,
|
|
772
769
|
href: `#awcm-${e.comment.parentId}`,
|
|
773
770
|
class: "inline-block px-2 py-1 rounded-lg me-1 bg-base-300 text-gray-500 dark:bg-neutral-400/20 dark:text-gray-400",
|
|
774
771
|
target: "_self"
|
|
775
|
-
}, "@" +
|
|
776
|
-
|
|
772
|
+
}, "@" + A(d(e.comment.parentId)), 9, Gt)) : C("", !0),
|
|
773
|
+
z(A(e.comment.content), 1)
|
|
777
774
|
]));
|
|
778
775
|
}
|
|
779
776
|
});
|
|
780
|
-
function
|
|
777
|
+
function Jt(e) {
|
|
781
778
|
let s = 0;
|
|
782
779
|
for (let n = 0; n < e.length; n++)
|
|
783
780
|
s = e.charCodeAt(n) + ((s << 5) - s);
|
|
@@ -788,10 +785,10 @@ function Gt(e) {
|
|
|
788
785
|
}
|
|
789
786
|
return t;
|
|
790
787
|
}
|
|
791
|
-
const
|
|
788
|
+
const Wt = { class: "flex items-center gap-2 text-sm text-base-content dark:text-white" }, Yt = { class: "ac-avatar" }, qt = {
|
|
792
789
|
key: 0,
|
|
793
790
|
class: "w-6 h-6"
|
|
794
|
-
},
|
|
791
|
+
}, Zt = ["alt", "src"], Xt = { class: "text-neutral-content mix-blend-color-dodge uppercase font-bold leading-6" }, Qt = ["data-tip"], en = ["href"], tn = ["datetime", "title"], nn = /* @__PURE__ */ D({
|
|
795
792
|
__name: "comment-header",
|
|
796
793
|
props: {
|
|
797
794
|
comment: {},
|
|
@@ -800,66 +797,66 @@ const Ht = { class: "flex items-center gap-2 text-sm text-base-content dark:text
|
|
|
800
797
|
},
|
|
801
798
|
emits: ["edit"],
|
|
802
799
|
setup(e, { emit: s }) {
|
|
803
|
-
const t = e, n = s, { t: i } = U(), d =
|
|
800
|
+
const t = e, n = s, { t: i } = U(), d = J(() => {
|
|
804
801
|
if (t.comment.isAdmin) return i("admin");
|
|
805
|
-
let
|
|
806
|
-
return
|
|
802
|
+
let c = t.comment.user?.name || i("anonymous");
|
|
803
|
+
return c = c.replace(yt, ""), c;
|
|
807
804
|
});
|
|
808
|
-
function
|
|
809
|
-
return `${location.origin}${location.pathname}#awcm-${
|
|
805
|
+
function l(c) {
|
|
806
|
+
return `${location.origin}${location.pathname}#awcm-${c}`;
|
|
810
807
|
}
|
|
811
|
-
return (
|
|
812
|
-
|
|
813
|
-
e.comment.user?.avatar ? (f(), v("div",
|
|
814
|
-
|
|
808
|
+
return (c, o) => (f(), v("div", Wt, [
|
|
809
|
+
w("div", Yt, [
|
|
810
|
+
e.comment.user?.avatar ? (f(), v("div", qt, [
|
|
811
|
+
w("img", {
|
|
815
812
|
alt: d.value,
|
|
816
813
|
src: e.comment.user?.avatar,
|
|
817
814
|
class: "rounded-full max-w-full max-h-full"
|
|
818
|
-
}, null, 8,
|
|
815
|
+
}, null, 8, Zt)
|
|
819
816
|
])) : (f(), v("div", {
|
|
820
817
|
key: 1,
|
|
821
|
-
style: je({ "background-color": m(
|
|
818
|
+
style: je({ "background-color": m(Jt)(d.value) }),
|
|
822
819
|
class: "avatar-char rounded-full w-6 h-6 text-center"
|
|
823
820
|
}, [
|
|
824
|
-
|
|
821
|
+
w("span", Xt, A(d.value.substring(0, 1)), 1)
|
|
825
822
|
], 4))
|
|
826
823
|
]),
|
|
827
|
-
|
|
824
|
+
z(" " + A(d.value) + " ", 1),
|
|
828
825
|
e.comment.isAdmin ? (f(), v("div", {
|
|
829
826
|
key: 0,
|
|
830
827
|
"data-tip": m(i)("admin"),
|
|
831
828
|
class: "ac-tooltip text-success"
|
|
832
829
|
}, [
|
|
833
|
-
|
|
830
|
+
j(m(Ye), {
|
|
834
831
|
class: "block",
|
|
835
832
|
size: 18
|
|
836
833
|
})
|
|
837
|
-
], 8,
|
|
838
|
-
|
|
839
|
-
href:
|
|
834
|
+
], 8, Qt)) : C("", !0),
|
|
835
|
+
w("a", {
|
|
836
|
+
href: l(e.comment.id),
|
|
840
837
|
class: "no-underline hover:underline hover:decoration-green-middle"
|
|
841
838
|
}, [
|
|
842
|
-
|
|
839
|
+
w("time", {
|
|
843
840
|
datetime: e.comment.createdAt.toISOString(),
|
|
844
|
-
title: m(
|
|
841
|
+
title: m($e)(e.comment.createdAt),
|
|
845
842
|
class: "text-xs text-gray-600 dark:text-gray-400"
|
|
846
|
-
},
|
|
847
|
-
], 8,
|
|
843
|
+
}, A(m($e)(e.comment.createdAt)), 9, tn)
|
|
844
|
+
], 8, en),
|
|
848
845
|
e.isEditable ? (f(), v("button", {
|
|
849
846
|
key: 1,
|
|
850
847
|
class: "ac-btn ac-btn-link ac-btn-xs hover:no-underline",
|
|
851
848
|
type: "button",
|
|
852
849
|
onClick: o[0] || (o[0] = (r) => n("edit"))
|
|
853
|
-
},
|
|
850
|
+
}, A(m(i)("edit")), 1)) : C("", !0)
|
|
854
851
|
]));
|
|
855
852
|
}
|
|
856
|
-
}),
|
|
853
|
+
}), on = ["id"], sn = { class: "flex justify-between items-center font-sans" }, an = {
|
|
857
854
|
key: 0,
|
|
858
855
|
class: "italic mt-4 text-emerald-600 mb-0 text-sm dark:text-emerald-300"
|
|
859
|
-
},
|
|
856
|
+
}, rn = {
|
|
860
857
|
name: "CommentItem"
|
|
861
|
-
},
|
|
862
|
-
...
|
|
858
|
+
}, cn = /* @__PURE__ */ D({
|
|
859
|
+
...rn,
|
|
863
860
|
props: {
|
|
864
861
|
comment: {},
|
|
865
862
|
isFirst: { type: Boolean },
|
|
@@ -868,107 +865,107 @@ const Ht = { class: "flex items-center gap-2 text-sm text-base-content dark:text
|
|
|
868
865
|
ancestorId: {}
|
|
869
866
|
},
|
|
870
867
|
setup(e) {
|
|
871
|
-
const s = e, { t } = U(), n =
|
|
868
|
+
const s = e, { t } = U(), n = G(), i = oe();
|
|
872
869
|
let d;
|
|
873
|
-
const
|
|
874
|
-
return
|
|
870
|
+
const l = I(Date.now()), c = I(!1), o = I(!1), r = J(() => s.comment.userId === i.user?.sub && l.value - s.comment.createdAt.getTime() < 36e5);
|
|
871
|
+
return ne(() => {
|
|
875
872
|
r.value && (d = setInterval(() => {
|
|
876
|
-
|
|
873
|
+
l.value = Date.now(), r.value || clearInterval(d);
|
|
877
874
|
}, 1e3));
|
|
878
|
-
}),
|
|
875
|
+
}), De(() => {
|
|
879
876
|
clearInterval(d);
|
|
880
|
-
}), (a,
|
|
881
|
-
const
|
|
877
|
+
}), (a, u) => {
|
|
878
|
+
const y = Ue("comment-item", !0);
|
|
882
879
|
return f(), v("div", {
|
|
883
880
|
id: "awcm-" + e.comment.id,
|
|
884
|
-
class:
|
|
885
|
-
onAnimationend:
|
|
881
|
+
class: pe([[{ "animated flash": e.comment.isNew }, e.isFirstLevel ? "mb-4" : e.isFirst ? "-mt-4" : "mt-1"], "comment-item target:outline target:outline-green-500 target:outline-2 dark:target:outline-1"]),
|
|
882
|
+
onAnimationend: u[6] || (u[6] = (g) => m(n).updateComment(e.comment.id, { isNew: !1 }))
|
|
886
883
|
}, [
|
|
887
|
-
|
|
888
|
-
class:
|
|
884
|
+
w("div", {
|
|
885
|
+
class: pe(["pt-2 px-4 text-base bg-base-200 dark:bg-gray-900", [{ "rounded-lg": e.isFirstLevel, "rounded-b-lg": e.isLast, "rounded-t-lg shadow-outline-md": e.isFirst }, e.comment.children?.length ? "pb-6" : "pb-3"]])
|
|
889
886
|
}, [
|
|
890
|
-
|
|
891
|
-
|
|
887
|
+
w("header", sn, [
|
|
888
|
+
j(nn, {
|
|
892
889
|
comment: e.comment,
|
|
893
890
|
"is-editable": r.value,
|
|
894
|
-
"is-editing":
|
|
895
|
-
onEdit:
|
|
891
|
+
"is-editing": c.value,
|
|
892
|
+
onEdit: u[0] || (u[0] = (g) => c.value = !c.value)
|
|
896
893
|
}, null, 8, ["comment", "is-editable", "is-editing"]),
|
|
897
|
-
|
|
894
|
+
j(Ft, {
|
|
898
895
|
comment: e.comment,
|
|
899
|
-
onReply:
|
|
896
|
+
onReply: u[1] || (u[1] = (g) => o.value = !o.value)
|
|
900
897
|
}, null, 8, ["comment"])
|
|
901
898
|
]),
|
|
902
|
-
|
|
899
|
+
j(Ht, {
|
|
903
900
|
"ancestor-id": e.ancestorId,
|
|
904
901
|
comment: e.comment
|
|
905
902
|
}, null, 8, ["ancestor-id", "comment"]),
|
|
906
|
-
e.comment.status === m(
|
|
903
|
+
e.comment.status === m(Q).Pending ? (f(), v("p", an, A(m(t)("approve_hint")), 1)) : C("", !0)
|
|
907
904
|
], 2),
|
|
908
|
-
|
|
905
|
+
c.value ? (f(), B(X, {
|
|
909
906
|
key: 0,
|
|
910
907
|
content: e.comment.content,
|
|
911
908
|
"current-id": e.comment.id,
|
|
912
909
|
status: e.comment.status,
|
|
913
910
|
class: "mt-3",
|
|
914
911
|
"no-version": "",
|
|
915
|
-
onClose:
|
|
916
|
-
onUpdate:
|
|
917
|
-
}, null, 8, ["content", "current-id", "status"])) :
|
|
918
|
-
o.value && e.isFirstLevel ? (f(),
|
|
912
|
+
onClose: u[2] || (u[2] = (g) => c.value = !1),
|
|
913
|
+
onUpdate: u[3] || (u[3] = (g) => m(n).updateComment(e.comment.id, { content: g }))
|
|
914
|
+
}, null, 8, ["content", "current-id", "status"])) : C("", !0),
|
|
915
|
+
o.value && e.isFirstLevel ? (f(), B(X, {
|
|
919
916
|
key: 1,
|
|
920
917
|
"ancestor-id": e.ancestorId,
|
|
921
918
|
"parent-id": Number(e.comment.id),
|
|
922
919
|
class: "mt-2 ms-7",
|
|
923
920
|
"no-version": "",
|
|
924
|
-
onClose:
|
|
925
|
-
}, null, 8, ["ancestor-id", "parent-id"])) :
|
|
926
|
-
e.comment.children?.length ? (f(!0), v(
|
|
921
|
+
onClose: u[4] || (u[4] = (g) => o.value = !1)
|
|
922
|
+
}, null, 8, ["ancestor-id", "parent-id"])) : C("", !0),
|
|
923
|
+
e.comment.children?.length ? (f(!0), v(P, { key: 2 }, Te(e.comment.children, (g, b) => (f(), B(y, {
|
|
927
924
|
key: g.id,
|
|
928
925
|
"ancestor-id": e.ancestorId,
|
|
929
926
|
comment: g,
|
|
930
|
-
"is-first":
|
|
927
|
+
"is-first": b === 0,
|
|
931
928
|
"is-first-level": !1,
|
|
932
|
-
"is-last":
|
|
929
|
+
"is-last": b === e.comment.children.length - 1,
|
|
933
930
|
class: "ms-7"
|
|
934
|
-
}, null, 8, ["ancestor-id", "comment", "is-first", "is-last"]))), 128)) :
|
|
935
|
-
o.value && !e.isFirstLevel ? (f(),
|
|
931
|
+
}, null, 8, ["ancestor-id", "comment", "is-first", "is-last"]))), 128)) : C("", !0),
|
|
932
|
+
o.value && !e.isFirstLevel ? (f(), B(X, {
|
|
936
933
|
key: 3,
|
|
937
934
|
"ancestor-id": e.ancestorId,
|
|
938
935
|
"parent-id": e.comment.id,
|
|
939
936
|
class: "mt-2 ms-7",
|
|
940
937
|
"no-version": "",
|
|
941
|
-
onClose:
|
|
942
|
-
}, null, 8, ["ancestor-id", "parent-id"])) :
|
|
943
|
-
], 42,
|
|
938
|
+
onClose: u[5] || (u[5] = (g) => o.value = !1)
|
|
939
|
+
}, null, 8, ["ancestor-id", "parent-id"])) : C("", !0)
|
|
940
|
+
], 42, on);
|
|
944
941
|
};
|
|
945
942
|
}
|
|
946
|
-
}),
|
|
943
|
+
}), ln = {
|
|
947
944
|
key: 0,
|
|
948
945
|
class: "comments-wrapper"
|
|
949
|
-
},
|
|
946
|
+
}, un = ["disabled"], dn = {
|
|
950
947
|
key: 0,
|
|
951
948
|
class: "ac-loading ac-loading-xs ac-loading-spinner"
|
|
952
|
-
},
|
|
949
|
+
}, mn = {
|
|
953
950
|
key: 1,
|
|
954
951
|
class: "py-8 text-center"
|
|
955
|
-
},
|
|
952
|
+
}, pn = {
|
|
956
953
|
name: "CommentSections"
|
|
957
|
-
},
|
|
958
|
-
...
|
|
954
|
+
}, fn = /* @__PURE__ */ D({
|
|
955
|
+
...pn,
|
|
959
956
|
setup(e) {
|
|
960
|
-
const { t: s } = U(), t =
|
|
957
|
+
const { t: s } = U(), t = G();
|
|
961
958
|
function n() {
|
|
962
959
|
t.start += 20, t.loadComments();
|
|
963
960
|
}
|
|
964
|
-
return
|
|
961
|
+
return ne(() => {
|
|
965
962
|
t.isLoaded || t.loadComments();
|
|
966
|
-
}), (i, d) => m(t).isLoaded ? (f(), v("div",
|
|
967
|
-
(f(!0), v(
|
|
968
|
-
key:
|
|
969
|
-
"ancestor-id":
|
|
970
|
-
comment:
|
|
971
|
-
"parent-id":
|
|
963
|
+
}), (i, d) => m(t).isLoaded ? (f(), v("div", ln, [
|
|
964
|
+
(f(!0), v(P, null, Te(Object.values(m(t).comments).reverse(), (l) => (f(), B(cn, {
|
|
965
|
+
key: l.id,
|
|
966
|
+
"ancestor-id": l.id,
|
|
967
|
+
comment: l,
|
|
968
|
+
"parent-id": l.parentId,
|
|
972
969
|
"is-first-level": ""
|
|
973
970
|
}, null, 8, ["ancestor-id", "comment", "parent-id"]))), 128)),
|
|
974
971
|
m(t).hasMore ? (f(), v("button", {
|
|
@@ -978,40 +975,40 @@ const Ht = { class: "flex items-center gap-2 text-sm text-base-content dark:text
|
|
|
978
975
|
type: "button",
|
|
979
976
|
onClick: n
|
|
980
977
|
}, [
|
|
981
|
-
m(t).loadingMore ? (f(), v("span",
|
|
982
|
-
|
|
983
|
-
], 8,
|
|
984
|
-
])) : (f(), v("div",
|
|
985
|
-
|
|
978
|
+
m(t).loadingMore ? (f(), v("span", dn)) : C("", !0),
|
|
979
|
+
z(" " + A(m(s)("load_more")), 1)
|
|
980
|
+
], 8, un)) : C("", !0)
|
|
981
|
+
])) : (f(), v("div", mn, [...d[0] || (d[0] = [
|
|
982
|
+
w("span", { class: "ac-loading ac-loading-spinner text-base-content" }, null, -1)
|
|
986
983
|
])]));
|
|
987
984
|
}
|
|
988
|
-
}),
|
|
985
|
+
}), hn = { class: "awesome-comment" }, vn = {
|
|
989
986
|
key: 0,
|
|
990
987
|
class: "ac-alert ac-alert-error mb-4"
|
|
991
|
-
},
|
|
988
|
+
}, gn = { class: "flex justify-between items-center py-2" }, yn = { class: "text-lg font-bold text-base-content my-0" }, bn = {
|
|
992
989
|
key: 0,
|
|
993
990
|
class: "ac-loading ac-loading-spinner"
|
|
994
|
-
},
|
|
991
|
+
}, _n = {
|
|
995
992
|
key: 1,
|
|
996
993
|
class: "ac-dropdown ac-dropdown-end"
|
|
997
|
-
},
|
|
994
|
+
}, wn = {
|
|
998
995
|
key: 0,
|
|
999
996
|
class: "ac-avatar flex",
|
|
1000
997
|
tabindex: "0"
|
|
1001
|
-
},
|
|
998
|
+
}, kn = { class: "block w-6 h-6 rounded-full" }, xn = ["alt", "src"], An = {
|
|
1002
999
|
key: 1,
|
|
1003
1000
|
class: "ac-btn ac-btn-ghost",
|
|
1004
1001
|
tabindex: "0"
|
|
1005
|
-
},
|
|
1002
|
+
}, In = {
|
|
1006
1003
|
class: "ac-dropdown-content z-10 ac-menu p-2 shadow bg-base-100 rounded-box w-52",
|
|
1007
1004
|
tabindex: "0"
|
|
1008
|
-
},
|
|
1005
|
+
}, $n = {
|
|
1009
1006
|
key: 0,
|
|
1010
1007
|
class: "border-b border-neutral pb-2 mb-2 pointer-events-none"
|
|
1011
|
-
},
|
|
1008
|
+
}, Cn = { class: "text-base-content" }, Sn = ["disabled"], En = ["disabled"], Tn = /* @__PURE__ */ D({
|
|
1012
1009
|
__name: "App",
|
|
1013
1010
|
setup(e) {
|
|
1014
|
-
const s =
|
|
1011
|
+
const s = G(), { t } = U(), n = oe(), i = I(), d = J(() => {
|
|
1015
1012
|
const r = s.hasMore ? s.total + "+" : s.total;
|
|
1016
1013
|
if (s.total === 0) return "0";
|
|
1017
1014
|
const a = new CustomEvent("AwesomeComment:total", {
|
|
@@ -1021,17 +1018,17 @@ const Ht = { class: "flex items-center gap-2 text-sm text-base-content dark:text
|
|
|
1021
1018
|
});
|
|
1022
1019
|
return document.body.dispatchEvent(a), r;
|
|
1023
1020
|
});
|
|
1024
|
-
function
|
|
1021
|
+
function l() {
|
|
1025
1022
|
n.login();
|
|
1026
1023
|
}
|
|
1027
|
-
function
|
|
1024
|
+
function c() {
|
|
1028
1025
|
n.logout({
|
|
1029
1026
|
openUrl: !1
|
|
1030
1027
|
});
|
|
1031
1028
|
}
|
|
1032
1029
|
async function o() {
|
|
1033
1030
|
if (!n.isAwesomeAuth || n.isAuthenticated) return;
|
|
1034
|
-
await
|
|
1031
|
+
await me();
|
|
1035
1032
|
const r = i.value;
|
|
1036
1033
|
if (!r) return;
|
|
1037
1034
|
r.innerHTML = "";
|
|
@@ -1043,43 +1040,43 @@ const Ht = { class: "flex items-center gap-2 text-sm text-base-content dark:text
|
|
|
1043
1040
|
shape: "pill"
|
|
1044
1041
|
});
|
|
1045
1042
|
}
|
|
1046
|
-
return
|
|
1043
|
+
return ne(() => {
|
|
1047
1044
|
o();
|
|
1048
|
-
}),
|
|
1045
|
+
}), K(
|
|
1049
1046
|
() => n.isAuthenticated,
|
|
1050
1047
|
(r) => {
|
|
1051
1048
|
r || o();
|
|
1052
1049
|
}
|
|
1053
|
-
), (r, a) => (f(), v("div",
|
|
1054
|
-
m(s).message ? (f(), v("div",
|
|
1055
|
-
|
|
1056
|
-
])) :
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
m(n).isLoading ? (f(), v("span",
|
|
1060
|
-
m(n).user.picture ? (f(), v("label",
|
|
1061
|
-
|
|
1062
|
-
|
|
1050
|
+
), (r, a) => (f(), v("div", hn, [
|
|
1051
|
+
m(s).message ? (f(), v("div", vn, [
|
|
1052
|
+
w("p", null, A(m(s).message), 1)
|
|
1053
|
+
])) : C("", !0),
|
|
1054
|
+
w("header", gn, [
|
|
1055
|
+
w("h2", yn, A(m(t)("discussion")) + " (" + A(d.value) + ") ", 1),
|
|
1056
|
+
m(n).isLoading ? (f(), v("span", bn)) : m(n).isAuthenticated && m(n).user ? (f(), v("div", _n, [
|
|
1057
|
+
m(n).user.picture ? (f(), v("label", wn, [
|
|
1058
|
+
w("span", kn, [
|
|
1059
|
+
w("img", {
|
|
1063
1060
|
alt: m(n).user.name || m(n).user.email,
|
|
1064
1061
|
src: m(n).user.picture,
|
|
1065
1062
|
class: "w-full h-full block"
|
|
1066
|
-
}, null, 8,
|
|
1063
|
+
}, null, 8, xn)
|
|
1067
1064
|
])
|
|
1068
|
-
])) : (f(), v("label",
|
|
1069
|
-
|
|
1070
|
-
m(n).user.picture ? (f(), v("li",
|
|
1071
|
-
|
|
1072
|
-
])) :
|
|
1073
|
-
|
|
1074
|
-
|
|
1065
|
+
])) : (f(), v("label", An, A(m(n).user.email), 1)),
|
|
1066
|
+
w("ul", In, [
|
|
1067
|
+
m(n).user.picture ? (f(), v("li", $n, [
|
|
1068
|
+
w("span", Cn, A(m(n).user.email), 1)
|
|
1069
|
+
])) : C("", !0),
|
|
1070
|
+
w("li", null, [
|
|
1071
|
+
w("button", {
|
|
1075
1072
|
disabled: m(n).isLoading,
|
|
1076
1073
|
class: "border-0 bg-base-100",
|
|
1077
1074
|
type: "button",
|
|
1078
|
-
onClick:
|
|
1079
|
-
},
|
|
1075
|
+
onClick: c
|
|
1076
|
+
}, A(m(t)("logout")), 9, Sn)
|
|
1080
1077
|
])
|
|
1081
1078
|
])
|
|
1082
|
-
])) : (f(), v(
|
|
1079
|
+
])) : (f(), v(P, { key: 2 }, [
|
|
1083
1080
|
m(n).isAwesomeAuth ? (f(), v("div", {
|
|
1084
1081
|
key: 0,
|
|
1085
1082
|
ref_key: "googleButton",
|
|
@@ -1090,39 +1087,39 @@ const Ht = { class: "flex items-center gap-2 text-sm text-base-content dark:text
|
|
|
1090
1087
|
disabled: m(n).isLoading,
|
|
1091
1088
|
class: "ac-btn ac-btn-secondary ac-btn-xs",
|
|
1092
1089
|
type: "button",
|
|
1093
|
-
onClick:
|
|
1094
|
-
},
|
|
1090
|
+
onClick: l
|
|
1091
|
+
}, A(m(t)("login")), 9, En))
|
|
1095
1092
|
], 64))
|
|
1096
1093
|
]),
|
|
1097
|
-
|
|
1098
|
-
|
|
1094
|
+
j(X),
|
|
1095
|
+
j(fn)
|
|
1099
1096
|
]));
|
|
1100
1097
|
}
|
|
1101
1098
|
}), Ee = [];
|
|
1102
|
-
let
|
|
1103
|
-
function
|
|
1099
|
+
let de = 0, fe = null;
|
|
1100
|
+
function Ln({
|
|
1104
1101
|
domain: e,
|
|
1105
1102
|
clientId: s,
|
|
1106
1103
|
locale: t = navigator.language
|
|
1107
1104
|
}) {
|
|
1108
|
-
const n =
|
|
1105
|
+
const n = Fe(Tn), i = Ke(), d = fe || e && s && Ne({
|
|
1109
1106
|
domain: e,
|
|
1110
1107
|
clientId: s,
|
|
1111
1108
|
authorizationParams: {
|
|
1112
1109
|
redirect_uri: location.origin
|
|
1113
1110
|
}
|
|
1114
|
-
}),
|
|
1111
|
+
}), l = Ve({
|
|
1115
1112
|
legacy: !1,
|
|
1116
1113
|
locale: t,
|
|
1117
1114
|
fallbackLocale: "en",
|
|
1118
1115
|
messages: {
|
|
1119
|
-
...
|
|
1116
|
+
...Ge(ke, "cn"),
|
|
1120
1117
|
"zh-CN": ke.cn
|
|
1121
1118
|
}
|
|
1122
1119
|
});
|
|
1123
|
-
return d && n.use(d), n.use(i), n.use(
|
|
1120
|
+
return d && n.use(d), n.use(i), n.use(l), n;
|
|
1124
1121
|
}
|
|
1125
|
-
const
|
|
1122
|
+
const Dn = {
|
|
1126
1123
|
postId: "",
|
|
1127
1124
|
apiUrl: "",
|
|
1128
1125
|
domain: "",
|
|
@@ -1136,14 +1133,14 @@ const jn = {
|
|
|
1136
1133
|
domain: n,
|
|
1137
1134
|
clientId: i,
|
|
1138
1135
|
awesomeAuth: d,
|
|
1139
|
-
turnstileSiteKey:
|
|
1140
|
-
locale:
|
|
1136
|
+
turnstileSiteKey: l,
|
|
1137
|
+
locale: c = navigator.language,
|
|
1141
1138
|
siteId: o,
|
|
1142
1139
|
autoFocus: r
|
|
1143
1140
|
} = {}) {
|
|
1144
|
-
s ??= this.postId, t ??= this.apiUrl, n ??= this.domain || "", i ??= this.clientId, d ??= this.awesomeAuth,
|
|
1145
|
-
const a =
|
|
1146
|
-
a.provide("ApiBaseUrl", t), a.provide("postId", s), a.provide("Auth0Domain", n), a.provide("comments", Ee), a.provide("total",
|
|
1141
|
+
s ??= this.postId, t ??= this.apiUrl, n ??= this.domain || "", i ??= this.clientId, d ??= this.awesomeAuth, l ??= this.turnstileSiteKey, o ??= this.siteId;
|
|
1142
|
+
const a = Ln({ domain: n, clientId: i, locale: c });
|
|
1143
|
+
a.provide("ApiBaseUrl", t), a.provide("postId", s), a.provide("Auth0Domain", n), a.provide("comments", Ee), a.provide("total", de), a.provide("awesomeAuth", d), a.provide("TurnstileSiteKey", l), a.provide("siteId", o), a.provide("AutoFocus", r || !1), a.mount(e);
|
|
1147
1144
|
},
|
|
1148
1145
|
async preload({
|
|
1149
1146
|
postId: e,
|
|
@@ -1152,9 +1149,9 @@ const jn = {
|
|
|
1152
1149
|
clientId: n,
|
|
1153
1150
|
awesomeAuth: i,
|
|
1154
1151
|
turnstileSiteKey: d,
|
|
1155
|
-
siteId:
|
|
1152
|
+
siteId: l
|
|
1156
1153
|
}) {
|
|
1157
|
-
if (this.postId = e || "", this.apiUrl = s || "", this.domain = t || "", this.clientId = n || "", this.turnstileSiteKey = d || "", this.siteId =
|
|
1154
|
+
if (this.postId = e || "", this.apiUrl = s || "", this.domain = t || "", this.clientId = n || "", this.turnstileSiteKey = d || "", this.siteId = l || "", t && n && (fe = Ne({
|
|
1158
1155
|
domain: t,
|
|
1159
1156
|
clientId: n,
|
|
1160
1157
|
authorizationParams: {
|
|
@@ -1163,22 +1160,22 @@ const jn = {
|
|
|
1163
1160
|
})), !fe && !i)
|
|
1164
1161
|
throw new Error("You need at least 1 Auth provider.");
|
|
1165
1162
|
this.awesomeAuth = i;
|
|
1166
|
-
const
|
|
1167
|
-
|
|
1168
|
-
const o = await fetch(`${s}/api/comments?${
|
|
1163
|
+
const c = new URLSearchParams();
|
|
1164
|
+
c.set("postId", e), l && c.set("siteId", l);
|
|
1165
|
+
const o = await fetch(`${s}/api/comments?${c.toString()}`);
|
|
1169
1166
|
o.ok || console.log("[Awesome comment] Failed to preload comments.");
|
|
1170
1167
|
const r = await o.json();
|
|
1171
1168
|
if (r.data) {
|
|
1172
|
-
Ee.push(...r.data),
|
|
1169
|
+
Ee.push(...r.data), de = r.meta?.total || r.data.length;
|
|
1173
1170
|
const a = new CustomEvent("AwesomeComment:total", {
|
|
1174
1171
|
bubbles: !0,
|
|
1175
1172
|
cancelable: !0,
|
|
1176
|
-
detail:
|
|
1173
|
+
detail: de
|
|
1177
1174
|
});
|
|
1178
1175
|
document.body.dispatchEvent(a);
|
|
1179
1176
|
}
|
|
1180
1177
|
}
|
|
1181
1178
|
};
|
|
1182
1179
|
export {
|
|
1183
|
-
|
|
1180
|
+
Dn as default
|
|
1184
1181
|
};
|