@pitvox/partner-react 0.5.4 → 0.5.6

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 CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("react"),y=require("@tanstack/react-query"),W=N.createContext(null),Ue="https://cdn.pitvox.com",Ae="https://pitvox.com";let O=null;function Ee({partnerSlug:s,cdnUrl:r=Ue,pitvoxUrl:n=Ae,getSteamId:t,onRegister:a,onWithdraw:i,onFetchNotifications:o,onMarkNotificationRead:l,onMarkAllNotificationsRead:x,children:c}){const d=N.useMemo(()=>({partnerSlug:s,cdnUrl:r.replace(/\/$/,""),pitvoxUrl:n.replace(/\/$/,""),getSteamId:t||(()=>null),onRegister:a||null,onWithdraw:i||null,onFetchNotifications:o||null,onMarkNotificationRead:l||null,onMarkAllNotificationsRead:x||null}),[s,r,n,t,a,i,o,l,x]);let m=!1;try{y.useQueryClient(),m=!0}catch{m=!1}return m?e.jsx(W.Provider,{value:d,children:c}):(O||(O=new y.QueryClient({defaultOptions:{queries:{staleTime:6e4}}})),e.jsx(y.QueryClientProvider,{client:O,children:e.jsx(W.Provider,{value:d,children:c})}))}function k(){const s=N.useContext(W);if(!s)throw new Error("usePitVox must be used within a <PitVoxPartnerProvider>");return s}async function R(s,r){const n=await fetch(`${s}/${r}`);if(!n.ok){if(n.status===404||n.status===403)return null;throw new Error(`CDN fetch failed: ${n.status}`)}return n.json()}function M(s){if(!s&&s!==0)return"-";const r=Math.floor(s/1e3),n=Math.floor(r/60),t=r%60,a=s%1e3;return`${n}:${String(t).padStart(2,"0")}.${String(a).padStart(3,"0")}`}function S(s){return!s&&s!==0?"-":(s/1e3).toFixed(3)}function L(s){if(!s)return"";let r=s;return r.startsWith("ks_")&&(r=r.slice(3)),r.split("_").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function D(s,r,n){const t=s.split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" "),a=n==="acc"||!n&&(r==null?void 0:r.toLowerCase())==="track config";if(!r||r==="default"||a)return t;const i=r.split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ");return`${t} ${i}`}function I(s){if(!s)return"-";try{return new Date(s).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}catch{return"-"}}function G(s){if(!s)return"";const r=Date.now()-new Date(s).getTime(),n=Math.floor(r/1e3);if(n<60)return"Just now";const t=Math.floor(n/60);if(t<60)return`${t}m ago`;const a=Math.floor(t/60);if(a<24)return`${a}h ago`;const i=Math.floor(a/24);return i<30?`${i}d ago`:I(s)}function Fe(s){return s==null?"":`${s>=0?"+":"-"}${(Math.abs(s)/1e3).toFixed(3)}`}function ne(s,r){const{type:n,title:t,trackId:a,trackLayout:i,carId:o,game:l,data:x}=s,c=a?D(a,i,l):null,d=o?L(o):null,m=[c,d].filter(Boolean).join(" — ");return n==="RECORD_BEATEN"&&m?`${x!=null&&x.beatenBySteamId&&r?r(x.beatenBySteamId).displayName:"Someone"} beat your record on ${m}`:n==="RECORD_SET"&&m?`You set a new record on ${m}`:t||"New notification"}function z(s){return s?{E:"Eco",RD:"Road",SC:"SuperCar",RV:"Race Vintage",SM:"Semislick",ST:"Street",HR:"Hard Race",MR:"Medium Race",SR:"Soft Race",S:"Soft"}[s]||s:"Unknown"}function _e(s={}){var l,x,c,d,m,g;const{cdnUrl:r,partnerSlug:n}=k(),{game:t,gameVersion:a}=s,i=y.useQuery({queryKey:["pitvox","leaderboards",n,"index"],queryFn:()=>R(r,`leaderboards/partners/${n}/index.json`),staleTime:3e4,refetchInterval:3e4}),o=N.useMemo(()=>{var f;if(!((f=i.data)!=null&&f.tracks))return[];let u=i.data.tracks;return t&&(u=u.filter(p=>p.game===t)),a&&(u=u.filter(p=>p.gameVersion===a)),u.map(p=>({id:p.trackId,layout:p.layout,game:p.game,gameVersion:p.gameVersion,displayName:D(p.trackId,p.layout,p.game),driverCount:p.driverCount||0,carCount:p.carCount||0,record:p.recordHolder?{visibleId:p.recordHolder.steamId||p.recordHolder.userId,carId:p.recordHolder.carId,carDisplayName:L(p.recordHolder.carId),lapTimeMs:p.recordHolder.lapTimeMs,timestamp:p.recordHolder.recordedAt}:null,recordByTag:p.recordByTag||null}))},[(l=i.data)==null?void 0:l.tracks,t,a]);return{...i,data:o,partner:((x=i.data)==null?void 0:x.partner)||null,generatedAt:(c=i.data)==null?void 0:c.generatedAt,totalLaps:((d=i.data)==null?void 0:d.totalLaps)||0,totalUsers:((m=i.data)==null?void 0:m.totalUsers)||0,versions:((g=i.data)==null?void 0:g.versions)||{}}}function ae(s,r,n={}){const{cdnUrl:t,partnerSlug:a}=k(),{carId:i,game:o,gameVersion:l}=n,x=r||"default",c=l?`leaderboards/partners/${a}/v/${l}/tracks/${s}/${x}.json`:`leaderboards/partners/${a}/tracks/${s}/${x}.json`,{data:d,isLoading:m,error:g}=y.useQuery({queryKey:["pitvox","leaderboards",a,"track",s,x,l],queryFn:()=>R(t,c),enabled:!!s,staleTime:3e4,refetchInterval:3e4});return{data:N.useMemo(()=>{if(!(d!=null&&d.entries))return[];let f=d.entries;if(o&&(f=f.filter(p=>p.game===o)),!i){const p=new Map,j=new Map;for(const v of f){const h=v.steamId||v.userId;j.has(v.carId)||j.set(v.carId,new Set),j.get(v.carId).add(h),(!p.has(v.carId)||v.lapTimeMs<p.get(v.carId).lapTimeMs)&&p.set(v.carId,v)}return Array.from(p.values()).map(v=>{var h;return{...v,driverCount:((h=j.get(v.carId))==null?void 0:h.size)||0}}).sort((v,h)=>v.lapTimeMs-h.lapTimeMs)}return f.filter(p=>p.carId===i).sort((p,j)=>p.lapTimeMs-j.lapTimeMs)},[d==null?void 0:d.entries,i,o]),isLoading:m,error:g}}function ie(s,r,n,t,a={}){var g,u;const{cdnUrl:i,partnerSlug:o}=k(),{showInvalid:l=!1,game:x,gameVersion:c}=a,d=y.useQuery({queryKey:["pitvox","laps",o,s],queryFn:()=>R(i,`laps/partners/${o}/${s}.json`),enabled:!!s,staleTime:3e4,refetchInterval:3e4}),m=N.useMemo(()=>{var f;return(f=d.data)!=null&&f.laps?d.data.laps.filter(p=>{if(p.trackId!==r)return!1;if(n){if(p.trackLayout!==n)return!1}else if(p.trackLayout&&p.trackLayout!=="default")return!1;return!(p.carId!==t||x&&p.game!==x||c&&p.gameVersion!==c||!l&&!p.isValid)}).sort((p,j)=>p.lapTimeMs-j.lapTimeMs):[]},[(g=d.data)==null?void 0:g.laps,r,n,t,x,c,l]);return{...d,data:m,driverName:((u=d.data)==null?void 0:u.driverName)||"Driver"}}function Y(){const{cdnUrl:s}=k(),{data:r}=y.useQuery({queryKey:["pitvox","users","index"],queryFn:()=>R(s,"users/index.json"),staleTime:5*6e4,gcTime:30*6e4}),n=(r==null?void 0:r.users)||{};return(t,a)=>{const i=n[t];return{displayName:(i==null?void 0:i.displayName)||a||t||"Unknown",avatarUrl:(i==null?void 0:i.avatarUrl)||null,affiliations:(i==null?void 0:i.affiliations)||[]}}}function qe(){const{cdnUrl:s}=k(),{data:r}=y.useQuery({queryKey:["pitvox","cars","index"],queryFn:()=>R(s,"cars/index.json"),staleTime:5*6e4,gcTime:30*6e4});return{tags:(r==null?void 0:r.tags)||[],cars:(r==null?void 0:r.cars)||{}}}function Ve(s,r){return ae(s,null,{carId:r})}function Ke(){const{cdnUrl:s,partnerSlug:r}=k();return y.useQuery({queryKey:["pitvox","competitions",r],queryFn:async()=>{const n=await R(s,"competitions/index.json");return n!=null&&n.competitions?n.competitions.filter(t=>t.partnerSlug===r):[]},staleTime:6e4})}function oe(s){const{cdnUrl:r,partnerSlug:n}=k();return y.useQuery({queryKey:["pitvox","competition",n,s,"config"],queryFn:()=>R(r,`competitions/${n}/${s}/config.json`),enabled:!!s,staleTime:6e4})}function ce(s){const{cdnUrl:r,partnerSlug:n}=k();return y.useQuery({queryKey:["pitvox","competition",n,s,"standings"],queryFn:()=>R(r,`competitions/${n}/${s}/standings.json`),enabled:!!s,staleTime:6e4})}function le(s,r){const{cdnUrl:n,partnerSlug:t}=k();return y.useQuery({queryKey:["pitvox","competition",t,s,"round",r],queryFn:()=>R(n,`competitions/${t}/${s}/rounds/${r}.json`),enabled:!!s&&r!=null,staleTime:6e4})}function He(s,r=[]){const{cdnUrl:n,partnerSlug:t}=k();return y.useQuery({queryKey:["pitvox","competition",t,s,"allRounds",r],queryFn:async()=>(await Promise.all(r.map(i=>R(n,`competitions/${t}/${s}/rounds/${i}.json`).catch(()=>null)))).filter(Boolean),enabled:!!s&&r.length>0,staleTime:6e4})}function Z(s){const{cdnUrl:r,partnerSlug:n}=k();return y.useQuery({queryKey:["pitvox","competition",n,s,"entrylist"],queryFn:()=>R(r,`competitions/${n}/${s}/entrylist.json`),enabled:!!s,staleTime:6e4})}function _(s){const{cdnUrl:r,partnerSlug:n,getSteamId:t}=k(),a=t();return y.useQuery({queryKey:["pitvox","registration",n,s,a],queryFn:async()=>{var x;const i=await fetch(`${r}/competitions/${n}/${s}/entrylist.json`);if(!i.ok)return{isRegistered:!1,entryList:null};const o=await i.json();return{isRegistered:!!a&&((x=o.drivers)==null?void 0:x.some(c=>c.steamId===a)),entryList:o}},enabled:!!s,staleTime:6e4})}function J(s){const{onRegister:r,partnerSlug:n,getSteamId:t}=k(),a=y.useQueryClient(),i=Y();return y.useMutation({mutationFn:o=>{if(!r)throw new Error("No onRegister callback provided to PitVoxPartnerProvider. Provide onRegister for in-app registration, or use useRegistrationUrl() to link to pitvox.com.");return r(s,o)},onSuccess:()=>{const o=t();if(a.setQueriesData({queryKey:["pitvox","registration",n,s]},l=>l?{...l,isRegistered:!0}:{isRegistered:!0,entryList:null}),o){const l=i(o),x={steamId:o,displayName:l.displayName,avatarUrl:l.avatarUrl};a.setQueriesData({queryKey:["pitvox","competition",n,s,"entrylist"]},c=>{var m;return c?((m=c.drivers)==null?void 0:m.some(g=>g.steamId===o))?c:{...c,drivers:[...c.drivers||[],x]}:{drivers:[x]}})}}})}function X(s){const{onWithdraw:r,partnerSlug:n,getSteamId:t}=k(),a=y.useQueryClient();return y.useMutation({mutationFn:i=>{if(!r)throw new Error("No onWithdraw callback provided to PitVoxPartnerProvider. Provide onWithdraw for in-app withdrawal, or use useRegistrationUrl() to link to pitvox.com.");const o=i||t();if(!o)throw new Error("No Steam ID available");return r(s,o)},onSuccess:()=>{const i=t();a.setQueriesData({queryKey:["pitvox","registration",n,s]},o=>o?{...o,isRegistered:!1}:{isRegistered:!1,entryList:null}),i&&a.setQueriesData({queryKey:["pitvox","competition",n,s,"entrylist"]},o=>o!=null&&o.drivers?{...o,drivers:o.drivers.filter(l=>l.steamId!==i)}:o)}})}function q(){const{onRegister:s,onWithdraw:r}=k(),n=!!(s&&r);return{isPowerMode:n,isBasicMode:!n}}function V(s){const{pitvoxUrl:r,partnerSlug:n}=k();return`${r}/p/${n}/competitions/${s}/register`}const Qe={formula:"Formula",gt3:"GT3",gt2:"GT2",gt4:"GT4",cup:"Cup",prototype:"Prototype",rally:"Rally",hypercar:"Hypercar",supercar:"Supercar",sports_car:"Sports Car",hot_hatch:"Hot Hatch",lightweight:"Lightweight","1960s":"1960s","1970s":"1970s","1980s":"1980s","1990s":"1990s","2000s":"2000s","2010s":"2010s","2020s":"2020s"},de=[{id:"class",tags:["formula","gt3","gt2","gt4","cup","prototype","rally"]},{id:"tier",tags:["hypercar","supercar","sports_car","hot_hatch","lightweight"]},{id:"era",tags:["1960s","1970s","1980s","1990s","2000s","2010s","2020s"]}];function Oe(s){for(const r of de)if(r.tags.includes(s))return r.id;return"other"}function pe(s,r){if(r.size===0)return!0;const n={};for(const t of r){const a=Oe(t);n[a]||(n[a]=[]),n[a].push(t)}for(const t of Object.values(n))if(!t.some(a=>s.includes(a)))return!1;return!0}function xe(s,r){const[n,t]=N.useState(new Set),a=s!==void 0,i=a?s:n,o=N.useCallback(x=>{const c=new Set(i);c.has(x)?c.delete(x):c.add(x),a&&r?r(c):t(c)},[i,a,r]),l=N.useCallback(()=>{a&&r?r(new Set):t(new Set)},[a,r]);return{activeTags:i,toggle:o,clear:l}}function K(s){const[r,n]=N.useState(s),t=N.useCallback(a=>{n(i=>i.key===a?{key:a,dir:i.dir==="asc"?"desc":"asc"}:{key:a,dir:a.includes("timestamp")||a.includes("Date")?"desc":"asc"})},[]);return[r,t]}function H(s,r,n){return[...s].sort((t,a)=>{const i=n(t,r.key),o=n(a,r.key);if(i==null&&o==null)return 0;if(i==null)return 1;if(o==null)return-1;const l=typeof i=="string"?i.localeCompare(o):i-o;return r.dir==="desc"?-l:l})}function ue(s,r=!1){const n=r?s==null?void 0:s.filter(t=>t.isValid):s;return n!=null&&n.length?{s1:Math.min(...n.map(t=>t.sector1Ms).filter(Boolean)),s2:Math.min(...n.map(t=>t.sector2Ms).filter(Boolean)),s3:Math.min(...n.map(t=>t.sector3Ms).filter(Boolean))}:null}function We({active:s,dir:r}){return s?r==="asc"?e.jsx("svg",{className:"pvx-sort-icon",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 15.75l7.5-7.5 7.5 7.5"})}):e.jsx("svg",{className:"pvx-sort-icon",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})}):e.jsx("svg",{className:"pvx-sort-icon pvx-sort-icon--inactive",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 9l4-4 4 4M16 15l-4 4-4-4"})})}function w({label:s,sortKey:r,config:n,onSort:t,className:a=""}){return e.jsx("th",{className:`pvx-th pvx-th--sortable ${a}`,onClick:()=>t(r),children:e.jsxs("span",{className:"pvx-th-inner",children:[s,e.jsx(We,{active:n.key===r,dir:n.dir})]})})}function Q({userId:s,getUserDisplay:r}){const{displayName:n,avatarUrl:t}=r(s);return e.jsxs("span",{className:"pvx-driver",children:[t?e.jsx("img",{src:t,alt:"",className:"pvx-driver-avatar"}):e.jsx("span",{className:"pvx-driver-avatar pvx-driver-avatar--placeholder"}),e.jsx("span",{className:"pvx-driver-name",children:n})]})}function ee({rank:s,podium:r=!1}){const n=r?s===1?"pvx-rank pvx-rank--gold":s===2?"pvx-rank pvx-rank--silver":s===3?"pvx-rank pvx-rank--bronze":"pvx-rank":"pvx-rank";return e.jsx("span",{className:n,children:s})}function me({availableTags:s,activeTags:r,onToggle:n,onClear:t}){if(!s||s.length<2)return null;const a=de.map(i=>({id:i.id,tags:i.tags.filter(o=>s.includes(o))})).filter(i=>i.tags.length>0);return e.jsxs("div",{className:"pvx-tag-bar",children:[e.jsx("button",{onClick:t,className:`pvx-tag ${r.size===0?"pvx-tag--active":""}`,children:"All"}),a.map((i,o)=>e.jsxs("span",{className:"contents",children:[o>0&&e.jsx("span",{className:"pvx-tag-separator"}),i.tags.map(l=>e.jsx("button",{onClick:()=>n(l),className:`pvx-tag ${r.has(l)?"pvx-tag--active":""}`,children:Qe[l]||l},l))]},i.id))]})}function se({segments:s}){return e.jsx("nav",{className:"pvx-breadcrumb","aria-label":"Breadcrumb",children:e.jsx("ol",{className:"pvx-breadcrumb-list",children:s.map((r,n)=>{const t=n===s.length-1;return e.jsxs("li",{className:"pvx-breadcrumb-item",children:[n>0&&e.jsx("svg",{className:"pvx-breadcrumb-chevron",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})}),!t&&r.onClick?e.jsx("button",{onClick:r.onClick,className:"pvx-breadcrumb-link",children:r.label}):e.jsx("span",{className:"pvx-breadcrumb-current",children:r.label})]},r.key)})})})}function U({message:s}){return e.jsxs("div",{className:"pvx-empty",children:[e.jsx("svg",{className:"pvx-empty-icon",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.5 18.75h-9m9 0a3 3 0 013 3h-15a3 3 0 013-3m9 0v-4.5A3.375 3.375 0 0013.125 10.875h-2.25A3.375 3.375 0 007.5 14.25v4.5"})}),e.jsx("p",{children:s})]})}function A(){return e.jsx("div",{className:"pvx-loading",children:"Loading..."})}function Ge(){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 ze(){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 Ye({tracks:s,isLoading:r,carMetadata:n,getUserDisplay:t,onTrackSelect:a,tags:i,onTagChange:o}){const[l,x]=K({key:"record.timestamp",dir:"desc"}),{activeTags:c,toggle:d,clear:m}=xe(i,o),g=N.useMemo(()=>{var j;if(!((j=n==null?void 0:n.tags)!=null&&j.length))return[];const p=new Set;for(const v of s||[])v.recordByTag&&Object.keys(v.recordByTag).forEach(h=>p.add(h));return n.tags.filter(v=>p.has(v))},[s,n]),u=N.useMemo(()=>s?c.size===0?s:s.map(p=>{var h,b;if(!p.recordByTag)return null;let j=null;const v=new Set;for(const C of Object.values(p.recordByTag)){if(v.has(C.carId))continue;v.add(C.carId);const T=((b=(h=n==null?void 0:n.cars)==null?void 0:h[C.carId])==null?void 0:b.tags)||["sports_car"];pe(T,c)&&(!j||C.lapTimeMs<j.lapTimeMs)&&(j=C)}return j?{...p,record:{visibleId:j.steamId||j.identifier,carId:j.carId,carDisplayName:L(j.carId),lapTimeMs:j.lapTimeMs,timestamp:j.recordedAt}}:null}).filter(Boolean):[],[s,c,n]),f=N.useMemo(()=>H(u,l,(p,j)=>{var v,h;switch(j){case"displayName":return p.displayName;case"record.lapTimeMs":return(v=p.record)==null?void 0:v.lapTimeMs;case"driverCount":return p.driverCount||0;case"carCount":return p.carCount||0;case"record.timestamp":default:return(h=p.record)!=null&&h.timestamp?new Date(p.record.timestamp).getTime():0}}),[u,l]);return r?e.jsx(A,{}):s!=null&&s.length?e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx("h2",{className:"pvx-card-title",children:"Track Records"})}),e.jsx(me,{availableTags:g,activeTags:c,onToggle:d,onClear:m}),e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx(w,{label:"Track",sortKey:"displayName",config:l,onSort:x}),e.jsx("th",{className:"pvx-th",children:"Record Holder"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Car"}),e.jsx(w,{label:"Lap Time",sortKey:"record.lapTimeMs",config:l,onSort:x}),e.jsx(w,{label:"Drivers",sortKey:"driverCount",config:l,onSort:x,className:"pvx-hidden-below-md"}),e.jsx(w,{label:"Cars",sortKey:"carCount",config:l,onSort:x,className:"pvx-hidden-below-lg"}),e.jsx(w,{label:"Date",sortKey:"record.timestamp",config:l,onSort:x,className:"pvx-hidden-below-xl"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:f.map(p=>{var j,v,h;return e.jsxs("tr",{className:"pvx-row pvx-row--clickable",onClick:()=>a(p.id,p.layout),children:[e.jsx("td",{className:"pvx-td pvx-td--primary",children:p.displayName}),e.jsx("td",{className:"pvx-td",children:(j=p.record)!=null&&j.visibleId?e.jsx(Q,{userId:p.record.visibleId,getUserDisplay:t}):"-"}),e.jsx("td",{className:"pvx-td pvx-hidden-below-lg",children:((v=p.record)==null?void 0:v.carDisplayName)||"-"}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:p.record?M(p.record.lapTimeMs):"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-md",children:p.driverCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",children:p.carCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-xl",children:(h=p.record)!=null&&h.timestamp?I(p.record.timestamp):"-"})]},`${p.id}|${p.layout||""}`)})})]})})]}):e.jsx(U,{message:"No lap times recorded yet."})}function Ze({entries:s,isLoading:r,track:n,carMetadata:t,getUserDisplay:a,onCarSelect:i,onNavigate:o,tags:l,onTagChange:x}){const[c,d]=K({key:"lapTimeMs",dir:"asc"}),{activeTags:m,toggle:g,clear:u}=xe(l,x),f=N.useMemo(()=>{var b,C,T;if(!s||!((b=t==null?void 0:t.tags)!=null&&b.length))return[];const h=new Set;for(const P of s)(((T=(C=t.cars)==null?void 0:C[P.carId])==null?void 0:T.tags)||["sports_car"]).forEach(Pe=>h.add(Pe));return t.tags.filter(P=>h.has(P))},[s,t]),p=N.useMemo(()=>s?m.size===0?s:s.filter(h=>{var C,T;const b=((T=(C=t==null?void 0:t.cars)==null?void 0:C[h.carId])==null?void 0:T.tags)||["sports_car"];return pe(b,m)}):[],[s,m,t]),j=N.useMemo(()=>H(p,c,(h,b)=>{switch(b){case"carId":return L(h.carId);case"driverCount":return h.driverCount||0;case"lapTimeMs":default:return h.lapTimeMs}}),[p,c]),v=[{key:"tracks",label:"Tracks",onClick:()=>o("tracks")},{key:"track",label:n.displayName}];return r?e.jsx(A,{}):e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx(se,{segments:v})}),e.jsx(me,{availableTags:f,activeTags:m,onToggle:g,onClear:u}),s!=null&&s.length?e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"#"}),e.jsx(w,{label:"Car",sortKey:"carId",config:c,onSort:d}),e.jsx("th",{className:"pvx-th",children:"Record Holder"}),e.jsx(w,{label:"Lap Time",sortKey:"lapTimeMs",config:c,onSort:d}),e.jsx(w,{label:"Drivers",sortKey:"driverCount",config:c,onSort:d,className:"pvx-hidden-below-md"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Date"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:j.map((h,b)=>e.jsxs("tr",{className:"pvx-row pvx-row--clickable",onClick:()=>i(h.carId),children:[e.jsx("td",{className:"pvx-td",children:e.jsx(ee,{rank:b+1,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:L(h.carId)}),e.jsx("td",{className:"pvx-td",children:e.jsx(Q,{userId:h.steamId||h.userId,getUserDisplay:a})}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:M(h.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--muted pvx-hidden-below-lg",children:h.recordedAt?I(h.recordedAt):"-"})]},h.carId))})]})}):e.jsx(U,{message:"No lap times for this track yet."})]})}function Je({entries:s,isLoading:r,track:n,carId:t,getUserDisplay:a,onDriverSelect:i,onNavigate:o,highlightId:l}){const[x,c]=K({key:"lapTimeMs",dir:"asc"}),d=N.useMemo(()=>ue(s),[s]),m=N.useMemo(()=>H(s||[],x,(u,f)=>{switch(f){case"userId":return a(u.steamId||u.userId).displayName;case"lapCount":return u.lapCount||0;case"lapTimeMs":default:return u.lapTimeMs}}),[s,x,a]),g=[{key:"tracks",label:"Tracks",onClick:()=>o("tracks")},{key:"track",label:n.displayName,onClick:()=>o("track")},{key:"car",label:L(t)}];return r?e.jsx(A,{}):e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx(se,{segments: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(w,{label:"Driver",sortKey:"userId",config:x,onSort:c}),e.jsx(w,{label:"Lap Time",sortKey:"lapTimeMs",config:x,onSort:c}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S1"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S2"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S3"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Tyre"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-xl",children:"Fuel"}),e.jsx(w,{label:"Laps",sortKey:"lapCount",config:x,onSort:c,className:"pvx-hidden-below-lg"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-xl",children:"Date"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:m.map((u,f)=>{const p=f+1,j=u.steamId||u.userId,v=d&&u.sector1Ms===d.s1,h=d&&u.sector2Ms===d.s2,b=d&&u.sector3Ms===d.s3,C=l&&j===l;return e.jsxs("tr",{className:`pvx-row pvx-row--clickable ${C?"pvx-row--highlight":p<=3?"pvx-row--podium":""}`,onClick:()=>i(j),children:[e.jsx("td",{className:"pvx-td",children:e.jsx(ee,{rank:p,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:e.jsx(Q,{userId:j,getUserDisplay:a})}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:M(u.lapTimeMs)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${v?"pvx-td--best-sector":""}`,children:S(u.sector1Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${h?"pvx-td--best-sector":""}`,children:S(u.sector2Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${b?"pvx-td--best-sector":""}`,children:S(u.sector3Ms)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",title:z(u.tyreCompound),children:u.tyreCompound||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-xl",children:u.startingFuelL?`${u.startingFuelL}L`:"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",children:u.lapCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-xl",children:u.recordedAt?I(u.recordedAt):"-"})]},j)})})]})}):e.jsx(U,{message:"No lap times for this car yet."})]})}function Xe({userId:s,track:r,carId:n,game:t,gameVersion:a,showInvalid:i,getUserDisplay:o,onToggleInvalid:l,onNavigate:x}){const{data:c,driverName:d,isLoading:m}=ie(s,r.id,r.layout,n,{showInvalid:i,game:t,gameVersion:a}),{displayName:g,avatarUrl:u}=o(s,d),f=N.useMemo(()=>ue(c,!0),[c]),p=N.useMemo(()=>{const v=(c==null?void 0:c.filter(h=>h.isValid))||[];return v.length?Math.min(...v.map(h=>h.lapTimeMs)):null},[c]),j=[{key:"tracks",label:"Tracks",onClick:()=>x("tracks")},{key:"track",label:r.displayName,onClick:()=>x("track")},{key:"car",label:L(n),onClick:()=>x("car")},{key:"driver",label:g}];return m?e.jsx(A,{}):e.jsxs("div",{className:"pvx-card",children:[e.jsxs("div",{className:"pvx-card-header pvx-card-header--split",children:[e.jsxs("div",{className:"pvx-card-header-left",children:[e.jsx(se,{segments:j}),u?e.jsx("img",{src:u,alt:"",className:"pvx-driver-avatar pvx-driver-avatar--lg"}):e.jsx("span",{className:"pvx-driver-avatar pvx-driver-avatar--lg pvx-driver-avatar--placeholder"})]}),e.jsxs("label",{className:"pvx-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:l,className:"pvx-checkbox"}),e.jsx("span",{children:"Show invalid laps"})]})]}),c!=null&&c.length?e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"#"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-md",children:"Lap"}),e.jsx("th",{className:"pvx-th",children:"Lap Time"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S1"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S2"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S3"}),e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"Valid"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Tyre"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Fuel"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-xl",children:"Date"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:c.map((v,h)=>{const b=v.isValid&&v.lapTimeMs===p,C=f&&v.isValid&&v.sector1Ms===f.s1,T=f&&v.isValid&&v.sector2Ms===f.s2,P=f&&v.isValid&&v.sector3Ms===f.s3;let E="pvx-row";return v.isValid||(E+=" pvx-row--invalid"),b&&(E+=" pvx-row--personal-best"),e.jsxs("tr",{className:E,children:[e.jsx("td",{className:"pvx-td",children:e.jsx("span",{className:`pvx-rank ${b?"pvx-rank--gold":""}`,children:h+1})}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-md",children:v.lapNumber||"-"}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:M(v.lapTimeMs)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${C?"pvx-td--best-sector":""}`,children:S(v.sector1Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${T?"pvx-td--best-sector":""}`,children:S(v.sector2Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${P?"pvx-td--best-sector":""}`,children:S(v.sector3Ms)}),e.jsx("td",{className:"pvx-td",title:v.isValid?void 0:v.invalidReason||"Invalid",children:v.isValid?e.jsx(Ge,{}):e.jsx(ze,{})}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",title:z(v.tyreCompound),children:v.tyreCompound||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",children:v.startingFuelL?`${v.startingFuelL}L`:"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-xl",children:I(v.timestamp)})]},v.id)})})]})}):e.jsx(U,{message:i?"No laps recorded for this combination.":'No valid laps. Try enabling "Show invalid laps".'})]})}function es({drivers:s,isLoading:r,getUserDisplay:n,game:t,gameVersion:a,onComboSelect:i}){const[o,l]=K({key:"rank",dir:"asc"}),[x,c]=N.useState(null),d=N.useMemo(()=>s?H(s,o,(g,u)=>{switch(u){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(r)return e.jsx(A,{});if(!(s!=null&&s.length))return e.jsx("div",{className:"pvx-card",children:e.jsx(U,{message:"Not enough data for rankings yet."})});const m=5;return e.jsxs("div",{className:"pvx-card",children:[e.jsxs("div",{className:"pvx-card-header pvx-rankings-header",children:[e.jsx("h2",{className:"pvx-card-title",children:"Driver Rankings"}),e.jsxs("div",{className:"pvx-rankings-info-trigger",children:[e.jsx("svg",{className:"pvx-rankings-info-icon",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"})}),e.jsxs("div",{className:"pvx-rankings-info-tooltip",children:[e.jsx("p",{className:"pvx-rankings-info-title",children:"How ratings work"}),e.jsxs("ul",{className:"pvx-rankings-info-list",children:[e.jsx("li",{children:"For each car/track combo with 3+ drivers, you're ranked by lap time and given a percentile (100 = fastest, 0 = slowest)"}),e.jsx("li",{children:"Your rating is a weighted average across all your combos — bigger fields count more"}),e.jsx("li",{children:"A confidence adjustment rewards car diversity: the more different cars you drive competitively, the closer your rating reflects your true score"}),e.jsx("li",{children:"Minimum 2 qualifying combos required"})]})]})]})]}),e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx(w,{label:"#",sortKey:"rank",config:o,onSort:l,className:"pvx-th--narrow"}),e.jsx("th",{className:"pvx-th",children:"Driver"}),e.jsx(w,{label:"Rating",sortKey:"rating",config:o,onSort:l}),e.jsx(w,{label:"Cars",sortKey:"distinctCars",config:o,onSort:l,className:"pvx-hidden-below-sm"}),e.jsx(w,{label:"Combos",sortKey:"comboCount",config:o,onSort:l,className:"pvx-hidden-below-sm"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:d.map(g=>{const u=x===g.identifier;return e.jsx(ss,{driver:g,getUserDisplay:n,isExpanded:u,onToggle:()=>c(u?null:g.identifier),colCount:m,game:t,gameVersion:a,onComboSelect:i},g.identifier)})})]})})]})}function ss({driver:s,getUserDisplay:r,isExpanded:n,onToggle:t,colCount:a,game:i,gameVersion:o,onComboSelect:l}){const x=s.identifier;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:`pvx-row pvx-row--clickable ${s.rank<=3?"pvx-row--podium":""}`,onClick:t,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(ee,{rank:s.rank,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:e.jsx(Q,{userId:x,getUserDisplay:r})}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:s.rating.toFixed(1)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-sm",children:s.distinctCars||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-sm",children:e.jsxs("span",{className:"pvx-rankings-combo-count",children:[s.comboCount,e.jsx("svg",{className:`pvx-rankings-chevron ${n?"pvx-rankings-chevron--open":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]})})]}),n&&s.combos&&e.jsx("tr",{children:e.jsx("td",{colSpan:a,className:"pvx-rankings-combos-cell",children:e.jsx("div",{className:"pvx-rankings-combos",children:s.combos.map((c,d)=>{const m=c.layout?`${c.trackId}|${c.layout}`:c.trackId,g=l?()=>l({track:m,car:c.carId,highlight:x,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:D(c.trackId,c.layout,i)}),e.jsx("p",{className:"pvx-rankings-combo-car",children:L(c.carId)})]}),e.jsxs("div",{className:"pvx-rankings-combo-stats",children:[e.jsx("p",{className:"pvx-rankings-combo-time",children:M(c.lapTimeMs)}),e.jsxs("p",{className:`pvx-rankings-combo-pct ${c.percentile>=75?"pvx-rankings-combo-pct--high":c.percentile>=50?"pvx-rankings-combo-pct--mid":c.percentile>=25?"pvx-rankings-combo-pct--low":"pvx-rankings-combo-pct--bottom"}`,children:[c.percentile.toFixed(0),"%",e.jsxs("span",{className:"pvx-rankings-combo-rank",children:["(",c.rank,"/",c.totalDrivers,")"]})]})]})]},d)})})})})]})}const rs={GBR:"🇬🇧",DEU:"🇩🇪",NLD:"🇳🇱",SWE:"🇸🇪",ESP:"🇪🇸",ZAF:"🇿🇦",FRA:"🇫🇷",ITA:"🇮🇹",USA:"🇺🇸",AUS:"🇦🇺",BRA:"🇧🇷",JPN:"🇯🇵",CAN:"🇨🇦",POL:"🇵🇱",AUT:"🇦🇹",BEL:"🇧🇪",PRT:"🇵🇹",NOR:"🇳🇴",DNK:"🇩🇰",FIN:"🇫🇮",IRL:"🇮🇪",CHE:"🇨🇭",NZL:"🇳🇿",MEX:"🇲🇽",ARG:"🇦🇷",CZE:"🇨🇿",HUN:"🇭🇺",RUS:"🇷🇺",TUR:"🇹🇷",KOR:"🇰🇷"},ve=["🥇","🥈","🥉"],ts={championship:"Championship",series:"Series",event:"Event"},re=["PRACTICE","QUALIFYING","RACE"];function he({position:s}){const r=s===1?"pvx-rank pvx-rank--gold":s===2?"pvx-rank pvx-rank--silver":s===3?"pvx-rank pvx-rank--bronze":"pvx-rank";return e.jsx("span",{className:r,children:s})}function ge({nation:s}){const r=s&&rs[s];return r?e.jsx("span",{className:"pvx-nation-flag",title:s,children:r}):null}function ns({sessions:s,activeSession:r,onSelect:n}){if(!s||s.length<=1)return null;const t=[...s].sort((a,i)=>re.indexOf(a.type)-re.indexOf(i.type));return e.jsx("div",{className:"pvx-session-tabs",children:t.map(a=>e.jsx("button",{onClick:()=>n(a.type),className:`pvx-session-tab ${r===a.type?"pvx-session-tab--active":""}`,children:a.type},a.type))})}function je({type:s}){return e.jsx("span",{className:`pvx-comp-badge pvx-comp-badge--${s}`,children:ts[s]||s})}function F({children:s,variant:r="default"}){return e.jsx("span",{className:`pvx-info-pill ${r!=="default"?`pvx-info-pill--${r}`:""}`,children:s})}function as(s){if(!s)return"TBD";const r=new Date(s);if(isNaN(r))return"TBD";const n=r.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"}),t=r.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} • ${t}`}function is(s){return s.reduce((r,n)=>{var t;return(t=n.splits)!=null&&t.length?r?r.map((a,i)=>{const o=n.splits[i];return o&&o<a?o:a}):[...n.splits]:r},null)}function B({message:s="Loading..."}){return e.jsx("div",{className:"pvx-loading",children:s})}function $({message:s="No data available."}){return e.jsx("div",{className:"pvx-empty",children:e.jsx("p",{children:s})})}function os({competitions:s,isLoading:r,onSelect:n,onRegister:t,className:a}){return r?e.jsx(B,{message:"Loading competitions..."}):s!=null&&s.length?e.jsx("div",{className:`pvx-comp-grid ${a||""}`,children:s.map(i=>e.jsx(cs,{comp:i,onSelect:n,onRegister:t||n},i.id))}):e.jsx($,{message:"No competitions available."})}function cs({comp:s,onSelect:r,onRegister:n}){var p,j,v;const{cdnUrl:t}=k(),a=s.posterCdnPath?`${t}/${s.posterCdnPath}`:null,i=s.registration,o=(i==null?void 0:i.currentCount)||0,l=i==null?void 0:i.maxParticipants,x=l&&o>=l,c=(i==null?void 0:i.deadline)&&new Date(i.deadline)<new Date,d=(i==null?void 0:i.isOpen)&&!c&&!x,m=new Date,g=(p=s.rounds)==null?void 0:p.find(h=>h.startTime&&new Date(h.startTime)>=m),u=((j=s.rounds)==null?void 0:j.length)||0,f=((v=s.rounds)==null?void 0:v.filter(h=>h.isFinalized).length)||0;return e.jsxs("div",{className:"pvx-comp-card",onClick:()=>r(s.id),role:"button",tabIndex:0,onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),r(s.id))},children:[e.jsx("div",{className:"pvx-comp-card-poster",children:a?e.jsx("img",{src:a,alt:s.name,className:"pvx-comp-card-poster-img"}):e.jsx("div",{className:"pvx-comp-card-poster-placeholder",children:e.jsx(ds,{})})}),e.jsxs("div",{className:"pvx-comp-card-body",children:[e.jsx("h3",{className:"pvx-comp-card-title",children:s.name}),s.description&&e.jsx("p",{className:"pvx-comp-card-desc",children:s.description}),e.jsxs("div",{className:"pvx-comp-card-pills",children:[e.jsx(je,{type:s.type}),s.game&&e.jsx(F,{children:s.game.toUpperCase()}),s.formatDescription&&s.formatDescription.split(", ").map((h,b)=>e.jsx(F,{variant:"format",children:h},b))]}),s.carsDescription&&e.jsx("div",{className:"pvx-comp-card-pills",children:s.carsDescription.split(", ").map((h,b)=>e.jsx(F,{children:h},b))}),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:"})," ","R",g.roundNumber," ",g.track||"TBD"," — ",as(g.startTime)]}):u>0?e.jsxs("span",{className:"pvx-comp-card-schedule-next",children:[f,"/",u," rounds completed"]}):null,u>0&&e.jsxs("span",{className:"pvx-comp-card-round-count",children:[u," round",u!==1?"s":""]})]}),i&&e.jsx(ls,{competitionId:s.id,regOpen:d,isFull:x,deadlinePassed:c,regCount:o,regMax:l,onRegister:n})]})]})}function ls({competitionId:s,regOpen:r,isFull:n,deadlinePassed:t,regCount:a,regMax:i,onRegister:o}){const{isPowerMode:l}=q(),x=V(s),{data:c}=_(s),d=(c==null?void 0:c.isRegistered)||!1,m=i?a/i*100:0,g=m>=100?"full":m>=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:d?e.jsx("button",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--registered",onClick:u=>{u.stopPropagation(),o(s)},children:"✓ Registered"}):r?l?e.jsx("button",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--open",onClick:u=>{u.stopPropagation(),o(s)},children:"Register"}):e.jsx("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--open",onClick:u=>u.stopPropagation(),children:"Register"}):e.jsx("span",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--closed",children:n?"Full":"Closed"})})]})}function ds(){return e.jsxs("svg",{className:"pvx-comp-trophy-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6"}),e.jsx("path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18"}),e.jsx("path",{d:"M4 22h16"}),e.jsx("path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22"}),e.jsx("path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22"}),e.jsx("path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z"})]})}function ps({competitionId:s,className:r}){var l,x;const{data:n,isLoading:t}=ce(s),{data:a,isLoading:i}=oe(s);if(t||i)return e.jsx(B,{message:"Loading standings..."});if(!((l=n==null?void 0:n.standings)!=null&&l.length))return e.jsx($,{message:"No standings data yet. Results will appear once rounds are finalised."});const o=((x=a==null?void 0:a.rounds)==null?void 0:x.filter(c=>c.isFinalized))||[];return e.jsxs("div",{className:`pvx-card ${r||""}`,children:[e.jsx("div",{className:"pvx-card-header--split",children:e.jsxs("div",{className:"pvx-card-header-left",children:[e.jsx("h3",{className:"pvx-card-title",children:"Championship Standings"}),e.jsxs("span",{className:"pvx-standings-subtitle",children:["After ",n.roundsCompleted," round",n.roundsCompleted!==1?"s":"",n.countingRounds>0&&` (best ${n.countingRounds} count)`]})]})}),e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"Pos"}),e.jsx("th",{className:"pvx-th",children:"Driver"}),e.jsx("th",{className:"pvx-th pvx-th--center pvx-hidden-below-sm",children:"W"}),e.jsx("th",{className:"pvx-th pvx-th--center pvx-hidden-below-sm",children:"Pod"}),e.jsx("th",{className:"pvx-th pvx-th--center",children:"Points"}),o.map(c=>e.jsxs("th",{className:"pvx-th pvx-th--center pvx-hidden-below-md",title:c.track||`Round ${c.roundNumber}`,children:["R",c.roundNumber]},c.roundNumber))]})}),e.jsx("tbody",{className:"pvx-tbody",children:n.standings.map(c=>e.jsx(xs,{driver:c,finalizedRounds:o},c.driverId||c.driverName))})]})})]})}function xs({driver:s,finalizedRounds:r}){var o,l,x;const n=s.position<=3,t=new Map(((o=s.roundResults)==null?void 0:o.map(c=>[c.roundNumber,c]))||[]),a=((l=s.roundResults)==null?void 0:l.filter(c=>c.position===1).length)||0,i=((x=s.roundResults)==null?void 0:x.filter(c=>c.position<=3).length)||0;return e.jsxs("tr",{className:`pvx-row ${n?"pvx-row--podium":""}`,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(he,{position:s.position})}),e.jsxs("td",{className:"pvx-td pvx-td--primary",children:[e.jsx(ge,{nation:s.nation}),s.driverName]}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-sm",children:a||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-sm",children:i||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-standings-total",children:s.totalPoints}),r.map(c=>{const d=t.get(c.roundNumber),m=d==null?void 0:d.dropped;return e.jsx("td",{className:`pvx-td pvx-td--center pvx-hidden-below-md ${!m&&(d==null?void 0:d.position)<=3?"pvx-standings-cell--podium":""}`,children:d?e.jsxs("div",{className:`pvx-standings-round-cell ${m?"pvx-standings-round-cell--dropped":""}`,children:[e.jsxs("span",{className:"pvx-standings-round-pos",children:["P",d.position]}),e.jsx("span",{className:"pvx-standings-round-pts",children:d.points})]}):e.jsx("span",{className:"pvx-td--muted",children:"-"})},c.roundNumber)})]})}function us({competitionId:s,roundNumber:r,className:n}){var x;const{data:t,isLoading:a}=le(s,r);if(a)return e.jsx(B,{message:"Loading results..."});if(!t)return e.jsx($,{message:"No results for this round."});const o=(t.sessions||[]).find(c=>c.type==="RACE"),l=(x=o==null?void 0:o.results)==null?void 0:x.filter(c=>c.position<=3).sort((c,d)=>c.position-d.position);return e.jsxs("div",{className:`pvx-round-results ${n||""}`,children:[e.jsxs("div",{className:"pvx-round-results-header",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"pvx-round-results-title",children:["Round ",t.roundNumber,t.track?`: ${t.track}`:""]}),t.startTime&&e.jsx("p",{className:"pvx-round-results-date",children:new Date(t.startTime).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})})]}),(l==null?void 0:l.length)>0&&e.jsx("div",{className:"pvx-round-podium-summary",children:l.map(c=>e.jsxs("span",{className:"pvx-round-podium-item",children:[e.jsx("span",{children:ve[c.position-1]}),e.jsx("span",{children:c.driverName})]},c.driverId))})]}),e.jsx(fe,{round:t})]})}function fe({round:s,className:r}){var l,x;const[n,t]=N.useState(null),a=(s==null?void 0:s.sessions)||[];if(!a.length)return e.jsx($,{message:"No session data for this round."});const i=n||((l=a.find(c=>c.type==="RACE"))==null?void 0:l.type)||((x=a[0])==null?void 0:x.type),o=a.find(c=>c.type===i)||a[0];return e.jsxs("div",{className:r||"",children:[e.jsx(ns,{sessions:a,activeSession:i,onSelect:t}),e.jsx(ms,{session:o})]})}function ms({session:s}){var t;const r=s.type==="RACE";if(!((t=s.results)!=null&&t.length))return e.jsx($,{message:`No results for ${s.type}.`});const n=is(s.results);return e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"Pos"}),e.jsx("th",{className:"pvx-th",children:"Driver"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Car"}),e.jsx("th",{className:"pvx-th",children:"Best Lap"}),r&&e.jsxs(e.Fragment,{children:[e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Laps"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Time / Gap"}),e.jsx("th",{className:"pvx-th pvx-th--center",children:"Points"})]})]})}),e.jsx("tbody",{className:"pvx-tbody",children:s.results.map((a,i)=>e.jsx(vs,{result:a,isRace:r,fastestSplits:n,rowIndex:i},a.driverId||i))})]})})}function vs({result:s,isRace:r,fastestSplits:n,rowIndex:t}){const a=s.position<=3;return e.jsxs("tr",{className:`pvx-row ${a?"pvx-row--podium":""}`,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(he,{position:s.position})}),e.jsxs("td",{className:"pvx-td pvx-td--primary",children:[e.jsx(ge,{nation:s.nation}),s.driverName,s.carNumber!=null&&e.jsxs("span",{className:"pvx-car-number",children:["#",s.carNumber]}),s.penalty&&e.jsx("span",{className:"pvx-penalty",children:s.penalty})]}),e.jsx("td",{className:"pvx-td pvx-hidden-below-sm",children:L(s.carId)}),e.jsx("td",{className:"pvx-td pvx-td--mono",children:e.jsx(hs,{bestLap:s.bestLapFormatted,hasBestLap:s.hasBestLap,splits:s.splits,fastestSplits:n,showAbove:t<=1})}),r&&e.jsxs(e.Fragment,{children:[e.jsx("td",{className:"pvx-td pvx-hidden-below-sm",children:s.lapsCompleted}),e.jsx("td",{className:"pvx-td pvx-td--mono pvx-td--muted pvx-hidden-below-sm",children:s.position===1?s.totalTime||"-":s.gap||"-"}),e.jsxs("td",{className:"pvx-td pvx-td--center",children:[e.jsx("span",{className:"pvx-session-points",children:s.points}),s.pointsOverride!==0&&s.pointsOverride&&e.jsxs("span",{className:"pvx-points-override",children:["(",s.pointsOverride>0?"+":"",s.pointsOverride,")"]})]})]})]})}function hs({bestLap:s,hasBestLap:r,splits:n,fastestSplits:t,showAbove:a}){return s?e.jsxs("span",{className:`pvx-best-lap-cell ${r?"pvx-best-lap-cell--fastest":""}`,children:[e.jsx("span",{className:"pvx-best-lap-time",children:s}),(n==null?void 0:n.length)>0&&e.jsx("span",{className:"pvx-splits-tooltip-anchor",children:e.jsx("span",{className:`pvx-splits-tooltip ${a?"":"pvx-splits-tooltip--above"}`,children:n.map((i,o)=>{const l=t&&i===t[o];return e.jsxs("span",{className:"pvx-splits-tooltip-row",children:[e.jsxs("span",{className:"pvx-splits-tooltip-label",children:["S",o+1]}),e.jsx("span",{className:l?"pvx-splits-tooltip-best":"",children:i})]},o)})})})]}):e.jsx("span",{className:"pvx-td--muted",children:"-"})}function gs({competitionId:s,className:r}){const{getSteamId:n}=k(),{data:t,isLoading:a}=Z(s),i=n();if(a)return e.jsx(B,{message:"Loading drivers..."});const o=(t==null?void 0:t.drivers)||(t==null?void 0:t.entries)||[];return o.length?e.jsx("div",{className:`pvx-entry-grid ${r||""}`,children:o.map(l=>{var c,d;const x=i&&l.steamId===i;return e.jsxs("div",{className:`pvx-entry-card ${x?"pvx-entry-card--you":""}`,children:[l.avatarUrl?e.jsx("img",{src:l.avatarUrl,alt:"",className:"pvx-entry-avatar"}):e.jsx("div",{className:"pvx-entry-avatar pvx-entry-avatar--placeholder",children:((d=(c=l.displayName)==null?void 0:c.charAt(0))==null?void 0:d.toUpperCase())||"?"}),e.jsxs("span",{className:"pvx-entry-name",children:[l.displayName,x&&e.jsx("span",{className:"pvx-entry-you",children:" (you)"})]})]},l.steamId||l.driverId)})}):e.jsx($,{message:"No drivers registered yet."})}function js({competitionId:s,driverData:r,className:n,children:t}){const{data:a,isLoading:i}=_(s),{isPowerMode:o}=q(),l=V(s),x=J(s),c=X(s),d=(a==null?void 0:a.isRegistered)||!1,m=i||x.isPending||c.isPending,g=x.error||c.error||null,u=()=>{o&&x.mutate(r||{})},f=()=>{o&&c.mutate()};return typeof t=="function"?t({isRegistered:d,isLoading:m,register:u,withdraw:f,error:g,isPowerMode:o,registrationUrl:l}):o?e.jsx("button",{className:`pvx-comp-register-btn ${n||""}`,onClick:d?f:u,disabled:m,children:m?"Loading...":d?"Withdraw":"Register"}):e.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:`pvx-comp-register-link ${n||""}`,children:d?"View Registration":"Register on PitVox"})}function fs({competitionId:s,registration:r,onWithdrawSuccess:n,className:t}){const{getSteamId:a}=k(),{isPowerMode:i}=q(),o=V(s),{data:l,isLoading:x}=_(s),{data:c,isLoading:d}=Z(s),m=J(s),g=X(s),u=a(),f=(l==null?void 0:l.isRegistered)||!1,p=(c==null?void 0:c.drivers)||(c==null?void 0:c.entries)||[],j=r||{},v=p.length||j.currentCount||0,h=j.maxParticipants&&v>=j.maxParticipants,b=j.deadline&&new Date(j.deadline)<new Date,C=j.isOpen&&!b&&!h;return x||d?e.jsx(B,{message:"Loading registration..."}):f?e.jsx("div",{className:`pvx-reg-panel ${t||""}`,children:e.jsx(bs,{competitionId:s,drivers:p,steamId:u,isPowerMode:i,registrationUrl:o,withdrawMutation:g,onWithdrawSuccess:n,registration:j})}):C?u?i?e.jsx("div",{className:`pvx-reg-panel ${t||""}`,children:e.jsx(Ns,{competitionId:s,registerMutation:m,registration:j})}):e.jsx("div",{className:`pvx-reg-panel ${t||""}`,children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-register-link",children:"Register on PitVox"})}):e.jsx("div",{className:`pvx-reg-panel ${t||""}`,children:i?e.jsx("div",{className:"pvx-reg-status-msg",children:"Sign in to register for this competition."}):e.jsx("div",{className:"pvx-reg-status-msg",children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-register-link",children:"Register on PitVox"})})}):e.jsxs("div",{className:`pvx-reg-panel ${t||""}`,children:[e.jsx("div",{className:"pvx-reg-status-msg",children:h?"Registration is full.":b?"Registration deadline has passed.":"Registration is closed."}),p.length>0&&e.jsx(Ne,{drivers:p,steamId:u})]})}function Ns({competitionId:s,registerMutation:r,registration:n}){const[t,a]=N.useState(""),[i,o]=N.useState("intermediate"),[l,x]=N.useState(""),c=u=>{u.preventDefault(),r.mutate({discordUsername:t||void 0,experience:i,comments:l||void 0})},d=n||{},m=d.currentCount||0,g=d.maxParticipants;return e.jsxs("form",{className:"pvx-reg-form",onSubmit:c,children:[e.jsxs("div",{className:"pvx-reg-form-header",children:[e.jsx("h3",{className:"pvx-reg-form-title",children:"Register"}),g&&e.jsx(be,{count:m,max:g})]}),r.error&&e.jsx("div",{className:"pvx-reg-error",children:r.error.message||"Registration failed"}),e.jsxs("div",{className:"pvx-reg-field",children:[e.jsxs("label",{className:"pvx-reg-label",htmlFor:`pvx-discord-${s}`,children:["Discord Username ",e.jsx("span",{className:"pvx-reg-optional",children:"(optional)"})]}),e.jsx("input",{id:`pvx-discord-${s}`,type:"text",className:"pvx-reg-input",placeholder:"e.g. username",value:t,onChange:u=>a(u.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:u=>o(u.target.value),children:[e.jsx("option",{value:"beginner",children:"Beginner"}),e.jsx("option",{value:"intermediate",children:"Intermediate"}),e.jsx("option",{value:"advanced",children:"Advanced"})]})]}),e.jsxs("div",{className:"pvx-reg-field",children:[e.jsxs("label",{className:"pvx-reg-label",htmlFor:`pvx-comments-${s}`,children:["Comments ",e.jsx("span",{className:"pvx-reg-optional",children:"(optional)"})]}),e.jsx("textarea",{id:`pvx-comments-${s}`,className:"pvx-reg-textarea",rows:3,placeholder:"Anything the organisers should know?",value:l,onChange:u=>x(u.target.value)})]}),e.jsx("div",{className:"pvx-reg-actions",children:e.jsx("button",{type:"submit",className:"pvx-comp-register-btn",disabled:r.isPending,children:r.isPending?"Registering...":"Register"})})]})}function bs({competitionId:s,drivers:r,steamId:n,isPowerMode:t,registrationUrl:a,withdrawMutation:i,onWithdrawSuccess:o,registration:l}){const[x,c]=N.useState(!1),d=()=>{i.mutate(void 0,{onSuccess:()=>{c(!1),o&&o()}})},m=l||{},g=r.length||m.currentCount||0,u=m.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"}),u&&e.jsx(be,{count:g,max:u})]}),e.jsx(Ne,{drivers:r,steamId:n}),i.error&&e.jsx("div",{className:"pvx-reg-error",children:i.error.message||"Withdrawal failed"}),t?e.jsx("div",{className:"pvx-reg-actions",children:x?e.jsxs("div",{className:"pvx-reg-confirm",children:[e.jsx("p",{className:"pvx-reg-confirm-text",children:"Are you sure you want to unregister?"}),e.jsxs("div",{className:"pvx-reg-confirm-actions",children:[e.jsx("button",{type:"button",className:"pvx-reg-cancel-btn",onClick:()=>c(!1),children:"Cancel"}),e.jsx("button",{type:"button",className:"pvx-reg-danger-btn",onClick:d,disabled:i.isPending,children:i.isPending?"Unregistering...":"Yes, Unregister"})]})]}):e.jsx("button",{type:"button",className:"pvx-reg-unregister-btn",onClick:()=>c(!0),children:"Unregister"})}):e.jsx("div",{className:"pvx-reg-actions",children:e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-register-link",children:"Manage on PitVox"})})]})}function Ne({drivers:s,steamId:r}){if(!s.length)return e.jsx("div",{className:"pvx-reg-no-drivers",children:"No drivers registered yet."});const n=[...s].sort((t,a)=>{const i=r&&t.steamId===r?-1:0,o=r&&a.steamId===r?-1:0;return i-o});return e.jsx("div",{className:"pvx-reg-driver-list",children:n.map(t=>{var i,o;const a=r&&t.steamId===r;return e.jsxs("div",{className:`pvx-reg-driver-row ${a?"pvx-reg-driver-row--you":""}`,children:[t.avatarUrl?e.jsx("img",{src:t.avatarUrl,alt:"",className:"pvx-reg-driver-avatar"}):e.jsx("div",{className:"pvx-reg-driver-avatar pvx-reg-driver-avatar--placeholder",children:((o=(i=t.displayName)==null?void 0:i.charAt(0))==null?void 0:o.toUpperCase())||"?"}),e.jsxs("span",{className:"pvx-reg-driver-name",children:[t.displayName,a&&e.jsx("span",{className:"pvx-entry-you",children:" (you)"})]})]},t.steamId||t.driverId)})})}function be({count:s,max:r}){const n=r?s/r*100:0,t=n>=100?"full":n>=75?"warning":"ok";return e.jsxs("span",{className:`pvx-reg-capacity pvx-reg-capacity--${t}`,children:[s,"/",r," drivers"]})}function ye(s){const{cdnUrl:r}=k(),n=y.useQuery({queryKey:["pitvox","laps","global",s],queryFn:()=>R(r,`laps/${s}.json`),enabled:!!s,staleTime:3e4,refetchInterval:3e4}),t=n.data;return{isLoading:n.isLoading,error:n.error,data:t?{driverName:t.driverName||"Driver",lapCount:t.lapCount||0,trackBreakdown:t.trackBreakdown||[],carBreakdown:t.carBreakdown||[],recordsHeld:t.recordsHeld||0,currentRecords:t.currentRecords||[],bestRanking:t.bestRanking??null,bestRankingTrackId:t.bestRankingTrackId??null,bestRankingLayout:t.bestRankingLayout??null,bestRankingCarId:t.bestRankingCarId??null,generatedAt:t.generatedAt}:null}}function ke(s={}){const{cdnUrl:r,partnerSlug:n}=k(),{gameVersion:t,enabled:a=!0}=s,i=t?`leaderboards/partners/${n}/v/${t}/ratings.json`:`leaderboards/partners/${n}/ratings.json`;return y.useQuery({queryKey:["pitvox","ratings",n,t||null],queryFn:()=>R(r,i),staleTime:3e4,refetchInterval:3e4,enabled:a})}function Ce(s){var t;const r=ke(),n=N.useMemo(()=>{var a;return!((a=r.data)!=null&&a.drivers)||!s?null:r.data.drivers.find(i=>i.identifier===s)||null},[(t=r.data)==null?void 0:t.drivers,s]);return{isLoading:r.isLoading,error:r.error,data:n?{rating:n.rating,rank:n.rank,totalDrivers:r.data.driverCount||r.data.drivers.length,comboCount:n.comboCount||0,distinctCars:n.distinctCars||0,combos:n.combos||[]}:null}}function ys(s={}){const r=ke(s);return{data:r.data||null,isLoading:r.isLoading,error:r.error}}function we(){const{cdnUrl:s,partnerSlug:r,getSteamId:n}=k(),t=n(),{data:a,isLoading:i}=y.useQuery({queryKey:["pitvox","competitions",r],queryFn:async()=>{const d=await R(s,"competitions/index.json");return d!=null&&d.competitions?d.competitions.filter(m=>m.partnerSlug===r):[]},staleTime:6e4}),o=(a==null?void 0:a.map(d=>d.id))||[],l=y.useQueries({queries:o.map(d=>({queryKey:["pitvox","competition",r,d,"entrylist"],queryFn:()=>R(s,`competitions/${r}/${d}/entrylist.json`),enabled:!!t&&o.length>0,staleTime:6e4}))}),x=l.some(d=>d.isLoading);return{data:N.useMemo(()=>{var g,u;if(!a||!t||x)return[];const d=new Date,m=[];for(let f=0;f<a.length;f++){const p=a[f],j=(g=l[f])==null?void 0:g.data;if(!((u=j==null?void 0:j.drivers)==null?void 0:u.some(b=>b.steamId===t)))continue;const h=p.rounds||[];for(const b of h)b.isFinalized||!b.startTime||new Date(b.startTime)<=d||m.push({competitionId:p.id,competitionName:p.name,roundNumber:b.roundNumber,track:b.track||"TBD",startTime:b.startTime})}return m.sort((f,p)=>new Date(f.startTime)-new Date(p.startTime)),m.length>0&&(m[0].isNext=!0),m},[a,t,x,l]),isLoading:i||!!t&&x}}function Re(){const{onFetchNotifications:s}=k();return!!s}function Le(s={}){const{onFetchNotifications:r,partnerSlug:n}=k(),{limit:t=20,unreadOnly:a=!1}=s;return y.useQuery({queryKey:["pitvox","notifications",n,{limit:t,unreadOnly:a}],queryFn:()=>r({limit:t,unreadOnly:a}),enabled:!!r,staleTime:3e4,refetchInterval:3e4})}function ks(){const{onFetchNotifications:s,partnerSlug:r}=k(),{data:n,isLoading:t}=y.useQuery({queryKey:["pitvox","notifications",r,{limit:1,unreadOnly:!1}],queryFn:()=>s({limit:1}),enabled:!!s,staleTime:3e4,refetchInterval:3e4,select:a=>(a==null?void 0:a.unreadCount)??0});return{count:n??0,isLoading:t}}function Te(){const{onMarkNotificationRead:s,partnerSlug:r}=k(),n=y.useQueryClient();return y.useMutation({mutationFn:t=>{if(!s)throw new Error("No onMarkNotificationRead callback provided to PitVoxPartnerProvider.");return s(t)},onSuccess:(t,a)=>{n.setQueriesData({queryKey:["pitvox","notifications",r]},i=>i!=null&&i.notifications?{...i,unreadCount:Math.max(0,(i.unreadCount||0)-1),notifications:i.notifications.map(o=>o.id===a?{...o,isRead:!0,readAt:new Date().toISOString()}:o)}:i)}})}function Se(){const{onMarkAllNotificationsRead:s,partnerSlug:r}=k(),n=y.useQueryClient();return y.useMutation({mutationFn:()=>{if(!s)throw new Error("No onMarkAllNotificationsRead callback provided to PitVoxPartnerProvider.");return s()},onSuccess:()=>{n.setQueriesData({queryKey:["pitvox","notifications",r]},t=>t!=null&&t.notifications?{...t,unreadCount:0,notifications:t.notifications.map(a=>({...a,isRead:!0,readAt:a.readAt||new Date().toISOString()}))}:t)}})}function Me({driverName:s,avatarUrl:r,memberSince:n,className:t=""}){const a=n?new Date(n).toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric"}):null;return e.jsxs("div",{className:`pvx-card pvx-dash-profile ${t}`,children:[r?e.jsx("img",{src:r,alt:"",className:"pvx-dash-profile-avatar"}):e.jsx("div",{className:"pvx-dash-profile-avatar pvx-dash-profile-avatar--placeholder",children:(s||"?")[0].toUpperCase()}),e.jsxs("div",{className:"pvx-dash-profile-info",children:[e.jsx("h2",{className:"pvx-dash-profile-name",children:s}),a&&e.jsxs("p",{className:"pvx-dash-profile-since",children:["Racing since ",a]})]})]})}function Cs(){return e.jsxs("svg",{className:"pvx-dash-stat-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),e.jsx("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),e.jsx("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),e.jsx("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function ws(){return e.jsxs("svg",{className:"pvx-dash-stat-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"}),e.jsx("path",{d:"M12 14v4"}),e.jsx("path",{d:"M10.5 12.5l-4 2.5"}),e.jsx("path",{d:"M13.5 12.5l4 2.5"})]})}function Rs(){return e.jsx("svg",{className:"pvx-dash-stat-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})}function te({icon:s,value:r,label:n,items:t,labelKey:a,countKey:i}){const[o,l]=N.useState(!1),x=N.useRef(null);N.useEffect(()=>{if(!o)return;function d(m){x.current&&!x.current.contains(m.target)&&l(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[o]);const c=t!=null&&t.length?t.slice().sort((d,m)=>m[i]-d[i]):null;return e.jsxs("div",{ref:x,className:`pvx-dash-stat-card ${c?"pvx-dash-stat-card--clickable":""}`,onClick:c?()=>l(d=>!d):void 0,children:[s,e.jsxs("div",{className:"pvx-dash-stat-content",children:[e.jsx("span",{className:"pvx-dash-stat-value",children:r}),e.jsx("span",{className:"pvx-dash-stat-label",children:n})]}),c&&e.jsx("div",{className:`pvx-dash-tooltip pvx-dash-tooltip--scrollable ${o?"pvx-dash-tooltip--open":""}`,children:c.map((d,m)=>e.jsxs("div",{className:"pvx-dash-tooltip-row",children:[e.jsx("span",{className:"pvx-dash-tooltip-label",children:d[a]}),e.jsx("span",{className:"pvx-dash-tooltip-value",children:d[i]})]},m))})]})}function $e({stats:s,rating:r,className:n=""}){if(!s)return null;const t=s.trackBreakdown.map(i=>({name:D(i.trackId,i.layout),lapCount:i.lapCount})),a=s.carBreakdown.map(i=>({name:L(i.carId),lapCount:i.lapCount}));return e.jsxs("div",{className:`pvx-dash-stats ${n}`,children:[e.jsx(te,{icon:e.jsx(Cs,{}),value:s.lapCount.toLocaleString(),label:"Total Laps",items:t,labelKey:"name",countKey:"lapCount"}),e.jsx(te,{icon:e.jsx(ws,{}),value:s.carBreakdown.length,label:"Cars Used",items:a,labelKey:"name",countKey:"lapCount"}),r&&e.jsxs("div",{className:"pvx-dash-stat-card pvx-dash-stat-card--rating",children:[e.jsx(Rs,{}),e.jsxs("div",{className:"pvx-dash-stat-content",children:[e.jsx("span",{className:"pvx-dash-stat-value",children:r.rating.toFixed(1)}),e.jsx("span",{className:"pvx-dash-stat-label",children:"Driver Rating"}),e.jsxs("span",{className:"pvx-dash-stat-sub",children:["#",r.rank," of ",r.totalDrivers]})]})]})]})}function De({records:s,className:r=""}){const n=N.useMemo(()=>s!=null&&s.length?s.slice().sort((t,a)=>{const i=t.recordedAt?new Date(t.recordedAt).getTime():0;return(a.recordedAt?new Date(a.recordedAt).getTime():0)-i}):[],[s]);return n.length?e.jsxs("div",{className:`pvx-card ${r}`,children:[e.jsx("div",{className:"pvx-card-header",children:e.jsxs("h3",{className:"pvx-card-title",children:[e.jsx("span",{className:"pvx-dash-records-icon",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 9H4.5a2.5 2.5 0 010-5H6"}),e.jsx("path",{d:"M18 9h1.5a2.5 2.5 0 000-5H18"}),e.jsx("path",{d:"M4 22h16"}),e.jsx("path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20 7 22"}),e.jsx("path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20 17 22"}),e.jsx("path",{d:"M18 2H6v7a6 6 0 0012 0V2z"})]})}),"Current Records",e.jsxs("span",{className:"pvx-dash-records-count",children:["(",n.length,")"]})]})}),e.jsx("div",{className:"pvx-dash-records-list",children:n.map((t,a)=>e.jsxs("div",{className:"pvx-dash-record-row",children:[e.jsxs("div",{className:"pvx-dash-record-info",children:[e.jsx("span",{className:"pvx-dash-record-track",children:D(t.trackId,t.layout,t.game)}),e.jsx("span",{className:"pvx-dash-record-car",children:L(t.carId)})]}),e.jsxs("div",{className:"pvx-dash-record-time",children:[e.jsx("span",{className:"pvx-dash-record-lap",children:M(t.lapTimeMs)}),e.jsxs("span",{className:`pvx-dash-game-badge pvx-dash-game-badge--${t.game||"evo"}`,children:[(t.game||"evo").toUpperCase(),t.gameVersion?` ${t.gameVersion}`:""]})]})]},a))})]}):null}function Ie({events:s,isLoading:r,className:n,limit:t=3}){if(r)return e.jsx("div",{className:"pvx-loading",children:"Loading upcoming events..."});if(!(s!=null&&s.length))return null;const a=t?s.slice(0,t):s,i=s.length-a.length;return e.jsxs("div",{className:`pvx-card ${n||""}`,children:[e.jsx("div",{className:"pvx-card-header",children:e.jsxs("h3",{className:"pvx-card-title",children:[e.jsx(Ts,{}),"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]})]}),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:Ls(o.startTime)}),o.isNext&&e.jsx("span",{className:"pvx-upcoming-badge",children:"Next"})]})]},`${o.competitionId}-${o.roundNumber}`)),i>0&&e.jsxs("div",{className:"pvx-upcoming-remaining",children:["+",i," more event",i!==1?"s":""]})]})]})}function Ls(s){const r=new Date(s).getTime()-Date.now();if(r<=0)return"Now";const n=Math.floor(r/(1e3*60*60));if(n<1)return"Less than 1 hour";if(n<24)return`in ${n}h`;const t=Math.floor(n/24);if(t===1)return"Tomorrow";if(t<7)return`in ${t} days`;if(t<30){const a=Math.floor(t/7);return`in ${a} week${a!==1?"s":""}`}return G(s)}function Ts(){return e.jsxs("svg",{className:"pvx-dash-records-icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M16 2v4M8 2v4M3 10h18"})]})}function Be({notifications:s,unreadCount:r=0,onMarkRead:n,onMarkAllRead:t,isLoading:a,className:i}){const o=Y();return a?e.jsx("div",{className:"pvx-loading",children:"Loading notifications..."}):e.jsxs("div",{className:`pvx-card ${i||""}`,children:[e.jsxs("div",{className:"pvx-card-header",children:[e.jsxs("h3",{className:"pvx-card-title",children:[e.jsx($s,{}),"Notifications",r>0&&e.jsx("span",{className:"pvx-notif-badge",children:r>99?"99+":r})]}),r>0&&t&&e.jsx("button",{className:"pvx-notif-mark-all",onClick:t,children:"Mark all read"})]}),s!=null&&s.length?e.jsx("div",{className:"pvx-notif-list",children:s.map(l=>e.jsx(Ss,{notification:l,getUserDisplay:o,onMarkRead:n},l.id))}):e.jsx("div",{className:"pvx-notif-empty",children:"No notifications"})]})}function Ss({notification:s,getUserDisplay:r,onMarkRead:n}){const t=()=>{!s.isRead&&n&&n(s.id)};return e.jsxs("button",{className:`pvx-notif-item ${s.isRead?"":"pvx-notif-item--unread"}`,onClick:t,children:[e.jsx(Ms,{type:s.type}),e.jsxs("div",{className:"pvx-notif-content",children:[e.jsx("span",{className:"pvx-notif-message",children:ne(s,r)}),e.jsx("span",{className:"pvx-notif-time",children:G(s.createdAt)})]}),!s.isRead&&e.jsx("span",{className:"pvx-notif-dot"})]})}function Ms({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 $s(){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 Ds({steamId:s,avatarUrl:r,memberSince:n,className:t=""}){const{data:a,isLoading:i,error:o}=ye(s),{data:l,isLoading:x}=Ce(s),{data:c,isLoading:d}=we(),m=Re(),{data:g,isLoading:u}=Le({limit:10}),f=Te(),p=Se();return i||x?e.jsx("div",{className:"pvx-loading",children:"Loading dashboard..."}):o?e.jsx("div",{className:"pvx-empty",children:"Failed to load dashboard data."}):a?e.jsxs("div",{className:`pvx-dash ${t}`,children:[e.jsx(Me,{driverName:a.driverName,avatarUrl:r,memberSince:n}),e.jsx($e,{stats:a,rating:l}),s&&e.jsx(Ie,{events:c,isLoading:d}),e.jsxs("div",{className:`pvx-dash-row ${m?"pvx-dash-row--2col":""}`,children:[e.jsx(De,{records:a.currentRecords}),m&&e.jsx(Be,{notifications:g==null?void 0:g.notifications,unreadCount:(g==null?void 0:g.unreadCount)||0,onMarkRead:j=>f.mutate(j),onMarkAllRead:()=>p.mutate(),isLoading:u})]})]}):e.jsx("div",{className:"pvx-empty",children:"No data available yet. Start driving to see your stats!"})}exports.CarsTable=Ze;exports.CompEmptyState=$;exports.CompLoadingState=B;exports.CompetitionCards=os;exports.DriverDashboard=Ds;exports.DriverProfile=Me;exports.DriversTable=Je;exports.EntryList=gs;exports.InfoPill=F;exports.LapHistoryTable=Xe;exports.NotificationsCard=Be;exports.PODIUM_MEDALS=ve;exports.PitVoxPartnerProvider=Ee;exports.RankingsTable=es;exports.RecordsTable=De;exports.RegisterButton=js;exports.RegistrationPanel=fs;exports.RoundResults=us;exports.RoundSessionResults=fe;exports.StandingsTable=ps;exports.StatsCards=$e;exports.TracksTable=Ye;exports.TypeBadge=je;exports.UpcomingEvents=Ie;exports.formatCarName=L;exports.formatDate=I;exports.formatDelta=Fe;exports.formatLapTime=M;exports.formatNotificationMessage=ne;exports.formatRelativeTime=G;exports.formatSectorTime=S;exports.formatTrackName=D;exports.formatTyreCompound=z;exports.useCarLeaderboard=Ve;exports.useCarMetadata=qe;exports.useCompetitionAllRounds=He;exports.useCompetitionConfig=oe;exports.useCompetitionEntryList=Z;exports.useCompetitionRound=le;exports.useCompetitionStandings=ce;exports.useCompetitions=Ke;exports.useDriverLaps=ie;exports.useDriverRating=Ce;exports.useDriverRatings=ys;exports.useDriverStats=ye;exports.useLeaderboardIndex=_e;exports.useMarkAllNotificationsRead=Se;exports.useMarkNotificationRead=Te;exports.useNotifications=Le;exports.useNotificationsEnabled=Re;exports.usePitVox=k;exports.useRegister=J;exports.useRegistrationMode=q;exports.useRegistrationStatus=_;exports.useRegistrationUrl=V;exports.useTrackLeaderboard=ae;exports.useUnreadCount=ks;exports.useUpcomingEvents=we;exports.useUserLookup=Y;exports.useWithdraw=X;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("react"),y=require("@tanstack/react-query"),W=N.createContext(null),Ue="https://cdn.pitvox.com",Ae="https://pitvox.com";let O=null;function Ee({partnerSlug:s,cdnUrl:r=Ue,pitvoxUrl:n=Ae,getSteamId:t,onRegister:a,onWithdraw:i,onFetchNotifications:o,onMarkNotificationRead:l,onMarkAllNotificationsRead:x,children:c}){const d=N.useMemo(()=>({partnerSlug:s,cdnUrl:r.replace(/\/$/,""),pitvoxUrl:n.replace(/\/$/,""),getSteamId:t||(()=>null),onRegister:a||null,onWithdraw:i||null,onFetchNotifications:o||null,onMarkNotificationRead:l||null,onMarkAllNotificationsRead:x||null}),[s,r,n,t,a,i,o,l,x]);let m=!1;try{y.useQueryClient(),m=!0}catch{m=!1}return m?e.jsx(W.Provider,{value:d,children:c}):(O||(O=new y.QueryClient({defaultOptions:{queries:{staleTime:6e4}}})),e.jsx(y.QueryClientProvider,{client:O,children:e.jsx(W.Provider,{value:d,children:c})}))}function k(){const s=N.useContext(W);if(!s)throw new Error("usePitVox must be used within a <PitVoxPartnerProvider>");return s}async function R(s,r){const n=await fetch(`${s}/${r}`);if(!n.ok){if(n.status===404||n.status===403)return null;throw new Error(`CDN fetch failed: ${n.status}`)}return n.json()}function M(s){if(!s&&s!==0)return"-";const r=Math.floor(s/1e3),n=Math.floor(r/60),t=r%60,a=s%1e3;return`${n}:${String(t).padStart(2,"0")}.${String(a).padStart(3,"0")}`}function S(s){return!s&&s!==0?"-":(s/1e3).toFixed(3)}function L(s){if(!s)return"";let r=s;return r.startsWith("ks_")&&(r=r.slice(3)),r.split("_").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function D(s,r,n){const t=s.split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" "),a=n==="acc"||!n&&(r==null?void 0:r.toLowerCase())==="track config";if(!r||r==="default"||a)return t;const i=r.split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ");return`${t} ${i}`}function I(s){if(!s)return"-";try{return new Date(s).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}catch{return"-"}}function G(s){if(!s)return"";const r=Date.now()-new Date(s).getTime(),n=Math.floor(r/1e3);if(n<60)return"Just now";const t=Math.floor(n/60);if(t<60)return`${t}m ago`;const a=Math.floor(t/60);if(a<24)return`${a}h ago`;const i=Math.floor(a/24);return i<30?`${i}d ago`:I(s)}function Fe(s){return s==null?"":`${s>=0?"+":"-"}${(Math.abs(s)/1e3).toFixed(3)}`}function ne(s,r){const{type:n,title:t,trackId:a,trackLayout:i,carId:o,game:l,data:x}=s,c=typeof x=="string"?JSON.parse(x):x,d=a?D(a,i,l):null,m=o?L(o):null,h=[d,m].filter(Boolean).join(" — ");return n==="RECORD_BEATEN"&&h?`${c!=null&&c.beatenBySteamId&&r?r(c.beatenBySteamId).displayName:"Someone"} beat your record on ${h}`:n==="RECORD_SET"&&h?`You set a new record on ${h}`:t||"New notification"}function z(s){return s?{E:"Eco",RD:"Road",SC:"SuperCar",RV:"Race Vintage",SM:"Semislick",ST:"Street",HR:"Hard Race",MR:"Medium Race",SR:"Soft Race",S:"Soft"}[s]||s:"Unknown"}function _e(s={}){var l,x,c,d,m,h;const{cdnUrl:r,partnerSlug:n}=k(),{game:t,gameVersion:a}=s,i=y.useQuery({queryKey:["pitvox","leaderboards",n,"index"],queryFn:()=>R(r,`leaderboards/partners/${n}/index.json`),staleTime:3e4,refetchInterval:3e4}),o=N.useMemo(()=>{var f;if(!((f=i.data)!=null&&f.tracks))return[];let u=i.data.tracks;return t&&(u=u.filter(p=>p.game===t)),a&&(u=u.filter(p=>p.gameVersion===a)),u.map(p=>({id:p.trackId,layout:p.layout,game:p.game,gameVersion:p.gameVersion,displayName:D(p.trackId,p.layout,p.game),driverCount:p.driverCount||0,carCount:p.carCount||0,record:p.recordHolder?{visibleId:p.recordHolder.steamId||p.recordHolder.userId,carId:p.recordHolder.carId,carDisplayName:L(p.recordHolder.carId),lapTimeMs:p.recordHolder.lapTimeMs,timestamp:p.recordHolder.recordedAt}:null,recordByTag:p.recordByTag||null}))},[(l=i.data)==null?void 0:l.tracks,t,a]);return{...i,data:o,partner:((x=i.data)==null?void 0:x.partner)||null,generatedAt:(c=i.data)==null?void 0:c.generatedAt,totalLaps:((d=i.data)==null?void 0:d.totalLaps)||0,totalUsers:((m=i.data)==null?void 0:m.totalUsers)||0,versions:((h=i.data)==null?void 0:h.versions)||{}}}function ae(s,r,n={}){const{cdnUrl:t,partnerSlug:a}=k(),{carId:i,game:o,gameVersion:l}=n,x=r||"default",c=l?`leaderboards/partners/${a}/v/${l}/tracks/${s}/${x}.json`:`leaderboards/partners/${a}/tracks/${s}/${x}.json`,{data:d,isLoading:m,error:h}=y.useQuery({queryKey:["pitvox","leaderboards",a,"track",s,x,l],queryFn:()=>R(t,c),enabled:!!s,staleTime:3e4,refetchInterval:3e4});return{data:N.useMemo(()=>{if(!(d!=null&&d.entries))return[];let f=d.entries;if(o&&(f=f.filter(p=>p.game===o)),!i){const p=new Map,j=new Map;for(const v of f){const g=v.steamId||v.userId;j.has(v.carId)||j.set(v.carId,new Set),j.get(v.carId).add(g),(!p.has(v.carId)||v.lapTimeMs<p.get(v.carId).lapTimeMs)&&p.set(v.carId,v)}return Array.from(p.values()).map(v=>{var g;return{...v,driverCount:((g=j.get(v.carId))==null?void 0:g.size)||0}}).sort((v,g)=>v.lapTimeMs-g.lapTimeMs)}return f.filter(p=>p.carId===i).sort((p,j)=>p.lapTimeMs-j.lapTimeMs)},[d==null?void 0:d.entries,i,o]),isLoading:m,error:h}}function ie(s,r,n,t,a={}){var h,u;const{cdnUrl:i,partnerSlug:o}=k(),{showInvalid:l=!1,game:x,gameVersion:c}=a,d=y.useQuery({queryKey:["pitvox","laps",o,s],queryFn:()=>R(i,`laps/partners/${o}/${s}.json`),enabled:!!s,staleTime:3e4,refetchInterval:3e4}),m=N.useMemo(()=>{var f;return(f=d.data)!=null&&f.laps?d.data.laps.filter(p=>{if(p.trackId!==r)return!1;if(n){if(p.trackLayout!==n)return!1}else if(p.trackLayout&&p.trackLayout!=="default")return!1;return!(p.carId!==t||x&&p.game!==x||c&&p.gameVersion!==c||!l&&!p.isValid)}).sort((p,j)=>p.lapTimeMs-j.lapTimeMs):[]},[(h=d.data)==null?void 0:h.laps,r,n,t,x,c,l]);return{...d,data:m,driverName:((u=d.data)==null?void 0:u.driverName)||"Driver"}}function Y(){const{cdnUrl:s}=k(),{data:r}=y.useQuery({queryKey:["pitvox","users","index"],queryFn:()=>R(s,"users/index.json"),staleTime:5*6e4,gcTime:30*6e4}),n=(r==null?void 0:r.users)||{};return(t,a)=>{const i=n[t];return{displayName:(i==null?void 0:i.displayName)||a||t||"Unknown",avatarUrl:(i==null?void 0:i.avatarUrl)||null,affiliations:(i==null?void 0:i.affiliations)||[]}}}function qe(){const{cdnUrl:s}=k(),{data:r}=y.useQuery({queryKey:["pitvox","cars","index"],queryFn:()=>R(s,"cars/index.json"),staleTime:5*6e4,gcTime:30*6e4});return{tags:(r==null?void 0:r.tags)||[],cars:(r==null?void 0:r.cars)||{}}}function Ve(s,r){return ae(s,null,{carId:r})}function Ke(){const{cdnUrl:s,partnerSlug:r}=k();return y.useQuery({queryKey:["pitvox","competitions",r],queryFn:async()=>{const n=await R(s,"competitions/index.json");return n!=null&&n.competitions?n.competitions.filter(t=>t.partnerSlug===r):[]},staleTime:6e4})}function oe(s){const{cdnUrl:r,partnerSlug:n}=k();return y.useQuery({queryKey:["pitvox","competition",n,s,"config"],queryFn:()=>R(r,`competitions/${n}/${s}/config.json`),enabled:!!s,staleTime:6e4})}function ce(s){const{cdnUrl:r,partnerSlug:n}=k();return y.useQuery({queryKey:["pitvox","competition",n,s,"standings"],queryFn:()=>R(r,`competitions/${n}/${s}/standings.json`),enabled:!!s,staleTime:6e4})}function le(s,r){const{cdnUrl:n,partnerSlug:t}=k();return y.useQuery({queryKey:["pitvox","competition",t,s,"round",r],queryFn:()=>R(n,`competitions/${t}/${s}/rounds/${r}.json`),enabled:!!s&&r!=null,staleTime:6e4})}function He(s,r=[]){const{cdnUrl:n,partnerSlug:t}=k();return y.useQuery({queryKey:["pitvox","competition",t,s,"allRounds",r],queryFn:async()=>(await Promise.all(r.map(i=>R(n,`competitions/${t}/${s}/rounds/${i}.json`).catch(()=>null)))).filter(Boolean),enabled:!!s&&r.length>0,staleTime:6e4})}function Z(s){const{cdnUrl:r,partnerSlug:n}=k();return y.useQuery({queryKey:["pitvox","competition",n,s,"entrylist"],queryFn:()=>R(r,`competitions/${n}/${s}/entrylist.json`),enabled:!!s,staleTime:6e4})}function _(s){const{cdnUrl:r,partnerSlug:n,getSteamId:t}=k(),a=t();return y.useQuery({queryKey:["pitvox","registration",n,s,a],queryFn:async()=>{var x;const i=await fetch(`${r}/competitions/${n}/${s}/entrylist.json`);if(!i.ok)return{isRegistered:!1,entryList:null};const o=await i.json();return{isRegistered:!!a&&((x=o.drivers)==null?void 0:x.some(c=>c.steamId===a)),entryList:o}},enabled:!!s,staleTime:6e4})}function J(s){const{onRegister:r,partnerSlug:n,getSteamId:t}=k(),a=y.useQueryClient(),i=Y();return y.useMutation({mutationFn:o=>{if(!r)throw new Error("No onRegister callback provided to PitVoxPartnerProvider. Provide onRegister for in-app registration, or use useRegistrationUrl() to link to pitvox.com.");return r(s,o)},onSuccess:()=>{const o=t();if(a.setQueriesData({queryKey:["pitvox","registration",n,s]},l=>l?{...l,isRegistered:!0}:{isRegistered:!0,entryList:null}),o){const l=i(o),x={steamId:o,displayName:l.displayName,avatarUrl:l.avatarUrl};a.setQueriesData({queryKey:["pitvox","competition",n,s,"entrylist"]},c=>{var m;return c?((m=c.drivers)==null?void 0:m.some(h=>h.steamId===o))?c:{...c,drivers:[...c.drivers||[],x]}:{drivers:[x]}})}}})}function X(s){const{onWithdraw:r,partnerSlug:n,getSteamId:t}=k(),a=y.useQueryClient();return y.useMutation({mutationFn:i=>{if(!r)throw new Error("No onWithdraw callback provided to PitVoxPartnerProvider. Provide onWithdraw for in-app withdrawal, or use useRegistrationUrl() to link to pitvox.com.");const o=i||t();if(!o)throw new Error("No Steam ID available");return r(s,o)},onSuccess:()=>{const i=t();a.setQueriesData({queryKey:["pitvox","registration",n,s]},o=>o?{...o,isRegistered:!1}:{isRegistered:!1,entryList:null}),i&&a.setQueriesData({queryKey:["pitvox","competition",n,s,"entrylist"]},o=>o!=null&&o.drivers?{...o,drivers:o.drivers.filter(l=>l.steamId!==i)}:o)}})}function q(){const{onRegister:s,onWithdraw:r}=k(),n=!!(s&&r);return{isPowerMode:n,isBasicMode:!n}}function V(s){const{pitvoxUrl:r,partnerSlug:n}=k();return`${r}/p/${n}/competitions/${s}/register`}const Qe={formula:"Formula",gt3:"GT3",gt2:"GT2",gt4:"GT4",cup:"Cup",prototype:"Prototype",rally:"Rally",hypercar:"Hypercar",supercar:"Supercar",sports_car:"Sports Car",hot_hatch:"Hot Hatch",lightweight:"Lightweight","1960s":"1960s","1970s":"1970s","1980s":"1980s","1990s":"1990s","2000s":"2000s","2010s":"2010s","2020s":"2020s"},de=[{id:"class",tags:["formula","gt3","gt2","gt4","cup","prototype","rally"]},{id:"tier",tags:["hypercar","supercar","sports_car","hot_hatch","lightweight"]},{id:"era",tags:["1960s","1970s","1980s","1990s","2000s","2010s","2020s"]}];function Oe(s){for(const r of de)if(r.tags.includes(s))return r.id;return"other"}function pe(s,r){if(r.size===0)return!0;const n={};for(const t of r){const a=Oe(t);n[a]||(n[a]=[]),n[a].push(t)}for(const t of Object.values(n))if(!t.some(a=>s.includes(a)))return!1;return!0}function xe(s,r){const[n,t]=N.useState(new Set),a=s!==void 0,i=a?s:n,o=N.useCallback(x=>{const c=new Set(i);c.has(x)?c.delete(x):c.add(x),a&&r?r(c):t(c)},[i,a,r]),l=N.useCallback(()=>{a&&r?r(new Set):t(new Set)},[a,r]);return{activeTags:i,toggle:o,clear:l}}function K(s){const[r,n]=N.useState(s),t=N.useCallback(a=>{n(i=>i.key===a?{key:a,dir:i.dir==="asc"?"desc":"asc"}:{key:a,dir:a.includes("timestamp")||a.includes("Date")?"desc":"asc"})},[]);return[r,t]}function H(s,r,n){return[...s].sort((t,a)=>{const i=n(t,r.key),o=n(a,r.key);if(i==null&&o==null)return 0;if(i==null)return 1;if(o==null)return-1;const l=typeof i=="string"?i.localeCompare(o):i-o;return r.dir==="desc"?-l:l})}function ue(s,r=!1){const n=r?s==null?void 0:s.filter(t=>t.isValid):s;return n!=null&&n.length?{s1:Math.min(...n.map(t=>t.sector1Ms).filter(Boolean)),s2:Math.min(...n.map(t=>t.sector2Ms).filter(Boolean)),s3:Math.min(...n.map(t=>t.sector3Ms).filter(Boolean))}:null}function We({active:s,dir:r}){return s?r==="asc"?e.jsx("svg",{className:"pvx-sort-icon",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 15.75l7.5-7.5 7.5 7.5"})}):e.jsx("svg",{className:"pvx-sort-icon",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})}):e.jsx("svg",{className:"pvx-sort-icon pvx-sort-icon--inactive",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 9l4-4 4 4M16 15l-4 4-4-4"})})}function w({label:s,sortKey:r,config:n,onSort:t,className:a=""}){return e.jsx("th",{className:`pvx-th pvx-th--sortable ${a}`,onClick:()=>t(r),children:e.jsxs("span",{className:"pvx-th-inner",children:[s,e.jsx(We,{active:n.key===r,dir:n.dir})]})})}function Q({userId:s,getUserDisplay:r}){const{displayName:n,avatarUrl:t}=r(s);return e.jsxs("span",{className:"pvx-driver",children:[t?e.jsx("img",{src:t,alt:"",className:"pvx-driver-avatar"}):e.jsx("span",{className:"pvx-driver-avatar pvx-driver-avatar--placeholder"}),e.jsx("span",{className:"pvx-driver-name",children:n})]})}function ee({rank:s,podium:r=!1}){const n=r?s===1?"pvx-rank pvx-rank--gold":s===2?"pvx-rank pvx-rank--silver":s===3?"pvx-rank pvx-rank--bronze":"pvx-rank":"pvx-rank";return e.jsx("span",{className:n,children:s})}function me({availableTags:s,activeTags:r,onToggle:n,onClear:t}){if(!s||s.length<2)return null;const a=de.map(i=>({id:i.id,tags:i.tags.filter(o=>s.includes(o))})).filter(i=>i.tags.length>0);return e.jsxs("div",{className:"pvx-tag-bar",children:[e.jsx("button",{onClick:t,className:`pvx-tag ${r.size===0?"pvx-tag--active":""}`,children:"All"}),a.map((i,o)=>e.jsxs("span",{className:"contents",children:[o>0&&e.jsx("span",{className:"pvx-tag-separator"}),i.tags.map(l=>e.jsx("button",{onClick:()=>n(l),className:`pvx-tag ${r.has(l)?"pvx-tag--active":""}`,children:Qe[l]||l},l))]},i.id))]})}function se({segments:s}){return e.jsx("nav",{className:"pvx-breadcrumb","aria-label":"Breadcrumb",children:e.jsx("ol",{className:"pvx-breadcrumb-list",children:s.map((r,n)=>{const t=n===s.length-1;return e.jsxs("li",{className:"pvx-breadcrumb-item",children:[n>0&&e.jsx("svg",{className:"pvx-breadcrumb-chevron",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})}),!t&&r.onClick?e.jsx("button",{onClick:r.onClick,className:"pvx-breadcrumb-link",children:r.label}):e.jsx("span",{className:"pvx-breadcrumb-current",children:r.label})]},r.key)})})})}function U({message:s}){return e.jsxs("div",{className:"pvx-empty",children:[e.jsx("svg",{className:"pvx-empty-icon",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.5 18.75h-9m9 0a3 3 0 013 3h-15a3 3 0 013-3m9 0v-4.5A3.375 3.375 0 0013.125 10.875h-2.25A3.375 3.375 0 007.5 14.25v4.5"})}),e.jsx("p",{children:s})]})}function A(){return e.jsx("div",{className:"pvx-loading",children:"Loading..."})}function Ge(){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 ze(){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 Ye({tracks:s,isLoading:r,carMetadata:n,getUserDisplay:t,onTrackSelect:a,tags:i,onTagChange:o}){const[l,x]=K({key:"record.timestamp",dir:"desc"}),{activeTags:c,toggle:d,clear:m}=xe(i,o),h=N.useMemo(()=>{var j;if(!((j=n==null?void 0:n.tags)!=null&&j.length))return[];const p=new Set;for(const v of s||[])v.recordByTag&&Object.keys(v.recordByTag).forEach(g=>p.add(g));return n.tags.filter(v=>p.has(v))},[s,n]),u=N.useMemo(()=>s?c.size===0?s:s.map(p=>{var g,b;if(!p.recordByTag)return null;let j=null;const v=new Set;for(const C of Object.values(p.recordByTag)){if(v.has(C.carId))continue;v.add(C.carId);const T=((b=(g=n==null?void 0:n.cars)==null?void 0:g[C.carId])==null?void 0:b.tags)||["sports_car"];pe(T,c)&&(!j||C.lapTimeMs<j.lapTimeMs)&&(j=C)}return j?{...p,record:{visibleId:j.steamId||j.identifier,carId:j.carId,carDisplayName:L(j.carId),lapTimeMs:j.lapTimeMs,timestamp:j.recordedAt}}:null}).filter(Boolean):[],[s,c,n]),f=N.useMemo(()=>H(u,l,(p,j)=>{var v,g;switch(j){case"displayName":return p.displayName;case"record.lapTimeMs":return(v=p.record)==null?void 0:v.lapTimeMs;case"driverCount":return p.driverCount||0;case"carCount":return p.carCount||0;case"record.timestamp":default:return(g=p.record)!=null&&g.timestamp?new Date(p.record.timestamp).getTime():0}}),[u,l]);return r?e.jsx(A,{}):s!=null&&s.length?e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx("h2",{className:"pvx-card-title",children:"Track Records"})}),e.jsx(me,{availableTags:h,activeTags:c,onToggle:d,onClear:m}),e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx(w,{label:"Track",sortKey:"displayName",config:l,onSort:x}),e.jsx("th",{className:"pvx-th",children:"Record Holder"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Car"}),e.jsx(w,{label:"Lap Time",sortKey:"record.lapTimeMs",config:l,onSort:x}),e.jsx(w,{label:"Drivers",sortKey:"driverCount",config:l,onSort:x,className:"pvx-hidden-below-md"}),e.jsx(w,{label:"Cars",sortKey:"carCount",config:l,onSort:x,className:"pvx-hidden-below-lg"}),e.jsx(w,{label:"Date",sortKey:"record.timestamp",config:l,onSort:x,className:"pvx-hidden-below-xl"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:f.map(p=>{var j,v,g;return e.jsxs("tr",{className:"pvx-row pvx-row--clickable",onClick:()=>a(p.id,p.layout),children:[e.jsx("td",{className:"pvx-td pvx-td--primary",children:p.displayName}),e.jsx("td",{className:"pvx-td",children:(j=p.record)!=null&&j.visibleId?e.jsx(Q,{userId:p.record.visibleId,getUserDisplay:t}):"-"}),e.jsx("td",{className:"pvx-td pvx-hidden-below-lg",children:((v=p.record)==null?void 0:v.carDisplayName)||"-"}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:p.record?M(p.record.lapTimeMs):"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-md",children:p.driverCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",children:p.carCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-xl",children:(g=p.record)!=null&&g.timestamp?I(p.record.timestamp):"-"})]},`${p.id}|${p.layout||""}`)})})]})})]}):e.jsx(U,{message:"No lap times recorded yet."})}function Ze({entries:s,isLoading:r,track:n,carMetadata:t,getUserDisplay:a,onCarSelect:i,onNavigate:o,tags:l,onTagChange:x}){const[c,d]=K({key:"lapTimeMs",dir:"asc"}),{activeTags:m,toggle:h,clear:u}=xe(l,x),f=N.useMemo(()=>{var b,C,T;if(!s||!((b=t==null?void 0:t.tags)!=null&&b.length))return[];const g=new Set;for(const P of s)(((T=(C=t.cars)==null?void 0:C[P.carId])==null?void 0:T.tags)||["sports_car"]).forEach(Pe=>g.add(Pe));return t.tags.filter(P=>g.has(P))},[s,t]),p=N.useMemo(()=>s?m.size===0?s:s.filter(g=>{var C,T;const b=((T=(C=t==null?void 0:t.cars)==null?void 0:C[g.carId])==null?void 0:T.tags)||["sports_car"];return pe(b,m)}):[],[s,m,t]),j=N.useMemo(()=>H(p,c,(g,b)=>{switch(b){case"carId":return L(g.carId);case"driverCount":return g.driverCount||0;case"lapTimeMs":default:return g.lapTimeMs}}),[p,c]),v=[{key:"tracks",label:"Tracks",onClick:()=>o("tracks")},{key:"track",label:n.displayName}];return r?e.jsx(A,{}):e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx(se,{segments:v})}),e.jsx(me,{availableTags:f,activeTags:m,onToggle:h,onClear:u}),s!=null&&s.length?e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"#"}),e.jsx(w,{label:"Car",sortKey:"carId",config:c,onSort:d}),e.jsx("th",{className:"pvx-th",children:"Record Holder"}),e.jsx(w,{label:"Lap Time",sortKey:"lapTimeMs",config:c,onSort:d}),e.jsx(w,{label:"Drivers",sortKey:"driverCount",config:c,onSort:d,className:"pvx-hidden-below-md"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Date"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:j.map((g,b)=>e.jsxs("tr",{className:"pvx-row pvx-row--clickable",onClick:()=>i(g.carId),children:[e.jsx("td",{className:"pvx-td",children:e.jsx(ee,{rank:b+1,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:L(g.carId)}),e.jsx("td",{className:"pvx-td",children:e.jsx(Q,{userId:g.steamId||g.userId,getUserDisplay:a})}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:M(g.lapTimeMs)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-md",children:g.driverCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-lg",children:g.recordedAt?I(g.recordedAt):"-"})]},g.carId))})]})}):e.jsx(U,{message:"No lap times for this track yet."})]})}function Je({entries:s,isLoading:r,track:n,carId:t,getUserDisplay:a,onDriverSelect:i,onNavigate:o,highlightId:l}){const[x,c]=K({key:"lapTimeMs",dir:"asc"}),d=N.useMemo(()=>ue(s),[s]),m=N.useMemo(()=>H(s||[],x,(u,f)=>{switch(f){case"userId":return a(u.steamId||u.userId).displayName;case"lapCount":return u.lapCount||0;case"lapTimeMs":default:return u.lapTimeMs}}),[s,x,a]),h=[{key:"tracks",label:"Tracks",onClick:()=>o("tracks")},{key:"track",label:n.displayName,onClick:()=>o("track")},{key:"car",label:L(t)}];return r?e.jsx(A,{}):e.jsxs("div",{className:"pvx-card",children:[e.jsx("div",{className:"pvx-card-header",children:e.jsx(se,{segments:h})}),s!=null&&s.length?e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"#"}),e.jsx(w,{label:"Driver",sortKey:"userId",config:x,onSort:c}),e.jsx(w,{label:"Lap Time",sortKey:"lapTimeMs",config:x,onSort:c}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S1"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S2"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S3"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Tyre"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-xl",children:"Fuel"}),e.jsx(w,{label:"Laps",sortKey:"lapCount",config:x,onSort:c,className:"pvx-hidden-below-lg"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-xl",children:"Date"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:m.map((u,f)=>{const p=f+1,j=u.steamId||u.userId,v=d&&u.sector1Ms===d.s1,g=d&&u.sector2Ms===d.s2,b=d&&u.sector3Ms===d.s3,C=l&&j===l;return e.jsxs("tr",{className:`pvx-row pvx-row--clickable ${C?"pvx-row--highlight":p<=3?"pvx-row--podium":""}`,onClick:()=>i(j),children:[e.jsx("td",{className:"pvx-td",children:e.jsx(ee,{rank:p,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:e.jsx(Q,{userId:j,getUserDisplay:a})}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:M(u.lapTimeMs)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${v?"pvx-td--best-sector":""}`,children:S(u.sector1Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${g?"pvx-td--best-sector":""}`,children:S(u.sector2Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${b?"pvx-td--best-sector":""}`,children:S(u.sector3Ms)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",title:z(u.tyreCompound),children:u.tyreCompound||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-xl",children:u.startingFuelL?`${u.startingFuelL}L`:"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",children:u.lapCount||"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-xl",children:u.recordedAt?I(u.recordedAt):"-"})]},j)})})]})}):e.jsx(U,{message:"No lap times for this car yet."})]})}function Xe({userId:s,track:r,carId:n,game:t,gameVersion:a,showInvalid:i,getUserDisplay:o,onToggleInvalid:l,onNavigate:x}){const{data:c,driverName:d,isLoading:m}=ie(s,r.id,r.layout,n,{showInvalid:i,game:t,gameVersion:a}),{displayName:h,avatarUrl:u}=o(s,d),f=N.useMemo(()=>ue(c,!0),[c]),p=N.useMemo(()=>{const v=(c==null?void 0:c.filter(g=>g.isValid))||[];return v.length?Math.min(...v.map(g=>g.lapTimeMs)):null},[c]),j=[{key:"tracks",label:"Tracks",onClick:()=>x("tracks")},{key:"track",label:r.displayName,onClick:()=>x("track")},{key:"car",label:L(n),onClick:()=>x("car")},{key:"driver",label:h}];return m?e.jsx(A,{}):e.jsxs("div",{className:"pvx-card",children:[e.jsxs("div",{className:"pvx-card-header pvx-card-header--split",children:[e.jsxs("div",{className:"pvx-card-header-left",children:[e.jsx(se,{segments:j}),u?e.jsx("img",{src:u,alt:"",className:"pvx-driver-avatar pvx-driver-avatar--lg"}):e.jsx("span",{className:"pvx-driver-avatar pvx-driver-avatar--lg pvx-driver-avatar--placeholder"})]}),e.jsxs("label",{className:"pvx-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:l,className:"pvx-checkbox"}),e.jsx("span",{children:"Show invalid laps"})]})]}),c!=null&&c.length?e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"#"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-md",children:"Lap"}),e.jsx("th",{className:"pvx-th",children:"Lap Time"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S1"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S2"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"S3"}),e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"Valid"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Tyre"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-lg",children:"Fuel"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-xl",children:"Date"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:c.map((v,g)=>{const b=v.isValid&&v.lapTimeMs===p,C=f&&v.isValid&&v.sector1Ms===f.s1,T=f&&v.isValid&&v.sector2Ms===f.s2,P=f&&v.isValid&&v.sector3Ms===f.s3;let E="pvx-row";return v.isValid||(E+=" pvx-row--invalid"),b&&(E+=" pvx-row--personal-best"),e.jsxs("tr",{className:E,children:[e.jsx("td",{className:"pvx-td",children:e.jsx("span",{className:`pvx-rank ${b?"pvx-rank--gold":""}`,children:g+1})}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-md",children:v.lapNumber||"-"}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:M(v.lapTimeMs)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${C?"pvx-td--best-sector":""}`,children:S(v.sector1Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${T?"pvx-td--best-sector":""}`,children:S(v.sector2Ms)}),e.jsx("td",{className:`pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${P?"pvx-td--best-sector":""}`,children:S(v.sector3Ms)}),e.jsx("td",{className:"pvx-td",title:v.isValid?void 0:v.invalidReason||"Invalid",children:v.isValid?e.jsx(Ge,{}):e.jsx(ze,{})}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",title:z(v.tyreCompound),children:v.tyreCompound||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-lg",children:v.startingFuelL?`${v.startingFuelL}L`:"-"}),e.jsx("td",{className:"pvx-td pvx-td--muted pvx-hidden-below-xl",children:I(v.timestamp)})]},v.id)})})]})}):e.jsx(U,{message:i?"No laps recorded for this combination.":'No valid laps. Try enabling "Show invalid laps".'})]})}function es({drivers:s,isLoading:r,getUserDisplay:n,game:t,gameVersion:a,onComboSelect:i}){const[o,l]=K({key:"rank",dir:"asc"}),[x,c]=N.useState(null),d=N.useMemo(()=>s?H(s,o,(h,u)=>{switch(u){case"rating":return h.rating;case"comboCount":return h.comboCount||0;case"distinctCars":return h.distinctCars||0;case"rank":default:return h.rank}}):[],[s,o]);if(r)return e.jsx(A,{});if(!(s!=null&&s.length))return e.jsx("div",{className:"pvx-card",children:e.jsx(U,{message:"Not enough data for rankings yet."})});const m=5;return e.jsxs("div",{className:"pvx-card",children:[e.jsxs("div",{className:"pvx-card-header pvx-rankings-header",children:[e.jsx("h2",{className:"pvx-card-title",children:"Driver Rankings"}),e.jsxs("div",{className:"pvx-rankings-info-trigger",children:[e.jsx("svg",{className:"pvx-rankings-info-icon",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"})}),e.jsxs("div",{className:"pvx-rankings-info-tooltip",children:[e.jsx("p",{className:"pvx-rankings-info-title",children:"How ratings work"}),e.jsxs("ul",{className:"pvx-rankings-info-list",children:[e.jsx("li",{children:"For each car/track combo with 3+ drivers, you're ranked by lap time and given a percentile (100 = fastest, 0 = slowest)"}),e.jsx("li",{children:"Your rating is a weighted average across all your combos — bigger fields count more"}),e.jsx("li",{children:"A confidence adjustment rewards car diversity: the more different cars you drive competitively, the closer your rating reflects your true score"}),e.jsx("li",{children:"Minimum 2 qualifying combos required"})]})]})]})]}),e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx(w,{label:"#",sortKey:"rank",config:o,onSort:l,className:"pvx-th--narrow"}),e.jsx("th",{className:"pvx-th",children:"Driver"}),e.jsx(w,{label:"Rating",sortKey:"rating",config:o,onSort:l}),e.jsx(w,{label:"Cars",sortKey:"distinctCars",config:o,onSort:l,className:"pvx-hidden-below-sm"}),e.jsx(w,{label:"Combos",sortKey:"comboCount",config:o,onSort:l,className:"pvx-hidden-below-sm"})]})}),e.jsx("tbody",{className:"pvx-tbody",children:d.map(h=>{const u=x===h.identifier;return e.jsx(ss,{driver:h,getUserDisplay:n,isExpanded:u,onToggle:()=>c(u?null:h.identifier),colCount:m,game:t,gameVersion:a,onComboSelect:i},h.identifier)})})]})})]})}function ss({driver:s,getUserDisplay:r,isExpanded:n,onToggle:t,colCount:a,game:i,gameVersion:o,onComboSelect:l}){const x=s.identifier;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:`pvx-row pvx-row--clickable ${s.rank<=3?"pvx-row--podium":""}`,onClick:t,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(ee,{rank:s.rank,podium:!0})}),e.jsx("td",{className:"pvx-td pvx-td--primary",children:e.jsx(Q,{userId:x,getUserDisplay:r})}),e.jsx("td",{className:"pvx-td pvx-td--primary pvx-td--mono",children:s.rating.toFixed(1)}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-sm",children:s.distinctCars||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-sm",children:e.jsxs("span",{className:"pvx-rankings-combo-count",children:[s.comboCount,e.jsx("svg",{className:`pvx-rankings-chevron ${n?"pvx-rankings-chevron--open":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]})})]}),n&&s.combos&&e.jsx("tr",{children:e.jsx("td",{colSpan:a,className:"pvx-rankings-combos-cell",children:e.jsx("div",{className:"pvx-rankings-combos",children:s.combos.map((c,d)=>{const m=c.layout?`${c.trackId}|${c.layout}`:c.trackId,h=l?()=>l({track:m,car:c.carId,highlight:x,game:i,gameVersion:o}):void 0;return e.jsxs("div",{className:`pvx-rankings-combo ${h?"pvx-rankings-combo--clickable":""}`,onClick:h,role:h?"button":void 0,children:[e.jsxs("div",{className:"pvx-rankings-combo-info",children:[e.jsx("p",{className:"pvx-rankings-combo-track",children:D(c.trackId,c.layout,i)}),e.jsx("p",{className:"pvx-rankings-combo-car",children:L(c.carId)})]}),e.jsxs("div",{className:"pvx-rankings-combo-stats",children:[e.jsx("p",{className:"pvx-rankings-combo-time",children:M(c.lapTimeMs)}),e.jsxs("p",{className:`pvx-rankings-combo-pct ${c.percentile>=75?"pvx-rankings-combo-pct--high":c.percentile>=50?"pvx-rankings-combo-pct--mid":c.percentile>=25?"pvx-rankings-combo-pct--low":"pvx-rankings-combo-pct--bottom"}`,children:[c.percentile.toFixed(0),"%",e.jsxs("span",{className:"pvx-rankings-combo-rank",children:["(",c.rank,"/",c.totalDrivers,")"]})]})]})]},d)})})})})]})}const rs={GBR:"🇬🇧",DEU:"🇩🇪",NLD:"🇳🇱",SWE:"🇸🇪",ESP:"🇪🇸",ZAF:"🇿🇦",FRA:"🇫🇷",ITA:"🇮🇹",USA:"🇺🇸",AUS:"🇦🇺",BRA:"🇧🇷",JPN:"🇯🇵",CAN:"🇨🇦",POL:"🇵🇱",AUT:"🇦🇹",BEL:"🇧🇪",PRT:"🇵🇹",NOR:"🇳🇴",DNK:"🇩🇰",FIN:"🇫🇮",IRL:"🇮🇪",CHE:"🇨🇭",NZL:"🇳🇿",MEX:"🇲🇽",ARG:"🇦🇷",CZE:"🇨🇿",HUN:"🇭🇺",RUS:"🇷🇺",TUR:"🇹🇷",KOR:"🇰🇷"},ve=["🥇","🥈","🥉"],ts={championship:"Championship",series:"Series",event:"Event"},re=["PRACTICE","QUALIFYING","RACE"];function he({position:s}){const r=s===1?"pvx-rank pvx-rank--gold":s===2?"pvx-rank pvx-rank--silver":s===3?"pvx-rank pvx-rank--bronze":"pvx-rank";return e.jsx("span",{className:r,children:s})}function ge({nation:s}){const r=s&&rs[s];return r?e.jsx("span",{className:"pvx-nation-flag",title:s,children:r}):null}function ns({sessions:s,activeSession:r,onSelect:n}){if(!s||s.length<=1)return null;const t=[...s].sort((a,i)=>re.indexOf(a.type)-re.indexOf(i.type));return e.jsx("div",{className:"pvx-session-tabs",children:t.map(a=>e.jsx("button",{onClick:()=>n(a.type),className:`pvx-session-tab ${r===a.type?"pvx-session-tab--active":""}`,children:a.type},a.type))})}function je({type:s}){return e.jsx("span",{className:`pvx-comp-badge pvx-comp-badge--${s}`,children:ts[s]||s})}function F({children:s,variant:r="default"}){return e.jsx("span",{className:`pvx-info-pill ${r!=="default"?`pvx-info-pill--${r}`:""}`,children:s})}function as(s){if(!s)return"TBD";const r=new Date(s);if(isNaN(r))return"TBD";const n=r.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"}),t=r.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} • ${t}`}function is(s){return s.reduce((r,n)=>{var t;return(t=n.splits)!=null&&t.length?r?r.map((a,i)=>{const o=n.splits[i];return o&&o<a?o:a}):[...n.splits]:r},null)}function B({message:s="Loading..."}){return e.jsx("div",{className:"pvx-loading",children:s})}function $({message:s="No data available."}){return e.jsx("div",{className:"pvx-empty",children:e.jsx("p",{children:s})})}function os({competitions:s,isLoading:r,onSelect:n,onRegister:t,className:a}){return r?e.jsx(B,{message:"Loading competitions..."}):s!=null&&s.length?e.jsx("div",{className:`pvx-comp-grid ${a||""}`,children:s.map(i=>e.jsx(cs,{comp:i,onSelect:n,onRegister:t||n},i.id))}):e.jsx($,{message:"No competitions available."})}function cs({comp:s,onSelect:r,onRegister:n}){var p,j,v;const{cdnUrl:t}=k(),a=s.posterCdnPath?`${t}/${s.posterCdnPath}`:null,i=s.registration,o=(i==null?void 0:i.currentCount)||0,l=i==null?void 0:i.maxParticipants,x=l&&o>=l,c=(i==null?void 0:i.deadline)&&new Date(i.deadline)<new Date,d=(i==null?void 0:i.isOpen)&&!c&&!x,m=new Date,h=(p=s.rounds)==null?void 0:p.find(g=>g.startTime&&new Date(g.startTime)>=m),u=((j=s.rounds)==null?void 0:j.length)||0,f=((v=s.rounds)==null?void 0:v.filter(g=>g.isFinalized).length)||0;return e.jsxs("div",{className:"pvx-comp-card",onClick:()=>r(s.id),role:"button",tabIndex:0,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),r(s.id))},children:[e.jsx("div",{className:"pvx-comp-card-poster",children:a?e.jsx("img",{src:a,alt:s.name,className:"pvx-comp-card-poster-img"}):e.jsx("div",{className:"pvx-comp-card-poster-placeholder",children:e.jsx(ds,{})})}),e.jsxs("div",{className:"pvx-comp-card-body",children:[e.jsx("h3",{className:"pvx-comp-card-title",children:s.name}),s.description&&e.jsx("p",{className:"pvx-comp-card-desc",children:s.description}),e.jsxs("div",{className:"pvx-comp-card-pills",children:[e.jsx(je,{type:s.type}),s.game&&e.jsx(F,{children:s.game.toUpperCase()}),s.formatDescription&&s.formatDescription.split(", ").map((g,b)=>e.jsx(F,{variant:"format",children:g},b))]}),s.carsDescription&&e.jsx("div",{className:"pvx-comp-card-pills",children:s.carsDescription.split(", ").map((g,b)=>e.jsx(F,{children:g},b))}),e.jsxs("div",{className:"pvx-comp-card-schedule",children:[h?e.jsxs("span",{className:"pvx-comp-card-schedule-next",children:[e.jsx("span",{className:"pvx-comp-card-schedule-label",children:"Next:"})," ","R",h.roundNumber," ",h.track||"TBD"," — ",as(h.startTime)]}):u>0?e.jsxs("span",{className:"pvx-comp-card-schedule-next",children:[f,"/",u," rounds completed"]}):null,u>0&&e.jsxs("span",{className:"pvx-comp-card-round-count",children:[u," round",u!==1?"s":""]})]}),i&&e.jsx(ls,{competitionId:s.id,regOpen:d,isFull:x,deadlinePassed:c,regCount:o,regMax:l,onRegister:n})]})]})}function ls({competitionId:s,regOpen:r,isFull:n,deadlinePassed:t,regCount:a,regMax:i,onRegister:o}){const{isPowerMode:l}=q(),x=V(s),{data:c}=_(s),d=(c==null?void 0:c.isRegistered)||!1,m=i?a/i*100:0,h=m>=100?"full":m>=75?"warning":"ok";return e.jsxs("div",{className:"pvx-comp-card-reg",children:[e.jsx("div",{className:"pvx-comp-card-reg-info",children:e.jsxs("span",{className:`pvx-reg-capacity pvx-reg-capacity--${h}`,children:[a,"/",i||"∞"," drivers"]})}),e.jsx("div",{className:"pvx-comp-card-reg-action",children:d?e.jsx("button",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--registered",onClick:u=>{u.stopPropagation(),o(s)},children:"✓ Registered"}):r?l?e.jsx("button",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--open",onClick:u=>{u.stopPropagation(),o(s)},children:"Register"}):e.jsx("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--open",onClick:u=>u.stopPropagation(),children:"Register"}):e.jsx("span",{className:"pvx-comp-card-reg-btn pvx-comp-card-reg-btn--closed",children:n?"Full":"Closed"})})]})}function ds(){return e.jsxs("svg",{className:"pvx-comp-trophy-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6"}),e.jsx("path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18"}),e.jsx("path",{d:"M4 22h16"}),e.jsx("path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22"}),e.jsx("path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22"}),e.jsx("path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z"})]})}function ps({competitionId:s,className:r}){var l,x;const{data:n,isLoading:t}=ce(s),{data:a,isLoading:i}=oe(s);if(t||i)return e.jsx(B,{message:"Loading standings..."});if(!((l=n==null?void 0:n.standings)!=null&&l.length))return e.jsx($,{message:"No standings data yet. Results will appear once rounds are finalised."});const o=((x=a==null?void 0:a.rounds)==null?void 0:x.filter(c=>c.isFinalized))||[];return e.jsxs("div",{className:`pvx-card ${r||""}`,children:[e.jsx("div",{className:"pvx-card-header--split",children:e.jsxs("div",{className:"pvx-card-header-left",children:[e.jsx("h3",{className:"pvx-card-title",children:"Championship Standings"}),e.jsxs("span",{className:"pvx-standings-subtitle",children:["After ",n.roundsCompleted," round",n.roundsCompleted!==1?"s":"",n.countingRounds>0&&` (best ${n.countingRounds} count)`]})]})}),e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"Pos"}),e.jsx("th",{className:"pvx-th",children:"Driver"}),e.jsx("th",{className:"pvx-th pvx-th--center pvx-hidden-below-sm",children:"W"}),e.jsx("th",{className:"pvx-th pvx-th--center pvx-hidden-below-sm",children:"Pod"}),e.jsx("th",{className:"pvx-th pvx-th--center",children:"Points"}),o.map(c=>e.jsxs("th",{className:"pvx-th pvx-th--center pvx-hidden-below-md",title:c.track||`Round ${c.roundNumber}`,children:["R",c.roundNumber]},c.roundNumber))]})}),e.jsx("tbody",{className:"pvx-tbody",children:n.standings.map(c=>e.jsx(xs,{driver:c,finalizedRounds:o},c.driverId||c.driverName))})]})})]})}function xs({driver:s,finalizedRounds:r}){var o,l,x;const n=s.position<=3,t=new Map(((o=s.roundResults)==null?void 0:o.map(c=>[c.roundNumber,c]))||[]),a=((l=s.roundResults)==null?void 0:l.filter(c=>c.position===1).length)||0,i=((x=s.roundResults)==null?void 0:x.filter(c=>c.position<=3).length)||0;return e.jsxs("tr",{className:`pvx-row ${n?"pvx-row--podium":""}`,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(he,{position:s.position})}),e.jsxs("td",{className:"pvx-td pvx-td--primary",children:[e.jsx(ge,{nation:s.nation}),s.driverName]}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-sm",children:a||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-hidden-below-sm",children:i||"-"}),e.jsx("td",{className:"pvx-td pvx-td--center pvx-standings-total",children:s.totalPoints}),r.map(c=>{const d=t.get(c.roundNumber),m=d==null?void 0:d.dropped;return e.jsx("td",{className:`pvx-td pvx-td--center pvx-hidden-below-md ${!m&&(d==null?void 0:d.position)<=3?"pvx-standings-cell--podium":""}`,children:d?e.jsxs("div",{className:`pvx-standings-round-cell ${m?"pvx-standings-round-cell--dropped":""}`,children:[e.jsxs("span",{className:"pvx-standings-round-pos",children:["P",d.position]}),e.jsx("span",{className:"pvx-standings-round-pts",children:d.points})]}):e.jsx("span",{className:"pvx-td--muted",children:"-"})},c.roundNumber)})]})}function us({competitionId:s,roundNumber:r,className:n}){var x;const{data:t,isLoading:a}=le(s,r);if(a)return e.jsx(B,{message:"Loading results..."});if(!t)return e.jsx($,{message:"No results for this round."});const o=(t.sessions||[]).find(c=>c.type==="RACE"),l=(x=o==null?void 0:o.results)==null?void 0:x.filter(c=>c.position<=3).sort((c,d)=>c.position-d.position);return e.jsxs("div",{className:`pvx-round-results ${n||""}`,children:[e.jsxs("div",{className:"pvx-round-results-header",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"pvx-round-results-title",children:["Round ",t.roundNumber,t.track?`: ${t.track}`:""]}),t.startTime&&e.jsx("p",{className:"pvx-round-results-date",children:new Date(t.startTime).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})})]}),(l==null?void 0:l.length)>0&&e.jsx("div",{className:"pvx-round-podium-summary",children:l.map(c=>e.jsxs("span",{className:"pvx-round-podium-item",children:[e.jsx("span",{children:ve[c.position-1]}),e.jsx("span",{children:c.driverName})]},c.driverId))})]}),e.jsx(fe,{round:t})]})}function fe({round:s,className:r}){var l,x;const[n,t]=N.useState(null),a=(s==null?void 0:s.sessions)||[];if(!a.length)return e.jsx($,{message:"No session data for this round."});const i=n||((l=a.find(c=>c.type==="RACE"))==null?void 0:l.type)||((x=a[0])==null?void 0:x.type),o=a.find(c=>c.type===i)||a[0];return e.jsxs("div",{className:r||"",children:[e.jsx(ns,{sessions:a,activeSession:i,onSelect:t}),e.jsx(ms,{session:o})]})}function ms({session:s}){var t;const r=s.type==="RACE";if(!((t=s.results)!=null&&t.length))return e.jsx($,{message:`No results for ${s.type}.`});const n=is(s.results);return e.jsx("div",{className:"pvx-table-scroll",children:e.jsxs("table",{className:"pvx-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"pvx-thead-row",children:[e.jsx("th",{className:"pvx-th pvx-th--narrow",children:"Pos"}),e.jsx("th",{className:"pvx-th",children:"Driver"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Car"}),e.jsx("th",{className:"pvx-th",children:"Best Lap"}),r&&e.jsxs(e.Fragment,{children:[e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Laps"}),e.jsx("th",{className:"pvx-th pvx-hidden-below-sm",children:"Time / Gap"}),e.jsx("th",{className:"pvx-th pvx-th--center",children:"Points"})]})]})}),e.jsx("tbody",{className:"pvx-tbody",children:s.results.map((a,i)=>e.jsx(vs,{result:a,isRace:r,fastestSplits:n,rowIndex:i},a.driverId||i))})]})})}function vs({result:s,isRace:r,fastestSplits:n,rowIndex:t}){const a=s.position<=3;return e.jsxs("tr",{className:`pvx-row ${a?"pvx-row--podium":""}`,children:[e.jsx("td",{className:"pvx-td",children:e.jsx(he,{position:s.position})}),e.jsxs("td",{className:"pvx-td pvx-td--primary",children:[e.jsx(ge,{nation:s.nation}),s.driverName,s.carNumber!=null&&e.jsxs("span",{className:"pvx-car-number",children:["#",s.carNumber]}),s.penalty&&e.jsx("span",{className:"pvx-penalty",children:s.penalty})]}),e.jsx("td",{className:"pvx-td pvx-hidden-below-sm",children:L(s.carId)}),e.jsx("td",{className:"pvx-td pvx-td--mono",children:e.jsx(hs,{bestLap:s.bestLapFormatted,hasBestLap:s.hasBestLap,splits:s.splits,fastestSplits:n,showAbove:t<=1})}),r&&e.jsxs(e.Fragment,{children:[e.jsx("td",{className:"pvx-td pvx-hidden-below-sm",children:s.lapsCompleted}),e.jsx("td",{className:"pvx-td pvx-td--mono pvx-td--muted pvx-hidden-below-sm",children:s.position===1?s.totalTime||"-":s.gap||"-"}),e.jsxs("td",{className:"pvx-td pvx-td--center",children:[e.jsx("span",{className:"pvx-session-points",children:s.points}),s.pointsOverride!==0&&s.pointsOverride&&e.jsxs("span",{className:"pvx-points-override",children:["(",s.pointsOverride>0?"+":"",s.pointsOverride,")"]})]})]})]})}function hs({bestLap:s,hasBestLap:r,splits:n,fastestSplits:t,showAbove:a}){return s?e.jsxs("span",{className:`pvx-best-lap-cell ${r?"pvx-best-lap-cell--fastest":""}`,children:[e.jsx("span",{className:"pvx-best-lap-time",children:s}),(n==null?void 0:n.length)>0&&e.jsx("span",{className:"pvx-splits-tooltip-anchor",children:e.jsx("span",{className:`pvx-splits-tooltip ${a?"":"pvx-splits-tooltip--above"}`,children:n.map((i,o)=>{const l=t&&i===t[o];return e.jsxs("span",{className:"pvx-splits-tooltip-row",children:[e.jsxs("span",{className:"pvx-splits-tooltip-label",children:["S",o+1]}),e.jsx("span",{className:l?"pvx-splits-tooltip-best":"",children:i})]},o)})})})]}):e.jsx("span",{className:"pvx-td--muted",children:"-"})}function gs({competitionId:s,className:r}){const{getSteamId:n}=k(),{data:t,isLoading:a}=Z(s),i=n();if(a)return e.jsx(B,{message:"Loading drivers..."});const o=(t==null?void 0:t.drivers)||(t==null?void 0:t.entries)||[];return o.length?e.jsx("div",{className:`pvx-entry-grid ${r||""}`,children:o.map(l=>{var c,d;const x=i&&l.steamId===i;return e.jsxs("div",{className:`pvx-entry-card ${x?"pvx-entry-card--you":""}`,children:[l.avatarUrl?e.jsx("img",{src:l.avatarUrl,alt:"",className:"pvx-entry-avatar"}):e.jsx("div",{className:"pvx-entry-avatar pvx-entry-avatar--placeholder",children:((d=(c=l.displayName)==null?void 0:c.charAt(0))==null?void 0:d.toUpperCase())||"?"}),e.jsxs("span",{className:"pvx-entry-name",children:[l.displayName,x&&e.jsx("span",{className:"pvx-entry-you",children:" (you)"})]})]},l.steamId||l.driverId)})}):e.jsx($,{message:"No drivers registered yet."})}function js({competitionId:s,driverData:r,className:n,children:t}){const{data:a,isLoading:i}=_(s),{isPowerMode:o}=q(),l=V(s),x=J(s),c=X(s),d=(a==null?void 0:a.isRegistered)||!1,m=i||x.isPending||c.isPending,h=x.error||c.error||null,u=()=>{o&&x.mutate(r||{})},f=()=>{o&&c.mutate()};return typeof t=="function"?t({isRegistered:d,isLoading:m,register:u,withdraw:f,error:h,isPowerMode:o,registrationUrl:l}):o?e.jsx("button",{className:`pvx-comp-register-btn ${n||""}`,onClick:d?f:u,disabled:m,children:m?"Loading...":d?"Withdraw":"Register"}):e.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:`pvx-comp-register-link ${n||""}`,children:d?"View Registration":"Register on PitVox"})}function fs({competitionId:s,registration:r,onWithdrawSuccess:n,className:t}){const{getSteamId:a}=k(),{isPowerMode:i}=q(),o=V(s),{data:l,isLoading:x}=_(s),{data:c,isLoading:d}=Z(s),m=J(s),h=X(s),u=a(),f=(l==null?void 0:l.isRegistered)||!1,p=(c==null?void 0:c.drivers)||(c==null?void 0:c.entries)||[],j=r||{},v=p.length||j.currentCount||0,g=j.maxParticipants&&v>=j.maxParticipants,b=j.deadline&&new Date(j.deadline)<new Date,C=j.isOpen&&!b&&!g;return x||d?e.jsx(B,{message:"Loading registration..."}):f?e.jsx("div",{className:`pvx-reg-panel ${t||""}`,children:e.jsx(bs,{competitionId:s,drivers:p,steamId:u,isPowerMode:i,registrationUrl:o,withdrawMutation:h,onWithdrawSuccess:n,registration:j})}):C?u?i?e.jsx("div",{className:`pvx-reg-panel ${t||""}`,children:e.jsx(Ns,{competitionId:s,registerMutation:m,registration:j})}):e.jsx("div",{className:`pvx-reg-panel ${t||""}`,children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-register-link",children:"Register on PitVox"})}):e.jsx("div",{className:`pvx-reg-panel ${t||""}`,children:i?e.jsx("div",{className:"pvx-reg-status-msg",children:"Sign in to register for this competition."}):e.jsx("div",{className:"pvx-reg-status-msg",children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-register-link",children:"Register on PitVox"})})}):e.jsxs("div",{className:`pvx-reg-panel ${t||""}`,children:[e.jsx("div",{className:"pvx-reg-status-msg",children:g?"Registration is full.":b?"Registration deadline has passed.":"Registration is closed."}),p.length>0&&e.jsx(Ne,{drivers:p,steamId:u})]})}function Ns({competitionId:s,registerMutation:r,registration:n}){const[t,a]=N.useState(""),[i,o]=N.useState("intermediate"),[l,x]=N.useState(""),c=u=>{u.preventDefault(),r.mutate({discordUsername:t||void 0,experience:i,comments:l||void 0})},d=n||{},m=d.currentCount||0,h=d.maxParticipants;return e.jsxs("form",{className:"pvx-reg-form",onSubmit:c,children:[e.jsxs("div",{className:"pvx-reg-form-header",children:[e.jsx("h3",{className:"pvx-reg-form-title",children:"Register"}),h&&e.jsx(be,{count:m,max:h})]}),r.error&&e.jsx("div",{className:"pvx-reg-error",children:r.error.message||"Registration failed"}),e.jsxs("div",{className:"pvx-reg-field",children:[e.jsxs("label",{className:"pvx-reg-label",htmlFor:`pvx-discord-${s}`,children:["Discord Username ",e.jsx("span",{className:"pvx-reg-optional",children:"(optional)"})]}),e.jsx("input",{id:`pvx-discord-${s}`,type:"text",className:"pvx-reg-input",placeholder:"e.g. username",value:t,onChange:u=>a(u.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:u=>o(u.target.value),children:[e.jsx("option",{value:"beginner",children:"Beginner"}),e.jsx("option",{value:"intermediate",children:"Intermediate"}),e.jsx("option",{value:"advanced",children:"Advanced"})]})]}),e.jsxs("div",{className:"pvx-reg-field",children:[e.jsxs("label",{className:"pvx-reg-label",htmlFor:`pvx-comments-${s}`,children:["Comments ",e.jsx("span",{className:"pvx-reg-optional",children:"(optional)"})]}),e.jsx("textarea",{id:`pvx-comments-${s}`,className:"pvx-reg-textarea",rows:3,placeholder:"Anything the organisers should know?",value:l,onChange:u=>x(u.target.value)})]}),e.jsx("div",{className:"pvx-reg-actions",children:e.jsx("button",{type:"submit",className:"pvx-comp-register-btn",disabled:r.isPending,children:r.isPending?"Registering...":"Register"})})]})}function bs({competitionId:s,drivers:r,steamId:n,isPowerMode:t,registrationUrl:a,withdrawMutation:i,onWithdrawSuccess:o,registration:l}){const[x,c]=N.useState(!1),d=()=>{i.mutate(void 0,{onSuccess:()=>{c(!1),o&&o()}})},m=l||{},h=r.length||m.currentCount||0,u=m.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"}),u&&e.jsx(be,{count:h,max:u})]}),e.jsx(Ne,{drivers:r,steamId:n}),i.error&&e.jsx("div",{className:"pvx-reg-error",children:i.error.message||"Withdrawal failed"}),t?e.jsx("div",{className:"pvx-reg-actions",children:x?e.jsxs("div",{className:"pvx-reg-confirm",children:[e.jsx("p",{className:"pvx-reg-confirm-text",children:"Are you sure you want to unregister?"}),e.jsxs("div",{className:"pvx-reg-confirm-actions",children:[e.jsx("button",{type:"button",className:"pvx-reg-cancel-btn",onClick:()=>c(!1),children:"Cancel"}),e.jsx("button",{type:"button",className:"pvx-reg-danger-btn",onClick:d,disabled:i.isPending,children:i.isPending?"Unregistering...":"Yes, Unregister"})]})]}):e.jsx("button",{type:"button",className:"pvx-reg-unregister-btn",onClick:()=>c(!0),children:"Unregister"})}):e.jsx("div",{className:"pvx-reg-actions",children:e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"pvx-comp-register-link",children:"Manage on PitVox"})})]})}function Ne({drivers:s,steamId:r}){if(!s.length)return e.jsx("div",{className:"pvx-reg-no-drivers",children:"No drivers registered yet."});const n=[...s].sort((t,a)=>{const i=r&&t.steamId===r?-1:0,o=r&&a.steamId===r?-1:0;return i-o});return e.jsx("div",{className:"pvx-reg-driver-list",children:n.map(t=>{var i,o;const a=r&&t.steamId===r;return e.jsxs("div",{className:`pvx-reg-driver-row ${a?"pvx-reg-driver-row--you":""}`,children:[t.avatarUrl?e.jsx("img",{src:t.avatarUrl,alt:"",className:"pvx-reg-driver-avatar"}):e.jsx("div",{className:"pvx-reg-driver-avatar pvx-reg-driver-avatar--placeholder",children:((o=(i=t.displayName)==null?void 0:i.charAt(0))==null?void 0:o.toUpperCase())||"?"}),e.jsxs("span",{className:"pvx-reg-driver-name",children:[t.displayName,a&&e.jsx("span",{className:"pvx-entry-you",children:" (you)"})]})]},t.steamId||t.driverId)})})}function be({count:s,max:r}){const n=r?s/r*100:0,t=n>=100?"full":n>=75?"warning":"ok";return e.jsxs("span",{className:`pvx-reg-capacity pvx-reg-capacity--${t}`,children:[s,"/",r," drivers"]})}function ye(s){const{cdnUrl:r}=k(),n=y.useQuery({queryKey:["pitvox","laps","global",s],queryFn:()=>R(r,`laps/${s}.json`),enabled:!!s,staleTime:3e4,refetchInterval:3e4}),t=n.data;return{isLoading:n.isLoading,error:n.error,data:t?{driverName:t.driverName||"Driver",lapCount:t.lapCount||0,trackBreakdown:t.trackBreakdown||[],carBreakdown:t.carBreakdown||[],recordsHeld:t.recordsHeld||0,currentRecords:t.currentRecords||[],bestRanking:t.bestRanking??null,bestRankingTrackId:t.bestRankingTrackId??null,bestRankingLayout:t.bestRankingLayout??null,bestRankingCarId:t.bestRankingCarId??null,generatedAt:t.generatedAt}:null}}function ke(s={}){const{cdnUrl:r,partnerSlug:n}=k(),{gameVersion:t,enabled:a=!0}=s,i=t?`leaderboards/partners/${n}/v/${t}/ratings.json`:`leaderboards/partners/${n}/ratings.json`;return y.useQuery({queryKey:["pitvox","ratings",n,t||null],queryFn:()=>R(r,i),staleTime:3e4,refetchInterval:3e4,enabled:a})}function Ce(s){var t;const r=ke(),n=N.useMemo(()=>{var a;return!((a=r.data)!=null&&a.drivers)||!s?null:r.data.drivers.find(i=>i.identifier===s)||null},[(t=r.data)==null?void 0:t.drivers,s]);return{isLoading:r.isLoading,error:r.error,data:n?{rating:n.rating,rank:n.rank,totalDrivers:r.data.driverCount||r.data.drivers.length,comboCount:n.comboCount||0,distinctCars:n.distinctCars||0,combos:n.combos||[]}:null}}function ys(s={}){const r=ke(s);return{data:r.data||null,isLoading:r.isLoading,error:r.error}}function we(){const{cdnUrl:s,partnerSlug:r,getSteamId:n}=k(),t=n(),{data:a,isLoading:i}=y.useQuery({queryKey:["pitvox","competitions",r],queryFn:async()=>{const d=await R(s,"competitions/index.json");return d!=null&&d.competitions?d.competitions.filter(m=>m.partnerSlug===r):[]},staleTime:6e4}),o=(a==null?void 0:a.map(d=>d.id))||[],l=y.useQueries({queries:o.map(d=>({queryKey:["pitvox","competition",r,d,"entrylist"],queryFn:()=>R(s,`competitions/${r}/${d}/entrylist.json`),enabled:!!t&&o.length>0,staleTime:6e4}))}),x=l.some(d=>d.isLoading);return{data:N.useMemo(()=>{var h,u;if(!a||!t||x)return[];const d=new Date,m=[];for(let f=0;f<a.length;f++){const p=a[f],j=(h=l[f])==null?void 0:h.data;if(!((u=j==null?void 0:j.drivers)==null?void 0:u.some(b=>b.steamId===t)))continue;const g=p.rounds||[];for(const b of g)b.isFinalized||!b.startTime||new Date(b.startTime)<=d||m.push({competitionId:p.id,competitionName:p.name,roundNumber:b.roundNumber,track:b.track||"TBD",startTime:b.startTime})}return m.sort((f,p)=>new Date(f.startTime)-new Date(p.startTime)),m.length>0&&(m[0].isNext=!0),m},[a,t,x,l]),isLoading:i||!!t&&x}}function Re(){const{onFetchNotifications:s}=k();return!!s}function Le(s={}){const{onFetchNotifications:r,partnerSlug:n}=k(),{limit:t=20,unreadOnly:a=!1}=s;return y.useQuery({queryKey:["pitvox","notifications",n,{limit:t,unreadOnly:a}],queryFn:()=>r({limit:t,unreadOnly:a}),enabled:!!r,staleTime:3e4,refetchInterval:3e4})}function ks(){const{onFetchNotifications:s,partnerSlug:r}=k(),{data:n,isLoading:t}=y.useQuery({queryKey:["pitvox","notifications",r,{limit:1,unreadOnly:!1}],queryFn:()=>s({limit:1}),enabled:!!s,staleTime:3e4,refetchInterval:3e4,select:a=>(a==null?void 0:a.unreadCount)??0});return{count:n??0,isLoading:t}}function Te(){const{onMarkNotificationRead:s,partnerSlug:r}=k(),n=y.useQueryClient();return y.useMutation({mutationFn:t=>{if(!s)throw new Error("No onMarkNotificationRead callback provided to PitVoxPartnerProvider.");return s(t)},onSuccess:(t,a)=>{n.setQueriesData({queryKey:["pitvox","notifications",r]},i=>i!=null&&i.notifications?{...i,unreadCount:Math.max(0,(i.unreadCount||0)-1),notifications:i.notifications.map(o=>o.id===a?{...o,isRead:!0,readAt:new Date().toISOString()}:o)}:i)}})}function Se(){const{onMarkAllNotificationsRead:s,partnerSlug:r}=k(),n=y.useQueryClient();return y.useMutation({mutationFn:()=>{if(!s)throw new Error("No onMarkAllNotificationsRead callback provided to PitVoxPartnerProvider.");return s()},onSuccess:()=>{n.setQueriesData({queryKey:["pitvox","notifications",r]},t=>t!=null&&t.notifications?{...t,unreadCount:0,notifications:t.notifications.map(a=>({...a,isRead:!0,readAt:a.readAt||new Date().toISOString()}))}:t)}})}function Me({driverName:s,avatarUrl:r,memberSince:n,className:t=""}){const a=n?new Date(n).toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric"}):null;return e.jsxs("div",{className:`pvx-card pvx-dash-profile ${t}`,children:[r?e.jsx("img",{src:r,alt:"",className:"pvx-dash-profile-avatar"}):e.jsx("div",{className:"pvx-dash-profile-avatar pvx-dash-profile-avatar--placeholder",children:(s||"?")[0].toUpperCase()}),e.jsxs("div",{className:"pvx-dash-profile-info",children:[e.jsx("h2",{className:"pvx-dash-profile-name",children:s}),a&&e.jsxs("p",{className:"pvx-dash-profile-since",children:["Racing since ",a]})]})]})}function Cs(){return e.jsxs("svg",{className:"pvx-dash-stat-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),e.jsx("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),e.jsx("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),e.jsx("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function ws(){return e.jsxs("svg",{className:"pvx-dash-stat-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"}),e.jsx("path",{d:"M12 14v4"}),e.jsx("path",{d:"M10.5 12.5l-4 2.5"}),e.jsx("path",{d:"M13.5 12.5l4 2.5"})]})}function Rs(){return e.jsx("svg",{className:"pvx-dash-stat-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})}function te({icon:s,value:r,label:n,items:t,labelKey:a,countKey:i}){const[o,l]=N.useState(!1),x=N.useRef(null);N.useEffect(()=>{if(!o)return;function d(m){x.current&&!x.current.contains(m.target)&&l(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[o]);const c=t!=null&&t.length?t.slice().sort((d,m)=>m[i]-d[i]):null;return e.jsxs("div",{ref:x,className:`pvx-dash-stat-card ${c?"pvx-dash-stat-card--clickable":""}`,onClick:c?()=>l(d=>!d):void 0,children:[s,e.jsxs("div",{className:"pvx-dash-stat-content",children:[e.jsx("span",{className:"pvx-dash-stat-value",children:r}),e.jsx("span",{className:"pvx-dash-stat-label",children:n})]}),c&&e.jsx("div",{className:`pvx-dash-tooltip pvx-dash-tooltip--scrollable ${o?"pvx-dash-tooltip--open":""}`,children:c.map((d,m)=>e.jsxs("div",{className:"pvx-dash-tooltip-row",children:[e.jsx("span",{className:"pvx-dash-tooltip-label",children:d[a]}),e.jsx("span",{className:"pvx-dash-tooltip-value",children:d[i]})]},m))})]})}function $e({stats:s,rating:r,className:n=""}){if(!s)return null;const t=s.trackBreakdown.map(i=>({name:D(i.trackId,i.layout),lapCount:i.lapCount})),a=s.carBreakdown.map(i=>({name:L(i.carId),lapCount:i.lapCount}));return e.jsxs("div",{className:`pvx-dash-stats ${n}`,children:[e.jsx(te,{icon:e.jsx(Cs,{}),value:s.lapCount.toLocaleString(),label:"Total Laps",items:t,labelKey:"name",countKey:"lapCount"}),e.jsx(te,{icon:e.jsx(ws,{}),value:s.carBreakdown.length,label:"Cars Used",items:a,labelKey:"name",countKey:"lapCount"}),r&&e.jsxs("div",{className:"pvx-dash-stat-card pvx-dash-stat-card--rating",children:[e.jsx(Rs,{}),e.jsxs("div",{className:"pvx-dash-stat-content",children:[e.jsx("span",{className:"pvx-dash-stat-value",children:r.rating.toFixed(1)}),e.jsx("span",{className:"pvx-dash-stat-label",children:"Driver Rating"}),e.jsxs("span",{className:"pvx-dash-stat-sub",children:["#",r.rank," of ",r.totalDrivers]})]})]})]})}function De({records:s,className:r=""}){const n=N.useMemo(()=>s!=null&&s.length?s.slice().sort((t,a)=>{const i=t.recordedAt?new Date(t.recordedAt).getTime():0;return(a.recordedAt?new Date(a.recordedAt).getTime():0)-i}):[],[s]);return n.length?e.jsxs("div",{className:`pvx-card ${r}`,children:[e.jsx("div",{className:"pvx-card-header",children:e.jsxs("h3",{className:"pvx-card-title",children:[e.jsx("span",{className:"pvx-dash-records-icon",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 9H4.5a2.5 2.5 0 010-5H6"}),e.jsx("path",{d:"M18 9h1.5a2.5 2.5 0 000-5H18"}),e.jsx("path",{d:"M4 22h16"}),e.jsx("path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20 7 22"}),e.jsx("path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20 17 22"}),e.jsx("path",{d:"M18 2H6v7a6 6 0 0012 0V2z"})]})}),"Current Records",e.jsxs("span",{className:"pvx-dash-records-count",children:["(",n.length,")"]})]})}),e.jsx("div",{className:"pvx-dash-records-list",children:n.map((t,a)=>e.jsxs("div",{className:"pvx-dash-record-row",children:[e.jsxs("div",{className:"pvx-dash-record-info",children:[e.jsx("span",{className:"pvx-dash-record-track",children:D(t.trackId,t.layout,t.game)}),e.jsx("span",{className:"pvx-dash-record-car",children:L(t.carId)})]}),e.jsxs("div",{className:"pvx-dash-record-time",children:[e.jsx("span",{className:"pvx-dash-record-lap",children:M(t.lapTimeMs)}),e.jsxs("span",{className:`pvx-dash-game-badge pvx-dash-game-badge--${t.game||"evo"}`,children:[(t.game||"evo").toUpperCase(),t.gameVersion?` ${t.gameVersion}`:""]})]})]},a))})]}):null}function Ie({events:s,isLoading:r,className:n,limit:t=3}){if(r)return e.jsx("div",{className:"pvx-loading",children:"Loading upcoming events..."});if(!(s!=null&&s.length))return null;const a=t?s.slice(0,t):s,i=s.length-a.length;return e.jsxs("div",{className:`pvx-card ${n||""}`,children:[e.jsx("div",{className:"pvx-card-header",children:e.jsxs("h3",{className:"pvx-card-title",children:[e.jsx(Ts,{}),"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]})]}),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:Ls(o.startTime)}),o.isNext&&e.jsx("span",{className:"pvx-upcoming-badge",children:"Next"})]})]},`${o.competitionId}-${o.roundNumber}`)),i>0&&e.jsxs("div",{className:"pvx-upcoming-remaining",children:["+",i," more event",i!==1?"s":""]})]})]})}function Ls(s){const r=new Date(s).getTime()-Date.now();if(r<=0)return"Now";const n=Math.floor(r/(1e3*60*60));if(n<1)return"Less than 1 hour";if(n<24)return`in ${n}h`;const t=Math.floor(n/24);if(t===1)return"Tomorrow";if(t<7)return`in ${t} days`;if(t<30){const a=Math.floor(t/7);return`in ${a} week${a!==1?"s":""}`}return G(s)}function Ts(){return e.jsxs("svg",{className:"pvx-dash-records-icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M16 2v4M8 2v4M3 10h18"})]})}function Be({notifications:s,unreadCount:r=0,onMarkRead:n,onMarkAllRead:t,isLoading:a,className:i}){const o=Y();return a?e.jsx("div",{className:"pvx-loading",children:"Loading notifications..."}):e.jsxs("div",{className:`pvx-card ${i||""}`,children:[e.jsxs("div",{className:"pvx-card-header",children:[e.jsxs("h3",{className:"pvx-card-title",children:[e.jsx($s,{}),"Notifications",r>0&&e.jsx("span",{className:"pvx-notif-badge",children:r>99?"99+":r})]}),r>0&&t&&e.jsx("button",{className:"pvx-notif-mark-all",onClick:t,children:"Mark all read"})]}),s!=null&&s.length?e.jsx("div",{className:"pvx-notif-list",children:s.map(l=>e.jsx(Ss,{notification:l,getUserDisplay:o,onMarkRead:n},l.id))}):e.jsx("div",{className:"pvx-notif-empty",children:"No notifications"})]})}function Ss({notification:s,getUserDisplay:r,onMarkRead:n}){const t=()=>{!s.isRead&&n&&n(s.id)};return e.jsxs("button",{className:`pvx-notif-item ${s.isRead?"":"pvx-notif-item--unread"}`,onClick:t,children:[e.jsx(Ms,{type:s.type}),e.jsxs("div",{className:"pvx-notif-content",children:[e.jsx("span",{className:"pvx-notif-message",children:ne(s,r)}),e.jsx("span",{className:"pvx-notif-time",children:G(s.createdAt)})]}),!s.isRead&&e.jsx("span",{className:"pvx-notif-dot"})]})}function Ms({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 $s(){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 Ds({steamId:s,avatarUrl:r,memberSince:n,className:t=""}){const{data:a,isLoading:i,error:o}=ye(s),{data:l,isLoading:x}=Ce(s),{data:c,isLoading:d}=we(),m=Re(),{data:h,isLoading:u}=Le({limit:10}),f=Te(),p=Se();return i||x?e.jsx("div",{className:"pvx-loading",children:"Loading dashboard..."}):o?e.jsx("div",{className:"pvx-empty",children:"Failed to load dashboard data."}):a?e.jsxs("div",{className:`pvx-dash ${t}`,children:[e.jsx(Me,{driverName:a.driverName,avatarUrl:r,memberSince:n}),e.jsx($e,{stats:a,rating:l}),s&&e.jsx(Ie,{events:c,isLoading:d}),e.jsxs("div",{className:`pvx-dash-row ${m?"pvx-dash-row--2col":""}`,children:[e.jsx(De,{records:a.currentRecords}),m&&e.jsx(Be,{notifications:h==null?void 0:h.notifications,unreadCount:(h==null?void 0:h.unreadCount)||0,onMarkRead:j=>f.mutate(j),onMarkAllRead:()=>p.mutate(),isLoading:u})]})]}):e.jsx("div",{className:"pvx-empty",children:"No data available yet. Start driving to see your stats!"})}exports.CarsTable=Ze;exports.CompEmptyState=$;exports.CompLoadingState=B;exports.CompetitionCards=os;exports.DriverDashboard=Ds;exports.DriverProfile=Me;exports.DriversTable=Je;exports.EntryList=gs;exports.InfoPill=F;exports.LapHistoryTable=Xe;exports.NotificationsCard=Be;exports.PODIUM_MEDALS=ve;exports.PitVoxPartnerProvider=Ee;exports.RankingsTable=es;exports.RecordsTable=De;exports.RegisterButton=js;exports.RegistrationPanel=fs;exports.RoundResults=us;exports.RoundSessionResults=fe;exports.StandingsTable=ps;exports.StatsCards=$e;exports.TracksTable=Ye;exports.TypeBadge=je;exports.UpcomingEvents=Ie;exports.formatCarName=L;exports.formatDate=I;exports.formatDelta=Fe;exports.formatLapTime=M;exports.formatNotificationMessage=ne;exports.formatRelativeTime=G;exports.formatSectorTime=S;exports.formatTrackName=D;exports.formatTyreCompound=z;exports.useCarLeaderboard=Ve;exports.useCarMetadata=qe;exports.useCompetitionAllRounds=He;exports.useCompetitionConfig=oe;exports.useCompetitionEntryList=Z;exports.useCompetitionRound=le;exports.useCompetitionStandings=ce;exports.useCompetitions=Ke;exports.useDriverLaps=ie;exports.useDriverRating=Ce;exports.useDriverRatings=ys;exports.useDriverStats=ye;exports.useLeaderboardIndex=_e;exports.useMarkAllNotificationsRead=Se;exports.useMarkNotificationRead=Te;exports.useNotifications=Le;exports.useNotificationsEnabled=Re;exports.usePitVox=k;exports.useRegister=J;exports.useRegistrationMode=q;exports.useRegistrationStatus=_;exports.useRegistrationUrl=V;exports.useTrackLeaderboard=ae;exports.useUnreadCount=ks;exports.useUpcomingEvents=we;exports.useUserLookup=Y;exports.useWithdraw=X;
package/dist/index.js CHANGED
@@ -98,8 +98,8 @@ function $r(r) {
98
98
  return r == null ? "" : `${r >= 0 ? "+" : "-"}${(Math.abs(r) / 1e3).toFixed(3)}`;
99
99
  }
100
100
  function Me(r, n) {
101
- const { type: s, title: t, trackId: a, trackLayout: i, carId: o, game: d, data: m } = r, c = a ? A(a, i, d) : null, p = o ? S(o) : null, h = [c, p].filter(Boolean).join(" — ");
102
- return s === "RECORD_BEATEN" && h ? `${m != null && m.beatenBySteamId && n ? n(m.beatenBySteamId).displayName : "Someone"} beat your record on ${h}` : s === "RECORD_SET" && h ? `You set a new record on ${h}` : t || "New notification";
101
+ const { type: s, title: t, trackId: a, trackLayout: i, carId: o, game: d, data: m } = r, c = typeof m == "string" ? JSON.parse(m) : m, p = a ? A(a, i, d) : null, h = o ? S(o) : null, g = [p, h].filter(Boolean).join(" — ");
102
+ return s === "RECORD_BEATEN" && g ? `${c != null && c.beatenBySteamId && n ? n(c.beatenBySteamId).displayName : "Someone"} beat your record on ${g}` : s === "RECORD_SET" && g ? `You set a new record on ${g}` : t || "New notification";
103
103
  }
104
104
  function ae(r) {
105
105
  return r ? {
@@ -116,7 +116,7 @@ function ae(r) {
116
116
  }[r] || r : "Unknown";
117
117
  }
118
118
  function Mr(r = {}) {
119
- var d, m, c, p, h, f;
119
+ var d, m, c, p, h, g;
120
120
  const { cdnUrl: n, partnerSlug: s } = k(), { game: t, gameVersion: a } = r, i = C({
121
121
  queryKey: ["pitvox", "leaderboards", s, "index"],
122
122
  queryFn: () => T(n, `leaderboards/partners/${s}/index.json`),
@@ -151,11 +151,11 @@ function Mr(r = {}) {
151
151
  generatedAt: (c = i.data) == null ? void 0 : c.generatedAt,
152
152
  totalLaps: ((p = i.data) == null ? void 0 : p.totalLaps) || 0,
153
153
  totalUsers: ((h = i.data) == null ? void 0 : h.totalUsers) || 0,
154
- versions: ((f = i.data) == null ? void 0 : f.versions) || {}
154
+ versions: ((g = i.data) == null ? void 0 : g.versions) || {}
155
155
  };
156
156
  }
157
157
  function De(r, n, s = {}) {
158
- const { cdnUrl: t, partnerSlug: a } = k(), { carId: i, game: o, gameVersion: d } = s, m = n || "default", c = d ? `leaderboards/partners/${a}/v/${d}/tracks/${r}/${m}.json` : `leaderboards/partners/${a}/tracks/${r}/${m}.json`, { data: p, isLoading: h, error: f } = C({
158
+ const { cdnUrl: t, partnerSlug: a } = k(), { carId: i, game: o, gameVersion: d } = s, m = n || "default", c = d ? `leaderboards/partners/${a}/v/${d}/tracks/${r}/${m}.json` : `leaderboards/partners/${a}/tracks/${r}/${m}.json`, { data: p, isLoading: h, error: g } = C({
159
159
  queryKey: ["pitvox", "leaderboards", a, "track", r, m, d],
160
160
  queryFn: () => T(t, c),
161
161
  enabled: !!r,
@@ -168,19 +168,19 @@ function De(r, n, s = {}) {
168
168
  if (o && (b = b.filter((u) => u.game === o)), !i) {
169
169
  const u = /* @__PURE__ */ new Map(), N = /* @__PURE__ */ new Map();
170
170
  for (const x of b) {
171
- const g = x.steamId || x.userId;
172
- N.has(x.carId) || N.set(x.carId, /* @__PURE__ */ new Set()), N.get(x.carId).add(g), (!u.has(x.carId) || x.lapTimeMs < u.get(x.carId).lapTimeMs) && u.set(x.carId, x);
171
+ const f = x.steamId || x.userId;
172
+ N.has(x.carId) || N.set(x.carId, /* @__PURE__ */ new Set()), N.get(x.carId).add(f), (!u.has(x.carId) || x.lapTimeMs < u.get(x.carId).lapTimeMs) && u.set(x.carId, x);
173
173
  }
174
174
  return Array.from(u.values()).map((x) => {
175
- var g;
176
- return { ...x, driverCount: ((g = N.get(x.carId)) == null ? void 0 : g.size) || 0 };
177
- }).sort((x, g) => x.lapTimeMs - g.lapTimeMs);
175
+ var f;
176
+ return { ...x, driverCount: ((f = N.get(x.carId)) == null ? void 0 : f.size) || 0 };
177
+ }).sort((x, f) => x.lapTimeMs - f.lapTimeMs);
178
178
  }
179
179
  return b.filter((u) => u.carId === i).sort((u, N) => u.lapTimeMs - N.lapTimeMs);
180
- }, [p == null ? void 0 : p.entries, i, o]), isLoading: h, error: f };
180
+ }, [p == null ? void 0 : p.entries, i, o]), isLoading: h, error: g };
181
181
  }
182
182
  function Ie(r, n, s, t, a = {}) {
183
- var f, v;
183
+ var g, v;
184
184
  const { cdnUrl: i, partnerSlug: o } = k(), { showInvalid: d = !1, game: m, gameVersion: c } = a, p = C({
185
185
  queryKey: ["pitvox", "laps", o, r],
186
186
  queryFn: () => T(i, `laps/partners/${o}/${r}.json`),
@@ -196,7 +196,7 @@ function Ie(r, n, s, t, a = {}) {
196
196
  } else if (u.trackLayout && u.trackLayout !== "default") return !1;
197
197
  return !(u.carId !== t || m && u.game !== m || c && u.gameVersion !== c || !d && !u.isValid);
198
198
  }).sort((u, N) => u.lapTimeMs - N.lapTimeMs) : [];
199
- }, [(f = p.data) == null ? void 0 : f.laps, n, s, t, m, c, d]);
199
+ }, [(g = p.data) == null ? void 0 : g.laps, n, s, t, m, c, d]);
200
200
  return {
201
201
  ...p,
202
202
  data: h,
@@ -334,7 +334,7 @@ function ce(r) {
334
334
  { queryKey: ["pitvox", "competition", s, r, "entrylist"] },
335
335
  (c) => {
336
336
  var h;
337
- return c ? ((h = c.drivers) == null ? void 0 : h.some((f) => f.steamId === o)) ? c : { ...c, drivers: [...c.drivers || [], m] } : { drivers: [m] };
337
+ return c ? ((h = c.drivers) == null ? void 0 : h.some((g) => g.steamId === o)) ? c : { ...c, drivers: [...c.drivers || [], m] } : { drivers: [m] };
338
338
  }
339
339
  );
340
340
  }
