@pitvox/partner-react 0.5.12 → 0.6.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/README.md +4 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +746 -717
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -116,13 +116,14 @@ import {
|
|
|
116
116
|
|
|
117
117
|
```jsx
|
|
118
118
|
import {
|
|
119
|
-
CompetitionCards, StandingsTable, RoundResults,
|
|
120
|
-
EntryList, RegisterButton, RegistrationPanel,
|
|
119
|
+
CompetitionCards, CompetitionCard, StandingsTable, RoundResults,
|
|
120
|
+
RoundSessionResults, EntryList, RegisterButton, RegistrationPanel,
|
|
121
121
|
} from '@pitvox/partner-react'
|
|
122
122
|
import '@pitvox/partner-react/styles.css'
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
-
- **`<CompetitionCards>`** — Card grid with posters, type badges, schedule, registration status
|
|
125
|
+
- **`<CompetitionCards>`** — Card grid with posters, type badges, schedule, registration status. Bundles its own CSS grid layout.
|
|
126
|
+
- **`<CompetitionCard>`** — Individual competition card. Use this when you want to control the grid layout yourself (e.g. with Tailwind). Props: `comp`, `onSelect`, `onRegister`.
|
|
126
127
|
- **`<StandingsTable>`** — Championship standings with per-round breakdowns, podium highlights
|
|
127
128
|
- **`<RoundResults>`** — Standalone round results (fetches data, renders header + sessions)
|
|
128
129
|
- **`<RoundSessionResults>`** — Session tabs + results table (data-prop driven, no fetch)
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("react"),b=require("@tanstack/react-query"),W=N.createContext(null),Ae="https://cdn.pitvox.com",Ee="https://pitvox.com";let O=null;function Fe({partnerSlug:s,cdnUrl:r=Ae,pitvoxUrl:n=Ee,getSteamId:t,onRegister:i,onWithdraw:a,onFetchNotifications:o,onMarkNotificationRead:l,onMarkAllNotificationsRead:x,onFetchServerPassword:c,children:u}){const g=N.useMemo(()=>({partnerSlug:s,cdnUrl:r.replace(/\/$/,""),pitvoxUrl:n.replace(/\/$/,""),getSteamId:t||(()=>null),onRegister:i||null,onWithdraw:a||null,onFetchNotifications:o||null,onMarkNotificationRead:l||null,onMarkAllNotificationsRead:x||null,onFetchServerPassword:c||null}),[s,r,n,t,i,a,o,l,x,c]);let h=!1;try{b.useQueryClient(),h=!0}catch{h=!1}return h?e.jsx(W.Provider,{value:g,children:u}):(O||(O=new b.QueryClient({defaultOptions:{queries:{staleTime:6e4}}})),e.jsx(b.QueryClientProvider,{client:O,children:e.jsx(W.Provider,{value:g,children:u})}))}function y(){const s=N.useContext(W);if(!s)throw new Error("usePitVox must be used within a <PitVoxPartnerProvider>");return s}async function R(s,r){const n=await fetch(`${s}/${r}`);if(!n.ok){if(n.status===404||n.status===403)return null;throw new Error(`CDN fetch failed: ${n.status}`)}return n.json()}function $(s){if(!s&&s!==0)return"-";const r=Math.floor(s/1e3),n=Math.floor(r/60),t=r%60,i=s%1e3;return`${n}:${String(t).padStart(2,"0")}.${String(i).padStart(3,"0")}`}function M(s){return!s&&s!==0?"-":(s/1e3).toFixed(3)}function S(s){if(!s)return"";let r=s;return r.startsWith("ks_")&&(r=r.slice(3)),r.split("_").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function I(s,r,n){const t=s.split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" "),i=n==="acc"||!n&&(r==null?void 0:r.toLowerCase())==="track config";if(!r||r==="default"||i)return t;const a=r.split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ");return`${t} ${a}`}function P(s){if(!s)return"-";try{return new Date(s).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}catch{return"-"}}function G(s){if(!s)return"";const r=Date.now()-new Date(s).getTime(),n=Math.floor(r/1e3);if(n<60)return"Just now";const t=Math.floor(n/60);if(t<60)return`${t}m ago`;const i=Math.floor(t/60);if(i<24)return`${i}h ago`;const a=Math.floor(i/24);return a<30?`${a}d ago`:P(s)}function qe(s){return s==null?"":`${s>=0?"+":"-"}${(Math.abs(s)/1e3).toFixed(3)}`}function ne(s,r){const{type:n,title:t,trackId:i,trackLayout:a,carId:o,game:l,data:x}=s,c=typeof x=="string"?JSON.parse(x):x,u=i?I(i,a,l):null,g=o?S(o):null,h=[u,g].filter(Boolean).join(" — ");return n==="RECORD_BEATEN"&&h?`${c!=null&&c.beatenBySteamId&&r?r(c.beatenBySteamId).displayName:"Someone"} beat your record on ${h}`:n==="RECORD_SET"&&h?`You set a new record on ${h}`:t||"New notification"}function z(s){return s?{E:"Eco",RD:"Road",SC:"SuperCar",RV:"Race Vintage",SM:"Semislick",ST:"Street",HR:"Hard Race",MR:"Medium Race",SR:"Soft Race",S:"Soft"}[s]||s:"Unknown"}function _e(s={}){var l,x,c,u,g,h;const{cdnUrl:r,partnerSlug:n}=y(),{game:t,gameVersion:i}=s,a=b.useQuery({queryKey:["pitvox","leaderboards",n,"index"],queryFn:()=>R(r,`leaderboards/partners/${n}/index.json`),staleTime:3e4,refetchInterval:3e4}),o=N.useMemo(()=>{var f;if(!((f=a.data)!=null&&f.tracks))return[];let d=a.data.tracks;return t&&(d=d.filter(p=>p.game===t)),i&&(d=d.filter(p=>p.gameVersion===i)),d.map(p=>({id:p.trackId,layout:p.layout,game:p.game,gameVersion:p.gameVersion,displayName:I(p.trackId,p.layout,p.game),driverCount:p.driverCount||0,carCount:p.carCount||0,record:p.recordHolder?{visibleId:p.recordHolder.steamId||p.recordHolder.userId,carId:p.recordHolder.carId,carDisplayName:S(p.recordHolder.carId),lapTimeMs:p.recordHolder.lapTimeMs,timestamp:p.recordHolder.recordedAt}:null,recordByTag:p.recordByTag||null}))},[(l=a.data)==null?void 0:l.tracks,t,i]);return{...a,data:o,partner:((x=a.data)==null?void 0:x.partner)||null,generatedAt:(c=a.data)==null?void 0:c.generatedAt,totalLaps:((u=a.data)==null?void 0:u.totalLaps)||0,totalUsers:((g=a.data)==null?void 0:g.totalUsers)||0,versions:((h=a.data)==null?void 0:h.versions)||{}}}function ae(s,r,n={}){const{cdnUrl:t,partnerSlug:i}=y(),{carId:a,game:o,gameVersion:l}=n,x=r||"default",c=l?`leaderboards/partners/${i}/v/${l}/tracks/${s}/${x}.json`:`leaderboards/partners/${i}/tracks/${s}/${x}.json`,{data:u,isLoading:g,error:h}=b.useQuery({queryKey:["pitvox","leaderboards",i,"track",s,x,l],queryFn:()=>R(t,c),enabled:!!s,staleTime:3e4,refetchInterval:3e4});return{data:N.useMemo(()=>{if(!(u!=null&&u.entries))return[];let f=u.entries;if(o&&(f=f.filter(p=>p.game===o)),!a){const p=new Map,j=new Map;for(const m of f){const v=m.steamId||m.userId;j.has(m.carId)||j.set(m.carId,new Set),j.get(m.carId).add(v),(!p.has(m.carId)||m.lapTimeMs<p.get(m.carId).lapTimeMs)&&p.set(m.carId,m)}return Array.from(p.values()).map(m=>{var v;return{...m,driverCount:((v=j.get(m.carId))==null?void 0:v.size)||0}}).sort((m,v)=>m.lapTimeMs-v.lapTimeMs)}return f.filter(p=>p.carId===a).sort((p,j)=>p.lapTimeMs-j.lapTimeMs)},[u==null?void 0:u.entries,a,o]),isLoading:g,error:h}}function ie(s,r,n,t,i={}){var h,d;const{cdnUrl:a,partnerSlug:o}=y(),{showInvalid:l=!1,game:x,gameVersion:c}=i,u=b.useQuery({queryKey:["pitvox","laps",o,s],queryFn:()=>R(a,`laps/partners/${o}/${s}.json`),enabled:!!s,staleTime:3e4,refetchInterval:3e4}),g=N.useMemo(()=>{var f;return(f=u.data)!=null&&f.laps?u.data.laps.filter(p=>{if(p.trackId!==r)return!1;if(n){if(p.trackLayout!==n)return!1}else if(p.trackLayout&&p.trackLayout!=="default")return!1;return!(p.carId!==t||x&&p.game!==x||c&&p.gameVersion!==c||!l&&!p.isValid)}).sort((p,j)=>p.lapTimeMs-j.lapTimeMs):[]},[(h=u.data)==null?void 0:h.laps,r,n,t,x,c,l]);return{...u,data:g,driverName:((d=u.data)==null?void 0:d.driverName)||"Driver"}}function Y(){const{cdnUrl:s}=y(),{data:r}=b.useQuery({queryKey:["pitvox","users","index"],queryFn:()=>R(s,"users/index.json"),staleTime:5*6e4,gcTime:30*6e4}),n=(r==null?void 0:r.users)||{};return(t,i)=>{const a=n[t];return{displayName:(a==null?void 0:a.displayName)||i||t||"Unknown",avatarUrl:(a==null?void 0:a.avatarUrl)||null,affiliations:(a==null?void 0:a.affiliations)||[]}}}function Ve(){const{cdnUrl:s}=y(),{data:r}=b.useQuery({queryKey:["pitvox","cars","index"],queryFn:()=>R(s,"cars/index.json"),staleTime:5*6e4,gcTime:30*6e4});return{tags:(r==null?void 0:r.tags)||[],cars:(r==null?void 0:r.cars)||{}}}function Ke(s,r){return ae(s,null,{carId:r})}function He(){const{cdnUrl:s,partnerSlug:r}=y();return b.useQuery({queryKey:["pitvox","competitions",r],queryFn:async()=>{const n=await R(s,"competitions/index.json");return n!=null&&n.competitions?n.competitions.filter(t=>t.partnerSlug===r):[]},staleTime:6e4})}function oe(s){const{cdnUrl:r,partnerSlug:n}=y();return b.useQuery({queryKey:["pitvox","competition",n,s,"config"],queryFn:()=>R(r,`competitions/${n}/${s}/config.json`),enabled:!!s,staleTime:6e4})}function ce(s){const{cdnUrl:r,partnerSlug:n}=y();return b.useQuery({queryKey:["pitvox","competition",n,s,"standings"],queryFn:()=>R(r,`competitions/${n}/${s}/standings.json`),enabled:!!s,staleTime:6e4})}function le(s,r){const{cdnUrl:n,partnerSlug:t}=y();return b.useQuery({queryKey:["pitvox","competition",t,s,"round",r],queryFn:()=>R(n,`competitions/${t}/${s}/rounds/${r}.json`),enabled:!!s&&r!=null,staleTime:6e4})}function Qe(s,r=[]){const{cdnUrl:n,partnerSlug:t}=y();return b.useQuery({queryKey:["pitvox","competition",t,s,"allRounds",r],queryFn:async()=>(await Promise.all(r.map(a=>R(n,`competitions/${t}/${s}/rounds/${a}.json`).catch(()=>null)))).filter(Boolean),enabled:!!s&&r.length>0,staleTime:6e4})}function J(s){const{cdnUrl:r,partnerSlug:n}=y();return b.useQuery({queryKey:["pitvox","competition",n,s,"entrylist"],queryFn:()=>R(r,`competitions/${n}/${s}/entrylist.json`),enabled:!!s,staleTime:6e4})}function q(s){const{cdnUrl:r,partnerSlug:n,getSteamId:t}=y(),i=t();return b.useQuery({queryKey:["pitvox","registration",n,s,i],queryFn:async()=>{var x;const a=await fetch(`${r}/competitions/${n}/${s}/entrylist.json`);if(!a.ok)return{isRegistered:!1,entryList:null};const o=await a.json();return{isRegistered:!!i&&((x=o.drivers)==null?void 0:x.some(c=>c.steamId===i)),entryList:o}},enabled:!!s,staleTime:6e4})}function Z(s){const{onRegister:r,partnerSlug:n,getSteamId:t}=y(),i=b.useQueryClient(),a=Y();return b.useMutation({mutationFn:o=>{if(!r)throw new Error("No onRegister callback provided to PitVoxPartnerProvider. Provide onRegister for in-app registration, or use useRegistrationUrl() to link to pitvox.com.");return r(s,o)},onSuccess:()=>{const o=t();if(i.setQueriesData({queryKey:["pitvox","registration",n,s]},l=>l?{...l,isRegistered:!0}:{isRegistered:!0,entryList:null}),o){const l=a(o),x={steamId:o,displayName:l.displayName,avatarUrl:l.avatarUrl};i.setQueriesData({queryKey:["pitvox","competition",n,s,"entrylist"]},c=>{var g;return c?((g=c.drivers)==null?void 0:g.some(h=>h.steamId===o))?c:{...c,drivers:[...c.drivers||[],x]}:{drivers:[x]}})}}})}function X(s){const{onWithdraw:r,partnerSlug:n,getSteamId:t}=y(),i=b.useQueryClient();return b.useMutation({mutationFn:a=>{if(!r)throw new Error("No onWithdraw callback provided to PitVoxPartnerProvider. Provide onWithdraw for in-app withdrawal, or use useRegistrationUrl() to link to pitvox.com.");const o=a||t();if(!o)throw new Error("No Steam ID available");return r(s,o)},onSuccess:()=>{const a=t();i.setQueriesData({queryKey:["pitvox","registration",n,s]},o=>o?{...o,isRegistered:!1}:{isRegistered:!1,entryList:null}),a&&i.setQueriesData({queryKey:["pitvox","competition",n,s,"entrylist"]},o=>o!=null&&o.drivers?{...o,drivers:o.drivers.filter(l=>l.steamId!==a)}:o)}})}function _(){const{onRegister:s,onWithdraw:r}=y(),n=!!(s&&r);return{isPowerMode:n,isBasicMode:!n}}function V(s){const{pitvoxUrl:r,partnerSlug:n}=y();return`${r}/p/${n}/competitions/${s}/register`}const Oe={formula:"Formula",gt3:"GT3",gt2:"GT2",gt4:"GT4",cup:"Cup",prototype:"Prototype",rally:"Rally",hypercar:"Hypercar",supercar:"Supercar",sports_car:"Sports Car",hot_hatch:"Hot Hatch",lightweight:"Lightweight","1960s":"1960s","1970s":"1970s","1980s":"1980s","1990s":"1990s","2000s":"2000s","2010s":"2010s","2020s":"2020s"},de=[{id:"class",tags:["formula","gt3","gt2","gt4","cup","prototype","rally"]},{id:"tier",tags:["hypercar","supercar","sports_car","hot_hatch","lightweight"]},{id:"era",tags:["1960s","1970s","1980s","1990s","2000s","2010s","2020s"]}];function We(s){for(const r of de)if(r.tags.includes(s))return r.id;return"other"}function pe(s,r){if(r.size===0)return!0;const n={};for(const t of r){const i=We(t);n[i]||(n[i]=[]),n[i].push(t)}for(const t of Object.values(n))if(!t.some(i=>s.includes(i)))return!1;return!0}function xe(s,r){const[n,t]=N.useState(new Set),i=s!==void 0,a=i?s:n,o=N.useCallback(x=>{const c=new Set(a);c.has(x)?c.delete(x):c.add(x),i&&r?r(c):t(c)},[a,i,r]),l=N.useCallback(()=>{i&&r?r(new Set):t(new Set)},[i,r]);return{activeTags:a,toggle:o,clear:l}}function K(s){const[r,n]=N.useState(s),t=N.useCallback(i=>{n(a=>a.key===i?{key:i,dir:a.dir==="asc"?"desc":"asc"}:{key:i,dir:i.includes("timestamp")||i.includes("Date")?"desc":"asc"})},[]);return[r,t]}function H(s,r,n){return[...s].sort((t,i)=>{const a=n(t,r.key),o=n(i,r.key);if(a==null&&o==null)return 0;if(a==null)return 1;if(o==null)return-1;const l=typeof a=="string"?a.localeCompare(o):a-o;return r.dir==="desc"?-l:l})}function ue(s,r=!1){const n=r?s==null?void 0:s.filter(t=>t.isValid):s;return n!=null&&n.length?{s1:Math.min(...n.map(t=>t.sector1Ms).filter(Boolean)),s2:Math.min(...n.map(t=>t.sector2Ms).filter(Boolean)),s3:Math.min(...n.map(t=>t.sector3Ms).filter(Boolean))}:null}function Ge({active:s,dir:r}){return s?r==="asc"?e.jsx("svg",{className:"pvx-sort-icon",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 15.75l7.5-7.5 7.5 7.5"})}):e.jsx("svg",{className:"pvx-sort-icon",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})}):e.jsx("svg",{className:"pvx-sort-icon pvx-sort-icon--inactive",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 9l4-4 4 4M16 15l-4 4-4-4"})})}function w({label:s,sortKey:r,config:n,onSort:t,className:i=""}){return e.jsx("th",{className:`pvx-th pvx-th--sortable ${i}`,onClick:()=>t(r),children:e.jsxs("span",{className:"pvx-th-inner",children:[s,e.jsx(Ge,{active:n.key===r,dir:n.dir})]})})}function Q({userId:s,getUserDisplay:r}){const{displayName:n,avatarUrl:t}=r(s);return e.jsxs("span",{className:"pvx-driver",children:[t?e.jsx("img",{src:t,alt:"",className:"pvx-driver-avatar"}):e.jsx("span",{className:"pvx-driver-avatar pvx-driver-avatar--placeholder"}),e.jsx("span",{className:"pvx-driver-name",children:n})]})}function ee({rank:s,podium:r=!1}){const n=r?s===1?"pvx-rank pvx-rank--gold":s===2?"pvx-rank pvx-rank--silver":s===3?"pvx-rank pvx-rank--bronze":"pvx-rank":"pvx-rank";return e.jsx("span",{className:n,children:s})}function me({availableTags:s,activeTags:r,onToggle:n,onClear:t}){if(!s||s.length<2)return null;const i=de.map(a=>({id:a.id,tags:a.tags.filter(o=>s.includes(o))})).filter(a=>a.tags.length>0);return e.jsxs("div",{className:"pvx-tag-bar",children:[e.jsx("button",{onClick:t,className:`pvx-tag ${r.size===0?"pvx-tag--active":""}`,children:"All"}),i.map((a,o)=>e.jsxs("span",{className:"contents",children:[o>0&&e.jsx("span",{className:"pvx-tag-separator"}),a.tags.map(l=>e.jsx("button",{onClick:()=>n(l),className:`pvx-tag ${r.has(l)?"pvx-tag--active":""}`,children:Oe[l]||l},l))]},a.id))]})}function se({segments:s}){return e.jsx("nav",{className:"pvx-breadcrumb","aria-label":"Breadcrumb",children:e.jsx("ol",{className:"pvx-breadcrumb-list",children:s.map((r,n)=>{const t=n===s.length-1;return e.jsxs("li",{className:"pvx-breadcrumb-item",children:[n>0&&e.jsx("svg",{className:"pvx-breadcrumb-chevron",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})}),!t&&r.onClick?e.jsx("button",{onClick:r.onClick,className:"pvx-breadcrumb-link",children:r.label}):e.jsx("span",{className:"pvx-breadcrumb-current",children:r.label})]},r.key)})})})}function U({message:s}){return e.jsxs("div",{className:"pvx-empty",children:[e.jsx("svg",{className:"pvx-empty-icon",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("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"})}),e.jsx("p",{children:s})]})}function A(){return e.jsx("div",{className:"pvx-loading",children:"Loading..."})}function ze(){return e.jsx("svg",{className:"pvx-icon pvx-icon--valid",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}function Ye(){return e.jsx("svg",{className:"pvx-icon pvx-icon--invalid",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}function Je({tracks:s,isLoading:r,carMetadata:n,getUserDisplay:t,onTrackSelect:i,tags:a,onTagChange:o}){const[l,x]=K({key:"record.timestamp",dir:"desc"}),{activeTags:c,toggle:u,clear:g}=xe(a,o),h=N.useMemo(()=>{var j;if(!((j=n==null?void 0:n.tags)!=null&&j.length))return[];const p=new Set;for(const m of s||[])m.recordByTag&&Object.keys(m.recordByTag).forEach(v=>p.add(v));return n.tags.filter(m=>p.has(m))},[s,n]),d=N.useMemo(()=>s?c.size===0?s:s.map(p=>{var v,k;if(!p.recordByTag)return null;let j=null;const m=new Set;for(const C of Object.values(p.recordByTag)){if(m.has(C.carId))continue;m.add(C.carId);const T=((k=(v=n==null?void 0:n.cars)==null?void 0:v[C.carId])==null?void 0:k.tags)||["sports_car"];pe(T,c)&&(!j||C.lapTimeMs<j.lapTimeMs)&&(j=C)}return j?{...p,record:{visibleId:j.steamId||j.identifier,carId:j.carId,carDisplayName:S(j.carId),lapTimeMs:j.lapTimeMs,timestamp:j.recordedAt}}:null}).filter(Boolean):[],[s,c,n]),f=N.useMemo(()=>H(d,l,(p,j)=>{var m,v;switch(j){case"displayName":return p.displayName;case"record.lapTimeMs":return(m=p.record)==null?void 0:m.lapTimeMs;case"driverCount":return p.driverCount||0;case"carCount":return p.carCount||0;case"record.timestamp":default:return(v=p.record)!=null&&v.timestamp?new Date(p.record.timestamp).getTime():0}}),[d,l]);return r?e.jsx(A,{}):s!=null&&s.length?e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx("h2",{className:"pvx-card-title",children:"Track Records"})}),e.jsx(me,{availableTags:h,activeTags:c,onToggle:u,onClear:g}),e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx(w,{label:"Track",sortKey:"displayName",config:l,onSort:x}),e.jsx("th",{className:"pvx-th",children:"Record Holder"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Car"}),e.jsx(w,{label:"Lap Time",sortKey:"record.lapTimeMs",config:l,onSort:x}),e.jsx(w,{label:"Drivers",sortKey:"driverCount",config:l,onSort:x,className:"pvx-hidden-below-md"}),e.jsx(w,{label:"Cars",sortKey:"carCount",config:l,onSort:x,className:"pvx-hidden-below-lg"}),e.jsx(w,{label:"Date",sortKey:"record.timestamp",config:l,onSort:x,className:"pvx-hidden-below-xl"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:f.map(p=>{var j,m,v;return e.jsxs("tr",{className:"pvx-row pvx-row--clickable",onClick:()=>i(p.id,p.layout),children:[e.jsx("td",{className:"pvx-td pvx-td--primary",children:p.displayName}),e.jsx("td",{className:"pvx-td",children:(j=p.record)!=null&&j.visibleId?e.jsx(Q,{userId:p.record.visibleId,getUserDisplay:t}):"-"}),e.jsx("td",{className:"pvx-td pvx-hidden-below-lg",children:((m=p.record)==null?void 0:m.carDisplayName)||"-"}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:p.record?$(p.record.lapTimeMs):"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-md",children:p.driverCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",children:p.carCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-xl",children:(v=p.record)!=null&&v.timestamp?P(p.record.timestamp):"-"})]},`${p.id}|${p.layout||""}`)})})]})})]}):e.jsx(U,{message:"No lap times recorded yet."})}function Ze({entries:s,isLoading:r,track:n,carMetadata:t,getUserDisplay:i,onCarSelect:a,onNavigate:o,tags:l,onTagChange:x}){const[c,u]=K({key:"lapTimeMs",dir:"asc"}),{activeTags:g,toggle:h,clear:d}=xe(l,x),f=N.useMemo(()=>{var k,C,T;if(!s||!((k=t==null?void 0:t.tags)!=null&&k.length))return[];const v=new Set;for(const L of s)(((T=(C=t.cars)==null?void 0:C[L.carId])==null?void 0:T.tags)||["sports_car"]).forEach(Ue=>v.add(Ue));return t.tags.filter(L=>v.has(L))},[s,t]),p=N.useMemo(()=>s?g.size===0?s:s.filter(v=>{var C,T;const k=((T=(C=t==null?void 0:t.cars)==null?void 0:C[v.carId])==null?void 0:T.tags)||["sports_car"];return pe(k,g)}):[],[s,g,t]),j=N.useMemo(()=>H(p,c,(v,k)=>{switch(k){case"carId":return S(v.carId);case"driverCount":return v.driverCount||0;case"lapTimeMs":default:return v.lapTimeMs}}),[p,c]),m=[{key:"tracks",label:"Tracks",onClick:()=>o("tracks")},{key:"track",label:n.displayName}];return r?e.jsx(A,{}):e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx(se,{segments:m})}),e.jsx(me,{availableTags:f,activeTags:g,onToggle:h,onClear:d}),s!=null&&s.length?e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"#"}),e.jsx(w,{label:"Car",sortKey:"carId",config:c,onSort:u}),e.jsx("th",{className:"pvx-th",children:"Record Holder"}),e.jsx(w,{label:"Lap Time",sortKey:"lapTimeMs",config:c,onSort:u}),e.jsx(w,{label:"Drivers",sortKey:"driverCount",config:c,onSort:u,className:"pvx-hidden-below-md"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Date"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:j.map((v,k)=>e.jsxs("tr",{className:"pvx-row pvx-row--clickable",onClick:()=>a(v.carId),children:[e.jsx("td",{className:"pvx-td",children:e.jsx(ee,{rank:k+1,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:S(v.carId)}),e.jsx("td",{className:"pvx-td",children:e.jsx(Q,{userId:v.steamId||v.userId,getUserDisplay:i})}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:$(v.lapTimeMs)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-md",children:v.driverCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-lg",children:v.recordedAt?P(v.recordedAt):"-"})]},v.carId))})]})}):e.jsx(U,{message:"No lap times for this track yet."})]})}function Xe({entries:s,isLoading:r,track:n,carId:t,getUserDisplay:i,onDriverSelect:a,onNavigate:o,highlightId:l}){const[x,c]=K({key:"lapTimeMs",dir:"asc"}),u=N.useMemo(()=>ue(s),[s]),g=N.useMemo(()=>H(s||[],x,(d,f)=>{switch(f){case"userId":return i(d.steamId||d.userId).displayName;case"lapCount":return d.lapCount||0;case"lapTimeMs":default:return d.lapTimeMs}}),[s,x,i]),h=[{key:"tracks",label:"Tracks",onClick:()=>o("tracks")},{key:"track",label:n.displayName,onClick:()=>o("track")},{key:"car",label:S(t)}];return r?e.jsx(A,{}):e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx(se,{segments:h})}),s!=null&&s.length?e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"#"}),e.jsx(w,{label:"Driver",sortKey:"userId",config:x,onSort:c}),e.jsx(w,{label:"Lap Time",sortKey:"lapTimeMs",config:x,onSort:c}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S1"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S2"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S3"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Tyre"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-xl",children:"Fuel"}),e.jsx(w,{label:"Laps",sortKey:"lapCount",config:x,onSort:c,className:"pvx-hidden-below-lg"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-xl",children:"Date"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:g.map((d,f)=>{const p=f+1,j=d.steamId||d.userId,m=u&&d.sector1Ms===u.s1,v=u&&d.sector2Ms===u.s2,k=u&&d.sector3Ms===u.s3,C=l&&j===l;return e.jsxs("tr",{className:`pvx-row pvx-row--clickable ${C?"pvx-row--highlight":p<=3?"pvx-row--podium":""}`,onClick:()=>a(j),children:[e.jsx("td",{className:"pvx-td",children:e.jsx(ee,{rank:p,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:e.jsx(Q,{userId:j,getUserDisplay:i})}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:$(d.lapTimeMs)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${m?"pvx-td--best-sector":""}`,children:M(d.sector1Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${v?"pvx-td--best-sector":""}`,children:M(d.sector2Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${k?"pvx-td--best-sector":""}`,children:M(d.sector3Ms)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",title:z(d.tyreCompound),children:d.tyreCompound||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-xl",children:d.startingFuelL?`${d.startingFuelL}L`:"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",children:d.lapCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-xl",children:d.recordedAt?P(d.recordedAt):"-"})]},j)})})]})}):e.jsx(U,{message:"No lap times for this car yet."})]})}function es({userId:s,track:r,carId:n,game:t,gameVersion:i,showInvalid:a,getUserDisplay:o,onToggleInvalid:l,onNavigate:x}){const{data:c,driverName:u,isLoading:g}=ie(s,r.id,r.layout,n,{showInvalid:a,game:t,gameVersion:i}),{displayName:h,avatarUrl:d}=o(s,u),f=N.useMemo(()=>ue(c,!0),[c]),p=N.useMemo(()=>{const m=(c==null?void 0:c.filter(v=>v.isValid))||[];return m.length?Math.min(...m.map(v=>v.lapTimeMs)):null},[c]),j=[{key:"tracks",label:"Tracks",onClick:()=>x("tracks")},{key:"track",label:r.displayName,onClick:()=>x("track")},{key:"car",label:S(n),onClick:()=>x("car")},{key:"driver",label:h}];return g?e.jsx(A,{}):e.jsxs("div",{className:"pvx-card",children:[e.jsxs("div",{className:"pvx-card-header pvx-card-header--split",children:[e.jsxs("div",{className:"pvx-card-header-left",children:[e.jsx(se,{segments:j}),d?e.jsx("img",{src:d,alt:"",className:"pvx-driver-avatar pvx-driver-avatar--lg"}):e.jsx("span",{className:"pvx-driver-avatar pvx-driver-avatar--lg pvx-driver-avatar--placeholder"})]}),e.jsxs("label",{className:"pvx-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:a,onChange:l,className:"pvx-checkbox"}),e.jsx("span",{children:"Show invalid laps"})]})]}),c!=null&&c.length?e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"#"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-md",children:"Lap"}),e.jsx("th",{className:"pvx-th",children:"Lap Time"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S1"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S2"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S3"}),e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"Valid"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Tyre"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Fuel"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-xl",children:"Date"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:c.map((m,v)=>{const k=m.isValid&&m.lapTimeMs===p,C=f&&m.isValid&&m.sector1Ms===f.s1,T=f&&m.isValid&&m.sector2Ms===f.s2,L=f&&m.isValid&&m.sector3Ms===f.s3;let E="pvx-row";return m.isValid||(E+=" pvx-row--invalid"),k&&(E+=" pvx-row--personal-best"),e.jsxs("tr",{className:E,children:[e.jsx("td",{className:"pvx-td",children:e.jsx("span",{className:`pvx-rank ${k?"pvx-rank--gold":""}`,children:v+1})}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-md",children:m.lapNumber||"-"}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:$(m.lapTimeMs)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${C?"pvx-td--best-sector":""}`,children:M(m.sector1Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${T?"pvx-td--best-sector":""}`,children:M(m.sector2Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${L?"pvx-td--best-sector":""}`,children:M(m.sector3Ms)}),e.jsx("td",{className:"pvx-td",title:m.isValid?void 0:m.invalidReason||"Invalid",children:m.isValid?e.jsx(ze,{}):e.jsx(Ye,{})}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",title:z(m.tyreCompound),children:m.tyreCompound||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",children:m.startingFuelL?`${m.startingFuelL}L`:"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-xl",children:P(m.timestamp)})]},m.id)})})]})}):e.jsx(U,{message:a?"No laps recorded for this combination.":'No valid laps. Try enabling "Show invalid laps".'})]})}function ss({drivers:s,isLoading:r,getUserDisplay:n,game:t,gameVersion:i,onComboSelect:a}){const[o,l]=K({key:"rank",dir:"asc"}),[x,c]=N.useState(null),u=N.useMemo(()=>s?H(s,o,(h,d)=>{switch(d){case"rating":return h.rating;case"comboCount":return h.comboCount||0;case"distinctCars":return h.distinctCars||0;case"rank":default:return h.rank}}):[],[s,o]);if(r)return e.jsx(A,{});if(!(s!=null&&s.length))return e.jsx("div",{className:"pvx-card",children:e.jsx(U,{message:"Not enough data for rankings yet."})});const g=5;return e.jsxs("div",{className:"pvx-card",children:[e.jsxs("div",{className:"pvx-card-header pvx-rankings-header",children:[e.jsx("h2",{className:"pvx-card-title",children:"Driver Rankings"}),e.jsxs("div",{className:"pvx-rankings-info-trigger",children:[e.jsx("svg",{className:"pvx-rankings-info-icon",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"})}),e.jsxs("div",{className:"pvx-rankings-info-tooltip",children:[e.jsx("p",{className:"pvx-rankings-info-title",children:"How ratings work"}),e.jsxs("ul",{className:"pvx-rankings-info-list",children:[e.jsx("li",{children:"For each car/track combo with 3+ drivers, you're ranked by lap time and given a percentile (100 = fastest, 0 = slowest)"}),e.jsx("li",{children:"Your rating is a weighted average across all your combos — bigger fields count more"}),e.jsx("li",{children:"A confidence adjustment rewards car diversity: the more different cars you drive competitively, the closer your rating reflects your true score"}),e.jsx("li",{children:"Minimum 2 qualifying combos required"})]})]})]})]}),e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx(w,{label:"#",sortKey:"rank",config:o,onSort:l,className:"pvx-th--narrow"}),e.jsx("th",{className:"pvx-th",children:"Driver"}),e.jsx(w,{label:"Rating",sortKey:"rating",config:o,onSort:l}),e.jsx(w,{label:"Cars",sortKey:"distinctCars",config:o,onSort:l,className:"pvx-hidden-below-sm"}),e.jsx(w,{label:"Combos",sortKey:"comboCount",config:o,onSort:l,className:"pvx-hidden-below-sm"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:u.map(h=>{const d=x===h.identifier;return e.jsx(rs,{driver:h,getUserDisplay:n,isExpanded:d,onToggle:()=>c(d?null:h.identifier),colCount:g,game:t,gameVersion:i,onComboSelect:a},h.identifier)})})]})})]})}function rs({driver:s,getUserDisplay:r,isExpanded:n,onToggle:t,colCount:i,game:a,gameVersion:o,onComboSelect:l}){const x=s.identifier;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:`pvx-row pvx-row--clickable ${s.rank<=3?"pvx-row--podium":""}`,onClick:t,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(ee,{rank:s.rank,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:e.jsx(Q,{userId:x,getUserDisplay:r})}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:s.rating.toFixed(1)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-sm",children:s.distinctCars||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-sm",children:e.jsxs("span",{className:"pvx-rankings-combo-count",children:[s.comboCount,e.jsx("svg",{className:`pvx-rankings-chevron ${n?"pvx-rankings-chevron--open":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]})})]}),n&&s.combos&&e.jsx("tr",{children:e.jsx("td",{colSpan:i,className:"pvx-rankings-combos-cell",children:e.jsx("div",{className:"pvx-rankings-combos",children:s.combos.map((c,u)=>{const g=c.layout?`${c.trackId}|${c.layout}`:c.trackId,h=l?()=>l({track:g,car:c.carId,highlight:x,game:a,gameVersion:o}):void 0;return e.jsxs("div",{className:`pvx-rankings-combo ${h?"pvx-rankings-combo--clickable":""}`,onClick:h,role:h?"button":void 0,children:[e.jsxs("div",{className:"pvx-rankings-combo-info",children:[e.jsx("p",{className:"pvx-rankings-combo-track",children:I(c.trackId,c.layout,a)}),e.jsx("p",{className:"pvx-rankings-combo-car",children:S(c.carId)})]}),e.jsxs("div",{className:"pvx-rankings-combo-stats",children:[e.jsx("p",{className:"pvx-rankings-combo-time",children:$(c.lapTimeMs)}),e.jsxs("p",{className:`pvx-rankings-combo-pct ${c.percentile>=75?"pvx-rankings-combo-pct--high":c.percentile>=50?"pvx-rankings-combo-pct--mid":c.percentile>=25?"pvx-rankings-combo-pct--low":"pvx-rankings-combo-pct--bottom"}`,children:[c.percentile.toFixed(0),"%",e.jsxs("span",{className:"pvx-rankings-combo-rank",children:["(",c.rank,"/",c.totalDrivers,")"]})]})]})]},u)})})})})]})}const ts={GBR:"🇬🇧",DEU:"🇩🇪",NLD:"🇳🇱",SWE:"🇸🇪",ESP:"🇪🇸",ZAF:"🇿🇦",FRA:"🇫🇷",ITA:"🇮🇹",USA:"🇺🇸",AUS:"🇦🇺",BRA:"🇧🇷",JPN:"🇯🇵",CAN:"🇨🇦",POL:"🇵🇱",AUT:"🇦🇹",BEL:"🇧🇪",PRT:"🇵🇹",NOR:"🇳🇴",DNK:"🇩🇰",FIN:"🇫🇮",IRL:"🇮🇪",CHE:"🇨🇭",NZL:"🇳🇿",MEX:"🇲🇽",ARG:"🇦🇷",CZE:"🇨🇿",HUN:"🇭🇺",RUS:"🇷🇺",TUR:"🇹🇷",KOR:"🇰🇷"},ve=["🥇","🥈","🥉"],ns={championship:"Championship",series:"Series",event:"Event"},re=["PRACTICE","QUALIFYING","RACE"];function he({position:s}){const r=s===1?"pvx-rank pvx-rank--gold":s===2?"pvx-rank pvx-rank--silver":s===3?"pvx-rank pvx-rank--bronze":"pvx-rank";return e.jsx("span",{className:r,children:s})}function ge({nation:s}){const r=s&&ts[s];return r?e.jsx("span",{className:"pvx-nation-flag",title:s,children:r}):null}function as({sessions:s,activeSession:r,onSelect:n}){if(!s||s.length<=1)return null;const t=[...s].sort((i,a)=>re.indexOf(i.type)-re.indexOf(a.type));return e.jsx("div",{className:"pvx-session-tabs",children:t.map(i=>e.jsx("button",{onClick:()=>n(i.type),className:`pvx-session-tab ${r===i.type?"pvx-session-tab--active":""}`,children:i.type},i.type))})}function je({type:s}){return e.jsx("span",{className:`pvx-comp-badge pvx-comp-badge--${s}`,children:ns[s]||s})}function F({children:s,variant:r="default"}){return e.jsx("span",{className:`pvx-info-pill ${r!=="default"?`pvx-info-pill--${r}`:""}`,children:s})}function is(s){if(!s)return"TBD";const r=new Date(s);if(isNaN(r))return"TBD";const n=r.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"}),t=r.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} • ${t}`}function os(s){return s.reduce((r,n)=>{var t;return(t=n.splits)!=null&&t.length?r?r.map((i,a)=>{const o=n.splits[a];return o&&o<i?o:i}):[...n.splits]:r},null)}function B({message:s="Loading..."}){return e.jsx("div",{className:"pvx-loading",children:s})}function D({message:s="No data available."}){return e.jsx("div",{className:"pvx-empty",children:e.jsx("p",{children:s})})}function cs({competitions:s,isLoading:r,onSelect:n,onRegister:t,className:i}){return r?e.jsx(B,{message:"Loading competitions..."}):s!=null&&s.length?e.jsx("div",{className:`pvx-comp-grid ${i||""}`,children:s.map(a=>e.jsx(fe,{comp:a,onSelect:n,onRegister:t||n},a.id))}):e.jsx(D,{message:"No competitions available."})}function fe({comp:s,onSelect:r,onRegister:n}){var p,j,m;const{cdnUrl:t}=y(),i=s.posterCdnPath?`${t}/${s.posterCdnPath}`:null,a=s.registration,o=(a==null?void 0:a.currentCount)||0,l=a==null?void 0:a.maxParticipants,x=l&&o>=l,c=(a==null?void 0:a.deadline)&&new Date(a.deadline)<new Date,u=(a==null?void 0:a.isOpen)&&!c&&!x,g=new Date,h=(p=s.rounds)==null?void 0:p.find(v=>v.startTime&&new Date(v.startTime)>=g),d=((j=s.rounds)==null?void 0:j.length)||0,f=((m=s.rounds)==null?void 0:m.filter(v=>v.isFinalized).length)||0;return e.jsxs("div",{className:"pvx-comp-card",onClick:()=>r(s.id),role:"button",tabIndex:0,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),r(s.id))},children:[e.jsx("div",{className:"pvx-comp-card-poster",children:i?e.jsx("img",{src:i,alt:s.name,className:"pvx-comp-card-poster-img"}):e.jsx("div",{className:"pvx-comp-card-poster-placeholder",children:e.jsx(ds,{})})}),e.jsxs("div",{className:"pvx-comp-card-body",children:[e.jsx("h3",{className:"pvx-comp-card-title",children:s.name}),s.description&&e.jsx("p",{className:"pvx-comp-card-desc",children:s.description}),e.jsxs("div",{className:"pvx-comp-card-pills",children:[e.jsx(je,{type:s.type}),s.game&&e.jsx(F,{children:s.game.toUpperCase()}),s.formatDescription&&s.formatDescription.split(", ").map((v,k)=>e.jsx(F,{variant:"format",children:v},k))]}),s.carsDescription&&e.jsx("div",{className:"pvx-comp-card-pills",children:s.carsDescription.split(", ").map((v,k)=>e.jsx(F,{children:v},k))}),e.jsxs("div",{className:"pvx-comp-card-schedule",children:[h?e.jsxs("span",{className:"pvx-comp-card-schedule-next",children:[e.jsx("span",{className:"pvx-comp-card-schedule-label",children:"Next:"})," ","R",h.roundNumber," ",h.track||"TBD"," — ",is(h.startTime)]}):d>0?e.jsxs("span",{className:"pvx-comp-card-schedule-next",children:[f,"/",d," rounds completed"]}):null,d>0&&e.jsxs("span",{className:"pvx-comp-card-round-count",children:[d," round",d!==1?"s":""]})]}),a&&e.jsx(ls,{competitionId:s.id,regOpen:u,isFull:x,deadlinePassed:c,regCount:o,regMax:l,onRegister:n})]})]})}function ls({competitionId:s,regOpen:r,isFull:n,deadlinePassed:t,regCount:i,regMax:a,onRegister:o}){const{isPowerMode:l}=_(),x=V(s),{data:c}=q(s),u=(c==null?void 0:c.isRegistered)||!1,g=a?i/a*100:0,h=g>=100?"full":g>=75?"warning":"ok";return e.jsxs("div",{className:"pvx-comp-card-reg",children:[e.jsx("div",{className:"pvx-comp-card-reg-info",children:e.jsxs("span",{className:`pvx-reg-capacity pvx-reg-capacity--${h}`,children:[i,"/",a||"∞"," drivers"]})}),e.jsx("div",{className:"pvx-comp-card-reg-action",children:u?e.jsx("button",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--registered",onClick:d=>{d.stopPropagation(),o(s)},children:"✓ Registered"}):r?l?e.jsx("button",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--open",onClick:d=>{d.stopPropagation(),o(s)},children:"Register"}):e.jsx("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--open",onClick:d=>d.stopPropagation(),children:"Register"}):e.jsx("span",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--closed",children:n?"Full":"Closed"})})]})}function ds(){return e.jsxs("svg",{className:"pvx-comp-trophy-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6"}),e.jsx("path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18"}),e.jsx("path",{d:"M4 22h16"}),e.jsx("path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22"}),e.jsx("path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22"}),e.jsx("path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z"})]})}function ps({competitionId:s,className:r}){var l,x;const{data:n,isLoading:t}=ce(s),{data:i,isLoading:a}=oe(s);if(t||a)return e.jsx(B,{message:"Loading standings..."});if(!((l=n==null?void 0:n.standings)!=null&&l.length))return e.jsx(D,{message:"No standings data yet. Results will appear once rounds are finalised."});const o=((x=i==null?void 0:i.rounds)==null?void 0:x.filter(c=>c.isFinalized))||[];return e.jsxs("div",{className:`pvx-card ${r||""}`,children:[e.jsx("div",{className:"pvx-card-header--split",children:e.jsxs("div",{className:"pvx-card-header-left",children:[e.jsx("h3",{className:"pvx-card-title",children:"Championship Standings"}),e.jsxs("span",{className:"pvx-standings-subtitle",children:["After ",n.roundsCompleted," round",n.roundsCompleted!==1?"s":"",n.countingRounds>0&&` (best ${n.countingRounds} count)`]})]})}),e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"Pos"}),e.jsx("th",{className:"pvx-th",children:"Driver"}),e.jsx("th",{className:"pvx-th pvx-th--center pvx-hidden-below-sm",children:"W"}),e.jsx("th",{className:"pvx-th pvx-th--center pvx-hidden-below-sm",children:"Pod"}),e.jsx("th",{className:"pvx-th pvx-th--center",children:"Points"}),o.map(c=>e.jsxs("th",{className:"pvx-th pvx-th--center pvx-hidden-below-md",title:c.track||`Round ${c.roundNumber}`,children:["R",c.roundNumber]},c.roundNumber))]})}),e.jsx("tbody",{className:"pvx-tbody",children:n.standings.map(c=>e.jsx(xs,{driver:c,finalizedRounds:o},c.driverId||c.driverName))})]})})]})}function xs({driver:s,finalizedRounds:r}){var o,l,x;const n=s.position<=3,t=new Map(((o=s.roundResults)==null?void 0:o.map(c=>[c.roundNumber,c]))||[]),i=((l=s.roundResults)==null?void 0:l.filter(c=>c.position===1).length)||0,a=((x=s.roundResults)==null?void 0:x.filter(c=>c.position<=3).length)||0;return e.jsxs("tr",{className:`pvx-row ${n?"pvx-row--podium":""}`,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(he,{position:s.position})}),e.jsxs("td",{className:"pvx-td pvx-td--primary",children:[e.jsx(ge,{nation:s.nation}),s.driverName]}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-sm",children:i||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-sm",children:a||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-standings-total",children:s.totalPoints}),r.map(c=>{const u=t.get(c.roundNumber),g=u==null?void 0:u.dropped;return e.jsx("td",{className:`pvx-td pvx-td--center pvx-hidden-below-md ${!g&&(u==null?void 0:u.position)<=3?"pvx-standings-cell--podium":""}`,children:u?e.jsxs("div",{className:`pvx-standings-round-cell ${g?"pvx-standings-round-cell--dropped":""}`,children:[e.jsxs("span",{className:"pvx-standings-round-pos",children:["P",u.position]}),e.jsx("span",{className:"pvx-standings-round-pts",children:u.points})]}):e.jsx("span",{className:"pvx-td--muted",children:"-"})},c.roundNumber)})]})}function us({competitionId:s,roundNumber:r,className:n}){var x;const{data:t,isLoading:i}=le(s,r);if(i)return e.jsx(B,{message:"Loading results..."});if(!t)return e.jsx(D,{message:"No results for this round."});const o=(t.sessions||[]).find(c=>c.type==="RACE"),l=(x=o==null?void 0:o.results)==null?void 0:x.filter(c=>c.position<=3).sort((c,u)=>c.position-u.position);return e.jsxs("div",{className:`pvx-round-results ${n||""}`,children:[e.jsxs("div",{className:"pvx-round-results-header",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"pvx-round-results-title",children:["Round ",t.roundNumber,t.track?`: ${t.track}`:""]}),t.startTime&&e.jsx("p",{className:"pvx-round-results-date",children:new Date(t.startTime).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})})]}),(l==null?void 0:l.length)>0&&e.jsx("div",{className:"pvx-round-podium-summary",children:l.map(c=>e.jsxs("span",{className:"pvx-round-podium-item",children:[e.jsx("span",{children:ve[c.position-1]}),e.jsx("span",{children:c.driverName})]},c.driverId))})]}),e.jsx(Ne,{round:t})]})}function Ne({round:s,className:r}){var l,x;const[n,t]=N.useState(null),i=(s==null?void 0:s.sessions)||[];if(!i.length)return e.jsx(D,{message:"No session data for this round."});const a=n||((l=i.find(c=>c.type==="RACE"))==null?void 0:l.type)||((x=i[0])==null?void 0:x.type),o=i.find(c=>c.type===a)||i[0];return e.jsxs("div",{className:r||"",children:[e.jsx(as,{sessions:i,activeSession:a,onSelect:t}),e.jsx(ms,{session:o})]})}function ms({session:s}){var t;const r=s.type==="RACE";if(!((t=s.results)!=null&&t.length))return e.jsx(D,{message:`No results for ${s.type}.`});const n=os(s.results);return e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"Pos"}),e.jsx("th",{className:"pvx-th",children:"Driver"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Car"}),e.jsx("th",{className:"pvx-th",children:"Best Lap"}),r&&e.jsxs(e.Fragment,{children:[e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Laps"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Time / Gap"}),e.jsx("th",{className:"pvx-th pvx-th--center",children:"Points"})]})]})}),e.jsx("tbody",{className:"pvx-tbody",children:s.results.map((i,a)=>e.jsx(vs,{result:i,isRace:r,fastestSplits:n,rowIndex:a},i.driverId||a))})]})})}function vs({result:s,isRace:r,fastestSplits:n,rowIndex:t}){const i=s.position<=3;return e.jsxs("tr",{className:`pvx-row ${i?"pvx-row--podium":""}`,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(he,{position:s.position})}),e.jsxs("td",{className:"pvx-td pvx-td--primary",children:[e.jsx(ge,{nation:s.nation}),s.driverName,s.carNumber!=null&&e.jsxs("span",{className:"pvx-car-number",children:["#",s.carNumber]}),s.penalty&&e.jsx("span",{className:"pvx-penalty",children:s.penalty})]}),e.jsx("td",{className:"pvx-td pvx-hidden-below-sm",children:S(s.carId)}),e.jsx("td",{className:"pvx-td pvx-td--mono",children:e.jsx(hs,{bestLap:s.bestLapFormatted,hasBestLap:s.hasBestLap,splits:s.splits,fastestSplits:n,showAbove:t<=1})}),r&&e.jsxs(e.Fragment,{children:[e.jsx("td",{className:"pvx-td pvx-hidden-below-sm",children:s.lapsCompleted}),e.jsx("td",{className:"pvx-td pvx-td--mono pvx-td--muted pvx-hidden-below-sm",children:s.position===1?s.totalTime||"-":s.gap||"-"}),e.jsxs("td",{className:"pvx-td pvx-td--center",children:[e.jsx("span",{className:"pvx-session-points",children:s.points}),s.pointsOverride!==0&&s.pointsOverride&&e.jsxs("span",{className:"pvx-points-override",children:["(",s.pointsOverride>0?"+":"",s.pointsOverride,")"]})]})]})]})}function hs({bestLap:s,hasBestLap:r,splits:n,fastestSplits:t,showAbove:i}){return s?e.jsxs("span",{className:`pvx-best-lap-cell ${r?"pvx-best-lap-cell--fastest":""}`,children:[e.jsx("span",{className:"pvx-best-lap-time",children:s}),(n==null?void 0:n.length)>0&&e.jsx("span",{className:"pvx-splits-tooltip-anchor",children:e.jsx("span",{className:`pvx-splits-tooltip ${i?"":"pvx-splits-tooltip--above"}`,children:n.map((a,o)=>{const l=t&&a===t[o];return e.jsxs("span",{className:"pvx-splits-tooltip-row",children:[e.jsxs("span",{className:"pvx-splits-tooltip-label",children:["S",o+1]}),e.jsx("span",{className:l?"pvx-splits-tooltip-best":"",children:a})]},o)})})})]}):e.jsx("span",{className:"pvx-td--muted",children:"-"})}function gs({competitionId:s,className:r}){const{getSteamId:n}=y(),{data:t,isLoading:i}=J(s),a=n();if(i)return e.jsx(B,{message:"Loading drivers..."});const o=(t==null?void 0:t.drivers)||(t==null?void 0:t.entries)||[];return o.length?e.jsx("div",{className:`pvx-entry-grid ${r||""}`,children:o.map(l=>{var c,u;const x=a&&l.steamId===a;return e.jsxs("div",{className:`pvx-entry-card ${x?"pvx-entry-card--you":""}`,children:[l.avatarUrl?e.jsx("img",{src:l.avatarUrl,alt:"",className:"pvx-entry-avatar"}):e.jsx("div",{className:"pvx-entry-avatar pvx-entry-avatar--placeholder",children:((u=(c=l.displayName)==null?void 0:c.charAt(0))==null?void 0:u.toUpperCase())||"?"}),e.jsxs("span",{className:"pvx-entry-name",children:[l.displayName,x&&e.jsx("span",{className:"pvx-entry-you",children:" (you)"})]})]},l.steamId||l.driverId)})}):e.jsx(D,{message:"No drivers registered yet."})}function js({competitionId:s,driverData:r,className:n,children:t}){const{data:i,isLoading:a}=q(s),{isPowerMode:o}=_(),l=V(s),x=Z(s),c=X(s),u=(i==null?void 0:i.isRegistered)||!1,g=a||x.isPending||c.isPending,h=x.error||c.error||null,d=()=>{o&&x.mutate(r||{})},f=()=>{o&&c.mutate()};return typeof t=="function"?t({isRegistered:u,isLoading:g,register:d,withdraw:f,error:h,isPowerMode:o,registrationUrl:l}):o?e.jsx("button",{className:`pvx-comp-register-btn ${n||""}`,onClick:u?f:d,disabled:g,children:g?"Loading...":u?"Withdraw":"Register"}):e.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:`pvx-comp-register-link ${n||""}`,children:u?"View Registration":"Register on PitVox"})}function fs({competitionId:s,registration:r,onWithdrawSuccess:n,className:t}){const{getSteamId:i}=y(),{isPowerMode:a}=_(),o=V(s),{data:l,isLoading:x}=q(s),{data:c,isLoading:u}=J(s),g=Z(s),h=X(s),d=i(),f=(l==null?void 0:l.isRegistered)||!1,p=(c==null?void 0:c.drivers)||(c==null?void 0:c.entries)||[],j=r||{},m=p.length||j.currentCount||0,v=j.maxParticipants&&m>=j.maxParticipants,k=j.deadline&&new Date(j.deadline)<new Date,C=j.isOpen&&!k&&!v;return x||u?e.jsx(B,{message:"Loading registration..."}):f?e.jsx("div",{className:`pvx-reg-panel ${t||""}`,children:e.jsx(bs,{competitionId:s,drivers:p,steamId:d,isPowerMode:a,registrationUrl:o,withdrawMutation:h,onWithdrawSuccess:n,registration:j})}):C?d?a?e.jsx("div",{className:`pvx-reg-panel ${t||""}`,children:e.jsx(Ns,{competitionId:s,registerMutation:g,registration:j})}):e.jsx("div",{className:`pvx-reg-panel ${t||""}`,children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-register-link",children:"Register on PitVox"})}):e.jsx("div",{className:`pvx-reg-panel ${t||""}`,children:a?e.jsx("div",{className:"pvx-reg-status-msg",children:"Sign in to register for this competition."}):e.jsx("div",{className:"pvx-reg-status-msg",children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-register-link",children:"Register on PitVox"})})}):e.jsxs("div",{className:`pvx-reg-panel ${t||""}`,children:[e.jsx("div",{className:"pvx-reg-status-msg",children:v?"Registration is full.":k?"Registration deadline has passed.":"Registration is closed."}),p.length>0&&e.jsx(be,{drivers:p,steamId:d})]})}function Ns({competitionId:s,registerMutation:r,registration:n}){const[t,i]=N.useState(""),[a,o]=N.useState("intermediate"),[l,x]=N.useState(""),c=d=>{d.preventDefault(),r.mutate({discordUsername:t||void 0,experience:a,comments:l||void 0})},u=n||{},g=u.currentCount||0,h=u.maxParticipants;return e.jsxs("form",{className:"pvx-reg-form",onSubmit:c,children:[e.jsxs("div",{className:"pvx-reg-form-header",children:[e.jsx("h3",{className:"pvx-reg-form-title",children:"Register"}),h&&e.jsx(ye,{count:g,max:h})]}),r.error&&e.jsx("div",{className:"pvx-reg-error",children:r.error.message||"Registration failed"}),e.jsxs("div",{className:"pvx-reg-field",children:[e.jsxs("label",{className:"pvx-reg-label",htmlFor:`pvx-discord-${s}`,children:["Discord Username ",e.jsx("span",{className:"pvx-reg-optional",children:"(optional)"})]}),e.jsx("input",{id:`pvx-discord-${s}`,type:"text",className:"pvx-reg-input",placeholder:"e.g. username",value:t,onChange:d=>i(d.target.value)})]}),e.jsxs("div",{className:"pvx-reg-field",children:[e.jsx("label",{className:"pvx-reg-label",htmlFor:`pvx-exp-${s}`,children:"Experience Level"}),e.jsxs("select",{id:`pvx-exp-${s}`,className:"pvx-reg-select",value:a,onChange:d=>o(d.target.value),children:[e.jsx("option",{value:"beginner",children:"Beginner"}),e.jsx("option",{value:"intermediate",children:"Intermediate"}),e.jsx("option",{value:"advanced",children:"Advanced"})]})]}),e.jsxs("div",{className:"pvx-reg-field",children:[e.jsxs("label",{className:"pvx-reg-label",htmlFor:`pvx-comments-${s}`,children:["Comments ",e.jsx("span",{className:"pvx-reg-optional",children:"(optional)"})]}),e.jsx("textarea",{id:`pvx-comments-${s}`,className:"pvx-reg-textarea",rows:3,placeholder:"Anything the organisers should know?",value:l,onChange:d=>x(d.target.value)})]}),e.jsx("div",{className:"pvx-reg-actions",children:e.jsx("button",{type:"submit",className:"pvx-comp-register-btn",disabled:r.isPending,children:r.isPending?"Registering...":"Register"})})]})}function bs({competitionId:s,drivers:r,steamId:n,isPowerMode:t,registrationUrl:i,withdrawMutation:a,onWithdrawSuccess:o,registration:l}){const[x,c]=N.useState(!1),u=()=>{a.mutate(void 0,{onSuccess:()=>{c(!1),o&&o()}})},g=l||{},h=r.length||g.currentCount||0,d=g.maxParticipants;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pvx-reg-form-header",children:[e.jsx("h3",{className:"pvx-reg-form-title",children:"Registered Drivers"}),d&&e.jsx(ye,{count:h,max:d})]}),e.jsx(be,{drivers:r,steamId:n}),a.error&&e.jsx("div",{className:"pvx-reg-error",children:a.error.message||"Withdrawal failed"}),t?e.jsx("div",{className:"pvx-reg-actions",children:x?e.jsxs("div",{className:"pvx-reg-confirm",children:[e.jsx("p",{className:"pvx-reg-confirm-text",children:"Are you sure you want to unregister?"}),e.jsxs("div",{className:"pvx-reg-confirm-actions",children:[e.jsx("button",{type:"button",className:"pvx-reg-cancel-btn",onClick:()=>c(!1),children:"Cancel"}),e.jsx("button",{type:"button",className:"pvx-reg-danger-btn",onClick:u,disabled:a.isPending,children:a.isPending?"Unregistering...":"Yes, Unregister"})]})]}):e.jsx("button",{type:"button",className:"pvx-reg-unregister-btn",onClick:()=>c(!0),children:"Unregister"})}):e.jsx("div",{className:"pvx-reg-actions",children:e.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-register-link",children:"Manage on PitVox"})})]})}function be({drivers:s,steamId:r}){if(!s.length)return e.jsx("div",{className:"pvx-reg-no-drivers",children:"No drivers registered yet."});const n=[...s].sort((t,i)=>{const a=r&&t.steamId===r?-1:0,o=r&&i.steamId===r?-1:0;return a-o});return e.jsx("div",{className:"pvx-reg-driver-list",children:n.map(t=>{var a,o;const i=r&&t.steamId===r;return e.jsxs("div",{className:`pvx-reg-driver-row ${i?"pvx-reg-driver-row--you":""}`,children:[t.avatarUrl?e.jsx("img",{src:t.avatarUrl,alt:"",className:"pvx-reg-driver-avatar"}):e.jsx("div",{className:"pvx-reg-driver-avatar pvx-reg-driver-avatar--placeholder",children:((o=(a=t.displayName)==null?void 0:a.charAt(0))==null?void 0:o.toUpperCase())||"?"}),e.jsxs("span",{className:"pvx-reg-driver-name",children:[t.displayName,i&&e.jsx("span",{className:"pvx-entry-you",children:" (you)"})]})]},t.steamId||t.driverId)})})}function ye({count:s,max:r}){const n=r?s/r*100:0,t=n>=100?"full":n>=75?"warning":"ok";return e.jsxs("span",{className:`pvx-reg-capacity pvx-reg-capacity--${t}`,children:[s,"/",r," drivers"]})}function ke(s){const{cdnUrl:r}=y(),n=b.useQuery({queryKey:["pitvox","laps","global",s],queryFn:()=>R(r,`laps/${s}.json`),enabled:!!s,staleTime:3e4,refetchInterval:3e4}),t=n.data;return{isLoading:n.isLoading,error:n.error,data:t?{driverName:t.driverName||"Driver",lapCount:t.lapCount||0,trackBreakdown:t.trackBreakdown||[],carBreakdown:t.carBreakdown||[],recordsHeld:t.recordsHeld||0,currentRecords:t.currentRecords||[],bestRanking:t.bestRanking??null,bestRankingTrackId:t.bestRankingTrackId??null,bestRankingLayout:t.bestRankingLayout??null,bestRankingCarId:t.bestRankingCarId??null,generatedAt:t.generatedAt}:null}}function Ce(s={}){const{cdnUrl:r,partnerSlug:n}=y(),{gameVersion:t,enabled:i=!0}=s,a=t?`leaderboards/partners/${n}/v/${t}/ratings.json`:`leaderboards/partners/${n}/ratings.json`;return b.useQuery({queryKey:["pitvox","ratings",n,t||null],queryFn:()=>R(r,a),staleTime:3e4,refetchInterval:3e4,enabled:i})}function we(s){var t;const r=Ce(),n=N.useMemo(()=>{var i;return!((i=r.data)!=null&&i.drivers)||!s?null:r.data.drivers.find(a=>a.identifier===s)||null},[(t=r.data)==null?void 0:t.drivers,s]);return{isLoading:r.isLoading,error:r.error,data:n?{rating:n.rating,rank:n.rank,totalDrivers:r.data.driverCount||r.data.drivers.length,comboCount:n.comboCount||0,distinctCars:n.distinctCars||0,combos:n.combos||[]}:null}}function ys(s={}){const r=Ce(s);return{data:r.data||null,isLoading:r.isLoading,error:r.error}}function Re(){const{cdnUrl:s,partnerSlug:r,getSteamId:n,onFetchServerPassword:t}=y(),i=n(),{data:a,isLoading:o}=b.useQuery({queryKey:["pitvox","competitions",r],queryFn:async()=>{const d=await R(s,"competitions/index.json");return d!=null&&d.competitions?d.competitions.filter(f=>f.partnerSlug===r):[]},staleTime:6e4}),l=(a==null?void 0:a.map(d=>d.id))||[],x=b.useQueries({queries:l.map(d=>({queryKey:["pitvox","competition",r,d,"entrylist"],queryFn:()=>R(s,`competitions/${r}/${d}/entrylist.json`),enabled:!!i&&l.length>0,staleTime:6e4}))}),c=x.some(d=>d.isLoading),u=N.useMemo(()=>{var p,j;if(!a||!i||c)return[];const d=new Date,f=[];for(let m=0;m<a.length;m++){const v=a[m],k=(p=x[m])==null?void 0:p.data;if(!((j=k==null?void 0:k.drivers)==null?void 0:j.some(L=>L.steamId===i)))continue;const T=v.rounds||[];for(const L of T)L.isFinalized||!L.startTime||new Date(L.startTime)<=d||f.push({competitionId:v.id,competitionName:v.name,roundNumber:L.roundNumber,track:L.track||"TBD",startTime:L.startTime})}return f.sort((m,v)=>new Date(m.startTime)-new Date(v.startTime)),f.length>0&&(f[0].isNext=!0),f},[a,i,c,x]),g=b.useQueries({queries:u.map(d=>({queryKey:["pitvox","serverInfo",d.competitionId,d.roundNumber],queryFn:()=>t(d.competitionId,d.roundNumber),enabled:!!t&&u.length>0,staleTime:5*6e4,retry:!1}))});return{data:N.useMemo(()=>u.length?t?u.map((d,f)=>{var j;const p=(j=g[f])==null?void 0:j.data;return p!=null&&p.success?{...d,serverAddress:p.serverAddress||null,serverPassword:p.serverPassword||null}:d}):u:[],[u,t,g]),isLoading:o||!!i&&c}}function Le(){const{onFetchNotifications:s}=y();return!!s}function Se(s={}){const{onFetchNotifications:r,partnerSlug:n}=y(),{limit:t=20,unreadOnly:i=!1}=s;return b.useQuery({queryKey:["pitvox","notifications",n,{limit:t,unreadOnly:i}],queryFn:()=>r({limit:t,unreadOnly:i}),enabled:!!r,staleTime:3e4,refetchInterval:3e4})}function ks(){const{onFetchNotifications:s,partnerSlug:r}=y(),{data:n,isLoading:t}=b.useQuery({queryKey:["pitvox","notifications",r,{limit:1,unreadOnly:!1}],queryFn:()=>s({limit:1}),enabled:!!s,staleTime:3e4,refetchInterval:3e4,select:i=>(i==null?void 0:i.unreadCount)??0});return{count:n??0,isLoading:t}}function Te(){const{onMarkNotificationRead:s,partnerSlug:r}=y(),n=b.useQueryClient();return b.useMutation({mutationFn:t=>{if(!s)throw new Error("No onMarkNotificationRead callback provided to PitVoxPartnerProvider.");return s(t)},onSuccess:(t,i)=>{n.setQueriesData({queryKey:["pitvox","notifications",r]},a=>a!=null&&a.notifications?{...a,unreadCount:Math.max(0,(a.unreadCount||0)-1),notifications:a.notifications.map(o=>o.id===i?{...o,isRead:!0,readAt:new Date().toISOString()}:o)}:a)}})}function Me(){const{onMarkAllNotificationsRead:s,partnerSlug:r}=y(),n=b.useQueryClient();return b.useMutation({mutationFn:()=>{if(!s)throw new Error("No onMarkAllNotificationsRead callback provided to PitVoxPartnerProvider.");return s()},onSuccess:()=>{n.setQueriesData({queryKey:["pitvox","notifications",r]},t=>t!=null&&t.notifications?{...t,unreadCount:0,notifications:t.notifications.map(i=>({...i,isRead:!0,readAt:i.readAt||new Date().toISOString()}))}:t)}})}function $e({driverName:s,avatarUrl:r,memberSince:n,className:t=""}){const i=n?new Date(n).toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric"}):null;return e.jsxs("div",{className:`pvx-card pvx-dash-profile ${t}`,children:[r?e.jsx("img",{src:r,alt:"",className:"pvx-dash-profile-avatar"}):e.jsx("div",{className:"pvx-dash-profile-avatar pvx-dash-profile-avatar--placeholder",children:(s||"?")[0].toUpperCase()}),e.jsxs("div",{className:"pvx-dash-profile-info",children:[e.jsx("h2",{className:"pvx-dash-profile-name",children:s}),i&&e.jsxs("p",{className:"pvx-dash-profile-since",children:["Racing since ",i]})]})]})}function Cs(){return e.jsxs("svg",{className:"pvx-dash-stat-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),e.jsx("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),e.jsx("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),e.jsx("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function ws(){return e.jsxs("svg",{className:"pvx-dash-stat-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"}),e.jsx("path",{d:"M12 14v4"}),e.jsx("path",{d:"M10.5 12.5l-4 2.5"}),e.jsx("path",{d:"M13.5 12.5l4 2.5"})]})}function Rs(){return e.jsx("svg",{className:"pvx-dash-stat-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("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"})})}function te({icon:s,value:r,label:n,items:t,labelKey:i,countKey:a}){const[o,l]=N.useState(!1),x=N.useRef(null);N.useEffect(()=>{if(!o)return;function u(g){x.current&&!x.current.contains(g.target)&&l(!1)}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[o]);const c=t!=null&&t.length?t.slice().sort((u,g)=>g[a]-u[a]):null;return e.jsxs("div",{ref:x,className:`pvx-dash-stat-card ${c?"pvx-dash-stat-card--clickable":""}`,onClick:c?()=>l(u=>!u):void 0,children:[s,e.jsxs("div",{className:"pvx-dash-stat-content",children:[e.jsx("span",{className:"pvx-dash-stat-value",children:r}),e.jsx("span",{className:"pvx-dash-stat-label",children:n})]}),c&&e.jsx("div",{className:`pvx-dash-tooltip pvx-dash-tooltip--scrollable ${o?"pvx-dash-tooltip--open":""}`,children:c.map((u,g)=>e.jsxs("div",{className:"pvx-dash-tooltip-row",children:[e.jsx("span",{className:"pvx-dash-tooltip-label",children:u[i]}),e.jsx("span",{className:"pvx-dash-tooltip-value",children:u[a]})]},g))})]})}function De({stats:s,rating:r,className:n=""}){if(!s)return null;const t=s.trackBreakdown.map(a=>({name:I(a.trackId,a.layout),lapCount:a.lapCount})),i=s.carBreakdown.map(a=>({name:S(a.carId),lapCount:a.lapCount}));return e.jsxs("div",{className:`pvx-dash-stats ${n}`,children:[e.jsx(te,{icon:e.jsx(Cs,{}),value:s.lapCount.toLocaleString(),label:"Total Laps",items:t,labelKey:"name",countKey:"lapCount"}),e.jsx(te,{icon:e.jsx(ws,{}),value:s.carBreakdown.length,label:"Cars Used",items:i,labelKey:"name",countKey:"lapCount"}),r&&e.jsxs("div",{className:"pvx-dash-stat-card pvx-dash-stat-card--rating",children:[e.jsx(Rs,{}),e.jsxs("div",{className:"pvx-dash-stat-content",children:[e.jsx("span",{className:"pvx-dash-stat-value",children:r.rating.toFixed(1)}),e.jsx("span",{className:"pvx-dash-stat-label",children:"Driver Rating"}),e.jsxs("span",{className:"pvx-dash-stat-sub",children:["#",r.rank," of ",r.totalDrivers]})]})]})]})}function Ie({records:s,className:r=""}){const n=N.useMemo(()=>s!=null&&s.length?s.slice().sort((t,i)=>{const a=t.recordedAt?new Date(t.recordedAt).getTime():0;return(i.recordedAt?new Date(i.recordedAt).getTime():0)-a}):[],[s]);return n.length?e.jsxs("div",{className:`pvx-card ${r}`,children:[e.jsx("div",{className:"pvx-card-header",children:e.jsxs("h3",{className:"pvx-card-title",children:[e.jsx("span",{className:"pvx-dash-records-icon",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 9H4.5a2.5 2.5 0 010-5H6"}),e.jsx("path",{d:"M18 9h1.5a2.5 2.5 0 000-5H18"}),e.jsx("path",{d:"M4 22h16"}),e.jsx("path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20 7 22"}),e.jsx("path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20 17 22"}),e.jsx("path",{d:"M18 2H6v7a6 6 0 0012 0V2z"})]})}),"Current Records",e.jsxs("span",{className:"pvx-dash-records-count",children:["(",n.length,")"]})]})}),e.jsx("div",{className:"pvx-dash-records-list",children:n.map((t,i)=>e.jsxs("div",{className:"pvx-dash-record-row",children:[e.jsxs("div",{className:"pvx-dash-record-info",children:[e.jsx("span",{className:"pvx-dash-record-track",children:I(t.trackId,t.layout,t.game)}),e.jsx("span",{className:"pvx-dash-record-car",children:S(t.carId)})]}),e.jsxs("div",{className:"pvx-dash-record-time",children:[e.jsx("span",{className:"pvx-dash-record-lap",children:$(t.lapTimeMs)}),e.jsxs("span",{className:`pvx-dash-game-badge pvx-dash-game-badge--${t.game||"evo"}`,children:[(t.game||"evo").toUpperCase(),t.gameVersion?` ${t.gameVersion}`:""]})]})]},i))})]}):null}function Pe({events:s,isLoading:r,className:n,limit:t=3}){if(r)return e.jsx("div",{className:"pvx-loading",children:"Loading upcoming events..."});if(!(s!=null&&s.length))return null;const i=t?s.slice(0,t):s,a=s.length-i.length;return e.jsxs("div",{className:`pvx-card ${n||""}`,children:[e.jsx("div",{className:"pvx-card-header",children:e.jsxs("h3",{className:"pvx-card-title",children:[e.jsx(Ts,{}),"Upcoming Events",e.jsxs("span",{className:"pvx-dash-records-count",children:["(",s.length,")"]})]})}),e.jsxs("div",{className:"pvx-upcoming-list",children:[i.map(o=>e.jsxs("div",{className:`pvx-upcoming-item ${o.isNext?"pvx-upcoming-item--next":""}`,children:[e.jsxs("div",{className:"pvx-upcoming-info",children:[e.jsx("span",{className:"pvx-upcoming-comp",children:o.competitionName}),e.jsxs("span",{className:"pvx-upcoming-round",children:["Round ",o.roundNumber,": ",o.track]}),o.serverPassword&&e.jsx(Ls,{password:o.serverPassword,address:o.serverAddress})]}),e.jsxs("div",{className:"pvx-upcoming-time",children:[e.jsx("span",{className:"pvx-upcoming-date",children:new Date(o.startTime).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}),e.jsx("span",{className:"pvx-upcoming-relative",children:Ss(o.startTime)}),o.isNext&&e.jsx("span",{className:"pvx-upcoming-badge",children:"Next"})]})]},`${o.competitionId}-${o.roundNumber}`)),a>0&&e.jsxs("div",{className:"pvx-upcoming-remaining",children:["+",a," more event",a!==1?"s":""]})]})]})}function Ls({password:s,address:r}){const[n,t]=N.useState(!1),[i,a]=N.useState(!1),o=r?s?`join:${r}|${s}`:`join:${r}`:null,l=N.useCallback(async()=>{if(o)try{await navigator.clipboard.writeText(o),t(!0),setTimeout(()=>t(!1),2e3)}catch{}},[o]);return e.jsxs("div",{className:"pvx-server-info",children:[o&&e.jsxs("span",{className:"pvx-server-detail pvx-server-detail--clickable",onClick:l,title:"Copy join string to clipboard",children:[e.jsx($s,{})," ",n?"Copied!":"Join"]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"pvx-server-detail pvx-server-detail--clickable",onClick:()=>a(x=>!x),title:i?"Hide password":"Reveal password",children:i?e.jsx(Is,{}):e.jsx(Ds,{})}),i&&e.jsxs("span",{className:"pvx-server-detail",children:[e.jsx(Ms,{})," ",s]})]})]})}function Ss(s){const r=new Date(s).getTime()-Date.now();if(r<=0)return"Now";const n=Math.floor(r/(1e3*60*60));if(n<1)return"Less than 1 hour";if(n<24)return`in ${n}h`;const t=Math.floor(n/24);if(t===1)return"Tomorrow";if(t<7)return`in ${t} days`;if(t<30){const i=Math.floor(t/7);return`in ${i} week${i!==1?"s":""}`}return G(s)}function Ts(){return e.jsxs("svg",{className:"pvx-dash-records-icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M16 2v4M8 2v4M3 10h18"})]})}function Ms(){return e.jsxs("svg",{className:"pvx-server-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function $s(){return e.jsxs("svg",{className:"pvx-server-icon pvx-server-icon--action",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function Ds(){return e.jsxs("svg",{className:"pvx-server-icon pvx-server-icon--action",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function Is(){return e.jsxs("svg",{className:"pvx-server-icon pvx-server-icon--action",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"}),e.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Be({notifications:s,unreadCount:r=0,onMarkRead:n,onMarkAllRead:t,isLoading:i,className:a}){const o=Y();return i?e.jsx("div",{className:"pvx-loading",children:"Loading notifications..."}):e.jsxs("div",{className:`pvx-card ${a||""}`,children:[e.jsxs("div",{className:"pvx-card-header",children:[e.jsxs("h3",{className:"pvx-card-title",children:[e.jsx(Us,{}),"Notifications",r>0&&e.jsx("span",{className:"pvx-notif-badge",children:r>99?"99+":r})]}),r>0&&t&&e.jsx("button",{className:"pvx-notif-mark-all",onClick:t,children:"Mark all read"})]}),s!=null&&s.length?e.jsx("div",{className:"pvx-notif-list",children:s.map(l=>e.jsx(Ps,{notification:l,getUserDisplay:o,onMarkRead:n},l.id))}):e.jsx("div",{className:"pvx-notif-empty",children:"No notifications"})]})}function Ps({notification:s,getUserDisplay:r,onMarkRead:n}){const t=()=>{!s.isRead&&n&&n(s.id)};return e.jsxs("button",{className:`pvx-notif-item ${s.isRead?"":"pvx-notif-item--unread"}`,onClick:t,children:[e.jsx(Bs,{type:s.type}),e.jsxs("div",{className:"pvx-notif-content",children:[e.jsx("span",{className:"pvx-notif-message",children:ne(s,r)}),e.jsx("span",{className:"pvx-notif-time",children:G(s.createdAt)})]}),!s.isRead&&e.jsx("span",{className:"pvx-notif-dot"})]})}function Bs({type:s}){return s==="RECORD_BEATEN"?e.jsx("span",{className:"pvx-notif-icon pvx-notif-icon--beaten",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m7 7 10 10M17 7v10H7"})})}):s==="ADMIN_MESSAGE"?e.jsx("span",{className:"pvx-notif-icon pvx-notif-icon--admin",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"m3 11 18-5v12L3 13v-2z"}),e.jsx("path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6"})]})}):e.jsx("span",{className:"pvx-notif-icon pvx-notif-icon--record",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6"}),e.jsx("path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18"}),e.jsx("path",{d:"M4 22h16"}),e.jsx("path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22"}),e.jsx("path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22"}),e.jsx("path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z"})]})})}function Us(){return e.jsxs("svg",{className:"pvx-dash-records-icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"}),e.jsx("path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0"})]})}function As({steamId:s,avatarUrl:r,memberSince:n,className:t=""}){const{data:i,isLoading:a,error:o}=ke(s),{data:l,isLoading:x}=we(s),{data:c,isLoading:u}=Re(),g=Le(),{data:h,isLoading:d}=Se({limit:10}),f=Te(),p=Me();return a||x?e.jsx("div",{className:"pvx-loading",children:"Loading dashboard..."}):o?e.jsx("div",{className:"pvx-empty",children:"Failed to load dashboard data."}):i?e.jsxs("div",{className:`pvx-dash ${t}`,children:[e.jsx($e,{driverName:i.driverName,avatarUrl:r,memberSince:n}),e.jsx(De,{stats:i,rating:l}),s&&e.jsx(Pe,{events:c,isLoading:u}),e.jsxs("div",{className:`pvx-dash-row ${g?"pvx-dash-row--2col":""}`,children:[e.jsx(Ie,{records:i.currentRecords}),g&&e.jsx(Be,{notifications:h==null?void 0:h.notifications,unreadCount:(h==null?void 0:h.unreadCount)||0,onMarkRead:j=>f.mutate(j),onMarkAllRead:()=>p.mutate(),isLoading:d})]})]}):e.jsx("div",{className:"pvx-empty",children:"No data available yet. Start driving to see your stats!"})}exports.CarsTable=Ze;exports.CompEmptyState=D;exports.CompLoadingState=B;exports.CompetitionCard=fe;exports.CompetitionCards=cs;exports.DriverDashboard=As;exports.DriverProfile=$e;exports.DriversTable=Xe;exports.EntryList=gs;exports.InfoPill=F;exports.LapHistoryTable=es;exports.NotificationsCard=Be;exports.PODIUM_MEDALS=ve;exports.PitVoxPartnerProvider=Fe;exports.RankingsTable=ss;exports.RecordsTable=Ie;exports.RegisterButton=js;exports.RegistrationPanel=fs;exports.RoundResults=us;exports.RoundSessionResults=Ne;exports.StandingsTable=ps;exports.StatsCards=De;exports.TracksTable=Je;exports.TypeBadge=je;exports.UpcomingEvents=Pe;exports.formatCarName=S;exports.formatDate=P;exports.formatDelta=qe;exports.formatLapTime=$;exports.formatNotificationMessage=ne;exports.formatRelativeTime=G;exports.formatSectorTime=M;exports.formatTrackName=I;exports.formatTyreCompound=z;exports.useCarLeaderboard=Ke;exports.useCarMetadata=Ve;exports.useCompetitionAllRounds=Qe;exports.useCompetitionConfig=oe;exports.useCompetitionEntryList=J;exports.useCompetitionRound=le;exports.useCompetitionStandings=ce;exports.useCompetitions=He;exports.useDriverLaps=ie;exports.useDriverRating=we;exports.useDriverRatings=ys;exports.useDriverStats=ke;exports.useLeaderboardIndex=_e;exports.useMarkAllNotificationsRead=Me;exports.useMarkNotificationRead=Te;exports.useNotifications=Se;exports.useNotificationsEnabled=Le;exports.usePitVox=y;exports.useRegister=Z;exports.useRegistrationMode=_;exports.useRegistrationStatus=q;exports.useRegistrationUrl=V;exports.useTrackLeaderboard=ae;exports.useUnreadCount=ks;exports.useUpcomingEvents=Re;exports.useUserLookup=Y;exports.useWithdraw=X;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("react"),y=require("@tanstack/react-query"),G=N.createContext(null),qe="https://cdn.pitvox.com",_e="https://pitvox.com";let W=null;function Ve({partnerSlug:s=null,cdnUrl:r=qe,pitvoxUrl:n=_e,getSteamId:t,onRegister:a,onWithdraw:i,onFetchNotifications:o,onMarkNotificationRead:l,onMarkAllNotificationsRead:p,onFetchServerPassword:c,children:u}){const v=N.useMemo(()=>({partnerSlug:s,cdnUrl:r.replace(/\/$/,""),pitvoxUrl:n.replace(/\/$/,""),getSteamId:t||(()=>null),onRegister:a||null,onWithdraw:i||null,onFetchNotifications:o||null,onMarkNotificationRead:l||null,onMarkAllNotificationsRead:p||null,onFetchServerPassword:c||null}),[s,r,n,t,a,i,o,l,p,c]);let j=!1;try{y.useQueryClient(),j=!0}catch{j=!1}return j?e.jsx(G.Provider,{value:v,children:u}):(W||(W=new y.QueryClient({defaultOptions:{queries:{staleTime:6e4}}})),e.jsx(y.QueryClientProvider,{client:W,children:e.jsx(G.Provider,{value:v,children:u})}))}function k(){const s=N.useContext(G);if(!s)throw new Error("usePitVox must be used within a <PitVoxPartnerProvider>");return s}async function w(s,r){const n=await fetch(`${s}/${r}`);if(!n.ok){if(n.status===404||n.status===403)return null;throw new Error(`CDN fetch failed: ${n.status}`)}return n.json()}function q(s,...r){return[s?`leaderboards/partners/${s}`:"leaderboards",...r].join("/")}function ae(s,r){return s?`laps/partners/${s}/${r}.json`:`laps/${r}.json`}function ie(s){return s?`recent-laps/partners/${s}.json`:"recent-laps.json"}function $(s){if(!s&&s!==0)return"-";const r=Math.floor(s/1e3),n=Math.floor(r/60),t=r%60,a=s%1e3;return`${n}:${String(t).padStart(2,"0")}.${String(a).padStart(3,"0")}`}function M(s){return!s&&s!==0?"-":(s/1e3).toFixed(3)}function S(s){if(!s)return"";let r=s;return r.startsWith("ks_")&&(r=r.slice(3)),r.split("_").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function I(s,r,n){const t=s.split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" "),a=n==="acc"||!n&&(r==null?void 0:r.toLowerCase())==="track config";if(!r||r==="default"||a)return t;const i=r.split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ");return`${t} ${i}`}function P(s){if(!s)return"-";try{return new Date(s).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}catch{return"-"}}function z(s){if(!s)return"";const r=Date.now()-new Date(s).getTime(),n=Math.floor(r/1e3);if(n<60)return"Just now";const t=Math.floor(n/60);if(t<60)return`${t}m ago`;const a=Math.floor(t/60);if(a<24)return`${a}h ago`;const i=Math.floor(a/24);return i<30?`${i}d ago`:P(s)}function Ke(s){return s==null?"":`${s>=0?"+":"-"}${(Math.abs(s)/1e3).toFixed(3)}`}function oe(s,r){const{type:n,title:t,trackId:a,trackLayout:i,carId:o,game:l,data:p}=s,c=typeof p=="string"?JSON.parse(p):p,u=a?I(a,i,l):null,v=o?S(o):null,j=[u,v].filter(Boolean).join(" — ");return n==="RECORD_BEATEN"&&j?`${c!=null&&c.beatenBySteamId&&r?r(c.beatenBySteamId).displayName:"Someone"} beat your record on ${j}`:n==="RECORD_SET"&&j?`You set a new record on ${j}`:t||"New notification"}function J(s){return s?{E:"Eco",RD:"Road",SC:"SuperCar",RV:"Race Vintage",SM:"Semislick",ST:"Street",HR:"Hard Race",MR:"Medium Race",SR:"Soft Race",S:"Soft"}[s]||s:"Unknown"}function He(s={}){var p,c,u,v,j,d;const{cdnUrl:r,partnerSlug:n}=k(),{game:t,gameVersion:a}=s,i=q(n,"index.json"),o=y.useQuery({queryKey:["pitvox","leaderboards",n,"index"],queryFn:()=>w(r,i),staleTime:3e4,refetchInterval:3e4}),l=N.useMemo(()=>{var h;if(!((h=o.data)!=null&&h.tracks))return[];let f=o.data.tracks;return t&&(f=f.filter(x=>x.game===t)),a&&(f=f.filter(x=>x.gameVersion===a)),f.map(x=>({id:x.trackId,layout:x.layout,game:x.game,gameVersion:x.gameVersion,displayName:I(x.trackId,x.layout,x.game),driverCount:x.driverCount||0,carCount:x.carCount||0,record:x.recordHolder?{visibleId:x.recordHolder.steamId||x.recordHolder.userId,carId:x.recordHolder.carId,carDisplayName:S(x.recordHolder.carId),lapTimeMs:x.recordHolder.lapTimeMs,timestamp:x.recordHolder.recordedAt}:null,recordByTag:x.recordByTag||null}))},[(p=o.data)==null?void 0:p.tracks,t,a]);return{...o,data:l,partner:((c=o.data)==null?void 0:c.partner)||null,generatedAt:(u=o.data)==null?void 0:u.generatedAt,totalLaps:((v=o.data)==null?void 0:v.totalLaps)||0,totalUsers:((j=o.data)==null?void 0:j.totalUsers)||0,versions:((d=o.data)==null?void 0:d.versions)||{}}}function ce(s,r,n={}){const{cdnUrl:t,partnerSlug:a}=k(),{carId:i,game:o,gameVersion:l}=n,p=r||"default",c=l?`v/${l}/`:"",u=q(a,`${c}tracks/${s}/${p}.json`),{data:v,isLoading:j,error:d}=y.useQuery({queryKey:["pitvox","leaderboards",a,"track",s,p,l],queryFn:()=>w(t,u),enabled:!!s,staleTime:3e4,refetchInterval:3e4});return{data:N.useMemo(()=>{if(!(v!=null&&v.entries))return[];let h=v.entries;if(o&&(h=h.filter(x=>x.game===o)),!i){const x=new Map,g=new Map;for(const m of h){const b=m.steamId||m.userId;g.has(m.carId)||g.set(m.carId,new Set),g.get(m.carId).add(b),(!x.has(m.carId)||m.lapTimeMs<x.get(m.carId).lapTimeMs)&&x.set(m.carId,m)}return Array.from(x.values()).map(m=>{var b;return{...m,driverCount:((b=g.get(m.carId))==null?void 0:b.size)||0}}).sort((m,b)=>m.lapTimeMs-b.lapTimeMs)}return h.filter(x=>x.carId===i).sort((x,g)=>x.lapTimeMs-g.lapTimeMs)},[v==null?void 0:v.entries,i,o]),isLoading:j,error:d}}function le(s,r,n,t,a={}){var d,f;const{cdnUrl:i,partnerSlug:o}=k(),{showInvalid:l=!1,game:p,gameVersion:c}=a,u=ae(o,s),v=y.useQuery({queryKey:["pitvox","laps",o,s],queryFn:()=>w(i,u),enabled:!!s,staleTime:3e4,refetchInterval:3e4}),j=N.useMemo(()=>{var h;return(h=v.data)!=null&&h.laps?v.data.laps.filter(x=>{if(x.trackId!==r)return!1;if(n){if(x.trackLayout!==n)return!1}else if(x.trackLayout&&x.trackLayout!=="default")return!1;return!(x.carId!==t||p&&x.game!==p||c&&x.gameVersion!==c||!l&&!x.isValid)}).sort((x,g)=>x.lapTimeMs-g.lapTimeMs):[]},[(d=v.data)==null?void 0:d.laps,r,n,t,p,c,l]);return{...v,data:j,driverName:((f=v.data)==null?void 0:f.driverName)||"Driver"}}function Y(){const{cdnUrl:s}=k(),{data:r}=y.useQuery({queryKey:["pitvox","users","index"],queryFn:()=>w(s,"users/index.json"),staleTime:5*6e4,gcTime:30*6e4}),n=(r==null?void 0:r.users)||{};return(t,a)=>{const i=n[t];return{displayName:(i==null?void 0:i.displayName)||a||t||"Unknown",avatarUrl:(i==null?void 0:i.avatarUrl)||null,affiliations:(i==null?void 0:i.affiliations)||[]}}}function Qe(){const{cdnUrl:s}=k(),{data:r}=y.useQuery({queryKey:["pitvox","cars","index"],queryFn:()=>w(s,"cars/index.json"),staleTime:5*6e4,gcTime:30*6e4});return{tags:(r==null?void 0:r.tags)||[],cars:(r==null?void 0:r.cars)||{}}}function Oe(){var a,i;const{cdnUrl:s,partnerSlug:r}=k(),n=ie(r),t=y.useQuery({queryKey:["pitvox","recentLaps",r],queryFn:()=>w(s,n),staleTime:3e4,refetchInterval:3e4,gcTime:10*6e4});return{groups:((a=t.data)==null?void 0:a.groups)||[],generatedAt:((i=t.data)==null?void 0:i.generatedAt)||null,isLoading:t.isLoading}}function We(s,r){return ce(s,null,{carId:r})}function Ge(){const{cdnUrl:s,partnerSlug:r}=k();return y.useQuery({queryKey:["pitvox","competitions",r],queryFn:async()=>{const n=await w(s,"competitions/index.json");return n!=null&&n.competitions?r?n.competitions.filter(t=>t.partnerSlug===r):n.competitions:[]},staleTime:6e4})}function de(s,r={}){const n=k(),t=r.partnerSlug||n.partnerSlug;return y.useQuery({queryKey:["pitvox","competition",t,s,"config"],queryFn:()=>w(n.cdnUrl,`competitions/${t}/${s}/config.json`),enabled:!!t&&!!s,staleTime:6e4})}function pe(s,r={}){const n=k(),t=r.partnerSlug||n.partnerSlug;return y.useQuery({queryKey:["pitvox","competition",t,s,"standings"],queryFn:()=>w(n.cdnUrl,`competitions/${t}/${s}/standings.json`),enabled:!!t&&!!s,staleTime:6e4})}function xe(s,r,n={}){const t=k(),a=n.partnerSlug||t.partnerSlug;return y.useQuery({queryKey:["pitvox","competition",a,s,"round",r],queryFn:()=>w(t.cdnUrl,`competitions/${a}/${s}/rounds/${r}.json`),enabled:!!a&&!!s&&r!=null,staleTime:6e4})}function ze(s,r=[],n={}){const t=k(),a=n.partnerSlug||t.partnerSlug;return y.useQuery({queryKey:["pitvox","competition",a,s,"allRounds",r],queryFn:async()=>(await Promise.all(r.map(o=>w(t.cdnUrl,`competitions/${a}/${s}/rounds/${o}.json`).catch(()=>null)))).filter(Boolean),enabled:!!a&&!!s&&r.length>0,staleTime:6e4})}function Z(s,r={}){const n=k(),t=r.partnerSlug||n.partnerSlug;return y.useQuery({queryKey:["pitvox","competition",t,s,"entrylist"],queryFn:()=>w(n.cdnUrl,`competitions/${t}/${s}/entrylist.json`),enabled:!!t&&!!s,staleTime:6e4})}function _(s){const{cdnUrl:r,partnerSlug:n,getSteamId:t}=k(),a=t();return y.useQuery({queryKey:["pitvox","registration",n,s,a],queryFn:async()=>{var p;const i=await fetch(`${r}/competitions/${n}/${s}/entrylist.json`);if(!i.ok)return{isRegistered:!1,entryList:null};const o=await i.json();return{isRegistered:!!a&&((p=o.drivers)==null?void 0:p.some(c=>c.steamId===a)),entryList:o}},enabled:!!s,staleTime:6e4})}function X(s){const{onRegister:r,partnerSlug:n,getSteamId:t}=k(),a=y.useQueryClient(),i=Y();return y.useMutation({mutationFn:o=>{if(!r)throw new Error("No onRegister callback provided to PitVoxPartnerProvider. Provide onRegister for in-app registration, or use useRegistrationUrl() to link to pitvox.com.");return r(s,o)},onSuccess:()=>{const o=t();if(a.setQueriesData({queryKey:["pitvox","registration",n,s]},l=>l?{...l,isRegistered:!0}:{isRegistered:!0,entryList:null}),o){const l=i(o),p={steamId:o,displayName:l.displayName,avatarUrl:l.avatarUrl};a.setQueriesData({queryKey:["pitvox","competition",n,s,"entrylist"]},c=>{var v;return c?((v=c.drivers)==null?void 0:v.some(j=>j.steamId===o))?c:{...c,drivers:[...c.drivers||[],p]}:{drivers:[p]}})}}})}function ee(s){const{onWithdraw:r,partnerSlug:n,getSteamId:t}=k(),a=y.useQueryClient();return y.useMutation({mutationFn:i=>{if(!r)throw new Error("No onWithdraw callback provided to PitVoxPartnerProvider. Provide onWithdraw for in-app withdrawal, or use useRegistrationUrl() to link to pitvox.com.");const o=i||t();if(!o)throw new Error("No Steam ID available");return r(s,o)},onSuccess:()=>{const i=t();a.setQueriesData({queryKey:["pitvox","registration",n,s]},o=>o?{...o,isRegistered:!1}:{isRegistered:!1,entryList:null}),i&&a.setQueriesData({queryKey:["pitvox","competition",n,s,"entrylist"]},o=>o!=null&&o.drivers?{...o,drivers:o.drivers.filter(l=>l.steamId!==i)}:o)}})}function V(){const{onRegister:s,onWithdraw:r}=k(),n=!!(s&&r);return{isPowerMode:n,isBasicMode:!n}}function K(s){const{pitvoxUrl:r,partnerSlug:n}=k();return`${r}/p/${n}/competitions/${s}/register`}const Je={formula:"Formula",gt3:"GT3",gt2:"GT2",gt4:"GT4",cup:"Cup",prototype:"Prototype",rally:"Rally",hypercar:"Hypercar",supercar:"Supercar",sports_car:"Sports Car",hot_hatch:"Hot Hatch",lightweight:"Lightweight","1960s":"1960s","1970s":"1970s","1980s":"1980s","1990s":"1990s","2000s":"2000s","2010s":"2010s","2020s":"2020s"},ue=[{id:"class",tags:["formula","gt3","gt2","gt4","cup","prototype","rally"]},{id:"tier",tags:["hypercar","supercar","sports_car","hot_hatch","lightweight"]},{id:"era",tags:["1960s","1970s","1980s","1990s","2000s","2010s","2020s"]}];function Ye(s){for(const r of ue)if(r.tags.includes(s))return r.id;return"other"}function me(s,r){if(r.size===0)return!0;const n={};for(const t of r){const a=Ye(t);n[a]||(n[a]=[]),n[a].push(t)}for(const t of Object.values(n))if(!t.some(a=>s.includes(a)))return!1;return!0}function ve(s,r){const[n,t]=N.useState(new Set),a=s!==void 0,i=a?s:n,o=N.useCallback(p=>{const c=new Set(i);c.has(p)?c.delete(p):c.add(p),a&&r?r(c):t(c)},[i,a,r]),l=N.useCallback(()=>{a&&r?r(new Set):t(new Set)},[a,r]);return{activeTags:i,toggle:o,clear:l}}function H(s){const[r,n]=N.useState(s),t=N.useCallback(a=>{n(i=>i.key===a?{key:a,dir:i.dir==="asc"?"desc":"asc"}:{key:a,dir:a.includes("timestamp")||a.includes("Date")?"desc":"asc"})},[]);return[r,t]}function Q(s,r,n){return[...s].sort((t,a)=>{const i=n(t,r.key),o=n(a,r.key);if(i==null&&o==null)return 0;if(i==null)return 1;if(o==null)return-1;const l=typeof i=="string"?i.localeCompare(o):i-o;return r.dir==="desc"?-l:l})}function he(s,r=!1){const n=r?s==null?void 0:s.filter(t=>t.isValid):s;return n!=null&&n.length?{s1:Math.min(...n.map(t=>t.sector1Ms).filter(Boolean)),s2:Math.min(...n.map(t=>t.sector2Ms).filter(Boolean)),s3:Math.min(...n.map(t=>t.sector3Ms).filter(Boolean))}:null}function Ze({active:s,dir:r}){return s?r==="asc"?e.jsx("svg",{className:"pvx-sort-icon",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 15.75l7.5-7.5 7.5 7.5"})}):e.jsx("svg",{className:"pvx-sort-icon",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})}):e.jsx("svg",{className:"pvx-sort-icon pvx-sort-icon--inactive",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 9l4-4 4 4M16 15l-4 4-4-4"})})}function L({label:s,sortKey:r,config:n,onSort:t,className:a=""}){return e.jsx("th",{className:`pvx-th pvx-th--sortable ${a}`,onClick:()=>t(r),children:e.jsxs("span",{className:"pvx-th-inner",children:[s,e.jsx(Ze,{active:n.key===r,dir:n.dir})]})})}function O({userId:s,getUserDisplay:r}){const{displayName:n,avatarUrl:t}=r(s);return e.jsxs("span",{className:"pvx-driver",children:[t?e.jsx("img",{src:t,alt:"",className:"pvx-driver-avatar"}):e.jsx("span",{className:"pvx-driver-avatar pvx-driver-avatar--placeholder"}),e.jsx("span",{className:"pvx-driver-name",children:n})]})}function se({rank:s,podium:r=!1}){const n=r?s===1?"pvx-rank pvx-rank--gold":s===2?"pvx-rank pvx-rank--silver":s===3?"pvx-rank pvx-rank--bronze":"pvx-rank":"pvx-rank";return e.jsx("span",{className:n,children:s})}function ge({availableTags:s,activeTags:r,onToggle:n,onClear:t}){if(!s||s.length<2)return null;const a=ue.map(i=>({id:i.id,tags:i.tags.filter(o=>s.includes(o))})).filter(i=>i.tags.length>0);return e.jsxs("div",{className:"pvx-tag-bar",children:[e.jsx("button",{onClick:t,className:`pvx-tag ${r.size===0?"pvx-tag--active":""}`,children:"All"}),a.map((i,o)=>e.jsxs("span",{className:"contents",children:[o>0&&e.jsx("span",{className:"pvx-tag-separator"}),i.tags.map(l=>e.jsx("button",{onClick:()=>n(l),className:`pvx-tag ${r.has(l)?"pvx-tag--active":""}`,children:Je[l]||l},l))]},i.id))]})}function re({segments:s}){return e.jsx("nav",{className:"pvx-breadcrumb","aria-label":"Breadcrumb",children:e.jsx("ol",{className:"pvx-breadcrumb-list",children:s.map((r,n)=>{const t=n===s.length-1;return e.jsxs("li",{className:"pvx-breadcrumb-item",children:[n>0&&e.jsx("svg",{className:"pvx-breadcrumb-chevron",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})}),!t&&r.onClick?e.jsx("button",{onClick:r.onClick,className:"pvx-breadcrumb-link",children:r.label}):e.jsx("span",{className:"pvx-breadcrumb-current",children:r.label})]},r.key)})})})}function U({message:s}){return e.jsxs("div",{className:"pvx-empty",children:[e.jsx("svg",{className:"pvx-empty-icon",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("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"})}),e.jsx("p",{children:s})]})}function A(){return e.jsx("div",{className:"pvx-loading",children:"Loading..."})}function Xe(){return e.jsx("svg",{className:"pvx-icon pvx-icon--valid",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}function es(){return e.jsx("svg",{className:"pvx-icon pvx-icon--invalid",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}function ss({tracks:s,isLoading:r,carMetadata:n,getUserDisplay:t,onTrackSelect:a,tags:i,onTagChange:o}){const[l,p]=H({key:"record.timestamp",dir:"desc"}),{activeTags:c,toggle:u,clear:v}=ve(i,o),j=N.useMemo(()=>{var x;if(!((x=n==null?void 0:n.tags)!=null&&x.length))return[];const h=new Set;for(const g of s||[])g.recordByTag&&Object.keys(g.recordByTag).forEach(m=>h.add(m));return n.tags.filter(g=>h.has(g))},[s,n]),d=N.useMemo(()=>s?c.size===0?s:s.map(h=>{var m,b;if(!h.recordByTag)return null;let x=null;const g=new Set;for(const C of Object.values(h.recordByTag)){if(g.has(C.carId))continue;g.add(C.carId);const T=((b=(m=n==null?void 0:n.cars)==null?void 0:m[C.carId])==null?void 0:b.tags)||["sports_car"];me(T,c)&&(!x||C.lapTimeMs<x.lapTimeMs)&&(x=C)}return x?{...h,record:{visibleId:x.steamId||x.identifier,carId:x.carId,carDisplayName:S(x.carId),lapTimeMs:x.lapTimeMs,timestamp:x.recordedAt}}:null}).filter(Boolean):[],[s,c,n]),f=N.useMemo(()=>Q(d,l,(h,x)=>{var g,m;switch(x){case"displayName":return h.displayName;case"record.lapTimeMs":return(g=h.record)==null?void 0:g.lapTimeMs;case"driverCount":return h.driverCount||0;case"carCount":return h.carCount||0;case"record.timestamp":default:return(m=h.record)!=null&&m.timestamp?new Date(h.record.timestamp).getTime():0}}),[d,l]);return r?e.jsx(A,{}):s!=null&&s.length?e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx("h2",{className:"pvx-card-title",children:"Track Records"})}),e.jsx(ge,{availableTags:j,activeTags:c,onToggle:u,onClear:v}),e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx(L,{label:"Track",sortKey:"displayName",config:l,onSort:p}),e.jsx("th",{className:"pvx-th",children:"Record Holder"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Car"}),e.jsx(L,{label:"Lap Time",sortKey:"record.lapTimeMs",config:l,onSort:p}),e.jsx(L,{label:"Drivers",sortKey:"driverCount",config:l,onSort:p,className:"pvx-hidden-below-md"}),e.jsx(L,{label:"Cars",sortKey:"carCount",config:l,onSort:p,className:"pvx-hidden-below-lg"}),e.jsx(L,{label:"Date",sortKey:"record.timestamp",config:l,onSort:p,className:"pvx-hidden-below-xl"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:f.map(h=>{var x,g,m;return e.jsxs("tr",{className:"pvx-row pvx-row--clickable",onClick:()=>a(h.id,h.layout),children:[e.jsx("td",{className:"pvx-td pvx-td--primary",children:h.displayName}),e.jsx("td",{className:"pvx-td",children:(x=h.record)!=null&&x.visibleId?e.jsx(O,{userId:h.record.visibleId,getUserDisplay:t}):"-"}),e.jsx("td",{className:"pvx-td pvx-hidden-below-lg",children:((g=h.record)==null?void 0:g.carDisplayName)||"-"}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:h.record?$(h.record.lapTimeMs):"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-md",children:h.driverCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",children:h.carCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-xl",children:(m=h.record)!=null&&m.timestamp?P(h.record.timestamp):"-"})]},`${h.id}|${h.layout||""}`)})})]})})]}):e.jsx(U,{message:"No lap times recorded yet."})}function rs({entries:s,isLoading:r,track:n,carMetadata:t,getUserDisplay:a,onCarSelect:i,onNavigate:o,tags:l,onTagChange:p}){const[c,u]=H({key:"lapTimeMs",dir:"asc"}),{activeTags:v,toggle:j,clear:d}=ve(l,p),f=N.useMemo(()=>{var b,C,T;if(!s||!((b=t==null?void 0:t.tags)!=null&&b.length))return[];const m=new Set;for(const R of s)(((T=(C=t.cars)==null?void 0:C[R.carId])==null?void 0:T.tags)||["sports_car"]).forEach(Fe=>m.add(Fe));return t.tags.filter(R=>m.has(R))},[s,t]),h=N.useMemo(()=>s?v.size===0?s:s.filter(m=>{var C,T;const b=((T=(C=t==null?void 0:t.cars)==null?void 0:C[m.carId])==null?void 0:T.tags)||["sports_car"];return me(b,v)}):[],[s,v,t]),x=N.useMemo(()=>Q(h,c,(m,b)=>{switch(b){case"carId":return S(m.carId);case"driverCount":return m.driverCount||0;case"lapTimeMs":default:return m.lapTimeMs}}),[h,c]),g=[{key:"tracks",label:"Tracks",onClick:()=>o("tracks")},{key:"track",label:n.displayName}];return r?e.jsx(A,{}):e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx(re,{segments:g})}),e.jsx(ge,{availableTags:f,activeTags:v,onToggle:j,onClear:d}),s!=null&&s.length?e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"#"}),e.jsx(L,{label:"Car",sortKey:"carId",config:c,onSort:u}),e.jsx("th",{className:"pvx-th",children:"Record Holder"}),e.jsx(L,{label:"Lap Time",sortKey:"lapTimeMs",config:c,onSort:u}),e.jsx(L,{label:"Drivers",sortKey:"driverCount",config:c,onSort:u,className:"pvx-hidden-below-md"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Date"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:x.map((m,b)=>e.jsxs("tr",{className:"pvx-row pvx-row--clickable",onClick:()=>i(m.carId),children:[e.jsx("td",{className:"pvx-td",children:e.jsx(se,{rank:b+1,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:S(m.carId)}),e.jsx("td",{className:"pvx-td",children:e.jsx(O,{userId:m.steamId||m.userId,getUserDisplay:a})}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:$(m.lapTimeMs)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-md",children:m.driverCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-lg",children:m.recordedAt?P(m.recordedAt):"-"})]},m.carId))})]})}):e.jsx(U,{message:"No lap times for this track yet."})]})}function ts({entries:s,isLoading:r,track:n,carId:t,getUserDisplay:a,onDriverSelect:i,onNavigate:o,highlightId:l}){const[p,c]=H({key:"lapTimeMs",dir:"asc"}),u=N.useMemo(()=>he(s),[s]),v=N.useMemo(()=>Q(s||[],p,(d,f)=>{switch(f){case"userId":return a(d.steamId||d.userId).displayName;case"lapCount":return d.lapCount||0;case"lapTimeMs":default:return d.lapTimeMs}}),[s,p,a]),j=[{key:"tracks",label:"Tracks",onClick:()=>o("tracks")},{key:"track",label:n.displayName,onClick:()=>o("track")},{key:"car",label:S(t)}];return r?e.jsx(A,{}):e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx(re,{segments:j})}),s!=null&&s.length?e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"#"}),e.jsx(L,{label:"Driver",sortKey:"userId",config:p,onSort:c}),e.jsx(L,{label:"Lap Time",sortKey:"lapTimeMs",config:p,onSort:c}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S1"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S2"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S3"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Tyre"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-xl",children:"Fuel"}),e.jsx(L,{label:"Laps",sortKey:"lapCount",config:p,onSort:c,className:"pvx-hidden-below-lg"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-xl",children:"Date"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:v.map((d,f)=>{const h=f+1,x=d.steamId||d.userId,g=u&&d.sector1Ms===u.s1,m=u&&d.sector2Ms===u.s2,b=u&&d.sector3Ms===u.s3,C=l&&x===l;return e.jsxs("tr",{className:`pvx-row pvx-row--clickable ${C?"pvx-row--highlight":h<=3?"pvx-row--podium":""}`,onClick:()=>i(x),children:[e.jsx("td",{className:"pvx-td",children:e.jsx(se,{rank:h,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:e.jsx(O,{userId:x,getUserDisplay:a})}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:$(d.lapTimeMs)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${g?"pvx-td--best-sector":""}`,children:M(d.sector1Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${m?"pvx-td--best-sector":""}`,children:M(d.sector2Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${b?"pvx-td--best-sector":""}`,children:M(d.sector3Ms)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",title:J(d.tyreCompound),children:d.tyreCompound||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-xl",children:d.startingFuelL?`${d.startingFuelL}L`:"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",children:d.lapCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-xl",children:d.recordedAt?P(d.recordedAt):"-"})]},x)})})]})}):e.jsx(U,{message:"No lap times for this car yet."})]})}function ns({userId:s,track:r,carId:n,game:t,gameVersion:a,showInvalid:i,getUserDisplay:o,onToggleInvalid:l,onNavigate:p}){const{data:c,driverName:u,isLoading:v}=le(s,r.id,r.layout,n,{showInvalid:i,game:t,gameVersion:a}),{displayName:j,avatarUrl:d}=o(s,u),f=N.useMemo(()=>he(c,!0),[c]),h=N.useMemo(()=>{const g=(c==null?void 0:c.filter(m=>m.isValid))||[];return g.length?Math.min(...g.map(m=>m.lapTimeMs)):null},[c]),x=[{key:"tracks",label:"Tracks",onClick:()=>p("tracks")},{key:"track",label:r.displayName,onClick:()=>p("track")},{key:"car",label:S(n),onClick:()=>p("car")},{key:"driver",label:j}];return v?e.jsx(A,{}):e.jsxs("div",{className:"pvx-card",children:[e.jsxs("div",{className:"pvx-card-header pvx-card-header--split",children:[e.jsxs("div",{className:"pvx-card-header-left",children:[e.jsx(re,{segments:x}),d?e.jsx("img",{src:d,alt:"",className:"pvx-driver-avatar pvx-driver-avatar--lg"}):e.jsx("span",{className:"pvx-driver-avatar pvx-driver-avatar--lg pvx-driver-avatar--placeholder"})]}),e.jsxs("label",{className:"pvx-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:l,className:"pvx-checkbox"}),e.jsx("span",{children:"Show invalid laps"})]})]}),c!=null&&c.length?e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"#"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-md",children:"Lap"}),e.jsx("th",{className:"pvx-th",children:"Lap Time"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S1"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S2"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S3"}),e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"Valid"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Tyre"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Fuel"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-xl",children:"Date"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:c.map((g,m)=>{const b=g.isValid&&g.lapTimeMs===h,C=f&&g.isValid&&g.sector1Ms===f.s1,T=f&&g.isValid&&g.sector2Ms===f.s2,R=f&&g.isValid&&g.sector3Ms===f.s3;let E="pvx-row";return g.isValid||(E+=" pvx-row--invalid"),b&&(E+=" pvx-row--personal-best"),e.jsxs("tr",{className:E,children:[e.jsx("td",{className:"pvx-td",children:e.jsx("span",{className:`pvx-rank ${b?"pvx-rank--gold":""}`,children:m+1})}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-md",children:g.lapNumber||"-"}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:$(g.lapTimeMs)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${C?"pvx-td--best-sector":""}`,children:M(g.sector1Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${T?"pvx-td--best-sector":""}`,children:M(g.sector2Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${R?"pvx-td--best-sector":""}`,children:M(g.sector3Ms)}),e.jsx("td",{className:"pvx-td",title:g.isValid?void 0:g.invalidReason||"Invalid",children:g.isValid?e.jsx(Xe,{}):e.jsx(es,{})}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",title:J(g.tyreCompound),children:g.tyreCompound||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",children:g.startingFuelL?`${g.startingFuelL}L`:"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-xl",children:P(g.timestamp)})]},g.id)})})]})}):e.jsx(U,{message:i?"No laps recorded for this combination.":'No valid laps. Try enabling "Show invalid laps".'})]})}function as({drivers:s,isLoading:r,getUserDisplay:n,game:t,gameVersion:a,onComboSelect:i}){const[o,l]=H({key:"rank",dir:"asc"}),[p,c]=N.useState(null),u=N.useMemo(()=>s?Q(s,o,(j,d)=>{switch(d){case"rating":return j.rating;case"comboCount":return j.comboCount||0;case"distinctCars":return j.distinctCars||0;case"rank":default:return j.rank}}):[],[s,o]);if(r)return e.jsx(A,{});if(!(s!=null&&s.length))return e.jsx("div",{className:"pvx-card",children:e.jsx(U,{message:"Not enough data for rankings yet."})});const v=5;return e.jsxs("div",{className:"pvx-card",children:[e.jsxs("div",{className:"pvx-card-header pvx-rankings-header",children:[e.jsx("h2",{className:"pvx-card-title",children:"Driver Rankings"}),e.jsxs("div",{className:"pvx-rankings-info-trigger",children:[e.jsx("svg",{className:"pvx-rankings-info-icon",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"})}),e.jsxs("div",{className:"pvx-rankings-info-tooltip",children:[e.jsx("p",{className:"pvx-rankings-info-title",children:"How ratings work"}),e.jsxs("ul",{className:"pvx-rankings-info-list",children:[e.jsx("li",{children:"For each car/track combo with 3+ drivers, you're ranked by lap time and given a percentile (100 = fastest, 0 = slowest)"}),e.jsx("li",{children:"Your rating is a weighted average across all your combos — bigger fields count more"}),e.jsx("li",{children:"A confidence adjustment rewards car diversity: the more different cars you drive competitively, the closer your rating reflects your true score"}),e.jsx("li",{children:"Minimum 2 qualifying combos required"})]})]})]})]}),e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx(L,{label:"#",sortKey:"rank",config:o,onSort:l,className:"pvx-th--narrow"}),e.jsx("th",{className:"pvx-th",children:"Driver"}),e.jsx(L,{label:"Rating",sortKey:"rating",config:o,onSort:l}),e.jsx(L,{label:"Cars",sortKey:"distinctCars",config:o,onSort:l,className:"pvx-hidden-below-sm"}),e.jsx(L,{label:"Combos",sortKey:"comboCount",config:o,onSort:l,className:"pvx-hidden-below-sm"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:u.map(j=>{const d=p===j.identifier;return e.jsx(is,{driver:j,getUserDisplay:n,isExpanded:d,onToggle:()=>c(d?null:j.identifier),colCount:v,game:t,gameVersion:a,onComboSelect:i},j.identifier)})})]})})]})}function is({driver:s,getUserDisplay:r,isExpanded:n,onToggle:t,colCount:a,game:i,gameVersion:o,onComboSelect:l}){const p=s.identifier;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:`pvx-row pvx-row--clickable ${s.rank<=3?"pvx-row--podium":""}`,onClick:t,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(se,{rank:s.rank,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:e.jsx(O,{userId:p,getUserDisplay:r})}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:s.rating.toFixed(1)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-sm",children:s.distinctCars||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-sm",children:e.jsxs("span",{className:"pvx-rankings-combo-count",children:[s.comboCount,e.jsx("svg",{className:`pvx-rankings-chevron ${n?"pvx-rankings-chevron--open":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]})})]}),n&&s.combos&&e.jsx("tr",{children:e.jsx("td",{colSpan:a,className:"pvx-rankings-combos-cell",children:e.jsx("div",{className:"pvx-rankings-combos",children:s.combos.map((c,u)=>{const v=c.layout?`${c.trackId}|${c.layout}`:c.trackId,j=l?()=>l({track:v,car:c.carId,highlight:p,game:i,gameVersion:o}):void 0;return e.jsxs("div",{className:`pvx-rankings-combo ${j?"pvx-rankings-combo--clickable":""}`,onClick:j,role:j?"button":void 0,children:[e.jsxs("div",{className:"pvx-rankings-combo-info",children:[e.jsx("p",{className:"pvx-rankings-combo-track",children:I(c.trackId,c.layout,i)}),e.jsx("p",{className:"pvx-rankings-combo-car",children:S(c.carId)})]}),e.jsxs("div",{className:"pvx-rankings-combo-stats",children:[e.jsx("p",{className:"pvx-rankings-combo-time",children:$(c.lapTimeMs)}),e.jsxs("p",{className:`pvx-rankings-combo-pct ${c.percentile>=75?"pvx-rankings-combo-pct--high":c.percentile>=50?"pvx-rankings-combo-pct--mid":c.percentile>=25?"pvx-rankings-combo-pct--low":"pvx-rankings-combo-pct--bottom"}`,children:[c.percentile.toFixed(0),"%",e.jsxs("span",{className:"pvx-rankings-combo-rank",children:["(",c.rank,"/",c.totalDrivers,")"]})]})]})]},u)})})})})]})}const os={GBR:"🇬🇧",DEU:"🇩🇪",NLD:"🇳🇱",SWE:"🇸🇪",ESP:"🇪🇸",ZAF:"🇿🇦",FRA:"🇫🇷",ITA:"🇮🇹",USA:"🇺🇸",AUS:"🇦🇺",BRA:"🇧🇷",JPN:"🇯🇵",CAN:"🇨🇦",POL:"🇵🇱",AUT:"🇦🇹",BEL:"🇧🇪",PRT:"🇵🇹",NOR:"🇳🇴",DNK:"🇩🇰",FIN:"🇫🇮",IRL:"🇮🇪",CHE:"🇨🇭",NZL:"🇳🇿",MEX:"🇲🇽",ARG:"🇦🇷",CZE:"🇨🇿",HUN:"🇭🇺",RUS:"🇷🇺",TUR:"🇹🇷",KOR:"🇰🇷"},je=["🥇","🥈","🥉"],cs={championship:"Championship",series:"Series",event:"Event"},te=["PRACTICE","QUALIFYING","RACE"];function fe({position:s}){const r=s===1?"pvx-rank pvx-rank--gold":s===2?"pvx-rank pvx-rank--silver":s===3?"pvx-rank pvx-rank--bronze":"pvx-rank";return e.jsx("span",{className:r,children:s})}function Ne({nation:s}){const r=s&&os[s];return r?e.jsx("span",{className:"pvx-nation-flag",title:s,children:r}):null}function ls({sessions:s,activeSession:r,onSelect:n}){if(!s||s.length<=1)return null;const t=[...s].sort((a,i)=>te.indexOf(a.type)-te.indexOf(i.type));return e.jsx("div",{className:"pvx-session-tabs",children:t.map(a=>e.jsx("button",{onClick:()=>n(a.type),className:`pvx-session-tab ${r===a.type?"pvx-session-tab--active":""}`,children:a.type},a.type))})}function be({type:s}){return e.jsx("span",{className:`pvx-comp-badge pvx-comp-badge--${s}`,children:cs[s]||s})}function F({children:s,variant:r="default"}){return e.jsx("span",{className:`pvx-info-pill ${r!=="default"?`pvx-info-pill--${r}`:""}`,children:s})}function ds(s){if(!s)return"TBD";const r=new Date(s);if(isNaN(r))return"TBD";const n=r.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"}),t=r.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} • ${t}`}function ps(s){return s.reduce((r,n)=>{var t;return(t=n.splits)!=null&&t.length?r?r.map((a,i)=>{const o=n.splits[i];return o&&o<a?o:a}):[...n.splits]:r},null)}function B({message:s="Loading..."}){return e.jsx("div",{className:"pvx-loading",children:s})}function D({message:s="No data available."}){return e.jsx("div",{className:"pvx-empty",children:e.jsx("p",{children:s})})}function xs({competitions:s,isLoading:r,onSelect:n,onRegister:t,className:a}){return r?e.jsx(B,{message:"Loading competitions..."}):s!=null&&s.length?e.jsx("div",{className:`pvx-comp-grid ${a||""}`,children:s.map(i=>e.jsx(ye,{comp:i,onSelect:n,onRegister:t||n},i.id))}):e.jsx(D,{message:"No competitions available."})}function ye({comp:s,onSelect:r,onRegister:n}){var h,x,g;const{cdnUrl:t}=k(),a=s.posterCdnPath?`${t}/${s.posterCdnPath}`:null,i=s.registration,o=(i==null?void 0:i.currentCount)||0,l=i==null?void 0:i.maxParticipants,p=l&&o>=l,c=(i==null?void 0:i.deadline)&&new Date(i.deadline)<new Date,u=(i==null?void 0:i.isOpen)&&!c&&!p,v=new Date,j=(h=s.rounds)==null?void 0:h.find(m=>m.startTime&&new Date(m.startTime)>=v),d=((x=s.rounds)==null?void 0:x.length)||0,f=((g=s.rounds)==null?void 0:g.filter(m=>m.isFinalized).length)||0;return e.jsxs("div",{className:"pvx-comp-card",onClick:()=>r(s.id),role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),r(s.id))},children:[e.jsx("div",{className:"pvx-comp-card-poster",children:a?e.jsx("img",{src:a,alt:s.name,className:"pvx-comp-card-poster-img"}):e.jsx("div",{className:"pvx-comp-card-poster-placeholder",children:e.jsx(ms,{})})}),e.jsxs("div",{className:"pvx-comp-card-body",children:[e.jsx("h3",{className:"pvx-comp-card-title",children:s.name}),s.description&&e.jsx("p",{className:"pvx-comp-card-desc",children:s.description}),e.jsxs("div",{className:"pvx-comp-card-pills",children:[e.jsx(be,{type:s.type}),s.game&&e.jsx(F,{children:s.game.toUpperCase()}),s.formatDescription&&s.formatDescription.split(", ").map((m,b)=>e.jsx(F,{variant:"format",children:m},b))]}),s.carsDescription&&e.jsx("div",{className:"pvx-comp-card-pills",children:s.carsDescription.split(", ").map((m,b)=>e.jsx(F,{children:m},b))}),e.jsxs("div",{className:"pvx-comp-card-schedule",children:[j?e.jsxs("span",{className:"pvx-comp-card-schedule-next",children:[e.jsx("span",{className:"pvx-comp-card-schedule-label",children:"Next:"})," ","R",j.roundNumber," ",j.track||"TBD"," — ",ds(j.startTime)]}):d>0?e.jsxs("span",{className:"pvx-comp-card-schedule-next",children:[f,"/",d," rounds completed"]}):null,d>0&&e.jsxs("span",{className:"pvx-comp-card-round-count",children:[d," round",d!==1?"s":""]})]}),i&&e.jsx(us,{competitionId:s.id,regOpen:u,isFull:p,deadlinePassed:c,regCount:o,regMax:l,onRegister:n})]})]})}function us({competitionId:s,regOpen:r,isFull:n,deadlinePassed:t,regCount:a,regMax:i,onRegister:o}){const{isPowerMode:l}=V(),p=K(s),{data:c}=_(s),u=(c==null?void 0:c.isRegistered)||!1,v=i?a/i*100:0,j=v>=100?"full":v>=75?"warning":"ok";return e.jsxs("div",{className:"pvx-comp-card-reg",children:[e.jsx("div",{className:"pvx-comp-card-reg-info",children:e.jsxs("span",{className:`pvx-reg-capacity pvx-reg-capacity--${j}`,children:[a,"/",i||"∞"," drivers"]})}),e.jsx("div",{className:"pvx-comp-card-reg-action",children:u?e.jsx("button",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--registered",onClick:d=>{d.stopPropagation(),o(s)},children:"✓ Registered"}):r?l?e.jsx("button",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--open",onClick:d=>{d.stopPropagation(),o(s)},children:"Register"}):e.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--open",onClick:d=>d.stopPropagation(),children:"Register"}):e.jsx("span",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--closed",children:n?"Full":"Closed"})})]})}function ms(){return e.jsxs("svg",{className:"pvx-comp-trophy-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6"}),e.jsx("path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18"}),e.jsx("path",{d:"M4 22h16"}),e.jsx("path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22"}),e.jsx("path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22"}),e.jsx("path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z"})]})}function vs({competitionId:s,className:r}){var l,p;const{data:n,isLoading:t}=pe(s),{data:a,isLoading:i}=de(s);if(t||i)return e.jsx(B,{message:"Loading standings..."});if(!((l=n==null?void 0:n.standings)!=null&&l.length))return e.jsx(D,{message:"No standings data yet. Results will appear once rounds are finalised."});const o=((p=a==null?void 0:a.rounds)==null?void 0:p.filter(c=>c.isFinalized))||[];return e.jsxs("div",{className:`pvx-card ${r||""}`,children:[e.jsx("div",{className:"pvx-card-header--split",children:e.jsxs("div",{className:"pvx-card-header-left",children:[e.jsx("h3",{className:"pvx-card-title",children:"Championship Standings"}),e.jsxs("span",{className:"pvx-standings-subtitle",children:["After ",n.roundsCompleted," round",n.roundsCompleted!==1?"s":"",n.countingRounds>0&&` (best ${n.countingRounds} count)`]})]})}),e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"Pos"}),e.jsx("th",{className:"pvx-th",children:"Driver"}),e.jsx("th",{className:"pvx-th pvx-th--center pvx-hidden-below-sm",children:"W"}),e.jsx("th",{className:"pvx-th pvx-th--center pvx-hidden-below-sm",children:"Pod"}),e.jsx("th",{className:"pvx-th pvx-th--center",children:"Points"}),o.map(c=>e.jsxs("th",{className:"pvx-th pvx-th--center pvx-hidden-below-md",title:c.track||`Round ${c.roundNumber}`,children:["R",c.roundNumber]},c.roundNumber))]})}),e.jsx("tbody",{className:"pvx-tbody",children:n.standings.map(c=>e.jsx(hs,{driver:c,finalizedRounds:o},c.driverId||c.driverName))})]})})]})}function hs({driver:s,finalizedRounds:r}){var o,l,p;const n=s.position<=3,t=new Map(((o=s.roundResults)==null?void 0:o.map(c=>[c.roundNumber,c]))||[]),a=((l=s.roundResults)==null?void 0:l.filter(c=>c.position===1).length)||0,i=((p=s.roundResults)==null?void 0:p.filter(c=>c.position<=3).length)||0;return e.jsxs("tr",{className:`pvx-row ${n?"pvx-row--podium":""}`,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(fe,{position:s.position})}),e.jsxs("td",{className:"pvx-td pvx-td--primary",children:[e.jsx(Ne,{nation:s.nation}),s.driverName]}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-sm",children:a||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-sm",children:i||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-standings-total",children:s.totalPoints}),r.map(c=>{const u=t.get(c.roundNumber),v=u==null?void 0:u.dropped;return e.jsx("td",{className:`pvx-td pvx-td--center pvx-hidden-below-md ${!v&&(u==null?void 0:u.position)<=3?"pvx-standings-cell--podium":""}`,children:u?e.jsxs("div",{className:`pvx-standings-round-cell ${v?"pvx-standings-round-cell--dropped":""}`,children:[e.jsxs("span",{className:"pvx-standings-round-pos",children:["P",u.position]}),e.jsx("span",{className:"pvx-standings-round-pts",children:u.points})]}):e.jsx("span",{className:"pvx-td--muted",children:"-"})},c.roundNumber)})]})}function gs({competitionId:s,roundNumber:r,className:n}){var p;const{data:t,isLoading:a}=xe(s,r);if(a)return e.jsx(B,{message:"Loading results..."});if(!t)return e.jsx(D,{message:"No results for this round."});const o=(t.sessions||[]).find(c=>c.type==="RACE"),l=(p=o==null?void 0:o.results)==null?void 0:p.filter(c=>c.position<=3).sort((c,u)=>c.position-u.position);return e.jsxs("div",{className:`pvx-round-results ${n||""}`,children:[e.jsxs("div",{className:"pvx-round-results-header",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"pvx-round-results-title",children:["Round ",t.roundNumber,t.track?`: ${t.track}`:""]}),t.startTime&&e.jsx("p",{className:"pvx-round-results-date",children:new Date(t.startTime).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})})]}),(l==null?void 0:l.length)>0&&e.jsx("div",{className:"pvx-round-podium-summary",children:l.map(c=>e.jsxs("span",{className:"pvx-round-podium-item",children:[e.jsx("span",{children:je[c.position-1]}),e.jsx("span",{children:c.driverName})]},c.driverId))})]}),e.jsx(ke,{round:t})]})}function ke({round:s,className:r}){var l,p;const[n,t]=N.useState(null),a=(s==null?void 0:s.sessions)||[];if(!a.length)return e.jsx(D,{message:"No session data for this round."});const i=n||((l=a.find(c=>c.type==="RACE"))==null?void 0:l.type)||((p=a[0])==null?void 0:p.type),o=a.find(c=>c.type===i)||a[0];return e.jsxs("div",{className:r||"",children:[e.jsx(ls,{sessions:a,activeSession:i,onSelect:t}),e.jsx(js,{session:o})]})}function js({session:s}){var t;const r=s.type==="RACE";if(!((t=s.results)!=null&&t.length))return e.jsx(D,{message:`No results for ${s.type}.`});const n=ps(s.results);return e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"Pos"}),e.jsx("th",{className:"pvx-th",children:"Driver"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Car"}),e.jsx("th",{className:"pvx-th",children:"Best Lap"}),r&&e.jsxs(e.Fragment,{children:[e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Laps"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Time / Gap"}),e.jsx("th",{className:"pvx-th pvx-th--center",children:"Points"})]})]})}),e.jsx("tbody",{className:"pvx-tbody",children:s.results.map((a,i)=>e.jsx(fs,{result:a,isRace:r,fastestSplits:n,rowIndex:i},a.driverId||i))})]})})}function fs({result:s,isRace:r,fastestSplits:n,rowIndex:t}){const a=s.position<=3;return e.jsxs("tr",{className:`pvx-row ${a?"pvx-row--podium":""}`,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(fe,{position:s.position})}),e.jsxs("td",{className:"pvx-td pvx-td--primary",children:[e.jsx(Ne,{nation:s.nation}),s.driverName,s.carNumber!=null&&e.jsxs("span",{className:"pvx-car-number",children:["#",s.carNumber]}),s.penalty&&e.jsx("span",{className:"pvx-penalty",children:s.penalty})]}),e.jsx("td",{className:"pvx-td pvx-hidden-below-sm",children:S(s.carId)}),e.jsx("td",{className:"pvx-td pvx-td--mono",children:e.jsx(Ns,{bestLap:s.bestLapFormatted,hasBestLap:s.hasBestLap,splits:s.splits,fastestSplits:n,showAbove:t<=1})}),r&&e.jsxs(e.Fragment,{children:[e.jsx("td",{className:"pvx-td pvx-hidden-below-sm",children:s.lapsCompleted}),e.jsx("td",{className:"pvx-td pvx-td--mono pvx-td--muted pvx-hidden-below-sm",children:s.position===1?s.totalTime||"-":s.gap||"-"}),e.jsxs("td",{className:"pvx-td pvx-td--center",children:[e.jsx("span",{className:"pvx-session-points",children:s.points}),s.pointsOverride!==0&&s.pointsOverride&&e.jsxs("span",{className:"pvx-points-override",children:["(",s.pointsOverride>0?"+":"",s.pointsOverride,")"]})]})]})]})}function Ns({bestLap:s,hasBestLap:r,splits:n,fastestSplits:t,showAbove:a}){return s?e.jsxs("span",{className:`pvx-best-lap-cell ${r?"pvx-best-lap-cell--fastest":""}`,children:[e.jsx("span",{className:"pvx-best-lap-time",children:s}),(n==null?void 0:n.length)>0&&e.jsx("span",{className:"pvx-splits-tooltip-anchor",children:e.jsx("span",{className:`pvx-splits-tooltip ${a?"":"pvx-splits-tooltip--above"}`,children:n.map((i,o)=>{const l=t&&i===t[o];return e.jsxs("span",{className:"pvx-splits-tooltip-row",children:[e.jsxs("span",{className:"pvx-splits-tooltip-label",children:["S",o+1]}),e.jsx("span",{className:l?"pvx-splits-tooltip-best":"",children:i})]},o)})})})]}):e.jsx("span",{className:"pvx-td--muted",children:"-"})}function bs({competitionId:s,className:r}){const{getSteamId:n}=k(),{data:t,isLoading:a}=Z(s),i=n();if(a)return e.jsx(B,{message:"Loading drivers..."});const o=(t==null?void 0:t.drivers)||(t==null?void 0:t.entries)||[];return o.length?e.jsx("div",{className:`pvx-entry-grid ${r||""}`,children:o.map(l=>{var c,u;const p=i&&l.steamId===i;return e.jsxs("div",{className:`pvx-entry-card ${p?"pvx-entry-card--you":""}`,children:[l.avatarUrl?e.jsx("img",{src:l.avatarUrl,alt:"",className:"pvx-entry-avatar"}):e.jsx("div",{className:"pvx-entry-avatar pvx-entry-avatar--placeholder",children:((u=(c=l.displayName)==null?void 0:c.charAt(0))==null?void 0:u.toUpperCase())||"?"}),e.jsxs("span",{className:"pvx-entry-name",children:[l.displayName,p&&e.jsx("span",{className:"pvx-entry-you",children:" (you)"})]})]},l.steamId||l.driverId)})}):e.jsx(D,{message:"No drivers registered yet."})}function ys({competitionId:s,driverData:r,className:n,children:t}){const{data:a,isLoading:i}=_(s),{isPowerMode:o}=V(),l=K(s),p=X(s),c=ee(s),u=(a==null?void 0:a.isRegistered)||!1,v=i||p.isPending||c.isPending,j=p.error||c.error||null,d=()=>{o&&p.mutate(r||{})},f=()=>{o&&c.mutate()};return typeof t=="function"?t({isRegistered:u,isLoading:v,register:d,withdraw:f,error:j,isPowerMode:o,registrationUrl:l}):o?e.jsx("button",{className:`pvx-comp-register-btn ${n||""}`,onClick:u?f:d,disabled:v,children:v?"Loading...":u?"Withdraw":"Register"}):e.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:`pvx-comp-register-link ${n||""}`,children:u?"View Registration":"Register on PitVox"})}function ks({competitionId:s,registration:r,onWithdrawSuccess:n,className:t}){const{getSteamId:a}=k(),{isPowerMode:i}=V(),o=K(s),{data:l,isLoading:p}=_(s),{data:c,isLoading:u}=Z(s),v=X(s),j=ee(s),d=a(),f=(l==null?void 0:l.isRegistered)||!1,h=(c==null?void 0:c.drivers)||(c==null?void 0:c.entries)||[],x=r||{},g=h.length||x.currentCount||0,m=x.maxParticipants&&g>=x.maxParticipants,b=x.deadline&&new Date(x.deadline)<new Date,C=x.isOpen&&!b&&!m;return p||u?e.jsx(B,{message:"Loading registration..."}):f?e.jsx("div",{className:`pvx-reg-panel ${t||""}`,children:e.jsx(ws,{competitionId:s,drivers:h,steamId:d,isPowerMode:i,registrationUrl:o,withdrawMutation:j,onWithdrawSuccess:n,registration:x})}):C?d?i?e.jsx("div",{className:`pvx-reg-panel ${t||""}`,children:e.jsx(Cs,{competitionId:s,registerMutation:v,registration:x})}):e.jsx("div",{className:`pvx-reg-panel ${t||""}`,children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-register-link",children:"Register on PitVox"})}):e.jsx("div",{className:`pvx-reg-panel ${t||""}`,children:i?e.jsx("div",{className:"pvx-reg-status-msg",children:"Sign in to register for this competition."}):e.jsx("div",{className:"pvx-reg-status-msg",children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-register-link",children:"Register on PitVox"})})}):e.jsxs("div",{className:`pvx-reg-panel ${t||""}`,children:[e.jsx("div",{className:"pvx-reg-status-msg",children:m?"Registration is full.":b?"Registration deadline has passed.":"Registration is closed."}),h.length>0&&e.jsx(Ce,{drivers:h,steamId:d})]})}function Cs({competitionId:s,registerMutation:r,registration:n}){const[t,a]=N.useState(""),[i,o]=N.useState("intermediate"),[l,p]=N.useState(""),c=d=>{d.preventDefault(),r.mutate({discordUsername:t||void 0,experience:i,comments:l||void 0})},u=n||{},v=u.currentCount||0,j=u.maxParticipants;return e.jsxs("form",{className:"pvx-reg-form",onSubmit:c,children:[e.jsxs("div",{className:"pvx-reg-form-header",children:[e.jsx("h3",{className:"pvx-reg-form-title",children:"Register"}),j&&e.jsx(we,{count:v,max:j})]}),r.error&&e.jsx("div",{className:"pvx-reg-error",children:r.error.message||"Registration failed"}),e.jsxs("div",{className:"pvx-reg-field",children:[e.jsxs("label",{className:"pvx-reg-label",htmlFor:`pvx-discord-${s}`,children:["Discord Username ",e.jsx("span",{className:"pvx-reg-optional",children:"(optional)"})]}),e.jsx("input",{id:`pvx-discord-${s}`,type:"text",className:"pvx-reg-input",placeholder:"e.g. username",value:t,onChange:d=>a(d.target.value)})]}),e.jsxs("div",{className:"pvx-reg-field",children:[e.jsx("label",{className:"pvx-reg-label",htmlFor:`pvx-exp-${s}`,children:"Experience Level"}),e.jsxs("select",{id:`pvx-exp-${s}`,className:"pvx-reg-select",value:i,onChange:d=>o(d.target.value),children:[e.jsx("option",{value:"beginner",children:"Beginner"}),e.jsx("option",{value:"intermediate",children:"Intermediate"}),e.jsx("option",{value:"advanced",children:"Advanced"})]})]}),e.jsxs("div",{className:"pvx-reg-field",children:[e.jsxs("label",{className:"pvx-reg-label",htmlFor:`pvx-comments-${s}`,children:["Comments ",e.jsx("span",{className:"pvx-reg-optional",children:"(optional)"})]}),e.jsx("textarea",{id:`pvx-comments-${s}`,className:"pvx-reg-textarea",rows:3,placeholder:"Anything the organisers should know?",value:l,onChange:d=>p(d.target.value)})]}),e.jsx("div",{className:"pvx-reg-actions",children:e.jsx("button",{type:"submit",className:"pvx-comp-register-btn",disabled:r.isPending,children:r.isPending?"Registering...":"Register"})})]})}function ws({competitionId:s,drivers:r,steamId:n,isPowerMode:t,registrationUrl:a,withdrawMutation:i,onWithdrawSuccess:o,registration:l}){const[p,c]=N.useState(!1),u=()=>{i.mutate(void 0,{onSuccess:()=>{c(!1),o&&o()}})},v=l||{},j=r.length||v.currentCount||0,d=v.maxParticipants;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pvx-reg-form-header",children:[e.jsx("h3",{className:"pvx-reg-form-title",children:"Registered Drivers"}),d&&e.jsx(we,{count:j,max:d})]}),e.jsx(Ce,{drivers:r,steamId:n}),i.error&&e.jsx("div",{className:"pvx-reg-error",children:i.error.message||"Withdrawal failed"}),t?e.jsx("div",{className:"pvx-reg-actions",children:p?e.jsxs("div",{className:"pvx-reg-confirm",children:[e.jsx("p",{className:"pvx-reg-confirm-text",children:"Are you sure you want to unregister?"}),e.jsxs("div",{className:"pvx-reg-confirm-actions",children:[e.jsx("button",{type:"button",className:"pvx-reg-cancel-btn",onClick:()=>c(!1),children:"Cancel"}),e.jsx("button",{type:"button",className:"pvx-reg-danger-btn",onClick:u,disabled:i.isPending,children:i.isPending?"Unregistering...":"Yes, Unregister"})]})]}):e.jsx("button",{type:"button",className:"pvx-reg-unregister-btn",onClick:()=>c(!0),children:"Unregister"})}):e.jsx("div",{className:"pvx-reg-actions",children:e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-register-link",children:"Manage on PitVox"})})]})}function Ce({drivers:s,steamId:r}){if(!s.length)return e.jsx("div",{className:"pvx-reg-no-drivers",children:"No drivers registered yet."});const n=[...s].sort((t,a)=>{const i=r&&t.steamId===r?-1:0,o=r&&a.steamId===r?-1:0;return i-o});return e.jsx("div",{className:"pvx-reg-driver-list",children:n.map(t=>{var i,o;const a=r&&t.steamId===r;return e.jsxs("div",{className:`pvx-reg-driver-row ${a?"pvx-reg-driver-row--you":""}`,children:[t.avatarUrl?e.jsx("img",{src:t.avatarUrl,alt:"",className:"pvx-reg-driver-avatar"}):e.jsx("div",{className:"pvx-reg-driver-avatar pvx-reg-driver-avatar--placeholder",children:((o=(i=t.displayName)==null?void 0:i.charAt(0))==null?void 0:o.toUpperCase())||"?"}),e.jsxs("span",{className:"pvx-reg-driver-name",children:[t.displayName,a&&e.jsx("span",{className:"pvx-entry-you",children:" (you)"})]})]},t.steamId||t.driverId)})})}function we({count:s,max:r}){const n=r?s/r*100:0,t=n>=100?"full":n>=75?"warning":"ok";return e.jsxs("span",{className:`pvx-reg-capacity pvx-reg-capacity--${t}`,children:[s,"/",r," drivers"]})}function Le(s){const{cdnUrl:r}=k(),n=y.useQuery({queryKey:["pitvox","laps","global",s],queryFn:()=>w(r,`laps/${s}.json`),enabled:!!s,staleTime:3e4,refetchInterval:3e4}),t=n.data;return{isLoading:n.isLoading,error:n.error,data:t?{driverName:t.driverName||"Driver",lapCount:t.lapCount||0,trackBreakdown:t.trackBreakdown||[],carBreakdown:t.carBreakdown||[],recordsHeld:t.recordsHeld||0,currentRecords:t.currentRecords||[],bestRanking:t.bestRanking??null,bestRankingTrackId:t.bestRankingTrackId??null,bestRankingLayout:t.bestRankingLayout??null,bestRankingCarId:t.bestRankingCarId??null,generatedAt:t.generatedAt}:null}}function Re(s={}){const{cdnUrl:r,partnerSlug:n}=k(),{gameVersion:t,enabled:a=!0}=s,i=t?`v/${t}/`:"",o=q(n,`${i}ratings.json`);return y.useQuery({queryKey:["pitvox","ratings",n,t||null],queryFn:()=>w(r,o),staleTime:3e4,refetchInterval:3e4,enabled:a})}function Se(s){var t;const r=Re(),n=N.useMemo(()=>{var a;return!((a=r.data)!=null&&a.drivers)||!s?null:r.data.drivers.find(i=>i.identifier===s)||null},[(t=r.data)==null?void 0:t.drivers,s]);return{isLoading:r.isLoading,error:r.error,data:n?{rating:n.rating,rank:n.rank,totalDrivers:r.data.driverCount||r.data.drivers.length,comboCount:n.comboCount||0,distinctCars:n.distinctCars||0,combos:n.combos||[]}:null}}function Ls(s={}){const r=Re(s);return{data:r.data||null,isLoading:r.isLoading,error:r.error}}function Te(){const{cdnUrl:s,partnerSlug:r,getSteamId:n,onFetchServerPassword:t}=k(),a=n(),{data:i,isLoading:o}=y.useQuery({queryKey:["pitvox","competitions",r],queryFn:async()=>{const d=await w(s,"competitions/index.json");return d!=null&&d.competitions?d.competitions.filter(f=>f.partnerSlug===r):[]},staleTime:6e4}),l=(i==null?void 0:i.map(d=>d.id))||[],p=y.useQueries({queries:l.map(d=>({queryKey:["pitvox","competition",r,d,"entrylist"],queryFn:()=>w(s,`competitions/${r}/${d}/entrylist.json`),enabled:!!a&&l.length>0,staleTime:6e4}))}),c=p.some(d=>d.isLoading),u=N.useMemo(()=>{var h,x;if(!i||!a||c)return[];const d=new Date,f=[];for(let g=0;g<i.length;g++){const m=i[g],b=(h=p[g])==null?void 0:h.data;if(!((x=b==null?void 0:b.drivers)==null?void 0:x.some(R=>R.steamId===a)))continue;const T=m.rounds||[];for(const R of T)R.isFinalized||!R.startTime||new Date(R.startTime)<=d||f.push({competitionId:m.id,competitionName:m.name,roundNumber:R.roundNumber,track:R.track||"TBD",startTime:R.startTime})}return f.sort((g,m)=>new Date(g.startTime)-new Date(m.startTime)),f.length>0&&(f[0].isNext=!0),f},[i,a,c,p]),v=y.useQueries({queries:u.map(d=>({queryKey:["pitvox","serverInfo",d.competitionId,d.roundNumber],queryFn:()=>t(d.competitionId,d.roundNumber),enabled:!!t&&u.length>0,staleTime:5*6e4,retry:!1}))});return{data:N.useMemo(()=>u.length?t?u.map((d,f)=>{var x;const h=(x=v[f])==null?void 0:x.data;return h!=null&&h.success?{...d,serverAddress:h.serverAddress||null,serverPassword:h.serverPassword||null}:d}):u:[],[u,t,v]),isLoading:o||!!a&&c}}function Me(){const{onFetchNotifications:s}=k();return!!s}function $e(s={}){const{onFetchNotifications:r,partnerSlug:n}=k(),{limit:t=20,unreadOnly:a=!1}=s;return y.useQuery({queryKey:["pitvox","notifications",n,{limit:t,unreadOnly:a}],queryFn:()=>r({limit:t,unreadOnly:a}),enabled:!!r,staleTime:3e4,refetchInterval:3e4})}function Rs(){const{onFetchNotifications:s,partnerSlug:r}=k(),{data:n,isLoading:t}=y.useQuery({queryKey:["pitvox","notifications",r,{limit:1,unreadOnly:!1}],queryFn:()=>s({limit:1}),enabled:!!s,staleTime:3e4,refetchInterval:3e4,select:a=>(a==null?void 0:a.unreadCount)??0});return{count:n??0,isLoading:t}}function De(){const{onMarkNotificationRead:s,partnerSlug:r}=k(),n=y.useQueryClient();return y.useMutation({mutationFn:t=>{if(!s)throw new Error("No onMarkNotificationRead callback provided to PitVoxPartnerProvider.");return s(t)},onSuccess:(t,a)=>{n.setQueriesData({queryKey:["pitvox","notifications",r]},i=>i!=null&&i.notifications?{...i,unreadCount:Math.max(0,(i.unreadCount||0)-1),notifications:i.notifications.map(o=>o.id===a?{...o,isRead:!0,readAt:new Date().toISOString()}:o)}:i)}})}function Ie(){const{onMarkAllNotificationsRead:s,partnerSlug:r}=k(),n=y.useQueryClient();return y.useMutation({mutationFn:()=>{if(!s)throw new Error("No onMarkAllNotificationsRead callback provided to PitVoxPartnerProvider.");return s()},onSuccess:()=>{n.setQueriesData({queryKey:["pitvox","notifications",r]},t=>t!=null&&t.notifications?{...t,unreadCount:0,notifications:t.notifications.map(a=>({...a,isRead:!0,readAt:a.readAt||new Date().toISOString()}))}:t)}})}function Pe({driverName:s,avatarUrl:r,memberSince:n,className:t=""}){const a=n?new Date(n).toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric"}):null;return e.jsxs("div",{className:`pvx-card pvx-dash-profile ${t}`,children:[r?e.jsx("img",{src:r,alt:"",className:"pvx-dash-profile-avatar"}):e.jsx("div",{className:"pvx-dash-profile-avatar pvx-dash-profile-avatar--placeholder",children:(s||"?")[0].toUpperCase()}),e.jsxs("div",{className:"pvx-dash-profile-info",children:[e.jsx("h2",{className:"pvx-dash-profile-name",children:s}),a&&e.jsxs("p",{className:"pvx-dash-profile-since",children:["Racing since ",a]})]})]})}function Ss(){return e.jsxs("svg",{className:"pvx-dash-stat-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),e.jsx("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),e.jsx("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),e.jsx("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function Ts(){return e.jsxs("svg",{className:"pvx-dash-stat-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"}),e.jsx("path",{d:"M12 14v4"}),e.jsx("path",{d:"M10.5 12.5l-4 2.5"}),e.jsx("path",{d:"M13.5 12.5l4 2.5"})]})}function Ms(){return e.jsx("svg",{className:"pvx-dash-stat-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("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"})})}function ne({icon:s,value:r,label:n,items:t,labelKey:a,countKey:i}){const[o,l]=N.useState(!1),p=N.useRef(null);N.useEffect(()=>{if(!o)return;function u(v){p.current&&!p.current.contains(v.target)&&l(!1)}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[o]);const c=t!=null&&t.length?t.slice().sort((u,v)=>v[i]-u[i]):null;return e.jsxs("div",{ref:p,className:`pvx-dash-stat-card ${c?"pvx-dash-stat-card--clickable":""}`,onClick:c?()=>l(u=>!u):void 0,children:[s,e.jsxs("div",{className:"pvx-dash-stat-content",children:[e.jsx("span",{className:"pvx-dash-stat-value",children:r}),e.jsx("span",{className:"pvx-dash-stat-label",children:n})]}),c&&e.jsx("div",{className:`pvx-dash-tooltip pvx-dash-tooltip--scrollable ${o?"pvx-dash-tooltip--open":""}`,children:c.map((u,v)=>e.jsxs("div",{className:"pvx-dash-tooltip-row",children:[e.jsx("span",{className:"pvx-dash-tooltip-label",children:u[a]}),e.jsx("span",{className:"pvx-dash-tooltip-value",children:u[i]})]},v))})]})}function Be({stats:s,rating:r,className:n=""}){if(!s)return null;const t=s.trackBreakdown.map(i=>({name:I(i.trackId,i.layout),lapCount:i.lapCount})),a=s.carBreakdown.map(i=>({name:S(i.carId),lapCount:i.lapCount}));return e.jsxs("div",{className:`pvx-dash-stats ${n}`,children:[e.jsx(ne,{icon:e.jsx(Ss,{}),value:s.lapCount.toLocaleString(),label:"Total Laps",items:t,labelKey:"name",countKey:"lapCount"}),e.jsx(ne,{icon:e.jsx(Ts,{}),value:s.carBreakdown.length,label:"Cars Used",items:a,labelKey:"name",countKey:"lapCount"}),r&&e.jsxs("div",{className:"pvx-dash-stat-card pvx-dash-stat-card--rating",children:[e.jsx(Ms,{}),e.jsxs("div",{className:"pvx-dash-stat-content",children:[e.jsx("span",{className:"pvx-dash-stat-value",children:r.rating.toFixed(1)}),e.jsx("span",{className:"pvx-dash-stat-label",children:"Driver Rating"}),e.jsxs("span",{className:"pvx-dash-stat-sub",children:["#",r.rank," of ",r.totalDrivers]})]})]})]})}function Ue({records:s,className:r=""}){const n=N.useMemo(()=>s!=null&&s.length?s.slice().sort((t,a)=>{const i=t.recordedAt?new Date(t.recordedAt).getTime():0;return(a.recordedAt?new Date(a.recordedAt).getTime():0)-i}):[],[s]);return n.length?e.jsxs("div",{className:`pvx-card ${r}`,children:[e.jsx("div",{className:"pvx-card-header",children:e.jsxs("h3",{className:"pvx-card-title",children:[e.jsx("span",{className:"pvx-dash-records-icon",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 9H4.5a2.5 2.5 0 010-5H6"}),e.jsx("path",{d:"M18 9h1.5a2.5 2.5 0 000-5H18"}),e.jsx("path",{d:"M4 22h16"}),e.jsx("path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20 7 22"}),e.jsx("path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20 17 22"}),e.jsx("path",{d:"M18 2H6v7a6 6 0 0012 0V2z"})]})}),"Current Records",e.jsxs("span",{className:"pvx-dash-records-count",children:["(",n.length,")"]})]})}),e.jsx("div",{className:"pvx-dash-records-list",children:n.map((t,a)=>e.jsxs("div",{className:"pvx-dash-record-row",children:[e.jsxs("div",{className:"pvx-dash-record-info",children:[e.jsx("span",{className:"pvx-dash-record-track",children:I(t.trackId,t.layout,t.game)}),e.jsx("span",{className:"pvx-dash-record-car",children:S(t.carId)})]}),e.jsxs("div",{className:"pvx-dash-record-time",children:[e.jsx("span",{className:"pvx-dash-record-lap",children:$(t.lapTimeMs)}),e.jsxs("span",{className:`pvx-dash-game-badge pvx-dash-game-badge--${t.game||"evo"}`,children:[(t.game||"evo").toUpperCase(),t.gameVersion?` ${t.gameVersion}`:""]})]})]},a))})]}):null}function Ae({events:s,isLoading:r,className:n,limit:t=3}){if(r)return e.jsx("div",{className:"pvx-loading",children:"Loading upcoming events..."});if(!(s!=null&&s.length))return null;const a=t?s.slice(0,t):s,i=s.length-a.length;return e.jsxs("div",{className:`pvx-card ${n||""}`,children:[e.jsx("div",{className:"pvx-card-header",children:e.jsxs("h3",{className:"pvx-card-title",children:[e.jsx(Is,{}),"Upcoming Events",e.jsxs("span",{className:"pvx-dash-records-count",children:["(",s.length,")"]})]})}),e.jsxs("div",{className:"pvx-upcoming-list",children:[a.map(o=>e.jsxs("div",{className:`pvx-upcoming-item ${o.isNext?"pvx-upcoming-item--next":""}`,children:[e.jsxs("div",{className:"pvx-upcoming-info",children:[e.jsx("span",{className:"pvx-upcoming-comp",children:o.competitionName}),e.jsxs("span",{className:"pvx-upcoming-round",children:["Round ",o.roundNumber,": ",o.track]}),o.serverPassword&&e.jsx($s,{password:o.serverPassword,address:o.serverAddress})]}),e.jsxs("div",{className:"pvx-upcoming-time",children:[e.jsx("span",{className:"pvx-upcoming-date",children:new Date(o.startTime).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}),e.jsx("span",{className:"pvx-upcoming-relative",children:Ds(o.startTime)}),o.isNext&&e.jsx("span",{className:"pvx-upcoming-badge",children:"Next"})]})]},`${o.competitionId}-${o.roundNumber}`)),i>0&&e.jsxs("div",{className:"pvx-upcoming-remaining",children:["+",i," more event",i!==1?"s":""]})]})]})}function $s({password:s,address:r}){const[n,t]=N.useState(!1),[a,i]=N.useState(!1),o=r?s?`join:${r}|${s}`:`join:${r}`:null,l=N.useCallback(async()=>{if(o)try{await navigator.clipboard.writeText(o),t(!0),setTimeout(()=>t(!1),2e3)}catch{}},[o]);return e.jsxs("div",{className:"pvx-server-info",children:[o&&e.jsxs("span",{className:"pvx-server-detail pvx-server-detail--clickable",onClick:l,title:"Copy join string to clipboard",children:[e.jsx(Bs,{})," ",n?"Copied!":"Join"]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"pvx-server-detail pvx-server-detail--clickable",onClick:()=>i(p=>!p),title:a?"Hide password":"Reveal password",children:a?e.jsx(As,{}):e.jsx(Us,{})}),a&&e.jsxs("span",{className:"pvx-server-detail",children:[e.jsx(Ps,{})," ",s]})]})]})}function Ds(s){const r=new Date(s).getTime()-Date.now();if(r<=0)return"Now";const n=Math.floor(r/(1e3*60*60));if(n<1)return"Less than 1 hour";if(n<24)return`in ${n}h`;const t=Math.floor(n/24);if(t===1)return"Tomorrow";if(t<7)return`in ${t} days`;if(t<30){const a=Math.floor(t/7);return`in ${a} week${a!==1?"s":""}`}return z(s)}function Is(){return e.jsxs("svg",{className:"pvx-dash-records-icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M16 2v4M8 2v4M3 10h18"})]})}function Ps(){return e.jsxs("svg",{className:"pvx-server-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function Bs(){return e.jsxs("svg",{className:"pvx-server-icon pvx-server-icon--action",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function Us(){return e.jsxs("svg",{className:"pvx-server-icon pvx-server-icon--action",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function As(){return e.jsxs("svg",{className:"pvx-server-icon pvx-server-icon--action",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"}),e.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Ee({notifications:s,unreadCount:r=0,onMarkRead:n,onMarkAllRead:t,isLoading:a,className:i}){const o=Y();return a?e.jsx("div",{className:"pvx-loading",children:"Loading notifications..."}):e.jsxs("div",{className:`pvx-card ${i||""}`,children:[e.jsxs("div",{className:"pvx-card-header",children:[e.jsxs("h3",{className:"pvx-card-title",children:[e.jsx(qs,{}),"Notifications",r>0&&e.jsx("span",{className:"pvx-notif-badge",children:r>99?"99+":r})]}),r>0&&t&&e.jsx("button",{className:"pvx-notif-mark-all",onClick:t,children:"Mark all read"})]}),s!=null&&s.length?e.jsx("div",{className:"pvx-notif-list",children:s.map(l=>e.jsx(Es,{notification:l,getUserDisplay:o,onMarkRead:n},l.id))}):e.jsx("div",{className:"pvx-notif-empty",children:"No notifications"})]})}function Es({notification:s,getUserDisplay:r,onMarkRead:n}){const t=()=>{!s.isRead&&n&&n(s.id)};return e.jsxs("button",{className:`pvx-notif-item ${s.isRead?"":"pvx-notif-item--unread"}`,onClick:t,children:[e.jsx(Fs,{type:s.type}),e.jsxs("div",{className:"pvx-notif-content",children:[e.jsx("span",{className:"pvx-notif-message",children:oe(s,r)}),e.jsx("span",{className:"pvx-notif-time",children:z(s.createdAt)})]}),!s.isRead&&e.jsx("span",{className:"pvx-notif-dot"})]})}function Fs({type:s}){return s==="RECORD_BEATEN"?e.jsx("span",{className:"pvx-notif-icon pvx-notif-icon--beaten",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m7 7 10 10M17 7v10H7"})})}):s==="ADMIN_MESSAGE"?e.jsx("span",{className:"pvx-notif-icon pvx-notif-icon--admin",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"m3 11 18-5v12L3 13v-2z"}),e.jsx("path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6"})]})}):e.jsx("span",{className:"pvx-notif-icon pvx-notif-icon--record",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6"}),e.jsx("path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18"}),e.jsx("path",{d:"M4 22h16"}),e.jsx("path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22"}),e.jsx("path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22"}),e.jsx("path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z"})]})})}function qs(){return e.jsxs("svg",{className:"pvx-dash-records-icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"}),e.jsx("path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0"})]})}function _s({steamId:s,avatarUrl:r,memberSince:n,className:t=""}){const{data:a,isLoading:i,error:o}=Le(s),{data:l,isLoading:p}=Se(s),{data:c,isLoading:u}=Te(),v=Me(),{data:j,isLoading:d}=$e({limit:10}),f=De(),h=Ie();return i||p?e.jsx("div",{className:"pvx-loading",children:"Loading dashboard..."}):o?e.jsx("div",{className:"pvx-empty",children:"Failed to load dashboard data."}):a?e.jsxs("div",{className:`pvx-dash ${t}`,children:[e.jsx(Pe,{driverName:a.driverName,avatarUrl:r,memberSince:n}),e.jsx(Be,{stats:a,rating:l}),s&&e.jsx(Ae,{events:c,isLoading:u}),e.jsxs("div",{className:`pvx-dash-row ${v?"pvx-dash-row--2col":""}`,children:[e.jsx(Ue,{records:a.currentRecords}),v&&e.jsx(Ee,{notifications:j==null?void 0:j.notifications,unreadCount:(j==null?void 0:j.unreadCount)||0,onMarkRead:x=>f.mutate(x),onMarkAllRead:()=>h.mutate(),isLoading:d})]})]}):e.jsx("div",{className:"pvx-empty",children:"No data available yet. Start driving to see your stats!"})}exports.CarsTable=rs;exports.CompEmptyState=D;exports.CompLoadingState=B;exports.CompetitionCard=ye;exports.CompetitionCards=xs;exports.DriverDashboard=_s;exports.DriverProfile=Pe;exports.DriversTable=ts;exports.EntryList=bs;exports.InfoPill=F;exports.LapHistoryTable=ns;exports.NotificationsCard=Ee;exports.PODIUM_MEDALS=je;exports.PitVoxPartnerProvider=Ve;exports.RankingsTable=as;exports.RecordsTable=Ue;exports.RegisterButton=ys;exports.RegistrationPanel=ks;exports.RoundResults=gs;exports.RoundSessionResults=ke;exports.StandingsTable=vs;exports.StatsCards=Be;exports.TracksTable=ss;exports.TypeBadge=be;exports.UpcomingEvents=Ae;exports.buildLapsPath=ae;exports.buildLeaderboardPath=q;exports.buildRecentLapsPath=ie;exports.fetchCdnJson=w;exports.formatCarName=S;exports.formatDate=P;exports.formatDelta=Ke;exports.formatLapTime=$;exports.formatNotificationMessage=oe;exports.formatRelativeTime=z;exports.formatSectorTime=M;exports.formatTrackName=I;exports.formatTyreCompound=J;exports.useCarLeaderboard=We;exports.useCarMetadata=Qe;exports.useCompetitionAllRounds=ze;exports.useCompetitionConfig=de;exports.useCompetitionEntryList=Z;exports.useCompetitionRound=xe;exports.useCompetitionStandings=pe;exports.useCompetitions=Ge;exports.useDriverLaps=le;exports.useDriverRating=Se;exports.useDriverRatings=Ls;exports.useDriverStats=Le;exports.useLeaderboardIndex=He;exports.useMarkAllNotificationsRead=Ie;exports.useMarkNotificationRead=De;exports.useNotifications=$e;exports.useNotificationsEnabled=Me;exports.usePitVox=k;exports.useRecentLaps=Oe;exports.useRegister=X;exports.useRegistrationMode=V;exports.useRegistrationStatus=_;exports.useRegistrationUrl=K;exports.useTrackLeaderboard=ce;exports.useUnreadCount=Rs;exports.useUpcomingEvents=Te;exports.useUserLookup=Y;exports.useWithdraw=ee;
|