fansunited-frontend-components 0.0.92 → 0.0.94

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 (139) hide show
  1. package/Betslip.js +1 -1
  2. package/ChanceGame.js +139 -146
  3. package/ClassicQuizPlay.js +1 -1
  4. package/CollectLead.js +14 -20
  5. package/CompetitionStatistics.js +27 -27
  6. package/CompetitorCard.js +895 -891
  7. package/Discussion.js +1 -1
  8. package/EitherOrPlay.js +1 -1
  9. package/EventCard.js +1494 -1571
  10. package/EventGamePlay.js +1 -1
  11. package/Leaderboard.js +249 -257
  12. package/List.js +319 -436
  13. package/MatchQuizPlay.js +1 -1
  14. package/Odds.js +30 -30
  15. package/PersonalityQuizPlay.js +1 -1
  16. package/PickThePair.js +627 -693
  17. package/PlayerOfTheMatch.js +256 -279
  18. package/PollVote.js +1 -1
  19. package/Predictor.js +19443 -2
  20. package/README.md +2 -1
  21. package/Standings.js +94 -99
  22. package/TopX.js +5871 -6988
  23. package/chunks/ChanceGameEmbedVariant-C3NGwvTF.js +21 -0
  24. package/chunks/OddsSkeleton-Bav8FHHN.js +26 -0
  25. package/chunks/{OddsStrip-B159Nivm.js → OddsStrip-CviVfQI4.js} +51 -53
  26. package/chunks/{PickOneOfX-D9qlxKTD.js → PickOneOfX-a6Dv0-rR.js} +210 -212
  27. package/chunks/index-B1d9q8fX.js +4 -0
  28. package/chunks/index-BP0pvFJ4.js +4 -0
  29. package/chunks/index-CHZyL_g_.js +4 -0
  30. package/chunks/index-CeCUdRmF.js +4 -0
  31. package/chunks/index-Ckyyw-I8.js +4 -0
  32. package/chunks/index-DGvCP5G8.js +4 -0
  33. package/chunks/index-yjMVOgwO.js +4 -0
  34. package/chunks/{main-CcPVuc5G.js → main-CFwRpvUi.js} +219 -238
  35. package/chunks/{main-By2Fg4Us.js → main-D9tFZv2q.js} +272 -309
  36. package/chunks/{main-Db4YC1C9.js → main-Dj4Manb5.js} +386 -407
  37. package/chunks/{main-BhONg691.js → main-DjiQz1dv.js} +764 -1125
  38. package/chunks/{main-BoLNJccN.js → main-Dys2_Jt2.js} +1625 -1954
  39. package/chunks/{main-JAewg2VD.js → main-dwV_55lz.js} +409 -432
  40. package/chunks/main-eAQMCxQ7.js +1949 -0
  41. package/chunks/{main-CWfREbUv.js → main-gexg6lc-.js} +959 -977
  42. package/index.js +40 -44
  43. package/package.json +13 -5
  44. package/chunks/AccessTime-B7Q_InTi.js +0 -10
  45. package/chunks/AlertMessage-CTbc9daZ.js +0 -318
  46. package/chunks/Avatar-Ve0m4ut_.js +0 -353
  47. package/chunks/Button-x1sQVMH2.js +0 -665
  48. package/chunks/Card-DfxnA3Cz.js +0 -196
  49. package/chunks/CardActions-TMBAbk8a.js +0 -140
  50. package/chunks/CardContent-CLQHztIU.js +0 -106
  51. package/chunks/ChanceGameEmbedVariant-C3TKbPI4.js +0 -913
  52. package/chunks/CheckCircle-DW1VzjQO.js +0 -8
  53. package/chunks/Chip-BUoNpinI.js +0 -365
  54. package/chunks/CircularProgress-D88LgW2V.js +0 -317
  55. package/chunks/Close-BxLZcPtb.js +0 -9
  56. package/chunks/Close-DVx6f5-e.js +0 -8
  57. package/chunks/CollectLeadForm-DtUFKk99.js +0 -3419
  58. package/chunks/ConsentsList-BcIMKviP.js +0 -339
  59. package/chunks/DirectionScope-CK0duYt8.js +0 -36
  60. package/chunks/Divider-D_ALv2uC.js +0 -166
  61. package/chunks/Edit-CiKqhDom.js +0 -99
  62. package/chunks/EmojiEvents-BYoxruEl.js +0 -8
  63. package/chunks/FavoriteBorder-YhT6RHv5.js +0 -11
  64. package/chunks/FormControl-BNG04EhC.js +0 -656
  65. package/chunks/FormControlContext-Ct0huDDM.js +0 -6
  66. package/chunks/FormLabel-Bl7hTa8O.js +0 -130
  67. package/chunks/GlobalStyles-PokSS9bO.js +0 -12
  68. package/chunks/InlineSpinner-BhKW6lxZ.js +0 -28
  69. package/chunks/Input-B7kPqO0b.js +0 -391
  70. package/chunks/KeyboardArrowDown-OGGGLEnE.js +0 -8
  71. package/chunks/KeyboardArrowRight-DN7qrp17.js +0 -11
  72. package/chunks/KeyboardArrowUp-jvN5m_A0.js +0 -8
  73. package/chunks/Link-brb09X-6.js +0 -319
  74. package/chunks/ListItemButton-BFG5QJbo.js +0 -1151
  75. package/chunks/ModalClose-D3i-AyMB.js +0 -153
  76. package/chunks/ModalDialog-Be6w76fh.js +0 -880
  77. package/chunks/NotFoundSkeleton-BHRVG8yg.js +0 -83
  78. package/chunks/Notification-CC66HKXb.js +0 -614
  79. package/chunks/OddsSkeleton-BBOVhfsn.js +0 -137
  80. package/chunks/OverlayScoreStateSkeleton-D5rnBJ_w.js +0 -154
  81. package/chunks/OverlayScoreStateWrapperSkeleton-CTXzD0bm.js +0 -81
  82. package/chunks/OverlaySignInSkeleton-T8A_9Tco.js +0 -518
  83. package/chunks/OverlaySkeleton-y02LRXZy.js +0 -1193
  84. package/chunks/Person-BD-IO4aX.js +0 -8
  85. package/chunks/PersonOutline-Nxl_9g9S.js +0 -8
  86. package/chunks/Popper-CGfJHTbM.js +0 -1263
  87. package/chunks/Portal-DQQSLiON.js +0 -74
  88. package/chunks/Portal-X8O64KaQ.js +0 -66
  89. package/chunks/Predictor-BJBBwZ6R.js +0 -19513
  90. package/chunks/PrizeCard-B2tBhY45.js +0 -36400
  91. package/chunks/Search-jaDXe8g7.js +0 -14
  92. package/chunks/Select-CzBMHr7z.js +0 -1165
  93. package/chunks/Sheet-x-YGYOYz.js +0 -132
  94. package/chunks/SignInCta-3NFxIOuf.js +0 -79
  95. package/chunks/Spinner-_5U881sC.js +0 -39
  96. package/chunks/SportsSoccer-DLUgspA-.js +0 -20
  97. package/chunks/Stack-CDpKA1D-.js +0 -169
  98. package/chunks/StandardContentSkeleton-DaZftDxZ.js +0 -57
  99. package/chunks/Table-IJ9-D2DF.js +0 -394
  100. package/chunks/Tabs-iyOvjGfd.js +0 -1084
  101. package/chunks/Textarea-Dv_Z4l5j.js +0 -475
  102. package/chunks/TimerOutlined-jNsK__Zz.js +0 -8
  103. package/chunks/Tooltip-clSjN1oC.js +0 -535
  104. package/chunks/Typography-BsucZNXl.js +0 -775
  105. package/chunks/areArraysEqual-B3mXtHvh.js +0 -6
  106. package/chunks/colorInversionUtils-AoR_6ghW.js +0 -347
  107. package/chunks/createSvgIcon-BWoHeNkc.js +0 -2813
  108. package/chunks/createSvgIcon-DBkOhFdn.js +0 -206
  109. package/chunks/dividerClasses-BkQMLbsL.js +0 -9
  110. package/chunks/elementAcceptingRef-DjUfkpLB.js +0 -25
  111. package/chunks/enums-B1lTCQvC.js +0 -15
  112. package/chunks/formLabelClasses-N0g8NZ67.js +0 -9
  113. package/chunks/getReactElementRef-B3MFPBbS.js +0 -21
  114. package/chunks/helpers-CKFwVhwj.js +0 -558
  115. package/chunks/index-Bg5jypgn.js +0 -11
  116. package/chunks/index-Bnad45hB.js +0 -4
  117. package/chunks/index-C6rtfeRX.js +0 -4
  118. package/chunks/index-CFc0WTOi.js +0 -848
  119. package/chunks/index-C_kf8WZI.js +0 -4
  120. package/chunks/index-CaVpDbdC.js +0 -4
  121. package/chunks/index-DJJVbXn_.js +0 -4
  122. package/chunks/index-DQO7VDRC.js +0 -4
  123. package/chunks/index-Kgehqf8J.js +0 -4
  124. package/chunks/main-W_W6YBtr.js +0 -3280
  125. package/chunks/ownerWindow-PI509BpA.js +0 -7
  126. package/chunks/searchEntities-SJcoznz0.js +0 -38
  127. package/chunks/sportsEvents-CGX-WkNB.js +0 -27
  128. package/chunks/useButton-C9taTgFS.js +0 -106
  129. package/chunks/useConsents-BLhgfEDf.js +0 -1168
  130. package/chunks/useControlled-BYdyS7Pn.js +0 -31
  131. package/chunks/useEmbedCode-DCWnWGak.js +0 -31
  132. package/chunks/useEventCallback-C9W0M_8l.js +0 -14
  133. package/chunks/useForwardedInput-CkAnayh_.js +0 -180
  134. package/chunks/useImageVariant-B62O7iLC.js +0 -15
  135. package/chunks/useInfoPage-BHdgKdme.js +0 -50
  136. package/chunks/useParticipationDraft-Brnd_p3w.js +0 -307
  137. package/chunks/useSwitch-DLSSqtcZ.js +0 -66
  138. package/chunks/variantColorInheritance-DZr7CNx6.js +0 -30
  139. package/chunks/visuallyHidden-B8J7BVSJ.js +0 -14