@@ -526,22 +526,22 @@ function qe() {
526
526
  return /* @__PURE__ */ e("svg", { className: "pvx-icon pvx-icon--invalid", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) });
527
527
  }
528
528
  function Ur({ tracks: r, isLoading: n, carMetadata: s, getUserDisplay: t, onTrackSelect: a, tags: i, onTagChange: o }) {
529
- const [d, m] = H({ key: "record.timestamp", dir: "desc" }), { activeTags: c, toggle: p, clear: h } = ue(i, o), f = w(() => {
529
+ const [d, m] = H({ key: "record.timestamp", dir: "desc" }), { activeTags: c, toggle: p, clear: h } = ue(i, o), g = w(() => {
530
530
  var N;
531
531
  if (!((N = s == null ? void 0 : s.tags) != null && N.length)) return [];
532
532
  const u = /* @__PURE__ */ new Set();
533
533
  for (const x of r || [])
534
- x.recordByTag && Object.keys(x.recordByTag).forEach((g) => u.add(g));
534
+ x.recordByTag && Object.keys(x.recordByTag).forEach((f) => u.add(f));
535
535
  return s.tags.filter((x) => u.has(x));
536
536
  }, [r, s]), v = w(() => r ? c.size === 0 ? r : r.map((u) => {
537
- var g, y;
537
+ var f, y;
538
538
  if (!u.recordByTag) return null;
539
539
  let N = null;
540
540
  const x = /* @__PURE__ */ new Set();
541
541
  for (const L of Object.values(u.recordByTag)) {
542
542
  if (x.has(L.carId)) continue;
543
543
  x.add(L.carId);
544
- const $ = ((y = (g = s == null ? void 0 : s.cars) == null ? void 0 : g[L.carId]) == null ? void 0 : y.tags) || ["sports_car"];
544
+ const $ = ((y = (f = s == null ? void 0 : s.cars) == null ? void 0 : f[L.carId]) == null ? void 0 : y.tags) || ["sports_car"];
545
545
  pe($, c) && (!N || L.lapTimeMs < N.lapTimeMs) && (N = L);
546
546
  }
547
547
  return N ? {
@@ -555,7 +555,7 @@ function Ur({ tracks: r, isLoading: n, carMetadata: s, getUserDisplay: t, onTrac
555
555
  }
556
556
  } : null;
557
557
  }).filter(Boolean) : [], [r, c, s]), b = w(() => O(v, d, (u, N) => {
558
- var x, g;
558
+ var x, f;
559
559
  switch (N) {
560
560
  case "displayName":
561
561
  return u.displayName;
@@ -567,12 +567,12 @@ function Ur({ tracks: r, isLoading: n, carMetadata: s, getUserDisplay: t, onTrac
567
567
  return u.carCount || 0;
568
568
  case "record.timestamp":
569
569
  default:
570
- return (g = u.record) != null && g.timestamp ? new Date(u.record.timestamp).getTime() : 0;
570
+ return (f = u.record) != null && f.timestamp ? new Date(u.record.timestamp).getTime() : 0;
571
571
  }
572
572
  }), [v, d]);
573
573
  return n ? /* @__PURE__ */ e(_, {}) : r != null && r.length ? /* @__PURE__ */ l("div", { className: "pvx-card", children: [
574
574
  /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ e("h2", { className: "pvx-card-title", children: "Track Records" }) }),
575
- /* @__PURE__ */ e(ve, { availableTags: f, activeTags: c, onToggle: p, onClear: h }),
575
+ /* @__PURE__ */ e(ve, { availableTags: g, activeTags: c, onToggle: p, onClear: h }),
576
576
  /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
577
577
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
578
578
  /* @__PURE__ */ e(R, { label: "Track", sortKey: "displayName", config: d, onSort: m }),
@@ -584,7 +584,7 @@ function Ur({ tracks: r, isLoading: n, carMetadata: s, getUserDisplay: t, onTrac
584
584
  /* @__PURE__ */ e(R, { label: "Date", sortKey: "record.timestamp", config: d, onSort: m, className: "pvx-hidden-below-xl" })
585
585
  ] }) }),
586
586
  /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: b.map((u) => {
587
- var N, x, g;
587
+ var N, x, f;
588
588
  return /* @__PURE__ */ l(
589
589
  "tr",
590
590
  {
@@ -597,7 +597,7 @@ function Ur({ tracks: r, isLoading: n, carMetadata: s, getUserDisplay: t, onTrac
597
597
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: u.record ? I(u.record.lapTimeMs) : "-" }),
598
598
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: u.driverCount || "-" }),
599
599
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: u.carCount || "-" }),
600
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: (g = u.record) != null && g.timestamp ? E(u.record.timestamp) : "-" })
600
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: (f = u.record) != null && f.timestamp ? E(u.record.timestamp) : "-" })
601
601
  ]
