@pitvox/partner-react 0.2.1 → 0.3.0

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,70 +1,72 @@
1
1
  import { jsx as e, jsxs as l, Fragment as Q } from "react/jsx-runtime";
2
- import { createContext as Re, useMemo as k, useContext as De, useState as j, useCallback as G } from "react";
3
- import { useQueryClient as J, QueryClient as Ie, QueryClientProvider as Me, useQuery as L, useMutation as ie } from "@tanstack/react-query";
2
+ import { createContext as Re, useMemo as T, useContext as $e, useState as q, useCallback as G } from "react";
3
+ import { useQueryClient as Z, QueryClient as Me, QueryClientProvider as De, useQuery as L, useMutation as ie } from "@tanstack/react-query";
4
4
  import { useSearchParams as oe } from "react-router-dom";
5
- const z = Re(null), Be = "https://cdn.pitvox.com", Ae = "https://api.pitvox.com";
5
+ const z = Re(null), Be = "https://cdn.pitvox.com", Ie = "https://pitvox.com";
6
6
  let W = null;
7
- function At({
7
+ function Pt({
8
8
  partnerSlug: t,
9
- apiKey: r,
10
9
  cdnUrl: n = Be,
11
- apiUrl: a = Ae,
12
- getSteamId: s,
13
- children: i
10
+ pitvoxUrl: r = Ie,
11
+ getSteamId: a,
12
+ onRegister: s,
13
+ onWithdraw: i,
14
+ children: c
14
15
  }) {
15
- const c = k(() => ({
16
+ const o = T(() => ({
16
17
  partnerSlug: t,
17
- apiKey: r,
18
18
  cdnUrl: n.replace(/\/$/, ""),
19
- apiUrl: a.replace(/\/$/, ""),
20
- getSteamId: s || (() => null)
21
- }), [t, r, n, a, s]);
22
- let o = !1;
19
+ pitvoxUrl: r.replace(/\/$/, ""),
20
+ getSteamId: a || (() => null),
21
+ onRegister: s || null,
22
+ onWithdraw: i || null
23
+ }), [t, n, r, a, s, i]);
24
+ let m = !1;
23
25
  try {
24
- J(), o = !0;
26
+ Z(), m = !0;
25
27
  } catch {
26
- o = !1;
28
+ m = !1;
27
29
  }
28
- return o ? /* @__PURE__ */ e(z.Provider, { value: c, children: i }) : (W || (W = new Ie({
30
+ return m ? /* @__PURE__ */ e(z.Provider, { value: o, children: c }) : (W || (W = new Me({
29
31
  defaultOptions: {
30
32
  queries: { staleTime: 6e4 }
31
33
  }
32
- })), /* @__PURE__ */ e(Me, { client: W, children: /* @__PURE__ */ e(z.Provider, { value: c, children: i }) }));
34
+ })), /* @__PURE__ */ e(De, { client: W, children: /* @__PURE__ */ e(z.Provider, { value: o, children: c }) }));
33
35
  }
34
- function T() {
35
- const t = De(z);
36
+ function k() {
37
+ const t = $e(z);
36
38
  if (!t)
37
39
  throw new Error("usePitVox must be used within a <PitVoxPartnerProvider>");
38
40
  return t;
39
41
  }
40
- async function $(t, r) {
41
- const n = await fetch(`${t}/${r}`);
42
- if (!n.ok) {
43
- if (n.status === 404 || n.status === 403) return null;
44
- throw new Error(`CDN fetch failed: ${n.status}`);
42
+ async function R(t, n) {
43
+ const r = await fetch(`${t}/${n}`);
44
+ if (!r.ok) {
45
+ if (r.status === 404 || r.status === 403) return null;
46
+ throw new Error(`CDN fetch failed: ${r.status}`);
45
47
  }
46
- return n.json();
48
+ return r.json();
47
49
  }
48
- function E(t) {
50
+ function F(t) {
49
51
  if (!t && t !== 0) return "-";
50
- const r = Math.floor(t / 1e3), n = Math.floor(r / 60), a = r % 60, s = t % 1e3;
51
- return `${n}:${String(a).padStart(2, "0")}.${String(s).padStart(3, "0")}`;
52
+ const n = Math.floor(t / 1e3), r = Math.floor(n / 60), a = n % 60, s = t % 1e3;
53
+ return `${r}:${String(a).padStart(2, "0")}.${String(s).padStart(3, "0")}`;
52
54
  }
53
- function P(t) {
55
+ function A(t) {
54
56
  return !t && t !== 0 ? "-" : (t / 1e3).toFixed(3);
55
57
  }
56
- function I(t) {
58
+ function D(t) {
57
59
  if (!t) return "";
58
- let r = t;
59
- return r.startsWith("ks_") && (r = r.slice(3)), r.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ");
60
+ let n = t;
61
+ return n.startsWith("ks_") && (n = n.slice(3)), n.split("_").map((r) => r.charAt(0).toUpperCase() + r.slice(1)).join(" ");
60
62
  }
61
- function V(t, r, n) {
62
- const a = t.split("_").map((c) => c.charAt(0).toUpperCase() + c.slice(1)).join(" "), s = n === "acc" || !n && (r == null ? void 0 : r.toLowerCase()) === "track config";
63
- if (!r || r === "default" || s) return a;
64
- const i = r.split("_").map((c) => c.charAt(0).toUpperCase() + c.slice(1)).join(" ");
63
+ function j(t, n, r) {
64
+ const a = t.split("_").map((c) => c.charAt(0).toUpperCase() + c.slice(1)).join(" "), s = r === "acc" || !r && (n == null ? void 0 : n.toLowerCase()) === "track config";
65
+ if (!n || n === "default" || s) return a;
66
+ const i = n.split("_").map((c) => c.charAt(0).toUpperCase() + c.slice(1)).join(" ");
65
67
  return `${a} ${i}`;
66
68
  }
67
- function F(t) {
69
+ function E(t) {
68
70
  if (!t) return "-";
69
71
  try {
70
72
  return new Date(t).toLocaleDateString("en-GB", {
@@ -76,16 +78,16 @@ function F(t) {
76
78
  return "-";
77
79
  }
78
80
  }
79
- function Pt(t) {
81
+ function At(t) {
80
82
  if (!t) return "";
81
- const r = Date.now() - new Date(t).getTime(), n = Math.floor(r / 1e3);
82
- if (n < 60) return "Just now";
83
- const a = Math.floor(n / 60);
83
+ const n = Date.now() - new Date(t).getTime(), r = Math.floor(n / 1e3);
84
+ if (r < 60) return "Just now";
85
+ const a = Math.floor(r / 60);
84
86
  if (a < 60) return `${a}m ago`;
85
87
  const s = Math.floor(a / 60);
86
88
  if (s < 24) return `${s}h ago`;
87
89
  const i = Math.floor(s / 24);
88
- return i < 30 ? `${i}d ago` : F(t);
90
+ return i < 30 ? `${i}d ago` : E(t);
89
91
  }
90
92
  function Ut(t) {
91
93
  return t == null ? "" : `${t >= 0 ? "+" : "-"}${(Math.abs(t) / 1e3).toFixed(3)}`;
@@ -105,28 +107,28 @@ function le(t) {
105
107
  }[t] || t : "Unknown";
106
108
  }
107
109
  function Pe(t = {}) {
108
- var o, m, d, g, N, x;
109
- const { cdnUrl: r, partnerSlug: n } = T(), { game: a, gameVersion: s } = t, i = L({
110
- queryKey: ["pitvox", "leaderboards", n, "index"],
111
- queryFn: () => $(r, `leaderboards/partners/${n}/index.json`),
110
+ var o, m, d, x, N, f;
111
+ const { cdnUrl: n, partnerSlug: r } = k(), { game: a, gameVersion: s } = t, i = L({
112
+ queryKey: ["pitvox", "leaderboards", r, "index"],
113
+ queryFn: () => R(n, `leaderboards/partners/${r}/index.json`),
112
114
  staleTime: 3e4,
113
115
  refetchInterval: 3e4
114
- }), c = k(() => {
115
- var f;
116
- if (!((f = i.data) != null && f.tracks)) return [];
117
- let h = i.data.tracks;
118
- return a && (h = h.filter((p) => p.game === a)), s && (h = h.filter((p) => p.gameVersion === s)), h.map((p) => ({
116
+ }), c = T(() => {
117
+ var g;
118
+ if (!((g = i.data) != null && g.tracks)) return [];
119
+ let v = i.data.tracks;
120
+ return a && (v = v.filter((p) => p.game === a)), s && (v = v.filter((p) => p.gameVersion === s)), v.map((p) => ({
119
121
  id: p.trackId,
120
122
  layout: p.layout,
121
123
  game: p.game,
122
124
  gameVersion: p.gameVersion,
123
- displayName: V(p.trackId, p.layout, p.game),
125
+ displayName: j(p.trackId, p.layout, p.game),
124
126
  driverCount: p.driverCount || 0,
125
127
  carCount: p.carCount || 0,
126
128
  record: p.recordHolder ? {
127
129
  visibleId: p.recordHolder.steamId || p.recordHolder.userId,
128
130
  carId: p.recordHolder.carId,
129
- carDisplayName: I(p.recordHolder.carId),
131
+ carDisplayName: D(p.recordHolder.carId),
130
132
  lapTimeMs: p.recordHolder.lapTimeMs,
131
133
  timestamp: p.recordHolder.recordedAt
132
134
  } : null,
@@ -138,69 +140,69 @@ function Pe(t = {}) {
138
140
  data: c,
139
141
  partner: ((m = i.data) == null ? void 0 : m.partner) || null,
140
142
  generatedAt: (d = i.data) == null ? void 0 : d.generatedAt,
141
- totalLaps: ((g = i.data) == null ? void 0 : g.totalLaps) || 0,
143
+ totalLaps: ((x = i.data) == null ? void 0 : x.totalLaps) || 0,
142
144
  totalUsers: ((N = i.data) == null ? void 0 : N.totalUsers) || 0,
143
- versions: ((x = i.data) == null ? void 0 : x.versions) || {}
145
+ versions: ((f = i.data) == null ? void 0 : f.versions) || {}
144
146
  };
145
147
  }
146
- function ce(t, r, n = {}) {
147
- const { cdnUrl: a, partnerSlug: s } = T(), { carId: i, game: c, gameVersion: o } = n, m = r || "default", d = o ? `leaderboards/partners/${s}/v/${o}/tracks/${t}/${m}.json` : `leaderboards/partners/${s}/tracks/${t}/${m}.json`, { data: g, isLoading: N, error: x } = L({
148
+ function ce(t, n, r = {}) {
149
+ const { cdnUrl: a, partnerSlug: s } = k(), { carId: i, game: c, gameVersion: o } = r, m = n || "default", d = o ? `leaderboards/partners/${s}/v/${o}/tracks/${t}/${m}.json` : `leaderboards/partners/${s}/tracks/${t}/${m}.json`, { data: x, isLoading: N, error: f } = L({
148
150
  queryKey: ["pitvox", "leaderboards", s, "track", t, m, o],
149
- queryFn: () => $(a, d),
151
+ queryFn: () => R(a, d),
150
152
  enabled: !!t,
151
153
  staleTime: 3e4,
152
154
  refetchInterval: 3e4
153
155
  });
154
- return { data: k(() => {
155
- if (!(g != null && g.entries)) return [];
156
- let f = g.entries;
157
- if (c && (f = f.filter((p) => p.game === c)), !i) {
158
- const p = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map();
159
- for (const u of f) {
156
+ return { data: T(() => {
157
+ if (!(x != null && x.entries)) return [];
158
+ let g = x.entries;
159
+ if (c && (g = g.filter((p) => p.game === c)), !i) {
160
+ const p = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
161
+ for (const u of g) {
160
162
  const y = u.steamId || u.userId;
161
- v.has(u.carId) || v.set(u.carId, /* @__PURE__ */ new Set()), v.get(u.carId).add(y), (!p.has(u.carId) || u.lapTimeMs < p.get(u.carId).lapTimeMs) && p.set(u.carId, u);
163
+ h.has(u.carId) || h.set(u.carId, /* @__PURE__ */ new Set()), h.get(u.carId).add(y), (!p.has(u.carId) || u.lapTimeMs < p.get(u.carId).lapTimeMs) && p.set(u.carId, u);
162
164
  }
163
165
  return Array.from(p.values()).map((u) => {
164
166
  var y;
165
- return { ...u, driverCount: ((y = v.get(u.carId)) == null ? void 0 : y.size) || 0 };
167
+ return { ...u, driverCount: ((y = h.get(u.carId)) == null ? void 0 : y.size) || 0 };
166
168
  }).sort((u, y) => u.lapTimeMs - y.lapTimeMs);
167
169
  }
168
- return f.filter((p) => p.carId === i).sort((p, v) => p.lapTimeMs - v.lapTimeMs);
169
- }, [g == null ? void 0 : g.entries, i, c]), isLoading: N, error: x };
170
+ return g.filter((p) => p.carId === i).sort((p, h) => p.lapTimeMs - h.lapTimeMs);
171
+ }, [x == null ? void 0 : x.entries, i, c]), isLoading: N, error: f };
170
172
  }
171
- function Ue(t, r, n, a, s = {}) {
172
- var x, h;
173
- const { cdnUrl: i, partnerSlug: c } = T(), { showInvalid: o = !1, game: m, gameVersion: d } = s, g = L({
173
+ function Ae(t, n, r, a, s = {}) {
174
+ var f, v;
175
+ const { cdnUrl: i, partnerSlug: c } = k(), { showInvalid: o = !1, game: m, gameVersion: d } = s, x = L({
174
176
  queryKey: ["pitvox", "laps", c, t],
175
- queryFn: () => $(i, `laps/partners/${c}/${t}.json`),
177
+ queryFn: () => R(i, `laps/partners/${c}/${t}.json`),
176
178
  enabled: !!t,
177
179
  staleTime: 3e4,
178
180
  refetchInterval: 3e4
179
- }), N = k(() => {
180
- var f;
181
- return (f = g.data) != null && f.laps ? g.data.laps.filter((p) => {
182
- if (p.trackId !== r) return !1;
183
- if (n) {
184
- if (p.trackLayout !== n) return !1;
181
+ }), N = T(() => {
182
+ var g;
183
+ return (g = x.data) != null && g.laps ? x.data.laps.filter((p) => {
184
+ if (p.trackId !== n) return !1;
185
+ if (r) {
186
+ if (p.trackLayout !== r) return !1;
185
187
  } else if (p.trackLayout && p.trackLayout !== "default") return !1;
186
188
  return !(p.carId !== a || m && p.game !== m || d && p.gameVersion !== d || !o && !p.isValid);
187
- }).sort((p, v) => p.lapTimeMs - v.lapTimeMs) : [];
188
- }, [(x = g.data) == null ? void 0 : x.laps, r, n, a, m, d, o]);
189
+ }).sort((p, h) => p.lapTimeMs - h.lapTimeMs) : [];
190
+ }, [(f = x.data) == null ? void 0 : f.laps, n, r, a, m, d, o]);
189
191
  return {
190
- ...g,
192
+ ...x,
191
193
  data: N,
192
- driverName: ((h = g.data) == null ? void 0 : h.driverName) || "Driver"
194
+ driverName: ((v = x.data) == null ? void 0 : v.driverName) || "Driver"
193
195
  };
194
196
  }
195
- function Ee() {
196
- const { cdnUrl: t } = T(), { data: r } = L({
197
+ function Ue() {
198
+ const { cdnUrl: t } = k(), { data: n } = L({
197
199
  queryKey: ["pitvox", "users", "index"],
198
- queryFn: () => $(t, "users/index.json"),
200
+ queryFn: () => R(t, "users/index.json"),
199
201
  staleTime: 5 * 6e4,
200
202
  gcTime: 30 * 6e4
201
- }), n = (r == null ? void 0 : r.users) || {};
203
+ }), r = (n == null ? void 0 : n.users) || {};
202
204
  return (a, s) => {
203
- const i = n[a];
205
+ const i = r[a];
204
206
  return {
205
207
  displayName: (i == null ? void 0 : i.displayName) || s || a || "Unknown",
206
208
  avatarUrl: (i == null ? void 0 : i.avatarUrl) || null,
@@ -209,113 +211,87 @@ function Ee() {
209
211
  };
210
212
  }
211
213
  function Fe() {
212
- const { cdnUrl: t } = T(), { data: r } = L({
214
+ const { cdnUrl: t } = k(), { data: n } = L({
213
215
  queryKey: ["pitvox", "cars", "index"],
214
- queryFn: () => $(t, "cars/index.json"),
216
+ queryFn: () => R(t, "cars/index.json"),
215
217
  staleTime: 5 * 6e4,
216
218
  gcTime: 30 * 6e4
217
219
  });
218
220
  return {
219
- tags: (r == null ? void 0 : r.tags) || [],
220
- cars: (r == null ? void 0 : r.cars) || {}
221
+ tags: (n == null ? void 0 : n.tags) || [],
222
+ cars: (n == null ? void 0 : n.cars) || {}
221
223
  };
222
224
  }
223
- function Et(t, r) {
224
- return ce(t, null, { carId: r });
225
+ function Ft(t, n) {
226
+ return ce(t, null, { carId: n });
225
227
  }
226
- function _e() {
227
- const { cdnUrl: t, partnerSlug: r } = T();
228
+ function Ee() {
229
+ const { cdnUrl: t, partnerSlug: n } = k();
228
230
  return L({
229
- queryKey: ["pitvox", "competitions", r],
231
+ queryKey: ["pitvox", "competitions", n],
230
232
  queryFn: async () => {
231
- const n = await $(t, "competitions/index.json");
232
- return n != null && n.competitions ? n.competitions.filter((a) => a.partnerSlug === r) : [];
233
+ const r = await R(t, "competitions/index.json");
234
+ return r != null && r.competitions ? r.competitions.filter((a) => a.partnerSlug === n) : [];
233
235
  },
234
236
  staleTime: 6e4
235
237
  });
236
238
  }
237
239
  function de(t) {
238
- const { cdnUrl: r, partnerSlug: n } = T();
240
+ const { cdnUrl: n, partnerSlug: r } = k();
239
241
  return L({
240
- queryKey: ["pitvox", "competition", n, t, "config"],
241
- queryFn: () => $(r, `competitions/${n}/${t}/config.json`),
242
+ queryKey: ["pitvox", "competition", r, t, "config"],
243
+ queryFn: () => R(n, `competitions/${r}/${t}/config.json`),
242
244
  enabled: !!t,
243
245
  staleTime: 6e4
244
246
  });
245
247
  }
246
- function qe(t) {
247
- const { cdnUrl: r, partnerSlug: n } = T();
248
+ function Ve(t) {
249
+ const { cdnUrl: n, partnerSlug: r } = k();
248
250
  return L({
249
- queryKey: ["pitvox", "competition", n, t, "standings"],
250
- queryFn: () => $(r, `competitions/${n}/${t}/standings.json`),
251
+ queryKey: ["pitvox", "competition", r, t, "standings"],
252
+ queryFn: () => R(n, `competitions/${r}/${t}/standings.json`),
251
253
  enabled: !!t,
252
254
  staleTime: 6e4
253
255
  });
254
256
  }
255
- function je(t, r) {
256
- const { cdnUrl: n, partnerSlug: a } = T();
257
+ function _e(t, n) {
258
+ const { cdnUrl: r, partnerSlug: a } = k();
257
259
  return L({
258
- queryKey: ["pitvox", "competition", a, t, "round", r],
259
- queryFn: () => $(n, `competitions/${a}/${t}/rounds/${r}.json`),
260
- enabled: !!t && r != null,
260
+ queryKey: ["pitvox", "competition", a, t, "round", n],
261
+ queryFn: () => R(r, `competitions/${a}/${t}/rounds/${n}.json`),
262
+ enabled: !!t && n != null,
261
263
  staleTime: 6e4
262
264
  });
263
265
  }
264
- function Ft(t, r = []) {
265
- const { cdnUrl: n, partnerSlug: a } = T();
266
+ function Et(t, n = []) {
267
+ const { cdnUrl: r, partnerSlug: a } = k();
266
268
  return L({
267
- queryKey: ["pitvox", "competition", a, t, "allRounds", r],
269
+ queryKey: ["pitvox", "competition", a, t, "allRounds", n],
268
270
  queryFn: async () => (await Promise.all(
269
- r.map(
270
- (i) => $(n, `competitions/${a}/${t}/rounds/${i}.json`).catch(() => null)
271
+ n.map(
272
+ (i) => R(r, `competitions/${a}/${t}/rounds/${i}.json`).catch(() => null)
271
273
  )
272
274
  )).filter(Boolean),
273
- enabled: !!t && r.length > 0,
275
+ enabled: !!t && n.length > 0,
274
276
  staleTime: 6e4
275
277
  });
276
278
  }
277
- function Ve(t) {
278
- const { cdnUrl: r, partnerSlug: n } = T();
279
+ function qe(t) {
280
+ const { cdnUrl: n, partnerSlug: r } = k();
279
281
  return L({
280
- queryKey: ["pitvox", "competition", n, t, "entrylist"],
281
- queryFn: () => $(r, `competitions/${n}/${t}/entrylist.json`),
282
+ queryKey: ["pitvox", "competition", r, t, "entrylist"],
283
+ queryFn: () => R(n, `competitions/${r}/${t}/entrylist.json`),
282
284
  enabled: !!t,
283
285
  staleTime: 6e4
284
286
  });
285
287
  }
286
- async function pe(t, r, n, a = {}) {
287
- const s = await fetch(`${t}${n}`, {
288
- ...a,
289
- headers: {
290
- "Content-Type": "application/json",
291
- "X-Partner-Key": r,
292
- ...a.headers
293
- }
294
- });
295
- if (!s.ok) {
296
- const i = await s.json().catch(() => ({}));
297
- throw new Error(i.detail || `API request failed: ${s.status}`);
298
- }
299
- return s.json();
300
- }
301
- function Ke(t, r, n, a) {
302
- return pe(t, r, `/api/v1/competitions/${n}/register`, {
303
- method: "POST",
304
- body: JSON.stringify(a)
305
- });
306
- }
307
- function He(t, r, n, a) {
308
- return pe(t, r, `/api/v1/competitions/${n}/register/${a}`, {
309
- method: "DELETE"
310
- });
311
- }
312
- function Oe(t) {
313
- const { cdnUrl: r, partnerSlug: n, getSteamId: a } = T(), s = a();
288
+ function je(t) {
289
+ const { cdnUrl: n, partnerSlug: r, getSteamId: a } = k(), s = a();
314
290
  return L({
315
- queryKey: ["pitvox", "registration", n, t, s],
291
+ queryKey: ["pitvox", "registration", r, t, s],
316
292
  queryFn: async () => {
317
293
  var m;
318
- const i = await fetch(`${r}/competitions/${n}/${t}/entrylist.json`);
294
+ const i = await fetch(`${n}/competitions/${r}/${t}/entrylist.json`);
319
295
  if (!i.ok) return { isRegistered: !1, entryList: null };
320
296
  const c = await i.json();
321
297
  return { isRegistered: !!s && ((m = c.drivers) == null ? void 0 : m.some((d) => d.steamId === s)), entryList: c };
@@ -324,37 +300,55 @@ function Oe(t) {
324
300
  staleTime: 6e4
325
301
  });
326
302
  }
327
- function We(t) {
328
- const { apiUrl: r, apiKey: n, partnerSlug: a } = T(), s = J();
303
+ function Ke(t) {
304
+ const { onRegister: n, partnerSlug: r } = k(), a = Z();
329
305
  return ie({
330
- mutationFn: (i) => Ke(r, n, t, i),
306
+ mutationFn: (s) => {
307
+ if (!n)
308
+ throw new Error(
309
+ "No onRegister callback provided to PitVoxPartnerProvider. Provide onRegister for in-app registration, or use useRegistrationUrl() to link to pitvox.com."
310
+ );
311
+ return n(t, s);
312
+ },
331
313
  onSuccess: () => {
332
- s.invalidateQueries({
333
- queryKey: ["pitvox", "registration", a, t]
334
- }), s.invalidateQueries({
335
- queryKey: ["pitvox", "competition", a, t, "entrylist"]
314
+ a.invalidateQueries({
315
+ queryKey: ["pitvox", "registration", r, t]
316
+ }), a.invalidateQueries({
317
+ queryKey: ["pitvox", "competition", r, t, "entrylist"]
336
318
  });
337
319
  }
338
320
  });
339
321
  }
340
- function Ge(t) {
341
- const { apiUrl: r, apiKey: n, partnerSlug: a, getSteamId: s } = T(), i = J();
322
+ function He(t) {
323
+ const { onWithdraw: n, partnerSlug: r, getSteamId: a } = k(), s = Z();
342
324
  return ie({
343
- mutationFn: (c) => {
344
- const o = c || s();
345
- if (!o) throw new Error("No Steam ID available");
346
- return He(r, n, t, o);
325
+ mutationFn: (i) => {
326
+ if (!n)
327
+ throw new Error(
328
+ "No onWithdraw callback provided to PitVoxPartnerProvider. Provide onWithdraw for in-app withdrawal, or use useRegistrationUrl() to link to pitvox.com."
329
+ );
330
+ const c = i || a();
331
+ if (!c) throw new Error("No Steam ID available");
332
+ return n(t, c);
347
333
  },
348
334
  onSuccess: () => {
349
- i.invalidateQueries({
350
- queryKey: ["pitvox", "registration", a, t]
351
- }), i.invalidateQueries({
352
- queryKey: ["pitvox", "competition", a, t, "entrylist"]
335
+ s.invalidateQueries({
336
+ queryKey: ["pitvox", "registration", r, t]
337
+ }), s.invalidateQueries({
338
+ queryKey: ["pitvox", "competition", r, t, "entrylist"]
353
339
  });
354
340
  }
355
341
  });
356
342
  }
357
- const ze = {
343
+ function Oe() {
344
+ const { onRegister: t, onWithdraw: n } = k(), r = !!(t && n);
345
+ return { isPowerMode: r, isBasicMode: !r };
346
+ }
347
+ function We(t) {
348
+ const { pitvoxUrl: n, partnerSlug: r } = k();
349
+ return `${n}/p/${r}/competitions/${t}/register`;
350
+ }
351
+ const Ge = {
358
352
  formula: "Formula",
359
353
  gt3: "GT3",
360
354
  gt2: "GT2",
@@ -374,97 +368,97 @@ const ze = {
374
368
  "2000s": "2000s",
375
369
  "2010s": "2010s",
376
370
  "2020s": "2020s"
377
- }, ue = [
371
+ }, pe = [
378
372
  { id: "class", tags: ["formula", "gt3", "gt2", "gt4", "cup", "prototype", "rally"] },
379
373
  { id: "tier", tags: ["hypercar", "supercar", "sports_car", "hot_hatch", "lightweight"] },
380
374
  { id: "era", tags: ["1960s", "1970s", "1980s", "1990s", "2000s", "2010s", "2020s"] }
381
375
  ];
382
- function Qe(t) {
383
- for (const r of ue)
384
- if (r.tags.includes(t)) return r.id;
376
+ function ze(t) {
377
+ for (const n of pe)
378
+ if (n.tags.includes(t)) return n.id;
385
379
  return "other";
386
380
  }
387
- function me(t, r) {
388
- if (r.size === 0) return !0;
389
- const n = {};
390
- for (const a of r) {
391
- const s = Qe(a);
392
- n[s] || (n[s] = []), n[s].push(a);
381
+ function ue(t, n) {
382
+ if (n.size === 0) return !0;
383
+ const r = {};
384
+ for (const a of n) {
385
+ const s = ze(a);
386
+ r[s] || (r[s] = []), r[s].push(a);
393
387
  }
394
- for (const a of Object.values(n))
388
+ for (const a of Object.values(r))
395
389
  if (!a.some((s) => t.includes(s))) return !1;
396
390
  return !0;
397
391
  }
398
- function he() {
399
- const [t, r] = j(/* @__PURE__ */ new Set()), n = G((s) => {
400
- r((i) => {
392
+ function me() {
393
+ const [t, n] = q(/* @__PURE__ */ new Set()), r = G((s) => {
394
+ n((i) => {
401
395
  const c = new Set(i);
402
396
  return c.has(s) ? c.delete(s) : c.add(s), c;
403
397
  });
404
- }, []), a = G(() => r(/* @__PURE__ */ new Set()), []);
405
- return { activeTags: t, toggle: n, clear: a };
398
+ }, []), a = G(() => n(/* @__PURE__ */ new Set()), []);
399
+ return { activeTags: t, toggle: r, clear: a };
406
400
  }
407
- function Z(t) {
408
- const [r, n] = j(t), a = G((s) => {
409
- n(
401
+ function J(t) {
402
+ const [n, r] = q(t), a = G((s) => {
403
+ r(
410
404
  (i) => i.key === s ? { key: s, dir: i.dir === "asc" ? "desc" : "asc" } : { key: s, dir: s.includes("timestamp") || s.includes("Date") ? "desc" : "asc" }
411
405
  );
412
406
  }, []);
413
- return [r, a];
407
+ return [n, a];
414
408
  }
415
- function X(t, r, n) {
409
+ function X(t, n, r) {
416
410
  return [...t].sort((a, s) => {
417
- const i = n(a, r.key), c = n(s, r.key);
411
+ const i = r(a, n.key), c = r(s, n.key);
418
412
  if (i == null && c == null) return 0;
419
413
  if (i == null) return 1;
420
414
  if (c == null) return -1;
421
415
  const o = typeof i == "string" ? i.localeCompare(c) : i - c;
422
- return r.dir === "desc" ? -o : o;
416
+ return n.dir === "desc" ? -o : o;
423
417
  });
424
418
  }
425
- function ve(t, r = !1) {
426
- const n = r ? t == null ? void 0 : t.filter((a) => a.isValid) : t;
427
- return n != null && n.length ? {
428
- s1: Math.min(...n.map((a) => a.sector1Ms).filter(Boolean)),
429
- s2: Math.min(...n.map((a) => a.sector2Ms).filter(Boolean)),
430
- s3: Math.min(...n.map((a) => a.sector3Ms).filter(Boolean))
419
+ function he(t, n = !1) {
420
+ const r = n ? t == null ? void 0 : t.filter((a) => a.isValid) : t;
421
+ return r != null && r.length ? {
422
+ s1: Math.min(...r.map((a) => a.sector1Ms).filter(Boolean)),
423
+ s2: Math.min(...r.map((a) => a.sector2Ms).filter(Boolean)),
424
+ s3: Math.min(...r.map((a) => a.sector3Ms).filter(Boolean))
431
425
  } : null;
432
426
  }
433
- function Je({ active: t, dir: r }) {
434
- return t ? r === "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" }) });
427
+ function Qe({ active: t, dir: n }) {
428
+ return t ? n === "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" }) });
435
429
  }
436
- function D({ label: t, sortKey: r, config: n, onSort: a, className: s = "" }) {
430
+ function M({ label: t, sortKey: n, config: r, onSort: a, className: s = "" }) {
437
431
  return /* @__PURE__ */ e(
438
432
  "th",
439
433
  {
440
434
  className: `pvx-th pvx-th--sortable ${s}`,
441
- onClick: () => a(r),
435
+ onClick: () => a(n),
442
436
  children: /* @__PURE__ */ l("span", { className: "pvx-th-inner", children: [
443
437
  t,
444
- /* @__PURE__ */ e(Je, { active: n.key === r, dir: n.dir })
438
+ /* @__PURE__ */ e(Qe, { active: r.key === n, dir: r.dir })
445
439
  ] })
446
440
  }
447
441
  );
448
442
  }
449
- function Y({ userId: t, getUserDisplay: r }) {
450
- const { displayName: n, avatarUrl: a } = r(t);
443
+ function Y({ userId: t, getUserDisplay: n }) {
444
+ const { displayName: r, avatarUrl: a } = n(t);
451
445
  return /* @__PURE__ */ l("span", { className: "pvx-driver", children: [
452
446
  a ? /* @__PURE__ */ e("img", { src: a, alt: "", className: "pvx-driver-avatar" }) : /* @__PURE__ */ e("span", { className: "pvx-driver-avatar pvx-driver-avatar--placeholder" }),
453
- /* @__PURE__ */ e("span", { className: "pvx-driver-name", children: n })
447
+ /* @__PURE__ */ e("span", { className: "pvx-driver-name", children: r })
454
448
  ] });
455
449
  }
456
- function xe({ rank: t, podium: r = !1 }) {
457
- return /* @__PURE__ */ e("span", { className: r ? t === 1 ? "pvx-rank pvx-rank--gold" : t === 2 ? "pvx-rank pvx-rank--silver" : t === 3 ? "pvx-rank pvx-rank--bronze" : "pvx-rank" : "pvx-rank", children: t });
450
+ function ve({ rank: t, podium: n = !1 }) {
451
+ return /* @__PURE__ */ e("span", { className: n ? t === 1 ? "pvx-rank pvx-rank--gold" : t === 2 ? "pvx-rank pvx-rank--silver" : t === 3 ? "pvx-rank pvx-rank--bronze" : "pvx-rank" : "pvx-rank", children: t });
458
452
  }
459
- function ge({ availableTags: t, activeTags: r, onToggle: n, onClear: a }) {
453
+ function xe({ availableTags: t, activeTags: n, onToggle: r, onClear: a }) {
460
454
  if (!t || t.length < 2) return null;
461
- const s = ue.map((i) => ({ id: i.id, tags: i.tags.filter((c) => t.includes(c)) })).filter((i) => i.tags.length > 0);
455
+ const s = pe.map((i) => ({ id: i.id, tags: i.tags.filter((c) => t.includes(c)) })).filter((i) => i.tags.length > 0);
462
456
  return /* @__PURE__ */ l("div", { className: "pvx-tag-bar", children: [
463
457
  /* @__PURE__ */ e(
464
458
  "button",
465
459
  {
466
460
  onClick: a,
467
- className: `pvx-tag ${r.size === 0 ? "pvx-tag--active" : ""}`,
461
+ className: `pvx-tag ${n.size === 0 ? "pvx-tag--active" : ""}`,
468
462
  children: "All"
469
463
  }
470
464
  ),
@@ -473,9 +467,9 @@ function ge({ availableTags: t, activeTags: r, onToggle: n, onClear: a }) {
473
467
  i.tags.map((o) => /* @__PURE__ */ e(
474
468
  "button",
475
469
  {
476
- onClick: () => n(o),
477
- className: `pvx-tag ${r.has(o) ? "pvx-tag--active" : ""}`,
478
- children: ze[o] || o
470
+ onClick: () => r(o),
471
+ className: `pvx-tag ${n.has(o) ? "pvx-tag--active" : ""}`,
472
+ children: Ge[o] || o
479
473
  },
480
474
  o
481
475
  ))
@@ -483,12 +477,12 @@ function ge({ availableTags: t, activeTags: r, onToggle: n, onClear: a }) {
483
477
  ] });
484
478
  }
485
479
  function ee({ segments: t }) {
486
- return /* @__PURE__ */ e("nav", { className: "pvx-breadcrumb", "aria-label": "Breadcrumb", children: /* @__PURE__ */ e("ol", { className: "pvx-breadcrumb-list", children: t.map((r, n) => {
487
- const a = n === t.length - 1;
480
+ return /* @__PURE__ */ e("nav", { className: "pvx-breadcrumb", "aria-label": "Breadcrumb", children: /* @__PURE__ */ e("ol", { className: "pvx-breadcrumb-list", children: t.map((n, r) => {
481
+ const a = r === t.length - 1;
488
482
  return /* @__PURE__ */ l("li", { className: "pvx-breadcrumb-item", children: [
489
- 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" }) }),
490
- !a && r.onClick ? /* @__PURE__ */ e("button", { onClick: r.onClick, className: "pvx-breadcrumb-link", children: r.label }) : /* @__PURE__ */ e("span", { className: "pvx-breadcrumb-current", children: r.label })
491
- ] }, r.key);
483
+ r > 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" }) }),
484
+ !a && n.onClick ? /* @__PURE__ */ e("button", { onClick: n.onClick, className: "pvx-breadcrumb-link", children: n.label }) : /* @__PURE__ */ e("span", { className: "pvx-breadcrumb-current", children: n.label })
485
+ ] }, n.key);
492
486
  }) }) });
493
487
  }
494
488
  function K({ message: t }) {
@@ -503,196 +497,196 @@ function H() {
503
497
  function Ze() {
504
498
  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" }) });
505
499
  }
506
- function Xe() {
500
+ function Je() {
507
501
  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" }) });
508
502
  }
509
- function Ye({ tracks: t, isLoading: r, carMetadata: n, getUserDisplay: a, onTrackSelect: s }) {
510
- const [i, c] = Z({ key: "record.timestamp", dir: "desc" }), { activeTags: o, toggle: m, clear: d } = he(), g = k(() => {
511
- var f;
512
- if (!((f = n == null ? void 0 : n.tags) != null && f.length)) return [];
513
- const h = /* @__PURE__ */ new Set();
503
+ function Xe({ tracks: t, isLoading: n, carMetadata: r, getUserDisplay: a, onTrackSelect: s }) {
504
+ const [i, c] = J({ key: "record.timestamp", dir: "desc" }), { activeTags: o, toggle: m, clear: d } = me(), x = T(() => {
505
+ var g;
506
+ if (!((g = r == null ? void 0 : r.tags) != null && g.length)) return [];
507
+ const v = /* @__PURE__ */ new Set();
514
508
  for (const p of t || [])
515
- p.recordByTag && Object.keys(p.recordByTag).forEach((v) => h.add(v));
516
- return n.tags.filter((p) => h.has(p));
517
- }, [t, n]), N = k(() => t ? o.size === 0 ? t : t.map((h) => {
518
- var v, u;
519
- if (!h.recordByTag) return null;
520
- let f = null;
509
+ p.recordByTag && Object.keys(p.recordByTag).forEach((h) => v.add(h));
510
+ return r.tags.filter((p) => v.has(p));
511
+ }, [t, r]), N = T(() => t ? o.size === 0 ? t : t.map((v) => {
512
+ var h, u;
513
+ if (!v.recordByTag) return null;
514
+ let g = null;
521
515
  const p = /* @__PURE__ */ new Set();
522
- for (const y of Object.values(h.recordByTag)) {
516
+ for (const y of Object.values(v.recordByTag)) {
523
517
  if (p.has(y.carId)) continue;
524
518
  p.add(y.carId);
525
- const C = ((u = (v = n == null ? void 0 : n.cars) == null ? void 0 : v[y.carId]) == null ? void 0 : u.tags) || ["sports_car"];
526
- me(C, o) && (!f || y.lapTimeMs < f.lapTimeMs) && (f = y);
519
+ const C = ((u = (h = r == null ? void 0 : r.cars) == null ? void 0 : h[y.carId]) == null ? void 0 : u.tags) || ["sports_car"];
520
+ ue(C, o) && (!g || y.lapTimeMs < g.lapTimeMs) && (g = y);
527
521
  }
528
- return f ? {
529
- ...h,
522
+ return g ? {
523
+ ...v,
530
524
  record: {
531
- visibleId: f.steamId || f.identifier,
532
- carId: f.carId,
533
- carDisplayName: I(f.carId),
534
- lapTimeMs: f.lapTimeMs,
535
- timestamp: f.recordedAt
525
+ visibleId: g.steamId || g.identifier,
526
+ carId: g.carId,
527
+ carDisplayName: D(g.carId),
528
+ lapTimeMs: g.lapTimeMs,
529
+ timestamp: g.recordedAt
536
530
  }
537
531
  } : null;
538
- }).filter(Boolean) : [], [t, o, n]), x = k(() => X(N, i, (h, f) => {
539
- var p, v;
540
- switch (f) {
532
+ }).filter(Boolean) : [], [t, o, r]), f = T(() => X(N, i, (v, g) => {
533
+ var p, h;
534
+ switch (g) {
541
535
  case "displayName":
542
- return h.displayName;
536
+ return v.displayName;
543
537
  case "record.lapTimeMs":
544
- return (p = h.record) == null ? void 0 : p.lapTimeMs;
538
+ return (p = v.record) == null ? void 0 : p.lapTimeMs;
545
539
  case "driverCount":
546
- return h.driverCount || 0;
540
+ return v.driverCount || 0;
547
541
  case "carCount":
548
- return h.carCount || 0;
542
+ return v.carCount || 0;
549
543
  case "record.timestamp":
550
544
  default:
551
- return (v = h.record) != null && v.timestamp ? new Date(h.record.timestamp).getTime() : 0;
545
+ return (h = v.record) != null && h.timestamp ? new Date(v.record.timestamp).getTime() : 0;
552
546
  }
553
547
  }), [N, i]);
554
- return r ? /* @__PURE__ */ e(H, {}) : t != null && t.length ? /* @__PURE__ */ l("div", { className: "pvx-card", children: [
548
+ return n ? /* @__PURE__ */ e(H, {}) : t != null && t.length ? /* @__PURE__ */ l("div", { className: "pvx-card", children: [
555
549
  /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ e("h2", { className: "pvx-card-title", children: "Track Records" }) }),
556
- /* @__PURE__ */ e(ge, { availableTags: g, activeTags: o, onToggle: m, onClear: d }),
550
+ /* @__PURE__ */ e(xe, { availableTags: x, activeTags: o, onToggle: m, onClear: d }),
557
551
  /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
558
552
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
559
- /* @__PURE__ */ e(D, { label: "Track", sortKey: "displayName", config: i, onSort: c }),
553
+ /* @__PURE__ */ e(M, { label: "Track", sortKey: "displayName", config: i, onSort: c }),
560
554
  /* @__PURE__ */ e("th", { className: "pvx-th", children: "Record Holder" }),
561
555
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-lg", children: "Car" }),
562
- /* @__PURE__ */ e(D, { label: "Lap Time", sortKey: "record.lapTimeMs", config: i, onSort: c }),
563
- /* @__PURE__ */ e(D, { label: "Drivers", sortKey: "driverCount", config: i, onSort: c, className: "pvx-hidden-below-md" }),
564
- /* @__PURE__ */ e(D, { label: "Cars", sortKey: "carCount", config: i, onSort: c, className: "pvx-hidden-below-lg" }),
565
- /* @__PURE__ */ e(D, { label: "Date", sortKey: "record.timestamp", config: i, onSort: c, className: "pvx-hidden-below-xl" })
556
+ /* @__PURE__ */ e(M, { label: "Lap Time", sortKey: "record.lapTimeMs", config: i, onSort: c }),
557
+ /* @__PURE__ */ e(M, { label: "Drivers", sortKey: "driverCount", config: i, onSort: c, className: "pvx-hidden-below-md" }),
558
+ /* @__PURE__ */ e(M, { label: "Cars", sortKey: "carCount", config: i, onSort: c, className: "pvx-hidden-below-lg" }),
559
+ /* @__PURE__ */ e(M, { label: "Date", sortKey: "record.timestamp", config: i, onSort: c, className: "pvx-hidden-below-xl" })
566
560
  ] }) }),
567
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: x.map((h) => {
568
- var f, p, v;
561
+ /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: f.map((v) => {
562
+ var g, p, h;
569
563
  return /* @__PURE__ */ l(
570
564
  "tr",
571
565
  {
572
566
  className: "pvx-row pvx-row--clickable",
573
- onClick: () => s(h.id, h.layout),
567
+ onClick: () => s(v.id, v.layout),
574
568
  children: [
575
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: h.displayName }),
576
- /* @__PURE__ */ e("td", { className: "pvx-td", children: (f = h.record) != null && f.visibleId ? /* @__PURE__ */ e(Y, { userId: h.record.visibleId, getUserDisplay: a }) : "-" }),
577
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-hidden-below-lg", children: ((p = h.record) == null ? void 0 : p.carDisplayName) || "-" }),
578
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: h.record ? E(h.record.lapTimeMs) : "-" }),
579
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: h.driverCount || "-" }),
580
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: h.carCount || "-" }),
581
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: (v = h.record) != null && v.timestamp ? F(h.record.timestamp) : "-" })
569
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: v.displayName }),
570
+ /* @__PURE__ */ e("td", { className: "pvx-td", children: (g = v.record) != null && g.visibleId ? /* @__PURE__ */ e(Y, { userId: v.record.visibleId, getUserDisplay: a }) : "-" }),
571
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-hidden-below-lg", children: ((p = v.record) == null ? void 0 : p.carDisplayName) || "-" }),
572
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: v.record ? F(v.record.lapTimeMs) : "-" }),
573
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: v.driverCount || "-" }),
574
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: v.carCount || "-" }),
575
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: (h = v.record) != null && h.timestamp ? E(v.record.timestamp) : "-" })
582
576
  ]
583
577
  },
584
- `${h.id}|${h.layout || ""}`
578
+ `${v.id}|${v.layout || ""}`
585
579
  );
586
580
  }) })
587
581
  ] }) })
588
582
  ] }) : /* @__PURE__ */ e(K, { message: "No lap times recorded yet." });
589
583
  }
590
- function et({ entries: t, isLoading: r, track: n, carMetadata: a, getUserDisplay: s, onCarSelect: i, onNavigate: c }) {
591
- const [o, m] = Z({ key: "lapTimeMs", dir: "asc" }), { activeTags: d, toggle: g, clear: N } = he(), x = k(() => {
584
+ function Ye({ entries: t, isLoading: n, track: r, carMetadata: a, getUserDisplay: s, onCarSelect: i, onNavigate: c }) {
585
+ const [o, m] = J({ key: "lapTimeMs", dir: "asc" }), { activeTags: d, toggle: x, clear: N } = me(), f = T(() => {
592
586
  var u, y, C;
593
587
  if (!t || !((u = a == null ? void 0 : a.tags) != null && u.length)) return [];
594
- const v = /* @__PURE__ */ new Set();
595
- for (const R of t)
596
- (((C = (y = a.cars) == null ? void 0 : y[R.carId]) == null ? void 0 : C.tags) || ["sports_car"]).forEach((S) => v.add(S));
597
- return a.tags.filter((R) => v.has(R));
598
- }, [t, a]), h = k(() => t ? d.size === 0 ? t : t.filter((v) => {
588
+ const h = /* @__PURE__ */ new Set();
589
+ for (const $ of t)
590
+ (((C = (y = a.cars) == null ? void 0 : y[$.carId]) == null ? void 0 : C.tags) || ["sports_car"]).forEach((S) => h.add(S));
591
+ return a.tags.filter(($) => h.has($));
592
+ }, [t, a]), v = T(() => t ? d.size === 0 ? t : t.filter((h) => {
599
593
  var y, C;
600
- const u = ((C = (y = a == null ? void 0 : a.cars) == null ? void 0 : y[v.carId]) == null ? void 0 : C.tags) || ["sports_car"];
601
- return me(u, d);
602
- }) : [], [t, d, a]), f = k(() => X(h, o, (v, u) => {
594
+ const u = ((C = (y = a == null ? void 0 : a.cars) == null ? void 0 : y[h.carId]) == null ? void 0 : C.tags) || ["sports_car"];
595
+ return ue(u, d);
596
+ }) : [], [t, d, a]), g = T(() => X(v, o, (h, u) => {
603
597
  switch (u) {
604
598
  case "carId":
605
- return I(v.carId);
599
+ return D(h.carId);
606
600
  case "driverCount":
607
- return v.driverCount || 0;
601
+ return h.driverCount || 0;
608
602
  case "lapTimeMs":
609
603
  default:
610
- return v.lapTimeMs;
604
+ return h.lapTimeMs;
611
605
  }
612
- }), [h, o]), p = [
606
+ }), [v, o]), p = [
613
607
  { key: "tracks", label: "Tracks", onClick: () => c("tracks") },
614
- { key: "track", label: n.displayName }
608
+ { key: "track", label: r.displayName }
615
609
  ];
616
- return r ? /* @__PURE__ */ e(H, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
610
+ return n ? /* @__PURE__ */ e(H, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
617
611
  /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ e(ee, { segments: p }) }),
618
- /* @__PURE__ */ e(ge, { availableTags: x, activeTags: d, onToggle: g, onClear: N }),
612
+ /* @__PURE__ */ e(xe, { availableTags: f, activeTags: d, onToggle: x, onClear: N }),
619
613
  t != null && t.length ? /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
620
614
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
621
615
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--narrow", children: "#" }),
622
- /* @__PURE__ */ e(D, { label: "Car", sortKey: "carId", config: o, onSort: m }),
616
+ /* @__PURE__ */ e(M, { label: "Car", sortKey: "carId", config: o, onSort: m }),
623
617
  /* @__PURE__ */ e("th", { className: "pvx-th", children: "Record Holder" }),
624
- /* @__PURE__ */ e(D, { label: "Lap Time", sortKey: "lapTimeMs", config: o, onSort: m }),
625
- /* @__PURE__ */ e(D, { label: "Drivers", sortKey: "driverCount", config: o, onSort: m, className: "pvx-hidden-below-md" }),
618
+ /* @__PURE__ */ e(M, { label: "Lap Time", sortKey: "lapTimeMs", config: o, onSort: m }),
619
+ /* @__PURE__ */ e(M, { label: "Drivers", sortKey: "driverCount", config: o, onSort: m, className: "pvx-hidden-below-md" }),
626
620
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-lg", children: "Date" })
627
621
  ] }) }),
628
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: f.map((v, u) => /* @__PURE__ */ l(
622
+ /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: g.map((h, u) => /* @__PURE__ */ l(
629
623
  "tr",
630
624
  {
631
625
  className: "pvx-row pvx-row--clickable",
632
- onClick: () => i(v.carId),
626
+ onClick: () => i(h.carId),
633
627
  children: [
634
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(xe, { rank: u + 1, podium: !0 }) }),
635
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: I(v.carId) }),
636
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(Y, { userId: v.steamId || v.userId, getUserDisplay: s }) }),
637
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: E(v.lapTimeMs) }),
638
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: v.driverCount || "-" }),
639
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-lg", children: v.recordedAt ? F(v.recordedAt) : "-" })
628
+ /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(ve, { rank: u + 1, podium: !0 }) }),
629
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: D(h.carId) }),
630
+ /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(Y, { userId: h.steamId || h.userId, getUserDisplay: s }) }),
631
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: F(h.lapTimeMs) }),
632
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: h.driverCount || "-" }),
633
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-lg", children: h.recordedAt ? E(h.recordedAt) : "-" })
640
634
  ]
641
635
  },
642
- v.carId
636
+ h.carId
643
637
  )) })
644
638
  ] }) }) : /* @__PURE__ */ e(K, { message: "No lap times for this track yet." })
645
639
  ] });
646
640
  }
647
- function tt({ entries: t, isLoading: r, track: n, carId: a, getUserDisplay: s, onDriverSelect: i, onNavigate: c }) {
648
- const [o, m] = Z({ key: "lapTimeMs", dir: "asc" }), d = k(() => ve(t), [t]), g = k(() => X(t || [], o, (x, h) => {
649
- switch (h) {
641
+ function et({ entries: t, isLoading: n, track: r, carId: a, getUserDisplay: s, onDriverSelect: i, onNavigate: c }) {
642
+ const [o, m] = J({ key: "lapTimeMs", dir: "asc" }), d = T(() => he(t), [t]), x = T(() => X(t || [], o, (f, v) => {
643
+ switch (v) {
650
644
  case "userId":
651
- return s(x.steamId || x.userId).displayName;
645
+ return s(f.steamId || f.userId).displayName;
652
646
  case "lapCount":
653
- return x.lapCount || 0;
647
+ return f.lapCount || 0;
654
648
  case "lapTimeMs":
655
649
  default:
656
- return x.lapTimeMs;
650
+ return f.lapTimeMs;
657
651
  }
658
652
  }), [t, o, s]), N = [
659
653
  { key: "tracks", label: "Tracks", onClick: () => c("tracks") },
660
- { key: "track", label: n.displayName, onClick: () => c("track") },
661
- { key: "car", label: I(a) }
654
+ { key: "track", label: r.displayName, onClick: () => c("track") },
655
+ { key: "car", label: D(a) }
662
656
  ];
663
- return r ? /* @__PURE__ */ e(H, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
657
+ return n ? /* @__PURE__ */ e(H, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
664
658
  /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ e(ee, { segments: N }) }),
665
659
  t != null && t.length ? /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
666
660
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
667
661
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--narrow", children: "#" }),
668
- /* @__PURE__ */ e(D, { label: "Driver", sortKey: "userId", config: o, onSort: m }),
669
- /* @__PURE__ */ e(D, { label: "Lap Time", sortKey: "lapTimeMs", config: o, onSort: m }),
662
+ /* @__PURE__ */ e(M, { label: "Driver", sortKey: "userId", config: o, onSort: m }),
663
+ /* @__PURE__ */ e(M, { label: "Lap Time", sortKey: "lapTimeMs", config: o, onSort: m }),
670
664
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "S1" }),
671
665
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "S2" }),
672
666
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "S3" }),
673
667
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-lg", children: "Tyre" }),
674
668
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-xl", children: "Fuel" }),
675
- /* @__PURE__ */ e(D, { label: "Laps", sortKey: "lapCount", config: o, onSort: m, className: "pvx-hidden-below-lg" }),
669
+ /* @__PURE__ */ e(M, { label: "Laps", sortKey: "lapCount", config: o, onSort: m, className: "pvx-hidden-below-lg" }),
676
670
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-xl", children: "Date" })
677
671
  ] }) }),
678
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: g.map((x, h) => {
679
- const f = h + 1, p = x.steamId || x.userId, v = d && x.sector1Ms === d.s1, u = d && x.sector2Ms === d.s2, y = d && x.sector3Ms === d.s3;
672
+ /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: x.map((f, v) => {
673
+ const g = v + 1, p = f.steamId || f.userId, h = d && f.sector1Ms === d.s1, u = d && f.sector2Ms === d.s2, y = d && f.sector3Ms === d.s3;
680
674
  return /* @__PURE__ */ l(
681
675
  "tr",
682
676
  {
683
- className: `pvx-row pvx-row--clickable ${f <= 3 ? "pvx-row--podium" : ""}`,
677
+ className: `pvx-row pvx-row--clickable ${g <= 3 ? "pvx-row--podium" : ""}`,
684
678
  onClick: () => i(p),
685
679
  children: [
686
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(xe, { rank: f, podium: !0 }) }),
680
+ /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(ve, { rank: g, podium: !0 }) }),
687
681
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: /* @__PURE__ */ e(Y, { userId: p, getUserDisplay: s }) }),
688
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: E(x.lapTimeMs) }),
689
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${v ? "pvx-td--best-sector" : ""}`, children: P(x.sector1Ms) }),
690
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${u ? "pvx-td--best-sector" : ""}`, children: P(x.sector2Ms) }),
691
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${y ? "pvx-td--best-sector" : ""}`, children: P(x.sector3Ms) }),
692
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", title: le(x.tyreCompound), children: x.tyreCompound || "-" }),
693
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-xl", children: x.startingFuelL ? `${x.startingFuelL}L` : "-" }),
694
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: x.lapCount || "-" }),
695
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: x.recordedAt ? F(x.recordedAt) : "-" })
682
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: F(f.lapTimeMs) }),
683
+ /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${h ? "pvx-td--best-sector" : ""}`, children: A(f.sector1Ms) }),
684
+ /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${u ? "pvx-td--best-sector" : ""}`, children: A(f.sector2Ms) }),
685
+ /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${y ? "pvx-td--best-sector" : ""}`, children: A(f.sector3Ms) }),
686
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", title: le(f.tyreCompound), children: f.tyreCompound || "-" }),
687
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-xl", children: f.startingFuelL ? `${f.startingFuelL}L` : "-" }),
688
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: f.lapCount || "-" }),
689
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: f.recordedAt ? E(f.recordedAt) : "-" })
696
690
  ]
697
691
  },
698
692
  p
@@ -701,21 +695,21 @@ function tt({ entries: t, isLoading: r, track: n, carId: a, getUserDisplay: s, o
701
695
  ] }) }) : /* @__PURE__ */ e(K, { message: "No lap times for this car yet." })
