fansunited-widgets-cdn 0.0.84 → 0.0.86-RC1

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 (75) hide show
  1. package/chunks/Alert-CuOsmojH.js +149 -0
  2. package/chunks/AspectRatio-D3Sgxj7p.js +125 -0
  3. package/chunks/Avatar-BTsEKfhc.js +186 -0
  4. package/chunks/Button-BV7YIFkS.js +858 -0
  5. package/chunks/Card-DRIT0wtY.js +129 -0
  6. package/chunks/CardContent-CD-WZh1l.js +60 -0
  7. package/chunks/ChevronRight-BrCKlr3T.js +11 -0
  8. package/chunks/Chip-6HLNTHMI.js +281 -0
  9. package/chunks/ClassicQuizWrapper-t04e9_6c.js +4883 -0
  10. package/chunks/CollectLeadForm-DtmR2Vuf-B_3JkHJC.js +1560 -0
  11. package/chunks/CollectLeadWrapper-CVAVswua.js +1294 -0
  12. package/chunks/DialogActions-C5kAgHal.js +45 -0
  13. package/chunks/DialogContent-MIXff4nd.js +60 -0
  14. package/chunks/EitherOrById-CAo8gPjm.js +1496 -0
  15. package/chunks/EitherOrPreviewWrapper-DFi2bviS.js +47 -0
  16. package/chunks/Error-DhQL89pn-BwTV1meb.js +418 -0
  17. package/chunks/EventGameWrapper-BxyLL3eA.js +7633 -0
  18. package/chunks/Grid-Dpv_ZL23.js +279 -0
  19. package/chunks/IconButton-Lt9Xks7c.js +207 -0
  20. package/chunks/Link-DLuj1USf.js +228 -0
  21. package/chunks/List-DLPlZGTP.js +397 -0
  22. package/chunks/ListItemDecorator-CE2eQLip.js +1882 -0
  23. package/chunks/MatchPredictionContainer-Ct6gXvLw.js +751 -0
  24. package/chunks/MatchQuizWrapper-Fu6RfWVn.js +11046 -0
  25. package/chunks/ModalDialog-Ci3hulZA.js +619 -0
  26. package/chunks/NotFoundSkeleton-BYJTzYJR-Be3R34nS.js +2764 -0
  27. package/chunks/OverlayLeadAfterCollection-DnqztPJ5-CpELr0AC.js +896 -0
  28. package/chunks/OverlayScoreStateSkeleton-C9FUhcnd-DMFELrvA.js +146 -0
  29. package/chunks/PersonalityQuizWrapper-MpUK4n3Y.js +34374 -0
  30. package/chunks/PlayerOfTheMatch-D4vuR7pz.js +1406 -0
  31. package/chunks/PollWrapper-CzKj8xxE.js +4198 -0
  32. package/chunks/Portal-BWqqFvVm-TuHZWjxn.js +12717 -0
  33. package/chunks/Portal-DA1mxzSo.js +41 -0
  34. package/chunks/PreviewQuizById-WWS_LyJR.js +4864 -0
  35. package/chunks/Select-p_cHpLhi.js +3418 -0
  36. package/chunks/Sheet-BaCzogZK.js +167 -0
  37. package/chunks/Snackbar-DHxnbCA3.js +358 -0
  38. package/chunks/Stack-Dgf2LXN0.js +117 -0
  39. package/chunks/Tabs-CSu_cWNi.js +784 -0
  40. package/chunks/TeamNextMatchPrediction-C7HilNqW.js +6 -0
  41. package/chunks/Tutorial-DFNZxmAx.js +427 -0
  42. package/chunks/createLucideIcon-B6NxpYkb.js +79 -0
  43. package/chunks/createSvgIcon-7h7XC877.js +119 -0
  44. package/chunks/createSvgIcon-DVA0KIUd.js +2490 -0
  45. package/chunks/dataAttributeParser-CF9vxaVN.js +28 -0
  46. package/chunks/default-quiz-bg-CTzaADn7.js +4 -0
  47. package/chunks/getReactElementRef-BD-S8A24.js +25 -0
  48. package/chunks/index-24AwmTVJ.js +85 -0
  49. package/chunks/index-3vJS8JzK.js +63 -0
  50. package/chunks/index-BSD7mvEU.js +57 -0
  51. package/chunks/index-BU6iona7.js +57 -0
  52. package/chunks/index-BqCHiyI6.js +59 -0
  53. package/chunks/index-C5qRf4TV.js +20 -0
  54. package/chunks/index-C9MpfjqV.js +35 -0
  55. package/chunks/index-CMmQs5A5.js +56 -0
  56. package/chunks/index-CicEY2Jv.js +5 -0
  57. package/chunks/index-DNeawo0R.js +17 -0
  58. package/chunks/index-DePIySlY.js +29 -0
  59. package/chunks/index-DoRYU_1L.js +41 -0
  60. package/chunks/index-DvgG9XJj.js +20 -0
  61. package/chunks/index-QpZE-92Y.js +33 -0
  62. package/chunks/index-rgFj976B.js +17 -0
  63. package/chunks/index-tzsdMoo-.js +16 -0
  64. package/chunks/index.es-CHqz6mjo.js +6162 -0
  65. package/chunks/init-BEkECL0v.js +32 -0
  66. package/chunks/main-XP7dqk6g.js +39843 -0
  67. package/chunks/resolveProps-BfYZubfk.js +37 -0
  68. package/chunks/users-D_xgC4iQ.js +16 -0
  69. package/chunks/variantColorInheritance-DI3wUohX.js +28 -0
  70. package/fu-widgets-loader.es.js +76 -0
  71. package/fu-widgets-loader.js +1 -0
  72. package/fu-widgets.es.js +4 -0
  73. package/fu-widgets.iife.js +621 -682
  74. package/manifest.json +84 -0
  75. package/package.json +9 -2