602
602
  },
603
603
  `${u.id}|${u.layout || ""}`
@@ -607,26 +607,26 @@ function Ur({ tracks: r, isLoading: n, carMetadata: s, getUserDisplay: t, onTrac
607
607
  ] }) : /* @__PURE__ */ e(F, { message: "No lap times recorded yet." });
608
608
  }
609
609
  function Ar({ entries: r, isLoading: n, track: s, carMetadata: t, getUserDisplay: a, onCarSelect: i, onNavigate: o, tags: d, onTagChange: m }) {
610
- const [c, p] = H({ key: "lapTimeMs", dir: "asc" }), { activeTags: h, toggle: f, clear: v } = ue(d, m), b = w(() => {
610
+ const [c, p] = H({ key: "lapTimeMs", dir: "asc" }), { activeTags: h, toggle: g, clear: v } = ue(d, m), b = w(() => {
611
611
  var y, L, $;
612
612
  if (!r || !((y = t == null ? void 0 : t.tags) != null && y.length)) return [];
613
- const g = /* @__PURE__ */ new Set();
613
+ const f = /* @__PURE__ */ new Set();
614
614
  for (const P of r)
615
- ((($ = (L = t.cars) == null ? void 0 : L[P.carId]) == null ? void 0 : $.tags) || ["sports_car"]).forEach((be) => g.add(be));
616
- return t.tags.filter((P) => g.has(P));
617
- }, [r, t]), u = w(() => r ? h.size === 0 ? r : r.filter((g) => {
615
+ ((($ = (L = t.cars) == null ? void 0 : L[P.carId]) == null ? void 0 : $.tags) || ["sports_car"]).forEach((be) => f.add(be));
616
+ return t.tags.filter((P) => f.has(P));
617
+ }, [r, t]), u = w(() => r ? h.size === 0 ? r : r.filter((f) => {
618
618
  var L, $;
619
- const y = (($ = (L = t == null ? void 0 : t.cars) == null ? void 0 : L[g.carId]) == null ? void 0 : $.tags) || ["sports_car"];
619
+ const y = (($ = (L = t == null ? void 0 : t.cars) == null ? void 0 : L[f.carId]) == null ? void 0 : $.tags) || ["sports_car"];
620
620
  return pe(y, h);
621
- }) : [], [r, h, t]), N = w(() => O(u, c, (g, y) => {
621
+ }) : [], [r, h, t]), N = w(() => O(u, c, (f, y) => {
622
622
  switch (y) {
623
623
  case "carId":
624
- return S(g.carId);
624
+ return S(f.carId);
625
625
  case "driverCount":
626
- return g.driverCount || 0;
626
+ return f.driverCount || 0;
627
627
  case "lapTimeMs":
628
628
  default:
629
- return g.lapTimeMs;
629
+ return f.lapTimeMs;
630
630
  }
631
631
  }), [u, c]), x = [
632
632
  { key: "tracks", label: "Tracks", onClick: () => o("tracks") },
@@ -634,7 +634,7 @@ function Ar({ entries: r, isLoading: n, track: s, carMetadata: t, getUserDisplay
634
634
  ];
635
635
  return n ? /* @__PURE__ */ e(_, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
636
636
  /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ e(re, { segments: x }) }),
637
- /* @__PURE__ */ e(ve, { availableTags: b, activeTags: h, onToggle: f, onClear: v }),
637
+ /* @__PURE__ */ e(ve, { availableTags: b, activeTags: h, onToggle: g, onClear: v }),
638
638
  r != null && r.length ? /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
639
639
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
640
640
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--narrow", children: "#" }),
@@ -644,21 +644,21 @@ function Ar({ entries: r, isLoading: n, track: s, carMetadata: t, getUserDisplay
644
644
  /* @__PURE__ */ e(R, { label: "Drivers", sortKey: "driverCount", config: c, onSort: p, className: "pvx-hidden-below-md" }),
645
645
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-lg", children: "Date" })
646
646
  ] }) }),
647
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: N.map((g, y) => /* @__PURE__ */ l(
647
+ /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: N.map((f, y) => /* @__PURE__ */ l(
648
648
  "tr",
649
649
  {
650
650
  className: "pvx-row pvx-row--clickable",
651
- onClick: () => i(g.carId),
651
+ onClick: () => i(f.carId),
652
652
  children: [
653
653
  /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(ee, { rank: y + 1, podium: !0 }) }),
654
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: S(g.carId) }),
655
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(W, { userId: g.steamId || g.userId, getUserDisplay: a }) }),
656
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: I(g.lapTimeMs) }),
657
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: g.driverCount || "-" }),
658
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-lg", children: g.recordedAt ? E(g.recordedAt) : "-" })
654
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: S(f.carId) }),
655
+ /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(W, { userId: f.steamId || f.userId, getUserDisplay: a }) }),
656
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: I(f.lapTimeMs) }),
657
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: f.driverCount || "-" }),
658
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-lg", children: f.recordedAt ? E(f.recordedAt) : "-" })
659
659
  ]
