@pitvox/partner-react 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,74 +1,80 @@
1
- import { jsx as e, jsxs as l, Fragment as K } from "react/jsx-runtime";
2
- import { createContext as fe, useMemo as C, useContext as Ne, useState as L, useCallback as q } from "react";
3
- import { useQueryClient as H, QueryClient as be, QueryClientProvider as ye, useQuery as k, useMutation as ne } from "@tanstack/react-query";
4
- const j = fe(null), Ce = "https://cdn.pitvox.com", we = "https://pitvox.com";
5
- let V = null;
6
- function or({
7
- partnerSlug: r,
8
- cdnUrl: t = Ce,
9
- pitvoxUrl: n = we,
10
- getSteamId: a,
11
- onRegister: s,
1
+ import { jsx as r, jsxs as c, Fragment as G } from "react/jsx-runtime";
2
+ import { createContext as be, useMemo as C, useContext as ye, useState as M, useCallback as O } from "react";
3
+ import { useQueryClient as P, QueryClient as we, QueryClientProvider as Ce, useQuery as k, useMutation as _, useQueries as ke } from "@tanstack/react-query";
4
+ const W = be(null), Le = "https://cdn.pitvox.com", Re = "https://pitvox.com";
5
+ let K = null;
6
+ function kr({
7
+ partnerSlug: e,
8
+ cdnUrl: n = Le,
9
+ pitvoxUrl: s = Re,
10
+ getSteamId: t,
11
+ onRegister: a,
12
12
  onWithdraw: i,
13
- children: o
13
+ onFetchNotifications: o,
14
+ onMarkNotificationRead: d,
15
+ onMarkAllNotificationsRead: u,
16
+ children: l
14
17
  }) {
15
- const c = C(() => ({
16
- partnerSlug: r,
17
- cdnUrl: t.replace(/\/$/, ""),
18
- pitvoxUrl: n.replace(/\/$/, ""),
19
- getSteamId: a || (() => null),
20
- onRegister: s || null,
21
- onWithdraw: i || null
22
- }), [r, t, n, a, s, i]);
23
- let v = !1;
18
+ const m = C(() => ({
19
+ partnerSlug: e,
20
+ cdnUrl: n.replace(/\/$/, ""),
21
+ pitvoxUrl: s.replace(/\/$/, ""),
22
+ getSteamId: t || (() => null),
23
+ onRegister: a || null,
24
+ onWithdraw: i || null,
25
+ onFetchNotifications: o || null,
26
+ onMarkNotificationRead: d || null,
27
+ onMarkAllNotificationsRead: u || null
28
+ }), [e, n, s, t, a, i, o, d, u]);
29
+ let g = !1;
24
30
  try {
25
- H(), v = !0;
31
+ P(), g = !0;
26
32
  } catch {
27
- v = !1;
33
+ g = !1;
28
34
  }
29
- return v ? /* @__PURE__ */ e(j.Provider, { value: c, children: o }) : (V || (V = new be({
35
+ return g ? /* @__PURE__ */ r(W.Provider, { value: m, children: l }) : (K || (K = new we({
30
36
  defaultOptions: {
31
37
  queries: { staleTime: 6e4 }
32
38
  }
33
- })), /* @__PURE__ */ e(ye, { client: V, children: /* @__PURE__ */ e(j.Provider, { value: c, children: o }) }));
39
+ })), /* @__PURE__ */ r(Ce, { client: K, children: /* @__PURE__ */ r(W.Provider, { value: m, children: l }) }));
34
40
  }
35
- function y() {
36
- const r = Ne(j);
37
- if (!r)
41
+ function w() {
42
+ const e = ye(W);
43
+ if (!e)
38
44
  throw new Error("usePitVox must be used within a <PitVoxPartnerProvider>");
39
- return r;
45
+ return e;
40
46
  }
41
- async function T(r, t) {
42
- const n = await fetch(`${r}/${t}`);
43
- if (!n.ok) {
44
- if (n.status === 404 || n.status === 403) return null;
45
- throw new Error(`CDN fetch failed: ${n.status}`);
47
+ async function R(e, n) {
48
+ const s = await fetch(`${e}/${n}`);
49
+ if (!s.ok) {
50
+ if (s.status === 404 || s.status === 403) return null;
51
+ throw new Error(`CDN fetch failed: ${s.status}`);
46
52
  }
47
- return n.json();
53
+ return s.json();
48
54
  }
49
- function B(r) {
50
- if (!r && r !== 0) return "-";
51
- const t = Math.floor(r / 1e3), n = Math.floor(t / 60), a = t % 60, s = r % 1e3;
52
- return `${n}:${String(a).padStart(2, "0")}.${String(s).padStart(3, "0")}`;
55
+ function U(e) {
56
+ if (!e && e !== 0) return "-";
57
+ const n = Math.floor(e / 1e3), s = Math.floor(n / 60), t = n % 60, a = e % 1e3;
58
+ return `${s}:${String(t).padStart(2, "0")}.${String(a).padStart(3, "0")}`;
53
59
  }
54
- function $(r) {
55
- return !r && r !== 0 ? "-" : (r / 1e3).toFixed(3);
60
+ function D(e) {
61
+ return !e && e !== 0 ? "-" : (e / 1e3).toFixed(3);
56
62
  }
57
- function R(r) {
58
- if (!r) return "";
59
- let t = r;
60
- return t.startsWith("ks_") && (t = t.slice(3)), t.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ");
63
+ function S(e) {
64
+ if (!e) return "";
65
+ let n = e;
66
+ return n.startsWith("ks_") && (n = n.slice(3)), n.split("_").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(" ");
61
67
  }
62
- function O(r, t, n) {
63
- const a = r.split("_").map((o) => o.charAt(0).toUpperCase() + o.slice(1)).join(" "), s = n === "acc" || !n && (t == null ? void 0 : t.toLowerCase()) === "track config";
64
- if (!t || t === "default" || s) return a;
65
- const i = t.split("_").map((o) => o.charAt(0).toUpperCase() + o.slice(1)).join(" ");
66
- return `${a} ${i}`;
68
+ function q(e, n, s) {
69
+ const t = e.split("_").map((o) => o.charAt(0).toUpperCase() + o.slice(1)).join(" "), a = s === "acc" || !s && (n == null ? void 0 : n.toLowerCase()) === "track config";
70
+ if (!n || n === "default" || a) return t;
71
+ const i = n.split("_").map((o) => o.charAt(0).toUpperCase() + o.slice(1)).join(" ");
72
+ return `${t} ${i}`;
67
73
  }
68
- function D(r) {
69
- if (!r) return "-";
74
+ function A(e) {
75
+ if (!e) return "-";
70
76
  try {
71
- return new Date(r).toLocaleDateString("en-GB", {
77
+ return new Date(e).toLocaleDateString("en-GB", {
72
78
  day: "numeric",
73
79
  month: "short",
74
80
  year: "numeric"
@@ -77,22 +83,26 @@ function D(r) {
77
83
  return "-";
78
84
  }
79
85
  }
80
- function cr(r) {
81
- if (!r) return "";
82
- const t = Date.now() - new Date(r).getTime(), n = Math.floor(t / 1e3);
83
- if (n < 60) return "Just now";
84
- const a = Math.floor(n / 60);
85
- if (a < 60) return `${a}m ago`;
86
- const s = Math.floor(a / 60);
87
- if (s < 24) return `${s}h ago`;
88
- const i = Math.floor(s / 24);
89
- return i < 30 ? `${i}d ago` : D(r);
90
- }
91
- function dr(r) {
92
- return r == null ? "" : `${r >= 0 ? "+" : "-"}${(Math.abs(r) / 1e3).toFixed(3)}`;
93
- }
94
- function se(r) {
95
- return r ? {
86
+ function ne(e) {
87
+ if (!e) return "";
88
+ const n = Date.now() - new Date(e).getTime(), s = Math.floor(n / 1e3);
89
+ if (s < 60) return "Just now";
90
+ const t = Math.floor(s / 60);
91
+ if (t < 60) return `${t}m ago`;
92
+ const a = Math.floor(t / 60);
93
+ if (a < 24) return `${a}h ago`;
94
+ const i = Math.floor(a / 24);
95
+ return i < 30 ? `${i}d ago` : A(e);
96
+ }
97
+ function Lr(e) {
98
+ return e == null ? "" : `${e >= 0 ? "+" : "-"}${(Math.abs(e) / 1e3).toFixed(3)}`;
99
+ }
100
+ function Te(e, n) {
101
+ const { type: s, title: t, trackId: a, trackLayout: i, carId: o, game: d, data: u } = e, l = a ? q(a, i, d) : null, m = o ? S(o) : null, g = [l, m].filter(Boolean).join(" — ");
102
+ return s === "RECORD_BEATEN" && g ? `${u != null && u.beatenBySteamId && n ? n(u.beatenBySteamId).displayName : "Someone"} beat your record on ${g}` : s === "RECORD_SET" && g ? `You set a new record on ${g}` : t || "New notification";
103
+ }
104
+ function se(e) {
105
+ return e ? {
96
106
  E: "Eco",
97
107
  RD: "Road",
98
108
  SC: "SuperCar",
@@ -103,251 +113,267 @@ function se(r) {
103
113
  MR: "Medium Race",
104
114
  SR: "Soft Race",
105
115
  S: "Soft"
106
- }[r] || r : "Unknown";
116
+ }[e] || e : "Unknown";
107
117
  }
108
- function pr(r = {}) {
109
- var c, v, d, u, b, x;
110
- const { cdnUrl: t, partnerSlug: n } = y(), { game: a, gameVersion: s } = r, i = k({
111
- queryKey: ["pitvox", "leaderboards", n, "index"],
112
- queryFn: () => T(t, `leaderboards/partners/${n}/index.json`),
118
+ function Rr(e = {}) {
119
+ var d, u, l, m, g, h;
120
+ const { cdnUrl: n, partnerSlug: s } = w(), { game: t, gameVersion: a } = e, i = k({
121
+ queryKey: ["pitvox", "leaderboards", s, "index"],
122
+ queryFn: () => R(n, `leaderboards/partners/${s}/index.json`),
113
123
  staleTime: 3e4,
114
124
  refetchInterval: 3e4
115
125
  }), o = C(() => {
116
- var g;
117
- if (!((g = i.data) != null && g.tracks)) return [];
118
- let m = i.data.tracks;
119
- return a && (m = m.filter((p) => p.game === a)), s && (m = m.filter((p) => p.gameVersion === s)), m.map((p) => ({
126
+ var b;
127
+ if (!((b = i.data) != null && b.tracks)) return [];
128
+ let f = i.data.tracks;
129
+ return t && (f = f.filter((p) => p.game === t)), a && (f = f.filter((p) => p.gameVersion === a)), f.map((p) => ({
120
130
  id: p.trackId,
121
131
  layout: p.layout,
122
132
  game: p.game,
123
133
  gameVersion: p.gameVersion,
124
- displayName: O(p.trackId, p.layout, p.game),
134
+ displayName: q(p.trackId, p.layout, p.game),
125
135
  driverCount: p.driverCount || 0,
126
136
  carCount: p.carCount || 0,
127
137
  record: p.recordHolder ? {
128
138
  visibleId: p.recordHolder.steamId || p.recordHolder.userId,
129
139
  carId: p.recordHolder.carId,
130
- carDisplayName: R(p.recordHolder.carId),
140
+ carDisplayName: S(p.recordHolder.carId),
131
141
  lapTimeMs: p.recordHolder.lapTimeMs,
132
142
  timestamp: p.recordHolder.recordedAt
133
143
  } : null,
134
144
  recordByTag: p.recordByTag || null
135
145
  }));
136
- }, [(c = i.data) == null ? void 0 : c.tracks, a, s]);
146
+ }, [(d = i.data) == null ? void 0 : d.tracks, t, a]);
137
147
  return {
138
148
  ...i,
139
149
  data: o,
140
- partner: ((v = i.data) == null ? void 0 : v.partner) || null,
141
- generatedAt: (d = i.data) == null ? void 0 : d.generatedAt,
142
- totalLaps: ((u = i.data) == null ? void 0 : u.totalLaps) || 0,
143
- totalUsers: ((b = i.data) == null ? void 0 : b.totalUsers) || 0,
144
- versions: ((x = i.data) == null ? void 0 : x.versions) || {}
150
+ partner: ((u = i.data) == null ? void 0 : u.partner) || null,
151
+ generatedAt: (l = i.data) == null ? void 0 : l.generatedAt,
152
+ totalLaps: ((m = i.data) == null ? void 0 : m.totalLaps) || 0,
153
+ totalUsers: ((g = i.data) == null ? void 0 : g.totalUsers) || 0,
154
+ versions: ((h = i.data) == null ? void 0 : h.versions) || {}
145
155
  };
146
156
  }
147
- function ke(r, t, n = {}) {
148
- const { cdnUrl: a, partnerSlug: s } = y(), { carId: i, game: o, gameVersion: c } = n, v = t || "default", d = c ? `leaderboards/partners/${s}/v/${c}/tracks/${r}/${v}.json` : `leaderboards/partners/${s}/tracks/${r}/${v}.json`, { data: u, isLoading: b, error: x } = k({
149
- queryKey: ["pitvox", "leaderboards", s, "track", r, v, c],
150
- queryFn: () => T(a, d),
151
- enabled: !!r,
157
+ function Se(e, n, s = {}) {
158
+ const { cdnUrl: t, partnerSlug: a } = w(), { carId: i, game: o, gameVersion: d } = s, u = n || "default", l = d ? `leaderboards/partners/${a}/v/${d}/tracks/${e}/${u}.json` : `leaderboards/partners/${a}/tracks/${e}/${u}.json`, { data: m, isLoading: g, error: h } = k({
159
+ queryKey: ["pitvox", "leaderboards", a, "track", e, u, d],
160
+ queryFn: () => R(t, l),
161
+ enabled: !!e,
152
162
  staleTime: 3e4,
153
163
  refetchInterval: 3e4
154
164
  });
155
165
  return { data: C(() => {
156
- if (!(u != null && u.entries)) return [];
157
- let g = u.entries;
158
- if (o && (g = g.filter((p) => p.game === o)), !i) {
159
- const p = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
160
- for (const h of g) {
161
- const N = h.steamId || h.userId;
162
- f.has(h.carId) || f.set(h.carId, /* @__PURE__ */ new Set()), f.get(h.carId).add(N), (!p.has(h.carId) || h.lapTimeMs < p.get(h.carId).lapTimeMs) && p.set(h.carId, h);
166
+ if (!(m != null && m.entries)) return [];
167
+ let b = m.entries;
168
+ if (o && (b = b.filter((p) => p.game === o)), !i) {
169
+ const p = /* @__PURE__ */ new Map(), N = /* @__PURE__ */ new Map();
170
+ for (const v of b) {
171
+ const x = v.steamId || v.userId;
172
+ N.has(v.carId) || N.set(v.carId, /* @__PURE__ */ new Set()), N.get(v.carId).add(x), (!p.has(v.carId) || v.lapTimeMs < p.get(v.carId).lapTimeMs) && p.set(v.carId, v);
163
173
  }
164
- return Array.from(p.values()).map((h) => {
165
- var N;
166
- return { ...h, driverCount: ((N = f.get(h.carId)) == null ? void 0 : N.size) || 0 };
167
- }).sort((h, N) => h.lapTimeMs - N.lapTimeMs);
174
+ return Array.from(p.values()).map((v) => {
175
+ var x;
176
+ return { ...v, driverCount: ((x = N.get(v.carId)) == null ? void 0 : x.size) || 0 };
177
+ }).sort((v, x) => v.lapTimeMs - x.lapTimeMs);
168
178
  }
169
- return g.filter((p) => p.carId === i).sort((p, f) => p.lapTimeMs - f.lapTimeMs);
170
- }, [u == null ? void 0 : u.entries, i, o]), isLoading: b, error: x };
171
- }
172
- function Te(r, t, n, a, s = {}) {
173
- var x, m;
174
- const { cdnUrl: i, partnerSlug: o } = y(), { showInvalid: c = !1, game: v, gameVersion: d } = s, u = k({
175
- queryKey: ["pitvox", "laps", o, r],
176
- queryFn: () => T(i, `laps/partners/${o}/${r}.json`),
177
- enabled: !!r,
179
+ return b.filter((p) => p.carId === i).sort((p, N) => p.lapTimeMs - N.lapTimeMs);
180
+ }, [m == null ? void 0 : m.entries, i, o]), isLoading: g, error: h };
181
+ }
182
+ function $e(e, n, s, t, a = {}) {
183
+ var h, f;
184
+ const { cdnUrl: i, partnerSlug: o } = w(), { showInvalid: d = !1, game: u, gameVersion: l } = a, m = k({
185
+ queryKey: ["pitvox", "laps", o, e],
186
+ queryFn: () => R(i, `laps/partners/${o}/${e}.json`),
187
+ enabled: !!e,
178
188
  staleTime: 3e4,
179
189
  refetchInterval: 3e4
180
- }), b = C(() => {
181
- var g;
182
- return (g = u.data) != null && g.laps ? u.data.laps.filter((p) => {
183
- if (p.trackId !== t) return !1;
184
- if (n) {
185
- if (p.trackLayout !== n) return !1;
190
+ }), g = C(() => {
191
+ var b;
192
+ return (b = m.data) != null && b.laps ? m.data.laps.filter((p) => {
193
+ if (p.trackId !== n) return !1;
194
+ if (s) {
195
+ if (p.trackLayout !== s) return !1;
186
196
  } else if (p.trackLayout && p.trackLayout !== "default") return !1;
187
- return !(p.carId !== a || v && p.game !== v || d && p.gameVersion !== d || !c && !p.isValid);
188
- }).sort((p, f) => p.lapTimeMs - f.lapTimeMs) : [];
189
- }, [(x = u.data) == null ? void 0 : x.laps, t, n, a, v, d, c]);
197
+ return !(p.carId !== t || u && p.game !== u || l && p.gameVersion !== l || !d && !p.isValid);
198
+ }).sort((p, N) => p.lapTimeMs - N.lapTimeMs) : [];
199
+ }, [(h = m.data) == null ? void 0 : h.laps, n, s, t, u, l, d]);
190
200
  return {
191
- ...u,
192
- data: b,
193
- driverName: ((m = u.data) == null ? void 0 : m.driverName) || "Driver"
201
+ ...m,
202
+ data: g,
203
+ driverName: ((f = m.data) == null ? void 0 : f.driverName) || "Driver"
194
204
  };
195
205
  }
196
- function vr() {
197
- const { cdnUrl: r } = y(), { data: t } = k({
206
+ function ae() {
207
+ const { cdnUrl: e } = w(), { data: n } = k({
198
208
  queryKey: ["pitvox", "users", "index"],
199
- queryFn: () => T(r, "users/index.json"),
209
+ queryFn: () => R(e, "users/index.json"),
200
210
  staleTime: 5 * 6e4,
201
211
  gcTime: 30 * 6e4
202
- }), n = (t == null ? void 0 : t.users) || {};
203
- return (a, s) => {
204
- const i = n[a];
212
+ }), s = (n == null ? void 0 : n.users) || {};
213
+ return (t, a) => {
214
+ const i = s[t];
205
215
  return {
206
- displayName: (i == null ? void 0 : i.displayName) || s || a || "Unknown",
216
+ displayName: (i == null ? void 0 : i.displayName) || a || t || "Unknown",
207
217
  avatarUrl: (i == null ? void 0 : i.avatarUrl) || null,
208
218
  affiliations: (i == null ? void 0 : i.affiliations) || []
209
219
  };
210
220
  };
211
221
  }
212
- function mr() {
213
- const { cdnUrl: r } = y(), { data: t } = k({
222
+ function Tr() {
223
+ const { cdnUrl: e } = w(), { data: n } = k({
214
224
  queryKey: ["pitvox", "cars", "index"],
215
- queryFn: () => T(r, "cars/index.json"),
225
+ queryFn: () => R(e, "cars/index.json"),
216
226
  staleTime: 5 * 6e4,
217
227
  gcTime: 30 * 6e4
218
228
  });
219
229
  return {
220
- tags: (t == null ? void 0 : t.tags) || [],
221
- cars: (t == null ? void 0 : t.cars) || {}
230
+ tags: (n == null ? void 0 : n.tags) || [],
231
+ cars: (n == null ? void 0 : n.cars) || {}
222
232
  };
223
233
  }
224
- function hr(r, t) {
225
- return ke(r, null, { carId: t });
234
+ function Sr(e, n) {
235
+ return Se(e, null, { carId: n });
226
236
  }
227
- function ur() {
228
- const { cdnUrl: r, partnerSlug: t } = y();
237
+ function $r() {
238
+ const { cdnUrl: e, partnerSlug: n } = w();
229
239
  return k({
230
- queryKey: ["pitvox", "competitions", t],
240
+ queryKey: ["pitvox", "competitions", n],
231
241
  queryFn: async () => {
232
- const n = await T(r, "competitions/index.json");
233
- return n != null && n.competitions ? n.competitions.filter((a) => a.partnerSlug === t) : [];
242
+ const s = await R(e, "competitions/index.json");
243
+ return s != null && s.competitions ? s.competitions.filter((t) => t.partnerSlug === n) : [];
234
244
  },
235
245
  staleTime: 6e4
236
246
  });
237
247
  }
238
- function Se(r) {
239
- const { cdnUrl: t, partnerSlug: n } = y();
248
+ function Me(e) {
249
+ const { cdnUrl: n, partnerSlug: s } = w();
240
250
  return k({
241
- queryKey: ["pitvox", "competition", n, r, "config"],
242
- queryFn: () => T(t, `competitions/${n}/${r}/config.json`),
243
- enabled: !!r,
251
+ queryKey: ["pitvox", "competition", s, e, "config"],
252
+ queryFn: () => R(n, `competitions/${s}/${e}/config.json`),
253
+ enabled: !!e,
244
254
  staleTime: 6e4
245
255
  });
246
256
  }
247
- function Re(r) {
248
- const { cdnUrl: t, partnerSlug: n } = y();
257
+ function De(e) {
258
+ const { cdnUrl: n, partnerSlug: s } = w();
249
259
  return k({
250
- queryKey: ["pitvox", "competition", n, r, "standings"],
251
- queryFn: () => T(t, `competitions/${n}/${r}/standings.json`),
252
- enabled: !!r,
260
+ queryKey: ["pitvox", "competition", s, e, "standings"],
261
+ queryFn: () => R(n, `competitions/${s}/${e}/standings.json`),
262
+ enabled: !!e,
253
263
  staleTime: 6e4
254
264
  });
255
265
  }
256
- function Le(r, t) {
257
- const { cdnUrl: n, partnerSlug: a } = y();
266
+ function Ie(e, n) {
267
+ const { cdnUrl: s, partnerSlug: t } = w();
258
268
  return k({
259
- queryKey: ["pitvox", "competition", a, r, "round", t],
260
- queryFn: () => T(n, `competitions/${a}/${r}/rounds/${t}.json`),
261
- enabled: !!r && t != null,
269
+ queryKey: ["pitvox", "competition", t, e, "round", n],
270
+ queryFn: () => R(s, `competitions/${t}/${e}/rounds/${n}.json`),
271
+ enabled: !!e && n != null,
262
272
  staleTime: 6e4
263
273
  });
264
274
  }
265
- function xr(r, t = []) {
266
- const { cdnUrl: n, partnerSlug: a } = y();
275
+ function Mr(e, n = []) {
276
+ const { cdnUrl: s, partnerSlug: t } = w();
267
277
  return k({
268
- queryKey: ["pitvox", "competition", a, r, "allRounds", t],
278
+ queryKey: ["pitvox", "competition", t, e, "allRounds", n],
269
279
  queryFn: async () => (await Promise.all(
270
- t.map(
271
- (i) => T(n, `competitions/${a}/${r}/rounds/${i}.json`).catch(() => null)
280
+ n.map(
281
+ (i) => R(s, `competitions/${t}/${e}/rounds/${i}.json`).catch(() => null)
272
282
  )
273
283
  )).filter(Boolean),
274
- enabled: !!r && t.length > 0,
284
+ enabled: !!e && n.length > 0,
275
285
  staleTime: 6e4
276
286
  });
277
287
  }
278
- function ae(r) {
279
- const { cdnUrl: t, partnerSlug: n } = y();
288
+ function ie(e) {
289
+ const { cdnUrl: n, partnerSlug: s } = w();
280
290
  return k({
281
- queryKey: ["pitvox", "competition", n, r, "entrylist"],
282
- queryFn: () => T(t, `competitions/${n}/${r}/entrylist.json`),
283
- enabled: !!r,
291
+ queryKey: ["pitvox", "competition", s, e, "entrylist"],
292
+ queryFn: () => R(n, `competitions/${s}/${e}/entrylist.json`),
293
+ enabled: !!e,
284
294
  staleTime: 6e4
285
295
  });
286
296
  }
287
- function W(r) {
288
- const { cdnUrl: t, partnerSlug: n, getSteamId: a } = y(), s = a();
297
+ function z(e) {
298
+ const { cdnUrl: n, partnerSlug: s, getSteamId: t } = w(), a = t();
289
299
  return k({
290
- queryKey: ["pitvox", "registration", n, r, s],
300
+ queryKey: ["pitvox", "registration", s, e, a],
291
301
  queryFn: async () => {
292
- var v;
293
- const i = await fetch(`${t}/competitions/${n}/${r}/entrylist.json`);
302
+ var u;
303
+ const i = await fetch(`${n}/competitions/${s}/${e}/entrylist.json`);
294
304
  if (!i.ok) return { isRegistered: !1, entryList: null };
295
305
  const o = await i.json();
296
- return { isRegistered: !!s && ((v = o.drivers) == null ? void 0 : v.some((d) => d.steamId === s)), entryList: o };
306
+ return { isRegistered: !!a && ((u = o.drivers) == null ? void 0 : u.some((l) => l.steamId === a)), entryList: o };
297
307
  },
298
- enabled: !!r,
308
+ enabled: !!e,
299
309
  staleTime: 6e4
300
310
  });
301
311
  }
302
- function ie(r) {
303
- const { onRegister: t, partnerSlug: n } = y(), a = H();
304
- return ne({
305
- mutationFn: (s) => {
306
- if (!t)
312
+ function oe(e) {
313
+ const { onRegister: n, partnerSlug: s, getSteamId: t } = w(), a = P(), i = ae();
314
+ return _({
315
+ mutationFn: (o) => {
316
+ if (!n)
307
317
  throw new Error(
308
318
  "No onRegister callback provided to PitVoxPartnerProvider. Provide onRegister for in-app registration, or use useRegistrationUrl() to link to pitvox.com."
309
319
  );
310
- return t(r, s);
320
+ return n(e, o);
311
321
  },
312
322
  onSuccess: () => {
313
- a.invalidateQueries({
314
- queryKey: ["pitvox", "registration", n, r]
315
- }), a.invalidateQueries({
316
- queryKey: ["pitvox", "competition", n, r, "entrylist"]
317
- });
323
+ const o = t();
324
+ if (a.setQueriesData(
325
+ { queryKey: ["pitvox", "registration", s, e] },
326
+ (d) => d ? { ...d, isRegistered: !0 } : { isRegistered: !0, entryList: null }
327
+ ), o) {
328
+ const d = i(o), u = {
329
+ steamId: o,
330
+ displayName: d.displayName,
331
+ avatarUrl: d.avatarUrl
332
+ };
333
+ a.setQueriesData(
334
+ { queryKey: ["pitvox", "competition", s, e, "entrylist"] },
335
+ (l) => {
336
+ var g;
337
+ return l ? ((g = l.drivers) == null ? void 0 : g.some((h) => h.steamId === o)) ? l : { ...l, drivers: [...l.drivers || [], u] } : { drivers: [u] };
338
+ }
339
+ );
340
+ }
318
341
  }
319
342
  });
320
343
  }
321
- function le(r) {
322
- const { onWithdraw: t, partnerSlug: n, getSteamId: a } = y(), s = H();
323
- return ne({
344
+ function ce(e) {
345
+ const { onWithdraw: n, partnerSlug: s, getSteamId: t } = w(), a = P();
346
+ return _({
324
347
  mutationFn: (i) => {
325
- if (!t)
348
+ if (!n)
326
349
  throw new Error(
327
350
  "No onWithdraw callback provided to PitVoxPartnerProvider. Provide onWithdraw for in-app withdrawal, or use useRegistrationUrl() to link to pitvox.com."
328
351
  );
329
- const o = i || a();
352
+ const o = i || t();
330
353
  if (!o) throw new Error("No Steam ID available");
331
- return t(r, o);
354
+ return n(e, o);
332
355
  },
333
356
  onSuccess: () => {
334
- s.invalidateQueries({
335
- queryKey: ["pitvox", "registration", n, r]
336
- }), s.invalidateQueries({
337
- queryKey: ["pitvox", "competition", n, r, "entrylist"]
338
- });
357
+ const i = t();
358
+ a.setQueriesData(
359
+ { queryKey: ["pitvox", "registration", s, e] },
360
+ (o) => o ? { ...o, isRegistered: !1 } : { isRegistered: !1, entryList: null }
361
+ ), i && a.setQueriesData(
362
+ { queryKey: ["pitvox", "competition", s, e, "entrylist"] },
363
+ (o) => o != null && o.drivers ? { ...o, drivers: o.drivers.filter((d) => d.steamId !== i) } : o
364
+ );
339
365
  }
340
366
  });
341
367
  }
342
- function G() {
343
- const { onRegister: r, onWithdraw: t } = y(), n = !!(r && t);
344
- return { isPowerMode: n, isBasicMode: !n };
368
+ function Q() {
369
+ const { onRegister: e, onWithdraw: n } = w(), s = !!(e && n);
370
+ return { isPowerMode: s, isBasicMode: !s };
345
371
  }
346
- function z(r) {
347
- const { pitvoxUrl: t, partnerSlug: n } = y();
348
- return `${t}/p/${n}/competitions/${r}/register`;
372
+ function Y(e) {
373
+ const { pitvoxUrl: n, partnerSlug: s } = w();
374
+ return `${n}/p/${s}/competitions/${e}/register`;
349
375
  }
350
- const $e = {
376
+ const Be = {
351
377
  formula: "Formula",
352
378
  gt3: "GT3",
353
379
  gt2: "GT2",
@@ -367,395 +393,395 @@ const $e = {
367
393
  "2000s": "2000s",
368
394
  "2010s": "2010s",
369
395
  "2020s": "2020s"
370
- }, oe = [
396
+ }, le = [
371
397
  { id: "class", tags: ["formula", "gt3", "gt2", "gt4", "cup", "prototype", "rally"] },
372
398
  { id: "tier", tags: ["hypercar", "supercar", "sports_car", "hot_hatch", "lightweight"] },
373
399
  { id: "era", tags: ["1960s", "1970s", "1980s", "1990s", "2000s", "2010s", "2020s"] }
374
400
  ];
375
- function Me(r) {
376
- for (const t of oe)
377
- if (t.tags.includes(r)) return t.id;
401
+ function Pe(e) {
402
+ for (const n of le)
403
+ if (n.tags.includes(e)) return n.id;
378
404
  return "other";
379
405
  }
380
- function ce(r, t) {
381
- if (t.size === 0) return !0;
382
- const n = {};
383
- for (const a of t) {
384
- const s = Me(a);
385
- n[s] || (n[s] = []), n[s].push(a);
406
+ function de(e, n) {
407
+ if (n.size === 0) return !0;
408
+ const s = {};
409
+ for (const t of n) {
410
+ const a = Pe(t);
411
+ s[a] || (s[a] = []), s[a].push(t);
386
412
  }
387
- for (const a of Object.values(n))
388
- if (!a.some((s) => r.includes(s))) return !1;
413
+ for (const t of Object.values(s))
414
+ if (!t.some((a) => e.includes(a))) return !1;
389
415
  return !0;
390
416
  }
391
- function de() {
392
- const [r, t] = L(/* @__PURE__ */ new Set()), n = q((s) => {
393
- t((i) => {
394
- const o = new Set(i);
395
- return o.has(s) ? o.delete(s) : o.add(s), o;
396
- });
397
- }, []), a = q(() => t(/* @__PURE__ */ new Set()), []);
398
- return { activeTags: r, toggle: n, clear: a };
399
- }
400
- function Q(r) {
401
- const [t, n] = L(r), a = q((s) => {
402
- n(
403
- (i) => i.key === s ? { key: s, dir: i.dir === "asc" ? "desc" : "asc" } : { key: s, dir: s.includes("timestamp") || s.includes("Date") ? "desc" : "asc" }
417
+ function pe(e, n) {
418
+ const [s, t] = M(/* @__PURE__ */ new Set()), a = e !== void 0, i = a ? e : s, o = O((u) => {
419
+ const l = new Set(i);
420
+ l.has(u) ? l.delete(u) : l.add(u), a && n ? n(l) : t(l);
421
+ }, [i, a, n]), d = O(() => {
422
+ a && n ? n(/* @__PURE__ */ new Set()) : t(/* @__PURE__ */ new Set());
423
+ }, [a, n]);
424
+ return { activeTags: i, toggle: o, clear: d };
425
+ }
426
+ function Z(e) {
427
+ const [n, s] = M(e), t = O((a) => {
428
+ s(
429
+ (i) => i.key === a ? { key: a, dir: i.dir === "asc" ? "desc" : "asc" } : { key: a, dir: a.includes("timestamp") || a.includes("Date") ? "desc" : "asc" }
404
430
  );
405
431
  }, []);
406
- return [t, a];
432
+ return [n, t];
407
433
  }
408
- function Z(r, t, n) {
409
- return [...r].sort((a, s) => {
410
- const i = n(a, t.key), o = n(s, t.key);
434
+ function J(e, n, s) {
435
+ return [...e].sort((t, a) => {
436
+ const i = s(t, n.key), o = s(a, n.key);
411
437
  if (i == null && o == null) return 0;
412
438
  if (i == null) return 1;
413
439
  if (o == null) return -1;
414
- const c = typeof i == "string" ? i.localeCompare(o) : i - o;
415
- return t.dir === "desc" ? -c : c;
440
+ const d = typeof i == "string" ? i.localeCompare(o) : i - o;
441
+ return n.dir === "desc" ? -d : d;
416
442
  });
417
443
  }
418
- function pe(r, t = !1) {
419
- const n = t ? r == null ? void 0 : r.filter((a) => a.isValid) : r;
420
- return n != null && n.length ? {
421
- s1: Math.min(...n.map((a) => a.sector1Ms).filter(Boolean)),
422
- s2: Math.min(...n.map((a) => a.sector2Ms).filter(Boolean)),
423
- s3: Math.min(...n.map((a) => a.sector3Ms).filter(Boolean))
444
+ function ue(e, n = !1) {
445
+ const s = n ? e == null ? void 0 : e.filter((t) => t.isValid) : e;
446
+ return s != null && s.length ? {
447
+ s1: Math.min(...s.map((t) => t.sector1Ms).filter(Boolean)),
448
+ s2: Math.min(...s.map((t) => t.sector2Ms).filter(Boolean)),
449
+ s3: Math.min(...s.map((t) => t.sector3Ms).filter(Boolean))
424
450
  } : null;
425
451
  }
426
- function Pe({ active: r, dir: t }) {
427
- return r ? t === "asc" ? /* @__PURE__ */ e("svg", { className: "pvx-sort-icon", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 15.75l7.5-7.5 7.5 7.5" }) }) : /* @__PURE__ */ e("svg", { className: "pvx-sort-icon", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" }) }) : /* @__PURE__ */ e("svg", { className: "pvx-sort-icon pvx-sort-icon--inactive", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8 9l4-4 4 4M16 15l-4 4-4-4" }) });
452
+ function Ue({ active: e, dir: n }) {
453
+ return e ? n === "asc" ? /* @__PURE__ */ r("svg", { className: "pvx-sort-icon", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 15.75l7.5-7.5 7.5 7.5" }) }) : /* @__PURE__ */ r("svg", { className: "pvx-sort-icon", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" }) }) : /* @__PURE__ */ r("svg", { className: "pvx-sort-icon pvx-sort-icon--inactive", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8 9l4-4 4 4M16 15l-4 4-4-4" }) });
428
454
  }
429
- function S({ label: r, sortKey: t, config: n, onSort: a, className: s = "" }) {
430
- return /* @__PURE__ */ e(
455
+ function T({ label: e, sortKey: n, config: s, onSort: t, className: a = "" }) {
456
+ return /* @__PURE__ */ r(
431
457
  "th",
432
458
  {
433
- className: `pvx-th pvx-th--sortable ${s}`,
434
- onClick: () => a(t),
435
- children: /* @__PURE__ */ l("span", { className: "pvx-th-inner", children: [
436
- r,
437
- /* @__PURE__ */ e(Pe, { active: n.key === t, dir: n.dir })
459
+ className: `pvx-th pvx-th--sortable ${a}`,
460
+ onClick: () => t(n),
461
+ children: /* @__PURE__ */ c("span", { className: "pvx-th-inner", children: [
462
+ e,
463
+ /* @__PURE__ */ r(Ue, { active: s.key === n, dir: s.dir })
438
464
  ] })
439
465
  }
440
466
  );
441
467
  }
442
- function J({ userId: r, getUserDisplay: t }) {
443
- const { displayName: n, avatarUrl: a } = t(r);
444
- return /* @__PURE__ */ l("span", { className: "pvx-driver", children: [
445
- a ? /* @__PURE__ */ e("img", { src: a, alt: "", className: "pvx-driver-avatar" }) : /* @__PURE__ */ e("span", { className: "pvx-driver-avatar pvx-driver-avatar--placeholder" }),
446
- /* @__PURE__ */ e("span", { className: "pvx-driver-name", children: n })
468
+ function X({ userId: e, getUserDisplay: n }) {
469
+ const { displayName: s, avatarUrl: t } = n(e);
470
+ return /* @__PURE__ */ c("span", { className: "pvx-driver", children: [
471
+ t ? /* @__PURE__ */ r("img", { src: t, alt: "", className: "pvx-driver-avatar" }) : /* @__PURE__ */ r("span", { className: "pvx-driver-avatar pvx-driver-avatar--placeholder" }),
472
+ /* @__PURE__ */ r("span", { className: "pvx-driver-name", children: s })
447
473
  ] });
448
474
  }
449
- function ve({ rank: r, podium: t = !1 }) {
450
- return /* @__PURE__ */ e("span", { className: t ? r === 1 ? "pvx-rank pvx-rank--gold" : r === 2 ? "pvx-rank pvx-rank--silver" : r === 3 ? "pvx-rank pvx-rank--bronze" : "pvx-rank" : "pvx-rank", children: r });
475
+ function me({ rank: e, podium: n = !1 }) {
476
+ return /* @__PURE__ */ r("span", { className: n ? e === 1 ? "pvx-rank pvx-rank--gold" : e === 2 ? "pvx-rank pvx-rank--silver" : e === 3 ? "pvx-rank pvx-rank--bronze" : "pvx-rank" : "pvx-rank", children: e });
451
477
  }
452
- function me({ availableTags: r, activeTags: t, onToggle: n, onClear: a }) {
453
- if (!r || r.length < 2) return null;
454
- const s = oe.map((i) => ({ id: i.id, tags: i.tags.filter((o) => r.includes(o)) })).filter((i) => i.tags.length > 0);
455
- return /* @__PURE__ */ l("div", { className: "pvx-tag-bar", children: [
456
- /* @__PURE__ */ e(
478
+ function ve({ availableTags: e, activeTags: n, onToggle: s, onClear: t }) {
479
+ if (!e || e.length < 2) return null;
480
+ const a = le.map((i) => ({ id: i.id, tags: i.tags.filter((o) => e.includes(o)) })).filter((i) => i.tags.length > 0);
481
+ return /* @__PURE__ */ c("div", { className: "pvx-tag-bar", children: [
482
+ /* @__PURE__ */ r(
457
483
  "button",
458
484
  {
459
- onClick: a,
460
- className: `pvx-tag ${t.size === 0 ? "pvx-tag--active" : ""}`,
485
+ onClick: t,
486
+ className: `pvx-tag ${n.size === 0 ? "pvx-tag--active" : ""}`,
461
487
  children: "All"
462
488
  }
463
489
  ),
464
- s.map((i, o) => /* @__PURE__ */ l("span", { className: "contents", children: [
465
- o > 0 && /* @__PURE__ */ e("span", { className: "pvx-tag-separator" }),
466
- i.tags.map((c) => /* @__PURE__ */ e(
490
+ a.map((i, o) => /* @__PURE__ */ c("span", { className: "contents", children: [
491
+ o > 0 && /* @__PURE__ */ r("span", { className: "pvx-tag-separator" }),
492
+ i.tags.map((d) => /* @__PURE__ */ r(
467
493
  "button",
468
494
  {
469
- onClick: () => n(c),
470
- className: `pvx-tag ${t.has(c) ? "pvx-tag--active" : ""}`,
471
- children: $e[c] || c
495
+ onClick: () => s(d),
496
+ className: `pvx-tag ${n.has(d) ? "pvx-tag--active" : ""}`,
497
+ children: Be[d] || d
472
498
  },
473
- c
499
+ d
474
500
  ))
475
501
  ] }, i.id))
476
502
  ] });
477
503
  }
478
- function Y({ segments: r }) {
479
- return /* @__PURE__ */ e("nav", { className: "pvx-breadcrumb", "aria-label": "Breadcrumb", children: /* @__PURE__ */ e("ol", { className: "pvx-breadcrumb-list", children: r.map((t, n) => {
480
- const a = n === r.length - 1;
481
- return /* @__PURE__ */ l("li", { className: "pvx-breadcrumb-item", children: [
482
- n > 0 && /* @__PURE__ */ e("svg", { className: "pvx-breadcrumb-chevron", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8.25 4.5l7.5 7.5-7.5 7.5" }) }),
483
- !a && t.onClick ? /* @__PURE__ */ e("button", { onClick: t.onClick, className: "pvx-breadcrumb-link", children: t.label }) : /* @__PURE__ */ e("span", { className: "pvx-breadcrumb-current", children: t.label })
484
- ] }, t.key);
504
+ function ee({ segments: e }) {
505
+ return /* @__PURE__ */ r("nav", { className: "pvx-breadcrumb", "aria-label": "Breadcrumb", children: /* @__PURE__ */ r("ol", { className: "pvx-breadcrumb-list", children: e.map((n, s) => {
506
+ const t = s === e.length - 1;
507
+ return /* @__PURE__ */ c("li", { className: "pvx-breadcrumb-item", children: [
508
+ s > 0 && /* @__PURE__ */ r("svg", { className: "pvx-breadcrumb-chevron", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8.25 4.5l7.5 7.5-7.5 7.5" }) }),
509
+ !t && n.onClick ? /* @__PURE__ */ r("button", { onClick: n.onClick, className: "pvx-breadcrumb-link", children: n.label }) : /* @__PURE__ */ r("span", { className: "pvx-breadcrumb-current", children: n.label })
510
+ ] }, n.key);
485
511
  }) }) });
486
512
  }
487
- function I({ message: r }) {
488
- return /* @__PURE__ */ l("div", { className: "pvx-empty", children: [
489
- /* @__PURE__ */ e("svg", { className: "pvx-empty-icon", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M16.5 18.75h-9m9 0a3 3 0 013 3h-15a3 3 0 013-3m9 0v-4.5A3.375 3.375 0 0013.125 10.875h-2.25A3.375 3.375 0 007.5 14.25v4.5" }) }),
490
- /* @__PURE__ */ e("p", { children: r })
513
+ function V({ message: e }) {
514
+ return /* @__PURE__ */ c("div", { className: "pvx-empty", children: [
515
+ /* @__PURE__ */ r("svg", { className: "pvx-empty-icon", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M16.5 18.75h-9m9 0a3 3 0 013 3h-15a3 3 0 013-3m9 0v-4.5A3.375 3.375 0 0013.125 10.875h-2.25A3.375 3.375 0 007.5 14.25v4.5" }) }),
516
+ /* @__PURE__ */ r("p", { children: e })
491
517
  ] });
492
518
  }
493
- function A() {
494
- return /* @__PURE__ */ e("div", { className: "pvx-loading", children: "Loading..." });
495
- }
496
- function Be() {
497
- return /* @__PURE__ */ e("svg", { className: "pvx-icon pvx-icon--valid", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 12.75l6 6 9-13.5" }) });
498
- }
499
- function De() {
500
- return /* @__PURE__ */ e("svg", { className: "pvx-icon pvx-icon--invalid", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) });
501
- }
502
- function gr({ tracks: r, isLoading: t, carMetadata: n, getUserDisplay: a, onTrackSelect: s }) {
503
- const [i, o] = Q({ key: "record.timestamp", dir: "desc" }), { activeTags: c, toggle: v, clear: d } = de(), u = C(() => {
504
- var g;
505
- if (!((g = n == null ? void 0 : n.tags) != null && g.length)) return [];
506
- const m = /* @__PURE__ */ new Set();
507
- for (const p of r || [])
508
- p.recordByTag && Object.keys(p.recordByTag).forEach((f) => m.add(f));
509
- return n.tags.filter((p) => m.has(p));
510
- }, [r, n]), b = C(() => r ? c.size === 0 ? r : r.map((m) => {
511
- var f, h;
512
- if (!m.recordByTag) return null;
513
- let g = null;
519
+ function j() {
520
+ return /* @__PURE__ */ r("div", { className: "pvx-loading", children: "Loading..." });
521
+ }
522
+ function Ae() {
523
+ return /* @__PURE__ */ r("svg", { className: "pvx-icon pvx-icon--valid", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 12.75l6 6 9-13.5" }) });
524
+ }
525
+ function Fe() {
526
+ return /* @__PURE__ */ r("svg", { className: "pvx-icon pvx-icon--invalid", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) });
527
+ }
528
+ function Dr({ tracks: e, isLoading: n, carMetadata: s, getUserDisplay: t, onTrackSelect: a, tags: i, onTagChange: o }) {
529
+ const [d, u] = Z({ key: "record.timestamp", dir: "desc" }), { activeTags: l, toggle: m, clear: g } = pe(i, o), h = C(() => {
530
+ var N;
531
+ if (!((N = s == null ? void 0 : s.tags) != null && N.length)) return [];
514
532
  const p = /* @__PURE__ */ new Set();
515
- for (const N of Object.values(m.recordByTag)) {
516
- if (p.has(N.carId)) continue;
517
- p.add(N.carId);
518
- const w = ((h = (f = n == null ? void 0 : n.cars) == null ? void 0 : f[N.carId]) == null ? void 0 : h.tags) || ["sports_car"];
519
- ce(w, c) && (!g || N.lapTimeMs < g.lapTimeMs) && (g = N);
533
+ for (const v of e || [])
534
+ v.recordByTag && Object.keys(v.recordByTag).forEach((x) => p.add(x));
535
+ return s.tags.filter((v) => p.has(v));
536
+ }, [e, s]), f = C(() => e ? l.size === 0 ? e : e.map((p) => {
537
+ var x, y;
538
+ if (!p.recordByTag) return null;
539
+ let N = null;
540
+ const v = /* @__PURE__ */ new Set();
541
+ for (const L of Object.values(p.recordByTag)) {
542
+ if (v.has(L.carId)) continue;
543
+ v.add(L.carId);
544
+ const $ = ((y = (x = s == null ? void 0 : s.cars) == null ? void 0 : x[L.carId]) == null ? void 0 : y.tags) || ["sports_car"];
545
+ de($, l) && (!N || L.lapTimeMs < N.lapTimeMs) && (N = L);
520
546
  }
521
- return g ? {
522
- ...m,
547
+ return N ? {
548
+ ...p,
523
549
  record: {
524
- visibleId: g.steamId || g.identifier,
525
- carId: g.carId,
526
- carDisplayName: R(g.carId),
527
- lapTimeMs: g.lapTimeMs,
528
- timestamp: g.recordedAt
550
+ visibleId: N.steamId || N.identifier,
551
+ carId: N.carId,
552
+ carDisplayName: S(N.carId),
553
+ lapTimeMs: N.lapTimeMs,
554
+ timestamp: N.recordedAt
529
555
  }
530
556
  } : null;
531
- }).filter(Boolean) : [], [r, c, n]), x = C(() => Z(b, i, (m, g) => {
532
- var p, f;
533
- switch (g) {
557
+ }).filter(Boolean) : [], [e, l, s]), b = C(() => J(f, d, (p, N) => {
558
+ var v, x;
559
+ switch (N) {
534
560
  case "displayName":
535
- return m.displayName;
561
+ return p.displayName;
536
562
  case "record.lapTimeMs":
537
- return (p = m.record) == null ? void 0 : p.lapTimeMs;
563
+ return (v = p.record) == null ? void 0 : v.lapTimeMs;
538
564
  case "driverCount":
539
- return m.driverCount || 0;
565
+ return p.driverCount || 0;
540
566
  case "carCount":
541
- return m.carCount || 0;
567
+ return p.carCount || 0;
542
568
  case "record.timestamp":
543
569
  default:
544
- return (f = m.record) != null && f.timestamp ? new Date(m.record.timestamp).getTime() : 0;
570
+ return (x = p.record) != null && x.timestamp ? new Date(p.record.timestamp).getTime() : 0;
545
571
  }
546
- }), [b, i]);
547
- return t ? /* @__PURE__ */ e(A, {}) : r != null && r.length ? /* @__PURE__ */ l("div", { className: "pvx-card", children: [
548
- /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ e("h2", { className: "pvx-card-title", children: "Track Records" }) }),
549
- /* @__PURE__ */ e(me, { availableTags: u, activeTags: c, onToggle: v, onClear: d }),
550
- /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
551
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
552
- /* @__PURE__ */ e(S, { label: "Track", sortKey: "displayName", config: i, onSort: o }),
553
- /* @__PURE__ */ e("th", { className: "pvx-th", children: "Record Holder" }),
554
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-lg", children: "Car" }),
555
- /* @__PURE__ */ e(S, { label: "Lap Time", sortKey: "record.lapTimeMs", config: i, onSort: o }),
556
- /* @__PURE__ */ e(S, { label: "Drivers", sortKey: "driverCount", config: i, onSort: o, className: "pvx-hidden-below-md" }),
557
- /* @__PURE__ */ e(S, { label: "Cars", sortKey: "carCount", config: i, onSort: o, className: "pvx-hidden-below-lg" }),
558
- /* @__PURE__ */ e(S, { label: "Date", sortKey: "record.timestamp", config: i, onSort: o, className: "pvx-hidden-below-xl" })
572
+ }), [f, d]);
573
+ return n ? /* @__PURE__ */ r(j, {}) : e != null && e.length ? /* @__PURE__ */ c("div", { className: "pvx-card", children: [
574
+ /* @__PURE__ */ r("div", { className: "pvx-card-header", children: /* @__PURE__ */ r("h2", { className: "pvx-card-title", children: "Track Records" }) }),
575
+ /* @__PURE__ */ r(ve, { availableTags: h, activeTags: l, onToggle: m, onClear: g }),
576
+ /* @__PURE__ */ r("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ c("table", { className: "pvx-table", children: [
577
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ c("tr", { className: "pvx-thead-row", children: [
578
+ /* @__PURE__ */ r(T, { label: "Track", sortKey: "displayName", config: d, onSort: u }),
579
+ /* @__PURE__ */ r("th", { className: "pvx-th", children: "Record Holder" }),
580
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-lg", children: "Car" }),
581
+ /* @__PURE__ */ r(T, { label: "Lap Time", sortKey: "record.lapTimeMs", config: d, onSort: u }),
582
+ /* @__PURE__ */ r(T, { label: "Drivers", sortKey: "driverCount", config: d, onSort: u, className: "pvx-hidden-below-md" }),
583
+ /* @__PURE__ */ r(T, { label: "Cars", sortKey: "carCount", config: d, onSort: u, className: "pvx-hidden-below-lg" }),
584
+ /* @__PURE__ */ r(T, { label: "Date", sortKey: "record.timestamp", config: d, onSort: u, className: "pvx-hidden-below-xl" })
559
585
  ] }) }),
560
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: x.map((m) => {
561
- var g, p, f;
562
- return /* @__PURE__ */ l(
586
+ /* @__PURE__ */ r("tbody", { className: "pvx-tbody", children: b.map((p) => {
587
+ var N, v, x;
588
+ return /* @__PURE__ */ c(
563
589
  "tr",
564
590
  {
565
591
  className: "pvx-row pvx-row--clickable",
566
- onClick: () => s(m.id, m.layout),
592
+ onClick: () => a(p.id, p.layout),
567
593
  children: [
568
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: m.displayName }),
569
- /* @__PURE__ */ e("td", { className: "pvx-td", children: (g = m.record) != null && g.visibleId ? /* @__PURE__ */ e(J, { userId: m.record.visibleId, getUserDisplay: a }) : "-" }),
570
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-hidden-below-lg", children: ((p = m.record) == null ? void 0 : p.carDisplayName) || "-" }),
571
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: m.record ? B(m.record.lapTimeMs) : "-" }),
572
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: m.driverCount || "-" }),
573
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: m.carCount || "-" }),
574
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: (f = m.record) != null && f.timestamp ? D(m.record.timestamp) : "-" })
594
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--primary", children: p.displayName }),
595
+ /* @__PURE__ */ r("td", { className: "pvx-td", children: (N = p.record) != null && N.visibleId ? /* @__PURE__ */ r(X, { userId: p.record.visibleId, getUserDisplay: t }) : "-" }),
596
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-hidden-below-lg", children: ((v = p.record) == null ? void 0 : v.carDisplayName) || "-" }),
597
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: p.record ? U(p.record.lapTimeMs) : "-" }),
598
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: p.driverCount || "-" }),
599
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: p.carCount || "-" }),
600
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: (x = p.record) != null && x.timestamp ? A(p.record.timestamp) : "-" })
575
601
  ]
576
602
  },
577
- `${m.id}|${m.layout || ""}`
603
+ `${p.id}|${p.layout || ""}`
578
604
  );
579
605
  }) })
580
606
  ] }) })
581
- ] }) : /* @__PURE__ */ e(I, { message: "No lap times recorded yet." });
582
- }
583
- function fr({ entries: r, isLoading: t, track: n, carMetadata: a, getUserDisplay: s, onCarSelect: i, onNavigate: o }) {
584
- const [c, v] = Q({ key: "lapTimeMs", dir: "asc" }), { activeTags: d, toggle: u, clear: b } = de(), x = C(() => {
585
- var h, N, w;
586
- if (!r || !((h = a == null ? void 0 : a.tags) != null && h.length)) return [];
587
- const f = /* @__PURE__ */ new Set();
588
- for (const P of r)
589
- (((w = (N = a.cars) == null ? void 0 : N[P.carId]) == null ? void 0 : w.tags) || ["sports_car"]).forEach((F) => f.add(F));
590
- return a.tags.filter((P) => f.has(P));
591
- }, [r, a]), m = C(() => r ? d.size === 0 ? r : r.filter((f) => {
592
- var N, w;
593
- const h = ((w = (N = a == null ? void 0 : a.cars) == null ? void 0 : N[f.carId]) == null ? void 0 : w.tags) || ["sports_car"];
594
- return ce(h, d);
595
- }) : [], [r, d, a]), g = C(() => Z(m, c, (f, h) => {
596
- switch (h) {
607
+ ] }) : /* @__PURE__ */ r(V, { message: "No lap times recorded yet." });
608
+ }
609
+ function Ir({ entries: e, isLoading: n, track: s, carMetadata: t, getUserDisplay: a, onCarSelect: i, onNavigate: o, tags: d, onTagChange: u }) {
610
+ const [l, m] = Z({ key: "lapTimeMs", dir: "asc" }), { activeTags: g, toggle: h, clear: f } = pe(d, u), b = C(() => {
611
+ var y, L, $;
612
+ if (!e || !((y = t == null ? void 0 : t.tags) != null && y.length)) return [];
613
+ const x = /* @__PURE__ */ new Set();
614
+ for (const B of e)
615
+ ((($ = (L = t.cars) == null ? void 0 : L[B.carId]) == null ? void 0 : $.tags) || ["sports_car"]).forEach((Ne) => x.add(Ne));
616
+ return t.tags.filter((B) => x.has(B));
617
+ }, [e, t]), p = C(() => e ? g.size === 0 ? e : e.filter((x) => {
618
+ var L, $;
619
+ const y = (($ = (L = t == null ? void 0 : t.cars) == null ? void 0 : L[x.carId]) == null ? void 0 : $.tags) || ["sports_car"];
620
+ return de(y, g);
621
+ }) : [], [e, g, t]), N = C(() => J(p, l, (x, y) => {
622
+ switch (y) {
597
623
  case "carId":
598
- return R(f.carId);
624
+ return S(x.carId);
599
625
  case "driverCount":
600
- return f.driverCount || 0;
626
+ return x.driverCount || 0;
601
627
  case "lapTimeMs":
602
628
  default:
603
- return f.lapTimeMs;
629
+ return x.lapTimeMs;
604
630
  }
605
- }), [m, c]), p = [
631
+ }), [p, l]), v = [
606
632
  { key: "tracks", label: "Tracks", onClick: () => o("tracks") },
607
- { key: "track", label: n.displayName }
633
+ { key: "track", label: s.displayName }
608
634
  ];
609
- return t ? /* @__PURE__ */ e(A, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
610
- /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ e(Y, { segments: p }) }),
611
- /* @__PURE__ */ e(me, { availableTags: x, activeTags: d, onToggle: u, onClear: b }),
612
- r != null && r.length ? /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
613
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
614
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--narrow", children: "#" }),
615
- /* @__PURE__ */ e(S, { label: "Car", sortKey: "carId", config: c, onSort: v }),
616
- /* @__PURE__ */ e("th", { className: "pvx-th", children: "Record Holder" }),
617
- /* @__PURE__ */ e(S, { label: "Lap Time", sortKey: "lapTimeMs", config: c, onSort: v }),
618
- /* @__PURE__ */ e(S, { label: "Drivers", sortKey: "driverCount", config: c, onSort: v, className: "pvx-hidden-below-md" }),
619
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-lg", children: "Date" })
635
+ return n ? /* @__PURE__ */ r(j, {}) : /* @__PURE__ */ c("div", { className: "pvx-card", children: [
636
+ /* @__PURE__ */ r("div", { className: "pvx-card-header", children: /* @__PURE__ */ r(ee, { segments: v }) }),
637
+ /* @__PURE__ */ r(ve, { availableTags: b, activeTags: g, onToggle: h, onClear: f }),
638
+ e != null && e.length ? /* @__PURE__ */ r("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ c("table", { className: "pvx-table", children: [
639
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ c("tr", { className: "pvx-thead-row", children: [
640
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-th--narrow", children: "#" }),
641
+ /* @__PURE__ */ r(T, { label: "Car", sortKey: "carId", config: l, onSort: m }),
642
+ /* @__PURE__ */ r("th", { className: "pvx-th", children: "Record Holder" }),
643
+ /* @__PURE__ */ r(T, { label: "Lap Time", sortKey: "lapTimeMs", config: l, onSort: m }),
644
+ /* @__PURE__ */ r(T, { label: "Drivers", sortKey: "driverCount", config: l, onSort: m, className: "pvx-hidden-below-md" }),
645
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-lg", children: "Date" })
620
646
  ] }) }),
621
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: g.map((f, h) => /* @__PURE__ */ l(
647
+ /* @__PURE__ */ r("tbody", { className: "pvx-tbody", children: N.map((x, y) => /* @__PURE__ */ c(
622
648
  "tr",
623
649
  {
624
650
  className: "pvx-row pvx-row--clickable",
625
- onClick: () => i(f.carId),
651
+ onClick: () => i(x.carId),
626
652
  children: [
627
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(ve, { rank: h + 1, podium: !0 }) }),
628
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: R(f.carId) }),
629
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(J, { userId: f.steamId || f.userId, getUserDisplay: s }) }),
630
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: B(f.lapTimeMs) }),
631
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: f.driverCount || "-" }),
632
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-lg", children: f.recordedAt ? D(f.recordedAt) : "-" })
653
+ /* @__PURE__ */ r("td", { className: "pvx-td", children: /* @__PURE__ */ r(me, { rank: y + 1, podium: !0 }) }),
654
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--primary", children: S(x.carId) }),
655
+ /* @__PURE__ */ r("td", { className: "pvx-td", children: /* @__PURE__ */ r(X, { userId: x.steamId || x.userId, getUserDisplay: a }) }),
656
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: U(x.lapTimeMs) }),
657
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: x.driverCount || "-" }),
658
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-lg", children: x.recordedAt ? A(x.recordedAt) : "-" })
633
659
  ]
634
660
  },
635
- f.carId
661
+ x.carId
636
662
  )) })
637
- ] }) }) : /* @__PURE__ */ e(I, { message: "No lap times for this track yet." })
663
+ ] }) }) : /* @__PURE__ */ r(V, { message: "No lap times for this track yet." })
638
664
  ] });
639
665
  }
640
- function Nr({ entries: r, isLoading: t, track: n, carId: a, getUserDisplay: s, onDriverSelect: i, onNavigate: o }) {
641
- const [c, v] = Q({ key: "lapTimeMs", dir: "asc" }), d = C(() => pe(r), [r]), u = C(() => Z(r || [], c, (x, m) => {
642
- switch (m) {
666
+ function Br({ entries: e, isLoading: n, track: s, carId: t, getUserDisplay: a, onDriverSelect: i, onNavigate: o }) {
667
+ const [d, u] = Z({ key: "lapTimeMs", dir: "asc" }), l = C(() => ue(e), [e]), m = C(() => J(e || [], d, (h, f) => {
668
+ switch (f) {
643
669
  case "userId":
644
- return s(x.steamId || x.userId).displayName;
670
+ return a(h.steamId || h.userId).displayName;
645
671
  case "lapCount":
646
- return x.lapCount || 0;
672
+ return h.lapCount || 0;
647
673
  case "lapTimeMs":
648
674
  default:
649
- return x.lapTimeMs;
675
+ return h.lapTimeMs;
650
676
  }
651
- }), [r, c, s]), b = [
677
+ }), [e, d, a]), g = [
652
678
  { key: "tracks", label: "Tracks", onClick: () => o("tracks") },
653
- { key: "track", label: n.displayName, onClick: () => o("track") },
654
- { key: "car", label: R(a) }
679
+ { key: "track", label: s.displayName, onClick: () => o("track") },
680
+ { key: "car", label: S(t) }
655
681
  ];
656
- return t ? /* @__PURE__ */ e(A, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
657
- /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ e(Y, { segments: b }) }),
658
- r != null && r.length ? /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
659
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
660
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--narrow", children: "#" }),
661
- /* @__PURE__ */ e(S, { label: "Driver", sortKey: "userId", config: c, onSort: v }),
662
- /* @__PURE__ */ e(S, { label: "Lap Time", sortKey: "lapTimeMs", config: c, onSort: v }),
663
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "S1" }),
664
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "S2" }),
665
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "S3" }),
666
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-lg", children: "Tyre" }),
667
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-xl", children: "Fuel" }),
668
- /* @__PURE__ */ e(S, { label: "Laps", sortKey: "lapCount", config: c, onSort: v, className: "pvx-hidden-below-lg" }),
669
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-xl", children: "Date" })
682
+ return n ? /* @__PURE__ */ r(j, {}) : /* @__PURE__ */ c("div", { className: "pvx-card", children: [
683
+ /* @__PURE__ */ r("div", { className: "pvx-card-header", children: /* @__PURE__ */ r(ee, { segments: g }) }),
684
+ e != null && e.length ? /* @__PURE__ */ r("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ c("table", { className: "pvx-table", children: [
685
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ c("tr", { className: "pvx-thead-row", children: [
686
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-th--narrow", children: "#" }),
687
+ /* @__PURE__ */ r(T, { label: "Driver", sortKey: "userId", config: d, onSort: u }),
688
+ /* @__PURE__ */ r(T, { label: "Lap Time", sortKey: "lapTimeMs", config: d, onSort: u }),
689
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-sm", children: "S1" }),
690
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-sm", children: "S2" }),
691
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-sm", children: "S3" }),
692
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-lg", children: "Tyre" }),
693
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-xl", children: "Fuel" }),
694
+ /* @__PURE__ */ r(T, { label: "Laps", sortKey: "lapCount", config: d, onSort: u, className: "pvx-hidden-below-lg" }),
695
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-xl", children: "Date" })
670
696
  ] }) }),
671
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: u.map((x, m) => {
672
- const g = m + 1, p = x.steamId || x.userId, f = d && x.sector1Ms === d.s1, h = d && x.sector2Ms === d.s2, N = d && x.sector3Ms === d.s3;
673
- return /* @__PURE__ */ l(
697
+ /* @__PURE__ */ r("tbody", { className: "pvx-tbody", children: m.map((h, f) => {
698
+ const b = f + 1, p = h.steamId || h.userId, N = l && h.sector1Ms === l.s1, v = l && h.sector2Ms === l.s2, x = l && h.sector3Ms === l.s3;
699
+ return /* @__PURE__ */ c(
674
700
  "tr",
675
701
  {
676
- className: `pvx-row pvx-row--clickable ${g <= 3 ? "pvx-row--podium" : ""}`,
702
+ className: `pvx-row pvx-row--clickable ${b <= 3 ? "pvx-row--podium" : ""}`,
677
703
  onClick: () => i(p),
678
704
  children: [
679
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(ve, { rank: g, podium: !0 }) }),
680
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: /* @__PURE__ */ e(J, { userId: p, getUserDisplay: s }) }),
681
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: B(x.lapTimeMs) }),
682
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${f ? "pvx-td--best-sector" : ""}`, children: $(x.sector1Ms) }),
683
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${h ? "pvx-td--best-sector" : ""}`, children: $(x.sector2Ms) }),
684
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${N ? "pvx-td--best-sector" : ""}`, children: $(x.sector3Ms) }),
685
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", title: se(x.tyreCompound), children: x.tyreCompound || "-" }),
686
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-xl", children: x.startingFuelL ? `${x.startingFuelL}L` : "-" }),
687
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: x.lapCount || "-" }),
688
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: x.recordedAt ? D(x.recordedAt) : "-" })
705
+ /* @__PURE__ */ r("td", { className: "pvx-td", children: /* @__PURE__ */ r(me, { rank: b, podium: !0 }) }),
706
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--primary", children: /* @__PURE__ */ r(X, { userId: p, getUserDisplay: a }) }),
707
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: U(h.lapTimeMs) }),
708
+ /* @__PURE__ */ r("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${N ? "pvx-td--best-sector" : ""}`, children: D(h.sector1Ms) }),
709
+ /* @__PURE__ */ r("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${v ? "pvx-td--best-sector" : ""}`, children: D(h.sector2Ms) }),
710
+ /* @__PURE__ */ r("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${x ? "pvx-td--best-sector" : ""}`, children: D(h.sector3Ms) }),
711
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", title: se(h.tyreCompound), children: h.tyreCompound || "-" }),
712
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--center pvx-hidden-below-xl", children: h.startingFuelL ? `${h.startingFuelL}L` : "-" }),
713
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: h.lapCount || "-" }),
714
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: h.recordedAt ? A(h.recordedAt) : "-" })
689
715
  ]
690
716
  },
691
717
  p
692
718
  );
693
719
  }) })
694
- ] }) }) : /* @__PURE__ */ e(I, { message: "No lap times for this car yet." })
720
+ ] }) }) : /* @__PURE__ */ r(V, { message: "No lap times for this car yet." })
695
721
  ] });
696
722
  }
697
- function br({ userId: r, track: t, carId: n, game: a, gameVersion: s, showInvalid: i, getUserDisplay: o, onToggleInvalid: c, onNavigate: v }) {
698
- const { data: d, driverName: u, isLoading: b } = Te(r, t.id, t.layout, n, { showInvalid: i, game: a, gameVersion: s }), { displayName: x, avatarUrl: m } = o(r, u), g = C(() => pe(d, !0), [d]), p = C(() => {
699
- const h = (d == null ? void 0 : d.filter((N) => N.isValid)) || [];
700
- return h.length ? Math.min(...h.map((N) => N.lapTimeMs)) : null;
701
- }, [d]), f = [
702
- { key: "tracks", label: "Tracks", onClick: () => v("tracks") },
703
- { key: "track", label: t.displayName, onClick: () => v("track") },
704
- { key: "car", label: R(n), onClick: () => v("car") },
705
- { key: "driver", label: x }
723
+ function Pr({ userId: e, track: n, carId: s, game: t, gameVersion: a, showInvalid: i, getUserDisplay: o, onToggleInvalid: d, onNavigate: u }) {
724
+ const { data: l, driverName: m, isLoading: g } = $e(e, n.id, n.layout, s, { showInvalid: i, game: t, gameVersion: a }), { displayName: h, avatarUrl: f } = o(e, m), b = C(() => ue(l, !0), [l]), p = C(() => {
725
+ const v = (l == null ? void 0 : l.filter((x) => x.isValid)) || [];
726
+ return v.length ? Math.min(...v.map((x) => x.lapTimeMs)) : null;
727
+ }, [l]), N = [
728
+ { key: "tracks", label: "Tracks", onClick: () => u("tracks") },
729
+ { key: "track", label: n.displayName, onClick: () => u("track") },
730
+ { key: "car", label: S(s), onClick: () => u("car") },
731
+ { key: "driver", label: h }
706
732
  ];
707
- return b ? /* @__PURE__ */ e(A, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
708
- /* @__PURE__ */ l("div", { className: "pvx-card-header pvx-card-header--split", children: [
709
- /* @__PURE__ */ l("div", { className: "pvx-card-header-left", children: [
710
- /* @__PURE__ */ e(Y, { segments: f }),
711
- m ? /* @__PURE__ */ e("img", { src: m, alt: "", className: "pvx-driver-avatar pvx-driver-avatar--lg" }) : /* @__PURE__ */ e("span", { className: "pvx-driver-avatar pvx-driver-avatar--lg pvx-driver-avatar--placeholder" })
733
+ return g ? /* @__PURE__ */ r(j, {}) : /* @__PURE__ */ c("div", { className: "pvx-card", children: [
734
+ /* @__PURE__ */ c("div", { className: "pvx-card-header pvx-card-header--split", children: [
735
+ /* @__PURE__ */ c("div", { className: "pvx-card-header-left", children: [
736
+ /* @__PURE__ */ r(ee, { segments: N }),
737
+ f ? /* @__PURE__ */ r("img", { src: f, alt: "", className: "pvx-driver-avatar pvx-driver-avatar--lg" }) : /* @__PURE__ */ r("span", { className: "pvx-driver-avatar pvx-driver-avatar--lg pvx-driver-avatar--placeholder" })
712
738
  ] }),
713
- /* @__PURE__ */ l("label", { className: "pvx-checkbox-label", children: [
714
- /* @__PURE__ */ e(
739
+ /* @__PURE__ */ c("label", { className: "pvx-checkbox-label", children: [
740
+ /* @__PURE__ */ r(
715
741
  "input",
716
742
  {
717
743
  type: "checkbox",
718
744
  checked: i,
719
- onChange: c,
745
+ onChange: d,
720
746
  className: "pvx-checkbox"
721
747
  }
722
748
  ),
723
- /* @__PURE__ */ e("span", { children: "Show invalid laps" })
749
+ /* @__PURE__ */ r("span", { children: "Show invalid laps" })
724
750
  ] })
725
751
  ] }),
726
- d != null && d.length ? /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
727
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
728
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--narrow", children: "#" }),
729
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-md", children: "Lap" }),
730
- /* @__PURE__ */ e("th", { className: "pvx-th", children: "Lap Time" }),
731
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "S1" }),
732
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "S2" }),
733
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "S3" }),
734
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--narrow", children: "Valid" }),
735
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-lg", children: "Tyre" }),
736
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-lg", children: "Fuel" }),
737
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-xl", children: "Date" })
752
+ l != null && l.length ? /* @__PURE__ */ r("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ c("table", { className: "pvx-table", children: [
753
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ c("tr", { className: "pvx-thead-row", children: [
754
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-th--narrow", children: "#" }),
755
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-md", children: "Lap" }),
756
+ /* @__PURE__ */ r("th", { className: "pvx-th", children: "Lap Time" }),
757
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-sm", children: "S1" }),
758
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-sm", children: "S2" }),
759
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-sm", children: "S3" }),
760
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-th--narrow", children: "Valid" }),
761
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-lg", children: "Tyre" }),
762
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-lg", children: "Fuel" }),
763
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-xl", children: "Date" })
738
764
  ] }) }),
739
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: d.map((h, N) => {
740
- const w = h.isValid && h.lapTimeMs === p, P = g && h.isValid && h.sector1Ms === g.s1, X = g && h.isValid && h.sector2Ms === g.s2, F = g && h.isValid && h.sector3Ms === g.s3;
741
- let _ = "pvx-row";
742
- return h.isValid || (_ += " pvx-row--invalid"), w && (_ += " pvx-row--personal-best"), /* @__PURE__ */ l("tr", { className: _, children: [
743
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e("span", { className: `pvx-rank ${w ? "pvx-rank--gold" : ""}`, children: N + 1 }) }),
744
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-md", children: h.lapNumber || "-" }),
745
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: B(h.lapTimeMs) }),
746
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${P ? "pvx-td--best-sector" : ""}`, children: $(h.sector1Ms) }),
747
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${X ? "pvx-td--best-sector" : ""}`, children: $(h.sector2Ms) }),
748
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${F ? "pvx-td--best-sector" : ""}`, children: $(h.sector3Ms) }),
749
- /* @__PURE__ */ e("td", { className: "pvx-td", title: h.isValid ? void 0 : h.invalidReason || "Invalid", children: h.isValid ? /* @__PURE__ */ e(Be, {}) : /* @__PURE__ */ e(De, {}) }),
750
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", title: se(h.tyreCompound), children: h.tyreCompound || "-" }),
751
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: h.startingFuelL ? `${h.startingFuelL}L` : "-" }),
752
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: D(h.timestamp) })
753
- ] }, h.id);
765
+ /* @__PURE__ */ r("tbody", { className: "pvx-tbody", children: l.map((v, x) => {
766
+ const y = v.isValid && v.lapTimeMs === p, L = b && v.isValid && v.sector1Ms === b.s1, $ = b && v.isValid && v.sector2Ms === b.s2, B = b && v.isValid && v.sector3Ms === b.s3;
767
+ let E = "pvx-row";
768
+ return v.isValid || (E += " pvx-row--invalid"), y && (E += " pvx-row--personal-best"), /* @__PURE__ */ c("tr", { className: E, children: [
769
+ /* @__PURE__ */ r("td", { className: "pvx-td", children: /* @__PURE__ */ r("span", { className: `pvx-rank ${y ? "pvx-rank--gold" : ""}`, children: x + 1 }) }),
770
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-md", children: v.lapNumber || "-" }),
771
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: U(v.lapTimeMs) }),
772
+ /* @__PURE__ */ r("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${L ? "pvx-td--best-sector" : ""}`, children: D(v.sector1Ms) }),
773
+ /* @__PURE__ */ r("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${$ ? "pvx-td--best-sector" : ""}`, children: D(v.sector2Ms) }),
774
+ /* @__PURE__ */ r("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${B ? "pvx-td--best-sector" : ""}`, children: D(v.sector3Ms) }),
775
+ /* @__PURE__ */ r("td", { className: "pvx-td", title: v.isValid ? void 0 : v.invalidReason || "Invalid", children: v.isValid ? /* @__PURE__ */ r(Ae, {}) : /* @__PURE__ */ r(Fe, {}) }),
776
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", title: se(v.tyreCompound), children: v.tyreCompound || "-" }),
777
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: v.startingFuelL ? `${v.startingFuelL}L` : "-" }),
778
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: A(v.timestamp) })
779
+ ] }, v.id);
754
780
  }) })
755
- ] }) }) : /* @__PURE__ */ e(I, { message: i ? "No laps recorded for this combination." : 'No valid laps. Try enabling "Show invalid laps".' })
781
+ ] }) }) : /* @__PURE__ */ r(V, { message: i ? "No laps recorded for this combination." : 'No valid laps. Try enabling "Show invalid laps".' })
756
782
  ] });
757
783
  }
758
- const Ue = {
784
+ const Ee = {
759
785
  GBR: "🇬🇧",
760
786
  DEU: "🇩🇪",
761
787
  NLD: "🇳🇱",
@@ -786,120 +812,120 @@ const Ue = {
786
812
  RUS: "🇷🇺",
787
813
  TUR: "🇹🇷",
788
814
  KOR: "🇰🇷"
789
- }, Ie = ["🥇", "🥈", "🥉"], Ae = {
815
+ }, _e = ["🥇", "🥈", "🥉"], qe = {
790
816
  championship: "Championship",
791
817
  series: "Series",
792
818
  event: "Event"
793
- }, ee = ["PRACTICE", "QUALIFYING", "RACE"];
794
- function he({ position: r }) {
795
- return /* @__PURE__ */ e("span", { className: r === 1 ? "pvx-rank pvx-rank--gold" : r === 2 ? "pvx-rank pvx-rank--silver" : r === 3 ? "pvx-rank pvx-rank--bronze" : "pvx-rank", children: r });
796
- }
797
- function ue({ nation: r }) {
798
- const t = r && Ue[r];
799
- return t ? /* @__PURE__ */ e("span", { className: "pvx-nation-flag", title: r, children: t }) : null;
800
- }
801
- function Fe({ sessions: r, activeSession: t, onSelect: n }) {
802
- if (!r || r.length <= 1) return null;
803
- const a = [...r].sort(
804
- (s, i) => ee.indexOf(s.type) - ee.indexOf(i.type)
819
+ }, re = ["PRACTICE", "QUALIFYING", "RACE"];
820
+ function he({ position: e }) {
821
+ return /* @__PURE__ */ r("span", { className: e === 1 ? "pvx-rank pvx-rank--gold" : e === 2 ? "pvx-rank pvx-rank--silver" : e === 3 ? "pvx-rank pvx-rank--bronze" : "pvx-rank", children: e });
822
+ }
823
+ function xe({ nation: e }) {
824
+ const n = e && Ee[e];
825
+ return n ? /* @__PURE__ */ r("span", { className: "pvx-nation-flag", title: e, children: n }) : null;
826
+ }
827
+ function Ve({ sessions: e, activeSession: n, onSelect: s }) {
828
+ if (!e || e.length <= 1) return null;
829
+ const t = [...e].sort(
830
+ (a, i) => re.indexOf(a.type) - re.indexOf(i.type)
805
831
  );
806
- return /* @__PURE__ */ e("div", { className: "pvx-session-tabs", children: a.map((s) => /* @__PURE__ */ e(
832
+ return /* @__PURE__ */ r("div", { className: "pvx-session-tabs", children: t.map((a) => /* @__PURE__ */ r(
807
833
  "button",
808
834
  {
809
- onClick: () => n(s.type),
810
- className: `pvx-session-tab ${t === s.type ? "pvx-session-tab--active" : ""}`,
811
- children: s.type
835
+ onClick: () => s(a.type),
836
+ className: `pvx-session-tab ${n === a.type ? "pvx-session-tab--active" : ""}`,
837
+ children: a.type
812
838
  },
813
- s.type
839
+ a.type
814
840
  )) });
815
841
  }
816
- function _e({ type: r }) {
817
- return /* @__PURE__ */ e("span", { className: `pvx-comp-badge pvx-comp-badge--${r}`, children: Ae[r] || r });
818
- }
819
- function E({ children: r, variant: t = "default" }) {
820
- return /* @__PURE__ */ e("span", { className: `pvx-info-pill ${t !== "default" ? `pvx-info-pill--${t}` : ""}`, children: r });
821
- }
822
- function Ve(r) {
823
- if (!r) return "TBD";
824
- const t = new Date(r);
825
- if (isNaN(t)) return "TBD";
826
- const n = t.toLocaleDateString("en-GB", { weekday: "short", day: "numeric", month: "short" }), a = t.toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit" });
827
- return `${n} • ${a}`;
828
- }
829
- function Ee(r) {
830
- return r.reduce((t, n) => {
831
- var a;
832
- return (a = n.splits) != null && a.length ? t ? t.map((s, i) => {
833
- const o = n.splits[i];
834
- return o && o < s ? o : s;
835
- }) : [...n.splits] : t;
842
+ function je({ type: e }) {
843
+ return /* @__PURE__ */ r("span", { className: `pvx-comp-badge pvx-comp-badge--${e}`, children: qe[e] || e });
844
+ }
845
+ function H({ children: e, variant: n = "default" }) {
846
+ return /* @__PURE__ */ r("span", { className: `pvx-info-pill ${n !== "default" ? `pvx-info-pill--${n}` : ""}`, children: e });
847
+ }
848
+ function Ke(e) {
849
+ if (!e) return "TBD";
850
+ const n = new Date(e);
851
+ if (isNaN(n)) return "TBD";
852
+ const s = n.toLocaleDateString("en-GB", { weekday: "short", day: "numeric", month: "short" }), t = n.toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit" });
853
+ return `${s} • ${t}`;
854
+ }
855
+ function He(e) {
856
+ return e.reduce((n, s) => {
857
+ var t;
858
+ return (t = s.splits) != null && t.length ? n ? n.map((a, i) => {
859
+ const o = s.splits[i];
860
+ return o && o < a ? o : a;
861
+ }) : [...s.splits] : n;
836
862
  }, null);
837
863
  }
838
- function U({ message: r = "Loading..." }) {
839
- return /* @__PURE__ */ e("div", { className: "pvx-loading", children: r });
864
+ function F({ message: e = "Loading..." }) {
865
+ return /* @__PURE__ */ r("div", { className: "pvx-loading", children: e });
840
866
  }
841
- function M({ message: r = "No data available." }) {
842
- return /* @__PURE__ */ e("div", { className: "pvx-empty", children: /* @__PURE__ */ e("p", { children: r }) });
867
+ function I({ message: e = "No data available." }) {
868
+ return /* @__PURE__ */ r("div", { className: "pvx-empty", children: /* @__PURE__ */ r("p", { children: e }) });
843
869
  }
844
- function yr({ competitions: r, isLoading: t, onSelect: n, onRegister: a, className: s }) {
845
- return t ? /* @__PURE__ */ e(U, { message: "Loading competitions..." }) : r != null && r.length ? /* @__PURE__ */ e("div", { className: `pvx-comp-grid ${s || ""}`, children: r.map((i) => /* @__PURE__ */ e(qe, { comp: i, onSelect: n, onRegister: a || n }, i.id)) }) : /* @__PURE__ */ e(M, { message: "No competitions available." });
870
+ function Ur({ competitions: e, isLoading: n, onSelect: s, onRegister: t, className: a }) {
871
+ return n ? /* @__PURE__ */ r(F, { message: "Loading competitions..." }) : e != null && e.length ? /* @__PURE__ */ r("div", { className: `pvx-comp-grid ${a || ""}`, children: e.map((i) => /* @__PURE__ */ r(Oe, { comp: i, onSelect: s, onRegister: t || s }, i.id)) }) : /* @__PURE__ */ r(I, { message: "No competitions available." });
846
872
  }
847
- function qe({ comp: r, onSelect: t, onRegister: n }) {
848
- var p, f, h;
849
- const { cdnUrl: a } = y(), s = r.posterCdnPath ? `${a}/${r.posterCdnPath}` : null, i = r.registration, o = (i == null ? void 0 : i.currentCount) || 0, c = i == null ? void 0 : i.maxParticipants, v = c && o >= c, d = (i == null ? void 0 : i.deadline) && new Date(i.deadline) < /* @__PURE__ */ new Date(), u = (i == null ? void 0 : i.isOpen) && !d && !v, b = /* @__PURE__ */ new Date(), x = (p = r.rounds) == null ? void 0 : p.find((N) => N.startTime && new Date(N.startTime) >= b), m = ((f = r.rounds) == null ? void 0 : f.length) || 0, g = ((h = r.rounds) == null ? void 0 : h.filter((N) => N.isFinalized).length) || 0;
850
- return /* @__PURE__ */ l(
873
+ function Oe({ comp: e, onSelect: n, onRegister: s }) {
874
+ var p, N, v;
875
+ const { cdnUrl: t } = w(), a = e.posterCdnPath ? `${t}/${e.posterCdnPath}` : null, i = e.registration, o = (i == null ? void 0 : i.currentCount) || 0, d = i == null ? void 0 : i.maxParticipants, u = d && o >= d, l = (i == null ? void 0 : i.deadline) && new Date(i.deadline) < /* @__PURE__ */ new Date(), m = (i == null ? void 0 : i.isOpen) && !l && !u, g = /* @__PURE__ */ new Date(), h = (p = e.rounds) == null ? void 0 : p.find((x) => x.startTime && new Date(x.startTime) >= g), f = ((N = e.rounds) == null ? void 0 : N.length) || 0, b = ((v = e.rounds) == null ? void 0 : v.filter((x) => x.isFinalized).length) || 0;
876
+ return /* @__PURE__ */ c(
851
877
  "div",
852
878
  {
853
879
  className: "pvx-comp-card",
854
- onClick: () => t(r.id),
880
+ onClick: () => n(e.id),
855
881
  role: "button",
856
882
  tabIndex: 0,
857
- onKeyDown: (N) => {
858
- (N.key === "Enter" || N.key === " ") && (N.preventDefault(), t(r.id));
883
+ onKeyDown: (x) => {
884
+ (x.key === "Enter" || x.key === " ") && (x.preventDefault(), n(e.id));
859
885
  },
860
886
  children: [
861
- /* @__PURE__ */ e("div", { className: "pvx-comp-card-poster", children: s ? /* @__PURE__ */ e("img", { src: s, alt: r.name, className: "pvx-comp-card-poster-img" }) : /* @__PURE__ */ e("div", { className: "pvx-comp-card-poster-placeholder", children: /* @__PURE__ */ e(Ke, {}) }) }),
862
- /* @__PURE__ */ l("div", { className: "pvx-comp-card-body", children: [
863
- /* @__PURE__ */ e("h3", { className: "pvx-comp-card-title", children: r.name }),
864
- r.description && /* @__PURE__ */ e("p", { className: "pvx-comp-card-desc", children: r.description }),
865
- /* @__PURE__ */ l("div", { className: "pvx-comp-card-pills", children: [
866
- /* @__PURE__ */ e(_e, { type: r.type }),
867
- r.game && /* @__PURE__ */ e(E, { children: r.game.toUpperCase() }),
868
- r.formatDescription && r.formatDescription.split(", ").map((N, w) => /* @__PURE__ */ e(E, { variant: "format", children: N }, w))
887
+ /* @__PURE__ */ r("div", { className: "pvx-comp-card-poster", children: a ? /* @__PURE__ */ r("img", { src: a, alt: e.name, className: "pvx-comp-card-poster-img" }) : /* @__PURE__ */ r("div", { className: "pvx-comp-card-poster-placeholder", children: /* @__PURE__ */ r(Ge, {}) }) }),
888
+ /* @__PURE__ */ c("div", { className: "pvx-comp-card-body", children: [
889
+ /* @__PURE__ */ r("h3", { className: "pvx-comp-card-title", children: e.name }),
890
+ e.description && /* @__PURE__ */ r("p", { className: "pvx-comp-card-desc", children: e.description }),
891
+ /* @__PURE__ */ c("div", { className: "pvx-comp-card-pills", children: [
892
+ /* @__PURE__ */ r(je, { type: e.type }),
893
+ e.game && /* @__PURE__ */ r(H, { children: e.game.toUpperCase() }),
894
+ e.formatDescription && e.formatDescription.split(", ").map((x, y) => /* @__PURE__ */ r(H, { variant: "format", children: x }, y))
869
895
  ] }),
870
- r.carsDescription && /* @__PURE__ */ e("div", { className: "pvx-comp-card-pills", children: r.carsDescription.split(", ").map((N, w) => /* @__PURE__ */ e(E, { children: N }, w)) }),
871
- /* @__PURE__ */ l("div", { className: "pvx-comp-card-schedule", children: [
872
- x ? /* @__PURE__ */ l("span", { className: "pvx-comp-card-schedule-next", children: [
873
- /* @__PURE__ */ e("span", { className: "pvx-comp-card-schedule-label", children: "Next:" }),
896
+ e.carsDescription && /* @__PURE__ */ r("div", { className: "pvx-comp-card-pills", children: e.carsDescription.split(", ").map((x, y) => /* @__PURE__ */ r(H, { children: x }, y)) }),
897
+ /* @__PURE__ */ c("div", { className: "pvx-comp-card-schedule", children: [
898
+ h ? /* @__PURE__ */ c("span", { className: "pvx-comp-card-schedule-next", children: [
899
+ /* @__PURE__ */ r("span", { className: "pvx-comp-card-schedule-label", children: "Next:" }),
874
900
  " ",
875
901
  "R",
876
- x.roundNumber,
902
+ h.roundNumber,
877
903
  " ",
878
- x.track || "TBD",
904
+ h.track || "TBD",
879
905
  " — ",
880
- Ve(x.startTime)
881
- ] }) : m > 0 ? /* @__PURE__ */ l("span", { className: "pvx-comp-card-schedule-next", children: [
882
- g,
906
+ Ke(h.startTime)
907
+ ] }) : f > 0 ? /* @__PURE__ */ c("span", { className: "pvx-comp-card-schedule-next", children: [
908
+ b,
883
909
  "/",
884
- m,
910
+ f,
885
911
  " rounds completed"
886
912
  ] }) : null,
887
- m > 0 && /* @__PURE__ */ l("span", { className: "pvx-comp-card-round-count", children: [
888
- m,
913
+ f > 0 && /* @__PURE__ */ c("span", { className: "pvx-comp-card-round-count", children: [
914
+ f,
889
915
  " round",
890
- m !== 1 ? "s" : ""
916
+ f !== 1 ? "s" : ""
891
917
  ] })
892
918
  ] }),
893
- i && /* @__PURE__ */ e(
894
- je,
919
+ i && /* @__PURE__ */ r(
920
+ We,
895
921
  {
896
- competitionId: r.id,
897
- regOpen: u,
898
- isFull: v,
899
- deadlinePassed: d,
922
+ competitionId: e.id,
923
+ regOpen: m,
924
+ isFull: u,
925
+ deadlinePassed: l,
900
926
  regCount: o,
901
- regMax: c,
902
- onRegister: n
927
+ regMax: d,
928
+ onRegister: s
903
929
  }
904
930
  )
905
931
  ] })
@@ -907,754 +933,1006 @@ function qe({ comp: r, onSelect: t, onRegister: n }) {
907
933
  }
908
934
  );
909
935
  }
910
- function je({ competitionId: r, regOpen: t, isFull: n, deadlinePassed: a, regCount: s, regMax: i, onRegister: o }) {
911
- const { isPowerMode: c } = G(), v = z(r), { data: d } = W(r), u = (d == null ? void 0 : d.isRegistered) || !1, b = i ? s / i * 100 : 0, x = b >= 100 ? "full" : b >= 75 ? "warning" : "ok";
912
- return /* @__PURE__ */ l("div", { className: "pvx-comp-card-reg", children: [
913
- /* @__PURE__ */ e("div", { className: "pvx-comp-card-reg-info", children: /* @__PURE__ */ l("span", { className: `pvx-reg-capacity pvx-reg-capacity--${x}`, children: [
914
- s,
936
+ function We({ competitionId: e, regOpen: n, isFull: s, deadlinePassed: t, regCount: a, regMax: i, onRegister: o }) {
937
+ const { isPowerMode: d } = Q(), u = Y(e), { data: l } = z(e), m = (l == null ? void 0 : l.isRegistered) || !1, g = i ? a / i * 100 : 0, h = g >= 100 ? "full" : g >= 75 ? "warning" : "ok";
938
+ return /* @__PURE__ */ c("div", { className: "pvx-comp-card-reg", children: [
939
+ /* @__PURE__ */ r("div", { className: "pvx-comp-card-reg-info", children: /* @__PURE__ */ c("span", { className: `pvx-reg-capacity pvx-reg-capacity--${h}`, children: [
940
+ a,
915
941
  "/",
916
942
  i || "∞",
917
943
  " drivers"
918
944
  ] }) }),
919
- /* @__PURE__ */ e("div", { className: "pvx-comp-card-reg-action", children: u ? /* @__PURE__ */ e(
945
+ /* @__PURE__ */ r("div", { className: "pvx-comp-card-reg-action", children: m ? /* @__PURE__ */ r(
920
946
  "button",
921
947
  {
922
948
  className: "pvx-comp-card-reg-btn pvx-comp-card-reg-btn--registered",
923
- onClick: (m) => {
924
- m.stopPropagation(), o(r);
949
+ onClick: (f) => {
950
+ f.stopPropagation(), o(e);
925
951
  },
926
952
  children: "✓ Registered"
927
953
  }
928
- ) : t ? c ? /* @__PURE__ */ e(
954
+ ) : n ? d ? /* @__PURE__ */ r(
929
955
  "button",
930
956
  {
931
957
  className: "pvx-comp-card-reg-btn pvx-comp-card-reg-btn--open",
932
- onClick: (m) => {
933
- m.stopPropagation(), o(r);
958
+ onClick: (f) => {
959
+ f.stopPropagation(), o(e);
934
960
  },
935
961
  children: "Register"
936
962
  }
937
- ) : /* @__PURE__ */ e(
963
+ ) : /* @__PURE__ */ r(
938
964
  "a",
939
965
  {
940
- href: v,
966
+ href: u,
941
967
  target: "_blank",
942
968
  rel: "noopener noreferrer",
943
969
  className: "pvx-comp-card-reg-btn pvx-comp-card-reg-btn--open",
944
- onClick: (m) => m.stopPropagation(),
970
+ onClick: (f) => f.stopPropagation(),
945
971
  children: "Register"
946
972
  }
947
- ) : /* @__PURE__ */ e("span", { className: "pvx-comp-card-reg-btn pvx-comp-card-reg-btn--closed", children: n ? "Full" : "Closed" }) })
973
+ ) : /* @__PURE__ */ r("span", { className: "pvx-comp-card-reg-btn pvx-comp-card-reg-btn--closed", children: s ? "Full" : "Closed" }) })
948
974
  ] });
949
975
  }
950
- function Ke() {
951
- return /* @__PURE__ */ l("svg", { className: "pvx-comp-trophy-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
952
- /* @__PURE__ */ e("path", { d: "M6 9H4.5a2.5 2.5 0 0 1 0-5H6" }),
953
- /* @__PURE__ */ e("path", { d: "M18 9h1.5a2.5 2.5 0 0 0 0-5H18" }),
954
- /* @__PURE__ */ e("path", { d: "M4 22h16" }),
955
- /* @__PURE__ */ e("path", { d: "M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22" }),
956
- /* @__PURE__ */ e("path", { d: "M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22" }),
957
- /* @__PURE__ */ e("path", { d: "M18 2H6v7a6 6 0 0 0 12 0V2Z" })
976
+ function Ge() {
977
+ return /* @__PURE__ */ c("svg", { className: "pvx-comp-trophy-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
978
+ /* @__PURE__ */ r("path", { d: "M6 9H4.5a2.5 2.5 0 0 1 0-5H6" }),
979
+ /* @__PURE__ */ r("path", { d: "M18 9h1.5a2.5 2.5 0 0 0 0-5H18" }),
980
+ /* @__PURE__ */ r("path", { d: "M4 22h16" }),
981
+ /* @__PURE__ */ r("path", { d: "M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22" }),
982
+ /* @__PURE__ */ r("path", { d: "M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22" }),
983
+ /* @__PURE__ */ r("path", { d: "M18 2H6v7a6 6 0 0 0 12 0V2Z" })
958
984
  ] });
959
985
  }
960
- function Cr({ competitionId: r, className: t }) {
961
- var c, v;
962
- const { data: n, isLoading: a } = Re(r), { data: s, isLoading: i } = Se(r);
963
- if (a || i)
964
- return /* @__PURE__ */ e(U, { message: "Loading standings..." });
965
- if (!((c = n == null ? void 0 : n.standings) != null && c.length))
966
- return /* @__PURE__ */ e(M, { message: "No standings data yet. Results will appear once rounds are finalised." });
967
- const o = ((v = s == null ? void 0 : s.rounds) == null ? void 0 : v.filter((d) => d.isFinalized)) || [];
968
- return /* @__PURE__ */ l("div", { className: `pvx-card ${t || ""}`, children: [
969
- /* @__PURE__ */ e("div", { className: "pvx-card-header--split", children: /* @__PURE__ */ l("div", { className: "pvx-card-header-left", children: [
970
- /* @__PURE__ */ e("h3", { className: "pvx-card-title", children: "Championship Standings" }),
971
- /* @__PURE__ */ l("span", { className: "pvx-standings-subtitle", children: [
986
+ function Ar({ competitionId: e, className: n }) {
987
+ var d, u;
988
+ const { data: s, isLoading: t } = De(e), { data: a, isLoading: i } = Me(e);
989
+ if (t || i)
990
+ return /* @__PURE__ */ r(F, { message: "Loading standings..." });
991
+ if (!((d = s == null ? void 0 : s.standings) != null && d.length))
992
+ return /* @__PURE__ */ r(I, { message: "No standings data yet. Results will appear once rounds are finalised." });
993
+ const o = ((u = a == null ? void 0 : a.rounds) == null ? void 0 : u.filter((l) => l.isFinalized)) || [];
994
+ return /* @__PURE__ */ c("div", { className: `pvx-card ${n || ""}`, children: [
995
+ /* @__PURE__ */ r("div", { className: "pvx-card-header--split", children: /* @__PURE__ */ c("div", { className: "pvx-card-header-left", children: [
996
+ /* @__PURE__ */ r("h3", { className: "pvx-card-title", children: "Championship Standings" }),
997
+ /* @__PURE__ */ c("span", { className: "pvx-standings-subtitle", children: [
972
998
  "After ",
973
- n.roundsCompleted,
999
+ s.roundsCompleted,
974
1000
  " round",
975
- n.roundsCompleted !== 1 ? "s" : "",
976
- n.countingRounds > 0 && ` (best ${n.countingRounds} count)`
1001
+ s.roundsCompleted !== 1 ? "s" : "",
1002
+ s.countingRounds > 0 && ` (best ${s.countingRounds} count)`
977
1003
  ] })
978
1004
  ] }) }),
979
- /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
980
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
981
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--narrow", children: "Pos" }),
982
- /* @__PURE__ */ e("th", { className: "pvx-th", children: "Driver" }),
983
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--center pvx-hidden-below-sm", children: "W" }),
984
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--center pvx-hidden-below-sm", children: "Pod" }),
985
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--center", children: "Points" }),
986
- o.map((d) => /* @__PURE__ */ l(
1005
+ /* @__PURE__ */ r("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ c("table", { className: "pvx-table", children: [
1006
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ c("tr", { className: "pvx-thead-row", children: [
1007
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-th--narrow", children: "Pos" }),
1008
+ /* @__PURE__ */ r("th", { className: "pvx-th", children: "Driver" }),
1009
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-th--center pvx-hidden-below-sm", children: "W" }),
1010
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-th--center pvx-hidden-below-sm", children: "Pod" }),
1011
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-th--center", children: "Points" }),
1012
+ o.map((l) => /* @__PURE__ */ c(
987
1013
  "th",
988
1014
  {
989
1015
  className: "pvx-th pvx-th--center pvx-hidden-below-md",
990
- title: d.track || `Round ${d.roundNumber}`,
1016
+ title: l.track || `Round ${l.roundNumber}`,
991
1017
  children: [
992
1018
  "R",
993
- d.roundNumber
1019
+ l.roundNumber
994
1020
  ]
995
1021
  },
996
- d.roundNumber
1022
+ l.roundNumber
997
1023
  ))
998
1024
  ] }) }),
999
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: n.standings.map((d) => /* @__PURE__ */ e(
1000
- He,
1025
+ /* @__PURE__ */ r("tbody", { className: "pvx-tbody", children: s.standings.map((l) => /* @__PURE__ */ r(
1026
+ ze,
1001
1027
  {
1002
- driver: d,
1028
+ driver: l,
1003
1029
  finalizedRounds: o
1004
1030
  },
1005
- d.driverId || d.driverName
1031
+ l.driverId || l.driverName
1006
1032
  )) })
1007
1033
  ] }) })
1008
1034
  ] });
1009
1035
  }
1010
- function He({ driver: r, finalizedRounds: t }) {
1011
- var o, c, v;
1012
- const n = r.position <= 3, a = new Map(
1013
- ((o = r.roundResults) == null ? void 0 : o.map((d) => [d.roundNumber, d])) || []
1014
- ), s = ((c = r.roundResults) == null ? void 0 : c.filter((d) => d.position === 1).length) || 0, i = ((v = r.roundResults) == null ? void 0 : v.filter((d) => d.position <= 3).length) || 0;
1015
- return /* @__PURE__ */ l("tr", { className: `pvx-row ${n ? "pvx-row--podium" : ""}`, children: [
1016
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(he, { position: r.position }) }),
1017
- /* @__PURE__ */ l("td", { className: "pvx-td pvx-td--primary", children: [
1018
- /* @__PURE__ */ e(ue, { nation: r.nation }),
1019
- r.driverName
1036
+ function ze({ driver: e, finalizedRounds: n }) {
1037
+ var o, d, u;
1038
+ const s = e.position <= 3, t = new Map(
1039
+ ((o = e.roundResults) == null ? void 0 : o.map((l) => [l.roundNumber, l])) || []
1040
+ ), a = ((d = e.roundResults) == null ? void 0 : d.filter((l) => l.position === 1).length) || 0, i = ((u = e.roundResults) == null ? void 0 : u.filter((l) => l.position <= 3).length) || 0;
1041
+ return /* @__PURE__ */ c("tr", { className: `pvx-row ${s ? "pvx-row--podium" : ""}`, children: [
1042
+ /* @__PURE__ */ r("td", { className: "pvx-td", children: /* @__PURE__ */ r(he, { position: e.position }) }),
1043
+ /* @__PURE__ */ c("td", { className: "pvx-td pvx-td--primary", children: [
1044
+ /* @__PURE__ */ r(xe, { nation: e.nation }),
1045
+ e.driverName
1020
1046
  ] }),
1021
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-sm", children: s || "-" }),
1022
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-sm", children: i || "-" }),
1023
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-standings-total", children: r.totalPoints }),
1024
- t.map((d) => {
1025
- const u = a.get(d.roundNumber), b = u == null ? void 0 : u.dropped;
1026
- return /* @__PURE__ */ e(
1047
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--center pvx-hidden-below-sm", children: a || "-" }),
1048
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--center pvx-hidden-below-sm", children: i || "-" }),
1049
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--center pvx-standings-total", children: e.totalPoints }),
1050
+ n.map((l) => {
1051
+ const m = t.get(l.roundNumber), g = m == null ? void 0 : m.dropped;
1052
+ return /* @__PURE__ */ r(
1027
1053
  "td",
1028
1054
  {
1029
- className: `pvx-td pvx-td--center pvx-hidden-below-md ${!b && (u == null ? void 0 : u.position) <= 3 ? "pvx-standings-cell--podium" : ""}`,
1030
- children: u ? /* @__PURE__ */ l("div", { className: `pvx-standings-round-cell ${b ? "pvx-standings-round-cell--dropped" : ""}`, children: [
1031
- /* @__PURE__ */ l("span", { className: "pvx-standings-round-pos", children: [
1055
+ className: `pvx-td pvx-td--center pvx-hidden-below-md ${!g && (m == null ? void 0 : m.position) <= 3 ? "pvx-standings-cell--podium" : ""}`,
1056
+ children: m ? /* @__PURE__ */ c("div", { className: `pvx-standings-round-cell ${g ? "pvx-standings-round-cell--dropped" : ""}`, children: [
1057
+ /* @__PURE__ */ c("span", { className: "pvx-standings-round-pos", children: [
1032
1058
  "P",
1033
- u.position
1059
+ m.position
1034
1060
  ] }),
1035
- /* @__PURE__ */ e("span", { className: "pvx-standings-round-pts", children: u.points })
1036
- ] }) : /* @__PURE__ */ e("span", { className: "pvx-td--muted", children: "-" })
1061
+ /* @__PURE__ */ r("span", { className: "pvx-standings-round-pts", children: m.points })
1062
+ ] }) : /* @__PURE__ */ r("span", { className: "pvx-td--muted", children: "-" })
1037
1063
  },
1038
- d.roundNumber
1064
+ l.roundNumber
1039
1065
  );
1040
1066
  })
1041
1067
  ] });
1042
1068
  }
1043
- function wr({ competitionId: r, roundNumber: t, className: n }) {
1044
- var v;
1045
- const { data: a, isLoading: s } = Le(r, t);
1046
- if (s)
1047
- return /* @__PURE__ */ e(U, { message: "Loading results..." });
1048
- if (!a)
1049
- return /* @__PURE__ */ e(M, { message: "No results for this round." });
1050
- const o = (a.sessions || []).find((d) => d.type === "RACE"), c = (v = o == null ? void 0 : o.results) == null ? void 0 : v.filter((d) => d.position <= 3).sort((d, u) => d.position - u.position);
1051
- return /* @__PURE__ */ l("div", { className: `pvx-round-results ${n || ""}`, children: [
1052
- /* @__PURE__ */ l("div", { className: "pvx-round-results-header", children: [
1053
- /* @__PURE__ */ l("div", { children: [
1054
- /* @__PURE__ */ l("h4", { className: "pvx-round-results-title", children: [
1069
+ function Fr({ competitionId: e, roundNumber: n, className: s }) {
1070
+ var u;
1071
+ const { data: t, isLoading: a } = Ie(e, n);
1072
+ if (a)
1073
+ return /* @__PURE__ */ r(F, { message: "Loading results..." });
1074
+ if (!t)
1075
+ return /* @__PURE__ */ r(I, { message: "No results for this round." });
1076
+ const o = (t.sessions || []).find((l) => l.type === "RACE"), d = (u = o == null ? void 0 : o.results) == null ? void 0 : u.filter((l) => l.position <= 3).sort((l, m) => l.position - m.position);
1077
+ return /* @__PURE__ */ c("div", { className: `pvx-round-results ${s || ""}`, children: [
1078
+ /* @__PURE__ */ c("div", { className: "pvx-round-results-header", children: [
1079
+ /* @__PURE__ */ c("div", { children: [
1080
+ /* @__PURE__ */ c("h4", { className: "pvx-round-results-title", children: [
1055
1081
  "Round ",
1056
- a.roundNumber,
1057
- a.track ? `: ${a.track}` : ""
1082
+ t.roundNumber,
1083
+ t.track ? `: ${t.track}` : ""
1058
1084
  ] }),
1059
- a.startTime && /* @__PURE__ */ e("p", { className: "pvx-round-results-date", children: new Date(a.startTime).toLocaleDateString("en-GB", {
1085
+ t.startTime && /* @__PURE__ */ r("p", { className: "pvx-round-results-date", children: new Date(t.startTime).toLocaleDateString("en-GB", {
1060
1086
  day: "numeric",
1061
1087
  month: "long",
1062
1088
  year: "numeric"
1063
1089
  }) })
1064
1090
  ] }),
1065
- (c == null ? void 0 : c.length) > 0 && /* @__PURE__ */ e("div", { className: "pvx-round-podium-summary", children: c.map((d) => /* @__PURE__ */ l("span", { className: "pvx-round-podium-item", children: [
1066
- /* @__PURE__ */ e("span", { children: Ie[d.position - 1] }),
1067
- /* @__PURE__ */ e("span", { children: d.driverName })
1068
- ] }, d.driverId)) })
1091
+ (d == null ? void 0 : d.length) > 0 && /* @__PURE__ */ r("div", { className: "pvx-round-podium-summary", children: d.map((l) => /* @__PURE__ */ c("span", { className: "pvx-round-podium-item", children: [
1092
+ /* @__PURE__ */ r("span", { children: _e[l.position - 1] }),
1093
+ /* @__PURE__ */ r("span", { children: l.driverName })
1094
+ ] }, l.driverId)) })
1069
1095
  ] }),
1070
- /* @__PURE__ */ e(Oe, { round: a })
1096
+ /* @__PURE__ */ r(Qe, { round: t })
1071
1097
  ] });
1072
1098
  }
1073
- function Oe({ round: r, className: t }) {
1074
- var c, v;
1075
- const [n, a] = L(null), s = (r == null ? void 0 : r.sessions) || [];
1076
- if (!s.length)
1077
- return /* @__PURE__ */ e(M, { message: "No session data for this round." });
1078
- const i = n || ((c = s.find((d) => d.type === "RACE")) == null ? void 0 : c.type) || ((v = s[0]) == null ? void 0 : v.type), o = s.find((d) => d.type === i) || s[0];
1079
- return /* @__PURE__ */ l("div", { className: t || "", children: [
1080
- /* @__PURE__ */ e(
1081
- Fe,
1099
+ function Qe({ round: e, className: n }) {
1100
+ var d, u;
1101
+ const [s, t] = M(null), a = (e == null ? void 0 : e.sessions) || [];
1102
+ if (!a.length)
1103
+ return /* @__PURE__ */ r(I, { message: "No session data for this round." });
1104
+ const i = s || ((d = a.find((l) => l.type === "RACE")) == null ? void 0 : d.type) || ((u = a[0]) == null ? void 0 : u.type), o = a.find((l) => l.type === i) || a[0];
1105
+ return /* @__PURE__ */ c("div", { className: n || "", children: [
1106
+ /* @__PURE__ */ r(
1107
+ Ve,
1082
1108
  {
1083
- sessions: s,
1109
+ sessions: a,
1084
1110
  activeSession: i,
1085
- onSelect: a
1111
+ onSelect: t
1086
1112
  }
1087
1113
  ),
1088
- /* @__PURE__ */ e(We, { session: o })
1114
+ /* @__PURE__ */ r(Ye, { session: o })
1089
1115
  ] });
1090
1116
  }
1091
- function We({ session: r }) {
1092
- var a;
1093
- const t = r.type === "RACE";
1094
- if (!((a = r.results) != null && a.length))
1095
- return /* @__PURE__ */ e(M, { message: `No results for ${r.type}.` });
1096
- const n = Ee(r.results);
1097
- return /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
1098
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
1099
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--narrow", children: "Pos" }),
1100
- /* @__PURE__ */ e("th", { className: "pvx-th", children: "Driver" }),
1101
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "Car" }),
1102
- /* @__PURE__ */ e("th", { className: "pvx-th", children: "Best Lap" }),
1103
- t && /* @__PURE__ */ l(K, { children: [
1104
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "Laps" }),
1105
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "Time / Gap" }),
1106
- /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--center", children: "Points" })
1117
+ function Ye({ session: e }) {
1118
+ var t;
1119
+ const n = e.type === "RACE";
1120
+ if (!((t = e.results) != null && t.length))
1121
+ return /* @__PURE__ */ r(I, { message: `No results for ${e.type}.` });
1122
+ const s = He(e.results);
1123
+ return /* @__PURE__ */ r("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ c("table", { className: "pvx-table", children: [
1124
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ c("tr", { className: "pvx-thead-row", children: [
1125
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-th--narrow", children: "Pos" }),
1126
+ /* @__PURE__ */ r("th", { className: "pvx-th", children: "Driver" }),
1127
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-sm", children: "Car" }),
1128
+ /* @__PURE__ */ r("th", { className: "pvx-th", children: "Best Lap" }),
1129
+ n && /* @__PURE__ */ c(G, { children: [
1130
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-sm", children: "Laps" }),
1131
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-hidden-below-sm", children: "Time / Gap" }),
1132
+ /* @__PURE__ */ r("th", { className: "pvx-th pvx-th--center", children: "Points" })
1107
1133
  ] })
1108
1134
  ] }) }),
1109
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: r.results.map((s, i) => /* @__PURE__ */ e(
1110
- Ge,
1135
+ /* @__PURE__ */ r("tbody", { className: "pvx-tbody", children: e.results.map((a, i) => /* @__PURE__ */ r(
1136
+ Ze,
1111
1137
  {
1112
- result: s,
1113
- isRace: t,
1114
- fastestSplits: n,
1138
+ result: a,
1139
+ isRace: n,
1140
+ fastestSplits: s,
1115
1141
  rowIndex: i
1116
1142
  },
1117
- s.driverId || i
1143
+ a.driverId || i
1118
1144
  )) })
1119
1145
  ] }) });
1120
1146
  }
1121
- function Ge({ result: r, isRace: t, fastestSplits: n, rowIndex: a }) {
1122
- const s = r.position <= 3;
1123
- return /* @__PURE__ */ l("tr", { className: `pvx-row ${s ? "pvx-row--podium" : ""}`, children: [
1124
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(he, { position: r.position }) }),
1125
- /* @__PURE__ */ l("td", { className: "pvx-td pvx-td--primary", children: [
1126
- /* @__PURE__ */ e(ue, { nation: r.nation }),
1127
- r.driverName,
1128
- r.carNumber != null && /* @__PURE__ */ l("span", { className: "pvx-car-number", children: [
1147
+ function Ze({ result: e, isRace: n, fastestSplits: s, rowIndex: t }) {
1148
+ const a = e.position <= 3;
1149
+ return /* @__PURE__ */ c("tr", { className: `pvx-row ${a ? "pvx-row--podium" : ""}`, children: [
1150
+ /* @__PURE__ */ r("td", { className: "pvx-td", children: /* @__PURE__ */ r(he, { position: e.position }) }),
1151
+ /* @__PURE__ */ c("td", { className: "pvx-td pvx-td--primary", children: [
1152
+ /* @__PURE__ */ r(xe, { nation: e.nation }),
1153
+ e.driverName,
1154
+ e.carNumber != null && /* @__PURE__ */ c("span", { className: "pvx-car-number", children: [
1129
1155
  "#",
1130
- r.carNumber
1156
+ e.carNumber
1131
1157
  ] }),
1132
- r.penalty && /* @__PURE__ */ e("span", { className: "pvx-penalty", children: r.penalty })
1158
+ e.penalty && /* @__PURE__ */ r("span", { className: "pvx-penalty", children: e.penalty })
1133
1159
  ] }),
1134
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-hidden-below-sm", children: R(r.carId) }),
1135
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--mono", children: /* @__PURE__ */ e(
1136
- ze,
1160
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-hidden-below-sm", children: S(e.carId) }),
1161
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--mono", children: /* @__PURE__ */ r(
1162
+ Je,
1137
1163
  {
1138
- bestLap: r.bestLapFormatted,
1139
- hasBestLap: r.hasBestLap,
1140
- splits: r.splits,
1141
- fastestSplits: n,
1142
- showAbove: a <= 1
1164
+ bestLap: e.bestLapFormatted,
1165
+ hasBestLap: e.hasBestLap,
1166
+ splits: e.splits,
1167
+ fastestSplits: s,
1168
+ showAbove: t <= 1
1143
1169
  }
1144
1170
  ) }),
1145
- t && /* @__PURE__ */ l(K, { children: [
1146
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-hidden-below-sm", children: r.lapsCompleted }),
1147
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--mono pvx-td--muted pvx-hidden-below-sm", children: r.position === 1 ? r.totalTime || "-" : r.gap || "-" }),
1148
- /* @__PURE__ */ l("td", { className: "pvx-td pvx-td--center", children: [
1149
- /* @__PURE__ */ e("span", { className: "pvx-session-points", children: r.points }),
1150
- r.pointsOverride !== 0 && r.pointsOverride && /* @__PURE__ */ l("span", { className: "pvx-points-override", children: [
1171
+ n && /* @__PURE__ */ c(G, { children: [
1172
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-hidden-below-sm", children: e.lapsCompleted }),
1173
+ /* @__PURE__ */ r("td", { className: "pvx-td pvx-td--mono pvx-td--muted pvx-hidden-below-sm", children: e.position === 1 ? e.totalTime || "-" : e.gap || "-" }),
1174
+ /* @__PURE__ */ c("td", { className: "pvx-td pvx-td--center", children: [
1175
+ /* @__PURE__ */ r("span", { className: "pvx-session-points", children: e.points }),
1176
+ e.pointsOverride !== 0 && e.pointsOverride && /* @__PURE__ */ c("span", { className: "pvx-points-override", children: [
1151
1177
  "(",
1152
- r.pointsOverride > 0 ? "+" : "",
1153
- r.pointsOverride,
1178
+ e.pointsOverride > 0 ? "+" : "",
1179
+ e.pointsOverride,
1154
1180
  ")"
1155
1181
  ] })
1156
1182
  ] })
1157
1183
  ] })
1158
1184
  ] });
1159
1185
  }
1160
- function ze({ bestLap: r, hasBestLap: t, splits: n, fastestSplits: a, showAbove: s }) {
1161
- return r ? /* @__PURE__ */ l("span", { className: `pvx-best-lap-cell ${t ? "pvx-best-lap-cell--fastest" : ""}`, children: [
1162
- /* @__PURE__ */ e("span", { className: "pvx-best-lap-time", children: r }),
1163
- (n == null ? void 0 : n.length) > 0 && /* @__PURE__ */ e("span", { className: "pvx-splits-tooltip-anchor", children: /* @__PURE__ */ e("span", { className: `pvx-splits-tooltip ${s ? "" : "pvx-splits-tooltip--above"}`, children: n.map((i, o) => {
1164
- const c = a && i === a[o];
1165
- return /* @__PURE__ */ l("span", { className: "pvx-splits-tooltip-row", children: [
1166
- /* @__PURE__ */ l("span", { className: "pvx-splits-tooltip-label", children: [
1186
+ function Je({ bestLap: e, hasBestLap: n, splits: s, fastestSplits: t, showAbove: a }) {
1187
+ return e ? /* @__PURE__ */ c("span", { className: `pvx-best-lap-cell ${n ? "pvx-best-lap-cell--fastest" : ""}`, children: [
1188
+ /* @__PURE__ */ r("span", { className: "pvx-best-lap-time", children: e }),
1189
+ (s == null ? void 0 : s.length) > 0 && /* @__PURE__ */ r("span", { className: "pvx-splits-tooltip-anchor", children: /* @__PURE__ */ r("span", { className: `pvx-splits-tooltip ${a ? "" : "pvx-splits-tooltip--above"}`, children: s.map((i, o) => {
1190
+ const d = t && i === t[o];
1191
+ return /* @__PURE__ */ c("span", { className: "pvx-splits-tooltip-row", children: [
1192
+ /* @__PURE__ */ c("span", { className: "pvx-splits-tooltip-label", children: [
1167
1193
  "S",
1168
1194
  o + 1
1169
1195
  ] }),
1170
- /* @__PURE__ */ e("span", { className: c ? "pvx-splits-tooltip-best" : "", children: i })
1196
+ /* @__PURE__ */ r("span", { className: d ? "pvx-splits-tooltip-best" : "", children: i })
1171
1197
  ] }, o);
1172
1198
  }) }) })
1173
- ] }) : /* @__PURE__ */ e("span", { className: "pvx-td--muted", children: "-" });
1174
- }
1175
- function kr({ competitionId: r, className: t }) {
1176
- const { getSteamId: n } = y(), { data: a, isLoading: s } = ae(r), i = n();
1177
- if (s)
1178
- return /* @__PURE__ */ e(U, { message: "Loading drivers..." });
1179
- const o = (a == null ? void 0 : a.drivers) || (a == null ? void 0 : a.entries) || [];
1180
- return o.length ? /* @__PURE__ */ e("div", { className: `pvx-entry-grid ${t || ""}`, children: o.map((c) => {
1181
- var d, u;
1182
- const v = i && c.steamId === i;
1183
- return /* @__PURE__ */ l("div", { className: `pvx-entry-card ${v ? "pvx-entry-card--you" : ""}`, children: [
1184
- c.avatarUrl ? /* @__PURE__ */ e(
1199
+ ] }) : /* @__PURE__ */ r("span", { className: "pvx-td--muted", children: "-" });
1200
+ }
1201
+ function Er({ competitionId: e, className: n }) {
1202
+ const { getSteamId: s } = w(), { data: t, isLoading: a } = ie(e), i = s();
1203
+ if (a)
1204
+ return /* @__PURE__ */ r(F, { message: "Loading drivers..." });
1205
+ const o = (t == null ? void 0 : t.drivers) || (t == null ? void 0 : t.entries) || [];
1206
+ return o.length ? /* @__PURE__ */ r("div", { className: `pvx-entry-grid ${n || ""}`, children: o.map((d) => {
1207
+ var l, m;
1208
+ const u = i && d.steamId === i;
1209
+ return /* @__PURE__ */ c("div", { className: `pvx-entry-card ${u ? "pvx-entry-card--you" : ""}`, children: [
1210
+ d.avatarUrl ? /* @__PURE__ */ r(
1185
1211
  "img",
1186
1212
  {
1187
- src: c.avatarUrl,
1213
+ src: d.avatarUrl,
1188
1214
  alt: "",
1189
1215
  className: "pvx-entry-avatar"
1190
1216
  }
1191
- ) : /* @__PURE__ */ e("div", { className: "pvx-entry-avatar pvx-entry-avatar--placeholder", children: ((u = (d = c.displayName) == null ? void 0 : d.charAt(0)) == null ? void 0 : u.toUpperCase()) || "?" }),
1192
- /* @__PURE__ */ l("span", { className: "pvx-entry-name", children: [
1193
- c.displayName,
1194
- v && /* @__PURE__ */ e("span", { className: "pvx-entry-you", children: " (you)" })
1217
+ ) : /* @__PURE__ */ r("div", { className: "pvx-entry-avatar pvx-entry-avatar--placeholder", children: ((m = (l = d.displayName) == null ? void 0 : l.charAt(0)) == null ? void 0 : m.toUpperCase()) || "?" }),
1218
+ /* @__PURE__ */ c("span", { className: "pvx-entry-name", children: [
1219
+ d.displayName,
1220
+ u && /* @__PURE__ */ r("span", { className: "pvx-entry-you", children: " (you)" })
1195
1221
  ] })
1196
- ] }, c.steamId || c.driverId);
1197
- }) }) : /* @__PURE__ */ e(M, { message: "No drivers registered yet." });
1198
- }
1199
- function Tr({
1200
- competitionId: r,
1201
- driverData: t,
1202
- className: n,
1203
- children: a
1222
+ ] }, d.steamId || d.driverId);
1223
+ }) }) : /* @__PURE__ */ r(I, { message: "No drivers registered yet." });
1224
+ }
1225
+ function _r({
1226
+ competitionId: e,
1227
+ driverData: n,
1228
+ className: s,
1229
+ children: t
1204
1230
  }) {
1205
- const { data: s, isLoading: i } = W(r), { isPowerMode: o } = G(), c = z(r), v = ie(r), d = le(r), u = (s == null ? void 0 : s.isRegistered) || !1, b = i || v.isPending || d.isPending, x = v.error || d.error || null, m = () => {
1206
- o && v.mutate(t || {});
1207
- }, g = () => {
1208
- o && d.mutate();
1231
+ const { data: a, isLoading: i } = z(e), { isPowerMode: o } = Q(), d = Y(e), u = oe(e), l = ce(e), m = (a == null ? void 0 : a.isRegistered) || !1, g = i || u.isPending || l.isPending, h = u.error || l.error || null, f = () => {
1232
+ o && u.mutate(n || {});
1233
+ }, b = () => {
1234
+ o && l.mutate();
1209
1235
  };
1210
- return typeof a == "function" ? a({ isRegistered: u, isLoading: b, register: m, withdraw: g, error: x, isPowerMode: o, registrationUrl: c }) : o ? /* @__PURE__ */ e(
1236
+ return typeof t == "function" ? t({ isRegistered: m, isLoading: g, register: f, withdraw: b, error: h, isPowerMode: o, registrationUrl: d }) : o ? /* @__PURE__ */ r(
1211
1237
  "button",
1212
1238
  {
1213
- className: `pvx-comp-register-btn ${n || ""}`,
1214
- onClick: u ? g : m,
1215
- disabled: b,
1216
- children: b ? "Loading..." : u ? "Withdraw" : "Register"
1239
+ className: `pvx-comp-register-btn ${s || ""}`,
1240
+ onClick: m ? b : f,
1241
+ disabled: g,
1242
+ children: g ? "Loading..." : m ? "Withdraw" : "Register"
1217
1243
  }
1218
- ) : /* @__PURE__ */ e(
1244
+ ) : /* @__PURE__ */ r(
1219
1245
  "a",
1220
1246
  {
1221
- href: c,
1247
+ href: d,
1222
1248
  target: "_blank",
1223
1249
  rel: "noopener noreferrer",
1224
- className: `pvx-comp-register-link ${n || ""}`,
1225
- children: u ? "View Registration" : "Register on PitVox"
1250
+ className: `pvx-comp-register-link ${s || ""}`,
1251
+ children: m ? "View Registration" : "Register on PitVox"
1226
1252
  }
1227
1253
  );
1228
1254
  }
1229
- function Sr({ competitionId: r, registration: t, className: n }) {
1230
- const { getSteamId: a } = y(), { isPowerMode: s } = G(), i = z(r), { data: o, isLoading: c } = W(r), { data: v, isLoading: d } = ae(r), u = ie(r), b = le(r), x = a(), m = (o == null ? void 0 : o.isRegistered) || !1, g = (v == null ? void 0 : v.drivers) || (v == null ? void 0 : v.entries) || [], p = t || {}, f = p.maxParticipants && (p.currentCount || 0) >= p.maxParticipants, h = p.deadline && new Date(p.deadline) < /* @__PURE__ */ new Date(), N = p.isOpen && !h && !f;
1231
- return c || d ? /* @__PURE__ */ e(U, { message: "Loading registration..." }) : m ? /* @__PURE__ */ e("div", { className: `pvx-reg-panel ${n || ""}`, children: /* @__PURE__ */ e(
1232
- Ze,
1255
+ function qr({ competitionId: e, registration: n, onWithdrawSuccess: s, className: t }) {
1256
+ const { getSteamId: a } = w(), { isPowerMode: i } = Q(), o = Y(e), { data: d, isLoading: u } = z(e), { data: l, isLoading: m } = ie(e), g = oe(e), h = ce(e), f = a(), b = (d == null ? void 0 : d.isRegistered) || !1, p = (l == null ? void 0 : l.drivers) || (l == null ? void 0 : l.entries) || [], N = n || {}, v = p.length || N.currentCount || 0, x = N.maxParticipants && v >= N.maxParticipants, y = N.deadline && new Date(N.deadline) < /* @__PURE__ */ new Date(), L = N.isOpen && !y && !x;
1257
+ return u || m ? /* @__PURE__ */ r(F, { message: "Loading registration..." }) : b ? /* @__PURE__ */ r("div", { className: `pvx-reg-panel ${t || ""}`, children: /* @__PURE__ */ r(
1258
+ er,
1233
1259
  {
1234
- competitionId: r,
1235
- drivers: g,
1236
- steamId: x,
1237
- isPowerMode: s,
1238
- registrationUrl: i,
1239
- withdrawMutation: b,
1240
- registration: p
1260
+ competitionId: e,
1261
+ drivers: p,
1262
+ steamId: f,
1263
+ isPowerMode: i,
1264
+ registrationUrl: o,
1265
+ withdrawMutation: h,
1266
+ onWithdrawSuccess: s,
1267
+ registration: N
1241
1268
  }
1242
- ) }) : N ? x ? s ? /* @__PURE__ */ e("div", { className: `pvx-reg-panel ${n || ""}`, children: /* @__PURE__ */ e(
1243
- Qe,
1269
+ ) }) : L ? f ? i ? /* @__PURE__ */ r("div", { className: `pvx-reg-panel ${t || ""}`, children: /* @__PURE__ */ r(
1270
+ Xe,
1244
1271
  {
1245
- competitionId: r,
1246
- registerMutation: u,
1247
- registration: p
1272
+ competitionId: e,
1273
+ registerMutation: g,
1274
+ registration: N
1248
1275
  }
1249
- ) }) : /* @__PURE__ */ e("div", { className: `pvx-reg-panel ${n || ""}`, children: /* @__PURE__ */ e("a", { href: i, target: "_blank", rel: "noopener noreferrer", className: "pvx-comp-register-link", children: "Register on PitVox" }) }) : /* @__PURE__ */ e("div", { className: `pvx-reg-panel ${n || ""}`, children: s ? /* @__PURE__ */ e("div", { className: "pvx-reg-status-msg", children: "Sign in to register for this competition." }) : /* @__PURE__ */ e("div", { className: "pvx-reg-status-msg", children: /* @__PURE__ */ e("a", { href: i, target: "_blank", rel: "noopener noreferrer", className: "pvx-comp-register-link", children: "Register on PitVox" }) }) }) : /* @__PURE__ */ l("div", { className: `pvx-reg-panel ${n || ""}`, children: [
1250
- /* @__PURE__ */ e("div", { className: "pvx-reg-status-msg", children: f ? "Registration is full." : h ? "Registration deadline has passed." : "Registration is closed." }),
1251
- g.length > 0 && /* @__PURE__ */ e(xe, { drivers: g, steamId: x })
1276
+ ) }) : /* @__PURE__ */ r("div", { className: `pvx-reg-panel ${t || ""}`, children: /* @__PURE__ */ r("a", { href: o, target: "_blank", rel: "noopener noreferrer", className: "pvx-comp-register-link", children: "Register on PitVox" }) }) : /* @__PURE__ */ r("div", { className: `pvx-reg-panel ${t || ""}`, children: i ? /* @__PURE__ */ r("div", { className: "pvx-reg-status-msg", children: "Sign in to register for this competition." }) : /* @__PURE__ */ r("div", { className: "pvx-reg-status-msg", children: /* @__PURE__ */ r("a", { href: o, target: "_blank", rel: "noopener noreferrer", className: "pvx-comp-register-link", children: "Register on PitVox" }) }) }) : /* @__PURE__ */ c("div", { className: `pvx-reg-panel ${t || ""}`, children: [
1277
+ /* @__PURE__ */ r("div", { className: "pvx-reg-status-msg", children: x ? "Registration is full." : y ? "Registration deadline has passed." : "Registration is closed." }),
1278
+ p.length > 0 && /* @__PURE__ */ r(ge, { drivers: p, steamId: f })
1252
1279
  ] });
1253
1280
  }
1254
- function Qe({ competitionId: r, registerMutation: t, registration: n }) {
1255
- const [a, s] = L(""), [i, o] = L("intermediate"), [c, v] = L(""), d = (m) => {
1256
- m.preventDefault(), t.mutate({
1257
- discordUsername: a || void 0,
1281
+ function Xe({ competitionId: e, registerMutation: n, registration: s }) {
1282
+ const [t, a] = M(""), [i, o] = M("intermediate"), [d, u] = M(""), l = (f) => {
1283
+ f.preventDefault(), n.mutate({
1284
+ discordUsername: t || void 0,
1258
1285
  experience: i,
1259
- comments: c || void 0
1286
+ comments: d || void 0
1260
1287
  });
1261
- }, u = n || {}, b = u.currentCount || 0, x = u.maxParticipants;
1262
- return /* @__PURE__ */ l("form", { className: "pvx-reg-form", onSubmit: d, children: [
1263
- /* @__PURE__ */ l("div", { className: "pvx-reg-form-header", children: [
1264
- /* @__PURE__ */ e("h3", { className: "pvx-reg-form-title", children: "Register" }),
1265
- x && /* @__PURE__ */ e(ge, { count: b, max: x })
1288
+ }, m = s || {}, g = m.currentCount || 0, h = m.maxParticipants;
1289
+ return /* @__PURE__ */ c("form", { className: "pvx-reg-form", onSubmit: l, children: [
1290
+ /* @__PURE__ */ c("div", { className: "pvx-reg-form-header", children: [
1291
+ /* @__PURE__ */ r("h3", { className: "pvx-reg-form-title", children: "Register" }),
1292
+ h && /* @__PURE__ */ r(fe, { count: g, max: h })
1266
1293
  ] }),
1267
- t.error && /* @__PURE__ */ e("div", { className: "pvx-reg-error", children: t.error.message || "Registration failed" }),
1268
- /* @__PURE__ */ l("div", { className: "pvx-reg-field", children: [
1269
- /* @__PURE__ */ l("label", { className: "pvx-reg-label", htmlFor: `pvx-discord-${r}`, children: [
1294
+ n.error && /* @__PURE__ */ r("div", { className: "pvx-reg-error", children: n.error.message || "Registration failed" }),
1295
+ /* @__PURE__ */ c("div", { className: "pvx-reg-field", children: [
1296
+ /* @__PURE__ */ c("label", { className: "pvx-reg-label", htmlFor: `pvx-discord-${e}`, children: [
1270
1297
  "Discord Username ",
1271
- /* @__PURE__ */ e("span", { className: "pvx-reg-optional", children: "(optional)" })
1298
+ /* @__PURE__ */ r("span", { className: "pvx-reg-optional", children: "(optional)" })
1272
1299
  ] }),
1273
- /* @__PURE__ */ e(
1300
+ /* @__PURE__ */ r(
1274
1301
  "input",
1275
1302
  {
1276
- id: `pvx-discord-${r}`,
1303
+ id: `pvx-discord-${e}`,
1277
1304
  type: "text",
1278
1305
  className: "pvx-reg-input",
1279
1306
  placeholder: "e.g. username",
1280
- value: a,
1281
- onChange: (m) => s(m.target.value)
1307
+ value: t,
1308
+ onChange: (f) => a(f.target.value)
1282
1309
  }
1283
1310
  )
1284
1311
  ] }),
1285
- /* @__PURE__ */ l("div", { className: "pvx-reg-field", children: [
1286
- /* @__PURE__ */ e("label", { className: "pvx-reg-label", htmlFor: `pvx-exp-${r}`, children: "Experience Level" }),
1287
- /* @__PURE__ */ l(
1312
+ /* @__PURE__ */ c("div", { className: "pvx-reg-field", children: [
1313
+ /* @__PURE__ */ r("label", { className: "pvx-reg-label", htmlFor: `pvx-exp-${e}`, children: "Experience Level" }),
1314
+ /* @__PURE__ */ c(
1288
1315
  "select",
1289
1316
  {
1290
- id: `pvx-exp-${r}`,
1317
+ id: `pvx-exp-${e}`,
1291
1318
  className: "pvx-reg-select",
1292
1319
  value: i,
1293
- onChange: (m) => o(m.target.value),
1320
+ onChange: (f) => o(f.target.value),
1294
1321
  children: [
1295
- /* @__PURE__ */ e("option", { value: "beginner", children: "Beginner" }),
1296
- /* @__PURE__ */ e("option", { value: "intermediate", children: "Intermediate" }),
1297
- /* @__PURE__ */ e("option", { value: "advanced", children: "Advanced" })
1322
+ /* @__PURE__ */ r("option", { value: "beginner", children: "Beginner" }),
1323
+ /* @__PURE__ */ r("option", { value: "intermediate", children: "Intermediate" }),
1324
+ /* @__PURE__ */ r("option", { value: "advanced", children: "Advanced" })
1298
1325
  ]
1299
1326
  }
1300
1327
  )
1301
1328
  ] }),
1302
- /* @__PURE__ */ l("div", { className: "pvx-reg-field", children: [
1303
- /* @__PURE__ */ l("label", { className: "pvx-reg-label", htmlFor: `pvx-comments-${r}`, children: [
1329
+ /* @__PURE__ */ c("div", { className: "pvx-reg-field", children: [
1330
+ /* @__PURE__ */ c("label", { className: "pvx-reg-label", htmlFor: `pvx-comments-${e}`, children: [
1304
1331
  "Comments ",
1305
- /* @__PURE__ */ e("span", { className: "pvx-reg-optional", children: "(optional)" })
1332
+ /* @__PURE__ */ r("span", { className: "pvx-reg-optional", children: "(optional)" })
1306
1333
  ] }),
1307
- /* @__PURE__ */ e(
1334
+ /* @__PURE__ */ r(
1308
1335
  "textarea",
1309
1336
  {
1310
- id: `pvx-comments-${r}`,
1337
+ id: `pvx-comments-${e}`,
1311
1338
  className: "pvx-reg-textarea",
1312
1339
  rows: 3,
1313
1340
  placeholder: "Anything the organisers should know?",
1314
- value: c,
1315
- onChange: (m) => v(m.target.value)
1341
+ value: d,
1342
+ onChange: (f) => u(f.target.value)
1316
1343
  }
1317
1344
  )
1318
1345
  ] }),
1319
- /* @__PURE__ */ e("div", { className: "pvx-reg-actions", children: /* @__PURE__ */ e(
1346
+ /* @__PURE__ */ r("div", { className: "pvx-reg-actions", children: /* @__PURE__ */ r(
1320
1347
  "button",
1321
1348
  {
1322
1349
  type: "submit",
1323
1350
  className: "pvx-comp-register-btn",
1324
- disabled: t.isPending,
1325
- children: t.isPending ? "Registering..." : "Register"
1351
+ disabled: n.isPending,
1352
+ children: n.isPending ? "Registering..." : "Register"
1326
1353
  }
1327
1354
  ) })
1328
1355
  ] });
1329
1356
  }
1330
- function Ze({ competitionId: r, drivers: t, steamId: n, isPowerMode: a, registrationUrl: s, withdrawMutation: i, registration: o }) {
1331
- const [c, v] = L(!1), d = () => {
1357
+ function er({ competitionId: e, drivers: n, steamId: s, isPowerMode: t, registrationUrl: a, withdrawMutation: i, onWithdrawSuccess: o, registration: d }) {
1358
+ const [u, l] = M(!1), m = () => {
1332
1359
  i.mutate(void 0, {
1333
- onSuccess: () => v(!1)
1360
+ onSuccess: () => {
1361
+ l(!1), o && o();
1362
+ }
1334
1363
  });
1335
- }, u = o || {}, b = t.length || u.currentCount || 0, x = u.maxParticipants;
1336
- return /* @__PURE__ */ l(K, { children: [
1337
- /* @__PURE__ */ l("div", { className: "pvx-reg-form-header", children: [
1338
- /* @__PURE__ */ e("h3", { className: "pvx-reg-form-title", children: "Registered Drivers" }),
1339
- x && /* @__PURE__ */ e(ge, { count: b, max: x })
1364
+ }, g = d || {}, h = n.length || g.currentCount || 0, f = g.maxParticipants;
1365
+ return /* @__PURE__ */ c(G, { children: [
1366
+ /* @__PURE__ */ c("div", { className: "pvx-reg-form-header", children: [
1367
+ /* @__PURE__ */ r("h3", { className: "pvx-reg-form-title", children: "Registered Drivers" }),
1368
+ f && /* @__PURE__ */ r(fe, { count: h, max: f })
1340
1369
  ] }),
1341
- /* @__PURE__ */ e(xe, { drivers: t, steamId: n }),
1342
- i.error && /* @__PURE__ */ e("div", { className: "pvx-reg-error", children: i.error.message || "Withdrawal failed" }),
1343
- a ? /* @__PURE__ */ e("div", { className: "pvx-reg-actions", children: c ? /* @__PURE__ */ l("div", { className: "pvx-reg-confirm", children: [
1344
- /* @__PURE__ */ e("p", { className: "pvx-reg-confirm-text", children: "Are you sure you want to unregister?" }),
1345
- /* @__PURE__ */ l("div", { className: "pvx-reg-confirm-actions", children: [
1346
- /* @__PURE__ */ e(
1370
+ /* @__PURE__ */ r(ge, { drivers: n, steamId: s }),
1371
+ i.error && /* @__PURE__ */ r("div", { className: "pvx-reg-error", children: i.error.message || "Withdrawal failed" }),
1372
+ t ? /* @__PURE__ */ r("div", { className: "pvx-reg-actions", children: u ? /* @__PURE__ */ c("div", { className: "pvx-reg-confirm", children: [
1373
+ /* @__PURE__ */ r("p", { className: "pvx-reg-confirm-text", children: "Are you sure you want to unregister?" }),
1374
+ /* @__PURE__ */ c("div", { className: "pvx-reg-confirm-actions", children: [
1375
+ /* @__PURE__ */ r(
1347
1376
  "button",
1348
1377
  {
1349
1378
  type: "button",
1350
1379
  className: "pvx-reg-cancel-btn",
1351
- onClick: () => v(!1),
1380
+ onClick: () => l(!1),
1352
1381
  children: "Cancel"
1353
1382
  }
1354
1383
  ),
1355
- /* @__PURE__ */ e(
1384
+ /* @__PURE__ */ r(
1356
1385
  "button",
1357
1386
  {
1358
1387
  type: "button",
1359
1388
  className: "pvx-reg-danger-btn",
1360
- onClick: d,
1389
+ onClick: m,
1361
1390
  disabled: i.isPending,
1362
1391
  children: i.isPending ? "Unregistering..." : "Yes, Unregister"
1363
1392
  }
1364
1393
  )
1365
1394
  ] })
1366
- ] }) : /* @__PURE__ */ e(
1395
+ ] }) : /* @__PURE__ */ r(
1367
1396
  "button",
1368
1397
  {
1369
1398
  type: "button",
1370
1399
  className: "pvx-reg-unregister-btn",
1371
- onClick: () => v(!0),
1400
+ onClick: () => l(!0),
1372
1401
  children: "Unregister"
1373
1402
  }
1374
- ) }) : /* @__PURE__ */ e("div", { className: "pvx-reg-actions", children: /* @__PURE__ */ e("a", { href: s, target: "_blank", rel: "noopener noreferrer", className: "pvx-comp-register-link", children: "Manage on PitVox" }) })
1403
+ ) }) : /* @__PURE__ */ r("div", { className: "pvx-reg-actions", children: /* @__PURE__ */ r("a", { href: a, target: "_blank", rel: "noopener noreferrer", className: "pvx-comp-register-link", children: "Manage on PitVox" }) })
1375
1404
  ] });
1376
1405
  }
1377
- function xe({ drivers: r, steamId: t }) {
1378
- return r.length ? /* @__PURE__ */ e("div", { className: "pvx-reg-driver-list", children: r.map((n) => {
1379
- var s, i;
1380
- const a = t && n.steamId === t;
1381
- return /* @__PURE__ */ l(
1406
+ function ge({ drivers: e, steamId: n }) {
1407
+ if (!e.length)
1408
+ return /* @__PURE__ */ r("div", { className: "pvx-reg-no-drivers", children: "No drivers registered yet." });
1409
+ const s = [...e].sort((t, a) => {
1410
+ const i = n && t.steamId === n ? -1 : 0, o = n && a.steamId === n ? -1 : 0;
1411
+ return i - o;
1412
+ });
1413
+ return /* @__PURE__ */ r("div", { className: "pvx-reg-driver-list", children: s.map((t) => {
1414
+ var i, o;
1415
+ const a = n && t.steamId === n;
1416
+ return /* @__PURE__ */ c(
1382
1417
  "div",
1383
1418
  {
1384
- className: `pvx-entry-card ${a ? "pvx-entry-card--you" : ""}`,
1419
+ className: `pvx-reg-driver-row ${a ? "pvx-reg-driver-row--you" : ""}`,
1385
1420
  children: [
1386
- n.avatarUrl ? /* @__PURE__ */ e("img", { src: n.avatarUrl, alt: "", className: "pvx-entry-avatar" }) : /* @__PURE__ */ e("div", { className: "pvx-entry-avatar pvx-entry-avatar--placeholder", children: ((i = (s = n.displayName) == null ? void 0 : s.charAt(0)) == null ? void 0 : i.toUpperCase()) || "?" }),
1387
- /* @__PURE__ */ l("span", { className: "pvx-entry-name", children: [
1388
- n.displayName,
1389
- a && /* @__PURE__ */ e("span", { className: "pvx-entry-you", children: " (you)" })
1421
+ t.avatarUrl ? /* @__PURE__ */ r("img", { src: t.avatarUrl, alt: "", className: "pvx-reg-driver-avatar" }) : /* @__PURE__ */ r("div", { className: "pvx-reg-driver-avatar pvx-reg-driver-avatar--placeholder", children: ((o = (i = t.displayName) == null ? void 0 : i.charAt(0)) == null ? void 0 : o.toUpperCase()) || "?" }),
1422
+ /* @__PURE__ */ c("span", { className: "pvx-reg-driver-name", children: [
1423
+ t.displayName,
1424
+ a && /* @__PURE__ */ r("span", { className: "pvx-entry-you", children: " (you)" })
1390
1425
  ] })
1391
1426
  ]
1392
1427
  },
1393
- n.steamId || n.driverId
1428
+ t.steamId || t.driverId
1394
1429
  );
1395
- }) }) : /* @__PURE__ */ e("div", { className: "pvx-reg-no-drivers", children: "No drivers registered yet." });
1430
+ }) });
1396
1431
  }
1397
- function ge({ count: r, max: t }) {
1398
- const n = t ? r / t * 100 : 0, a = n >= 100 ? "full" : n >= 75 ? "warning" : "ok";
1399
- return /* @__PURE__ */ l("span", { className: `pvx-reg-capacity pvx-reg-capacity--${a}`, children: [
1400
- r,
1432
+ function fe({ count: e, max: n }) {
1433
+ const s = n ? e / n * 100 : 0, t = s >= 100 ? "full" : s >= 75 ? "warning" : "ok";
1434
+ return /* @__PURE__ */ c("span", { className: `pvx-reg-capacity pvx-reg-capacity--${t}`, children: [
1435
+ e,
1401
1436
  "/",
1402
- t,
1437
+ n,
1403
1438
  " drivers"
1404
1439
  ] });
1405
1440
  }
1406
- function Je(r) {
1407
- const { cdnUrl: t, partnerSlug: n } = y(), a = k({
1408
- queryKey: ["pitvox", "laps", n, r],
1409
- queryFn: () => T(t, `laps/partners/${n}/${r}.json`),
1410
- enabled: !!r,
1441
+ function rr(e) {
1442
+ const { cdnUrl: n } = w(), s = k({
1443
+ queryKey: ["pitvox", "laps", "global", e],
1444
+ queryFn: () => R(n, `laps/${e}.json`),
1445
+ enabled: !!e,
1411
1446
  staleTime: 3e4,
1412
1447
  refetchInterval: 3e4
1413
- }), s = a.data;
1448
+ }), t = s.data;
1414
1449
  return {
1415
- isLoading: a.isLoading,
1416
- error: a.error,
1417
- data: s ? {
1418
- driverName: s.driverName || "Driver",
1419
- lapCount: s.lapCount || 0,
1420
- trackBreakdown: s.trackBreakdown || [],
1421
- carBreakdown: s.carBreakdown || [],
1422
- recordsHeld: s.recordsHeld || 0,
1423
- currentRecords: s.currentRecords || [],
1424
- bestRanking: s.bestRanking ?? null,
1425
- bestRankingTrackId: s.bestRankingTrackId ?? null,
1426
- bestRankingLayout: s.bestRankingLayout ?? null,
1427
- bestRankingCarId: s.bestRankingCarId ?? null,
1428
- generatedAt: s.generatedAt
1450
+ isLoading: s.isLoading,
1451
+ error: s.error,
1452
+ data: t ? {
1453
+ driverName: t.driverName || "Driver",
1454
+ lapCount: t.lapCount || 0,
1455
+ trackBreakdown: t.trackBreakdown || [],
1456
+ carBreakdown: t.carBreakdown || [],
1457
+ recordsHeld: t.recordsHeld || 0,
1458
+ currentRecords: t.currentRecords || [],
1459
+ bestRanking: t.bestRanking ?? null,
1460
+ bestRankingTrackId: t.bestRankingTrackId ?? null,
1461
+ bestRankingLayout: t.bestRankingLayout ?? null,
1462
+ bestRankingCarId: t.bestRankingCarId ?? null,
1463
+ generatedAt: t.generatedAt
1429
1464
  } : null
1430
1465
  };
1431
1466
  }
1432
- function Ye(r) {
1467
+ function tr(e) {
1433
1468
  var i;
1434
- const { cdnUrl: t, partnerSlug: n } = y(), a = k({
1435
- queryKey: ["pitvox", "ratings", n],
1436
- queryFn: () => T(t, `leaderboards/partners/${n}/ratings.json`),
1469
+ const { cdnUrl: n, partnerSlug: s } = w(), t = k({
1470
+ queryKey: ["pitvox", "ratings", s],
1471
+ queryFn: () => R(n, `leaderboards/partners/${s}/ratings.json`),
1437
1472
  staleTime: 6e4,
1438
1473
  refetchInterval: 6e4
1439
- }), s = C(() => {
1474
+ }), a = C(() => {
1440
1475
  var o;
1441
- return !((o = a.data) != null && o.drivers) || !r ? null : a.data.drivers.find(
1442
- (c) => c.identifier === r
1476
+ return !((o = t.data) != null && o.drivers) || !e ? null : t.data.drivers.find(
1477
+ (d) => d.identifier === e
1443
1478
  ) || null;
1444
- }, [(i = a.data) == null ? void 0 : i.drivers, r]);
1479
+ }, [(i = t.data) == null ? void 0 : i.drivers, e]);
1445
1480
  return {
1446
- isLoading: a.isLoading,
1447
- error: a.error,
1448
- data: s ? {
1449
- rating: s.rating,
1450
- rank: s.rank,
1451
- totalDrivers: a.data.driverCount || a.data.drivers.length,
1452
- comboCount: s.comboCount || 0,
1453
- distinctCars: s.distinctCars || 0,
1454
- combos: s.combos || []
1481
+ isLoading: t.isLoading,
1482
+ error: t.error,
1483
+ data: a ? {
1484
+ rating: a.rating,
1485
+ rank: a.rank,
1486
+ totalDrivers: t.data.driverCount || t.data.drivers.length,
1487
+ comboCount: a.comboCount || 0,
1488
+ distinctCars: a.distinctCars || 0,
1489
+ combos: a.combos || []
1455
1490
  } : null
1456
1491
  };
1457
1492
  }
1458
- function Xe({ driverName: r, avatarUrl: t, memberSince: n, className: a = "" }) {
1459
- const s = n ? new Date(n).toLocaleDateString("en-GB", { day: "2-digit", month: "2-digit", year: "numeric" }) : null;
1460
- return /* @__PURE__ */ l("div", { className: `pvx-card pvx-dash-profile ${a}`, children: [
1461
- t ? /* @__PURE__ */ e("img", { src: t, alt: "", className: "pvx-dash-profile-avatar" }) : /* @__PURE__ */ e("div", { className: "pvx-dash-profile-avatar pvx-dash-profile-avatar--placeholder", children: (r || "?")[0].toUpperCase() }),
1462
- /* @__PURE__ */ l("div", { className: "pvx-dash-profile-info", children: [
1463
- /* @__PURE__ */ e("h2", { className: "pvx-dash-profile-name", children: r }),
1464
- s && /* @__PURE__ */ l("p", { className: "pvx-dash-profile-since", children: [
1493
+ function nr() {
1494
+ const { cdnUrl: e, partnerSlug: n, getSteamId: s } = w(), t = s(), { data: a, isLoading: i } = k({
1495
+ queryKey: ["pitvox", "competitions", n],
1496
+ queryFn: async () => {
1497
+ const m = await R(e, "competitions/index.json");
1498
+ return m != null && m.competitions ? m.competitions.filter((g) => g.partnerSlug === n) : [];
1499
+ },
1500
+ staleTime: 6e4
1501
+ }), o = (a == null ? void 0 : a.map((m) => m.id)) || [], d = ke({
1502
+ queries: o.map((m) => ({
1503
+ queryKey: ["pitvox", "competition", n, m, "entrylist"],
1504
+ queryFn: () => R(e, `competitions/${n}/${m}/entrylist.json`),
1505
+ enabled: !!t && o.length > 0,
1506
+ staleTime: 6e4
1507
+ }))
1508
+ }), u = d.some((m) => m.isLoading);
1509
+ return {
1510
+ data: C(() => {
1511
+ var h, f;
1512
+ if (!a || !t || u) return [];
1513
+ const m = /* @__PURE__ */ new Date(), g = [];
1514
+ for (let b = 0; b < a.length; b++) {
1515
+ const p = a[b], N = (h = d[b]) == null ? void 0 : h.data;
1516
+ if (!((f = N == null ? void 0 : N.drivers) == null ? void 0 : f.some((y) => y.steamId === t))) continue;
1517
+ const x = p.rounds || [];
1518
+ for (const y of x)
1519
+ y.isFinalized || !y.startTime || new Date(y.startTime) <= m || g.push({
1520
+ competitionId: p.id,
1521
+ competitionName: p.name,
1522
+ roundNumber: y.roundNumber,
1523
+ track: y.track || "TBD",
1524
+ startTime: y.startTime
1525
+ });
1526
+ }
1527
+ return g.sort((b, p) => new Date(b.startTime) - new Date(p.startTime)), g.length > 0 && (g[0].isNext = !0), g;
1528
+ }, [a, t, u, d]),
1529
+ isLoading: i || !!t && u
1530
+ };
1531
+ }
1532
+ function sr() {
1533
+ const { onFetchNotifications: e } = w();
1534
+ return !!e;
1535
+ }
1536
+ function ar(e = {}) {
1537
+ const { onFetchNotifications: n, partnerSlug: s } = w(), { limit: t = 20, unreadOnly: a = !1 } = e;
1538
+ return k({
1539
+ queryKey: ["pitvox", "notifications", s, { limit: t, unreadOnly: a }],
1540
+ queryFn: () => n({ limit: t, unreadOnly: a }),
1541
+ enabled: !!n,
1542
+ staleTime: 3e4,
1543
+ refetchInterval: 3e4
1544
+ });
1545
+ }
1546
+ function Vr() {
1547
+ const { onFetchNotifications: e, partnerSlug: n } = w(), { data: s, isLoading: t } = k({
1548
+ queryKey: ["pitvox", "notifications", n, { limit: 1, unreadOnly: !1 }],
1549
+ queryFn: () => e({ limit: 1 }),
1550
+ enabled: !!e,
1551
+ staleTime: 3e4,
1552
+ refetchInterval: 3e4,
1553
+ select: (a) => (a == null ? void 0 : a.unreadCount) ?? 0
1554
+ });
1555
+ return { count: s ?? 0, isLoading: t };
1556
+ }
1557
+ function ir() {
1558
+ const { onMarkNotificationRead: e, partnerSlug: n } = w(), s = P();
1559
+ return _({
1560
+ mutationFn: (t) => {
1561
+ if (!e)
1562
+ throw new Error("No onMarkNotificationRead callback provided to PitVoxPartnerProvider.");
1563
+ return e(t);
1564
+ },
1565
+ onSuccess: (t, a) => {
1566
+ s.setQueriesData(
1567
+ { queryKey: ["pitvox", "notifications", n] },
1568
+ (i) => i != null && i.notifications ? {
1569
+ ...i,
1570
+ unreadCount: Math.max(0, (i.unreadCount || 0) - 1),
1571
+ notifications: i.notifications.map(
1572
+ (o) => o.id === a ? { ...o, isRead: !0, readAt: (/* @__PURE__ */ new Date()).toISOString() } : o
1573
+ )
1574
+ } : i
1575
+ );
1576
+ }
1577
+ });
1578
+ }
1579
+ function or() {
1580
+ const { onMarkAllNotificationsRead: e, partnerSlug: n } = w(), s = P();
1581
+ return _({
1582
+ mutationFn: () => {
1583
+ if (!e)
1584
+ throw new Error("No onMarkAllNotificationsRead callback provided to PitVoxPartnerProvider.");
1585
+ return e();
1586
+ },
1587
+ onSuccess: () => {
1588
+ s.setQueriesData(
1589
+ { queryKey: ["pitvox", "notifications", n] },
1590
+ (t) => t != null && t.notifications ? {
1591
+ ...t,
1592
+ unreadCount: 0,
1593
+ notifications: t.notifications.map((a) => ({
1594
+ ...a,
1595
+ isRead: !0,
1596
+ readAt: a.readAt || (/* @__PURE__ */ new Date()).toISOString()
1597
+ }))
1598
+ } : t
1599
+ );
1600
+ }
1601
+ });
1602
+ }
1603
+ function cr({ driverName: e, avatarUrl: n, memberSince: s, className: t = "" }) {
1604
+ const a = s ? new Date(s).toLocaleDateString("en-GB", { day: "2-digit", month: "2-digit", year: "numeric" }) : null;
1605
+ return /* @__PURE__ */ c("div", { className: `pvx-card pvx-dash-profile ${t}`, children: [
1606
+ n ? /* @__PURE__ */ r("img", { src: n, alt: "", className: "pvx-dash-profile-avatar" }) : /* @__PURE__ */ r("div", { className: "pvx-dash-profile-avatar pvx-dash-profile-avatar--placeholder", children: (e || "?")[0].toUpperCase() }),
1607
+ /* @__PURE__ */ c("div", { className: "pvx-dash-profile-info", children: [
1608
+ /* @__PURE__ */ r("h2", { className: "pvx-dash-profile-name", children: e }),
1609
+ a && /* @__PURE__ */ c("p", { className: "pvx-dash-profile-since", children: [
1465
1610
  "Racing since ",
1466
- s
1611
+ a
1467
1612
  ] })
1468
1613
  ] })
1469
1614
  ] });
1470
1615
  }
1471
- function er() {
1472
- return /* @__PURE__ */ l("svg", { className: "pvx-dash-stat-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1473
- /* @__PURE__ */ e("line", { x1: "4", y1: "9", x2: "20", y2: "9" }),
1474
- /* @__PURE__ */ e("line", { x1: "4", y1: "15", x2: "20", y2: "15" }),
1475
- /* @__PURE__ */ e("line", { x1: "10", y1: "3", x2: "8", y2: "21" }),
1476
- /* @__PURE__ */ e("line", { x1: "16", y1: "3", x2: "14", y2: "21" })
1616
+ function lr() {
1617
+ return /* @__PURE__ */ c("svg", { className: "pvx-dash-stat-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1618
+ /* @__PURE__ */ r("line", { x1: "4", y1: "9", x2: "20", y2: "9" }),
1619
+ /* @__PURE__ */ r("line", { x1: "4", y1: "15", x2: "20", y2: "15" }),
1620
+ /* @__PURE__ */ r("line", { x1: "10", y1: "3", x2: "8", y2: "21" }),
1621
+ /* @__PURE__ */ r("line", { x1: "16", y1: "3", x2: "14", y2: "21" })
1477
1622
  ] });
1478
1623
  }
1479
- function rr() {
1480
- return /* @__PURE__ */ l("svg", { className: "pvx-dash-stat-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1481
- /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10" }),
1482
- /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "2" }),
1483
- /* @__PURE__ */ e("path", { d: "M12 14v4" }),
1484
- /* @__PURE__ */ e("path", { d: "M10.5 12.5l-4 2.5" }),
1485
- /* @__PURE__ */ e("path", { d: "M13.5 12.5l4 2.5" })
1624
+ function dr() {
1625
+ return /* @__PURE__ */ c("svg", { className: "pvx-dash-stat-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1626
+ /* @__PURE__ */ r("circle", { cx: "12", cy: "12", r: "10" }),
1627
+ /* @__PURE__ */ r("circle", { cx: "12", cy: "12", r: "2" }),
1628
+ /* @__PURE__ */ r("path", { d: "M12 14v4" }),
1629
+ /* @__PURE__ */ r("path", { d: "M10.5 12.5l-4 2.5" }),
1630
+ /* @__PURE__ */ r("path", { d: "M13.5 12.5l4 2.5" })
1486
1631
  ] });
1487
1632
  }
1488
- function tr() {
1489
- return /* @__PURE__ */ e("svg", { className: "pvx-dash-stat-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("polygon", { points: "12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" }) });
1633
+ function pr() {
1634
+ return /* @__PURE__ */ r("svg", { className: "pvx-dash-stat-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ r("polygon", { points: "12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" }) });
1490
1635
  }
1491
- function re({ items: r, labelKey: t, countKey: n }) {
1492
- if (!(r != null && r.length)) return null;
1493
- const a = r.slice().sort((s, i) => i[n] - s[n]).slice(0, 10);
1494
- return /* @__PURE__ */ l("div", { className: "pvx-dash-tooltip", children: [
1495
- a.map((s, i) => /* @__PURE__ */ l("div", { className: "pvx-dash-tooltip-row", children: [
1496
- /* @__PURE__ */ e("span", { className: "pvx-dash-tooltip-label", children: s[t] }),
1497
- /* @__PURE__ */ e("span", { className: "pvx-dash-tooltip-value", children: s[n] })
1636
+ function te({ items: e, labelKey: n, countKey: s }) {
1637
+ if (!(e != null && e.length)) return null;
1638
+ const t = e.slice().sort((a, i) => i[s] - a[s]).slice(0, 10);
1639
+ return /* @__PURE__ */ c("div", { className: "pvx-dash-tooltip", children: [
1640
+ t.map((a, i) => /* @__PURE__ */ c("div", { className: "pvx-dash-tooltip-row", children: [
1641
+ /* @__PURE__ */ r("span", { className: "pvx-dash-tooltip-label", children: a[n] }),
1642
+ /* @__PURE__ */ r("span", { className: "pvx-dash-tooltip-value", children: a[s] })
1498
1643
  ] }, i)),
1499
- r.length > 10 && /* @__PURE__ */ l("div", { className: "pvx-dash-tooltip-row pvx-dash-tooltip-more", children: [
1644
+ e.length > 10 && /* @__PURE__ */ c("div", { className: "pvx-dash-tooltip-row pvx-dash-tooltip-more", children: [
1500
1645
  "+",
1501
- r.length - 10,
1646
+ e.length - 10,
1502
1647
  " more"
1503
1648
  ] })
1504
1649
  ] });
1505
1650
  }
1506
- function nr({ stats: r, rating: t, className: n = "" }) {
1507
- if (!r) return null;
1508
- const a = r.trackBreakdown.map((i) => ({
1509
- name: O(i.trackId, i.layout),
1651
+ function ur({ stats: e, rating: n, className: s = "" }) {
1652
+ if (!e) return null;
1653
+ const t = e.trackBreakdown.map((i) => ({
1654
+ name: q(i.trackId, i.layout),
1510
1655
  lapCount: i.lapCount
1511
- })), s = r.carBreakdown.map((i) => ({
1512
- name: R(i.carId),
1656
+ })), a = e.carBreakdown.map((i) => ({
1657
+ name: S(i.carId),
1513
1658
  lapCount: i.lapCount
1514
1659
  }));
1515
- return /* @__PURE__ */ l("div", { className: `pvx-dash-stats ${n}`, children: [
1516
- /* @__PURE__ */ l("div", { className: "pvx-dash-stat-card pvx-dash-stat-card--has-tooltip", children: [
1517
- /* @__PURE__ */ e(er, {}),
1518
- /* @__PURE__ */ l("div", { className: "pvx-dash-stat-content", children: [
1519
- /* @__PURE__ */ e("span", { className: "pvx-dash-stat-value", children: r.lapCount.toLocaleString() }),
1520
- /* @__PURE__ */ e("span", { className: "pvx-dash-stat-label", children: "Total Laps" })
1660
+ return /* @__PURE__ */ c("div", { className: `pvx-dash-stats ${s}`, children: [
1661
+ /* @__PURE__ */ c("div", { className: "pvx-dash-stat-card pvx-dash-stat-card--has-tooltip", children: [
1662
+ /* @__PURE__ */ r(lr, {}),
1663
+ /* @__PURE__ */ c("div", { className: "pvx-dash-stat-content", children: [
1664
+ /* @__PURE__ */ r("span", { className: "pvx-dash-stat-value", children: e.lapCount.toLocaleString() }),
1665
+ /* @__PURE__ */ r("span", { className: "pvx-dash-stat-label", children: "Total Laps" })
1521
1666
  ] }),
1522
- /* @__PURE__ */ e(re, { items: a, labelKey: "name", countKey: "lapCount" })
1667
+ /* @__PURE__ */ r(te, { items: t, labelKey: "name", countKey: "lapCount" })
1523
1668
  ] }),
1524
- /* @__PURE__ */ l("div", { className: "pvx-dash-stat-card pvx-dash-stat-card--has-tooltip", children: [
1525
- /* @__PURE__ */ e(rr, {}),
1526
- /* @__PURE__ */ l("div", { className: "pvx-dash-stat-content", children: [
1527
- /* @__PURE__ */ e("span", { className: "pvx-dash-stat-value", children: r.carBreakdown.length }),
1528
- /* @__PURE__ */ e("span", { className: "pvx-dash-stat-label", children: "Cars Used" })
1669
+ /* @__PURE__ */ c("div", { className: "pvx-dash-stat-card pvx-dash-stat-card--has-tooltip", children: [
1670
+ /* @__PURE__ */ r(dr, {}),
1671
+ /* @__PURE__ */ c("div", { className: "pvx-dash-stat-content", children: [
1672
+ /* @__PURE__ */ r("span", { className: "pvx-dash-stat-value", children: e.carBreakdown.length }),
1673
+ /* @__PURE__ */ r("span", { className: "pvx-dash-stat-label", children: "Cars Used" })
1529
1674
  ] }),
1530
- /* @__PURE__ */ e(re, { items: s, labelKey: "name", countKey: "lapCount" })
1675
+ /* @__PURE__ */ r(te, { items: a, labelKey: "name", countKey: "lapCount" })
1531
1676
  ] }),
1532
- t && /* @__PURE__ */ l("div", { className: "pvx-dash-stat-card pvx-dash-stat-card--rating", children: [
1533
- /* @__PURE__ */ e(tr, {}),
1534
- /* @__PURE__ */ l("div", { className: "pvx-dash-stat-content", children: [
1535
- /* @__PURE__ */ e("span", { className: "pvx-dash-stat-value", children: t.rating.toFixed(1) }),
1536
- /* @__PURE__ */ e("span", { className: "pvx-dash-stat-label", children: "Driver Rating" }),
1537
- /* @__PURE__ */ l("span", { className: "pvx-dash-stat-sub", children: [
1677
+ n && /* @__PURE__ */ c("div", { className: "pvx-dash-stat-card pvx-dash-stat-card--rating", children: [
1678
+ /* @__PURE__ */ r(pr, {}),
1679
+ /* @__PURE__ */ c("div", { className: "pvx-dash-stat-content", children: [
1680
+ /* @__PURE__ */ r("span", { className: "pvx-dash-stat-value", children: n.rating.toFixed(1) }),
1681
+ /* @__PURE__ */ r("span", { className: "pvx-dash-stat-label", children: "Driver Rating" }),
1682
+ /* @__PURE__ */ c("span", { className: "pvx-dash-stat-sub", children: [
1538
1683
  "#",
1539
- t.rank,
1684
+ n.rank,
1540
1685
  " of ",
1541
- t.totalDrivers
1686
+ n.totalDrivers
1542
1687
  ] })
1543
1688
  ] })
1544
1689
  ] })
1545
1690
  ] });
1546
1691
  }
1547
- const te = 10;
1548
- function sr({ records: r, className: t = "" }) {
1549
- const [n, a] = L(!1), s = C(() => r != null && r.length ? r.slice().sort((c, v) => {
1550
- const d = c.recordedAt ? new Date(c.recordedAt).getTime() : 0;
1551
- return (v.recordedAt ? new Date(v.recordedAt).getTime() : 0) - d;
1552
- }) : [], [r]);
1553
- if (!s.length) return null;
1554
- const i = n ? s : s.slice(0, te), o = s.length > te;
1555
- return /* @__PURE__ */ l("div", { className: `pvx-card ${t}`, children: [
1556
- /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ l("h3", { className: "pvx-card-title", children: [
1557
- /* @__PURE__ */ e("span", { className: "pvx-dash-records-icon", children: /* @__PURE__ */ l("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1558
- /* @__PURE__ */ e("path", { d: "M6 9H4.5a2.5 2.5 0 010-5H6" }),
1559
- /* @__PURE__ */ e("path", { d: "M18 9h1.5a2.5 2.5 0 000-5H18" }),
1560
- /* @__PURE__ */ e("path", { d: "M4 22h16" }),
1561
- /* @__PURE__ */ e("path", { d: "M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20 7 22" }),
1562
- /* @__PURE__ */ e("path", { d: "M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20 17 22" }),
1563
- /* @__PURE__ */ e("path", { d: "M18 2H6v7a6 6 0 0012 0V2z" })
1692
+ function mr({ records: e, className: n = "" }) {
1693
+ const s = C(() => e != null && e.length ? e.slice().sort((t, a) => {
1694
+ const i = t.recordedAt ? new Date(t.recordedAt).getTime() : 0;
1695
+ return (a.recordedAt ? new Date(a.recordedAt).getTime() : 0) - i;
1696
+ }) : [], [e]);
1697
+ return s.length ? /* @__PURE__ */ c("div", { className: `pvx-card ${n}`, children: [
1698
+ /* @__PURE__ */ r("div", { className: "pvx-card-header", children: /* @__PURE__ */ c("h3", { className: "pvx-card-title", children: [
1699
+ /* @__PURE__ */ r("span", { className: "pvx-dash-records-icon", children: /* @__PURE__ */ c("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1700
+ /* @__PURE__ */ r("path", { d: "M6 9H4.5a2.5 2.5 0 010-5H6" }),
1701
+ /* @__PURE__ */ r("path", { d: "M18 9h1.5a2.5 2.5 0 000-5H18" }),
1702
+ /* @__PURE__ */ r("path", { d: "M4 22h16" }),
1703
+ /* @__PURE__ */ r("path", { d: "M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20 7 22" }),
1704
+ /* @__PURE__ */ r("path", { d: "M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20 17 22" }),
1705
+ /* @__PURE__ */ r("path", { d: "M18 2H6v7a6 6 0 0012 0V2z" })
1564
1706
  ] }) }),
1565
1707
  "Current Records",
1566
- /* @__PURE__ */ l("span", { className: "pvx-dash-records-count", children: [
1708
+ /* @__PURE__ */ c("span", { className: "pvx-dash-records-count", children: [
1567
1709
  "(",
1568
1710
  s.length,
1569
1711
  ")"
1570
1712
  ] })
1571
1713
  ] }) }),
1572
- /* @__PURE__ */ e("div", { className: "pvx-dash-records-list", children: i.map((c, v) => /* @__PURE__ */ l("div", { className: "pvx-dash-record-row", children: [
1573
- /* @__PURE__ */ l("div", { className: "pvx-dash-record-info", children: [
1574
- /* @__PURE__ */ e("span", { className: "pvx-dash-record-track", children: O(c.trackId, c.layout, c.game) }),
1575
- /* @__PURE__ */ e("span", { className: "pvx-dash-record-car", children: R(c.carId) })
1714
+ /* @__PURE__ */ r("div", { className: "pvx-dash-records-list", children: s.map((t, a) => /* @__PURE__ */ c("div", { className: "pvx-dash-record-row", children: [
1715
+ /* @__PURE__ */ c("div", { className: "pvx-dash-record-info", children: [
1716
+ /* @__PURE__ */ r("span", { className: "pvx-dash-record-track", children: q(t.trackId, t.layout, t.game) }),
1717
+ /* @__PURE__ */ r("span", { className: "pvx-dash-record-car", children: S(t.carId) })
1576
1718
  ] }),
1577
- /* @__PURE__ */ l("div", { className: "pvx-dash-record-time", children: [
1578
- /* @__PURE__ */ e("span", { className: "pvx-dash-record-lap", children: B(c.lapTimeMs) }),
1579
- /* @__PURE__ */ l("span", { className: `pvx-dash-game-badge pvx-dash-game-badge--${c.game || "evo"}`, children: [
1580
- (c.game || "evo").toUpperCase(),
1581
- c.gameVersion ? ` ${c.gameVersion}` : ""
1719
+ /* @__PURE__ */ c("div", { className: "pvx-dash-record-time", children: [
1720
+ /* @__PURE__ */ r("span", { className: "pvx-dash-record-lap", children: U(t.lapTimeMs) }),
1721
+ /* @__PURE__ */ c("span", { className: `pvx-dash-game-badge pvx-dash-game-badge--${t.game || "evo"}`, children: [
1722
+ (t.game || "evo").toUpperCase(),
1723
+ t.gameVersion ? ` ${t.gameVersion}` : ""
1582
1724
  ] })
1583
1725
  ] })
1584
- ] }, v)) }),
1585
- o && /* @__PURE__ */ e(
1586
- "button",
1726
+ ] }, a)) })
1727
+ ] }) : null;
1728
+ }
1729
+ function vr({ events: e, isLoading: n, className: s }) {
1730
+ return n ? /* @__PURE__ */ r("div", { className: "pvx-loading", children: "Loading upcoming events..." }) : e != null && e.length ? /* @__PURE__ */ c("div", { className: `pvx-card ${s || ""}`, children: [
1731
+ /* @__PURE__ */ r("div", { className: "pvx-card-header", children: /* @__PURE__ */ c("h3", { className: "pvx-card-title", children: [
1732
+ /* @__PURE__ */ r(xr, {}),
1733
+ "Upcoming Events",
1734
+ /* @__PURE__ */ c("span", { className: "pvx-dash-records-count", children: [
1735
+ "(",
1736
+ e.length,
1737
+ ")"
1738
+ ] })
1739
+ ] }) }),
1740
+ /* @__PURE__ */ r("div", { className: "pvx-upcoming-list", children: e.map((t) => /* @__PURE__ */ c(
1741
+ "div",
1587
1742
  {
1588
- className: "pvx-dash-records-toggle",
1589
- onClick: () => a(!n),
1590
- children: n ? "Show less" : `Show all ${s.length} records`
1591
- }
1592
- )
1743
+ className: `pvx-upcoming-item ${t.isNext ? "pvx-upcoming-item--next" : ""}`,
1744
+ children: [
1745
+ /* @__PURE__ */ c("div", { className: "pvx-upcoming-info", children: [
1746
+ /* @__PURE__ */ r("span", { className: "pvx-upcoming-comp", children: t.competitionName }),
1747
+ /* @__PURE__ */ c("span", { className: "pvx-upcoming-round", children: [
1748
+ "Round ",
1749
+ t.roundNumber,
1750
+ ": ",
1751
+ t.track
1752
+ ] })
1753
+ ] }),
1754
+ /* @__PURE__ */ c("div", { className: "pvx-upcoming-time", children: [
1755
+ /* @__PURE__ */ r("span", { className: "pvx-upcoming-date", children: new Date(t.startTime).toLocaleDateString("en-GB", {
1756
+ day: "numeric",
1757
+ month: "short",
1758
+ year: "numeric"
1759
+ }) }),
1760
+ /* @__PURE__ */ r("span", { className: "pvx-upcoming-relative", children: hr(t.startTime) }),
1761
+ t.isNext && /* @__PURE__ */ r("span", { className: "pvx-upcoming-badge", children: "Next" })
1762
+ ] })
1763
+ ]
1764
+ },
1765
+ `${t.competitionId}-${t.roundNumber}`
1766
+ )) })
1767
+ ] }) : null;
1768
+ }
1769
+ function hr(e) {
1770
+ const n = new Date(e).getTime() - Date.now();
1771
+ if (n <= 0) return "Now";
1772
+ const s = Math.floor(n / (1e3 * 60 * 60));
1773
+ if (s < 1) return "Less than 1 hour";
1774
+ if (s < 24) return `in ${s}h`;
1775
+ const t = Math.floor(s / 24);
1776
+ if (t === 1) return "Tomorrow";
1777
+ if (t < 7) return `in ${t} days`;
1778
+ if (t < 30) {
1779
+ const a = Math.floor(t / 7);
1780
+ return `in ${a} week${a !== 1 ? "s" : ""}`;
1781
+ }
1782
+ return ne(e);
1783
+ }
1784
+ function xr() {
1785
+ return /* @__PURE__ */ c("svg", { className: "pvx-dash-records-icon", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1786
+ /* @__PURE__ */ r("rect", { x: "3", y: "4", width: "18", height: "18", rx: "2" }),
1787
+ /* @__PURE__ */ r("path", { d: "M16 2v4M8 2v4M3 10h18" })
1593
1788
  ] });
1594
1789
  }
1595
- function Rr({ steamId: r, avatarUrl: t, memberSince: n, className: a = "" }) {
1596
- const { data: s, isLoading: i, error: o } = Je(r), { data: c, isLoading: v } = Ye(r);
1597
- return i || v ? /* @__PURE__ */ e("div", { className: "pvx-loading", children: "Loading dashboard..." }) : o ? /* @__PURE__ */ e("div", { className: "pvx-empty", children: "Failed to load dashboard data." }) : s ? /* @__PURE__ */ l("div", { className: `pvx-dash ${a}`, children: [
1598
- /* @__PURE__ */ e(
1599
- Xe,
1790
+ function gr({ notifications: e, unreadCount: n = 0, onMarkRead: s, onMarkAllRead: t, isLoading: a, className: i }) {
1791
+ const o = ae();
1792
+ return a ? /* @__PURE__ */ r("div", { className: "pvx-loading", children: "Loading notifications..." }) : /* @__PURE__ */ c("div", { className: `pvx-card ${i || ""}`, children: [
1793
+ /* @__PURE__ */ c("div", { className: "pvx-card-header", children: [
1794
+ /* @__PURE__ */ c("h3", { className: "pvx-card-title", children: [
1795
+ /* @__PURE__ */ r(br, {}),
1796
+ "Notifications",
1797
+ n > 0 && /* @__PURE__ */ r("span", { className: "pvx-notif-badge", children: n > 99 ? "99+" : n })
1798
+ ] }),
1799
+ n > 0 && t && /* @__PURE__ */ r("button", { className: "pvx-notif-mark-all", onClick: t, children: "Mark all read" })
1800
+ ] }),
1801
+ e != null && e.length ? /* @__PURE__ */ r("div", { className: "pvx-notif-list", children: e.map((d) => /* @__PURE__ */ r(
1802
+ fr,
1600
1803
  {
1601
- driverName: s.driverName,
1602
- avatarUrl: t,
1603
- memberSince: n
1804
+ notification: d,
1805
+ getUserDisplay: o,
1806
+ onMarkRead: s
1807
+ },
1808
+ d.id
1809
+ )) }) : /* @__PURE__ */ r("div", { className: "pvx-notif-empty", children: "No notifications" })
1810
+ ] });
1811
+ }
1812
+ function fr({ notification: e, getUserDisplay: n, onMarkRead: s }) {
1813
+ const t = () => {
1814
+ !e.isRead && s && s(e.id);
1815
+ };
1816
+ return /* @__PURE__ */ c(
1817
+ "button",
1818
+ {
1819
+ className: `pvx-notif-item ${e.isRead ? "" : "pvx-notif-item--unread"}`,
1820
+ onClick: t,
1821
+ children: [
1822
+ /* @__PURE__ */ r(Nr, { type: e.type }),
1823
+ /* @__PURE__ */ c("div", { className: "pvx-notif-content", children: [
1824
+ /* @__PURE__ */ r("span", { className: "pvx-notif-message", children: Te(e, n) }),
1825
+ /* @__PURE__ */ r("span", { className: "pvx-notif-time", children: ne(e.createdAt) })
1826
+ ] }),
1827
+ !e.isRead && /* @__PURE__ */ r("span", { className: "pvx-notif-dot" })
1828
+ ]
1829
+ }
1830
+ );
1831
+ }
1832
+ function Nr({ type: e }) {
1833
+ return e === "RECORD_BEATEN" ? /* @__PURE__ */ r("span", { className: "pvx-notif-icon pvx-notif-icon--beaten", children: /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ r("path", { d: "m7 7 10 10M17 7v10H7" }) }) }) : e === "ADMIN_MESSAGE" ? /* @__PURE__ */ r("span", { className: "pvx-notif-icon pvx-notif-icon--admin", children: /* @__PURE__ */ c("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1834
+ /* @__PURE__ */ r("path", { d: "m3 11 18-5v12L3 13v-2z" }),
1835
+ /* @__PURE__ */ r("path", { d: "M11.6 16.8a3 3 0 1 1-5.8-1.6" })
1836
+ ] }) }) : /* @__PURE__ */ r("span", { className: "pvx-notif-icon pvx-notif-icon--record", children: /* @__PURE__ */ c("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1837
+ /* @__PURE__ */ r("path", { d: "M6 9H4.5a2.5 2.5 0 0 1 0-5H6" }),
1838
+ /* @__PURE__ */ r("path", { d: "M18 9h1.5a2.5 2.5 0 0 0 0-5H18" }),
1839
+ /* @__PURE__ */ r("path", { d: "M4 22h16" }),
1840
+ /* @__PURE__ */ r("path", { d: "M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22" }),
1841
+ /* @__PURE__ */ r("path", { d: "M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22" }),
1842
+ /* @__PURE__ */ r("path", { d: "M18 2H6v7a6 6 0 0 0 12 0V2Z" })
1843
+ ] }) });
1844
+ }
1845
+ function br() {
1846
+ return /* @__PURE__ */ c("svg", { className: "pvx-dash-records-icon", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1847
+ /* @__PURE__ */ r("path", { d: "M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9" }),
1848
+ /* @__PURE__ */ r("path", { d: "M10.3 21a1.94 1.94 0 0 0 3.4 0" })
1849
+ ] });
1850
+ }
1851
+ function jr({ steamId: e, avatarUrl: n, memberSince: s, className: t = "" }) {
1852
+ const { data: a, isLoading: i, error: o } = rr(e), { data: d, isLoading: u } = tr(e), { data: l, isLoading: m } = nr(), g = sr(), { data: h, isLoading: f } = ar({ limit: 10 }), b = ir(), p = or();
1853
+ return i || u ? /* @__PURE__ */ r("div", { className: "pvx-loading", children: "Loading dashboard..." }) : o ? /* @__PURE__ */ r("div", { className: "pvx-empty", children: "Failed to load dashboard data." }) : a ? /* @__PURE__ */ c("div", { className: `pvx-dash ${t}`, children: [
1854
+ /* @__PURE__ */ r(
1855
+ cr,
1856
+ {
1857
+ driverName: a.driverName,
1858
+ avatarUrl: n,
1859
+ memberSince: s
1604
1860
  }
1605
1861
  ),
1606
- /* @__PURE__ */ e(nr, { stats: s, rating: c }),
1607
- /* @__PURE__ */ e(sr, { records: s.currentRecords })
1608
- ] }) : /* @__PURE__ */ e("div", { className: "pvx-empty", children: "No data available yet. Start driving to see your stats!" });
1862
+ /* @__PURE__ */ r(ur, { stats: a, rating: d }),
1863
+ e && /* @__PURE__ */ r(vr, { events: l, isLoading: m }),
1864
+ /* @__PURE__ */ c("div", { className: `pvx-dash-row ${g ? "pvx-dash-row--2col" : ""}`, children: [
1865
+ /* @__PURE__ */ r(mr, { records: a.currentRecords }),
1866
+ g && /* @__PURE__ */ r(
1867
+ gr,
1868
+ {
1869
+ notifications: h == null ? void 0 : h.notifications,
1870
+ unreadCount: (h == null ? void 0 : h.unreadCount) || 0,
1871
+ onMarkRead: (N) => b.mutate(N),
1872
+ onMarkAllRead: () => p.mutate(),
1873
+ isLoading: f
1874
+ }
1875
+ )
1876
+ ] })
1877
+ ] }) : /* @__PURE__ */ r("div", { className: "pvx-empty", children: "No data available yet. Start driving to see your stats!" });
1609
1878
  }
1610
1879
  export {
1611
- fr as CarsTable,
1612
- M as CompEmptyState,
1613
- U as CompLoadingState,
1614
- yr as CompetitionCards,
1615
- Rr as DriverDashboard,
1616
- Xe as DriverProfile,
1617
- Nr as DriversTable,
1618
- kr as EntryList,
1619
- E as InfoPill,
1620
- br as LapHistoryTable,
1621
- Ie as PODIUM_MEDALS,
1622
- or as PitVoxPartnerProvider,
1623
- sr as RecordsTable,
1624
- Tr as RegisterButton,
1625
- Sr as RegistrationPanel,
1626
- wr as RoundResults,
1627
- Oe as RoundSessionResults,
1628
- Cr as StandingsTable,
1629
- nr as StatsCards,
1630
- gr as TracksTable,
1631
- _e as TypeBadge,
1632
- R as formatCarName,
1633
- D as formatDate,
1634
- dr as formatDelta,
1635
- B as formatLapTime,
1636
- cr as formatRelativeTime,
1637
- $ as formatSectorTime,
1638
- O as formatTrackName,
1880
+ Ir as CarsTable,
1881
+ I as CompEmptyState,
1882
+ F as CompLoadingState,
1883
+ Ur as CompetitionCards,
1884
+ jr as DriverDashboard,
1885
+ cr as DriverProfile,
1886
+ Br as DriversTable,
1887
+ Er as EntryList,
1888
+ H as InfoPill,
1889
+ Pr as LapHistoryTable,
1890
+ gr as NotificationsCard,
1891
+ _e as PODIUM_MEDALS,
1892
+ kr as PitVoxPartnerProvider,
1893
+ mr as RecordsTable,
1894
+ _r as RegisterButton,
1895
+ qr as RegistrationPanel,
1896
+ Fr as RoundResults,
1897
+ Qe as RoundSessionResults,
1898
+ Ar as StandingsTable,
1899
+ ur as StatsCards,
1900
+ Dr as TracksTable,
1901
+ je as TypeBadge,
1902
+ vr as UpcomingEvents,
1903
+ S as formatCarName,
1904
+ A as formatDate,
1905
+ Lr as formatDelta,
1906
+ U as formatLapTime,
1907
+ Te as formatNotificationMessage,
1908
+ ne as formatRelativeTime,
1909
+ D as formatSectorTime,
1910
+ q as formatTrackName,
1639
1911
  se as formatTyreCompound,
1640
- hr as useCarLeaderboard,
1641
- mr as useCarMetadata,
1642
- xr as useCompetitionAllRounds,
1643
- Se as useCompetitionConfig,
1644
- ae as useCompetitionEntryList,
1645
- Le as useCompetitionRound,
1646
- Re as useCompetitionStandings,
1647
- ur as useCompetitions,
1648
- Te as useDriverLaps,
1649
- Ye as useDriverRating,
1650
- Je as useDriverStats,
1651
- pr as useLeaderboardIndex,
1652
- y as usePitVox,
1653
- ie as useRegister,
1654
- G as useRegistrationMode,
1655
- W as useRegistrationStatus,
1656
- z as useRegistrationUrl,
1657
- ke as useTrackLeaderboard,
1658
- vr as useUserLookup,
1659
- le as useWithdraw
1912
+ Sr as useCarLeaderboard,
1913
+ Tr as useCarMetadata,
1914
+ Mr as useCompetitionAllRounds,
1915
+ Me as useCompetitionConfig,
1916
+ ie as useCompetitionEntryList,
1917
+ Ie as useCompetitionRound,
1918
+ De as useCompetitionStandings,
1919
+ $r as useCompetitions,
1920
+ $e as useDriverLaps,
1921
+ tr as useDriverRating,
1922
+ rr as useDriverStats,
1923
+ Rr as useLeaderboardIndex,
1924
+ or as useMarkAllNotificationsRead,
1925
+ ir as useMarkNotificationRead,
1926
+ ar as useNotifications,
1927
+ sr as useNotificationsEnabled,
1928
+ w as usePitVox,
1929
+ oe as useRegister,
1930
+ Q as useRegistrationMode,
1931
+ z as useRegistrationStatus,
1932
+ Y as useRegistrationUrl,
1933
+ Se as useTrackLeaderboard,
1934
+ Vr as useUnreadCount,
1935
+ nr as useUpcomingEvents,
1936
+ ae as useUserLookup,
1937
+ ce as useWithdraw
1660
1938
  };