@@ -0,0 +1,751 @@
1
+ import { j as e, B as h, t as C, r as a, a as W, f as q, C as ne } from "./main-XP7dqk6g.js";
2
+ import { B as U, T as w } from "./Button-BV7YIFkS.js";
3
+ import { C as K } from "./Card-DRIT0wtY.js";
4
+ import { G as D } from "./Grid-Dpv_ZL23.js";
5
+ import { S as te } from "./Snackbar-DHxnbCA3.js";
6
+ import { c as V } from "./createSvgIcon-DVA0KIUd.js";
7
+ import { C as ie, a as ae } from "./ChevronRight-BrCKlr3T.js";
8
+ import { I as ce } from "./IconButton-Lt9Xks7c.js";
9
+ import { A as le } from "./Alert-CuOsmojH.js";
10
+ const de = V(/* @__PURE__ */ e.jsx("path", {
11
+ d: "M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"
12
+ }), "CheckCircleOutline"), ue = V(/* @__PURE__ */ e.jsx("path", {
13
+ d: "M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"
14
+ }), "KeyboardArrowDown"), xe = V(/* @__PURE__ */ e.jsx("path", {
15
+ d: "M7.41 15.41 12 10.83l4.59 4.58L18 14l-6-6-6 6z"
16
+ }), "KeyboardArrowUp"), b = {
17
+ // Main card styles
18
+ card: {
19
+ borderColor: "divider",
20
+ backgroundRepeat: "no-repeat",
21
+ backgroundSize: "cover",
22
+ backgroundPosition: "center",
23
+ "&:hover": { borderColor: "divider" },
24
+ p: 2.5
25
+ },
26
+ // Prediction button styles
27
+ predictionButton: {
28
+ base: (t, r, s) => {
29
+ const n = r ? t.palette.primary[500] : "transparent", l = t.palette.text.primary;
30
+ return {
31
+ width: "100%",
32
+ height: "100px",
33
+ display: "flex",
34
+ flexDirection: "column",
35
+ justifyContent: "center",
36
+ alignItems: "center",
37
+ backgroundColor: n,
38
+ border: r ? "none !important" : "1px solid " + t.palette.primary.outlinedBorder + " !important",
39
+ color: l,
40
+ "& .MuiTypography-root": {
41
+ color: l
42
+ },
43
+ "&:hover": {
44
+ backgroundColor: s ? void 0 : t.palette.primary[500]
45
+ }
46
+ };
47
+ }
48
+ },
49
+ // Team logo container
50
+ teamLogoContainer: {
51
+ width: 64,
52
+ height: 64,
53
+ display: "flex",
54
+ justifyContent: "center",
55
+ alignItems: "center",
56
+ borderRadius: "50%",
57
+ // backgroundColor: "neutral.softBg",
58
+ padding: "4px"
59
+ },
60
+ // Team logo image
61
+ teamLogoImage: {
62
+ width: 64,
63
+ height: 64,
64
+ objectFit: "contain"
65
+ },
66
+ // Progress bar container
67
+ progressContainer: {
68
+ mt: 1
69
+ },
70
+ // Progress bar track
71
+ progressTrack: {
72
+ height: 8,
73
+ width: "100%",
74
+ backgroundColor: "primary.outlinedColor",
75
+ borderRadius: 4,
76
+ overflow: "hidden",
77
+ mb: 0.5
78
+ },
79
+ // Progress bar indicator
80
+ progressIndicator: (t, r) => ({
81
+ height: "100%",
82
+ width: `${r}%`,
83
+ backgroundColor: t ? "primary.500" : "primary.outlinedColor",
84
+ transition: "width 0.4s ease-in-out"
85
+ })
86
+ }, g = {
87
+ // Main card styles
88
+ card: {
89
+ p: 2,
90
+ display: "flex",
91
+ flexDirection: "column",
92
+ gap: 2,
93
+ backgroundRepeat: "no-repeat",
94
+ backgroundSize: "cover",
95
+ backgroundPosition: "center",
96
+ borderRadius: "md",
97
+ // boxShadow: "sm",
98
+ border: "1px solid",
99
+ borderColor: "divider",
100
+ "&:hover": { borderColor: "divider" },
101
+ "&:active": { borderColor: "divider" }
102
+ },
103
+ // Title styles
104
+ title: {
105
+ textAlign: "center"
106
+ },
107
+ // Desktop layout container
108
+ desktopContainer: {
109
+ display: { xs: "none", sm: "flex" },
110
+ alignItems: "center",
111
+ justifyContent: "space-between",
112
+ gap: 2
113
+ },
114
+ // Mobile layout container
115
+ mobileContainer: {
116
+ display: { xs: "flex", sm: "none" },
117
+ flexDirection: "column",
118
+ gap: 1.5
119
+ },
120
+ // Mobile row container
121
+ mobileRow: {
122
+ display: "flex",
123
+ justifyContent: "space-between",
124
+ alignItems: "center"
125
+ },
126
+ // Team display container
127
+ teamDisplay: {
128
+ base: {
129
+ display: "flex",
130
+ alignItems: "center",
131
+ gap: 1.5,
132
+ flex: 1,
133
+ minWidth: 0
134
+ },
135
+ homeDesktop: {
136
+ justifyContent: "flex-start"
137
+ },
138
+ awayDesktop: {
139
+ flexDirection: "row-reverse",
140
+ textAlign: "right"
141
+ }
142
+ },
143
+ // Team logo
144
+ teamLogo: {
145
+ width: { xs: 32, sm: 48, md: 64 },
146
+ height: { xs: 32, sm: 48, md: 64 },
147
+ objectFit: "contain"
148
+ },
149
+ // Team name
150
+ teamName: {
151
+ fontWeight: 600,
152
+ color: "text.primary",
153
+ overflow: "hidden",
154
+ textOverflow: "ellipsis",
155
+ whiteSpace: "nowrap"
156
+ },
157
+ // Score controls container
158
+ scoreControlsContainer: {
159
+ display: "flex",
160
+ alignItems: "center",
161
+ gap: 1.5,
162
+ flexShrink: 0
163
+ },
164
+ // Score input container
165
+ scoreInputContainer: {
166
+ horizontal: {
167
+ display: "flex",
168
+ alignItems: "center",
169
+ gap: 0.5
170
+ },
171
+ vertical: {
172
+ display: "flex",
173
+ alignItems: "center",
174
+ gap: 1
175
+ },
176
+ verticalInner: {
177
+ display: "flex",
178
+ flexDirection: "column"
179
+ }
180
+ },
181
+ // Score display
182
+ scoreDisplay: {
183
+ fontWeight: 700,
184
+ minWidth: "44px",
185
+ textAlign: "center",
186
+ userSelect: "none",
187
+ bgcolor: "white",
188
+ borderRadius: "sm",
189
+ px: 1.5,
190
+ height: "48px",
191
+ display: "flex",
192
+ alignItems: "center",
193
+ justifyContent: "center",
194
+ color: "neutral.700"
195
+ },
196
+ // Score separator
197
+ scoreSeparator: {
198
+ color: "neutral.400",
199
+ userSelect: "none"
200
+ },
201
+ // Submit button
202
+ submitButton: {
203
+ mt: 1,
204
+ width: { xs: "100%", sm: "auto" },
205
+ alignSelf: { sm: "center" },
206
+ "&:disabled": {
207
+ bgcolor: "primary.50"
208
+ }
209
+ },
210
+ // Error alert
211
+ errorAlert: {
212
+ mt: 1
213
+ }
214
+ }, re = (t, r) => r === 0 ? 0 : Math.round(t / r * 100), X = ({
215
+ type: t,
216
+ isSelected: r,
217
+ isPredictionMade: s,
218
+ isLoading: n,
219
+ predictionCount: l,
220
+ totalPredictions: c,
221
+ onClick: f,
222
+ teamName: x,
223
+ teamLogo: p
224
+ }) => {
225
+ const m = re(l, c), y = t === "x";
226
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
227
+ /* @__PURE__ */ e.jsx(
228
+ U,
229
+ {
230
+ variant: "outlined",
231
+ color: "primary",
232
+ onClick: () => !s && f(t),
233
+ disabled: n || s,
234
+ sx: (i) => b.predictionButton.base(i, r, s),
235
+ children: y ? (
236
+ // Draw button content
237
+ /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
238
+ /* @__PURE__ */ e.jsx(h, { sx: b.teamLogoContainer, children: /* @__PURE__ */ e.jsx(w, { level: "h3", textColor: "text.primary", sx: { fontWeight: "bold" }, children: "X" }) }),
239
+ /* @__PURE__ */ e.jsx(w, { level: "body-sm", textColor: "text.primary", children: C("predictions.draw") })
240
+ ] })
241
+ ) : (
242
+ // Team button content
243
+ /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
244
+ p && /* @__PURE__ */ e.jsx(h, { sx: b.teamLogoContainer, children: /* @__PURE__ */ e.jsx("img", { src: p, alt: x || "", style: b.teamLogoImage }) }),
245
+ /* @__PURE__ */ e.jsx(w, { level: "body-sm", textColor: "text.primary", children: x || "" })
246
+ ] })
247
+ )
248
+ }
249
+ ),
250
+ s && /* @__PURE__ */ e.jsxs(h, { sx: b.progressContainer, children: [
251
+ /* @__PURE__ */ e.jsx(h, { sx: b.progressTrack, children: /* @__PURE__ */ e.jsx(h, { sx: b.progressIndicator(r, m) }) }),
252
+ /* @__PURE__ */ e.jsxs(w, { level: "body-xs", textAlign: "center", textColor: "text.secondary", children: [
253
+ m,
254
+ "% (",
255
+ l,
256
+ ")"
257
+ ] })
258
+ ] })
259
+ ] });
260
+ }, oe = (t, r, s) => {
261
+ const [n, l] = a.useState({
262
+ 1: 0,
263
+ x: 0,
264
+ 2: 0,
265
+ total: 0
266
+ }), [c, f] = a.useState(!1), [x, p] = a.useState(null), m = async () => {
267
+ try {
268
+ const i = await t.predictor.getMarketSummary(r, s);
269
+ if (i && i.fullTimeOneXTwo) {
270
+ const { "1": o, x: d, "2": u } = i.fullTimeOneXTwo, S = o + d + u;
271
+ l({
272
+ 1: o,
273
+ x: d,
274
+ 2: u,
275
+ total: S
276
+ });
277
+ }
278
+ p(null);
279
+ } catch (i) {
280
+ console.error("Error fetching market summary:", i), p(i instanceof Error ? i : new Error("Failed to fetch market summary"));
281
+ }
282
+ }, y = async (i) => {
283
+ f(!0);
284
+ try {
285
+ return await t.predictor.makeFootballPrediction(r, s, i), l((o) => {
286
+ const d = { ...o };
287
+ return d[i] += 1, d.total += 1, d;
288
+ }), p(null), !0;
289
+ } catch (o) {
290
+ return console.error("Error making prediction:", o), p(o instanceof Error ? o : new Error("Failed to make prediction")), !1;
291
+ } finally {
292
+ f(!1);
293
+ }
294
+ };
295
+ return a.useEffect(() => {
296
+ r && m();
297
+ }, [r]), {
298
+ predictionStats: n,
299
+ isLoading: c,
300
+ error: x,
301
+ makePrediction: y,
302
+ refreshSummary: m
303
+ };
304
+ }, pe = ({ match: t, market: r, title: s }) => {
305
+ var A, E, O, T, B, z;
306
+ const n = W(), { defaultImagePlaceholderUrl: l } = q(), [c, f] = a.useState(null), [x, p] = a.useState(!1), [m, y] = a.useState(!1), { predictionStats: i, isLoading: o, makePrediction: d } = oe(n, t.id, r), u = async (H) => {
307
+ f(H), await d(H) && (p(!0), y(!0), setTimeout(() => {
308
+ y(!1);
309
+ }, 3e3));
310
+ }, S = s || (r === "HT_1X2" ? C("predictions.question_ht_1x2") : C("predictions.question_ft_1x2"));
311
+ return /* @__PURE__ */ e.jsxs(K, { sx: { ...b.card, backgroundImage: l ? `url(${l})` : "none" }, children: [
312
+ /* @__PURE__ */ e.jsx(w, { level: "h4", textAlign: "center", children: S }),
313
+ /* @__PURE__ */ e.jsxs(D, { container: !0, spacing: 1, sx: { justifyContent: "center" }, children: [
314
+ /* @__PURE__ */ e.jsx(D, { xs: 4, children: /* @__PURE__ */ e.jsx(
315
+ X,
316
+ {
317
+ type: "1",
318
+ isSelected: c === "1",
319
+ isPredictionMade: x,
320
+ isLoading: o,
321
+ predictionCount: i[1],
322
+ totalPredictions: i.total,
323
+ onClick: u,
324
+ teamName: ((A = t.homeTeam) == null ? void 0 : A.name) || "",
325
+ teamLogo: (O = (E = t.homeTeam) == null ? void 0 : E.assets) == null ? void 0 : O.logo
326
+ }
327
+ ) }),
328
+ /* @__PURE__ */ e.jsx(D, { xs: 4, children: /* @__PURE__ */ e.jsx(
329
+ X,
330
+ {
331
+ type: "x",
332
+ isSelected: c === "x",
333
+ isPredictionMade: x,
334
+ isLoading: o,
335
+ predictionCount: i.x,
336
+ totalPredictions: i.total,
337
+ onClick: u
338
+ }
339
+ ) }),
340
+ /* @__PURE__ */ e.jsx(D, { xs: 4, children: /* @__PURE__ */ e.jsx(
341
+ X,
342
+ {
343
+ type: "2",
344
+ isSelected: c === "2",
345
+ isPredictionMade: x,
346
+ isLoading: o,
347
+ predictionCount: i[2],
348
+ totalPredictions: i.total,
349
+ onClick: u,
350
+ teamName: ((T = t.awayTeam) == null ? void 0 : T.name) || "",
351
+ teamLogo: (z = (B = t.awayTeam) == null ? void 0 : B.assets) == null ? void 0 : z.logo
352
+ }
353
+ ) })
354
+ ] }),
355
+ /* @__PURE__ */ e.jsx(
356
+ te,
357
+ {
358
+ open: m,
359
+ anchorOrigin: { vertical: "top", horizontal: "center" },
360
+ autoHideDuration: 3e3,
361
+ color: "success",
362
+ onClose: () => y(!1),
363
+ children: C("predictions.success_message")
364
+ }
365
+ )
366
+ ] });
367
+ }, N = a.memo(({ score: t, onIncrement: r, onDecrement: s, isLoading: n, layout: l }) => {
368
+ const c = (x) => /* @__PURE__ */ e.jsx(ce, { size: "sm", variant: "solid", color: "primary", ...x }), f = /* @__PURE__ */ e.jsx(w, { level: "h3", sx: g.scoreDisplay, children: t });
369
+ return l === "horizontal" ? /* @__PURE__ */ e.jsxs(h, { sx: g.scoreInputContainer.horizontal, children: [
370
+ /* @__PURE__ */ e.jsx(
371
+ c,
372
+ {
373
+ onClick: s,
374
+ disabled: n || t <= 0,
375
+ size: "md",
376
+ sx: {
377
+ p: 0.3,
378
+ minWidth: "34px",
379
+ height: "36px",
380
+ display: "flex",
381
+ alignItems: "center",
382
+ justifyContent: "center",
383
+ "&:disabled": {
384
+ bgcolor: "primary.200"
385
+ }
386
+ },
387
+ children: /* @__PURE__ */ e.jsx(ie, {})
388
+ }
389
+ ),
390
+ f,
391
+ /* @__PURE__ */ e.jsx(
392
+ c,
393
+ {
394
+ onClick: r,
395
+ disabled: n || t >= 99,
396
+ size: "md",
397
+ sx: {
398
+ p: 0.3,
399
+ minWidth: "34px",
400
+ height: "36px",
401
+ display: "flex",
402
+ alignItems: "center",
403
+ justifyContent: "center",
404
+ "&:disabled": {
405
+ bgcolor: "primary.200"
406
+ }
407
+ },
408
+ children: /* @__PURE__ */ e.jsx(ae, {})
409
+ }
410
+ )
411
+ ] }) : /* @__PURE__ */ e.jsx(h, { sx: g.scoreInputContainer.vertical, children: /* @__PURE__ */ e.jsxs(h, { sx: g.scoreInputContainer.verticalInner, children: [
412
+ /* @__PURE__ */ e.jsx(
413
+ c,
414
+ {
415
+ onClick: r,
416
+ disabled: n || t >= 99,
417
+ sx: {
418
+ p: 0.3,
419
+ mb: 0.5,
420
+ "&:disabled": {
421
+ bgcolor: "primary.200"
422
+ }
423
+ },
424
+ children: /* @__PURE__ */ e.jsx(xe, {})
425
+ }
426
+ ),
427
+ f,
428
+ /* @__PURE__ */ e.jsx(
429
+ c,
430
+ {
431
+ onClick: s,
432
+ disabled: n || t <= 0,
433
+ sx: {
434
+ p: 0.3,
435
+ mt: 0.5,
436
+ "&:disabled": {
437
+ bgcolor: "primary.200"
438
+ }
439
+ },
440
+ children: /* @__PURE__ */ e.jsx(ue, {})
441
+ }
442
+ )
443
+ ] }) });
444
+ });
445
+ N.displayName = "ScoreInput";
446
+ const F = a.memo(({ team: t, sx: r }) => {
447
+ var s;
448
+ return /* @__PURE__ */ e.jsxs(h, { sx: { ...g.teamDisplay.base, ...r }, children: [
449
+ ((s = t == null ? void 0 : t.assets) == null ? void 0 : s.logo) && /* @__PURE__ */ e.jsx(h, { component: "img", src: t.assets.logo, alt: t.name, sx: g.teamLogo }),
450
+ /* @__PURE__ */ e.jsx(w, { level: "title-md", sx: g.teamName, children: (t == null ? void 0 : t.name) || "Team" })
451
+ ] });
452
+ });
453
+ F.displayName = "TeamDisplay";
454
+ const me = ({ match: t, market: r, title: s }) => {
455
+ const n = W(), { defaultImagePlaceholderUrl: l } = q(), [c, f] = a.useState(0), [x, p] = a.useState(0), [m, y] = a.useState(!1), [i, o] = a.useState(!1), [d, u] = a.useState(!1), [S, A] = a.useState(!0), [E, O] = a.useState(null), { isLoading: T, makePrediction: B } = oe(n, t.id, r);
456
+ a.useEffect(() => {
457
+ const k = async () => {
458
+ var j, $, R;
459
+ try {
460
+ A(!0);
461
+ const _ = await n.predictor.getMyPredictionsForMatches([t.id]);
462
+ if (_ != null && _.data && _.data.length > 0) {
463
+ const P = _.data.find(
464
+ (M) => {
465
+ var v, L, G, J, Q, Z;
466
+ return ((L = (v = M.fixtures) == null ? void 0 : v[0]) == null ? void 0 : L.market) === r || // Handle market variations (e.g., CORRECT_SCORE_HT)
467
+ r === "CORRECT_SCORE_HT" && ((J = (G = M.fixtures) == null ? void 0 : G[0]) == null ? void 0 : J.market) === "CORRECT_SCORE_HT" || r === "CORRECT_SCORE_ADVANCED" && ((Z = (Q = M.fixtures) == null ? void 0 : Q[0]) == null ? void 0 : Z.market) === "CORRECT_SCORE_ADVANCED";
468
+ }
469
+ );
470
+ if ((R = ($ = (j = P == null ? void 0 : P.fixtures) == null ? void 0 : j[0]) == null ? void 0 : $.prediction) != null && R.value) {
471
+ const M = P.fixtures[0].prediction.value, [v, L] = M.split(":").map(Number);
472
+ !isNaN(v) && !isNaN(L) && (f(v), p(L), O(P.id));
473
+ }
474
+ }
475
+ } catch (_) {
476
+ console.error("Error fetching existing prediction:", _);
477
+ } finally {
478
+ A(!1);
479
+ }
480
+ };
481
+ n != null && n.predictor && (t != null && t.id) && k();
482
+ }, [n, t.id, r]);
483
+ const z = s || (r === "CORRECT_SCORE_HT" ? C("predictions.question_correct_score_ht") : C("predictions.question_correct_score")), H = async () => {
484
+ var k;
485
+ y(!0), u(!1);
486
+ try {
487
+ if (E)
488
+ try {
489
+ await n.predictor.deleteFootballPrediction(E);
490
+ } catch (R) {
491
+ console.error("Error deleting existing prediction:", R);
492
+ }
493
+ const j = `${c}:${x}`, $ = await B(j);
494
+ if (y(!1), $) {
495
+ if (o(!0), !E) {
496
+ const R = await n.predictor.getMyPredictionsForMatches([t.id]), _ = (k = R == null ? void 0 : R.data) == null ? void 0 : k.find((P) => {
497
+ var M, v;
498
+ return ((v = (M = P.fixtures) == null ? void 0 : M[0]) == null ? void 0 : v.market) === r;
499
+ });
500
+ _ && O(_.id);
501
+ }
502
+ setTimeout(() => o(!1), 3e3);
503
+ } else
504
+ u(!0), setTimeout(() => u(!1), 3e3);
505
+ } catch {
506
+ y(!1), u(!0), setTimeout(() => u(!1), 3e3);
507
+ }
508
+ }, I = (k) => {
509
+ k === "home" ? f((j) => Math.min(j + 1, 99)) : p((j) => Math.min(j + 1, 99)), o(!1);
510
+ }, Y = (k) => {
511
+ k === "home" ? f((j) => Math.max(j - 1, 0)) : p((j) => Math.max(j - 1, 0)), o(!1);
512
+ }, se = i ? C("predictions.success_message", "Prediction accepted") : E ? C("predictions.update_prediction", "Update prediction") : C("predictions.make_prediction", "Submit prediction");
513
+ return /* @__PURE__ */ e.jsxs(K, { sx: { ...g.card, backgroundImage: l ? `url(${l})` : "none" }, children: [
514
+ /* @__PURE__ */ e.jsx(w, { level: "h4", sx: g.title, children: z }),
515
+ /* @__PURE__ */ e.jsxs(h, { sx: g.desktopContainer, children: [
516
+ /* @__PURE__ */ e.jsx(F, { team: t.homeTeam, sx: g.teamDisplay.homeDesktop }),
517
+ /* @__PURE__ */ e.jsxs(h, { sx: g.scoreControlsContainer, children: [
518
+ /* @__PURE__ */ e.jsx(
519
+ N,
520
+ {
521
+ score: c,
522
+ onIncrement: () => I("home"),
523
+ onDecrement: () => Y("home"),
524
+ isLoading: T || m || S,
525
+ layout: "vertical"
526
+ }
527
+ ),
528
+ /* @__PURE__ */ e.jsx(w, { level: "h3", sx: g.scoreSeparator, children: ":" }),
529
+ /* @__PURE__ */ e.jsx(
530
+ N,
531
+ {
532
+ score: x,
533
+ onIncrement: () => I("away"),
534
+ onDecrement: () => Y("away"),
535
+ isLoading: T || m || S,
536
+ layout: "vertical"
537
+ }
538
+ )
539
+ ] }),
540
+ /* @__PURE__ */ e.jsx(F, { team: t.awayTeam, sx: g.teamDisplay.awayDesktop })
541
+ ] }),
542
+ /* @__PURE__ */ e.jsxs(h, { sx: g.mobileContainer, children: [
543
+ /* @__PURE__ */ e.jsxs(h, { sx: g.mobileRow, children: [
544
+ /* @__PURE__ */ e.jsx(F, { team: t.homeTeam }),
545
+ /* @__PURE__ */ e.jsx(
546
+ N,
547
+ {
548
+ score: c,
549
+ onIncrement: () => I("home"),
550
+ onDecrement: () => Y("home"),
551
+ isLoading: T || m || S,
552
+ layout: "horizontal"
553
+ }
554
+ )
555
+ ] }),
556
+ /* @__PURE__ */ e.jsxs(h, { sx: g.mobileRow, children: [
557
+ /* @__PURE__ */ e.jsx(F, { team: t.awayTeam }),
558
+ /* @__PURE__ */ e.jsx(
559
+ N,
560
+ {
561
+ score: x,
562
+ onIncrement: () => I("away"),
563
+ onDecrement: () => Y("away"),
564
+ isLoading: T || m || S,
565
+ layout: "horizontal"
566
+ }
567
+ )
568
+ ] })
569
+ ] }),
570
+ /* @__PURE__ */ e.jsx(
571
+ U,
572
+ {
573
+ onClick: H,
574
+ loading: m || S,
575
+ disabled: T,
576
+ color: i ? "success" : "primary",
577
+ variant: "solid",
578
+ startDecorator: i ? /* @__PURE__ */ e.jsx(de, {}) : void 0,
579
+ sx: g.submitButton,
580
+ children: se
581
+ }
582
+ ),
583
+ d && /* @__PURE__ */ e.jsx(le, { variant: "soft", color: "danger", sx: g.errorAlert, children: C("predictions.error_message", "Failed to submit prediction. Please try again.") })
584
+ ] });
585
+ }, ee = ({
586
+ type: t,
587
+ isSelected: r,
588
+ isPredictionMade: s,
589
+ isLoading: n,
590
+ predictionCount: l,
591
+ totalPredictions: c,
592
+ onClick: f
593
+ }) => {
594
+ const x = re(l, c);
595
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
596
+ /* @__PURE__ */ e.jsx(
597
+ U,
598
+ {
599
+ variant: "outlined",
600
+ color: "primary",
601
+ onClick: () => !s && f(),
602
+ disabled: n || s,
603
+ sx: (p) => ({
604
+ ...b.predictionButton.base(p, r, s),
605
+ height: "auto"
606
+ }),
607
+ children: /* @__PURE__ */ e.jsx(w, { level: "body-sm", textColor: "text.primary", children: t === "yes" ? C("predictions.yes") : C("predictions.no") })
608
+ }
609
+ ),
610
+ s && /* @__PURE__ */ e.jsxs(h, { sx: b.progressContainer, children: [
611
+ /* @__PURE__ */ e.jsx(h, { sx: b.progressTrack, children: /* @__PURE__ */ e.jsx(h, { sx: b.progressIndicator(r, x) }) }),
612
+ /* @__PURE__ */ e.jsxs(w, { level: "body-xs", textAlign: "center", textColor: "text.secondary", children: [
613
+ x,
614
+ "% (",
615
+ l,
616
+ ")"
617
+ ] })
618
+ ] })
619
+ ] });
620
+ }, fe = (t, r, s, n) => {
621
+ const [l, c] = a.useState({
622
+ yes: 0,
623
+ no: 0,
624
+ total: 0
625
+ }), [f, x] = a.useState(!1), [p, m] = a.useState(null), y = async () => {
626
+ try {
627
+ const o = n ? (
628
+ // @ts-expect-error - market is not assignable to type 'MarketType'
629
+ await t.predictor.getMarketSummary(r, s, n)
630
+ ) : (
631
+ // @ts-expect-error - market is not assignable to type 'MarketType'
632
+ await t.predictor.getMarketSummary(r, s)
633
+ );
634
+ if (o) {
635
+ let d = 0, u = 0;
636
+ o.bothTeamsScore ? (d = o.bothTeamsScore.yes, u = o.bothTeamsScore.no) : o.penaltyMatch ? (d = o.penaltyMatch.yes, u = o.penaltyMatch.no) : o.redCardMatch ? (d = o.redCardMatch.yes, u = o.redCardMatch.no) : n && o.yes !== void 0 && o.no !== void 0 && (d = o.yes, u = o.no);
637
+ const S = d + u;
638
+ c({
639
+ yes: d,
640
+ no: u,
641
+ total: S
642
+ });
643
+ }
644
+ m(null);
645
+ } catch (o) {
646
+ console.error("Error fetching market summary:", o), m(o instanceof Error ? o : new Error("Failed to fetch market summary"));
647
+ }
648
+ }, i = async (o) => {
649
+ x(!0);
650
+ try {
651
+ return n && ["PLAYER_SCORE", "PLAYER_YELLOW_CARD", "PLAYER_RED_CARD"].includes(s) ? await t.predictor.makeFootballPrediction(r, s, o, n) : await t.predictor.makeFootballPrediction(r, s, o), c((d) => {
652
+ const u = { ...d };
653
+ return o ? u.yes += 1 : u.no += 1, u.total += 1, u;
654
+ }), m(null), !0;
655
+ } catch (d) {
656
+ return console.error("Error making prediction:", d), m(d instanceof Error ? d : new Error("Failed to make prediction")), !1;
657
+ } finally {
658
+ x(!1);
659
+ }
660
+ };
661
+ return a.useEffect(() => {
662
+ r && y();
663
+ }, [r, n]), {
664
+ predictionStats: l,
665
+ isLoading: f,
666
+ error: p,
667
+ makePrediction: i,
668
+ refreshSummary: y
669
+ };
670
+ }, he = ({ match: t, market: r, title: s, playerId: n }) => {
671
+ const l = W(), { defaultImagePlaceholderUrl: c } = q(), [f, x] = a.useState(null), [p, m] = a.useState(!1), [y, i] = a.useState(!1), { predictionStats: o, isLoading: d, makePrediction: u } = fe(l, t.id, r, n), S = async (E) => {
672
+ x(E), await u(E) && (m(!0), i(!0), setTimeout(() => {
673
+ i(!1);
674
+ }, 3e3));
675
+ }, A = () => {
676
+ if (s) return s;
677
+ switch (r) {
678
+ case "BOTH_TEAMS_SCORE":
679
+ return C("predictions.question_both_teams_score");
680
+ case "PENALTY_MATCH":
681
+ return C("predictions.question_penalty_match");
682
+ case "RED_CARD_MATCH":
683
+ return C("predictions.question_red_card_match");
684
+ case "PLAYER_SCORE":
685
+ return C("predictions.question_player_score");
686
+ default:
687
+ return C("predictions.make_prediction");
688
+ }
689
+ };
690
+ return /* @__PURE__ */ e.jsxs(K, { sx: { ...b.card, backgroundImage: c ? `url(${c})` : "none" }, children: [
691
+ /* @__PURE__ */ e.jsx(w, { level: "h4", textAlign: "center", children: A() }),
692
+ /* @__PURE__ */ e.jsxs(D, { container: !0, spacing: 1, sx: { justifyContent: "center" }, children: [
693
+ /* @__PURE__ */ e.jsx(D, { xs: 6, children: /* @__PURE__ */ e.jsx(
694
+ ee,
695
+ {
696
+ type: "yes",
697
+ isSelected: f === !0,
698
+ isPredictionMade: p,
699
+ isLoading: d,
700
+ predictionCount: o.yes,
701
+ totalPredictions: o.total,
702
+ onClick: () => S(!0)
703
+ }
704
+ ) }),
705
+ /* @__PURE__ */ e.jsx(D, { xs: 6, children: /* @__PURE__ */ e.jsx(
706
+ ee,
707
+ {
708
+ type: "no",
709
+ isSelected: f === !1,
710
+ isPredictionMade: p,
711
+ isLoading: d,
712
+ predictionCount: o.no,
713
+ totalPredictions: o.total,
714
+ onClick: () => S(!1)
715
+ }
716
+ ) })
717
+ ] }),
718
+ /* @__PURE__ */ e.jsx(
719
+ te,
720
+ {
721
+ open: y,
722
+ anchorOrigin: { vertical: "top", horizontal: "center" },
723
+ autoHideDuration: 3e3,
724
+ color: "success",
725
+ onClose: () => i(!1),
726
+ children: C("predictions.success_message")
727
+ }
728
+ )
729
+ ] });
730
+ }, ge = ["BOTH_TEAMS_SCORE", "PENALTY_MATCH", "RED_CARD_MATCH"], ye = ["FT_1X2", "HT_1X2"], Ce = ["CORRECT_SCORE", "CORRECT_SCORE_HT", "CORRECT_SCORE_ADVANCED"], Se = ({ match: t, market: r }) => {
731
+ const s = () => !t || !t.availableMarkets ? !1 : t.availableMarkets.includes(r), n = () => s() ? ye.includes(r) ? /* @__PURE__ */ e.jsx(pe, { match: t, market: r }) : ge.includes(r) ? /* @__PURE__ */ e.jsx(he, { match: t, market: r }) : Ce.includes(r) ? /* @__PURE__ */ e.jsx(me, { match: t, market: r }) : (console.warn(`Unsupported market type: ${r}`), null) : (console.warn(`Market ${r} is not available for match ${t.id}`), null);
732
+ return /* @__PURE__ */ e.jsx(h, { children: n() });
733
+ }, ve = ({ contentId: t, market: r, contentType: s }) => {
734
+ const [n, l] = a.useState(!0), [c, f] = a.useState(null), [x, p] = a.useState(!1), m = W(), y = async () => {
735
+ l(!0), p(!1);
736
+ try {
737
+ let i;
738
+ s === "match" ? i = await m.football.getMatchById(t) : i = await m.football.getNextMatchForTeam(t), f(i);
739
+ } catch (i) {
740
+ console.warn(`Error fetching ${s}:`, i), p(!0);
741
+ } finally {
742
+ l(!1);
743
+ }
744
+ };
745
+ return a.useEffect(() => {
746
+ y();
747
+ }, [t, s]), !c || x ? null : n ? /* @__PURE__ */ e.jsx(h, { sx: { display: "flex", justifyContent: "center", p: 4 }, children: /* @__PURE__ */ e.jsx(ne, {}) }) : /* @__PURE__ */ e.jsx(Se, { match: c, market: r });
748
+ };
749
+ export {
750
+ ve as default
751
+ };