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