702
696
  ] });
703
697
  }
704
- function nt({ userId: t, track: r, carId: n, game: a, gameVersion: s, showInvalid: i, getUserDisplay: c, onToggleInvalid: o, onNavigate: m }) {
705
- const { data: d, driverName: g, isLoading: N } = Ue(t, r.id, r.layout, n, { showInvalid: i, game: a, gameVersion: s }), { displayName: x, avatarUrl: h } = c(t, g), f = k(() => ve(d, !0), [d]), p = k(() => {
698
+ function tt({ userId: t, track: n, carId: r, game: a, gameVersion: s, showInvalid: i, getUserDisplay: c, onToggleInvalid: o, onNavigate: m }) {
699
+ const { data: d, driverName: x, isLoading: N } = Ae(t, n.id, n.layout, r, { showInvalid: i, game: a, gameVersion: s }), { displayName: f, avatarUrl: v } = c(t, x), g = T(() => he(d, !0), [d]), p = T(() => {
706
700
  const u = (d == null ? void 0 : d.filter((y) => y.isValid)) || [];
707
701
  return u.length ? Math.min(...u.map((y) => y.lapTimeMs)) : null;
708
- }, [d]), v = [
702
+ }, [d]), h = [
709
703
  { key: "tracks", label: "Tracks", onClick: () => m("tracks") },
710
- { key: "track", label: r.displayName, onClick: () => m("track") },
711
- { key: "car", label: I(n), onClick: () => m("car") },
712
- { key: "driver", label: x }
704
+ { key: "track", label: n.displayName, onClick: () => m("track") },
705
+ { key: "car", label: D(r), onClick: () => m("car") },
706
+ { key: "driver", label: f }
713
707
  ];
714
708
  return N ? /* @__PURE__ */ e(H, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
715
709
  /* @__PURE__ */ l("div", { className: "pvx-card-header pvx-card-header--split", children: [
716
710
  /* @__PURE__ */ l("div", { className: "pvx-card-header-left", children: [
717
- /* @__PURE__ */ e(ee, { segments: v }),
718
- h ? /* @__PURE__ */ e("img", { src: h, alt: "", className: "pvx-driver-avatar pvx-driver-avatar--lg" }) : /* @__PURE__ */ e("span", { className: "pvx-driver-avatar pvx-driver-avatar--lg pvx-driver-avatar--placeholder" })
711
+ /* @__PURE__ */ e(ee, { segments: h }),
712
+ v ? /* @__PURE__ */ e("img", { src: v, alt: "", className: "pvx-driver-avatar pvx-driver-avatar--lg" }) : /* @__PURE__ */ e("span", { className: "pvx-driver-avatar pvx-driver-avatar--lg pvx-driver-avatar--placeholder" })
719
713
  ] }),
720
714
  /* @__PURE__ */ l("label", { className: "pvx-checkbox-label", children: [
721
715
  /* @__PURE__ */ e(
@@ -744,125 +738,125 @@ function nt({ userId: t, track: r, carId: n, game: a, gameVersion: s, showInvali
744
738
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-xl", children: "Date" })
745
739
  ] }) }),
746
740
  /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: d.map((u, y) => {
747
- const C = u.isValid && u.lapTimeMs === p, R = f && u.isValid && u.sector1Ms === f.s1, q = f && u.isValid && u.sector2Ms === f.s2, S = f && u.isValid && u.sector3Ms === f.s3;
748
- let A = "pvx-row";
749
- return u.isValid || (A += " pvx-row--invalid"), C && (A += " pvx-row--personal-best"), /* @__PURE__ */ l("tr", { className: A, children: [
741
+ const C = u.isValid && u.lapTimeMs === p, $ = g && u.isValid && u.sector1Ms === g.s1, _ = g && u.isValid && u.sector2Ms === g.s2, S = g && u.isValid && u.sector3Ms === g.s3;
742
+ let P = "pvx-row";
743
+ return u.isValid || (P += " pvx-row--invalid"), C && (P += " pvx-row--personal-best"), /* @__PURE__ */ l("tr", { className: P, children: [
750
744
  /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e("span", { className: `pvx-rank ${C ? "pvx-rank--gold" : ""}`, children: y + 1 }) }),
751
745
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-md", children: u.lapNumber || "-" }),
752
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: E(u.lapTimeMs) }),
753
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${R ? "pvx-td--best-sector" : ""}`, children: P(u.sector1Ms) }),
754
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${q ? "pvx-td--best-sector" : ""}`, children: P(u.sector2Ms) }),
755
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${S ? "pvx-td--best-sector" : ""}`, children: P(u.sector3Ms) }),
756
- /* @__PURE__ */ e("td", { className: "pvx-td", title: u.isValid ? void 0 : u.invalidReason || "Invalid", children: u.isValid ? /* @__PURE__ */ e(Ze, {}) : /* @__PURE__ */ e(Xe, {}) }),
746
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: F(u.lapTimeMs) }),
747
+ /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${$ ? "pvx-td--best-sector" : ""}`, children: A(u.sector1Ms) }),
748
+ /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${_ ? "pvx-td--best-sector" : ""}`, children: A(u.sector2Ms) }),
749
+ /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${S ? "pvx-td--best-sector" : ""}`, children: A(u.sector3Ms) }),
750
+ /* @__PURE__ */ e("td", { className: "pvx-td", title: u.isValid ? void 0 : u.invalidReason || "Invalid", children: u.isValid ? /* @__PURE__ */ e(Ze, {}) : /* @__PURE__ */ e(Je, {}) }),
757
751
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", title: le(u.tyreCompound), children: u.tyreCompound || "-" }),
758
752
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: u.startingFuelL ? `${u.startingFuelL}L` : "-" }),
759
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: F(u.timestamp) })
753
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: E(u.timestamp) })
760
754
  ] }, u.id);