660
660
  },
661
- g.carId
661
+ f.carId
662
662
  )) })
663
663
  ] }) }) : /* @__PURE__ */ e(F, { message: "No lap times for this track yet." })
664
664
  ] });
@@ -674,13 +674,13 @@ function Er({ entries: r, isLoading: n, track: s, carId: t, getUserDisplay: a, o
674
674
  default:
675
675
  return v.lapTimeMs;
676
676
  }
677
- }), [r, m, a]), f = [
677
+ }), [r, m, a]), g = [
678
678
  { key: "tracks", label: "Tracks", onClick: () => o("tracks") },
679
679
  { key: "track", label: s.displayName, onClick: () => o("track") },
680
680
  { key: "car", label: S(t) }
681
681
  ];
682
682
  return n ? /* @__PURE__ */ e(_, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
683
- /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ e(re, { segments: f }) }),
683
+ /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ e(re, { segments: g }) }),
684
684
  r != null && r.length ? /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
685
685
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
686
686
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--narrow", children: "#" }),
@@ -695,7 +695,7 @@ function Er({ entries: r, isLoading: n, track: s, carId: t, getUserDisplay: a, o
695
695
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-xl", children: "Date" })
696
696
  ] }) }),
697
697
  /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: h.map((v, b) => {
698
- const u = b + 1, N = v.steamId || v.userId, x = p && v.sector1Ms === p.s1, g = p && v.sector2Ms === p.s2, y = p && v.sector3Ms === p.s3;
698
+ const u = b + 1, N = v.steamId || v.userId, x = p && v.sector1Ms === p.s1, f = p && v.sector2Ms === p.s2, y = p && v.sector3Ms === p.s3;
699
699
  return /* @__PURE__ */ l(
700
700
  "tr",
701
701
  {
@@ -706,7 +706,7 @@ function Er({ entries: r, isLoading: n, track: s, carId: t, getUserDisplay: a, o
706
706
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: /* @__PURE__ */ e(W, { userId: N, getUserDisplay: a }) }),
707
707
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: I(v.lapTimeMs) }),
708
708
  /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${x ? "pvx-td--best-sector" : ""}`, children: D(v.sector1Ms) }),
709
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${g ? "pvx-td--best-sector" : ""}`, children: D(v.sector2Ms) }),
709
+ /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${f ? "pvx-td--best-sector" : ""}`, children: D(v.sector2Ms) }),
710
710
  /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${y ? "pvx-td--best-sector" : ""}`, children: D(v.sector3Ms) }),
