fansunited-frontend-components 0.0.97 → 0.0.99

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 (69) hide show
  1. package/Betslip.js +2 -2
  2. package/ChanceGame.js +958 -1464
  3. package/ClassicQuizPlay.js +2 -2
  4. package/CollectLead.js +1 -1
  5. package/CompetitionStatistics.js +2042 -2215
  6. package/CompetitorCard.js +4281 -4919
  7. package/Discussion.js +2 -2
  8. package/EitherOrPlay.js +2 -2
  9. package/EventCard.js +6010 -7547
  10. package/EventGamePlay.js +2 -2
  11. package/Leaderboard.js +546 -849
  12. package/List.js +227 -218
  13. package/MatchQuizPlay.js +2 -2
  14. package/Odds.js +50 -42
  15. package/PersonalityQuizPlay.js +2 -2
  16. package/PickThePair.js +2 -2
  17. package/PlayerOfTheMatch.js +285 -269
  18. package/PollVote.js +2 -2
  19. package/Predictor.js +80 -127
  20. package/README.md +1 -1
  21. package/Standings.js +991 -1324
  22. package/TopX.js +1120 -1167
  23. package/chunks/{ChanceGameEmbedVariant-CVys-3Zh.js → ChanceGameEmbedVariant-DM9eLG5s.js} +2 -2
  24. package/chunks/CheckCircle-I1FktW5Y.js +13 -0
  25. package/chunks/OddsSkeleton-DP5Yfqpr.js +522 -0
  26. package/chunks/Person-CXRqyF4E.js +11 -0
  27. package/chunks/PickOneOfX-DET4ZhjV.js +3117 -0
  28. package/chunks/Search-CIXthh0D.js +17 -0
  29. package/chunks/TimerOutlined-D-WA_vpE.js +8 -0
  30. package/chunks/WorkspacePremiumOutlined-DUXVgJlF.js +136 -0
  31. package/chunks/{chevrons-right-CXSpQt9w.js → chevrons-right-HWKW2c4I.js} +24 -4
  32. package/chunks/index-BENM3N_w.js +4 -0
  33. package/chunks/index-BRxAV693.js +4 -0
  34. package/chunks/index-BXYTsvIX.js +4 -0
  35. package/chunks/index-C0ilols1.js +4 -0
  36. package/chunks/index-D7VhczXH.js +4 -0
  37. package/chunks/index-DKwvdw9t.js +4 -0
  38. package/chunks/index-DZN-AITW.js +4 -0
  39. package/chunks/main-B2sDRFF4.js +2184 -0
  40. package/chunks/main-CzfWaEQP.js +4869 -0
  41. package/chunks/main-DFNl3g_U.js +4910 -0
  42. package/chunks/{main-65WcUqAl.js → main-DLwnvntz.js} +600 -593
  43. package/chunks/main-DiBlJBNb.js +1956 -0
  44. package/chunks/main-DxvBjXsd.js +1775 -0
  45. package/chunks/main-S8_NDSiY.js +3209 -0
  46. package/chunks/main-lBgr8Liq.js +6571 -0
  47. package/chunks/{withVersionStamp-BkiEu_79.js → withVersionStamp-BsLyhvNA.js} +1 -1
  48. package/package.json +2 -2
  49. package/chunks/OddsSkeleton-ClJE2xhR.js +0 -26
  50. package/chunks/OddsStrip-BnSp5TXa.js +0 -383
  51. package/chunks/PickOneOfX-DaJtkbCw.js +0 -4206
  52. package/chunks/chevron-left-CxfCSZcr.js +0 -13
  53. package/chunks/chevron-right-BEQMacFn.js +0 -13
  54. package/chunks/index-Aq5MbUB9.js +0 -4
  55. package/chunks/index-BBQm_8LD.js +0 -4
  56. package/chunks/index-BC_sWWgc.js +0 -4
  57. package/chunks/index-DXKDJ1Vp.js +0 -4
  58. package/chunks/index-DjT5NrbA.js +0 -4
  59. package/chunks/index-DvLRehH6.js +0 -4
  60. package/chunks/index-aIMaxR-p.js +0 -4
  61. package/chunks/main-52Wff7qC.js +0 -11441
  62. package/chunks/main-B58mi9jx.js +0 -5622
  63. package/chunks/main-BIdXUTZS.js +0 -7308
  64. package/chunks/main-DD-NEzC7.js +0 -8241
  65. package/chunks/main-DUnfJPzY.js +0 -3608
  66. package/chunks/main-DpCBqqg_.js +0 -1950
  67. package/chunks/main-Drznt1ak.js +0 -1790
  68. package/chunks/users-wbJRbqW8.js +0 -16
  69. package/chunks/x-CK4GYo7T.js +0 -14