761
755
  }) })
762
756
  ] }) }) : /* @__PURE__ */ e(K, { message: i ? "No laps recorded for this combination." : 'No valid laps. Try enabling "Show invalid laps".' })
763
757
  ] });
764
758
  }
765
- function _t({ className: t, defaultGame: r = "evo", title: n = "Leaderboards" }) {
766
- const [a, s] = oe(), i = Ee(), c = Fe(), o = a.get("game") || r, m = a.get("version"), d = a.get("track"), g = a.get("car"), N = a.get("driver"), x = a.get("invalid") === "true", {
767
- data: h,
768
- isLoading: f,
759
+ function Vt({ className: t, defaultGame: n = "evo", title: r = "Leaderboards" }) {
760
+ const [a, s] = oe(), i = Ue(), c = Fe(), o = a.get("game") || n, m = a.get("version"), d = a.get("track"), x = a.get("car"), N = a.get("driver"), f = a.get("invalid") === "true", {
761
+ data: v,
762
+ isLoading: g,
769
763
  generatedAt: p,
770
- totalLaps: v,
764
+ totalLaps: h,
771
765
  totalUsers: u,
772
766
  versions: y
773
- } = Pe({ game: o }), C = y == null ? void 0 : y[o], R = m || (C == null ? void 0 : C.default) || null, q = k(() => !h || !R ? h || [] : h.filter((b) => b.gameVersion === R), [h, R]), S = k(() => {
767
+ } = Pe({ game: o }), C = y == null ? void 0 : y[o], $ = m || (C == null ? void 0 : C.default) || null, _ = T(() => !v || !$ ? v || [] : v.filter((b) => b.gameVersion === $), [v, $]), S = T(() => {
774
768
  if (!d) return null;
775
769
  const [b, w] = d.split("|");
776
- return { id: b, layout: w || null, displayName: V(b, w, o) };
777
- }, [d, o]), { data: A, isLoading: te } = ce(
770
+ return { id: b, layout: w || null, displayName: j(b, w, o) };
771
+ }, [d, o]), { data: P, isLoading: te } = ce(
778
772
  S == null ? void 0 : S.id,
779
773
  S == null ? void 0 : S.layout,
780
- { carId: g, game: o, gameVersion: R }
774
+ { carId: x, game: o, gameVersion: $ }
781
775
  );
782
- function B(b) {
776
+ function I(b) {
783
777
  s(b);
784
778
  }
785
- function Ce(b) {
786
- B({ game: b });
779
+ function ye(b) {
780
+ I({ game: b });
787
781
  }
788
- function we(b) {
782
+ function Ce(b) {
789
783
  const w = { game: o };
790
- b && b !== (C == null ? void 0 : C.default) && (w.version = b), B(w);
784
+ b && b !== (C == null ? void 0 : C.default) && (w.version = b), I(w);
791
785
  }
792
- function ke(b, w) {
793
- const ne = { game: o, track: w ? `${b}|${w}` : b };
794
- m && (ne.version = m), B(ne);
786
+ function we(b, w) {
787
+ const re = { game: o, track: w ? `${b}|${w}` : b };
788
+ m && (re.version = m), I(re);
795
789
  }
796
- function Te(b) {
790
+ function ke(b) {
797
791
  const w = { game: o, track: d };
798
- m && (w.version = m), b && (w.car = b), B(w);
792
+ m && (w.version = m), b && (w.car = b), I(w);
799
793
  }
800
- function Se(b) {
801
- const w = { game: o, track: d, car: g, driver: b };
802
- m && (w.version = m), B(w);
794
+ function Te(b) {
795
+ const w = { game: o, track: d, car: x, driver: b };
796
+ m && (w.version = m), I(w);
803
797
  }
804
798
  function O(b) {
805
799
  const w = { game: o };
806
- m && (w.version = m), (b === "track" || b === "car") && (w.track = d), b === "car" && (w.car = g), B(w);
800
+ m && (w.version = m), (b === "track" || b === "car") && (w.track = d), b === "car" && (w.car = x), I(w);
807
801
  }
808
- function Le() {
809
- const b = { game: o, track: d, car: g, driver: N };
810
- m && (b.version = m), x || (b.invalid = "true"), B(b);
802
+ function Se() {
803
+ const b = { game: o, track: d, car: x, driver: N };
804
+ m && (b.version = m), f || (b.invalid = "true"), I(b);
811
805
  }
812
- const $e = () => S && g && N ? /* @__PURE__ */ e(
813
- nt,
806
+ const Le = () => S && x && N ? /* @__PURE__ */ e(
807
+ tt,
814
808
  {
815
809
  userId: N,
816
810
  track: S,
817
- carId: g,
811
+ carId: x,
818
812
  game: o,
819
- gameVersion: R,
820
- showInvalid: x,
813
+ gameVersion: $,
814
+ showInvalid: f,
821
815
  getUserDisplay: i,
822
- onToggleInvalid: Le,
816
+ onToggleInvalid: Se,
823
817
  onNavigate: O
824
818
  }
825
- ) : S && g ? /* @__PURE__ */ e(
826
- tt,
819
+ ) : S && x ? /* @__PURE__ */ e(
820
+ et,
827
821
  {
828
- entries: A || [],
822
+ entries: P || [],
829
823
  isLoading: te,
830
824
  track: S,
831
- carId: g,
825
+ carId: x,
832
826
  getUserDisplay: i,
833
- onDriverSelect: Se,
827
+ onDriverSelect: Te,
834
828
  onNavigate: O
835
829
  }
836
830
  ) : S ? /* @__PURE__ */ e(
837
- et,
831
+ Ye,
838
832
  {
839
- entries: A || [],
833
+ entries: P || [],
840
834
  isLoading: te,
841
835
  track: S,
842
836
  carMetadata: c,
843
837
  getUserDisplay: i,
844
- onCarSelect: Te,
838
+ onCarSelect: ke,
845
839
  onNavigate: O
846
840
  }
847
841
  ) : /* @__PURE__ */ e(
848
- Ye,
842
+ Xe,
849
843
  {
850
- tracks: q,
851
- isLoading: f,
844
+ tracks: _,
845
+ isLoading: g,
852
846
  carMetadata: c,
853
847
  getUserDisplay: i,
854
- onTrackSelect: ke
848
+ onTrackSelect: we
855
849
  }
856
850
  );
857
851
  return /* @__PURE__ */ l("div", { className: `pvx-leaderboard-explorer ${t || ""}`, children: [
858
852
  /* @__PURE__ */ l("div", { className: "pvx-explorer-header", children: [
859
- /* @__PURE__ */ e("h1", { className: "pvx-explorer-title", children: n }),
853
+ /* @__PURE__ */ e("h1", { className: "pvx-explorer-title", children: r }),
860
854
  /* @__PURE__ */ l("div", { className: "pvx-explorer-stats", children: [
861
- v > 0 && /* @__PURE__ */ l("span", { children: [
862
- v.toLocaleString(),
855
+ h > 0 && /* @__PURE__ */ l("span", { children: [
856
+ h.toLocaleString(),
863
857
  " laps"
864
858
  ] }),
865
- v > 0 && u > 0 && /* @__PURE__ */ e("span", { className: "pvx-explorer-stats-sep", children: "|" }),
859
+ h > 0 && u > 0 && /* @__PURE__ */ e("span", { className: "pvx-explorer-stats-sep", children: "|" }),
866
860
  u > 0 && /* @__PURE__ */ l("span", { children: [
867
861
  u.toLocaleString(),
868
862
  " drivers"
@@ -873,7 +867,7 @@ function _t({ className: t, defaultGame: r = "evo", title: n = "Leaderboards" })
873
867
  /* @__PURE__ */ e("div", { className: "pvx-game-tabs", children: ["evo", "acc"].map((b) => /* @__PURE__ */ e(
874
868
  "button",
875
869
  {
876
- onClick: () => Ce(b),
870
+ onClick: () => ye(b),
877
871
  className: `pvx-game-tab ${o === b ? "pvx-game-tab--active" : ""}`,
878
872
  children: b === "evo" ? "AC EVO" : "ACC"
879
873
  },
@@ -882,8 +876,8 @@ function _t({ className: t, defaultGame: r = "evo", title: n = "Leaderboards" })
882
876
  C && /* @__PURE__ */ e(
883
877
  "select",
884
878
  {
885
- value: R || "",
886
- onChange: (b) => we(b.target.value),
879
+ value: $ || "",
880
+ onChange: (b) => Ce(b.target.value),
887
881
  className: "pvx-version-select",
888
882
  children: C.available.slice().reverse().map((b) => /* @__PURE__ */ l("option", { value: b, children: [
889
883
  "v",
@@ -893,7 +887,7 @@ function _t({ className: t, defaultGame: r = "evo", title: n = "Leaderboards" })
893
887
  }
894
888
  )
895
889
  ] }),
896
- $e(),
890
+ Le(),
897
891
  p && /* @__PURE__ */ l("p", { className: "pvx-data-timestamp", children: [
898
892
  "Data updated: ",
899
893
  new Date(p).toLocaleString()
@@ -931,84 +925,84 @@ const rt = {
931
925
  RUS: "🇷🇺",
932
926
  TUR: "🇹🇷",
933
927
  KOR: "🇰🇷"
934
- }, at = {
928
+ }, nt = {
935
929
  championship: "Championship",
936
930
  series: "Series",
937
931
  event: "Event"
938
- }, re = ["PRACTICE", "QUALIFYING", "RACE"];
939
- function fe({ position: t }) {
932
+ }, ne = ["PRACTICE", "QUALIFYING", "RACE"];
933
+ function ge({ position: t }) {
940
934
  return /* @__PURE__ */ e("span", { className: t === 1 ? "pvx-rank pvx-rank--gold" : t === 2 ? "pvx-rank pvx-rank--silver" : t === 3 ? "pvx-rank pvx-rank--bronze" : "pvx-rank", children: t });
941
935
  }
942
- function Ne({ nation: t }) {
943
- const r = t && rt[t];
944
- return r ? /* @__PURE__ */ e("span", { className: "pvx-nation-flag", title: t, children: r }) : null;
936
+ function fe({ nation: t }) {
937
+ const n = t && rt[t];
938
+ return n ? /* @__PURE__ */ e("span", { className: "pvx-nation-flag", title: t, children: n }) : null;
945
939
  }
946
- function st({ sessions: t, activeSession: r, onSelect: n }) {
940
+ function at({ sessions: t, activeSession: n, onSelect: r }) {
947
941
  if (!t || t.length <= 1) return null;
948
942
  const a = [...t].sort(
949
- (s, i) => re.indexOf(s.type) - re.indexOf(i.type)
943
+ (s, i) => ne.indexOf(s.type) - ne.indexOf(i.type)
950
944
  );
951
945
  return /* @__PURE__ */ e("div", { className: "pvx-session-tabs", children: a.map((s) => /* @__PURE__ */ e(
952
946
  "button",
953
947
  {
954
- onClick: () => n(s.type),
955
- className: `pvx-session-tab ${r === s.type ? "pvx-session-tab--active" : ""}`,
948
+ onClick: () => r(s.type),
949
+ className: `pvx-session-tab ${n === s.type ? "pvx-session-tab--active" : ""}`,
956
950
  children: s.type
957
951
  },
958
952
  s.type
959
953
  )) });
960
954
  }
961
- function be({ type: t }) {
962
- return /* @__PURE__ */ e("span", { className: `pvx-comp-badge pvx-comp-badge--${t}`, children: at[t] || t });
955
+ function Ne({ type: t }) {
956
+ return /* @__PURE__ */ e("span", { className: `pvx-comp-badge pvx-comp-badge--${t}`, children: nt[t] || t });
963
957
  }
964
- function U({ children: t, variant: r = "default" }) {
965
- return /* @__PURE__ */ e("span", { className: `pvx-info-pill ${r !== "default" ? `pvx-info-pill--${r}` : ""}`, children: t });
958
+ function U({ children: t, variant: n = "default" }) {
959
+ return /* @__PURE__ */ e("span", { className: `pvx-info-pill ${n !== "default" ? `pvx-info-pill--${n}` : ""}`, children: t });
966
960
  }
967
- function ye(t) {
961
+ function be(t) {
968
962
  if (!t) return "TBD";
969
- const r = new Date(t);
970
- if (isNaN(r)) return "TBD";
971
- const n = r.toLocaleDateString("en-GB", { weekday: "short", day: "numeric", month: "short" }), a = r.toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit" });
972
- return `${n} • ${a}`;
963
+ const n = new Date(t);
964
+ if (isNaN(n)) return "TBD";
965
+ const r = n.toLocaleDateString("en-GB", { weekday: "short", day: "numeric", month: "short" }), a = n.toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit" });
966
+ return `${r} • ${a}`;
973
967
  }
974
- function it(t) {
975
- return t.reduce((r, n) => {
968
+ function st(t) {
969
+ return t.reduce((n, r) => {
976
970
  var a;
977
- return (a = n.splits) != null && a.length ? r ? r.map((s, i) => {
978
- const c = n.splits[i];
971
+ return (a = r.splits) != null && a.length ? n ? n.map((s, i) => {
972
+ const c = r.splits[i];
979
973
  return c && c < s ? c : s;
980
- }) : [...n.splits] : r;
974
+ }) : [...r.splits] : n;
981
975
  }, null);
982
976
  }
983
- function _({ message: t = "Loading..." }) {
977
+ function V({ message: t = "Loading..." }) {
984
978
  return /* @__PURE__ */ e("div", { className: "pvx-loading", children: t });
985
979
  }
986
- function M({ message: t = "No data available." }) {
980
+ function B({ message: t = "No data available." }) {
987
981
  return /* @__PURE__ */ e("div", { className: "pvx-empty", children: /* @__PURE__ */ e("p", { children: t }) });
988
982
  }
989
- function ot({ competitions: t, isLoading: r, onSelect: n, className: a }) {
990
- return r ? /* @__PURE__ */ e(_, { message: "Loading competitions..." }) : t != null && t.length ? /* @__PURE__ */ e("div", { className: `pvx-comp-grid ${a || ""}`, children: t.map((s) => /* @__PURE__ */ e(lt, { comp: s, onSelect: n }, s.id)) }) : /* @__PURE__ */ e(M, { message: "No competitions available." });
983
+ function it({ competitions: t, isLoading: n, onSelect: r, className: a }) {
984
+ return n ? /* @__PURE__ */ e(V, { message: "Loading competitions..." }) : t != null && t.length ? /* @__PURE__ */ e("div", { className: `pvx-comp-grid ${a || ""}`, children: t.map((s) => /* @__PURE__ */ e(ot, { comp: s, onSelect: r }, s.id)) }) : /* @__PURE__ */ e(B, { message: "No competitions available." });
991
985
  }
992
- function lt({ comp: t, onSelect: r }) {
993
- var f, p, v;
994
- const { cdnUrl: n } = T(), a = t.posterCdnPath ? `${n}/${t.posterCdnPath}` : null, s = t.registration, i = (s == null ? void 0 : s.currentCount) || 0, c = s == null ? void 0 : s.maxParticipants, o = c && i >= c, m = (s == null ? void 0 : s.deadline) && new Date(s.deadline) < /* @__PURE__ */ new Date(), d = (s == null ? void 0 : s.isOpen) && !m && !o, g = /* @__PURE__ */ new Date(), N = (f = t.rounds) == null ? void 0 : f.find((u) => u.startTime && new Date(u.startTime) >= g), x = ((p = t.rounds) == null ? void 0 : p.length) || 0, h = ((v = t.rounds) == null ? void 0 : v.filter((u) => u.isFinalized).length) || 0;
986
+ function ot({ comp: t, onSelect: n }) {
987
+ var g, p, h;
988
+ const { cdnUrl: r } = k(), a = t.posterCdnPath ? `${r}/${t.posterCdnPath}` : null, s = t.registration, i = (s == null ? void 0 : s.currentCount) || 0, c = s == null ? void 0 : s.maxParticipants, o = c && i >= c, m = (s == null ? void 0 : s.deadline) && new Date(s.deadline) < /* @__PURE__ */ new Date(), d = (s == null ? void 0 : s.isOpen) && !m && !o, x = /* @__PURE__ */ new Date(), N = (g = t.rounds) == null ? void 0 : g.find((u) => u.startTime && new Date(u.startTime) >= x), f = ((p = t.rounds) == null ? void 0 : p.length) || 0, v = ((h = t.rounds) == null ? void 0 : h.filter((u) => u.isFinalized).length) || 0;
995
989
  return /* @__PURE__ */ l(
996
990
  "div",
997
991
  {
998
992
  className: "pvx-comp-card",
999
- onClick: () => r(t.id),
993
+ onClick: () => n(t.id),
1000
994
  role: "button",
1001
995
  tabIndex: 0,
1002
996
  onKeyDown: (u) => {
1003
- (u.key === "Enter" || u.key === " ") && (u.preventDefault(), r(t.id));
997
+ (u.key === "Enter" || u.key === " ") && (u.preventDefault(), n(t.id));
1004
998
  },
1005
999
  children: [
1006
- /* @__PURE__ */ e("div", { className: "pvx-comp-card-poster", children: a ? /* @__PURE__ */ e("img", { src: a, alt: t.name, className: "pvx-comp-card-poster-img" }) : /* @__PURE__ */ e("div", { className: "pvx-comp-card-poster-placeholder", children: /* @__PURE__ */ e(ct, {}) }) }),
1000
+ /* @__PURE__ */ e("div", { className: "pvx-comp-card-poster", children: a ? /* @__PURE__ */ e("img", { src: a, alt: t.name, className: "pvx-comp-card-poster-img" }) : /* @__PURE__ */ e("div", { className: "pvx-comp-card-poster-placeholder", children: /* @__PURE__ */ e(lt, {}) }) }),
1007
1001
  /* @__PURE__ */ l("div", { className: "pvx-comp-card-body", children: [
1008
1002
  /* @__PURE__ */ e("h3", { className: "pvx-comp-card-title", children: t.name }),
1009
1003
  t.description && /* @__PURE__ */ e("p", { className: "pvx-comp-card-desc", children: t.description }),
1010
1004
  /* @__PURE__ */ l("div", { className: "pvx-comp-card-pills", children: [
1011
- /* @__PURE__ */ e(be, { type: t.type }),
1005
+ /* @__PURE__ */ e(Ne, { type: t.type }),
1012
1006
  t.game && /* @__PURE__ */ e(U, { children: t.game.toUpperCase() }),
1013
1007
  t.formatDescription && t.formatDescription.split(", ").map((u, y) => /* @__PURE__ */ e(U, { variant: "format", children: u }, y))
1014
1008
  ] }),
@@ -1022,17 +1016,17 @@ function lt({ comp: t, onSelect: r }) {
1022
1016
  " ",
1023
1017
  N.track || "TBD",
1024
1018
  " — ",
1025
- ye(N.startTime)
1026
- ] }) : x > 0 ? /* @__PURE__ */ l("span", { className: "pvx-comp-card-schedule-next", children: [
1027
- h,
1019
+ be(N.startTime)
1020
+ ] }) : f > 0 ? /* @__PURE__ */ l("span", { className: "pvx-comp-card-schedule-next", children: [
1021
+ v,
1028
1022
  "/",
1029
- x,
1023
+ f,
1030
1024
  " rounds completed"
1031
1025
  ] }) : null,
1032
- x > 0 && /* @__PURE__ */ l("span", { className: "pvx-comp-card-round-count", children: [
1033
- x,
1026
+ f > 0 && /* @__PURE__ */ l("span", { className: "pvx-comp-card-round-count", children: [
1027
+ f,
1034
1028
  " round",
1035
- x !== 1 ? "s" : ""
1029
+ f !== 1 ? "s" : ""
1036
1030
  ] })
1037
1031
  ] }),
1038
1032
  s && /* @__PURE__ */ l("div", { className: "pvx-comp-card-reg", children: [
@@ -1049,7 +1043,7 @@ function lt({ comp: t, onSelect: r }) {
1049
1043
  }
1050
1044
  );
1051
1045
  }
1052
- function ct() {
1046
+ function lt() {
1053
1047
  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: [
1054
1048
  /* @__PURE__ */ e("path", { d: "M6 9H4.5a2.5 2.5 0 0 1 0-5H6" }),
1055
1049
  /* @__PURE__ */ e("path", { d: "M18 9h1.5a2.5 2.5 0 0 0 0-5H18" }),
@@ -1059,23 +1053,23 @@ function ct() {
1059
1053
  /* @__PURE__ */ e("path", { d: "M18 2H6v7a6 6 0 0 0 12 0V2Z" })
1060
1054
  ] });
1061
1055
  }
1062
- function dt({ competitionId: t, className: r }) {
1056
+ function ct({ competitionId: t, className: n }) {
1063
1057
  var o, m;
1064
- const { data: n, isLoading: a } = qe(t), { data: s, isLoading: i } = de(t);
1058
+ const { data: r, isLoading: a } = Ve(t), { data: s, isLoading: i } = de(t);
1065
1059
  if (a || i)
1066
- return /* @__PURE__ */ e(_, { message: "Loading standings..." });
1067
- if (!((o = n == null ? void 0 : n.standings) != null && o.length))
1068
- return /* @__PURE__ */ e(M, { message: "No standings data yet. Results will appear once rounds are finalised." });
1060
+ return /* @__PURE__ */ e(V, { message: "Loading standings..." });
1061
+ if (!((o = r == null ? void 0 : r.standings) != null && o.length))
1062
+ return /* @__PURE__ */ e(B, { message: "No standings data yet. Results will appear once rounds are finalised." });
1069
1063
  const c = ((m = s == null ? void 0 : s.rounds) == null ? void 0 : m.filter((d) => d.isFinalized)) || [];
1070
- return /* @__PURE__ */ l("div", { className: `pvx-card ${r || ""}`, children: [
1064
+ return /* @__PURE__ */ l("div", { className: `pvx-card ${n || ""}`, children: [
1071
1065
  /* @__PURE__ */ e("div", { className: "pvx-card-header--split", children: /* @__PURE__ */ l("div", { className: "pvx-card-header-left", children: [
1072
1066
  /* @__PURE__ */ e("h3", { className: "pvx-card-title", children: "Championship Standings" }),
1073
1067
  /* @__PURE__ */ l("span", { className: "pvx-standings-subtitle", children: [
1074
1068
  "After ",
1075
- n.roundsCompleted,
1069
+ r.roundsCompleted,
1076
1070
  " round",
1077
- n.roundsCompleted !== 1 ? "s" : "",
1078
- n.countingRounds > 0 && ` (best ${n.countingRounds} count)`
1071
+ r.roundsCompleted !== 1 ? "s" : "",
1072
+ r.countingRounds > 0 && ` (best ${r.countingRounds} count)`
1079
1073
  ] })
1080
1074
  ] }) }),
1081
1075
  /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
@@ -1098,8 +1092,8 @@ function dt({ competitionId: t, className: r }) {
1098
1092
  d.roundNumber
1099
1093
  ))
1100
1094
  ] }) }),
1101
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: n.standings.map((d) => /* @__PURE__ */ e(
1102
- pt,
1095
+ /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: r.standings.map((d) => /* @__PURE__ */ e(
1096
+ dt,
1103
1097
  {
1104
1098
  driver: d,
1105
1099
  finalizedRounds: c
@@ -1109,32 +1103,32 @@ function dt({ competitionId: t, className: r }) {
1109
1103
  ] }) })
1110
1104
  ] });
1111
1105
  }
1112
- function pt({ driver: t, finalizedRounds: r }) {
1106
+ function dt({ driver: t, finalizedRounds: n }) {
1113
1107
  var c, o, m;
1114
- const n = t.position <= 3, a = new Map(
1108
+ const r = t.position <= 3, a = new Map(
1115
1109
  ((c = t.roundResults) == null ? void 0 : c.map((d) => [d.roundNumber, d])) || []
1116
1110
  ), s = ((o = t.roundResults) == null ? void 0 : o.filter((d) => d.position === 1).length) || 0, i = ((m = t.roundResults) == null ? void 0 : m.filter((d) => d.position <= 3).length) || 0;
1117
- return /* @__PURE__ */ l("tr", { className: `pvx-row ${n ? "pvx-row--podium" : ""}`, children: [
1118
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(fe, { position: t.position }) }),
1111
+ return /* @__PURE__ */ l("tr", { className: `pvx-row ${r ? "pvx-row--podium" : ""}`, children: [
1112
+ /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(ge, { position: t.position }) }),
1119
1113
  /* @__PURE__ */ l("td", { className: "pvx-td pvx-td--primary", children: [
1120
- /* @__PURE__ */ e(Ne, { nation: t.nation }),
1114
+ /* @__PURE__ */ e(fe, { nation: t.nation }),
1121
1115
  t.driverName
1122
1116
  ] }),
1123
1117
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-sm", children: s || "-" }),
1124
1118
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-sm", children: i || "-" }),
1125
1119
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-standings-total", children: t.totalPoints }),
1126
- r.map((d) => {
1127
- const g = a.get(d.roundNumber), N = g == null ? void 0 : g.dropped;
1120
+ n.map((d) => {
1121
+ const x = a.get(d.roundNumber), N = x == null ? void 0 : x.dropped;
1128
1122
  return /* @__PURE__ */ e(
1129
1123
  "td",
1130
1124
  {
1131
- className: `pvx-td pvx-td--center pvx-hidden-below-md ${!N && (g == null ? void 0 : g.position) <= 3 ? "pvx-standings-cell--podium" : ""}`,
1132
- children: g ? /* @__PURE__ */ l("div", { className: `pvx-standings-round-cell ${N ? "pvx-standings-round-cell--dropped" : ""}`, children: [
1125
+ className: `pvx-td pvx-td--center pvx-hidden-below-md ${!N && (x == null ? void 0 : x.position) <= 3 ? "pvx-standings-cell--podium" : ""}`,
1126
+ children: x ? /* @__PURE__ */ l("div", { className: `pvx-standings-round-cell ${N ? "pvx-standings-round-cell--dropped" : ""}`, children: [
1133
1127
  /* @__PURE__ */ l("span", { className: "pvx-standings-round-pos", children: [
1134
1128
  "P",
1135
- g.position
1129
+ x.position
1136
1130
  ] }),
1137
- /* @__PURE__ */ e("span", { className: "pvx-standings-round-pts", children: g.points })
1131
+ /* @__PURE__ */ e("span", { className: "pvx-standings-round-pts", children: x.points })
1138
1132
  ] }) : /* @__PURE__ */ e("span", { className: "pvx-td--muted", children: "-" })
1139
1133
  },
1140
1134
  d.roundNumber
@@ -1142,18 +1136,18 @@ function pt({ driver: t, finalizedRounds: r }) {
1142
1136
  })
1143
1137
  ] });
1144
1138
  }
1145
- function ut({ competitionId: t, roundNumber: r, className: n }) {
1146
- var g, N;
1147
- const { data: a, isLoading: s } = je(t, r), [i, c] = j(null);
1139
+ function pt({ competitionId: t, roundNumber: n, className: r }) {
1140
+ var x, N;
1141
+ const { data: a, isLoading: s } = _e(t, n), [i, c] = q(null);
1148
1142
  if (s)
1149
- return /* @__PURE__ */ e(_, { message: "Loading results..." });
1143
+ return /* @__PURE__ */ e(V, { message: "Loading results..." });
1150
1144
  if (!a)
1151
- return /* @__PURE__ */ e(M, { message: "No results for this round." });
1145
+ return /* @__PURE__ */ e(B, { message: "No results for this round." });
1152
1146
  const o = a.sessions || [];
1153
1147
  if (!o.length)
1154
- return /* @__PURE__ */ e(M, { message: "No session data for this round." });
1155
- const m = i || ((g = o.find((x) => x.type === "RACE")) == null ? void 0 : g.type) || ((N = o[0]) == null ? void 0 : N.type), d = o.find((x) => x.type === m) || o[0];
1156
- return /* @__PURE__ */ l("div", { className: `pvx-round-results ${n || ""}`, children: [
1148
+ return /* @__PURE__ */ e(B, { message: "No session data for this round." });
1149
+ const m = i || ((x = o.find((f) => f.type === "RACE")) == null ? void 0 : x.type) || ((N = o[0]) == null ? void 0 : N.type), d = o.find((f) => f.type === m) || o[0];
1150
+ return /* @__PURE__ */ l("div", { className: `pvx-round-results ${r || ""}`, children: [
1157
1151
  /* @__PURE__ */ l("div", { className: "pvx-round-results-header", children: [
1158
1152
  /* @__PURE__ */ l("div", { children: [
1159
1153
  /* @__PURE__ */ l("h4", { className: "pvx-round-results-title", children: [
@@ -1167,65 +1161,65 @@ function ut({ competitionId: t, roundNumber: r, className: n }) {
1167
1161
  year: "numeric"
1168
1162
  }) })
1169
1163
  ] }),
1170
- /* @__PURE__ */ e(mt, { sessions: o })
1164
+ /* @__PURE__ */ e(ut, { sessions: o })
1171
1165
  ] }),
1172
1166
  /* @__PURE__ */ e(
1173
- st,
1167
+ at,
1174
1168
  {
1175
1169
  sessions: o,
1176
1170
  activeSession: m,
1177
1171
  onSelect: c
1178
1172
  }
1179
1173
  ),
1180
- /* @__PURE__ */ e(ht, { session: d })
1174
+ /* @__PURE__ */ e(mt, { session: d })
1181
1175
  ] });
1182
1176
  }
1183
- function mt({ sessions: t }) {
1177
+ function ut({ sessions: t }) {
1184
1178
  var s;
1185
- const r = t.find((i) => i.type === "RACE"), n = (s = r == null ? void 0 : r.results) == null ? void 0 : s.filter((i) => i.position <= 3).sort((i, c) => i.position - c.position);
1186
- if (!(n != null && n.length)) return null;
1179
+ const n = t.find((i) => i.type === "RACE"), r = (s = n == null ? void 0 : n.results) == null ? void 0 : s.filter((i) => i.position <= 3).sort((i, c) => i.position - c.position);
1180
+ if (!(r != null && r.length)) return null;
1187
1181
  const a = ["🥇", "🥈", "🥉"];
1188
- return /* @__PURE__ */ e("div", { className: "pvx-round-podium-summary", children: n.map((i) => /* @__PURE__ */ l("span", { className: "pvx-round-podium-item", children: [
1182
+ return /* @__PURE__ */ e("div", { className: "pvx-round-podium-summary", children: r.map((i) => /* @__PURE__ */ l("span", { className: "pvx-round-podium-item", children: [
1189
1183
  /* @__PURE__ */ e("span", { children: a[i.position - 1] }),
1190
1184
  /* @__PURE__ */ e("span", { children: i.driverName })
1191
1185
  ] }, i.driverId)) });
1192
1186
  }
1193
- function ht({ session: t }) {
1187
+ function mt({ session: t }) {
1194
1188
  var a;
1195
- const r = t.type === "RACE";
1189
+ const n = t.type === "RACE";
1196
1190
  if (!((a = t.results) != null && a.length))
1197
- return /* @__PURE__ */ e(M, { message: `No results for ${t.type}.` });
1198
- const n = it(t.results);
1191
+ return /* @__PURE__ */ e(B, { message: `No results for ${t.type}.` });
1192
+ const r = st(t.results);
1199
1193
  return /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
1200
1194
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
1201
1195
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--narrow", children: "Pos" }),
1202
1196
  /* @__PURE__ */ e("th", { className: "pvx-th", children: "Driver" }),
1203
1197
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "Car" }),
1204
1198
  /* @__PURE__ */ e("th", { className: "pvx-th", children: "Best Lap" }),
1205
- r && /* @__PURE__ */ l(Q, { children: [
1199
+ n && /* @__PURE__ */ l(Q, { children: [
1206
1200
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "Laps" }),
1207
1201
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "Time / Gap" }),
1208
1202
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--center", children: "Points" })
1209
1203
  ] })
1210
1204
  ] }) }),
1211
1205
  /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: t.results.map((s, i) => /* @__PURE__ */ e(
1212
- vt,
1206
+ ht,
1213
1207
  {
1214
1208
  result: s,
1215
- isRace: r,
1216
- fastestSplits: n,
1209
+ isRace: n,
1210
+ fastestSplits: r,
1217
1211
  rowIndex: i
1218
1212
  },
1219
1213
  s.driverId || i
1220
1214
  )) })
1221
1215
  ] }) });
1222
1216
  }
1223
- function vt({ result: t, isRace: r, fastestSplits: n, rowIndex: a }) {
1217
+ function ht({ result: t, isRace: n, fastestSplits: r, rowIndex: a }) {
1224
1218
  const s = t.position <= 3;
1225
1219
  return /* @__PURE__ */ l("tr", { className: `pvx-row ${s ? "pvx-row--podium" : ""}`, children: [
1226
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(fe, { position: t.position }) }),
1220
+ /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(ge, { position: t.position }) }),
1227
1221
  /* @__PURE__ */ l("td", { className: "pvx-td pvx-td--primary", children: [
1228
- /* @__PURE__ */ e(Ne, { nation: t.nation }),
1222
+ /* @__PURE__ */ e(fe, { nation: t.nation }),
1229
1223
  t.driverName,
1230
1224
  t.carNumber != null && /* @__PURE__ */ l("span", { className: "pvx-car-number", children: [
1231
1225
  "#",
@@ -1233,18 +1227,18 @@ function vt({ result: t, isRace: r, fastestSplits: n, rowIndex: a }) {
1233
1227
  ] }),
1234
1228
  t.penalty && /* @__PURE__ */ e("span", { className: "pvx-penalty", children: t.penalty })
1235
1229
  ] }),
1236
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-hidden-below-sm", children: I(t.carId) }),
1230
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-hidden-below-sm", children: D(t.carId) }),
1237
1231
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--mono", children: /* @__PURE__ */ e(
1238
- xt,
1232
+ vt,
1239
1233
  {
1240
1234
  bestLap: t.bestLapFormatted,
1241
1235
  hasBestLap: t.hasBestLap,
1242
1236
  splits: t.splits,
1243
- fastestSplits: n,
1237
+ fastestSplits: r,
1244
1238
  showAbove: a <= 1
1245
1239
  }
1246
1240
  ) }),
1247
- r && /* @__PURE__ */ l(Q, { children: [
1241
+ n && /* @__PURE__ */ l(Q, { children: [
1248
1242
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-hidden-below-sm", children: t.lapsCompleted }),
1249
1243
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--mono pvx-td--muted pvx-hidden-below-sm", children: t.position === 1 ? t.totalTime || "-" : t.gap || "-" }),
1250
1244
  /* @__PURE__ */ l("td", { className: "pvx-td pvx-td--center", children: [
@@ -1259,10 +1253,10 @@ function vt({ result: t, isRace: r, fastestSplits: n, rowIndex: a }) {
1259
1253
  ] })
1260
1254
  ] });
1261
1255
  }
1262
- function xt({ bestLap: t, hasBestLap: r, splits: n, fastestSplits: a, showAbove: s }) {
1263
- return t ? /* @__PURE__ */ l("span", { className: `pvx-best-lap-cell ${r ? "pvx-best-lap-cell--fastest" : ""}`, children: [
1256
+ function vt({ bestLap: t, hasBestLap: n, splits: r, fastestSplits: a, showAbove: s }) {
1257
+ return t ? /* @__PURE__ */ l("span", { className: `pvx-best-lap-cell ${n ? "pvx-best-lap-cell--fastest" : ""}`, children: [
1264
1258
  /* @__PURE__ */ e("span", { className: "pvx-best-lap-time", children: t }),
1265
- (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, c) => {
1259
+ (r == null ? void 0 : r.length) > 0 && /* @__PURE__ */ e("span", { className: "pvx-splits-tooltip-anchor", children: /* @__PURE__ */ e("span", { className: `pvx-splits-tooltip ${s ? "" : "pvx-splits-tooltip--above"}`, children: r.map((i, c) => {
1266
1260
  const o = a && i === a[c];
1267
1261
  return /* @__PURE__ */ l("span", { className: "pvx-splits-tooltip-row", children: [
1268
1262
  /* @__PURE__ */ l("span", { className: "pvx-splits-tooltip-label", children: [
@@ -1274,12 +1268,12 @@ function xt({ bestLap: t, hasBestLap: r, splits: n, fastestSplits: a, showAbove:
1274
1268
  }) }) })
1275
1269
  ] }) : /* @__PURE__ */ e("span", { className: "pvx-td--muted", children: "-" });
1276
1270
  }
1277
- function gt({ competitionId: t, className: r }) {
1278
- const { data: n, isLoading: a } = Ve(t);
1271
+ function xt({ competitionId: t, className: n }) {
1272
+ const { data: r, isLoading: a } = qe(t);
1279
1273
  if (a)
1280
- return /* @__PURE__ */ e(_, { message: "Loading drivers..." });
1281
- const s = (n == null ? void 0 : n.drivers) || (n == null ? void 0 : n.entries) || [];
1282
- return s.length ? /* @__PURE__ */ e("div", { className: `pvx-entry-grid ${r || ""}`, children: s.map((i) => {
1274
+ return /* @__PURE__ */ e(V, { message: "Loading drivers..." });
1275
+ const s = (r == null ? void 0 : r.drivers) || (r == null ? void 0 : r.entries) || [];
1276
+ return s.length ? /* @__PURE__ */ e("div", { className: `pvx-entry-grid ${n || ""}`, children: s.map((i) => {
1283
1277
  var c, o;
1284
1278
  return /* @__PURE__ */ l("div", { className: "pvx-entry-card", children: [
1285
1279
  i.avatarUrl ? /* @__PURE__ */ e(
@@ -1292,28 +1286,58 @@ function gt({ competitionId: t, className: r }) {
1292
1286
  ) : /* @__PURE__ */ e("div", { className: "pvx-entry-avatar pvx-entry-avatar--placeholder", children: ((o = (c = i.displayName) == null ? void 0 : c.charAt(0)) == null ? void 0 : o.toUpperCase()) || "?" }),
1293
1287
  /* @__PURE__ */ e("span", { className: "pvx-entry-name", children: i.displayName })
1294
1288
  ] }, i.steamId || i.driverId);
1295
- }) }) : /* @__PURE__ */ e(M, { message: "No drivers registered yet." });
1289
+ }) }) : /* @__PURE__ */ e(B, { message: "No drivers registered yet." });
1290
+ }
1291
+ function gt({
1292
+ competitionId: t,
1293
+ driverData: n,
1294
+ className: r,
1295
+ children: a
1296
+ }) {
1297
+ const { data: s, isLoading: i } = je(t), { isPowerMode: c } = Oe(), o = We(t), m = Ke(t), d = He(t), x = (s == null ? void 0 : s.isRegistered) || !1, N = i || m.isPending || d.isPending, f = m.error || d.error || null, v = () => {
1298
+ c && n && m.mutate(n);
1299
+ }, g = () => {
1300
+ c && d.mutate();
1301
+ };
1302
+ return typeof a == "function" ? a({ isRegistered: x, isLoading: N, register: v, withdraw: g, error: f, isPowerMode: c, registrationUrl: o }) : c ? /* @__PURE__ */ e(
1303
+ "button",
1304
+ {
1305
+ className: `pvx-comp-register-btn ${r || ""}`,
1306
+ onClick: x ? g : v,
1307
+ disabled: N,
1308
+ children: N ? "Loading..." : x ? "Withdraw" : "Register"
1309
+ }
1310
+ ) : /* @__PURE__ */ e(
1311
+ "a",
1312
+ {
1313
+ href: o,
1314
+ target: "_blank",
1315
+ rel: "noopener noreferrer",
1316
+ className: `pvx-comp-register-link ${r || ""}`,
1317
+ children: x ? "View Registration" : "Register on PitVox"
1318
+ }
1319
+ );
1296
1320
  }
1297
1321
  const ft = [
1298
1322
  { id: "standings", label: "Standings" },
1299
1323
  { id: "rounds", label: "Rounds" },
1300
1324
  { id: "drivers", label: "Drivers" }
1301
1325
  ];
1302
- function qt({ className: t, title: r = "Competitions" }) {
1303
- const [n, a] = oe(), s = n.get("competition"), i = n.get("tab") || "standings", c = n.get("round") ? Number(n.get("round")) : null, { data: o, isLoading: m } = _e();
1304
- function d(f) {
1305
- a({ competition: f });
1326
+ function _t({ className: t, title: n = "Competitions" }) {
1327
+ const [r, a] = oe(), s = r.get("competition"), i = r.get("tab") || "standings", c = r.get("round") ? Number(r.get("round")) : null, { data: o, isLoading: m } = Ee();
1328
+ function d(g) {
1329
+ a({ competition: g });
1306
1330
  }
1307
- function g() {
1331
+ function x() {
1308
1332
  a({});
1309
1333
  }
1310
- function N(f) {
1311
- a({ competition: s, tab: f });
1334
+ function N(g) {
1335
+ a({ competition: s, tab: g });
1312
1336
  }
1313
- function x(f) {
1314
- a({ competition: s, tab: "rounds", round: String(f) });
1337
+ function f(g) {
1338
+ a({ competition: s, tab: "rounds", round: String(g) });
1315
1339
  }
1316
- function h() {
1340
+ function v() {
1317
1341
  a({ competition: s, tab: "rounds" });
1318
1342
  }
1319
1343
  return s ? /* @__PURE__ */ e("div", { className: `pvx-comp-explorer ${t || ""}`, children: /* @__PURE__ */ e(
@@ -1322,14 +1346,14 @@ function qt({ className: t, title: r = "Competitions" }) {
1322
1346
  competitionId: s,
1323
1347
  activeTab: i,
1324
1348
  selectedRound: c,
1325
- onBack: g,
1349
+ onBack: x,
1326
1350
  onTabChange: N,
1327
- onSelectRound: x,
1328
- onDeselectRound: h
1351
+ onSelectRound: f,
1352
+ onDeselectRound: v
1329
1353
  }
1330
1354
  ) }) : /* @__PURE__ */ l("div", { className: `pvx-comp-explorer ${t || ""}`, children: [
1331
1355
  /* @__PURE__ */ l("div", { className: "pvx-explorer-header", children: [
1332
- /* @__PURE__ */ e("h2", { className: "pvx-explorer-title", children: r }),
1356
+ /* @__PURE__ */ e("h2", { className: "pvx-explorer-title", children: n }),
1333
1357
  !m && (o == null ? void 0 : o.length) > 0 && /* @__PURE__ */ e("div", { className: "pvx-explorer-stats", children: /* @__PURE__ */ l("span", { children: [
1334
1358
  o.length,
1335
1359
  " competition",
@@ -1337,7 +1361,7 @@ function qt({ className: t, title: r = "Competitions" }) {
1337
1361
  ] }) })
1338
1362
  ] }),
1339
1363
  /* @__PURE__ */ e(
1340
- ot,
1364
+ it,
1341
1365
  {
1342
1366
  competitions: o,
1343
1367
  isLoading: m,
@@ -1348,30 +1372,30 @@ function qt({ className: t, title: r = "Competitions" }) {
1348
1372
  }
1349
1373
  function Nt({
1350
1374
  competitionId: t,
1351
- activeTab: r,
1352
- selectedRound: n,
1375
+ activeTab: n,
1376
+ selectedRound: r,
1353
1377
  onBack: a,
1354
1378
  onTabChange: s,
1355
1379
  onSelectRound: i,
1356
1380
  onDeselectRound: c
1357
1381
  }) {
1358
- var f, p;
1382
+ var g, p;
1359
1383
  const { data: o, isLoading: m } = de(t);
1360
1384
  if (m)
1361
- return /* @__PURE__ */ e(_, { message: "Loading competition..." });
1385
+ return /* @__PURE__ */ e(V, { message: "Loading competition..." });
1362
1386
  if (!o)
1363
1387
  return /* @__PURE__ */ l("div", { children: [
1364
- /* @__PURE__ */ e(M, { message: "Competition not found." }),
1388
+ /* @__PURE__ */ e(B, { message: "Competition not found." }),
1365
1389
  /* @__PURE__ */ e("div", { className: "pvx-comp-back-link-wrap", children: /* @__PURE__ */ e("button", { onClick: a, className: "pvx-comp-back-link", children: "← Back to competitions" }) })
1366
1390
  ] });
1367
- const d = o.type === "championship", g = ((f = o.rounds) == null ? void 0 : f.filter((v) => v.isFinalized)) || [], N = o.rounds || [], x = ft.filter((v) => !(v.id === "standings" && !d || v.id === "rounds" && g.length === 0)), h = x.find((v) => v.id === r) ? r : ((p = x[0]) == null ? void 0 : p.id) || "standings";
1391
+ const d = o.type === "championship", x = ((g = o.rounds) == null ? void 0 : g.filter((h) => h.isFinalized)) || [], N = o.rounds || [], f = ft.filter((h) => !(h.id === "standings" && !d || h.id === "rounds" && x.length === 0)), v = f.find((h) => h.id === n) ? n : ((p = f[0]) == null ? void 0 : p.id) || "standings";
1368
1392
  return /* @__PURE__ */ l(Q, { children: [
1369
1393
  /* @__PURE__ */ e("button", { onClick: a, className: "pvx-comp-back-link", children: "← Competitions" }),
1370
1394
  /* @__PURE__ */ l("div", { className: "pvx-comp-detail-header", children: [
1371
1395
  /* @__PURE__ */ e("h2", { className: "pvx-explorer-title", children: o.name }),
1372
1396
  o.description && /* @__PURE__ */ e("p", { className: "pvx-comp-detail-desc", children: o.description }),
1373
1397
  /* @__PURE__ */ l("div", { className: "pvx-comp-detail-meta", children: [
1374
- /* @__PURE__ */ e(be, { type: o.type }),
1398
+ /* @__PURE__ */ e(Ne, { type: o.type }),
1375
1399
  o.game && /* @__PURE__ */ e(U, { children: o.game.toUpperCase() }),
1376
1400
  o.countingRounds > 0 && /* @__PURE__ */ l(U, { variant: "format", children: [
1377
1401
  "Best ",
@@ -1387,34 +1411,40 @@ function Nt({
1387
1411
  ] })
1388
1412
  ] })
1389
1413
  ] }),
1414
+ (() => {
1415
+ const h = o.registration;
1416
+ if (!h) return null;
1417
+ const u = h.deadline && new Date(h.deadline) < /* @__PURE__ */ new Date(), y = h.maxParticipants && (h.currentCount || 0) >= h.maxParticipants;
1418
+ return h.isOpen && !u && !y ? /* @__PURE__ */ e("div", { className: "pvx-comp-register-cta", children: /* @__PURE__ */ e(gt, { competitionId: t }) }) : null;
1419
+ })(),
1390
1420
  N.length > 0 && /* @__PURE__ */ e(bt, { rounds: N }),
1391
- x.length > 1 && /* @__PURE__ */ e("div", { className: "pvx-comp-tabs", children: x.map((v) => /* @__PURE__ */ e(
1421
+ f.length > 1 && /* @__PURE__ */ e("div", { className: "pvx-comp-tabs", children: f.map((h) => /* @__PURE__ */ e(
1392
1422
  "button",
1393
1423
  {
1394
- onClick: () => s(v.id),
1395
- className: `pvx-comp-tab ${h === v.id ? "pvx-comp-tab--active" : ""}`,
1396
- children: v.label
1424
+ onClick: () => s(h.id),
1425
+ className: `pvx-comp-tab ${v === h.id ? "pvx-comp-tab--active" : ""}`,
1426
+ children: h.label
1397
1427
  },
1398
- v.id
1428
+ h.id
1399
1429
  )) }),
1400
- h === "standings" && /* @__PURE__ */ e(dt, { competitionId: t }),
1401
- h === "rounds" && /* @__PURE__ */ e(
1430
+ v === "standings" && /* @__PURE__ */ e(ct, { competitionId: t }),
1431
+ v === "rounds" && /* @__PURE__ */ e(
1402
1432
  yt,
1403
1433
  {
1404
1434
  competitionId: t,
1405
- finalizedRounds: g,
1406
- selectedRound: n,
1435
+ finalizedRounds: x,
1436
+ selectedRound: r,
1407
1437
  onSelectRound: i,
1408
1438
  onDeselectRound: c
1409
1439
  }
1410
1440
  ),
1411
- h === "drivers" && /* @__PURE__ */ e(gt, { competitionId: t })
1441
+ v === "drivers" && /* @__PURE__ */ e(xt, { competitionId: t })
1412
1442
  ] });
1413
1443
  }
1414
1444
  function bt({ rounds: t }) {
1415
- const r = /* @__PURE__ */ new Date(), n = t.find((a) => a.startTime && new Date(a.startTime) >= r);
1445
+ const n = /* @__PURE__ */ new Date(), r = t.find((a) => a.startTime && new Date(a.startTime) >= n);
1416
1446
  return /* @__PURE__ */ e("div", { className: "pvx-comp-schedule", children: /* @__PURE__ */ e("div", { className: "pvx-comp-schedule-list", children: t.map((a) => {
1417
- const s = a === n, i = a.startTime && new Date(a.startTime) < r;
1447
+ const s = a === r, i = a.startTime && new Date(a.startTime) < n;
1418
1448
  return /* @__PURE__ */ l(
1419
1449
  "div",
1420
1450
  {
@@ -1425,7 +1455,7 @@ function bt({ rounds: t }) {
1425
1455
  a.roundNumber
1426
1456
  ] }),
1427
1457
  /* @__PURE__ */ e("span", { className: "pvx-comp-schedule-track", children: a.track || "TBD" }),
1428
- /* @__PURE__ */ e("span", { className: "pvx-comp-schedule-date", children: ye(a.startTime) }),
1458
+ /* @__PURE__ */ e("span", { className: "pvx-comp-schedule-date", children: be(a.startTime) }),
1429
1459
  a.isFinalized && /* @__PURE__ */ e("span", { className: "pvx-comp-schedule-badge", children: "Results" })
1430
1460
  ]
1431
1461
  },
@@ -1433,13 +1463,13 @@ function bt({ rounds: t }) {
1433
1463
  );
1434
1464
  }) }) });
1435
1465
  }
1436
- function yt({ competitionId: t, finalizedRounds: r, selectedRound: n, onSelectRound: a, onDeselectRound: s }) {
1437
- return r.length ? /* @__PURE__ */ l("div", { className: "pvx-comp-rounds", children: [
1438
- /* @__PURE__ */ e("div", { className: "pvx-comp-round-pills", children: r.map((i) => /* @__PURE__ */ l(
1466
+ function yt({ competitionId: t, finalizedRounds: n, selectedRound: r, onSelectRound: a, onDeselectRound: s }) {
1467
+ return n.length ? /* @__PURE__ */ l("div", { className: "pvx-comp-rounds", children: [
1468
+ /* @__PURE__ */ e("div", { className: "pvx-comp-round-pills", children: n.map((i) => /* @__PURE__ */ l(
1439
1469
  "button",
1440
1470
  {
1441
- onClick: () => n === i.roundNumber ? s() : a(i.roundNumber),
1442
- className: `pvx-comp-round-pill ${n === i.roundNumber ? "pvx-comp-round-pill--active" : ""}`,
1471
+ onClick: () => r === i.roundNumber ? s() : a(i.roundNumber),
1472
+ className: `pvx-comp-round-pill ${r === i.roundNumber ? "pvx-comp-round-pill--active" : ""}`,
1443
1473
  children: [
1444
1474
  /* @__PURE__ */ l("span", { className: "pvx-comp-round-pill-num", children: [
1445
1475
  "R",
@@ -1450,34 +1480,13 @@ function yt({ competitionId: t, finalizedRounds: r, selectedRound: n, onSelectRo
1450
1480
  },
1451
1481
  i.roundNumber
1452
1482
  )) }),
1453
- n ? /* @__PURE__ */ e(ut, { competitionId: t, roundNumber: n }) : /* @__PURE__ */ e("div", { className: "pvx-empty", children: /* @__PURE__ */ e("p", { children: "Select a round to view results." }) })
1454
- ] }) : /* @__PURE__ */ e(M, { message: "No finalised rounds yet." });
1455
- }
1456
- function jt({
1457
- competitionId: t,
1458
- driverData: r,
1459
- className: n,
1460
- children: a
1461
- }) {
1462
- const { data: s, isLoading: i } = Oe(t), c = We(t), o = Ge(t), m = (s == null ? void 0 : s.isRegistered) || !1, d = i || c.isPending || o.isPending, g = c.error || o.error || null, N = () => {
1463
- r && c.mutate(r);
1464
- }, x = () => {
1465
- o.mutate();
1466
- };
1467
- return typeof a == "function" ? a({ isRegistered: m, isLoading: d, register: N, withdraw: x, error: g }) : /* @__PURE__ */ e(
1468
- "button",
1469
- {
1470
- className: n,
1471
- onClick: m ? x : N,
1472
- disabled: d,
1473
- children: d ? "Loading..." : m ? "Withdraw" : "Register"
1474
- }
1475
- );
1483
+ r ? /* @__PURE__ */ e(pt, { competitionId: t, roundNumber: r }) : /* @__PURE__ */ e("div", { className: "pvx-empty", children: /* @__PURE__ */ e("p", { children: "Select a round to view results." }) })
1484
+ ] }) : /* @__PURE__ */ e(B, { message: "No finalised rounds yet." });
1476
1485
  }
1477
1486
  function Ct(t) {
1478
- const { cdnUrl: r, partnerSlug: n } = T(), a = L({
1479
- queryKey: ["pitvox", "laps", n, t],
1480
- queryFn: () => $(r, `laps/partners/${n}/${t}.json`),
1487
+ const { cdnUrl: n, partnerSlug: r } = k(), a = L({
1488
+ queryKey: ["pitvox", "laps", r, t],
1489
+ queryFn: () => R(n, `laps/partners/${r}/${t}.json`),
1481
1490
  enabled: !!t,
1482
1491
  staleTime: 3e4,
1483
1492
  refetchInterval: 3e4
@@ -1502,12 +1511,12 @@ function Ct(t) {
1502
1511
  }
1503
1512
  function wt(t) {
1504
1513
  var i;
1505
- const { cdnUrl: r, partnerSlug: n } = T(), a = L({
1506
- queryKey: ["pitvox", "ratings", n],
1507
- queryFn: () => $(r, `leaderboards/partners/${n}/ratings.json`),
1514
+ const { cdnUrl: n, partnerSlug: r } = k(), a = L({
1515
+ queryKey: ["pitvox", "ratings", r],
1516
+ queryFn: () => R(n, `leaderboards/partners/${r}/ratings.json`),
1508
1517
  staleTime: 6e4,
1509
1518
  refetchInterval: 6e4
1510
- }), s = k(() => {
1519
+ }), s = T(() => {
1511
1520
  var c;
1512
1521
  return !((c = a.data) != null && c.drivers) || !t ? null : a.data.drivers.find(
1513
1522
  (o) => o.identifier === t
@@ -1526,10 +1535,10 @@ function wt(t) {
1526
1535
  } : null
1527
1536
  };
1528
1537
  }
1529
- function kt({ driverName: t, avatarUrl: r, memberSince: n, className: a = "" }) {
1530
- const s = n ? new Date(n).toLocaleDateString("en-GB", { day: "2-digit", month: "2-digit", year: "numeric" }) : null;
1538
+ function kt({ driverName: t, avatarUrl: n, memberSince: r, className: a = "" }) {
1539
+ const s = r ? new Date(r).toLocaleDateString("en-GB", { day: "2-digit", month: "2-digit", year: "numeric" }) : null;
1531
1540
  return /* @__PURE__ */ l("div", { className: `pvx-card pvx-dash-profile ${a}`, children: [
1532
- r ? /* @__PURE__ */ e("img", { src: r, alt: "", className: "pvx-dash-profile-avatar" }) : /* @__PURE__ */ e("div", { className: "pvx-dash-profile-avatar pvx-dash-profile-avatar--placeholder", children: (t || "?")[0].toUpperCase() }),
1541
+ n ? /* @__PURE__ */ e("img", { src: n, alt: "", className: "pvx-dash-profile-avatar" }) : /* @__PURE__ */ e("div", { className: "pvx-dash-profile-avatar pvx-dash-profile-avatar--placeholder", children: (t || "?")[0].toUpperCase() }),
1533
1542
  /* @__PURE__ */ l("div", { className: "pvx-dash-profile-info", children: [
1534
1543
  /* @__PURE__ */ e("h2", { className: "pvx-dash-profile-name", children: t }),
1535
1544
  s && /* @__PURE__ */ l("p", { className: "pvx-dash-profile-since", children: [
@@ -1559,13 +1568,13 @@ function St() {
1559
1568
  function Lt() {
1560
1569
  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" }) });
1561
1570
  }
1562
- function ae({ items: t, labelKey: r, countKey: n }) {
1571
+ function ae({ items: t, labelKey: n, countKey: r }) {
1563
1572
  if (!(t != null && t.length)) return null;
1564
- const a = t.slice().sort((s, i) => i[n] - s[n]).slice(0, 10);
1573
+ const a = t.slice().sort((s, i) => i[r] - s[r]).slice(0, 10);
1565
1574
  return /* @__PURE__ */ l("div", { className: "pvx-dash-tooltip", children: [
1566
1575
  a.map((s, i) => /* @__PURE__ */ l("div", { className: "pvx-dash-tooltip-row", children: [
1567
- /* @__PURE__ */ e("span", { className: "pvx-dash-tooltip-label", children: s[r] }),
1568
- /* @__PURE__ */ e("span", { className: "pvx-dash-tooltip-value", children: s[n] })
1576
+ /* @__PURE__ */ e("span", { className: "pvx-dash-tooltip-label", children: s[n] }),
1577
+ /* @__PURE__ */ e("span", { className: "pvx-dash-tooltip-value", children: s[r] })
1569
1578
  ] }, i)),
1570
1579
  t.length > 10 && /* @__PURE__ */ l("div", { className: "pvx-dash-tooltip-row pvx-dash-tooltip-more", children: [
1571
1580
  "+",
@@ -1574,16 +1583,16 @@ function ae({ items: t, labelKey: r, countKey: n }) {
1574
1583
  ] })
1575
1584
  ] });
1576
1585
  }
1577
- function $t({ stats: t, rating: r, className: n = "" }) {
1586
+ function Rt({ stats: t, rating: n, className: r = "" }) {
1578
1587
  if (!t) return null;
1579
1588
  const a = t.trackBreakdown.map((i) => ({
1580
- name: V(i.trackId, i.layout),
1589
+ name: j(i.trackId, i.layout),
1581
1590
  lapCount: i.lapCount
1582
1591
  })), s = t.carBreakdown.map((i) => ({
1583
- name: I(i.carId),
1592
+ name: D(i.carId),
1584
1593
  lapCount: i.lapCount
1585
1594
  }));
1586
- return /* @__PURE__ */ l("div", { className: `pvx-dash-stats ${n}`, children: [
1595
+ return /* @__PURE__ */ l("div", { className: `pvx-dash-stats ${r}`, children: [
1587
1596
  /* @__PURE__ */ l("div", { className: "pvx-dash-stat-card pvx-dash-stat-card--has-tooltip", children: [
1588
1597
  /* @__PURE__ */ e(Tt, {}),
1589
1598
  /* @__PURE__ */ l("div", { className: "pvx-dash-stat-content", children: [
@@ -1600,30 +1609,30 @@ function $t({ stats: t, rating: r, className: n = "" }) {
1600
1609
  ] }),
1601
1610
  /* @__PURE__ */ e(ae, { items: s, labelKey: "name", countKey: "lapCount" })
1602
1611
  ] }),
1603
- r && /* @__PURE__ */ l("div", { className: "pvx-dash-stat-card pvx-dash-stat-card--rating", children: [
1612
+ n && /* @__PURE__ */ l("div", { className: "pvx-dash-stat-card pvx-dash-stat-card--rating", children: [
1604
1613
  /* @__PURE__ */ e(Lt, {}),
1605
1614
  /* @__PURE__ */ l("div", { className: "pvx-dash-stat-content", children: [
1606
- /* @__PURE__ */ e("span", { className: "pvx-dash-stat-value", children: r.rating.toFixed(1) }),
1615
+ /* @__PURE__ */ e("span", { className: "pvx-dash-stat-value", children: n.rating.toFixed(1) }),
1607
1616
  /* @__PURE__ */ e("span", { className: "pvx-dash-stat-label", children: "Driver Rating" }),
1608
1617
  /* @__PURE__ */ l("span", { className: "pvx-dash-stat-sub", children: [
1609
1618
  "#",
1610
- r.rank,
1619
+ n.rank,
1611
1620
  " of ",
1612
- r.totalDrivers
1621
+ n.totalDrivers
1613
1622
  ] })
1614
1623
  ] })
1615
1624
  ] })
1616
1625
  ] });
1617
1626
  }
1618
1627
  const se = 10;
1619
- function Rt({ records: t, className: r = "" }) {
1620
- const [n, a] = j(!1), s = k(() => t != null && t.length ? t.slice().sort((o, m) => {
1628
+ function $t({ records: t, className: n = "" }) {
1629
+ const [r, a] = q(!1), s = T(() => t != null && t.length ? t.slice().sort((o, m) => {
1621
1630
  const d = o.recordedAt ? new Date(o.recordedAt).getTime() : 0;
1622
1631
  return (m.recordedAt ? new Date(m.recordedAt).getTime() : 0) - d;
1623
1632
  }) : [], [t]);
1624
1633
  if (!s.length) return null;
1625
- const i = n ? s : s.slice(0, se), c = s.length > se;
1626
- return /* @__PURE__ */ l("div", { className: `pvx-card ${r}`, children: [
1634
+ const i = r ? s : s.slice(0, se), c = s.length > se;
1635
+ return /* @__PURE__ */ l("div", { className: `pvx-card ${n}`, children: [
1627
1636
  /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ l("h3", { className: "pvx-card-title", children: [
1628
1637
  /* @__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: [
1629
1638
  /* @__PURE__ */ e("path", { d: "M6 9H4.5a2.5 2.5 0 010-5H6" }),
@@ -1642,11 +1651,11 @@ function Rt({ records: t, className: r = "" }) {
1642
1651
  ] }) }),
1643
1652
  /* @__PURE__ */ e("div", { className: "pvx-dash-records-list", children: i.map((o, m) => /* @__PURE__ */ l("div", { className: "pvx-dash-record-row", children: [
1644
1653
  /* @__PURE__ */ l("div", { className: "pvx-dash-record-info", children: [
1645
- /* @__PURE__ */ e("span", { className: "pvx-dash-record-track", children: V(o.trackId, o.layout, o.game) }),
1646
- /* @__PURE__ */ e("span", { className: "pvx-dash-record-car", children: I(o.carId) })
1654
+ /* @__PURE__ */ e("span", { className: "pvx-dash-record-track", children: j(o.trackId, o.layout, o.game) }),
1655
+ /* @__PURE__ */ e("span", { className: "pvx-dash-record-car", children: D(o.carId) })
1647
1656
  ] }),
1648
1657
  /* @__PURE__ */ l("div", { className: "pvx-dash-record-time", children: [
1649
- /* @__PURE__ */ e("span", { className: "pvx-dash-record-lap", children: E(o.lapTimeMs) }),
1658
+ /* @__PURE__ */ e("span", { className: "pvx-dash-record-lap", children: F(o.lapTimeMs) }),
1650
1659
  /* @__PURE__ */ l("span", { className: `pvx-dash-game-badge pvx-dash-game-badge--${o.game || "evo"}`, children: [
1651
1660
  (o.game || "evo").toUpperCase(),
1652
1661
  o.gameVersion ? ` ${o.gameVersion}` : ""
@@ -1657,68 +1666,70 @@ function Rt({ records: t, className: r = "" }) {
1657
1666
  "button",
1658
1667
  {
1659
1668
  className: "pvx-dash-records-toggle",
1660
- onClick: () => a(!n),
1661
- children: n ? "Show less" : `Show all ${s.length} records`
1669
+ onClick: () => a(!r),
1670
+ children: r ? "Show less" : `Show all ${s.length} records`
1662
1671
  }
1663
1672
  )
1664
1673
  ] });
1665
1674
  }
1666
- function Vt({ steamId: t, avatarUrl: r, memberSince: n, className: a = "" }) {
1675
+ function qt({ steamId: t, avatarUrl: n, memberSince: r, className: a = "" }) {
1667
1676
  const { data: s, isLoading: i, error: c } = Ct(t), { data: o, isLoading: m } = wt(t);
1668
1677
  return i || m ? /* @__PURE__ */ e("div", { className: "pvx-loading", children: "Loading dashboard..." }) : c ? /* @__PURE__ */ e("div", { className: "pvx-empty", children: "Failed to load dashboard data." }) : s ? /* @__PURE__ */ l("div", { className: `pvx-dash ${a}`, children: [
1669
1678
  /* @__PURE__ */ e(
1670
1679
  kt,
1671
1680
  {
1672
1681
  driverName: s.driverName,
1673
- avatarUrl: r,
1674
- memberSince: n
1682
+ avatarUrl: n,
1683
+ memberSince: r
1675
1684
  }
1676
1685
  ),
1677
- /* @__PURE__ */ e($t, { stats: s, rating: o }),
1678
- /* @__PURE__ */ e(Rt, { records: s.currentRecords })
1686
+ /* @__PURE__ */ e(Rt, { stats: s, rating: o }),
1687
+ /* @__PURE__ */ e($t, { records: s.currentRecords })
1679
1688
  ] }) : /* @__PURE__ */ e("div", { className: "pvx-empty", children: "No data available yet. Start driving to see your stats!" });
1680
1689
  }
1681
1690
  export {
1682
- et as CarsTable,
1683
- ot as CompetitionCards,
1684
- qt as CompetitionExplorer,
1685
- Vt as DriverDashboard,
1691
+ Ye as CarsTable,
1692
+ it as CompetitionCards,
1693
+ _t as CompetitionExplorer,
1694
+ qt as DriverDashboard,
1686
1695
  kt as DriverProfile,
1687
- tt as DriversTable,
1688
- gt as EntryList,
1689
- nt as LapHistoryTable,
1690
- _t as LeaderboardExplorer,
1691
- At as PitVoxPartnerProvider,
1692
- Rt as RecordsTable,
1693
- jt as RegisterButton,
1694
- ut as RoundResults,
1695
- dt as StandingsTable,
1696
- $t as StatsCards,
1697
- Ye as TracksTable,
1698
- I as formatCarName,
1699
- F as formatDate,
1696
+ et as DriversTable,
1697
+ xt as EntryList,
1698
+ tt as LapHistoryTable,
1699
+ Vt as LeaderboardExplorer,
1700
+ Pt as PitVoxPartnerProvider,
1701
+ $t as RecordsTable,
1702
+ gt as RegisterButton,
1703
+ pt as RoundResults,
1704
+ ct as StandingsTable,
1705
+ Rt as StatsCards,
1706
+ Xe as TracksTable,
1707
+ D as formatCarName,
1708
+ E as formatDate,
1700
1709
  Ut as formatDelta,
1701
- E as formatLapTime,
1702
- Pt as formatRelativeTime,
1703
- P as formatSectorTime,
1704
- V as formatTrackName,
1710
+ F as formatLapTime,
1711
+ At as formatRelativeTime,
1712
+ A as formatSectorTime,
1713
+ j as formatTrackName,
1705
1714
  le as formatTyreCompound,
1706
- Et as useCarLeaderboard,
1715
+ Ft as useCarLeaderboard,
1707
1716
  Fe as useCarMetadata,
1708
- Ft as useCompetitionAllRounds,
1717
+ Et as useCompetitionAllRounds,
1709
1718
  de as useCompetitionConfig,
1710
- Ve as useCompetitionEntryList,
1711
- je as useCompetitionRound,
1712
- qe as useCompetitionStandings,
1713
- _e as useCompetitions,
1714
- Ue as useDriverLaps,
1719
+ qe as useCompetitionEntryList,
1720
+ _e as useCompetitionRound,
1721
+ Ve as useCompetitionStandings,
1722
+ Ee as useCompetitions,
1723
+ Ae as useDriverLaps,
1715
1724
  wt as useDriverRating,
1716
1725
  Ct as useDriverStats,
1717
1726
  Pe as useLeaderboardIndex,
1718
- T as usePitVox,
1719
- We as useRegister,
1720
- Oe as useRegistrationStatus,
1727
+ k as usePitVox,
1728
+ Ke as useRegister,
1729
+ Oe as useRegistrationMode,
1730
+ je as useRegistrationStatus,
1731
+ We as useRegistrationUrl,
1721
1732
  ce as useTrackLeaderboard,
1722
- Ee as useUserLookup,
1723
- Ge as useWithdraw
1733
+ Ue as useUserLookup,
1734
+ He as useWithdraw
1724
1735
  };