@pitvox/partner-react 0.7.10 → 0.7.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +89 -89
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("react"),C=require("@tanstack/react-query"),X=b.createContext(null),Xe="https://cdn.pitvox.com",es="https://pitvox.com";let Z=null;function ss({partnerSlug:s=null,cdnUrl:t=Xe,pitvoxUrl:r=es,getSteamId:n,onRegister:a,onWithdraw:i,onFetchNotifications:o,onMarkNotificationRead:c,onMarkAllNotificationsRead:d,onFetchServerPassword:l,children:p}){const v=b.useMemo(()=>({partnerSlug:s,cdnUrl:t.replace(/\/$/,""),pitvoxUrl:r.replace(/\/$/,""),getSteamId:n||(()=>null),onRegister:a||null,onWithdraw:i||null,onFetchNotifications:o||null,onMarkNotificationRead:c||null,onMarkAllNotificationsRead:d||null,onFetchServerPassword:l||null}),[s,t,r,n,a,i,o,c,d,l]);let g=!1;try{C.useQueryClient(),g=!0}catch{g=!1}return g?e.jsx(X.Provider,{value:v,children:p}):(Z||(Z=new C.QueryClient({defaultOptions:{queries:{staleTime:6e4}}})),e.jsx(C.QueryClientProvider,{client:Z,children:e.jsx(X.Provider,{value:v,children:p})}))}function k(){const s=b.useContext(X);if(!s)throw new Error("usePitVox must be used within a <PitVoxPartnerProvider>");return s}async function S(s,t){const r=await fetch(`${s}/${t}`);if(!r.ok){if(r.status===404||r.status===403)return null;throw new Error(`CDN fetch failed: ${r.status}`)}return r.json()}function q(s,t,r,...n){const a=["leaderboards"];return s&&a.push(`partners/${s}`),t&&a.push(t),r&&a.push(`v/${r}`),[...a,...n].join("/")}function ve(s,t,r,n){const a=n||"default";return s?`laps/partners/${s}/${t}/${r}/${a}.json`:`laps/${t}/${r}/${a}.json`}function ge(s,t){return s?`laps/partners/${s}/${t}/index.json`:`laps/${t}/index.json`}function je(s){return s?`recent-laps/partners/${s}.json`:"recent-laps.json"}function P(s){if(!s&&s!==0)return"-";const t=Math.floor(s/1e3),r=Math.floor(t/60),n=t%60,a=s%1e3;return`${r}:${String(n).padStart(2,"0")}.${String(a).padStart(3,"0")}`}function D(s){return!s&&s!==0?"-":s>=6e4?P(s):(s/1e3).toFixed(3)}function M(s){if(!s)return"";let t=s;return t.startsWith("ks_")&&(t=t.slice(3)),t.split("_").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function B(s,t,r){if(!s)return"";const n=s.split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" "),a=r==="acc"||!r&&(t==null?void 0:t.toLowerCase())==="track config";if(!t||t==="default"||a)return n;const i=t.split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ");return`${n} ${i}`}function A(s){if(!s)return"-";try{return new Date(s).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}catch{return"-"}}function ee(s){if(!s)return"";const t=Date.now()-new Date(s).getTime(),r=Math.floor(t/1e3);if(r<60)return"Just now";const n=Math.floor(r/60);if(n<60)return`${n}m ago`;const a=Math.floor(n/60);if(a<24)return`${a}h ago`;const i=Math.floor(a/24);return i<30?`${i}d ago`:A(s)}function ts(s){return s==null?"":`${s>=0?"+":"-"}${(Math.abs(s)/1e3).toFixed(3)}`}function fe(s,t){const{type:r,title:n,trackId:a,trackLayout:i,carId:o,game:c,data:d}=s,l=typeof d=="string"?JSON.parse(d):d,p=a?B(a,i,c):null,v=o?M(o):null,g=[p,v].filter(Boolean).join(" — ");return r==="RECORD_BEATEN"&&g?`${l!=null&&l.beatenBySteamId&&t?t(l.beatenBySteamId).displayName:"Someone"} beat your record on ${g}`:r==="RECORD_SET"&&g?`You set a new record on ${g}`:n||"New notification"}function se(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 te(s){if(!s)return"-";const t=Number(s);return isNaN(t)?"-":t%1?`${t.toFixed(1)}L`:`${t}L`}function ns(s={}){var d,l,p,v,g,x;const{cdnUrl:t,partnerSlug:r}=k(),{game:n,gameVersion:a}=s,i=q(r,null,null,"index.json"),o=C.useQuery({queryKey:["pitvox","leaderboards",r,"index"],queryFn:()=>S(t,i),staleTime:3e4,refetchInterval:3e4}),c=b.useMemo(()=>{var h;if(!((h=o.data)!=null&&h.tracks))return[];let f=o.data.tracks;return n&&(f=f.filter(m=>m.game===n)),a&&(f=f.filter(m=>m.gameVersion===a)),f.map(m=>({id:m.trackId,layout:m.layout,game:m.game,gameVersion:m.gameVersion,displayName:B(m.trackId,m.layout,m.game),driverCount:m.driverCount||0,carCount:m.carCount||0,record:m.recordHolder?{visibleId:m.recordHolder.steamId||m.recordHolder.userId,carId:m.recordHolder.carId,carDisplayName:M(m.recordHolder.carId),lapTimeMs:m.recordHolder.lapTimeMs,timestamp:m.recordHolder.recordedAt}:null,recordByTag:m.recordByTag||null}))},[(d=o.data)==null?void 0:d.tracks,n,a]);return{...o,data:c,partner:((l=o.data)==null?void 0:l.partner)||null,generatedAt:(p=o.data)==null?void 0:p.generatedAt,totalLaps:((v=o.data)==null?void 0:v.totalLaps)||0,totalUsers:((g=o.data)==null?void 0:g.totalUsers)||0,versions:((x=o.data)==null?void 0:x.versions)||{}}}function Ne(s,t,r={}){const{cdnUrl:n,partnerSlug:a}=k(),{carId:i,game:o,gameVersion:c}=r,d=t||"default",l=q(a,o,c,`tracks/${s}/${d}.json`),{data:p,isLoading:v,error:g}=C.useQuery({queryKey:["pitvox","leaderboards",a,"track",s,d,o,c],queryFn:()=>S(n,l),enabled:!!s,staleTime:3e4,refetchInterval:3e4});return{data:b.useMemo(()=>{if(!(p!=null&&p.entries))return[];let f=p.entries;if(o&&(f=f.filter(h=>h.game===o)),!i){const h=new Map,m=new Map;for(const j of f){const u=j.steamId||j.userId;m.has(j.carId)||m.set(j.carId,new Set),m.get(j.carId).add(u),(!h.has(j.carId)||j.lapTimeMs<h.get(j.carId).lapTimeMs)&&h.set(j.carId,j)}return Array.from(h.values()).map(j=>{var u;return{...j,driverCount:((u=m.get(j.carId))==null?void 0:u.size)||0}}).sort((j,u)=>j.lapTimeMs-u.lapTimeMs)}return f.filter(h=>h.carId===i).sort((h,m)=>h.lapTimeMs-m.lapTimeMs)},[p==null?void 0:p.entries,i,o]),isLoading:v,error:g}}function be(s,t,r,n,a={}){var h,m;const{cdnUrl:i,partnerSlug:o}=k(),{showInvalid:c=!1,game:d,gameVersion:l}=a,p=s&&t?ve(o,s,t,r):null,v=r||"default",g=C.useQuery({queryKey:["pitvox","laps",o,s,t,v],queryFn:()=>S(i,p),enabled:!!s&&!!t,staleTime:3e4,refetchInterval:3e4}),x=b.useMemo(()=>{var j;return(j=g.data)!=null&&j.laps?g.data.laps.filter(u=>!(u.carId!==n||d&&u.game!==d||l&&u.gameVersion!==l||!c&&!u.isValid)).sort((u,y)=>u.lapTimeMs-y.lapTimeMs):[]},[(h=g.data)==null?void 0:h.laps,n,d,l,c]),f=b.useMemo(()=>{const j=x.filter(T=>T.isValid&&T.sector1Ms&&T.sector2Ms&&T.sector3Ms);if(j.length<2)return null;const u=Math.min(...j.map(T=>T.sector1Ms)),y=Math.min(...j.map(T=>T.sector2Ms)),N=Math.min(...j.map(T=>T.sector3Ms)),w=u+y+N,L=Math.min(...j.map(T=>T.lapTimeMs));return w>=L?null:{lapTimeMs:w,sector1Ms:u,sector2Ms:y,sector3Ms:N}},[x]);return{...g,data:x,driverName:((m=g.data)==null?void 0:m.driverName)||"Driver",theoreticalBest:f}}function ne(){const{cdnUrl:s}=k(),{data:t}=C.useQuery({queryKey:["pitvox","users","index"],queryFn:()=>S(s,"users/index.json"),staleTime:5*6e4,gcTime:30*6e4}),r=(t==null?void 0:t.users)||{};return(n,a)=>{const i=r[n];return{displayName:(i==null?void 0:i.displayName)||a||n||"Unknown",avatarUrl:(i==null?void 0:i.avatarUrl)||null,affiliations:(i==null?void 0:i.affiliations)||[]}}}function rs(){const{cdnUrl:s}=k(),{data:t}=C.useQuery({queryKey:["pitvox","cars","evo"],queryFn:()=>S(s,"cars/evo.json"),staleTime:5*6e4,gcTime:30*6e4});return{tags:(t==null?void 0:t.tags)||[],cars:(t==null?void 0:t.cars)||{}}}function as(){var a,i;const{cdnUrl:s,partnerSlug:t}=k(),r=je(t),n=C.useQuery({queryKey:["pitvox","recentLaps",t],queryFn:()=>S(s,r),staleTime:3e4,refetchInterval:3e4,gcTime:10*6e4});return{groups:((a=n.data)==null?void 0:a.groups)||[],generatedAt:((i=n.data)==null?void 0:i.generatedAt)||null,isLoading:n.isLoading}}function is(s,t){return Ne(s,null,{carId:t})}function os(){const{cdnUrl:s,partnerSlug:t}=k();return C.useQuery({queryKey:["pitvox","competitions",t],queryFn:async()=>{const r=await S(s,"competitions/index.json");return r!=null&&r.competitions?t?r.competitions.filter(n=>n.partnerSlug===t):r.competitions:[]},staleTime:6e4})}function re(s,t={}){const r=k(),n=t.partnerSlug||r.partnerSlug;return C.useQuery({queryKey:["pitvox","competition",n,s,"config"],queryFn:()=>S(r.cdnUrl,`competitions/${n}/${s}/config.json`),enabled:!!n&&!!s,staleTime:6e4})}function ae(s,t={}){const r=k(),n=t.partnerSlug||r.partnerSlug;return C.useQuery({queryKey:["pitvox","competition",n,s,"standings"],queryFn:()=>S(r.cdnUrl,`competitions/${n}/${s}/standings.json`),enabled:!!n&&!!s,staleTime:6e4})}function ye(s,t,r={}){const n=k(),a=r.partnerSlug||n.partnerSlug;return C.useQuery({queryKey:["pitvox","competition",a,s,"round",t],queryFn:()=>S(n.cdnUrl,`competitions/${a}/${s}/rounds/${t}.json`),enabled:!!a&&!!s&&t!=null,staleTime:6e4})}function Ce(s,t=[],r={}){const n=k(),a=r.partnerSlug||n.partnerSlug;return C.useQuery({queryKey:["pitvox","competition",a,s,"allRounds",t],queryFn:async()=>(await Promise.all(t.map(o=>S(n.cdnUrl,`competitions/${a}/${s}/rounds/${o}.json`).catch(()=>null)))).filter(Boolean),enabled:!!a&&!!s&&t.length>0,staleTime:6e4})}function ke(s,t={}){const r=k(),n=t.partnerSlug||r.partnerSlug;return C.useQuery({queryKey:["pitvox","competition",n,s,"leaderboard"],queryFn:()=>S(r.cdnUrl,`competitions/${n}/${s}/leaderboard.json`).catch(()=>null),enabled:!!n&&!!s,staleTime:6e4})}function we(s,t,r={}){const n=k(),a=r.partnerSlug||n.partnerSlug;return C.useQuery({queryKey:["pitvox","competition",a,s,"round",t,"laps"],queryFn:()=>S(n.cdnUrl,`competitions/${a}/${s}/rounds/${t}/laps.json`).catch(()=>null),enabled:!!a&&!!s&&t!=null,staleTime:6e4})}function ie(s,t={}){const r=k(),n=t.partnerSlug||r.partnerSlug;return C.useQuery({queryKey:["pitvox","competition",n,s,"entrylist"],queryFn:()=>S(r.cdnUrl,`competitions/${n}/${s}/entrylist.json`),enabled:!!n&&!!s,staleTime:6e4})}function V(s){const{cdnUrl:t,partnerSlug:r,getSteamId:n}=k(),a=n();return C.useQuery({queryKey:["pitvox","registration",r,s,a],queryFn:async()=>{var d;const i=await fetch(`${t}/competitions/${r}/${s}/entrylist.json`);if(!i.ok)return{isRegistered:!1,entryList:null};const o=await i.json();return{isRegistered:!!a&&((d=o.drivers)==null?void 0:d.some(l=>l.steamId===a)),entryList:o}},enabled:!!s,staleTime:6e4})}function oe(s){const{onRegister:t,partnerSlug:r,getSteamId:n}=k(),a=C.useQueryClient(),i=ne();return C.useMutation({mutationFn:o=>{if(!t)throw new Error("No onRegister callback provided to PitVoxPartnerProvider. Provide onRegister for in-app registration, or use useRegistrationUrl() to link to pitvox.com.");return t(s,o)},onSuccess:()=>{const o=n();if(a.setQueriesData({queryKey:["pitvox","registration",r,s]},c=>c?{...c,isRegistered:!0}:{isRegistered:!0,entryList:null}),o){const c=i(o),d={steamId:o,displayName:c.displayName,avatarUrl:c.avatarUrl};a.setQueriesData({queryKey:["pitvox","competition",r,s,"entrylist"]},l=>{var v;return l?((v=l.drivers)==null?void 0:v.some(g=>g.steamId===o))?l:{...l,drivers:[...l.drivers||[],d]}:{drivers:[d]}})}}})}function le(s){const{onWithdraw:t,partnerSlug:r,getSteamId:n}=k(),a=C.useQueryClient();return C.useMutation({mutationFn:i=>{if(!t)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||n();if(!o)throw new Error("No Steam ID available");return t(s,o)},onSuccess:()=>{const i=n();a.setQueriesData({queryKey:["pitvox","registration",r,s]},o=>o?{...o,isRegistered:!1}:{isRegistered:!1,entryList:null}),i&&a.setQueriesData({queryKey:["pitvox","competition",r,s,"entrylist"]},o=>o!=null&&o.drivers?{...o,drivers:o.drivers.filter(c=>c.steamId!==i)}:o)}})}function K(){const{onRegister:s,onWithdraw:t}=k(),r=!!(s&&t);return{isPowerMode:r,isBasicMode:!r}}function H(s){const{pitvoxUrl:t,partnerSlug:r}=k();return`${t}/p/${r}/competitions/${s}/register`}const ls={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"},Le=[{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 cs(s){for(const t of Le)if(t.tags.includes(s))return t.id;return"other"}function Se(s,t){if(t.size===0)return!0;const r={};for(const n of t){const a=cs(n);r[a]||(r[a]=[]),r[a].push(n)}for(const n of Object.values(r))if(!n.some(a=>s.includes(a)))return!1;return!0}function Te(s,t){const[r,n]=b.useState(new Set),a=s!==void 0,i=a?s:r,o=b.useCallback(d=>{const l=new Set(i);l.has(d)?l.delete(d):l.add(d),a&&t?t(l):n(l)},[i,a,t]),c=b.useCallback(()=>{a&&t?t(new Set):n(new Set)},[a,t]);return{activeTags:i,toggle:o,clear:c}}function Q(s){const[t,r]=b.useState(s),n=b.useCallback(a=>{r(i=>i.key===a?{key:a,dir:i.dir==="asc"?"desc":"asc"}:{key:a,dir:a.includes("timestamp")||a.includes("Date")?"desc":"asc"})},[]);return[t,n]}function O(s,t,r){return[...s].sort((n,a)=>{const i=r(n,t.key),o=r(a,t.key);if(i==null&&o==null)return 0;if(i==null)return 1;if(o==null)return-1;const c=typeof i=="string"?i.localeCompare(o):i-o;return t.dir==="desc"?-c:c})}function Re(s,t=!1){const r=t?s==null?void 0:s.filter(n=>n.isValid):s;return r!=null&&r.length?{s1:Math.min(...r.map(n=>n.sector1Ms).filter(Boolean)),s2:Math.min(...r.map(n=>n.sector2Ms).filter(Boolean)),s3:Math.min(...r.map(n=>n.sector3Ms).filter(Boolean))}:null}function ds({active:s,dir:t}){return s?t==="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 R({label:s,sortKey:t,config:r,onSort:n,className:a=""}){return e.jsx("th",{className:`pvx-th pvx-th--sortable ${a}`,onClick:()=>n(t),children:e.jsxs("span",{className:"pvx-th-inner",children:[s,e.jsx(ds,{active:r.key===t,dir:r.dir})]})})}function W({userId:s,getUserDisplay:t}){const{displayName:r,avatarUrl:n}=t(s);return e.jsxs("span",{className:"pvx-driver",children:[n?e.jsx("img",{src:n,alt:"",className:"pvx-driver-avatar"}):e.jsx("span",{className:"pvx-driver-avatar pvx-driver-avatar--placeholder"}),e.jsx("span",{className:"pvx-driver-name",children:r})]})}function ce({rank:s,podium:t=!1}){const r=t?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:r,children:s})}function Me({availableTags:s,activeTags:t,onToggle:r,onClear:n}){if(!s||s.length<2)return null;const a=Le.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:n,className:`pvx-tag ${t.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(c=>e.jsx("button",{onClick:()=>r(c),className:`pvx-tag ${t.has(c)?"pvx-tag--active":""}`,children:ls[c]||c},c))]},i.id))]})}function de({segments:s}){return e.jsx("nav",{className:"pvx-breadcrumb","aria-label":"Breadcrumb",children:e.jsx("ol",{className:"pvx-breadcrumb-list",children:s.map((t,r)=>{const n=r===s.length-1;return e.jsxs("li",{className:"pvx-breadcrumb-item",children:[r>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"})}),!n&&t.onClick?e.jsx("button",{onClick:t.onClick,className:"pvx-breadcrumb-link",children:t.label}):e.jsx("span",{className:"pvx-breadcrumb-current",children:t.label})]},t.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 F(){return e.jsx("div",{className:"pvx-loading",children:"Loading..."})}function ps(){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 xs(){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 us({tracks:s,isLoading:t,carMetadata:r,getUserDisplay:n,onTrackSelect:a,tags:i,onTagChange:o}){const[c,d]=Q({key:"record.timestamp",dir:"desc"}),{activeTags:l,toggle:p,clear:v}=Te(i,o),g=b.useMemo(()=>{var m;if(!((m=r==null?void 0:r.tags)!=null&&m.length))return[];const h=new Set;for(const j of s||[])j.recordByTag&&Object.keys(j.recordByTag).forEach(u=>h.add(u));return r.tags.filter(j=>h.has(j))},[s,r]),x=b.useMemo(()=>s?l.size===0?s:s.map(h=>{var u,y;if(!h.recordByTag)return null;let m=null;const j=new Set;for(const N of Object.values(h.recordByTag)){if(j.has(N.carId))continue;j.add(N.carId);const w=((y=(u=r==null?void 0:r.cars)==null?void 0:u[N.carId])==null?void 0:y.tags)||["sports_car"];Se(w,l)&&(!m||N.lapTimeMs<m.lapTimeMs)&&(m=N)}return m?{...h,record:{visibleId:m.steamId||m.identifier,carId:m.carId,carDisplayName:M(m.carId),lapTimeMs:m.lapTimeMs,timestamp:m.recordedAt}}:null}).filter(Boolean):[],[s,l,r]),f=b.useMemo(()=>O(x,c,(h,m)=>{var j,u;switch(m){case"displayName":return h.displayName;case"record.lapTimeMs":return(j=h.record)==null?void 0:j.lapTimeMs;case"driverCount":return h.driverCount||0;case"carCount":return h.carCount||0;case"record.timestamp":default:return(u=h.record)!=null&&u.timestamp?new Date(h.record.timestamp).getTime():0}}),[x,c]);return t?e.jsx(F,{}):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:g,activeTags:l,onToggle:p,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(R,{label:"Track",sortKey:"displayName",config:c,onSort:d}),e.jsx("th",{className:"pvx-th",children:"Record Holder"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Car"}),e.jsx(R,{label:"Lap Time",sortKey:"record.lapTimeMs",config:c,onSort:d}),e.jsx(R,{label:"Drivers",sortKey:"driverCount",config:c,onSort:d,className:"pvx-hidden-below-md"}),e.jsx(R,{label:"Cars",sortKey:"carCount",config:c,onSort:d,className:"pvx-hidden-below-lg"}),e.jsx(R,{label:"Date",sortKey:"record.timestamp",config:c,onSort:d,className:"pvx-hidden-below-xl"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:f.map(h=>{var m,j,u;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:(m=h.record)!=null&&m.visibleId?e.jsx(W,{userId:h.record.visibleId,getUserDisplay:n}):"-"}),e.jsx("td",{className:"pvx-td pvx-hidden-below-lg",children:((j=h.record)==null?void 0:j.carDisplayName)||"-"}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:h.record?P(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:(u=h.record)!=null&&u.timestamp?A(h.record.timestamp):"-"})]},`${h.id}|${h.layout||""}`)})})]})})]}):e.jsx(U,{message:"No lap times recorded yet."})}function ms({entries:s,isLoading:t,track:r,carMetadata:n,getUserDisplay:a,onCarSelect:i,onNavigate:o,tags:c,onTagChange:d}){const[l,p]=Q({key:"lapTimeMs",dir:"asc"}),{activeTags:v,toggle:g,clear:x}=Te(c,d),f=b.useMemo(()=>{var y,N,w;if(!s||!((y=n==null?void 0:n.tags)!=null&&y.length))return[];const u=new Set;for(const L of s)(((w=(N=n.cars)==null?void 0:N[L.carId])==null?void 0:w.tags)||["sports_car"]).forEach(E=>u.add(E));return n.tags.filter(L=>u.has(L))},[s,n]),h=b.useMemo(()=>s?v.size===0?s:s.filter(u=>{var N,w;const y=((w=(N=n==null?void 0:n.cars)==null?void 0:N[u.carId])==null?void 0:w.tags)||["sports_car"];return Se(y,v)}):[],[s,v,n]),m=b.useMemo(()=>O(h,l,(u,y)=>{switch(y){case"carId":return M(u.carId);case"driverCount":return u.driverCount||0;case"lapTimeMs":default:return u.lapTimeMs}}),[h,l]),j=[{key:"tracks",label:"Tracks",onClick:()=>o("tracks")},{key:"track",label:r.displayName}];return t?e.jsx(F,{}):e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx(de,{segments:j})}),e.jsx(Me,{availableTags:f,activeTags:v,onToggle:g,onClear:x}),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(R,{label:"Car",sortKey:"carId",config:l,onSort:p}),e.jsx("th",{className:"pvx-th",children:"Record Holder"}),e.jsx(R,{label:"Lap Time",sortKey:"lapTimeMs",config:l,onSort:p}),e.jsx(R,{label:"Drivers",sortKey:"driverCount",config:l,onSort:p,className:"pvx-hidden-below-md"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Date"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:m.map((u,y)=>e.jsxs("tr",{className:"pvx-row pvx-row--clickable",onClick:()=>i(u.carId),children:[e.jsx("td",{className:"pvx-td",children:e.jsx(ce,{rank:y+1,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:M(u.carId)}),e.jsx("td",{className:"pvx-td",children:e.jsx(W,{userId:u.steamId||u.userId,getUserDisplay:a})}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:P(u.lapTimeMs)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-md",children:u.driverCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-lg",children:u.recordedAt?A(u.recordedAt):"-"})]},u.carId))})]})}):e.jsx(U,{message:"No lap times for this track yet."})]})}function hs({entries:s,isLoading:t,track:r,carId:n,getUserDisplay:a,onDriverSelect:i,onNavigate:o,highlightId:c}){const[d,l]=Q({key:"lapTimeMs",dir:"asc"}),p=b.useMemo(()=>Re(s),[s]),v=b.useMemo(()=>O(s||[],d,(x,f)=>{switch(f){case"userId":return a(x.steamId||x.userId).displayName;case"lapCount":return x.lapCount||0;case"lapTimeMs":default:return x.lapTimeMs}}),[s,d,a]),g=[{key:"tracks",label:"Tracks",onClick:()=>o("tracks")},{key:"track",label:r.displayName,onClick:()=>o("track")},{key:"car",label:M(n)}];return t?e.jsx(F,{}):e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx(de,{segments:g})}),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(R,{label:"Driver",sortKey:"userId",config:d,onSort:l}),e.jsx(R,{label:"Lap Time",sortKey:"lapTimeMs",config:d,onSort:l}),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(R,{label:"Laps",sortKey:"lapCount",config:d,onSort:l,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((x,f)=>{const h=f+1,m=x.steamId||x.userId,j=p&&x.sector1Ms===p.s1,u=p&&x.sector2Ms===p.s2,y=p&&x.sector3Ms===p.s3,N=c&&m===c;return e.jsxs("tr",{className:`pvx-row pvx-row--clickable ${N?"pvx-row--highlight":h<=3?"pvx-row--podium":""}`,onClick:()=>i(m),children:[e.jsx("td",{className:"pvx-td",children:e.jsx(ce,{rank:h,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:e.jsx(W,{userId:m,getUserDisplay:a})}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:P(x.lapTimeMs)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${j?"pvx-td--best-sector":""}`,children:D(x.sector1Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${u?"pvx-td--best-sector":""}`,children:D(x.sector2Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${y?"pvx-td--best-sector":""}`,children:D(x.sector3Ms)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",title:se(x.tyreCompound),children:x.tyreCompound||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-xl",children:te(x.startingFuelL)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",children:x.lapCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-xl",children:x.recordedAt?A(x.recordedAt):"-"})]},m)})})]})}):e.jsx(U,{message:"No lap times for this car yet."})]})}function vs({userId:s,track:t,carId:r,game:n,gameVersion:a,showInvalid:i,getUserDisplay:o,onToggleInvalid:c,onNavigate:d}){const{data:l,driverName:p,theoreticalBest:v,isLoading:g}=be(s,t.id,t.layout,r,{showInvalid:i,game:n,gameVersion:a}),{displayName:x,avatarUrl:f}=o(s,p),h=b.useMemo(()=>Re(l,!0),[l]),m=b.useMemo(()=>{const u=(l==null?void 0:l.filter(y=>y.isValid))||[];return u.length?Math.min(...u.map(y=>y.lapTimeMs)):null},[l]),j=[{key:"tracks",label:"Tracks",onClick:()=>d("tracks")},{key:"track",label:t.displayName,onClick:()=>d("track")},{key:"car",label:M(r),onClick:()=>d("car")},{key:"driver",label:x}];return g?e.jsx(F,{}):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(de,{segments:j}),f?e.jsx("img",{src:f,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:c,className:"pvx-checkbox"}),e.jsx("span",{children:"Show invalid laps"})]})]}),v&&e.jsxs("div",{className:"pvx-theoretical-best",children:[e.jsx("span",{className:"pvx-theoretical-best-label",children:"Theoretical Best:"}),e.jsx("span",{className:"pvx-theoretical-best-time",children:P(v.lapTimeMs)}),e.jsxs("span",{className:"pvx-theoretical-best-sectors",children:["(",D(v.sector1Ms)," + ",D(v.sector2Ms)," + ",D(v.sector3Ms),")"]})]}),l!=null&&l.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:l.map((u,y)=>{const N=u.isValid&&u.lapTimeMs===m,w=h&&u.isValid&&u.sector1Ms===h.s1,L=h&&u.isValid&&u.sector2Ms===h.s2,T=h&&u.isValid&&u.sector3Ms===h.s3;let E="pvx-row";return u.isValid||(E+=" pvx-row--invalid"),N&&(E+=" pvx-row--personal-best"),e.jsxs("tr",{className:E,children:[e.jsx("td",{className:"pvx-td",children:e.jsx("span",{className:`pvx-rank ${N?"pvx-rank--gold":""}`,children:y+1})}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-md",children:u.lapNumber||"-"}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:P(u.lapTimeMs)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${w?"pvx-td--best-sector":""}`,children:D(u.sector1Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${L?"pvx-td--best-sector":""}`,children:D(u.sector2Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${T?"pvx-td--best-sector":""}`,children:D(u.sector3Ms)}),e.jsx("td",{className:"pvx-td",title:u.isValid?void 0:u.invalidReason||"Invalid",children:u.isValid?e.jsx(ps,{}):e.jsx(xs,{})}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",title:se(u.tyreCompound),children:u.tyreCompound||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",children:te(u.startingFuelL)}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-xl",children:A(u.timestamp)})]},u.id)})})]})}):e.jsx(U,{message:i?"No laps recorded for this combination.":'No valid laps. Try enabling "Show invalid laps".'})]})}function gs({drivers:s,isLoading:t,getUserDisplay:r,game:n,gameVersion:a,onComboSelect:i}){const[o,c]=Q({key:"rank",dir:"asc"}),[d,l]=b.useState(null),p=b.useMemo(()=>s?O(s,o,(g,x)=>{switch(x){case"rating":return g.rating;case"comboCount":return g.comboCount||0;case"distinctCars":return g.distinctCars||0;case"rank":default:return g.rank}}):[],[s,o]);if(t)return e.jsx(F,{});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(R,{label:"#",sortKey:"rank",config:o,onSort:c,className:"pvx-th--narrow"}),e.jsx("th",{className:"pvx-th",children:"Driver"}),e.jsx(R,{label:"Rating",sortKey:"rating",config:o,onSort:c}),e.jsx(R,{label:"Cars",sortKey:"distinctCars",config:o,onSort:c,className:"pvx-hidden-below-sm"}),e.jsx(R,{label:"Combos",sortKey:"comboCount",config:o,onSort:c,className:"pvx-hidden-below-sm"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:p.map(g=>{const x=d===g.identifier;return e.jsx(js,{driver:g,getUserDisplay:r,isExpanded:x,onToggle:()=>l(x?null:g.identifier),colCount:v,game:n,gameVersion:a,onComboSelect:i},g.identifier)})})]})})]})}function js({driver:s,getUserDisplay:t,isExpanded:r,onToggle:n,colCount:a,game:i,gameVersion:o,onComboSelect:c}){const d=s.identifier;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:`pvx-row pvx-row--clickable ${s.rank<=3?"pvx-row--podium":""}`,onClick:n,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(ce,{rank:s.rank,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:e.jsx(W,{userId:d,getUserDisplay:t})}),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 ${r?"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"})})]})})]}),r&&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((l,p)=>{const v=l.layout?`${l.trackId}|${l.layout}`:l.trackId,g=c?()=>c({track:v,car:l.carId,highlight:d,game:i,gameVersion:o}):void 0;return e.jsxs("div",{className:`pvx-rankings-combo ${g?"pvx-rankings-combo--clickable":""}`,onClick:g,role:g?"button":void 0,children:[e.jsxs("div",{className:"pvx-rankings-combo-info",children:[e.jsx("p",{className:"pvx-rankings-combo-track",children:B(l.trackId,l.layout,i)}),e.jsx("p",{className:"pvx-rankings-combo-car",children:M(l.carId)})]}),e.jsxs("div",{className:"pvx-rankings-combo-stats",children:[e.jsx("p",{className:"pvx-rankings-combo-time",children:P(l.lapTimeMs)}),e.jsxs("p",{className:`pvx-rankings-combo-pct ${l.percentile>=75?"pvx-rankings-combo-pct--high":l.percentile>=50?"pvx-rankings-combo-pct--mid":l.percentile>=25?"pvx-rankings-combo-pct--low":"pvx-rankings-combo-pct--bottom"}`,children:[l.percentile.toFixed(0),"%",e.jsxs("span",{className:"pvx-rankings-combo-rank",children:["(",l.rank,"/",l.totalDrivers,")"]})]})]})]},p)})})})})]})}const fs={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:"🇰🇷"},G=["🥇","🥈","🥉"],Ns={championship:"Championship",series:"Series",event:"Event",hotlap:"Hotlap"},bs=["PRACTICE","QUALIFYING","RACE"];function me(s){const t=bs.indexOf(s);if(t>=0)return t;const r=s.match(/^PRACTICE_(\d+)$/);return r?100+parseInt(r[1]):999}function z(s){const t=s.match(/^PRACTICE_(\d+)$/);return t?`P${t[1]}`:s}function pe({position:s}){const t=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:t,children:s})}function Y({nation:s}){const t=s&&fs[s];return t?e.jsx("span",{className:"pvx-nation-flag",title:s,children:t}):null}function ys({sessions:s,activeSession:t,onSelect:r}){if(!s||s.length<=1)return null;const n=[...s].sort((a,i)=>me(a.type)-me(i.type));return e.jsx("div",{className:"pvx-session-tabs",children:n.map(a=>e.jsx("button",{onClick:()=>r(a.type),className:`pvx-session-tab ${t===a.type?"pvx-session-tab--active":""}`,children:z(a.type)},a.type))})}function $e({type:s}){return e.jsx("span",{className:`pvx-comp-badge pvx-comp-badge--${s}`,children:Ns[s]||s})}function _({children:s,variant:t="default"}){return e.jsx("span",{className:`pvx-info-pill ${t!=="default"?`pvx-info-pill--${t}`:""}`,children:s})}function Cs(s){if(!s)return"TBD";const t=new Date(s);if(isNaN(t))return"TBD";const r=t.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"}),n=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${r} • ${n}`}function ks(s){return s.reduce((t,r)=>{var n;return(n=r.splits)!=null&&n.length?t?t.map((a,i)=>{const o=r.splits[i];return o&&o<a?o:a}):[...r.splits]:t},null)}function I({message:s="Loading..."}){return e.jsx("div",{className:"pvx-loading",children:s})}function $({message:s="No data available."}){return e.jsx("div",{className:"pvx-empty",children:e.jsx("p",{children:s})})}const xe=3;function De(s){const t=s==null?void 0:s.rounds;return t!=null&&t.length?t.every(r=>r.isFinalized):!1}function Pe(s){const t=s==null?void 0:s.rounds;if(!(t!=null&&t.length))return null;let r=null;for(const n of t){if(!n.startTime)continue;const a=new Date(n.startTime);isNaN(a)||(!r||a>r)&&(r=a)}return r}function ue(s,t=xe){if(!De(s))return"active";const r=Pe(s);if(!r)return"recently-completed";const n=t*24*60*60*1e3;return Date.now()-r.getTime()<=n?"recently-completed":"archived"}function ws(s,t,r=xe){if(!(s!=null&&s.length))return[];const n=new Set(Array.isArray(t)?t:[t]);return s.filter(a=>n.has(ue(a,r)))}function Ie(s,t=3){const r=s==null?void 0:s.standings;return Array.isArray(r)?[...r].sort((n,a)=>(n.position??999)-(a.position??999)).slice(0,t):[]}function Be({competitionId:s,topN:t=3,label:r="Completed",className:n}){const{data:a}=ae(s),i=Ie(a,t);return e.jsxs("div",{className:`pvx-comp-completed-badge ${n||""}`,children:[e.jsx("span",{className:"pvx-comp-completed-badge-label",children:r}),i.length>0&&e.jsx("ol",{className:"pvx-comp-completed-badge-podium",children:i.map((o,c)=>e.jsxs("li",{className:"pvx-comp-completed-badge-driver",children:[e.jsx("span",{className:"pvx-comp-completed-badge-medal","aria-hidden":"true",children:G[c]||""}),e.jsx(Y,{nation:o.nation}),e.jsx("span",{className:"pvx-comp-completed-badge-name",children:o.driverName})]},o.driverId||c))})]})}function Ls({competitions:s,isLoading:t,onSelect:r,onRegister:n,className:a}){return t?e.jsx(I,{message:"Loading competitions..."}):s!=null&&s.length?e.jsx("div",{className:`pvx-comp-grid ${a||""}`,children:s.map(i=>e.jsx(Ae,{comp:i,onSelect:r,onRegister:n||r},i.id))}):e.jsx($,{message:"No competitions available."})}function Ae({comp:s,onSelect:t,onRegister:r}){var u,y,N;const{cdnUrl:n}=k(),a=s.posterCdnPath?`${n}/${s.posterCdnPath}`:null,i=s.registration,o=(i==null?void 0:i.currentCount)||0,c=i==null?void 0:i.maxParticipants,d=c&&o>=c,l=(i==null?void 0:i.deadline)&&new Date(i.deadline)<new Date,p=(i==null?void 0:i.isOpen)&&!l&&!d,v=new Date,g=(u=s.rounds)==null?void 0:u.find(w=>w.startTime&&new Date(w.startTime)>=v),x=((y=s.rounds)==null?void 0:y.length)||0,f=((N=s.rounds)==null?void 0:N.filter(w=>w.isFinalized).length)||0,h=ue(s),m=h==="recently-completed"||h==="archived",j=s.type==="championship";return e.jsxs("div",{className:"pvx-comp-card",onClick:()=>t(s.id),role:"button",tabIndex:0,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),t(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(Ts,{})})}),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($e,{type:s.type}),s.game&&e.jsx(_,{children:s.game.toUpperCase()}),s.formatDescription&&s.formatDescription.split(", ").map((w,L)=>e.jsx(_,{variant:"format",children:w},L))]}),s.carsDescription&&e.jsx("div",{className:"pvx-comp-card-pills",children:s.carsDescription.split(", ").map((w,L)=>e.jsx(_,{children:w},L))}),e.jsxs("div",{className:"pvx-comp-card-schedule",children:[g?e.jsxs("span",{className:"pvx-comp-card-schedule-next",children:[e.jsx("span",{className:"pvx-comp-card-schedule-label",children:"Next:"})," ",s.type!=="hotlap"&&`R${g.roundNumber} `,g.track||"TBD"," · ",Cs(g.startTime)]}):x>0?e.jsxs("span",{className:"pvx-comp-card-schedule-next",children:[f,"/",x," rounds completed"]}):null,x>0&&e.jsxs("span",{className:"pvx-comp-card-round-count",children:[x," round",x!==1?"s":""]})]}),m&&j&&e.jsx(Be,{competitionId:s.id}),i&&!m&&e.jsx(Ss,{competitionId:s.id,regOpen:p,isFull:d,deadlinePassed:l,regCount:o,regMax:c,onRegister:r})]})]})}function Ss({competitionId:s,regOpen:t,isFull:r,deadlinePassed:n,regCount:a,regMax:i,onRegister:o}){const{isPowerMode:c}=K(),d=H(s),{data:l}=V(s),p=(l==null?void 0:l.isRegistered)||!1,v=i?a/i*100:0,g=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--${g}`,children:[a,"/",i||"∞"," drivers"]})}),e.jsx("div",{className:"pvx-comp-card-reg-action",children:p?e.jsx("button",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--registered",onClick:x=>{x.stopPropagation(),o(s)},children:"✓ Registered"}):t?c?e.jsx("button",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--open",onClick:x=>{x.stopPropagation(),o(s)},children:"Register"}):e.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--open",onClick:x=>x.stopPropagation(),children:"Register"}):e.jsx("span",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--closed",children:r?"Full":"Closed"})})]})}function Ts(){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 Ee({competitionId:s,className:t}){var c,d;const{data:r,isLoading:n}=ae(s),{data:a,isLoading:i}=re(s);if(n||i)return e.jsx(I,{message:"Loading standings..."});if(!((c=r==null?void 0:r.standings)!=null&&c.length))return e.jsx($,{message:"No standings data yet. Results will appear once rounds are finalised."});const o=((d=a==null?void 0:a.rounds)==null?void 0:d.filter(l=>l.isFinalized))||[];return e.jsxs("div",{className:`pvx-card ${t||""}`,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 ",r.roundsCompleted," round",r.roundsCompleted!==1?"s":"",r.countingRounds>0&&` (best ${r.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(l=>e.jsxs("th",{className:"pvx-th pvx-th--center pvx-hidden-below-md",title:l.track||`Round ${l.roundNumber}`,children:["R",l.roundNumber]},l.roundNumber))]})}),e.jsx("tbody",{className:"pvx-tbody",children:r.standings.map(l=>e.jsx(Rs,{driver:l,finalizedRounds:o},l.driverId||l.driverName))})]})})]})}function Rs({driver:s,finalizedRounds:t}){var o,c,d;const r=s.position<=3,n=new Map(((o=s.roundResults)==null?void 0:o.map(l=>[l.roundNumber,l]))||[]),a=((c=s.roundResults)==null?void 0:c.filter(l=>l.position===1).length)||0,i=((d=s.roundResults)==null?void 0:d.filter(l=>l.position<=3).length)||0;return e.jsxs("tr",{className:`pvx-row ${r?"pvx-row--podium":""}`,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(pe,{position:s.position})}),e.jsxs("td",{className:"pvx-td pvx-td--primary",children:[e.jsx(Y,{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}),t.map(l=>{const p=n.get(l.roundNumber),v=p==null?void 0:p.dropped;return e.jsx("td",{className:`pvx-td pvx-td--center pvx-hidden-below-md ${!v&&(p==null?void 0:p.position)===1?"pvx-standings-cell--p1":!v&&(p==null?void 0:p.position)===2?"pvx-standings-cell--p2":!v&&(p==null?void 0:p.position)===3?"pvx-standings-cell--p3":""}`,children:p?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",p.position]}),e.jsx("span",{className:"pvx-standings-round-pts",children:p.points})]}):e.jsx("span",{className:"pvx-td--muted",children:"-"})},l.roundNumber)})]})}function Ms({competitionId:s,roundNumber:t,className:r}){var d;const{data:n,isLoading:a}=ye(s,t);if(a)return e.jsx(I,{message:"Loading results..."});if(!n)return e.jsx($,{message:"No results for this round."});const o=(n.sessions||[]).find(l=>l.type==="RACE"),c=(d=o==null?void 0:o.results)==null?void 0:d.filter(l=>l.position<=3).sort((l,p)=>l.position-p.position);return e.jsxs("div",{className:`pvx-round-results ${r||""}`,children:[e.jsxs("div",{className:"pvx-round-results-header",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"pvx-round-results-title",children:["Round ",n.roundNumber,n.track?`: ${n.track}`:""]}),n.startTime&&e.jsx("p",{className:"pvx-round-results-date",children:new Date(n.startTime).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})})]}),(c==null?void 0:c.length)>0&&e.jsx("div",{className:"pvx-round-podium-summary",children:c.map(l=>e.jsxs("span",{className:"pvx-round-podium-item",children:[e.jsx("span",{children:G[l.position-1]}),e.jsx("span",{children:l.driverName})]},l.driverId))})]}),e.jsx(J,{round:n,competitionId:s})]})}function J({round:s,competitionId:t,className:r}){var p,v,g,x;const[n,a]=b.useState(null),i=(s==null?void 0:s.sessions)||[];if(!i.length)return e.jsx($,{message:"No session data for this round."});const{data:o}=we(t,s==null?void 0:s.roundNumber,{}),c=n||((p=i.find(f=>f.type==="RACE"))==null?void 0:p.type)||((v=i[0])==null?void 0:v.type),d=i.find(f=>f.type===c)||i[0],l=((x=(g=o==null?void 0:o.sessions)==null?void 0:g.find(f=>f.type===c))==null?void 0:x.drivers)||null;return e.jsxs("div",{className:r||"",children:[e.jsx(ys,{sessions:i,activeSession:c,onSelect:a}),e.jsx($s,{session:d,sessionLaps:l})]})}function $s({session:s,sessionLaps:t}){var c;const r=s.type==="RACE",[n,a]=b.useState(null);if(!((c=s.results)!=null&&c.length))return e.jsx($,{message:`No results for ${s.type}.`});const i=ks(s.results),o=r?7:4;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((d,l)=>{var g;const p=(g=t==null?void 0:t[d.driverId])==null?void 0:g.laps,v=n===d.driverId&&!!p;return e.jsx(Ds,{result:d,isRace:r,fastestSplits:i,rowIndex:l,hasLapDetail:!!p,isExpanded:v,onToggle:()=>a(v?null:d.driverId),driverLaps:v?p:null,colCount:o},d.driverId||l)})})]})})}function Ds({result:s,isRace:t,fastestSplits:r,rowIndex:n,hasLapDetail:a,isExpanded:i,onToggle:o,driverLaps:c,colCount:d}){const l=s.position<=3;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:`pvx-row ${l?"pvx-row--podium":""} ${a?"pvx-row--expandable":""}`,onClick:a?o:void 0,style:a?{cursor:"pointer"}:void 0,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(pe,{position:s.position})}),e.jsxs("td",{className:"pvx-td pvx-td--primary",children:[e.jsx(Y,{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:M(s.carId)}),e.jsx("td",{className:"pvx-td pvx-td--mono",children:e.jsx(Is,{bestLap:s.bestLapFormatted,hasBestLap:s.hasBestLap,splits:s.splits,fastestSplits:r,showAbove:n<=1})}),t&&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,")"]})]})]})]}),i&&c&&e.jsx("tr",{className:"pvx-row pvx-row--lap-detail",children:e.jsx("td",{colSpan:d,className:"pvx-td pvx-td--lap-detail",children:e.jsx(Ps,{laps:c})})})]})}function Ps({laps:s}){const t=Math.min(...s.filter(r=>r.valid&&r.timeMs>0).map(r=>r.timeMs));return e.jsxs("table",{className:"pvx-table pvx-table--laps",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"Lap"}),e.jsx("th",{className:"pvx-th",children:"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("tbody",{className:"pvx-tbody",children:s.map(r=>{var a;const n=r.valid&&r.timeMs===t;return e.jsxs("tr",{className:`pvx-row ${r.valid?"":"pvx-row--invalid"} ${n?"pvx-row--fastest":""}`,children:[e.jsx("td",{className:"pvx-td pvx-td--muted",children:r.lap}),e.jsx("td",{className:"pvx-td pvx-td--mono",children:r.time}),(r.splits||[]).map((i,o)=>e.jsx("td",{className:"pvx-td pvx-td--mono pvx-td--muted pvx-hidden-below-sm",children:i},o)),Array.from({length:Math.max(0,3-(((a=r.splits)==null?void 0:a.length)||0))}).map((i,o)=>e.jsx("td",{className:"pvx-td pvx-hidden-below-sm"},`pad-${o}`))]},r.lap)})})]})}function Is({bestLap:s,hasBestLap:t,splits:r,fastestSplits:n,showAbove:a}){return s?e.jsxs("span",{className:`pvx-best-lap-cell ${t?"pvx-best-lap-cell--fastest":""}`,children:[e.jsx("span",{className:"pvx-best-lap-time",children:s}),(r==null?void 0:r.length)>0&&e.jsx("span",{className:"pvx-splits-tooltip-anchor",children:e.jsx("span",{className:`pvx-splits-tooltip ${a?"":"pvx-splits-tooltip--above"}`,children:r.map((i,o)=>{const c=n&&i===n[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:c?"pvx-splits-tooltip-best":"",children:i})]},o)})})})]}):e.jsx("span",{className:"pvx-td--muted",children:"-"})}function Bs({competitionId:s,className:t}){const{getSteamId:r}=k(),{data:n,isLoading:a}=ie(s),i=r();if(a)return e.jsx(I,{message:"Loading drivers..."});const o=(n==null?void 0:n.drivers)||(n==null?void 0:n.entries)||[];return o.length?e.jsx("div",{className:`pvx-entry-grid ${t||""}`,children:o.map(c=>{var l,p;const d=i&&c.steamId===i;return e.jsxs("div",{className:`pvx-entry-card ${d?"pvx-entry-card--you":""}`,children:[c.avatarUrl?e.jsx("img",{src:c.avatarUrl,alt:"",className:"pvx-entry-avatar"}):e.jsx("div",{className:"pvx-entry-avatar pvx-entry-avatar--placeholder",children:((p=(l=c.displayName)==null?void 0:l.charAt(0))==null?void 0:p.toUpperCase())||"?"}),e.jsxs("span",{className:"pvx-entry-name",children:[c.displayName,d&&e.jsx("span",{className:"pvx-entry-you",children:" (you)"})]})]},c.steamId||c.driverId)})}):e.jsx($,{message:"No drivers registered yet."})}function As({competitionId:s,driverData:t,className:r,children:n}){const{data:a,isLoading:i}=V(s),{isPowerMode:o}=K(),c=H(s),d=oe(s),l=le(s),p=(a==null?void 0:a.isRegistered)||!1,v=i||d.isPending||l.isPending,g=d.error||l.error||null,x=()=>{o&&d.mutate(t||{})},f=()=>{o&&l.mutate()};return typeof n=="function"?n({isRegistered:p,isLoading:v,register:x,withdraw:f,error:g,isPowerMode:o,registrationUrl:c}):o?e.jsx("button",{className:`pvx-comp-register-btn ${r||""}`,onClick:p?f:x,disabled:v,children:v?"Loading...":p?"Withdraw":"Register"}):e.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:`pvx-comp-register-link ${r||""}`,children:p?"View Registration":"Register on PitVox"})}function Es({competitionId:s,registration:t,onWithdrawSuccess:r,className:n}){const{getSteamId:a}=k(),{isPowerMode:i}=K(),o=H(s),{data:c,isLoading:d}=V(s),{data:l,isLoading:p}=ie(s),v=oe(s),g=le(s),x=a(),f=(c==null?void 0:c.isRegistered)||!1,h=(l==null?void 0:l.drivers)||(l==null?void 0:l.entries)||[],m=t||{},j=h.length||m.currentCount||0,u=m.maxParticipants&&j>=m.maxParticipants,y=m.deadline&&new Date(m.deadline)<new Date,N=m.isOpen&&!y&&!u;return d||p?e.jsx(I,{message:"Loading registration..."}):f?e.jsx("div",{className:`pvx-reg-panel ${n||""}`,children:e.jsx(Fs,{competitionId:s,drivers:h,steamId:x,isPowerMode:i,registrationUrl:o,withdrawMutation:g,onWithdrawSuccess:r,registration:m})}):N?x?i?e.jsx("div",{className:`pvx-reg-panel ${n||""}`,children:e.jsx(Us,{competitionId:s,registerMutation:v,registration:m})}):e.jsx("div",{className:`pvx-reg-panel ${n||""}`,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 ${n||""}`,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 ${n||""}`,children:[e.jsx("div",{className:"pvx-reg-status-msg",children:u?"Registration is full.":y?"Registration deadline has passed.":"Registration is closed."}),h.length>0&&e.jsx(Ue,{drivers:h,steamId:x})]})}function Us({competitionId:s,registerMutation:t,registration:r}){const[n,a]=b.useState(""),[i,o]=b.useState("intermediate"),[c,d]=b.useState(""),l=x=>{x.preventDefault(),t.mutate({discordUsername:n||void 0,experience:i,comments:c||void 0})},p=r||{},v=p.currentCount||0,g=p.maxParticipants;return e.jsxs("form",{className:"pvx-reg-form",onSubmit:l,children:[e.jsxs("div",{className:"pvx-reg-form-header",children:[e.jsx("h3",{className:"pvx-reg-form-title",children:"Register"}),g&&e.jsx(Fe,{count:v,max:g})]}),t.error&&e.jsx("div",{className:"pvx-reg-error",children:t.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:n,onChange:x=>a(x.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:x=>o(x.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:c,onChange:x=>d(x.target.value)})]}),e.jsx("div",{className:"pvx-reg-actions",children:e.jsx("button",{type:"submit",className:"pvx-comp-register-btn",disabled:t.isPending,children:t.isPending?"Registering...":"Register"})})]})}function Fs({competitionId:s,drivers:t,steamId:r,isPowerMode:n,registrationUrl:a,withdrawMutation:i,onWithdrawSuccess:o,registration:c}){const[d,l]=b.useState(!1),p=()=>{i.mutate(void 0,{onSuccess:()=>{l(!1),o&&o()}})},v=c||{},g=t.length||v.currentCount||0,x=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"}),x&&e.jsx(Fe,{count:g,max:x})]}),e.jsx(Ue,{drivers:t,steamId:r}),i.error&&e.jsx("div",{className:"pvx-reg-error",children:i.error.message||"Withdrawal failed"}),n?e.jsx("div",{className:"pvx-reg-actions",children:d?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:()=>l(!1),children:"Cancel"}),e.jsx("button",{type:"button",className:"pvx-reg-danger-btn",onClick:p,disabled:i.isPending,children:i.isPending?"Unregistering...":"Yes, Unregister"})]})]}):e.jsx("button",{type:"button",className:"pvx-reg-unregister-btn",onClick:()=>l(!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 Ue({drivers:s,steamId:t}){if(!s.length)return e.jsx("div",{className:"pvx-reg-no-drivers",children:"No drivers registered yet."});const r=[...s].sort((n,a)=>{const i=t&&n.steamId===t?-1:0,o=t&&a.steamId===t?-1:0;return i-o});return e.jsx("div",{className:"pvx-reg-driver-list",children:r.map(n=>{var i,o;const a=t&&n.steamId===t;return e.jsxs("div",{className:`pvx-reg-driver-row ${a?"pvx-reg-driver-row--you":""}`,children:[n.avatarUrl?e.jsx("img",{src:n.avatarUrl,alt:"",className:"pvx-reg-driver-avatar"}):e.jsx("div",{className:"pvx-reg-driver-avatar pvx-reg-driver-avatar--placeholder",children:((o=(i=n.displayName)==null?void 0:i.charAt(0))==null?void 0:o.toUpperCase())||"?"}),e.jsxs("span",{className:"pvx-reg-driver-name",children:[n.displayName,a&&e.jsx("span",{className:"pvx-entry-you",children:" (you)"})]})]},n.steamId||n.driverId)})})}function Fe({count:s,max:t}){const r=t?s/t*100:0,n=r>=100?"full":r>=75?"warning":"ok";return e.jsxs("span",{className:`pvx-reg-capacity pvx-reg-capacity--${n}`,children:[s,"/",t," drivers"]})}function _s({competitionId:s,className:t}){const{data:r,isLoading:n}=re(s),a=(r==null?void 0:r.type)==="championship",i=(r==null?void 0:r.type)==="hotlap",{data:o}=ke(i?s:null),c=b.useMemo(()=>{var N;return((N=r==null?void 0:r.rounds)==null?void 0:N.filter(w=>w.isFinalized))||[]},[r]),d=b.useMemo(()=>c.map(N=>N.roundNumber),[c]),{data:l=[],isLoading:p}=Ce(s,d),v=i&&l.length>0?l[0]:null,g=(v==null?void 0:v.sessions)||[],x=i?"leaderboard":a?"standings":d.length>0?`round-${d[d.length-1]}`:null,[f,h]=b.useState(null),m=f||x;if(n||p)return e.jsx(I,{message:"Loading results..."});if(!r)return e.jsx($,{message:"Competition not found."});if(!c.length)return e.jsx($,{message:"No results available yet. Results will appear here once rounds are finalised."});const j=new Map(l.map(N=>[`round-${N.roundNumber}`,N])),u=[];if(a&&u.push({id:"standings",label:"Standings"}),i){u.push({id:"leaderboard",label:"Leaderboard"});for(const N of g)u.push({id:`session-${N.type}`,label:z(N.type)})}else for(const N of c)u.push({id:`round-${N.roundNumber}`,label:`R${N.roundNumber}`,track:null});const y=j.get(m);return e.jsxs("div",{className:t||"",children:[e.jsx("div",{className:"pvx-results-tabs",children:u.map(N=>e.jsxs("button",{className:`pvx-results-tab ${m===N.id?"pvx-results-tab--active":""}`,onClick:()=>h(N.id),title:N.track||void 0,children:[e.jsx("span",{className:"pvx-results-tab-label",children:N.label}),N.track&&e.jsx("span",{className:"pvx-results-tab-track",children:N.track})]},N.id))}),m==="standings"?e.jsx(Ee,{competitionId:s}):m==="leaderboard"?e.jsx(Vs,{leaderboard:o,config:r}):m!=null&&m.startsWith("session-")?e.jsx(Ks,{session:g.find(N=>`session-${N.type}`===m),round:v,competitionId:s}):y?e.jsx(qs,{round:y,competitionId:s}):e.jsx($,{message:"No results for this round."})]})}function qs({round:s,competitionId:t}){var i;const n=(s.sessions||[]).find(o=>o.type==="RACE"),a=(i=n==null?void 0:n.results)==null?void 0:i.filter(o=>o.position<=3).sort((o,c)=>o.position-c.position);return e.jsxs("div",{className:"pvx-card",children:[e.jsxs("div",{className:"pvx-card-header--split",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"pvx-card-title",children:["Round ",s.roundNumber,s.track?`: ${s.track}`:""]}),s.startTime&&e.jsx("span",{className:"pvx-standings-subtitle",children:new Date(s.startTime).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})})]}),(a==null?void 0:a.length)>0&&e.jsx("div",{className:"pvx-round-podium-summary",children:a.map(o=>e.jsxs("span",{className:"pvx-round-podium-item",children:[e.jsx("span",{children:G[o.position-1]}),e.jsx("span",{children:o.driverName})]},o.driverId))})]}),e.jsx(J,{round:s,competitionId:t})]})}function Vs({leaderboard:s,config:t}){var r;return(r=s==null?void 0:s.drivers)!=null&&r.length?e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header--split",children:e.jsxs("div",{children:[e.jsx("h4",{className:"pvx-card-title",children:s.track||(t==null?void 0:t.name)||"Hotlap Leaderboard"}),e.jsxs("span",{className:"pvx-standings-subtitle",children:[s.sessionsCompleted," session",s.sessionsCompleted!==1?"s":""," completed"]})]})}),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"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Laps"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Sessions"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Gap"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:s.drivers.map(n=>{const a=n.position===1?"":`+${((n.bestLapMs-s.drivers[0].bestLapMs)/1e3).toFixed(3)}`;return e.jsxs("tr",{className:`pvx-row ${n.position<=3?"pvx-row--podium":""}`,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(pe,{position:n.position})}),e.jsxs("td",{className:"pvx-td pvx-td--primary",children:[e.jsx(Y,{nation:n.nation}),n.driverName]}),e.jsx("td",{className:"pvx-td pvx-hidden-below-sm",children:M(n.carId)}),e.jsx("td",{className:"pvx-td pvx-td--mono",children:e.jsx("span",{className:n.position===1?"pvx-best-lap-cell--fastest":"",children:n.bestLapFormatted})}),e.jsx("td",{className:"pvx-td pvx-hidden-below-sm",children:n.totalLaps}),e.jsx("td",{className:"pvx-td pvx-hidden-below-sm",children:n.sessionsParticipated}),e.jsx("td",{className:"pvx-td pvx-td--mono pvx-td--muted pvx-hidden-below-sm",children:a})]},n.driverId)})})]})})]}):e.jsx($,{message:"No lap times recorded yet."})}function Ks({session:s,round:t,competitionId:r}){return s?e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx("h4",{className:"pvx-card-title",children:z(s.type)})}),e.jsx(J,{round:{...t,sessions:[s]},competitionId:r})]}):e.jsx($,{message:"Session data not available."})}function _e(s){const{cdnUrl:t}=k(),r=C.useQuery({queryKey:["pitvox","laps","global",s,"index"],queryFn:()=>S(t,ge(null,s)),enabled:!!s,staleTime:3e4,refetchInterval:3e4}),n=r.data;return{isLoading:r.isLoading,error:r.error,data:n?{driverName:n.driverName||"Driver",lapCount:n.lapCount||0,trackBreakdown:n.trackBreakdown||[],carBreakdown:n.carBreakdown||[],recordsHeld:n.recordsHeld||0,currentRecords:n.currentRecords||[],bestRanking:n.bestRanking??null,bestRankingTrackId:n.bestRankingTrackId??null,bestRankingLayout:n.bestRankingLayout??null,bestRankingCarId:n.bestRankingCarId??null,generatedAt:n.generatedAt}:null}}function qe(s={}){const{cdnUrl:t,partnerSlug:r}=k(),{game:n,gameVersion:a,enabled:i=!0}=s,o=q(r,n,a,"ratings.json");return C.useQuery({queryKey:["pitvox","ratings",r,n||null,a||null],queryFn:()=>S(t,o),staleTime:3e4,refetchInterval:3e4,enabled:i})}function Ve(s){var n;const t=qe(),r=b.useMemo(()=>{var a;return!((a=t.data)!=null&&a.drivers)||!s?null:t.data.drivers.find(i=>i.identifier===s)||null},[(n=t.data)==null?void 0:n.drivers,s]);return{isLoading:t.isLoading,error:t.error,data:r?{rating:r.rating,rank:r.rank,totalDrivers:t.data.driverCount||t.data.drivers.length,comboCount:r.comboCount||0,distinctCars:r.distinctCars||0,combos:r.combos||[]}:null}}function Hs(s={}){const t=qe(s);return{data:t.data||null,isLoading:t.isLoading,error:t.error}}function Ke(){const{cdnUrl:s,partnerSlug:t,getSteamId:r,onFetchServerPassword:n}=k(),a=r(),{data:i,isLoading:o}=C.useQuery({queryKey:["pitvox","competitions",t],queryFn:async()=>{const x=await S(s,"competitions/index.json");return x!=null&&x.competitions?x.competitions.filter(f=>f.partnerSlug===t):[]},staleTime:6e4}),c=(i==null?void 0:i.map(x=>x.id))||[],d=C.useQueries({queries:c.map(x=>({queryKey:["pitvox","competition",t,x,"entrylist"],queryFn:()=>S(s,`competitions/${t}/${x}/entrylist.json`),enabled:!!a&&c.length>0,staleTime:6e4}))}),l=d.some(x=>x.isLoading),p=b.useMemo(()=>{var h,m;if(!i||!a||l)return[];const x=new Date,f=[];for(let j=0;j<i.length;j++){const u=i[j],y=(h=d[j])==null?void 0:h.data;if(!((m=y==null?void 0:y.drivers)==null?void 0:m.some(L=>L.steamId===a)))continue;const w=u.rounds||[];for(const L of w)L.isFinalized||!L.startTime||new Date(L.startTime)<=x||f.push({competitionId:u.id,competitionName:u.name,roundNumber:L.roundNumber,track:L.track||"TBD",startTime:L.startTime})}return f.sort((j,u)=>new Date(j.startTime)-new Date(u.startTime)),f.length>0&&(f[0].isNext=!0),f},[i,a,l,d]),v=C.useQueries({queries:p.map(x=>({queryKey:["pitvox","serverInfo",x.competitionId,x.roundNumber],queryFn:()=>n(x.competitionId,x.roundNumber),enabled:!!n&&p.length>0,staleTime:5*6e4,retry:!1}))});return{data:b.useMemo(()=>p.length?n?p.map((x,f)=>{var m;const h=(m=v[f])==null?void 0:m.data;return h!=null&&h.success?{...x,serverAddress:h.serverAddress||null,serverPassword:h.serverPassword||null}:x}):p:[],[p,n,v]),isLoading:o||!!a&&l}}function He(){const{onFetchNotifications:s}=k();return!!s}function Qe(s={}){const{onFetchNotifications:t,partnerSlug:r}=k(),{limit:n=20,unreadOnly:a=!1}=s;return C.useQuery({queryKey:["pitvox","notifications",r,{limit:n,unreadOnly:a}],queryFn:()=>t({limit:n,unreadOnly:a}),enabled:!!t,staleTime:3e4,refetchInterval:3e4})}function Qs(){const{onFetchNotifications:s,partnerSlug:t}=k(),{data:r,isLoading:n}=C.useQuery({queryKey:["pitvox","notifications",t,{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:r??0,isLoading:n}}function Oe(){const{onMarkNotificationRead:s,partnerSlug:t}=k(),r=C.useQueryClient();return C.useMutation({mutationFn:n=>{if(!s)throw new Error("No onMarkNotificationRead callback provided to PitVoxPartnerProvider.");return s(n)},onSuccess:(n,a)=>{r.setQueriesData({queryKey:["pitvox","notifications",t]},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 We(){const{onMarkAllNotificationsRead:s,partnerSlug:t}=k(),r=C.useQueryClient();return C.useMutation({mutationFn:()=>{if(!s)throw new Error("No onMarkAllNotificationsRead callback provided to PitVoxPartnerProvider.");return s()},onSuccess:()=>{r.setQueriesData({queryKey:["pitvox","notifications",t]},n=>n!=null&&n.notifications?{...n,unreadCount:0,notifications:n.notifications.map(a=>({...a,isRead:!0,readAt:a.readAt||new Date().toISOString()}))}:n)}})}function Ge({driverName:s,avatarUrl:t,memberSince:r,className:n=""}){const a=r?new Date(r).toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric"}):null;return e.jsxs("div",{className:`pvx-card pvx-dash-profile ${n}`,children:[t?e.jsx("img",{src:t,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 Os(){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 Gs(){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 he({icon:s,value:t,label:r,items:n,labelKey:a,countKey:i}){const[o,c]=b.useState(!1),d=b.useRef(null);b.useEffect(()=>{if(!o)return;function p(v){d.current&&!d.current.contains(v.target)&&c(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[o]);const l=n!=null&&n.length?n.slice().sort((p,v)=>v[i]-p[i]):null;return e.jsxs("div",{ref:d,className:`pvx-dash-stat-card ${l?"pvx-dash-stat-card--clickable":""}`,onClick:l?()=>c(p=>!p):void 0,children:[s,e.jsxs("div",{className:"pvx-dash-stat-content",children:[e.jsx("span",{className:"pvx-dash-stat-value",children:t}),e.jsx("span",{className:"pvx-dash-stat-label",children:r})]}),l&&e.jsx("div",{className:`pvx-dash-tooltip pvx-dash-tooltip--scrollable ${o?"pvx-dash-tooltip--open":""}`,children:l.map((p,v)=>e.jsxs("div",{className:"pvx-dash-tooltip-row",children:[e.jsx("span",{className:"pvx-dash-tooltip-label",children:p[a]}),e.jsx("span",{className:"pvx-dash-tooltip-value",children:p[i]})]},v))})]})}function ze({stats:s,rating:t,className:r=""}){if(!s)return null;const n=s.trackBreakdown.map(i=>({name:B(i.trackId,i.layout),lapCount:i.lapCount})),a=s.carBreakdown.map(i=>({name:M(i.carId),lapCount:i.lapCount}));return e.jsxs("div",{className:`pvx-dash-stats ${r}`,children:[e.jsx(he,{icon:e.jsx(Os,{}),value:s.lapCount.toLocaleString(),label:"Total Laps",items:n,labelKey:"name",countKey:"lapCount"}),e.jsx(he,{icon:e.jsx(Ws,{}),value:s.carBreakdown.length,label:"Cars Used",items:a,labelKey:"name",countKey:"lapCount"}),t&&e.jsxs("div",{className:"pvx-dash-stat-card pvx-dash-stat-card--rating",children:[e.jsx(Gs,{}),e.jsxs("div",{className:"pvx-dash-stat-content",children:[e.jsx("span",{className:"pvx-dash-stat-value",children:t.rating.toFixed(1)}),e.jsx("span",{className:"pvx-dash-stat-label",children:"Driver Rating"}),e.jsxs("span",{className:"pvx-dash-stat-sub",children:["#",t.rank," of ",t.totalDrivers]})]})]})]})}function Ye({records:s,className:t=""}){const r=b.useMemo(()=>s!=null&&s.length?s.slice().sort((n,a)=>{const i=n.recordedAt?new Date(n.recordedAt).getTime():0;return(a.recordedAt?new Date(a.recordedAt).getTime():0)-i}):[],[s]);return r.length?e.jsxs("div",{className:`pvx-card ${t}`,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:["(",r.length,")"]})]})}),e.jsx("div",{className:"pvx-dash-records-list",children:r.map((n,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:B(n.trackId,n.layout,n.game)}),e.jsx("span",{className:"pvx-dash-record-car",children:M(n.carId)})]}),e.jsxs("div",{className:"pvx-dash-record-time",children:[e.jsx("span",{className:"pvx-dash-record-lap",children:P(n.lapTimeMs)}),e.jsxs("span",{className:`pvx-dash-game-badge pvx-dash-game-badge--${n.game||"evo"}`,children:[(n.game||"evo").toUpperCase(),n.gameVersion?` ${n.gameVersion}`:""]})]})]},a))})]}):null}function Je({events:s,isLoading:t,className:r,limit:n=3}){if(t)return e.jsx("div",{className:"pvx-loading",children:"Loading upcoming events..."});if(!(s!=null&&s.length))return null;const a=n?s.slice(0,n):s,i=s.length-a.length;return 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(Js,{}),"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(zs,{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:o.dediStatus==="running"?"Live now":o.dediStatus==="provisioning"?"Starting...":Ys(o.startTime)}),o.dediStatus==="running"&&e.jsx("span",{className:"pvx-upcoming-badge pvx-upcoming-badge--live",children:"Live"}),!o.dediStatus&&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 zs({password:s,address:t}){const[r,n]=b.useState(!1),[a,i]=b.useState(!1),o=t?s?`join:${t}|${s}`:`join:${t}`:null,c=b.useCallback(async()=>{if(o)try{await navigator.clipboard.writeText(o),n(!0),setTimeout(()=>n(!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:c,title:"Copy join string to clipboard",children:[e.jsx(Xs,{})," ",r?"Copied!":"Join"]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"pvx-server-detail pvx-server-detail--clickable",onClick:()=>i(d=>!d),title:a?"Hide password":"Reveal password",children:a?e.jsx(st,{}):e.jsx(et,{})}),a&&e.jsxs("span",{className:"pvx-server-detail",children:[e.jsx(Zs,{})," ",s]})]})]})}function Ys(s){const t=new Date(s).getTime()-Date.now();if(t<=0)return"Now";const r=Math.floor(t/(1e3*60*60));if(r<1)return"Less than 1 hour";if(r<24)return`in ${r}h`;const n=Math.floor(r/24);if(n===1)return"Tomorrow";if(n<7)return`in ${n} days`;if(n<30){const a=Math.floor(n/7);return`in ${a} week${a!==1?"s":""}`}return ee(s)}function Js(){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 Zs(){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 Xs(){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 et(){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 st(){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 Ze({notifications:s,unreadCount:t=0,onMarkRead:r,onMarkAllRead:n,isLoading:a,className:i}){const o=ne();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(rt,{}),"Notifications",t>0&&e.jsx("span",{className:"pvx-notif-badge",children:t>99?"99+":t})]}),t>0&&n&&e.jsx("button",{className:"pvx-notif-mark-all",onClick:n,children:"Mark all read"})]}),s!=null&&s.length?e.jsx("div",{className:"pvx-notif-list",children:s.map(c=>e.jsx(tt,{notification:c,getUserDisplay:o,onMarkRead:r},c.id))}):e.jsx("div",{className:"pvx-notif-empty",children:"No notifications"})]})}function tt({notification:s,getUserDisplay:t,onMarkRead:r}){const n=()=>{!s.isRead&&r&&r(s.id)};return e.jsxs("button",{className:`pvx-notif-item ${s.isRead?"":"pvx-notif-item--unread"}`,onClick:n,children:[e.jsx(nt,{type:s.type}),e.jsxs("div",{className:"pvx-notif-content",children:[e.jsx("span",{className:"pvx-notif-message",children:fe(s,t)}),e.jsx("span",{className:"pvx-notif-time",children:ee(s.createdAt)})]}),!s.isRead&&e.jsx("span",{className:"pvx-notif-dot"})]})}function nt({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 rt(){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 at({steamId:s,avatarUrl:t,memberSince:r,className:n=""}){const{data:a,isLoading:i,error:o}=_e(s),{data:c,isLoading:d}=Ve(s),{data:l,isLoading:p}=Ke(),v=He(),{data:g,isLoading:x}=Qe({limit:10}),f=Oe(),h=We();return i||d?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 ${n}`,children:[e.jsx(Ge,{driverName:a.driverName,avatarUrl:t,memberSince:r}),e.jsx(ze,{stats:a,rating:c}),s&&e.jsx(Je,{events:l,isLoading:p}),e.jsxs("div",{className:`pvx-dash-row ${v?"pvx-dash-row--2col":""}`,children:[e.jsx(Ye,{records:a.currentRecords}),v&&e.jsx(Ze,{notifications:g==null?void 0:g.notifications,unreadCount:(g==null?void 0:g.unreadCount)||0,onMarkRead:m=>f.mutate(m),onMarkAllRead:()=>h.mutate(),isLoading:x})]})]}):e.jsx("div",{className:"pvx-empty",children:"No data available yet. Start driving to see your stats!"})}exports.CarsTable=ms;exports.CompEmptyState=$;exports.CompLoadingState=I;exports.CompetitionCard=Ae;exports.CompetitionCards=Ls;exports.CompetitionResultsTabs=_s;exports.CompletedBadge=Be;exports.DEFAULT_COMPLETION_GRACE_DAYS=xe;exports.DriverDashboard=at;exports.DriverProfile=Ge;exports.DriversTable=hs;exports.EntryList=Bs;exports.InfoPill=_;exports.LapHistoryTable=vs;exports.NotificationsCard=Ze;exports.PODIUM_MEDALS=G;exports.PitVoxPartnerProvider=ss;exports.RankingsTable=gs;exports.RecordsTable=Ye;exports.RegisterButton=As;exports.RegistrationPanel=Es;exports.RoundResults=Ms;exports.RoundSessionResults=J;exports.StandingsTable=Ee;exports.StatsCards=ze;exports.TracksTable=us;exports.TypeBadge=$e;exports.UpcomingEvents=Je;exports.buildDriverIndexPath=ge;exports.buildLapsPath=ve;exports.buildLeaderboardPath=q;exports.buildRecentLapsPath=je;exports.fetchCdnJson=S;exports.filterCompetitionsByStatus=ws;exports.formatCarName=M;exports.formatDate=A;exports.formatDelta=ts;exports.formatFuel=te;exports.formatLapTime=P;exports.formatNotificationMessage=fe;exports.formatRelativeTime=ee;exports.formatSectorTime=D;exports.formatSessionLabel=z;exports.formatTrackName=B;exports.formatTyreCompound=se;exports.getCompetitionPodium=Ie;exports.getCompetitionStatus=ue;exports.getCompletionDate=Pe;exports.isCompetitionComplete=De;exports.useCarLeaderboard=is;exports.useCarMetadata=rs;exports.useCompetitionAllRounds=Ce;exports.useCompetitionConfig=re;exports.useCompetitionEntryList=ie;exports.useCompetitionLeaderboard=ke;exports.useCompetitionRound=ye;exports.useCompetitionRoundLaps=we;exports.useCompetitionStandings=ae;exports.useCompetitions=os;exports.useDriverLaps=be;exports.useDriverRating=Ve;exports.useDriverRatings=Hs;exports.useDriverStats=_e;exports.useLeaderboardIndex=ns;exports.useMarkAllNotificationsRead=We;exports.useMarkNotificationRead=Oe;exports.useNotifications=Qe;exports.useNotificationsEnabled=He;exports.usePitVox=k;exports.useRecentLaps=as;exports.useRegister=oe;exports.useRegistrationMode=K;exports.useRegistrationStatus=V;exports.useRegistrationUrl=H;exports.useTrackLeaderboard=Ne;exports.useUnreadCount=Qs;exports.useUpcomingEvents=Ke;exports.useUserLookup=ne;exports.useWithdraw=le;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("react"),C=require("@tanstack/react-query"),X=b.createContext(null),Xe="https://cdn.pitvox.com",es="https://pitvox.com";let Z=null;function ss({partnerSlug:s=null,cdnUrl:t=Xe,pitvoxUrl:r=es,getSteamId:n,onRegister:a,onWithdraw:i,onFetchNotifications:o,onMarkNotificationRead:c,onMarkAllNotificationsRead:d,onFetchServerPassword:l,children:p}){const v=b.useMemo(()=>({partnerSlug:s,cdnUrl:t.replace(/\/$/,""),pitvoxUrl:r.replace(/\/$/,""),getSteamId:n||(()=>null),onRegister:a||null,onWithdraw:i||null,onFetchNotifications:o||null,onMarkNotificationRead:c||null,onMarkAllNotificationsRead:d||null,onFetchServerPassword:l||null}),[s,t,r,n,a,i,o,c,d,l]);let g=!1;try{C.useQueryClient(),g=!0}catch{g=!1}return g?e.jsx(X.Provider,{value:v,children:p}):(Z||(Z=new C.QueryClient({defaultOptions:{queries:{staleTime:6e4}}})),e.jsx(C.QueryClientProvider,{client:Z,children:e.jsx(X.Provider,{value:v,children:p})}))}function k(){const s=b.useContext(X);if(!s)throw new Error("usePitVox must be used within a <PitVoxPartnerProvider>");return s}async function S(s,t){const r=await fetch(`${s}/${t}`);if(!r.ok){if(r.status===404||r.status===403)return null;throw new Error(`CDN fetch failed: ${r.status}`)}return r.json()}function q(s,t,r,...n){const a=["leaderboards"];return s&&a.push(`partners/${s}`),t&&a.push(t),r&&a.push(`v/${r}`),[...a,...n].join("/")}function ve(s,t,r,n){const a=n||"default";return s?`laps/partners/${s}/${t}/${r}/${a}.json`:`laps/${t}/${r}/${a}.json`}function ge(s,t){return s?`laps/partners/${s}/${t}/index.json`:`laps/${t}/index.json`}function je(s){return s?`recent-laps/partners/${s}.json`:"recent-laps.json"}function P(s){if(!s&&s!==0)return"-";const t=Math.floor(s/1e3),r=Math.floor(t/60),n=t%60,a=s%1e3;return`${r}:${String(n).padStart(2,"0")}.${String(a).padStart(3,"0")}`}function D(s){return!s&&s!==0?"-":s>=6e4?P(s):(s/1e3).toFixed(3)}function M(s){if(!s)return"";let t=s;return t.startsWith("ks_")&&(t=t.slice(3)),t.split("_").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function B(s,t,r){if(!s)return"";const n=s.split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" "),a=r==="acc"||!r&&(t==null?void 0:t.toLowerCase())==="track config";if(!t||t==="default"||a)return n;const i=t.split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ");return`${n} ${i}`}function A(s){if(!s)return"-";try{return new Date(s).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}catch{return"-"}}function ee(s){if(!s)return"";const t=Date.now()-new Date(s).getTime(),r=Math.floor(t/1e3);if(r<60)return"Just now";const n=Math.floor(r/60);if(n<60)return`${n}m ago`;const a=Math.floor(n/60);if(a<24)return`${a}h ago`;const i=Math.floor(a/24);return i<30?`${i}d ago`:A(s)}function ts(s){return s==null?"":`${s>=0?"+":"-"}${(Math.abs(s)/1e3).toFixed(3)}`}function fe(s,t){const{type:r,title:n,trackId:a,trackLayout:i,carId:o,game:c,data:d}=s,l=typeof d=="string"?JSON.parse(d):d,p=a?B(a,i,c):null,v=o?M(o):null,g=[p,v].filter(Boolean).join(" — ");return r==="RECORD_BEATEN"&&g?`${l!=null&&l.beatenBySteamId&&t?t(l.beatenBySteamId).displayName:"Someone"} beat your record on ${g}`:r==="RECORD_SET"&&g?`You set a new record on ${g}`:n||"New notification"}function se(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 te(s){if(!s)return"-";const t=Number(s);return isNaN(t)?"-":t%1?`${t.toFixed(1)}L`:`${t}L`}function ns(s={}){var d,l,p,v,g,x;const{cdnUrl:t,partnerSlug:r}=k(),{game:n,gameVersion:a}=s,i=q(r,null,null,"index.json"),o=C.useQuery({queryKey:["pitvox","leaderboards",r,"index"],queryFn:()=>S(t,i),staleTime:3e4,refetchInterval:3e4}),c=b.useMemo(()=>{var h;if(!((h=o.data)!=null&&h.tracks))return[];let f=o.data.tracks;return n&&(f=f.filter(m=>m.game===n)),a&&(f=f.filter(m=>m.gameVersion===a)),f.map(m=>({id:m.trackId,layout:m.layout,game:m.game,gameVersion:m.gameVersion,displayName:B(m.trackId,m.layout,m.game),driverCount:m.driverCount||0,carCount:m.carCount||0,record:m.recordHolder?{visibleId:m.recordHolder.steamId||m.recordHolder.userId,carId:m.recordHolder.carId,carDisplayName:M(m.recordHolder.carId),lapTimeMs:m.recordHolder.lapTimeMs,timestamp:m.recordHolder.recordedAt}:null,recordByTag:m.recordByTag||null}))},[(d=o.data)==null?void 0:d.tracks,n,a]);return{...o,data:c,partner:((l=o.data)==null?void 0:l.partner)||null,generatedAt:(p=o.data)==null?void 0:p.generatedAt,totalLaps:((v=o.data)==null?void 0:v.totalLaps)||0,totalUsers:((g=o.data)==null?void 0:g.totalUsers)||0,versions:((x=o.data)==null?void 0:x.versions)||{}}}function Ne(s,t,r={}){const{cdnUrl:n,partnerSlug:a}=k(),{carId:i,game:o,gameVersion:c}=r,d=t||"default",l=q(a,o,c,`tracks/${s}/${d}.json`),{data:p,isLoading:v,error:g}=C.useQuery({queryKey:["pitvox","leaderboards",a,"track",s,d,o,c],queryFn:()=>S(n,l),enabled:!!s,staleTime:3e4,refetchInterval:3e4});return{data:b.useMemo(()=>{if(!(p!=null&&p.entries))return[];let f=p.entries;if(o&&(f=f.filter(h=>h.game===o)),!i){const h=new Map,m=new Map;for(const j of f){const u=j.steamId||j.userId;m.has(j.carId)||m.set(j.carId,new Set),m.get(j.carId).add(u),(!h.has(j.carId)||j.lapTimeMs<h.get(j.carId).lapTimeMs)&&h.set(j.carId,j)}return Array.from(h.values()).map(j=>{var u;return{...j,driverCount:((u=m.get(j.carId))==null?void 0:u.size)||0}}).sort((j,u)=>j.lapTimeMs-u.lapTimeMs)}return f.filter(h=>h.carId===i).sort((h,m)=>h.lapTimeMs-m.lapTimeMs)},[p==null?void 0:p.entries,i,o]),isLoading:v,error:g}}function be(s,t,r,n,a={}){var h,m;const{cdnUrl:i,partnerSlug:o}=k(),{showInvalid:c=!1,game:d,gameVersion:l}=a,p=s&&t?ve(o,s,t,r):null,v=r||"default",g=C.useQuery({queryKey:["pitvox","laps",o,s,t,v],queryFn:()=>S(i,p),enabled:!!s&&!!t,staleTime:3e4,refetchInterval:3e4}),x=b.useMemo(()=>{var j;return(j=g.data)!=null&&j.laps?g.data.laps.filter(u=>!(u.carId!==n||d&&u.game!==d||l&&u.gameVersion!==l||!c&&!u.isValid)).sort((u,y)=>u.lapTimeMs-y.lapTimeMs):[]},[(h=g.data)==null?void 0:h.laps,n,d,l,c]),f=b.useMemo(()=>{const j=x.filter(T=>T.isValid&&T.sector1Ms&&T.sector2Ms&&T.sector3Ms);if(j.length<2)return null;const u=Math.min(...j.map(T=>T.sector1Ms)),y=Math.min(...j.map(T=>T.sector2Ms)),N=Math.min(...j.map(T=>T.sector3Ms)),w=u+y+N,L=Math.min(...j.map(T=>T.lapTimeMs));return w>=L?null:{lapTimeMs:w,sector1Ms:u,sector2Ms:y,sector3Ms:N}},[x]);return{...g,data:x,driverName:((m=g.data)==null?void 0:m.driverName)||"Driver",theoreticalBest:f}}function ne(){const{cdnUrl:s}=k(),{data:t}=C.useQuery({queryKey:["pitvox","users","index"],queryFn:()=>S(s,"users/index.json"),staleTime:5*6e4,gcTime:30*6e4}),r=(t==null?void 0:t.users)||{};return(n,a)=>{const i=r[n];return{displayName:(i==null?void 0:i.displayName)||a||n||"Unknown",avatarUrl:(i==null?void 0:i.avatarUrl)||null,affiliations:(i==null?void 0:i.affiliations)||[]}}}function rs(){const{cdnUrl:s}=k(),{data:t}=C.useQuery({queryKey:["pitvox","cars","evo"],queryFn:()=>S(s,"cars/evo.json"),staleTime:5*6e4,gcTime:30*6e4});return{tags:(t==null?void 0:t.tags)||[],cars:(t==null?void 0:t.cars)||{}}}function as(){var a,i;const{cdnUrl:s,partnerSlug:t}=k(),r=je(t),n=C.useQuery({queryKey:["pitvox","recentLaps",t],queryFn:()=>S(s,r),staleTime:3e4,refetchInterval:3e4,gcTime:10*6e4});return{groups:((a=n.data)==null?void 0:a.groups)||[],generatedAt:((i=n.data)==null?void 0:i.generatedAt)||null,isLoading:n.isLoading}}function is(s,t){return Ne(s,null,{carId:t})}function os(){const{cdnUrl:s,partnerSlug:t}=k();return C.useQuery({queryKey:["pitvox","competitions",t],queryFn:async()=>{const r=await S(s,"competitions/index.json");return r!=null&&r.competitions?t?r.competitions.filter(n=>n.partnerSlug===t):r.competitions:[]},staleTime:6e4})}function re(s,t={}){const r=k(),n=t.partnerSlug||r.partnerSlug;return C.useQuery({queryKey:["pitvox","competition",n,s,"config"],queryFn:()=>S(r.cdnUrl,`competitions/${n}/${s}/config.json`),enabled:!!n&&!!s,staleTime:6e4})}function ae(s,t={}){const r=k(),n=t.partnerSlug||r.partnerSlug;return C.useQuery({queryKey:["pitvox","competition",n,s,"standings"],queryFn:()=>S(r.cdnUrl,`competitions/${n}/${s}/standings.json`),enabled:!!n&&!!s,staleTime:6e4})}function ye(s,t,r={}){const n=k(),a=r.partnerSlug||n.partnerSlug;return C.useQuery({queryKey:["pitvox","competition",a,s,"round",t],queryFn:()=>S(n.cdnUrl,`competitions/${a}/${s}/rounds/${t}.json`),enabled:!!a&&!!s&&t!=null,staleTime:6e4})}function Ce(s,t=[],r={}){const n=k(),a=r.partnerSlug||n.partnerSlug;return C.useQuery({queryKey:["pitvox","competition",a,s,"allRounds",t],queryFn:async()=>(await Promise.all(t.map(o=>S(n.cdnUrl,`competitions/${a}/${s}/rounds/${o}.json`).catch(()=>null)))).filter(Boolean),enabled:!!a&&!!s&&t.length>0,staleTime:6e4})}function ke(s,t={}){const r=k(),n=t.partnerSlug||r.partnerSlug;return C.useQuery({queryKey:["pitvox","competition",n,s,"leaderboard"],queryFn:()=>S(r.cdnUrl,`competitions/${n}/${s}/leaderboard.json`).catch(()=>null),enabled:!!n&&!!s,staleTime:6e4})}function we(s,t,r={}){const n=k(),a=r.partnerSlug||n.partnerSlug;return C.useQuery({queryKey:["pitvox","competition",a,s,"round",t,"laps"],queryFn:()=>S(n.cdnUrl,`competitions/${a}/${s}/rounds/${t}/laps.json`).catch(()=>null),enabled:!!a&&!!s&&t!=null,staleTime:6e4})}function ie(s,t={}){const r=k(),n=t.partnerSlug||r.partnerSlug;return C.useQuery({queryKey:["pitvox","competition",n,s,"entrylist"],queryFn:()=>S(r.cdnUrl,`competitions/${n}/${s}/entrylist.json`),enabled:!!n&&!!s,staleTime:6e4})}function V(s){const{cdnUrl:t,partnerSlug:r,getSteamId:n}=k(),a=n();return C.useQuery({queryKey:["pitvox","registration",r,s,a],queryFn:async()=>{var d;const i=await fetch(`${t}/competitions/${r}/${s}/entrylist.json`);if(!i.ok)return{isRegistered:!1,entryList:null};const o=await i.json();return{isRegistered:!!a&&((d=o.drivers)==null?void 0:d.some(l=>l.steamId===a)),entryList:o}},enabled:!!s,staleTime:6e4})}function oe(s){const{onRegister:t,partnerSlug:r,getSteamId:n}=k(),a=C.useQueryClient(),i=ne();return C.useMutation({mutationFn:o=>{if(!t)throw new Error("No onRegister callback provided to PitVoxPartnerProvider. Provide onRegister for in-app registration, or use useRegistrationUrl() to link to pitvox.com.");return t(s,o)},onSuccess:()=>{const o=n();if(a.setQueriesData({queryKey:["pitvox","registration",r,s]},c=>c?{...c,isRegistered:!0}:{isRegistered:!0,entryList:null}),o){const c=i(o),d={steamId:o,displayName:c.displayName,avatarUrl:c.avatarUrl};a.setQueriesData({queryKey:["pitvox","competition",r,s,"entrylist"]},l=>{var v;return l?((v=l.drivers)==null?void 0:v.some(g=>g.steamId===o))?l:{...l,drivers:[...l.drivers||[],d]}:{drivers:[d]}})}}})}function le(s){const{onWithdraw:t,partnerSlug:r,getSteamId:n}=k(),a=C.useQueryClient();return C.useMutation({mutationFn:i=>{if(!t)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||n();if(!o)throw new Error("No Steam ID available");return t(s,o)},onSuccess:()=>{const i=n();a.setQueriesData({queryKey:["pitvox","registration",r,s]},o=>o?{...o,isRegistered:!1}:{isRegistered:!1,entryList:null}),i&&a.setQueriesData({queryKey:["pitvox","competition",r,s,"entrylist"]},o=>o!=null&&o.drivers?{...o,drivers:o.drivers.filter(c=>c.steamId!==i)}:o)}})}function K(){const{onRegister:s,onWithdraw:t}=k(),r=!!(s&&t);return{isPowerMode:r,isBasicMode:!r}}function H(s){const{pitvoxUrl:t,partnerSlug:r}=k();return`${t}/p/${r}/competitions/${s}/register`}const ls={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"},Le=[{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 cs(s){for(const t of Le)if(t.tags.includes(s))return t.id;return"other"}function Se(s,t){if(t.size===0)return!0;const r={};for(const n of t){const a=cs(n);r[a]||(r[a]=[]),r[a].push(n)}for(const n of Object.values(r))if(!n.some(a=>s.includes(a)))return!1;return!0}function Te(s,t){const[r,n]=b.useState(new Set),a=s!==void 0,i=a?s:r,o=b.useCallback(d=>{const l=new Set(i);l.has(d)?l.delete(d):l.add(d),a&&t?t(l):n(l)},[i,a,t]),c=b.useCallback(()=>{a&&t?t(new Set):n(new Set)},[a,t]);return{activeTags:i,toggle:o,clear:c}}function Q(s){const[t,r]=b.useState(s),n=b.useCallback(a=>{r(i=>i.key===a?{key:a,dir:i.dir==="asc"?"desc":"asc"}:{key:a,dir:a.includes("timestamp")||a.includes("Date")?"desc":"asc"})},[]);return[t,n]}function O(s,t,r){return[...s].sort((n,a)=>{const i=r(n,t.key),o=r(a,t.key);if(i==null&&o==null)return 0;if(i==null)return 1;if(o==null)return-1;const c=typeof i=="string"?i.localeCompare(o):i-o;return t.dir==="desc"?-c:c})}function Re(s,t=!1){const r=t?s==null?void 0:s.filter(n=>n.isValid):s;return r!=null&&r.length?{s1:Math.min(...r.map(n=>n.sector1Ms).filter(Boolean)),s2:Math.min(...r.map(n=>n.sector2Ms).filter(Boolean)),s3:Math.min(...r.map(n=>n.sector3Ms).filter(Boolean))}:null}function ds({active:s,dir:t}){return s?t==="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 R({label:s,sortKey:t,config:r,onSort:n,className:a=""}){return e.jsx("th",{className:`pvx-th pvx-th--sortable ${a}`,onClick:()=>n(t),children:e.jsxs("span",{className:"pvx-th-inner",children:[s,e.jsx(ds,{active:r.key===t,dir:r.dir})]})})}function W({userId:s,getUserDisplay:t}){const{displayName:r,avatarUrl:n}=t(s);return e.jsxs("span",{className:"pvx-driver",children:[n?e.jsx("img",{src:n,alt:"",className:"pvx-driver-avatar"}):e.jsx("span",{className:"pvx-driver-avatar pvx-driver-avatar--placeholder"}),e.jsx("span",{className:"pvx-driver-name",children:r})]})}function ce({rank:s,podium:t=!1}){const r=t?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:r,children:s})}function Me({availableTags:s,activeTags:t,onToggle:r,onClear:n}){if(!s||s.length<2)return null;const a=Le.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:n,className:`pvx-tag ${t.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(c=>e.jsx("button",{onClick:()=>r(c),className:`pvx-tag ${t.has(c)?"pvx-tag--active":""}`,children:ls[c]||c},c))]},i.id))]})}function de({segments:s}){return e.jsx("nav",{className:"pvx-breadcrumb","aria-label":"Breadcrumb",children:e.jsx("ol",{className:"pvx-breadcrumb-list",children:s.map((t,r)=>{const n=r===s.length-1;return e.jsxs("li",{className:"pvx-breadcrumb-item",children:[r>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"})}),!n&&t.onClick?e.jsx("button",{onClick:t.onClick,className:"pvx-breadcrumb-link",children:t.label}):e.jsx("span",{className:"pvx-breadcrumb-current",children:t.label})]},t.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 F(){return e.jsx("div",{className:"pvx-loading",children:"Loading..."})}function ps(){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 xs(){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 us({tracks:s,isLoading:t,carMetadata:r,getUserDisplay:n,onTrackSelect:a,tags:i,onTagChange:o}){const[c,d]=Q({key:"record.timestamp",dir:"desc"}),{activeTags:l,toggle:p,clear:v}=Te(i,o),g=b.useMemo(()=>{var m;if(!((m=r==null?void 0:r.tags)!=null&&m.length))return[];const h=new Set;for(const j of s||[])j.recordByTag&&Object.keys(j.recordByTag).forEach(u=>h.add(u));return r.tags.filter(j=>h.has(j))},[s,r]),x=b.useMemo(()=>s?l.size===0?s:s.map(h=>{var u,y;if(!h.recordByTag)return null;let m=null;const j=new Set;for(const N of Object.values(h.recordByTag)){if(j.has(N.carId))continue;j.add(N.carId);const w=((y=(u=r==null?void 0:r.cars)==null?void 0:u[N.carId])==null?void 0:y.tags)||["sports_car"];Se(w,l)&&(!m||N.lapTimeMs<m.lapTimeMs)&&(m=N)}return m?{...h,record:{visibleId:m.steamId||m.identifier,carId:m.carId,carDisplayName:M(m.carId),lapTimeMs:m.lapTimeMs,timestamp:m.recordedAt}}:null}).filter(Boolean):[],[s,l,r]),f=b.useMemo(()=>O(x,c,(h,m)=>{var j,u;switch(m){case"displayName":return h.displayName;case"record.lapTimeMs":return(j=h.record)==null?void 0:j.lapTimeMs;case"driverCount":return h.driverCount||0;case"carCount":return h.carCount||0;case"record.timestamp":default:return(u=h.record)!=null&&u.timestamp?new Date(h.record.timestamp).getTime():0}}),[x,c]);return t?e.jsx(F,{}):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:g,activeTags:l,onToggle:p,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(R,{label:"Track",sortKey:"displayName",config:c,onSort:d}),e.jsx("th",{className:"pvx-th",children:"Record Holder"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Car"}),e.jsx(R,{label:"Lap Time",sortKey:"record.lapTimeMs",config:c,onSort:d}),e.jsx(R,{label:"Drivers",sortKey:"driverCount",config:c,onSort:d,className:"pvx-hidden-below-md"}),e.jsx(R,{label:"Cars",sortKey:"carCount",config:c,onSort:d,className:"pvx-hidden-below-lg"}),e.jsx(R,{label:"Date",sortKey:"record.timestamp",config:c,onSort:d,className:"pvx-hidden-below-xl"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:f.map(h=>{var m,j,u;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:(m=h.record)!=null&&m.visibleId?e.jsx(W,{userId:h.record.visibleId,getUserDisplay:n}):"-"}),e.jsx("td",{className:"pvx-td pvx-hidden-below-lg",children:((j=h.record)==null?void 0:j.carDisplayName)||"-"}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:h.record?P(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:(u=h.record)!=null&&u.timestamp?A(h.record.timestamp):"-"})]},`${h.id}|${h.layout||""}`)})})]})})]}):e.jsx(U,{message:"No lap times recorded yet."})}function ms({entries:s,isLoading:t,track:r,carMetadata:n,getUserDisplay:a,onCarSelect:i,onNavigate:o,tags:c,onTagChange:d}){const[l,p]=Q({key:"lapTimeMs",dir:"asc"}),{activeTags:v,toggle:g,clear:x}=Te(c,d),f=b.useMemo(()=>{var y,N,w;if(!s||!((y=n==null?void 0:n.tags)!=null&&y.length))return[];const u=new Set;for(const L of s)(((w=(N=n.cars)==null?void 0:N[L.carId])==null?void 0:w.tags)||["sports_car"]).forEach(E=>u.add(E));return n.tags.filter(L=>u.has(L))},[s,n]),h=b.useMemo(()=>s?v.size===0?s:s.filter(u=>{var N,w;const y=((w=(N=n==null?void 0:n.cars)==null?void 0:N[u.carId])==null?void 0:w.tags)||["sports_car"];return Se(y,v)}):[],[s,v,n]),m=b.useMemo(()=>O(h,l,(u,y)=>{switch(y){case"carId":return M(u.carId);case"driverCount":return u.driverCount||0;case"lapTimeMs":default:return u.lapTimeMs}}),[h,l]),j=[{key:"tracks",label:"Tracks",onClick:()=>o("tracks")},{key:"track",label:r.displayName}];return t?e.jsx(F,{}):e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx(de,{segments:j})}),e.jsx(Me,{availableTags:f,activeTags:v,onToggle:g,onClear:x}),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(R,{label:"Car",sortKey:"carId",config:l,onSort:p}),e.jsx("th",{className:"pvx-th",children:"Record Holder"}),e.jsx(R,{label:"Lap Time",sortKey:"lapTimeMs",config:l,onSort:p}),e.jsx(R,{label:"Drivers",sortKey:"driverCount",config:l,onSort:p,className:"pvx-hidden-below-md"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Date"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:m.map((u,y)=>e.jsxs("tr",{className:"pvx-row pvx-row--clickable",onClick:()=>i(u.carId),children:[e.jsx("td",{className:"pvx-td",children:e.jsx(ce,{rank:y+1,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:M(u.carId)}),e.jsx("td",{className:"pvx-td",children:e.jsx(W,{userId:u.steamId||u.userId,getUserDisplay:a})}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:P(u.lapTimeMs)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-md",children:u.driverCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-lg",children:u.recordedAt?A(u.recordedAt):"-"})]},u.carId))})]})}):e.jsx(U,{message:"No lap times for this track yet."})]})}function hs({entries:s,isLoading:t,track:r,carId:n,getUserDisplay:a,onDriverSelect:i,onNavigate:o,highlightId:c}){const[d,l]=Q({key:"lapTimeMs",dir:"asc"}),p=b.useMemo(()=>Re(s),[s]),v=b.useMemo(()=>O(s||[],d,(x,f)=>{switch(f){case"userId":return a(x.steamId||x.userId).displayName;case"lapCount":return x.lapCount||0;case"lapTimeMs":default:return x.lapTimeMs}}),[s,d,a]),g=[{key:"tracks",label:"Tracks",onClick:()=>o("tracks")},{key:"track",label:r.displayName,onClick:()=>o("track")},{key:"car",label:M(n)}];return t?e.jsx(F,{}):e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx(de,{segments:g})}),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(R,{label:"Driver",sortKey:"userId",config:d,onSort:l}),e.jsx(R,{label:"Lap Time",sortKey:"lapTimeMs",config:d,onSort:l}),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(R,{label:"Laps",sortKey:"lapCount",config:d,onSort:l,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((x,f)=>{const h=f+1,m=x.steamId||x.userId,j=p&&x.sector1Ms===p.s1,u=p&&x.sector2Ms===p.s2,y=p&&x.sector3Ms===p.s3,N=c&&m===c;return e.jsxs("tr",{className:`pvx-row pvx-row--clickable ${N?"pvx-row--highlight":h<=3?"pvx-row--podium":""}`,onClick:()=>i(m),children:[e.jsx("td",{className:"pvx-td",children:e.jsx(ce,{rank:h,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:e.jsx(W,{userId:m,getUserDisplay:a})}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:P(x.lapTimeMs)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${j?"pvx-td--best-sector":""}`,children:D(x.sector1Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${u?"pvx-td--best-sector":""}`,children:D(x.sector2Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${y?"pvx-td--best-sector":""}`,children:D(x.sector3Ms)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",title:se(x.tyreCompound),children:x.tyreCompound||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-xl",children:te(x.startingFuelL)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",children:x.lapCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-xl",children:x.recordedAt?A(x.recordedAt):"-"})]},m)})})]})}):e.jsx(U,{message:"No lap times for this car yet."})]})}function vs({userId:s,track:t,carId:r,game:n,gameVersion:a,showInvalid:i,getUserDisplay:o,onToggleInvalid:c,onNavigate:d}){const{data:l,driverName:p,theoreticalBest:v,isLoading:g}=be(s,t.id,t.layout,r,{showInvalid:i,game:n,gameVersion:a}),{displayName:x,avatarUrl:f}=o(s,p),h=b.useMemo(()=>Re(l,!0),[l]),m=b.useMemo(()=>{const u=(l==null?void 0:l.filter(y=>y.isValid))||[];return u.length?Math.min(...u.map(y=>y.lapTimeMs)):null},[l]),j=[{key:"tracks",label:"Tracks",onClick:()=>d("tracks")},{key:"track",label:t.displayName,onClick:()=>d("track")},{key:"car",label:M(r),onClick:()=>d("car")},{key:"driver",label:x}];return g?e.jsx(F,{}):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(de,{segments:j}),f?e.jsx("img",{src:f,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:c,className:"pvx-checkbox"}),e.jsx("span",{children:"Show invalid laps"})]})]}),v&&e.jsxs("div",{className:"pvx-theoretical-best",children:[e.jsx("span",{className:"pvx-theoretical-best-label",children:"Theoretical Best:"}),e.jsx("span",{className:"pvx-theoretical-best-time",children:P(v.lapTimeMs)}),e.jsxs("span",{className:"pvx-theoretical-best-sectors",children:["(",D(v.sector1Ms)," + ",D(v.sector2Ms)," + ",D(v.sector3Ms),")"]})]}),l!=null&&l.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:l.map((u,y)=>{const N=u.isValid&&u.lapTimeMs===m,w=h&&u.isValid&&u.sector1Ms===h.s1,L=h&&u.isValid&&u.sector2Ms===h.s2,T=h&&u.isValid&&u.sector3Ms===h.s3;let E="pvx-row";return u.isValid||(E+=" pvx-row--invalid"),N&&(E+=" pvx-row--personal-best"),e.jsxs("tr",{className:E,children:[e.jsx("td",{className:"pvx-td",children:e.jsx("span",{className:`pvx-rank ${N?"pvx-rank--gold":""}`,children:y+1})}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-md",children:u.lapNumber||"-"}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:P(u.lapTimeMs)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${w?"pvx-td--best-sector":""}`,children:D(u.sector1Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${L?"pvx-td--best-sector":""}`,children:D(u.sector2Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${T?"pvx-td--best-sector":""}`,children:D(u.sector3Ms)}),e.jsx("td",{className:"pvx-td",title:u.isValid?void 0:u.invalidReason||"Invalid",children:u.isValid?e.jsx(ps,{}):e.jsx(xs,{})}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",title:se(u.tyreCompound),children:u.tyreCompound||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",children:te(u.startingFuelL)}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-xl",children:A(u.timestamp)})]},u.id)})})]})}):e.jsx(U,{message:i?"No laps recorded for this combination.":'No valid laps. Try enabling "Show invalid laps".'})]})}function gs({drivers:s,isLoading:t,getUserDisplay:r,game:n,gameVersion:a,onComboSelect:i}){const[o,c]=Q({key:"rank",dir:"asc"}),[d,l]=b.useState(null),p=b.useMemo(()=>s?O(s,o,(g,x)=>{switch(x){case"rating":return g.rating;case"comboCount":return g.comboCount||0;case"distinctCars":return g.distinctCars||0;case"rank":default:return g.rank}}):[],[s,o]);if(t)return e.jsx(F,{});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(R,{label:"#",sortKey:"rank",config:o,onSort:c,className:"pvx-th--narrow"}),e.jsx("th",{className:"pvx-th",children:"Driver"}),e.jsx(R,{label:"Rating",sortKey:"rating",config:o,onSort:c}),e.jsx(R,{label:"Cars",sortKey:"distinctCars",config:o,onSort:c,className:"pvx-hidden-below-sm"}),e.jsx(R,{label:"Combos",sortKey:"comboCount",config:o,onSort:c,className:"pvx-hidden-below-sm"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:p.map(g=>{const x=d===g.identifier;return e.jsx(js,{driver:g,getUserDisplay:r,isExpanded:x,onToggle:()=>l(x?null:g.identifier),colCount:v,game:n,gameVersion:a,onComboSelect:i},g.identifier)})})]})})]})}function js({driver:s,getUserDisplay:t,isExpanded:r,onToggle:n,colCount:a,game:i,gameVersion:o,onComboSelect:c}){const d=s.identifier;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:`pvx-row pvx-row--clickable ${s.rank<=3?"pvx-row--podium":""}`,onClick:n,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(ce,{rank:s.rank,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:e.jsx(W,{userId:d,getUserDisplay:t})}),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 ${r?"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"})})]})})]}),r&&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((l,p)=>{const v=l.layout?`${l.trackId}|${l.layout}`:l.trackId,g=c?()=>c({track:v,car:l.carId,highlight:d,game:i,gameVersion:o}):void 0;return e.jsxs("div",{className:`pvx-rankings-combo ${g?"pvx-rankings-combo--clickable":""}`,onClick:g,role:g?"button":void 0,children:[e.jsxs("div",{className:"pvx-rankings-combo-info",children:[e.jsx("p",{className:"pvx-rankings-combo-track",children:B(l.trackId,l.layout,i)}),e.jsx("p",{className:"pvx-rankings-combo-car",children:M(l.carId)})]}),e.jsxs("div",{className:"pvx-rankings-combo-stats",children:[e.jsx("p",{className:"pvx-rankings-combo-time",children:P(l.lapTimeMs)}),e.jsxs("p",{className:`pvx-rankings-combo-pct ${l.percentile>=75?"pvx-rankings-combo-pct--high":l.percentile>=50?"pvx-rankings-combo-pct--mid":l.percentile>=25?"pvx-rankings-combo-pct--low":"pvx-rankings-combo-pct--bottom"}`,children:[l.percentile.toFixed(0),"%",e.jsxs("span",{className:"pvx-rankings-combo-rank",children:["(",l.rank,"/",l.totalDrivers,")"]})]})]})]},p)})})})})]})}const fs={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:"🇰🇷"},G=["🥇","🥈","🥉"],Ns={championship:"Championship",series:"Series",event:"Event",hotlap:"Hotlap"},bs=["PRACTICE","QUALIFYING","RACE"];function me(s){const t=bs.indexOf(s);if(t>=0)return t;const r=s.match(/^PRACTICE_(\d+)$/);return r?100+parseInt(r[1]):999}function z(s){const t=s.match(/^PRACTICE_(\d+)$/);return t?`P${t[1]}`:s}function pe({position:s}){const t=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:t,children:s})}function Y({nation:s}){const t=s&&fs[s];return t?e.jsx("span",{className:"pvx-nation-flag",title:s,children:t}):null}function ys({sessions:s,activeSession:t,onSelect:r}){if(!s||s.length<=1)return null;const n=[...s].sort((a,i)=>me(a.type)-me(i.type));return e.jsx("div",{className:"pvx-session-tabs",children:n.map(a=>e.jsx("button",{onClick:()=>r(a.type),className:`pvx-session-tab ${t===a.type?"pvx-session-tab--active":""}`,children:z(a.type)},a.type))})}function $e({type:s}){return e.jsx("span",{className:`pvx-comp-badge pvx-comp-badge--${s}`,children:Ns[s]||s})}function _({children:s,variant:t="default"}){return e.jsx("span",{className:`pvx-info-pill ${t!=="default"?`pvx-info-pill--${t}`:""}`,children:s})}function Cs(s){if(!s)return"TBD";const t=new Date(s);if(isNaN(t))return"TBD";const r=t.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"}),n=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${r} • ${n}`}function ks(s){return s.reduce((t,r)=>{var n;return(n=r.splits)!=null&&n.length?t?t.map((a,i)=>{const o=r.splits[i];return o&&o<a?o:a}):[...r.splits]:t},null)}function I({message:s="Loading..."}){return e.jsx("div",{className:"pvx-loading",children:s})}function $({message:s="No data available."}){return e.jsx("div",{className:"pvx-empty",children:e.jsx("p",{children:s})})}const xe=3;function De(s){const t=s==null?void 0:s.rounds;return t!=null&&t.length?s.type==="hotlap"?t.every(r=>r.isFinalized&&r.dediStatus==="completed"):t.every(r=>r.isFinalized):!1}function Pe(s){const t=s==null?void 0:s.rounds;if(!(t!=null&&t.length))return null;let r=null;for(const n of t){if(!n.startTime)continue;const a=new Date(n.startTime);isNaN(a)||(!r||a>r)&&(r=a)}return r}function ue(s,t=xe){if(!De(s))return"active";const r=Pe(s);if(!r)return"recently-completed";const n=t*24*60*60*1e3;return Date.now()-r.getTime()<=n?"recently-completed":"archived"}function ws(s,t,r=xe){if(!(s!=null&&s.length))return[];const n=new Set(Array.isArray(t)?t:[t]);return s.filter(a=>n.has(ue(a,r)))}function Ie(s,t=3){const r=s==null?void 0:s.standings;return Array.isArray(r)?[...r].sort((n,a)=>(n.position??999)-(a.position??999)).slice(0,t):[]}function Be({competitionId:s,topN:t=3,label:r="Completed",className:n}){const{data:a}=ae(s),i=Ie(a,t);return e.jsxs("div",{className:`pvx-comp-completed-badge ${n||""}`,children:[e.jsx("span",{className:"pvx-comp-completed-badge-label",children:r}),i.length>0&&e.jsx("ol",{className:"pvx-comp-completed-badge-podium",children:i.map((o,c)=>e.jsxs("li",{className:"pvx-comp-completed-badge-driver",children:[e.jsx("span",{className:"pvx-comp-completed-badge-medal","aria-hidden":"true",children:G[c]||""}),e.jsx(Y,{nation:o.nation}),e.jsx("span",{className:"pvx-comp-completed-badge-name",children:o.driverName})]},o.driverId||c))})]})}function Ls({competitions:s,isLoading:t,onSelect:r,onRegister:n,className:a}){return t?e.jsx(I,{message:"Loading competitions..."}):s!=null&&s.length?e.jsx("div",{className:`pvx-comp-grid ${a||""}`,children:s.map(i=>e.jsx(Ae,{comp:i,onSelect:r,onRegister:n||r},i.id))}):e.jsx($,{message:"No competitions available."})}function Ae({comp:s,onSelect:t,onRegister:r}){var u,y,N;const{cdnUrl:n}=k(),a=s.posterCdnPath?`${n}/${s.posterCdnPath}`:null,i=s.registration,o=(i==null?void 0:i.currentCount)||0,c=i==null?void 0:i.maxParticipants,d=c&&o>=c,l=(i==null?void 0:i.deadline)&&new Date(i.deadline)<new Date,p=(i==null?void 0:i.isOpen)&&!l&&!d,v=new Date,g=(u=s.rounds)==null?void 0:u.find(w=>w.startTime&&new Date(w.startTime)>=v),x=((y=s.rounds)==null?void 0:y.length)||0,f=((N=s.rounds)==null?void 0:N.filter(w=>w.isFinalized).length)||0,h=ue(s),m=h==="recently-completed"||h==="archived",j=s.type==="championship";return e.jsxs("div",{className:"pvx-comp-card",onClick:()=>t(s.id),role:"button",tabIndex:0,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),t(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(Ts,{})})}),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($e,{type:s.type}),s.game&&e.jsx(_,{children:s.game.toUpperCase()}),s.formatDescription&&s.formatDescription.split(", ").map((w,L)=>e.jsx(_,{variant:"format",children:w},L))]}),s.carsDescription&&e.jsx("div",{className:"pvx-comp-card-pills",children:s.carsDescription.split(", ").map((w,L)=>e.jsx(_,{children:w},L))}),e.jsxs("div",{className:"pvx-comp-card-schedule",children:[g?e.jsxs("span",{className:"pvx-comp-card-schedule-next",children:[e.jsx("span",{className:"pvx-comp-card-schedule-label",children:"Next:"})," ",s.type!=="hotlap"&&`R${g.roundNumber} `,g.track||"TBD"," · ",Cs(g.startTime)]}):x>0?e.jsxs("span",{className:"pvx-comp-card-schedule-next",children:[f,"/",x," rounds completed"]}):null,x>0&&e.jsxs("span",{className:"pvx-comp-card-round-count",children:[x," round",x!==1?"s":""]})]}),m&&j&&e.jsx(Be,{competitionId:s.id}),i&&!m&&e.jsx(Ss,{competitionId:s.id,regOpen:p,isFull:d,deadlinePassed:l,regCount:o,regMax:c,onRegister:r})]})]})}function Ss({competitionId:s,regOpen:t,isFull:r,deadlinePassed:n,regCount:a,regMax:i,onRegister:o}){const{isPowerMode:c}=K(),d=H(s),{data:l}=V(s),p=(l==null?void 0:l.isRegistered)||!1,v=i?a/i*100:0,g=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--${g}`,children:[a,"/",i||"∞"," drivers"]})}),e.jsx("div",{className:"pvx-comp-card-reg-action",children:p?e.jsx("button",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--registered",onClick:x=>{x.stopPropagation(),o(s)},children:"✓ Registered"}):t?c?e.jsx("button",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--open",onClick:x=>{x.stopPropagation(),o(s)},children:"Register"}):e.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--open",onClick:x=>x.stopPropagation(),children:"Register"}):e.jsx("span",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--closed",children:r?"Full":"Closed"})})]})}function Ts(){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 Ee({competitionId:s,className:t}){var c,d;const{data:r,isLoading:n}=ae(s),{data:a,isLoading:i}=re(s);if(n||i)return e.jsx(I,{message:"Loading standings..."});if(!((c=r==null?void 0:r.standings)!=null&&c.length))return e.jsx($,{message:"No standings data yet. Results will appear once rounds are finalised."});const o=((d=a==null?void 0:a.rounds)==null?void 0:d.filter(l=>l.isFinalized))||[];return e.jsxs("div",{className:`pvx-card ${t||""}`,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 ",r.roundsCompleted," round",r.roundsCompleted!==1?"s":"",r.countingRounds>0&&` (best ${r.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(l=>e.jsxs("th",{className:"pvx-th pvx-th--center pvx-hidden-below-md",title:l.track||`Round ${l.roundNumber}`,children:["R",l.roundNumber]},l.roundNumber))]})}),e.jsx("tbody",{className:"pvx-tbody",children:r.standings.map(l=>e.jsx(Rs,{driver:l,finalizedRounds:o},l.driverId||l.driverName))})]})})]})}function Rs({driver:s,finalizedRounds:t}){var o,c,d;const r=s.position<=3,n=new Map(((o=s.roundResults)==null?void 0:o.map(l=>[l.roundNumber,l]))||[]),a=((c=s.roundResults)==null?void 0:c.filter(l=>l.position===1).length)||0,i=((d=s.roundResults)==null?void 0:d.filter(l=>l.position<=3).length)||0;return e.jsxs("tr",{className:`pvx-row ${r?"pvx-row--podium":""}`,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(pe,{position:s.position})}),e.jsxs("td",{className:"pvx-td pvx-td--primary",children:[e.jsx(Y,{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}),t.map(l=>{const p=n.get(l.roundNumber),v=p==null?void 0:p.dropped;return e.jsx("td",{className:`pvx-td pvx-td--center pvx-hidden-below-md ${!v&&(p==null?void 0:p.position)===1?"pvx-standings-cell--p1":!v&&(p==null?void 0:p.position)===2?"pvx-standings-cell--p2":!v&&(p==null?void 0:p.position)===3?"pvx-standings-cell--p3":""}`,children:p?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",p.position]}),e.jsx("span",{className:"pvx-standings-round-pts",children:p.points})]}):e.jsx("span",{className:"pvx-td--muted",children:"-"})},l.roundNumber)})]})}function Ms({competitionId:s,roundNumber:t,className:r}){var d;const{data:n,isLoading:a}=ye(s,t);if(a)return e.jsx(I,{message:"Loading results..."});if(!n)return e.jsx($,{message:"No results for this round."});const o=(n.sessions||[]).find(l=>l.type==="RACE"),c=(d=o==null?void 0:o.results)==null?void 0:d.filter(l=>l.position<=3).sort((l,p)=>l.position-p.position);return e.jsxs("div",{className:`pvx-round-results ${r||""}`,children:[e.jsxs("div",{className:"pvx-round-results-header",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"pvx-round-results-title",children:["Round ",n.roundNumber,n.track?`: ${n.track}`:""]}),n.startTime&&e.jsx("p",{className:"pvx-round-results-date",children:new Date(n.startTime).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})})]}),(c==null?void 0:c.length)>0&&e.jsx("div",{className:"pvx-round-podium-summary",children:c.map(l=>e.jsxs("span",{className:"pvx-round-podium-item",children:[e.jsx("span",{children:G[l.position-1]}),e.jsx("span",{children:l.driverName})]},l.driverId))})]}),e.jsx(J,{round:n,competitionId:s})]})}function J({round:s,competitionId:t,className:r}){var p,v,g,x;const[n,a]=b.useState(null),i=(s==null?void 0:s.sessions)||[];if(!i.length)return e.jsx($,{message:"No session data for this round."});const{data:o}=we(t,s==null?void 0:s.roundNumber,{}),c=n||((p=i.find(f=>f.type==="RACE"))==null?void 0:p.type)||((v=i[0])==null?void 0:v.type),d=i.find(f=>f.type===c)||i[0],l=((x=(g=o==null?void 0:o.sessions)==null?void 0:g.find(f=>f.type===c))==null?void 0:x.drivers)||null;return e.jsxs("div",{className:r||"",children:[e.jsx(ys,{sessions:i,activeSession:c,onSelect:a}),e.jsx($s,{session:d,sessionLaps:l})]})}function $s({session:s,sessionLaps:t}){var c;const r=s.type==="RACE",[n,a]=b.useState(null);if(!((c=s.results)!=null&&c.length))return e.jsx($,{message:`No results for ${s.type}.`});const i=ks(s.results),o=r?7:4;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((d,l)=>{var g;const p=(g=t==null?void 0:t[d.driverId])==null?void 0:g.laps,v=n===d.driverId&&!!p;return e.jsx(Ds,{result:d,isRace:r,fastestSplits:i,rowIndex:l,hasLapDetail:!!p,isExpanded:v,onToggle:()=>a(v?null:d.driverId),driverLaps:v?p:null,colCount:o},d.driverId||l)})})]})})}function Ds({result:s,isRace:t,fastestSplits:r,rowIndex:n,hasLapDetail:a,isExpanded:i,onToggle:o,driverLaps:c,colCount:d}){const l=s.position<=3;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:`pvx-row ${l?"pvx-row--podium":""} ${a?"pvx-row--expandable":""}`,onClick:a?o:void 0,style:a?{cursor:"pointer"}:void 0,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(pe,{position:s.position})}),e.jsxs("td",{className:"pvx-td pvx-td--primary",children:[e.jsx(Y,{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:M(s.carId)}),e.jsx("td",{className:"pvx-td pvx-td--mono",children:e.jsx(Is,{bestLap:s.bestLapFormatted,hasBestLap:s.hasBestLap,splits:s.splits,fastestSplits:r,showAbove:n<=1})}),t&&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,")"]})]})]})]}),i&&c&&e.jsx("tr",{className:"pvx-row pvx-row--lap-detail",children:e.jsx("td",{colSpan:d,className:"pvx-td pvx-td--lap-detail",children:e.jsx(Ps,{laps:c})})})]})}function Ps({laps:s}){const t=Math.min(...s.filter(r=>r.valid&&r.timeMs>0).map(r=>r.timeMs));return e.jsxs("table",{className:"pvx-table pvx-table--laps",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"Lap"}),e.jsx("th",{className:"pvx-th",children:"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("tbody",{className:"pvx-tbody",children:s.map(r=>{var a;const n=r.valid&&r.timeMs===t;return e.jsxs("tr",{className:`pvx-row ${r.valid?"":"pvx-row--invalid"} ${n?"pvx-row--fastest":""}`,children:[e.jsx("td",{className:"pvx-td pvx-td--muted",children:r.lap}),e.jsx("td",{className:"pvx-td pvx-td--mono",children:r.time}),(r.splits||[]).map((i,o)=>e.jsx("td",{className:"pvx-td pvx-td--mono pvx-td--muted pvx-hidden-below-sm",children:i},o)),Array.from({length:Math.max(0,3-(((a=r.splits)==null?void 0:a.length)||0))}).map((i,o)=>e.jsx("td",{className:"pvx-td pvx-hidden-below-sm"},`pad-${o}`))]},r.lap)})})]})}function Is({bestLap:s,hasBestLap:t,splits:r,fastestSplits:n,showAbove:a}){return s?e.jsxs("span",{className:`pvx-best-lap-cell ${t?"pvx-best-lap-cell--fastest":""}`,children:[e.jsx("span",{className:"pvx-best-lap-time",children:s}),(r==null?void 0:r.length)>0&&e.jsx("span",{className:"pvx-splits-tooltip-anchor",children:e.jsx("span",{className:`pvx-splits-tooltip ${a?"":"pvx-splits-tooltip--above"}`,children:r.map((i,o)=>{const c=n&&i===n[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:c?"pvx-splits-tooltip-best":"",children:i})]},o)})})})]}):e.jsx("span",{className:"pvx-td--muted",children:"-"})}function Bs({competitionId:s,className:t}){const{getSteamId:r}=k(),{data:n,isLoading:a}=ie(s),i=r();if(a)return e.jsx(I,{message:"Loading drivers..."});const o=(n==null?void 0:n.drivers)||(n==null?void 0:n.entries)||[];return o.length?e.jsx("div",{className:`pvx-entry-grid ${t||""}`,children:o.map(c=>{var l,p;const d=i&&c.steamId===i;return e.jsxs("div",{className:`pvx-entry-card ${d?"pvx-entry-card--you":""}`,children:[c.avatarUrl?e.jsx("img",{src:c.avatarUrl,alt:"",className:"pvx-entry-avatar"}):e.jsx("div",{className:"pvx-entry-avatar pvx-entry-avatar--placeholder",children:((p=(l=c.displayName)==null?void 0:l.charAt(0))==null?void 0:p.toUpperCase())||"?"}),e.jsxs("span",{className:"pvx-entry-name",children:[c.displayName,d&&e.jsx("span",{className:"pvx-entry-you",children:" (you)"})]})]},c.steamId||c.driverId)})}):e.jsx($,{message:"No drivers registered yet."})}function As({competitionId:s,driverData:t,className:r,children:n}){const{data:a,isLoading:i}=V(s),{isPowerMode:o}=K(),c=H(s),d=oe(s),l=le(s),p=(a==null?void 0:a.isRegistered)||!1,v=i||d.isPending||l.isPending,g=d.error||l.error||null,x=()=>{o&&d.mutate(t||{})},f=()=>{o&&l.mutate()};return typeof n=="function"?n({isRegistered:p,isLoading:v,register:x,withdraw:f,error:g,isPowerMode:o,registrationUrl:c}):o?e.jsx("button",{className:`pvx-comp-register-btn ${r||""}`,onClick:p?f:x,disabled:v,children:v?"Loading...":p?"Withdraw":"Register"}):e.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:`pvx-comp-register-link ${r||""}`,children:p?"View Registration":"Register on PitVox"})}function Es({competitionId:s,registration:t,onWithdrawSuccess:r,className:n}){const{getSteamId:a}=k(),{isPowerMode:i}=K(),o=H(s),{data:c,isLoading:d}=V(s),{data:l,isLoading:p}=ie(s),v=oe(s),g=le(s),x=a(),f=(c==null?void 0:c.isRegistered)||!1,h=(l==null?void 0:l.drivers)||(l==null?void 0:l.entries)||[],m=t||{},j=h.length||m.currentCount||0,u=m.maxParticipants&&j>=m.maxParticipants,y=m.deadline&&new Date(m.deadline)<new Date,N=m.isOpen&&!y&&!u;return d||p?e.jsx(I,{message:"Loading registration..."}):f?e.jsx("div",{className:`pvx-reg-panel ${n||""}`,children:e.jsx(Fs,{competitionId:s,drivers:h,steamId:x,isPowerMode:i,registrationUrl:o,withdrawMutation:g,onWithdrawSuccess:r,registration:m})}):N?x?i?e.jsx("div",{className:`pvx-reg-panel ${n||""}`,children:e.jsx(Us,{competitionId:s,registerMutation:v,registration:m})}):e.jsx("div",{className:`pvx-reg-panel ${n||""}`,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 ${n||""}`,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 ${n||""}`,children:[e.jsx("div",{className:"pvx-reg-status-msg",children:u?"Registration is full.":y?"Registration deadline has passed.":"Registration is closed."}),h.length>0&&e.jsx(Ue,{drivers:h,steamId:x})]})}function Us({competitionId:s,registerMutation:t,registration:r}){const[n,a]=b.useState(""),[i,o]=b.useState("intermediate"),[c,d]=b.useState(""),l=x=>{x.preventDefault(),t.mutate({discordUsername:n||void 0,experience:i,comments:c||void 0})},p=r||{},v=p.currentCount||0,g=p.maxParticipants;return e.jsxs("form",{className:"pvx-reg-form",onSubmit:l,children:[e.jsxs("div",{className:"pvx-reg-form-header",children:[e.jsx("h3",{className:"pvx-reg-form-title",children:"Register"}),g&&e.jsx(Fe,{count:v,max:g})]}),t.error&&e.jsx("div",{className:"pvx-reg-error",children:t.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:n,onChange:x=>a(x.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:x=>o(x.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:c,onChange:x=>d(x.target.value)})]}),e.jsx("div",{className:"pvx-reg-actions",children:e.jsx("button",{type:"submit",className:"pvx-comp-register-btn",disabled:t.isPending,children:t.isPending?"Registering...":"Register"})})]})}function Fs({competitionId:s,drivers:t,steamId:r,isPowerMode:n,registrationUrl:a,withdrawMutation:i,onWithdrawSuccess:o,registration:c}){const[d,l]=b.useState(!1),p=()=>{i.mutate(void 0,{onSuccess:()=>{l(!1),o&&o()}})},v=c||{},g=t.length||v.currentCount||0,x=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"}),x&&e.jsx(Fe,{count:g,max:x})]}),e.jsx(Ue,{drivers:t,steamId:r}),i.error&&e.jsx("div",{className:"pvx-reg-error",children:i.error.message||"Withdrawal failed"}),n?e.jsx("div",{className:"pvx-reg-actions",children:d?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:()=>l(!1),children:"Cancel"}),e.jsx("button",{type:"button",className:"pvx-reg-danger-btn",onClick:p,disabled:i.isPending,children:i.isPending?"Unregistering...":"Yes, Unregister"})]})]}):e.jsx("button",{type:"button",className:"pvx-reg-unregister-btn",onClick:()=>l(!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 Ue({drivers:s,steamId:t}){if(!s.length)return e.jsx("div",{className:"pvx-reg-no-drivers",children:"No drivers registered yet."});const r=[...s].sort((n,a)=>{const i=t&&n.steamId===t?-1:0,o=t&&a.steamId===t?-1:0;return i-o});return e.jsx("div",{className:"pvx-reg-driver-list",children:r.map(n=>{var i,o;const a=t&&n.steamId===t;return e.jsxs("div",{className:`pvx-reg-driver-row ${a?"pvx-reg-driver-row--you":""}`,children:[n.avatarUrl?e.jsx("img",{src:n.avatarUrl,alt:"",className:"pvx-reg-driver-avatar"}):e.jsx("div",{className:"pvx-reg-driver-avatar pvx-reg-driver-avatar--placeholder",children:((o=(i=n.displayName)==null?void 0:i.charAt(0))==null?void 0:o.toUpperCase())||"?"}),e.jsxs("span",{className:"pvx-reg-driver-name",children:[n.displayName,a&&e.jsx("span",{className:"pvx-entry-you",children:" (you)"})]})]},n.steamId||n.driverId)})})}function Fe({count:s,max:t}){const r=t?s/t*100:0,n=r>=100?"full":r>=75?"warning":"ok";return e.jsxs("span",{className:`pvx-reg-capacity pvx-reg-capacity--${n}`,children:[s,"/",t," drivers"]})}function _s({competitionId:s,className:t}){const{data:r,isLoading:n}=re(s),a=(r==null?void 0:r.type)==="championship",i=(r==null?void 0:r.type)==="hotlap",{data:o}=ke(i?s:null),c=b.useMemo(()=>{var N;return((N=r==null?void 0:r.rounds)==null?void 0:N.filter(w=>w.isFinalized))||[]},[r]),d=b.useMemo(()=>c.map(N=>N.roundNumber),[c]),{data:l=[],isLoading:p}=Ce(s,d),v=i&&l.length>0?l[0]:null,g=(v==null?void 0:v.sessions)||[],x=i?"leaderboard":a?"standings":d.length>0?`round-${d[d.length-1]}`:null,[f,h]=b.useState(null),m=f||x;if(n||p)return e.jsx(I,{message:"Loading results..."});if(!r)return e.jsx($,{message:"Competition not found."});if(!c.length)return e.jsx($,{message:"No results available yet. Results will appear here once rounds are finalised."});const j=new Map(l.map(N=>[`round-${N.roundNumber}`,N])),u=[];if(a&&u.push({id:"standings",label:"Standings"}),i){u.push({id:"leaderboard",label:"Leaderboard"});for(const N of g)u.push({id:`session-${N.type}`,label:z(N.type)})}else for(const N of c)u.push({id:`round-${N.roundNumber}`,label:`R${N.roundNumber}`,track:null});const y=j.get(m);return e.jsxs("div",{className:t||"",children:[e.jsx("div",{className:"pvx-results-tabs",children:u.map(N=>e.jsxs("button",{className:`pvx-results-tab ${m===N.id?"pvx-results-tab--active":""}`,onClick:()=>h(N.id),title:N.track||void 0,children:[e.jsx("span",{className:"pvx-results-tab-label",children:N.label}),N.track&&e.jsx("span",{className:"pvx-results-tab-track",children:N.track})]},N.id))}),m==="standings"?e.jsx(Ee,{competitionId:s}):m==="leaderboard"?e.jsx(Vs,{leaderboard:o,config:r}):m!=null&&m.startsWith("session-")?e.jsx(Ks,{session:g.find(N=>`session-${N.type}`===m),round:v,competitionId:s}):y?e.jsx(qs,{round:y,competitionId:s}):e.jsx($,{message:"No results for this round."})]})}function qs({round:s,competitionId:t}){var i;const n=(s.sessions||[]).find(o=>o.type==="RACE"),a=(i=n==null?void 0:n.results)==null?void 0:i.filter(o=>o.position<=3).sort((o,c)=>o.position-c.position);return e.jsxs("div",{className:"pvx-card",children:[e.jsxs("div",{className:"pvx-card-header--split",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"pvx-card-title",children:["Round ",s.roundNumber,s.track?`: ${s.track}`:""]}),s.startTime&&e.jsx("span",{className:"pvx-standings-subtitle",children:new Date(s.startTime).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})})]}),(a==null?void 0:a.length)>0&&e.jsx("div",{className:"pvx-round-podium-summary",children:a.map(o=>e.jsxs("span",{className:"pvx-round-podium-item",children:[e.jsx("span",{children:G[o.position-1]}),e.jsx("span",{children:o.driverName})]},o.driverId))})]}),e.jsx(J,{round:s,competitionId:t})]})}function Vs({leaderboard:s,config:t}){var r;return(r=s==null?void 0:s.drivers)!=null&&r.length?e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header--split",children:e.jsxs("div",{children:[e.jsx("h4",{className:"pvx-card-title",children:s.track||(t==null?void 0:t.name)||"Hotlap Leaderboard"}),e.jsxs("span",{className:"pvx-standings-subtitle",children:[s.sessionsCompleted," session",s.sessionsCompleted!==1?"s":""," completed"]})]})}),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"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Laps"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Sessions"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Gap"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:s.drivers.map(n=>{const a=n.position===1?"":`+${((n.bestLapMs-s.drivers[0].bestLapMs)/1e3).toFixed(3)}`;return e.jsxs("tr",{className:`pvx-row ${n.position<=3?"pvx-row--podium":""}`,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(pe,{position:n.position})}),e.jsxs("td",{className:"pvx-td pvx-td--primary",children:[e.jsx(Y,{nation:n.nation}),n.driverName]}),e.jsx("td",{className:"pvx-td pvx-hidden-below-sm",children:M(n.carId)}),e.jsx("td",{className:"pvx-td pvx-td--mono",children:e.jsx("span",{className:n.position===1?"pvx-best-lap-cell--fastest":"",children:n.bestLapFormatted})}),e.jsx("td",{className:"pvx-td pvx-hidden-below-sm",children:n.totalLaps}),e.jsx("td",{className:"pvx-td pvx-hidden-below-sm",children:n.sessionsParticipated}),e.jsx("td",{className:"pvx-td pvx-td--mono pvx-td--muted pvx-hidden-below-sm",children:a})]},n.driverId)})})]})})]}):e.jsx($,{message:"No lap times recorded yet."})}function Ks({session:s,round:t,competitionId:r}){return s?e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx("h4",{className:"pvx-card-title",children:z(s.type)})}),e.jsx(J,{round:{...t,sessions:[s]},competitionId:r})]}):e.jsx($,{message:"Session data not available."})}function _e(s){const{cdnUrl:t}=k(),r=C.useQuery({queryKey:["pitvox","laps","global",s,"index"],queryFn:()=>S(t,ge(null,s)),enabled:!!s,staleTime:3e4,refetchInterval:3e4}),n=r.data;return{isLoading:r.isLoading,error:r.error,data:n?{driverName:n.driverName||"Driver",lapCount:n.lapCount||0,trackBreakdown:n.trackBreakdown||[],carBreakdown:n.carBreakdown||[],recordsHeld:n.recordsHeld||0,currentRecords:n.currentRecords||[],bestRanking:n.bestRanking??null,bestRankingTrackId:n.bestRankingTrackId??null,bestRankingLayout:n.bestRankingLayout??null,bestRankingCarId:n.bestRankingCarId??null,generatedAt:n.generatedAt}:null}}function qe(s={}){const{cdnUrl:t,partnerSlug:r}=k(),{game:n,gameVersion:a,enabled:i=!0}=s,o=q(r,n,a,"ratings.json");return C.useQuery({queryKey:["pitvox","ratings",r,n||null,a||null],queryFn:()=>S(t,o),staleTime:3e4,refetchInterval:3e4,enabled:i})}function Ve(s){var n;const t=qe(),r=b.useMemo(()=>{var a;return!((a=t.data)!=null&&a.drivers)||!s?null:t.data.drivers.find(i=>i.identifier===s)||null},[(n=t.data)==null?void 0:n.drivers,s]);return{isLoading:t.isLoading,error:t.error,data:r?{rating:r.rating,rank:r.rank,totalDrivers:t.data.driverCount||t.data.drivers.length,comboCount:r.comboCount||0,distinctCars:r.distinctCars||0,combos:r.combos||[]}:null}}function Hs(s={}){const t=qe(s);return{data:t.data||null,isLoading:t.isLoading,error:t.error}}function Ke(){const{cdnUrl:s,partnerSlug:t,getSteamId:r,onFetchServerPassword:n}=k(),a=r(),{data:i,isLoading:o}=C.useQuery({queryKey:["pitvox","competitions",t],queryFn:async()=>{const x=await S(s,"competitions/index.json");return x!=null&&x.competitions?x.competitions.filter(f=>f.partnerSlug===t):[]},staleTime:6e4}),c=(i==null?void 0:i.map(x=>x.id))||[],d=C.useQueries({queries:c.map(x=>({queryKey:["pitvox","competition",t,x,"entrylist"],queryFn:()=>S(s,`competitions/${t}/${x}/entrylist.json`),enabled:!!a&&c.length>0,staleTime:6e4}))}),l=d.some(x=>x.isLoading),p=b.useMemo(()=>{var h,m;if(!i||!a||l)return[];const x=new Date,f=[];for(let j=0;j<i.length;j++){const u=i[j],y=(h=d[j])==null?void 0:h.data;if(!((m=y==null?void 0:y.drivers)==null?void 0:m.some(L=>L.steamId===a)))continue;const w=u.rounds||[];for(const L of w)L.isFinalized||!L.startTime||new Date(L.startTime)<=x||f.push({competitionId:u.id,competitionName:u.name,roundNumber:L.roundNumber,track:L.track||"TBD",startTime:L.startTime})}return f.sort((j,u)=>new Date(j.startTime)-new Date(u.startTime)),f.length>0&&(f[0].isNext=!0),f},[i,a,l,d]),v=C.useQueries({queries:p.map(x=>({queryKey:["pitvox","serverInfo",x.competitionId,x.roundNumber],queryFn:()=>n(x.competitionId,x.roundNumber),enabled:!!n&&p.length>0,staleTime:5*6e4,retry:!1}))});return{data:b.useMemo(()=>p.length?n?p.map((x,f)=>{var m;const h=(m=v[f])==null?void 0:m.data;return h!=null&&h.success?{...x,serverAddress:h.serverAddress||null,serverPassword:h.serverPassword||null}:x}):p:[],[p,n,v]),isLoading:o||!!a&&l}}function He(){const{onFetchNotifications:s}=k();return!!s}function Qe(s={}){const{onFetchNotifications:t,partnerSlug:r}=k(),{limit:n=20,unreadOnly:a=!1}=s;return C.useQuery({queryKey:["pitvox","notifications",r,{limit:n,unreadOnly:a}],queryFn:()=>t({limit:n,unreadOnly:a}),enabled:!!t,staleTime:3e4,refetchInterval:3e4})}function Qs(){const{onFetchNotifications:s,partnerSlug:t}=k(),{data:r,isLoading:n}=C.useQuery({queryKey:["pitvox","notifications",t,{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:r??0,isLoading:n}}function Oe(){const{onMarkNotificationRead:s,partnerSlug:t}=k(),r=C.useQueryClient();return C.useMutation({mutationFn:n=>{if(!s)throw new Error("No onMarkNotificationRead callback provided to PitVoxPartnerProvider.");return s(n)},onSuccess:(n,a)=>{r.setQueriesData({queryKey:["pitvox","notifications",t]},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 We(){const{onMarkAllNotificationsRead:s,partnerSlug:t}=k(),r=C.useQueryClient();return C.useMutation({mutationFn:()=>{if(!s)throw new Error("No onMarkAllNotificationsRead callback provided to PitVoxPartnerProvider.");return s()},onSuccess:()=>{r.setQueriesData({queryKey:["pitvox","notifications",t]},n=>n!=null&&n.notifications?{...n,unreadCount:0,notifications:n.notifications.map(a=>({...a,isRead:!0,readAt:a.readAt||new Date().toISOString()}))}:n)}})}function Ge({driverName:s,avatarUrl:t,memberSince:r,className:n=""}){const a=r?new Date(r).toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric"}):null;return e.jsxs("div",{className:`pvx-card pvx-dash-profile ${n}`,children:[t?e.jsx("img",{src:t,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 Os(){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 Gs(){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 he({icon:s,value:t,label:r,items:n,labelKey:a,countKey:i}){const[o,c]=b.useState(!1),d=b.useRef(null);b.useEffect(()=>{if(!o)return;function p(v){d.current&&!d.current.contains(v.target)&&c(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[o]);const l=n!=null&&n.length?n.slice().sort((p,v)=>v[i]-p[i]):null;return e.jsxs("div",{ref:d,className:`pvx-dash-stat-card ${l?"pvx-dash-stat-card--clickable":""}`,onClick:l?()=>c(p=>!p):void 0,children:[s,e.jsxs("div",{className:"pvx-dash-stat-content",children:[e.jsx("span",{className:"pvx-dash-stat-value",children:t}),e.jsx("span",{className:"pvx-dash-stat-label",children:r})]}),l&&e.jsx("div",{className:`pvx-dash-tooltip pvx-dash-tooltip--scrollable ${o?"pvx-dash-tooltip--open":""}`,children:l.map((p,v)=>e.jsxs("div",{className:"pvx-dash-tooltip-row",children:[e.jsx("span",{className:"pvx-dash-tooltip-label",children:p[a]}),e.jsx("span",{className:"pvx-dash-tooltip-value",children:p[i]})]},v))})]})}function ze({stats:s,rating:t,className:r=""}){if(!s)return null;const n=s.trackBreakdown.map(i=>({name:B(i.trackId,i.layout),lapCount:i.lapCount})),a=s.carBreakdown.map(i=>({name:M(i.carId),lapCount:i.lapCount}));return e.jsxs("div",{className:`pvx-dash-stats ${r}`,children:[e.jsx(he,{icon:e.jsx(Os,{}),value:s.lapCount.toLocaleString(),label:"Total Laps",items:n,labelKey:"name",countKey:"lapCount"}),e.jsx(he,{icon:e.jsx(Ws,{}),value:s.carBreakdown.length,label:"Cars Used",items:a,labelKey:"name",countKey:"lapCount"}),t&&e.jsxs("div",{className:"pvx-dash-stat-card pvx-dash-stat-card--rating",children:[e.jsx(Gs,{}),e.jsxs("div",{className:"pvx-dash-stat-content",children:[e.jsx("span",{className:"pvx-dash-stat-value",children:t.rating.toFixed(1)}),e.jsx("span",{className:"pvx-dash-stat-label",children:"Driver Rating"}),e.jsxs("span",{className:"pvx-dash-stat-sub",children:["#",t.rank," of ",t.totalDrivers]})]})]})]})}function Ye({records:s,className:t=""}){const r=b.useMemo(()=>s!=null&&s.length?s.slice().sort((n,a)=>{const i=n.recordedAt?new Date(n.recordedAt).getTime():0;return(a.recordedAt?new Date(a.recordedAt).getTime():0)-i}):[],[s]);return r.length?e.jsxs("div",{className:`pvx-card ${t}`,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:["(",r.length,")"]})]})}),e.jsx("div",{className:"pvx-dash-records-list",children:r.map((n,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:B(n.trackId,n.layout,n.game)}),e.jsx("span",{className:"pvx-dash-record-car",children:M(n.carId)})]}),e.jsxs("div",{className:"pvx-dash-record-time",children:[e.jsx("span",{className:"pvx-dash-record-lap",children:P(n.lapTimeMs)}),e.jsxs("span",{className:`pvx-dash-game-badge pvx-dash-game-badge--${n.game||"evo"}`,children:[(n.game||"evo").toUpperCase(),n.gameVersion?` ${n.gameVersion}`:""]})]})]},a))})]}):null}function Je({events:s,isLoading:t,className:r,limit:n=3}){if(t)return e.jsx("div",{className:"pvx-loading",children:"Loading upcoming events..."});if(!(s!=null&&s.length))return null;const a=n?s.slice(0,n):s,i=s.length-a.length;return 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(Js,{}),"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(zs,{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:o.dediStatus==="running"?"Live now":o.dediStatus==="provisioning"?"Starting...":Ys(o.startTime)}),o.dediStatus==="running"&&e.jsx("span",{className:"pvx-upcoming-badge pvx-upcoming-badge--live",children:"Live"}),!o.dediStatus&&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 zs({password:s,address:t}){const[r,n]=b.useState(!1),[a,i]=b.useState(!1),o=t?s?`join:${t}|${s}`:`join:${t}`:null,c=b.useCallback(async()=>{if(o)try{await navigator.clipboard.writeText(o),n(!0),setTimeout(()=>n(!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:c,title:"Copy join string to clipboard",children:[e.jsx(Xs,{})," ",r?"Copied!":"Join"]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"pvx-server-detail pvx-server-detail--clickable",onClick:()=>i(d=>!d),title:a?"Hide password":"Reveal password",children:a?e.jsx(st,{}):e.jsx(et,{})}),a&&e.jsxs("span",{className:"pvx-server-detail",children:[e.jsx(Zs,{})," ",s]})]})]})}function Ys(s){const t=new Date(s).getTime()-Date.now();if(t<=0)return"Now";const r=Math.floor(t/(1e3*60*60));if(r<1)return"Less than 1 hour";if(r<24)return`in ${r}h`;const n=Math.floor(r/24);if(n===1)return"Tomorrow";if(n<7)return`in ${n} days`;if(n<30){const a=Math.floor(n/7);return`in ${a} week${a!==1?"s":""}`}return ee(s)}function Js(){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 Zs(){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 Xs(){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 et(){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 st(){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 Ze({notifications:s,unreadCount:t=0,onMarkRead:r,onMarkAllRead:n,isLoading:a,className:i}){const o=ne();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(rt,{}),"Notifications",t>0&&e.jsx("span",{className:"pvx-notif-badge",children:t>99?"99+":t})]}),t>0&&n&&e.jsx("button",{className:"pvx-notif-mark-all",onClick:n,children:"Mark all read"})]}),s!=null&&s.length?e.jsx("div",{className:"pvx-notif-list",children:s.map(c=>e.jsx(tt,{notification:c,getUserDisplay:o,onMarkRead:r},c.id))}):e.jsx("div",{className:"pvx-notif-empty",children:"No notifications"})]})}function tt({notification:s,getUserDisplay:t,onMarkRead:r}){const n=()=>{!s.isRead&&r&&r(s.id)};return e.jsxs("button",{className:`pvx-notif-item ${s.isRead?"":"pvx-notif-item--unread"}`,onClick:n,children:[e.jsx(nt,{type:s.type}),e.jsxs("div",{className:"pvx-notif-content",children:[e.jsx("span",{className:"pvx-notif-message",children:fe(s,t)}),e.jsx("span",{className:"pvx-notif-time",children:ee(s.createdAt)})]}),!s.isRead&&e.jsx("span",{className:"pvx-notif-dot"})]})}function nt({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 rt(){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 at({steamId:s,avatarUrl:t,memberSince:r,className:n=""}){const{data:a,isLoading:i,error:o}=_e(s),{data:c,isLoading:d}=Ve(s),{data:l,isLoading:p}=Ke(),v=He(),{data:g,isLoading:x}=Qe({limit:10}),f=Oe(),h=We();return i||d?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 ${n}`,children:[e.jsx(Ge,{driverName:a.driverName,avatarUrl:t,memberSince:r}),e.jsx(ze,{stats:a,rating:c}),s&&e.jsx(Je,{events:l,isLoading:p}),e.jsxs("div",{className:`pvx-dash-row ${v?"pvx-dash-row--2col":""}`,children:[e.jsx(Ye,{records:a.currentRecords}),v&&e.jsx(Ze,{notifications:g==null?void 0:g.notifications,unreadCount:(g==null?void 0:g.unreadCount)||0,onMarkRead:m=>f.mutate(m),onMarkAllRead:()=>h.mutate(),isLoading:x})]})]}):e.jsx("div",{className:"pvx-empty",children:"No data available yet. Start driving to see your stats!"})}exports.CarsTable=ms;exports.CompEmptyState=$;exports.CompLoadingState=I;exports.CompetitionCard=Ae;exports.CompetitionCards=Ls;exports.CompetitionResultsTabs=_s;exports.CompletedBadge=Be;exports.DEFAULT_COMPLETION_GRACE_DAYS=xe;exports.DriverDashboard=at;exports.DriverProfile=Ge;exports.DriversTable=hs;exports.EntryList=Bs;exports.InfoPill=_;exports.LapHistoryTable=vs;exports.NotificationsCard=Ze;exports.PODIUM_MEDALS=G;exports.PitVoxPartnerProvider=ss;exports.RankingsTable=gs;exports.RecordsTable=Ye;exports.RegisterButton=As;exports.RegistrationPanel=Es;exports.RoundResults=Ms;exports.RoundSessionResults=J;exports.StandingsTable=Ee;exports.StatsCards=ze;exports.TracksTable=us;exports.TypeBadge=$e;exports.UpcomingEvents=Je;exports.buildDriverIndexPath=ge;exports.buildLapsPath=ve;exports.buildLeaderboardPath=q;exports.buildRecentLapsPath=je;exports.fetchCdnJson=S;exports.filterCompetitionsByStatus=ws;exports.formatCarName=M;exports.formatDate=A;exports.formatDelta=ts;exports.formatFuel=te;exports.formatLapTime=P;exports.formatNotificationMessage=fe;exports.formatRelativeTime=ee;exports.formatSectorTime=D;exports.formatSessionLabel=z;exports.formatTrackName=B;exports.formatTyreCompound=se;exports.getCompetitionPodium=Ie;exports.getCompetitionStatus=ue;exports.getCompletionDate=Pe;exports.isCompetitionComplete=De;exports.useCarLeaderboard=is;exports.useCarMetadata=rs;exports.useCompetitionAllRounds=Ce;exports.useCompetitionConfig=re;exports.useCompetitionEntryList=ie;exports.useCompetitionLeaderboard=ke;exports.useCompetitionRound=ye;exports.useCompetitionRoundLaps=we;exports.useCompetitionStandings=ae;exports.useCompetitions=os;exports.useDriverLaps=be;exports.useDriverRating=Ve;exports.useDriverRatings=Hs;exports.useDriverStats=_e;exports.useLeaderboardIndex=ns;exports.useMarkAllNotificationsRead=We;exports.useMarkNotificationRead=Oe;exports.useNotifications=Qe;exports.useNotificationsEnabled=He;exports.usePitVox=k;exports.useRecentLaps=as;exports.useRegister=oe;exports.useRegistrationMode=K;exports.useRegistrationStatus=V;exports.useRegistrationUrl=H;exports.useTrackLeaderboard=Ne;exports.useUnreadCount=Qs;exports.useUpcomingEvents=Ke;exports.useUserLookup=ne;exports.useWithdraw=le;
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as t, jsxs as l, Fragment as U } from "react/jsx-runtime";
|
|
2
2
|
import { createContext as De, useMemo as L, useContext as Ie, useState as D, useCallback as H, useRef as Pe, useEffect as Be } from "react";
|
|
3
|
-
import { useQueryClient as _, QueryClient as Ae, QueryClientProvider as Ue, useQuery as
|
|
4
|
-
const Z = De(null),
|
|
3
|
+
import { useQueryClient as _, QueryClient as Ae, QueryClientProvider as Ue, useQuery as T, useMutation as O, useQueries as ce } from "@tanstack/react-query";
|
|
4
|
+
const Z = De(null), Fe = "https://cdn.pitvox.com", Ee = "https://pitvox.com";
|
|
5
5
|
let Y = null;
|
|
6
6
|
function en({
|
|
7
7
|
partnerSlug: e = null,
|
|
8
|
-
cdnUrl: n =
|
|
9
|
-
pitvoxUrl: s =
|
|
8
|
+
cdnUrl: n = Fe,
|
|
9
|
+
pitvoxUrl: s = Ee,
|
|
10
10
|
getSteamId: r,
|
|
11
11
|
onRegister: a,
|
|
12
12
|
onWithdraw: i,
|
|
@@ -139,7 +139,7 @@ function he(e) {
|
|
|
139
139
|
}
|
|
140
140
|
function nn(e = {}) {
|
|
141
141
|
var p, c, u, g, f, m;
|
|
142
|
-
const { cdnUrl: n, partnerSlug: s } = k(), { game: r, gameVersion: a } = e, i = X(s, null, null, "index.json"), o =
|
|
142
|
+
const { cdnUrl: n, partnerSlug: s } = k(), { game: r, gameVersion: a } = e, i = X(s, null, null, "index.json"), o = T({
|
|
143
143
|
queryKey: ["pitvox", "leaderboards", s, "index"],
|
|
144
144
|
queryFn: () => R(n, i),
|
|
145
145
|
staleTime: 3e4,
|
|
@@ -177,7 +177,7 @@ function nn(e = {}) {
|
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
function Ke(e, n, s = {}) {
|
|
180
|
-
const { cdnUrl: r, partnerSlug: a } = k(), { carId: i, game: o, gameVersion: d } = s, p = n || "default", c = X(a, o, d, `tracks/${e}/${p}.json`), { data: u, isLoading: g, error: f } =
|
|
180
|
+
const { cdnUrl: r, partnerSlug: a } = k(), { carId: i, game: o, gameVersion: d } = s, p = n || "default", c = X(a, o, d, `tracks/${e}/${p}.json`), { data: u, isLoading: g, error: f } = T({
|
|
181
181
|
queryKey: ["pitvox", "leaderboards", a, "track", e, p, o, d],
|
|
182
182
|
queryFn: () => R(r, c),
|
|
183
183
|
enabled: !!e,
|
|
@@ -203,7 +203,7 @@ function Ke(e, n, s = {}) {
|
|
|
203
203
|
}
|
|
204
204
|
function He(e, n, s, r, a = {}) {
|
|
205
205
|
var x, v;
|
|
206
|
-
const { cdnUrl: i, partnerSlug: o } = k(), { showInvalid: d = !1, game: p, gameVersion: c } = a, u = e && n ? _e(o, e, n, s) : null, f =
|
|
206
|
+
const { cdnUrl: i, partnerSlug: o } = k(), { showInvalid: d = !1, game: p, gameVersion: c } = a, u = e && n ? _e(o, e, n, s) : null, f = T({
|
|
207
207
|
queryKey: ["pitvox", "laps", o, e, n, s || "default"],
|
|
208
208
|
queryFn: () => R(i, u),
|
|
209
209
|
enabled: !!e && !!n,
|
|
@@ -215,8 +215,8 @@ function He(e, n, s, r, a = {}) {
|
|
|
215
215
|
}, [(x = f.data) == null ? void 0 : x.laps, r, p, c, d]), b = L(() => {
|
|
216
216
|
const N = m.filter(($) => $.isValid && $.sector1Ms && $.sector2Ms && $.sector3Ms);
|
|
217
217
|
if (N.length < 2) return null;
|
|
218
|
-
const h = Math.min(...N.map(($) => $.sector1Ms)), w = Math.min(...N.map(($) => $.sector2Ms)), y = Math.min(...N.map(($) => $.sector3Ms)), C = h + w + y,
|
|
219
|
-
return C >=
|
|
218
|
+
const h = Math.min(...N.map(($) => $.sector1Ms)), w = Math.min(...N.map(($) => $.sector2Ms)), y = Math.min(...N.map(($) => $.sector3Ms)), C = h + w + y, S = Math.min(...N.map(($) => $.lapTimeMs));
|
|
219
|
+
return C >= S ? null : { lapTimeMs: C, sector1Ms: h, sector2Ms: w, sector3Ms: y };
|
|
220
220
|
}, [m]);
|
|
221
221
|
return {
|
|
222
222
|
...f,
|
|
@@ -226,7 +226,7 @@ function He(e, n, s, r, a = {}) {
|
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
228
|
function ve() {
|
|
229
|
-
const { cdnUrl: e } = k(), { data: n } =
|
|
229
|
+
const { cdnUrl: e } = k(), { data: n } = T({
|
|
230
230
|
queryKey: ["pitvox", "users", "index"],
|
|
231
231
|
queryFn: () => R(e, "users/index.json"),
|
|
232
232
|
staleTime: 5 * 6e4,
|
|
@@ -242,7 +242,7 @@ function ve() {
|
|
|
242
242
|
};
|
|
243
243
|
}
|
|
244
244
|
function rn() {
|
|
245
|
-
const { cdnUrl: e } = k(), { data: n } =
|
|
245
|
+
const { cdnUrl: e } = k(), { data: n } = T({
|
|
246
246
|
queryKey: ["pitvox", "cars", "evo"],
|
|
247
247
|
queryFn: () => R(e, "cars/evo.json"),
|
|
248
248
|
staleTime: 5 * 6e4,
|
|
@@ -255,7 +255,7 @@ function rn() {
|
|
|
255
255
|
}
|
|
256
256
|
function sn() {
|
|
257
257
|
var a, i;
|
|
258
|
-
const { cdnUrl: e, partnerSlug: n } = k(), s = je(n), r =
|
|
258
|
+
const { cdnUrl: e, partnerSlug: n } = k(), s = je(n), r = T({
|
|
259
259
|
queryKey: ["pitvox", "recentLaps", n],
|
|
260
260
|
queryFn: () => R(e, s),
|
|
261
261
|
staleTime: 3e4,
|
|
@@ -273,7 +273,7 @@ function an(e, n) {
|
|
|
273
273
|
}
|
|
274
274
|
function on() {
|
|
275
275
|
const { cdnUrl: e, partnerSlug: n } = k();
|
|
276
|
-
return
|
|
276
|
+
return T({
|
|
277
277
|
queryKey: ["pitvox", "competitions", n],
|
|
278
278
|
queryFn: async () => {
|
|
279
279
|
const s = await R(e, "competitions/index.json");
|
|
@@ -284,7 +284,7 @@ function on() {
|
|
|
284
284
|
}
|
|
285
285
|
function xe(e, n = {}) {
|
|
286
286
|
const s = k(), r = n.partnerSlug || s.partnerSlug;
|
|
287
|
-
return
|
|
287
|
+
return T({
|
|
288
288
|
queryKey: ["pitvox", "competition", r, e, "config"],
|
|
289
289
|
queryFn: () => R(s.cdnUrl, `competitions/${r}/${e}/config.json`),
|
|
290
290
|
enabled: !!r && !!e,
|
|
@@ -293,7 +293,7 @@ function xe(e, n = {}) {
|
|
|
293
293
|
}
|
|
294
294
|
function ge(e, n = {}) {
|
|
295
295
|
const s = k(), r = n.partnerSlug || s.partnerSlug;
|
|
296
|
-
return
|
|
296
|
+
return T({
|
|
297
297
|
queryKey: ["pitvox", "competition", r, e, "standings"],
|
|
298
298
|
queryFn: () => R(s.cdnUrl, `competitions/${r}/${e}/standings.json`),
|
|
299
299
|
enabled: !!r && !!e,
|
|
@@ -302,7 +302,7 @@ function ge(e, n = {}) {
|
|
|
302
302
|
}
|
|
303
303
|
function Oe(e, n, s = {}) {
|
|
304
304
|
const r = k(), a = s.partnerSlug || r.partnerSlug;
|
|
305
|
-
return
|
|
305
|
+
return T({
|
|
306
306
|
queryKey: ["pitvox", "competition", a, e, "round", n],
|
|
307
307
|
queryFn: () => R(r.cdnUrl, `competitions/${a}/${e}/rounds/${n}.json`),
|
|
308
308
|
enabled: !!a && !!e && n != null,
|
|
@@ -311,7 +311,7 @@ function Oe(e, n, s = {}) {
|
|
|
311
311
|
}
|
|
312
312
|
function We(e, n = [], s = {}) {
|
|
313
313
|
const r = k(), a = s.partnerSlug || r.partnerSlug;
|
|
314
|
-
return
|
|
314
|
+
return T({
|
|
315
315
|
queryKey: ["pitvox", "competition", a, e, "allRounds", n],
|
|
316
316
|
queryFn: async () => (await Promise.all(
|
|
317
317
|
n.map(
|
|
@@ -322,18 +322,18 @@ function We(e, n = [], s = {}) {
|
|
|
322
322
|
staleTime: 6e4
|
|
323
323
|
});
|
|
324
324
|
}
|
|
325
|
-
function
|
|
325
|
+
function ze(e, n = {}) {
|
|
326
326
|
const s = k(), r = n.partnerSlug || s.partnerSlug;
|
|
327
|
-
return
|
|
327
|
+
return T({
|
|
328
328
|
queryKey: ["pitvox", "competition", r, e, "leaderboard"],
|
|
329
329
|
queryFn: () => R(s.cdnUrl, `competitions/${r}/${e}/leaderboard.json`).catch(() => null),
|
|
330
330
|
enabled: !!r && !!e,
|
|
331
331
|
staleTime: 6e4
|
|
332
332
|
});
|
|
333
333
|
}
|
|
334
|
-
function
|
|
334
|
+
function Ge(e, n, s = {}) {
|
|
335
335
|
const r = k(), a = s.partnerSlug || r.partnerSlug;
|
|
336
|
-
return
|
|
336
|
+
return T({
|
|
337
337
|
queryKey: ["pitvox", "competition", a, e, "round", n, "laps"],
|
|
338
338
|
queryFn: () => R(r.cdnUrl, `competitions/${a}/${e}/rounds/${n}/laps.json`).catch(() => null),
|
|
339
339
|
enabled: !!a && !!e && n != null,
|
|
@@ -342,7 +342,7 @@ function ze(e, n, s = {}) {
|
|
|
342
342
|
}
|
|
343
343
|
function fe(e, n = {}) {
|
|
344
344
|
const s = k(), r = n.partnerSlug || s.partnerSlug;
|
|
345
|
-
return
|
|
345
|
+
return T({
|
|
346
346
|
queryKey: ["pitvox", "competition", r, e, "entrylist"],
|
|
347
347
|
queryFn: () => R(s.cdnUrl, `competitions/${r}/${e}/entrylist.json`),
|
|
348
348
|
enabled: !!r && !!e,
|
|
@@ -351,7 +351,7 @@ function fe(e, n = {}) {
|
|
|
351
351
|
}
|
|
352
352
|
function ee(e) {
|
|
353
353
|
const { cdnUrl: n, partnerSlug: s, getSteamId: r } = k(), a = r();
|
|
354
|
-
return
|
|
354
|
+
return T({
|
|
355
355
|
queryKey: ["pitvox", "registration", s, e, a],
|
|
356
356
|
queryFn: async () => {
|
|
357
357
|
var p;
|
|
@@ -486,7 +486,7 @@ function W(e) {
|
|
|
486
486
|
}, []);
|
|
487
487
|
return [n, r];
|
|
488
488
|
}
|
|
489
|
-
function
|
|
489
|
+
function z(e, n, s) {
|
|
490
490
|
return [...e].sort((r, a) => {
|
|
491
491
|
const i = s(r, n.key), o = s(a, n.key);
|
|
492
492
|
if (i == null && o == null) return 0;
|
|
@@ -520,7 +520,7 @@ function M({ label: e, sortKey: n, config: s, onSort: r, className: a = "" }) {
|
|
|
520
520
|
}
|
|
521
521
|
);
|
|
522
522
|
}
|
|
523
|
-
function
|
|
523
|
+
function G({ userId: e, getUserDisplay: n }) {
|
|
524
524
|
const { displayName: s, avatarUrl: r } = n(e);
|
|
525
525
|
return /* @__PURE__ */ l("span", { className: "pvx-driver", children: [
|
|
526
526
|
r ? /* @__PURE__ */ t("img", { src: r, alt: "", className: "pvx-driver-avatar" }) : /* @__PURE__ */ t("span", { className: "pvx-driver-avatar pvx-driver-avatar--placeholder" }),
|
|
@@ -609,7 +609,7 @@ function ln({ tracks: e, isLoading: n, carMetadata: s, getUserDisplay: r, onTrac
|
|
|
609
609
|
timestamp: v.recordedAt
|
|
610
610
|
}
|
|
611
611
|
} : null;
|
|
612
|
-
}).filter(Boolean) : [], [e, c, s]), b = L(() =>
|
|
612
|
+
}).filter(Boolean) : [], [e, c, s]), b = L(() => z(m, d, (x, v) => {
|
|
613
613
|
var N, h;
|
|
614
614
|
switch (v) {
|
|
615
615
|
case "displayName":
|
|
@@ -647,7 +647,7 @@ function ln({ tracks: e, isLoading: n, carMetadata: s, getUserDisplay: r, onTrac
|
|
|
647
647
|
onClick: () => a(x.id, x.layout),
|
|
648
648
|
children: [
|
|
649
649
|
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--primary", children: x.displayName }),
|
|
650
|
-
/* @__PURE__ */ t("td", { className: "pvx-td", children: (v = x.record) != null && v.visibleId ? /* @__PURE__ */ t(
|
|
650
|
+
/* @__PURE__ */ t("td", { className: "pvx-td", children: (v = x.record) != null && v.visibleId ? /* @__PURE__ */ t(G, { userId: x.record.visibleId, getUserDisplay: r }) : "-" }),
|
|
651
651
|
/* @__PURE__ */ t("td", { className: "pvx-td pvx-hidden-below-lg", children: ((N = x.record) == null ? void 0 : N.carDisplayName) || "-" }),
|
|
652
652
|
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: x.record ? A(x.record.lapTimeMs) : "-" }),
|
|
653
653
|
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: x.driverCount || "-" }),
|
|
@@ -666,14 +666,14 @@ function cn({ entries: e, isLoading: n, track: s, carMetadata: r, getUserDisplay
|
|
|
666
666
|
var w, y, C;
|
|
667
667
|
if (!e || !((w = r == null ? void 0 : r.tags) != null && w.length)) return [];
|
|
668
668
|
const h = /* @__PURE__ */ new Set();
|
|
669
|
-
for (const
|
|
670
|
-
(((C = (y = r.cars) == null ? void 0 : y[
|
|
671
|
-
return r.tags.filter((
|
|
669
|
+
for (const S of e)
|
|
670
|
+
(((C = (y = r.cars) == null ? void 0 : y[S.carId]) == null ? void 0 : C.tags) || ["sports_car"]).forEach((E) => h.add(E));
|
|
671
|
+
return r.tags.filter((S) => h.has(S));
|
|
672
672
|
}, [e, r]), x = L(() => e ? g.size === 0 ? e : e.filter((h) => {
|
|
673
673
|
var y, C;
|
|
674
674
|
const w = ((C = (y = r == null ? void 0 : r.cars) == null ? void 0 : y[h.carId]) == null ? void 0 : C.tags) || ["sports_car"];
|
|
675
675
|
return we(w, g);
|
|
676
|
-
}) : [], [e, g, r]), v = L(() =>
|
|
676
|
+
}) : [], [e, g, r]), v = L(() => z(x, c, (h, w) => {
|
|
677
677
|
switch (w) {
|
|
678
678
|
case "carId":
|
|
679
679
|
return I(h.carId);
|
|
@@ -707,7 +707,7 @@ function cn({ entries: e, isLoading: n, track: s, carMetadata: r, getUserDisplay
|
|
|
707
707
|
children: [
|
|
708
708
|
/* @__PURE__ */ t("td", { className: "pvx-td", children: /* @__PURE__ */ t(re, { rank: w + 1, podium: !0 }) }),
|
|
709
709
|
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--primary", children: I(h.carId) }),
|
|
710
|
-
/* @__PURE__ */ t("td", { className: "pvx-td", children: /* @__PURE__ */ t(
|
|
710
|
+
/* @__PURE__ */ t("td", { className: "pvx-td", children: /* @__PURE__ */ t(G, { userId: h.steamId || h.userId, getUserDisplay: a }) }),
|
|
711
711
|
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: A(h.lapTimeMs) }),
|
|
712
712
|
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: h.driverCount || "-" }),
|
|
713
713
|
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-lg", children: h.recordedAt ? j(h.recordedAt) : "-" })
|
|
@@ -719,7 +719,7 @@ function cn({ entries: e, isLoading: n, track: s, carMetadata: r, getUserDisplay
|
|
|
719
719
|
] });
|
|
720
720
|
}
|
|
721
721
|
function dn({ entries: e, isLoading: n, track: s, carId: r, getUserDisplay: a, onDriverSelect: i, onNavigate: o, highlightId: d }) {
|
|
722
|
-
const [p, c] = W({ key: "lapTimeMs", dir: "asc" }), u = L(() => Ce(e), [e]), g = L(() =>
|
|
722
|
+
const [p, c] = W({ key: "lapTimeMs", dir: "asc" }), u = L(() => Ce(e), [e]), g = L(() => z(e || [], p, (m, b) => {
|
|
723
723
|
switch (b) {
|
|
724
724
|
case "userId":
|
|
725
725
|
return a(m.steamId || m.userId).displayName;
|
|
@@ -758,7 +758,7 @@ function dn({ entries: e, isLoading: n, track: s, carId: r, getUserDisplay: a, o
|
|
|
758
758
|
onClick: () => i(v),
|
|
759
759
|
children: [
|
|
760
760
|
/* @__PURE__ */ t("td", { className: "pvx-td", children: /* @__PURE__ */ t(re, { rank: x, podium: !0 }) }),
|
|
761
|
-
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--primary", children: /* @__PURE__ */ t(
|
|
761
|
+
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--primary", children: /* @__PURE__ */ t(G, { userId: v, getUserDisplay: a }) }),
|
|
762
762
|
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: A(m.lapTimeMs) }),
|
|
763
763
|
/* @__PURE__ */ t("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${N ? "pvx-td--best-sector" : ""}`, children: B(m.sector1Ms) }),
|
|
764
764
|
/* @__PURE__ */ t("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${h ? "pvx-td--best-sector" : ""}`, children: B(m.sector2Ms) }),
|
|
@@ -831,14 +831,14 @@ function pn({ userId: e, track: n, carId: s, game: r, gameVersion: a, showInvali
|
|
|
831
831
|
/* @__PURE__ */ t("th", { className: "pvx-th pvx-hidden-below-xl", children: "Date" })
|
|
832
832
|
] }) }),
|
|
833
833
|
/* @__PURE__ */ t("tbody", { className: "pvx-tbody", children: c.map((h, w) => {
|
|
834
|
-
const y = h.isValid && h.lapTimeMs === v, C = x && h.isValid && h.sector1Ms === x.s1,
|
|
835
|
-
let
|
|
836
|
-
return h.isValid || (
|
|
834
|
+
const y = h.isValid && h.lapTimeMs === v, C = x && h.isValid && h.sector1Ms === x.s1, S = x && h.isValid && h.sector2Ms === x.s2, $ = x && h.isValid && h.sector3Ms === x.s3;
|
|
835
|
+
let E = "pvx-row";
|
|
836
|
+
return h.isValid || (E += " pvx-row--invalid"), y && (E += " pvx-row--personal-best"), /* @__PURE__ */ l("tr", { className: E, children: [
|
|
837
837
|
/* @__PURE__ */ t("td", { className: "pvx-td", children: /* @__PURE__ */ t("span", { className: `pvx-rank ${y ? "pvx-rank--gold" : ""}`, children: w + 1 }) }),
|
|
838
838
|
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-md", children: h.lapNumber || "-" }),
|
|
839
839
|
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: A(h.lapTimeMs) }),
|
|
840
840
|
/* @__PURE__ */ t("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${C ? "pvx-td--best-sector" : ""}`, children: B(h.sector1Ms) }),
|
|
841
|
-
/* @__PURE__ */ t("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${
|
|
841
|
+
/* @__PURE__ */ t("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${S ? "pvx-td--best-sector" : ""}`, children: B(h.sector2Ms) }),
|
|
842
842
|
/* @__PURE__ */ t("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${$ ? "pvx-td--best-sector" : ""}`, children: B(h.sector3Ms) }),
|
|
843
843
|
/* @__PURE__ */ t("td", { className: "pvx-td", title: h.isValid ? void 0 : h.invalidReason || "Invalid", children: h.isValid ? /* @__PURE__ */ t(Ze, {}) : /* @__PURE__ */ t(Xe, {}) }),
|
|
844
844
|
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", title: me(h.tyreCompound), children: h.tyreCompound || "-" }),
|
|
@@ -850,7 +850,7 @@ function pn({ userId: e, track: n, carId: s, game: r, gameVersion: a, showInvali
|
|
|
850
850
|
] });
|
|
851
851
|
}
|
|
852
852
|
function un({ drivers: e, isLoading: n, getUserDisplay: s, game: r, gameVersion: a, onComboSelect: i }) {
|
|
853
|
-
const [o, d] = W({ key: "rank", dir: "asc" }), [p, c] = D(null), u = L(() => e ?
|
|
853
|
+
const [o, d] = W({ key: "rank", dir: "asc" }), [p, c] = D(null), u = L(() => e ? z(e, o, (f, m) => {
|
|
854
854
|
switch (m) {
|
|
855
855
|
case "rating":
|
|
856
856
|
return f.rating;
|
|
@@ -921,7 +921,7 @@ function et({ driver: e, getUserDisplay: n, isExpanded: s, onToggle: r, colCount
|
|
|
921
921
|
onClick: r,
|
|
922
922
|
children: [
|
|
923
923
|
/* @__PURE__ */ t("td", { className: "pvx-td", children: /* @__PURE__ */ t(re, { rank: e.rank, podium: !0 }) }),
|
|
924
|
-
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--primary", children: /* @__PURE__ */ t(
|
|
924
|
+
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--primary", children: /* @__PURE__ */ t(G, { userId: p, getUserDisplay: n }) }),
|
|
925
925
|
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: e.rating.toFixed(1) }),
|
|
926
926
|
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--center pvx-hidden-below-sm", children: e.distinctCars || "-" }),
|
|
927
927
|
/* @__PURE__ */ t("td", { className: "pvx-td pvx-td--center pvx-hidden-below-sm", children: /* @__PURE__ */ l("span", { className: "pvx-rankings-combo-count", children: [
|
|
@@ -1056,16 +1056,16 @@ function ot(e) {
|
|
|
1056
1056
|
}) : [...s.splits] : n;
|
|
1057
1057
|
}, null);
|
|
1058
1058
|
}
|
|
1059
|
-
function
|
|
1059
|
+
function F({ message: e = "Loading..." }) {
|
|
1060
1060
|
return /* @__PURE__ */ t("div", { className: "pvx-loading", children: e });
|
|
1061
1061
|
}
|
|
1062
1062
|
function P({ message: e = "No data available." }) {
|
|
1063
1063
|
return /* @__PURE__ */ t("div", { className: "pvx-empty", children: /* @__PURE__ */ t("p", { children: e }) });
|
|
1064
1064
|
}
|
|
1065
|
-
const
|
|
1065
|
+
const Se = 3;
|
|
1066
1066
|
function lt(e) {
|
|
1067
1067
|
const n = e == null ? void 0 : e.rounds;
|
|
1068
|
-
return n != null && n.length ? n.every((s) => s.isFinalized) : !1;
|
|
1068
|
+
return n != null && n.length ? e.type === "hotlap" ? n.every((s) => s.isFinalized && s.dediStatus === "completed") : n.every((s) => s.isFinalized) : !1;
|
|
1069
1069
|
}
|
|
1070
1070
|
function ct(e) {
|
|
1071
1071
|
const n = e == null ? void 0 : e.rounds;
|
|
@@ -1078,17 +1078,17 @@ function ct(e) {
|
|
|
1078
1078
|
}
|
|
1079
1079
|
return s;
|
|
1080
1080
|
}
|
|
1081
|
-
function
|
|
1081
|
+
function Te(e, n = Se) {
|
|
1082
1082
|
if (!lt(e)) return "active";
|
|
1083
1083
|
const s = ct(e);
|
|
1084
1084
|
if (!s) return "recently-completed";
|
|
1085
1085
|
const r = n * 24 * 60 * 60 * 1e3;
|
|
1086
1086
|
return Date.now() - s.getTime() <= r ? "recently-completed" : "archived";
|
|
1087
1087
|
}
|
|
1088
|
-
function mn(e, n, s =
|
|
1088
|
+
function mn(e, n, s = Se) {
|
|
1089
1089
|
if (!(e != null && e.length)) return [];
|
|
1090
1090
|
const r = new Set(Array.isArray(n) ? n : [n]);
|
|
1091
|
-
return e.filter((a) => r.has(
|
|
1091
|
+
return e.filter((a) => r.has(Te(a, s)));
|
|
1092
1092
|
}
|
|
1093
1093
|
function dt(e, n = 3) {
|
|
1094
1094
|
const s = e == null ? void 0 : e.standings;
|
|
@@ -1106,11 +1106,11 @@ function pt({ competitionId: e, topN: n = 3, label: s = "Completed", className:
|
|
|
1106
1106
|
] });
|
|
1107
1107
|
}
|
|
1108
1108
|
function hn({ competitions: e, isLoading: n, onSelect: s, onRegister: r, className: a }) {
|
|
1109
|
-
return n ? /* @__PURE__ */ t(
|
|
1109
|
+
return n ? /* @__PURE__ */ t(F, { message: "Loading competitions..." }) : e != null && e.length ? /* @__PURE__ */ t("div", { className: `pvx-comp-grid ${a || ""}`, children: e.map((i) => /* @__PURE__ */ t(ut, { comp: i, onSelect: s, onRegister: r || s }, i.id)) }) : /* @__PURE__ */ t(P, { message: "No competitions available." });
|
|
1110
1110
|
}
|
|
1111
1111
|
function ut({ comp: e, onSelect: n, onRegister: s }) {
|
|
1112
1112
|
var h, w, y;
|
|
1113
|
-
const { cdnUrl: r } = k(), a = e.posterCdnPath ? `${r}/${e.posterCdnPath}` : null, i = e.registration, o = (i == null ? void 0 : i.currentCount) || 0, d = i == null ? void 0 : i.maxParticipants, p = d && o >= d, c = (i == null ? void 0 : i.deadline) && new Date(i.deadline) < /* @__PURE__ */ new Date(), u = (i == null ? void 0 : i.isOpen) && !c && !p, g = /* @__PURE__ */ new Date(), f = (h = e.rounds) == null ? void 0 : h.find((C) => C.startTime && new Date(C.startTime) >= g), m = ((w = e.rounds) == null ? void 0 : w.length) || 0, b = ((y = e.rounds) == null ? void 0 : y.filter((C) => C.isFinalized).length) || 0, x =
|
|
1113
|
+
const { cdnUrl: r } = k(), a = e.posterCdnPath ? `${r}/${e.posterCdnPath}` : null, i = e.registration, o = (i == null ? void 0 : i.currentCount) || 0, d = i == null ? void 0 : i.maxParticipants, p = d && o >= d, c = (i == null ? void 0 : i.deadline) && new Date(i.deadline) < /* @__PURE__ */ new Date(), u = (i == null ? void 0 : i.isOpen) && !c && !p, g = /* @__PURE__ */ new Date(), f = (h = e.rounds) == null ? void 0 : h.find((C) => C.startTime && new Date(C.startTime) >= g), m = ((w = e.rounds) == null ? void 0 : w.length) || 0, b = ((y = e.rounds) == null ? void 0 : y.filter((C) => C.isFinalized).length) || 0, x = Te(e), v = x === "recently-completed" || x === "archived", N = e.type === "championship";
|
|
1114
1114
|
return /* @__PURE__ */ l(
|
|
1115
1115
|
"div",
|
|
1116
1116
|
{
|
|
@@ -1129,9 +1129,9 @@ function ut({ comp: e, onSelect: n, onRegister: s }) {
|
|
|
1129
1129
|
/* @__PURE__ */ l("div", { className: "pvx-comp-card-pills", children: [
|
|
1130
1130
|
/* @__PURE__ */ t(at, { type: e.type }),
|
|
1131
1131
|
e.game && /* @__PURE__ */ t(J, { children: e.game.toUpperCase() }),
|
|
1132
|
-
e.formatDescription && e.formatDescription.split(", ").map((C,
|
|
1132
|
+
e.formatDescription && e.formatDescription.split(", ").map((C, S) => /* @__PURE__ */ t(J, { variant: "format", children: C }, S))
|
|
1133
1133
|
] }),
|
|
1134
|
-
e.carsDescription && /* @__PURE__ */ t("div", { className: "pvx-comp-card-pills", children: e.carsDescription.split(", ").map((C,
|
|
1134
|
+
e.carsDescription && /* @__PURE__ */ t("div", { className: "pvx-comp-card-pills", children: e.carsDescription.split(", ").map((C, S) => /* @__PURE__ */ t(J, { children: C }, S)) }),
|
|
1135
1135
|
/* @__PURE__ */ l("div", { className: "pvx-comp-card-schedule", children: [
|
|
1136
1136
|
f ? /* @__PURE__ */ l("span", { className: "pvx-comp-card-schedule-next", children: [
|
|
1137
1137
|
/* @__PURE__ */ t("span", { className: "pvx-comp-card-schedule-label", children: "Next:" }),
|
|
@@ -1224,7 +1224,7 @@ function vt({ competitionId: e, className: n }) {
|
|
|
1224
1224
|
var d, p;
|
|
1225
1225
|
const { data: s, isLoading: r } = ge(e), { data: a, isLoading: i } = xe(e);
|
|
1226
1226
|
if (r || i)
|
|
1227
|
-
return /* @__PURE__ */ t(
|
|
1227
|
+
return /* @__PURE__ */ t(F, { message: "Loading standings..." });
|
|
1228
1228
|
if (!((d = s == null ? void 0 : s.standings) != null && d.length))
|
|
1229
1229
|
return /* @__PURE__ */ t(P, { message: "No standings data yet. Results will appear once rounds are finalised." });
|
|
1230
1230
|
const o = ((p = a == null ? void 0 : a.rounds) == null ? void 0 : p.filter((c) => c.isFinalized)) || [];
|
|
@@ -1307,7 +1307,7 @@ function vn({ competitionId: e, roundNumber: n, className: s }) {
|
|
|
1307
1307
|
var p;
|
|
1308
1308
|
const { data: r, isLoading: a } = Oe(e, n);
|
|
1309
1309
|
if (a)
|
|
1310
|
-
return /* @__PURE__ */ t(
|
|
1310
|
+
return /* @__PURE__ */ t(F, { message: "Loading results..." });
|
|
1311
1311
|
if (!r)
|
|
1312
1312
|
return /* @__PURE__ */ t(P, { message: "No results for this round." });
|
|
1313
1313
|
const o = (r.sessions || []).find((c) => c.type === "RACE"), d = (p = o == null ? void 0 : o.results) == null ? void 0 : p.filter((c) => c.position <= 3).sort((c, u) => c.position - u.position);
|
|
@@ -1338,7 +1338,7 @@ function le({ round: e, competitionId: n, className: s }) {
|
|
|
1338
1338
|
const [r, a] = D(null), i = (e == null ? void 0 : e.sessions) || [];
|
|
1339
1339
|
if (!i.length)
|
|
1340
1340
|
return /* @__PURE__ */ t(P, { message: "No session data for this round." });
|
|
1341
|
-
const { data: o } =
|
|
1341
|
+
const { data: o } = Ge(
|
|
1342
1342
|
n,
|
|
1343
1343
|
e == null ? void 0 : e.roundNumber,
|
|
1344
1344
|
{}
|
|
@@ -1484,7 +1484,7 @@ function bt({ bestLap: e, hasBestLap: n, splits: s, fastestSplits: r, showAbove:
|
|
|
1484
1484
|
function xn({ competitionId: e, className: n }) {
|
|
1485
1485
|
const { getSteamId: s } = k(), { data: r, isLoading: a } = fe(e), i = s();
|
|
1486
1486
|
if (a)
|
|
1487
|
-
return /* @__PURE__ */ t(
|
|
1487
|
+
return /* @__PURE__ */ t(F, { message: "Loading drivers..." });
|
|
1488
1488
|
const o = (r == null ? void 0 : r.drivers) || (r == null ? void 0 : r.entries) || [];
|
|
1489
1489
|
return o.length ? /* @__PURE__ */ t("div", { className: `pvx-entry-grid ${n || ""}`, children: o.map((d) => {
|
|
1490
1490
|
var c, u;
|
|
@@ -1537,7 +1537,7 @@ function gn({
|
|
|
1537
1537
|
}
|
|
1538
1538
|
function fn({ competitionId: e, registration: n, onWithdrawSuccess: s, className: r }) {
|
|
1539
1539
|
const { getSteamId: a } = k(), { isPowerMode: i } = te(), o = ne(e), { data: d, isLoading: p } = ee(e), { data: c, isLoading: u } = fe(e), g = Ne(e), f = be(e), m = a(), b = (d == null ? void 0 : d.isRegistered) || !1, x = (c == null ? void 0 : c.drivers) || (c == null ? void 0 : c.entries) || [], v = n || {}, N = x.length || v.currentCount || 0, h = v.maxParticipants && N >= v.maxParticipants, w = v.deadline && new Date(v.deadline) < /* @__PURE__ */ new Date(), y = v.isOpen && !w && !h;
|
|
1540
|
-
return p || u ? /* @__PURE__ */ t(
|
|
1540
|
+
return p || u ? /* @__PURE__ */ t(F, { message: "Loading registration..." }) : b ? /* @__PURE__ */ t("div", { className: `pvx-reg-panel ${r || ""}`, children: /* @__PURE__ */ t(
|
|
1541
1541
|
wt,
|
|
1542
1542
|
{
|
|
1543
1543
|
competitionId: e,
|
|
@@ -1722,7 +1722,7 @@ function $e({ count: e, max: n }) {
|
|
|
1722
1722
|
] });
|
|
1723
1723
|
}
|
|
1724
1724
|
function Nn({ competitionId: e, className: n }) {
|
|
1725
|
-
const { data: s, isLoading: r } = xe(e), a = (s == null ? void 0 : s.type) === "championship", i = (s == null ? void 0 : s.type) === "hotlap", { data: o } =
|
|
1725
|
+
const { data: s, isLoading: r } = xe(e), a = (s == null ? void 0 : s.type) === "championship", i = (s == null ? void 0 : s.type) === "hotlap", { data: o } = ze(i ? e : null), d = L(
|
|
1726
1726
|
() => {
|
|
1727
1727
|
var y;
|
|
1728
1728
|
return ((y = s == null ? void 0 : s.rounds) == null ? void 0 : y.filter((C) => C.isFinalized)) || [];
|
|
@@ -1736,7 +1736,7 @@ function Nn({ competitionId: e, className: n }) {
|
|
|
1736
1736
|
p
|
|
1737
1737
|
), g = i && c.length > 0 ? c[0] : null, f = (g == null ? void 0 : g.sessions) || [], m = i ? "leaderboard" : a ? "standings" : p.length > 0 ? `round-${p[p.length - 1]}` : null, [b, x] = D(null), v = b || m;
|
|
1738
1738
|
if (r || u)
|
|
1739
|
-
return /* @__PURE__ */ t(
|
|
1739
|
+
return /* @__PURE__ */ t(F, { message: "Loading results..." });
|
|
1740
1740
|
if (!s)
|
|
1741
1741
|
return /* @__PURE__ */ t(P, { message: "Competition not found." });
|
|
1742
1742
|
if (!d.length)
|
|
@@ -1855,8 +1855,8 @@ function Lt({ session: e, round: n, competitionId: s }) {
|
|
|
1855
1855
|
)
|
|
1856
1856
|
] }) : /* @__PURE__ */ t(P, { message: "Session data not available." });
|
|
1857
1857
|
}
|
|
1858
|
-
function
|
|
1859
|
-
const { cdnUrl: n } = k(), s =
|
|
1858
|
+
function St(e) {
|
|
1859
|
+
const { cdnUrl: n } = k(), s = T({
|
|
1860
1860
|
queryKey: ["pitvox", "laps", "global", e, "index"],
|
|
1861
1861
|
queryFn: () => R(n, qe(null, e)),
|
|
1862
1862
|
enabled: !!e,
|
|
@@ -1883,7 +1883,7 @@ function Tt(e) {
|
|
|
1883
1883
|
}
|
|
1884
1884
|
function Me(e = {}) {
|
|
1885
1885
|
const { cdnUrl: n, partnerSlug: s } = k(), { game: r, gameVersion: a, enabled: i = !0 } = e, o = X(s, r, a, "ratings.json");
|
|
1886
|
-
return
|
|
1886
|
+
return T({
|
|
1887
1887
|
queryKey: ["pitvox", "ratings", s, r || null, a || null],
|
|
1888
1888
|
queryFn: () => R(n, o),
|
|
1889
1889
|
staleTime: 3e4,
|
|
@@ -1891,7 +1891,7 @@ function Me(e = {}) {
|
|
|
1891
1891
|
enabled: i
|
|
1892
1892
|
});
|
|
1893
1893
|
}
|
|
1894
|
-
function
|
|
1894
|
+
function Tt(e) {
|
|
1895
1895
|
var r;
|
|
1896
1896
|
const n = Me(), s = L(() => {
|
|
1897
1897
|
var a;
|
|
@@ -1921,7 +1921,7 @@ function bn(e = {}) {
|
|
|
1921
1921
|
};
|
|
1922
1922
|
}
|
|
1923
1923
|
function Rt() {
|
|
1924
|
-
const { cdnUrl: e, partnerSlug: n, getSteamId: s, onFetchServerPassword: r } = k(), a = s(), { data: i, isLoading: o } =
|
|
1924
|
+
const { cdnUrl: e, partnerSlug: n, getSteamId: s, onFetchServerPassword: r } = k(), a = s(), { data: i, isLoading: o } = T({
|
|
1925
1925
|
queryKey: ["pitvox", "competitions", n],
|
|
1926
1926
|
queryFn: async () => {
|
|
1927
1927
|
const m = await R(e, "competitions/index.json");
|
|
@@ -1941,15 +1941,15 @@ function Rt() {
|
|
|
1941
1941
|
const m = /* @__PURE__ */ new Date(), b = [];
|
|
1942
1942
|
for (let N = 0; N < i.length; N++) {
|
|
1943
1943
|
const h = i[N], w = (x = p[N]) == null ? void 0 : x.data;
|
|
1944
|
-
if (!((v = w == null ? void 0 : w.drivers) == null ? void 0 : v.some((
|
|
1944
|
+
if (!((v = w == null ? void 0 : w.drivers) == null ? void 0 : v.some((S) => S.steamId === a))) continue;
|
|
1945
1945
|
const C = h.rounds || [];
|
|
1946
|
-
for (const
|
|
1947
|
-
|
|
1946
|
+
for (const S of C)
|
|
1947
|
+
S.isFinalized || !S.startTime || new Date(S.startTime) <= m || b.push({
|
|
1948
1948
|
competitionId: h.id,
|
|
1949
1949
|
competitionName: h.name,
|
|
1950
|
-
roundNumber:
|
|
1951
|
-
track:
|
|
1952
|
-
startTime:
|
|
1950
|
+
roundNumber: S.roundNumber,
|
|
1951
|
+
track: S.track || "TBD",
|
|
1952
|
+
startTime: S.startTime
|
|
1953
1953
|
});
|
|
1954
1954
|
}
|
|
1955
1955
|
return b.sort((N, h) => new Date(N.startTime) - new Date(h.startTime)), b.length > 0 && (b[0].isNext = !0), b;
|
|
@@ -1982,7 +1982,7 @@ function $t() {
|
|
|
1982
1982
|
}
|
|
1983
1983
|
function Mt(e = {}) {
|
|
1984
1984
|
const { onFetchNotifications: n, partnerSlug: s } = k(), { limit: r = 20, unreadOnly: a = !1 } = e;
|
|
1985
|
-
return
|
|
1985
|
+
return T({
|
|
1986
1986
|
queryKey: ["pitvox", "notifications", s, { limit: r, unreadOnly: a }],
|
|
1987
1987
|
queryFn: () => n({ limit: r, unreadOnly: a }),
|
|
1988
1988
|
enabled: !!n,
|
|
@@ -1991,7 +1991,7 @@ function Mt(e = {}) {
|
|
|
1991
1991
|
});
|
|
1992
1992
|
}
|
|
1993
1993
|
function yn() {
|
|
1994
|
-
const { onFetchNotifications: e, partnerSlug: n } = k(), { data: s, isLoading: r } =
|
|
1994
|
+
const { onFetchNotifications: e, partnerSlug: n } = k(), { data: s, isLoading: r } = T({
|
|
1995
1995
|
queryKey: ["pitvox", "notifications", n, { limit: 1, unreadOnly: !1 }],
|
|
1996
1996
|
queryFn: () => e({ limit: 1 }),
|
|
1997
1997
|
enabled: !!e,
|
|
@@ -2110,7 +2110,7 @@ function pe({ icon: e, value: n, label: s, items: r, labelKey: a, countKey: i })
|
|
|
2110
2110
|
}
|
|
2111
2111
|
);
|
|
2112
2112
|
}
|
|
2113
|
-
function
|
|
2113
|
+
function Ft({ stats: e, rating: n, className: s = "" }) {
|
|
2114
2114
|
if (!e) return null;
|
|
2115
2115
|
const r = e.trackBreakdown.map((i) => ({
|
|
2116
2116
|
name: q(i.trackId, i.layout),
|
|
@@ -2157,7 +2157,7 @@ function Et({ stats: e, rating: n, className: s = "" }) {
|
|
|
2157
2157
|
] })
|
|
2158
2158
|
] });
|
|
2159
2159
|
}
|
|
2160
|
-
function
|
|
2160
|
+
function Et({ records: e, className: n = "" }) {
|
|
2161
2161
|
const s = L(() => e != null && e.length ? e.slice().sort((r, a) => {
|
|
2162
2162
|
const i = r.recordedAt ? new Date(r.recordedAt).getTime() : 0;
|
|
2163
2163
|
return (a.recordedAt ? new Date(a.recordedAt).getTime() : 0) - i;
|
|
@@ -2340,7 +2340,7 @@ function Wt() {
|
|
|
2340
2340
|
/* @__PURE__ */ t("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
2341
2341
|
] });
|
|
2342
2342
|
}
|
|
2343
|
-
function
|
|
2343
|
+
function zt({ notifications: e, unreadCount: n = 0, onMarkRead: s, onMarkAllRead: r, isLoading: a, className: i }) {
|
|
2344
2344
|
const o = ve();
|
|
2345
2345
|
return a ? /* @__PURE__ */ t("div", { className: "pvx-loading", children: "Loading notifications..." }) : /* @__PURE__ */ l("div", { className: `pvx-card ${i || ""}`, children: [
|
|
2346
2346
|
/* @__PURE__ */ l("div", { className: "pvx-card-header", children: [
|
|
@@ -2352,7 +2352,7 @@ function Gt({ notifications: e, unreadCount: n = 0, onMarkRead: s, onMarkAllRead
|
|
|
2352
2352
|
n > 0 && r && /* @__PURE__ */ t("button", { className: "pvx-notif-mark-all", onClick: r, children: "Mark all read" })
|
|
2353
2353
|
] }),
|
|
2354
2354
|
e != null && e.length ? /* @__PURE__ */ t("div", { className: "pvx-notif-list", children: e.map((d) => /* @__PURE__ */ t(
|
|
2355
|
-
|
|
2355
|
+
Gt,
|
|
2356
2356
|
{
|
|
2357
2357
|
notification: d,
|
|
2358
2358
|
getUserDisplay: o,
|
|
@@ -2362,7 +2362,7 @@ function Gt({ notifications: e, unreadCount: n = 0, onMarkRead: s, onMarkAllRead
|
|
|
2362
2362
|
)) }) : /* @__PURE__ */ t("div", { className: "pvx-notif-empty", children: "No notifications" })
|
|
2363
2363
|
] });
|
|
2364
2364
|
}
|
|
2365
|
-
function
|
|
2365
|
+
function Gt({ notification: e, getUserDisplay: n, onMarkRead: s }) {
|
|
2366
2366
|
const r = () => {
|
|
2367
2367
|
!e.isRead && s && s(e.id);
|
|
2368
2368
|
};
|
|
@@ -2402,7 +2402,7 @@ function Yt() {
|
|
|
2402
2402
|
] });
|
|
2403
2403
|
}
|
|
2404
2404
|
function wn({ steamId: e, avatarUrl: n, memberSince: s, className: r = "" }) {
|
|
2405
|
-
const { data: a, isLoading: i, error: o } =
|
|
2405
|
+
const { data: a, isLoading: i, error: o } = St(e), { data: d, isLoading: p } = Tt(e), { data: c, isLoading: u } = Rt(), g = $t(), { data: f, isLoading: m } = Mt({ limit: 10 }), b = Dt(), x = It();
|
|
2406
2406
|
return i || p ? /* @__PURE__ */ t("div", { className: "pvx-loading", children: "Loading dashboard..." }) : o ? /* @__PURE__ */ t("div", { className: "pvx-empty", children: "Failed to load dashboard data." }) : a ? /* @__PURE__ */ l("div", { className: `pvx-dash ${r}`, children: [
|
|
2407
2407
|
/* @__PURE__ */ t(
|
|
2408
2408
|
Pt,
|
|
@@ -2412,12 +2412,12 @@ function wn({ steamId: e, avatarUrl: n, memberSince: s, className: r = "" }) {
|
|
|
2412
2412
|
memberSince: s
|
|
2413
2413
|
}
|
|
2414
2414
|
),
|
|
2415
|
-
/* @__PURE__ */ t(
|
|
2415
|
+
/* @__PURE__ */ t(Ft, { stats: a, rating: d }),
|
|
2416
2416
|
e && /* @__PURE__ */ t(_t, { events: c, isLoading: u }),
|
|
2417
2417
|
/* @__PURE__ */ l("div", { className: `pvx-dash-row ${g ? "pvx-dash-row--2col" : ""}`, children: [
|
|
2418
|
-
/* @__PURE__ */ t(
|
|
2418
|
+
/* @__PURE__ */ t(Et, { records: a.currentRecords }),
|
|
2419
2419
|
g && /* @__PURE__ */ t(
|
|
2420
|
-
|
|
2420
|
+
zt,
|
|
2421
2421
|
{
|
|
2422
2422
|
notifications: f == null ? void 0 : f.notifications,
|
|
2423
2423
|
unreadCount: (f == null ? void 0 : f.unreadCount) || 0,
|
|
@@ -2432,29 +2432,29 @@ function wn({ steamId: e, avatarUrl: n, memberSince: s, className: r = "" }) {
|
|
|
2432
2432
|
export {
|
|
2433
2433
|
cn as CarsTable,
|
|
2434
2434
|
P as CompEmptyState,
|
|
2435
|
-
|
|
2435
|
+
F as CompLoadingState,
|
|
2436
2436
|
ut as CompetitionCard,
|
|
2437
2437
|
hn as CompetitionCards,
|
|
2438
2438
|
Nn as CompetitionResultsTabs,
|
|
2439
2439
|
pt as CompletedBadge,
|
|
2440
|
-
|
|
2440
|
+
Se as DEFAULT_COMPLETION_GRACE_DAYS,
|
|
2441
2441
|
wn as DriverDashboard,
|
|
2442
2442
|
Pt as DriverProfile,
|
|
2443
2443
|
dn as DriversTable,
|
|
2444
2444
|
xn as EntryList,
|
|
2445
2445
|
J as InfoPill,
|
|
2446
2446
|
pn as LapHistoryTable,
|
|
2447
|
-
|
|
2447
|
+
zt as NotificationsCard,
|
|
2448
2448
|
ae as PODIUM_MEDALS,
|
|
2449
2449
|
en as PitVoxPartnerProvider,
|
|
2450
2450
|
un as RankingsTable,
|
|
2451
|
-
|
|
2451
|
+
Et as RecordsTable,
|
|
2452
2452
|
gn as RegisterButton,
|
|
2453
2453
|
fn as RegistrationPanel,
|
|
2454
2454
|
vn as RoundResults,
|
|
2455
2455
|
le as RoundSessionResults,
|
|
2456
2456
|
vt as StandingsTable,
|
|
2457
|
-
|
|
2457
|
+
Ft as StatsCards,
|
|
2458
2458
|
ln as TracksTable,
|
|
2459
2459
|
at as TypeBadge,
|
|
2460
2460
|
_t as UpcomingEvents,
|
|
@@ -2476,7 +2476,7 @@ export {
|
|
|
2476
2476
|
q as formatTrackName,
|
|
2477
2477
|
me as formatTyreCompound,
|
|
2478
2478
|
dt as getCompetitionPodium,
|
|
2479
|
-
|
|
2479
|
+
Te as getCompetitionStatus,
|
|
2480
2480
|
ct as getCompletionDate,
|
|
2481
2481
|
lt as isCompetitionComplete,
|
|
2482
2482
|
an as useCarLeaderboard,
|
|
@@ -2484,15 +2484,15 @@ export {
|
|
|
2484
2484
|
We as useCompetitionAllRounds,
|
|
2485
2485
|
xe as useCompetitionConfig,
|
|
2486
2486
|
fe as useCompetitionEntryList,
|
|
2487
|
-
|
|
2487
|
+
ze as useCompetitionLeaderboard,
|
|
2488
2488
|
Oe as useCompetitionRound,
|
|
2489
|
-
|
|
2489
|
+
Ge as useCompetitionRoundLaps,
|
|
2490
2490
|
ge as useCompetitionStandings,
|
|
2491
2491
|
on as useCompetitions,
|
|
2492
2492
|
He as useDriverLaps,
|
|
2493
|
-
|
|
2493
|
+
Tt as useDriverRating,
|
|
2494
2494
|
bn as useDriverRatings,
|
|
2495
|
-
|
|
2495
|
+
St as useDriverStats,
|
|
2496
2496
|
nn as useLeaderboardIndex,
|
|
2497
2497
|
It as useMarkAllNotificationsRead,
|
|
2498
2498
|
Dt as useMarkNotificationRead,
|
package/package.json
CHANGED