@@ -0,0 +1,1956 @@
1
+ import { jsxs as S, jsx as n, Fragment as Re } from "@emotion/react/jsx-runtime";
2
+ import { InlineSpinner as vt, Modal as ut, Avatar as St, Notification as pt, useSelect as wt, Spinner as We, WidgetPortal as Ct } from "fansunited-frontend-core/ui/emotion";
3
+ import Ie, { useState as D, useEffect as he, useRef as W, useCallback as Se, useLayoutEffect as Ne, useId as kt } from "react";
4
+ import { useDisableCache as Rt, useColors as It, useIsRtl as Et, useConstantContext as je, ConstantsContext as Ve, toIntlLocale as ft } from "fansunited-frontend-core";
5
+ import { css as o } from "@emotion/react";
6
+ import { useTranslation as ye } from "react-i18next";
7
+ import { ThumbUpIcon as Dt, ThumbDownIcon as Bt, FavoriteIcon as Tt, SentimentSatisfiedIcon as Pt, FavoriteBorderIcon as Mt, EmojiEmotionsIcon as At, SentimentVeryDissatisfiedIcon as Lt, MoodBadIcon as zt, ReplyIcon as $t, MoreVertIcon as Ft, DeleteIcon as Ht, FlagIcon as Xt, CloseIcon as Ot, PersonIcon as Wt, RemoveCircleOutlineIcon as Nt, BlockIcon as Kt, KeyboardArrowDownIcon as Ut, UnfoldIcon as jt } from "fansunited-frontend-core/ui/icons";
8
+ import { createPortal as Vt } from "react-dom";
9
+ const _t = (t, r) => {
10
+ const [i, s] = D(null), [p, a] = D(!0), [m, d] = D(null), [l, c] = D(!1);
11
+ return he(() => {
12
+ r && (async () => {
13
+ try {
14
+ a(!0);
15
+ const u = await t.discussions.getById(r);
16
+ s(u), d(null), c(!1);
17
+ } catch (u) {
18
+ (t.helpers.getSDKConfiguration().errorHandlingMode === "standard" ? u.error.code === 404 : u.data.error.code === 404) ? (c(!0), d(null), s(null)) : (d(m), s(null), c(!1));
19
+ } finally {
20
+ a(!1);
21
+ }
22
+ })();
23
+ }, [t, r]), { discussion: i, setDiscussion: s, isLoading: p, error: m, isNotFound: l };
24
+ }, Yt = 5e3, Gt = 5, Jt = (t, r, i = null, s = "", p = "LATEST", a = 20, m, d = !1, l = 0) => {
25
+ const c = a <= 0, [h, u] = D([]), [y, b] = D(!c), [g, k] = D(!1), [I, v] = D(null), [f, B] = D(p), [A, E] = D(
26
+ null
27
+ ), [$, J] = D(!1), [U, V] = D(() => /* @__PURE__ */ new Set()), q = W(0), T = Se(
28
+ async (R, w, C = !1) => {
29
+ var M, N;
30
+ C || (q.current += 1, V(/* @__PURE__ */ new Set()));
31
+ try {
32
+ b(!0);
33
+ const X = await t.discussions.getPosts(r, {
34
+ sort: R,
35
+ limit: a,
36
+ startAfter: w,
37
+ skipDeleted: !0,
38
+ skipModerated: !d
39
+ }), ae = X.data;
40
+ u(C ? (F) => [...F, ...ae] : ae);
41
+ const x = !!((M = X.meta.pagination) != null && M.nextPageStartsAfter) && ae.length === a;
42
+ E(
43
+ ((N = X.meta.pagination) == null ? void 0 : N.nextPageStartsAfter) || null
44
+ ), J(x), v(null);
45
+ } catch (X) {
46
+ (t.helpers.getSDKConfiguration().errorHandlingMode === "standard" ? X.error.code === 404 : X.data.error.code === 404) ? (u([]), J(!1), E(null), v(null)) : v(I);
47
+ } finally {
48
+ b(!1);
49
+ }
50
+ },
51
+ [t, r, a, d]
52
+ );
53
+ he(() => {
54
+ if (c) {
55
+ u([]), J(!1), b(!1);
56
+ return;
57
+ }
58
+ r && T(f);
59
+ }, [r, f, T, c]);
60
+ const _ = (R) => {
61
+ B(R), E(null);
62
+ }, oe = W(y);
63
+ oe.current = y;
64
+ const ne = W(A);
65
+ ne.current = A;
66
+ const pe = Se(() => {
67
+ ne.current && !oe.current && T(f, ne.current, !0);
68
+ }, [T, f]), Z = W(h);
69
+ Z.current = h;
70
+ const de = W($);
71
+ de.current = $;
72
+ const re = W(m);
73
+ re.current = m;
74
+ const ie = W(!1), Q = Se(async () => {
75
+ var X, ae;
76
+ if (oe.current || ie.current) return;
77
+ const R = f === "LATEST" || !de.current;
78
+ ie.current = !0;
79
+ const w = q.current, C = Z.current, M = new Map(C.map((x) => [x.id, x])), N = (x) => !M.has(x.id);
80
+ try {
81
+ const x = [], F = /* @__PURE__ */ new Map();
82
+ let ee;
83
+ for (let K = 0; K < Gt; K++) {
84
+ const Y = await t.discussions.getPosts(r, {
85
+ sort: "LATEST",
86
+ limit: a,
87
+ startAfter: ee,
88
+ skipDeleted: !0,
89
+ // Always included, so a shown post that got moderated can be detected
90
+ skipModerated: !1
91
+ }), G = Y.data;
92
+ G.forEach((me) => {
93
+ const Ge = M.get(me.id);
94
+ Ge ? me.moderated && !Ge.moderated && F.set(me.id, me) : (d || !me.moderated) && x.push(me);
95
+ }), ee = ((X = Y.meta.pagination) == null ? void 0 : X.nextPageStartsAfter) || void 0;
96
+ const xe = G.length === a && G.every(N);
97
+ if (!R || !C.length || !xe || !ee) break;
98
+ }
99
+ if (w !== q.current || (F.size && u(
100
+ (K) => d ? K.map((Y) => {
101
+ const G = F.get(Y.id);
102
+ return G ? {
103
+ ...Y,
104
+ moderated: !0,
105
+ moderatedAt: G.moderatedAt,
106
+ moderatedBy: G.moderatedBy,
107
+ moderatedReason: G.moderatedReason
108
+ } : Y;
109
+ }) : K.filter((Y) => !F.has(Y.id))
110
+ ), !R)) return;
111
+ const ke = new Set(Z.current.map((K) => K.id)), ce = x.filter((K) => !ke.has(K.id));
112
+ if (!ce.length) return;
113
+ C.length ? u((K) => {
114
+ const Y = new Set(K.map((xe) => xe.id)), G = ce.filter((xe) => !Y.has(xe.id));
115
+ return f === "LATEST" ? [...G, ...K].sort(
116
+ (xe, me) => Date.parse(me.createdAt) - Date.parse(xe.createdAt)
117
+ ) : [...K, ...G.reverse()];
118
+ }) : await T(f), V((K) => {
119
+ const Y = new Set(K);
120
+ return ce.forEach((G) => Y.add(G.id)), Y;
121
+ }), (ae = re.current) == null || ae.call(re, ce.length);
122
+ } catch {
123
+ } finally {
124
+ ie.current = !1;
125
+ }
126
+ }, [
127
+ t,
128
+ r,
129
+ a,
130
+ d,
131
+ f,
132
+ T
133
+ ]), se = l > 0 ? Math.max(l, Yt) : 0;
134
+ he(() => {
135
+ if (!se || c || !r) return;
136
+ const R = () => {
137
+ document.visibilityState !== "hidden" && Q();
138
+ }, w = () => {
139
+ document.visibilityState === "visible" && Q();
140
+ }, C = setInterval(R, se);
141
+ return document.addEventListener("visibilitychange", w), () => {
142
+ clearInterval(C), document.removeEventListener("visibilitychange", w);
143
+ };
144
+ }, [se, c, r, Q]);
145
+ const P = Se((R) => {
146
+ V((w) => {
147
+ if (!w.has(R)) return w;
148
+ const C = new Set(w);
149
+ return C.delete(R), C;
150
+ });
151
+ }, []);
152
+ return {
153
+ posts: h,
154
+ postsHidden: c,
155
+ isLoading: y,
156
+ isSubmitting: g,
157
+ error: I,
158
+ currentSort: f,
159
+ hasMore: $,
160
+ newPostIds: U,
161
+ markPostSeen: P,
162
+ handleSortChange: _,
163
+ handleLoadMore: pe,
164
+ handleCreatePost: async (R, w) => {
165
+ try {
166
+ k(!0);
167
+ let M = await t.discussions.createPost(r, {
168
+ content: R,
169
+ replyId: w || null,
170
+ userNickname: null,
171
+ discussionLabel: i,
172
+ discussionUrl: s,
173
+ context: {
174
+ content: null,
175
+ tags: [],
176
+ campaign: null
177
+ }
178
+ });
179
+ try {
180
+ const N = await t.profile.getOwn().getInfo();
181
+ M = { ...M, userModel: N };
182
+ } catch {
183
+ }
184
+ w ? u(
185
+ (N) => N.map(
186
+ (X) => X.id === w ? { ...X, repliesCount: (X.repliesCount || 0) + 1 } : X
187
+ )
188
+ ) : c || u((N) => [M, ...N]), m == null || m(1), v(null);
189
+ } catch (C) {
190
+ throw v(
191
+ C
192
+ ), C;
193
+ } finally {
194
+ k(!1);
195
+ }
196
+ },
197
+ handleReact: async (R, w) => {
198
+ try {
199
+ const C = await t.discussions.react(R, w);
200
+ return u(
201
+ (M) => M.map((N) => N.id === R ? C : N)
202
+ ), v(null), C;
203
+ } catch (C) {
204
+ throw console.error("Error reacting to post:", C), v(
205
+ C
206
+ ), C;
207
+ }
208
+ },
209
+ handleDeletePost: async (R, w) => {
210
+ try {
211
+ await t.discussions.deletePost(R), u((C) => C.filter((M) => M.id !== R)), w && u(
212
+ (C) => C.map(
213
+ (M) => M.id === w ? { ...M, repliesCount: Math.max(0, (M.repliesCount || 0) - 1) } : M
214
+ )
215
+ ), m == null || m(-1), v(null);
216
+ } catch (C) {
217
+ throw v(
218
+ C
219
+ ), C;
220
+ }
221
+ },
222
+ handleReportPost: async (R, w, C) => {
223
+ try {
224
+ await t.discussions.reportPost(R, w, C), v(null);
225
+ } catch (M) {
226
+ throw v(
227
+ M
228
+ ), M;
229
+ }
230
+ }
231
+ };
232
+ }, qt = async (t) => {
233
+ var r;
234
+ try {
235
+ const s = (r = t.helpers.getSDKConfiguration().authProvider) == null ? void 0 : r.getIdToken(), p = s == null ? void 0 : s.split(".")[1];
236
+ if (!p) return null;
237
+ const { sub: a } = JSON.parse(
238
+ atob(p.replace(/-/g, "+").replace(/_/g, "/"))
239
+ );
240
+ return typeof a == "string" && a ? a : null;
241
+ } catch {
242
+ return null;
243
+ }
244
+ }, Zt = (t, r) => {
245
+ var d;
246
+ const [i, s] = D(null), p = Rt(), a = Se(
247
+ async (l) => {
248
+ if (!r) {
249
+ s(null);
250
+ return;
251
+ }
252
+ try {
253
+ const c = await qt(t);
254
+ if (!c) return;
255
+ s(await t.discussions.getUserBan(c, l));
256
+ } catch (c) {
257
+ console.error("Failed to get user ban:", c);
258
+ }
259
+ },
260
+ [t, r]
261
+ );
262
+ he(() => {
263
+ a(p);
264
+ }, [a, p]);
265
+ const m = Se(() => a(!0), [a]);
266
+ return { ban: i, isBanned: !!((d = i == null ? void 0 : i.activeBan) != null && d.banned), refresh: m };
267
+ }, mt = (t) => {
268
+ var r, i, s;
269
+ return (((r = t == null ? void 0 : t.error) == null ? void 0 : r.status) ?? ((s = (i = t == null ? void 0 : t.data) == null ? void 0 : i.error) == null ? void 0 : s.status)) === "ban";
270
+ }, e = {
271
+ surface: "var(--fu-ucrc-surface)",
272
+ surfaceVariant: "var(--fu-ucrc-surface-variant)",
273
+ text: "var(--fu-ucrc-text-primary)",
274
+ textSecondary: "var(--fu-ucrc-text-secondary)",
275
+ textBody: "var(--fu-ucrc-text-body)",
276
+ border: "var(--fu-ucrc-outline-enabled-border)",
277
+ primary: "var(--fu-ucrc-primary-plain-color)",
278
+ onPrimary: "var(--fu-ucrc-primary-on-primary)",
279
+ danger: "var(--fu-ucrc-danger-plain-color)",
280
+ dangerSoft: "var(--fu-ucrc-danger-soft-bg)",
281
+ // Joy's own defaults, where a Joy component painted something the client theme doesn't set.
282
+ joyText: "var(--fu-ucrc-joy-text-primary)",
283
+ icon: "var(--fu-ucrc-joy-text-icon)",
284
+ focus: "var(--fu-ucrc-focus-visible)",
285
+ fontPrimary: "var(--fu-ucrc-font-primary)",
286
+ fontBody: "var(--fu-ucrc-font-body)",
287
+ radiusXs: "var(--fu-ucrc-radius-xs)",
288
+ radiusSm: "var(--fu-ucrc-radius-sm)",
289
+ radiusMd: "var(--fu-ucrc-radius-md)",
290
+ radiusLg: "var(--fu-ucrc-radius-lg)",
291
+ radiusFull: "var(--fu-ucrc-radius-full)",
292
+ space2xs: "var(--fu-ucrc-space-2xs)",
293
+ spaceXs: "var(--fu-ucrc-space-xs)",
294
+ spaceSm: "var(--fu-ucrc-space-sm)",
295
+ spaceMd: "var(--fu-ucrc-space-md)",
296
+ spaceLg: "var(--fu-ucrc-space-lg)",
297
+ spaceXl: "var(--fu-ucrc-space-xl)",
298
+ primary14: "var(--fu-ucrc-dsc-primary-14)",
299
+ primary1a: "var(--fu-ucrc-dsc-primary-1a)",
300
+ primary1f: "var(--fu-ucrc-dsc-primary-1f)",
301
+ text14: "var(--fu-ucrc-dsc-text-14)",
302
+ danger1f: "var(--fu-ucrc-dsc-danger-1f)",
303
+ danger33: "var(--fu-ucrc-dsc-danger-33)"
304
+ }, _e = () => {
305
+ const t = It(), r = t.palette.primary.plainColor, i = t.palette.danger.plainColor, s = t.textPrimary;
306
+ return Ie.useMemo(
307
+ () => ({
308
+ "--fu-ucrc-dsc-primary-14": `${r}14`,
309
+ "--fu-ucrc-dsc-primary-1a": `${r}1A`,
310
+ "--fu-ucrc-dsc-primary-1f": `${r}1F`,
311
+ "--fu-ucrc-dsc-text-14": `${s}14`,
312
+ "--fu-ucrc-dsc-danger-1f": `${i}1F`,
313
+ "--fu-ucrc-dsc-danger-33": `${i}33`
314
+ }),
315
+ [r, i, s]
316
+ );
317
+ }, ve = (t, r, i) => o({ margin: 0, fontFamily: e.fontBody, fontSize: t, fontWeight: r, lineHeight: i }), z = {
318
+ h3: o(ve("1.5em", 600, 1.33334), { letterSpacing: "-0.025em", color: e.joyText }),
319
+ titleLg: o(ve("1.25em", 600, 1.33334), { color: e.joyText }),
320
+ titleMd: o(ve("1em", 500, 1.5), { color: e.joyText }),
321
+ titleSm: ve("0.875em", 500, 1.42858),
322
+ bodyMd: ve("1em", 400, 1.5),
323
+ bodySm: ve("0.875em", 400, 1.5),
324
+ bodyXs: ve("0.75em", 500, 1.5)
325
+ }, Ye = o({
326
+ boxSizing: "border-box",
327
+ position: "relative",
328
+ display: "inline-flex",
329
+ alignItems: "center",
330
+ justifyContent: "center",
331
+ minHeight: "2.25em",
332
+ margin: 0,
333
+ paddingBlock: "0.375em",
334
+ paddingInline: "1em",
335
+ border: "none",
336
+ borderRadius: e.radiusSm,
337
+ font: "inherit",
338
+ fontSize: "1em",
339
+ backgroundColor: "transparent",
340
+ cursor: "pointer",
341
+ userSelect: "none",
342
+ "&:focus-visible": { outline: `2px solid ${e.focus}`, outlineOffset: "2px" },
343
+ "&:disabled": { pointerEvents: "none", cursor: "default" }
344
+ }), Qt = o(Ye, {
345
+ fontFamily: e.fontPrimary,
346
+ color: e.onPrimary,
347
+ backgroundColor: e.primary,
348
+ "&:active": { backgroundColor: "var(--fu-ucrc-primary-solid-active-bg)" },
349
+ "&:hover": { backgroundColor: e.primary, opacity: 0.9 },
350
+ "&:disabled": { opacity: 0.4 }
351
+ }), Je = o(Ye, {
352
+ fontFamily: e.fontPrimary,
353
+ color: e.text,
354
+ "&:active": { backgroundColor: "var(--fu-ucrc-primary-plain-active-bg)" },
355
+ "&:hover": { backgroundColor: e.text14 },
356
+ "&:disabled": { color: "var(--fu-ucrc-neutral-plain-disabled-color)" }
357
+ }), qe = o(Ye, {
358
+ border: `1px solid ${e.primary}`,
359
+ color: e.primary,
360
+ "&:active": { backgroundColor: "var(--fu-ucrc-primary-outlined-active-bg)" },
361
+ "&:hover": { backgroundColor: e.primary14, borderColor: e.primary },
362
+ "&:disabled": { opacity: 0.4 }
363
+ }), Pe = {
364
+ solid: Qt,
365
+ plain: Je,
366
+ outlined: qe,
367
+ signIn: o(qe, { width: "100%", paddingBlock: e.spaceSm, fontFamily: e.fontPrimary }),
368
+ // Joy's small plain button, as the post's Reply action.
369
+ reply: o(Je, {
370
+ minHeight: "auto",
371
+ marginInlineStart: e.spaceXs,
372
+ paddingBlock: e.space2xs,
373
+ paddingInline: e.spaceXs,
374
+ fontSize: "0.8125em",
375
+ fontWeight: 600
376
+ }),
377
+ decorator: o({ display: "inherit", marginInlineEnd: "calc(0.375em / 0.8125)" }),
378
+ loading: o({ display: "flex", position: "absolute", left: "50%", transform: "translateX(-50%)" })
379
+ }, ue = ({ look: t, loading: r, startDecorator: i, disabled: s, children: p, ...a }) => /* @__PURE__ */ S("button", { type: "button", css: Pe[t], disabled: s || r, ...a, children: [
380
+ i && /* @__PURE__ */ n("span", { css: Pe.decorator, children: i }),
381
+ p,
382
+ r && /* @__PURE__ */ n("span", { css: Pe.loading, children: /* @__PURE__ */ n(vt, { size: 20, color: "var(--fu-ucrc-primary-solid-bg)" }) })
383
+ ] }), Me = {
384
+ // Joy's outlined Textarea with the widget's overrides.
385
+ root: o({
386
+ boxSizing: "border-box",
387
+ position: "relative",
388
+ display: "flex",
389
+ flexDirection: "column",
390
+ minWidth: 0,
391
+ minHeight: "2.25em",
392
+ paddingBlock: "calc(0.375em - 1px)",
393
+ paddingInlineStart: "0.75em",
394
+ border: `1px solid ${e.border}`,
395
+ borderRadius: e.radiusSm,
396
+ backgroundColor: e.surfaceVariant,
397
+ color: e.text,
398
+ fontFamily: e.fontBody,
399
+ fontSize: "1em",
400
+ fontWeight: 400,
401
+ lineHeight: 1.5,
402
+ cursor: "text",
403
+ "&:focus-within": { borderColor: e.primary },
404
+ "&[data-disabled]": {
405
+ pointerEvents: "none",
406
+ cursor: "default",
407
+ color: "var(--fu-ucrc-neutral-outlined-disabled-color)",
408
+ borderColor: "var(--fu-ucrc-neutral-outlined-disabled-border)"
409
+ }
410
+ }),
411
+ textarea: o({
412
+ flex: "auto",
413
+ alignSelf: "stretch",
414
+ minWidth: 0,
415
+ margin: 0,
416
+ padding: 0,
417
+ paddingInlineEnd: "0.75em",
418
+ border: "none",
419
+ outline: 0,
420
+ resize: "none",
421
+ color: "inherit",
422
+ backgroundColor: "transparent",
423
+ font: "inherit",
424
+ "&::placeholder": { color: "inherit", opacity: 0.64 }
425
+ })
426
+ }, eo = {
427
+ visibility: "hidden",
428
+ position: "absolute",
429
+ overflow: "hidden",
430
+ height: 0,
431
+ top: 0,
432
+ left: 0,
433
+ transform: "translateZ(0)",
434
+ paddingTop: 0,
435
+ paddingBottom: 0
436
+ }, De = (t) => parseInt(t, 10) || 0, gt = ({
437
+ value: t,
438
+ onChange: r,
439
+ placeholder: i,
440
+ minRows: s,
441
+ maxRows: p,
442
+ disabled: a,
443
+ marginBottom: m
444
+ }) => {
445
+ const d = W(null), l = W(null), c = W(null), h = Se(() => {
446
+ const u = d.current, y = l.current;
447
+ if (!u || !y) return;
448
+ const b = getComputedStyle(u);
449
+ if (b.width === "0px") return;
450
+ y.style.width = b.width, y.value = u.value || i || "x", y.value.slice(-1) === `
451
+ ` && (y.value += " ");
452
+ const g = y.scrollHeight;
453
+ y.value = "x";
454
+ const k = y.scrollHeight, I = Math.max(Math.min(Math.max(s * k, g), p * k), k), v = I + (b.boxSizing === "border-box" ? De(b.paddingTop) + De(b.paddingBottom) + De(b.borderTopWidth) + De(b.borderBottomWidth) : 0);
455
+ v !== 0 && (c.current !== v && (c.current = v, u.style.height = `${v}px`), u.style.overflow = Math.abs(I - g) <= 1 ? "hidden" : "");
456
+ }, [s, p, i]);
457
+ return Ne(() => {
458
+ h();
459
+ }), Ne(() => {
460
+ const u = d.current;
461
+ if (!u) return;
462
+ const y = new ResizeObserver(() => h());
463
+ return y.observe(u), window.addEventListener("resize", h), () => {
464
+ y.disconnect(), window.removeEventListener("resize", h);
465
+ };
466
+ }, [h]), /* @__PURE__ */ S("div", { css: Me.root, "data-disabled": a || void 0, style: { marginBottom: m }, children: [
467
+ /* @__PURE__ */ n(
468
+ "textarea",
469
+ {
470
+ ref: d,
471
+ css: Me.textarea,
472
+ rows: s,
473
+ value: t,
474
+ placeholder: i,
475
+ disabled: a,
476
+ onChange: (u) => r(u.target.value)
477
+ }
478
+ ),
479
+ /* @__PURE__ */ n("textarea", { ref: l, css: Me.textarea, "aria-hidden": !0, readOnly: !0, tabIndex: -1, style: eo })
480
+ ] });
481
+ }, Be = {
482
+ form: o({ marginBottom: e.spaceLg }),
483
+ replyingTo: o(z.bodySm, { marginBottom: e.spaceXs, color: e.textSecondary }),
484
+ actions: o({ display: "flex", gap: e.spaceXs, justifyContent: "flex-end" })
485
+ }, ht = ({
486
+ onSubmit: t,
487
+ userIsLoggedIn: r,
488
+ onSignInClick: i,
489
+ placeholder: s,
490
+ isSubmitting: p,
491
+ replyTo: a,
492
+ onCancel: m,
493
+ disabled: d = !1
494
+ }) => {
495
+ const { t: l } = ye(), [c, h] = D(""), u = async (y) => {
496
+ if (y.preventDefault(), !(!c.trim() || d))
497
+ try {
498
+ await t(c), h("");
499
+ } catch (b) {
500
+ console.error("Failed to submit comment:", b);
501
+ }
502
+ };
503
+ return r ? /* @__PURE__ */ S("form", { onSubmit: u, css: Be.form, children: [
504
+ a && /* @__PURE__ */ n("p", { css: Be.replyingTo, children: l("discussion.replyingTo", "Replying to {{name}}", {
505
+ name: a
506
+ }) }),
507
+ /* @__PURE__ */ n(
508
+ gt,
509
+ {
510
+ placeholder: s || l("discussion.writeComment", "Write a comment..."),
511
+ value: c,
512
+ onChange: h,
513
+ minRows: 3,
514
+ maxRows: 8,
515
+ disabled: p || d,
516
+ marginBottom: e.spaceSm
517
+ }
518
+ ),
519
+ /* @__PURE__ */ S("div", { css: Be.actions, children: [
520
+ m && /* @__PURE__ */ n(ue, { look: "plain", onClick: m, disabled: p, children: l("common.cancel", "Cancel") }),
521
+ /* @__PURE__ */ n(
522
+ ue,
523
+ {
524
+ look: "solid",
525
+ type: "submit",
526
+ disabled: !c.trim() || p || d,
527
+ loading: p,
528
+ children: a ? l("discussion.reply", "Reply") : l("discussion.post", "Post")
529
+ }
530
+ )
531
+ ] })
532
+ ] }) : /* @__PURE__ */ n("div", { css: Be.form, children: /* @__PURE__ */ n(ue, { look: "signIn", onClick: i, children: l("discussion.signInToPost", "Sign in to post") }) });
533
+ }, ge = { size: "1em", color: e.icon }, to = {
534
+ LIKE: /* @__PURE__ */ n(Dt, { ...ge }),
535
+ DISLIKE: /* @__PURE__ */ n(Bt, { ...ge }),
536
+ LOVE: /* @__PURE__ */ n(Tt, { ...ge }),
537
+ LAUGH: /* @__PURE__ */ n(Pt, { ...ge }),
538
+ CARE: /* @__PURE__ */ n(Mt, { ...ge }),
539
+ WOW: /* @__PURE__ */ n(At, { ...ge }),
540
+ SAD: /* @__PURE__ */ n(Lt, { ...ge }),
541
+ ANGRY: /* @__PURE__ */ n(zt, { ...ge })
542
+ }, Ae = o({
543
+ display: "inline-flex",
544
+ alignItems: "center",
545
+ gap: e.space2xs,
546
+ paddingInline: e.spaceSm,
547
+ paddingBlock: e.space2xs,
548
+ borderRadius: "18px",
549
+ backgroundColor: "transparent",
550
+ color: e.textSecondary
551
+ }), Le = o(z.bodySm, { fontWeight: 500, color: e.text }), we = {
552
+ idle: Ae,
553
+ primary: o(Ae, { backgroundColor: "var(--fu-ucrc-neutral-soft-bg)", color: e.primary }),
554
+ danger: o(Ae, { backgroundColor: "var(--fu-ucrc-neutral-soft-bg)", color: e.danger })
555
+ }, ze = {
556
+ cursor: "pointer",
557
+ "&:hover": { backgroundColor: "var(--fu-ucrc-neutral-soft-hover-bg)" }
558
+ }, $e = { opacity: 0.5 }, Fe = {
559
+ pill: {
560
+ enabled: {
561
+ idle: o(we.idle, ze),
562
+ primary: o(we.primary, ze),
563
+ danger: o(we.danger, ze)
564
+ },
565
+ disabled: {
566
+ idle: o(we.idle, $e),
567
+ primary: o(we.primary, $e),
568
+ danger: o(we.danger, $e)
569
+ }
570
+ },
571
+ icon: o({ display: "flex", alignItems: "center", fontSize: "1.25em", color: "inherit" }),
572
+ count: { idle: Le, primary: o(Le, { color: e.primary }), danger: o(Le, { color: e.danger }) }
573
+ }, Ze = ({
574
+ reaction: t,
575
+ count: r,
576
+ isActive: i,
577
+ onClick: s,
578
+ disabled: p
579
+ }) => {
580
+ const a = (d) => d >= 1e6 ? (d / 1e6).toFixed(1).replace(/\.0$/, "") + "M" : d >= 1e3 ? (d / 1e3).toFixed(1).replace(/\.0$/, "") + "K" : d.toString(), m = i ? t === "LOVE" || t === "ANGRY" ? "danger" : "primary" : "idle";
581
+ return /* @__PURE__ */ S(
582
+ "div",
583
+ {
584
+ css: Fe.pill[p ? "disabled" : "enabled"][m],
585
+ onClick: p ? void 0 : s,
586
+ children: [
587
+ /* @__PURE__ */ n("div", { css: Fe.icon, children: to[t] }),
588
+ r > 0 && /* @__PURE__ */ n("p", { css: Fe.count[m], children: a(r) })
589
+ ]
590
+ }
591
+ );
592
+ }, bt = (t, r) => {
593
+ const [i, s] = D(null);
594
+ return he(() => {
595
+ (async () => {
596
+ if (r)
597
+ try {
598
+ const a = await t.profile.getOwn().getInfo();
599
+ s(a.id);
600
+ } catch (a) {
601
+ console.error("Failed to get current user ID:", a);
602
+ }
603
+ })();
604
+ }, [r, t]), i;
605
+ }, Qe = {
606
+ row: o({
607
+ display: "flex",
608
+ gap: e.spaceXs,
609
+ alignItems: "center",
610
+ flexWrap: "wrap",
611
+ marginBottom: e.spaceXs
612
+ }),
613
+ // Joy set --Icon-color to the text colour on this button; disabled, it follows the label.
614
+ replyIcon: o({ color: e.text, "button:disabled &": { color: "currentColor" } })
615
+ }, oo = ({
616
+ post: t,
617
+ sdk: r,
618
+ userIsLoggedIn: i,
619
+ onSignInClick: s,
620
+ onReact: p,
621
+ showReactions: a = !0,
622
+ showReplyButton: m = !0,
623
+ onReplyClick: d,
624
+ isBanned: l = !1
625
+ }) => {
626
+ var g, k, I, v;
627
+ const { t: c } = ye(), h = bt(r, i), y = (() => {
628
+ if (!h || !t.reactions)
629
+ return null;
630
+ for (const f of t.reactions)
631
+ if (f.userIds.includes(h))
632
+ return f.type;
633
+ return null;
634
+ })(), b = (f) => {
635
+ if (!i) {
636
+ s == null || s();
637
+ return;
638
+ }
639
+ p(t.id, f).catch(() => {
640
+ });
641
+ };
642
+ return /* @__PURE__ */ S("div", { css: Qe.row, children: [
643
+ a && /* @__PURE__ */ S(Re, { children: [
644
+ /* @__PURE__ */ n(
645
+ Ze,
646
+ {
647
+ reaction: "LIKE",
648
+ count: ((k = (g = t.reactions) == null ? void 0 : g.find((f) => f.type === "LIKE")) == null ? void 0 : k.reactionCount) || 0,
649
+ isActive: y === "LIKE",
650
+ onClick: () => b("LIKE"),
651
+ disabled: !i || l
652
+ }
653
+ ),
654
+ /* @__PURE__ */ n(
655
+ Ze,
656
+ {
657
+ reaction: "DISLIKE",
658
+ count: ((v = (I = t.reactions) == null ? void 0 : I.find((f) => f.type === "DISLIKE")) == null ? void 0 : v.reactionCount) || 0,
659
+ isActive: y === "DISLIKE",
660
+ onClick: () => b("DISLIKE"),
661
+ disabled: !i || l
662
+ }
663
+ )
664
+ ] }),
665
+ m && /* @__PURE__ */ n(
666
+ ue,
667
+ {
668
+ look: "reply",
669
+ onClick: d,
670
+ disabled: l,
671
+ startDecorator: /* @__PURE__ */ n($t, { size: "1em", css: Qe.replyIcon, style: { marginLeft: "calc(0.375em / -1.625)" } }),
672
+ children: c("discussion.reply", "Reply")
673
+ }
674
+ )
675
+ ] });
676
+ }, He = 4, et = { visibility: "hidden" }, yt = (t, r, i, s) => {
677
+ const p = Et(), [a, m] = D(et);
678
+ return Ne(() => {
679
+ if (!t) {
680
+ m(et);
681
+ return;
682
+ }
683
+ const d = () => {
684
+ var k;
685
+ const l = (k = r.current) == null ? void 0 : k.getBoundingClientRect(), c = i.current;
686
+ if (!l || !c) return;
687
+ s === "start" && (c.style.width = `${l.width}px`);
688
+ const { width: h, height: u } = c.getBoundingClientRect(), y = document.documentElement;
689
+ let b = s === "center" ? l.left + l.width / 2 - h / 2 : p ? l.right - h : l.left;
690
+ b = Math.max(0, Math.min(b, y.clientWidth - h));
691
+ let g = l.bottom + He;
692
+ g + u > y.clientHeight && l.top - He - u >= 0 && (g = l.top - He - u), m({
693
+ left: Math.round(b),
694
+ top: Math.round(g),
695
+ width: s === "start" ? l.width : void 0
696
+ });
697
+ };
698
+ return d(), window.addEventListener("resize", d), window.addEventListener("scroll", d, { capture: !0, passive: !0 }), () => {
699
+ window.removeEventListener("resize", d), window.removeEventListener("scroll", d, { capture: !0 });
700
+ };
701
+ }, [t, s, p, r, i]), a;
702
+ }, Xe = {
703
+ // Joy's small plain IconButton; its radius variable never resolved, so it's square.
704
+ trigger: o({
705
+ boxSizing: "border-box",
706
+ position: "relative",
707
+ display: "inline-flex",
708
+ alignItems: "center",
709
+ justifyContent: "center",
710
+ minWidth: "2em",
711
+ minHeight: "2em",
712
+ margin: 0,
713
+ marginLeft: "auto",
714
+ paddingBlock: 0,
715
+ paddingInline: "2px",
716
+ border: "none",
717
+ backgroundColor: "transparent",
718
+ color: e.text,
719
+ font: "inherit",
720
+ fontSize: "1em",
721
+ // Unlike Joy's Button, its IconButton kept the browser's line height.
722
+ lineHeight: "normal",
723
+ cursor: "pointer",
724
+ "& svg": { color: e.icon },
725
+ "&:hover": { backgroundColor: e.text14, color: "var(--fu-ucrc-neutral-plain-hover-color)" },
726
+ "&:active": { backgroundColor: "var(--fu-ucrc-neutral-plain-active-bg)" },
727
+ "&:hover svg, &:active svg, &:focus-visible svg": { color: "currentColor" },
728
+ "&:focus-visible": { outline: `2px solid ${e.focus}`, outlineOffset: "2px" }
729
+ }),
730
+ menu: o({
731
+ position: "fixed",
732
+ zIndex: 1300,
733
+ boxSizing: "border-box",
734
+ display: "flex",
735
+ flexDirection: "column",
736
+ margin: 0,
737
+ paddingBlock: "0.375em",
738
+ paddingInline: 0,
739
+ listStyle: "none",
740
+ overflow: "auto",
741
+ outline: 0,
742
+ border: `1px solid ${e.border}`,
743
+ borderRadius: e.radiusSm,
744
+ backgroundColor: e.surface,
745
+ color: "var(--fu-ucrc-neutral-outlined-color)",
746
+ fontFamily: e.fontBody,
747
+ fontSize: "1em",
748
+ fontWeight: 400,
749
+ lineHeight: 1.5
750
+ }),
751
+ item: o({
752
+ boxSizing: "border-box",
753
+ position: "relative",
754
+ display: "flex",
755
+ alignItems: "center",
756
+ flexShrink: 0,
757
+ gap: "0.625em",
758
+ minHeight: "2.25em",
759
+ paddingBlock: "0.25em",
760
+ paddingInline: "0.75em",
761
+ border: "1px solid transparent",
762
+ color: e.text,
763
+ backgroundColor: e.surface,
764
+ cursor: "pointer",
765
+ outline: 0,
766
+ "&:hover, &:focus-visible": { backgroundColor: e.surfaceVariant },
767
+ "&[aria-disabled='true']": { pointerEvents: "none", cursor: "default" }
768
+ })
769
+ }, tt = { marginInlineEnd: e.spaceXs }, no = ({
770
+ isOwnPost: t,
771
+ canReport: r,
772
+ onDelete: i,
773
+ onReport: s,
774
+ disabled: p = !1
775
+ }) => {
776
+ const { t: a } = ye(), { shadowRootElement: m } = je(Ve), d = kt(), [l, c] = Ie.useState(!1), h = W(null), u = W(null), y = yt(l, h, u, "center");
777
+ if (Ie.useEffect(() => {
778
+ if (!l) return;
779
+ const f = (A) => {
780
+ const E = A.composedPath();
781
+ h.current && E.includes(h.current) || u.current && E.includes(u.current) || c(!1);
782
+ }, B = setTimeout(() => {
783
+ document.addEventListener("click", f, !0);
784
+ }, 0);
785
+ return () => {
786
+ clearTimeout(B), document.removeEventListener("click", f, !0);
787
+ };
788
+ }, [l]), !t && !r) return null;
789
+ const b = () => {
790
+ var f;
791
+ return [...((f = u.current) == null ? void 0 : f.querySelectorAll('[role="menuitem"]')) ?? []];
792
+ }, g = () => {
793
+ var f;
794
+ c(!1), (f = h.current) == null || f.focus();
795
+ }, k = (f) => {
796
+ var B;
797
+ c(!1), (B = h.current) == null || B.focus(), f();
798
+ }, I = (f) => {
799
+ const B = b(), A = B.indexOf(f.target), E = (J) => {
800
+ var U;
801
+ return (U = B[(J + B.length) % B.length]) == null ? void 0 : U.focus();
802
+ }, $ = {
803
+ ArrowDown: () => E(A + 1),
804
+ ArrowUp: () => E(A - 1),
805
+ Home: () => E(0),
806
+ End: () => E(B.length - 1),
807
+ Escape: g
808
+ };
809
+ $[f.key] ? (f.preventDefault(), $[f.key]()) : f.key === "Tab" && c(!1);
810
+ }, v = (f, B, A, E) => /* @__PURE__ */ S(
811
+ "li",
812
+ {
813
+ role: "menuitem",
814
+ tabIndex: -1,
815
+ "aria-disabled": p,
816
+ css: Xe.item,
817
+ onClick: () => k(E),
818
+ onKeyDown: ($) => {
819
+ $.key !== "Enter" && $.key !== " " || ($.preventDefault(), p || k(E));
820
+ },
821
+ children: [
822
+ B,
823
+ A
824
+ ]
825
+ },
826
+ f
827
+ );
828
+ return /* @__PURE__ */ S(Re, { children: [
829
+ /* @__PURE__ */ n(
830
+ "button",
831
+ {
832
+ ref: h,
833
+ type: "button",
834
+ "aria-haspopup": "menu",
835
+ "aria-expanded": l,
836
+ "aria-controls": l ? d : void 0,
837
+ css: Xe.trigger,
838
+ onClick: (f) => {
839
+ c(!l), !l && f.detail === 0 && requestAnimationFrame(() => {
840
+ var B;
841
+ return (B = b()[0]) == null ? void 0 : B.focus();
842
+ });
843
+ },
844
+ children: /* @__PURE__ */ n(Ft, { size: "1.25em" })
845
+ }
846
+ ),
847
+ l && m && Vt(
848
+ /* @__PURE__ */ S("ul", { ref: u, id: d, role: "menu", css: Xe.menu, style: y, onKeyDown: I, children: [
849
+ t && v("delete", /* @__PURE__ */ n(Ht, { size: "1em", color: e.icon, style: tt }), a("discussion.delete.action", "Delete"), i),
850
+ r && v("report", /* @__PURE__ */ n(Xt, { size: "1em", color: e.icon, style: tt }), a("discussion.report.action", "Report"), s)
851
+ ] }),
852
+ m
853
+ )
854
+ ] });
855
+ }, ot = "rgba(var(--fu-ucrc-shadow-channel) / var(--fu-ucrc-shadow-opacity))", nt = o({
856
+ position: "absolute",
857
+ top: "50%",
858
+ left: "50%",
859
+ transform: "translate(-50%, -50%)",
860
+ boxSizing: "border-box",
861
+ display: "flex",
862
+ flexDirection: "column",
863
+ gap: "0.75em 1em",
864
+ minWidth: "320px",
865
+ maxHeight: "calc(100% - 3em)",
866
+ padding: e.spaceLg,
867
+ border: "1px solid var(--fu-ucrc-neutral-outlined-border)",
868
+ borderRadius: e.radiusMd,
869
+ outline: 0,
870
+ boxShadow: `var(--fu-ucrc-shadow-ring), 0px 2px 8px -2px ${ot}, 0px 6px 12px -2px ${ot}`,
871
+ backgroundColor: e.surface,
872
+ color: e.text,
873
+ fontFamily: e.fontBody,
874
+ fontSize: "1em",
875
+ fontWeight: 400,
876
+ lineHeight: 1.5
877
+ }), be = {
878
+ delete: o(nt, { maxWidth: "400px" }),
879
+ report: o(nt, { maxWidth: "440px" }),
880
+ title: o(z.titleLg, { fontFamily: e.fontPrimary }),
881
+ description: o(z.bodySm, { color: e.textSecondary }),
882
+ actions: o({ display: "flex", gap: e.spaceXs, justifyContent: "flex-end" })
883
+ }, rt = {
884
+ title: o(be.title, { marginBottom: e.spaceXs }),
885
+ description: o(be.description, { marginBottom: e.spaceLg })
886
+ }, ro = ({
887
+ open: t,
888
+ onClose: r,
889
+ onConfirm: i,
890
+ onError: s
891
+ }) => {
892
+ const { t: p } = ye(), a = _e(), m = Ie.useId(), [d, l] = D(!1), c = async () => {
893
+ l(!0);
894
+ try {
895
+ await i(), r();
896
+ } catch {
897
+ s(
898
+ p(
899
+ "discussion.delete.error",
900
+ "Failed to delete comment. Please try again."
901
+ )
902
+ );
903
+ } finally {
904
+ l(!1);
905
+ }
906
+ };
907
+ return /* @__PURE__ */ n(ut, { open: t, onClose: r, children: /* @__PURE__ */ S("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": m, tabIndex: -1, css: be.delete, style: a, children: [
908
+ /* @__PURE__ */ n("p", { id: m, css: rt.title, children: p("discussion.delete.title", "Delete comment") }),
909
+ /* @__PURE__ */ n("p", { css: rt.description, children: p(
910
+ "discussion.delete.description",
911
+ "Are you sure you want to delete this comment? This action cannot be undone."
912
+ ) }),
913
+ /* @__PURE__ */ S("div", { css: be.actions, children: [
914
+ /* @__PURE__ */ n(ue, { look: "plain", onClick: r, children: p("common.cancel", "Cancel") }),
915
+ /* @__PURE__ */ n(ue, { look: "solid", loading: d, onClick: c, children: p("discussion.delete.action", "Delete") })
916
+ ] })
917
+ ] }) });
918
+ }, it = o({
919
+ boxSizing: "border-box",
920
+ display: "inline-flex",
921
+ justifyContent: "center",
922
+ alignItems: "center",
923
+ flexShrink: 0,
924
+ width: "1.25em",
925
+ height: "1.25em",
926
+ margin: 0,
927
+ borderRadius: "1.25em",
928
+ border: `1px solid ${e.border}`,
929
+ backgroundColor: e.surfaceVariant,
930
+ color: "var(--fu-ucrc-neutral-outlined-color)",
931
+ "&:active": { backgroundColor: "var(--fu-ucrc-neutral-outlined-active-bg)" },
932
+ "&:hover": { backgroundColor: e.surface, borderColor: e.border }
933
+ }), st = o({
934
+ width: "0.625em",
935
+ height: "0.625em",
936
+ borderRadius: "inherit",
937
+ color: "inherit",
938
+ backgroundColor: "currentColor",
939
+ transform: "scale(0)"
940
+ }), le = {
941
+ title: o(be.title, { marginBottom: e.spaceMd }),
942
+ description: o(be.description, { marginBottom: e.spaceMd }),
943
+ // Joy's ModalClose: an 8px inset, 2rem square.
944
+ close: o({
945
+ position: "absolute",
946
+ zIndex: 1,
947
+ top: "0.5em",
948
+ right: "0.5em",
949
+ boxSizing: "border-box",
950
+ display: "inline-flex",
951
+ alignItems: "center",
952
+ justifyContent: "center",
953
+ minWidth: "2em",
954
+ minHeight: "2em",
955
+ margin: 0,
956
+ paddingBlock: 0,
957
+ paddingInline: "0.25em",
958
+ border: "none",
959
+ borderRadius: "4px",
960
+ backgroundColor: "transparent",
961
+ color: e.text,
962
+ fontFamily: e.fontBody,
963
+ fontSize: "1em",
964
+ cursor: "pointer",
965
+ "& svg": { color: e.icon },
966
+ "&:active": { backgroundColor: "var(--fu-ucrc-neutral-plain-active-bg)" },
967
+ "&:hover": { backgroundColor: e.text14, color: "var(--fu-ucrc-neutral-plain-hover-color)" },
968
+ "&:hover svg, &:active svg, &:focus-visible svg": { color: "currentColor" },
969
+ "&:focus-visible": { outline: `2px solid ${e.focus}`, outlineOffset: "2px" }
970
+ }),
971
+ group: o({
972
+ display: "flex",
973
+ flexDirection: "column",
974
+ gap: e.spaceXs,
975
+ marginBottom: e.spaceMd,
976
+ color: "var(--fu-ucrc-neutral-plain-color)"
977
+ }),
978
+ radio: o({
979
+ position: "relative",
980
+ display: "inline-flex",
981
+ boxSizing: "border-box",
982
+ minWidth: 0,
983
+ gap: "0.625em",
984
+ fontFamily: e.fontPrimary,
985
+ fontSize: "1em",
986
+ lineHeight: "1.25em",
987
+ color: e.text,
988
+ "& + &": { marginBlockStart: "0.875em" }
989
+ }),
990
+ circle: {
991
+ unchecked: it,
992
+ checked: o(it, {
993
+ color: "var(--fu-ucrc-primary-outlined-color)",
994
+ "&:active": { backgroundColor: "var(--fu-ucrc-primary-outlined-active-bg)" },
995
+ "&:hover": { backgroundColor: e.surface, borderColor: e.border }
996
+ })
997
+ },
998
+ dot: { unchecked: st, checked: o(st, { transform: "none" }) },
999
+ action: o({
1000
+ position: "absolute",
1001
+ inset: "-1px",
1002
+ zIndex: 1,
1003
+ borderRadius: "inherit",
1004
+ "&:has(input:focus-visible)": { outline: `2px solid ${e.focus}`, outlineOffset: "2px" }
1005
+ }),
1006
+ input: o({
1007
+ position: "absolute",
1008
+ width: "100%",
1009
+ height: "100%",
1010
+ margin: 0,
1011
+ opacity: 0,
1012
+ cursor: "pointer"
1013
+ }),
1014
+ label: o({ flex: 1, minWidth: 0 })
1015
+ }, io = [
1016
+ { value: "SPAM", labelKey: "discussion.report.spam", fallback: "Spam" },
1017
+ {
1018
+ value: "NOT_ON_THE_SUBJECT",
1019
+ labelKey: "discussion.report.offTopic",
1020
+ fallback: "Off topic"
1021
+ },
1022
+ { value: "AD", labelKey: "discussion.report.ad", fallback: "Advertisement" },
1023
+ {
1024
+ value: "COPYRIGHT",
1025
+ labelKey: "discussion.report.copyright",
1026
+ fallback: "Copyright violation"
1027
+ },
1028
+ {
1029
+ value: "EXPLICIT_SEXUAL_CONTENT",
1030
+ labelKey: "discussion.report.explicit",
1031
+ fallback: "Explicit sexual content"
1032
+ },
1033
+ {
1034
+ value: "HATEFUL_SPEECH",
1035
+ labelKey: "discussion.report.hateful",
1036
+ fallback: "Hateful speech"
1037
+ },
1038
+ { value: "INSULT", labelKey: "discussion.report.insult", fallback: "Insult" },
1039
+ { value: "OTHER", labelKey: "discussion.report.other", fallback: "Other" }
1040
+ ], so = ({
1041
+ open: t,
1042
+ onClose: r,
1043
+ onSubmit: i,
1044
+ onSuccess: s,
1045
+ onError: p
1046
+ }) => {
1047
+ const { t: a } = ye(), m = _e(), d = Ie.useId(), [l, c] = D(""), [h, u] = D(""), [y, b] = D(!1), g = () => {
1048
+ r(), c(""), u("");
1049
+ }, k = async () => {
1050
+ b(!0);
1051
+ try {
1052
+ await i(
1053
+ l,
1054
+ l === "OTHER" ? h : void 0
1055
+ ), s(
1056
+ a(
1057
+ "discussion.report.success",
1058
+ "Post reported successfully. Thank you."
1059
+ )
1060
+ ), g();
1061
+ } catch {
1062
+ p(
1063
+ a(
1064
+ "discussion.report.error",
1065
+ "Failed to report post. Please try again."
1066
+ )
1067
+ );
1068
+ } finally {
1069
+ b(!1);
1070
+ }
1071
+ };
1072
+ return /* @__PURE__ */ n(ut, { open: t, onClose: g, children: /* @__PURE__ */ S("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": `${d}title`, tabIndex: -1, css: be.report, style: m, children: [
1073
+ /* @__PURE__ */ n("button", { type: "button", "aria-label": a("common.rules.close", "Close"), css: le.close, onClick: g, children: /* @__PURE__ */ n(Ot, { size: "calc(2em / 1.5)" }) }),
1074
+ /* @__PURE__ */ n("p", { id: `${d}title`, css: le.title, children: a("discussion.report.title", "Report post") }),
1075
+ /* @__PURE__ */ n("p", { css: le.description, children: a(
1076
+ "discussion.report.description",
1077
+ "Why are you reporting this post?"
1078
+ ) }),
1079
+ /* @__PURE__ */ n("div", { role: "radiogroup", css: le.group, children: io.map((I) => {
1080
+ const v = l === I.value, f = v ? "checked" : "unchecked";
1081
+ return /* @__PURE__ */ S("span", { css: le.radio, children: [
1082
+ /* @__PURE__ */ S("span", { css: le.circle[f], children: [
1083
+ /* @__PURE__ */ n("span", { css: le.dot[f] }),
1084
+ /* @__PURE__ */ n("span", { css: le.action, children: /* @__PURE__ */ n(
1085
+ "input",
1086
+ {
1087
+ id: `${d}${I.value}`,
1088
+ type: "radio",
1089
+ name: `${d}reason`,
1090
+ value: I.value,
1091
+ checked: v,
1092
+ onChange: (B) => c(B.target.value),
1093
+ css: le.input
1094
+ }
1095
+ ) })
1096
+ ] }),
1097
+ /* @__PURE__ */ n("label", { htmlFor: `${d}${I.value}`, css: le.label, children: a(I.labelKey, I.fallback) })
1098
+ ] }, I.value);
1099
+ }) }),
1100
+ l === "OTHER" && /* @__PURE__ */ n(
1101
+ gt,
1102
+ {
1103
+ placeholder: a(
1104
+ "discussion.report.detailsPlaceholder",
1105
+ "Please provide more details..."
1106
+ ),
1107
+ value: h,
1108
+ onChange: u,
1109
+ minRows: 2,
1110
+ maxRows: 4,
1111
+ marginBottom: e.spaceMd
1112
+ }
1113
+ ),
1114
+ /* @__PURE__ */ S("div", { css: be.actions, children: [
1115
+ /* @__PURE__ */ n(ue, { look: "plain", onClick: g, children: a("common.cancel", "Cancel") }),
1116
+ /* @__PURE__ */ n(
1117
+ ue,
1118
+ {
1119
+ look: "solid",
1120
+ disabled: !l,
1121
+ loading: y,
1122
+ onClick: k,
1123
+ children: a("discussion.report.action", "Report")
1124
+ }
1125
+ )
1126
+ ] })
1127
+ ] }) });
1128
+ }, ao = (t, r, i) => {
1129
+ const s = new Date(t), a = (/* @__PURE__ */ new Date()).getTime() - s.getTime(), m = Math.floor(a / 6e4), d = Math.floor(a / 36e5), l = Math.floor(a / 864e5);
1130
+ return m < 1 ? r("discussion.justNow", "Just now") : m < 60 ? r("discussion.minutesAgo", "{{count}}m ago", { count: m }) : d < 24 ? r("discussion.hoursAgo", "{{count}}h ago", { count: d }) : l < 7 ? r("discussion.daysAgo", "{{count}}d ago", { count: l }) : s.toLocaleDateString(ft(i));
1131
+ }, Ke = o({ marginBottom: e.spaceMd }), Ue = o(Ke, {
1132
+ paddingInline: e.spaceSm,
1133
+ paddingBlock: e.spaceXs,
1134
+ borderInlineStart: "3px solid transparent",
1135
+ borderRadius: e.radiusXs,
1136
+ backgroundColor: "transparent",
1137
+ transition: "background-color 0.6s ease, border-color 0.6s ease"
1138
+ }), at = o(Ue, { borderInlineStartColor: e.primary, backgroundColor: e.primary1a }), co = { width: "64%", height: "64%" }, lo = { marginTop: "2px" }, O = {
1139
+ post: { top: Ke, reply: o(Ke, { marginLeft: e.spaceXl }) },
1140
+ highlightable: { top: Ue, reply: o(Ue, { marginLeft: e.spaceXl }) },
1141
+ highlighted: { top: at, reply: o(at, { marginLeft: e.spaceXl }) },
1142
+ row: o({ display: "flex", gap: e.spaceSm }),
1143
+ // Joy's small soft Avatar: 2rem square, in its own 0.875em font.
1144
+ avatar: o({
1145
+ position: "relative",
1146
+ width: "calc(2em / 0.875)",
1147
+ height: "calc(2em / 0.875)",
1148
+ userSelect: "none",
1149
+ backgroundColor: e.surfaceVariant,
1150
+ color: e.text,
1151
+ fontFamily: e.fontBody,
1152
+ fontSize: "0.875em",
1153
+ fontWeight: 500
1154
+ }),
1155
+ body: o({ flex: 1, minWidth: 0 }),
1156
+ header: o({ display: "flex", alignItems: "center", gap: e.spaceXs, marginBottom: e.space2xs }),
1157
+ name: o(z.titleSm, { color: e.text }),
1158
+ time: o(z.bodyXs, { color: e.textSecondary }),
1159
+ badge: o(z.bodyXs, {
1160
+ fontWeight: 600,
1161
+ paddingInline: e.spaceXs,
1162
+ borderRadius: e.radiusFull,
1163
+ color: e.primary,
1164
+ backgroundColor: e.primary1f
1165
+ }),
1166
+ moderated: o({
1167
+ display: "flex",
1168
+ alignItems: "flex-start",
1169
+ gap: e.spaceXs,
1170
+ marginBottom: e.spaceXs,
1171
+ marginRight: e.spaceMd,
1172
+ paddingInline: e.spaceSm,
1173
+ paddingBlock: e.spaceXs,
1174
+ borderRadius: e.radiusXs,
1175
+ borderLeft: `3px solid ${e.border}`,
1176
+ backgroundColor: e.surfaceVariant
1177
+ }),
1178
+ moderatedText: o(z.bodySm, { fontStyle: "italic", color: e.textSecondary }),
1179
+ content: o(z.bodySm, { marginBottom: e.spaceXs, whiteSpace: "pre-wrap", color: e.textBody }),
1180
+ repliesRow: o({ marginBottom: e.spaceXs }),
1181
+ repliesToggle: o(z.bodySm, {
1182
+ display: "flex",
1183
+ alignItems: "center",
1184
+ gap: e.space2xs,
1185
+ fontWeight: 600,
1186
+ color: e.primary,
1187
+ cursor: "pointer",
1188
+ "&:hover": { textDecoration: "underline", textUnderlineOffset: "2px" }
1189
+ }),
1190
+ nested: o({ marginTop: e.spaceMd })
1191
+ }, uo = 8e3, xt = ({
1192
+ post: t,
1193
+ sdk: r,
1194
+ userIsLoggedIn: i,
1195
+ onSignInClick: s,
1196
+ showReactions: p = !0,
1197
+ showReplies: a = !0,
1198
+ showReportPost: m = !0,
1199
+ onReply: d,
1200
+ onReact: l,
1201
+ onDelete: c,
1202
+ onReport: h,
1203
+ isSubmitting: u,
1204
+ showModeratedPosts: y = !1,
1205
+ isBanned: b = !1,
1206
+ highlightable: g = !1,
1207
+ isNew: k = !1,
1208
+ onNewSeen: I,
1209
+ depth: v = 0,
1210
+ parentPostId: f,
1211
+ onReplyCreated: B,
1212
+ onDeleteSuccess: A
1213
+ }) => {
1214
+ var M, N, X, ae;
1215
+ const { t: E } = ye(), { language: $ } = je(Ve), J = bt(r, i), [U, V] = D(!1), [q, T] = D([]), [_, oe] = D(!1), [ne, pe] = D(!1), [Z, de] = D(!1), [re, ie] = D({ open: !1, variant: "success", title: "", message: "" }), Q = W(null);
1216
+ he(() => {
1217
+ if (!k || !I || !Q.current) return;
1218
+ let x;
1219
+ const F = new IntersectionObserver(
1220
+ ([ee]) => {
1221
+ ee.isIntersecting && (F.disconnect(), x = setTimeout(() => I(t.id), uo));
1222
+ },
1223
+ { threshold: 0.5 }
1224
+ );
1225
+ return F.observe(Q.current), () => {
1226
+ F.disconnect(), clearTimeout(x);
1227
+ };
1228
+ }, [k, I, t.id]);
1229
+ const se = !!(i && J && t.userId === J), P = !!t.moderated, j = async (x) => {
1230
+ var ce;
1231
+ const F = v === 1 && f || t.id, ee = ((ce = t.userModel) == null ? void 0 : ce.name) || t.anonymousNickname || E("discussion.anonymous", "Anonymous"), ke = v === 1 ? `@${ee} ${x}` : x;
1232
+ await d(F, ke), V(!1), v === 1 && B ? B() : v === 0 && (oe(!0), H());
1233
+ }, H = async () => {
1234
+ if (!(!a || v >= 2))
1235
+ try {
1236
+ const x = await r.discussions.getPostReplies(t.id, {
1237
+ limit: 25,
1238
+ skipDeleted: !0,
1239
+ skipModerated: !y
1240
+ });
1241
+ T(x.data);
1242
+ } catch (x) {
1243
+ console.error("Failed to load replies:", x);
1244
+ }
1245
+ };
1246
+ he(() => {
1247
+ _ && q.length === 0 && H();
1248
+ }, [_]);
1249
+ const Ee = async (x) => {
1250
+ await c(x, t.id), T((F) => F.filter((ee) => ee.id !== x));
1251
+ }, fe = async (x, F) => {
1252
+ const ee = await l(x, F);
1253
+ ee && q.length > 0 && T(
1254
+ (ke) => ke.map((ce) => ce.id === x ? ee : ce)
1255
+ );
1256
+ }, R = (x, F) => {
1257
+ ie({ open: !0, variant: F, title: "", message: x });
1258
+ }, w = v > 0 ? "reply" : "top", C = ((M = t.userModel) == null ? void 0 : M.name) || t.anonymousNickname || "User";
1259
+ return /* @__PURE__ */ S(
1260
+ "div",
1261
+ {
1262
+ css: g ? k ? O.highlighted[w] : O.highlightable[w] : O.post[w],
1263
+ children: [
1264
+ /* @__PURE__ */ S("div", { css: O.row, children: [
1265
+ /* @__PURE__ */ n(St, { src: (N = t.userModel) == null ? void 0 : N.avatar, alt: C, css: O.avatar, children: /* @__PURE__ */ n(Wt, { color: e.icon, style: co }) }),
1266
+ /* @__PURE__ */ S("div", { css: O.body, children: [
1267
+ /* @__PURE__ */ S("div", { ref: Q, css: O.header, children: [
1268
+ /* @__PURE__ */ n("p", { css: O.name, children: ((X = t.userModel) == null ? void 0 : X.name) || t.anonymousNickname || E("discussion.anonymous", "Anonymous") }),
1269
+ /* @__PURE__ */ n("span", { css: O.time, children: ao(t.createdAt, E, $) }),
1270
+ k && /* @__PURE__ */ n("span", { css: O.badge, children: E("discussion.newPost", "New") }),
1271
+ /* @__PURE__ */ n(
1272
+ no,
1273
+ {
1274
+ isOwnPost: se,
1275
+ canReport: !!(m && i && !se) && !P,
1276
+ onDelete: () => pe(!0),
1277
+ onReport: () => de(!0),
1278
+ disabled: b
1279
+ }
1280
+ )
1281
+ ] }),
1282
+ P && y ? /* @__PURE__ */ S("div", { css: O.moderated, children: [
1283
+ /* @__PURE__ */ n(Nt, { size: "0.9375em", color: e.textSecondary, style: lo }),
1284
+ /* @__PURE__ */ n("p", { css: O.moderatedText, children: t.moderatedReason || E(
1285
+ "discussion.moderatedPost",
1286
+ "This comment has been moderated"
1287
+ ) })
1288
+ ] }) : /* @__PURE__ */ n("p", { css: O.content, children: t.content }),
1289
+ !P && /* @__PURE__ */ n(
1290
+ oo,
1291
+ {
1292
+ post: t,
1293
+ sdk: r,
1294
+ userIsLoggedIn: i,
1295
+ onSignInClick: s,
1296
+ onReact: l,
1297
+ showReactions: p,
1298
+ showReplyButton: a && v < 2,
1299
+ onReplyClick: () => V(!U),
1300
+ isBanned: b
1301
+ }
1302
+ ),
1303
+ a && t.repliesCount > 0 && /* @__PURE__ */ n("div", { css: O.repliesRow, children: /* @__PURE__ */ S(
1304
+ "p",
1305
+ {
1306
+ css: O.repliesToggle,
1307
+ onClick: () => oe(!_),
1308
+ children: [
1309
+ _ ? E("discussion.hideReplies", "Hide replies") : E("discussion.repliesCount", "{{count}} replies", {
1310
+ count: t.repliesCount
1311
+ }),
1312
+ !_ && " ▼"
1313
+ ]
1314
+ }
1315
+ ) }),
1316
+ U && !P && /* @__PURE__ */ n("div", { css: O.nested, children: /* @__PURE__ */ n(
1317
+ ht,
1318
+ {
1319
+ onSubmit: j,
1320
+ userIsLoggedIn: i,
1321
+ onSignInClick: s,
1322
+ placeholder: E("discussion.writeReply", "Write a reply..."),
1323
+ isSubmitting: u,
1324
+ replyTo: ((ae = t.userModel) == null ? void 0 : ae.name) || t.anonymousNickname,
1325
+ onCancel: () => V(!1),
1326
+ disabled: b
1327
+ }
1328
+ ) }),
1329
+ _ && q.length > 0 && /* @__PURE__ */ n("div", { css: O.nested, children: q.map((x) => /* @__PURE__ */ n(
1330
+ xt,
1331
+ {
1332
+ post: x,
1333
+ sdk: r,
1334
+ userIsLoggedIn: i,
1335
+ onSignInClick: s,
1336
+ showReactions: p,
1337
+ showReplies: a,
1338
+ showReportPost: m,
1339
+ onReply: d,
1340
+ onReact: fe,
1341
+ onDelete: Ee,
1342
+ onReport: h,
1343
+ isSubmitting: u,
1344
+ showModeratedPosts: y,
1345
+ isBanned: b,
1346
+ depth: v + 1,
1347
+ parentPostId: v === 0 ? t.id : f,
1348
+ onReplyCreated: v === 0 ? H : void 0,
1349
+ onDeleteSuccess: A
1350
+ },
1351
+ x.id
1352
+ )) })
1353
+ ] })
1354
+ ] }),
1355
+ /* @__PURE__ */ n(
1356
+ ro,
1357
+ {
1358
+ open: ne,
1359
+ onClose: () => pe(!1),
1360
+ onConfirm: async () => {
1361
+ await c(t.id), A == null || A();
1362
+ },
1363
+ onError: (x) => R(x, "error")
1364
+ }
1365
+ ),
1366
+ /* @__PURE__ */ n(
1367
+ so,
1368
+ {
1369
+ open: Z,
1370
+ onClose: () => de(!1),
1371
+ onSubmit: (x, F) => h(t.id, x, F),
1372
+ onSuccess: (x) => R(x, "success"),
1373
+ onError: (x) => R(x, "error")
1374
+ }
1375
+ ),
1376
+ /* @__PURE__ */ n(
1377
+ pt,
1378
+ {
1379
+ notification: re,
1380
+ onClose: () => ie((x) => ({ ...x, open: !1 }))
1381
+ }
1382
+ )
1383
+ ]
1384
+ }
1385
+ );
1386
+ }, Oe = 864e5, ct = -1, Te = o(z.bodyMd, { fontSize: "0.8125em", color: e.textSecondary }), lt = o({ transition: "transform 0.2s" }), L = {
1387
+ root: o({
1388
+ fontSize: "1em",
1389
+ marginBottom: e.spaceSm,
1390
+ padding: e.spaceMd,
1391
+ backgroundColor: e.dangerSoft,
1392
+ borderLeft: `4px solid ${e.danger}`,
1393
+ borderRadius: e.radiusSm
1394
+ }),
1395
+ row: o({ display: "flex", gap: e.spaceSm, alignItems: "flex-start" }),
1396
+ badge: o({
1397
+ flexShrink: 0,
1398
+ display: "flex",
1399
+ alignItems: "center",
1400
+ justifyContent: "center",
1401
+ width: "2.25em",
1402
+ height: "2.25em",
1403
+ borderRadius: "50%",
1404
+ backgroundColor: e.danger1f,
1405
+ color: e.danger
1406
+ }),
1407
+ body: o({ flex: 1, minWidth: 0 }),
1408
+ title: o(z.titleMd, { fontWeight: 700, fontFamily: e.fontPrimary, color: e.text }),
1409
+ description: o(z.bodySm, { marginTop: e.space2xs, color: e.textBody }),
1410
+ pills: o({ display: "flex", flexWrap: "wrap", alignItems: "center", gap: e.spaceXs, marginTop: e.spaceSm }),
1411
+ pill: o(z.bodyMd, {
1412
+ fontSize: "0.75em",
1413
+ fontWeight: 600,
1414
+ color: e.danger,
1415
+ border: `1px solid ${e.danger}`,
1416
+ borderRadius: e.radiusLg,
1417
+ paddingInline: e.spaceXs,
1418
+ paddingBlock: "0.125em"
1419
+ }),
1420
+ meta: Te,
1421
+ reasonBox: o({
1422
+ marginTop: e.spaceSm,
1423
+ paddingInline: e.spaceSm,
1424
+ paddingBlock: e.spaceXs,
1425
+ backgroundColor: e.surface,
1426
+ borderRadius: e.radiusXs
1427
+ }),
1428
+ // A Joy Typography span is a block.
1429
+ reasonLabel: o(z.bodyXs, { display: "block", fontWeight: 600, textTransform: "uppercase", color: e.textSecondary }),
1430
+ reason: o(z.bodySm, { color: e.text, whiteSpace: "pre-wrap", unicodeBidi: "plaintext" }),
1431
+ history: o({ marginTop: e.spaceSm }),
1432
+ // Typography as a button: Joy's reset plus the widget's look.
1433
+ toggle: o(z.bodyMd, {
1434
+ fontSize: "0.8125em",
1435
+ fontWeight: 600,
1436
+ fontFamily: e.fontPrimary,
1437
+ color: e.text,
1438
+ display: "inline-flex",
1439
+ alignItems: "center",
1440
+ gap: e.space2xs,
1441
+ padding: 0,
1442
+ border: "none",
1443
+ backgroundColor: "transparent",
1444
+ cursor: "pointer"
1445
+ }),
1446
+ chevron: { closed: lt, open: o(lt, { transform: "rotate(180deg)" }) },
1447
+ list: o({ listStyle: "none", margin: 0, padding: 0, marginTop: e.spaceXs }),
1448
+ entry: o({ paddingBlock: e.spaceXs, borderTop: `1px solid ${e.danger33}` }),
1449
+ entryDates: o(Te, { fontWeight: 600, color: e.text }),
1450
+ entryReason: o(Te, { unicodeBidi: "plaintext" }),
1451
+ entryLifted: o(Te, { fontStyle: "italic" }),
1452
+ isolate: o({ unicodeBidi: "isolate" })
1453
+ }, po = ({
1454
+ ban: t,
1455
+ showBanHistory: r = !1
1456
+ }) => {
1457
+ const { t: i } = ye(), { language: s } = je(Ve), [p, a] = D(!1), m = ft(s), d = (g) => new Date(g).toLocaleDateString(m, { dateStyle: "medium" }), l = (g) => new Date(g).toLocaleString(m, {
1458
+ dateStyle: "medium",
1459
+ timeStyle: "short"
1460
+ }), { activeBan: c } = t, h = c.bannedPeriodInDays === ct, u = new Date(
1461
+ new Date(c.bannedAt).getTime() + c.bannedPeriodInDays * Oe
1462
+ ), y = Math.max(
1463
+ 1,
1464
+ Math.ceil((u.getTime() - Date.now()) / Oe)
1465
+ ), b = (t.history || []).filter(
1466
+ (g) => g.bannedAt !== c.bannedAt
1467
+ );
1468
+ return /* @__PURE__ */ n("div", { role: "status", css: L.root, children: /* @__PURE__ */ S("div", { css: L.row, children: [
1469
+ /* @__PURE__ */ n("div", { css: L.badge, children: /* @__PURE__ */ n(Kt, { size: "1.25em", color: e.icon }) }),
1470
+ /* @__PURE__ */ S("div", { css: L.body, children: [
1471
+ /* @__PURE__ */ n("p", { css: L.title, children: i("discussion.ban.title", "You've been banned from commenting") }),
1472
+ /* @__PURE__ */ n("p", { css: L.description, children: h ? i(
1473
+ "discussion.ban.descriptionPermanent",
1474
+ "You can still read the discussion, but you can no longer post, reply or react."
1475
+ ) : i(
1476
+ "discussion.ban.description",
1477
+ "You can still read the discussion, but you can't post, reply or react until the ban ends."
1478
+ ) }),
1479
+ /* @__PURE__ */ S("div", { css: L.pills, children: [
1480
+ /* @__PURE__ */ n("span", { css: L.pill, children: h ? i("discussion.ban.permanent", "Permanent ban") : i("discussion.ban.daysLeft", "{{count}} days left", {
1481
+ count: y
1482
+ }) }),
1483
+ /* @__PURE__ */ n("span", { css: L.meta, children: i("discussion.ban.since", "Since {{date}}", {
1484
+ date: d(c.bannedAt)
1485
+ }) }),
1486
+ !h && /* @__PURE__ */ S("span", { css: L.meta, children: [
1487
+ "·",
1488
+ " ",
1489
+ i("discussion.ban.until", "Until {{date}}", {
1490
+ date: l(u)
1491
+ })
1492
+ ] })
1493
+ ] }),
1494
+ c.bannedReason && /* @__PURE__ */ S("div", { css: L.reasonBox, children: [
1495
+ /* @__PURE__ */ n("span", { css: L.reasonLabel, children: i("discussion.ban.reason", "Reason") }),
1496
+ /* @__PURE__ */ n("p", { css: L.reason, children: c.bannedReason })
1497
+ ] }),
1498
+ r && b.length > 0 && /* @__PURE__ */ S("div", { css: L.history, children: [
1499
+ /* @__PURE__ */ S(
1500
+ "button",
1501
+ {
1502
+ type: "button",
1503
+ "aria-expanded": p,
1504
+ onClick: () => a((g) => !g),
1505
+ css: L.toggle,
1506
+ children: [
1507
+ i("discussion.ban.previousBans", "Previous bans ({{count}})", {
1508
+ count: b.length
1509
+ }),
1510
+ /* @__PURE__ */ n(
1511
+ Ut,
1512
+ {
1513
+ size: "1.25em",
1514
+ color: e.icon,
1515
+ css: p ? L.chevron.open : L.chevron.closed
1516
+ }
1517
+ )
1518
+ ]
1519
+ }
1520
+ ),
1521
+ p && /* @__PURE__ */ n("ul", { css: L.list, children: b.map((g) => {
1522
+ const k = g.unbannedAt ?? (g.bannedPeriodInDays > 0 ? new Date(
1523
+ new Date(g.bannedAt).getTime() + g.bannedPeriodInDays * Oe
1524
+ ) : null);
1525
+ return /* @__PURE__ */ S("li", { css: L.entry, children: [
1526
+ /* @__PURE__ */ S("p", { css: L.entryDates, children: [
1527
+ d(g.bannedAt),
1528
+ k && ` – ${d(k)}`,
1529
+ g.bannedPeriodInDays === ct && ` · ${i("discussion.ban.permanent", "Permanent ban")}`,
1530
+ g.bannedPeriodInDays > 0 && ` · ${i("discussion.ban.days", "{{count}} days", { count: g.bannedPeriodInDays })}`
1531
+ ] }),
1532
+ g.bannedReason && /* @__PURE__ */ n("p", { css: L.entryReason, children: g.bannedReason }),
1533
+ g.unbannedAt && /* @__PURE__ */ S("p", { css: L.entryLifted, children: [
1534
+ i("discussion.ban.lifted", "Lifted on {{date}}", {
1535
+ date: d(g.unbannedAt)
1536
+ }),
1537
+ g.unbannedReason && /* @__PURE__ */ S(Re, { children: [
1538
+ ": ",
1539
+ /* @__PURE__ */ n("span", { css: L.isolate, children: g.unbannedReason })
1540
+ ] })
1541
+ ] })
1542
+ ] }, g.bannedAt);
1543
+ }) })
1544
+ ] })
1545
+ ] })
1546
+ ] }) });
1547
+ }, fo = (t) => {
1548
+ var r, i, s;
1549
+ return (((r = t == null ? void 0 : t.error) == null ? void 0 : r.code) ?? ((s = (i = t == null ? void 0 : t.data) == null ? void 0 : i.error) == null ? void 0 : s.code) ?? (t == null ? void 0 : t.status)) === 429;
1550
+ }, dt = { display: "flex", alignItems: "center", marginInlineStart: "0.5em", marginInlineEnd: "-2px" }, Ce = {
1551
+ root: o({
1552
+ boxSizing: "border-box",
1553
+ position: "relative",
1554
+ display: "flex",
1555
+ alignItems: "center",
1556
+ minWidth: "150px",
1557
+ minHeight: "2em",
1558
+ paddingBlock: "2px",
1559
+ paddingInline: "0.5em",
1560
+ border: `1px solid ${e.border}`,
1561
+ borderRadius: e.radiusSm,
1562
+ backgroundColor: e.surfaceVariant,
1563
+ color: e.text,
1564
+ fontFamily: e.fontBody,
1565
+ fontSize: "1em",
1566
+ fontWeight: 400,
1567
+ lineHeight: 1.5,
1568
+ cursor: "pointer",
1569
+ "&:has(:focus-visible)::before": {
1570
+ content: '""',
1571
+ position: "absolute",
1572
+ inset: 0,
1573
+ zIndex: 1,
1574
+ margin: "-1px",
1575
+ borderRadius: "inherit",
1576
+ pointerEvents: "none",
1577
+ boxShadow: `inset 0 0 0 2px ${e.focus}`
1578
+ }
1579
+ }),
1580
+ button: o({
1581
+ display: "flex",
1582
+ alignItems: "center",
1583
+ alignSelf: "stretch",
1584
+ flex: 1,
1585
+ boxSizing: "border-box",
1586
+ margin: 0,
1587
+ padding: 0,
1588
+ border: 0,
1589
+ outline: 0,
1590
+ background: "none",
1591
+ color: "inherit",
1592
+ font: "inherit",
1593
+ lineHeight: "normal",
1594
+ whiteSpace: "nowrap",
1595
+ overflow: "hidden",
1596
+ cursor: "pointer"
1597
+ }),
1598
+ // Joy's icon grey on the svg only; open, it takes the field's colour.
1599
+ indicatorClosed: o({ ...dt, "& svg": { color: e.icon } }),
1600
+ indicatorOpen: o(dt),
1601
+ list: o({
1602
+ position: "fixed",
1603
+ zIndex: 1300,
1604
+ boxSizing: "border-box",
1605
+ display: "flex",
1606
+ flexDirection: "column",
1607
+ minWidth: "max-content",
1608
+ maxHeight: "44vh",
1609
+ overflow: "auto",
1610
+ margin: 0,
1611
+ paddingBlock: "calc(0.25em / 0.875)",
1612
+ paddingInline: 0,
1613
+ listStyle: "none",
1614
+ border: `1px solid ${e.border}`,
1615
+ borderRadius: e.radiusSm,
1616
+ backgroundColor: e.surface,
1617
+ boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1)",
1618
+ color: "var(--fu-ucrc-neutral-outlined-color)",
1619
+ fontFamily: e.fontBody,
1620
+ fontSize: "0.875em",
1621
+ lineHeight: 1.5
1622
+ }),
1623
+ option: o({
1624
+ boxSizing: "border-box",
1625
+ position: "relative",
1626
+ display: "flex",
1627
+ alignItems: "center",
1628
+ flexShrink: 0,
1629
+ gap: "calc(0.5em / 0.875)",
1630
+ minHeight: "calc(2em / 0.875)",
1631
+ paddingBlock: "3px",
1632
+ paddingInline: "calc(0.5em / 0.875)",
1633
+ border: "1px solid transparent",
1634
+ fontSize: "1em",
1635
+ color: e.text,
1636
+ backgroundColor: e.surface,
1637
+ cursor: "pointer",
1638
+ "&:hover, &[aria-selected='true']": { backgroundColor: e.surfaceVariant }
1639
+ })
1640
+ }, mo = ({ value: t, options: r, onChange: i }) => {
1641
+ var l;
1642
+ const s = wt(
1643
+ r.map((c) => c.value),
1644
+ t,
1645
+ (c) => i(c)
1646
+ ), p = W(null), a = W(null), m = yt(s.open, s.rootRef, a, "start"), d = (c) => {
1647
+ var u, y, b;
1648
+ const h = c.target;
1649
+ (u = p.current) != null && u.contains(h) || (y = a.current) != null && y.contains(h) || ((b = p.current) == null || b.focus(), s.triggerProps.onClick());
1650
+ };
1651
+ return /* @__PURE__ */ S("div", { ref: s.rootRef, css: Ce.root, onClick: d, children: [
1652
+ /* @__PURE__ */ n("button", { ref: p, ...s.triggerProps, css: Ce.button, children: (l = r.find((c) => c.value === t)) == null ? void 0 : l.label }),
1653
+ /* @__PURE__ */ n("span", { css: s.open ? Ce.indicatorOpen : Ce.indicatorClosed, children: /* @__PURE__ */ n(jt, {}) }),
1654
+ s.open && /* @__PURE__ */ n("ul", { ref: a, ...s.listboxProps, css: Ce.list, style: m, children: r.map((c, h) => /* @__PURE__ */ n("li", { ...s.optionProps(h), css: Ce.option, children: c.label }, c.value)) })
1655
+ ] });
1656
+ }, te = {
1657
+ root: o({ marginInline: "auto", maxHeight: "100%", overflowY: "auto", backgroundColor: e.surface }),
1658
+ header: o({ marginBottom: e.spaceLg }),
1659
+ title: o(z.h3, { marginBottom: e.spaceXs }),
1660
+ count: o(z.bodySm, { color: e.textSecondary }),
1661
+ divider: o({
1662
+ position: "relative",
1663
+ flexShrink: 0,
1664
+ alignSelf: "stretch",
1665
+ height: "1px",
1666
+ marginBlock: e.spaceLg,
1667
+ marginInline: 0,
1668
+ border: "none",
1669
+ backgroundColor: "var(--fu-ucrc-divider)"
1670
+ }),
1671
+ sortRow: o({
1672
+ display: "flex",
1673
+ justifyContent: "space-between",
1674
+ alignItems: "center",
1675
+ marginBottom: e.spaceLg
1676
+ }),
1677
+ listSpinner: o({ paddingBlock: e.spaceXl }),
1678
+ empty: o({ textAlign: "center", paddingBlock: e.spaceXl }),
1679
+ emptyText: o(z.bodyMd, { color: e.textSecondary }),
1680
+ sentinel: o({ height: "1px" }),
1681
+ moreSpinner: o({ paddingBlock: e.spaceMd }),
1682
+ loadMore: o({ display: "flex", justifyContent: "center", marginTop: e.spaceLg })
1683
+ }, go = ({
1684
+ discussion: t,
1685
+ posts: r,
1686
+ postsHidden: i = !1,
1687
+ sdk: s,
1688
+ userIsLoggedIn: p,
1689
+ onSignInClick: a,
1690
+ showReactions: m,
1691
+ showReplies: d,
1692
+ showReportPost: l,
1693
+ currentSort: c,
1694
+ onSortChange: h,
1695
+ onCreatePost: u,
1696
+ onReact: y,
1697
+ onDeletePost: b,
1698
+ onReportPost: g,
1699
+ onLoadMore: k,
1700
+ hasMore: I,
1701
+ liveRefresh: v = !1,
1702
+ newPostIds: f,
1703
+ onNewPostSeen: B,
1704
+ isLoading: A,
1705
+ isSubmitting: E,
1706
+ infiniteScroll: $ = !1,
1707
+ showModeratedPosts: J = !1,
1708
+ ban: U,
1709
+ isBanned: V = !1,
1710
+ showBanHistory: q = !1
1711
+ }) => {
1712
+ const { t: T } = ye(), _ = _e(), oe = W(null), ne = W(null);
1713
+ he(() => {
1714
+ if (!$ || !ne.current) return;
1715
+ const P = new IntersectionObserver(
1716
+ (j) => {
1717
+ j[0].isIntersecting && I && !A && k();
1718
+ },
1719
+ { root: oe.current, threshold: 0.1 }
1720
+ );
1721
+ return P.observe(ne.current), () => P.disconnect();
1722
+ }, [$, I, A, k]);
1723
+ const [pe, Z] = D({ open: !1, variant: "success", title: "", message: "" }), de = () => {
1724
+ Z({
1725
+ open: !0,
1726
+ variant: "success",
1727
+ title: "",
1728
+ message: T("discussion.delete.success", "Comment deleted successfully.")
1729
+ });
1730
+ }, re = (P, j) => {
1731
+ mt(P) || Z({
1732
+ open: !0,
1733
+ variant: "error",
1734
+ title: "",
1735
+ message: fo(P) ? T(
1736
+ "discussion.rateLimited",
1737
+ "You're doing that too often. Please wait a moment and try again."
1738
+ ) : j
1739
+ });
1740
+ }, ie = async (P, j) => {
1741
+ try {
1742
+ return await y(P, j);
1743
+ } catch (H) {
1744
+ throw re(
1745
+ H,
1746
+ T("discussion.reactError", "Failed to add reaction. Please try again.")
1747
+ ), H;
1748
+ }
1749
+ }, Q = async (P, j) => {
1750
+ try {
1751
+ await u(P, j);
1752
+ } catch (H) {
1753
+ throw re(
1754
+ H,
1755
+ T("discussion.postError", "Failed to post comment. Please try again.")
1756
+ ), H;
1757
+ }
1758
+ Z({
1759
+ open: !0,
1760
+ variant: "success",
1761
+ title: "",
1762
+ message: T("discussion.postSuccess", "Comment posted successfully.")
1763
+ });
1764
+ }, se = [
1765
+ { value: "LATEST", label: T("discussion.sort.latest", "Latest") },
1766
+ { value: "OLDEST", label: T("discussion.sort.oldest", "Oldest") },
1767
+ { value: "POPULAR", label: T("discussion.sort.popular", "Popular") },
1768
+ {
1769
+ value: "INTERACTED",
1770
+ label: T("discussion.sort.interacted", "Most Interacted")
1771
+ }
1772
+ ];
1773
+ return /* @__PURE__ */ S("div", { ref: oe, css: te.root, style: _, children: [
1774
+ /* @__PURE__ */ S("div", { css: te.header, children: [
1775
+ /* @__PURE__ */ n("h3", { css: te.title, children: t.label || T("discussion.title", "Discussion") }),
1776
+ !i && /* @__PURE__ */ n("p", { css: te.count, children: T("discussion.postsCount", "{{count}} posts", {
1777
+ count: t.postsCount || 0
1778
+ }) })
1779
+ ] }),
1780
+ V && U && /* @__PURE__ */ n(po, { ban: U, showBanHistory: q }),
1781
+ /* @__PURE__ */ n(
1782
+ ht,
1783
+ {
1784
+ onSubmit: (P) => Q(P),
1785
+ userIsLoggedIn: p,
1786
+ onSignInClick: a,
1787
+ isSubmitting: E,
1788
+ disabled: V
1789
+ }
1790
+ ),
1791
+ !i && /* @__PURE__ */ S(Re, { children: [
1792
+ /* @__PURE__ */ n("hr", { css: te.divider }),
1793
+ /* @__PURE__ */ S("div", { css: te.sortRow, children: [
1794
+ /* @__PURE__ */ n("p", { css: z.titleMd, children: T("discussion.comments", "Comments") }),
1795
+ /* @__PURE__ */ n(mo, { value: c, options: se, onChange: h })
1796
+ ] }),
1797
+ A && r.length === 0 ? /* @__PURE__ */ n("div", { css: te.listSpinner, children: /* @__PURE__ */ n(We, { marginBlock: "32px" }) }) : r.length === 0 ? /* @__PURE__ */ n("div", { css: te.empty, children: /* @__PURE__ */ n("p", { css: te.emptyText, children: T(
1798
+ "discussion.noPosts",
1799
+ "No comments yet. Be the first to comment!"
1800
+ ) }) }) : /* @__PURE__ */ S(Re, { children: [
1801
+ /* @__PURE__ */ n("div", { children: r.map((P) => /* @__PURE__ */ n(
1802
+ xt,
1803
+ {
1804
+ post: P,
1805
+ sdk: s,
1806
+ userIsLoggedIn: p,
1807
+ onSignInClick: a,
1808
+ showReactions: m,
1809
+ showReplies: d,
1810
+ showReportPost: l,
1811
+ onReply: (j, H) => Q(H, j),
1812
+ onReact: ie,
1813
+ onDelete: b,
1814
+ onReport: g,
1815
+ isSubmitting: E,
1816
+ showModeratedPosts: J,
1817
+ isBanned: V,
1818
+ highlightable: v,
1819
+ isNew: f == null ? void 0 : f.has(P.id),
1820
+ onNewSeen: B,
1821
+ onDeleteSuccess: de
1822
+ },
1823
+ P.id
1824
+ )) }),
1825
+ $ && /* @__PURE__ */ n("div", { ref: ne, css: te.sentinel })
1826
+ ] }),
1827
+ $ && A && r.length > 0 && /* @__PURE__ */ n("div", { css: te.moreSpinner, children: /* @__PURE__ */ n(We, { marginBlock: "16px" }) }),
1828
+ !$ && I && /* @__PURE__ */ n("div", { css: te.loadMore, children: /* @__PURE__ */ n(ue, { look: "outlined", onClick: k, loading: A, children: T("discussion.loadMore", "Load More") }) })
1829
+ ] }),
1830
+ /* @__PURE__ */ n(
1831
+ pt,
1832
+ {
1833
+ notification: pe,
1834
+ onClose: () => Z((P) => ({ ...P, open: !1 }))
1835
+ }
1836
+ )
1837
+ ] });
1838
+ }, ho = (t) => {
1839
+ const {
1840
+ entityId: r,
1841
+ sdk: i,
1842
+ discussionLabel: s,
1843
+ discussionUrl: p = "",
1844
+ defaultSort: a = "LATEST",
1845
+ postsPerPage: m = 20,
1846
+ showReactions: d = !0,
1847
+ showReplies: l = !0,
1848
+ showReportPost: c = !0,
1849
+ infiniteScroll: h = !1,
1850
+ showModeratedPosts: u = !1,
1851
+ userIsLoggedIn: y = !1,
1852
+ showBanHistory: b = !1,
1853
+ refreshInterval: g = 0,
1854
+ onSignInClick: k
1855
+ } = t, { ban: I, isBanned: v, refresh: f } = Zt(i, y), {
1856
+ discussion: B,
1857
+ setDiscussion: A,
1858
+ isLoading: E,
1859
+ error: $,
1860
+ isNotFound: J
1861
+ } = _t(i, r), U = () => ({
1862
+ id: r,
1863
+ label: "",
1864
+ postsCount: 0,
1865
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1866
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1867
+ }), V = (fe) => {
1868
+ A((R) => {
1869
+ const w = R ?? U();
1870
+ return { ...w, postsCount: Math.max(0, w.postsCount + fe) };
1871
+ });
1872
+ }, {
1873
+ posts: q,
1874
+ postsHidden: T,
1875
+ isLoading: _,
1876
+ isSubmitting: oe,
1877
+ currentSort: ne,
1878
+ hasMore: pe,
1879
+ newPostIds: Z,
1880
+ markPostSeen: de,
1881
+ handleSortChange: re,
1882
+ handleLoadMore: ie,
1883
+ handleCreatePost: Q,
1884
+ handleReact: se,
1885
+ handleDeletePost: P,
1886
+ handleReportPost: j
1887
+ } = Jt(
1888
+ i,
1889
+ r,
1890
+ s || null,
1891
+ p,
1892
+ a,
1893
+ m,
1894
+ V,
1895
+ u,
1896
+ g
1897
+ ), H = (fe) => async (...R) => {
1898
+ try {
1899
+ return await fe(...R);
1900
+ } catch (w) {
1901
+ throw mt(w) && f(), w;
1902
+ }
1903
+ };
1904
+ if (E || !B && !J && _)
1905
+ return /* @__PURE__ */ n(We, { marginBlock: "160px" });
1906
+ if ($)
1907
+ return /* @__PURE__ */ n("div", { style: { padding: "20px", textAlign: "center" }, children: /* @__PURE__ */ n("p", { children: "Failed to load discussion. Please try again later." }) });
1908
+ const Ee = async (fe, R) => {
1909
+ await Q(fe, R), s && A((w) => ({ ...w ?? U(), label: s }));
1910
+ };
1911
+ return /* @__PURE__ */ n(
1912
+ go,
1913
+ {
1914
+ discussion: B ?? U(),
1915
+ posts: q,
1916
+ postsHidden: T,
1917
+ sdk: i,
1918
+ userIsLoggedIn: y,
1919
+ onSignInClick: k,
1920
+ showReactions: d,
1921
+ showReplies: l,
1922
+ showReportPost: c,
1923
+ currentSort: ne,
1924
+ onSortChange: re,
1925
+ onCreatePost: H(Ee),
1926
+ onReact: H(se),
1927
+ onDeletePost: H(P),
1928
+ onReportPost: H(j),
1929
+ onLoadMore: ie,
1930
+ hasMore: pe,
1931
+ liveRefresh: g > 0,
1932
+ newPostIds: Z,
1933
+ onNewPostSeen: de,
1934
+ isLoading: _,
1935
+ isSubmitting: oe,
1936
+ infiniteScroll: h,
1937
+ showModeratedPosts: u,
1938
+ ban: I,
1939
+ isBanned: v,
1940
+ showBanHistory: b
1941
+ }
1942
+ );
1943
+ }, Ro = (t) => /* @__PURE__ */ n(
1944
+ Ct,
1945
+ {
1946
+ packageName: "discussion",
1947
+ language: t.language,
1948
+ themeOptions: t.themeOptions,
1949
+ disableCache: t.disableCache,
1950
+ fillHeight: !0,
1951
+ children: /* @__PURE__ */ n(ho, { ...t })
1952
+ }
1953
+ );
1954
+ export {
1955
+ Ro as M
1956
+ };