711
711
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", title: ae(v.tyreCompound), children: v.tyreCompound || "-" }),
712
712
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-xl", children: v.startingFuelL ? `${v.startingFuelL}L` : "-" }),
@@ -721,14 +721,14 @@ function Er({ entries: r, isLoading: n, track: s, carId: t, getUserDisplay: a, o
721
721
  ] });
722
722
  }
723
723
  function Fr({ userId: r, track: n, carId: s, game: t, gameVersion: a, showInvalid: i, getUserDisplay: o, onToggleInvalid: d, onNavigate: m }) {
724
- const { data: c, driverName: p, isLoading: h } = Ie(r, n.id, n.layout, s, { showInvalid: i, game: t, gameVersion: a }), { displayName: f, avatarUrl: v } = o(r, p), b = w(() => me(c, !0), [c]), u = w(() => {
725
- const x = (c == null ? void 0 : c.filter((g) => g.isValid)) || [];
726
- return x.length ? Math.min(...x.map((g) => g.lapTimeMs)) : null;
724
+ const { data: c, driverName: p, isLoading: h } = Ie(r, n.id, n.layout, s, { showInvalid: i, game: t, gameVersion: a }), { displayName: g, avatarUrl: v } = o(r, p), b = w(() => me(c, !0), [c]), u = w(() => {
725
+ const x = (c == null ? void 0 : c.filter((f) => f.isValid)) || [];
726
+ return x.length ? Math.min(...x.map((f) => f.lapTimeMs)) : null;
727
727
  }, [c]), N = [
728
728
  { key: "tracks", label: "Tracks", onClick: () => m("tracks") },
729
729
  { key: "track", label: n.displayName, onClick: () => m("track") },
730
730
  { key: "car", label: S(s), onClick: () => m("car") },
731
- { key: "driver", label: f }
731
+ { key: "driver", label: g }
732
732
  ];
733
733
  return h ? /* @__PURE__ */ e(_, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
734
734
  /* @__PURE__ */ l("div", { className: "pvx-card-header pvx-card-header--split", children: [
@@ -762,11 +762,11 @@ function Fr({ userId: r, track: n, carId: s, game: t, gameVersion: a, showInvali
762
762
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-lg", children: "Fuel" }),
763
763
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-xl", children: "Date" })
764
764
  ] }) }),
765
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: c.map((x, g) => {
765
+ /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: c.map((x, f) => {
766
766
  const y = x.isValid && x.lapTimeMs === u, L = b && x.isValid && x.sector1Ms === b.s1, $ = b && x.isValid && x.sector2Ms === b.s2, P = b && x.isValid && x.sector3Ms === b.s3;
767
767
  let V = "pvx-row";
768
768
  return x.isValid || (V += " pvx-row--invalid"), y && (V += " pvx-row--personal-best"), /* @__PURE__ */ l("tr", { className: V, children: [
769
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e("span", { className: `pvx-rank ${y ? "pvx-rank--gold" : ""}`, children: g + 1 }) }),
769
+ /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e("span", { className: `pvx-rank ${y ? "pvx-rank--gold" : ""}`, children: f + 1 }) }),
770
770
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-md", children: x.lapNumber || "-" }),
771
771
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: I(x.lapTimeMs) }),
772
772
  /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${L ? "pvx-td--best-sector" : ""}`, children: D(x.sector1Ms) }),
@@ -782,17 +782,17 @@ function Fr({ userId: r, track: n, carId: s, game: t, gameVersion: a, showInvali
782
782
  ] });
783
783
  }
784
784
  function _r({ drivers: r, isLoading: n, getUserDisplay: s, game: t, gameVersion: a, onComboSelect: i }) {
785
- const [o, d] = H({ key: "rank", dir: "asc" }), [m, c] = M(null), p = w(() => r ? O(r, o, (f, v) => {
785
+ const [o, d] = H({ key: "rank", dir: "asc" }), [m, c] = M(null), p = w(() => r ? O(r, o, (g, v) => {
786
786
  switch (v) {
787
787
  case "rating":
788
- return f.rating;
788
+ return g.rating;
789
789
  case "comboCount":
790
- return f.comboCount || 0;
790
+ return g.comboCount || 0;
791
791
  case "distinctCars":
792
- return f.distinctCars || 0;
792
+ return g.distinctCars || 0;
793
793
  case "rank":
794
794
  default:
795
- return f.rank;
795
+ return g.rank;
796
796
  }
797
797
  }) : [], [r, o]);
798
798
  if (n) return /* @__PURE__ */ e(_, {});
@@ -823,21 +823,21 @@ function _r({ drivers: r, isLoading: n, getUserDisplay: s, game: t, gameVersion:
823
823
  /* @__PURE__ */ e(R, { label: "Cars", sortKey: "distinctCars", config: o, onSort: d, className: "pvx-hidden-below-sm" }),
824
824
  /* @__PURE__ */ e(R, { label: "Combos", sortKey: "comboCount", config: o, onSort: d, className: "pvx-hidden-below-sm" })
825
825
  ] }) }),
826
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: p.map((f) => {
827
- const v = m === f.identifier;
826
+ /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: p.map((g) => {
827
+ const v = m === g.identifier;
828
828
  return /* @__PURE__ */ e(
829
829
  Ve,
830
830
  {
831
- driver: f,
831
+ driver: g,
832
832
  getUserDisplay: s,
833
833
  isExpanded: v,
834
- onToggle: () => c(v ? null : f.identifier),
834
+ onToggle: () => c(v ? null : g.identifier),
835
835
  colCount: h,
836
836
  game: t,
837
837
  gameVersion: a,
838
838
  onComboSelect: i
839
839
  },
840
- f.identifier
840
+ g.identifier
841
841
  );
842
842
  }) })
843
843
  ] }) })
@@ -864,13 +864,13 @@ function Ve({ driver: r, getUserDisplay: n, isExpanded: s, onToggle: t, colCount
864
864
  }
865
865
  ),
866
866
  s && r.combos && /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: a, className: "pvx-rankings-combos-cell", children: /* @__PURE__ */ e("div", { className: "pvx-rankings-combos", children: r.combos.map((c, p) => {
867
- const h = c.layout ? `${c.trackId}|${c.layout}` : c.trackId, f = d ? () => d({ track: h, car: c.carId, highlight: m, game: i, gameVersion: o }) : void 0;
867
+ const h = c.layout ? `${c.trackId}|${c.layout}` : c.trackId, g = d ? () => d({ track: h, car: c.carId, highlight: m, game: i, gameVersion: o }) : void 0;
868
868
  return /* @__PURE__ */ l(
869
869
  "div",
870
870
  {
871
- className: `pvx-rankings-combo ${f ? "pvx-rankings-combo--clickable" : ""}`,
872
- onClick: f,
873
- role: f ? "button" : void 0,
871
+ className: `pvx-rankings-combo ${g ? "pvx-rankings-combo--clickable" : ""}`,
872
+ onClick: g,
873
+ role: g ? "button" : void 0,
874
874
  children: [
875
875
  /* @__PURE__ */ l("div", { className: "pvx-rankings-combo-info", children: [
876
876
  /* @__PURE__ */ e("p", { className: "pvx-rankings-combo-track", children: A(c.trackId, c.layout, i) }),
@@ -988,7 +988,7 @@ function qr({ competitions: r, isLoading: n, onSelect: s, onRegister: t, classNa
988
988
  }
989
989
  function Qe({ comp: r, onSelect: n, onRegister: s }) {
990
990
  var u, N, x;
991
- const { cdnUrl: t } = k(), a = r.posterCdnPath ? `${t}/${r.posterCdnPath}` : null, i = r.registration, o = (i == null ? void 0 : i.currentCount) || 0, d = i == null ? void 0 : i.maxParticipants, m = d && o >= d, c = (i == null ? void 0 : i.deadline) && new Date(i.deadline) < /* @__PURE__ */ new Date(), p = (i == null ? void 0 : i.isOpen) && !c && !m, h = /* @__PURE__ */ new Date(), f = (u = r.rounds) == null ? void 0 : u.find((g) => g.startTime && new Date(g.startTime) >= h), v = ((N = r.rounds) == null ? void 0 : N.length) || 0, b = ((x = r.rounds) == null ? void 0 : x.filter((g) => g.isFinalized).length) || 0;
991
+ const { cdnUrl: t } = k(), a = r.posterCdnPath ? `${t}/${r.posterCdnPath}` : null, i = r.registration, o = (i == null ? void 0 : i.currentCount) || 0, d = i == null ? void 0 : i.maxParticipants, m = d && o >= d, c = (i == null ? void 0 : i.deadline) && new Date(i.deadline) < /* @__PURE__ */ new Date(), p = (i == null ? void 0 : i.isOpen) && !c && !m, h = /* @__PURE__ */ new Date(), g = (u = r.rounds) == null ? void 0 : u.find((f) => f.startTime && new Date(f.startTime) >= h), v = ((N = r.rounds) == null ? void 0 : N.length) || 0, b = ((x = r.rounds) == null ? void 0 : x.filter((f) => f.isFinalized).length) || 0;
992
992
  return /* @__PURE__ */ l(
993
993
  "div",
994
994
  {
@@ -996,8 +996,8 @@ function Qe({ comp: r, onSelect: n, onRegister: s }) {
996
996
  onClick: () => n(r.id),
997
997
  role: "button",
998
998
  tabIndex: 0,
999
- onKeyDown: (g) => {
1000
- (g.key === "Enter" || g.key === " ") && (g.preventDefault(), n(r.id));
999
+ onKeyDown: (f) => {
1000
+ (f.key === "Enter" || f.key === " ") && (f.preventDefault(), n(r.id));
1001
1001
  },
1002
1002
  children: [
1003
1003
  /* @__PURE__ */ e("div", { className: "pvx-comp-card-poster", children: a ? /* @__PURE__ */ e("img", { src: a, alt: r.name, className: "pvx-comp-card-poster-img" }) : /* @__PURE__ */ e("div", { className: "pvx-comp-card-poster-placeholder", children: /* @__PURE__ */ e(Ze, {}) }) }),
@@ -1007,19 +1007,19 @@ function Qe({ comp: r, onSelect: n, onRegister: s }) {
1007
1007
  /* @__PURE__ */ l("div", { className: "pvx-comp-card-pills", children: [
1008
1008
  /* @__PURE__ */ e(We, { type: r.type }),
1009
1009
  r.game && /* @__PURE__ */ e(z, { children: r.game.toUpperCase() }),
1010
- r.formatDescription && r.formatDescription.split(", ").map((g, y) => /* @__PURE__ */ e(z, { variant: "format", children: g }, y))
1010
+ r.formatDescription && r.formatDescription.split(", ").map((f, y) => /* @__PURE__ */ e(z, { variant: "format", children: f }, y))
1011
1011
  ] }),
1012
- r.carsDescription && /* @__PURE__ */ e("div", { className: "pvx-comp-card-pills", children: r.carsDescription.split(", ").map((g, y) => /* @__PURE__ */ e(z, { children: g }, y)) }),
1012
+ r.carsDescription && /* @__PURE__ */ e("div", { className: "pvx-comp-card-pills", children: r.carsDescription.split(", ").map((f, y) => /* @__PURE__ */ e(z, { children: f }, y)) }),
1013
1013
  /* @__PURE__ */ l("div", { className: "pvx-comp-card-schedule", children: [
1014
- f ? /* @__PURE__ */ l("span", { className: "pvx-comp-card-schedule-next", children: [
1014
+ g ? /* @__PURE__ */ l("span", { className: "pvx-comp-card-schedule-next", children: [
1015
1015
  /* @__PURE__ */ e("span", { className: "pvx-comp-card-schedule-label", children: "Next:" }),
1016
1016
  " ",
1017
1017
  "R",
1018
- f.roundNumber,
1018
+ g.roundNumber,
1019
1019
  " ",
1020
- f.track || "TBD",
1020
+ g.track || "TBD",
1021
1021
  " — ",
1022
- Ge(f.startTime)
1022
+ Ge(g.startTime)
1023
1023
  ] }) : v > 0 ? /* @__PURE__ */ l("span", { className: "pvx-comp-card-schedule-next", children: [
1024
1024
  b,
1025
1025
  "/",
@@ -1050,9 +1050,9 @@ function Qe({ comp: r, onSelect: n, onRegister: s }) {
1050
1050
  );
1051
1051
  }
1052
1052
  function Ye({ competitionId: r, regOpen: n, isFull: s, deadlinePassed: t, regCount: a, regMax: i, onRegister: o }) {
1053
- const { isPowerMode: d } = J(), m = X(r), { data: c } = Z(r), p = (c == null ? void 0 : c.isRegistered) || !1, h = i ? a / i * 100 : 0, f = h >= 100 ? "full" : h >= 75 ? "warning" : "ok";
1053
+ const { isPowerMode: d } = J(), m = X(r), { data: c } = Z(r), p = (c == null ? void 0 : c.isRegistered) || !1, h = i ? a / i * 100 : 0, g = h >= 100 ? "full" : h >= 75 ? "warning" : "ok";
1054
1054
  return /* @__PURE__ */ l("div", { className: "pvx-comp-card-reg", children: [
1055
- /* @__PURE__ */ e("div", { className: "pvx-comp-card-reg-info", children: /* @__PURE__ */ l("span", { className: `pvx-reg-capacity pvx-reg-capacity--${f}`, children: [
1055
+ /* @__PURE__ */ e("div", { className: "pvx-comp-card-reg-info", children: /* @__PURE__ */ l("span", { className: `pvx-reg-capacity pvx-reg-capacity--${g}`, children: [
1056
1056
  a,
1057
1057
  "/",
1058
1058
  i || "∞",
@@ -1344,12 +1344,12 @@ function Hr({
1344
1344
  className: s,
1345
1345
  children: t
1346
1346
  }) {
1347
- const { data: a, isLoading: i } = Z(r), { isPowerMode: o } = J(), d = X(r), m = ce(r), c = le(r), p = (a == null ? void 0 : a.isRegistered) || !1, h = i || m.isPending || c.isPending, f = m.error || c.error || null, v = () => {
1347
+ const { data: a, isLoading: i } = Z(r), { isPowerMode: o } = J(), d = X(r), m = ce(r), c = le(r), p = (a == null ? void 0 : a.isRegistered) || !1, h = i || m.isPending || c.isPending, g = m.error || c.error || null, v = () => {
1348
1348
  o && m.mutate(n || {});
1349
1349
  }, b = () => {
1350
1350
  o && c.mutate();
1351
1351
  };
1352
- return typeof t == "function" ? t({ isRegistered: p, isLoading: h, register: v, withdraw: b, error: f, isPowerMode: o, registrationUrl: d }) : o ? /* @__PURE__ */ e(
1352
+ return typeof t == "function" ? t({ isRegistered: p, isLoading: h, register: v, withdraw: b, error: g, isPowerMode: o, registrationUrl: d }) : o ? /* @__PURE__ */ e(
1353
1353
  "button",
1354
1354
  {
1355
1355
  className: `pvx-comp-register-btn ${s || ""}`,
@@ -1369,7 +1369,7 @@ function Hr({
1369
1369
  );
1370
1370
  }
1371
1371
  function Or({ competitionId: r, registration: n, onWithdrawSuccess: s, className: t }) {
1372
- const { getSteamId: a } = k(), { isPowerMode: i } = J(), o = X(r), { data: d, isLoading: m } = Z(r), { data: c, isLoading: p } = oe(r), h = ce(r), f = le(r), v = a(), b = (d == null ? void 0 : d.isRegistered) || !1, u = (c == null ? void 0 : c.drivers) || (c == null ? void 0 : c.entries) || [], N = n || {}, x = u.length || N.currentCount || 0, g = N.maxParticipants && x >= N.maxParticipants, y = N.deadline && new Date(N.deadline) < /* @__PURE__ */ new Date(), L = N.isOpen && !y && !g;
1372
+ const { getSteamId: a } = k(), { isPowerMode: i } = J(), o = X(r), { data: d, isLoading: m } = Z(r), { data: c, isLoading: p } = oe(r), h = ce(r), g = le(r), v = a(), b = (d == null ? void 0 : d.isRegistered) || !1, u = (c == null ? void 0 : c.drivers) || (c == null ? void 0 : c.entries) || [], N = n || {}, x = u.length || N.currentCount || 0, f = N.maxParticipants && x >= N.maxParticipants, y = N.deadline && new Date(N.deadline) < /* @__PURE__ */ new Date(), L = N.isOpen && !y && !f;
1373
1373
  return m || p ? /* @__PURE__ */ e(q, { message: "Loading registration..." }) : b ? /* @__PURE__ */ e("div", { className: `pvx-reg-panel ${t || ""}`, children: /* @__PURE__ */ e(
1374
1374
  sr,
1375
1375
  {
@@ -1378,7 +1378,7 @@ function Or({ competitionId: r, registration: n, onWithdrawSuccess: s, className
1378
1378
  steamId: v,
1379
1379
  isPowerMode: i,
1380
1380
  registrationUrl: o,
1381
- withdrawMutation: f,
1381
+ withdrawMutation: g,
1382
1382
  onWithdrawSuccess: s,
1383
1383
  registration: N
1384
1384
  }
@@ -1390,7 +1390,7 @@ function Or({ competitionId: r, registration: n, onWithdrawSuccess: s, className
1390
1390
  registration: N
1391
1391
  }
1392
1392
  ) }) : /* @__PURE__ */ e("div", { className: `pvx-reg-panel ${t || ""}`, children: /* @__PURE__ */ e("a", { href: o, target: "_blank", rel: "noopener noreferrer", className: "pvx-comp-register-link", children: "Register on PitVox" }) }) : /* @__PURE__ */ e("div", { className: `pvx-reg-panel ${t || ""}`, children: i ? /* @__PURE__ */ e("div", { className: "pvx-reg-status-msg", children: "Sign in to register for this competition." }) : /* @__PURE__ */ e("div", { className: "pvx-reg-status-msg", children: /* @__PURE__ */ e("a", { href: o, target: "_blank", rel: "noopener noreferrer", className: "pvx-comp-register-link", children: "Register on PitVox" }) }) }) : /* @__PURE__ */ l("div", { className: `pvx-reg-panel ${t || ""}`, children: [
1393
- /* @__PURE__ */ e("div", { className: "pvx-reg-status-msg", children: g ? "Registration is full." : y ? "Registration deadline has passed." : "Registration is closed." }),
1393
+ /* @__PURE__ */ e("div", { className: "pvx-reg-status-msg", children: f ? "Registration is full." : y ? "Registration deadline has passed." : "Registration is closed." }),
1394
1394
  u.length > 0 && /* @__PURE__ */ e(ge, { drivers: u, steamId: v })
1395
1395
  ] });
1396
1396
  }
@@ -1401,11 +1401,11 @@ function tr({ competitionId: r, registerMutation: n, registration: s }) {
1401
1401
  experience: i,
1402
1402
  comments: d || void 0
1403
1403
  });
1404
- }, p = s || {}, h = p.currentCount || 0, f = p.maxParticipants;
1404
+ }, p = s || {}, h = p.currentCount || 0, g = p.maxParticipants;
1405
1405
  return /* @__PURE__ */ l("form", { className: "pvx-reg-form", onSubmit: c, children: [
1406
1406
  /* @__PURE__ */ l("div", { className: "pvx-reg-form-header", children: [
1407
1407
  /* @__PURE__ */ e("h3", { className: "pvx-reg-form-title", children: "Register" }),
1408
- f && /* @__PURE__ */ e(fe, { count: h, max: f })
1408
+ g && /* @__PURE__ */ e(fe, { count: h, max: g })
1409
1409
  ] }),
1410
1410
  n.error && /* @__PURE__ */ e("div", { className: "pvx-reg-error", children: n.error.message || "Registration failed" }),
1411
1411
  /* @__PURE__ */ l("div", { className: "pvx-reg-field", children: [
@@ -1477,11 +1477,11 @@ function sr({ competitionId: r, drivers: n, steamId: s, isPowerMode: t, registra
1477
1477
  c(!1), o && o();
1478
1478
  }
1479
1479
  });
1480
- }, h = d || {}, f = n.length || h.currentCount || 0, v = h.maxParticipants;
1480
+ }, h = d || {}, g = n.length || h.currentCount || 0, v = h.maxParticipants;
1481
1481
  return /* @__PURE__ */ l(j, { children: [
1482
1482
  /* @__PURE__ */ l("div", { className: "pvx-reg-form-header", children: [
1483
1483
  /* @__PURE__ */ e("h3", { className: "pvx-reg-form-title", children: "Registered Drivers" }),
1484
- v && /* @__PURE__ */ e(fe, { count: f, max: v })
1484
+ v && /* @__PURE__ */ e(fe, { count: g, max: v })
1485
1485
  ] }),
1486
1486
  /* @__PURE__ */ e(ge, { drivers: n, steamId: s }),
1487
1487
  i.error && /* @__PURE__ */ e("div", { className: "pvx-reg-error", children: i.error.message || "Withdrawal failed" }),
@@ -1637,14 +1637,14 @@ function or() {
1637
1637
  }), m = d.some((p) => p.isLoading);
1638
1638
  return {
1639
1639
  data: w(() => {
1640
- var f, v;
1640
+ var g, v;
1641
1641
  if (!a || !t || m) return [];
1642
1642
  const p = /* @__PURE__ */ new Date(), h = [];
1643
1643
  for (let b = 0; b < a.length; b++) {
1644
- const u = a[b], N = (f = d[b]) == null ? void 0 : f.data;
1644
+ const u = a[b], N = (g = d[b]) == null ? void 0 : g.data;
1645
1645
  if (!((v = N == null ? void 0 : N.drivers) == null ? void 0 : v.some((y) => y.steamId === t))) continue;
1646
- const g = u.rounds || [];
1647
- for (const y of g)
1646
+ const f = u.rounds || [];
1647
+ for (const y of f)
1648
1648
  y.isFinalized || !y.startTime || new Date(y.startTime) <= p || h.push({
1649
1649
  competitionId: u.id,
1650
1650
  competitionName: u.name,
@@ -2012,7 +2012,7 @@ function Cr() {
2012
2012
  ] });
2013
2013
  }
2014
2014
  function zr({ steamId: r, avatarUrl: n, memberSince: s, className: t = "" }) {
2015
- const { data: a, isLoading: i, error: o } = ar(r), { data: d, isLoading: m } = ir(r), { data: c, isLoading: p } = or(), h = cr(), { data: f, isLoading: v } = lr({ limit: 10 }), b = dr(), u = pr();
2015
+ const { data: a, isLoading: i, error: o } = ar(r), { data: d, isLoading: m } = ir(r), { data: c, isLoading: p } = or(), h = cr(), { data: g, isLoading: v } = lr({ limit: 10 }), b = dr(), u = pr();
2016
2016
  return i || m ? /* @__PURE__ */ e("div", { className: "pvx-loading", children: "Loading dashboard..." }) : o ? /* @__PURE__ */ e("div", { className: "pvx-empty", children: "Failed to load dashboard data." }) : a ? /* @__PURE__ */ l("div", { className: `pvx-dash ${t}`, children: [
2017
2017
  /* @__PURE__ */ e(
2018
2018
  ur,
@@ -2029,8 +2029,8 @@ function zr({ steamId: r, avatarUrl: n, memberSince: s, className: t = "" }) {
2029
2029
  h && /* @__PURE__ */ e(
2030
2030
  yr,
2031
2031
  {
2032
- notifications: f == null ? void 0 : f.notifications,
2033
- unreadCount: (f == null ? void 0 : f.unreadCount) || 0,
2032
+ notifications: g == null ? void 0 : g.notifications,
2033
+ unreadCount: (g == null ? void 0 : g.unreadCount) || 0,
2034
2034
  onMarkRead: (N) => b.mutate(N),
2035
2035
  onMarkAllRead: () => u.mutate(),
2036
2036
  isLoading: v
package/dist/styles.css CHANGED
@@ -212,6 +212,10 @@
212
212
  width: 4rem;
213
213
  }
214
214
 
215
+ .pvx-th--center {
216
+ text-align: center;
217
+ }
218
+
215
219
  .pvx-th-inner {
216
220
  display: inline-flex;
217
221
  align-items: center;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pitvox/partner-react",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "React hooks and styled components for PitVox partner websites — leaderboards, competitions, driver dashboards",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",