@@ -1,3280 +0,0 @@
1
- import { jsx as n, jsxs as w, Fragment as Ie } from "react/jsx-runtime";
2
- import * as M from "react";
3
- import ce, { useState as U, useEffect as Re, useRef as fe, useCallback as Pe } from "react";
4
- import { _ as F, S as Me, D as je, G as De, F as we, H as $e, P as t, J as me, I as vo, a as Ce, g as be, f as Se, u as Te, d as ge, B as O, b as ke, v as Oe, z as Ye, p as xo, o as Ro, q as Co, r as So, C as Po, s as Io, E as zo, t as Eo, w as Mo } from "./PrizeCard-B2tBhY45.js";
5
- import { S as Ne } from "./Spinner-_5U881sC.js";
6
- import { createPortal as To } from "react-dom";
7
- import { B as ye, I as Do } from "./Button-x1sQVMH2.js";
8
- import { u as Xe, e as Qe, s as ve, a as Ae, c as Le, b as xe, h as wo, T as K } from "./Typography-BsucZNXl.js";
9
- import { T as Ze } from "./Textarea-Dv_Z4l5j.js";
10
- import { c as de } from "./createSvgIcon-BWoHeNkc.js";
11
- import { F as $o, a as ko } from "./FavoriteBorder-YhT6RHv5.js";
12
- import { i as ze, h as Oo, u as Ao, j as Lo, o as _e, e as Vo, k as Ke, n as Fo, f as No, S as _o, s as Bo, G as Ho, L as Wo, b as Ko, R as Uo, d as jo, p as eo } from "./ListItemButton-BFG5QJbo.js";
13
- import { V as Go, u as Jo } from "./variantColorInheritance-DZr7CNx6.js";
14
- import { a as qo, b as Yo } from "./colorInversionUtils-AoR_6ghW.js";
15
- import { u as Xo, P as Qo, r as Zo } from "./Popper-CGfJHTbM.js";
16
- import { u as et } from "./useButton-C9taTgFS.js";
17
- import { M as oo, a as to } from "./ModalDialog-Be6w76fh.js";
18
- import { M as ot } from "./ModalClose-D3i-AyMB.js";
19
- import { F as Be } from "./FormControlContext-Ct0huDDM.js";
20
- import { u as tt } from "./useControlled-BYdyS7Pn.js";
21
- import { u as nt } from "./useSwitch-DLSSqtcZ.js";
22
- import { N as no } from "./Notification-CC66HKXb.js";
23
- import { A as rt } from "./Avatar-Ve0m4ut_.js";
24
- import { K as st } from "./KeyboardArrowDown-OGGGLEnE.js";
25
- import { D as at } from "./Divider-D_ALv2uC.js";
26
- import { S as it, a as lt } from "./Select-CzBMHr7z.js";
27
- const Ue = /* @__PURE__ */ M.createContext(null);
28
- process.env.NODE_ENV !== "production" && (Ue.displayName = "DropdownContext");
29
- const He = {
30
- blur: "dropdown:blur",
31
- escapeKeyDown: "dropdown:escapeKeyDown",
32
- toggle: "dropdown:toggle",
33
- open: "dropdown:open",
34
- close: "dropdown:close"
35
- };
36
- function ct(e, o) {
37
- if (o.type === ze.itemHover)
38
- return F({}, e, {
39
- highlightedValue: o.item
40
- });
41
- const r = Oo(e, o);
42
- if (r.highlightedValue === null && o.context.items.length > 0)
43
- return F({}, r, {
44
- highlightedValue: o.context.items[0]
45
- });
46
- if (o.type === ze.keyDown && o.event.key === "Escape")
47
- return F({}, r, {
48
- open: !1
49
- });
50
- if (o.type === ze.blur) {
51
- var l;
52
- if (!((l = o.context.listboxRef.current) != null && l.contains(o.event.relatedTarget))) {
53
- var i, s;
54
- const c = (i = o.context.listboxRef.current) == null ? void 0 : i.getAttribute("id"), a = (s = o.event.relatedTarget) == null ? void 0 : s.getAttribute("aria-controls");
55
- return c && a && c === a ? r : F({}, r, {
56
- open: !1,
57
- highlightedValue: o.context.items[0]
58
- });
59
- }
60
- }
61
- return r;
62
- }
63
- const dt = {
64
- dispatch: () => {
65
- },
66
- popupId: "",
67
- registerPopup: () => {
68
- },
69
- registerTrigger: () => {
70
- },
71
- state: {
72
- open: !0,
73
- changeReason: null
74
- },
75
- triggerElement: null
76
- };
77
- function ut(e = {}) {
78
- var o, r;
79
- const {
80
- listboxRef: l,
81
- onItemsChange: i,
82
- id: s,
83
- disabledItemsFocusable: c = !0,
84
- disableListWrap: a = !1,
85
- autoFocus: d = !0,
86
- componentName: u = "useMenu"
87
- } = e, m = M.useRef(null), p = Xe(m, l), y = (o = Me(s)) != null ? o : "", {
88
- state: {
89
- open: b,
90
- changeReason: g
91
- },
92
- dispatch: x,
93
- triggerElement: I,
94
- registerPopup: v
95
- } = (r = M.useContext(Ue)) != null ? r : dt, C = M.useRef(b), {
96
- subitems: R,
97
- contextValue: A
98
- } = Ao(), f = M.useMemo(() => Array.from(R.keys()), [R]), P = M.useCallback((h) => {
99
- var T, z;
100
- return h == null ? null : (T = (z = R.get(h)) == null ? void 0 : z.ref.current) != null ? T : null;
101
- }, [R]), k = M.useCallback((h) => {
102
- var T;
103
- return (R == null || (T = R.get(h)) == null ? void 0 : T.disabled) || !1;
104
- }, [R]), D = M.useCallback((h) => {
105
- var T, z;
106
- return ((T = R.get(h)) == null ? void 0 : T.label) || ((z = R.get(h)) == null || (z = z.ref.current) == null ? void 0 : z.innerText);
107
- }, [R]), j = M.useMemo(() => ({
108
- listboxRef: m
109
- }), [m]), {
110
- dispatch: $,
111
- getRootProps: L,
112
- contextValue: ee,
113
- state: {
114
- highlightedValue: _
115
- },
116
- rootRef: E
117
- } = Lo({
118
- disabledItemsFocusable: c,
119
- disableListWrap: a,
120
- focusManagement: "DOM",
121
- getItemDomElement: P,
122
- getInitialState: () => ({
123
- selectedValues: [],
124
- highlightedValue: null
125
- }),
126
- isItemDisabled: k,
127
- items: f,
128
- getItemAsString: D,
129
- rootRef: p,
130
- onItemsChange: i,
131
- reducerActionContext: j,
132
- selectionMode: "none",
133
- stateReducer: ct,
134
- componentName: u
135
- });
136
- je(() => {
137
- v(y);
138
- }, [y, v]), je(() => {
139
- b && (g == null ? void 0 : g.type) === "keydown" && g.key === "ArrowUp" && $({
140
- type: ze.highlightLast,
141
- event: g
142
- });
143
- }, [b, g, $]), M.useEffect(() => {
144
- if (b && d && _ && !C.current) {
145
- var h;
146
- (h = R.get(_)) == null || (h = h.ref) == null || (h = h.current) == null || h.focus();
147
- }
148
- }, [b, d, _, R, f]), M.useEffect(() => {
149
- var h;
150
- if ((h = m.current) != null && h.contains(document.activeElement) && _ !== null) {
151
- var T;
152
- R == null || (T = R.get(_)) == null || (T = T.ref.current) == null || T.focus();
153
- }
154
- }, [_, R]);
155
- const N = (h) => (T) => {
156
- var z, ie;
157
- (z = h.onBlur) == null || z.call(h, T), !T.defaultMuiPrevented && ((ie = m.current) != null && ie.contains(T.relatedTarget) || T.relatedTarget === I || x({
158
- type: He.blur,
159
- event: T
160
- }));
161
- }, X = (h) => (T) => {
162
- var z;
163
- (z = h.onKeyDown) == null || z.call(h, T), !T.defaultMuiPrevented && T.key === "Escape" && x({
164
- type: He.escapeKeyDown,
165
- event: T
166
- });
167
- }, te = (h = {}) => ({
168
- onBlur: N(h),
169
- onKeyDown: X(h)
170
- }), ne = (h = {}) => {
171
- const T = _e(te, L), z = Qe(h);
172
- return F({}, h, z, T(z), {
173
- id: y,
174
- role: "menu"
175
- });
176
- };
177
- return M.useDebugValue({
178
- subitems: R,
179
- highlightedValue: _
180
- }), {
181
- contextValue: F({}, A, ee),
182
- dispatch: $,
183
- getListboxProps: ne,
184
- highlightedValue: _,
185
- listboxRef: E,
186
- menuItems: R,
187
- open: b,
188
- triggerElement: I
189
- };
190
- }
191
- function mt(e) {
192
- const {
193
- value: o,
194
- children: r
195
- } = e, {
196
- dispatch: l,
197
- getItemIndex: i,
198
- getItemState: s,
199
- registerItem: c,
200
- totalSubitemCount: a
201
- } = o, d = M.useMemo(() => ({
202
- dispatch: l,
203
- getItemState: s,
204
- getItemIndex: i
205
- }), [l, i, s]), u = M.useMemo(() => ({
206
- getItemIndex: i,
207
- registerItem: c,
208
- totalSubitemCount: a
209
- }), [c, i, a]);
210
- return /* @__PURE__ */ n(Vo.Provider, {
211
- value: u,
212
- children: /* @__PURE__ */ n(Ke.Provider, {
213
- value: d,
214
- children: r
215
- })
216
- });
217
- }
218
- function pt(e) {
219
- return `menu-item-${e.size}`;
220
- }
221
- const ft = {
222
- dispatch: () => {
223
- },
224
- popupId: "",
225
- registerPopup: () => {
226
- },
227
- registerTrigger: () => {
228
- },
229
- state: {
230
- open: !0,
231
- changeReason: null
232
- },
233
- triggerElement: null
234
- };
235
- function ht(e) {
236
- var o;
237
- const {
238
- disabled: r = !1,
239
- id: l,
240
- rootRef: i,
241
- label: s,
242
- disableFocusOnHover: c = !1
243
- } = e, a = Me(l), d = M.useRef(null), u = M.useMemo(() => ({
244
- disabled: r,
245
- id: a ?? "",
246
- label: s,
247
- ref: d
248
- }), [r, a, s]), {
249
- dispatch: m
250
- } = (o = M.useContext(Ue)) != null ? o : ft, {
251
- getRootProps: p,
252
- highlighted: y
253
- } = Fo({
254
- item: a,
255
- handlePointerOverEvents: !c
256
- }), {
257
- index: b,
258
- totalItemCount: g
259
- } = No(a ?? pt, u), {
260
- getRootProps: x,
261
- focusVisible: I,
262
- rootRef: v
263
- } = et({
264
- disabled: r,
265
- focusableWhenDisabled: !0
266
- }), C = Xe(v, i, d);
267
- M.useDebugValue({
268
- id: a,
269
- highlighted: y,
270
- disabled: r,
271
- label: s
272
- });
273
- const R = (P) => (k) => {
274
- var D;
275
- (D = P.onClick) == null || D.call(P, k), !k.defaultMuiPrevented && m({
276
- type: He.close,
277
- event: k
278
- });
279
- }, A = (P = {}) => F({}, P, {
280
- onClick: R(P)
281
- });
282
- function f(P = {}) {
283
- const k = Qe(P), D = _e(A, _e(x, p));
284
- return F({}, P, k, D(k), {
285
- id: a,
286
- ref: C,
287
- role: "menuitem"
288
- });
289
- }
290
- return a === void 0 ? {
291
- getRootProps: f,
292
- disabled: !1,
293
- focusVisible: I,
294
- highlighted: !1,
295
- index: -1,
296
- totalItemCount: 0,
297
- rootRef: C
298
- } : {
299
- getRootProps: f,
300
- disabled: r,
301
- focusVisible: I,
302
- highlighted: y,
303
- index: b,
304
- totalItemCount: g,
305
- rootRef: C
306
- };
307
- }
308
- function yt(e) {
309
- const o = M.useContext(Ke);
310
- if (!o)
311
- throw new Error("MenuItem: ListContext was not found.");
312
- const r = Me(e), {
313
- getItemState: l,
314
- dispatch: i
315
- } = o;
316
- let s;
317
- r != null ? s = l(r) : s = {
318
- focusable: !0,
319
- highlighted: !1,
320
- selected: !1
321
- };
322
- const {
323
- highlighted: c,
324
- selected: a,
325
- focusable: d
326
- } = s, u = M.useCallback((p) => {
327
- if (p !== r)
328
- throw new Error(["Base UI MenuItem: Tried to access the state of another MenuItem.", `itemValue: ${p} | id: ${r}`, "This is unsupported when the MenuItem uses the MenuItemContextStabilizer as a performance optimization."].join("/n"));
329
- return {
330
- highlighted: c,
331
- selected: a,
332
- focusable: d
333
- };
334
- }, [c, a, d, r]);
335
- return {
336
- contextValue: M.useMemo(() => ({
337
- dispatch: i,
338
- getItemState: u
339
- }), [i, u]),
340
- id: r
341
- };
342
- }
343
- function bt(e) {
344
- return De("MuiMenu", e);
345
- }
346
- we("MuiMenu", ["root", "listbox", "expanded", "colorPrimary", "colorNeutral", "colorDanger", "colorSuccess", "colorWarning", "colorContext", "variantPlain", "variantOutlined", "variantSoft", "variantSolid", "sizeSm", "sizeMd", "sizeLg"]);
347
- const gt = ["actions", "children", "color", "component", "disablePortal", "keepMounted", "id", "invertedColors", "onItemsChange", "modifiers", "variant", "size", "slots", "slotProps"], vt = (e) => {
348
- const {
349
- open: o,
350
- variant: r,
351
- color: l,
352
- size: i
353
- } = e, s = {
354
- root: ["root", o && "expanded", r && `variant${me(r)}`, l && `color${me(l)}`, i && `size${me(i)}`],
355
- listbox: ["listbox"]
356
- };
357
- return Le(s, bt, {});
358
- }, Ge = ve(_o, {
359
- name: "JoyMenu",
360
- slot: "Root",
361
- overridesResolver: (e, o) => o.root
362
- })(({
363
- theme: e,
364
- ownerState: o
365
- }) => {
366
- var r, l;
367
- const i = (r = e.variants[o.variant]) == null ? void 0 : r[o.color];
368
- return [F({
369
- "--focus-outline-offset": `calc(${e.vars.focus.thickness} * -1)`,
370
- // to prevent the focus outline from being cut by overflow
371
- "--ListItem-stickyBackground": (i == null ? void 0 : i.backgroundColor) || (i == null ? void 0 : i.background) || e.vars.palette.background.popup,
372
- "--ListItem-stickyTop": "calc(var(--List-padding, var(--ListDivider-gap)) * -1)"
373
- }, Bo, {
374
- borderRadius: `var(--List-radius, ${e.vars.radius.sm})`,
375
- boxShadow: e.shadow.md,
376
- overflow: "auto",
377
- // `unstable_popup-zIndex` is a private variable that lets other component, for example Modal, to override the z-index so that the listbox can be displayed above the Modal.
378
- zIndex: `var(--unstable_popup-zIndex, ${e.vars.zIndex.popup})`
379
- }, !(i != null && i.backgroundColor) && {
380
- backgroundColor: e.vars.palette.background.popup
381
- }, o.variant === "solid" && o.color && o.invertedColors && qo(o.color)(e), o.variant === "soft" && o.color && o.invertedColors && Yo(o.color)(e), (l = e.variants[o.variant]) == null ? void 0 : l[o.color])];
382
- }), ro = /* @__PURE__ */ M.forwardRef(function(o, r) {
383
- var l;
384
- const i = Ae({
385
- props: o,
386
- name: "JoyMenu"
387
- }), {
388
- actions: s,
389
- children: c,
390
- color: a = "neutral",
391
- component: d,
392
- disablePortal: u = !1,
393
- keepMounted: m = !1,
394
- id: p,
395
- invertedColors: y = !1,
396
- onItemsChange: b,
397
- modifiers: g,
398
- variant: x = "outlined",
399
- size: I = "md",
400
- slots: v = {},
401
- slotProps: C = {}
402
- } = i, R = $e(i, gt), {
403
- contextValue: A,
404
- getListboxProps: f,
405
- dispatch: P,
406
- open: k,
407
- triggerElement: D
408
- } = ut({
409
- onItemsChange: b,
410
- id: p,
411
- listboxRef: r
412
- });
413
- M.useImperativeHandle(s, () => ({
414
- dispatch: P,
415
- resetHighlight: () => P({
416
- type: ze.resetHighlight,
417
- event: null
418
- })
419
- }), [P]);
420
- const j = F({}, i, {
421
- disablePortal: u,
422
- invertedColors: y,
423
- color: a,
424
- variant: x,
425
- size: I,
426
- open: k,
427
- nesting: !1,
428
- row: !1
429
- }), $ = vt(j), L = F({}, R, {
430
- component: d,
431
- slots: v,
432
- slotProps: C
433
- }), ee = M.useMemo(() => [{
434
- name: "offset",
435
- options: {
436
- offset: [0, 4]
437
- }
438
- }, ...g || []], [g]), _ = Xo({
439
- elementType: Ge,
440
- getSlotProps: f,
441
- externalForwardedProps: L,
442
- externalSlotProps: {},
443
- ownerState: j,
444
- additionalProps: {
445
- anchorEl: D,
446
- open: k && D !== null,
447
- disablePortal: u,
448
- keepMounted: m,
449
- modifiers: ee
450
- },
451
- className: $.root
452
- });
453
- return /* @__PURE__ */ n(Ge, F({}, _, !((l = i.slots) != null && l.root) && {
454
- as: Qo,
455
- slots: {
456
- root: d || "ul"
457
- }
458
- }, {
459
- children: /* @__PURE__ */ n(mt, {
460
- value: A,
461
- children: /* @__PURE__ */ n(Go, {
462
- variant: y ? void 0 : x,
463
- color: a,
464
- children: /* @__PURE__ */ n(Ho.Provider, {
465
- value: "menu",
466
- children: /* @__PURE__ */ n(Wo, {
467
- nested: !0,
468
- children: c
469
- })
470
- })
471
- })
472
- })
473
- }));
474
- });
475
- process.env.NODE_ENV !== "production" && (ro.propTypes = {
476
- // ┌────────────────────────────── Warning ──────────────────────────────┐
477
- // │ These PropTypes are generated from the TypeScript type definitions. │
478
- // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
479
- // └─────────────────────────────────────────────────────────────────────┘
480
- /**
481
- * A ref with imperative actions.
482
- * It allows to select the first or last menu item.
483
- */
484
- actions: Zo,
485
- /**
486
- * @ignore
487
- */
488
- children: t.node,
489
- /**
490
- * The color of the component. It supports those theme colors that make sense for this component.
491
- * @default 'neutral'
492
- */
493
- color: t.oneOf(["danger", "neutral", "primary", "success", "warning"]),
494
- /**
495
- * The component used for the root node.
496
- * Either a string to use a HTML element or a component.
497
- */
498
- component: t.elementType,
499
- /**
500
- * The `children` will be under the DOM hierarchy of the parent component.
501
- * @default false
502
- */
503
- disablePortal: t.bool,
504
- /**
505
- * @ignore
506
- */
507
- id: t.string,
508
- /**
509
- * If `true`, the children with an implicit color prop invert their colors to match the component's variant and color.
510
- * @default false
511
- */
512
- invertedColors: t.bool,
513
- /**
514
- * Always keep the children in the DOM.
515
- * This prop can be useful in SEO situation or
516
- * when you want to maximize the responsiveness of the Popper.
517
- * @default false
518
- */
519
- keepMounted: t.bool,
520
- /**
521
- * Popper.js is based on a "plugin-like" architecture,
522
- * most of its features are fully encapsulated "modifiers".
523
- *
524
- * A modifier is a function that is called each time Popper.js needs to
525
- * compute the position of the popper.
526
- * For this reason, modifiers should be very performant to avoid bottlenecks.
527
- * To learn how to create a modifier, [read the modifiers documentation](https://popper.js.org/docs/v2/modifiers/).
528
- */
529
- modifiers: t.arrayOf(t.shape({
530
- data: t.object,
531
- effect: t.func,
532
- enabled: t.bool,
533
- fn: t.func,
534
- name: t.any,
535
- options: t.object,
536
- phase: t.oneOf(["afterMain", "afterRead", "afterWrite", "beforeMain", "beforeRead", "beforeWrite", "main", "read", "write"]),
537
- requires: t.arrayOf(t.string),
538
- requiresIfExists: t.arrayOf(t.string)
539
- })),
540
- /**
541
- * Triggered when focus leaves the menu and the menu should close.
542
- */
543
- onClose: t.func,
544
- /**
545
- * Function called when the items displayed in the menu change.
546
- */
547
- onItemsChange: t.func,
548
- /**
549
- * Controls whether the menu is displayed.
550
- * @default false
551
- */
552
- open: t.bool,
553
- /**
554
- * The size of the component (affect other nested list* components because the `Menu` inherits `List`).
555
- * @default 'md'
556
- */
557
- size: t.oneOfType([t.oneOf(["sm", "md", "lg"]), t.string]),
558
- /**
559
- * The props used for each slot inside.
560
- * @default {}
561
- */
562
- slotProps: t.shape({
563
- root: t.oneOfType([t.func, t.object])
564
- }),
565
- /**
566
- * The components used for each slot inside.
567
- * @default {}
568
- */
569
- slots: t.shape({
570
- root: t.elementType
571
- }),
572
- /**
573
- * The system prop that allows defining system overrides as well as additional CSS styles.
574
- */
575
- sx: t.oneOfType([t.arrayOf(t.oneOfType([t.func, t.object, t.bool])), t.func, t.object]),
576
- /**
577
- * The [global variant](https://mui.com/joy-ui/main-features/global-variants/) to use.
578
- * @default 'outlined'
579
- */
580
- variant: t.oneOfType([t.oneOf(["outlined", "plain", "soft", "solid"]), t.string])
581
- });
582
- function xt(e) {
583
- return De("MuiMenuItem", e);
584
- }
585
- we("MuiMenuItem", ["root", "focusVisible", "disabled", "selected", "colorPrimary", "colorNeutral", "colorDanger", "colorSuccess", "colorWarning", "colorContext", "variantPlain", "variantSoft", "variantOutlined", "variantSolid"]);
586
- const Rt = ["children", "disabled", "component", "selected", "color", "orientation", "variant", "slots", "slotProps", "id"], Ct = (e) => {
587
- const {
588
- focusVisible: o,
589
- disabled: r,
590
- selected: l,
591
- color: i,
592
- variant: s
593
- } = e, c = {
594
- root: ["root", o && "focusVisible", r && "disabled", l && "selected", i && `color${me(i)}`, s && `variant${me(s)}`]
595
- };
596
- return Le(c, xt, {});
597
- }, St = ve(Ko, {
598
- name: "JoyMenuItem",
599
- slot: "Root",
600
- overridesResolver: (e, o) => o.root
601
- })({}), Pt = /* @__PURE__ */ M.memo(/* @__PURE__ */ M.forwardRef(function(o, r) {
602
- const l = Ae({
603
- props: o,
604
- name: "JoyMenuItem"
605
- }), i = M.useContext(Uo), {
606
- children: s,
607
- disabled: c = !1,
608
- component: a = "li",
609
- selected: d = !1,
610
- color: u = "neutral",
611
- orientation: m = "horizontal",
612
- variant: p = "plain",
613
- slots: y = {},
614
- slotProps: b = {},
615
- id: g
616
- } = l, x = $e(l, Rt), {
617
- variant: I = p,
618
- color: v = u
619
- } = Jo(o.variant, o.color), {
620
- getRootProps: C,
621
- disabled: R,
622
- focusVisible: A
623
- } = ht({
624
- id: g,
625
- disabled: c,
626
- rootRef: r
627
- }), f = F({}, l, {
628
- component: a,
629
- color: v,
630
- disabled: R,
631
- focusVisible: A,
632
- orientation: m,
633
- selected: d,
634
- row: i,
635
- variant: I
636
- }), P = Ct(f), k = F({}, x, {
637
- component: a,
638
- slots: y,
639
- slotProps: b
640
- }), [D, j] = xe("root", {
641
- ref: r,
642
- elementType: St,
643
- getSlotProps: C,
644
- externalForwardedProps: k,
645
- className: P.root,
646
- ownerState: f
647
- });
648
- return /* @__PURE__ */ n(jo.Provider, {
649
- value: m,
650
- children: /* @__PURE__ */ n(D, F({}, j, {
651
- children: s
652
- }))
653
- });
654
- })), We = /* @__PURE__ */ M.forwardRef(function(o, r) {
655
- const {
656
- contextValue: l,
657
- id: i
658
- } = yt(o.id);
659
- return /* @__PURE__ */ n(Ke.Provider, {
660
- value: l,
661
- children: /* @__PURE__ */ n(Pt, F({}, o, {
662
- id: i,
663
- ref: r
664
- }))
665
- });
666
- });
667
- process.env.NODE_ENV !== "production" && (We.propTypes = {
668
- // ┌────────────────────────────── Warning ──────────────────────────────┐
669
- // │ These PropTypes are generated from the TypeScript type definitions. │
670
- // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
671
- // └─────────────────────────────────────────────────────────────────────┘
672
- /**
673
- * The content of the component.
674
- */
675
- children: t.node,
676
- id: t.string
677
- });
678
- function It(e) {
679
- return De("MuiRadio", e);
680
- }
681
- const Ee = we("MuiRadio", ["root", "radio", "icon", "action", "input", "label", "checked", "disabled", "focusVisible", "colorPrimary", "colorDanger", "colorNeutral", "colorSuccess", "colorWarning", "colorContext", "sizeSm", "sizeMd", "sizeLg", "variantOutlined", "variantSoft", "variantSolid"]), zt = ["checked", "checkedIcon", "defaultChecked", "disabled", "disableIcon", "overlay", "label", "id", "name", "onBlur", "onChange", "onFocus", "onFocusVisible", "readOnly", "required", "color", "variant", "size", "uncheckedIcon", "value", "component", "slots", "slotProps"], Et = (e) => {
682
- const {
683
- checked: o,
684
- disabled: r,
685
- disableIcon: l,
686
- focusVisible: i,
687
- color: s,
688
- variant: c,
689
- size: a
690
- } = e, d = {
691
- root: ["root", o && "checked", r && "disabled", i && "focusVisible", c && `variant${me(c)}`, s && `color${me(s)}`, a && `size${me(a)}`],
692
- radio: ["radio", o && "checked", r && "disabled"],
693
- // disabled class is necessary for displaying global variant
694
- icon: ["icon"],
695
- action: [
696
- "action",
697
- o && "checked",
698
- l && r && "disabled",
699
- // add disabled class to action element for displaying global variant
700
- i && "focusVisible"
701
- ],
702
- input: ["input"],
703
- label: ["label"]
704
- };
705
- return Le(d, It, {});
706
- };
707
- function Mt(e, o) {
708
- return typeof o == "object" && o !== null ? e === o : String(e) === String(o);
709
- }
710
- const Tt = ve("span", {
711
- name: "JoyRadio",
712
- slot: "Root",
713
- overridesResolver: (e, o) => o.root
714
- })(({
715
- ownerState: e,
716
- theme: o
717
- }) => {
718
- var r, l, i;
719
- return [F({
720
- "--Icon-fontSize": "var(--Radio-size)",
721
- "--Icon-color": "currentColor"
722
- }, e.size === "sm" && {
723
- "--Radio-size": "1rem",
724
- // --FormHelperText-margin is equal to --Radio-size + --Radio-gap but we can't use calc() with CSS variables because the FormHelperText is a sibling element
725
- "& ~ *": {
726
- "--FormHelperText-margin": "0 0 0 1.5rem"
727
- },
728
- fontSize: o.vars.fontSize.sm,
729
- gap: "var(--Radio-gap, 0.5rem)"
730
- }, e.size === "md" && {
731
- "--Radio-size": "1.25rem",
732
- "& ~ *": {
733
- "--FormHelperText-margin": "0.25rem 0 0 1.875rem"
734
- },
735
- fontSize: o.vars.fontSize.md,
736
- gap: "var(--Radio-gap, 0.625rem)"
737
- }, e.size === "lg" && {
738
- "--Radio-size": "1.5rem",
739
- "& ~ *": {
740
- "--FormHelperText-margin": "0.375rem 0 0 2.25rem"
741
- },
742
- fontSize: o.vars.fontSize.lg,
743
- gap: "var(--Radio-gap, 0.75rem)"
744
- }, {
745
- position: e.overlay ? "initial" : "relative",
746
- display: "inline-flex",
747
- boxSizing: "border-box",
748
- minWidth: 0,
749
- fontFamily: o.vars.fontFamily.body,
750
- lineHeight: "var(--Radio-size)",
751
- // prevent label from having larger height than the checkbox
752
- color: o.vars.palette.text.primary,
753
- [`&.${Ee.disabled}`]: {
754
- color: (r = o.variants.plainDisabled) == null || (r = r[e.color]) == null ? void 0 : r.color
755
- }
756
- }, e.disableIcon && {
757
- color: (l = o.variants[e.variant]) == null || (l = l[e.color]) == null ? void 0 : l.color,
758
- [`&.${Ee.disabled}`]: {
759
- color: (i = o.variants[`${e.variant}Disabled`]) == null || (i = i[e.color]) == null ? void 0 : i.color
760
- }
761
- }, e["data-parent"] === "RadioGroup" && e["data-first-child"] === void 0 && {
762
- marginInlineStart: e.orientation === "horizontal" ? "var(--RadioGroup-gap)" : void 0,
763
- marginBlockStart: e.orientation === "horizontal" ? void 0 : "var(--RadioGroup-gap)"
764
- })];
765
- }), Dt = ve("span", {
766
- name: "JoyRadio",
767
- slot: "Radio",
768
- overridesResolver: (e, o) => o.radio
769
- })(({
770
- ownerState: e,
771
- theme: o
772
- }) => {
773
- var r, l, i, s, c;
774
- const a = (r = o.variants[`${e.variant}`]) == null ? void 0 : r[e.color];
775
- return [F({
776
- "--Icon-color": e.color !== "neutral" || e.variant === "solid" ? "currentColor" : o.vars.palette.text.icon,
777
- margin: 0,
778
- boxSizing: "border-box",
779
- width: "var(--Radio-size)",
780
- height: "var(--Radio-size)",
781
- borderRadius: "var(--Radio-size)",
782
- display: "inline-flex",
783
- justifyContent: "center",
784
- alignItems: "center",
785
- flexShrink: 0
786
- }, e.disableIcon && {
787
- display: "contents"
788
- }, {
789
- [`&.${Ee.checked}`]: {
790
- "--Icon-color": "currentColor"
791
- }
792
- }), ...e.disableIcon ? [] : [F({}, a, {
793
- backgroundColor: (l = a == null ? void 0 : a.backgroundColor) != null ? l : o.vars.palette.background.surface
794
- }), {
795
- "&:hover": {
796
- "@media (hover: hover)": (i = o.variants[`${e.variant}Hover`]) == null ? void 0 : i[e.color]
797
- }
798
- }, {
799
- "&:active": (s = o.variants[`${e.variant}Active`]) == null ? void 0 : s[e.color]
800
- }, {
801
- [`&.${Ee.disabled}`]: (c = o.variants[`${e.variant}Disabled`]) == null ? void 0 : c[e.color]
802
- }]];
803
- }), wt = ve("span", {
804
- name: "JoyRadio",
805
- slot: "Action",
806
- overridesResolver: (e, o) => o.action
807
- })(({
808
- theme: e,
809
- ownerState: o
810
- }) => {
811
- var r, l, i, s;
812
- return [{
813
- position: "absolute",
814
- textAlign: "left",
815
- // prevent text-align inheritance
816
- borderRadius: `var(--Radio-actionRadius, ${// Automatic radius adjustment when composing with ListItem or Sheet
817
- o.overlay ? "var(--unstable_actionRadius, inherit)" : "inherit"})`,
818
- top: "calc(-1 * var(--variant-borderWidth, 0px))",
819
- // clickable on the border and focus outline does not move when checked/unchecked
820
- left: "calc(-1 * var(--variant-borderWidth, 0px))",
821
- bottom: "calc(-1 * var(--variant-borderWidth, 0px))",
822
- right: "calc(-1 * var(--variant-borderWidth, 0px))",
823
- zIndex: 1,
824
- // The action element usually cover the area of nearest positioned parent
825
- [e.focus.selector]: e.focus.default
826
- }, ...o.disableIcon ? [(r = e.variants[o.variant]) == null ? void 0 : r[o.color], {
827
- "&:hover": {
828
- "@media (hover: hover)": (l = e.variants[`${o.variant}Hover`]) == null ? void 0 : l[o.color]
829
- }
830
- }, {
831
- "&:active": (i = e.variants[`${o.variant}Active`]) == null ? void 0 : i[o.color]
832
- }, {
833
- [`&.${Ee.disabled}`]: (s = e.variants[`${o.variant}Disabled`]) == null ? void 0 : s[o.color]
834
- }] : []];
835
- }), $t = ve("input", {
836
- name: "JoyRadio",
837
- slot: "Input",
838
- overridesResolver: (e, o) => o.input
839
- })(() => ({
840
- margin: 0,
841
- opacity: 0,
842
- position: "absolute",
843
- height: "100%",
844
- width: "100%",
845
- cursor: "pointer"
846
- })), kt = ve("label", {
847
- name: "JoyRadio",
848
- slot: "Label",
849
- overridesResolver: (e, o) => o.label
850
- })(({
851
- ownerState: e
852
- }) => F({
853
- flex: 1,
854
- minWidth: 0
855
- }, e.disableIcon && {
856
- zIndex: 1,
857
- // label should stay on top of the action.
858
- pointerEvents: "none"
859
- // makes hover ineffect.
860
- })), Ot = ve("span", {
861
- name: "JoyRadio",
862
- slot: "Icon",
863
- overridesResolver: (e, o) => o.icon
864
- })(({
865
- ownerState: e
866
- }) => ({
867
- width: "calc(var(--Radio-size) / 2)",
868
- height: "calc(var(--Radio-size) / 2)",
869
- borderRadius: "inherit",
870
- color: "inherit",
871
- backgroundColor: "currentColor",
872
- transform: e.checked ? "scale(1)" : "scale(0)"
873
- })), so = /* @__PURE__ */ M.forwardRef(function(o, r) {
874
- var l, i, s, c, a, d, u;
875
- const m = Ae({
876
- props: o,
877
- name: "JoyRadio"
878
- }), {
879
- checked: p,
880
- checkedIcon: y,
881
- defaultChecked: b,
882
- disabled: g,
883
- disableIcon: x = !1,
884
- overlay: I = !1,
885
- label: v,
886
- id: C,
887
- name: R,
888
- onBlur: A,
889
- onChange: f,
890
- onFocus: P,
891
- onFocusVisible: k,
892
- readOnly: D,
893
- required: j,
894
- color: $,
895
- variant: L = "outlined",
896
- size: ee = "md",
897
- uncheckedIcon: _,
898
- value: E,
899
- component: N,
900
- slots: X = {},
901
- slotProps: te = {}
902
- } = m, ne = $e(m, zt), h = M.useContext(Be);
903
- if (process.env.NODE_ENV !== "production") {
904
- const Ve = h == null ? void 0 : h.registerEffect;
905
- M.useEffect(() => {
906
- if (Ve)
907
- return Ve();
908
- }, [Ve]);
909
- }
910
- const T = Me(C ?? (h == null ? void 0 : h.htmlFor)), z = M.useContext(eo), ie = h != null && h.error ? "danger" : (l = (i = (s = o.color) != null ? s : h == null ? void 0 : h.color) != null ? i : $) != null ? l : "primary", le = h != null && h.error ? "danger" : (c = (a = (d = o.color) != null ? d : h == null ? void 0 : h.color) != null ? a : $) != null ? c : "neutral", pe = o.size || (h == null ? void 0 : h.size) || (z == null ? void 0 : z.size) || ee, W = o.name || (z == null ? void 0 : z.name) || R, G = o.disableIcon || (z == null ? void 0 : z.disableIcon) || x, B = o.overlay || (z == null ? void 0 : z.overlay) || I, V = {
911
- checked: typeof p > "u" && E != null ? Mt(z == null ? void 0 : z.value, E) : p,
912
- defaultChecked: b,
913
- disabled: o.disabled || (h == null ? void 0 : h.disabled) || g,
914
- onBlur: A,
915
- onChange: f,
916
- onFocus: P,
917
- onFocusVisible: k
918
- }, {
919
- getInputProps: J,
920
- checked: q,
921
- disabled: Q,
922
- focusVisible: oe
923
- } = nt(V), ue = (u = o.color) != null ? u : q ? ie : le, re = F({}, m, {
924
- checked: q,
925
- disabled: Q,
926
- focusVisible: oe,
927
- color: ue,
928
- variant: L,
929
- size: pe,
930
- disableIcon: G,
931
- overlay: B,
932
- orientation: z == null ? void 0 : z.orientation
933
- }), se = Et(re), S = F({}, ne, {
934
- component: N,
935
- slots: X,
936
- slotProps: te
937
- }), [Y, Z] = xe("root", {
938
- ref: r,
939
- className: se.root,
940
- elementType: Tt,
941
- externalForwardedProps: S,
942
- ownerState: re
943
- }), [ae, he] = xe("radio", {
944
- className: se.radio,
945
- elementType: Dt,
946
- externalForwardedProps: S,
947
- ownerState: re
948
- }), [uo, mo] = xe("icon", {
949
- className: se.icon,
950
- elementType: Ot,
951
- externalForwardedProps: S,
952
- ownerState: re
953
- }), [po, fo] = xe("action", {
954
- className: se.action,
955
- elementType: wt,
956
- externalForwardedProps: S,
957
- ownerState: re
958
- }), [ho, yo] = xe("input", {
959
- additionalProps: {
960
- type: "radio",
961
- role: void 0,
962
- id: T,
963
- name: W,
964
- readOnly: D,
965
- required: j ?? (h == null ? void 0 : h.required),
966
- value: String(E),
967
- "aria-describedby": h == null ? void 0 : h["aria-describedby"]
968
- },
969
- className: se.input,
970
- elementType: $t,
971
- externalForwardedProps: S,
972
- getSlotProps: () => J({
973
- onChange: z == null ? void 0 : z.onChange
974
- }),
975
- ownerState: re
976
- }), [bo, go] = xe("label", {
977
- additionalProps: {
978
- htmlFor: T
979
- },
980
- className: se.label,
981
- elementType: kt,
982
- externalForwardedProps: S,
983
- ownerState: re
984
- });
985
- return /* @__PURE__ */ w(Y, F({}, Z, {
986
- children: [/* @__PURE__ */ w(ae, F({}, he, {
987
- children: [q && !G && y, !q && !G && _, !y && !_ && !G && /* @__PURE__ */ n(uo, F({}, mo)), /* @__PURE__ */ n(po, F({}, fo, {
988
- children: /* @__PURE__ */ n(ho, F({}, yo))
989
- }))]
990
- })), v && /* @__PURE__ */ n(bo, F({}, go, {
991
- children: /* @__PURE__ */ n(wo.Provider, {
992
- value: !0,
993
- children: v
994
- })
995
- }))]
996
- }));
997
- });
998
- process.env.NODE_ENV !== "production" && (so.propTypes = {
999
- // ┌────────────────────────────── Warning ──────────────────────────────┐
1000
- // │ These PropTypes are generated from the TypeScript type definitions. │
1001
- // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
1002
- // └─────────────────────────────────────────────────────────────────────┘
1003
- /**
1004
- * If `true`, the component is checked.
1005
- */
1006
- checked: t.bool,
1007
- /**
1008
- * The icon to display when the component is checked.
1009
- */
1010
- checkedIcon: t.node,
1011
- /**
1012
- * @ignore
1013
- */
1014
- children: t.node,
1015
- /**
1016
- * Class name applied to the root element.
1017
- */
1018
- className: t.string,
1019
- /**
1020
- * The color of the component. It supports those theme colors that make sense for this component.
1021
- * @default 'neutral'
1022
- */
1023
- color: t.oneOfType([t.oneOf(["danger", "primary", "success", "warning"]), t.string]),
1024
- /**
1025
- * The component used for the root node.
1026
- * Either a string to use a HTML element or a component.
1027
- */
1028
- component: t.elementType,
1029
- /**
1030
- * The default checked state. Use when the component is not controlled.
1031
- */
1032
- defaultChecked: t.bool,
1033
- /**
1034
- * If `true`, the component is disabled.
1035
- */
1036
- disabled: t.bool,
1037
- /**
1038
- * If `true`, the checked icon is removed and the selected variant is applied on the `action` element instead.
1039
- * @default false
1040
- */
1041
- disableIcon: t.bool,
1042
- /**
1043
- * @ignore
1044
- */
1045
- id: t.string,
1046
- /**
1047
- * The label element at the end the radio.
1048
- */
1049
- label: t.node,
1050
- /**
1051
- * The `name` attribute of the input.
1052
- */
1053
- name: t.string,
1054
- /**
1055
- * @ignore
1056
- */
1057
- onBlur: t.func,
1058
- /**
1059
- * Callback fired when the state is changed.
1060
- *
1061
- * @param {React.ChangeEvent<HTMLInputElement>} event The event source of the callback.
1062
- * You can pull out the new value by accessing `event.target.value` (string).
1063
- * You can pull out the new checked state by accessing `event.target.checked` (boolean).
1064
- */
1065
- onChange: t.func,
1066
- /**
1067
- * @ignore
1068
- */
1069
- onFocus: t.func,
1070
- /**
1071
- * @ignore
1072
- */
1073
- onFocusVisible: t.func,
1074
- /**
1075
- * If `true`, the root element's position is set to initial which allows the action area to fill the nearest positioned parent.
1076
- * This prop is useful for composing Radio with ListItem component.
1077
- * @default false
1078
- */
1079
- overlay: t.bool,
1080
- /**
1081
- * If `true`, the component is read only.
1082
- */
1083
- readOnly: t.bool,
1084
- /**
1085
- * If `true`, the `input` element is required.
1086
- */
1087
- required: t.bool,
1088
- /**
1089
- * The size of the component.
1090
- * @default 'md'
1091
- */
1092
- size: t.oneOfType([t.oneOf(["sm", "md", "lg"]), t.string]),
1093
- /**
1094
- * The props used for each slot inside.
1095
- * @default {}
1096
- */
1097
- slotProps: t.shape({
1098
- action: t.oneOfType([t.func, t.object]),
1099
- icon: t.oneOfType([t.func, t.object]),
1100
- input: t.oneOfType([t.func, t.object]),
1101
- label: t.oneOfType([t.func, t.object]),
1102
- radio: t.oneOfType([t.func, t.object]),
1103
- root: t.oneOfType([t.func, t.object])
1104
- }),
1105
- /**
1106
- * The components used for each slot inside.
1107
- * @default {}
1108
- */
1109
- slots: t.shape({
1110
- action: t.elementType,
1111
- icon: t.elementType,
1112
- input: t.elementType,
1113
- label: t.elementType,
1114
- radio: t.elementType,
1115
- root: t.elementType
1116
- }),
1117
- /**
1118
- * The system prop that allows defining system overrides as well as additional CSS styles.
1119
- */
1120
- sx: t.oneOfType([t.arrayOf(t.oneOfType([t.func, t.object, t.bool])), t.func, t.object]),
1121
- /**
1122
- * The icon to display when the component is not checked.
1123
- */
1124
- uncheckedIcon: t.node,
1125
- /**
1126
- * The value of the component. The DOM API casts this to a string.
1127
- */
1128
- value: t.any,
1129
- /**
1130
- * The [global variant](https://mui.com/joy-ui/main-features/global-variants/) to use.
1131
- * @default 'outlined'
1132
- */
1133
- variant: t.oneOfType([t.oneOf(["outlined", "plain", "soft", "solid"]), t.string])
1134
- });
1135
- function At(e) {
1136
- return De("MuiRadioGroup", e);
1137
- }
1138
- we("MuiRadioGroup", ["root", "colorPrimary", "colorNeutral", "colorDanger", "colorSuccess", "colorWarning", "variantPlain", "variantOutlined", "variantSoft", "variantSolid", "sizeSm", "sizeMd", "sizeLg", "horizontal", "vertical"]);
1139
- const Lt = ["className", "component", "children", "name", "defaultValue", "disableIcon", "overlay", "value", "onChange", "color", "variant", "size", "orientation", "role", "slots", "slotProps"], Vt = (e) => {
1140
- const {
1141
- orientation: o,
1142
- size: r,
1143
- variant: l,
1144
- color: i
1145
- } = e, s = {
1146
- root: ["root", o, l && `variant${me(l)}`, i && `color${me(i)}`, r && `size${me(r)}`]
1147
- };
1148
- return Le(s, At, {});
1149
- }, Ft = ve("div", {
1150
- name: "JoyRadioGroup",
1151
- slot: "Root",
1152
- overridesResolver: (e, o) => o.root
1153
- })(({
1154
- ownerState: e,
1155
- theme: o
1156
- }) => {
1157
- var r;
1158
- return F({}, e.size === "sm" && {
1159
- "--RadioGroup-gap": "0.625rem"
1160
- }, e.size === "md" && {
1161
- "--RadioGroup-gap": "0.875rem"
1162
- }, e.size === "lg" && {
1163
- "--RadioGroup-gap": "1.25rem"
1164
- }, {
1165
- display: "flex",
1166
- margin: "var(--unstable_RadioGroup-margin)",
1167
- flexDirection: e.orientation === "horizontal" ? "row" : "column",
1168
- borderRadius: o.vars.radius.sm
1169
- }, (r = o.variants[e.variant]) == null ? void 0 : r[e.color]);
1170
- }), ao = /* @__PURE__ */ M.forwardRef(function(o, r) {
1171
- const l = Ae({
1172
- props: o,
1173
- name: "JoyRadioGroup"
1174
- }), {
1175
- className: i,
1176
- component: s,
1177
- children: c,
1178
- name: a,
1179
- defaultValue: d,
1180
- disableIcon: u = !1,
1181
- overlay: m,
1182
- value: p,
1183
- onChange: y,
1184
- color: b = "neutral",
1185
- variant: g = "plain",
1186
- size: x = "md",
1187
- orientation: I = "vertical",
1188
- role: v = "radiogroup",
1189
- slots: C = {},
1190
- slotProps: R = {}
1191
- } = l, A = $e(l, Lt), [f, P] = tt({
1192
- controlled: p,
1193
- default: d,
1194
- name: "RadioGroup"
1195
- }), k = M.useContext(Be), D = o.size || (k == null ? void 0 : k.size) || x, j = F({
1196
- orientation: I,
1197
- size: D,
1198
- variant: g,
1199
- color: b,
1200
- role: v
1201
- }, l), $ = Vt(j), L = Me(a);
1202
- if (process.env.NODE_ENV !== "production") {
1203
- const N = k == null ? void 0 : k.registerEffect;
1204
- M.useEffect(() => {
1205
- if (N)
1206
- return N();
1207
- }, [N]);
1208
- }
1209
- const ee = M.useMemo(() => ({
1210
- disableIcon: u,
1211
- overlay: m,
1212
- orientation: I,
1213
- size: D,
1214
- name: L,
1215
- value: f,
1216
- onChange: (N) => {
1217
- P(N.target.value), y && y(N);
1218
- }
1219
- }), [u, L, y, m, I, P, D, f]), [_, E] = xe("root", {
1220
- ref: r,
1221
- className: vo($.root, i),
1222
- elementType: Ft,
1223
- externalForwardedProps: F({}, A, {
1224
- component: s,
1225
- slots: C,
1226
- slotProps: R
1227
- }),
1228
- ownerState: j,
1229
- additionalProps: {
1230
- as: s,
1231
- role: v,
1232
- // The `id` is just for the completeness, it does not have any effect because RadioGroup (div) is non-labelable element
1233
- // MDN: "If it is not a labelable element, then the for attribute has no effect"
1234
- // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label#attr-for
1235
- id: k == null ? void 0 : k.htmlFor,
1236
- "aria-labelledby": k == null ? void 0 : k.labelId,
1237
- "aria-describedby": k == null ? void 0 : k["aria-describedby"]
1238
- }
1239
- });
1240
- return /* @__PURE__ */ n(eo.Provider, {
1241
- value: ee,
1242
- children: /* @__PURE__ */ n(_, F({}, E, {
1243
- children: /* @__PURE__ */ n(Be.Provider, {
1244
- value: void 0,
1245
- children: M.Children.map(c, (N, X) => /* @__PURE__ */ M.isValidElement(N) ? /* @__PURE__ */ M.cloneElement(N, F({}, X === 0 && {
1246
- "data-first-child": ""
1247
- }, X === M.Children.count(c) - 1 && {
1248
- "data-last-child": ""
1249
- }, {
1250
- "data-parent": "RadioGroup"
1251
- })) : N)
1252
- })
1253
- }))
1254
- });
1255
- });
1256
- process.env.NODE_ENV !== "production" && (ao.propTypes = {
1257
- // ┌────────────────────────────── Warning ──────────────────────────────┐
1258
- // │ These PropTypes are generated from the TypeScript type definitions. │
1259
- // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
1260
- // └─────────────────────────────────────────────────────────────────────┘
1261
- /**
1262
- * @ignore
1263
- */
1264
- children: t.node,
1265
- /**
1266
- * Class name applied to the root element.
1267
- */
1268
- className: t.string,
1269
- /**
1270
- * The color of the component. It supports those theme colors that make sense for this component.
1271
- * @default 'neutral'
1272
- */
1273
- color: t.oneOfType([t.oneOf(["danger", "primary", "success", "warning"]), t.string]),
1274
- /**
1275
- * The component used for the root node.
1276
- * Either a string to use a HTML element or a component.
1277
- */
1278
- component: t.elementType,
1279
- /**
1280
- * The default value. Use when the component is not controlled.
1281
- */
1282
- defaultValue: t.any,
1283
- /**
1284
- * The radio's `disabledIcon` prop. If specified, the value is passed down to every radios under this element.
1285
- * @default false
1286
- */
1287
- disableIcon: t.bool,
1288
- /**
1289
- * The name used to reference the value of the control.
1290
- * If you don't provide this prop, it falls back to a randomly generated name.
1291
- */
1292
- name: t.string,
1293
- /**
1294
- * Callback fired when a radio button is selected.
1295
- *
1296
- * @param {React.ChangeEvent<HTMLInputElement>} event The event source of the callback.
1297
- * You can pull out the new value by accessing `event.target.value` (string).
1298
- */
1299
- onChange: t.func,
1300
- /**
1301
- * The component orientation.
1302
- * @default 'vertical'
1303
- */
1304
- orientation: t.oneOf(["horizontal", "vertical"]),
1305
- /**
1306
- * The radio's `overlay` prop. If specified, the value is passed down to every radios under this element.
1307
- * @default false
1308
- */
1309
- overlay: t.bool,
1310
- /**
1311
- * @ignore
1312
- */
1313
- role: t.string,
1314
- /**
1315
- * The size of the component.
1316
- * @default 'md'
1317
- */
1318
- size: t.oneOfType([t.oneOf(["sm", "md", "lg"]), t.string]),
1319
- /**
1320
- * The props used for each slot inside.
1321
- * @default {}
1322
- */
1323
- slotProps: t.shape({
1324
- root: t.oneOfType([t.func, t.object])
1325
- }),
1326
- /**
1327
- * The components used for each slot inside.
1328
- * @default {}
1329
- */
1330
- slots: t.shape({
1331
- root: t.elementType
1332
- }),
1333
- /**
1334
- * The system prop that allows defining system overrides as well as additional CSS styles.
1335
- */
1336
- sx: t.oneOfType([t.arrayOf(t.oneOfType([t.func, t.object, t.bool])), t.func, t.object]),
1337
- /**
1338
- * Value of the selected radio button. The DOM API casts this to a string.
1339
- */
1340
- value: t.any,
1341
- /**
1342
- * The [global variant](https://mui.com/joy-ui/main-features/global-variants/) to use.
1343
- * @default 'plain'
1344
- */
1345
- variant: t.oneOfType([t.oneOf(["outlined", "plain", "soft", "solid"]), t.string])
1346
- });
1347
- const Nt = (e, o) => {
1348
- const [r, l] = U(null), [i, s] = U(!0), [c, a] = U(null), [d, u] = U(!1);
1349
- return Re(() => {
1350
- o && (async () => {
1351
- try {
1352
- s(!0);
1353
- const p = await e.discussions.getById(o);
1354
- l(p), a(null), u(!1);
1355
- } catch (p) {
1356
- (e.helpers.getSDKConfiguration().errorHandlingMode === "standard" ? p.error.code === 404 : p.data.error.code === 404) ? (u(!0), a(null), l(null)) : (a(c), l(null), u(!1));
1357
- } finally {
1358
- s(!1);
1359
- }
1360
- })();
1361
- }, [e, o]), { discussion: r, setDiscussion: l, isLoading: i, error: c, isNotFound: d };
1362
- }, _t = 5e3, Bt = 5, Ht = (e, o, r = null, l = "", i = "LATEST", s = 20, c, a = !1, d = 0) => {
1363
- const u = s <= 0, [m, p] = U([]), [y, b] = U(!u), [g, x] = U(!1), [I, v] = U(null), [C, R] = U(i), [A, f] = U(
1364
- null
1365
- ), [P, k] = U(!1), [D, j] = U(() => /* @__PURE__ */ new Set()), $ = fe(0), L = Pe(
1366
- async (B, H, V = !1) => {
1367
- var J, q;
1368
- V || ($.current += 1, j(/* @__PURE__ */ new Set()));
1369
- try {
1370
- b(!0);
1371
- const Q = await e.discussions.getPosts(o, {
1372
- sort: B,
1373
- limit: s,
1374
- startAfter: H,
1375
- skipDeleted: !0,
1376
- skipModerated: !a
1377
- }), oe = Q.data;
1378
- p(V ? (re) => [...re, ...oe] : oe);
1379
- const ue = !!((J = Q.meta.pagination) != null && J.nextPageStartsAfter) && oe.length === s;
1380
- f(
1381
- ((q = Q.meta.pagination) == null ? void 0 : q.nextPageStartsAfter) || null
1382
- ), k(ue), v(null);
1383
- } catch (Q) {
1384
- (e.helpers.getSDKConfiguration().errorHandlingMode === "standard" ? Q.error.code === 404 : Q.data.error.code === 404) ? (p([]), k(!1), f(null), v(null)) : v(I);
1385
- } finally {
1386
- b(!1);
1387
- }
1388
- },
1389
- [e, o, s, a]
1390
- );
1391
- Re(() => {
1392
- if (u) {
1393
- p([]), k(!1), b(!1);
1394
- return;
1395
- }
1396
- o && L(C);
1397
- }, [o, C, L, u]);
1398
- const ee = (B) => {
1399
- R(B), f(null);
1400
- }, _ = fe(y);
1401
- _.current = y;
1402
- const E = fe(A);
1403
- E.current = A;
1404
- const N = Pe(() => {
1405
- E.current && !_.current && L(C, E.current, !0);
1406
- }, [L, C]), X = fe(m);
1407
- X.current = m;
1408
- const te = fe(P);
1409
- te.current = P;
1410
- const ne = fe(c);
1411
- ne.current = c;
1412
- const h = fe(!1), T = Pe(async () => {
1413
- var q, Q;
1414
- if (_.current || h.current || C !== "LATEST" && te.current) return;
1415
- h.current = !0;
1416
- const B = $.current, H = X.current, V = new Set(H.map((oe) => oe.id)), J = (oe) => !V.has(oe.id);
1417
- try {
1418
- const oe = [];
1419
- let ue;
1420
- for (let S = 0; S < Bt; S++) {
1421
- const Y = await e.discussions.getPosts(o, {
1422
- sort: "LATEST",
1423
- limit: s,
1424
- startAfter: ue,
1425
- skipDeleted: !0,
1426
- skipModerated: !a
1427
- }), Z = Y.data;
1428
- oe.push(...Z.filter(J)), ue = ((q = Y.meta.pagination) == null ? void 0 : q.nextPageStartsAfter) || void 0;
1429
- const ae = Z.length === s && Z.every(J);
1430
- if (!H.length || !ae || !ue) break;
1431
- }
1432
- if (B !== $.current) return;
1433
- const re = new Set(X.current.map((S) => S.id)), se = oe.filter((S) => !re.has(S.id));
1434
- if (!se.length) return;
1435
- H.length ? p((S) => {
1436
- const Y = new Set(S.map((ae) => ae.id)), Z = se.filter((ae) => !Y.has(ae.id));
1437
- return C === "LATEST" ? [...Z, ...S].sort(
1438
- (ae, he) => Date.parse(he.createdAt) - Date.parse(ae.createdAt)
1439
- ) : [...S, ...Z.reverse()];
1440
- }) : await L(C), j((S) => {
1441
- const Y = new Set(S);
1442
- return se.forEach((Z) => Y.add(Z.id)), Y;
1443
- }), (Q = ne.current) == null || Q.call(ne, se.length);
1444
- } catch {
1445
- } finally {
1446
- h.current = !1;
1447
- }
1448
- }, [
1449
- e,
1450
- o,
1451
- s,
1452
- a,
1453
- C,
1454
- L
1455
- ]), z = d > 0 ? Math.max(d, _t) : 0;
1456
- Re(() => {
1457
- if (!z || u || !o) return;
1458
- const B = () => {
1459
- document.visibilityState !== "hidden" && T();
1460
- }, H = () => {
1461
- document.visibilityState === "visible" && T();
1462
- }, V = setInterval(B, z);
1463
- return document.addEventListener("visibilitychange", H), () => {
1464
- clearInterval(V), document.removeEventListener("visibilitychange", H);
1465
- };
1466
- }, [z, u, o, T]);
1467
- const ie = Pe((B) => {
1468
- j((H) => {
1469
- if (!H.has(B)) return H;
1470
- const V = new Set(H);
1471
- return V.delete(B), V;
1472
- });
1473
- }, []);
1474
- return {
1475
- posts: m,
1476
- postsHidden: u,
1477
- isLoading: y,
1478
- isSubmitting: g,
1479
- error: I,
1480
- currentSort: C,
1481
- hasMore: P,
1482
- newPostIds: D,
1483
- markPostSeen: ie,
1484
- handleSortChange: ee,
1485
- handleLoadMore: N,
1486
- handleCreatePost: async (B, H) => {
1487
- try {
1488
- x(!0);
1489
- let J = await e.discussions.createPost(o, {
1490
- content: B,
1491
- replyId: H || null,
1492
- userNickname: null,
1493
- discussionLabel: r,
1494
- discussionUrl: l,
1495
- context: {
1496
- content: null,
1497
- tags: [],
1498
- campaign: null
1499
- }
1500
- });
1501
- try {
1502
- const q = await e.profile.getOwn().getInfo();
1503
- J = { ...J, userModel: q };
1504
- } catch {
1505
- }
1506
- H ? p(
1507
- (q) => q.map(
1508
- (Q) => Q.id === H ? { ...Q, repliesCount: (Q.repliesCount || 0) + 1 } : Q
1509
- )
1510
- ) : u || p((q) => [J, ...q]), c == null || c(1), v(null);
1511
- } catch (V) {
1512
- throw v(
1513
- V
1514
- ), V;
1515
- } finally {
1516
- x(!1);
1517
- }
1518
- },
1519
- handleReact: async (B, H) => {
1520
- try {
1521
- const V = await e.discussions.react(B, H);
1522
- return p(
1523
- (J) => J.map((q) => q.id === B ? V : q)
1524
- ), v(null), V;
1525
- } catch (V) {
1526
- throw console.error("Error reacting to post:", V), v(
1527
- V
1528
- ), V;
1529
- }
1530
- },
1531
- handleDeletePost: async (B, H) => {
1532
- try {
1533
- await e.discussions.deletePost(B), p((V) => V.filter((J) => J.id !== B)), H && p(
1534
- (V) => V.map(
1535
- (J) => J.id === H ? { ...J, repliesCount: Math.max(0, (J.repliesCount || 0) - 1) } : J
1536
- )
1537
- ), c == null || c(-1), v(null);
1538
- } catch (V) {
1539
- throw v(
1540
- V
1541
- ), V;
1542
- }
1543
- },
1544
- handleReportPost: async (B, H, V) => {
1545
- try {
1546
- await e.discussions.reportPost(B, H, V), v(null);
1547
- } catch (J) {
1548
- throw v(
1549
- J
1550
- ), J;
1551
- }
1552
- }
1553
- };
1554
- }, Wt = async (e) => {
1555
- var o;
1556
- try {
1557
- const l = (o = e.helpers.getSDKConfiguration().authProvider) == null ? void 0 : o.getIdToken(), i = l == null ? void 0 : l.split(".")[1];
1558
- if (!i) return null;
1559
- const { sub: s } = JSON.parse(
1560
- atob(i.replace(/-/g, "+").replace(/_/g, "/"))
1561
- );
1562
- return typeof s == "string" && s ? s : null;
1563
- } catch {
1564
- return null;
1565
- }
1566
- }, Kt = (e, o) => {
1567
- var c;
1568
- const [r, l] = U(null), i = Pe(
1569
- async (a = !1) => {
1570
- if (!o) {
1571
- l(null);
1572
- return;
1573
- }
1574
- try {
1575
- const d = await Wt(e);
1576
- if (!d) return;
1577
- l(await e.discussions.getUserBan(d, a));
1578
- } catch (d) {
1579
- console.error("Failed to get user ban:", d);
1580
- }
1581
- },
1582
- [e, o]
1583
- );
1584
- Re(() => {
1585
- i();
1586
- }, [i]);
1587
- const s = Pe(() => i(!0), [i]);
1588
- return { ban: r, isBanned: !!((c = r == null ? void 0 : r.activeBan) != null && c.banned), refresh: s };
1589
- }, Ut = (e) => {
1590
- var o, r, l;
1591
- return (((o = e == null ? void 0 : e.error) == null ? void 0 : o.status) ?? ((l = (r = e == null ? void 0 : e.data) == null ? void 0 : r.error) == null ? void 0 : l.status)) === "ban";
1592
- }, io = ({
1593
- onSubmit: e,
1594
- userIsLoggedIn: o,
1595
- onSignInClick: r,
1596
- placeholder: l,
1597
- isSubmitting: i,
1598
- replyTo: s,
1599
- onCancel: c,
1600
- disabled: a = !1
1601
- }) => {
1602
- const { t: d } = Ce(), [u, m] = U(""), p = be(), y = Se(), b = Te(), g = ge(), x = p.palette.primary.plainColor, I = p.palette.primary.onPrimary, v = async (C) => {
1603
- if (C.preventDefault(), !(!u.trim() || a))
1604
- try {
1605
- await e(u), m("");
1606
- } catch (R) {
1607
- console.error("Failed to submit comment:", R);
1608
- }
1609
- };
1610
- return o ? /* @__PURE__ */ w(O, { component: "form", onSubmit: v, sx: { mb: g.lg }, children: [
1611
- s && /* @__PURE__ */ n(K, { level: "body-sm", sx: { fontSize: "0.875em", mb: g.xs, color: p.textSecondary }, children: d("discussion.replyingTo", "Replying to {{name}}", {
1612
- name: s
1613
- }) }),
1614
- /* @__PURE__ */ n(
1615
- Ze,
1616
- {
1617
- placeholder: l || d("discussion.writeComment", "Write a comment..."),
1618
- value: u,
1619
- onChange: (C) => m(C.target.value),
1620
- minRows: 3,
1621
- maxRows: 8,
1622
- disabled: i || a,
1623
- sx: {
1624
- fontSize: "1em",
1625
- mb: g.sm,
1626
- bgcolor: p.surfaceVariant,
1627
- color: p.textPrimary,
1628
- border: `1px solid ${p.outlineEnabledBorder}`,
1629
- borderRadius: y.sm,
1630
- boxShadow: "none",
1631
- "&::before": { display: "none" },
1632
- "&::placeholder": { color: p.textSecondary, opacity: 0.6 },
1633
- "&:focus-within": {
1634
- border: `1px solid ${x}`,
1635
- boxShadow: "none",
1636
- outline: "none"
1637
- }
1638
- }
1639
- }
1640
- ),
1641
- /* @__PURE__ */ w(O, { sx: { display: "flex", gap: g.xs, justifyContent: "flex-end" }, children: [
1642
- c && /* @__PURE__ */ n(
1643
- ye,
1644
- {
1645
- variant: "plain",
1646
- onClick: c,
1647
- disabled: i,
1648
- sx: {
1649
- fontSize: "1em",
1650
- fontFamily: b.primary,
1651
- color: p.textPrimary,
1652
- borderRadius: y.sm,
1653
- "&:hover": {
1654
- bgcolor: `${p.textPrimary}14`
1655
- }
1656
- },
1657
- children: d("common.cancel", "Cancel")
1658
- }
1659
- ),
1660
- /* @__PURE__ */ n(
1661
- ye,
1662
- {
1663
- type: "submit",
1664
- variant: "solid",
1665
- disabled: !u.trim() || i || a,
1666
- loading: i,
1667
- sx: {
1668
- fontSize: "1em",
1669
- fontFamily: b.primary,
1670
- bgcolor: x,
1671
- color: I,
1672
- borderRadius: y.sm,
1673
- "&:hover": {
1674
- bgcolor: x,
1675
- opacity: 0.9
1676
- },
1677
- "&:disabled": {
1678
- bgcolor: x,
1679
- color: I,
1680
- opacity: 0.4
1681
- }
1682
- },
1683
- children: s ? d("discussion.reply", "Reply") : d("discussion.post", "Post")
1684
- }
1685
- )
1686
- ] })
1687
- ] }) : /* @__PURE__ */ n(O, { sx: { mb: g.lg }, children: /* @__PURE__ */ n(
1688
- ye,
1689
- {
1690
- fullWidth: !0,
1691
- variant: "outlined",
1692
- onClick: r,
1693
- sx: {
1694
- fontSize: "1em",
1695
- py: g.sm,
1696
- fontFamily: b.primary,
1697
- borderColor: x,
1698
- color: x,
1699
- borderRadius: y.sm,
1700
- "&:hover": {
1701
- bgcolor: `${x}14`,
1702
- borderColor: x
1703
- }
1704
- },
1705
- children: d("discussion.signInToPost", "Sign in to post")
1706
- }
1707
- ) });
1708
- }, jt = de(/* @__PURE__ */ n("path", {
1709
- d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12m8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8"
1710
- }), "Block"), Gt = de(/* @__PURE__ */ n("path", {
1711
- d: "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"
1712
- }), "Delete"), Jt = de(/* @__PURE__ */ n("path", {
1713
- d: "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M8.5 8c.83 0 1.5.67 1.5 1.5S9.33 11 8.5 11 7 10.33 7 9.5 7.67 8 8.5 8M12 18c-2.28 0-4.22-1.66-5-4h10c-.78 2.34-2.72 4-5 4m3.5-7c-.83 0-1.5-.67-1.5-1.5S14.67 8 15.5 8s1.5.67 1.5 1.5-.67 1.5-1.5 1.5"
1714
- }), "EmojiEmotions"), qt = de(/* @__PURE__ */ n("path", {
1715
- d: "M14.4 6 14 4H5v17h2v-7h5.6l.4 2h7V6z"
1716
- }), "Flag"), Yt = de(/* @__PURE__ */ n("path", {
1717
- d: "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8m3.5-9c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5s.67 1.5 1.5 1.5m-7 0c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11m3.5 3c-2.33 0-4.31 1.46-5.11 3.5h10.22c-.8-2.04-2.78-3.5-5.11-3.5"
1718
- }), "MoodBad"), Xt = de(/* @__PURE__ */ n("path", {
1719
- d: "M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"
1720
- }), "MoreVert"), Qt = de(/* @__PURE__ */ n("path", {
1721
- d: "M7 11v2h10v-2zm5-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8"
1722
- }), "RemoveCircleOutline"), Zt = de(/* @__PURE__ */ n("path", {
1723
- d: "M10 9V5l-7 7 7 7v-4.1c5 0 8.5 1.6 11 5.1-1-5-4-10-11-11"
1724
- }), "Reply"), en = de([/* @__PURE__ */ n("circle", {
1725
- cx: "15.5",
1726
- cy: "9.5",
1727
- r: "1.5"
1728
- }, "0"), /* @__PURE__ */ n("circle", {
1729
- cx: "8.5",
1730
- cy: "9.5",
1731
- r: "1.5"
1732
- }, "1"), /* @__PURE__ */ n("path", {
1733
- d: "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8m0-4c-.73 0-1.38-.18-1.96-.52-.12.14-.86.98-1.01 1.15.86.55 1.87.87 2.97.87 1.11 0 2.12-.33 2.98-.88-.97-1.09-.01-.02-1.01-1.15-.59.35-1.24.53-1.97.53"
1734
- }, "2")], "SentimentSatisfied"), on = de([/* @__PURE__ */ n("circle", {
1735
- cx: "15.5",
1736
- cy: "9.5",
1737
- r: "1.5"
1738
- }, "0"), /* @__PURE__ */ n("circle", {
1739
- cx: "8.5",
1740
- cy: "9.5",
1741
- r: "1.5"
1742
- }, "1"), /* @__PURE__ */ n("path", {
1743
- d: "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8m0-6c-2.33 0-4.32 1.45-5.12 3.5h1.67c.69-1.19 1.97-2 3.45-2s2.75.81 3.45 2h1.67c-.8-2.05-2.79-3.5-5.12-3.5"
1744
- }, "2")], "SentimentVeryDissatisfied"), tn = de(/* @__PURE__ */ n("path", {
1745
- d: "M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v2c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L9.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2m4 0v12h4V3z"
1746
- }), "ThumbDown"), nn = de(/* @__PURE__ */ n("path", {
1747
- d: "M1 21h4V9H1zm22-11c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73z"
1748
- }), "ThumbUp"), rn = {
1749
- LIKE: /* @__PURE__ */ n(nn, { fontSize: "small" }),
1750
- DISLIKE: /* @__PURE__ */ n(tn, { fontSize: "small" }),
1751
- LOVE: /* @__PURE__ */ n($o, { fontSize: "small" }),
1752
- LAUGH: /* @__PURE__ */ n(en, { fontSize: "small" }),
1753
- CARE: /* @__PURE__ */ n(ko, { fontSize: "small" }),
1754
- WOW: /* @__PURE__ */ n(Jt, { fontSize: "small" }),
1755
- SAD: /* @__PURE__ */ n(on, { fontSize: "small" }),
1756
- ANGRY: /* @__PURE__ */ n(Yt, { fontSize: "small" })
1757
- }, Je = ({
1758
- reaction: e,
1759
- count: o,
1760
- isActive: r,
1761
- onClick: l,
1762
- disabled: i
1763
- }) => {
1764
- const s = be(), c = ge(), a = (u) => u >= 1e6 ? (u / 1e6).toFixed(1).replace(/\.0$/, "") + "M" : u >= 1e3 ? (u / 1e3).toFixed(1).replace(/\.0$/, "") + "K" : u.toString(), d = () => {
1765
- if (!r) return s.textSecondary;
1766
- switch (e) {
1767
- case "LIKE":
1768
- return s.palette.primary.plainColor;
1769
- case "DISLIKE":
1770
- return s.palette.primary.plainColor;
1771
- case "LOVE":
1772
- return s.palette.danger.plainColor;
1773
- case "ANGRY":
1774
- return s.palette.danger.plainColor;
1775
- default:
1776
- return s.palette.primary.plainColor;
1777
- }
1778
- };
1779
- return /* @__PURE__ */ w(
1780
- O,
1781
- {
1782
- sx: {
1783
- display: "inline-flex",
1784
- alignItems: "center",
1785
- gap: c["2xs"],
1786
- px: c.sm,
1787
- py: c["2xs"],
1788
- borderRadius: "18px",
1789
- backgroundColor: r ? `${s.palette.neutral.softBg}` : "transparent",
1790
- color: d(),
1791
- "&:hover": {
1792
- backgroundColor: `${s.palette.neutral.softHoverBg}`
1793
- },
1794
- cursor: i ? "not-allowed" : "pointer",
1795
- opacity: i ? 0.5 : 1
1796
- },
1797
- onClick: i ? void 0 : l,
1798
- children: [
1799
- /* @__PURE__ */ n(
1800
- O,
1801
- {
1802
- sx: {
1803
- display: "flex",
1804
- alignItems: "center",
1805
- fontSize: "1.25em",
1806
- color: "inherit"
1807
- },
1808
- children: rn[e]
1809
- }
1810
- ),
1811
- o > 0 && /* @__PURE__ */ n(
1812
- K,
1813
- {
1814
- level: "body-sm",
1815
- sx: {
1816
- fontSize: "0.875em",
1817
- color: r ? d() : s.textPrimary,
1818
- fontWeight: 500
1819
- },
1820
- children: a(o)
1821
- }
1822
- )
1823
- ]
1824
- }
1825
- );
1826
- }, lo = (e, o) => {
1827
- const [r, l] = U(null);
1828
- return Re(() => {
1829
- (async () => {
1830
- if (o)
1831
- try {
1832
- const s = await e.profile.getOwn().getInfo();
1833
- l(s.id);
1834
- } catch (s) {
1835
- console.error("Failed to get current user ID:", s);
1836
- }
1837
- })();
1838
- }, [o, e]), r;
1839
- }, sn = ({
1840
- post: e,
1841
- sdk: o,
1842
- userIsLoggedIn: r,
1843
- onSignInClick: l,
1844
- onReact: i,
1845
- showReactions: s = !0,
1846
- showReplyButton: c = !0,
1847
- onReplyClick: a,
1848
- isBanned: d = !1
1849
- }) => {
1850
- var C, R, A, f;
1851
- const { t: u } = Ce(), m = be(), p = Se(), y = Te(), b = ge(), g = lo(o, r), I = (() => {
1852
- if (!g || !e.reactions)
1853
- return null;
1854
- for (const P of e.reactions)
1855
- if (P.userIds.includes(g))
1856
- return P.type;
1857
- return null;
1858
- })(), v = (P) => {
1859
- if (!r) {
1860
- l == null || l();
1861
- return;
1862
- }
1863
- i(e.id, P);
1864
- };
1865
- return /* @__PURE__ */ w(
1866
- O,
1867
- {
1868
- sx: {
1869
- display: "flex",
1870
- gap: b.xs,
1871
- alignItems: "center",
1872
- flexWrap: "wrap",
1873
- mb: b.xs
1874
- },
1875
- children: [
1876
- s && /* @__PURE__ */ w(Ie, { children: [
1877
- /* @__PURE__ */ n(
1878
- Je,
1879
- {
1880
- reaction: "LIKE",
1881
- count: ((R = (C = e.reactions) == null ? void 0 : C.find((P) => P.type === "LIKE")) == null ? void 0 : R.reactionCount) || 0,
1882
- isActive: I === "LIKE",
1883
- onClick: () => v("LIKE"),
1884
- disabled: !r || d
1885
- }
1886
- ),
1887
- /* @__PURE__ */ n(
1888
- Je,
1889
- {
1890
- reaction: "DISLIKE",
1891
- count: ((f = (A = e.reactions) == null ? void 0 : A.find((P) => P.type === "DISLIKE")) == null ? void 0 : f.reactionCount) || 0,
1892
- isActive: I === "DISLIKE",
1893
- onClick: () => v("DISLIKE"),
1894
- disabled: !r || d
1895
- }
1896
- )
1897
- ] }),
1898
- c && /* @__PURE__ */ n(
1899
- ye,
1900
- {
1901
- size: "sm",
1902
- variant: "plain",
1903
- onClick: a,
1904
- disabled: d,
1905
- startDecorator: /* @__PURE__ */ n(Zt, { fontSize: "small" }),
1906
- sx: {
1907
- ml: b.xs,
1908
- fontFamily: y.primary,
1909
- color: m.textPrimary,
1910
- fontWeight: 600,
1911
- fontSize: "0.8125em",
1912
- borderRadius: p.sm,
1913
- px: b.xs,
1914
- py: b["2xs"],
1915
- minHeight: "unset",
1916
- "--Icon-color": m.textPrimary,
1917
- "&:hover": {
1918
- bgcolor: `${m.textPrimary}14`
1919
- }
1920
- },
1921
- children: u("discussion.reply", "Reply")
1922
- }
1923
- )
1924
- ]
1925
- }
1926
- );
1927
- }, an = ({
1928
- isOwnPost: e,
1929
- canReport: o,
1930
- onDelete: r,
1931
- onReport: l,
1932
- disabled: i = !1
1933
- }) => {
1934
- const { t: s } = Ce(), { shadowRootElement: c } = ke(Oe), a = Se(), d = be(), u = ge(), [m, p] = ce.useState(null), y = ce.useRef(null);
1935
- if (ce.useEffect(() => {
1936
- if (!m) return;
1937
- const x = (v) => {
1938
- const C = v.composedPath();
1939
- m && C.includes(m) || y.current && C.includes(y.current) || p(null);
1940
- }, I = setTimeout(() => {
1941
- document.addEventListener("click", x, !0);
1942
- }, 0);
1943
- return () => {
1944
- clearTimeout(I), document.removeEventListener("click", x, !0);
1945
- };
1946
- }, [m]), !e && !o) return null;
1947
- const b = {
1948
- zIndex: 1300,
1949
- bgcolor: d.surface,
1950
- border: `1px solid ${d.outlineEnabledBorder}`,
1951
- borderRadius: a.sm,
1952
- boxShadow: "none"
1953
- }, g = {
1954
- color: `${d.textPrimary} !important`,
1955
- bgcolor: `${d.surface} !important`,
1956
- "&:hover": {
1957
- bgcolor: `${d.surfaceVariant} !important`,
1958
- color: `${d.textPrimary} !important`
1959
- }
1960
- };
1961
- return /* @__PURE__ */ w(Ie, { children: [
1962
- /* @__PURE__ */ n(
1963
- Do,
1964
- {
1965
- size: "sm",
1966
- variant: "plain",
1967
- onClick: (x) => p(m ? null : x.currentTarget),
1968
- sx: {
1969
- fontSize: "1em",
1970
- ml: "auto",
1971
- color: d.textPrimary,
1972
- "&:hover": {
1973
- bgcolor: `${d.textPrimary}14`
1974
- }
1975
- },
1976
- children: /* @__PURE__ */ n(Xt, { fontSize: "small" })
1977
- }
1978
- ),
1979
- /* @__PURE__ */ w(
1980
- ro,
1981
- {
1982
- ref: y,
1983
- anchorEl: m,
1984
- open: !!m,
1985
- onClose: () => p(null),
1986
- container: c,
1987
- sx: b,
1988
- children: [
1989
- e && /* @__PURE__ */ w(
1990
- We,
1991
- {
1992
- onClick: () => {
1993
- p(null), r();
1994
- },
1995
- disabled: i,
1996
- sx: g,
1997
- children: [
1998
- /* @__PURE__ */ n(Gt, { fontSize: "small", sx: { mr: u.xs } }),
1999
- s("discussion.delete.action", "Delete")
2000
- ]
2001
- }
2002
- ),
2003
- o && /* @__PURE__ */ w(
2004
- We,
2005
- {
2006
- onClick: () => {
2007
- p(null), l();
2008
- },
2009
- disabled: i,
2010
- sx: g,
2011
- children: [
2012
- /* @__PURE__ */ n(qt, { fontSize: "small", sx: { mr: u.xs } }),
2013
- s("discussion.report.action", "Report")
2014
- ]
2015
- }
2016
- )
2017
- ]
2018
- }
2019
- )
2020
- ] });
2021
- }, ln = ({
2022
- open: e,
2023
- onClose: o,
2024
- onConfirm: r,
2025
- onError: l,
2026
- container: i
2027
- }) => {
2028
- const { t: s } = Ce(), c = be(), a = Se(), d = Te(), u = ge(), m = c.palette.primary.plainColor, p = c.palette.primary.onPrimary, [y, b] = U(!1), g = async () => {
2029
- b(!0);
2030
- try {
2031
- await r(), o();
2032
- } catch {
2033
- l(
2034
- s(
2035
- "discussion.delete.error",
2036
- "Failed to delete comment. Please try again."
2037
- )
2038
- );
2039
- } finally {
2040
- b(!1);
2041
- }
2042
- };
2043
- return /* @__PURE__ */ n(oo, { open: e, onClose: o, container: i, children: /* @__PURE__ */ w(
2044
- to,
2045
- {
2046
- sx: {
2047
- fontSize: "1em",
2048
- bgcolor: c.surface,
2049
- color: c.textPrimary,
2050
- borderRadius: a.md,
2051
- p: u.lg,
2052
- minWidth: 320,
2053
- maxWidth: 400
2054
- },
2055
- children: [
2056
- /* @__PURE__ */ n(
2057
- K,
2058
- {
2059
- level: "title-lg",
2060
- sx: { fontSize: "1.25em", mb: u.xs, fontFamily: d.primary },
2061
- children: s("discussion.delete.title", "Delete comment")
2062
- }
2063
- ),
2064
- /* @__PURE__ */ n(K, { level: "body-sm", sx: { fontSize: "0.875em", mb: u.lg, color: c.textSecondary }, children: s(
2065
- "discussion.delete.description",
2066
- "Are you sure you want to delete this comment? This action cannot be undone."
2067
- ) }),
2068
- /* @__PURE__ */ w(O, { sx: { display: "flex", gap: u.xs, justifyContent: "flex-end" }, children: [
2069
- /* @__PURE__ */ n(
2070
- ye,
2071
- {
2072
- variant: "plain",
2073
- onClick: o,
2074
- sx: {
2075
- fontSize: "1em",
2076
- fontFamily: d.primary,
2077
- color: c.textPrimary,
2078
- borderRadius: a.sm,
2079
- "&:hover": { bgcolor: `${c.textPrimary}14` }
2080
- },
2081
- children: s("common.cancel", "Cancel")
2082
- }
2083
- ),
2084
- /* @__PURE__ */ n(
2085
- ye,
2086
- {
2087
- variant: "solid",
2088
- loading: y,
2089
- disabled: y,
2090
- onClick: g,
2091
- sx: {
2092
- fontSize: "1em",
2093
- fontFamily: d.primary,
2094
- bgcolor: m,
2095
- color: p,
2096
- borderRadius: a.sm,
2097
- "&:hover": {
2098
- bgcolor: m,
2099
- opacity: 0.9
2100
- },
2101
- "&:disabled": {
2102
- bgcolor: m,
2103
- color: p,
2104
- opacity: 0.4
2105
- }
2106
- },
2107
- children: s("discussion.delete.action", "Delete")
2108
- }
2109
- )
2110
- ] })
2111
- ]
2112
- }
2113
- ) });
2114
- }, cn = [
2115
- { value: "SPAM", labelKey: "discussion.report.spam", fallback: "Spam" },
2116
- {
2117
- value: "NOT_ON_THE_SUBJECT",
2118
- labelKey: "discussion.report.offTopic",
2119
- fallback: "Off topic"
2120
- },
2121
- { value: "AD", labelKey: "discussion.report.ad", fallback: "Advertisement" },
2122
- {
2123
- value: "COPYRIGHT",
2124
- labelKey: "discussion.report.copyright",
2125
- fallback: "Copyright violation"
2126
- },
2127
- {
2128
- value: "EXPLICIT_SEXUAL_CONTENT",
2129
- labelKey: "discussion.report.explicit",
2130
- fallback: "Explicit sexual content"
2131
- },
2132
- {
2133
- value: "HATEFUL_SPEECH",
2134
- labelKey: "discussion.report.hateful",
2135
- fallback: "Hateful speech"
2136
- },
2137
- { value: "INSULT", labelKey: "discussion.report.insult", fallback: "Insult" },
2138
- { value: "OTHER", labelKey: "discussion.report.other", fallback: "Other" }
2139
- ], dn = ({
2140
- open: e,
2141
- onClose: o,
2142
- onSubmit: r,
2143
- onSuccess: l,
2144
- onError: i,
2145
- container: s
2146
- }) => {
2147
- const { t: c } = Ce(), a = be(), d = Se(), u = Te(), m = ge(), p = a.palette.primary.plainColor, y = a.palette.primary.onPrimary, [b, g] = U(""), [x, I] = U(""), [v, C] = U(!1), R = () => {
2148
- o(), g(""), I("");
2149
- }, A = async () => {
2150
- C(!0);
2151
- try {
2152
- await r(
2153
- b,
2154
- b === "OTHER" ? x : void 0
2155
- ), l(
2156
- c(
2157
- "discussion.report.success",
2158
- "Post reported successfully. Thank you."
2159
- )
2160
- ), R();
2161
- } catch {
2162
- i(
2163
- c(
2164
- "discussion.report.error",
2165
- "Failed to report post. Please try again."
2166
- )
2167
- );
2168
- } finally {
2169
- C(!1);
2170
- }
2171
- };
2172
- return /* @__PURE__ */ n(oo, { open: e, onClose: R, container: s, children: /* @__PURE__ */ w(
2173
- to,
2174
- {
2175
- sx: {
2176
- fontSize: "1em",
2177
- bgcolor: a.surface,
2178
- color: a.textPrimary,
2179
- borderRadius: d.md,
2180
- p: m.lg,
2181
- minWidth: 320,
2182
- maxWidth: 440
2183
- },
2184
- children: [
2185
- /* @__PURE__ */ n(
2186
- ot,
2187
- {
2188
- sx: {
2189
- color: a.textPrimary,
2190
- "&:hover": { bgcolor: `${a.textPrimary}14` }
2191
- }
2192
- }
2193
- ),
2194
- /* @__PURE__ */ n(
2195
- K,
2196
- {
2197
- level: "title-lg",
2198
- sx: { fontSize: "1.25em", mb: m.md, fontFamily: u.primary },
2199
- children: c("discussion.report.title", "Report post")
2200
- }
2201
- ),
2202
- /* @__PURE__ */ n(K, { level: "body-sm", sx: { fontSize: "0.875em", mb: m.md, color: a.textSecondary }, children: c(
2203
- "discussion.report.description",
2204
- "Why are you reporting this post?"
2205
- ) }),
2206
- /* @__PURE__ */ n(
2207
- ao,
2208
- {
2209
- value: b,
2210
- onChange: (f) => g(f.target.value),
2211
- sx: { gap: m.xs, mb: m.md },
2212
- children: cn.map((f) => /* @__PURE__ */ n(
2213
- so,
2214
- {
2215
- value: f.value,
2216
- label: c(f.labelKey, f.fallback),
2217
- slotProps: {
2218
- radio: {
2219
- sx: {
2220
- bgcolor: a.surfaceVariant,
2221
- borderColor: a.outlineEnabledBorder,
2222
- "&:hover": {
2223
- bgcolor: a.surface,
2224
- borderColor: a.outlineEnabledBorder
2225
- }
2226
- }
2227
- }
2228
- },
2229
- sx: {
2230
- fontFamily: u.primary,
2231
- color: a.textPrimary
2232
- }
2233
- },
2234
- f.value
2235
- ))
2236
- }
2237
- ),
2238
- b === "OTHER" && /* @__PURE__ */ n(
2239
- Ze,
2240
- {
2241
- placeholder: c(
2242
- "discussion.report.detailsPlaceholder",
2243
- "Please provide more details..."
2244
- ),
2245
- value: x,
2246
- onChange: (f) => I(f.target.value),
2247
- minRows: 2,
2248
- maxRows: 4,
2249
- sx: {
2250
- fontSize: "1em",
2251
- mb: m.md,
2252
- bgcolor: a.surfaceVariant,
2253
- color: a.textPrimary,
2254
- border: `1px solid ${a.outlineEnabledBorder}`,
2255
- borderRadius: d.sm,
2256
- boxShadow: "none",
2257
- "&::before": { display: "none" },
2258
- "&:focus-within": {
2259
- border: `1px solid ${p}`,
2260
- boxShadow: "none"
2261
- }
2262
- }
2263
- }
2264
- ),
2265
- /* @__PURE__ */ w(O, { sx: { display: "flex", gap: m.xs, justifyContent: "flex-end" }, children: [
2266
- /* @__PURE__ */ n(
2267
- ye,
2268
- {
2269
- variant: "plain",
2270
- onClick: R,
2271
- sx: {
2272
- fontSize: "1em",
2273
- fontFamily: u.primary,
2274
- color: a.textPrimary,
2275
- borderRadius: d.sm,
2276
- "&:hover": { bgcolor: `${a.textPrimary}14` }
2277
- },
2278
- children: c("common.cancel", "Cancel")
2279
- }
2280
- ),
2281
- /* @__PURE__ */ n(
2282
- ye,
2283
- {
2284
- variant: "solid",
2285
- disabled: !b || v,
2286
- loading: v,
2287
- onClick: A,
2288
- sx: {
2289
- fontSize: "1em",
2290
- fontFamily: u.primary,
2291
- bgcolor: p,
2292
- color: y,
2293
- borderRadius: d.sm,
2294
- "&:hover": {
2295
- bgcolor: p,
2296
- opacity: 0.9
2297
- },
2298
- "&:disabled": {
2299
- bgcolor: p,
2300
- color: y,
2301
- opacity: 0.4
2302
- }
2303
- },
2304
- children: c("discussion.report.action", "Report")
2305
- }
2306
- )
2307
- ] })
2308
- ]
2309
- }
2310
- ) });
2311
- }, un = (e, o, r) => {
2312
- const l = new Date(e), s = (/* @__PURE__ */ new Date()).getTime() - l.getTime(), c = Math.floor(s / 6e4), a = Math.floor(s / 36e5), d = Math.floor(s / 864e5);
2313
- return c < 1 ? o("discussion.justNow", "Just now") : c < 60 ? o("discussion.minutesAgo", "{{count}}m ago", { count: c }) : a < 24 ? o("discussion.hoursAgo", "{{count}}h ago", { count: a }) : d < 7 ? o("discussion.daysAgo", "{{count}}d ago", { count: d }) : l.toLocaleDateString(Ye(r));
2314
- }, mn = 8e3, co = ({
2315
- post: e,
2316
- sdk: o,
2317
- userIsLoggedIn: r,
2318
- onSignInClick: l,
2319
- showReactions: i = !0,
2320
- showReplies: s = !0,
2321
- showReportPost: c = !0,
2322
- onReply: a,
2323
- onReact: d,
2324
- onDelete: u,
2325
- onReport: m,
2326
- isSubmitting: p,
2327
- showModeratedPosts: y = !1,
2328
- isBanned: b = !1,
2329
- highlightable: g = !1,
2330
- isNew: x = !1,
2331
- onNewSeen: I,
2332
- depth: v = 0,
2333
- parentPostId: C,
2334
- onReplyCreated: R,
2335
- onDeleteSuccess: A
2336
- }) => {
2337
- var oe, ue, re, se;
2338
- const { t: f } = Ce(), { shadowRootElement: P, language: k } = ke(Oe), D = be(), j = Se(), $ = ge(), L = lo(o, r), [ee, _] = U(!1), [E, N] = U([]), [X, te] = U(!1), [ne, h] = U(!1), [T, z] = U(!1), [ie, le] = U({ open: !1, variant: "success", title: "", message: "" }), pe = fe(null);
2339
- Re(() => {
2340
- if (!x || !I || !pe.current) return;
2341
- let S;
2342
- const Y = new IntersectionObserver(
2343
- ([Z]) => {
2344
- Z.isIntersecting && (Y.disconnect(), S = setTimeout(() => I(e.id), mn));
2345
- },
2346
- { threshold: 0.5 }
2347
- );
2348
- return Y.observe(pe.current), () => {
2349
- Y.disconnect(), clearTimeout(S);
2350
- };
2351
- }, [x, I, e.id]);
2352
- const W = !!(r && L && e.userId === L), G = !!e.moderated, B = async (S) => {
2353
- var he;
2354
- const Y = v === 1 && C || e.id, Z = ((he = e.userModel) == null ? void 0 : he.name) || e.anonymousNickname || f("discussion.anonymous", "Anonymous"), ae = v === 1 ? `@${Z} ${S}` : S;
2355
- await a(Y, ae), _(!1), v === 1 && R ? R() : v === 0 && (te(!0), H());
2356
- }, H = async () => {
2357
- if (!(!s || v >= 2))
2358
- try {
2359
- const S = await o.discussions.getPostReplies(e.id, {
2360
- limit: 25,
2361
- skipDeleted: !0,
2362
- skipModerated: !y
2363
- });
2364
- N(S.data);
2365
- } catch (S) {
2366
- console.error("Failed to load replies:", S);
2367
- }
2368
- };
2369
- Re(() => {
2370
- X && E.length === 0 && H();
2371
- }, [X]);
2372
- const V = async (S) => {
2373
- await u(S, e.id), N((Y) => Y.filter((Z) => Z.id !== S));
2374
- }, J = async (S, Y) => {
2375
- const Z = await d(S, Y);
2376
- Z && E.length > 0 && N(
2377
- (ae) => ae.map((he) => he.id === S ? Z : he)
2378
- );
2379
- }, q = (S, Y) => {
2380
- le({ open: !0, variant: Y, title: "", message: S });
2381
- }, Q = D.palette.primary.plainColor;
2382
- return /* @__PURE__ */ w(
2383
- O,
2384
- {
2385
- sx: {
2386
- mb: $.md,
2387
- ml: v > 0 ? $.xl : 0,
2388
- // Only colors change, so the post doesn't shift when the highlight fades
2389
- ...g && {
2390
- px: $.sm,
2391
- py: $.xs,
2392
- borderInlineStart: `3px solid ${x ? Q : "transparent"}`,
2393
- borderRadius: j.xs,
2394
- bgcolor: x ? `${Q}1A` : "transparent",
2395
- transition: "background-color 0.6s ease, border-color 0.6s ease"
2396
- }
2397
- },
2398
- children: [
2399
- /* @__PURE__ */ w(O, { sx: { display: "flex", gap: $.sm }, children: [
2400
- /* @__PURE__ */ n(
2401
- rt,
2402
- {
2403
- src: (oe = e.userModel) == null ? void 0 : oe.avatar,
2404
- alt: ((ue = e.userModel) == null ? void 0 : ue.name) || e.anonymousNickname || "User",
2405
- size: "sm",
2406
- sx: { bgcolor: D.surfaceVariant, color: D.textPrimary }
2407
- }
2408
- ),
2409
- /* @__PURE__ */ w(O, { sx: { flex: 1, minWidth: 0 }, children: [
2410
- /* @__PURE__ */ w(
2411
- O,
2412
- {
2413
- ref: pe,
2414
- sx: {
2415
- display: "flex",
2416
- alignItems: "center",
2417
- gap: $.xs,
2418
- mb: $["2xs"]
2419
- },
2420
- children: [
2421
- /* @__PURE__ */ n(
2422
- K,
2423
- {
2424
- level: "title-sm",
2425
- sx: { fontSize: "0.875em", color: D.textPrimary },
2426
- children: ((re = e.userModel) == null ? void 0 : re.name) || e.anonymousNickname || f("discussion.anonymous", "Anonymous")
2427
- }
2428
- ),
2429
- /* @__PURE__ */ n(
2430
- K,
2431
- {
2432
- level: "body-xs",
2433
- sx: { fontSize: "0.75em", color: D.textSecondary },
2434
- children: un(e.createdAt, f, k)
2435
- }
2436
- ),
2437
- x && /* @__PURE__ */ n(
2438
- K,
2439
- {
2440
- component: "span",
2441
- level: "body-xs",
2442
- sx: {
2443
- fontSize: "0.75em",
2444
- fontWeight: 600,
2445
- lineHeight: 1.5,
2446
- px: $.xs,
2447
- borderRadius: j.full,
2448
- color: D.palette.primary.plainColor,
2449
- bgcolor: `${D.palette.primary.plainColor}1F`
2450
- },
2451
- children: f("discussion.newPost", "New")
2452
- }
2453
- ),
2454
- /* @__PURE__ */ n(
2455
- an,
2456
- {
2457
- isOwnPost: W,
2458
- canReport: !!(c && r && !W) && !G,
2459
- onDelete: () => h(!0),
2460
- onReport: () => z(!0),
2461
- disabled: b
2462
- }
2463
- )
2464
- ]
2465
- }
2466
- ),
2467
- G && y ? /* @__PURE__ */ w(
2468
- O,
2469
- {
2470
- sx: {
2471
- mb: $.xs,
2472
- mr: $.md,
2473
- px: $.sm,
2474
- py: $.xs,
2475
- borderRadius: j.xs,
2476
- borderLeft: `3px solid ${D.outlineEnabledBorder}`,
2477
- bgcolor: D.surfaceVariant,
2478
- display: "flex",
2479
- alignItems: "flex-start",
2480
- gap: $.xs
2481
- },
2482
- children: [
2483
- /* @__PURE__ */ n(
2484
- Qt,
2485
- {
2486
- sx: {
2487
- fontSize: "0.9375em",
2488
- color: D.textSecondary,
2489
- mt: "2px",
2490
- flexShrink: 0
2491
- }
2492
- }
2493
- ),
2494
- /* @__PURE__ */ n(
2495
- K,
2496
- {
2497
- level: "body-sm",
2498
- sx: {
2499
- fontSize: "0.875em",
2500
- fontStyle: "italic",
2501
- color: D.textSecondary,
2502
- lineHeight: 1.5
2503
- },
2504
- children: e.moderatedReason || f(
2505
- "discussion.moderatedPost",
2506
- "This comment has been moderated"
2507
- )
2508
- }
2509
- )
2510
- ]
2511
- }
2512
- ) : /* @__PURE__ */ n(
2513
- K,
2514
- {
2515
- level: "body-sm",
2516
- sx: {
2517
- fontSize: "0.875em",
2518
- mb: $.xs,
2519
- whiteSpace: "pre-wrap",
2520
- color: D.textBody
2521
- },
2522
- children: e.content
2523
- }
2524
- ),
2525
- !G && /* @__PURE__ */ n(
2526
- sn,
2527
- {
2528
- post: e,
2529
- sdk: o,
2530
- userIsLoggedIn: r,
2531
- onSignInClick: l,
2532
- onReact: d,
2533
- showReactions: i,
2534
- showReplyButton: s && v < 2,
2535
- onReplyClick: () => _(!ee),
2536
- isBanned: b
2537
- }
2538
- ),
2539
- s && e.repliesCount > 0 && /* @__PURE__ */ n(O, { sx: { mb: $.xs }, children: /* @__PURE__ */ w(
2540
- K,
2541
- {
2542
- level: "body-sm",
2543
- sx: {
2544
- fontSize: "0.875em",
2545
- color: D.palette.primary.plainColor,
2546
- cursor: "pointer",
2547
- fontWeight: 600,
2548
- display: "flex",
2549
- alignItems: "center",
2550
- gap: $["2xs"]
2551
- },
2552
- onClick: () => te(!X),
2553
- children: [
2554
- X ? f("discussion.hideReplies", "Hide replies") : f("discussion.repliesCount", "{{count}} replies", {
2555
- count: e.repliesCount
2556
- }),
2557
- !X && " ▼"
2558
- ]
2559
- }
2560
- ) }),
2561
- ee && !G && /* @__PURE__ */ n(O, { sx: { mt: $.md }, children: /* @__PURE__ */ n(
2562
- io,
2563
- {
2564
- onSubmit: B,
2565
- userIsLoggedIn: r,
2566
- onSignInClick: l,
2567
- placeholder: f("discussion.writeReply", "Write a reply..."),
2568
- isSubmitting: p,
2569
- replyTo: ((se = e.userModel) == null ? void 0 : se.name) || e.anonymousNickname,
2570
- onCancel: () => _(!1),
2571
- disabled: b
2572
- }
2573
- ) }),
2574
- X && E.length > 0 && /* @__PURE__ */ n(O, { sx: { mt: $.md }, children: E.map((S) => /* @__PURE__ */ n(
2575
- co,
2576
- {
2577
- post: S,
2578
- sdk: o,
2579
- userIsLoggedIn: r,
2580
- onSignInClick: l,
2581
- showReactions: i,
2582
- showReplies: s,
2583
- showReportPost: c,
2584
- onReply: a,
2585
- onReact: J,
2586
- onDelete: V,
2587
- onReport: m,
2588
- isSubmitting: p,
2589
- showModeratedPosts: y,
2590
- isBanned: b,
2591
- depth: v + 1,
2592
- parentPostId: v === 0 ? e.id : C,
2593
- onReplyCreated: v === 0 ? H : void 0,
2594
- onDeleteSuccess: A
2595
- },
2596
- S.id
2597
- )) })
2598
- ] })
2599
- ] }),
2600
- /* @__PURE__ */ n(
2601
- ln,
2602
- {
2603
- open: ne,
2604
- onClose: () => h(!1),
2605
- onConfirm: async () => {
2606
- await u(e.id), A == null || A();
2607
- },
2608
- onError: (S) => q(S, "error"),
2609
- container: P
2610
- }
2611
- ),
2612
- /* @__PURE__ */ n(
2613
- dn,
2614
- {
2615
- open: T,
2616
- onClose: () => z(!1),
2617
- onSubmit: (S, Y) => m(e.id, S, Y),
2618
- onSuccess: (S) => q(S, "success"),
2619
- onError: (S) => q(S, "error"),
2620
- container: P
2621
- }
2622
- ),
2623
- /* @__PURE__ */ n(
2624
- no,
2625
- {
2626
- notification: ie,
2627
- onClose: () => le((S) => ({ ...S, open: !1 }))
2628
- }
2629
- )
2630
- ]
2631
- }
2632
- );
2633
- }, Fe = 864e5, qe = -1, pn = ({
2634
- ban: e,
2635
- showBanHistory: o = !1
2636
- }) => {
2637
- const { t: r } = Ce(), { language: l } = ke(Oe), i = be(), s = Se(), c = Te(), a = ge(), [d, u] = U(!1), m = i.palette.danger.plainColor, p = Ye(l), y = (f) => new Date(f).toLocaleDateString(p, { dateStyle: "medium" }), b = (f) => new Date(f).toLocaleString(p, {
2638
- dateStyle: "medium",
2639
- timeStyle: "short"
2640
- }), { activeBan: g } = e, x = g.bannedPeriodInDays === qe, I = new Date(
2641
- new Date(g.bannedAt).getTime() + g.bannedPeriodInDays * Fe
2642
- ), v = Math.max(
2643
- 1,
2644
- Math.ceil((I.getTime() - Date.now()) / Fe)
2645
- ), C = (e.history || []).filter(
2646
- (f) => f.bannedAt !== g.bannedAt
2647
- ), R = { fontSize: "0.8125em", color: i.textSecondary }, A = {
2648
- fontSize: "0.75em",
2649
- fontWeight: 600,
2650
- color: m,
2651
- border: `1px solid ${m}`,
2652
- borderRadius: s.lg,
2653
- px: a.xs,
2654
- py: "0.125em"
2655
- };
2656
- return /* @__PURE__ */ n(
2657
- O,
2658
- {
2659
- role: "status",
2660
- sx: {
2661
- fontSize: "1em",
2662
- mb: a.sm,
2663
- p: a.md,
2664
- bgcolor: i.palette.danger.softBg,
2665
- borderLeft: `4px solid ${m}`,
2666
- borderRadius: s.sm
2667
- },
2668
- children: /* @__PURE__ */ w(
2669
- O,
2670
- {
2671
- sx: { display: "flex", gap: a.sm, alignItems: "flex-start" },
2672
- children: [
2673
- /* @__PURE__ */ n(
2674
- O,
2675
- {
2676
- sx: {
2677
- flexShrink: 0,
2678
- display: "flex",
2679
- alignItems: "center",
2680
- justifyContent: "center",
2681
- width: "2.25em",
2682
- height: "2.25em",
2683
- borderRadius: "50%",
2684
- bgcolor: `${m}1F`,
2685
- color: m
2686
- },
2687
- children: /* @__PURE__ */ n(jt, { sx: { fontSize: "1.25em" } })
2688
- }
2689
- ),
2690
- /* @__PURE__ */ w(O, { sx: { flex: 1, minWidth: 0 }, children: [
2691
- /* @__PURE__ */ n(
2692
- K,
2693
- {
2694
- level: "title-md",
2695
- sx: {
2696
- fontSize: "1em",
2697
- fontWeight: 700,
2698
- fontFamily: c.primary,
2699
- color: i.textPrimary
2700
- },
2701
- children: r("discussion.ban.title", "You've been banned from commenting")
2702
- }
2703
- ),
2704
- /* @__PURE__ */ n(
2705
- K,
2706
- {
2707
- level: "body-sm",
2708
- sx: {
2709
- fontSize: "0.875em",
2710
- color: i.textBody,
2711
- mt: a["2xs"]
2712
- },
2713
- children: x ? r(
2714
- "discussion.ban.descriptionPermanent",
2715
- "You can still read the discussion, but you can no longer post, reply or react."
2716
- ) : r(
2717
- "discussion.ban.description",
2718
- "You can still read the discussion, but you can't post, reply or react until the ban ends."
2719
- )
2720
- }
2721
- ),
2722
- /* @__PURE__ */ w(
2723
- O,
2724
- {
2725
- sx: {
2726
- display: "flex",
2727
- flexWrap: "wrap",
2728
- alignItems: "center",
2729
- gap: a.xs,
2730
- mt: a.sm
2731
- },
2732
- children: [
2733
- /* @__PURE__ */ n(K, { component: "span", sx: A, children: x ? r("discussion.ban.permanent", "Permanent ban") : r("discussion.ban.daysLeft", "{{count}} days left", {
2734
- count: v
2735
- }) }),
2736
- /* @__PURE__ */ n(K, { component: "span", sx: R, children: r("discussion.ban.since", "Since {{date}}", {
2737
- date: y(g.bannedAt)
2738
- }) }),
2739
- !x && /* @__PURE__ */ w(K, { component: "span", sx: R, children: [
2740
- "·",
2741
- " ",
2742
- r("discussion.ban.until", "Until {{date}}", {
2743
- date: b(I)
2744
- })
2745
- ] })
2746
- ]
2747
- }
2748
- ),
2749
- g.bannedReason && /* @__PURE__ */ w(
2750
- O,
2751
- {
2752
- sx: {
2753
- mt: a.sm,
2754
- px: a.sm,
2755
- py: a.xs,
2756
- bgcolor: i.surface,
2757
- borderRadius: s.xs
2758
- },
2759
- children: [
2760
- /* @__PURE__ */ n(
2761
- K,
2762
- {
2763
- level: "body-xs",
2764
- sx: {
2765
- fontSize: "0.75em",
2766
- fontWeight: 600,
2767
- textTransform: "uppercase",
2768
- color: i.textSecondary
2769
- },
2770
- children: r("discussion.ban.reason", "Reason")
2771
- }
2772
- ),
2773
- /* @__PURE__ */ n(
2774
- K,
2775
- {
2776
- level: "body-sm",
2777
- sx: {
2778
- fontSize: "0.875em",
2779
- color: i.textPrimary,
2780
- whiteSpace: "pre-wrap",
2781
- unicodeBidi: "plaintext"
2782
- },
2783
- children: g.bannedReason
2784
- }
2785
- )
2786
- ]
2787
- }
2788
- ),
2789
- o && C.length > 0 && /* @__PURE__ */ w(O, { sx: { mt: a.sm }, children: [
2790
- /* @__PURE__ */ w(
2791
- K,
2792
- {
2793
- component: "button",
2794
- type: "button",
2795
- "aria-expanded": d,
2796
- onClick: () => u((f) => !f),
2797
- sx: {
2798
- fontSize: "0.8125em",
2799
- fontWeight: 600,
2800
- fontFamily: c.primary,
2801
- color: i.textPrimary,
2802
- display: "inline-flex",
2803
- alignItems: "center",
2804
- gap: a["2xs"],
2805
- p: 0,
2806
- border: "none",
2807
- bgcolor: "transparent",
2808
- cursor: "pointer"
2809
- },
2810
- children: [
2811
- r("discussion.ban.previousBans", "Previous bans ({{count}})", {
2812
- count: C.length
2813
- }),
2814
- /* @__PURE__ */ n(
2815
- st,
2816
- {
2817
- sx: {
2818
- fontSize: "1.25em",
2819
- transition: "transform 0.2s",
2820
- transform: d ? "rotate(180deg)" : "none"
2821
- }
2822
- }
2823
- )
2824
- ]
2825
- }
2826
- ),
2827
- d && /* @__PURE__ */ n(
2828
- O,
2829
- {
2830
- component: "ul",
2831
- sx: { listStyle: "none", m: 0, p: 0, mt: a.xs },
2832
- children: C.map((f) => {
2833
- const P = f.unbannedAt ?? (f.bannedPeriodInDays > 0 ? new Date(
2834
- new Date(f.bannedAt).getTime() + f.bannedPeriodInDays * Fe
2835
- ) : null);
2836
- return /* @__PURE__ */ w(
2837
- O,
2838
- {
2839
- component: "li",
2840
- sx: {
2841
- py: a.xs,
2842
- borderTop: `1px solid ${m}33`
2843
- },
2844
- children: [
2845
- /* @__PURE__ */ w(
2846
- K,
2847
- {
2848
- sx: {
2849
- ...R,
2850
- fontWeight: 600,
2851
- color: i.textPrimary
2852
- },
2853
- children: [
2854
- y(f.bannedAt),
2855
- P && ` – ${y(P)}`,
2856
- f.bannedPeriodInDays === qe && ` · ${r("discussion.ban.permanent", "Permanent ban")}`,
2857
- f.bannedPeriodInDays > 0 && ` · ${r("discussion.ban.days", "{{count}} days", { count: f.bannedPeriodInDays })}`
2858
- ]
2859
- }
2860
- ),
2861
- f.bannedReason && /* @__PURE__ */ n(
2862
- K,
2863
- {
2864
- sx: { ...R, unicodeBidi: "plaintext" },
2865
- children: f.bannedReason
2866
- }
2867
- ),
2868
- f.unbannedAt && /* @__PURE__ */ w(K, { sx: { ...R, fontStyle: "italic" }, children: [
2869
- r("discussion.ban.lifted", "Lifted on {{date}}", {
2870
- date: y(f.unbannedAt)
2871
- }),
2872
- f.unbannedReason && /* @__PURE__ */ w(Ie, { children: [
2873
- ": ",
2874
- /* @__PURE__ */ n(
2875
- O,
2876
- {
2877
- component: "span",
2878
- sx: { unicodeBidi: "isolate" },
2879
- children: f.unbannedReason
2880
- }
2881
- )
2882
- ] })
2883
- ] })
2884
- ]
2885
- },
2886
- f.bannedAt
2887
- );
2888
- })
2889
- }
2890
- )
2891
- ] })
2892
- ] })
2893
- ]
2894
- }
2895
- )
2896
- }
2897
- );
2898
- }, fn = ({
2899
- discussion: e,
2900
- posts: o,
2901
- postsHidden: r = !1,
2902
- sdk: l,
2903
- userIsLoggedIn: i,
2904
- onSignInClick: s,
2905
- showReactions: c,
2906
- showReplies: a,
2907
- showReportPost: d,
2908
- currentSort: u,
2909
- onSortChange: m,
2910
- onCreatePost: p,
2911
- onReact: y,
2912
- onDeletePost: b,
2913
- onReportPost: g,
2914
- onLoadMore: x,
2915
- hasMore: I,
2916
- liveRefresh: v = !1,
2917
- newPostIds: C,
2918
- onNewPostSeen: R,
2919
- isLoading: A,
2920
- isSubmitting: f,
2921
- infiniteScroll: P = !1,
2922
- showModeratedPosts: k = !1,
2923
- ban: D,
2924
- isBanned: j = !1,
2925
- showBanHistory: $ = !1
2926
- }) => {
2927
- const { t: L } = Ce(), { shadowRootElement: ee } = ke(Oe), _ = Se(), E = be(), N = ge(), X = fe(null), te = fe(null);
2928
- Re(() => {
2929
- if (!P || !te.current) return;
2930
- const W = new IntersectionObserver(
2931
- (G) => {
2932
- G[0].isIntersecting && I && !A && x();
2933
- },
2934
- { root: X.current, threshold: 0.1 }
2935
- );
2936
- return W.observe(te.current), () => W.disconnect();
2937
- }, [P, I, A, x]);
2938
- const [ne, h] = U({ open: !1, variant: "success", title: "", message: "" }), T = () => {
2939
- h({
2940
- open: !0,
2941
- variant: "success",
2942
- title: "",
2943
- message: L("discussion.delete.success", "Comment deleted successfully.")
2944
- });
2945
- }, z = async (W, G) => {
2946
- await p(W, G), h({
2947
- open: !0,
2948
- variant: "success",
2949
- title: "",
2950
- message: L("discussion.postSuccess", "Comment posted successfully.")
2951
- });
2952
- }, ie = [
2953
- { value: "LATEST", label: L("discussion.sort.latest", "Latest") },
2954
- { value: "OLDEST", label: L("discussion.sort.oldest", "Oldest") },
2955
- { value: "POPULAR", label: L("discussion.sort.popular", "Popular") },
2956
- {
2957
- value: "INTERACTED",
2958
- label: L("discussion.sort.interacted", "Most Interacted")
2959
- }
2960
- ], le = {
2961
- listbox: {
2962
- container: ee,
2963
- sx: {
2964
- zIndex: 1300,
2965
- bgcolor: E.surface,
2966
- border: `1px solid ${E.outlineEnabledBorder}`,
2967
- borderRadius: _.sm,
2968
- boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1)"
2969
- }
2970
- }
2971
- }, pe = {
2972
- fontSize: "1em",
2973
- color: `${E.textPrimary} !important`,
2974
- bgcolor: `${E.surface} !important`,
2975
- "&:hover": {
2976
- bgcolor: `${E.surfaceVariant} !important`,
2977
- color: `${E.textPrimary} !important`
2978
- },
2979
- "&.Mui-selected": {
2980
- bgcolor: `${E.surfaceVariant} !important`,
2981
- color: `${E.textPrimary} !important`
2982
- },
2983
- "&.Mui-selected:hover": {
2984
- bgcolor: `${E.surfaceVariant} !important`,
2985
- color: `${E.textPrimary} !important`
2986
- }
2987
- };
2988
- return /* @__PURE__ */ w(
2989
- O,
2990
- {
2991
- ref: X,
2992
- sx: {
2993
- mx: "auto",
2994
- maxHeight: "100%",
2995
- overflowY: "auto",
2996
- bgcolor: E.surface
2997
- },
2998
- children: [
2999
- /* @__PURE__ */ w(O, { sx: { mb: N.lg }, children: [
3000
- /* @__PURE__ */ n(K, { level: "h3", sx: { fontSize: "1.5em", mb: N.xs }, children: e.label || L("discussion.title", "Discussion") }),
3001
- !r && /* @__PURE__ */ n(K, { level: "body-sm", sx: { fontSize: "0.875em", color: E.textSecondary }, children: L("discussion.postsCount", "{{count}} posts", {
3002
- count: e.postsCount || 0
3003
- }) })
3004
- ] }),
3005
- j && D && /* @__PURE__ */ n(pn, { ban: D, showBanHistory: $ }),
3006
- /* @__PURE__ */ n(
3007
- io,
3008
- {
3009
- onSubmit: (W) => z(W),
3010
- userIsLoggedIn: i,
3011
- onSignInClick: s,
3012
- isSubmitting: f,
3013
- disabled: j
3014
- }
3015
- ),
3016
- !r && /* @__PURE__ */ w(Ie, { children: [
3017
- /* @__PURE__ */ n(at, { sx: { my: N.lg } }),
3018
- /* @__PURE__ */ w(
3019
- O,
3020
- {
3021
- sx: {
3022
- mb: N.lg,
3023
- display: "flex",
3024
- justifyContent: "space-between",
3025
- alignItems: "center"
3026
- },
3027
- children: [
3028
- /* @__PURE__ */ n(K, { level: "title-md", sx: { fontSize: "1em" }, children: L("discussion.comments", "Comments") }),
3029
- /* @__PURE__ */ n(
3030
- it,
3031
- {
3032
- value: u,
3033
- onChange: (W, G) => G && m(G),
3034
- size: "sm",
3035
- sx: {
3036
- fontSize: "1em",
3037
- minWidth: 150,
3038
- bgcolor: E.surfaceVariant,
3039
- color: E.textPrimary,
3040
- border: `1px solid ${E.outlineEnabledBorder}`,
3041
- borderRadius: _.sm,
3042
- boxShadow: "none",
3043
- "&:hover": {
3044
- bgcolor: E.surfaceVariant,
3045
- boxShadow: "none"
3046
- }
3047
- },
3048
- slotProps: le,
3049
- children: ie.map((W) => /* @__PURE__ */ n(lt, { value: W.value, sx: pe, children: W.label }, W.value))
3050
- }
3051
- )
3052
- ]
3053
- }
3054
- ),
3055
- A && o.length === 0 ? /* @__PURE__ */ n(O, { sx: { py: N.xl }, children: /* @__PURE__ */ n(Ne, { my: 4 }) }) : o.length === 0 ? /* @__PURE__ */ n(O, { sx: { textAlign: "center", py: N.xl }, children: /* @__PURE__ */ n(K, { level: "body-md", sx: { fontSize: "1em", color: E.textSecondary }, children: L(
3056
- "discussion.noPosts",
3057
- "No comments yet. Be the first to comment!"
3058
- ) }) }) : /* @__PURE__ */ w(Ie, { children: [
3059
- /* @__PURE__ */ n(O, { children: o.map((W) => /* @__PURE__ */ n(
3060
- co,
3061
- {
3062
- post: W,
3063
- sdk: l,
3064
- userIsLoggedIn: i,
3065
- onSignInClick: s,
3066
- showReactions: c,
3067
- showReplies: a,
3068
- showReportPost: d,
3069
- onReply: (G, B) => z(B, G),
3070
- onReact: y,
3071
- onDelete: b,
3072
- onReport: g,
3073
- isSubmitting: f,
3074
- showModeratedPosts: k,
3075
- isBanned: j,
3076
- highlightable: v,
3077
- isNew: C == null ? void 0 : C.has(W.id),
3078
- onNewSeen: R,
3079
- onDeleteSuccess: T
3080
- },
3081
- W.id
3082
- )) }),
3083
- P && /* @__PURE__ */ n(O, { ref: te, sx: { height: 1 } })
3084
- ] }),
3085
- P && A && o.length > 0 && /* @__PURE__ */ n(O, { sx: { py: N.md }, children: /* @__PURE__ */ n(Ne, { my: 2 }) }),
3086
- !P && I && /* @__PURE__ */ n(O, { sx: { display: "flex", justifyContent: "center", mt: N.lg }, children: /* @__PURE__ */ n(
3087
- ye,
3088
- {
3089
- variant: "outlined",
3090
- onClick: x,
3091
- loading: A,
3092
- disabled: A,
3093
- sx: {
3094
- fontSize: "1em",
3095
- borderColor: E.palette.primary.plainColor,
3096
- color: E.palette.primary.plainColor,
3097
- borderRadius: _.sm,
3098
- "&:hover": {
3099
- bgcolor: `${E.palette.primary.plainColor}14`,
3100
- borderColor: E.palette.primary.plainColor
3101
- },
3102
- "&:disabled": {
3103
- borderColor: E.palette.primary.plainColor,
3104
- color: E.palette.primary.plainColor,
3105
- opacity: 0.4
3106
- }
3107
- },
3108
- children: L("discussion.loadMore", "Load More")
3109
- }
3110
- ) })
3111
- ] }),
3112
- /* @__PURE__ */ n(
3113
- no,
3114
- {
3115
- notification: ne,
3116
- onClose: () => h((W) => ({ ...W, open: !1 }))
3117
- }
3118
- )
3119
- ]
3120
- }
3121
- );
3122
- }, hn = (e) => {
3123
- const {
3124
- entityId: o,
3125
- sdk: r,
3126
- discussionLabel: l,
3127
- discussionUrl: i = "",
3128
- defaultSort: s = "LATEST",
3129
- postsPerPage: c = 20,
3130
- showReactions: a = !0,
3131
- showReplies: d = !0,
3132
- showReportPost: u = !0,
3133
- infiniteScroll: m = !1,
3134
- showModeratedPosts: p = !1,
3135
- userIsLoggedIn: y = !1,
3136
- showBanHistory: b = !1,
3137
- refreshInterval: g = 0,
3138
- onSignInClick: x
3139
- } = e, { ban: I, isBanned: v, refresh: C } = Kt(r, y), {
3140
- discussion: R,
3141
- setDiscussion: A,
3142
- isLoading: f,
3143
- error: P,
3144
- isNotFound: k
3145
- } = Nt(r, o), D = (W) => {
3146
- A(
3147
- (G) => G && { ...G, postsCount: Math.max(0, G.postsCount + W) }
3148
- );
3149
- }, {
3150
- posts: j,
3151
- postsHidden: $,
3152
- isLoading: L,
3153
- isSubmitting: ee,
3154
- currentSort: _,
3155
- hasMore: E,
3156
- newPostIds: N,
3157
- markPostSeen: X,
3158
- handleSortChange: te,
3159
- handleLoadMore: ne,
3160
- handleCreatePost: h,
3161
- handleReact: T,
3162
- handleDeletePost: z,
3163
- handleReportPost: ie
3164
- } = Ht(
3165
- r,
3166
- o,
3167
- l || null,
3168
- i,
3169
- s,
3170
- c,
3171
- D,
3172
- p,
3173
- g
3174
- ), le = (W) => async (...G) => {
3175
- try {
3176
- return await W(...G);
3177
- } catch (B) {
3178
- throw Ut(B) && C(), B;
3179
- }
3180
- };
3181
- if (f || !R && !k && L)
3182
- return /* @__PURE__ */ n(Ne, { my: 20 });
3183
- if (P)
3184
- return /* @__PURE__ */ n("div", { style: { padding: "20px", textAlign: "center" }, children: /* @__PURE__ */ n("p", { children: "Failed to load discussion. Please try again later." }) });
3185
- const pe = R || {
3186
- id: o,
3187
- title: "",
3188
- description: "",
3189
- postsCount: 0,
3190
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3191
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
3192
- };
3193
- return /* @__PURE__ */ n(
3194
- fn,
3195
- {
3196
- discussion: pe,
3197
- posts: j,
3198
- postsHidden: $,
3199
- sdk: r,
3200
- userIsLoggedIn: y,
3201
- onSignInClick: x,
3202
- showReactions: a,
3203
- showReplies: d,
3204
- showReportPost: u,
3205
- currentSort: _,
3206
- onSortChange: te,
3207
- onCreatePost: le(h),
3208
- onReact: le(T),
3209
- onDeletePost: le(z),
3210
- onReportPost: le(ie),
3211
- onLoadMore: ne,
3212
- hasMore: E,
3213
- liveRefresh: g > 0,
3214
- newPostIds: N,
3215
- onNewPostSeen: X,
3216
- isLoading: L,
3217
- isSubmitting: ee,
3218
- infiniteScroll: m,
3219
- showModeratedPosts: p,
3220
- ban: I,
3221
- isBanned: v,
3222
- showBanHistory: b
3223
- }
3224
- );
3225
- }, yn = (e) => {
3226
- const [o, r] = ce.useState(!1), [l, i] = ce.useState(!1), s = xo(e.language), c = ce.useRef(
3227
- `$discussion-shadow-root-${Math.random().toString(36).substring(2, 11)}`
3228
- ), a = ce.useRef(null), d = ce.useRef(null), u = ce.useRef(null), [m, p] = ce.useState(null);
3229
- ce.useEffect(() => {
3230
- Ro(e.language || "en").finally(() => i(!0));
3231
- }, [e.language]), ce.useEffect(() => {
3232
- if (!a.current) return;
3233
- a.current.shadowRoot ? (d.current = a.current.shadowRoot, u.current = d.current.getElementById(
3234
- c.current
3235
- ), u.current || (u.current = document.createElement("div"), u.current.id = c.current, u.current.style.height = "100%", d.current.appendChild(u.current))) : (d.current = a.current.attachShadow({ mode: "open" }), u.current = document.createElement("div"), u.current.id = c.current, u.current.style.height = "100%", d.current.appendChild(u.current)), Co(u.current, s);
3236
- const x = Mo("discussion", s);
3237
- return p(
3238
- (I) => (I == null ? void 0 : I.key) === x ? I : So(
3239
- "discussion",
3240
- d.current,
3241
- s
3242
- )
3243
- ), r(!0), () => {
3244
- r(!1);
3245
- };
3246
- }, [s]);
3247
- const y = e.themeOptions, b = /* @__PURE__ */ n(O, { ref: a, lang: e.language || "en", sx: { height: "100%", display: "block" } }), g = o && l && u.current && m ? To(
3248
- // Keyed on the cache, not on `direction`: it must change in the same
3249
- // render that adopts the new cache, or CssVarsProvider writes its CSS
3250
- // variables into the outgoing cache and never repeats.
3251
- /* @__PURE__ */ n(Po, { value: m, children: /* @__PURE__ */ n(Io, { containerRef: a, children: /* @__PURE__ */ n(
3252
- zo,
3253
- {
3254
- customTheme: y,
3255
- mode: y == null ? void 0 : y.mode,
3256
- shadowRootElement: u.current,
3257
- direction: s,
3258
- children: /* @__PURE__ */ n(
3259
- Eo,
3260
- {
3261
- shadowRootElement: u.current,
3262
- leadPhoneCountryCode: null,
3263
- language: e.language,
3264
- optionsLayout: null,
3265
- direction: s,
3266
- children: e.children
3267
- }
3268
- )
3269
- }
3270
- ) }) }, m.key),
3271
- u.current
3272
- ) : null;
3273
- return /* @__PURE__ */ w(Ie, { children: [
3274
- b,
3275
- g
3276
- ] });
3277
- }, Hn = (e) => /* @__PURE__ */ n(yn, { ...e, children: /* @__PURE__ */ n(hn, { ...e }) });
3278
- export {
3279
- Hn as M
3280
- };